Skip to content
Snippets Groups Projects
Commit 52c42406 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Added PostgreSQL support to the update script.  Patch by Adrian.

- Making Adrian the new PostgreSQL maintainer.
parent 1127b04b
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -45,7 +45,7 @@ M: Moshe Weitzman <weitzman@tejasa.com> ...@@ -45,7 +45,7 @@ M: Moshe Weitzman <weitzman@tejasa.com>
S: maintained S: maintained
POSTGRES PORT POSTGRES PORT
M: James Arthur <j_a_arthur@yahoo.com> M: Adrian Rossouw <adrian@obsidian.co.za>
S: maintained S: maintained
STATISTICS MODULE STATISTICS MODULE
...@@ -62,7 +62,7 @@ S: maintained ...@@ -62,7 +62,7 @@ S: maintained
DEBIAN PACKAGE DEBIAN PACKAGE
M: Hugo Espuny <hec@debian.org> M: Hugo Espuny <hec@debian.org>
S: maintained S: fixes/patches
THE REST: THE REST:
M: Dries <dries@drupal.org> M: Dries <dries@drupal.org>
...@@ -580,7 +580,7 @@ INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1); ...@@ -580,7 +580,7 @@ INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1); INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1);
INSERT INTO users (uid, name, mail, rid) VALUES ('0', 'Anonymous', 'root@localhost', '1'); INSERT INTO users (uid, name, mail, rid) VALUES ('0', 'Anonymous', 'root@localhost', '1');
REPLACE variable SET name='update_start', value='s:10:"2003-04-19;"'; REPLACE variable SET name='update_start', value='s:10:"2003-09-29;"';
REPLACE variable SET name='theme_default', value='s:6:"marvin";'; REPLACE variable SET name='theme_default', value='s:6:"marvin";';
REPLACE blocks SET module = 'user', delta = '0', status = '1'; REPLACE blocks SET module = 'user', delta = '0', status = '1';
......
...@@ -124,7 +124,7 @@ CREATE TABLE comments ( ...@@ -124,7 +124,7 @@ CREATE TABLE comments (
link varchar(16) NOT NULL default '', link varchar(16) NOT NULL default '',
score integer NOT NULL default '0', score integer NOT NULL default '0',
status smallint NOT NULL default '0', status smallint NOT NULL default '0',
thread varchar(255) NOT NULL, thread varchar(255) default '',
users text default '', users text default '',
PRIMARY KEY (cid) PRIMARY KEY (cid)
); );
...@@ -521,6 +521,8 @@ CREATE TABLE users ( ...@@ -521,6 +521,8 @@ CREATE TABLE users (
); );
CREATE INDEX users_timestamp_idx ON users(timestamp); CREATE INDEX users_timestamp_idx ON users(timestamp);
CREATE SEQUENCE users_uid_seq INCREMENT 1 START 1;
-- --
-- Table structure for variable -- Table structure for variable
-- --
...@@ -578,7 +580,7 @@ INSERT INTO system VALUES ('modules/story.module','story','module','',1); ...@@ -578,7 +580,7 @@ INSERT INTO system VALUES ('modules/story.module','story','module','',1);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1); INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1); INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1);
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-04-19";'); INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-09-29";');
INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";'); INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";');
INSERT INTO users(uid,name,mail,rid) VALUES(0,'Anonymous','root@localhost', '1'); INSERT INTO users(uid,name,mail,rid) VALUES(0,'Anonymous','root@localhost', '1');
...@@ -598,3 +600,8 @@ BEGIN ...@@ -598,3 +600,8 @@ BEGIN
END; END;
' LANGUAGE 'plpgsql'; ' LANGUAGE 'plpgsql';
CREATE FUNCTION "rand"() RETURNS float AS '
BEGIN
RETURN random();
END;
' LANGUAGE 'plpgsql';
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
"2003-08-20" => "update_61", "2003-08-20" => "update_61",
"2003-08-27" => "update_62", "2003-08-27" => "update_62",
"2003-09-09" => "update_63", "2003-09-09" => "update_63",
"2003-09-10" => "update_64" "2003-09-10" => "update_64",
"2003-09-29" => "update_65"
); );
function update_32() { function update_32() {
...@@ -274,12 +275,23 @@ function update_57() { ...@@ -274,12 +275,23 @@ function update_57() {
} }
function update_58() { function update_58() {
update_sql("ALTER TABLE node ADD path varchar(250) NULL default ''"); if ($GLOBALS["db_type"] == "pgsql") {
update_sql("ALTER TABLE {node} ADD path varchar(250) NULL");
update_sql("ALTER TABLE {node} ALTER COLUMN path SET DEFAULT ''");
}
else {
update_sql("ALTER TABLE {node} ADD path varchar(250) NULL default ''");
}
} }
function update_59() { function update_59() {
if ($GLOBALS["db_type"] == "pgsql") {
update_sql("ALTER TABLE {comments} ADD thread VARCHAR(255) NOT NULL"); update_sql("ALTER TABLE {comments} ADD thread VARCHAR(255)");
update_sql("ALTER TABLE {comments} ALTER COLUMN thread SET NOT NULL");
}
else {
update_sql("ALTER TABLE {comments} ADD thread VARCHAR(255) NOT NULL");
}
$result = db_query("SELECT DISTINCT(nid) FROM {comments} WHERE thread = ''"); $result = db_query("SELECT DISTINCT(nid) FROM {comments} WHERE thread = ''");
...@@ -337,34 +349,71 @@ function update_60() { ...@@ -337,34 +349,71 @@ function update_60() {
} }
function update_61() { function update_61() {
update_sql("CREATE TABLE IF NOT EXISTS {sessions} ( if ($GLOBALS["db_type"] == "pgsql") {
uid int(10) unsigned NOT NULL, /**
sid varchar(32) NOT NULL default '', * Overkill.. the user cant get here without having this table
hostname varchar(128) NOT NULL default '', */
timestamp int(11) NOT NULL default '0',
session text, update_sql("CREATE TABLE {sessions} (
KEY uid (uid), uid integer NOT NULL,
KEY sid (sid(4)), sid varchar(32) NOT NULL default '',
KEY timestamp (timestamp) hostname varchar(128) NOT NULL default '',
)"); timestamp integer NOT NULL default '0',
session text,
PRIMARY KEY (sid)
);");
update_sql("ALTER TABLE {users} DROP session;");
update_sql("ALTER TABLE {users} DROP hostname;");
update_sql("ALTER TABLE {users} DROP sid;");
update_sql("ALTER TABLE {users} DROP session;"); }
update_sql("ALTER TABLE {users} DROP hostname;"); else {
update_sql("ALTER TABLE {users} DROP sid;"); update_sql("CREATE TABLE IF NOT EXISTS {sessions} (
uid int(10) unsigned NOT NULL,
sid varchar(32) NOT NULL default '',
hostname varchar(128) NOT NULL default '',
timestamp int(11) NOT NULL default '0',
session text,
KEY uid (uid),
KEY sid (sid(4)),
KEY timestamp (timestamp)
)");
update_sql("ALTER TABLE {users} DROP session;");
update_sql("ALTER TABLE {users} DROP hostname;");
update_sql("ALTER TABLE {users} DROP sid;");
}
} }
function update_62() { function update_62() {
update_sql("ALTER TABLE {accesslog} ADD INDEX accesslog_timestamp (timestamp)"); if ($GLOBALS["db_type"] == "pgsql") {
update_sql("CREATE INDEX accesslog_timestamp ON {accesslog} (timestamp)");
update_sql("DROP INDEX node_type_idx");
update_sql("DROP INDEX node_title_idx");
update_sql("DROP INDEX node_promote_idx");
update_sql("ALTER TABLE {node} DROP INDEX type"); update_sql("CREATE INDEX node_type ON {node} (type)");
update_sql("ALTER TABLE {node} DROP INDEX title"); update_sql("CREATE INDEX node_title_type ON {node} (title,type)");
update_sql("ALTER TABLE {node} DROP INDEX promote"); update_sql("CREATE INDEX node_moderate ON {node} (moderate)");
update_sql("CREATE INDEX node_path ON {node} (path)");
update_sql("CREATE INDEX node_promote_status ON {node} (promote, status)");
update_sql("ALTER TABLE {node} ADD INDEX node_type (type(4))"); }
update_sql("ALTER TABLE {node} ADD INDEX node_title_type (title,type(4))"); else {
update_sql("ALTER TABLE {node} ADD INDEX node_moderate (moderate)"); update_sql("ALTER TABLE {accesslog} ADD INDEX accesslog_timestamp (timestamp)");
update_sql("ALTER TABLE {node} ADD INDEX node_path (path(5))");
update_sql("ALTER TABLE {node} ADD INDEX node_promote_status (promote, status)"); update_sql("ALTER TABLE {node} DROP INDEX type");
update_sql("ALTER TABLE {node} DROP INDEX title");
update_sql("ALTER TABLE {node} DROP INDEX promote");
update_sql("ALTER TABLE {node} ADD INDEX node_type (type(4))");
update_sql("ALTER TABLE {node} ADD INDEX node_title_type (title,type(4))");
update_sql("ALTER TABLE {node} ADD INDEX node_moderate (moderate)");
update_sql("ALTER TABLE {node} ADD INDEX node_path (path(5))");
update_sql("ALTER TABLE {node} ADD INDEX node_promote_status (promote, status)");
}
} }
function _update_next_thread($structure, $parent) { function _update_next_thread($structure, $parent) {
...@@ -383,16 +432,31 @@ function _update_next_thread($structure, $parent) { ...@@ -383,16 +432,31 @@ function _update_next_thread($structure, $parent) {
} }
function update_63() { function update_63() {
update_sql("ALTER TABLE {users} CHANGE uid uid int(10) unsigned NOT NULL default '0'"); if ($GLOBALS["db_type"] == "pgsql") {
update_sql("INSERT INTO {users} (uid, name, mail, timestamp) VALUES ('0', 'Anonymous', 'root@localhost', '". time() ."')"); update_sql("INSERT INTO {users} (uid, name, mail, timestamp) VALUES ('0', 'Anonymous', 'root@localhost', '". time() ."')");
$users = db_result(db_query("SELECT MAX(uid) FROM {users};")); }
update_sql("INSERT INTO {sequences} (name, id) VALUES ('users_uid', '$users')"); else {
update_sql("ALTER TABLE {users} CHANGE uid uid int(10) unsigned NOT NULL default '0'");
update_sql("INSERT INTO {users} (uid, name, mail, timestamp) VALUES ('0', 'Anonymous', 'root@localhost', '". time() ."')");
$users = db_result(db_query("SELECT MAX(uid) FROM {users};"));
update_sql("INSERT INTO {sequences} (name, id) VALUES ('users_uid', '$users')");
}
} }
function update_64() { function update_64() {
update_sql("UPDATE {users} SET rid = 1 WHERE uid = 0"); update_sql("UPDATE {users} SET rid = 1 WHERE uid = 0");
} }
function update_65() {
/* PG SQL ONLY UPDATE */
if ($GLOBALS["db_type"] == "pgsql") {
update_sql("CREATE FUNCTION \"rand\"() RETURNS float AS '
BEGIN
RETURN random();
END;' LANGUAGE 'plpgsql';");
}
}
/* /*
** System functions ** System functions
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment