pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: cherio@gmail.com
Subject: BUG #16653: Regression in CTE evaluation
Date: Sun, 04 Oct 2020 16:18:43 +0000
Message-ID: <16653-3154c42c219f8693@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16653
Logged by:          Yuri Cherio
Email address:      cherio@gmail.com
PostgreSQL version: 13.0
Operating system:   Ubuntu Linux 20.04
Description:        

The following SQL worked in versions 9 through 12. It is throwing an error
in version 13.

CREATE TABLE test AS SELECT now() AS tstmp, 'value' AS val;

WITH exp_days AS (
	SELECT ''::TEXT AS days WHERE '' ~ E'^[-]?\\d+$'
)
SELECT test.*
FROM test
	CROSS JOIN exp_days
WHERE tstmp > date(current_date - CAST(exp_days.days || ' days' AS
interval));

I'd leave alone why this SQL looks ridiculous - it is a very, very
simplified case of more complex dynamic query. Statement "exp_days" returns
no rows and in previous versions the optimizer would not even try evaluating
WHERE in the final query. It doesn't seem to be the case starting version
13.



view thread (4+ messages)  latest in thread

Message-ID: <16653-3154c42c219f8693@postgresql.org>
Permalink:  ../16653-3154c42c219f8693@postgresql.org/
Also on:    postgresql.org/message-id/16653-3154c42c219f8693@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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, cherio@gmail.com
  Subject: Re: BUG #16653: Regression in CTE evaluation
  In-Reply-To: <16653-3154c42c219f8693@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