diff -ur drupal-6.11.dist/includes/database.pgsql.inc drupal-6.11/includes/database.pgsql.inc --- drupal-6.11.dist/includes/database.pgsql.inc 2009-03-30 15:04:06.000000000 +0200 +++ drupal-6.11/includes/database.pgsql.inc 2009-05-08 20:37:17.000000000 +0200 @@ -281,6 +281,7 @@ } _db_query_callback($args, TRUE); $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = preg_replace('/\'\'/', '\'', $query ); // line added by np@bsn.com 20090430 $query .= ' LIMIT '. (int)$count .' OFFSET '. (int)$from; return _db_query($query); } @@ -505,9 +506,18 @@ if (isset($table['primary key']) && is_array($table['primary key'])) { $sql_keys[] = 'PRIMARY KEY ('. implode(', ', $table['primary key']) .')'; } + + // np@bsn.com 20090430 added 5 lines: + if ( preg_match('/\.(.*$)/', $name , $matches )){ + $constraintName = $matches[1]; + } else { + $constraintName = $name; + } + + // np@bsn.com 20090430 use $constraintName: if (isset($table['unique keys']) && is_array($table['unique keys'])) { foreach ($table['unique keys'] as $key_name => $key) { - $sql_keys[] = 'CONSTRAINT {'. $name .'}_'. $key_name .'_key UNIQUE ('. implode(', ', $key) .')'; + $sql_keys[] = 'CONSTRAINT {'. $constraintName .'}_'. $key_name .'_key UNIQUE ('. implode(', ', $key) .')'; } } @@ -776,6 +786,11 @@ * The table to be altered. */ function db_drop_primary_key(&$ret, $table) { + // np@bsn.com: enable sites/settings/prefix with trailing dot for postgreSQL schema usage: + if ( preg_match('/\.(.*$)/', $table , $matches )){ + $table = $matches[1]; + } + $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP CONSTRAINT {'. $table .'}_pkey'); } @@ -792,7 +807,14 @@ * An array of field names. */ function db_add_unique_key(&$ret, $table, $name, $fields) { - $name = '{'. $table .'}_'. $name .'_key'; + // np@bsn.com changed for enabliing sites/settings/prefix with trailing dot for postgreSQL schema usage: + if ( preg_match('/\.(.*$)/', $table , $matches )){ + $tableWithoutSchema = $matches[1]; + } else { + $tableWithoutSchema = $table ; + } + + $name = '{'. $tableWithoutSchema .'}_'. $name .'_key'; $ret[] = update_sql('ALTER TABLE {'. $table .'} ADD CONSTRAINT '. $name .' UNIQUE ('. implode(',', $fields) .')'); } @@ -808,7 +830,14 @@ * The name of the key. */ function db_drop_unique_key(&$ret, $table, $name) { - $name = '{'. $table .'}_'. $name .'_key'; + // np@bsn.com: for postgreSQL schema + if ( preg_match('/\.(.*$)/', $table, $matches )){ + $tableWithoutSchema = $matches[1]; + } else { + $tableWithoutSchema = $table; + } + + $name = '{'. $tableWithoutSchema .'}_'. $name .'_key'; $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP CONSTRAINT '. $name); }