diff -urpN drupal-6.x-dev-200707241101/includes/cache.inc drupal-6.x-dev-clob-1.3/includes/cache.inc --- drupal-6.x-dev-200707241101/includes/cache.inc 2007-05-26 05:01:30.000000000 +0800 +++ drupal-6.x-dev-clob-1.3/includes/cache.inc 2007-07-24 11:02:24.000000000 +0800 @@ -105,10 +105,11 @@ function cache_set($cid, $data, $table = $serialized = 1; } $created = time(); - db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, $created, $expire, $headers, $serialized, $cid); + db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", NULL, $created, $expire, $headers, $serialized, $cid); if (!db_affected_rows()) { - @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, $created, $expire, $headers, $serialized); + @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, NULL, $created, $expire, $headers, $serialized); } + db_update_blob("cid = '%s'", $cid, db_prefix_tables('{' . $table . '}'), 'data', $data); } /** diff -urpN drupal-6.x-dev-200707241101/includes/database.inc drupal-6.x-dev-clob-1.3/includes/database.inc --- drupal-6.x-dev-200707241101/includes/database.inc 2007-07-12 17:21:30.000000000 +0800 +++ drupal-6.x-dev-clob-1.3/includes/database.inc 2007-07-24 20:37:10.000000000 +0800 @@ -175,15 +175,17 @@ function _db_query_callback($match, $ini return '%'; case '%f': return (float) array_shift($args); - case '%b': // binary data - return db_encode_blob(array_shift($args)); + case '%b': // Binary Large OBject. + return db_encode_blob(array_shift($args)); + case '%c': // Character Large OBject. + return db_encode_clob(array_shift($args)); } } /** * Indicates the place holders that should be replaced in _db_query_callback(). */ -define('DB_QUERY_REGEXP', '/(%d|%s|%%|%f|%b)/'); +define('DB_QUERY_REGEXP', '/(%d|%s|%%|%f|%b|%c)/'); /** * Helper function for db_rewrite_sql. diff -urpN drupal-6.x-dev-200707241101/includes/database.mysql-common.inc drupal-6.x-dev-clob-1.3/includes/database.mysql-common.inc --- drupal-6.x-dev-200707241101/includes/database.mysql-common.inc 2007-06-27 04:24:19.000000000 +0800 +++ drupal-6.x-dev-clob-1.3/includes/database.mysql-common.inc 2007-07-24 23:36:04.000000000 +0800 @@ -27,7 +27,11 @@ * you may also pass a single array containing the query arguments. * * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -217,6 +221,9 @@ function db_type_map() { 'blob:big' => 'LONGBLOB', 'blob:normal' => 'BLOB', + 'clob:big' => 'LONGTEXT', + 'clob:normal' => 'TEXT', + 'datetime:normal' => 'DATETIME', ); return $map; @@ -462,7 +469,95 @@ function db_last_insert_id($table, $fiel } /** + * Update the Binary Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_blob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_blob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** + * Update the Character Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_clob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_clob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** * @} End of "ingroup schemaapi". */ -?> \ No newline at end of file +?> diff -urpN drupal-6.x-dev-200707241101/includes/database.mysqli.inc drupal-6.x-dev-clob-1.3/includes/database.mysqli.inc --- drupal-6.x-dev-200707241101/includes/database.mysqli.inc 2007-07-23 16:05:14.000000000 +0800 +++ drupal-6.x-dev-clob-1.3/includes/database.mysqli.inc 2007-07-24 23:22:22.000000000 +0800 @@ -255,7 +255,11 @@ function db_affected_rows() { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -305,7 +309,11 @@ function db_query_range($query) { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -337,11 +345,11 @@ function db_query_temporary($query) { * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data, or empty LOB value placeholder for NULL $data. */ function db_encode_blob($data) { global $active_db; - return "'". mysqli_real_escape_string($active_db, $data) ."'"; + return !is_null($data) ? "'". mysqli_real_escape_string($active_db, $data) ."'" : "''"; } /** @@ -357,6 +365,31 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * + * @param $data + * Data to encode. + * @return + * Encoded data, or empty LOB value placeholder for NULL $data. + */ +function db_encode_clob($data) { + global $active_db; + return !is_null($data) ? "'". mysqli_real_escape_string($active_db, $data) ."'" : "''"; +} + +/** + * Returns text from a Character Large OBject value. + * + * @param $data + * Data to decode. + * @return + * Decoded data. + */ +function db_decode_clob($data) { + return $data; +} + +/** * Prepare user input for use in a database query, preventing SQL injection attacks. */ function db_escape_string($text) { diff -urpN drupal-6.x-dev-200707241101/includes/database.mysql.inc drupal-6.x-dev-clob-1.3/includes/database.mysql.inc --- drupal-6.x-dev-200707241101/includes/database.mysql.inc 2007-07-23 16:05:14.000000000 +0800 +++ drupal-6.x-dev-clob-1.3/includes/database.mysql.inc 2007-07-24 23:21:50.000000000 +0800 @@ -255,7 +255,11 @@ function db_affected_rows() { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -305,7 +309,11 @@ function db_query_range($query) { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -337,11 +345,11 @@ function db_query_temporary($query) { * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data, or empty LOB value placeholder for NULL $data. */ function db_encode_blob($data) { global $active_db; - return "'". mysql_real_escape_string($data, $active_db) ."'"; + return !is_null($data) ? "'". mysql_real_escape_string($data, $active_db) ."'" : "''"; } /** @@ -357,6 +365,31 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * + * @param $data + * Data to encode. + * @return + * Encoded data, or empty LOB value placeholder for NULL $data. + */ +function db_encode_clob($data) { + global $active_db; + return !is_null($data) ? "'". mysql_real_escape_string($data, $active_db) ."'" : "''"; +} + +/** + * Returns text from a Character Large Object value. + * + * @param $data + * Data to decode. + * @return + * Decoded data. + */ +function db_decode_clob($data) { + return $data; +} + +/** * Prepare user input for use in a database query, preventing SQL injection attacks. */ function db_escape_string($text) { diff -urpN drupal-6.x-dev-200707241101/includes/database.pgsql.inc drupal-6.x-dev-clob-1.3/includes/database.pgsql.inc --- drupal-6.x-dev-200707241101/includes/database.pgsql.inc 2007-07-23 16:05:14.000000000 +0800 +++ drupal-6.x-dev-clob-1.3/includes/database.pgsql.inc 2007-07-24 23:36:36.000000000 +0800 @@ -120,7 +120,11 @@ function db_connect($url) { * you may also pass a single array containing the query arguments. * * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -287,7 +291,11 @@ function db_affected_rows() { * using printf() syntax. Instead of a variable number of query arguments, * you may also pass a single array containing the query arguments. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -337,7 +345,11 @@ function db_query_range($query) { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -365,15 +377,15 @@ function db_query_temporary($query) { /** * Returns a properly formatted Binary Large OBject value. - * In case of PostgreSQL encodes data for insert into bytea field. + * In case of PostgreSQL encodes data for insert or update into bytea field. * * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data, or empty LOB value placeholder for NULL $data. */ function db_encode_blob($data) { - return "'". pg_escape_bytea($data) ."'"; + return !is_null($data) ? "'". pg_escape_bytea($data) ."'" : "''"; } /** @@ -390,6 +402,33 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * In case of PostgreSQL encodes data for insert or update into text field. + * + * @param $data + * Data to encode. + * @return + * Encoded data, or empty LOB value placeholder for NULL $data. + */ +function db_encode_clob($data) { + return !is_null($data) ? "'". pg_escape_string($data) ."'" : "''"; + +} + +/** + * Returns text from a Character Large OBject value. + * In case of PostgreSQL decodes data after select from bytea field. + * + * @param $data + * Data to decode. + * @return + * Decoded data. + */ +function db_decode_clob($data) { + return $data; +} + +/** * Prepare user input for use in a database query, preventing SQL injection attacks. * Note: This function requires PostgreSQL 7.2 or later. */ @@ -398,6 +437,94 @@ function db_escape_string($text) { } /** + * Update the Binary Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_blob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_blob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** + * Update the Character Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object, do not enclose in '') and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_clob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_clob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** * Lock a table. * This function automatically starts a transaction. */ @@ -501,6 +628,9 @@ function db_type_map() { 'blob:big' => 'bytea', 'blob:normal' => 'bytea', + 'clob:big' => 'text', + 'clob:normal' => 'text', + 'datetime:normal' => 'timestamp', 'serial:tiny' => 'serial', diff -urpN drupal-6.x-dev-200707241101/modules/aggregator/aggregator.module drupal-6.x-dev-clob-1.3/modules/aggregator/aggregator.module --- drupal-6.x-dev-200707241101/modules/aggregator/aggregator.module 2007-07-16 20:43:04.000000000 +0800 +++ drupal-6.x-dev-clob-1.3/modules/aggregator/aggregator.module 2007-07-24 11:02:24.000000000 +0800 @@ -977,15 +977,17 @@ function aggregator_parse_feed(&$data, $ function aggregator_save_item($edit) { if ($edit['iid'] && $edit['title']) { - db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']); + db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = %c, guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], NULL, $edit['guid'], $edit['timestamp'], $edit['iid']); + db_update_clob('iid = %d', $edit['iid'], db_prefix_tables('{aggregator_item}'), 'description', $edit['description']); } else if ($edit['iid']) { db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']); db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']); } else if ($edit['title'] && $edit['link']) { - db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']); + db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', %c, %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], NULL, $edit['timestamp'], $edit['guid']); $edit['iid'] = db_last_insert_id('aggregator_item', 'iid'); + db_update_clob('iid = %d', $edit['iid'], db_prefix_tables('{aggregator_item}'), 'description', $edit['description']); // file the items in the categories indicated by the feed $categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']); while ($category = db_fetch_object($categories)) { @@ -1232,6 +1234,7 @@ function aggregator_page_rss() { } while ($item = db_fetch_object($result)) { + $item->description = db_decode_clob($item->description); switch (variable_get('feed_item_length', 'teaser')) { case 'teaser': $teaser = node_teaser($item->description); @@ -1407,7 +1410,7 @@ function theme_aggregator_page_item($ite $output .= "
\n"; if ($item->description) { - $output .= '