? sites/default/files
? sites/default/settings.php
Index: includes/database.mysql-common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database.mysql-common.inc,v
retrieving revision 1.17
diff -u -p -r1.17 database.mysql-common.inc
--- includes/database.mysql-common.inc	30 Jan 2008 14:34:29 -0000	1.17
+++ includes/database.mysql-common.inc	5 Feb 2008 08:12:08 -0000
@@ -7,6 +7,55 @@
  */
 
 /**
+ * Indicates the concatenation operator.
+ */
+define('DB_CONCAT_OPERATOR', '+');
+
+/**
+ * Indicates the name of the SQL strtoupper function.
+ */
+define('DB_UPPER', 'UPPER');
+
+/**
+ * Indicates the SQL to generate a random number between 0.00 and 1.00.
+ */
+define('DB_RAND', 'RAND()');
+
+/**
+ * Indicates the name of the SQL strlen function.
+ */
+define('DB_STRLEN', 'LENGTH');
+
+/**
+ * Indicates the name of the SQL substring function.
+ */
+define('DB_SUBSTR', 'SUBSTRING');
+
+/**
+ * Portable SQL generating function.
+ *
+ * @param ...
+ *   Variable number of string parameters.
+ * @return
+ *   Portably concatenate strings.
+ */
+function db_concat() {
+  $args = func_get_args();
+  $return = implode(', ', $args);
+  return (strlen($return) > 0) ? "CONCAT($return)" : '';
+}
+
+/**
+ * Returns a string that is the equivalent of MySQL IFNULL or Oracle NVL.
+ *
+ * @return
+ *   If $expr1 is not NULL, returns $expr1; otherwise it returns $expr2.
+ */
+function db_if_null($expr1, $expr2) {
+  return " IFNULL($expr1, $expr2) ";
+}
+
+/**
  * Runs a basic query in the active database.
  *
  * User-supplied arguments to the query should be passed in as separate
Index: includes/database.pgsql.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database.pgsql.inc,v
retrieving revision 1.68
diff -u -p -r1.68 database.pgsql.inc
--- includes/database.pgsql.inc	4 Jan 2008 09:31:48 -0000	1.68
+++ includes/database.pgsql.inc	5 Feb 2008 08:12:08 -0000
@@ -12,6 +12,54 @@
  */
 
 /**
+ * Indicates the concatenation operator.
+ */
+define('DB_CONCAT_OPERATOR', '||');
+
+/**
+ * Indicates the name of the SQL strtoupper function.
+ */
+define('DB_UPPER', 'UPPER');
+
+/**
+ * Indicates the SQL to generate a random number between 0.00 and 1.00.
+ */
+define('DB_RAND', 'RANDOM()');
+
+/**
+ * Indicates the name of the SQL strlen function.
+ */
+define('DB_STRLEN', 'LENGTH');
+
+/**
+ * Indicates the name of the SQL substr function.
+ */
+define('DB_SUBSTR', 'SUBSTRING');
+
+/**
+ * Return a portably concatenate strings.
+ *
+ * @param ...
+ *   Variable number of string parameters.
+ * @return
+ *   Portably concatenate strings.
+ */
+function db_concat() {
+  $args = func_get_args();
+  return implode(DB_CONCAT_OPERATOR, $args);
+}
+
+/**
+ * Returns a string that is the equivalent of MySQL IFNULL or Oracle NVL.
+ *
+ * @return
+ *   If $expr1 is not NULL, returns $expr1; otherwise it returns $expr2.
+ */
+function db_if_null($expr1, $expr2) {
+  return " COALESCE($expr1, $expr2) ";
+}
+
+/**
  * Report database status.
  */
 function db_status_report() {
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.617
diff -u -p -r1.617 comment.module
--- modules/comment/comment.module	25 Jan 2008 16:19:12 -0000	1.617
+++ modules/comment/comment.module	5 Feb 2008 08:12:09 -0000
@@ -368,9 +368,9 @@ function comment_new_page_count($num_com
       }
       else {
         // Oldest first: find the first thread with new comment
-        $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d  AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY SUBSTRING(thread, 1, (LENGTH(thread) - 1)) LIMIT 1', $node->nid, $new_replies);
+        $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d  AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY '. DB_SUBSTR .'(thread, 1, ('. DB_STRLEN .'(thread) - 1)) LIMIT 1', $node->nid, $new_replies);
         $thread = substr(db_result($result), 0, -1);
-        $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < '". $thread ."'", $node->nid);
+        $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND ". DB_SUBSTR ."(thread, 1, (". DB_STRLEN ."(thread) - 1)) < '". $thread ."'", $node->nid);
       }
       $count = db_result($result_count);
     }
@@ -979,7 +979,7 @@ function comment_render($node, $cid = 0)
           // See comment above. Analysis reveals that this doesn't cost too
           // much. It scales much much better than having the whole comment
           // structure.
-          $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
+          $query .= ' ORDER BY '. DB_SUBSTR .'(c.thread, 1, ('. DB_STRLEN .'(c.thread) - 1))';
         }
       }
       $query = db_rewrite_sql($query, 'c', 'cid');
Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.212
diff -u -p -r1.212 locale.module
--- modules/locale/locale.module	28 Jan 2008 17:16:34 -0000	1.212
+++ modules/locale/locale.module	5 Feb 2008 08:12:09 -0000
@@ -351,7 +351,7 @@ function locale($string = NULL, $langcod
         // Refresh database stored cache of translations for given language.
         // We only store short strings used in current version, to improve
         // performance and consume less memory.
-        $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION);
+        $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND ". DB_STRLEN ."(s.source) < 75", $langcode, VERSION);
         while ($data = db_fetch_object($result)) {
           $locale_t[$langcode][$data->source] = (empty($data->translation) ? TRUE : $data->translation);
         }
