Re: recent ALTER whatever .. SET SCHEMA refactoring

From: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: recent ALTER whatever .. SET SCHEMA refactoring
Date: 2013-01-08 13:58:42
Message-ID: CADyhKSVLNmmV7T9e3R8BSwzcYHNxfOcrm_e+pONTA9oijXagkg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2013/1/8 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Tue, Jan 8, 2013 at 4:05 AM, Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp> wrote:
>> Does it make sense an idea to invoke AlterFunctionNamespace_oid()
>> or AlterCollationNamespace_oid() from AlterObjectNamespace_internal()
>> for checks of namespace conflicts?
>> It can handle special cases with keeping modularity between common
>> and specific parts. Let's consider function pointer when we have mode
>> than 5 object classes that needs special treatment.
>
> Unless I'm gravely mistaken, we're only talking about a handful of
> lines of code. We have lots of functions, in objectaddress.c for
> example, whose behavior is conditional on the type of object that they
> are operating on. And we just write out all the cases. I'm not
> understanding why we need to take a substantially more complex
> approach here.
>
I'm probably saying same idea. It just adds invocation of external
functions to check naming conflicts of functions or collation; that
takes additional 4-lines for special case handling
in AlterObjectNamespace_internal().
Do you have different image for the special case handling?

@@ -380,6 +368,10 @@ AlterObjectNamespace_internal(Relation rel, Oid
objid, Oid nspOid)
errmsg("%s already exists in schema \"%s\"",
getObjectDescriptionOids(classId, objid),
get_namespace_name(nspOid))));
+ else if (classId == ProcedureRelationId)
+ AlterFunctionNamespace_oid(rel, objid, nspOid);
+ else if (classId == CollationRelationId)
+ AlterCollationNamespace_oid(rel, objid, nspOid);

/* Build modified tuple */
values = palloc0(RelationGetNumberOfAttributes(rel) * sizeof(Datum));

Thanks,
--
KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>

Attachment Content-Type Size
pgsql-v9.3-alter-namespace-specials.patch application/octet-stream 7.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2013-01-08 14:21:39 Re: Extra XLOG in Checkpoint for StandbySnapshot
Previous Message Robert Haas 2013-01-08 13:47:27 Re: Re: Proposal: Store "timestamptz" of database creation on "pg_database"