Translation update done using Pootle.
[phpmyadmin.git] / libraries / data_drizzle.inc.php
blobf8b9dc94691df170b9b1c11f18074d16490cc692
1 <?php
2 /**
3 * Column types and functions supported by Drizzle
5 * @package PhpMyAdmin
6 */
8 $auto_column_types = empty($cfg['ColumnTypes']);
10 // VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
11 $cfg['ColumnTypes'] = !empty($cfg['ColumnTypes']) ? $cfg['ColumnTypes'] : array(
12 // most used
13 'INTEGER',
14 'VARCHAR',
15 'TEXT',
16 'DATE',
18 // numeric
19 'NUMERIC' => array(
20 'INTEGER',
21 'BIGINT',
22 '-',
23 'DECIMAL',
24 'DOUBLE',
25 '-',
26 'BOOLEAN',
27 'SERIAL',
28 'UUID',
32 // Date/Time
33 'DATE and TIME' => array(
34 'DATE',
35 'DATETIME',
36 'TIMESTAMP',
37 'TIME',
40 // Text
41 'STRING' => array(
42 'VARCHAR',
43 'TEXT',
44 '-',
45 'VARBINARY',
46 'BLOB',
47 '-',
48 'ENUM',
52 if ($auto_column_types && PMA_MYSQL_INT_VERSION >= 20120130) {
53 $cfg['ColumnTypes']['STRING'][] = '-';
54 $cfg['ColumnTypes']['STRING'][] = 'IPV6';
56 unset($auto_column_types);
58 $cfg['AttributeTypes'] = !empty($cfg['AttributeTypes']) ? $cfg['AttributeTypes'] : array(
59 '',
60 'on update CURRENT_TIMESTAMP',
63 if ($cfg['ShowFunctionFields']) {
64 $cfg['RestrictColumnTypes'] = !empty($cfg['RestrictColumnTypes']) ? $cfg['RestrictColumnTypes'] : array(
65 'INTEGER' => 'FUNC_NUMBER',
66 'BIGINT' => 'FUNC_NUMBER',
67 'DECIMAL' => 'FUNC_NUMBER',
68 'DOUBLE' => 'FUNC_NUMBER',
69 'BOOLEAN' => 'FUNC_NUMBER',
70 'SERIAL' => 'FUNC_NUMBER',
72 'DATE' => 'FUNC_DATE',
73 'DATETIME' => 'FUNC_DATE',
74 'TIMESTAMP' => 'FUNC_DATE',
75 'TIME' => 'FUNC_DATE',
77 'VARCHAR' => 'FUNC_CHAR',
78 'TEXT' => 'FUNC_CHAR',
79 'VARBINARY' => 'FUNC_CHAR',
80 'BLOB' => 'FUNC_CHAR',
81 'UUID' => 'FUNC_UUID',
82 'ENUM' => '',
85 $restrict_functions = array(
86 'FUNC_CHAR' => array(
87 'BIN',
88 'CHAR',
89 'CURRENT_USER',
90 'COMPRESS',
91 'DATABASE',
92 'DAYNAME',
93 'HEX',
94 'LOAD_FILE',
95 'LOWER',
96 'LTRIM',
97 'MD5',
98 'MONTHNAME',
99 'QUOTE',
100 'REVERSE',
101 'RTRIM',
102 'SCHEMA',
103 'SPACE',
104 'TRIM',
105 'UNCOMPRESS',
106 'UNHEX',
107 'UPPER',
108 'USER',
109 'UUID',
110 'VERSION',
113 'FUNC_UUID' => array(
114 'UUID',
117 'FUNC_DATE' => array(
118 'CURRENT_DATE',
119 'CURRENT_TIME',
120 'DATE',
121 'FROM_DAYS',
122 'FROM_UNIXTIME',
123 'LAST_DAY',
124 'NOW',
125 'SYSDATE',
126 //'TIME', // https://bugs.launchpad.net/drizzle/+bug/804571
127 'TIMESTAMP',
128 'UTC_DATE',
129 'UTC_TIME',
130 'UTC_TIMESTAMP',
131 'YEAR',
134 'FUNC_NUMBER' => array(
135 'ABS',
136 'ACOS',
137 'ASCII',
138 'ASIN',
139 'ATAN',
140 'BIT_COUNT',
141 'CEILING',
142 'CHAR_LENGTH',
143 'CONNECTION_ID',
144 'COS',
145 'COT',
146 'CRC32',
147 'DAYOFMONTH',
148 'DAYOFWEEK',
149 'DAYOFYEAR',
150 'DEGREES',
151 'EXP',
152 'FLOOR',
153 'HOUR',
154 'LENGTH',
155 'LN',
156 'LOG',
157 'LOG2',
158 'LOG10',
159 'MICROSECOND',
160 'MINUTE',
161 'MONTH',
162 'OCT',
163 'ORD',
164 'PI',
165 'QUARTER',
166 'RADIANS',
167 'RAND',
168 'ROUND',
169 'SECOND',
170 'SIGN',
171 'SIN',
172 'SQRT',
173 'TAN',
174 'TO_DAYS',
175 'TIME_TO_SEC',
176 'UNCOMPRESSED_LENGTH',
177 'UNIX_TIMESTAMP',
178 //'WEEK', // same as TIME
179 'WEEKDAY',
180 'WEEKOFYEAR',
181 'YEARWEEK',
184 $cfg_default_restrict_funcs = empty($cfg['RestrictFunctions']);
185 if ($cfg_default_restrict_funcs) {
186 $cfg['RestrictFunctions'] = $restrict_functions;
189 if (empty($cfg['Functions'])) {
190 // build a list of functions based on $restrict_functions
191 $cfg['Functions'] = array();
192 foreach ($restrict_functions as $cat => $functions) {
193 $cfg['Functions'] = array_merge($cfg['Functions'], $functions);
196 // check for some functions known to be in modules
197 $functions = array(
198 'MYSQL_PASSWORD' => 'FUNC_CHAR',
199 'ROT13' => 'FUNC_CHAR',
201 // add new functions
202 $sql = "SELECT upper(plugin_name) f
203 FROM data_dictionary.plugins
204 WHERE plugin_name IN ('" . implode("','", array_keys($functions)) . "')
205 AND plugin_type = 'Function'
206 AND is_active";
207 $drizzle_functions = PMA_DBI_fetch_result($sql, 'f', 'f');
208 $cfg['Functions'] = array_merge($cfg['Functions'], $drizzle_functions);
209 if ($cfg_default_restrict_funcs) {
210 foreach ($drizzle_functions as $function) {
211 $category = $functions[$function];
212 $cfg['RestrictFunctions'][$category][] = $function;
214 foreach ($cfg['RestrictFunctions'] as &$v) {
215 sort($v);
217 unset($v);
220 sort($cfg['Functions']);
222 unset($restrict_functions);
223 } // end if