From c3a1ca1a179ff9430dec552e4de843a02550291d Mon Sep 17 00:00:00 2001 From: yupeng Date: Sat, 26 Dec 2020 11:59:37 +0800 Subject: [PATCH] fix rownum --- src/common/backend/nodes/nodeFuncs.cpp | 1 + src/test/regress/expected/join.out | 13 +++++++++++++ src/test/regress/sql/join.sql | 11 ++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/common/backend/nodes/nodeFuncs.cpp b/src/common/backend/nodes/nodeFuncs.cpp index 38e0fb9e1..2ac9d1490 100755 --- a/src/common/backend/nodes/nodeFuncs.cpp +++ b/src/common/backend/nodes/nodeFuncs.cpp @@ -2755,6 +2755,7 @@ bool raw_expression_tree_walker(Node* node, bool (*walker)(), void* context) case T_ParamRef: case T_A_Const: case T_A_Star: + case T_Rownum: /* primitive node types with no subnodes */ break; case T_Alias: diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 27fae6a5a..6a64a1717 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -3763,6 +3763,19 @@ select * from hash_right_anti_y where not exists (select hash_right_anti_x.y fro drop table hash_right_anti_x; drop table hash_right_anti_y; +-- test rownum in outer join +create table t_a (id int, name varchar(10), code int); +create table t_b (id int, name varchar(10), code int); +insert into t_a values (1, 'tom', 3); +insert into t_b values (1, 'bat', 6); +select * from t_a a, t_b b where a.id(+) = b.id and rownum = 1; + id | name | code | id | name | code +----+------+------+----+------+------ + 1 | tom | 3 | 1 | bat | 6 +(1 row) + +drop table t_a; +drop table t_b; -- test datatype varchar in left join create table testa (id varchar); create table testb (id varchar); diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index 0cd4e0dd9..f813e8f4d 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -1209,6 +1209,15 @@ select * from hash_right_anti_y where not exists (select hash_right_anti_x.y fro drop table hash_right_anti_x; drop table hash_right_anti_y; +-- test rownum in outer join +create table t_a (id int, name varchar(10), code int); +create table t_b (id int, name varchar(10), code int); +insert into t_a values (1, 'tom', 3); +insert into t_b values (1, 'bat', 6); +select * from t_a a, t_b b where a.id(+) = b.id and rownum = 1; +drop table t_a; +drop table t_b; + -- test datatype varchar in left join create table testa (id varchar); create table testb (id varchar); @@ -1222,4 +1231,4 @@ insert into testb values('2'); select a.id from testa as a left join (select distinct id from testb) as b on a.id = b.id; drop table testa; -drop table testb; \ No newline at end of file +drop table testb;