diff --git a/keywords.md b/keywords.md
index 4c5d0b3b220fb..fbbb89ac377cb 100644
--- a/keywords.md
+++ b/keywords.md
@@ -79,9 +79,12 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- ANALYZE (R)
- AND (R)
- ANY
+- ARRAY (R)
- AS (R)
- ASC (R)
- ASCII
+- ATTRIBUTE
+- ATTRIBUTES
- AUTO_ID_CACHE
- AUTO_INCREMENT
- AUTO_RANDOM
@@ -95,11 +98,13 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- BACKUP
- BACKUPS
- BEGIN
+- BERNOULLI
- BETWEEN (R)
- BIGINT (R)
- BINARY (R)
- BINDING
- BINDINGS
+- BINDING_CACHE
- BINLOG
- BIT
- BLOB (R)
@@ -116,11 +121,14 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
C
- CACHE
+- CALIBRATE
+- CALL (R)
- CANCEL (R)
- CAPTURE
- CASCADE (R)
- CASCADED
- CASE (R)
+- CAUSAL
- CHAIN
- CHANGE (R)
- CHAR (R)
@@ -132,6 +140,9 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- CIPHER
- CLEANUP
- CLIENT
+- CLIENT_ERRORS_SUMMARY
+- CLUSTER
+- CLUSTERED
- CMSKETCH (R)
- COALESCE
- COLLATE (R)
@@ -148,6 +159,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- CONCURRENCY
- CONFIG
- CONNECTION
+- CONSISTENCY
- CONSISTENT
- CONSTRAINT (R)
- CONTEXT
@@ -195,8 +207,10 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- DEPTH (R)
- DESC (R)
- DESCRIBE (R)
+- DIGEST
- DIRECTORY
- DISABLE
+- DISABLED
- DISCARD
- DISK
- DISTINCT (R)
@@ -214,6 +228,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- ELSE (R)
- ENABLE
+- ENABLED
- ENCLOSED (R)
- ENCRYPTION
- END
@@ -240,8 +255,10 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
F
+- FAILED_LOGIN_ATTEMPTS
- FALSE (R)
- FAULTS
+- FETCH (R)
- FIELDS
- FILE
- FIRST
@@ -273,7 +290,9 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- HASH
- HAVING (R)
+- HELP
- HIGH_PRIORITY (R)
+- HISTOGRAM
- HISTORY
- HOSTS
- HOUR
@@ -286,6 +305,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- IDENTIFIED
- IF (R)
- IGNORE (R)
+- ILIKE (R)
- IMPORT
- IMPORTS
- IN (R)
@@ -305,6 +325,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- INT4 (R)
- INT8 (R)
- INTEGER (R)
+- INTERSECT (R)
- INTERVAL (R)
- INTO (R)
- INVISIBLE
@@ -354,6 +375,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- LOCALTIMESTAMP (R)
- LOCATION
- LOCK (R)
+- LOCKED
- LOGS
- LONG (R)
- LONGBLOB (R)
@@ -376,6 +398,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- MEDIUMBLOB (R)
- MEDIUMINT (R)
- MEDIUMTEXT (R)
+- MEMBER
- MEMORY
- MERGE
- MICROSECOND
@@ -406,6 +429,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- NODE_STATE (R)
- NOMAXVALUE
- NOMINVALUE
+- NONCLUSTERED
- NONE
- NOT (R)
- NOWAIT
@@ -419,7 +443,12 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
O
+- OF (R)
+- OFF
- OFFSET
+- OLTP_READ_ONLY
+- OLTP_READ_WRITE
+- OLTP_WRITE_ONLY
- ON (R)
- ONLINE
- ONLY
@@ -428,6 +457,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- OPTIMISTIC (R)
- OPTIMIZE (R)
- OPTION (R)
+- OPTIONAL
- OPTIONALLY (R)
- OR (R)
- ORDER (R)
@@ -445,15 +475,21 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- PARTITIONING
- PARTITIONS
- PASSWORD
+- PASSWORD_LOCK_TIME
+- PAUSE
+- PERCENT
- PERCENT_RANK (R-Window)
- PER_DB
- PER_TABLE
- PESSIMISTIC (R)
- PLACEMENT (S)
- PLUGINS
+- POINT
+- POLICY
- PRECEDING
- PRECISION (R)
- PREPARE
+- PRESERVE
- PRE_SPLIT_REGIONS
- PRIMARY (R)
- PRIVILEGES
@@ -462,7 +498,9 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- PROCESSLIST
- PROFILE
- PROFILES
+- PROXY
- PUMP (R)
+- PURGE
Q
@@ -480,6 +518,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- REAL (R)
- REBUILD
- RECOVER
+- RECURSIVE (R)
- REDUNDANT
- REFERENCES (R)
- REGEXP (R)
@@ -495,12 +534,18 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- REPEATABLE
- REPLACE (R)
- REPLICA
+- REPLICAS
- REPLICATION
- REQUIRE (R)
+- REQUIRED
+- RESOURCE
- RESPECT
+- RESTART
- RESTORE
- RESTORES
- RESTRICT (R)
+- RESUME
+- REUSE
- REVERSE
- REVOKE (R)
- RIGHT (R)
@@ -518,6 +563,8 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
S
- SAMPLES (R)
+- SAN
+- SAVEPOINT
- SECOND
- SECONDARY_ENGINE
- SECONDARY_LOAD
@@ -540,6 +587,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- SHUTDOWN
- SIGNED
- SIMPLE
+- SKIP
- SKIP_SCHEMA_FILES
- SLAVE
- SLOW
@@ -570,11 +618,16 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- STATS (R)
- STATS_AUTO_RECALC
- STATS_BUCKETS (R)
+- STATS_COL_CHOICE
+- STATS_COL_LIST
+- STATS_EXTENDED (R)
- STATS_HEALTHY (R)
- STATS_HISTOGRAMS (R)
- STATS_META (R)
+- STATS_OPTIONS
- STATS_PERSISTENT
- STATS_SAMPLE_PAGES
+- STATS_SAMPLE_RATE
- STATUS
- STORAGE
- STORED (R)
@@ -586,12 +639,14 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- SUPER
- SWAPS
- SWITCHES
+- SYSTEM
- SYSTEM_TIME
T
- TABLE (R)
- TABLES
+- TABLESAMPLE (R)
- TABLESPACE
- TABLE_CHECKSUM
- TEMPORARY
@@ -611,6 +666,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- TO (R)
- TOKEN_ISSUER
- TOPN (R)
+- TPCC
- TRACE
- TRADITIONAL
- TRAILING (R)
@@ -619,7 +675,11 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- TRIGGERS
- TRUE (R)
- TRUNCATE
+- TTL
+- TTL_ENABLE
+- TTL_JOB_INTERVAL
- TYPE
+- TiDB_CURRENT_TSO (R)
U
@@ -657,6 +717,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
W
+- WAIT
- WARNINGS
- WEEK
- WEIGHT_STRING
@@ -666,6 +727,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- WINDOW (R-Window)
- WITH (R)
- WITHOUT
+- WORKLOAD
- WRITE (R)
X
diff --git a/scripts/check-keywords.sh b/scripts/check-keywords.sh
new file mode 100755
index 0000000000000..c3ee221d5f335
--- /dev/null
+++ b/scripts/check-keywords.sh
@@ -0,0 +1,48 @@
+#!/bin/python3
+import re
+import sys
+from pathlib import Path
+
+parser = Path("../tidb/parser/parser.y")
+if not parser.exists():
+ sys.exit(f"{parser} doesn't exist")
+
+kwdocs = Path("keywords.md")
+if not parser.exists():
+ sys.exit(f"{kwdocs} doesn't exist")
+
+keywords = kwdocs.read_text()
+
+errors = 0
+section = "Unknown"
+for line in parser.read_text().split("\n"):
+ if line.find("The following tokens belong to ReservedKeyword") >= 0:
+ section = "ReservedKeyword"
+
+ if line.find("The following tokens belong to UnReservedKeyword") >= 0:
+ section = "UnReservedKeyword"
+
+ if line.find("The following tokens belong to NotKeywordToken") >= 0:
+ section = "NotKeywordToken"
+
+ if section == "ReservedKeyword":
+ if m := re.match(r'^\t\w+\s+"(\w+)"$', line):
+ kw = m.groups()[0]
+ if not (
+ kwm := re.search(f"^- {kw} \((R|R-Window)\)$", keywords, re.MULTILINE)
+ ):
+ if kwm := re.search(f"^- {kw}$", keywords, re.MULTILINE):
+ print(f"Keyword not labeled as reserved: {kw}")
+ errors += 1
+ else:
+ print(f"Missing docs for reserved keyword: {kw}")
+ errors += 1
+
+ if section == "UnReservedKeyword":
+ if m := re.match(r'^\t\w+\s+"(\w+)"$', line):
+ kw = m.groups()[0]
+ if not (kwm := re.search(f"^- {kw}$", keywords, re.MULTILINE)):
+ print(f"Missing docs for non-reserved keyword: {kw}")
+ errors += 1
+
+sys.exit(errors)