Tom Lane writes:
OK, that seems like an equally reasonable syntax; although doing it the
way I was thinking might have less of a code and documentation footprint
(I was vaguely imagining that it could share most of the COMMENT
infrastructure --- but haven't looked yet). In any case it seems like
this is a good piece to do next, since the required functionality is
clear and it's essential for more than one reason.
Well the code footprint is quite small already. When the grammar change
and the alter.c addition is in, it boils down to:

/*
* ALTER OBJECT SET EXTENSION
*
* This form allows for upgrading from previous PostgreSQL version to one
* supporting extensions, or to upgrade user objects to get to use the
* extension infrastructure.
*
* All we have to do is record an INTERNAL dependency between the selected
* object and the extension, which must of course already exist.
*/
void
AlterObjectExtension(const char *extname,
Oid classId, Oid objectId, Oid objectSubId)
{
ObjectAddress *extension, *object;

if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser to SET EXTENSION"))));

extension = (ObjectAddress *)palloc(sizeof(ObjectAddress));
extension->classId = ExtensionRelationId;
extension->objectId = get_extension_oid(extname, false);
extension->objectSubId = 0;

object = (ObjectAddress *)palloc(sizeof(ObjectAddress));
object->classId = classId;
object->objectId = objectId;
object->objectSubId = objectSubId;

recordDependencyOn(object, extension, DEPENDENCY_INTERNAL);

return;
}

Of course it needs some changes now, but well… I guess you'll be done
with that before I get to rebase my patch, I can only target tomorrow
now.

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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 14 of 33 | next ›
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedFeb 8, '11 at 4:54p
activeFeb 10, '11 at 4:59p
posts33
users5
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase