From 45d42edb42a7053dfea1be7d5869206cb30f8a8e Mon Sep 17 00:00:00 2001 From: lukeman Date: Thu, 16 Nov 2023 17:50:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BC=BA=E9=99=B7=EF=BC=9ACT?= =?UTF-8?q?E=E6=9F=A5=E8=AF=A2=E4=B8=ADorder-by=E5=AD=90=E5=8F=A5=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AE=B5=E6=89=80=E5=9C=A8=E7=9A=84=E8=A1=A8?= =?UTF-8?q?=E5=9C=A8=E5=A4=96=E5=B1=82=E6=9F=A5=E8=AF=A2=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=96=AD=E8=A8=80=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/parser/parse_clause.cpp | 7 ++----- src/test/regress/expected/single_node_with.out | 9 +++++++++ src/test/regress/sql/single_node_with.sql | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/common/backend/parser/parse_clause.cpp b/src/common/backend/parser/parse_clause.cpp index 492359ef9..c7f543d0a 100644 --- a/src/common/backend/parser/parse_clause.cpp +++ b/src/common/backend/parser/parse_clause.cpp @@ -2590,11 +2590,8 @@ bool has_not_null_constraint(ParseState* pstate,TargetEntry* tle) HeapTuple atttuple = SearchSysCacheCopy2(ATTNUM, ObjectIdGetDatum(reloid), Int16GetDatum(attno)); if (!HeapTupleIsValid(atttuple)) { - Assert(0); - ereport(ERROR, - (errcode(ERRCODE_CACHE_LOOKUP_FAILED), - errmsg("cache lookup failed for attribute %u of relation %hd", reloid, attno))); - } + return false; + } Form_pg_attribute attStruct = (Form_pg_attribute)GETSTRUCT(atttuple); bool attHasNotNull = attStruct->attnotnull; heap_freetuple_ext(atttuple); diff --git a/src/test/regress/expected/single_node_with.out b/src/test/regress/expected/single_node_with.out index 5af116b78..53e3a4719 100644 --- a/src/test/regress/expected/single_node_with.out +++ b/src/test/regress/expected/single_node_with.out @@ -2080,3 +2080,12 @@ WITH t AS ( VALUES(FALSE); ERROR: conditional DO INSTEAD rules are not supported for data-modifying statements in WITH DROP RULE y_rule ON y; +-- the table where the field of the subquery's 'order-by' clause is located is in the outer query's 'from' clause +CREATE TABLE table0 ( column3 INT ) ; +WITH t1 AS ( SELECT 1 , 1 column10 ) SELECT ( SELECT 1 FROM table0 ORDER BY column10 NULLS FIRST ) FROM t1; + ?column? +---------- + +(1 row) + +drop table table0; diff --git a/src/test/regress/sql/single_node_with.sql b/src/test/regress/sql/single_node_with.sql index 609f51b0c..f0aefb411 100644 --- a/src/test/regress/sql/single_node_with.sql +++ b/src/test/regress/sql/single_node_with.sql @@ -930,3 +930,8 @@ WITH t AS ( ) VALUES(FALSE); DROP RULE y_rule ON y; + +-- the table where the field of the subquery's 'order-by' clause is located is in the outer query's 'from' clause +CREATE TABLE table0 ( column3 INT ) ; +WITH t1 AS ( SELECT 1 , 1 column10 ) SELECT ( SELECT 1 FROM table0 ORDER BY column10 NULLS FIRST ) FROM t1; +drop table table0; \ No newline at end of file