Assert failure when CREATE TEMP TABLE

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: pgsql-bugs@postgresql.org
Date: 2023-10-16T11:02:29Z
Lists: pgsql-bugs
I came across an Assert failure while running sqlancer.  The repro query
is

CREATE TEMP TABLE t0 (c0 int4range CHECK ((('')||(0.005014271491241007) NOT
IN (upper(''), ((' 9O')||FALSE))) BETWEEN SYMMETRIC
(initcap('dj')LIKE(((('EizW~')||t0.c0) COLLATE "en_AG.utf8"))) AND
((((0.18773675)::MONEY) IN (0.52246463::MONEY))AND(t0.c0 BETWEEN SYMMETRIC
((t0.c0+t0.c0)) AND t0.c0)))) USING heap ON COMMIT DROP;

The failure happens in init_toast_snapshot():

 /*
  * Catalog snapshots can be returned by GetOldestSnapshot() even if not
  * registered or active. That easily hides bugs around not having a
  * snapshot set up - most of the time there is a valid catalog snapshot.
  * So additionally insist that the current snapshot is registered or
  * active.
  */
 Assert(HaveRegisteredOrActiveSnapshot());

And 'git bisect' says that the first bad commit is 2489d76c, which makes
me confused because the problemed query does not seem to involve
nullingrels stuff.

Thanks
Richard

Commits

  1. Ensure we have a snapshot while dropping ON COMMIT DROP temp tables.