Skip site navigation (1) Skip section navigation (2)

Re: ALTER command reworks

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER command reworks
Date: 2013-01-07 20:50:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Mon, Jan 7, 2013 at 3:43 PM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> Kohei KaiGai escribió:
>> The attached patch is a revised version.
>> It follows the manner in ExecAlterObjectSchemaStmt(); that tries to check
>> name duplication for object classes that support catcache with name-key.
>> Elsewhere, it calls individual routines for each object class to solve object
>> name and check namespace conflicts.
>> For example, RenameFunction() is still called from ExecRenameStmt(),
>> however, it looks up the given function name and checks namespace
>> conflict only, then it just invokes AlterObjectRename_internal() in spite
>> of system catalog updates by itself.
>> It allows to use this consolidated routine by object classes with special
>> rule for namespace conflicts, such as collation.
>> In addition, this design allowed to eliminate get_object_type() to pull
>> OBJECT_* enum from class_id/object_id pair.
> I checked this patch.  It needed a rebase for the changes to return
> OIDs.  Attached patch applies to current HEAD.  In general this looks
> good, with one exception: it's using getObjectDescriptionOids() to build
> the messages to complain in case the object already exists in the
> current schema, which results in diffs like this:
> -ERROR:  event trigger "regress_event_trigger2" already exists
> +ERROR:  event trigger regress_event_trigger2 already exists
> I don't know how tense we are about keeping the quotes, but I fear there
> would be complaints because it took us lots of sweat, blood and tears to
> get where we are now.
> If this is considered a problem, I think the way to fix it is to have a
> getObjectDescriptionOids() variant that quotes the object name in the
> output.  This would be pretty intrusive: we'd have to change things
> so that, for instance,
>                 appendStringInfo(&buffer, _("collation %s"),
>                         NameStr(coll->collname));
> would become
>                 if (quotes)
>                         appendStringInfo(&buffer, _("collation \"%s\""),
>                                 NameStr(coll->collname));
>                 else
>                         appendStringInfo(&buffer, _("collation %s"),
>                                 NameStr(coll->collname));
> Not really thrilled with this idea.  Of course,
> getObjectDescription() itself should keep the same API as now, to avoid
> useless churn all over the place.

This sort of thing has been rejected repeatedly in the past on
translation grounds:

+ 				ereport(ERROR,
+ 						 errmsg("%s already exists in schema \"%s\"",
+ 								getObjectDescriptionOids(classId, exists),
+ 								get_namespace_name(namespaceId))));

If we're going to start allowing that, there's plenty of other code
that can be hit with the same hammer, but I'm pretty sure that all
previous proposals in this area have been slapped down.

Robert Haas
The Enterprise PostgreSQL Company

In response to


pgsql-hackers by date

Next:From: Robert HaasDate: 2013-01-07 20:53:07
Subject: Re: psql \l to accept patterns
Previous:From: Robert HaasDate: 2013-01-07 20:47:13
Subject: Re: recent ALTER whatever .. SET SCHEMA refactoring

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group