vibesql-parser 0.2.0

SQL parser for vibesql database engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
use std::fmt;

/// SQL Keywords supported by the parser.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Keyword {
    Select,
    Distinct,
    From,
    Where,
    Insert,
    Into,
    Replace,
    Ignore,
    Update,
    Delete,
    Duplicate,
    Create,
    Table,
    Truncate,
    Drop,
    Alter,
    And,
    Or,
    Not,
    Null,
    True,
    False,
    Unknown,
    As,
    Join,
    Left,
    Right,
    Inner,
    Outer,
    Cross,
    Full,
    Natural,
    On,
    Group,
    Groups,
    By,
    // OLAP extensions for GROUP BY
    Rollup,
    Cube,
    Sets,
    Grouping,
    GroupingId,
    Having,
    Order,
    Asc,
    Desc,
    Nulls,
    Limit,
    Offset,
    Set,
    Values,
    In,
    Between,
    Asymmetric,
    Symmetric,
    Like,
    Glob,
    Escape,
    Exists,
    If,
    All,
    Any,
    Some,
    Union,
    Intersect,
    Except,
    With,
    Recursive,
    // CTE materialization hints (SQL:1999)
    Materialized,
    Date,
    Time,
    Timestamp,
    Interval,
    Cast,
    // CASE expression keywords
    Case,
    When,
    Then,
    Else,
    End,
    // Window function keywords
    Over,
    Partition,
    Rows,
    Range,
    Preceding,
    Following,
    Unbounded,
    Current,
    Filter,
    Exclude,
    Others,
    Ties,
    Window,
    // Note: Window function names (ROW_NUMBER, RANK, etc.) are identifiers, not keywords
    // Constraint keywords
    Primary,
    Foreign,
    Key,
    Unique,
    Check,
    References,
    // IS NULL keywords
    Is,
    // SQLite ISNULL/NOTNULL postfix operators
    Isnull,
    Notnull,
    // Transaction keywords
    Begin,
    Commit,
    Rollback,
    // SCHEMA keywords
    Cascade,
    Restrict,
    Schema,
    Start,
    Transaction,
    // ALTER TABLE keywords
    Add,
    Column,
    Constraint,
    Default,
    Rename,
    Modify,
    Change,
    /// RETURNING clause on DML statements (SQLite 3.35.0+)
    Returning,
    // SAVEPOINT keywords
    Savepoint,
    Release,
    To,
    // Role management keywords
    Role,
    // TRIM function keywords
    Both,
    Leading,
    Trailing,
    // MySQL arithmetic operators
    Div,
    // Data type keywords
    Varying,
    Characters,
    Octets,
    Using,
    // SUBSTRING function keywords
    For,
    // Current date/time function keywords
    CurrentDate,
    CurrentTime,
    CurrentTimestamp,
    // GRANT keywords
    Grant,
    Privileges,
    Usage,
    Option,
    // REVOKE keywords
    Revoke,
    Granted,
    // Advanced privilege keywords
    Execute,
    Trigger,
    Under,
    // Advanced SQL object keywords
    Domain,
    Sequence,
    Type,
    Collation,
    Character,
    Translation,
    View,
    Index,
    Analyze,
    Reindex,
    Vacuum,
    Explain,
    Assertion,
    Specific,
    // Trigger-specific keywords
    Before,
    After,
    Instead,
    Of,
    Each,
    Row,
    Statement,
    Enable,
    Disable,
    // SEQUENCE specific keywords
    Increment,
    Minvalue,
    Maxvalue,
    Cycle,
    No,
    Restart,
    Next,
    // Referential action keywords
    Action,
    // Constraint deferral keywords (SQL:1999)
    Deferrable,
    Deferred,
    Immediate,
    Initially,
    // Session configuration keywords (SQL:1999)
    Catalog,
    Names,
    Zone,
    Local,
    Session,
    Global,
    // Interval unit keywords
    Year,
    Quarter,
    Month,
    Week,
    Day,
    Hour,
    Minute,
    Second,
    Microsecond,
    // Callable object keywords (functions, procedures, methods)
    Function,
    Procedure,
    Call,
    Routine,
    Method,
    Constructor,
    Static,
    Instance,
    // Procedure/Function parameter modes
    Out,
    InOut,
    // Procedure/Function keywords
    Returns,
    While,
    Do,
    Loop,
    Repeat,
    Until,
    Return,
    Leave,
    Iterate,
    // Procedure/Function characteristics (Phase 6)
    Deterministic,
    Language,
    Sql,
    Security,
    Definer,
    Invoker,
    // Internationalization keywords (SQL:1999)
    Get,
    Pad,
    Space,
    Collate,
    // Generated column keywords (SQLite)
    Generated,
    Always,
    Stored,
    Virtual,
    // CURSOR keywords
    Declare,
    Cursor,
    Insensitive,
    // Prepared statement keywords
    Prepare,
    Deallocate,
    Scroll,
    Hold,
    Without,
    Read,
    Only,
    Oids,
    Rowid,
    Open,
    Fetch,
    Close,
    Prior,
    First,
    Last,
    Absolute,
    Relative,
    Serializable,
    Isolation,
    Level,
    Write,
    Comment,
    // MySQL table option keywords
    KeyBlockSize,
    Connection,
    InsertMethod,
    RowFormat,
    DelayKeyWrite,
    TableChecksum,
    Checksum,
    StatsSamplePages,
    Password,
    AvgRowLength,
    MinRows,
    MaxRows,
    SecondaryEngine,
    // MySQL table option values
    Dynamic,
    Fixed,
    Compressed,
    Redundant,
    Compact,
    // Full-text search keywords
    Fulltext,
    Match,
    Against,
    Boolean,
    Expansion,
    Mode,
    Query,
    Plan,
    // Spatial index keywords
    Spatial,
    // Vector index keywords (IVFFlat, HNSW)
    Ivfflat,
    Hnsw,
    Lists,
    Probes,
    EfConstruction,
    EfSearch,
    M,
    // Database introspection keywords
    Show,
    Describe,
    Databases,
    Tables,
    Columns,
    Fields,
    Indexes,
    Keys,
    // Auto-increment keywords (MySQL and SQLite)
    AutoIncrement,
    // Temporary object keywords (SQLite)
    Temp,
    Temporary,
    // VibeSQL storage format keywords
    Storage,
    Columnar,
    // Transaction durability hint keywords
    Durability,
    Lazy,
    Durable,
    Volatile,
    // SQLite compatibility keywords
    Pragma,
    // SQLite conflict resolution keywords
    Abort,
    Fail,
    Conflict,
    Nothing,
}

