Common strings for descriptions of DATE, TIME, DATETIME and VARCHAR2
[phpmyadmin.git] / libraries / data_drizzle.inc.php
blob3ff3a9907201de73b6306ea1bcce889b85da8bd4
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Column types and functions supported by Drizzle
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 $auto_column_types = empty($cfg['ColumnTypes']);
14 // VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
15 $cfg['ColumnTypes'] = !empty($cfg['ColumnTypes']) ? $cfg['ColumnTypes'] : array(
16 // most used
17 'INTEGER',
18 'VARCHAR',
19 'TEXT',
20 'DATE',
22 // numeric
23 'NUMERIC' => array(
24 'INTEGER',
25 'BIGINT',
26 '-',
27 'DECIMAL',
28 'DOUBLE',
29 '-',
30 'BOOLEAN',
31 'SERIAL',
32 'UUID',
36 // Date/Time
37 'DATE and TIME' => array(
38 'DATE',
39 'DATETIME',
40 'TIMESTAMP',
41 'TIME',
44 // Text
45 'STRING' => array(
46 'VARCHAR',
47 'TEXT',
48 '-',
49 'VARBINARY',
50 'BLOB',
51 '-',
52 'ENUM',
56 if ($auto_column_types && PMA_MYSQL_INT_VERSION >= 20120130) {
57 $cfg['ColumnTypes']['STRING'][] = '-';
58 $cfg['ColumnTypes']['STRING'][] = 'IPV6';
60 unset($auto_column_types);
62 $cfg['AttributeTypes'] = !empty($cfg['AttributeTypes']) ? $cfg['AttributeTypes'] : array(
63 '',
64 'on update CURRENT_TIMESTAMP',
67 if ($cfg['ShowFunctionFields']) {
68 $cfg['RestrictColumnTypes'] = !empty($cfg['RestrictColumnTypes']) ? $cfg['RestrictColumnTypes'] : array(
69 'INTEGER' => 'FUNC_NUMBER',
70 'BIGINT' => 'FUNC_NUMBER',
71 'DECIMAL' => 'FUNC_NUMBER',
72 'DOUBLE' => 'FUNC_NUMBER',
73 'BOOLEAN' => 'FUNC_NUMBER',
74 'SERIAL' => 'FUNC_NUMBER',
76 'DATE' => 'FUNC_DATE',
77 'DATETIME' => 'FUNC_DATE',
78 'TIMESTAMP' => 'FUNC_DATE',
79 'TIME' => 'FUNC_DATE',
81 'VARCHAR' => 'FUNC_CHAR',
82 'TEXT' => 'FUNC_CHAR',
83 'VARBINARY' => 'FUNC_CHAR',
84 'BLOB' => 'FUNC_CHAR',
85 'UUID' => 'FUNC_UUID',
86 'ENUM' => '',
89 $restrict_functions = array(
90 'FUNC_CHAR' => array(
91 'BIN',
92 'CHAR',
93 'CURRENT_USER',
94 'COMPRESS',
95 'DATABASE',
96 'DAYNAME',
97 'HEX',
98 'LOAD_FILE',
99 'LOWER',
100 'LTRIM',
101 'MD5',
102 'MONTHNAME',
103 'QUOTE',
104 'REVERSE',
105 'RTRIM',
106 'SCHEMA',
107 'SPACE',
108 'TRIM',
109 'UNCOMPRESS',
110 'UNHEX',
111 'UPPER',
112 'USER',
113 'UUID',
114 'VERSION',
117 'FUNC_UUID' => array(
118 'UUID',
121 'FUNC_DATE' => array(
122 'CURRENT_DATE',
123 'CURRENT_TIME',
124 'DATE',
125 'FROM_DAYS',
126 'FROM_UNIXTIME',
127 'LAST_DAY',
128 'NOW',
129 'SYSDATE',
130 //'TIME', // https://bugs.launchpad.net/drizzle/+bug/804571
131 'TIMESTAMP',
132 'UTC_DATE',
133 'UTC_TIME',
134 'UTC_TIMESTAMP',
135 'YEAR',
138 'FUNC_NUMBER' => array(
139 'ABS',
140 'ACOS',
141 'ASCII',
142 'ASIN',
143 'ATAN',
144 'BIT_COUNT',
145 'CEILING',
146 'CHAR_LENGTH',
147 'CONNECTION_ID',
148 'COS',
149 'COT',
150 'CRC32',
151 'DAYOFMONTH',
152 'DAYOFWEEK',
153 'DAYOFYEAR',
154 'DEGREES',
155 'EXP',
156 'FLOOR',
157 'HOUR',
158 'LENGTH',
159 'LN',
160 'LOG',
161 'LOG2',
162 'LOG10',
163 'MICROSECOND',
164 'MINUTE',
165 'MONTH',
166 'OCT',
167 'ORD',
168 'PI',
169 'QUARTER',
170 'RADIANS',
171 'RAND',
172 'ROUND',
173 'SECOND',
174 'SIGN',
175 'SIN',
176 'SQRT',
177 'TAN',
178 'TO_DAYS',
179 'TIME_TO_SEC',
180 'UNCOMPRESSED_LENGTH',
181 'UNIX_TIMESTAMP',
182 //'WEEK', // same as TIME
183 'WEEKDAY',
184 'WEEKOFYEAR',
185 'YEARWEEK',
188 $cfg_default_restrict_funcs = empty($cfg['RestrictFunctions']);
189 if ($cfg_default_restrict_funcs) {
190 $cfg['RestrictFunctions'] = $restrict_functions;
193 if (empty($cfg['Functions'])) {
194 // build a list of functions based on $restrict_functions
195 $cfg['Functions'] = array();
196 foreach ($restrict_functions as $cat => $functions) {
197 $cfg['Functions'] = array_merge($cfg['Functions'], $functions);
200 // check for some functions known to be in modules
201 $functions = array(
202 'MYSQL_PASSWORD' => 'FUNC_CHAR',
203 'ROT13' => 'FUNC_CHAR',
205 // add new functions
206 $sql = "SELECT upper(plugin_name) f
207 FROM data_dictionary.plugins
208 WHERE plugin_name IN ('" . implode("','", array_keys($functions)) . "')
209 AND plugin_type = 'Function'
210 AND is_active";
211 $drizzle_functions = PMA_DBI_fetch_result($sql, 'f', 'f');
212 $cfg['Functions'] = array_merge($cfg['Functions'], $drizzle_functions);
213 if ($cfg_default_restrict_funcs) {
214 foreach ($drizzle_functions as $function) {
215 $category = $functions[$function];
216 $cfg['RestrictFunctions'][$category][] = $function;
218 foreach ($cfg['RestrictFunctions'] as &$v) {
219 sort($v);
221 unset($v);
224 sort($cfg['Functions']);
226 unset($restrict_functions);
227 } // end if
230 * This function returns datatypes descriptions.
232 * @return array Drizzle datatypes descriptions.
235 function PMA_supportedDataTypesDescriptions()
237 // if possible, for easy translation these strings should be the same as for MySQL
238 return array(
239 'INTEGER' => __('A 4-byte integer, range is -2,147,483,648 to 2,147,483,647'),
240 'BIGINT' => __('An 8-byte integer, range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807'),
241 '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)'),
242 'DOUBLE' => __("A system's default double-precision floating-point number"),
243 'BOOLEAN' => __('True or false'),
244 // Drizzle doesn't have UNSIGNED types
245 'SERIAL' => __('An alias for BIGINT NOT NULL AUTO_INCREMENT UNIQUE'),
246 'UUID' => __('Stores a Universally Unique Identifier (UUID)'),
247 'DATE' => sprintf(__("A date, supported range is '%s' to '%s'"), '0001-01-01', '9999-12-31'),
248 'DATETIME' => sprintf(__("A date and time combination, supported range is '%s' to '%s'"), '0001-01-01 00:00:0', '9999-12-31 23:59:59'),
249 'TIMESTAMP' => __("A timestamp, range is '0001-01-01 00:00:00' UTC to '9999-12-31 23:59:59' UTC; TIMESTAMP(6) can store microseconds"),
250 'TIME' => sprintf(__("A time, range is '%s' to '%s'"), '00:00:00', '23:59:59'),
251 'VARCHAR' => sprintf(__('A variable-length (%s) string, the effective maximum length is subject to the maximum row size'), '0-16,383'),
252 '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'),
253 'VARBINARY' => __('A variable-length (0-65,535) string, uses binary collation for all comparisons'),
254 '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'),
255 // there is no limit on ENUM length
256 'ENUM' => __("An enumeration, chosen from the list of defined values"),
258 } // end PMA_supportedDataTypesDescriptions()