diff --git a/contrib/babelfishpg_tsql/src/tsql_analyze.c b/contrib/babelfishpg_tsql/src/tsql_analyze.c index 319f62a972..aa1600743a 100644 --- a/contrib/babelfishpg_tsql/src/tsql_analyze.c +++ b/contrib/babelfishpg_tsql/src/tsql_analyze.c @@ -132,7 +132,7 @@ pltsql_update_query_result_relation(Query *qry, Relation target_rel, List *rtabl { RangeTblEntry *rte = (RangeTblEntry *) list_nth(rtable, i); - if (rte->relid == target_relid) + if (rte->relid == target_relid && rte->rtekind != RTE_NAMEDTUPLESTORE) { qry->resultRelation = i + 1; return; diff --git a/test/JDBC/expected/BABEL-4606-vu-cleanup.out b/test/JDBC/expected/BABEL-4606-vu-cleanup.out new file mode 100644 index 0000000000..b2f49ddcd8 --- /dev/null +++ b/test/JDBC/expected/BABEL-4606-vu-cleanup.out @@ -0,0 +1,18 @@ +drop trigger babel_4606_trigger +go + +drop table babel_4606 +go + +drop trigger babel_4606_2_trigger +go + +drop table babel_4606_2 +go + +drop trigger babel_4606_3_trigger +go + +drop table babel_4606_3 +go + diff --git a/test/JDBC/expected/BABEL-4606-vu-prepare.out b/test/JDBC/expected/BABEL-4606-vu-prepare.out new file mode 100644 index 0000000000..ef746bd26e --- /dev/null +++ b/test/JDBC/expected/BABEL-4606-vu-prepare.out @@ -0,0 +1,61 @@ +create table babel_4606 (a int primary key, b int) +go + +insert into babel_4606 (a, b) values (1,7),(2,8),(3,9),(4,10),(5,11),(6,12) +go +~~ROW COUNT: 6~~ + + +create trigger babel_4606_trigger +on babel_4606 +after update +AS +begin + update t + set t.b = t.b + 1 + from inserted as i + join babel_4606 as t + on t.a = i.a +end +go + +create table babel_4606_2 (a int primary key, b int) +go + +insert into babel_4606_2 (a, b) values (1,7),(2,8),(3,9),(4,10),(5,11),(6,12) +go +~~ROW COUNT: 6~~ + + +create trigger babel_4606_2_trigger +on babel_4606_2 +after update +AS +begin + update babel_4606_2 + set babel_4606_2.b = babel_4606_2.b + 2 + from inserted as i + where babel_4606_2.a = i.a +end +go + +create table babel_4606_3 (a int primary key, b int) +go + +insert into babel_4606_3 (a, b) values (1,7),(2,8),(3,9),(4,10),(5,11),(6,12) +go +~~ROW COUNT: 6~~ + + +create trigger babel_4606_3_trigger +on babel_4606_3 +after update +AS +begin + update babel_4606_3 + set babel_4606_3.b = babel_4606_3.b + 200 + from deleted as i + where babel_4606_3.a = i.a +end +go + diff --git a/test/JDBC/expected/BABEL-4606-vu-verify.out b/test/JDBC/expected/BABEL-4606-vu-verify.out new file mode 100644 index 0000000000..c11a3fd2c3 --- /dev/null +++ b/test/JDBC/expected/BABEL-4606-vu-verify.out @@ -0,0 +1,98 @@ +select * from babel_4606 +GO +~~START~~ +int#!#int +1#!#7 +2#!#8 +3#!#9 +4#!#10 +5#!#11 +6#!#12 +~~END~~ + + +update babel_4606 set b = 100 where a = 1; +GO +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + + +select * from babel_4606 +GO +~~START~~ +int#!#int +2#!#8 +3#!#9 +4#!#10 +5#!#11 +6#!#12 +1#!#101 +~~END~~ + + +select * from babel_4606_2 +GO +~~START~~ +int#!#int +1#!#7 +2#!#8 +3#!#9 +4#!#10 +5#!#11 +6#!#12 +~~END~~ + + +update babel_4606_2 set b = 100 where a = 1; +go +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + + +select * from babel_4606_2 +GO +~~START~~ +int#!#int +2#!#8 +3#!#9 +4#!#10 +5#!#11 +6#!#12 +1#!#102 +~~END~~ + + +select * from babel_4606_3 +GO +~~START~~ +int#!#int +1#!#7 +2#!#8 +3#!#9 +4#!#10 +5#!#11 +6#!#12 +~~END~~ + + +update babel_4606_3 set b = 100 where a = 1; +go +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + + +select * from babel_4606_3 +GO +~~START~~ +int#!#int +2#!#8 +3#!#9 +4#!#10 +5#!#11 +6#!#12 +1#!#300 +~~END~~ + diff --git a/test/JDBC/input/BABEL-4606-vu-cleanup.sql b/test/JDBC/input/BABEL-4606-vu-cleanup.sql new file mode 100644 index 0000000000..b2f49ddcd8 --- /dev/null +++ b/test/JDBC/input/BABEL-4606-vu-cleanup.sql @@ -0,0 +1,18 @@ +drop trigger babel_4606_trigger +go + +drop table babel_4606 +go + +drop trigger babel_4606_2_trigger +go + +drop table babel_4606_2 +go + +drop trigger babel_4606_3_trigger +go + +drop table babel_4606_3 +go + diff --git a/test/JDBC/input/BABEL-4606-vu-prepare.sql b/test/JDBC/input/BABEL-4606-vu-prepare.sql new file mode 100644 index 0000000000..b09639af4f --- /dev/null +++ b/test/JDBC/input/BABEL-4606-vu-prepare.sql @@ -0,0 +1,55 @@ +create table babel_4606 (a int primary key, b int) +go + +insert into babel_4606 (a, b) values (1,7),(2,8),(3,9),(4,10),(5,11),(6,12) +go + +create trigger babel_4606_trigger +on babel_4606 +after update +AS +begin + update t + set t.b = t.b + 1 + from inserted as i + join babel_4606 as t + on t.a = i.a +end +go + +create table babel_4606_2 (a int primary key, b int) +go + +insert into babel_4606_2 (a, b) values (1,7),(2,8),(3,9),(4,10),(5,11),(6,12) +go + +create trigger babel_4606_2_trigger +on babel_4606_2 +after update +AS +begin + update babel_4606_2 + set babel_4606_2.b = babel_4606_2.b + 2 + from inserted as i + where babel_4606_2.a = i.a +end +go + +create table babel_4606_3 (a int primary key, b int) +go + +insert into babel_4606_3 (a, b) values (1,7),(2,8),(3,9),(4,10),(5,11),(6,12) +go + +create trigger babel_4606_3_trigger +on babel_4606_3 +after update +AS +begin + update babel_4606_3 + set babel_4606_3.b = babel_4606_3.b + 200 + from deleted as i + where babel_4606_3.a = i.a +end +go + diff --git a/test/JDBC/input/BABEL-4606-vu-verify.sql b/test/JDBC/input/BABEL-4606-vu-verify.sql new file mode 100644 index 0000000000..f92164f747 --- /dev/null +++ b/test/JDBC/input/BABEL-4606-vu-verify.sql @@ -0,0 +1,26 @@ +select * from babel_4606 +GO + +update babel_4606 set b = 100 where a = 1; +GO + +select * from babel_4606 +GO + +select * from babel_4606_2 +GO + +update babel_4606_2 set b = 100 where a = 1; +go + +select * from babel_4606_2 +GO + +select * from babel_4606_3 +GO + +update babel_4606_3 set b = 100 where a = 1; +go + +select * from babel_4606_3 +GO diff --git a/test/JDBC/upgrade/14_10/schedule b/test/JDBC/upgrade/14_10/schedule index 0b1bb7ddba..1b8f5a0a3e 100644 --- a/test/JDBC/upgrade/14_10/schedule +++ b/test/JDBC/upgrade/14_10/schedule @@ -416,3 +416,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 +BABEL-4606 diff --git a/test/JDBC/upgrade/14_11/schedule b/test/JDBC/upgrade/14_11/schedule index 0b1bb7ddba..1b8f5a0a3e 100644 --- a/test/JDBC/upgrade/14_11/schedule +++ b/test/JDBC/upgrade/14_11/schedule @@ -416,3 +416,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 +BABEL-4606 diff --git a/test/JDBC/upgrade/14_8/schedule b/test/JDBC/upgrade/14_8/schedule index 527fc5e57a..934de1a33d 100644 --- a/test/JDBC/upgrade/14_8/schedule +++ b/test/JDBC/upgrade/14_8/schedule @@ -413,3 +413,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 +BABEL-4606 diff --git a/test/JDBC/upgrade/14_9/schedule b/test/JDBC/upgrade/14_9/schedule index 367c135afa..94ecc6579a 100644 --- a/test/JDBC/upgrade/14_9/schedule +++ b/test/JDBC/upgrade/14_9/schedule @@ -415,3 +415,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 +BABEL-4606 diff --git a/test/JDBC/upgrade/15_1/schedule b/test/JDBC/upgrade/15_1/schedule index 745d4ace3f..4a15f4fd91 100644 --- a/test/JDBC/upgrade/15_1/schedule +++ b/test/JDBC/upgrade/15_1/schedule @@ -391,4 +391,5 @@ default_params cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 -BABEL-2999 \ No newline at end of file +BABEL-2999 +BABEL-4606 \ No newline at end of file diff --git a/test/JDBC/upgrade/15_2/schedule b/test/JDBC/upgrade/15_2/schedule index c18de8224d..360ab42139 100644 --- a/test/JDBC/upgrade/15_2/schedule +++ b/test/JDBC/upgrade/15_2/schedule @@ -422,3 +422,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 +BABEL-4606 \ No newline at end of file diff --git a/test/JDBC/upgrade/15_3/schedule b/test/JDBC/upgrade/15_3/schedule index 9844bb1691..7748b5cec8 100644 --- a/test/JDBC/upgrade/15_3/schedule +++ b/test/JDBC/upgrade/15_3/schedule @@ -444,3 +444,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 +BABEL-4606 diff --git a/test/JDBC/upgrade/15_4/schedule b/test/JDBC/upgrade/15_4/schedule index 61b24ca550..dae8876015 100644 --- a/test/JDBC/upgrade/15_4/schedule +++ b/test/JDBC/upgrade/15_4/schedule @@ -456,4 +456,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 - +BABEL-4606 diff --git a/test/JDBC/upgrade/15_5/schedule b/test/JDBC/upgrade/15_5/schedule index 9eca53fdc4..97c08d0141 100644 --- a/test/JDBC/upgrade/15_5/schedule +++ b/test/JDBC/upgrade/15_5/schedule @@ -484,3 +484,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order BABEL-2999 +BABEL-4606 diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index 6910c4bdeb..3c416c6cc5 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -490,3 +490,4 @@ cast_eliminate TestDatatypeAggSort babel_index_nulls_order BABEL-2999 +BABEL-4606