Error on every page of the website:
PDOException: SQLSTATE[42883]: Undefined function: 7 ERROR: function substring_index(character varying, unknown, integer) does not exist LINE 1: SELECT DISTINCT SUBSTRING_INDEX(source, '/', 1) AS path FROM... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.: SELECT DISTINCT SUBSTRING_INDEX(source, '/', 1) AS path FROM {url_alias}; Array ( ) in drupal_path_alias_whitelist_rebuild() (line 380 of /var/www/projects/petrol/webdir/includes/path.inc).
While importing taxonomies with taxonomy_csv the batch process failed with this error. I disabled and removed the module but this error is still blocking my site.
Function in question: http://api.drupal.org/api/drupal/includes!path.inc/function/drupal_path_...
The SQL query includes a MySQL specific function ... and if we're supporting multiple databases this can not be done this way.
Drupal 7.14
PostgreSQL 9.1.3
PHP 5.3.6
Nginx 1.0.5
Comments
Comment #1
Putr CreditAttribution: Putr commentedThe folowing is a Quick Fix:
Replace {{SCHEMA}} with your schema name and run in DB:
Soruce: http://okbob.blogspot.com/2009/08/mysql-functions-for-postgresql.html
Edit: includes/path.inc
Change line 380 to (do not forget the schema):
$result = db_query("SELECT DISTINCT {{SCHEMA}}.SUBSTRING_INDEX(source, '/', 1) AS path FROM {url_alias}");
And reload your page.
Comment #2
tim.plunkettMoving to D8
Comment #4
attiks CreditAttribution: attiks at Attiks commentedI'm unable to run some updates on a drupal 7 site
Comment #5
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThe
substring_index()
function is added to the Postgres driver in http://cgit.drupalcode.org/drupal/tree/includes/database/pgsql/install.i... (7.x) and http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Database/Dri... (8.x)Comment #6
attiks CreditAttribution: attiks at Attiks commentedYou're right!
Added to my update function, and all is fine, so probably a bad restore, not sure if this can be closed.
db_query('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
\'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
LANGUAGE \'sql\''
);
Comment #7
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI think it can be closed :)