_mysql_builtins.py 26 KB

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