| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: pg17: XX000: no relation entry for relid 0 |
| Date: | 2026-04-10 12:49:24 |
| Message-ID: | CAHewXN=_C3apEh4nDndgbOiYnFAYDDuMWAozPP0G3iL=7zQbJg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Justin Pryzby <pryzby(at)telsasoft(dot)com> 于2026年4月10日周五 18:54写道:
>
> CREATE VIEW x AS SELECT NULL::int[]
> UNION ALL SELECT NULL::int[]
> UNION ALL SELECT ARRAY[NULL::bigint];
>
> SELECT FROM x;
> ERROR: XX000: no relation entry for relid 0
>
> Since 9391f7152.
The varno = 0 is from below code:
*pTargetList = generate_setop_tlist(colTypes, colCollations,
0,
false,
*pTargetList,
refnames_tlist,
&trivial_tlist);
*istrivial_tlist = trivial_tlist;
target = create_pathtarget(root, *pTargetList);
in recurse_set_operations().
When calling set_pathtarget_cost_width(), we estimate the length of
the array that would enter estimate_array_length().
Before 9391f7152, we returned 10 directly. But now, we see if we can
find any statistics about it.
In examine_variable(), try to find base_rel in find_base_rel(), error
reported. Because the varno of the Var is 0.
I didn't think too much at now, a quick fix as below:
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 4160d2d6e24..ff93fc3ac8a 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -2265,6 +2265,9 @@ estimate_array_length(PlannerInfo *root, Node *arrayexpr)
AttStatsSlot sslot;
double nelem = 0;
+ if (IsA(arrayexpr, Var) && ((Var *) arrayexpr)->varno == 0)
+ return 10;
+
examine_variable(root, arrayexpr, 0, &vardata);
if (HeapTupleIsValid(vardata.statsTuple))
{
Any thoughts?
--
Thanks,
Tender Wang
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Dunstan | 2026-04-10 12:57:14 | Re: pg_waldump: support decoding of WAL inside tarfile |
| Previous Message | Alexander Korotkov | 2026-04-10 12:24:10 | Re: Heads Up: cirrus-ci is shutting down June 1st |