diff options
Diffstat (limited to 'modules/system/system.install')
-rw-r--r-- | modules/system/system.install | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index 15db982ca..4f94fb27e 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -339,6 +339,11 @@ function system_install() { \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\' LANGUAGE \'sql\'' ); + + db_query('CREATE OR REPLACE FUNCTION "substr_index"(text, text, integer) RETURNS text AS + \'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\' + LANGUAGE \'sql\'' + ); } // Create tables. @@ -3496,6 +3501,25 @@ function system_update_7023() { } /** + * Add the substr_index() function to PostgreSQL. + * + * Note: this should go into the driver itself, but we have no support + * for driver-specific updates yet. + */ +function system_update_7024() { + $ret = array(); + + if (db_driver() == 'pgsql') { + $ret[] = update_sql('CREATE OR REPLACE FUNCTION "substr_index"(text, text, integer) RETURNS text AS + \'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\' + LANGUAGE \'sql\'' + ); + } + + return $ret; +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ |