public inbox for [email protected]  
help / color / mirror / Atom feed
Note that ALTER TABLE cannot alter generated stored columns
4+ messages / 3 participants
[nested] [flat]

* Note that ALTER TABLE cannot alter generated stored columns
@ 2021-05-30 13:25  Emre Hasegeli <[email protected]>
  0 siblings, 2 replies; 4+ messages in thread

From: Emre Hasegeli @ 2021-05-30 13:25 UTC (permalink / raw)
  To: pgsql-docs

I was trying to change the generation expression of a generated stored
column using ALTER TABLE.  It took me a while before I figured SET
GENERATED applies only to generated identity columns.  I think it'd be
useful to note this in the documentation with something like the
attached.


Attachments:

  [application/octet-stream] 0001-doc-Note-that-ALTER-TABLE-cannot-alter-generated-sto.patch (2.0K, 2-0001-doc-Note-that-ALTER-TABLE-cannot-alter-generated-sto.patch)
  download | inline diff:
From 3d6fe7e6bb57081a9b7c3d5bcc23e5159ed65ba7 Mon Sep 17 00:00:00 2001
From: Emre Hasegeli <[email protected]>
Date: Sun, 30 May 2021 16:11:30 +0300
Subject: [PATCH] doc: Note that ALTER TABLE cannot alter generated stored

ALTER TABLE supports altering generated identity columns which could
confuse the reader as they share syntax with generated stored columns.
Clarify that a column cannot be turned into generated stored or
generation expressions cannot be changed with a note.
---
 doc/src/sgml/ref/alter_table.sgml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 939d3fe273..0e9846153e 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -251,20 +251,28 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       This form turns a stored generated column into a normal base column.
       Existing data in the columns is retained, but future changes will no
       longer apply the generation expression.
      </para>
 
      <para>
       If <literal>DROP EXPRESSION IF EXISTS</literal> is specified and the
       column is not a stored generated column, no error is thrown.  In this
       case a notice is issued instead.
      </para>
+
+     <note>
+      <para>
+       Turning a column into generated or changing the generation expression
+       is currently not supported.  To do that, use <command>DROP COLUMN</command>
+       and <command>CREATE COLUMN</command> with <command>GENERATED ALWAYS AS ( generation_expr ) STORED</command>.
+      </para>
+     </note>
     </listitem>
    </varlistentry>
 
    <varlistentry>
     <term><literal>ADD GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY</literal></term>
     <term><literal>SET GENERATED { ALWAYS | BY DEFAULT }</literal></term>
     <term><literal>DROP IDENTITY [ IF EXISTS ]</literal></term>
     <listitem>
      <para>
       These forms change whether a column is an identity column or change the
-- 
2.30.1 (Apple Git-130)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Note that ALTER TABLE cannot alter generated stored columns
@ 2021-05-31 05:42  Laurenz Albe <[email protected]>
  parent: Emre Hasegeli <[email protected]>
  1 sibling, 0 replies; 4+ messages in thread

From: Laurenz Albe @ 2021-05-31 05:42 UTC (permalink / raw)
  To: [email protected]; pgsql-docs

On Sun, 2021-05-30 at 16:25 +0300, Emre Hasegeli wrote:
> I was trying to change the generation expression of a generated stored
> column using ALTER TABLE.  It took me a while before I figured SET
> GENERATED applies only to generated identity columns.  I think it'd be
> useful to note this in the documentation with something like the
> attached.

+1

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Note that ALTER TABLE cannot alter generated stored columns
@ 2021-06-02 15:00  Peter Eisentraut <[email protected]>
  parent: Emre Hasegeli <[email protected]>
  1 sibling, 1 reply; 4+ messages in thread

From: Peter Eisentraut @ 2021-06-02 15:00 UTC (permalink / raw)
  To: [email protected]; pgsql-docs

On 30.05.21 15:25, Emre Hasegeli wrote:
> I was trying to change the generation expression of a generated stored
> column using ALTER TABLE.  It took me a while before I figured SET
> GENERATED applies only to generated identity columns.  I think it'd be
> useful to note this in the documentation with something like the
> attached.

I don't follow why you put this documentation under ALTER TABLE ... DROP 
EXPRESSION.  That action doesn't seem related to what you were hoping to do.





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Note that ALTER TABLE cannot alter generated stored columns
@ 2021-06-03 12:57  Emre Hasegeli <[email protected]>
  parent: Peter Eisentraut <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Emre Hasegeli @ 2021-06-03 12:57 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; +Cc: pgsql-docs

> I don't follow why you put this documentation under ALTER TABLE ... DROP
> EXPRESSION.  That action doesn't seem related to what you were hoping to do.

I thought that's where it would be if we had ADD/SET EXPRESSION
statements, just like the ADD/SET GENERATED statements just below.






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2021-06-03 12:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-05-30 13:25 Note that ALTER TABLE cannot alter generated stored columns Emre Hasegeli <[email protected]>
2021-05-31 05:42 ` Laurenz Albe <[email protected]>
2021-06-02 15:00 ` Peter Eisentraut <[email protected]>
2021-06-03 12:57   ` Emre Hasegeli <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox