A tidbit I spotted while playing in tablecmds.c

From: Greg Stark <stark(at)mit(dot)edu>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: A tidbit I spotted while playing in tablecmds.c
Date: 2018-12-19 23:22:28
Message-ID: CAM-w4HMCUh0xzpo-nYnHGtaBa4WY4fwkx7gMDvDZ8WZ+q+NFsw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I think this is a bug:

postgres=# alter table only x2 add if not exists i integer;
ERROR: 42701: column "i" of relation "x2" already exists

Note that it does not occur without the ONLY:

postgres=# alter table x2 add if not exists i integer;
NOTICE: 42701: column "i" of relation "x2" already exists, skipping
ALTER TABLE

And I think this would fix it:

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index eef3b3a26c..ad8c176793 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -4054,7 +4054,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
Relation rel,
case AT_AddColumnToView: /* add column via CREATE OR REPLACE VIEW */
address = ATExecAddColumn(wqueue, tab, rel, (ColumnDef *) cmd->def,
false, false,
- false, lockmode);
+ cmd->missing_ok, lockmode);
break;
case AT_AddColumnRecurse:
address = ATExecAddColumn(wqueue, tab, rel, (ColumnDef *) cmd->def,

--
greg

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?= 2018-12-19 23:22:29 Re: [PATCH] Improve tab completion for CREATE TABLE
Previous Message Tom Lane 2018-12-19 23:14:37 Re: slow queries over information schema.tables