pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Manuel Rigger <rigger.manuel@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Subject: Re: SELECT with COLLATE results in segfault on trunk and 12 Beta 2
Date: Sun, 14 Jul 2019 18:22:50 -0400
Message-ID: <25846.1563142970@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+u7OA40Fe9=A3wQ2PHWy8VZg8=GpD6dxQXeXVDx6HAhRSPeRA@mail.gmail.com>
References: <CA+u7OA40Fe9=A3wQ2PHWy8VZg8=GpD6dxQXeXVDx6HAhRSPeRA@mail.gmail.com>

Manuel Rigger <rigger.manuel@gmail.com> writes:
> When executing the statements below, Postgres crashes:

> CREATE TABLE t0(c0 BOOLEAN, c1 TEXT);
> CREATE STATISTICS s1 ON c0, c1 FROM t0;
> INSERT INTO t0(c0) VALUES (FALSE);
> VACUUM ANALYZE t0;
> SELECT * FROM t0 WHERE t0.c0 OR '' >= t0.c1 COLLATE "C"; -- unexpected: segfault

Backtrace shows

#0  pg_detoast_datum_packed (datum=0x7f7f7f7f7f7f7f7f) at fmgr.c:1773
#1  0x00000000008a9b90 in text_ge (fcinfo=0x7ffc8cdbfd40) at varlena.c:1859
#2  0x00000000008cf307 in FunctionCall2Coll (flinfo=0x7ffc8cdbfe00, 
    collation=<value optimized out>, arg1=<value optimized out>, 
    arg2=<value optimized out>) at fmgr.c:1162
#3  0x0000000000773db0 in mcv_get_match_bitmap (root=0x26b7bc8, 
    clauses=<value optimized out>, keys=0x26b8b90, mcvlist=0x26b88f0, 
    is_or=true) at mcv.c:1661
#4  0x0000000000773ecb in mcv_get_match_bitmap (root=0x26b7bc8, 
    clauses=<value optimized out>, keys=0x26b8b90, mcvlist=0x26b88f0, 
    is_or=false) at mcv.c:1744
#5  0x0000000000775d61 in mcv_clauselist_selectivity (root=0x26b7bc8, 
    stat=0x26b8b58, clauses=0x26b9008, varRelid=<value optimized out>, 
    jointype=<value optimized out>, sjinfo=<value optimized out>, 
    rel=0x25a46a0, basesel=0x7ffc8cdc0038, totalsel=0x7ffc8cdc0030)
    at mcv.c:1876

I think this is another variant of the mcv_get_match_bitmap
issues that you and Andreas already reported, ie, that code isn't
expecting to find anything but a bare Var or Const, so the
CollateExpr node above the Var confuses it.

It's possible that it'd be worth descending through CollateExpr
nodes in the same way as for RelabelType nodes, and for more or
less the same reason.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <25846.1563142970@sss.pgh.pa.us>
Permalink:  ../25846.1563142970@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25846.1563142970@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rigger.manuel@gmail.com, tomas.vondra@2ndquadrant.com
  Subject: Re: SELECT with COLLATE results in segfault on trunk and 12 Beta 2
  In-Reply-To: <25846.1563142970@sss.pgh.pa.us>
  References: <CA+u7OA40Fe9=A3wQ2PHWy8VZg8=GpD6dxQXeXVDx6HAhRSPeRA@mail.gmail.com> <25846.1563142970@sss.pgh.pa.us>

* 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