pgsql: Fix failure of "ALTER TABLE t ADD COLUMN c serial" when done by

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix failure of "ALTER TABLE t ADD COLUMN c serial" when done by
Date: 2010-08-18 18:35:30
Message-ID: 20100818183530.7DA177541D7@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Fix failure of "ALTER TABLE t ADD COLUMN c serial" when done by non-owner.

The implicitly created sequence was created as owned by the current user,
who could be different from the table owner, eg if current user is a
superuser or some member of the table's owning role. This caused sanity
checks in the SEQUENCE OWNED BY code to spit up. Although possibly we
don't need those sanity checks, the safest fix seems to be to make sure
the implicit sequence is assigned the same owner role as the table has.
(We still do all permissions checks as the current user, however.)
Per report from Josh Berkus.

Back-patch to 9.0. The bug goes back to the invention of SEQUENCE OWNED BY
in 8.2, but the fix requires an API change for DefineRelation(), which seems
to have potential for breaking third-party code if done in a minor release.
Given the lack of prior complaints, it's probably not worth fixing in the
stable branches.

Tags:
----
REL9_0_STABLE

Modified Files:
--------------
pgsql/src/backend/commands:
sequence.c (r1.168 -> r1.168.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/sequence.c?r1=1.168&r2=1.168.4.1)
tablecmds.c (r1.332.2.3 -> r1.332.2.4)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.332.2.3&r2=1.332.2.4)
typecmds.c (r1.148 -> r1.148.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/typecmds.c?r1=1.148&r2=1.148.4.1)
view.c (r1.120 -> r1.120.6.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/view.c?r1=1.120&r2=1.120.6.1)
pgsql/src/backend/nodes:
copyfuncs.c (r1.464.4.1 -> r1.464.4.2)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/copyfuncs.c?r1=1.464.4.1&r2=1.464.4.2)
equalfuncs.c (r1.385 -> r1.385.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/equalfuncs.c?r1=1.385&r2=1.385.4.1)
pgsql/src/backend/parser:
gram.y (r2.713 -> r2.713.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/gram.y?r1=2.713&r2=2.713.2.1)
parse_utilcmd.c (r2.40 -> r2.40.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_utilcmd.c?r1=2.40&r2=2.40.4.1)
pgsql/src/backend/tcop:
utility.c (r1.335 -> r1.335.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/tcop/utility.c?r1=1.335&r2=1.335.4.1)
pgsql/src/include/commands:
tablecmds.h (r1.46 -> r1.46.6.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/commands/tablecmds.h?r1=1.46&r2=1.46.6.1)
pgsql/src/include/nodes:
parsenodes.h (r1.432 -> r1.432.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/parsenodes.h?r1=1.432&r2=1.432.4.1)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-08-18 19:54:01 pgsql: Rename utf2ucs() to utf8_to_unicode(), and export it so it can be
Previous Message Tom Lane 2010-08-18 18:35:22 pgsql: Fix failure of "ALTER TABLE t ADD COLUMN c serial" when done by