#201060. query store get postgres support. patch by mailleux.
[project/devel.git] / devel.install
CommitLineData
48a80c07
GH
1<?php
2// $Id$
3/**
4 * Implementation of hook_install()
5 */
6function devel_install() {
9d450e49 7 // New module weights in core: put devel as the very last in the chain.
c01a051a 8 db_query("UPDATE {system} SET weight = 88 WHERE name = 'devel'");
20079c18 9
cd1b6ba3 10 switch ($GLOBALS['db_type']) {
11 case 'mysqli':
12 case 'mysql':
20079c18 13 $sql = "CREATE TABLE {devel_queries} (
4e736b5a 14 qid int(10) NOT NULL auto_increment,
15 function varchar(255) NOT NULL default '',
16 query text NOT NULL,
17 hash varchar(255) NOT NULL default '',
18 PRIMARY KEY (`hash`),
19 KEY qid (qid)
20 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
cd1b6ba3 21 db_query($sql);
22
20079c18 23 $sql = "CREATE TABLE {devel_times} (
cd1b6ba3 24 tid int(10) NOT NULL auto_increment,
25 qid int(10) NOT NULL default 0,
26 time float default NULL,
27 PRIMARY KEY (tid),
28 KEY qid (qid)
29 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
30 db_query($sql);
31 break;
47fd09f8 32 case 'mssql':
33 $sql = "CREATE TABLE {devel_queries} (
34 qid INT IDENTITY(1,1),
35 \"function\" varchar(255) NOT NULL default '',
36 query text NOT NULL,
37 hash varchar(255) NOT NULL default '',
38 PRIMARY KEY (qid));";
39 db_query($sql);
1c22ed5d 40 break;
41 case 'pgsql':
42 $sql = "CREATE TABLE {devel_queries} (
43 qid SERIAL NOT NULL,
44 \"function\" varchar(255) NOT NULL default '',
45 query text NOT NULL,
46 hash varchar(255) NOT NULL default '',
47 PRIMARY KEY (qid)
48 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
49 db_query($sql);
50 db_query("CREATE INDEX devel_queries_hash_idx ON {devel_queries}(hash)");
51
52 $sql = "CREATE TABLE {devel_times} (
53 tid SERIAL NOT NULL,
54 qid integer NOT NULL default 0,
55 time float default NULL,
56 PRIMARY KEY (tid)
57 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
58 db_query($sql);
59 break;
47fd09f8 60
61 $sql = "CREATE TABLE {devel_times} (
62 tid INT IDENTITY(1,1),
63 qid INT NOT NULL default 0,
64 time FLOAT default NULL,
65 PRIMARY KEY (tid)
66 );";
151f932d 67 db_query($sql);
cd1b6ba3 68 }
48a80c07
GH
69}
70
ca029ab6 71/**
72 * Implementation of hook_disable().
73 */
74function devel_disable() {
75 // Query logging should probably not be set if devel.module is disabled.
76 if (variable_get('dev_query', 0)) {
77 variable_set('dev_query',0);
78 drupal_set_message(t('Disabled query logging since devel module is disabled.'));
79 }
80}
81
48a80c07 82/**
9d450e49 83 * Do update 1 again as the hook_install() was missing and new
48a80c07
GH
84 * installations are not having the weight set.
85 */
86function devel_update_2() {
9d450e49 87 // New module weights in core: put devel as the very last in the chain.
48a80c07
GH
88 $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'devel'");
89 return $ret;
90}
cd1b6ba3 91
92function devel_update_3() {
93 switch ($GLOBALS['db_type']) {
94 case 'mysqli':
95 case 'mysql':
20079c18 96 $sql = "CREATE TABLE {devel_queries} (
4e736b5a 97 qid int(10) NOT NULL auto_increment,
98 query varchar(255) NOT NULL default '',
99 hash varchar(255) NOT NULL default '',
100 PRIMARY KEY (`hash`),
101 KEY qid (qid)
102 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
cd1b6ba3 103 $ret[] = update_sql($sql);
104
20079c18 105 $sql = "CREATE TABLE {devel_times} (
cd1b6ba3 106 tid int(10) NOT NULL auto_increment,
107 qid int(10) NOT NULL default 0,
108 time float default NULL,
109 PRIMARY KEY (tid),
110 KEY qid (qid)
111 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
112 $ret[] = update_sql($sql);
113 return $ret;
114 }
115}
20079c18
GK
116
117function devel_update_4() {
118 $ret = array();
119 switch ($GLOBALS['db_type']) {
120 case 'mysqli':
121 case 'mysql':
122 $ret[] = update_sql("ALTER TABLE {devel_queries} ADD `function` varchar(255) NOT NULL default ''");
123 }
124 return $ret;
125}
39ba736c
GK
126
127function devel_update_5() {
128 $ret = array();
129 switch ($GLOBALS['db_type']) {
130 case 'mysqli':
131 case 'mysql':
132 $ret[] = update_sql("ALTER TABLE {devel_queries} CHANGE query query text NOT NULL");
133 }
134 return $ret;
135}
d46bda4d 136
137// attention: from now on numbering as per http://drupal.org/node/114774