impl Keyword {
    /// Returns true if this keyword can be used as an unquoted column or table name.
    /// These are "unreserved" keywords that are only treated as keywords in specific contexts.
    ///
    /// This follows SQLite's behavior where temporal type keywords (TIMESTAMP, DATE, TIME,
    /// INTERVAL) and interval unit keywords (YEAR, MONTH, DAY, etc.) can be used as identifiers
    /// without quoting.
    ///
    /// TYPE and SQL are also unreserved to match SQLite compatibility (neither is in SQLite's
    /// 147-keyword reserved list). They work safely because:
    /// - TYPE: Parser uses peek_next_keyword() for CREATE TYPE dispatch
    /// - SQL: Only consumed after explicit LANGUAGE keyword in routines
    pub fn can_be_identifier(&self) -> bool {
        matches!(
            self,
            // Temporal type keywords
            Keyword::Timestamp | Keyword::Date | Keyword::Time | Keyword::Interval |
            // Interval unit keywords (used in EXTRACT, DATE_ADD, etc. but also valid as identifiers)
            Keyword::Year | Keyword::Quarter | Keyword::Month | Keyword::Week |
            Keyword::Day | Keyword::Hour | Keyword::Minute | Keyword::Second |
            Keyword::Microsecond |
            // SQLite compatibility: TYPE and SQL are not reserved in SQLite
            // (allows unquoted access to sqlite_master.type and sqlite_master.sql columns)
            // ROWID is the pseudo-column for implicit row IDs in SQLite tables
            Keyword::Type | Keyword::Sql | Keyword::Rowid |
            // Vector index parameter: M is only contextual in HNSW WITH clause
            // SQLite TCL tests commonly use 'm' as a column name
            Keyword::M |
            // NULLS is only contextual in ORDER BY (NULLS FIRST/LAST)
            // Can be used as identifier for table/column/CTE names
            Keyword::Nulls |
            // SQLite schema keywords: TEMP/TEMPORARY are valid schema names
            // Allows three-part qualified names like temp.t1.column
            Keyword::Temp | Keyword::Temporary |
            // Procedure parameter direction keywords: OUT/INOUT are only meaningful
            // in stored procedure contexts, safe to use as identifiers elsewhere
            // SQLite TCL tests use 'out' as a CTE name
            Keyword::Out | Keyword::InOut |
            // Join keywords: SQLite allows these as identifiers (table/column/function names)
            // when not in a join context. SQLite TCL tests (func8.test) use these extensively.
            Keyword::Cross | Keyword::Full | Keyword::Inner | Keyword::Left |
            Keyword::Natural | Keyword::Outer | Keyword::Right |
            // Window function keywords: These are contextual in window frame specifications
            // but can be used as identifiers elsewhere. SQLite TCL tests (window1.test)
            // create tables with these as column names.
            Keyword::Current | Keyword::Exclude | Keyword::Filter | Keyword::Following |
            Keyword::Groups | Keyword::No | Keyword::Others | Keyword::Over |
            Keyword::Partition | Keyword::Preceding | Keyword::Range | Keyword::Ties |
            Keyword::Unbounded | Keyword::Window | Keyword::First | Keyword::Last |
            // RETURNING is a "fallback" keyword in SQLite (3.35.0+): it is only
            // meaningful at the end of a DML statement and remains usable as an
            // ordinary identifier elsewhere.
            Keyword::Returning
        )
    }
}

