Common strings for descriptions of DATE, TIME, DATETIME and VARCHAR2
[phpmyadmin.git] / libraries / data_mysql.inc.php
blob97e614f25b4d68b8e5757a799ab173d17b8cb096
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Column types and functions supported by MySQL
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 // VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
13 $cfg['ColumnTypes'] = !empty($cfg['ColumnTypes']) ? $cfg['ColumnTypes'] : array(
14 // most used
15 'INT',
16 'VARCHAR',
17 'TEXT',
18 'DATE',
20 // numeric
21 'NUMERIC' => array(
22 'TINYINT',
23 'SMALLINT',
24 'MEDIUMINT',
25 'INT',
26 'BIGINT',
27 '-',
28 'DECIMAL',
29 'FLOAT',
30 'DOUBLE',
31 'REAL',
32 '-',
33 'BIT',
34 'BOOLEAN',
35 'SERIAL',
39 // Date/Time
40 'DATE and TIME' => array(
41 'DATE',
42 'DATETIME',
43 'TIMESTAMP',
44 'TIME',
45 'YEAR',
48 // Text
49 'STRING' => array(
50 'CHAR',
51 'VARCHAR',
52 '-',
53 'TINYTEXT',
54 'TEXT',
55 'MEDIUMTEXT',
56 'LONGTEXT',
57 '-',
58 'BINARY',
59 'VARBINARY',
60 '-',
61 'TINYBLOB',
62 'MEDIUMBLOB',
63 'BLOB',
64 'LONGBLOB',
65 '-',
66 'ENUM',
67 'SET',
70 'SPATIAL' => array(
71 'GEOMETRY',
72 'POINT',
73 'LINESTRING',
74 'POLYGON',
75 'MULTIPOINT',
76 'MULTILINESTRING',
77 'MULTIPOLYGON',
78 'GEOMETRYCOLLECTION',
82 $cfg['AttributeTypes'] = !empty($cfg['AttributeTypes']) ? $cfg['AttributeTypes'] : array(
83 '',
84 'BINARY',
85 'UNSIGNED',
86 'UNSIGNED ZEROFILL',
87 'on update CURRENT_TIMESTAMP',
90 if ($cfg['ShowFunctionFields']) {
91 $cfg['RestrictColumnTypes'] = !empty($cfg['RestrictColumnTypes']) ? $cfg['RestrictColumnTypes'] : array(
92 'TINYINT' => 'FUNC_NUMBER',
93 'SMALLINT' => 'FUNC_NUMBER',
94 'MEDIUMINT' => 'FUNC_NUMBER',
95 'INT' => 'FUNC_NUMBER',
96 'BIGINT' => 'FUNC_NUMBER',
97 'DECIMAL' => 'FUNC_NUMBER',
98 'FLOAT' => 'FUNC_NUMBER',
99 'DOUBLE' => 'FUNC_NUMBER',
100 'REAL' => 'FUNC_NUMBER',
101 'BIT' => 'FUNC_NUMBER',
102 'BOOLEAN' => 'FUNC_NUMBER',
103 'SERIAL' => 'FUNC_NUMBER',
105 'DATE' => 'FUNC_DATE',
106 'DATETIME' => 'FUNC_DATE',
107 'TIMESTAMP' => 'FUNC_DATE',
108 'TIME' => 'FUNC_DATE',
109 'YEAR' => 'FUNC_DATE',
111 'CHAR' => 'FUNC_CHAR',
112 'VARCHAR' => 'FUNC_CHAR',
113 'TINYTEXT' => 'FUNC_CHAR',
114 'TEXT' => 'FUNC_CHAR',
115 'MEDIUMTEXT' => 'FUNC_CHAR',
116 'LONGTEXT' => 'FUNC_CHAR',
117 'BINARY' => 'FUNC_CHAR',
118 'VARBINARY' => 'FUNC_CHAR',
119 'TINYBLOB' => 'FUNC_CHAR',
120 'MEDIUMBLOB' => 'FUNC_CHAR',
121 'BLOB' => 'FUNC_CHAR',
122 'LONGBLOB' => 'FUNC_CHAR',
123 'ENUM' => '',
124 'SET' => '',
126 'GEOMETRY' => 'FUNC_SPATIAL',
127 'POINT' => 'FUNC_SPATIAL',
128 'LINESTRING' => 'FUNC_SPATIAL',
129 'POLYGON' => 'FUNC_SPATIAL',
130 'MULTIPOINT' => 'FUNC_SPATIAL',
131 'MULTILINESTRING' => 'FUNC_SPATIAL',
132 'MULTIPOLYGON' => 'FUNC_SPATIAL',
133 'GEOMETRYCOLLECTION' => 'FUNC_SPATIAL',
137 $restrict_functions = array(
138 'FUNC_CHAR' => array(
139 'BIN',
140 'CHAR',
141 'CURRENT_USER',
142 'COMPRESS',
143 'DATABASE',
144 'DAYNAME',
145 'DES_DECRYPT',
146 'DES_ENCRYPT',
147 'ENCRYPT',
148 'HEX',
149 'INET_NTOA',
150 'LOAD_FILE',
151 'LOWER',
152 'LTRIM',
153 'MD5',
154 'MONTHNAME',
155 'OLD_PASSWORD',
156 'PASSWORD',
157 'QUOTE',
158 'REVERSE',
159 'RTRIM',
160 'SHA1',
161 'SOUNDEX',
162 'SPACE',
163 'TRIM',
164 'UNCOMPRESS',
165 'UNHEX',
166 'UPPER',
167 'USER',
168 'UUID',
169 'VERSION',
172 'FUNC_DATE' => array(
173 'CURRENT_DATE',
174 'CURRENT_TIME',
175 'DATE',
176 'FROM_DAYS',
177 'FROM_UNIXTIME',
178 'LAST_DAY',
179 'NOW',
180 'SEC_TO_TIME',
181 'SYSDATE',
182 'TIME',
183 'TIMESTAMP',
184 'UTC_DATE',
185 'UTC_TIME',
186 'UTC_TIMESTAMP',
187 'YEAR',
190 'FUNC_NUMBER' => array(
191 'ABS',
192 'ACOS',
193 'ASCII',
194 'ASIN',
195 'ATAN',
196 'BIT_LENGTH',
197 'BIT_COUNT',
198 'CEILING',
199 'CHAR_LENGTH',
200 'CONNECTION_ID',
201 'COS',
202 'COT',
203 'CRC32',
204 'DAYOFMONTH',
205 'DAYOFWEEK',
206 'DAYOFYEAR',
207 'DEGREES',
208 'EXP',
209 'FLOOR',
210 'HOUR',
211 'INET_ATON',
212 'LENGTH',
213 'LN',
214 'LOG',
215 'LOG2',
216 'LOG10',
217 'MICROSECOND',
218 'MINUTE',
219 'MONTH',
220 'OCT',
221 'ORD',
222 'PI',
223 'QUARTER',
224 'RADIANS',
225 'RAND',
226 'ROUND',
227 'SECOND',
228 'SIGN',
229 'SIN',
230 'SQRT',
231 'TAN',
232 'TO_DAYS',
233 'TO_SECONDS',
234 'TIME_TO_SEC',
235 'UNCOMPRESSED_LENGTH',
236 'UNIX_TIMESTAMP',
237 'UUID_SHORT',
238 'WEEK',
239 'WEEKDAY',
240 'WEEKOFYEAR',
241 'YEARWEEK',
244 'FUNC_SPATIAL' => array(
245 'GeomFromText',
246 'GeomFromWKB',
248 'GeomCollFromText',
249 'LineFromText',
250 'MLineFromText',
251 'PointFromText',
252 'MPointFromText',
253 'PolyFromText',
254 'MPolyFromText',
256 'GeomCollFromWKB',
257 'LineFromWKB',
258 'MLineFromWKB',
259 'PointFromWKB',
260 'MPointFromWKB',
261 'PolyFromWKB',
262 'MPolyFromWKB',
265 // $restrict_functions holds all known functions, remove these that are unavailable on current server
266 if (PMA_MYSQL_INT_VERSION < 50500) {
267 $restrict_functions['FUNC_NUMBER'] = array_diff($restrict_functions['FUNC_NUMBER'], array('TO_SECONDS'));
269 if (PMA_MYSQL_INT_VERSION < 50120) {
270 $restrict_functions['FUNC_NUMBER'] = array_diff($restrict_functions['FUNC_NUMBER'], array('UUID_SHORT'));
273 if (empty($cfg['RestrictFunctions'])) {
274 $cfg['RestrictFunctions'] = $restrict_functions;
277 if (empty($cfg['Functions'])) {
278 // build a list of functions based on $restrict_functions
279 $cfg['Functions'] = array();
280 foreach ($restrict_functions as $cat => $functions) {
281 if ($cat != 'FUNC_SPATIAL') {
282 $cfg['Functions'] = array_merge($cfg['Functions'], $functions);
285 sort($cfg['Functions']);
287 unset($restrict_functions);
288 } // end if
291 * This function returns datatypes descriptions.
293 * @return array MySQL datatypes descriptions.
296 function PMA_supportedDataTypesDescriptions()
298 // if possible, for easy translation these strings should be the same as for Drizzle
299 return array(
300 'TINYINT' => __('A 1-byte integer, signed range is -128 to 127, unsigned range is 0 to 255'),
301 'SMALLINT' => __('A 2-byte integer, signed range is -32,768 to 32,767, unsigned range is 0 to 65,535'),
302 'MEDIUMINT' => __('A 3-byte integer, signed range is -8,388,608 to 8,388,607, unsigned range is 0 to 16,777,215'),
303 'INT' => __('A 4-byte integer, signed range is -2,147,483,648 to 2,147,483,647, unsigned range is 0 to 4,294,967,295.'),
304 'BIGINT' => __('An 8-byte integer, signed range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, unsigned range is 0 to 18,446,744,073,709,551,615'),
305 'DECIMAL' => __('A fixed-point number (M, D) - the maximum number of digits (M) is 65 (default 10), the maximum number of decimals (D) is 30 (default 0)'),
306 'FLOAT' => __('A small floating-point number, allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38'),
307 'DOUBLE' => __('A double-precision floating-point number, allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308'),
308 'REAL' => __('Synonym for DOUBLE (exception: in REAL_AS_FLOAT SQL mode it is a synonym for FLOAT)'),
309 'BIT' => __('A bit-field type (M), storing M of bits per value (default is 1, maximum is 64)'),
310 'BOOLEAN' => __('A synonym for TINYINT(1), a value of zero is considered false, nonzero values are considered true'),
311 'SERIAL' => __('An alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE'),
312 'DATE' => sprintf(__("A date, supported range is '%s' to '%s'"), '1000-01-01', '9999-12-31'),
313 'DATETIME' => sprintf(__("A date and time combination, supported range is '%s' to '%s'"), '1000-01-01 00:00:00', '9999-12-31 23:59:59'),
314 'TIMESTAMP' => __("A timestamp, range is '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC, stored as the number of seconds since the epoch ('1970-01-01 00:00:00' UTC)"),
315 'TIME' => sprintf(__("A time, range is '%s' to '%s'"), '-838:59:59', '838:59:59'),
316 'YEAR' => __("A year in four-digit (4, default) or two-digit (2) format, the allowable values are 70 (1970) to 69 (2069) or 1901 to 2155 and 0000"),
317 'CHAR' => __('A fixed-length (0-255, default 1) string that is always right-padded with spaces to the specified length when stored'),
318 'VARCHAR' => sprintf(__('A variable-length (%s) string, the effective maximum length is subject to the maximum row size'), '0-65,535'),
319 'TINYTEXT' => __('A TEXT column with a maximum length of 255 (2^8 - 1) characters, stored with a one-byte prefix indicating the length of the value in bytes'),
320 'TEXT' => __('A TEXT column with a maximum length of 65,535 (2^16 - 1) characters, stored with a two-byte prefix indicating the length of the value in bytes'),
321 'MEDIUMTEXT' => __('A TEXT column with a maximum length of 16,777,215 (2^24 - 1) characters, stored with a three-byte prefix indicating the length of the value in bytes'),
322 'LONGTEXT' => __('A TEXT column with a maximum length of 4,294,967,295 or 4GB (2^32 - 1) characters, stored with a four-byte prefix indicating the length of the value in bytes'),
323 'BINARY' => __('Similar to the CHAR type, but stores binary byte strings rather than non-binary character strings'),
324 'VARBINARY' => __('Similar to the VARCHAR type, but stores binary byte strings rather than non-binary character strings'),
325 'TINYBLOB' => __('A BLOB column with a maximum length of 255 (2^8 - 1) bytes, stored with a one-byte prefix indicating the length of the value'),
326 'MEDIUMBLOB' => __('A BLOB column with a maximum length of 16,777,215 (2^24 - 1) bytes, stored with a three-byte prefix indicating the length of the value'),
327 'BLOB' => __('A BLOB column with a maximum length of 65,535 (2^16 - 1) bytes, stored with a four-byte prefix indicating the length of the value'),
328 'LONGBLOB' => __('A BLOB column with a maximum length of 4,294,967,295 or 4GB (2^32 - 1) bytes, stored with a two-byte prefix indicating the length of the value'),
329 'ENUM' => __("An enumeration, chosen from the list of up to 65,535 values or the special '' error value"),
330 'SET' => __("A single value chosen from a set of up to 64 members"),
331 'GEOMETRY' => __('A type that can store a geometry of any type'),
332 'POINT' => __('A point in 2-dimensional space'),
333 'LINESTRING' => __('A curve with linear interpolation between points'),
334 'POLYGON' => __('A polygon'),
335 'MULTIPOINT' => __('A collection of points'),
336 'MULTILINESTRING' => __('A collection of curves with linear interpolation between points'),
337 'MULTIPOLYGON' => __('A collection of polygons'),
338 'GEOMETRYCOLLECTION' => __('A collection of geometry objects of any type'),
340 } // end PMA_supportedDataTypesDescriptions()