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()
214 'MPOINTFROMTEXT', // MPointFromText()
215 'MPOINTFROMWKB', // MPointFromWKB()
216 'MPOLYFROMTEXT', // MPolyFromText()
217 'MPOLYFROMWKB', // MPolyFromWKB()
218 'MULTILINESTRING', // MultiLineString()
219 'MULTILINESTRINGFROMTEXT', // MultiLineStringFromText()
220 'MULTILINESTRINGFROMWKB', // MultiLineStringFromWKB()
221 'MULTIPOINT', // MultiPoint()
222 'MULTIPOINTFROMTEXT', // MultiPointFromText()
223 'MULTIPOINTFROMWKB', // MultiPointFromWKB()
224 'MULTIPOLYGON', // MultiPolygon()
225 'MULTIPOLYGONFROMTEXT', // MultiPolygonFromText()
226 'MULTIPOLYGONFROMWKB', // MultiPolygonFromWKB()
227 'NAME_CONST', // NAME_CONST()
230 'NUMGEOMETRIES', // NumGeometries() geometrycollection-property-functions.html
231 'NUMINTERIORRINGS', // NumInteriorRings() polygon-property-functions.html
232 'NUMPOINTS', // NumPoints() linestring-property-functions.html
237 'OVERLAPS', // Overlaps()
243 'POINTFROMTEXT', // PointFromText()
244 'POINTFROMWKB', // PointFromWKB()
245 'POINTN', // PointN() inestring-property-functions.html
246 'POINTONSURFACE', // PointOnSurface() multipolygon-property-functions.html
247 'POLYFROMTEXT', // PolyFromText()
248 'POLYFROMWKB', // PolyFromWKB()
249 'POLYGON', // Polygon()
250 'POLYGONFROMTEXT', // PolygonFromText()
251 'POLYGONFROMWKB', // PolygonFromWKB()
259 'RELATED', // Related()
262 'REPLACE', // string-functions.html
266 'ROW_COUNT', // information-functions.html
269 'SCHEMA', // information-functions.html
277 'SLEEP', // miscellaneous-functions.html
281 'SRID', // general-geometry-property-functions.html
282 'STARTPOINT', // StartPoint() linestring-property-functions.html
285 'STDDEV_POP', // group-by-functions.html
286 'STDDEV_SAMP', // group-by-functions.html
295 'SYMDIFFERENCE', // SymDifference()
306 'TOUCHES', // Touches()
309 'TRUNCATE', // mathematical-functions.html
311 'UNCOMPRESS', // string-functions.html
312 'UNCOMPRESSED_LENGTH', // string-functions.html
313 'UNHEX', // string-functions.html
316 'UPDATEXML', // UpdateXML() xml-functions.html
322 'UUID', // miscellaneous-functions.html
323 'VARIANCE', // group-by-functions.html
324 'VAR_POP', // group-by-functions.html
325 'VAR_SAMP', // group-by-functions.html
330 'WITHIN', // Within()
331 'X', // point-property-functions.html
332 'Y', // point-property-functions.html
337 * $PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name);
339 * @global integer MySQL attributes count
341 $PMA_SQPdata_function_name_cnt = 298;
345 $test_PMA_SQPdata_function_name = $PMA_SQPdata_function_name;
346 sort($PMA_SQPdata_function_name);
347 if ($PMA_SQPdata_function_name != $test_PMA_SQPdata_function_name) {
348 echo 'sort properly like this<pre>';
349 print_r($PMA_SQPdata_function_name);
355 * @global array MySQL attributes
357 $PMA_SQPdata_column_attrib = array (
362 'BERKELEYDB', // Engine alias BDB
364 'BLACKHOLE', // Engine
368 'FEDERATED', // Engine
370 'INNOBASE', // Engine alias InnoDB
371 'INNODB', // Engine InnoDB
374 'MEMORY', // Engine alias HEAP, but preferred
376 'MRG_ISAM', // Engine
377 'MRG_MYISAM', // Engine alias MERGE
378 'MYISAM', // Engine MyISAM
380 'NDB', // Engine alias NDBCLUSTER
381 'NDBCLUSTER', // Engine
390 * $PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib);
392 * @global integer MySQL attributes count
394 $PMA_SQPdata_column_attrib_cnt = 30;
397 * words that are reserved by MySQL and may not be used as identifiers without quotes
399 * @see http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
401 * @global array MySQL reserved words
403 $PMA_SQPdata_reserved_word = array (
496 'GEMINI_SPIN_RETRIES',
544 'MASTER_CONNECT_RETRY',
552 'MAX_CONNECTIONS_PER_HOUR',
553 'MAX_QUERIES_PER_HOUR',
555 'MAX_UPDATES_PER_HOUR',
556 'MAX_USER_CONNECTIONS',
569 // 'NO' is not allowed in SQL-99 but is allowed in MySQL
584 'PAGE', // 5.1-maria ?
635 'SOUNDS', // string-functions.html
643 'SQL_CALC_FOUND_ROWS',
647 'SQL_LOW_PRIORITY_UPDATES',
650 'SQL_QUOTE_SHOW_CREATE',
653 'SQL_SLAVE_SKIP_COUNTER',
672 'TRANSACTIONAL', // 5.1 ?
696 * $PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
698 * @global integer MySQL reserved words count
700 $PMA_SQPdata_reserved_word_cnt = 288;
702 * The previous array must be sorted so that the binary search work.
703 * Sometimes a word is not added in the correct order, so
704 * this debugging code shows the problem. The same should be
705 * done for all arrays.
708 $original = $PMA_SQPdata_reserved_word;
709 sort($PMA_SQPdata_reserved_word);
710 $difference = array_diff_assoc($original, $PMA_SQPdata_reserved_word);
712 print_r($difference);
715 print_r($PMA_SQPdata_reserved_word);
720 * words forbidden to be used as column or table name wihtout quotes
721 * as seen in http://dev.mysql.com/doc/mysql/en/reserved-words.html
723 * @global array MySQL forbidden words
725 $PMA_SQPdata_forbidden_word = array (
878 'GEOMETRYCOLLECTION',
955 'MASTER_CONNECT_RETRY',
970 'MAX_CONNECTIONS_PER_HOUR',
971 'MAX_QUERIES_PER_HOUR',
973 'MAX_UPDATES_PER_HOUR',
974 'MAX_USER_CONNECTIONS',
984 'MINUTE_MICROSECOND',
1008 'NO_WRITE_TO_BINLOG',
1051 'READ_WRITE', // 5.1
1089 'SECOND_MICROSECOND',
1116 'SQL_BUFFER_RESULT',
1118 'SQL_CALC_FOUND_ROWS',
1123 'SQL_TSI_FRAC_SECOND',
1211 * count($PMA_SQPdata_forbidden_word);
1213 * @global integer MySQL forbidden words count
1215 $PMA_SQPdata_forbidden_word_cnt = 483;
1218 * the MySQL column/data types
1220 * @see http://dev.mysql.com/doc/refman/5.1/en/data-types.html
1221 * @see http://dev.mysql.com/doc/refman/5.1/en/mysql-spatial-datatypes.html
1223 * @global array MySQL column types
1225 $PMA_SQPdata_column_type = array (
1231 'BOOLEAN', // numeric-type-overview.html
1243 'GEOMETRY', // spatial
1244 'GEOMETRYCOLLECTION', // spatial
1252 'LINESTRING', // spatial
1260 'MULTILINESTRING', // spatial
1261 'MULTIPOINT', // spatial
1262 'MULTIPOLYGON', // spatial
1266 'POLYGON', // spatial
1268 'SERIAL', // alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
1282 * $PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type);
1284 * @global integer MySQL column types count
1286 $PMA_SQPdata_column_type_cnt = 54;
1290 foreach ($GLOBALS as $n => $a) {
1291 echo is_array($a) ? $n . ': ' . count($a) . '<br />' : '';