_mysql_builtins.py 25 KB

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