Commit d7f3ace2 authored by Dries's avatar Dries
Browse files

- Patch #62478 by Cvbge: fixed some database inconsistencies with PostgreSQL.

parent 8c8af42c
...@@ -419,13 +419,14 @@ CREATE TABLE node ( ...@@ -419,13 +419,14 @@ CREATE TABLE node (
promote integer NOT NULL default '0', promote integer NOT NULL default '0',
moderate integer NOT NULL default '0', moderate integer NOT NULL default '0',
sticky integer NOT NULL default '0', sticky integer NOT NULL default '0',
PRIMARY KEY (nid) PRIMARY KEY (nid, vid)
); );
CREATE INDEX node_nid_idx ON node(nid);
CREATE INDEX node_type_idx ON node(type); CREATE INDEX node_type_idx ON node(type);
CREATE INDEX node_title_type_idx ON node(title,type); CREATE INDEX node_title_type_idx ON node(title,type);
CREATE INDEX node_status_idx ON node(status); CREATE INDEX node_status_idx ON node(status);
CREATE INDEX node_uid_idx ON node(uid); CREATE INDEX node_uid_idx ON node(uid);
CREATE INDEX node_vid_idx ON node(vid); CREATE UNIQUE INDEX node_vid_idx ON node(vid);
CREATE INDEX node_moderate_idx ON node (moderate); CREATE INDEX node_moderate_idx ON node (moderate);
CREATE INDEX node_promote_status_idx ON node (promote, status); CREATE INDEX node_promote_status_idx ON node (promote, status);
CREATE INDEX node_created_idx ON node(created); CREATE INDEX node_created_idx ON node(created);
......
...@@ -1964,17 +1964,24 @@ function system_update_179() { ...@@ -1964,17 +1964,24 @@ function system_update_179() {
function system_update_180() { function system_update_180() {
$ret = array(); $ret = array();
if ($GLOBALS['db_type'] == 'mysql') { switch ($GLOBALS['db_type']) {
$ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY"); case 'mysql':
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)"); case 'mysqli':
$ret[] = update_sql("ALTER TABLE {node} DROP INDEX vid"); $ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {node} ADD UNIQUE (vid)"); $ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$ret[] = update_sql("ALTER TABLE {node} ADD INDEX (nid)"); $ret[] = update_sql("ALTER TABLE {node} DROP INDEX vid");
$ret[] = update_sql("ALTER TABLE {node} ADD UNIQUE (vid)");
$ret[] = update_sql("ALTER TABLE {node} ADD INDEX (nid)");
$ret[] = update_sql("ALTER TABLE {node_counter} CHANGE nid nid INT(10) NOT NULL DEFAULT '0'"); $ret[] = update_sql("ALTER TABLE {node_counter} CHANGE nid nid INT(10) NOT NULL DEFAULT '0'");
} break;
else { // pgsql case 'pgsql':
// Insert queries here. $ret[] = update_sql("ALTER TABLE {node} DROP CONSTRAINT {node}_pkey"); // Change PK
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$ret[] = update_sql('DROP INDEX {node}_vid_idx'); // Change normal index to UNIQUE index
$ret[] = update_sql('CREATE UNIQUE INDEX {node}_vid_idx ON {node}(vid)');
$ret[] = update_sql('CREATE INDEX {node}_nid_idx ON {node}(nid)'); // Add index on nid
break;
} }
return $ret; return $ret;
...@@ -1988,7 +1995,7 @@ function system_update_181() { ...@@ -1988,7 +1995,7 @@ function system_update_181() {
$ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;"); $ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;");
break; break;
case 'pgsql': case 'pgsql':
db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint'); db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint', array('not null' => TRUE, 'default' => 0));
break; break;
} }
return $ret; return $ret;
...@@ -2001,7 +2008,7 @@ function system_update_182() { ...@@ -2001,7 +2008,7 @@ function system_update_182() {
$ret = array(); $ret = array();
if ($GLOBALS['db_type'] == 'pgsql') { if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_lid_idx'); $ret[] = update_sql('ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_lid_key');
$ret[] = update_sql('CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)'); $ret[] = update_sql('CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)');
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment