Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for DBCC CHECKIDENT #1646

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions contrib/babelfishpg_tsql/antlr/TSqlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,22 @@ CHANGETABLE: C H A N G E T A B L E;
CHANGE_RETENTION: C H A N G E UNDERLINE R E T E N T I O N;
CHANGE_TRACKING: C H A N G E UNDERLINE T R A C K I N G;
CHECK: C H E C K;
CHECKDB: C H E C K D B;
CHECKFILEGROUP: C H E C K F I L E G R O U P;
CHECKIDENT: C H E C K I D E N T;
CHECKPOINT: C H E C K P O I N T;
CHECKSUM: C H E C K S U M;
CHECKSUM_AGG: C H E C K S U M UNDERLINE A G G;
CHECKTABLE: C H E C K T A B L E;
CHECK_EXPIRATION: C H E C K UNDERLINE E X P I R A T I O N;
CHECK_POLICY: C H E C K UNDERLINE P O L I C Y;
CLASSIFIER: C L A S S I F I E R;
CLASSIFIER_FUNCTION: C L A S S I F I E R UNDERLINE F U N C T I O N;
CLEANUP: C L E A N U P;
CLEANTABLE: C L E A N T A B L E;
CLEANUP_POLICY: C L E A N U P UNDERLINE P O L I C Y;
CLEAR: C L E A R;
CLONEDATABASE: C L O N E D A T A B A S E;
CLOSE: C L O S E;
CLUSTER: C L U S T E R;
CLUSTERED: C L U S T E R E D;
Expand Down Expand Up @@ -247,6 +253,7 @@ DATE_CORRELATION_OPTIMIZATION: D A T E UNDERLINE C O R R E L
DAY: D A Y;
DAYS: D A Y S;
DBCC: D B C C;
DBREINDEX: D B R E I N D E X;
DB_CHAINING: D B UNDERLINE C H A I N I N G;
DB_FAILOVER: D B UNDERLINE F A I L O V E R;
DDL: D D L;
Expand Down Expand Up @@ -297,6 +304,7 @@ DOLLAR_ROWGUID: DOLLAR R O W G U I D;
DOLLAR_TO_ID: DOLLAR T O UNDERLINE I D; // graph
DOUBLE: D O U B L E;
DROP: D R O P;
DROPCLEANBUFFERS: D R O P C L E A N B U F F E R S;
DTC_SUPPORT: D T C UNDERLINE S U P P O R T;
DUMP: D U M P;
DYNAMIC: D Y N A M I C;
Expand Down Expand Up @@ -386,6 +394,9 @@ FORMAT: F O R M A T;
FORWARD_ONLY: F O R W A R D UNDERLINE O N L Y;
FORMAT_OPTIONS: F O R M A T UNDERLINE O P T I O N S;
FORMAT_TYPE: F O R M A T UNDERLINE T Y P E;
FREEPROCCACHE: F R E E P R O C C A C H E;
FREESESSIONCACHE: F R E E S E S S I O N C A C H E;
FREESYSTEMCACHE: F R E E S Y S T E M C A C H E;
FREETEXT: F R E E T E X T;
FREETEXTTABLE: F R E E T E X T T A B L E;
FROM: F R O M;
Expand Down Expand Up @@ -423,6 +434,7 @@ HASHED: H A S H E D;
HAVING: H A V I N G;
HEALTHCHECKTIMEOUT: H E A L T H C H E C K T I M E O U T;
HEALTH_CHECK_TIMEOUT: H E A L T H UNDERLINE C H E C K UNDERLINE T I M E O U T;
HELP: H E L P;
HIDDEN_RENAMED: H I D D E N;
HIGH: H I G H;
HINT: H I N T;
Expand All @@ -432,6 +444,7 @@ HOLDLOCK: H O L D L O C K;
HONOR_BROKER_PRIORITY: H O N O R UNDERLINE B R O K E R UNDERLINE P R I O R I T Y;
HOUR: H O U R;
HOURS: H O U R S;
INDEXDEFRAG: I N D E X D E F R A G;
IDENTITY: I D E N T I T Y;
IDENTITYCOL: I D E N T I T Y C O L;
IDENTITY_INSERT: I D E N T I T Y UNDERLINE I N S E R T;
Expand All @@ -454,6 +467,7 @@ INIT: I N I T;
INITIATOR: I N I T I A T O R;
INNER: I N N E R;
INPUT: I N P U T;
INPUTBUFFER: I N P U T B U F F E R;
INSENSITIVE: I N S E N S I T I V E;
INSERT: I N S E R T;
INSERTED: I N S E R T E D;
Expand Down Expand Up @@ -602,6 +616,7 @@ NONE: N O N E;
NON_TRANSACTED_ACCESS: N O N UNDERLINE T R A N S A C T E D UNDERLINE A C C E S S;
NORECOMPUTE: N O R E C O M P U T E;
NORECOVERY: N O R E C O V E R Y;
NORESEED: N O R E S E E D;
NOREWIND: N O R E W I N D;
NOSKIP: N O S K I P;
NOT: N O T;
Expand Down Expand Up @@ -642,6 +657,7 @@ OPENDATASOURCE: O P E N D A T A S O U R C E;
OPENJSON: O P E N J S O N;
OPENQUERY: O P E N Q U E R Y;
OPENROWSET: O P E N R O W S E T;
OPENTRAN: O P E N T R A N;
OPENXML: O P E N X M L;
OPEN_EXISTING: O P E N UNDERLINE E X I S T I N G;
OPERATIONS: O P E R A T I O N S;
Expand All @@ -654,6 +670,7 @@ ORDER: O R D E R;
OUT: O U T;
OUTER: O U T E R;
OUTPUT: O U T P U T;
OUTPUTBUFFER: O U T P U T B U F F E R;
OVER: O V E R;
OVERRIDE: O V E R R I D E;
OWNER: O W N E R;
Expand Down Expand Up @@ -710,6 +727,7 @@ PRIVATE: P R I V A T E;
PRIVATE_KEY: P R I V A T E UNDERLINE K E Y;
PRIVILEGES: P R I V I L E G E S;
PROC: P R O C;
PROCCACHE: P R O C C A C H E;
PROCEDURE: P R O C E D U R E;
PROCEDURE_CACHE: P R O C E D U R E UNDERLINE C A C H E;
PROCEDURE_NAME: P R O C E D U R E UNDERLINE N A M E;
Expand Down Expand Up @@ -780,6 +798,7 @@ REQUEST_MEMORY_GRANT_TIMEOUT_SEC: R E Q U E S T UNDERLINE M E M
REQUIRED: R E Q U I R E D;
REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT: R E Q U I R E D UNDERLINE S Y N C H R O N I Z E D UNDERLINE S E C O N D A R I E S UNDERLINE T O UNDERLINE C O M M I T;
RESAMPLE: R E S A M P L E;
RESEED: R E S E E D;
RESERVE_DISK_SPACE: R E S E R V E UNDERLINE D I S K UNDERLINE S P A C E;
RESET: R E S E T;
RESOURCE: R E S O U R C E;
Expand Down Expand Up @@ -870,10 +889,14 @@ SETS: S E T S;
SETTINGS: S E T T I N G S;
SETUSER: S E T U S E R;
SHARE: S H A R E;
SHOWCONTIG: S H O W C O N T I G;
SHOWPLAN: S H O W P L A N;
SHOWPLAN_ALL: S H O W P L A N UNDERLINE A L L;
SHOWPLAN_TEXT: S H O W P L A N UNDERLINE T E X T;
SHOWPLAN_XML: S H O W P L A N UNDERLINE X M L;
SHOW_STATISTICS: S H O W UNDERLINE S T A T I S T I C S;
SHRINKDATABASE: S H R I N K D A T A B A S E;
SHRINKFILE: S H R I N K F I L E;
SHRINKLOG: S H R I N K L O G;
SHUTDOWN: S H U T D O W N;
SID: S I D;
Expand All @@ -898,6 +921,7 @@ SQL: S Q L;
SQLDUMPERFLAGS: S Q L D U M P E R F L A G S;
SQLDUMPERPATH: S Q L D U M P E R P A T H;
SQLDUMPERTIMEOUT: S Q L D U M P E R T I M E O U T S;
SQLPERF: S Q L P E R F;
STALE_CAPTURE_POLICY_THRESHOLD: S T A L E UNDERLINE C A P T U R E UNDERLINE P O L I C Y UNDERLINE T H R E S H O L D;
STALE_QUERY_THRESHOLD_DAYS: S T A L E UNDERLINE Q U E R Y UNDERLINE T H R E S H O L D UNDERLINE D A Y S;
STANDBY: S T A N D B Y;
Expand Down Expand Up @@ -969,7 +993,10 @@ TOSTRING: T O S T R I N G;
TOTAL_COMPILE_CPU_TIME_MS: T O T A L UNDERLINE C O M P I L E UNDERLINE C P U UNDERLINE T I M E UNDERLINE M S;
TOTAL_EXECUTION_CPU_TIME_MS: T O T A L UNDERLINE E X E C U T I O N UNDERLINE C P U UNDERLINE T I M E UNDERLINE M S;
TRACE: T R A C E;
TRACEOFF: T R A C E O F F;
TRACEON: T R A C E O N;
TRACKING: T R A C K I N G;
TRACESTATUS: T R A C E S T A T U S;
TRACK_CAUSALITY: T R A C K UNDERLINE C A U S A L I T Y;
TRACK_COLUMNS_UPDATED: T R A C K UNDERLINE C O L U M N S UNDERLINE U P D A T E D;
TRAN: T R A N;
Expand Down Expand Up @@ -1008,13 +1035,15 @@ UNPIVOT: U N P I V O T;
UNSAFE: U N S A F E;
UOW: U O W;
UPDATE: U P D A T E;
UPDATEUSAGE: U P D A T E U S A G E;
UPDATETEXT: U P D A T E T E X T;
UPDLOCK: U P D L O C K;
URL: U R L;
USE: U S E;
USE_TYPE_DEFAULT: U S E UNDERLINE T Y P E UNDERLINE D E F A U L T;
USED: U S E D;
USER: U S E R;
USEROPTIONS: U S E R O P T I O N S;
USING: U S I N G;
VALIDATION: V A L I D A T I O N;
VALID_XML: V A L I D UNDERLINE X M L;
Expand Down
62 changes: 58 additions & 4 deletions contrib/babelfishpg_tsql/antlr/TSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -3094,13 +3094,40 @@ shutdown_statement
;

