summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2005-11-04 13:02:51 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2005-11-04 13:02:51 +0000
commit2ad97f0277c4eff591c4a7b826ad182e629a7f94 (patch)
tree0081c5bae2490981d5b264512ffd4ba48dcfe2b1
parent132517a8cb2d9e195687e71d6f0a8dbc505843cd (diff)
downloadbrdo-2ad97f0277c4eff591c4a7b826ad182e629a7f94.tar.gz
brdo-2ad97f0277c4eff591c4a7b826ad182e629a7f94.tar.bz2
- #36255: Fix db_query_temporary() in pgsql
- Prefix temporary table names (helps on restricted hosts)
-rw-r--r--includes/database.mysql.inc6
-rw-r--r--includes/database.pgsql.inc6
-rw-r--r--modules/search.module8
-rw-r--r--modules/search/search.module8
4 files changed, 14 insertions, 14 deletions
diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc
index 8f96dc3bb..21f763b8a 100644
--- a/includes/database.mysql.inc
+++ b/includes/database.mysql.inc
@@ -268,8 +268,8 @@ function db_query_range($query) {
* printf() syntax. Instead of a variable number of query arguments, you may
* also pass a single array containing the query arguments.
* @param $table
- * The name of the temporary table to select into. This name will not be
- * prefixed as there is no risk of collision.
+ * The name of the temporary table to select into. This name will be
+ * prefixed for compatibility reasons (even though there is no risk of collision)@.
* @return
* A database query result resource, or FALSE if the query was not executed
* correctly.
@@ -278,7 +278,7 @@ function db_query_temporary($query) {
$args = func_get_args();
$tablename = array_pop($args);
- $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' SELECT', db_prefix_tables($query));
+ $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE {'. $tablename .'} SELECT', db_prefix_tables($query));
if (count($args) > 1) {
// Check for array (alternative syntax).
if (is_array($args[1])) {
diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc
index 89b693bab..8a1e06ebf 100644
--- a/includes/database.pgsql.inc
+++ b/includes/database.pgsql.inc
@@ -253,8 +253,8 @@ function db_query_range($query) {
* printf() syntax. Instead of a variable number of query arguments, you may
* also pass a single array containing the query arguments.
* @param $table
- * The name of the temporary table to select into. This name will not be
- * prefixed as there is no risk of collision.
+ * The name of the temporary table to select into. This name will be
+ * prefixed for compatibility reasons (there is no risk of collision).
* @return
* A database query result resource, or FALSE if the query was not executed
* correctly.
@@ -263,7 +263,7 @@ function db_query_temporary($query) {
$args = func_get_args();
$tablename = array_pop($args);
- $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' AS', db_prefix_tables($query));
+ $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE {'. $tablename .'} AS SELECT', db_prefix_tables($query));
if (count($args) > 1) {
// Check for array (alternative syntax).
if (is_array($args[1])) {
diff --git a/modules/search.module b/modules/search.module
index ba0fca9f9..c31c03450 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -775,7 +775,7 @@ function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = a
$result = db_query_temporary("SELECT i.type, i.sid, SUM(i.score * t.count) AS relevance, COUNT(*) AS matches FROM {search_index} i INNER JOIN {search_total} t ON i.word = t.word $join1 WHERE $conditions GROUP BY i.type, i.sid HAVING matches >= %d", $arguments, 'temp_search_sids');
// Calculate maximum relevance, to normalize it
- $normalize = db_result(db_query('SELECT MAX(relevance) FROM temp_search_sids'));
+ $normalize = db_result(db_query('SELECT MAX(relevance) FROM {temp_search_sids}'));
if (!$normalize) {
return array();
}
@@ -784,14 +784,14 @@ function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = a
// Second pass: only keep items that match the complicated keywords conditions (phrase search, negative keywords, ...)
$conditions = '('. $query[0] .')';
$arguments = array_merge($arguments2, $query[1]);
- $result = db_query_temporary("SELECT i.type, i.sid, $select2 FROM temp_search_sids i INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type $join2 WHERE $conditions ORDER BY score DESC", $arguments, 'temp_search_results');
- if (($count = db_result(db_query('SELECT COUNT(*) FROM temp_search_results'))) == 0) {
+ $result = db_query_temporary("SELECT i.type, i.sid, $select2 FROM {temp_search_sids} i INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type $join2 WHERE $conditions ORDER BY score DESC", $arguments, 'temp_search_results');
+ if (($count = db_result(db_query('SELECT COUNT(*) FROM {temp_search_results}'))) == 0) {
return array();
}
$count_query = "SELECT $count";
// Do actual search query
- $result = pager_query("SELECT * FROM temp_search_results", 10, 0, $count_query, $arguments);
+ $result = pager_query("SELECT * FROM {temp_search_results}", 10, 0, $count_query, $arguments);
$results = array();
while ($item = db_fetch_object($result)) {
$results[] = $item->sid;
diff --git a/modules/search/search.module b/modules/search/search.module
index ba0fca9f9..c31c03450 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -775,7 +775,7 @@ function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = a
$result = db_query_temporary("SELECT i.type, i.sid, SUM(i.score * t.count) AS relevance, COUNT(*) AS matches FROM {search_index} i INNER JOIN {search_total} t ON i.word = t.word $join1 WHERE $conditions GROUP BY i.type, i.sid HAVING matches >= %d", $arguments, 'temp_search_sids');
// Calculate maximum relevance, to normalize it
- $normalize = db_result(db_query('SELECT MAX(relevance) FROM temp_search_sids'));
+ $normalize = db_result(db_query('SELECT MAX(relevance) FROM {temp_search_sids}'));
if (!$normalize) {
return array();
}
@@ -784,14 +784,14 @@ function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = a
// Second pass: only keep items that match the complicated keywords conditions (phrase search, negative keywords, ...)
$conditions = '('. $query[0] .')';
$arguments = array_merge($arguments2, $query[1]);
- $result = db_query_temporary("SELECT i.type, i.sid, $select2 FROM temp_search_sids i INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type $join2 WHERE $conditions ORDER BY score DESC", $arguments, 'temp_search_results');
- if (($count = db_result(db_query('SELECT COUNT(*) FROM temp_search_results'))) == 0) {
+ $result = db_query_temporary("SELECT i.type, i.sid, $select2 FROM {temp_search_sids} i INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type $join2 WHERE $conditions ORDER BY score DESC", $arguments, 'temp_search_results');
+ if (($count = db_result(db_query('SELECT COUNT(*) FROM {temp_search_results}'))) == 0) {
return array();
}
$count_query = "SELECT $count";
// Do actual search query
- $result = pager_query("SELECT * FROM temp_search_results", 10, 0, $count_query, $arguments);
+ $result = pager_query("SELECT * FROM {temp_search_results}", 10, 0, $count_query, $arguments);
$results = array();
while ($item = db_fetch_object($result)) {
$results[] = $item->sid;