62 #include "utils/fmgroids.h"
114 bool reject_indirect,
118 char *origSchemaName,
128 const char *initialVersion,
129 List *updateVersions,
130 char *origSchemaName,
155 (
errcode(ERRCODE_UNDEFINED_OBJECT),
156 errmsg(
"extension \"%s\" does not exist",
212 int namelen = strlen(extensionname);
220 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
221 errmsg(
"invalid extension name: \"%s\"", extensionname),
222 errdetail(
"Extension names must not be empty.")));
227 if (strstr(extensionname,
"--"))
229 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
230 errmsg(
"invalid extension name: \"%s\"", extensionname),
231 errdetail(
"Extension names must not contain \"--\".")));
239 if (extensionname[0] ==
'-' || extensionname[namelen - 1] ==
'-')
241 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
242 errmsg(
"invalid extension name: \"%s\"", extensionname),
243 errdetail(
"Extension names must not begin or end with \"-\".")));
251 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
252 errmsg(
"invalid extension name: \"%s\"", extensionname),
253 errdetail(
"Extension names must not contain directory separator characters.")));
259 int namelen = strlen(versionname);
267 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
268 errmsg(
"invalid extension version name: \"%s\"", versionname),
269 errdetail(
"Version names must not be empty.")));
274 if (strstr(versionname,
"--"))
276 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
277 errmsg(
"invalid extension version name: \"%s\"", versionname),
278 errdetail(
"Version names must not contain \"--\".")));
283 if (versionname[0] ==
'-' || versionname[namelen - 1] ==
'-')
285 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
286 errmsg(
"invalid extension version name: \"%s\"", versionname),
287 errdetail(
"Version names must not begin or end with \"-\".")));
295 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
296 errmsg(
"invalid extension version name: \"%s\"", versionname),
297 errdetail(
"Version names must not contain directory separator characters.")));
306 const char *extension = strrchr(
filename,
'.');
308 return (extension != NULL) && (strcmp(extension,
".control") == 0);
314 const char *extension = strrchr(
filename,
'.');
316 return (extension != NULL) && (strcmp(extension,
".sql") == 0);
380 scriptdir, control->
name, version);
389 const char *from_version,
const char *version)
399 scriptdir, control->
name, from_version, version);
402 scriptdir, control->
name, version);
450 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
451 errmsg(
"extension \"%s\" is not available", control->
name),
452 errdetail(
"Could not open extension control file \"%s\": %m.",
454 errhint(
"The extension must first be installed on the system where PostgreSQL is running.")));
458 errmsg(
"could not open extension control file \"%s\": %m",
474 for (item = head; item != NULL; item = item->
next)
476 if (strcmp(item->
name,
"directory") == 0)
480 (
errcode(ERRCODE_SYNTAX_ERROR),
481 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
486 else if (strcmp(item->
name,
"default_version") == 0)
490 (
errcode(ERRCODE_SYNTAX_ERROR),
491 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
496 else if (strcmp(item->
name,
"module_pathname") == 0)
500 else if (strcmp(item->
name,
"comment") == 0)
504 else if (strcmp(item->
name,
"schema") == 0)
508 else if (strcmp(item->
name,
"relocatable") == 0)
512 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
513 errmsg(
"parameter \"%s\" requires a Boolean value",
516 else if (strcmp(item->
name,
"superuser") == 0)
520 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
521 errmsg(
"parameter \"%s\" requires a Boolean value",
524 else if (strcmp(item->
name,
"trusted") == 0)
528 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
529 errmsg(
"parameter \"%s\" requires a Boolean value",
532 else if (strcmp(item->
name,
"encoding") == 0)
537 (
errcode(ERRCODE_UNDEFINED_OBJECT),
538 errmsg(
"\"%s\" is not a valid encoding name",
541 else if (strcmp(item->
name,
"requires") == 0)
551 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
552 errmsg(
"parameter \"%s\" must be a list of extension names",
556 else if (strcmp(item->
name,
"no_relocate") == 0)
566 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
567 errmsg(
"parameter \"%s\" must be a list of extension names",
573 (
errcode(ERRCODE_SYNTAX_ERROR),
574 errmsg(
"unrecognized parameter \"%s\" in file \"%s\"",
582 (
errcode(ERRCODE_SYNTAX_ERROR),
583 errmsg(
"parameter \"schema\" cannot be specified when \"relocatable\" is true")));
687 List *raw_parsetree_list;
704 foreach(lc1, raw_parsetree_list)
716 per_parsetree_context =
718 "execute_sql_string per-statement context",
732 foreach(lc2, stmt_list)
740 if (
stmt->utilityStmt == NULL)
747 dest, NULL, NULL, 0);
760 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
761 errmsg(
"transaction control statements are not allowed within an extension script")));
815 const char *from_version,
817 List *requiredSchemas,
818 const char *schemaName,
Oid schemaOid)
820 bool switch_to_superuser =
false;
823 int save_sec_context = 0;
837 switch_to_superuser =
true;
838 else if (from_version == NULL)
840 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
841 errmsg(
"permission denied to create extension \"%s\"",
844 ?
errhint(
"Must have CREATE privilege on current database to create this extension.")
845 :
errhint(
"Must be superuser to create this extension.")));
848 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
849 errmsg(
"permission denied to update extension \"%s\"",
852 ?
errhint(
"Must have CREATE privilege on current database to update this extension.")
853 :
errhint(
"Must be superuser to update this extension.")));
858 if (from_version == NULL)
859 elog(
DEBUG1,
"executing extension script for \"%s\" version '%s'", control->
name, version);
861 elog(
DEBUG1,
"executing extension script for \"%s\" update from version '%s' to '%s'", control->
name, from_version, version);
868 if (switch_to_superuser)
896 BOOTSTRAP_SUPERUSERID,
918 foreach(lc, requiredSchemas)
923 if (reqname && strcmp(reqname,
"pg_catalog") != 0)
952 const char *quoting_relevant_chars =
"\"$'\\";
972 if (strstr(c_sql,
"@extowner@"))
974 Oid uid = switch_to_superuser ? save_userid :
GetUserId();
983 if (strpbrk(userName, quoting_relevant_chars))
985 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
986 errmsg(
"invalid character in extension owner: must not contain any of \"%s\"",
987 quoting_relevant_chars)));
1007 if (t_sql != old && strpbrk(schemaName, quoting_relevant_chars))
1009 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1010 errmsg(
"invalid character in extension \"%s\" schema: must not contain any of \"%s\"",
1011 control->
name, quoting_relevant_chars)));
1022 char *reqextname = (
char *)
lfirst(lc);
1028 repltoken =
psprintf(
"@extschema:%s@", reqextname);
1034 if (t_sql != old && strpbrk(schemaName, quoting_relevant_chars))
1036 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1037 errmsg(
"invalid character in extension \"%s\" schema: must not contain any of \"%s\"",
1038 reqextname, quoting_relevant_chars)));
1074 if (switch_to_superuser)
1092 foreach(lc, *evi_list)
1095 if (strcmp(evi->
name, versionname) == 0)
1108 *evi_list =
lappend(*evi_list, evi);
1125 foreach(lc, evi_list)
1151 int extnamelen = strlen(control->
name);
1158 while ((de =
ReadDir(dir, location)) != NULL)
1170 if (strncmp(de->
d_name, control->
name, extnamelen) != 0 ||
1171 de->
d_name[extnamelen] !=
'-' ||
1172 de->
d_name[extnamelen + 1] !=
'-')
1177 *strrchr(vername,
'.') =
'\0';
1178 vername2 = strstr(vername,
"--");
1190 if (strstr(vername2,
"--"))
1212 const char *oldVersion,
const char *newVersion)
1231 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1232 errmsg(
"extension \"%s\" has no update path from version \"%s\" to version \"%s\"",
1233 control->
name, oldVersion, newVersion)));
1257 bool reject_indirect,
1265 Assert(evi_start != evi_target);
1271 foreach(lc, evi_list)
1287 if (evi == evi_target)
1298 if (newdist < evi2->distance)
1303 else if (newdist == evi2->
distance &&
1326 for (evi = evi_target; evi != evi_start; evi = evi->
previous)
1363 foreach(lc, evi_list)
1380 if (evi_start == NULL ||
1383 strcmp(evi_start->
name, evi1->
name) < 0))
1404 const char *versionName,
1409 char *origSchemaName = schemaName;
1416 List *updateVersions;
1417 List *requiredExtensions;
1418 List *requiredSchemas;
1433 if (versionName == NULL)
1439 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1440 errmsg(
"version to install must be specified")));
1454 updateVersions =
NIL;
1474 if (evi_start == NULL)
1476 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1477 errmsg(
"extension \"%s\" has no installation script nor update path for version \"%s\"",
1478 pcontrol->
name, versionName)));
1481 versionName = evi_start->
name;
1498 if (control->
schema != NULL)
1507 if (schemaName && strcmp(control->
schema, schemaName) != 0 &&
1510 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1511 errmsg(
"extension \"%s\" must be installed in schema \"%s\"",
1516 schemaName = control->
schema;
1548 if (search_path ==
NIL)
1550 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1551 errmsg(
"no schema has been selected to create in")));
1554 if (schemaName == NULL)
1556 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1557 errmsg(
"no schema has been selected to create in")));
1582 requiredExtensions =
NIL;
1583 requiredSchemas =
NIL;
1586 char *curreq = (
char *)
lfirst(lc);
1597 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
1598 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
1609 requiredExtensions);
1624 schemaName, schemaOid);
1631 versionName, updateVersions,
1632 origSchemaName, cascade, is_create);
1642 char *extensionName,
1643 char *origSchemaName,
1648 Oid reqExtensionOid;
1657 List *cascade_parents;
1664 foreach(lc, parents)
1666 char *pname = (
char *)
lfirst(lc);
1668 if (strcmp(pname, reqExtensionName) == 0)
1670 (
errcode(ERRCODE_INVALID_RECURSION),
1671 errmsg(
"cyclic dependency detected between extensions \"%s\" and \"%s\"",
1672 reqExtensionName, extensionName)));
1676 (
errmsg(
"installing required extension \"%s\"",
1677 reqExtensionName)));
1698 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1699 errmsg(
"required extension \"%s\" is not installed",
1702 errhint(
"Use CREATE EXTENSION ... CASCADE to install required extensions too.") : 0));
1705 return reqExtensionOid;
1715 DefElem *d_new_version = NULL;
1717 char *schemaName = NULL;
1718 char *versionName = NULL;
1719 bool cascade =
false;
1733 if (
stmt->if_not_exists)
1737 errmsg(
"extension \"%s\" already exists, skipping",
1744 errmsg(
"extension \"%s\" already exists",
1754 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1755 errmsg(
"nested CREATE EXTENSION is not supported")));
1758 foreach(lc,
stmt->options)
1762 if (strcmp(defel->
defname,
"schema") == 0)
1769 else if (strcmp(defel->
defname,
"new_version") == 0)
1773 d_new_version = defel;
1776 else if (strcmp(defel->
defname,
"cascade") == 0)
1811 Oid schemaOid,
bool relocatable,
const char *extVersion,
1813 List *requiredExtensions)
1818 bool nulls[Natts_pg_extension];
1831 memset(nulls, 0,
sizeof(nulls));
1834 Anum_pg_extension_oid);
1836 values[Anum_pg_extension_extname - 1] =
1844 nulls[Anum_pg_extension_extconfig - 1] =
true;
1846 values[Anum_pg_extension_extconfig - 1] = extConfig;
1849 nulls[Anum_pg_extension_extcondition - 1] =
true;
1851 values[Anum_pg_extension_extcondition - 1] = extCondition;
1872 foreach(lc, requiredExtensions)
1918 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1919 errmsg(
"cannot drop extension \"%s\" because it is being modified",
1925 Anum_pg_extension_oid,
1969 if (dir == NULL && errno == ENOENT)
1975 while ((de =
ReadDir(dir, location)) != NULL)
1986 extname =
pstrdup(de->d_name);
1987 *strrchr(extname,
'.') =
'\0';
1990 if (strstr(extname,
"--"))
1996 memset(nulls, 0,
sizeof(nulls));
2049 if (dir == NULL && errno == ENOENT)
2055 while ((de =
ReadDir(dir, location)) != NULL)
2064 extname =
pstrdup(de->d_name);
2065 *strrchr(extname,
'.') =
'\0';
2068 if (strstr(extname,
"--"))
2101 foreach(lc, evi_list)
2118 memset(nulls, 0,
sizeof(nulls));
2132 if (control->
schema == NULL)
2155 foreach(lc2, evi_list)
2206 bool result =
false;
2218 if (dir == NULL && errno == ENOENT)
2224 while ((de =
ReadDir(dir, location)) != NULL)
2233 *strrchr(extname,
'.') =
'\0';
2236 if (strstr(extname,
"--"))
2240 if (strcmp(extname, extensionName) == 0)
2267 foreach(lc, requires)
2269 char *curreq = (
char *)
lfirst(lc);
2304 foreach(lc1, evi_list)
2309 foreach(lc2, evi_list)
2324 memset(nulls, 0,
sizeof(nulls));
2343 char *versionName = (
char *)
lfirst(lcv);
2382 Datum repl_val[Natts_pg_extension];
2383 bool repl_null[Natts_pg_extension];
2384 bool repl_repl[Natts_pg_extension];
2393 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2394 errmsg(
"%s can only be called from an SQL script executed by CREATE EXTENSION",
2395 "pg_extension_config_dump()")));
2403 if (tablename == NULL)
2406 errmsg(
"OID %u does not refer to a table", tableoid)));
2410 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2411 errmsg(
"table \"%s\" is not a member of the extension being created",
2426 Anum_pg_extension_oid,
2436 elog(
ERROR,
"could not find tuple for extension %u",
2439 memset(repl_val, 0,
sizeof(repl_val));
2440 memset(repl_null,
false,
sizeof(repl_null));
2441 memset(repl_repl,
false,
sizeof(repl_repl));
2446 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2470 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2473 arrayIndex = arrayLength + 1;
2475 for (
i = 0;
i < arrayLength;
i++)
2477 if (arrayData[
i] == tableoid)
2493 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2498 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2502 if (arrayLength != 0)
2503 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2515 elog(
ERROR,
"extcondition is not a 1-D text array");
2517 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2529 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2532 repl_val, repl_null, repl_repl);
2561 Datum repl_val[Natts_pg_extension];
2562 bool repl_null[Natts_pg_extension];
2563 bool repl_repl[Natts_pg_extension];
2570 Anum_pg_extension_oid,
2580 elog(
ERROR,
"could not find tuple for extension %u",
2584 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2606 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2611 for (
i = 0;
i < arrayLength;
i++)
2613 if (arrayData[
i] == tableoid)
2630 memset(repl_val, 0,
sizeof(repl_val));
2631 memset(repl_null,
false,
sizeof(repl_null));
2632 memset(repl_repl,
false,
sizeof(repl_repl));
2634 if (arrayLength <= 1)
2637 repl_null[Anum_pg_extension_extconfig - 1] =
true;
2649 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2650 dvalues[
i] = dvalues[
i + 1];
2656 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2659 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2663 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2673 elog(
ERROR,
"extcondition is not a 1-D text array");
2675 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2678 if (arrayLength <= 1)
2681 repl_null[Anum_pg_extension_extcondition - 1] =
true;
2693 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2694 dvalues[
i] = dvalues[
i + 1];
2700 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2703 repl_val, repl_null, repl_repl);
2756 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2757 errmsg(
"cannot move extension \"%s\" into schema \"%s\" "
2758 "because the extension contains the schema",
2759 extensionName, newschema)));
2765 Anum_pg_extension_oid,
2775 elog(
ERROR,
"could not find tuple for extension %u",
2788 if (extForm->extnamespace == nspOid)
2795 if (!extForm->extrelocatable)
2797 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2798 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2804 oldNspOid = extForm->extnamespace;
2813 Anum_pg_depend_refclassid,
2817 Anum_pg_depend_refobjid,
2840 pg_depend->classid == ExtensionRelationId)
2849 char *nrextname = (
char *)
lfirst(lc);
2851 if (strcmp(nrextname,
NameStr(extForm->extname)) == 0)
2854 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2855 errmsg(
"cannot SET SCHEMA of extension \"%s\" because other extensions prevent it",
2857 errdetail(
"Extension \"%s\" requests no relocation of extension \"%s\".",
2872 dep.
classId = pg_depend->classid;
2877 elog(
ERROR,
"extension should not have a sub-object dependency");
2889 if (dep_oldNspOid !=
InvalidOid && dep_oldNspOid != oldNspOid)
2891 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2892 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2894 errdetail(
"%s is not in the extension's schema \"%s\"",
2901 *oldschema = oldNspOid;
2908 extForm->extnamespace = nspOid;
2916 NamespaceRelationId, oldNspOid, nspOid) != 1)
2917 elog(
ERROR,
"could not change schema dependency for extension %s",
2933 DefElem *d_new_version = NULL;
2935 char *oldVersionName;
2942 List *updateVersions;
2954 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2955 errmsg(
"nested ALTER EXTENSION is not supported")));
2963 Anum_pg_extension_extname,
2974 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2975 errmsg(
"extension \"%s\" does not exist",
2983 datum =
heap_getattr(extTup, Anum_pg_extension_extversion,
3008 foreach(lc,
stmt->options)
3012 if (strcmp(defel->
defname,
"new_version") == 0)
3016 d_new_version = defel;
3025 if (d_new_version && d_new_version->
arg)
3026 versionName =
strVal(d_new_version->
arg);
3032 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3033 errmsg(
"version to install must be specified")));
3041 if (strcmp(oldVersionName, versionName) == 0)
3044 (
errmsg(
"version \"%s\" of extension \"%s\" is already installed",
3045 versionName,
stmt->extname)));
3061 oldVersionName, updateVersions,
3062 NULL,
false,
false);
3080 const char *initialVersion,
3081 List *updateVersions,
3082 char *origSchemaName,
3086 const char *oldVersionName = initialVersion;
3089 foreach(lcv, updateVersions)
3091 char *versionName = (
char *)
lfirst(lcv);
3095 List *requiredExtensions;
3096 List *requiredSchemas;
3103 bool nulls[Natts_pg_extension];
3104 bool repl[Natts_pg_extension];
3117 Anum_pg_extension_oid,
3127 elog(
ERROR,
"could not find tuple for extension %u",
3135 schemaOid = extForm->extnamespace;
3142 memset(nulls, 0,
sizeof(nulls));
3143 memset(repl, 0,
sizeof(repl));
3145 values[Anum_pg_extension_extrelocatable - 1] =
3147 repl[Anum_pg_extension_extrelocatable - 1] =
true;
3148 values[Anum_pg_extension_extversion - 1] =
3150 repl[Anum_pg_extension_extversion - 1] =
true;
3166 requiredExtensions =
NIL;
3167 requiredSchemas =
NIL;
3170 char *curreq = (
char *)
lfirst(lc);
3181 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
3182 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
3189 ExtensionRelationId,
3192 myself.
classId = ExtensionRelationId;
3196 foreach(lc, requiredExtensions)
3201 otherext.
classId = ExtensionRelationId;
3214 oldVersionName, versionName,
3216 schemaName, schemaOid);
3223 oldVersionName = versionName;
3243 switch (
stmt->objtype)
3254 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3255 errmsg(
"cannot add an object of this type to an extension")));
3288 Assert(
object.objectSubId == 0);
3294 stmt->object, relation);
3308 if (relation != NULL)
3333 if (
stmt->action > 0)
3340 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3341 errmsg(
"%s is already a member of extension \"%s\"",
3349 if (
object.classId == NamespaceRelationId &&
3352 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3353 errmsg(
"cannot add schema \"%s\" to extension \"%s\" "
3354 "because the schema contains the extension",
3378 if (oldExtension != extension.
objectId)
3380 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3381 errmsg(
"%s is not a member of extension \"%s\"",
3389 ExtensionRelationId,
3391 elog(
ERROR,
"unexpected number of extension dependency records");
3397 if (
object.classId == RelationRelationId)
3416 if (
object.classId == TypeRelationId)
3420 depobject.
classId = TypeRelationId;
3434 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3435 errmsg(
"could not find multirange type for data type %s",
3440 if (
object.classId == RelationRelationId)
3444 depobject.
classId = TypeRelationId;
3465 size_t bytes_to_read;
3475 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
3477 bytes_to_read = (size_t) fst.
st_size;
3482 errmsg(
"could not open file \"%s\" for reading: %m",
3485 buf = (
char *)
palloc(bytes_to_read + 1);
3487 *length = fread(
buf, 1, bytes_to_read, file);
3496 buf[*length] =
'\0';
void recordExtObjInitPriv(Oid objoid, Oid classoid)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
void removeExtObjInitPriv(Oid objoid, Oid classoid)
Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid, ObjectAddresses *objsMoved)
#define DatumGetArrayTypeP(X)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
ArrayType * array_set(ArrayType *array, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
bool parse_bool(const char *value, bool *result)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define Assert(condition)
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
#define CONF_FILE_START_DEPTH
bool defGetBoolean(DefElem *def)
char * defGetString(DefElem *def)
void errorConflictingDefElem(DefElem *defel, ParseState *pstate)
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
ObjectAddresses * new_object_addresses(void)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
void free_object_addresses(ObjectAddresses *addrs)
DestReceiver * CreateDestReceiver(CommandDest dest)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecutorEnd(QueryDesc *queryDesc)
void ExecutorFinish(QueryDesc *queryDesc)
void ExecutorStart(QueryDesc *queryDesc, int eflags)
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
static ExtensionVersionInfo * get_ext_ver_info(const char *versionname, List **evi_list)
Oid get_extension_schema(Oid ext_oid)
static bool is_extension_script_filename(const char *filename)
static char * read_whole_file(const char *filename, int *length)
ObjectAddress InsertExtensionTuple(const char *extName, Oid extOwner, Oid schemaOid, bool relocatable, const char *extVersion, Datum extConfig, Datum extCondition, List *requiredExtensions)
static void check_valid_extension_name(const char *extensionname)
static char * read_extension_script_file(const ExtensionControlFile *control, const char *filename)
static List * identify_update_path(ExtensionControlFile *control, const char *oldVersion, const char *newVersion)
struct ExtensionVersionInfo ExtensionVersionInfo
ObjectAddress CreateExtension(ParseState *pstate, CreateExtensionStmt *stmt)
static void check_valid_version_name(const char *versionname)
static bool is_extension_control_filename(const char *filename)
static Oid get_required_extension(char *reqExtensionName, char *extensionName, char *origSchemaName, bool cascade, List *parents, bool is_create)
static char * get_extension_script_filename(ExtensionControlFile *control, const char *from_version, const char *version)
static List * get_ext_ver_list(ExtensionControlFile *control)
static void execute_extension_script(Oid extensionOid, ExtensionControlFile *control, const char *from_version, const char *version, List *requiredSchemas, const char *schemaName, Oid schemaOid)
static void parse_extension_control_file(ExtensionControlFile *control, const char *version)
Datum pg_available_extension_versions(PG_FUNCTION_ARGS)
static void extension_config_remove(Oid extensionoid, Oid tableoid)
static ExtensionVersionInfo * get_nearest_unprocessed_vertex(List *evi_list)
ObjectAddress AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *oldschema)
static char * get_extension_control_directory(void)
static char * get_extension_script_directory(ExtensionControlFile *control)
static void execute_sql_string(const char *sql)
static ExtensionControlFile * read_extension_control_file(const char *extname)
ObjectAddress ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
Oid CurrentExtensionObject
ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt, ObjectAddress *objAddr)
Datum pg_extension_update_paths(PG_FUNCTION_ARGS)
static void ExecAlterExtensionContentsRecurse(AlterExtensionContentsStmt *stmt, ObjectAddress extension, ObjectAddress object)
Oid get_extension_oid(const char *extname, bool missing_ok)
Datum pg_available_extensions(PG_FUNCTION_ARGS)
Datum pg_extension_config_dump(PG_FUNCTION_ARGS)
static ExtensionVersionInfo * find_install_path(List *evi_list, ExtensionVersionInfo *evi_target, List **best_path)
static Datum convert_requires_to_datum(List *requires)
static char * get_extension_control_filename(const char *extname)
static ExtensionControlFile * read_extension_aux_control_file(const ExtensionControlFile *pcontrol, const char *version)
struct ExtensionControlFile ExtensionControlFile
char * get_extension_name(Oid ext_oid)
void RemoveExtensionById(Oid extId)
static void get_available_versions_for_extension(ExtensionControlFile *pcontrol, Tuplestorestate *tupstore, TupleDesc tupdesc)
static List * find_update_path(List *evi_list, ExtensionVersionInfo *evi_start, ExtensionVersionInfo *evi_target, bool reject_indirect, bool reinitialize)
bool extension_file_exists(const char *extensionName)
static bool extension_is_trusted(ExtensionControlFile *control)
static void ApplyExtensionUpdates(Oid extensionOid, ExtensionControlFile *pcontrol, const char *initialVersion, List *updateVersions, char *origSchemaName, bool cascade, bool is_create)
static ObjectAddress CreateExtensionInternal(char *extensionName, char *schemaName, const char *versionName, bool cascade, List *parents, bool is_create)
static char * get_extension_aux_control_filename(ExtensionControlFile *control, const char *version)
struct dirent * ReadDir(DIR *dir, const char *dirname)
FILE * AllocateFile(const char *name, const char *mode)
DIR * AllocateDir(const char *dirname)
Datum DirectFunctionCall4Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
Datum DirectFunctionCall3Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3)
#define PG_GETARG_TEXT_PP(n)
#define DatumGetTextPP(X)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_NAME(n)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
char my_exec_path[MAXPGPATH]
int set_config_option_ext(const char *name, const char *value, GucContext context, GucSource source, Oid srole, GucAction action, bool changeVal, int elevel, bool is_reload)
int NewGUCNestLevel(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
void FreeConfigVariables(ConfigVariable *list)
bool ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
bool check_function_bodies
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_copytuple(HeapTuple tuple)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
if(TABLE==NULL||TABLE_index==NULL)
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
List * list_copy(const List *oldlist)
void list_free(List *list)
List * lcons(void *datum, List *list)
#define ShareUpdateExclusiveLock
bool type_is_range(Oid typid)
char * get_namespace_name(Oid nspid)
Oid get_rel_type_id(Oid relid)
char * get_rel_name(Oid relid)
Oid get_range_multirange(Oid rangeOid)
Oid get_array_type(Oid typid)
char * pg_any_to_server(const char *s, int len, int encoding)
int GetDatabaseEncoding(void)
bool pg_verify_mbstr(int encoding, const char *mbstr, int len, bool noError)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define SECURITY_LOCAL_USERID_CHANGE
char * GetUserNameFromId(Oid roleid, bool noerr)
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
Datum namein(PG_FUNCTION_ARGS)
bool isTempNamespace(Oid namespaceId)
Oid LookupCreationNamespace(const char *nspname)
List * fetch_search_path(bool includeImplicit)
Oid get_namespace_oid(const char *nspname, bool missing_ok)
#define IsA(nodeptr, _type_)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
char * getObjectDescription(const ObjectAddress *object, bool missing_ok)
void check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, Node *object, Relation relation)
const ObjectAddress InvalidObjectAddress
ObjectAddress get_object_address(ObjectType objtype, Node *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
#define ObjectAddressSet(addr, class_id, object_id)
#define CURSOR_OPT_PARALLEL_OK
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
long deleteDependencyRecordsForClass(Oid classId, Oid objectId, Oid refclassId, char deptype)
Oid getExtensionOfObject(Oid classId, Oid objectId)
FormData_pg_depend * Form_pg_depend
FormData_pg_extension * Form_pg_extension
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
#define pg_valid_server_encoding
#define ERRCODE_UNDEFINED_TABLE
void get_share_path(const char *my_exec_path, char *ret_path)
#define is_absolute_path(filename)
char * first_dir_separator(const char *filename)
List * pg_parse_query(const char *query_string)
List * pg_analyze_and_rewrite_fixedparams(RawStmt *parsetree, const char *query_string, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
List * pg_plan_queries(List *querytrees, const char *query_string, int cursorOptions, ParamListInfo boundParams)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
void FreeQueryDesc(QueryDesc *qdesc)
QueryDesc * CreateQueryDesc(PlannedStmt *plannedstmt, const char *sourceText, Snapshot snapshot, Snapshot crosscheck_snapshot, DestReceiver *dest, ParamListInfo params, QueryEnvironment *queryEnv, int instrument_options)
char * psprintf(const char *fmt,...)
MemoryContextSwitchTo(old_ctx)
Datum textregexreplace(PG_FUNCTION_ARGS)
#define RelationGetDescr(relation)
const char * quote_identifier(const char *ident)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Oid CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString, int stmt_location, int stmt_len)
Snapshot GetTransactionSnapshot(void)
void PushActiveSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
Snapshot GetActiveSnapshot(void)
void relation_close(Relation relation, LOCKMODE lockmode)
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
struct ConfigVariable * next
struct ExtensionVersionInfo * previous
Tuplestorestate * setResult
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define GetSysCacheOid1(cacheId, oidcol, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
void ProcessUtility(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc)
String * makeString(char *str)
char * text_to_cstring(const text *t)
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Datum replace_text(PG_FUNCTION_ARGS)
void CommandCounterIncrement(void)
#define XACT_FLAGS_ACCESSEDTEMPNAMESPACE