dbcc_statement
: DBCC name=dbcc_command ( LR_BRACKET expression_list RR_BRACKET )? (WITH dbcc_options)? SEMI?
: DBCC CHECKIDENT ( LR_BRACKET table_name ( (COMMA NORESEED) | (COMMA RESEED (COMMA MINUS? new_value=(DECIMAL | FLOAT))?) )? RR_BRACKET ) (WITH dbcc_options)? SEMI?
| DBCC name=dbcc_command ( LR_BRACKET expression_list RR_BRACKET )? (WITH dbcc_options)? SEMI?
//These are dbcc commands with strange syntax that doesn't fit the regular dbcc syntax
| DBCC SHRINKLOG ( LR_BRACKET SIZE EQUAL (constant_expression| id | DEFAULT) (KB | MB | GB | TB)? RR_BRACKET )? (WITH dbcc_options)? SEMI?
;
;

dbcc_command
: ID | keyword
: ID
| CHECKDB
| CHECKFILEGROUP
| CHECKTABLE
| CLEANTABLE
| CLONEDATABASE
| DBREINDEX
| DROPCLEANBUFFERS
| FREEPROCCACHE
| FREESESSIONCACHE
| FREESYSTEMCACHE
| HELP
| INDEXDEFRAG
| INPUTBUFFER
| OPENTRAN
| OUTPUTBUFFER
| PROCCACHE
| SHOW_STATISTICS
| SHOWCONTIG
| SHRINKDATABASE
| SHRINKFILE
| SQLPERF
| TRACEOFF
| TRACEON
| TRACESTATUS
| UPDATEUSAGE
| USEROPTIONS
;

