Re: ALTER OBJECT any_name SET SCHEMA name - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: ALTER OBJECT any_name SET SCHEMA name
Date
Msg-id m2lj59p4hz.fsf@2ndQuadrant.fr
Whole thread Raw
In response to Re: ALTER OBJECT any_name SET SCHEMA name  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: ALTER OBJECT any_name SET SCHEMA name
Re: ALTER OBJECT any_name SET SCHEMA name
List pgsql-hackers
Alvaro Herrera <alvherre@commandprompt.com> writes:
> FWIW I think you should use getObjectDescription, as in the attached
> patch.  (Note the patch is incomplete and does not compile because only
> one caller to CheckSetNamespace has been fixed).

I had to re-add the object name to the CheckSetNamespace prototype to
handle this particular check:

    /* check for duplicate name (more friendly than unique-index failure) */
    if (SearchSysCacheExists2(TYPENAMENSP,
                              CStringGetDatum(name),
                              ObjectIdGetDatum(nspOid)))

If you know how to get some struct attribute given a char * holding its
name, in C, I would adapt the patch and work on the refactoring asked
for by Tom.

Apart from that, it was just about adapting the call sites, which is
done in the attached set_schema.5.patch. Thanks!

Also attached, please find the complete version of ALTER EXTENSION ext
SET SCHEMA name; with support for all contrib extensions. That's the
example that allows to see the API (AlterFooNamespace_oid and _internal
functions) in action: that should help devising the best refactoring.

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Alter column to type serial
Next
From: Thom Brown
Date:
Subject: Re: Alter column to type serial