pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan S. Katz <jkatz@postgresql.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: krking@zju.edu.cn
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17477: A crash bug in transformValuesClause()
Date: Mon, 9 May 2022 13:20:23 -0400
Message-ID: <6f7f0d34-0f58-41a9-98b5-bf86e1960165@postgresql.org> (raw)
In-Reply-To: <3809468.1652109938@sss.pgh.pa.us>
References: <17477-0af3c6ac6b0a6ae0@postgresql.org>
	<CAD21AoCF5EWSXUR6MOGUWeqqo5bGw=_4LHDbwhPjO4x+xQn9QA@mail.gmail.com>
	<3809468.1652109938@sss.pgh.pa.us>

On 5/9/22 11:25 AM, Tom Lane wrote:
> Masahiko Sawada <sawada.mshk@gmail.com> writes:
>> It seems like transformValuesClause() cannot handle properly the value
>> clause having a relation that has an empty column. Should we raise an
>> error in this case?
> 
> Given that we try to support zero-column relations, I'm not sure why
> we'd insist on disallowing zero-column VALUES.  I think the problem
> is that the code in transformValuesClause needs to be tweaked to
> make that work.  The attached quick hack seems to do the trick.

Agree with the reasoning.

Confirmed reproducing the crash and that this fixes it. I did a short 
double-take on the error message:

	ERROR:  subquery must return only one column

but it is accurate, given this is what the subquery must do, and zero != 
one.

I don't see anything glaring in the code (though I'm not that familiar 
with this part of the codebase), but given this seems like an extreme 
edge case and protects against a crash, I'm satisfied with this.

Jonathan


Attachments:

  OpenPGP_signature (application/pgp-signature, 839B) download

view thread (9+ messages)  latest in thread

Message-ID: <6f7f0d34-0f58-41a9-98b5-bf86e1960165@postgresql.org>
Permalink:  ../6f7f0d34-0f58-41a9-98b5-bf86e1960165@postgresql.org/
Also on:    postgresql.org/message-id/6f7f0d34-0f58-41a9-98b5-bf86e1960165@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: jkatz@postgresql.org, tgl@sss.pgh.pa.us, sawada.mshk@gmail.com, krking@zju.edu.cn, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17477: A crash bug in transformValuesClause()
  In-Reply-To: <6f7f0d34-0f58-41a9-98b5-bf86e1960165@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox