1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Create extension infrastructure for the core procedural languages.

This mostly just involves creating control, install, and
update-from-unpackaged scripts for them.  However, I had to adjust plperl
and plpython to not share the same support functions between variants,
because we can't put the same function into multiple extensions.

catversion bump forced due to new contents of pg_pltemplate, and because
initdb now installs plpgsql as an extension not a bare language.

Add support for regression testing these as extensions not bare
languages.

Fix a couple of other issues that popped up while testing this: my initial
hack at pg_dump binary-upgrade support didn't work right, and we don't want
an extra schema permissions test after all.

Documentation changes still to come, but I'm committing now to see
whether the MSVC build scripts need work (likely they do).
This commit is contained in:
Tom Lane
2011-03-04 21:51:14 -05:00
parent efa415da8c
commit 63b656b7bf
41 changed files with 399 additions and 43 deletions

View File

@@ -1171,6 +1171,24 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo)
dinfo->dobj.dump = include_everything;
}
/*
* selectDumpableExtension: policy-setting subroutine
* Mark an extension as to be dumped or not
*
* Normally, we just dump all extensions. However, in binary-upgrade mode
* it's necessary to skip built-in extensions, since we assume those will
* already be installed in the target database. We identify such extensions
* by their having OIDs in the range reserved for initdb.
*/
static void
selectDumpableExtension(ExtensionInfo *extinfo)
{
if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
else
extinfo->dobj.dump = true;
}
/*
* selectDumpableObject: policy-setting subroutine
* Mark a generic dumpable object as to be dumped or not
@@ -2730,6 +2748,9 @@ getExtensions(int *numExtensions)
extinfo[i].extversion = strdup(PQgetvalue(res, i, i_extversion));
extinfo[i].extconfig = strdup(PQgetvalue(res, i, i_extconfig));
extinfo[i].extcondition = strdup(PQgetvalue(res, i, i_extcondition));
/* Decide whether we want to dump it */
selectDumpableExtension(&(extinfo[i]));
}
PQclear(res);
@@ -7042,19 +7063,6 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
if (!extinfo->dobj.dump || dataOnly)
return;
/*
* In a regular dump, we use IF NOT EXISTS so that there isn't a problem
* if the extension already exists in the target database; this is
* essential for installed-by-default extensions such as plpgsql.
*
* In binary-upgrade mode, that doesn't work well, so instead we skip
* extensions with OIDs less than FirstNormalObjectId; those were
* presumably installed by initdb, and we assume they'll exist in the
* target installation too.
*/
if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
return;
q = createPQExpBuffer();
delq = createPQExpBuffer();
labelq = createPQExpBuffer();
@@ -7065,6 +7073,16 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
if (!binary_upgrade)
{
/*
* In a regular dump, we use IF NOT EXISTS so that there isn't a
* problem if the extension already exists in the target database;
* this is essential for installed-by-default extensions such as
* plpgsql.
*
* In binary-upgrade mode, that doesn't work well, so instead we skip
* built-in extensions based on their OIDs; see
* selectDumpableExtension.
*/
appendPQExpBuffer(q, "CREATE EXTENSION IF NOT EXISTS %s WITH SCHEMA %s;\n",
qextname, fmtId(extinfo->namespace));
}