Bug: Live query chart always zero
[phpmyadmin/tyronm.git] / libraries / data_mysql.inc.php
blobd504d1592bb5270426f94dc50e2a8d6d9ce49f22
1 <?php
2 /**
3 * Column types and functions supported by MySQL
5 * @package phpMyAdmin
6 */
8 // VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
9 $cfg['ColumnTypes'] = !empty($cfg['ColumnTypes']) ? $cfg['ColumnTypes'] : array(
10 // most used
11 'INT',
12 'VARCHAR',
13 'TEXT',
14 'DATE',
16 // numeric
17 'NUMERIC' => array(
18 'TINYINT',
19 'SMALLINT',
20 'MEDIUMINT',
21 'INT',
22 'BIGINT',
23 '-',
24 'DECIMAL',
25 'FLOAT',
26 'DOUBLE',
27 'REAL',
28 '-',
29 'BIT',
30 'BOOLEAN',
31 'SERIAL',
35 // Date/Time
36 'DATE and TIME' => array(
37 'DATE',
38 'DATETIME',
39 'TIMESTAMP',
40 'TIME',
41 'YEAR',
44 // Text
45 'STRING' => array(
46 'CHAR',
47 'VARCHAR',
48 '-',
49 'TINYTEXT',
50 'TEXT',
51 'MEDIUMTEXT',
52 'LONGTEXT',
53 '-',
54 'BINARY',
55 'VARBINARY',
56 '-',
57 'TINYBLOB',
58 'MEDIUMBLOB',
59 'BLOB',
60 'LONGBLOB',
61 '-',
62 'ENUM',
63 'SET',
66 'SPATIAL' => array(
67 'GEOMETRY',
68 'POINT',
69 'LINESTRING',
70 'POLYGON',
71 'MULTIPOINT',
72 'MULTILINESTRING',
73 'MULTIPOLYGON',
74 'GEOMETRYCOLLECTION',
78 $cfg['AttributeTypes'] = !empty($cfg['AttributeTypes']) ? $cfg['AttributeTypes'] : array(
79 '',
80 'BINARY',
81 'UNSIGNED',
82 'UNSIGNED ZEROFILL',
83 'on update CURRENT_TIMESTAMP',
86 if ($cfg['ShowFunctionFields']) {
87 $cfg['RestrictColumnTypes'] = !empty($cfg['RestrictColumnTypes']) ? $cfg['RestrictColumnTypes'] : array(
88 'TINYINT' => 'FUNC_NUMBER',
89 'SMALLINT' => 'FUNC_NUMBER',
90 'MEDIUMINT' => 'FUNC_NUMBER',
91 'INT' => 'FUNC_NUMBER',
92 'BIGINT' => 'FUNC_NUMBER',
93 'DECIMAL' => 'FUNC_NUMBER',
94 'FLOAT' => 'FUNC_NUMBER',
95 'DOUBLE' => 'FUNC_NUMBER',
96 'REAL' => 'FUNC_NUMBER',
97 'BIT' => 'FUNC_NUMBER',
98 'BOOLEAN' => 'FUNC_NUMBER',
99 'SERIAL' => 'FUNC_NUMBER',
101 'DATE' => 'FUNC_DATE',
102 'DATETIME' => 'FUNC_DATE',
103 'TIMESTAMP' => 'FUNC_DATE',
104 'TIME' => 'FUNC_DATE',
105 'YEAR' => 'FUNC_DATE',
107 'CHAR' => 'FUNC_CHAR',
108 'VARCHAR' => 'FUNC_CHAR',
109 'TINYTEXT' => 'FUNC_CHAR',
110 'TEXT' => 'FUNC_CHAR',
111 'MEDIUMTEXT' => 'FUNC_CHAR',
112 'LONGTEXT' => 'FUNC_CHAR',
113 'BINARY' => 'FUNC_CHAR',
114 'VARBINARY' => 'FUNC_CHAR',
115 'TINYBLOB' => 'FUNC_CHAR',
116 'MEDIUMBLOB' => 'FUNC_CHAR',
117 'BLOB' => 'FUNC_CHAR',
118 'LONGBLOB' => 'FUNC_CHAR',
119 'ENUM' => '',
120 'SET' => '',
122 'GEOMETRY' => 'FUNC_SPATIAL',
123 'POINT' => 'FUNC_SPATIAL',
124 'LINESTRING' => 'FUNC_SPATIAL',
125 'POLYGON' => 'FUNC_SPATIAL',
126 'MULTIPOINT' => 'FUNC_SPATIAL',
127 'MULTILINESTRING' => 'FUNC_SPATIAL',
128 'MULTIPOLYGON' => 'FUNC_SPATIAL',
129 'GEOMETRYCOLLECTION' => 'FUNC_SPATIAL',
133 $restrict_functions = array(
134 'FUNC_CHAR' => array(
135 'BIN',
136 'CHAR',
137 'CURRENT_USER',
138 'COMPRESS',
139 'DATABASE',
140 'DAYNAME',
141 'DES_DECRYPT',
142 'DES_ENCRYPT',
143 'ENCRYPT',
144 'HEX',
145 'INET_NTOA',
146 'LOAD_FILE',
147 'LOWER',
148 'LTRIM',
149 'MD5',
150 'MONTHNAME',
151 'OLD_PASSWORD',
152 'PASSWORD',
153 'QUOTE',
154 'REVERSE',
155 'RTRIM',
156 'SHA1',
157 'SOUNDEX',
158 'SPACE',
159 'TRIM',
160 'UNCOMPRESS',
161 'UNHEX',
162 'UPPER',
163 'USER',
164 'UUID',
165 'VERSION',
168 'FUNC_DATE' => array(
169 'CURDATE',
170 'CURTIME',
171 'DATE',
172 'FROM_DAYS',
173 'FROM_UNIXTIME',
174 'LAST_DAY',
175 'NOW',
176 'SEC_TO_TIME',
177 'SYSDATE',
178 'TIME',
179 'TIMESTAMP',
180 'UTC_DATE',
181 'UTC_TIME',
182 'UTC_TIMESTAMP',
183 'YEAR',
186 'FUNC_NUMBER' => array(
187 'ABS',
188 'ACOS',
189 'ASCII',
190 'ASIN',
191 'ATAN',
192 'BIT_LENGTH',
193 'BIT_COUNT',
194 'CEILING',
195 'CHAR_LENGTH',
196 'CONNECTION_ID',
197 'COS',
198 'COT',
199 'CRC32',
200 'DAYOFMONTH',
201 'DAYOFWEEK',
202 'DAYOFYEAR',
203 'DEGREES',
204 'EXP',
205 'FLOOR',
206 'HOUR',
207 'INET_ATON',
208 'LENGTH',
209 'LN',
210 'LOG',
211 'LOG2',
212 'LOG10',
213 'MICROSECOND',
214 'MINUTE',
215 'MONTH',
216 'OCT',
217 'ORD',
218 'PI',
219 'QUARTER',
220 'RADIANS',
221 'RAND',
222 'ROUND',
223 'SECOND',
224 'SIGN',
225 'SIN',
226 'SQRT',
227 'TAN',
228 'TO_DAYS',
229 'TO_SECONDS',
230 'TIME_TO_SEC',
231 'UNCOMPRESSED_LENGTH',
232 'UNIX_TIMESTAMP',
233 'UUID_SHORT',
234 'WEEK',
235 'WEEKDAY',
236 'WEEKOFYEAR',
237 'YEARWEEK',
240 'FUNC_SPATIAL' => array(
241 'GeomFromText',
242 'GeomFromWKB',
244 'GeomCollFromText',
245 'LineFromText',
246 'MLineFromText',
247 'PointFromText',
248 'MPointFromText',
249 'PolyFromText',
250 'MPolyFromText',
252 'GeomCollFromWKB',
253 'LineFromWKB',
254 'MLineFromWKB',
255 'PointFromWKB',
256 'MPointFromWKB',
257 'PolyFromWKB',
258 'MPolyFromWKB',
261 // $restrict_functions holds all known functions, remove these that are unavailable on current server
262 if (PMA_MYSQL_INT_VERSION < 50500) {
263 $restrict_functions['FUNC_NUMBER'] = array_diff($restrict_functions['FUNC_NUMBER'], array('TO_SECONDS'));
265 if (PMA_MYSQL_INT_VERSION < 50120) {
266 $restrict_functions['FUNC_NUMBER'] = array_diff($restrict_functions['FUNC_NUMBER'], array('UUID_SHORT'));
269 if (empty($cfg['RestrictFunctions'])) {
270 $cfg['RestrictFunctions'] = $restrict_functions;
273 if (empty($cfg['Functions'])) {
274 // build a list of functions based on $restrict_functions
275 $cfg['Functions'] = array();
276 foreach ($restrict_functions as $cat => $functions) {
277 if ($cat != 'FUNC_SPATIAL') {
278 $cfg['Functions'] = array_merge($cfg['Functions'], $functions);
281 sort($cfg['Functions']);
283 unset($restrict_functions);
284 } // end if