62 #include "utils/fmgroids.h"
113 bool reject_indirect,
117 char *origSchemaName,
127 const char *initialVersion,
128 List *updateVersions,
129 char *origSchemaName,
156 Anum_pg_extension_extname,
177 (
errcode(ERRCODE_UNDEFINED_OBJECT),
178 errmsg(
"extension \"%s\" does not exist",
201 Anum_pg_extension_oid,
240 Anum_pg_extension_oid,
268 int namelen = strlen(extensionname);
276 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
277 errmsg(
"invalid extension name: \"%s\"", extensionname),
278 errdetail(
"Extension names must not be empty.")));
283 if (strstr(extensionname,
"--"))
285 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
286 errmsg(
"invalid extension name: \"%s\"", extensionname),
287 errdetail(
"Extension names must not contain \"--\".")));
295 if (extensionname[0] ==
'-' || extensionname[namelen - 1] ==
'-')
297 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
298 errmsg(
"invalid extension name: \"%s\"", extensionname),
299 errdetail(
"Extension names must not begin or end with \"-\".")));
307 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
308 errmsg(
"invalid extension name: \"%s\"", extensionname),
309 errdetail(
"Extension names must not contain directory separator characters.")));
315 int namelen = strlen(versionname);
323 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
324 errmsg(
"invalid extension version name: \"%s\"", versionname),
325 errdetail(
"Version names must not be empty.")));
330 if (strstr(versionname,
"--"))
332 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
333 errmsg(
"invalid extension version name: \"%s\"", versionname),
334 errdetail(
"Version names must not contain \"--\".")));
339 if (versionname[0] ==
'-' || versionname[namelen - 1] ==
'-')
341 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
342 errmsg(
"invalid extension version name: \"%s\"", versionname),
343 errdetail(
"Version names must not begin or end with \"-\".")));
351 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
352 errmsg(
"invalid extension version name: \"%s\"", versionname),
353 errdetail(
"Version names must not contain directory separator characters.")));
362 const char *extension = strrchr(
filename,
'.');
364 return (extension != NULL) && (strcmp(extension,
".control") == 0);
370 const char *extension = strrchr(
filename,
'.');
372 return (extension != NULL) && (strcmp(extension,
".sql") == 0);
436 scriptdir, control->
name, version);
445 const char *from_version,
const char *version)
455 scriptdir, control->
name, from_version, version);
458 scriptdir, control->
name, version);
506 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
507 errmsg(
"extension \"%s\" is not available", control->
name),
508 errdetail(
"Could not open extension control file \"%s\": %m.",
510 errhint(
"The extension must first be installed on the system where PostgreSQL is running.")));
514 errmsg(
"could not open extension control file \"%s\": %m",
530 for (item = head; item != NULL; item = item->
next)
532 if (strcmp(item->
name,
"directory") == 0)
536 (
errcode(ERRCODE_SYNTAX_ERROR),
537 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
542 else if (strcmp(item->
name,
"default_version") == 0)
546 (
errcode(ERRCODE_SYNTAX_ERROR),
547 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
552 else if (strcmp(item->
name,
"module_pathname") == 0)
556 else if (strcmp(item->
name,
"comment") == 0)
560 else if (strcmp(item->
name,
"schema") == 0)
564 else if (strcmp(item->
name,
"relocatable") == 0)
568 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
569 errmsg(
"parameter \"%s\" requires a Boolean value",
572 else if (strcmp(item->
name,
"superuser") == 0)
576 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
577 errmsg(
"parameter \"%s\" requires a Boolean value",
580 else if (strcmp(item->
name,
"trusted") == 0)
584 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
585 errmsg(
"parameter \"%s\" requires a Boolean value",
588 else if (strcmp(item->
name,
"encoding") == 0)
593 (
errcode(ERRCODE_UNDEFINED_OBJECT),
594 errmsg(
"\"%s\" is not a valid encoding name",
597 else if (strcmp(item->
name,
"requires") == 0)
607 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
608 errmsg(
"parameter \"%s\" must be a list of extension names",
612 else if (strcmp(item->
name,
"no_relocate") == 0)
622 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
623 errmsg(
"parameter \"%s\" must be a list of extension names",
629 (
errcode(ERRCODE_SYNTAX_ERROR),
630 errmsg(
"unrecognized parameter \"%s\" in file \"%s\"",
638 (
errcode(ERRCODE_SYNTAX_ERROR),
639 errmsg(
"parameter \"schema\" cannot be specified when \"relocatable\" is true")));
743 List *raw_parsetree_list;
760 foreach(lc1, raw_parsetree_list)
772 per_parsetree_context =
774 "execute_sql_string per-statement context",
788 foreach(lc2, stmt_list)
796 if (
stmt->utilityStmt == NULL)
803 dest, NULL, NULL, 0);
816 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
817 errmsg(
"transaction control statements are not allowed within an extension script")));
871 const char *from_version,
873 List *requiredSchemas,
874 const char *schemaName,
Oid schemaOid)
876 bool switch_to_superuser =
false;
879 int save_sec_context = 0;
893 switch_to_superuser =
true;
894 else if (from_version == NULL)
896 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
897 errmsg(
"permission denied to create extension \"%s\"",
900 ?
errhint(
"Must have CREATE privilege on current database to create this extension.")
901 :
errhint(
"Must be superuser to create this extension.")));
904 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
905 errmsg(
"permission denied to update extension \"%s\"",
908 ?
errhint(
"Must have CREATE privilege on current database to update this extension.")
909 :
errhint(
"Must be superuser to update this extension.")));
914 if (from_version == NULL)
915 elog(
DEBUG1,
"executing extension script for \"%s\" version '%s'", control->
name, version);
917 elog(
DEBUG1,
"executing extension script for \"%s\" update from version '%s' to '%s'", control->
name, from_version, version);
924 if (switch_to_superuser)
952 BOOTSTRAP_SUPERUSERID,
974 foreach(lc, requiredSchemas)
979 if (reqname && strcmp(reqname,
"pg_catalog") != 0)
1008 const char *quoting_relevant_chars =
"\"$'\\";
1028 if (strstr(c_sql,
"@extowner@"))
1030 Oid uid = switch_to_superuser ? save_userid :
GetUserId();
1039 if (strpbrk(userName, quoting_relevant_chars))
1041 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1042 errmsg(
"invalid character in extension owner: must not contain any of \"%s\"",
1043 quoting_relevant_chars)));
1063 if (t_sql != old && strpbrk(schemaName, quoting_relevant_chars))
1065 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1066 errmsg(
"invalid character in extension \"%s\" schema: must not contain any of \"%s\"",
1067 control->
name, quoting_relevant_chars)));
1078 char *reqextname = (
char *)
lfirst(lc);
1084 repltoken =
psprintf(
"@extschema:%s@", reqextname);
1090 if (t_sql != old && strpbrk(schemaName, quoting_relevant_chars))
1092 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1093 errmsg(
"invalid character in extension \"%s\" schema: must not contain any of \"%s\"",
1094 reqextname, quoting_relevant_chars)));
1130 if (switch_to_superuser)
1148 foreach(lc, *evi_list)
1151 if (strcmp(evi->
name, versionname) == 0)
1164 *evi_list =
lappend(*evi_list, evi);
1181 foreach(lc, evi_list)
1207 int extnamelen = strlen(control->
name);
1214 while ((de =
ReadDir(dir, location)) != NULL)
1226 if (strncmp(de->
d_name, control->
name, extnamelen) != 0 ||
1227 de->
d_name[extnamelen] !=
'-' ||
1228 de->
d_name[extnamelen + 1] !=
'-')
1233 *strrchr(vername,
'.') =
'\0';
1234 vername2 = strstr(vername,
"--");
1246 if (strstr(vername2,
"--"))
1268 const char *oldVersion,
const char *newVersion)
1287 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1288 errmsg(
"extension \"%s\" has no update path from version \"%s\" to version \"%s\"",
1289 control->
name, oldVersion, newVersion)));
1313 bool reject_indirect,
1321 Assert(evi_start != evi_target);
1327 foreach(lc, evi_list)
1343 if (evi == evi_target)
1354 if (newdist < evi2->distance)
1359 else if (newdist == evi2->
distance &&
1382 for (evi = evi_target; evi != evi_start; evi = evi->
previous)
1419 foreach(lc, evi_list)
1436 if (evi_start == NULL ||
1439 strcmp(evi_start->
name, evi1->
name) < 0))
1460 const char *versionName,
1465 char *origSchemaName = schemaName;
1472 List *updateVersions;
1473 List *requiredExtensions;
1474 List *requiredSchemas;
1489 if (versionName == NULL)
1495 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1496 errmsg(
"version to install must be specified")));
1510 updateVersions =
NIL;
1530 if (evi_start == NULL)
1532 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1533 errmsg(
"extension \"%s\" has no installation script nor update path for version \"%s\"",
1534 pcontrol->
name, versionName)));
1537 versionName = evi_start->
name;
1554 if (control->
schema != NULL)
1563 if (schemaName && strcmp(control->
schema, schemaName) != 0 &&
1566 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1567 errmsg(
"extension \"%s\" must be installed in schema \"%s\"",
1572 schemaName = control->
schema;
1604 if (search_path ==
NIL)
1606 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1607 errmsg(
"no schema has been selected to create in")));
1610 if (schemaName == NULL)
1612 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1613 errmsg(
"no schema has been selected to create in")));
1638 requiredExtensions =
NIL;
1639 requiredSchemas =
NIL;
1642 char *curreq = (
char *)
lfirst(lc);
1653 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
1654 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
1665 requiredExtensions);
1680 schemaName, schemaOid);
1687 versionName, updateVersions,
1688 origSchemaName, cascade, is_create);
1698 char *extensionName,
1699 char *origSchemaName,
1704 Oid reqExtensionOid;
1713 List *cascade_parents;
1720 foreach(lc, parents)
1722 char *pname = (
char *)
lfirst(lc);
1724 if (strcmp(pname, reqExtensionName) == 0)
1726 (
errcode(ERRCODE_INVALID_RECURSION),
1727 errmsg(
"cyclic dependency detected between extensions \"%s\" and \"%s\"",
1728 reqExtensionName, extensionName)));
1732 (
errmsg(
"installing required extension \"%s\"",
1733 reqExtensionName)));
1754 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1755 errmsg(
"required extension \"%s\" is not installed",
1758 errhint(
"Use CREATE EXTENSION ... CASCADE to install required extensions too.") : 0));
1761 return reqExtensionOid;
1771 DefElem *d_new_version = NULL;
1773 char *schemaName = NULL;
1774 char *versionName = NULL;
1775 bool cascade =
false;
1789 if (
stmt->if_not_exists)
1793 errmsg(
"extension \"%s\" already exists, skipping",
1800 errmsg(
"extension \"%s\" already exists",
1810 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1811 errmsg(
"nested CREATE EXTENSION is not supported")));
1814 foreach(lc,
stmt->options)
1818 if (strcmp(defel->
defname,
"schema") == 0)
1825 else if (strcmp(defel->
defname,
"new_version") == 0)
1829 d_new_version = defel;
1832 else if (strcmp(defel->
defname,
"cascade") == 0)
1867 Oid schemaOid,
bool relocatable,
const char *extVersion,
1869 List *requiredExtensions)
1874 bool nulls[Natts_pg_extension];
1887 memset(nulls, 0,
sizeof(nulls));
1890 Anum_pg_extension_oid);
1892 values[Anum_pg_extension_extname - 1] =
1900 nulls[Anum_pg_extension_extconfig - 1] =
true;
1902 values[Anum_pg_extension_extconfig - 1] = extConfig;
1905 nulls[Anum_pg_extension_extcondition - 1] =
true;
1907 values[Anum_pg_extension_extcondition - 1] = extCondition;
1928 foreach(lc, requiredExtensions)
1974 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1975 errmsg(
"cannot drop extension \"%s\" because it is being modified",
1981 Anum_pg_extension_oid,
2025 if (dir == NULL && errno == ENOENT)
2031 while ((de =
ReadDir(dir, location)) != NULL)
2042 extname =
pstrdup(de->d_name);
2043 *strrchr(extname,
'.') =
'\0';
2046 if (strstr(extname,
"--"))
2052 memset(nulls, 0,
sizeof(nulls));
2105 if (dir == NULL && errno == ENOENT)
2111 while ((de =
ReadDir(dir, location)) != NULL)
2120 extname =
pstrdup(de->d_name);
2121 *strrchr(extname,
'.') =
'\0';
2124 if (strstr(extname,
"--"))
2157 foreach(lc, evi_list)
2174 memset(nulls, 0,
sizeof(nulls));
2188 if (control->
schema == NULL)
2211 foreach(lc2, evi_list)
2262 bool result =
false;
2274 if (dir == NULL && errno == ENOENT)
2280 while ((de =
ReadDir(dir, location)) != NULL)
2289 *strrchr(extname,
'.') =
'\0';
2292 if (strstr(extname,
"--"))
2296 if (strcmp(extname, extensionName) == 0)
2323 foreach(lc, requires)
2325 char *curreq = (
char *)
lfirst(lc);
2360 foreach(lc1, evi_list)
2365 foreach(lc2, evi_list)
2380 memset(nulls, 0,
sizeof(nulls));
2399 char *versionName = (
char *)
lfirst(lcv);
2438 Datum repl_val[Natts_pg_extension];
2439 bool repl_null[Natts_pg_extension];
2440 bool repl_repl[Natts_pg_extension];
2449 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2450 errmsg(
"%s can only be called from an SQL script executed by CREATE EXTENSION",
2451 "pg_extension_config_dump()")));
2459 if (tablename == NULL)
2462 errmsg(
"OID %u does not refer to a table", tableoid)));
2466 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2467 errmsg(
"table \"%s\" is not a member of the extension being created",
2482 Anum_pg_extension_oid,
2492 elog(
ERROR,
"could not find tuple for extension %u",
2495 memset(repl_val, 0,
sizeof(repl_val));
2496 memset(repl_null,
false,
sizeof(repl_null));
2497 memset(repl_repl,
false,
sizeof(repl_repl));
2502 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2526 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2529 arrayIndex = arrayLength + 1;
2531 for (
i = 0;
i < arrayLength;
i++)
2533 if (arrayData[
i] == tableoid)
2549 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2554 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2558 if (arrayLength != 0)
2559 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2571 elog(
ERROR,
"extcondition is not a 1-D text array");
2573 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2585 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2588 repl_val, repl_null, repl_repl);
2617 Datum repl_val[Natts_pg_extension];
2618 bool repl_null[Natts_pg_extension];
2619 bool repl_repl[Natts_pg_extension];
2626 Anum_pg_extension_oid,
2636 elog(
ERROR,
"could not find tuple for extension %u",
2640 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2662 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2667 for (
i = 0;
i < arrayLength;
i++)
2669 if (arrayData[
i] == tableoid)
2686 memset(repl_val, 0,
sizeof(repl_val));
2687 memset(repl_null,
false,
sizeof(repl_null));
2688 memset(repl_repl,
false,
sizeof(repl_repl));
2690 if (arrayLength <= 1)
2693 repl_null[Anum_pg_extension_extconfig - 1] =
true;
2705 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2706 dvalues[
i] = dvalues[
i + 1];
2712 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2715 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2719 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2729 elog(
ERROR,
"extcondition is not a 1-D text array");
2731 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2734 if (arrayLength <= 1)
2737 repl_null[Anum_pg_extension_extcondition - 1] =
true;
2749 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2750 dvalues[
i] = dvalues[
i + 1];
2756 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2759 repl_val, repl_null, repl_repl);
2812 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2813 errmsg(
"cannot move extension \"%s\" into schema \"%s\" "
2814 "because the extension contains the schema",
2815 extensionName, newschema)));
2821 Anum_pg_extension_oid,
2831 elog(
ERROR,
"could not find tuple for extension %u",
2844 if (extForm->extnamespace == nspOid)
2851 if (!extForm->extrelocatable)
2853 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2854 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2860 oldNspOid = extForm->extnamespace;
2869 Anum_pg_depend_refclassid,
2873 Anum_pg_depend_refobjid,
2896 pg_depend->classid == ExtensionRelationId)
2905 char *nrextname = (
char *)
lfirst(lc);
2907 if (strcmp(nrextname,
NameStr(extForm->extname)) == 0)
2910 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2911 errmsg(
"cannot SET SCHEMA of extension \"%s\" because other extensions prevent it",
2913 errdetail(
"Extension \"%s\" requests no relocation of extension \"%s\".",
2928 dep.
classId = pg_depend->classid;
2933 elog(
ERROR,
"extension should not have a sub-object dependency");
2945 if (dep_oldNspOid !=
InvalidOid && dep_oldNspOid != oldNspOid)
2947 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2948 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2950 errdetail(
"%s is not in the extension's schema \"%s\"",
2957 *oldschema = oldNspOid;
2964 extForm->extnamespace = nspOid;
2972 NamespaceRelationId, oldNspOid, nspOid) != 1)
2973 elog(
ERROR,
"could not change schema dependency for extension %s",
2989 DefElem *d_new_version = NULL;
2991 char *oldVersionName;
2998 List *updateVersions;
3010 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3011 errmsg(
"nested ALTER EXTENSION is not supported")));
3019 Anum_pg_extension_extname,
3030 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3031 errmsg(
"extension \"%s\" does not exist",
3039 datum =
heap_getattr(extTup, Anum_pg_extension_extversion,
3064 foreach(lc,
stmt->options)
3068 if (strcmp(defel->
defname,
"new_version") == 0)
3072 d_new_version = defel;
3081 if (d_new_version && d_new_version->
arg)
3082 versionName =
strVal(d_new_version->
arg);
3088 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3089 errmsg(
"version to install must be specified")));
3097 if (strcmp(oldVersionName, versionName) == 0)
3100 (
errmsg(
"version \"%s\" of extension \"%s\" is already installed",
3101 versionName,
stmt->extname)));
3117 oldVersionName, updateVersions,
3118 NULL,
false,
false);
3136 const char *initialVersion,
3137 List *updateVersions,
3138 char *origSchemaName,
3142 const char *oldVersionName = initialVersion;
3145 foreach(lcv, updateVersions)
3147 char *versionName = (
char *)
lfirst(lcv);
3151 List *requiredExtensions;
3152 List *requiredSchemas;
3159 bool nulls[Natts_pg_extension];
3160 bool repl[Natts_pg_extension];
3173 Anum_pg_extension_oid,
3183 elog(
ERROR,
"could not find tuple for extension %u",
3191 schemaOid = extForm->extnamespace;
3198 memset(nulls, 0,
sizeof(nulls));
3199 memset(repl, 0,
sizeof(repl));
3201 values[Anum_pg_extension_extrelocatable - 1] =
3203 repl[Anum_pg_extension_extrelocatable - 1] =
true;
3204 values[Anum_pg_extension_extversion - 1] =
3206 repl[Anum_pg_extension_extversion - 1] =
true;
3222 requiredExtensions =
NIL;
3223 requiredSchemas =
NIL;
3226 char *curreq = (
char *)
lfirst(lc);
3237 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
3238 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
3245 ExtensionRelationId,
3248 myself.
classId = ExtensionRelationId;
3252 foreach(lc, requiredExtensions)
3257 otherext.
classId = ExtensionRelationId;
3270 oldVersionName, versionName,
3272 schemaName, schemaOid);
3279 oldVersionName = versionName;
3299 switch (
stmt->objtype)
3310 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3311 errmsg(
"cannot add an object of this type to an extension")));
3344 Assert(
object.objectSubId == 0);
3350 stmt->object, relation);
3364 if (relation != NULL)
3389 if (
stmt->action > 0)
3396 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3397 errmsg(
"%s is already a member of extension \"%s\"",
3405 if (
object.classId == NamespaceRelationId &&
3408 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3409 errmsg(
"cannot add schema \"%s\" to extension \"%s\" "
3410 "because the schema contains the extension",
3434 if (oldExtension != extension.
objectId)
3436 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3437 errmsg(
"%s is not a member of extension \"%s\"",
3445 ExtensionRelationId,
3447 elog(
ERROR,
"unexpected number of extension dependency records");
3453 if (
object.classId == RelationRelationId)
3472 if (
object.classId == TypeRelationId)
3476 depobject.
classId = TypeRelationId;
3490 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3491 errmsg(
"could not find multirange type for data type %s",
3496 if (
object.classId == RelationRelationId)
3500 depobject.
classId = TypeRelationId;
3521 size_t bytes_to_read;
3531 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
3533 bytes_to_read = (size_t) fst.
st_size;
3538 errmsg(
"could not open file \"%s\" for reading: %m",
3541 buf = (
char *)
palloc(bytes_to_read + 1);
3543 *length = fread(
buf, 1, bytes_to_read, file);
3552 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 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)
Assert(fmt[strlen(fmt) - 1] !='\n')
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 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