@@ -64,7 +64,7 @@ int mysql_yylex(union MYSQL_YYSTYPE* yylval_param, yyscan_t yyscanner, MysqlPars
6464/* TOKEN_FULL is already declared */
6565%token TOKEN_BEGIN TOKEN_COMMIT /* Added for BEGIN/COMMIT */
6666%token TOKEN_IS TOKEN_NULL_KEYWORD TOKEN_NOT /* Added for IS NULL / IS NOT NULL */
67-
67+ %token TOKEN_OFFSET /* Added for LIMIT ... OFFSET ... */
6868
6969%token <str_val> TOKEN_QUIT
7070%token <str_val> TOKEN_IDENTIFIER
@@ -1119,12 +1119,22 @@ opt_limit_clause:
11191119 $$->addChild($2); // count
11201120 }
11211121 | TOKEN_LIMIT number_literal_node TOKEN_COMMA number_literal_node { // LIMIT offset, count
1122- $$ = new MysqlParser::AstNode(MysqlParser::NodeType::NODE_LIMIT_CLAUSE);
1122+ // Standard SQL: LIMIT row_count OFFSET offset_row
1123+ // MySQL legacy: LIMIT offset_row, row_count
1124+ // Current AST: first child is offset, second is count for this form.
1125+ $$ = new MysqlParser::AstNode(MysqlParser::NodeType::NODE_LIMIT_CLAUSE, "OFFSET_COUNT");
11231126 $$->addChild($2); // offset
11241127 $$->addChild($4); // count
11251128 }
11261129 // MySQL also supports LIMIT count OFFSET offset, but that's more complex to add here without ambiguity
11271130 // For now, sticking to the common forms.
1131+ | TOKEN_LIMIT number_literal_node TOKEN_OFFSET number_literal_node { // LIMIT count OFFSET offset
1132+ // Standard SQL: LIMIT row_count OFFSET offset_row
1133+ // Current AST: first child is count, second is offset for this form.
1134+ $$ = new MysqlParser::AstNode(MysqlParser::NodeType::NODE_LIMIT_CLAUSE, "COUNT_OFFSET");
1135+ $$->addChild($2); // count
1136+ $$->addChild($4); // offset
1137+ }
11281138 ;
11291139
11301140opt_group_by_clause:
0 commit comments