解决缺陷:CTE查询中order-by子句中的字段所在的表在外层查询导致断言失败
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
Reference in New Issue
Block a user