-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the issue that inserted table refered in update join will cause c…
…rash (#2140) Previously when we implement update join, we missed a corner case that one of the join relations can be a named tuple store instead of RTE relation. And it'll lead analyzer to wrongly set resultRelation for the Query. This fix resolved the corner case by add a if condition to exclude RTE_NAMEDTUPLESTORE for being resultRelation. Task: BABEL-4606 Signed-off-by: Zhibai Song <[email protected]>
- Loading branch information
1 parent
507088e
commit 91ba800
Showing
17 changed files
with
288 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,3 +416,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order-before-15-5 | ||
BABEL-2999 | ||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,3 +416,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order-before-15-5 | ||
BABEL-2999 | ||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,3 +413,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order-before-15-5 | ||
BABEL-2999 | ||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,3 +415,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order-before-15-5 | ||
BABEL-2999 | ||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -422,3 +422,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order-before-15-5 | ||
BABEL-2999 | ||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -444,3 +444,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order-before-15-5 | ||
BABEL-2999 | ||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,4 +456,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order-before-15-5 | ||
BABEL-2999 | ||
|
||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -484,3 +484,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order | ||
BABEL-2999 | ||
BABEL-4606 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,3 +490,4 @@ cast_eliminate | |
TestDatatypeAggSort | ||
babel_index_nulls_order | ||
BABEL-2999 | ||
BABEL-4606 |