1"""
2 pygments.lexers._mysql_builtins
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
5 Self-updating data files for the MySQL lexer.
6
7 Run with `python -I` to update.
8
9 :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
10 :license: BSD, see LICENSE for details.
11"""
12
13
14MYSQL_CONSTANTS = (
15 'false',
16 'null',
17 'true',
18 'unknown',
19)
20
21
22# At this time, no easily-parsed, definitive list of data types
23# has been found in the MySQL source code or documentation. (The
24# `sql/sql_yacc.yy` file is definitive but is difficult to parse.)
25# Therefore these types are currently maintained manually.
26#
27# Some words in this list -- like "long", "national", "precision",
28# and "varying" -- appear to only occur in combination with other
29# data type keywords. Therefore they are included as separate words
30# even though they do not naturally occur in syntax separately.
31#
32# This list is also used to strip data types out of the list of
33# MySQL keywords, which is automatically updated later in the file.
34#
35# For future updates, these pages may be helpful references
36# when looking for additional data types and aliases:
37#
38# https://dev.mysql.com/doc/refman/9.4/en/data-types.html
39# https://dev.mysql.com/doc/refman/9.4/en/other-vendor-data-types.html
40#
41MYSQL_DATATYPES = (
42 # Numeric data types
43 'bigint',
44 'bit',
45 'bool',
46 'boolean',
47 'dec',
48 'decimal',
49 'double',
50 'fixed',
51 'float',
52 'float4',
53 'float8',
54 'int',
55 'int1',
56 'int2',
57 'int3',
58 'int4',
59 'int8',
60 'integer',
61 'mediumint',
62 'middleint',
63 'numeric',
64 'precision',
65 'real',
66 'serial',
67 'smallint',
68 'tinyint',
69
70 # Date and time data types
71 'date',
72 'datetime',
73 'time',
74 'timestamp',
75 'year',
76
77 # String data types
78 'binary',
79 'blob',
80 'byte',
81 'char',
82 'enum',
83 'long',
84 'longblob',
85 'longtext',
86 'mediumblob',
87 'mediumtext',
88 'national',
89 'nchar',
90 'nvarchar',
91 'set',
92 'text',
93 'tinyblob',
94 'tinytext',
95 'varbinary',
96 'varchar',
97 'varcharacter',
98 'varying',
99
100 # Spatial data types
101 'geometry',
102 'geometrycollection',
103 'linestring',
104 'multilinestring',
105 'multipoint',
106 'multipolygon',
107 'point',
108 'polygon',
109
110 # JSON data types
111 'json',
112)
113
114# Everything below this line is auto-generated from the MySQL source code.
115# Run this file in Python and it will update itself.
116# -----------------------------------------------------------------------------
117
118MYSQL_FUNCTIONS = (
119 'abs',
120 'acos',
121 'adddate',
122 'addtime',
123 'aes_decrypt',
124 'aes_encrypt',
125 'any_value',
126 'asin',
127 'atan',
128 'atan2',
129 'benchmark',
130 'bin',
131 'bin_to_uuid',
132 'bit_and',
133 'bit_count',
134 'bit_length',
135 'bit_or',
136 'bit_xor',
137 'can_access_column',
138 'can_access_database',
139 'can_access_event',
140 'can_access_resource_group',
141 'can_access_routine',
142 'can_access_table',
143 'can_access_trigger',
144 'can_access_user',
145 'can_access_view',
146 'cast',
147 'ceil',
148 'ceiling',
149 'char_length',
150 'character_length',
151 'coercibility',
152 'compress',
153 'concat',
154 'concat_ws',
155 'connection_id',
156 'conv',
157 'convert_cpu_id_mask',
158 'convert_interval_to_user_interval',
159 'convert_tz',
160 'cos',
161 'cot',
162 'count',
163 'crc32',
164 'curdate',
165 'current_role',
166 'curtime',
167 'date_add',
168 'date_format',
169 'date_sub',
170 'datediff',
171 'dayname',
172 'dayofmonth',
173 'dayofweek',
174 'dayofyear',
175 'degrees',
176 'elt',
177 'etag',
178 'exp',
179 'export_set',
180 'extract',
181 'extractvalue',
182 'field',
183 'find_in_set',
184 'floor',
185 'format_bytes',
186 'format_pico_time',
187 'found_rows',
188 'from_base64',
189 'from_days',
190 'from_unixtime',
191 'from_vector',
192 'get_dd_column_privileges',
193 'get_dd_create_options',
194 'get_dd_index_private_data',
195 'get_dd_index_sub_part_length',
196 'get_dd_property_key_value',
197 'get_dd_schema_options',
198 'get_dd_tablespace_private_data',
199 'get_jdv_property_key_value',
200 'get_lock',
201 'greatest',
202 'group_concat',
203 'gtid_subset',
204 'gtid_subtract',
205 'hex',
206 'icu_version',
207 'ifnull',
208 'inet6_aton',
209 'inet6_ntoa',
210 'inet_aton',
211 'inet_ntoa',
212 'instr',
213 'internal_auto_increment',
214 'internal_avg_row_length',
215 'internal_check_time',
216 'internal_checksum',
217 'internal_data_free',
218 'internal_data_length',
219 'internal_dd_char_length',
220 'internal_get_comment_or_error',
221 'internal_get_dd_column_extra',
222 'internal_get_enabled_role_json',
223 'internal_get_hostname',
224 'internal_get_mandatory_roles_json',
225 'internal_get_partition_nodegroup',
226 'internal_get_username',
227 'internal_get_view_warning_or_error',
228 'internal_index_column_cardinality',
229 'internal_index_length',
230 'internal_is_enabled_role',
231 'internal_is_mandatory_role',
232 'internal_keys_disabled',
233 'internal_max_data_length',
234 'internal_table_rows',
235 'internal_tablespace_autoextend_size',
236 'internal_tablespace_data_free',
237 'internal_tablespace_extent_size',
238 'internal_tablespace_extra',
239 'internal_tablespace_free_extents',
240 'internal_tablespace_id',
241 'internal_tablespace_initial_size',
242 'internal_tablespace_logfile_group_name',
243 'internal_tablespace_logfile_group_number',
244 'internal_tablespace_maximum_size',
245 'internal_tablespace_row_format',
246 'internal_tablespace_status',
247 'internal_tablespace_total_extents',
248 'internal_tablespace_type',
249 'internal_tablespace_version',
250 'internal_update_time',
251 'internal_use_terminology_previous',
252 'is_free_lock',
253 'is_ipv4',
254 'is_ipv4_compat',
255 'is_ipv4_mapped',
256 'is_ipv6',
257 'is_used_lock',
258 'is_uuid',
259 'is_visible_dd_object',
260 'isnull',
261 'json_array',
262 'json_array_append',
263 'json_array_insert',
264 'json_arrayagg',
265 'json_contains',
266 'json_contains_path',
267 'json_depth',
268 'json_duality_object',
269 'json_extract',
270 'json_insert',
271 'json_keys',
272 'json_length',
273 'json_merge',
274 'json_merge_patch',
275 'json_merge_preserve',
276 'json_object',
277 'json_objectagg',
278 'json_overlaps',
279 'json_pretty',
280 'json_quote',
281 'json_remove',
282 'json_replace',
283 'json_schema_valid',
284 'json_schema_validation_report',
285 'json_search',
286 'json_set',
287 'json_storage_free',
288 'json_storage_size',
289 'json_type',
290 'json_unquote',
291 'json_valid',
292 'last_day',
293 'last_insert_id',
294 'lcase',
295 'least',
296 'length',
297 'like_range_max',
298 'like_range_min',
299 'ln',
300 'load_file',
301 'locate',
302 'log',
303 'log10',
304 'log2',
305 'lower',
306 'lpad',
307 'ltrim',
308 'make_set',
309 'makedate',
310 'maketime',
311 'master_pos_wait',
312 'max',
313 'mbrcontains',
314 'mbrcoveredby',
315 'mbrcovers',
316 'mbrdisjoint',
317 'mbrequals',
318 'mbrintersects',
319 'mbroverlaps',
320 'mbrtouches',
321 'mbrwithin',
322 'md5',
323 'mid',
324 'min',
325 'monthname',
326 'name_const',
327 'now',
328 'nullif',
329 'oct',
330 'octet_length',
331 'ord',
332 'period_add',
333 'period_diff',
334 'pi',
335 'position',
336 'pow',
337 'power',
338 'ps_current_thread_id',
339 'ps_thread_id',
340 'quote',
341 'radians',
342 'rand',
343 'random_bytes',
344 'regexp_instr',
345 'regexp_like',
346 'regexp_replace',
347 'regexp_substr',
348 'release_all_locks',
349 'release_lock',
350 'remove_dd_property_key',
351 'reverse',
352 'roles_graphml',
353 'round',
354 'rpad',
355 'rtrim',
356 'sec_to_time',
357 'session_user',
358 'sha',
359 'sha1',
360 'sha2',
361 'sign',
362 'sin',
363 'sleep',
364 'soundex',
365 'source_pos_wait',
366 'space',
367 'sqrt',
368 'st_area',
369 'st_asbinary',
370 'st_asgeojson',
371 'st_astext',
372 'st_aswkb',
373 'st_aswkt',
374 'st_buffer',
375 'st_buffer_strategy',
376 'st_centroid',
377 'st_collect',
378 'st_contains',
379 'st_convexhull',
380 'st_crosses',
381 'st_difference',
382 'st_dimension',
383 'st_disjoint',
384 'st_distance',
385 'st_distance_sphere',
386 'st_endpoint',
387 'st_envelope',
388 'st_equals',
389 'st_exteriorring',
390 'st_frechetdistance',
391 'st_geohash',
392 'st_geomcollfromtext',
393 'st_geomcollfromtxt',
394 'st_geomcollfromwkb',
395 'st_geometrycollectionfromtext',
396 'st_geometrycollectionfromwkb',
397 'st_geometryfromtext',
398 'st_geometryfromwkb',
399 'st_geometryn',
400 'st_geometrytype',
401 'st_geomfromgeojson',
402 'st_geomfromtext',
403 'st_geomfromwkb',
404 'st_hausdorffdistance',
405 'st_interiorringn',
406 'st_intersection',
407 'st_intersects',
408 'st_isclosed',
409 'st_isempty',
410 'st_issimple',
411 'st_isvalid',
412 'st_latfromgeohash',
413 'st_latitude',
414 'st_length',
415 'st_linefromtext',
416 'st_linefromwkb',
417 'st_lineinterpolatepoint',
418 'st_lineinterpolatepoints',
419 'st_linestringfromtext',
420 'st_linestringfromwkb',
421 'st_longfromgeohash',
422 'st_longitude',
423 'st_makeenvelope',
424 'st_mlinefromtext',
425 'st_mlinefromwkb',
426 'st_mpointfromtext',
427 'st_mpointfromwkb',
428 'st_mpolyfromtext',
429 'st_mpolyfromwkb',
430 'st_multilinestringfromtext',
431 'st_multilinestringfromwkb',
432 'st_multipointfromtext',
433 'st_multipointfromwkb',
434 'st_multipolygonfromtext',
435 'st_multipolygonfromwkb',
436 'st_numgeometries',
437 'st_numinteriorring',
438 'st_numinteriorrings',
439 'st_numpoints',
440 'st_overlaps',
441 'st_pointatdistance',
442 'st_pointfromgeohash',
443 'st_pointfromtext',
444 'st_pointfromwkb',
445 'st_pointn',
446 'st_polyfromtext',
447 'st_polyfromwkb',
448 'st_polygonfromtext',
449 'st_polygonfromwkb',
450 'st_simplify',
451 'st_srid',
452 'st_startpoint',
453 'st_swapxy',
454 'st_symdifference',
455 'st_touches',
456 'st_transform',
457 'st_union',
458 'st_validate',
459 'st_within',
460 'st_x',
461 'st_y',
462 'statement_digest',
463 'statement_digest_text',
464 'std',
465 'stddev',
466 'stddev_pop',
467 'stddev_samp',
468 'str_to_date',
469 'strcmp',
470 'string_to_vector',
471 'subdate',
472 'substr',
473 'substring',
474 'substring_index',
475 'subtime',
476 'sum',
477 'sysdate',
478 'system_user',
479 'tan',
480 'time_format',
481 'time_to_sec',
482 'timediff',
483 'to_base64',
484 'to_days',
485 'to_seconds',
486 'to_vector',
487 'trim',
488 'ucase',
489 'uncompress',
490 'uncompressed_length',
491 'unhex',
492 'unix_timestamp',
493 'updatexml',
494 'upper',
495 'uuid',
496 'uuid_short',
497 'uuid_to_bin',
498 'validate_password_strength',
499 'var_pop',
500 'var_samp',
501 'variance',
502 'vector_dim',
503 'vector_to_string',
504 'version',
505 'wait_for_executed_gtid_set',
506 'wait_until_sql_thread_after_gtids',
507 'weekday',
508 'weekofyear',
509 'yearweek',
510)
511
512
513MYSQL_OPTIMIZER_HINTS = (
514 'bka',
515 'bnl',
516 'derived_condition_pushdown',
517 'dupsweedout',
518 'firstmatch',
519 'group_index',
520 'hash_join',
521 'index',
522 'index_merge',
523 'intoexists',
524 'join_fixed_order',
525 'join_index',
526 'join_order',
527 'join_prefix',
528 'join_suffix',
529 'loosescan',
530 'materialization',
531 'max_execution_time',
532 'merge',
533 'mrr',
534 'no_bka',
535 'no_bnl',
536 'no_derived_condition_pushdown',
537 'no_group_index',
538 'no_hash_join',
539 'no_icp',
540 'no_index',
541 'no_index_merge',
542 'no_join_index',
543 'no_merge',
544 'no_mrr',
545 'no_order_index',
546 'no_range_optimization',
547 'no_semijoin',
548 'no_skip_scan',
549 'order_index',
550 'qb_name',
551 'resource_group',
552 'semijoin',
553 'set_var',
554 'skip_scan',
555 'subquery',
556)
557
558
559MYSQL_KEYWORDS = (
560 'absent',
561 'accessible',
562 'account',
563 'action',
564 'active',
565 'add',
566 'admin',
567 'after',
568 'against',
569 'aggregate',
570 'algorithm',
571 'all',
572 'allow_missing_files',
573 'alter',
574 'always',
575 'analyze',
576 'and',
577 'any',
578 'array',
579 'as',
580 'asc',
581 'ascii',
582 'asensitive',
583 'assign_gtids_to_anonymous_transactions',
584 'at',
585 'attribute',
586 'authentication',
587 'auto',
588 'auto_increment',
589 'auto_refresh',
590 'auto_refresh_source',
591 'autoextend_size',
592 'avg',
593 'avg_row_length',
594 'backup',
595 'before',
596 'begin',
597 'bernoulli',
598 'between',
599 'binlog',
600 'block',
601 'both',
602 'btree',
603 'buckets',
604 'bulk',
605 'by',
606 'cache',
607 'call',
608 'cascade',
609 'cascaded',
610 'case',
611 'catalog_name',
612 'chain',
613 'challenge_response',
614 'change',
615 'changed',
616 'channel',
617 'character',
618 'charset',
619 'check',
620 'checksum',
621 'cipher',
622 'class_origin',
623 'client',
624 'clone',
625 'close',
626 'coalesce',
627 'code',
628 'collate',
629 'collation',
630 'column',
631 'column_format',
632 'column_name',
633 'columns',
634 'comment',
635 'commit',
636 'committed',
637 'compact',
638 'completion',
639 'component',
640 'compressed',
641 'compression',
642 'concurrent',
643 'condition',
644 'connection',
645 'consistent',
646 'constraint',
647 'constraint_catalog',
648 'constraint_name',
649 'constraint_schema',
650 'contains',
651 'context',
652 'continue',
653 'convert',
654 'cpu',
655 'create',
656 'cross',
657 'cube',
658 'cume_dist',
659 'current',
660 'current_date',
661 'current_time',
662 'current_timestamp',
663 'current_user',
664 'cursor',
665 'cursor_name',
666 'data',
667 'database',
668 'databases',
669 'datafile',
670 'day',
671 'day_hour',
672 'day_microsecond',
673 'day_minute',
674 'day_second',
675 'deallocate',
676 'declare',
677 'default',
678 'default_auth',
679 'definer',
680 'definition',
681 'delay_key_write',
682 'delayed',
683 'delete',
684 'dense_rank',
685 'desc',
686 'describe',
687 'description',
688 'deterministic',
689 'diagnostics',
690 'directory',
691 'disable',
692 'discard',
693 'disk',
694 'distinct',
695 'distinctrow',
696 'div',
697 'do',
698 'drop',
699 'dual',
700 'duality',
701 'dumpfile',
702 'duplicate',
703 'dynamic',
704 'each',
705 'else',
706 'elseif',
707 'empty',
708 'enable',
709 'enclosed',
710 'encryption',
711 'end',
712 'ends',
713 'enforced',
714 'engine',
715 'engine_attribute',
716 'engines',
717 'error',
718 'errors',
719 'escape',
720 'escaped',
721 'event',
722 'events',
723 'every',
724 'except',
725 'exchange',
726 'exclude',
727 'execute',
728 'exists',
729 'exit',
730 'expansion',
731 'expire',
732 'explain',
733 'export',
734 'extended',
735 'extent_size',
736 'external',
737 'external_format',
738 'factor',
739 'failed_login_attempts',
740 'false',
741 'fast',
742 'faults',
743 'fetch',
744 'fields',
745 'file',
746 'file_block_size',
747 'file_format',
748 'file_name',
749 'file_pattern',
750 'file_prefix',
751 'files',
752 'filter',
753 'finish',
754 'first',
755 'first_value',
756 'flush',
757 'following',
758 'follows',
759 'for',
760 'force',
761 'foreign',
762 'format',
763 'found',
764 'from',
765 'full',
766 'fulltext',
767 'function',
768 'general',
769 'generate',
770 'generated',
771 'geomcollection',
772 'get',
773 'get_format',
774 'get_master_public_key',
775 'get_source_public_key',
776 'global',
777 'grant',
778 'grants',
779 'group',
780 'group_replication',
781 'grouping',
782 'groups',
783 'gtid_only',
784 'gtids',
785 'handler',
786 'hash',
787 'having',
788 'header',
789 'help',
790 'high_priority',
791 'histogram',
792 'history',
793 'host',
794 'hosts',
795 'hour',
796 'hour_microsecond',
797 'hour_minute',
798 'hour_second',
799 'identified',
800 'if',
801 'ignore',
802 'ignore_server_ids',
803 'import',
804 'in',
805 'inactive',
806 'index',
807 'indexes',
808 'infile',
809 'initial',
810 'initial_size',
811 'initiate',
812 'inner',
813 'inout',
814 'insensitive',
815 'insert',
816 'insert_method',
817 'install',
818 'instance',
819 'intersect',
820 'interval',
821 'into',
822 'invisible',
823 'invoker',
824 'io',
825 'io_after_gtids',
826 'io_before_gtids',
827 'io_thread',
828 'ipc',
829 'is',
830 'isolation',
831 'issuer',
832 'iterate',
833 'join',
834 'json_table',
835 'json_value',
836 'key',
837 'key_block_size',
838 'keyring',
839 'keys',
840 'kill',
841 'lag',
842 'language',
843 'last',
844 'last_value',
845 'lateral',
846 'lead',
847 'leading',
848 'leave',
849 'leaves',
850 'left',
851 'less',
852 'level',
853 'library',
854 'like',
855 'limit',
856 'linear',
857 'lines',
858 'list',
859 'load',
860 'local',
861 'localtime',
862 'localtimestamp',
863 'lock',
864 'locked',
865 'locks',
866 'log',
867 'logfile',
868 'logs',
869 'loop',
870 'low_priority',
871 'manual',
872 'master',
873 'master_auto_position',
874 'master_bind',
875 'master_compression_algorithms',
876 'master_connect_retry',
877 'master_delay',
878 'master_heartbeat_period',
879 'master_host',
880 'master_log_file',
881 'master_log_pos',
882 'master_password',
883 'master_port',
884 'master_public_key_path',
885 'master_retry_count',
886 'master_ssl',
887 'master_ssl_ca',
888 'master_ssl_capath',
889 'master_ssl_cert',
890 'master_ssl_cipher',
891 'master_ssl_crl',
892 'master_ssl_crlpath',
893 'master_ssl_key',
894 'master_ssl_verify_server_cert',
895 'master_tls_ciphersuites',
896 'master_tls_version',
897 'master_user',
898 'master_zstd_compression_level',
899 'match',
900 'max_connections_per_hour',
901 'max_queries_per_hour',
902 'max_rows',
903 'max_size',
904 'max_updates_per_hour',
905 'max_user_connections',
906 'maxvalue',
907 'medium',
908 'member',
909 'memory',
910 'merge',
911 'message_text',
912 'microsecond',
913 'migrate',
914 'min_rows',
915 'minute',
916 'minute_microsecond',
917 'minute_second',
918 'mod',
919 'mode',
920 'modifies',
921 'modify',
922 'month',
923 'mutex',
924 'mysql_errno',
925 'name',
926 'names',
927 'natural',
928 'ndb',
929 'ndbcluster',
930 'nested',
931 'network_namespace',
932 'never',
933 'new',
934 'next',
935 'no',
936 'no_wait',
937 'no_write_to_binlog',
938 'nodegroup',
939 'none',
940 'not',
941 'nowait',
942 'nth_value',
943 'ntile',
944 'null',
945 'nulls',
946 'number',
947 'of',
948 'off',
949 'offset',
950 'oj',
951 'old',
952 'on',
953 'one',
954 'only',
955 'open',
956 'optimize',
957 'optimizer_costs',
958 'option',
959 'optional',
960 'optionally',
961 'options',
962 'or',
963 'order',
964 'ordinality',
965 'organization',
966 'others',
967 'out',
968 'outer',
969 'outfile',
970 'over',
971 'owner',
972 'pack_keys',
973 'page',
974 'parallel',
975 'parameters',
976 'parse_tree',
977 'parser',
978 'partial',
979 'partition',
980 'partitioning',
981 'partitions',
982 'password',
983 'password_lock_time',
984 'path',
985 'percent_rank',
986 'persist',
987 'persist_only',
988 'phase',
989 'plugin',
990 'plugin_dir',
991 'plugins',
992 'port',
993 'precedes',
994 'preceding',
995 'prepare',
996 'preserve',
997 'prev',
998 'primary',
999 'privilege_checks_user',
1000 'privileges',
1001 'procedure',
1002 'process',
1003 'processlist',
1004 'profile',
1005 'profiles',
1006 'proxy',
1007 'purge',
1008 'qualify',
1009 'quarter',
1010 'query',
1011 'quick',
1012 'random',
1013 'range',
1014 'rank',
1015 'read',
1016 'read_only',
1017 'read_write',
1018 'reads',
1019 'rebuild',
1020 'recover',
1021 'recursive',
1022 'redo_buffer_size',
1023 'redundant',
1024 'reference',
1025 'references',
1026 'regexp',
1027 'registration',
1028 'relational',
1029 'relay',
1030 'relay_log_file',
1031 'relay_log_pos',
1032 'relay_thread',
1033 'relaylog',
1034 'release',
1035 'reload',
1036 'remove',
1037 'rename',
1038 'reorganize',
1039 'repair',
1040 'repeat',
1041 'repeatable',
1042 'replace',
1043 'replica',
1044 'replicas',
1045 'replicate_do_db',
1046 'replicate_do_table',
1047 'replicate_ignore_db',
1048 'replicate_ignore_table',
1049 'replicate_rewrite_db',
1050 'replicate_wild_do_table',
1051 'replicate_wild_ignore_table',
1052 'replication',
1053 'require',
1054 'require_row_format',
1055 'require_table_primary_key_check',
1056 'reset',
1057 'resignal',
1058 'resource',
1059 'respect',
1060 'restart',
1061 'restore',
1062 'restrict',
1063 'resume',
1064 'retain',
1065 'return',
1066 'returned_sqlstate',
1067 'returning',
1068 'returns',
1069 'reuse',
1070 'reverse',
1071 'revoke',
1072 'right',
1073 'rlike',
1074 'role',
1075 'rollback',
1076 'rollup',
1077 'rotate',
1078 'routine',
1079 'row',
1080 'row_count',
1081 'row_format',
1082 'row_number',
1083 'rows',
1084 'rtree',
1085 's3',
1086 'savepoint',
1087 'schedule',
1088 'schema',
1089 'schema_name',
1090 'schemas',
1091 'second',
1092 'second_microsecond',
1093 'secondary',
1094 'secondary_engine',
1095 'secondary_engine_attribute',
1096 'secondary_load',
1097 'secondary_unload',
1098 'security',
1099 'select',
1100 'sensitive',
1101 'separator',
1102 'serializable',
1103 'server',
1104 'session',
1105 'share',
1106 'show',
1107 'shutdown',
1108 'signal',
1109 'signed',
1110 'simple',
1111 'skip',
1112 'slave',
1113 'slow',
1114 'snapshot',
1115 'socket',
1116 'some',
1117 'soname',
1118 'sounds',
1119 'source',
1120 'source_auto_position',
1121 'source_bind',
1122 'source_compression_algorithms',
1123 'source_connect_retry',
1124 'source_connection_auto_failover',
1125 'source_delay',
1126 'source_heartbeat_period',
1127 'source_host',
1128 'source_log_file',
1129 'source_log_pos',
1130 'source_password',
1131 'source_port',
1132 'source_public_key_path',
1133 'source_retry_count',
1134 'source_ssl',
1135 'source_ssl_ca',
1136 'source_ssl_capath',
1137 'source_ssl_cert',
1138 'source_ssl_cipher',
1139 'source_ssl_crl',
1140 'source_ssl_crlpath',
1141 'source_ssl_key',
1142 'source_ssl_verify_server_cert',
1143 'source_tls_ciphersuites',
1144 'source_tls_version',
1145 'source_user',
1146 'source_zstd_compression_level',
1147 'spatial',
1148 'specific',
1149 'sql',
1150 'sql_after_gtids',
1151 'sql_after_mts_gaps',
1152 'sql_before_gtids',
1153 'sql_big_result',
1154 'sql_buffer_result',
1155 'sql_calc_found_rows',
1156 'sql_no_cache',
1157 'sql_small_result',
1158 'sql_thread',
1159 'sql_tsi_day',
1160 'sql_tsi_hour',
1161 'sql_tsi_minute',
1162 'sql_tsi_month',
1163 'sql_tsi_quarter',
1164 'sql_tsi_second',
1165 'sql_tsi_week',
1166 'sql_tsi_year',
1167 'sqlexception',
1168 'sqlstate',
1169 'sqlwarning',
1170 'srid',
1171 'ssl',
1172 'stacked',
1173 'start',
1174 'starting',
1175 'starts',
1176 'stats_auto_recalc',
1177 'stats_persistent',
1178 'stats_sample_pages',
1179 'status',
1180 'stop',
1181 'storage',
1182 'stored',
1183 'straight_join',
1184 'stream',
1185 'strict_load',
1186 'string',
1187 'subclass_origin',
1188 'subject',
1189 'subpartition',
1190 'subpartitions',
1191 'super',
1192 'suspend',
1193 'swaps',
1194 'switches',
1195 'system',
1196 'table',
1197 'table_checksum',
1198 'table_name',
1199 'tables',
1200 'tablesample',
1201 'tablespace',
1202 'temporary',
1203 'temptable',
1204 'terminated',
1205 'than',
1206 'then',
1207 'thread_priority',
1208 'ties',
1209 'timestampadd',
1210 'timestampdiff',
1211 'tls',
1212 'to',
1213 'trailing',
1214 'transaction',
1215 'trigger',
1216 'triggers',
1217 'true',
1218 'truncate',
1219 'type',
1220 'types',
1221 'unbounded',
1222 'uncommitted',
1223 'undefined',
1224 'undo',
1225 'undo_buffer_size',
1226 'undofile',
1227 'unicode',
1228 'uninstall',
1229 'union',
1230 'unique',
1231 'unknown',
1232 'unlock',
1233 'unregister',
1234 'unsigned',
1235 'until',
1236 'update',
1237 'upgrade',
1238 'uri',
1239 'url',
1240 'usage',
1241 'use',
1242 'use_frm',
1243 'user',
1244 'user_resources',
1245 'using',
1246 'utc_date',
1247 'utc_time',
1248 'utc_timestamp',
1249 'validation',
1250 'value',
1251 'values',
1252 'variables',
1253 'vcpu',
1254 'vector',
1255 'verify_key_constraints',
1256 'view',
1257 'virtual',
1258 'visible',
1259 'wait',
1260 'warnings',
1261 'week',
1262 'weight_string',
1263 'when',
1264 'where',
1265 'while',
1266 'window',
1267 'with',
1268 'without',
1269 'work',
1270 'wrapper',
1271 'write',
1272 'x509',
1273 'xa',
1274 'xid',
1275 'xml',
1276 'xor',
1277 'year_month',
1278 'zerofill',
1279 'zone',
1280)
1281
1282
1283if __name__ == '__main__': # pragma: no cover
1284 import re
1285 from urllib.request import urlopen
1286
1287 from pygments.util import format_lines
1288
1289 # MySQL source code
1290 SOURCE_URL = 'https://github.com/mysql/mysql-server/raw/trunk'
1291 LEX_URL = SOURCE_URL + '/sql/lex.h'
1292 ITEM_CREATE_URL = SOURCE_URL + '/sql/item_create.cc'
1293
1294
1295 def update_myself():
1296 # Pull content from lex.h.
1297 lex_file = urlopen(LEX_URL).read().decode('utf8', errors='ignore')
1298 keywords = parse_lex_keywords(lex_file)
1299 functions = parse_lex_functions(lex_file)
1300 optimizer_hints = parse_lex_optimizer_hints(lex_file)
1301
1302 # Parse content in item_create.cc.
1303 item_create_file = urlopen(ITEM_CREATE_URL).read().decode('utf8', errors='ignore')
1304 functions.update(parse_item_create_functions(item_create_file))
1305
1306 # Remove data types from the set of keywords.
1307 keywords -= set(MYSQL_DATATYPES)
1308
1309 update_content('MYSQL_FUNCTIONS', tuple(sorted(functions)))
1310 update_content('MYSQL_KEYWORDS', tuple(sorted(keywords)))
1311 update_content('MYSQL_OPTIMIZER_HINTS', tuple(sorted(optimizer_hints)))
1312
1313
1314 def parse_lex_keywords(f):
1315 """Parse keywords in lex.h."""
1316
1317 results = set()
1318 for m in re.finditer(r'{SYM(?:_HK)?\("(?P<keyword>[a-z0-9_]+)",', f, flags=re.I):
1319 results.add(m.group('keyword').lower())
1320
1321 if not results:
1322 raise ValueError('No keywords found')
1323
1324 return results
1325
1326
1327 def parse_lex_optimizer_hints(f):
1328 """Parse optimizer hints in lex.h."""
1329
1330 results = set()
1331 for m in re.finditer(r'{SYM_H\("(?P<keyword>[a-z0-9_]+)",', f, flags=re.I):
1332 results.add(m.group('keyword').lower())
1333
1334 if not results:
1335 raise ValueError('No optimizer hints found')
1336
1337 return results
1338
1339
1340 def parse_lex_functions(f):
1341 """Parse MySQL function names from lex.h."""
1342
1343 results = set()
1344 for m in re.finditer(r'{SYM_FN?\("(?P<function>[a-z0-9_]+)",', f, flags=re.I):
1345 results.add(m.group('function').lower())
1346
1347 if not results:
1348 raise ValueError('No lex functions found')
1349
1350 return results
1351
1352
1353 def parse_item_create_functions(f):
1354 """Parse MySQL function names from item_create.cc."""
1355
1356 results = set()
1357 for m in re.finditer(r'{"(?P<function>[^"]+?)",\s*SQL_F[^(]+?\(', f, flags=re.I):
1358 results.add(m.group('function').lower())
1359
1360 if not results:
1361 raise ValueError('No item_create functions found')
1362
1363 return results
1364
1365
1366 def update_content(field_name, content):
1367 """Overwrite this file with content parsed from MySQL's source code."""
1368
1369 with open(__file__, encoding="utf-8") as f:
1370 data = f.read()
1371
1372 # Line to start/end inserting
1373 re_match = re.compile(rf'^{field_name}\s*=\s*\($.*?^\s*\)$', re.M | re.S)
1374 m = re_match.search(data)
1375 if not m:
1376 raise ValueError(f'Could not find an existing definition for {field_name}')
1377
1378 new_block = format_lines(field_name, content)
1379 data = data[:m.start()] + new_block + data[m.end():]
1380
1381 with open(__file__, 'w', encoding='utf-8', newline='\n') as f:
1382 f.write(data)
1383
1384 update_myself()