Index: includes/database/query.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/query.inc,v retrieving revision 1.55 diff -u -r1.55 query.inc --- includes/database/query.inc 5 Aug 2010 08:26:35 -0000 1.55 +++ includes/database/query.inc 28 Aug 2010 05:15:50 -0000 @@ -247,12 +247,33 @@ */ protected $comments = array(); + /** + * Query hints or flags that can be set on a query. + * + * @var string + */ + protected $hints = ''; + public function __construct(DatabaseConnection $connection, $options) { $this->connection = $connection; $this->queryOptions = $options; } /** + * Sets the hints or flags on a query. + * + * Hints and flags directly affect the way in which the query is run + * on the database server. Their syntax is database specific, so they + * should be used internally in database-specific classes only. + * + * @param $hints + * The hint string to be inserted into the query. + */ + public function setHints($hints) { + $this->hints = $hints; + } + + /** * Run the query against the database. */ abstract protected function execute(); Index: includes/database/select.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/select.inc,v retrieving revision 1.45 diff -u -r1.45 select.inc --- includes/database/select.inc 8 Aug 2010 02:18:53 -0000 1.45 +++ includes/database/select.inc 28 Aug 2010 05:15:50 -0000 @@ -1357,8 +1357,11 @@ // Create a comments string to prepend to the query. $comments = (!empty($this->comments)) ? '/* ' . implode('; ', $this->comments) . ' */ ' : ''; + // Create a hints string to include in the query. + $hints = (!empty($this->hints)) ? $this->hints . ' ' : ''; + // SELECT - $query = $comments . 'SELECT '; + $query = $comments . 'SELECT ' . $hints; if ($this->distinct) { $query .= 'DISTINCT '; } Index: includes/database/mysql/query.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/mysql/query.inc,v retrieving revision 1.18 diff -u -r1.18 query.inc --- includes/database/mysql/query.inc 26 Jun 2010 01:40:05 -0000 1.18 +++ includes/database/mysql/query.inc 28 Aug 2010 05:15:50 -0000 @@ -46,16 +46,19 @@ // Create a comments string to prepend to the query. $comments = (!empty($this->comments)) ? '/* ' . implode('; ', $this->comments) . ' */ ' : ''; + // Create a hints string to include in the query. + $hints = (!empty($this->hints)) ? $this->hints . ' ' : ''; + // Default fields are always placed first for consistency. $insert_fields = array_merge($this->defaultFields, $this->insertFields); // If we're selecting from a SelectQuery, finish building the query and // pass it back, as any remaining options are irrelevant. if (!empty($this->fromQuery)) { - return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') ' . $this->fromQuery; + return $comments . 'INSERT ' . $hints . 'INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') ' . $this->fromQuery; } - $query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES '; + $query = $comments . 'INSERT ' . $hints . 'INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES '; $max_placeholder = 0; $values = array(); Index: includes/database/pgsql/query.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/pgsql/query.inc,v retrieving revision 1.20 diff -u -r1.20 query.inc --- includes/database/pgsql/query.inc 27 Aug 2010 15:53:43 -0000 1.20 +++ includes/database/pgsql/query.inc 28 Aug 2010 05:15:50 -0000 @@ -107,16 +107,19 @@ // Create a comments string to prepend to the query. $comments = (!empty($this->comments)) ? '/* ' . implode('; ', $this->comments) . ' */ ' : ''; + // Create a hints string to include in the query. + $hints = (!empty($this->hints)) ? $this->hints . ' ' : ''; + // Default fields are always placed first for consistency. $insert_fields = array_merge($this->defaultFields, $this->insertFields); // If we're selecting from a SelectQuery, finish building the query and // pass it back, as any remaining options are irrelevant. if (!empty($this->fromQuery)) { - return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') ' . $this->fromQuery; + return $comments . 'INSERT ' . $hints . 'INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') ' . $this->fromQuery; } - $query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES '; + $query = $comments . 'INSERT ' . $hints . 'INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES '; $max_placeholder = 0; $values = array();