Re: Another multi-row VALUES bug

2022-11-28 Thread Tom Lane
Dean Rasheed writes: > A different way to do this, without relying on the contents of the > targetlist, is to note that, while processing a product query, what we > really want to do is ignore any VALUES RTEs from the original query, > since they will have already been processed. There should

Re: Another multi-row VALUES bug

2022-11-28 Thread Dean Rasheed
On Wed, 23 Nov 2022 at 18:56, Tom Lane wrote: > > I wonder if somehow we could just make one pass over > all the VALUES RTEs, and process each one as needed? The problem > is to identify the relevant target relation, I guess. > I have been thinking about that some more, but I think it would be

Re: Another multi-row VALUES bug

2022-11-23 Thread Tom Lane
Dean Rasheed writes: > On Wed, 23 Nov 2022 at 15:30, Tom Lane wrote: >> Hmm ... this patch does not feel any more principled or future-proof >> than what it replaces, because now instead of making assumptions >> about what's in the jointree, you're making assumptions about what's >> in the

Re: Another multi-row VALUES bug

2022-11-23 Thread Dean Rasheed
On Wed, 23 Nov 2022 at 15:30, Tom Lane wrote: > > > So I think what the code needs to do is examine the targetlist, and > > identify the VALUES RTE that the current query is using as a source, > > and rewrite just that RTE (so any original VALUES RTE is rewritten at > > the top level, and any

Re: Another multi-row VALUES bug

2022-11-23 Thread Tom Lane
Dean Rasheed writes: > In RewriteQuery(), the code assumes that in a multi-row INSERT query, > the VALUES RTE will be the only thing in the query's fromlist. That's > true for the original query, but it's not necessarily the case for > product queries, if the rule action performs a multi-row

Another multi-row VALUES bug

2022-11-23 Thread Dean Rasheed
I was thinking some more about the recent fix to multi-row VALUES handling in the rewriter (b8f2687fdc), and I realised that there is another bug in the way DEFAULT values are handled: In RewriteQuery(), the code assumes that in a multi-row INSERT query, the VALUES RTE will be the only thing in