Re: sqlsmith: ERROR: XX000: bogus varno: 2

2022-01-07 Thread Amit Langote
On Fri, Jan 7, 2022 at 12:24 AM Tom Lane wrote: > Amit Langote writes: > > Thanks for addressing that in the patch you posted. I guess fixing > > only expression_tree_walker/mutator() suffices for now, but curious to > > know if it was intentional that you decided not to touch the following > >

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2022-01-06 Thread Tom Lane
Amit Langote writes: > Thanks for addressing that in the patch you posted. I guess fixing > only expression_tree_walker/mutator() suffices for now, but curious to > know if it was intentional that you decided not to touch the following > sites: > exprCollation(): it would perhaps make sense to r

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2022-01-06 Thread Robert Haas
On Mon, Dec 20, 2021 at 4:20 PM Tom Lane wrote: > pg_get_expr doesn't (or didn't) depend on expression_tree_walker, > so there wasn't a problem there before. I am worried that there > might be other code paths, now or in future, that could try to apply > expression_tree_walker/mutator to relpartb

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2022-01-06 Thread Amit Langote
On Thu, Jan 6, 2022 at 3:43 PM Amit Langote wrote: > On Tue, Dec 21, 2021 at 6:20 AM Tom Lane wrote: > > Robert Haas writes: > > > OK ... but my point is that dump and restore does work. So whatever > > > cases pg_get_expr() doesn't work must be cases that aren't needed for > > > that to happen.

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2022-01-05 Thread Amit Langote
On Tue, Dec 21, 2021 at 6:20 AM Tom Lane wrote: > Robert Haas writes: > > OK ... but my point is that dump and restore does work. So whatever > > cases pg_get_expr() doesn't work must be cases that aren't needed for > > that to happen. Otherwise this problem would have been found long ago. > > pg

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Tom Lane
Here's a less hasty version of the patch. regards, tom lane diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index e276264882..5d4700430c 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -2201,6 +2201,26 @@ express

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Tom Lane
Robert Haas writes: > OK ... but my point is that dump and restore does work. So whatever > cases pg_get_expr() doesn't work must be cases that aren't needed for > that to happen. Otherwise this problem would have been found long ago. pg_get_expr doesn't (or didn't) depend on expression_tree_walk

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Robert Haas
On Mon, Dec 20, 2021 at 2:36 PM Tom Lane wrote: > I'm not sure why you're astonished by that, considering that > psql has applied pg_get_expr to relpartbound since f0e44751d, > which was the same commit that put code into ruleutils.c to > make pg_get_expr work on relpartbounds. > > It seems a bit

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Tom Lane
Robert Haas writes: > Right. I'm not surprised that relpartbound uses those node types. I > *am* surprised that pg_get_expr() is expected to be able to handle > them. IOW, they ARE node trees, consonant with the fact that the > column type is pg_node_tree, but they're NOT expressions. I'm not sur

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Robert Haas
On Mon, Dec 20, 2021 at 1:13 PM Tom Lane wrote: > The reason the regression tests fail if I only patch ruleutils is > that psql \d on a partitioned table invokes > ... pg_get_expr(c.relpartbound, c.oid) FROM pg_catalog.pg_class c > and evidently relpartbound does contain precisely these no

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Tom Lane
Robert Haas writes: > The commit that added PartitionBoundSpec and PartitionRangeDatum was > committed by me and authored by Amit Langote. It is the original table > partitioning commit -- f0e44751d7175fa3394da2c8f85e3ceb3cdbfe63. I'm > reasonably sure that the reason why those didn't get added to

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Robert Haas
On Mon, Dec 20, 2021 at 11:25 AM Tom Lane wrote: > I figured this would be just a quick hack in ruleutils.c, but was > dismayed to find the regression tests falling over, because some > bozo neglected to teach nodeFuncs.c about partition expressions. > It might be a good idea to back-patch that pa

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Tom Lane
Robert Haas writes: > On Sun, Dec 19, 2021 at 4:17 PM Tom Lane wrote: >> I don't see anything particularly surprising here. pg_get_expr is only >> able to cope with expression trees over a single relation, but ON UPDATE >> rules can refer to both OLD and NEW relations. Maybe we could make the >

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-20 Thread Robert Haas
On Sun, Dec 19, 2021 at 4:17 PM Tom Lane wrote: > Justin Pryzby writes: > > I reduced the problematic query to this. > > SELECT 1 FROM pg_rewrite WHERE > > pg_get_function_arg_default(ev_class, 1) !~~ > > pg_get_expr(ev_qual, ev_class, false); > > Or more simply, > > regression=# select pg_get_ex

Re: sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-19 Thread Tom Lane
Justin Pryzby writes: > I reduced the problematic query to this. > SELECT 1 FROM pg_rewrite WHERE > pg_get_function_arg_default(ev_class, 1) !~~ > pg_get_expr(ev_qual, ev_class, false); Or more simply, regression=# select pg_get_expr(ev_qual, ev_class, false) from pg_rewrite where rulename = 'p

sqlsmith: ERROR: XX000: bogus varno: 2

2021-12-19 Thread Justin Pryzby
I reduced the problematic query to this. SELECT 1 FROM pg_rewrite WHERE pg_get_function_arg_default(ev_class, 1) !~~ pg_get_expr(ev_qual, ev_class, false); #0 pg_re_throw () at elog.c:1800 #1 0x563f5d027932 in errfinish () at elog.c:593 #2 0x563f5cb874ee in resolve_special_varno (node=