diff --git a/contrib/babelfishpg_tsql/sql/sys_procedures.sql b/contrib/babelfishpg_tsql/sql/sys_procedures.sql index d0d3fcf837..306f3ed155 100644 --- a/contrib/babelfishpg_tsql/sql/sys_procedures.sql +++ b/contrib/babelfishpg_tsql/sql/sys_procedures.sql @@ -106,7 +106,8 @@ CREATE VIEW sys.babelfish_configurations_view as FROM pg_catalog.pg_settings WHERE name collate "C" like 'babelfishpg_tsql.explain_%' OR name collate "C" like 'babelfishpg_tsql.escape_hatch_%' OR - name collate "C" = 'babelfishpg_tsql.enable_pg_hint'; + name collate "C" = 'babelfishpg_tsql.enable_pg_hint' OR + name collate "C" like 'babelfishpg_tsql.isolation_level_%'; GRANT SELECT on sys.babelfish_configurations_view TO PUBLIC; CREATE OR REPLACE PROCEDURE sys.sp_babelfish_configure(IN "@option_name" varchar(128), IN "@option_value" varchar(128), IN "@option_scope" varchar(128)) diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql index 65b7ffdb38..447a82c68a 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql @@ -3023,6 +3023,16 @@ GRANT EXECUTE ON FUNCTION sys.FORMAT(IN anyelement, IN NVARCHAR, IN VARCHAR) TO -- Please have this be one of the last statements executed in this upgrade script. DROP PROCEDURE sys.babelfish_drop_deprecated_object(varchar, varchar, varchar); + +CREATE OR REPLACE VIEW sys.babelfish_configurations_view as + SELECT * + FROM pg_catalog.pg_settings + WHERE name collate "C" like 'babelfishpg_tsql.explain_%' OR + name collate "C" like 'babelfishpg_tsql.escape_hatch_%' OR + name collate "C" = 'babelfishpg_tsql.enable_pg_hint' OR + name collate "C" like 'babelfishpg_tsql.isolation_level_%'; +GRANT SELECT on sys.babelfish_configurations_view TO PUBLIC; + -- After upgrade, always run analyze for all babelfish catalogs. CALL sys.analyze_babelfish_catalogs(); diff --git a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y index b595c5adc1..6b09369007 100644 --- a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y +++ b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y @@ -4338,11 +4338,20 @@ tsql_IsolationLevelStr: } | REPEATABLE READ { - TSQLInstrumentation(INSTR_UNSUPPORTED_TSQL_ISOLATION_LEVEL_REPEATABLE_READ); - ereport(ERROR, + if (pltsql_isolation_level_repeatable_read) + { + TSQLInstrumentation(INSTR_TSQL_ISOLATION_LEVEL_REPEATABLE_READ); + $$ = "repeatable read"; + } + else + { + TSQLInstrumentation(INSTR_UNSUPPORTED_TSQL_ISOLATION_LEVEL_REPEATABLE_READ); + ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("REPEATABLE READ isolation level is not supported"), + errmsg("Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level."), parser_errposition(@1))); + } + } | SNAPSHOT { @@ -4351,11 +4360,19 @@ tsql_IsolationLevelStr: } | SERIALIZABLE { - TSQLInstrumentation(INSTR_UNSUPPORTED_TSQL_ISOLATION_LEVEL_SERIALIZABLE); - ereport(ERROR, + if (pltsql_isolation_level_serializable) + { + TSQLInstrumentation(INSTR_TSQL_ISOLATION_LEVEL_SERIALIZABLE); + $$ = "serializable"; + } + else + { + TSQLInstrumentation(INSTR_UNSUPPORTED_TSQL_ISOLATION_LEVEL_SERIALIZABLE); + ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("SERIALIZABLE isolation level is not supported"), + errmsg("Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level."), parser_errposition(@1))); + } } ; diff --git a/contrib/babelfishpg_tsql/src/guc.c b/contrib/babelfishpg_tsql/src/guc.c index 3ed7922902..adcdd588be 100644 --- a/contrib/babelfishpg_tsql/src/guc.c +++ b/contrib/babelfishpg_tsql/src/guc.c @@ -128,6 +128,12 @@ static const struct config_enum_entry escape_hatch_options[] = { {NULL, EH_NULL, false}, }; +static const struct config_enum_entry bbf_isolation_options[] = { + {"off", ISOLATION_OFF, false}, + {"pg_isolation", PG_ISOLATION, false}, + {NULL, ISOLATION_OFF, false}, +}; + static bool check_ansi_null_dflt_on(bool *newval, void **extra, GucSource source) { @@ -1207,6 +1213,8 @@ int escape_hatch_rowversion = EH_STRICT; int escape_hatch_showplan_all = EH_STRICT; int escape_hatch_checkpoint = EH_IGNORE; int escape_hatch_set_transaction_isolation_level = EH_STRICT; +int pltsql_isolation_level_repeatable_read = ISOLATION_OFF; +int pltsql_isolation_level_serializable = ISOLATION_OFF; void define_escape_hatch_variables(void) @@ -1557,6 +1565,28 @@ define_escape_hatch_variables(void) PGC_USERSET, GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_DISALLOW_IN_AUTO_FILE, NULL, NULL, NULL); + + /* REPEATABLE READ MAPPING */ + DefineCustomEnumVariable("babelfishpg_tsql.isolation_level_repeatable_read", + gettext_noop("Select mapping for isolation level reapeatable read"), + NULL, + &pltsql_isolation_level_repeatable_read, + ISOLATION_OFF, + bbf_isolation_options, + PGC_USERSET, + GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_DISALLOW_IN_AUTO_FILE, + NULL, NULL, NULL); + + /* SERIALIZABLE MAPPING */ + DefineCustomEnumVariable("babelfishpg_tsql.isolation_level_serializable", + gettext_noop("Select mapping for isolation level serializable"), + NULL, + &pltsql_isolation_level_serializable, + ISOLATION_OFF, + bbf_isolation_options, + PGC_USERSET, + GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_DISALLOW_IN_AUTO_FILE, + NULL, NULL, NULL); } void diff --git a/contrib/babelfishpg_tsql/src/guc.h b/contrib/babelfishpg_tsql/src/guc.h index 1cb47037de..19f2860a29 100644 --- a/contrib/babelfishpg_tsql/src/guc.h +++ b/contrib/babelfishpg_tsql/src/guc.h @@ -10,11 +10,18 @@ typedef enum EscapeHatchOption EH_STRICT, EH_IGNORE, EH_NULL } EscapeHatchOption; +typedef enum IsolationOptions +{ + ISOLATION_OFF, PG_ISOLATION +} IsolationOptions; + extern bool pltsql_fmtonly; extern bool pltsql_enable_create_alter_view_from_pg; extern bool pltsql_enable_linked_servers; extern bool pltsql_allow_windows_login; extern char *pltsql_psql_logical_babelfish_db_name; +extern int pltsql_isolation_level_repeatable_read; +extern int pltsql_isolation_level_serializable; extern void define_custom_variables(void); extern void pltsql_validate_set_config_function(char *name, char *value); diff --git a/contrib/babelfishpg_tsql/src/pltsql_instr.h b/contrib/babelfishpg_tsql/src/pltsql_instr.h index ae16a39b5a..0fbc729595 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_instr.h +++ b/contrib/babelfishpg_tsql/src/pltsql_instr.h @@ -632,8 +632,10 @@ typedef enum PgTsqlInstrMetricType INSTR_TSQL_ISOLATION_LEVEL_READ_UNCOMMITTED, INSTR_TSQL_ISOLATION_LEVEL_READ_COMMITTED, + INSTR_TSQL_ISOLATION_LEVEL_REPEATABLE_READ, INSTR_UNSUPPORTED_TSQL_ISOLATION_LEVEL_REPEATABLE_READ, INSTR_TSQL_ISOLATION_LEVEL_SNAPSHOT, + INSTR_TSQL_ISOLATION_LEVEL_SERIALIZABLE, INSTR_UNSUPPORTED_TSQL_ISOLATION_LEVEL_SERIALIZABLE, INSTR_UNSUPPORTED_TSQL_SELECT_COL_ALIAS, diff --git a/test/JDBC/expected/BABEL-3214.out b/test/JDBC/expected/BABEL-3214.out index c53402de2a..d770fdc5af 100644 --- a/test/JDBC/expected/BABEL-3214.out +++ b/test/JDBC/expected/BABEL-3214.out @@ -44,7 +44,7 @@ SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: REPEATABLE READ isolation level is not supported)~~ +~~ERROR (Message: Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level.)~~ SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; @@ -65,7 +65,7 @@ SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: SERIALIZABLE isolation level is not supported)~~ +~~ERROR (Message: Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level.)~~ SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; @@ -98,3 +98,92 @@ smallint 5 ~~END~~ + +SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','pg_isolation',false); +SELECT set_config('babelfishpg_tsql.isolation_level_serializable','pg_isolation',false); +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO +~~START~~ +text +pg_isolation +~~END~~ + +~~START~~ +text +pg_isolation +~~END~~ + +~~START~~ +varchar +read uncommitted +~~END~~ + +~~START~~ +smallint +1 +~~END~~ + + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO +~~START~~ +varchar +read committed +~~END~~ + +~~START~~ +smallint +2 +~~END~~ + + +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO +~~START~~ +varchar +repeatable read +~~END~~ + +~~START~~ +smallint +5 +~~END~~ + + +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO +~~START~~ +varchar +serializable +~~END~~ + +~~START~~ +smallint +4 +~~END~~ + + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO +~~START~~ +varchar +repeatable read +~~END~~ + +~~START~~ +smallint +5 +~~END~~ + diff --git a/test/JDBC/expected/BABEL-UNSUPPORTED.out b/test/JDBC/expected/BABEL-UNSUPPORTED.out index bfdd35f053..8f3de65c5f 100644 --- a/test/JDBC/expected/BABEL-UNSUPPORTED.out +++ b/test/JDBC/expected/BABEL-UNSUPPORTED.out @@ -2035,6 +2035,8 @@ babelfishpg_tsql.explain_summary#!#on#!#Include summary information (e.g., total babelfishpg_tsql.explain_timing#!#on#!#Include actual startup time and time spent in each node in the output babelfishpg_tsql.explain_verbose#!#off#!#Display additional information regarding the plan babelfishpg_tsql.explain_wal#!#off#!#Include information on WAL record generation +babelfishpg_tsql.isolation_level_repeatable_read#!#off#!#Select mapping for isolation level reapeatable read +babelfishpg_tsql.isolation_level_serializable#!#off#!#Select mapping for isolation level serializable ~~END~~ @@ -2101,6 +2103,8 @@ babelfishpg_tsql.explain_summary#!#on#!#Include summary information (e.g., total babelfishpg_tsql.explain_timing#!#on#!#Include actual startup time and time spent in each node in the output babelfishpg_tsql.explain_verbose#!#off#!#Display additional information regarding the plan babelfishpg_tsql.explain_wal#!#off#!#Include information on WAL record generation +babelfishpg_tsql.isolation_level_repeatable_read#!#off#!#Select mapping for isolation level reapeatable read +babelfishpg_tsql.isolation_level_serializable#!#off#!#Select mapping for isolation level serializable ~~END~~ @@ -2148,6 +2152,8 @@ babelfishpg_tsql.explain_summary#!#on#!#Include summary information (e.g., total babelfishpg_tsql.explain_timing#!#on#!#Include actual startup time and time spent in each node in the output babelfishpg_tsql.explain_verbose#!#off#!#Display additional information regarding the plan babelfishpg_tsql.explain_wal#!#off#!#Include information on WAL record generation +babelfishpg_tsql.isolation_level_repeatable_read#!#off#!#Select mapping for isolation level reapeatable read +babelfishpg_tsql.isolation_level_serializable#!#off#!#Select mapping for isolation level serializable ~~END~~ diff --git a/test/JDBC/expected/BABEL_4145.out b/test/JDBC/expected/BABEL_4145.out new file mode 100644 index 0000000000..e52cb738e6 --- /dev/null +++ b/test/JDBC/expected/BABEL_4145.out @@ -0,0 +1,364 @@ +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'off', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'off', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +off +~~END~~ + +~~START~~ +text +off +~~END~~ + +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'pg_isolatin' +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid value for parameter "babelfishpg_tsql.isolation_level_repeatable_read": "pg_isolatin")~~ + +EXEC sp_babelfish_configure 'isolation_level_serializable', 'of' +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid value for parameter "babelfishpg_tsql.isolation_level_serializable": "of")~~ + +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +off +~~END~~ + +~~START~~ +text +off +~~END~~ + +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'oFf' +GO +EXEC sp_babelfish_configure 'isolation_level_serializable', 'OfF' +GO +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +off +~~END~~ + +~~START~~ +text +off +~~END~~ + +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'Pg_ISOLaTiOn' +GO +EXEC sp_babelfish_configure 'isolation_level_serializable', 'pG_isolaTION' +GO +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +pg_isolation +~~END~~ + +~~START~~ +text +pg_isolation +~~END~~ + +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +off +~~END~~ + +~~START~~ +text +off +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read uncommitted +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read committed +~~END~~ + +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level.)~~ + +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read committed +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level.)~~ + +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'pg_isolation', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'off', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +pg_isolation +~~END~~ + +~~START~~ +text +off +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read uncommitted +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read committed +~~END~~ + +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level.)~~ + +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'off', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'pg_isolation', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +off +~~END~~ + +~~START~~ +text +pg_isolation +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read uncommitted +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read committed +~~END~~ + +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level.)~~ + +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read committed +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +serializable +~~END~~ + +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'pg_isolation', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'pg_isolation', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +~~START~~ +text +pg_isolation +~~END~~ + +~~START~~ +text +pg_isolation +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read uncommitted +~~END~~ + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +read committed +~~END~~ + +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +repeatable read +~~END~~ + +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT current_setting('transaction_isolation'); +GO +~~START~~ +text +serializable +~~END~~ + +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'off', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'off', 'server' +GO +-- terminate-tsql-conn diff --git a/test/JDBC/expected/TestIsolationLevels.out b/test/JDBC/expected/TestIsolationLevels.out index 0d5e21740c..83a45c4950 100644 --- a/test/JDBC/expected/TestIsolationLevels.out +++ b/test/JDBC/expected/TestIsolationLevels.out @@ -1,3 +1,17 @@ +SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','off',false); +SELECT set_config('babelfishpg_tsql.isolation_level_serializable','off',false); +GO +~~START~~ +text +off +~~END~~ + +~~START~~ +text +off +~~END~~ + + set transaction isolation level read uncommitted; go @@ -8,7 +22,7 @@ set transaction isolation level repeatable read; go ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: REPEATABLE READ isolation level is not supported)~~ +~~ERROR (Message: Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level.)~~ set transaction isolation level snapshot; @@ -18,7 +32,7 @@ set transaction isolation level serializable; go ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: SERIALIZABLE isolation level is not supported)~~ +~~ERROR (Message: Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level.)~~ select set_config('default_transaction_isolation', 'read uncommitted', false); diff --git a/test/JDBC/expected/TestTransactionsSQLBatch.out b/test/JDBC/expected/TestTransactionsSQLBatch.out index 1352248539..5db75c6d93 100644 --- a/test/JDBC/expected/TestTransactionsSQLBatch.out +++ b/test/JDBC/expected/TestTransactionsSQLBatch.out @@ -108,7 +108,7 @@ int set transaction isolation level repeatable read; ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: REPEATABLE READ isolation level is not supported)~~ +~~ERROR (Message: Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level.)~~ #show transaction_isolation; #show default_transaction_isolation; @@ -374,7 +374,7 @@ int set transaction isolation level serializable; ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: SERIALIZABLE isolation level is not supported)~~ +~~ERROR (Message: Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level.)~~ #show transaction_isolation; #show default_transaction_isolation; diff --git a/test/JDBC/expected/sys_babelfish_configurations_view-vu-verify.out b/test/JDBC/expected/sys_babelfish_configurations_view-vu-verify.out index 2854224556..3acde3ea4a 100644 --- a/test/JDBC/expected/sys_babelfish_configurations_view-vu-verify.out +++ b/test/JDBC/expected/sys_babelfish_configurations_view-vu-verify.out @@ -2,7 +2,7 @@ SELECT * FROM sys_babelfish_configurations_view_vu_prepare_view GO ~~START~~ int -40 +42 ~~END~~ @@ -10,7 +10,7 @@ EXEC sys_babelfish_configurations_view_vu_prepare_proc GO ~~START~~ int -40 +42 ~~END~~ @@ -18,7 +18,7 @@ SELECT * FROM sys_babelfish_configurations_view_vu_prepare_func() GO ~~START~~ int -40 +42 ~~END~~ diff --git a/test/JDBC/input/BABEL-3214.sql b/test/JDBC/input/BABEL-3214.sql index f047043dbb..ecf8020a3c 100644 --- a/test/JDBC/input/BABEL-3214.sql +++ b/test/JDBC/input/BABEL-3214.sql @@ -39,4 +39,33 @@ GO SET TRANSACTION ISOLATION LEVEL SNAPSHOT; SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; -GO \ No newline at end of file +GO + +SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','pg_isolation',false); +SELECT set_config('babelfishpg_tsql.isolation_level_serializable','pg_isolation',false); +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO + +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO + +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO + +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +SELECT CAST(current_setting('transaction_isolation') AS VARCHAR); +SELECT transaction_isolation_level from sys.dm_exec_sessions WHERE session_id = @@SPID; +GO diff --git a/test/JDBC/input/BABEL_4145.mix b/test/JDBC/input/BABEL_4145.mix new file mode 100644 index 0000000000..dedaba50cb --- /dev/null +++ b/test/JDBC/input/BABEL_4145.mix @@ -0,0 +1,160 @@ +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'off', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'off', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'pg_isolatin' +GO +EXEC sp_babelfish_configure 'isolation_level_serializable', 'of' +GO +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'oFf' +GO +EXEC sp_babelfish_configure 'isolation_level_serializable', 'OfF' +GO +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'Pg_ISOLaTiOn' +GO +EXEC sp_babelfish_configure 'isolation_level_serializable', 'pG_isolaTION' +GO +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT current_setting('transaction_isolation'); +GO +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'pg_isolation', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'off', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT current_setting('transaction_isolation'); +GO +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'off', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'pg_isolation', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT current_setting('transaction_isolation'); +GO +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'pg_isolation', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'pg_isolation', 'server' +GO +-- terminate-tsql-conn + +-- tsql +SELECT current_setting('babelfishpg_tsql.isolation_level_repeatable_read'); +SELECT current_setting('babelfishpg_tsql.isolation_level_serializable'); +GO +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SNAPSHOT; +GO +SELECT current_setting('transaction_isolation'); +GO +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +GO +SELECT current_setting('transaction_isolation'); +GO +-- terminate-tsql-conn + +-- tsql +EXEC sp_babelfish_configure 'isolation_level_repeatable_read', 'off', 'server' +EXEC sp_babelfish_configure 'isolation_level_serializable', 'off', 'server' +GO +-- terminate-tsql-conn \ No newline at end of file diff --git a/test/JDBC/input/transactions/TestIsolationLevels.sql b/test/JDBC/input/transactions/TestIsolationLevels.sql index 6c3ab561dd..e94b65dbf7 100644 --- a/test/JDBC/input/transactions/TestIsolationLevels.sql +++ b/test/JDBC/input/transactions/TestIsolationLevels.sql @@ -1,3 +1,7 @@ +SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','off',false); +SELECT set_config('babelfishpg_tsql.isolation_level_serializable','off',false); +GO + set transaction isolation level read uncommitted; go diff --git a/test/JDBC/parallel_query_jdbc_schedule b/test/JDBC/parallel_query_jdbc_schedule index f5360946e9..aa8aff89cf 100644 --- a/test/JDBC/parallel_query_jdbc_schedule +++ b/test/JDBC/parallel_query_jdbc_schedule @@ -102,6 +102,7 @@ ignore#!#sys-sp_statistics_100-vu-verify ignore#!#sys-sp_statistics_100-vu-cleanup ignore#!#sys-sp_statistics_100-dep-vu-verify ignore#!#BABEL-4264 +ignore#!#BABEL_4145 # Test failures caused by babel_extra_join_test_cases_northwind failure ignore#!#babelfish_sysdatabases-vu-prepare diff --git a/test/dotnet/ExpectedOutput/TestIsolationLevel.out b/test/dotnet/ExpectedOutput/TestIsolationLevel.out new file mode 100644 index 0000000000..3b45aadf9a --- /dev/null +++ b/test/dotnet/ExpectedOutput/TestIsolationLevel.out @@ -0,0 +1,48 @@ +#Q#SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','pg_isolation',false) +#D#text +pg_isolation +#Q#SELECT set_config('babelfishpg_tsql.isolation_level_serializable','off',false) +#D#text +off +#Q#select @@trancount; +#D#int +1 +#Q#select current_setting('transaction_isolation') +#D#text +repeatable read +#Q#select current_setting('default_transaction_isolation') +#D#text +repeatable read +#Q#select @@trancount; +#D#int +0 +#Q#select current_setting('transaction_isolation') +#D#text +read committed +#Q#select current_setting('default_transaction_isolation') +#D#text +read committed +#Q#SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','off',false) +#D#text +off +#Q#SELECT set_config('babelfishpg_tsql.isolation_level_serializable','pg_isolation',false) +#D#text +pg_isolation +#Q#select @@trancount; +#D#int +0 +#Q#select current_setting('transaction_isolation') +#D#text +read committed +#Q#select current_setting('default_transaction_isolation') +#D#text +read committed +#Q#select @@trancount; +#D#int +1 +#Q#select current_setting('transaction_isolation') +#D#text +serializable +#Q#select current_setting('default_transaction_isolation') +#D#text +serializable diff --git a/test/dotnet/input/Transaction/TestIsolationLevel.txt b/test/dotnet/input/Transaction/TestIsolationLevel.txt new file mode 100644 index 0000000000..5233f40c42 --- /dev/null +++ b/test/dotnet/input/Transaction/TestIsolationLevel.txt @@ -0,0 +1,31 @@ +SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','pg_isolation',false) +SELECT set_config('babelfishpg_tsql.isolation_level_serializable','off',false) + +# Begin transaction -> rollback transaction +txn#!#begin#!#isolation#!#rr +select @@trancount; +select current_setting('transaction_isolation') +select current_setting('default_transaction_isolation') +txn#!#rollback + +# Begin transaction -> error +txn#!#begin#!#isolation#!#s -- error +select @@trancount; +select current_setting('transaction_isolation') +select current_setting('default_transaction_isolation') + +SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','off',false) +SELECT set_config('babelfishpg_tsql.isolation_level_serializable','pg_isolation',false) + +# Begin transaction -> error +txn#!#begin#!#isolation#!#rr -- error +select @@trancount; +select current_setting('transaction_isolation') +select current_setting('default_transaction_isolation') + +# Begin transaction -> rollback transaction +txn#!#begin#!#isolation#!#s +select @@trancount; +select current_setting('transaction_isolation') +select current_setting('default_transaction_isolation') +txn#!#rollback \ No newline at end of file diff --git a/test/python/expected/pymssql/TestTransactionsSQLBatch.out b/test/python/expected/pymssql/TestTransactionsSQLBatch.out index f0c991b7a9..80824c2898 100644 --- a/test/python/expected/pymssql/TestTransactionsSQLBatch.out +++ b/test/python/expected/pymssql/TestTransactionsSQLBatch.out @@ -129,7 +129,7 @@ int set transaction isolation level repeatable read; ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: 'REPEATABLE READ isolation level is not supportedDB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')~~ +~~ERROR (Message: 'Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')~~ #show transaction_isolation; #show default_transaction_isolation; @@ -430,7 +430,7 @@ int # begin transaction name -> save transaction name -> rollback tran name, Rollback whole transaction set transaction isolation level serializable; ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: 'SERIALIZABLE isolation level is not supportedDB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')~~ +~~ERROR (Message: 'Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')~~ #show transaction_isolation; #show default_transaction_isolation; diff --git a/test/python/expected/pyodbc/BABEL-4145.out b/test/python/expected/pyodbc/BABEL-4145.out new file mode 100644 index 0000000000..9f8c26bd29 --- /dev/null +++ b/test/python/expected/pyodbc/BABEL-4145.out @@ -0,0 +1,76 @@ + +starting permutation : { s1s s1u1 s2u1 s1c s2c s1s } +step s1s: SELECT * from child ORDER BY child_value ASC; +~~START~~ +int#!#int +1#!#5 +2#!#10 +~~END~~ + +step s1u1: UPDATE child SET child_value = 12 where child_key = 1; +~~ROW COUNT: 1~~ + +step s2u1: UPDATE child SET child_value = 20 WHERE child_key in (SELECT TOP 1 child_key FROM child ORDER BY child_value DESC) +~~ROW COUNT: 1~~ + +step s1c: COMMIT; +~~ERROR (Code: 33557097)~~ +~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]could not serialize access due to read/write dependencies among transactions (33557097) (SQLExecDirectW))~~ + +step s2c: COMMIT; +step s1s: SELECT * from child ORDER BY child_value ASC; +~~START~~ +int#!#int +2#!#10 +1#!#12 +~~END~~ + + +starting permutation : { s1i s2i s1s s2s s2c s1c } +step s1i: INSERT INTO child VALUES (3, 15); +~~ROW COUNT: 1~~ + +step s2i: INSERT INTO child VALUES (4, 20); +~~ROW COUNT: 1~~ + +step s1s: SELECT * from child ORDER BY child_value ASC; +~~START~~ +int#!#int +1#!#5 +2#!#10 +3#!#15 +~~END~~ + +step s2s: SELECT * from child ORDER BY child_value ASC; +~~START~~ +int#!#int +1#!#5 +2#!#10 +4#!#20 +~~END~~ + +step s2c: COMMIT; +~~ERROR (Code: 33557097)~~ +~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]could not serialize access due to read/write dependencies among transactions (33557097) (SQLExecDirectW))~~ + +step s1c: COMMIT; + +starting permutation : { s1u1 s2u2 s1s s1c s2c } +step s1u1: UPDATE child SET child_value = 12 where child_key = 1; +~~ROW COUNT: 1~~ + +step s2u2: UPDATE child SET child_value = 5 where child_value >= 6 +~~ROW COUNT: 1~~ + +step s1s: SELECT * from child ORDER BY child_value ASC; +~~START~~ +int#!#int +2#!#10 +1#!#12 +~~END~~ + +step s1c: COMMIT; +~~ERROR (Code: 33557097)~~ +~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]could not serialize access due to read/write dependencies among transactions (33557097) (SQLExecDirectW))~~ + +step s2c: COMMIT; diff --git a/test/python/expected/pyodbc/BABEL-4146.out b/test/python/expected/pyodbc/BABEL-4146.out new file mode 100644 index 0000000000..7ffcc04c3c --- /dev/null +++ b/test/python/expected/pyodbc/BABEL-4146.out @@ -0,0 +1,148 @@ + +starting permutation : { s1i s2i s1c s2c } +step s1i: INSERT INTO child VALUES (1, 1); +~~ROW COUNT: 1~~ + +step s2i: INSERT INTO child VALUES (2, 1); +~~ROW COUNT: 1~~ + +step s1c: COMMIT; +step s2c: COMMIT; + +starting permutation : { s1i s2i s2c s1c } +step s1i: INSERT INTO child VALUES (1, 1); +~~ROW COUNT: 1~~ + +step s2i: INSERT INTO child VALUES (2, 1); +~~ROW COUNT: 1~~ + +step s2c: COMMIT; +step s1c: COMMIT; + +starting permutation : { s2i s1i s1c s2c } +step s2i: INSERT INTO child VALUES (2, 1); +~~ROW COUNT: 1~~ + +step s1i: INSERT INTO child VALUES (1, 1); +~~ROW COUNT: 1~~ + +step s1c: COMMIT; +step s2c: COMMIT; + +starting permutation : { s2i s1i s2c s1c } +step s2i: INSERT INTO child VALUES (2, 1); +~~ROW COUNT: 1~~ + +step s1i: INSERT INTO child VALUES (1, 1); +~~ROW COUNT: 1~~ + +step s2c: COMMIT; +step s1c: COMMIT; + +starting permutation : { s1i s2i s2c s1s s1c } +step s1i: INSERT INTO child VALUES (1, 1); +~~ROW COUNT: 1~~ + +step s2i: INSERT INTO child VALUES (2, 1); +~~ROW COUNT: 1~~ + +step s2c: COMMIT; +step s1s: SELECT * from child; +~~START~~ +int#!#int +3#!#1 +1#!#1 +~~END~~ + +step s1c: COMMIT; + +starting permutation : { s1u s2u s1c s2c } +step s1u: UPDATE parent SET aux = 'bar'; +~~ROW COUNT: 1~~ + +step s2u: UPDATE parent SET aux = 'baz'; +step s1c: COMMIT; +step s2u: <... completed> +~~ROW COUNT: 1~~ + +step s2c: COMMIT; + +starting permutation : { s2u s1u s2r s1c } +step s2u: UPDATE parent SET aux = 'baz'; +~~ROW COUNT: 1~~ + +step s1u: UPDATE parent SET aux = 'bar'; +step s2r: ROLLBACK; +step s1u: <... completed> +~~ROW COUNT: 1~~ + +step s1c: COMMIT; + +starting permutation : { s2u s1u s1c s2c } +step s2u: UPDATE parent SET aux = 'baz'; +~~ROW COUNT: 1~~ + +step s1u: UPDATE parent SET aux = 'bar'; +~~ERROR (Code: 33557097)~~ +~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]canceling statement due to lock timeout (33557097) (SQLExecDirectW))~~ + +step s1u: <... completed> +~~ERROR (Code: 3902)~~ +~~ERROR (Message: [25000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]COMMIT can only be used in transaction blocks (3902) (SQLExecDirectW))~~ + +step s1c: COMMIT; +step s2c: COMMIT; + +starting permutation : { s1d s2d s1c s2c } +step s1d: DELETE FROM child WHERE child_key = 3; +~~ROW COUNT: 1~~ + +step s2d: DELETE FROM child WHERE child_key = 3; +step s1c: COMMIT; +step s2d: <... completed> +step s2c: COMMIT; + +starting permutation : { s2d s1d s1c s2c } +step s2d: DELETE FROM child WHERE child_key = 3; +~~ROW COUNT: 1~~ + +step s1d: DELETE FROM child WHERE child_key = 3; +~~ERROR (Code: 33557097)~~ +~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]canceling statement due to lock timeout (33557097) (SQLExecDirectW))~~ + +step s1d: <... completed> +~~ERROR (Code: 3902)~~ +~~ERROR (Message: [25000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]COMMIT can only be used in transaction blocks (3902) (SQLExecDirectW))~~ + +step s1c: COMMIT; +step s2c: COMMIT; + +starting permutation : { s2d s1d s2r s1c } +step s2d: DELETE FROM child WHERE child_key = 3; +~~ROW COUNT: 1~~ + +step s1d: DELETE FROM child WHERE child_key = 3; +step s2r: ROLLBACK; +step s1d: <... completed> +~~ROW COUNT: 1~~ + +step s1c: COMMIT; + +starting permutation : { s1s s2i s2c s1s s1c } +step s1s: SELECT * from child; +~~START~~ +int#!#int +3#!#1 +~~END~~ + +step s2i: INSERT INTO child VALUES (2, 1); +~~ROW COUNT: 1~~ + +step s2c: COMMIT; +step s1s: SELECT * from child; +~~START~~ +int#!#int +3#!#1 +~~END~~ + +step s1c: COMMIT; diff --git a/test/python/expected/pyodbc/TestTransactionsSQLBatch.out b/test/python/expected/pyodbc/TestTransactionsSQLBatch.out index 5647d98aa9..81236fc80c 100644 --- a/test/python/expected/pyodbc/TestTransactionsSQLBatch.out +++ b/test/python/expected/pyodbc/TestTransactionsSQLBatch.out @@ -107,7 +107,7 @@ int set transaction isolation level repeatable read; ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]REPEATABLE READ isolation level is not supported (33557097) (SQLExecDirectW))~~ +~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Isolation level ‘REPEATABLE READ’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_repeatable_read’ config option to get PG repeatable read isolation level. (33557097) (SQLExecDirectW))~~ #show transaction_isolation; #show default_transaction_isolation; @@ -372,7 +372,7 @@ int # begin transaction name -> save transaction name -> rollback tran name, Rollback whole transaction set transaction isolation level serializable; ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]SERIALIZABLE isolation level is not supported (33557097) (SQLExecDirectW))~~ +~~ERROR (Message: [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Isolation level ‘SERIALIZABLE’ is not currently supported in Babelfish. Please use ‘babelfishpg_tsql.isolation_level_serializable’ config option to get PG serializable isolation level. (33557097) (SQLExecDirectW))~~ #show transaction_isolation; #show default_transaction_isolation; diff --git a/test/python/input/isolation/BABEL-4145.spec b/test/python/input/isolation/BABEL-4145.spec new file mode 100644 index 0000000000..aef7ee2017 --- /dev/null +++ b/test/python/input/isolation/BABEL-4145.spec @@ -0,0 +1,38 @@ +setup +{ + + CREATE TABLE child ( + child_key int PRIMARY KEY, + child_value int NOT NULL + ); + + INSERT INTO child VALUES (1,5); + INSERT INTO child VALUES (2,10); +} + +teardown +{ + DROP TABLE child; +} + +session s1 +setup { SELECT set_config('babelfishpg_tsql.isolation_level_serializable','pg_isolation',false); + set transaction isolation level serializable; BEGIN TRAN; SET lock_timeout '500'; } +step s1s { SELECT * from child ORDER BY child_value ASC; } +step s1u1 { UPDATE child SET child_value = 12 where child_key = 1; } +step s1u2 { UPDATE child SET child_value = 7 where child_value < 6 } +step s1i { INSERT INTO child VALUES (3, 15); } +step s1c { COMMIT; } + +session s2 +setup { SELECT set_config('babelfishpg_tsql.isolation_level_serializable','pg_isolation',false); + set transaction isolation level serializable; BEGIN TRAN; SET lock_timeout '500'; } +step s2s { SELECT * from child ORDER BY child_value ASC; } +step s2i { INSERT INTO child VALUES (4, 20); } +step s2u1 { UPDATE child SET child_value = 20 WHERE child_key in (SELECT TOP 1 child_key FROM child ORDER BY child_value DESC) } +step s2u2 { UPDATE child SET child_value = 5 where child_value >= 6 } +step s2c { COMMIT; } + +permutation s1s s1u1 s2u1 s1c s2c s1s +permutation s1i s2i s1s s2s s2c s1c +permutation s1u1 s2u2 s1s s1c s2c \ No newline at end of file diff --git a/test/python/input/isolation/BABEL-4146.spec b/test/python/input/isolation/BABEL-4146.spec new file mode 100644 index 0000000000..68a794c107 --- /dev/null +++ b/test/python/input/isolation/BABEL-4146.spec @@ -0,0 +1,52 @@ +setup +{ + + CREATE TABLE parent ( + parent_key int PRIMARY KEY, + aux text NOT NULL + ); + + CREATE TABLE child ( + child_key int PRIMARY KEY, + parent_key int NOT NULL REFERENCES parent + ); + + INSERT INTO parent VALUES (1, 'foo'); + INSERT INTO child VALUES (3,1); +} + +teardown +{ + DROP TABLE parent, child; +} + +session s1 +setup { SELECT set_config('babelfishpg_tsql.isolation_level_repeatable_read','pg_isolation',false); + set transaction isolation level repeatable read; BEGIN TRAN; SET lock_timeout '500'; } +step s1s { SELECT * from child; } +step s1i { INSERT INTO child VALUES (1, 1); } +step s1u { UPDATE parent SET aux = 'bar'; } +step s1d { DELETE FROM child WHERE child_key = 3; } +step s1r { ROLLBACK; } +step s1c { COMMIT; } + +session s2 +setup { BEGIN TRAN; SET lock_timeout '10000'; } +step s2i { INSERT INTO child VALUES (2, 1); } +step s2u { UPDATE parent SET aux = 'baz'; } +step s2d { DELETE FROM child WHERE child_key = 3; } +step s2c { COMMIT; } +step s2r { ROLLBACK; } + +permutation s1i s2i s1c s2c +permutation s1i s2i s2c s1c +permutation s2i s1i s1c s2c +permutation s2i s1i s2c s1c +permutation s1i s2i s2c s1s s1c +permutation s1u s2u s1c s2c +permutation s2u s1u s2r s1c +permutation s2u s1u s1c s2c +permutation s1d s2d s1c s2c +permutation s2d s1d s1c s2c +permutation s2d s1d s2r s1c +permutation s1s s2i s2c s1s s1c