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: Allow ALTER TYPE to change some properties of a base type.
Date: Fri, 06 Mar 2020 17:19:41 +0000
Message-ID: <E1jAGdR-0000c9-Os@gemulon.postgresql.org> (raw)

Allow ALTER TYPE to change some properties of a base type.

Specifically, this patch allows ALTER TYPE to:
* Change the default TOAST strategy for a toastable base type;
* Promote a non-toastable type to toastable;
* Add/remove binary I/O functions for a type;
* Add/remove typmod I/O functions for a type;
* Add/remove a custom ANALYZE statistics functions for a type.

The first of these can be done by the type's owner; all the others
require superuser privilege since misuse could cause problems.

The main motivation for this patch is to allow extensions to
upgrade the feature sets of their data types, so the set of
alterable properties is biased towards that use-case.  However
it's also true that changing some other properties would be
a lot harder, as they get baked into physical storage and/or
stored expressions that depend on the type.

Along the way, refactor GenerateTypeDependencies() to make it easier
to call, refactor DefineType's volatility checks so they can be shared
by AlterType, and teach typcache.c that it might have to reload data
from the type's pg_type row, a scenario it never handled before.
Also rearrange alter_type.sgml a bit for clarity (put the
composite-type operations together).

Tomas Vondra and Tom Lane

Discussion: https://postgr.es/m/20200228004440.b23ein4qvmxnlpht@development

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fe30e7ebfa3846416f1adeb7cf611006513a4ee0

Modified Files
--------------
doc/src/sgml/catalogs.sgml                |  28 +-
doc/src/sgml/ref/alter_type.sgml          | 155 ++++++++--
src/backend/catalog/pg_type.c             |  45 ++-
src/backend/commands/typecmds.c           | 490 ++++++++++++++++++++++++++----
src/backend/nodes/copyfuncs.c             |  14 +
src/backend/nodes/equalfuncs.c            |  12 +
src/backend/parser/gram.y                 |  21 +-
src/backend/tcop/utility.c                |  13 +
src/backend/utils/cache/typcache.c        | 158 +++++++---
src/bin/psql/tab-complete.c               |   2 +-
src/include/catalog/pg_type.h             |   4 +-
src/include/commands/typecmds.h           |   2 +
src/include/nodes/nodes.h                 |   1 +
src/include/nodes/parsenodes.h            |  13 +-
src/include/utils/typcache.h              |   2 +
src/test/regress/expected/create_type.out |  78 +++++
src/test/regress/sql/create_type.sql      |  57 ++++
17 files changed, 958 insertions(+), 137 deletions(-)



Message-ID: <E1jAGdR-0000c9-Os@gemulon.postgresql.org>
Permalink:  ../E1jAGdR-0000c9-Os@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jAGdR-0000c9-Os@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 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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Allow ALTER TYPE to change some properties of a base type.
  In-Reply-To: <E1jAGdR-0000c9-Os@gemulon.postgresql.org>
  References: <E1jAGdR-0000c9-Os@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