pgsql: Rework order of checks in ALTER / SET SCHEMA

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rework order of checks in ALTER / SET SCHEMA
Date: 2013-01-15 16:26:22
Message-ID: E1Tv9LC-00033o-UQ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Rework order of checks in ALTER / SET SCHEMA

When attempting to move an object into the schema in which it already
was, for most objects classes we were correctly complaining about
exactly that ("object is already in schema"); but for some other object
classes, such as functions, we were instead complaining of a name
collision ("object already exists in schema"). The latter is wrong and
misleading, per complaint from Robert Haas in
CA+TgmoZ0+gNf7RDKRc3u5rHXffP=QjqPZKGxb4BsPz65k7qnHQ(at)mail(dot)gmail(dot)com

To fix, refactor the way these checks are done. As a bonus, the
resulting code is smaller and can also share some code with Rename
cases.

While at it, remove use of getObjectDescriptionOids() in error messages.
These are normally disallowed because of translatability considerations,
but this one had slipped through since 9.1. (Not sure that this is
worth backpatching, though, as it would create some untranslated
messages in back branches.)

This is loosely based on a patch by KaiGai Kohei, heavily reworked by
me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/7ac5760fa283bc090c25e4ea495a0d2bb41db7b5

Modified Files
--------------
src/backend/commands/alter.c | 116 +++++++++++++++++++-------
src/backend/commands/collationcmds.c | 87 +++-----------------
src/backend/commands/functioncmds.c | 82 +++----------------
src/include/commands/alter.h | 3 +-
src/include/commands/collationcmds.h | 3 +-
src/include/commands/defrem.h | 5 +-
src/test/regress/expected/alter_generic.out | 14 ++--
7 files changed, 124 insertions(+), 186 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-01-15 17:26:52 pgsql: Don't pass NULL to fprintf, if not currently connected to a data
Previous Message Heikki Linnakangas 2013-01-15 13:47:27 pgsql: Give a proper error message if connecting to incompatible server