dbcc_options
Expand Down Expand Up @@ -4271,15 +4298,21 @@ keyword
| CHANGETABLE
| CHANGE_RETENTION
| CHANGE_TRACKING
| CHECKDB
| CHECKFILEGROUP
| CHECKIDENT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need these changes ? since in the dbcc_command rule we have already explicitly specified them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Removing.

| CHECKSUM
| CHECKSUM_AGG
| CHECKTABLE
| CHECK_EXPIRATION
| CHECK_POLICY
| CLASSIFIER
| CLASSIFIER_FUNCTION
| CLEANTABLE
| CLEANUP
| CLEANUP_POLICY
| CLEAR
| CLEAR
| CLONEDATABASE
| CLUSTER
| COALESCE
| COLLECTION
Expand Down Expand Up @@ -4342,6 +4375,7 @@ keyword
| DATE_FORMAT
| DAY
| DAYS
| DBREINDEX
| DB_CHAINING
| DB_FAILOVER
| DDL
Expand Down Expand Up @@ -4375,6 +4409,7 @@ keyword
| DISTRIBUTED_AGG
| DISTRIBUTION
| DOCUMENT
| DROPCLEANBUFFERS
| DTC_SUPPORT
| DYNAMIC
| EDGE
Expand Down Expand Up @@ -4448,6 +4483,9 @@ keyword
| FORMAT_OPTIONS
| FORMAT_TYPE
| FORWARD_ONLY
| FREEPROCCACHE
| FREESESSIONCACHE
| FREESYSTEMCACHE
| FULLSCAN
| FULLTEXT
| GB
Expand Down Expand Up @@ -4476,6 +4514,7 @@ keyword
| HASHED
| HEALTHCHECKTIMEOUT
| HEALTH_CHECK_TIMEOUT
| HELP
| HIDDEN_RENAMED
| HIGH
| HINT
Expand All @@ -4498,10 +4537,12 @@ keyword
| INCLUDE_NULL_VALUES
| INCREMENT
| INCREMENTAL
| INDEXDEFRAG
| INFINITE
| INIT
| INITIATOR
| INPUT
| INPUTBUFFER
| INSENSITIVE
| INSERTED
| INSTEAD
Expand Down Expand Up @@ -4667,13 +4708,15 @@ keyword
| ONLY
| ON_FAILURE
| OPENJSON
| OPENTRAN
| OPEN_EXISTING
| OPERATIONS
| OPERATION_MODE
| OPTIMISTIC
| OPTIMIZE
| OUT
| OUTPUT
| OUTPUTBUFFER
| OVERRIDE
| OWNER
| OWNERSHIP
Expand Down Expand Up @@ -4721,6 +4764,7 @@ keyword
| PRIVATE
| PRIVATE_KEY
| PRIVILEGES
| PROCCACHE
| PROCEDURE_CACHE
| PROCEDURE_NAME
| PROCESS
Expand Down Expand Up @@ -4849,10 +4893,14 @@ keyword
| SETS
| SETTINGS
| SHARE
| SHOWCONTIG
| SHOWPLAN
| SHOWPLAN_ALL
| SHOWPLAN_TEXT
| SHOWPLAN_XML
| SHOW_STATISTICS
| SHRINKDATABASE
| SHRINKFILE
| SHRINKLOG
| SID
| SIGNATURE
Expand All @@ -4875,6 +4923,7 @@ keyword
| SQLDUMPERFLAGS
| SQLDUMPERPATH
| SQLDUMPERTIMEOUT
| SQLPERF
| STALE_CAPTURE_POLICY_THRESHOLD
| STALE_QUERY_THRESHOLD_DAYS
| STANDBY
Expand Down Expand Up @@ -4936,6 +4985,9 @@ keyword
| TOTAL_COMPILE_CPU_TIME_MS
| TOTAL_EXECUTION_CPU_TIME_MS
| TRACE
| TRACEOFF
| TRACEON
| TRACESTATUS
| TRACKING
| TRACK_CAUSALITY
| TRACK_COLUMNS_UPDATED
Expand Down Expand Up @@ -4965,8 +5017,10 @@ keyword
| UNMASK
| UNSAFE
| UOW
| UPDATEUSAGE
| URL
| USED
| USEROPTIONS
| USE_TYPE_DEFAULT
| USING
| VALIDATION
Expand Down
1 change: 1 addition & 0 deletions contrib/babelfishpg_tsql/src/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ stmt_default_act(Walker_context *ctx, PLtsql_stmt *stmt)
case PLTSQL_STMT_USEDB:
case PLTSQL_STMT_GRANTDB:
case PLTSQL_STMT_INSERT_BULK:
case PLTSQL_STMT_DBCC:
case PLTSQL_STMT_SET_EXPLAIN_MODE:
/* TSQL-only executable node */
case PLTSQL_STMT_SAVE_CTX:
Expand Down
3 changes: 3 additions & 0 deletions contrib/babelfishpg_tsql/src/iterative_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ dispatch_stmt(PLtsql_execstate *estate, PLtsql_stmt *stmt)
}
exec_stmt_restore_ctx_partial(estate, (PLtsql_stmt_restore_ctx_partial *) stmt);
break;
case PLTSQL_STMT_DBCC:
exec_stmt_dbcc(estate, (PLtsql_stmt_dbcc *) stmt);
break;
case PLTSQL_STMT_KILL:
exec_stmt_kill(estate, (PLtsql_stmt_kill *) stmt);
break;
Expand Down
Loading