Re: ALTER OBJECT any_name SET SCHEMA name
Dimitri Fontaine <dimitri@2ndquadrant.fr>
From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
To: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Dimitri Fontaine <dimitri@2ndquadrant.fr>, Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>, Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2010-11-04T14:06:48Z
Lists: pgsql-hackers
Attachments
- set_schema.5.patch (text/x-patch) patch
- alter_extension.1.patch (text/x-patch) patch
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