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