impl fmt::Display for Keyword {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let keyword_str = match self {
            Keyword::Select => "SELECT",
            Keyword::Distinct => "DISTINCT",
            Keyword::From => "FROM",
            Keyword::Where => "WHERE",
            Keyword::Insert => "INSERT",
            Keyword::Into => "INTO",
            Keyword::Replace => "REPLACE",
            Keyword::Ignore => "IGNORE",
            Keyword::Update => "UPDATE",
            Keyword::Delete => "DELETE",
            Keyword::Duplicate => "DUPLICATE",
            Keyword::Create => "CREATE",
            Keyword::Table => "TABLE",
            Keyword::Truncate => "TRUNCATE",
            Keyword::Drop => "DROP",
            Keyword::Alter => "ALTER",
            Keyword::And => "AND",
            Keyword::Or => "OR",
            Keyword::Not => "NOT",
            Keyword::Null => "NULL",
            Keyword::True => "TRUE",
            Keyword::False => "FALSE",
            Keyword::Unknown => "UNKNOWN",
            Keyword::As => "AS",
            Keyword::Join => "JOIN",
            Keyword::Left => "LEFT",
            Keyword::Right => "RIGHT",
            Keyword::Inner => "INNER",
            Keyword::Outer => "OUTER",
            Keyword::Cross => "CROSS",
            Keyword::Full => "FULL",
            Keyword::Natural => "NATURAL",
            Keyword::On => "ON",
            Keyword::Group => "GROUP",
            Keyword::Groups => "GROUPS",
            Keyword::By => "BY",
            Keyword::Rollup => "ROLLUP",
            Keyword::Cube => "CUBE",
            Keyword::Sets => "SETS",
            Keyword::Grouping => "GROUPING",
            Keyword::GroupingId => "GROUPING_ID",
            Keyword::Having => "HAVING",
            Keyword::Order => "ORDER",
            Keyword::Asc => "ASC",
            Keyword::Desc => "DESC",
            Keyword::Nulls => "NULLS",
            Keyword::Limit => "LIMIT",
            Keyword::Offset => "OFFSET",
            Keyword::Set => "SET",
            Keyword::Values => "VALUES",
            Keyword::In => "IN",
            Keyword::Between => "BETWEEN",
            Keyword::Asymmetric => "ASYMMETRIC",
            Keyword::Symmetric => "SYMMETRIC",
            Keyword::Like => "LIKE",
            Keyword::Glob => "GLOB",
            Keyword::Escape => "ESCAPE",
            Keyword::Exists => "EXISTS",
            Keyword::If => "IF",
            Keyword::All => "ALL",
            Keyword::Any => "ANY",
            Keyword::Some => "SOME",
            Keyword::Union => "UNION",
            Keyword::Intersect => "INTERSECT",
            Keyword::Except => "EXCEPT",
            Keyword::With => "WITH",
            Keyword::Recursive => "RECURSIVE",
            Keyword::Materialized => "MATERIALIZED",
            Keyword::Date => "DATE",
            Keyword::Time => "TIME",
            Keyword::Timestamp => "TIMESTAMP",
            Keyword::Interval => "INTERVAL",
            Keyword::Cast => "CAST",
            Keyword::Case => "CASE",
            Keyword::When => "WHEN",
            Keyword::Then => "THEN",
            Keyword::Else => "ELSE",
            Keyword::End => "END",
            Keyword::Over => "OVER",
            Keyword::Partition => "PARTITION",
            Keyword::Rows => "ROWS",
            Keyword::Range => "RANGE",
            Keyword::Preceding => "PRECEDING",
            Keyword::Following => "FOLLOWING",
            Keyword::Unbounded => "UNBOUNDED",
            Keyword::Current => "CURRENT",
            Keyword::Filter => "FILTER",
            Keyword::Exclude => "EXCLUDE",
            Keyword::Others => "OTHERS",
            Keyword::Ties => "TIES",
            Keyword::Window => "WINDOW",
            Keyword::Primary => "PRIMARY",
            Keyword::Foreign => "FOREIGN",
            Keyword::Key => "KEY",
            Keyword::Unique => "UNIQUE",
            Keyword::Check => "CHECK",
            Keyword::References => "REFERENCES",
            Keyword::Is => "IS",
            Keyword::Isnull => "ISNULL",
            Keyword::Notnull => "NOTNULL",
            Keyword::Begin => "BEGIN",
            Keyword::Commit => "COMMIT",
            Keyword::Rollback => "ROLLBACK",
            Keyword::Cascade => "CASCADE",
            Keyword::Restrict => "RESTRICT",
            Keyword::Schema => "SCHEMA",
            Keyword::Start => "START",
            Keyword::Transaction => "TRANSACTION",
            Keyword::Add => "ADD",
            Keyword::Column => "COLUMN",
            Keyword::Constraint => "CONSTRAINT",
            Keyword::Default => "DEFAULT",
            Keyword::Rename => "RENAME",
            Keyword::Returning => "RETURNING",
            Keyword::Modify => "MODIFY",
            Keyword::Change => "CHANGE",
            Keyword::Savepoint => "SAVEPOINT",
            Keyword::Release => "RELEASE",
            Keyword::To => "TO",
            Keyword::Role => "ROLE",
            Keyword::Both => "BOTH",
            Keyword::Leading => "LEADING",
            Keyword::Trailing => "TRAILING",
            Keyword::Div => "DIV",
            Keyword::Varying => "VARYING",
            Keyword::Characters => "CHARACTERS",
            Keyword::Octets => "OCTETS",
            Keyword::Using => "USING",
            Keyword::For => "FOR",
            Keyword::CurrentDate => "CURRENT_DATE",
            Keyword::CurrentTime => "CURRENT_TIME",
            Keyword::CurrentTimestamp => "CURRENT_TIMESTAMP",
            Keyword::Grant => "GRANT",
            Keyword::Privileges => "PRIVILEGES",
            Keyword::Usage => "USAGE",
            Keyword::Option => "OPTION",
            Keyword::Revoke => "REVOKE",
            Keyword::Granted => "GRANTED",
            Keyword::Execute => "EXECUTE",
            Keyword::Trigger => "TRIGGER",
            Keyword::Under => "UNDER",
            Keyword::Domain => "DOMAIN",
            Keyword::Sequence => "SEQUENCE",
            Keyword::Type => "TYPE",
            Keyword::Collation => "COLLATION",
            Keyword::Character => "CHARACTER",
            Keyword::Translation => "TRANSLATION",
            Keyword::View => "VIEW",
            Keyword::Index => "INDEX",
            Keyword::Analyze => "ANALYZE",
            Keyword::Reindex => "REINDEX",
            Keyword::Vacuum => "VACUUM",
            Keyword::Explain => "EXPLAIN",
            Keyword::Assertion => "ASSERTION",
            Keyword::Specific => "SPECIFIC",
            Keyword::Before => "BEFORE",
            Keyword::After => "AFTER",
            Keyword::Instead => "INSTEAD",
            Keyword::Of => "OF",
            Keyword::Each => "EACH",
            Keyword::Row => "ROW",
            Keyword::Statement => "STATEMENT",
            Keyword::Enable => "ENABLE",
            Keyword::Disable => "DISABLE",
            Keyword::Increment => "INCREMENT",
            Keyword::Minvalue => "MINVALUE",
            Keyword::Maxvalue => "MAXVALUE",
            Keyword::Cycle => "CYCLE",
            Keyword::No => "NO",
            Keyword::Restart => "RESTART",
            Keyword::Next => "NEXT",
            Keyword::Action => "ACTION",
            Keyword::Deferrable => "DEFERRABLE",
            Keyword::Deferred => "DEFERRED",
            Keyword::Immediate => "IMMEDIATE",
            Keyword::Initially => "INITIALLY",
            Keyword::Catalog => "CATALOG",
            Keyword::Names => "NAMES",
            Keyword::Zone => "ZONE",
            Keyword::Local => "LOCAL",
            Keyword::Session => "SESSION",
            Keyword::Global => "GLOBAL",
            Keyword::Year => "YEAR",
            Keyword::Quarter => "QUARTER",
            Keyword::Month => "MONTH",
            Keyword::Week => "WEEK",
            Keyword::Day => "DAY",
            Keyword::Hour => "HOUR",
            Keyword::Minute => "MINUTE",
            Keyword::Second => "SECOND",
            Keyword::Microsecond => "MICROSECOND",
            Keyword::Function => "FUNCTION",
            Keyword::Procedure => "PROCEDURE",
            Keyword::Call => "CALL",
            Keyword::Routine => "ROUTINE",
            Keyword::Method => "METHOD",
            Keyword::Constructor => "CONSTRUCTOR",
            Keyword::Static => "STATIC",
            Keyword::Instance => "INSTANCE",
            Keyword::Out => "OUT",
            Keyword::InOut => "INOUT",
            Keyword::Returns => "RETURNS",
            Keyword::While => "WHILE",
            Keyword::Do => "DO",
            Keyword::Loop => "LOOP",
            Keyword::Repeat => "REPEAT",
            Keyword::Until => "UNTIL",
            Keyword::Return => "RETURN",
            Keyword::Leave => "LEAVE",
            Keyword::Iterate => "ITERATE",
            Keyword::Deterministic => "DETERMINISTIC",
            Keyword::Language => "LANGUAGE",
            Keyword::Sql => "SQL",
            Keyword::Security => "SECURITY",
            Keyword::Definer => "DEFINER",
            Keyword::Invoker => "INVOKER",
            Keyword::Comment => "COMMENT",
            Keyword::Get => "GET",
            Keyword::Pad => "PAD",
            Keyword::Space => "SPACE",
            Keyword::Collate => "COLLATE",
            Keyword::Generated => "GENERATED",
            Keyword::Always => "ALWAYS",
            Keyword::Stored => "STORED",
            Keyword::Virtual => "VIRTUAL",
            Keyword::Declare => "DECLARE",
            Keyword::Cursor => "CURSOR",
            Keyword::Insensitive => "INSENSITIVE",
            Keyword::Prepare => "PREPARE",
            Keyword::Deallocate => "DEALLOCATE",
            Keyword::Scroll => "SCROLL",
            Keyword::Hold => "HOLD",
            Keyword::Without => "WITHOUT",
            Keyword::Read => "READ",
            Keyword::Only => "ONLY",
            Keyword::Oids => "OIDS",
            Keyword::Rowid => "ROWID",
            Keyword::Open => "OPEN",
            Keyword::Fetch => "FETCH",
            Keyword::Close => "CLOSE",
            Keyword::Prior => "PRIOR",
            Keyword::First => "FIRST",
            Keyword::Last => "LAST",
            Keyword::Absolute => "ABSOLUTE",
            Keyword::Relative => "RELATIVE",
            Keyword::Serializable => "SERIALIZABLE",
            Keyword::Isolation => "ISOLATION",
            Keyword::Level => "LEVEL",
            Keyword::Write => "WRITE",
            // MySQL table option keywords
            Keyword::KeyBlockSize => "KEY_BLOCK_SIZE",
            Keyword::Connection => "CONNECTION",
            Keyword::InsertMethod => "INSERT_METHOD",
            Keyword::RowFormat => "ROW_FORMAT",
            Keyword::DelayKeyWrite => "DELAY_KEY_WRITE",
            Keyword::TableChecksum => "TABLE_CHECKSUM",
            Keyword::Checksum => "CHECKSUM",
            Keyword::StatsSamplePages => "STATS_SAMPLE_PAGES",
            Keyword::Password => "PASSWORD",
            Keyword::AvgRowLength => "AVG_ROW_LENGTH",
            Keyword::MinRows => "MIN_ROWS",
            Keyword::MaxRows => "MAX_ROWS",
            Keyword::SecondaryEngine => "SECONDARY_ENGINE",
            // MySQL table option values
            Keyword::Dynamic => "DYNAMIC",
            Keyword::Fixed => "FIXED",
            Keyword::Compressed => "COMPRESSED",
            Keyword::Redundant => "REDUNDANT",
            Keyword::Compact => "COMPACT",
            // Full-text search keywords
            Keyword::Fulltext => "FULLTEXT",
            Keyword::Match => "MATCH",
            Keyword::Against => "AGAINST",
            Keyword::Boolean => "BOOLEAN",
            Keyword::Expansion => "EXPANSION",
            Keyword::Mode => "MODE",
            Keyword::Query => "QUERY",
            Keyword::Plan => "PLAN",
            // Spatial index keywords
            Keyword::Spatial => "SPATIAL",
            // Vector index keywords (IVFFlat, HNSW)
            Keyword::Ivfflat => "IVFFLAT",
            Keyword::Hnsw => "HNSW",
            Keyword::Lists => "LISTS",
            Keyword::Probes => "PROBES",
            Keyword::EfConstruction => "EF_CONSTRUCTION",
            Keyword::EfSearch => "EF_SEARCH",
            Keyword::M => "M",
            // Database introspection keywords
            Keyword::Show => "SHOW",
            Keyword::Describe => "DESCRIBE",
            Keyword::Databases => "DATABASES",
            Keyword::Tables => "TABLES",
            Keyword::Columns => "COLUMNS",
            Keyword::Fields => "FIELDS",
            Keyword::Indexes => "INDEXES",
            Keyword::Keys => "KEYS",
            // Auto-increment keywords
            Keyword::AutoIncrement => "AUTO_INCREMENT",
            // Temporary object keywords
            Keyword::Temp => "TEMP",
            Keyword::Temporary => "TEMPORARY",
            // VibeSQL storage format keywords
            Keyword::Storage => "STORAGE",
            Keyword::Columnar => "COLUMNAR",
            // Transaction durability hint keywords
            Keyword::Durability => "DURABILITY",
            Keyword::Lazy => "LAZY",
            Keyword::Durable => "DURABLE",
            Keyword::Volatile => "VOLATILE",
            // SQLite compatibility keywords
            Keyword::Pragma => "PRAGMA",
            // SQLite conflict resolution keywords
            Keyword::Abort => "ABORT",
            Keyword::Fail => "FAIL",
            Keyword::Conflict => "CONFLICT",
            Keyword::Nothing => "NOTHING",
        };
        write!(f, "{}", keyword_str)
    }
}