2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * SQL Parser Matching Data
6 * Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
7 * http://www.orbis-terrarum.net/?l=people.robbat2
9 * This data is used by the SQL Parser to recognize keywords
11 * It has been extracted from the lex.h file in the MySQL BK tree
12 * (around 4.0.2) as well as the MySQL documentation.
14 * Note: before adding a value in the arrays, ensure that you respect
15 * proper sorting, especially with underscores. And don't forget to
16 * update the _cnt variable at the end of each array.
17 * (It's slower to have PHP do the count).
19 * It's easier to use only uppercase for proper sorting. In case of
20 * doubt, use the DEBUG code after this function's definition.
25 if (! defined('PHPMYADMIN')) {
29 if (! isset($GLOBALS['sql_delimiter'])) {
30 $GLOBALS['sql_delimiter'] = ';';
34 * @global array MySQL function names
36 $PMA_SQPdata_function_name = array (
43 'AREA', // Area() polygon-property-functions.html
44 'ASBINARY', // AsBinary()
51 'BDMPOLYFROMTEXT', // BdMPolyFromText()
52 'BDMPOLYFROMWKB', // BdMPolyFromWKB()
53 'BDPOLYFROMTEXT', // BdPolyFromText()
54 'BDPOLYFROMWKB', // BdPolyFromWKB()
61 'BIT_XOR', // group-by-functions.html
62 'BOUNDARY', // Boundary() general-geometry-property-functions.html
67 'CENTROID', // Centroid() multipolygon-property-functions.html
68 'CHAR', // string-functions.html
70 'CHARSET', // information-functions.html
73 'COERCIBILITY', // information-functions.html
74 'COLLATION', // information-functions.html
75 'COMPRESS', // string-functions.html
79 'CONTAINS', // Contains()
83 'CONVEXHULL', // ConvexHull()
87 'CRC32', // mathematical-functions.html
88 'CROSSES', // Crosses()
96 'DATE', // date-and-time-functions.html
97 'DATEDIFF', // date-and-time-functions.html
108 'DEFAULT', // miscellaneous-functions.html
112 'DIFFERENCE', // Difference()
113 'DIMENSION', // Dimension() general-geometry-property-functions.html
114 'DISJOINT', // Disjoint()
115 'DISTANCE', // Distance()
119 'ENDPOINT', // EndPoint() linestring-property-functions.html
120 'ENVELOPE', // Envelope() general-geometry-property-functions.html
121 'EQUALS', // Equals()
124 'EXTERIORRING', // ExteriorRing() polygon-property-functions.html
126 'EXTRACTVALUE', // ExtractValue() xml-functions.html
134 'GEOMCOLLFROMTEXT', // GeomCollFromText()
135 'GEOMCOLLFROMWKB', // GeomCollFromWKB()
136 'GEOMETRYCOLLECTION', // GeometryCollection()
137 'GEOMETRYCOLLECTIONFROMTEXT', // GeometryCollectionFromText()
138 'GEOMETRYCOLLECTIONFROMWKB', // GeometryCollectionFromWKB()
139 'GEOMETRYFROMTEXT', // GeometryFromText()
140 'GEOMETRYFROMWKB', // GeometryFromWKB()
141 'GEOMETRYN', // GeometryN() geometrycollection-property-functions.html
142 'GEOMETRYTYPE', // GeometryType() general-geometry-property-functions.html
143 'GEOMFROMTEXT', // GeomFromText()
144 'GEOMFROMWKB', // GeomFromWKB()
147 'GLENGTH', // GLength() linestring-property-functions.html
150 'GROUP_UNIQUE_USERS',
153 'IF', //control-flow-functions.html
157 'INSERT', // string-functions.html
159 'INTERIORRINGN', // InteriorRingN() polygon-property-functions.html
160 'INTERSECTION', // Intersection()
161 'INTERSECTS', // Intersects()
163 'ISCLOSED', // IsClosed() multilinestring-property-functions.html
164 'ISEMPTY', // IsEmpty() general-geometry-property-functions.html
166 'ISRING', // IsRing() linestring-property-functions.html
167 'ISSIMPLE', // IsSimple() general-geometry-property-functions.html
169 'IS_USED_LOCK', // miscellaneous-functions.html
176 'LINEFROMTEXT', // LineFromText()
177 'LINEFROMWKB', // LineFromWKB()
178 'LINESTRING', // LineString()
179 'LINESTRINGFROMTEXT', // LineStringFromText()
180 'LINESTRINGFROMWKB', // LineStringFromWKB()
197 'MBRCONTAINS', // MBRContains()
198 'MBRDISJOINT', // MBRDisjoint()
199 'MBREQUAL', // MBREqual()
200 'MBRINTERSECTS', // MBRIntersects()
201 'MBROVERLAPS', // MBROverlaps()
202 'MBRTOUCHES', // MBRTouches()
203 'MBRWITHIN', // MBRWithin()
209 'MLINEFROMTEXT', // MLineFromText()
210 'MLINEFROMWKB', // MLineFromWKB()
215 'MPOINTFROMTEXT', // MPointFromText()
216 'MPOINTFROMWKB', // MPointFromWKB()
217 'MPOLYFROMTEXT', // MPolyFromText()
218 'MPOLYFROMWKB', // MPolyFromWKB()
219 'MULTILINESTRING', // MultiLineString()
220 'MULTILINESTRINGFROMTEXT', // MultiLineStringFromText()
221 'MULTILINESTRINGFROMWKB', // MultiLineStringFromWKB()
222 'MULTIPOINT', // MultiPoint()
223 'MULTIPOINTFROMTEXT', // MultiPointFromText()
224 'MULTIPOINTFROMWKB', // MultiPointFromWKB()
225 'MULTIPOLYGON', // MultiPolygon()
226 'MULTIPOLYGONFROMTEXT', // MultiPolygonFromText()
227 'MULTIPOLYGONFROMWKB', // MultiPolygonFromWKB()
228 'NAME_CONST', // NAME_CONST()
231 'NUMGEOMETRIES', // NumGeometries() geometrycollection-property-functions.html
232 'NUMINTERIORRINGS', // NumInteriorRings() polygon-property-functions.html
233 'NUMPOINTS', // NumPoints() linestring-property-functions.html
238 'OVERLAPS', // Overlaps()
244 'POINTFROMTEXT', // PointFromText()
245 'POINTFROMWKB', // PointFromWKB()
246 'POINTN', // PointN() inestring-property-functions.html
247 'POINTONSURFACE', // PointOnSurface() multipolygon-property-functions.html
248 'POLYFROMTEXT', // PolyFromText()
249 'POLYFROMWKB', // PolyFromWKB()
250 'POLYGON', // Polygon()
251 'POLYGONFROMTEXT', // PolygonFromText()
252 'POLYGONFROMWKB', // PolygonFromWKB()
260 'RELATED', // Related()
263 'REPLACE', // string-functions.html
267 'ROW_COUNT', // information-functions.html
270 'SCHEMA', // information-functions.html
278 'SLEEP', // miscellaneous-functions.html
282 'SRID', // general-geometry-property-functions.html
283 'STARTPOINT', // StartPoint() linestring-property-functions.html
286 'STDDEV_POP', // group-by-functions.html
287 'STDDEV_SAMP', // group-by-functions.html
296 'SYMDIFFERENCE', // SymDifference()
307 'TOUCHES', // Touches()
310 'TRUNCATE', // mathematical-functions.html
312 'UNCOMPRESS', // string-functions.html
313 'UNCOMPRESSED_LENGTH', // string-functions.html
314 'UNHEX', // string-functions.html
317 'UPDATEXML', // UpdateXML() xml-functions.html
323 'UUID', // miscellaneous-functions.html
324 'VARIANCE', // group-by-functions.html
325 'VAR_POP', // group-by-functions.html
326 'VAR_SAMP', // group-by-functions.html
331 'WITHIN', // Within()
332 'X', // point-property-functions.html
333 'Y', // point-property-functions.html
338 * $PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name);
340 * @global integer MySQL attributes count
342 $PMA_SQPdata_function_name_cnt = 299;
346 $test_PMA_SQPdata_function_name = $PMA_SQPdata_function_name;
347 sort($PMA_SQPdata_function_name);
348 if ($PMA_SQPdata_function_name != $test_PMA_SQPdata_function_name) {
349 echo 'sort properly like this<pre>';
350 print_r($PMA_SQPdata_function_name);
356 * @global array MySQL attributes
358 $PMA_SQPdata_column_attrib = array (
363 'BERKELEYDB', // Engine alias BDB
365 'BLACKHOLE', // Engine
369 'FEDERATED', // Engine
371 'INNOBASE', // Engine alias InnoDB
372 'INNODB', // Engine InnoDB
375 'MEMORY', // Engine alias HEAP, but preferred
377 'MRG_ISAM', // Engine
378 'MRG_MYISAM', // Engine alias MERGE
379 'MYISAM', // Engine MyISAM
381 'NDB', // Engine alias NDBCLUSTER
382 'NDBCLUSTER', // Engine
391 * $PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib);
393 * @global integer MySQL attributes count
395 $PMA_SQPdata_column_attrib_cnt = 30;
398 * words that are reserved by MySQL and may not be used as identifiers without quotes
400 * @see http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
402 * @global array MySQL reserved words
404 $PMA_SQPdata_reserved_word = array (
498 'GEMINI_SPIN_RETRIES',
546 'MASTER_CONNECT_RETRY',
554 'MAX_CONNECTIONS_PER_HOUR',
555 'MAX_QUERIES_PER_HOUR',
557 'MAX_UPDATES_PER_HOUR',
558 'MAX_USER_CONNECTIONS',
571 // 'NO' is not allowed in SQL-99 but is allowed in MySQL
586 'PAGE', // 5.1-maria ?
637 'SOUNDS', // string-functions.html
645 'SQL_CALC_FOUND_ROWS',
649 'SQL_LOW_PRIORITY_UPDATES',
652 'SQL_QUOTE_SHOW_CREATE',
655 'SQL_SLAVE_SKIP_COUNTER',
674 'TRANSACTIONAL', // 5.1 ?
698 * $PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
700 * @global integer MySQL reserved words count
702 $PMA_SQPdata_reserved_word_cnt = 289;
704 * The previous array must be sorted so that the binary search work.
705 * Sometimes a word is not added in the correct order, so
706 * this debugging code shows the problem. The same should be
707 * done for all arrays.
710 $original = $PMA_SQPdata_reserved_word;
711 sort($PMA_SQPdata_reserved_word);
712 $difference = array_diff_assoc($original, $PMA_SQPdata_reserved_word);
714 print_r($difference);
717 print_r($PMA_SQPdata_reserved_word);
722 * words forbidden to be used as column or table name wihtout quotes
723 * as seen in http://dev.mysql.com/doc/mysql/en/reserved-words.html
725 * @global array MySQL forbidden words
727 $PMA_SQPdata_forbidden_word = array (
880 'GEOMETRYCOLLECTION',
957 'MASTER_CONNECT_RETRY',
972 'MAX_CONNECTIONS_PER_HOUR',
973 'MAX_QUERIES_PER_HOUR',
975 'MAX_UPDATES_PER_HOUR',
976 'MAX_USER_CONNECTIONS',
986 'MINUTE_MICROSECOND',
1010 'NO_WRITE_TO_BINLOG',
1052 'READ_WRITE', // 5.1
1091 'SECOND_MICROSECOND',
1118 'SQL_BUFFER_RESULT',
1120 'SQL_CALC_FOUND_ROWS',
1125 'SQL_TSI_FRAC_SECOND',
1213 * count($PMA_SQPdata_forbidden_word);
1215 * @global integer MySQL forbidden words count
1217 $PMA_SQPdata_forbidden_word_cnt = 483;
1220 * the MySQL column/data types
1222 * @see http://dev.mysql.com/doc/refman/5.1/en/data-types.html
1223 * @see http://dev.mysql.com/doc/refman/5.1/en/mysql-spatial-datatypes.html
1225 * @global array MySQL column types
1227 $PMA_SQPdata_column_type = array (
1233 'BOOLEAN', // numeric-type-overview.html
1245 'GEOMETRY', // spatial
1246 'GEOMETRYCOLLECTION', // spatial
1254 'LINESTRING', // spatial
1262 'MULTILINESTRING', // spatial
1263 'MULTIPOINT', // spatial
1264 'MULTIPOLYGON', // spatial
1268 'POLYGON', // spatial
1270 'SERIAL', // alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
1284 * $PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type);
1286 * @global integer MySQL column types count
1288 $PMA_SQPdata_column_type_cnt = 54;
1292 foreach ($GLOBALS as $n => $a) {
1293 echo is_array($a) ? $n . ': ' . count($a) . '<br />' : '';