diff options
Diffstat (limited to 'includes/database')
-rw-r--r-- | includes/database/database.inc | 4 | ||||
-rw-r--r-- | includes/database/log.inc | 10 | ||||
-rw-r--r-- | includes/database/pgsql/database.inc | 11 | ||||
-rw-r--r-- | includes/database/sqlite/query.inc | 12 |
4 files changed, 26 insertions, 11 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc index 5bcae67a3..cae50fb87 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -167,7 +167,7 @@ * } * @endcode * - * @link http://drupal.org/developing/api/database + * @link http://drupal.org/developing/api/database @endlink */ @@ -2769,7 +2769,7 @@ function _db_create_keys_sql($spec) { * Renames a table. * * @param $table - * The table to be renamed. + * The current name of the table to be renamed. * @param $new_name * The new name for the table. */ diff --git a/includes/database/log.inc b/includes/database/log.inc index ec27ef8e6..27eae62cd 100644 --- a/includes/database/log.inc +++ b/includes/database/log.inc @@ -128,9 +128,10 @@ class DatabaseLog { * Determine the routine that called this query. * * We define "the routine that called this query" as the first entry in - * the call stack that is not inside includes/database. That makes the - * climbing logic very simple, and handles the variable stack depth caused - * by the query builders. + * the call stack that is not inside includes/database and does have a file + * (which excludes call_user_func_array(), anonymous functions and similar). + * That makes the climbing logic very simple, and handles the variable stack + * depth caused by the query builders. * * @link http://www.php.net/debug_backtrace * @return @@ -144,7 +145,8 @@ class DatabaseLog { $stack = debug_backtrace(); $stack_count = count($stack); for ($i = 0; $i < $stack_count; ++$i) { - if (strpos($stack[$i]['file'], 'includes' . DIRECTORY_SEPARATOR . 'database') === FALSE) { + if (!empty($stack[$i]['file']) && strpos($stack[$i]['file'], 'includes' . DIRECTORY_SEPARATOR . 'database') === FALSE) { + $stack[$i] += array('args' => array()); return array( 'file' => $stack[$i]['file'], 'line' => $stack[$i]['line'], diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc index 79c16b212..00ed7990e 100644 --- a/includes/database/pgsql/database.inc +++ b/includes/database/pgsql/database.inc @@ -74,6 +74,17 @@ class DatabaseConnection_pgsql extends DatabaseConnection { } } + public function prepareQuery($query) { + // mapConditionOperator converts LIKE operations to ILIKE for consistency + // with MySQL. However, Postgres does not support ILIKE on bytea (blobs) + // fields. + // To make the ILIKE operator work, we type-cast bytea fields into text. + // @todo This workaround only affects bytea fields, but the involved field + // types involved in the query are unknown, so there is no way to + // conditionally execute this for affected queries only. + return parent::prepareQuery(preg_replace('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE) /i', ' ${1}::text ${2} ', $query)); + } + public function query($query, array $args = array(), $options = array()) { $options += $this->defaultOptions(); diff --git a/includes/database/sqlite/query.inc b/includes/database/sqlite/query.inc index 74ff9ba20..f0ff10d7d 100644 --- a/includes/database/sqlite/query.inc +++ b/includes/database/sqlite/query.inc @@ -72,11 +72,13 @@ class UpdateQuery_sqlite extends UpdateQuery { */ protected function removeFieldsInCondition(&$fields, QueryConditionInterface $condition) { foreach ($condition->conditions() as $child_condition) { - if ($child_condition['field'] instanceof QueryConditionInterface) { - $this->removeFieldsInCondition($fields, $child_condition['field']); - } - else { - unset($fields[$child_condition['field']]); + if (isset($child_condition['field'])) { + if ($child_condition['field'] instanceof ConditionInterface) { + $this->removeFieldsInCondition($fields, $child_condition['field']); + } + else { + unset($fields[$child_condition['field']]); + } } } } |