Re: Extensions versus pg_upgrade - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: Extensions versus pg_upgrade
Date
Msg-id m2ipwumb8w.fsf@2ndQuadrant.fr
Whole thread Raw
In response to Re: Extensions versus pg_upgrade  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Extensions versus pg_upgrade  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> 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
INTERNALdependency 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
superuserto 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


pgsql-hackers by date:

Previous
From: Bernd Helmle
Date:
Subject: Re: [COMMITTERS] pgsql: Extend ALTER TABLE to allow Foreign Keys to be added without ini
Next
From: Thom Brown
Date:
Subject: Re: Per-column collation, the finale