Commit 753f11d8 authored by Dries's avatar Dries
Browse files

- Patch #41755 by Cvbge:

   1. "int(10)" -> "int", fixed typo in index name [pgsql change only]
   2. added defaults for uid and hostname (needed for both)
   3. postgres supports "DROP column" syntax
   4. added missing DELETEs for new table in poll_delete() and poll_update()
parent 4c66ab52
......@@ -546,8 +546,8 @@ CREATE TABLE poll (
CREATE TABLE poll_votes (
nid int(10) unsigned NOT NULL,
uid int(10) unsigned NOT NULL,
hostname varchar(128) NOT NULL,
uid int(10) unsigned NOT NULL default 0,
hostname varchar(128) NOT NULL default '',
INDEX (nid),
INDEX (uid),
INDEX (hostname)
......
......@@ -540,11 +540,11 @@ CREATE TABLE poll (
--
CREATE TABLE poll_votes (
nid int(10) NOT NULL,
uid int(10) NOT NULL,
hostname varchar(128) NOT NULL
nid int NOT NULL,
uid int NOT NULL default 0,
hostname varchar(128) NOT NULL default ''
);
CREATE INDEX poll_voter_nid_idx ON poll_votes (nid);
CREATE INDEX poll_votes_nid_idx ON poll_votes (nid);
CREATE INDEX poll_votes_uid_idx ON poll_votes (uid);
CREATE INDEX poll_votes_hostname_idx ON poll_votes (hostname);
......
......@@ -1293,22 +1293,22 @@ function system_update_164() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('CREATE TABLE {poll_votes} (
$ret[] = update_sql("CREATE TABLE {poll_votes} (
nid int(10) unsigned NOT NULL,
uid int(10) unsigned NOT NULL,
hostname varchar(128) NOT NULL,
uid int(10) unsigned NOT NULL default 0,
hostname varchar(128) NOT NULL default '',
INDEX (nid),
INDEX (uid),
INDEX (hostname)
)');
)");
break;
case 'pgsql':
$ret[] = update_sql('CREATE TABLE {poll_votes} (
nid int(10) NOT NULL,
uid int(10) NOT NULL,
hostname varchar(128) NOT NULL
)');
$ret[] = update_sql("CREATE TABLE {poll_votes} (
nid int NOT NULL,
uid int NOT NULL default 0,
hostname varchar(128) NOT NULL default ''
)");
$ret[] = update_sql('CREATE INDEX {poll_votes}_nid_idx ON {poll_votes} (nid)');
$ret[] = update_sql('CREATE INDEX {poll_votes}_uid_idx ON {poll_votes} (uid)');
$ret[] = update_sql('CREATE INDEX {poll_votes}_hostname_idx ON {poll_votes} (hostname)');
......@@ -1329,16 +1329,7 @@ function system_update_164() {
}
}
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {poll} DROP polled');
break;
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {poll} RENAME polled TO polled_old');
break;
}
$ret[] = update_sql('ALTER TABLE {poll} DROP polled');
return $ret;
}
......@@ -87,6 +87,7 @@ function poll_cron() {
function poll_delete($node) {
db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid);
db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid);
}
/**
......@@ -482,6 +483,7 @@ function poll_update($node) {
db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid);
db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid);
foreach ($node->choice as $choice) {
$chvotes = (int)$choice['chvotes'];
$chtext = $choice['chtext'];
......
......@@ -87,6 +87,7 @@ function poll_cron() {
function poll_delete($node) {
db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid);
db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid);
}
/**
......@@ -482,6 +483,7 @@ function poll_update($node) {
db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid);
db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid);
foreach ($node->choice as $choice) {
$chvotes = (int)$choice['chvotes'];
$chtext = $choice['chtext'];
......
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