ROLLBACK
Description
Stops the current transaction and discards all updates made by that transaction. (Redshift SQL Language Reference ROLLBACK)
Grammar Syntax
ROLLBACK [WORK | TRANSACTION]Sample Source Patterns
Setup data
Redshift
CREATE TABLE transaction_values_test
(
col1 INTEGER
);Snowflake
ROLLBACK with TRANSACTION keyword
The TRANSACTION keyword is not supported in Snowflake. However, since it does not have an impact on functionality it will just be removed.
Redshift
Snowflake
ROLLBACK in a default transaction behavior procedure (without NONATOMIC clause)
In order to avoid out of scope transaction exceptions in Snowflake, the usages of ROLLBACK will be matched with BEGIN TRANSACTION.
When multiple transaction control statements are present in the procedure, multiple BEGIN TRANSACTION statements will be generated after every each one of them to emulate the Redshift transaction behavior.
Redshift
Snowflake
ROLLBACK in a procedure with NONATOMIC behavior
The NONATOMIC behavior from Redshift is emulated in Snowflake by using the session parameter AUTOCOMMIT set to true.
Since the AUTOCOMMIT session parameter is assumed to be true by SnowConvert, the ROLLBACK statement inside NONATOMIC procedures is left as is.
Redshift
Snowflake
Known Issues
1. ROLLBACK inside a nested procedure call
In Redshift, when a ROLLBACK statement is specified in a nested procedure call, the command will commit all pending work from previous statements in the current and parent scopes. Committing the parent scope actions is not supported in Snowflake, when this case is detected an FDM will be generated.
Redshift
Snowflake
2. ROLLBACK of DDL statements
In Snowflake, DDL statements perform an implicit commit whenever they are executed inside a procedure, making effective all the work prior to executing the DDL as well as the DDL itself. This causes the ROLLBACK statement to not be able to discard any changes before that point, this issue will be informed using an FDM.
Redshift
Snowflake
Known Issues
There are no known issues.
Related EWIs
SSC-FDM-RS0006: Called procedure contains usages of COMMIT/ROLLBACK, modifying the current transaction in child scopes is not supported in Snowflake.
SSC-FDM-RS0007: DDL statements perform an automatic COMMIT, ROLLBACK will not work as expected.
Last updated
