Which SET TYPE don't actually require a rewrite

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Which SET TYPE don't actually require a rewrite
Date: 2020-07-15 12:54:37
Message-ID: CABUevEz=bw-LoxaJiN48Q9akYODPhadphoLYBH9Yor1HNr-obg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Our Fine Manual (TM) specifies:
"As an exception, when changing the type of an existing column, if the
USING clause does not change the column contents and the old type is either
binary coercible to the new type or an unconstrained domain over the new
type, a table rewrite is not needed; but any indexes on the affected
columns must still be rebuilt."

First of all, how is a non-internals-expert even supposed to know what a
binary coercible type is? That's not a very user-friendly way to say it.

Second, how is even an expert supposed to find the list? :)

For example, we can query pg_cast for casts that are binary coercible,
that's a start, but it doesn't really tell us the answer.

We can also for example increase the precision of numeric without a rewrite
(but not scale). Or we can change between text and varchar. And we can
increase the length of a varchar but not decrease it.

Surely we can do better than this when it comes to documenting it? Even if
it's a pluggable thing so it may or may not be true of external
datatypes installed later, we should be able to at least be more clear
about the builtin types, I think?

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2020-07-15 13:05:32 Re: some more pg_dump refactoring
Previous Message Dilip Kumar 2020-07-15 12:51:20 Re: Have SIGHUP instead of SIGTERM for config reload in logical replication launcher