pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Extend ALTER OPERATOR to allow setting more optimization attribu
Date: Fri, 20 Oct 2023 16:28:56 +0000
Message-ID: <E1qtsMq-001WcL-06@gemulon.postgresql.org> (raw)

Extend ALTER OPERATOR to allow setting more optimization attributes.

Allow the COMMUTATOR, NEGATOR, MERGES, and HASHES attributes to be set
by ALTER OPERATOR.  However, we don't allow COMMUTATOR/NEGATOR to be
changed once set, nor allow the MERGES/HASHES flags to be unset once
set.  Changes like that might invalidate plans already made, and
dealing with the consequences seems like more trouble than it's worth.
The main use-case we foresee for this is to allow addition of missed
properties in extension update scripts, such as extending an existing
operator to support hashing.  So only transitions from not-set to set
states seem very useful.

This patch also causes us to reject some incorrect cases that formerly
resulted in inconsistent catalog state, such as trying to set the
commutator of an operator to be some other operator that already has a
(different) commutator.

While at it, move the InvokeObjectPostCreateHook call for CREATE
OPERATOR to not occur until after we've fixed up commutator or negator
links as needed.  The previous ordering could only be justified by
thinking of the OperatorUpd call as a kind of ALTER OPERATOR step;
but we don't call InvokeObjectPostAlterHook therein.  It seems better
to let the hook see the final state of the operator object.

In the documentation, move the discussion of how to establish
commutator pairs from xoper.sgml to the CREATE OPERATOR ref page.

Tommy Pavlicek, reviewed and editorialized a bit by me

Discussion: https://postgr.es/m/CAEhP-W-vGVzf4udhR5M8Bdv88UYnPrhoSkj3ieR3QNrsGQoqdg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2b5154beab794eae6e624c162d497df927ec9d27

Modified Files
--------------
doc/src/sgml/ref/alter_operator.sgml          |  86 ++++++++-
doc/src/sgml/ref/create_operator.sgml         |  66 ++++++-
doc/src/sgml/xoper.sgml                       |  44 -----
src/backend/catalog/pg_operator.c             | 254 +++++++++++++++++---------
src/backend/commands/operatorcmds.c           | 194 +++++++++++++++++---
src/backend/parser/gram.y                     |   2 +
src/backend/parser/parse_oper.c               |  38 ++--
src/include/catalog/pg_operator.h             |  15 ++
src/include/parser/parse_oper.h               |   3 +
src/test/regress/expected/alter_operator.out  | 148 ++++++++++++++-
src/test/regress/expected/create_operator.out |  44 +++++
src/test/regress/sql/alter_operator.sql       | 137 +++++++++++++-
src/test/regress/sql/create_operator.sql      |  43 +++++
13 files changed, 869 insertions(+), 205 deletions(-)



Message-ID: <E1qtsMq-001WcL-06@gemulon.postgresql.org>
Permalink:  ../E1qtsMq-001WcL-06@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qtsMq-001WcL-06@gemulon.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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Extend ALTER OPERATOR to allow setting more optimization attribu
  In-Reply-To: <E1qtsMq-001WcL-06@gemulon.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