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: d.koval@postgrespro.ru
Subject: BUG #17539: Assert after CREATE OPERATOR CLASS command
Date: Tue, 05 Jul 2022 20:08:35 +0000
Message-ID: <17539-37e89c604ebc0e02@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      17539
Logged by:          Dmitry Koval
Email address:      d.koval@postgrespro.ru
PostgreSQL version: 14.4
Operating system:   Ubuntu 20.04 LTS
Description:        

Hi,
PostgreSQL (REL_15_BETA2, REL_14_STABLE etc.) configured with
"--enable-cassert" option triggers Assert when executing a file test.sql:


CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
	AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 0 ELSE -1 END;
$$;
CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
	OPERATOR 5 > (int4,int4), FUNCTION 1 my_int4_sort(int4,int4);
CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops);
CREATE TABLE partkey_t_1 PARTITION OF partkey_t FOR VALUES FROM (0) TO
(1000);
INSERT INTO partkey_t VALUES (100);
DROP TABLE partkey_t;
DROP OPERATOR CLASS test_int4_ops USING btree;
DROP FUNCTION my_int4_sort(int4,int4);


PSQL utility prints error:


\i test.sql
CREATE FUNCTION
CREATE OPERATOR CLASS
CREATE TABLE
CREATE TABLE
psql:test.sql:7: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
psql:test.sql:7: error: connection to server was lost


log-file contains a string like this (master branch):


TRAP: FailedAssertion("next_index == nparts", File: "partbounds.c", Line:
891, PID: 87939)


I know that this situation is almost unreal, it was obtained using automated
testing with mixing queries and described in the documentation [1]: 
"CREATE OPERATOR CLASS does not presently check whether the operator class
definition includes all the operators and functions required by the index
method, nor whether the operators and functions form a self-consistent set.
It is the user's responsibility to define a valid operator class."
But probably an error in this case will be better than Assert, especially as
the community fixes situations like this [2].

(I'll attach file with patch for master branch in next email).

[1] https://www.postgresql.org/docs/15/sql-createopclass.html
[2] https://git.postgrespro.ru/pgpro-dev/postgrespro/-/commit/cbcea3b91

With best regards,
Dmitry Koval
Postgres Professional: http://postgrespro.com



view thread (5+ messages)  latest in thread

Message-ID: <17539-37e89c604ebc0e02@postgresql.org>
Permalink:  ../17539-37e89c604ebc0e02@postgresql.org/
Also on:    postgresql.org/message-id/17539-37e89c604ebc0e02@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, d.koval@postgrespro.ru
  Subject: Re: BUG #17539: Assert after CREATE OPERATOR CLASS command
  In-Reply-To: <17539-37e89c604ebc0e02@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