Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit fac0506

Browse files
authored
Merge pull request #21 from Automattic/driver-parity
Driver parity
2 parents ca775d2 + c6bc3cb commit fac0506

9 files changed

+2399
-520
lines changed

grammar-tools/MySQLParser.g4

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,18 @@ alterListItem:
298298
| OPEN_PAR_SYMBOL tableElementList CLOSE_PAR_SYMBOL
299299
)
300300
| ADD_SYMBOL tableConstraintDef
301-
| CHANGE_SYMBOL COLUMN_SYMBOL? columnInternalRef identifier fieldDefinition place?
302-
| MODIFY_SYMBOL COLUMN_SYMBOL? columnInternalRef fieldDefinition place?
301+
/* @CHANGED: Replaced "columnInternalRef" with "fieldIdentifier" as per sql_yacc.yy. */
302+
| CHANGE_SYMBOL COLUMN_SYMBOL? fieldIdentifier identifier fieldDefinition place?
303+
/* @CHANGED: Replaced "columnInternalRef" with "fieldIdentifier" as per sql_yacc.yy. */
304+
| MODIFY_SYMBOL COLUMN_SYMBOL? fieldIdentifier fieldDefinition place?
303305
| DROP_SYMBOL (
304-
COLUMN_SYMBOL? columnInternalRef restrict?
306+
/* @CHANGED: Replaced "columnInternalRef" with "fieldIdentifier" as per sql_yacc.yy. */
307+
COLUMN_SYMBOL? fieldIdentifier restrict?
305308
| FOREIGN_SYMBOL KEY_SYMBOL (
309+
/* @CHANGED: Replaced "columnInternalRef" with "fieldIdentifier" as per sql_yacc.yy. */
306310
// This part is no longer optional starting with 5.7.
307-
{serverVersion >= 50700}? columnInternalRef
308-
| {serverVersion < 50700}? columnInternalRef?
311+
{serverVersion >= 50700}? fieldIdentifier
312+
| {serverVersion < 50700}? fieldIdentifier?
309313
)
310314
| PRIMARY_SYMBOL KEY_SYMBOL
311315
| keyOrIndex indexRef
@@ -314,7 +318,8 @@ alterListItem:
314318
)
315319
| DISABLE_SYMBOL KEYS_SYMBOL
316320
| ENABLE_SYMBOL KEYS_SYMBOL
317-
| ALTER_SYMBOL COLUMN_SYMBOL? columnInternalRef (
321+
/* @CHANGED: Replaced "columnInternalRef" with "fieldIdentifier" as per sql_yacc.yy. */
322+
| ALTER_SYMBOL COLUMN_SYMBOL? fieldIdentifier (
318323
SET_SYMBOL DEFAULT_SYMBOL (
319324
{serverVersion >= 80014}? exprWithParentheses
320325
| signedLiteral
@@ -325,7 +330,8 @@ alterListItem:
325330
| {serverVersion >= 80000}? ALTER_SYMBOL INDEX_SYMBOL indexRef visibility
326331
| {serverVersion >= 80017}? ALTER_SYMBOL CHECK_SYMBOL identifier constraintEnforcement
327332
| {serverVersion >= 80019}? ALTER_SYMBOL CONSTRAINT_SYMBOL identifier constraintEnforcement
328-
| {serverVersion >= 80000}? RENAME_SYMBOL COLUMN_SYMBOL columnInternalRef TO_SYMBOL identifier
333+
/* @CHANGED: Replaced "columnInternalRef" with "fieldIdentifier" as per sql_yacc.yy. */
334+
| {serverVersion >= 80000}? RENAME_SYMBOL COLUMN_SYMBOL fieldIdentifier TO_SYMBOL identifier
329335
| RENAME_SYMBOL (TO_SYMBOL | AS_SYMBOL)? tableName
330336
| {serverVersion >= 50700}? RENAME_SYMBOL keyOrIndex indexRef TO_SYMBOL indexName
331337
| CONVERT_SYMBOL TO_SYMBOL charset (
@@ -353,11 +359,11 @@ restrict:
353359

354360
/*
355361
* @CHANGED:
356-
* Fixed ALTER TABLE with ORDER to use 'qualifiedIdentifier' instead of just 'identifier'.
362+
* Fixed ALTER TABLE with ORDER to use 'simpleIdentifier' instead of just 'identifier'.
357363
* This is necessary to support "t.id" in a query like "ALTER TABLE t ORDER BY t.id".
358364
*/
359365
alterOrderList:
360-
qualifiedIdentifier direction? (COMMA_SYMBOL qualifiedIdentifier direction?)*
366+
simpleIdentifier direction? (COMMA_SYMBOL simpleIdentifier direction?)*
361367
;
362368

363369
alterAlgorithmOption:
@@ -1711,7 +1717,7 @@ xid:
17111717
/*
17121718
* @CHANGED:
17131719
* Fixed "replicationStatement" to correctly support the "RESET PERSIST" statement.
1714-
* The "ifExists" clause wasn't optional, and "identifier" was used instead of "qualifiedIdentifier".
1720+
* The "ifExists" clause wasn't optional, and "identifier" was used instead of "internalVariableName".
17151721
*/
17161722
replicationStatement:
17171723
PURGE_SYMBOL (BINARY_SYMBOL | MASTER_SYMBOL) LOGS_SYMBOL (
@@ -3561,7 +3567,8 @@ getDiagnostics:
35613567
signalAllowedExpr:
35623568
literal
35633569
| variable
3564-
| qualifiedIdentifier
3570+
/* @CHANGED: Changed "qualifiedIdentifier" to "simpleIdentifier" as per sql_yacc.yy. */
3571+
| simpleIdentifier
35653572
;
35663573

35673574
statementInformationItem:
@@ -3627,7 +3634,8 @@ schedule:
36273634
;
36283635

36293636
columnDefinition:
3630-
columnName fieldDefinition checkOrReferences?
3637+
/* @CHANGED: Replaced "columnInternalRef" with "fieldIdentifier" as per sql_yacc.yy. */
3638+
fieldIdentifier fieldDefinition checkOrReferences?
36313639
;
36323640

36333641
checkOrReferences:
@@ -4265,16 +4273,19 @@ usePartition:
42654273
// Sometimes we need additional reference rules with different form, depending on the place such a reference is used.
42664274

42674275
// A name for a field (column/index). Can be qualified with the current schema + table (although it's not a reference).
4276+
/* @CHANGED: Moved the conditional from "columnName" to "fieldIdentifier" as per sql_yacc.yy. */
42684277
fieldIdentifier:
4269-
dotIdentifier
4270-
| qualifiedIdentifier dotIdentifier?
4278+
// With server 8.0 this became a simple identifier.
4279+
{serverVersion < 80000}? (dotIdentifier | qualifiedIdentifier dotIdentifier?)
4280+
| {serverVersion >= 80000}? identifier
42714281
;
42724282

4273-
columnName:
4283+
/* @CHANGED: Replaced more universally with "fieldIdentifier" as per sql_yacc.yy. */
4284+
/*columnName:
42744285
// With server 8.0 this became a simple identifier.
42754286
{serverVersion >= 80000}? identifier
42764287
| {serverVersion < 80000}? fieldIdentifier
4277-
;
4288+
;*/
42784289

42794290
// A reference to a column of the object we are working on.
42804291
columnInternalRef:
@@ -4340,12 +4351,14 @@ triggerRef:
43404351

43414352
viewName:
43424353
qualifiedIdentifier
4343-
| dotIdentifier
4354+
/* @CHANGED: Added missing version constraint. */
4355+
| {serverVersion < 80000}? dotIdentifier
43444356
;
43454357

43464358
viewRef:
43474359
qualifiedIdentifier
4348-
| dotIdentifier
4360+
/* @CHANGED: Added missing version constraint. */
4361+
| {serverVersion < 80000}? dotIdentifier
43494362
;
43504363

43514364
tablespaceName:
@@ -4390,7 +4403,8 @@ engineRef:
43904403

43914404
tableName:
43924405
qualifiedIdentifier
4393-
| dotIdentifier
4406+
/* @CHANGED: Added missing version constraint. */
4407+
| {serverVersion < 80000}? dotIdentifier
43944408
;
43954409

43964410
filterTableRef: // Always qualified.
@@ -4403,7 +4417,8 @@ tableRefWithWildcard:
44034417

44044418
tableRef:
44054419
qualifiedIdentifier
4406-
| dotIdentifier
4420+
/* @CHANGED: Added missing version constraint. */
4421+
| {serverVersion < 80000}? dotIdentifier
44074422
;
44084423

44094424
tableRefList:

0 commit comments

Comments
 (0)