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