64 #include "utils/fmgroids.h"
115 bool reject_indirect,
119 char *origSchemaName,
129 const char *initialVersion,
130 List *updateVersions,
131 char *origSchemaName,
155 Anum_pg_extension_extname,
176 (
errcode(ERRCODE_UNDEFINED_OBJECT),
177 errmsg(
"extension \"%s\" does not exist",
200 Anum_pg_extension_oid,
239 Anum_pg_extension_oid,
267 int namelen = strlen(extensionname);
275 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
276 errmsg(
"invalid extension name: \"%s\"", extensionname),
277 errdetail(
"Extension names must not be empty.")));
282 if (strstr(extensionname,
"--"))
284 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
285 errmsg(
"invalid extension name: \"%s\"", extensionname),
286 errdetail(
"Extension names must not contain \"--\".")));
294 if (extensionname[0] ==
'-' || extensionname[namelen - 1] ==
'-')
296 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
297 errmsg(
"invalid extension name: \"%s\"", extensionname),
298 errdetail(
"Extension names must not begin or end with \"-\".")));
306 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
307 errmsg(
"invalid extension name: \"%s\"", extensionname),
308 errdetail(
"Extension names must not contain directory separator characters.")));
314 int namelen = strlen(versionname);
322 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
323 errmsg(
"invalid extension version name: \"%s\"", versionname),
324 errdetail(
"Version names must not be empty.")));
329 if (strstr(versionname,
"--"))
331 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
332 errmsg(
"invalid extension version name: \"%s\"", versionname),
333 errdetail(
"Version names must not contain \"--\".")));
338 if (versionname[0] ==
'-' || versionname[namelen - 1] ==
'-')
340 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
341 errmsg(
"invalid extension version name: \"%s\"", versionname),
342 errdetail(
"Version names must not begin or end with \"-\".")));
350 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
351 errmsg(
"invalid extension version name: \"%s\"", versionname),
352 errdetail(
"Version names must not contain directory separator characters.")));
361 const char *extension = strrchr(
filename,
'.');
363 return (extension != NULL) && (strcmp(extension,
".control") == 0);
369 const char *extension = strrchr(
filename,
'.');
371 return (extension != NULL) && (strcmp(extension,
".sql") == 0);
435 scriptdir, control->
name, version);
444 const char *from_version,
const char *version)
454 scriptdir, control->
name, from_version, version);
457 scriptdir, control->
name, version);
505 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
506 errmsg(
"extension \"%s\" is not available", control->
name),
507 errdetail(
"Could not open extension control file \"%s\": %m.",
509 errhint(
"The extension must first be installed on the system where PostgreSQL is running.")));
513 errmsg(
"could not open extension control file \"%s\": %m",
529 for (item = head; item != NULL; item = item->
next)
531 if (strcmp(item->
name,
"directory") == 0)
535 (
errcode(ERRCODE_SYNTAX_ERROR),
536 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
541 else if (strcmp(item->
name,
"default_version") == 0)
545 (
errcode(ERRCODE_SYNTAX_ERROR),
546 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
551 else if (strcmp(item->
name,
"module_pathname") == 0)
555 else if (strcmp(item->
name,
"comment") == 0)
559 else if (strcmp(item->
name,
"schema") == 0)
563 else if (strcmp(item->
name,
"relocatable") == 0)
567 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
568 errmsg(
"parameter \"%s\" requires a Boolean value",
571 else if (strcmp(item->
name,
"superuser") == 0)
575 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
576 errmsg(
"parameter \"%s\" requires a Boolean value",
579 else if (strcmp(item->
name,
"trusted") == 0)
583 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
584 errmsg(
"parameter \"%s\" requires a Boolean value",
587 else if (strcmp(item->
name,
"encoding") == 0)
592 (
errcode(ERRCODE_UNDEFINED_OBJECT),
593 errmsg(
"\"%s\" is not a valid encoding name",
596 else if (strcmp(item->
name,
"requires") == 0)
606 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
607 errmsg(
"parameter \"%s\" must be a list of extension names",
611 else if (strcmp(item->
name,
"no_relocate") == 0)
621 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
622 errmsg(
"parameter \"%s\" must be a list of extension names",
628 (
errcode(ERRCODE_SYNTAX_ERROR),
629 errmsg(
"unrecognized parameter \"%s\" in file \"%s\"",
637 (
errcode(ERRCODE_SYNTAX_ERROR),
638 errmsg(
"parameter \"schema\" cannot be specified when \"relocatable\" is true")));
742 List *raw_parsetree_list;
759 foreach(lc1, raw_parsetree_list)
771 per_parsetree_context =
773 "execute_sql_string per-statement context",
787 foreach(lc2, stmt_list)
795 if (
stmt->utilityStmt == NULL)
802 dest, NULL, NULL, 0);
815 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
816 errmsg(
"transaction control statements are not allowed within an extension script")));
870 const char *from_version,
872 List *requiredSchemas,
873 const char *schemaName,
Oid schemaOid)
875 bool switch_to_superuser =
false;
878 int save_sec_context = 0;
892 switch_to_superuser =
true;
893 else if (from_version == NULL)
895 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
896 errmsg(
"permission denied to create extension \"%s\"",
899 ?
errhint(
"Must have CREATE privilege on current database to create this extension.")
900 :
errhint(
"Must be superuser to create this extension.")));
903 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
904 errmsg(
"permission denied to update extension \"%s\"",
907 ?
errhint(
"Must have CREATE privilege on current database to update this extension.")
908 :
errhint(
"Must be superuser to update this extension.")));
913 if (from_version == NULL)
914 elog(
DEBUG1,
"executing extension script for \"%s\" version '%s'", control->
name, version);
916 elog(
DEBUG1,
"executing extension script for \"%s\" update from version '%s' to '%s'", control->
name, from_version, version);
923 if (switch_to_superuser)
951 BOOTSTRAP_SUPERUSERID,
973 foreach(lc, requiredSchemas)
978 if (reqname && strcmp(reqname,
"pg_catalog") != 0)
1007 const char *quoting_relevant_chars =
"\"$'\\";
1027 if (strstr(c_sql,
"@extowner@"))
1029 Oid uid = switch_to_superuser ? save_userid :
GetUserId();
1038 if (strpbrk(userName, quoting_relevant_chars))
1040 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1041 errmsg(
"invalid character in extension owner: must not contain any of \"%s\"",
1042 quoting_relevant_chars)));
1062 if (t_sql != old && strpbrk(schemaName, quoting_relevant_chars))
1064 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1065 errmsg(
"invalid character in extension \"%s\" schema: must not contain any of \"%s\"",
1066 control->
name, quoting_relevant_chars)));
1077 char *reqextname = (
char *)
lfirst(lc);
1083 repltoken =
psprintf(
"@extschema:%s@", reqextname);
1089 if (t_sql != old && strpbrk(schemaName, quoting_relevant_chars))
1091 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1092 errmsg(
"invalid character in extension \"%s\" schema: must not contain any of \"%s\"",
1093 reqextname, quoting_relevant_chars)));
1129 if (switch_to_superuser)
1147 foreach(lc, *evi_list)
1150 if (strcmp(evi->
name, versionname) == 0)
1163 *evi_list =
lappend(*evi_list, evi);
1180 foreach(lc, evi_list)
1206 int extnamelen = strlen(control->
name);
1213 while ((de =
ReadDir(dir, location)) != NULL)
1225 if (strncmp(de->
d_name, control->
name, extnamelen) != 0 ||
1226 de->
d_name[extnamelen] !=
'-' ||
1227 de->
d_name[extnamelen + 1] !=
'-')
1232 *strrchr(vername,
'.') =
'\0';
1233 vername2 = strstr(vername,
"--");
1245 if (strstr(vername2,
"--"))
1267 const char *oldVersion,
const char *newVersion)
1286 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1287 errmsg(
"extension \"%s\" has no update path from version \"%s\" to version \"%s\"",
1288 control->
name, oldVersion, newVersion)));
1312 bool reject_indirect,
1320 Assert(evi_start != evi_target);
1326 foreach(lc, evi_list)
1342 if (evi == evi_target)
1353 if (newdist < evi2->distance)
1358 else if (newdist == evi2->
distance &&
1381 for (evi = evi_target; evi != evi_start; evi = evi->
previous)
1418 foreach(lc, evi_list)
1435 if (evi_start == NULL ||
1438 strcmp(evi_start->
name, evi1->
name) < 0))
1459 const char *versionName,
1464 char *origSchemaName = schemaName;
1471 List *updateVersions;
1472 List *requiredExtensions;
1473 List *requiredSchemas;
1488 if (versionName == NULL)
1494 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1495 errmsg(
"version to install must be specified")));
1509 updateVersions =
NIL;
1529 if (evi_start == NULL)
1531 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1532 errmsg(
"extension \"%s\" has no installation script nor update path for version \"%s\"",
1533 pcontrol->
name, versionName)));
1536 versionName = evi_start->
name;
1553 if (control->
schema != NULL)
1562 if (schemaName && strcmp(control->
schema, schemaName) != 0 &&
1565 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1566 errmsg(
"extension \"%s\" must be installed in schema \"%s\"",
1571 schemaName = control->
schema;
1603 if (search_path ==
NIL)
1605 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1606 errmsg(
"no schema has been selected to create in")));
1609 if (schemaName == NULL)
1611 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1612 errmsg(
"no schema has been selected to create in")));
1637 requiredExtensions =
NIL;
1638 requiredSchemas =
NIL;
1641 char *curreq = (
char *)
lfirst(lc);
1652 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
1653 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
1664 requiredExtensions);
1679 schemaName, schemaOid);
1686 versionName, updateVersions,
1687 origSchemaName, cascade, is_create);
1697 char *extensionName,
1698 char *origSchemaName,
1703 Oid reqExtensionOid;
1712 List *cascade_parents;
1719 foreach(lc, parents)
1721 char *pname = (
char *)
lfirst(lc);
1723 if (strcmp(pname, reqExtensionName) == 0)
1725 (
errcode(ERRCODE_INVALID_RECURSION),
1726 errmsg(
"cyclic dependency detected between extensions \"%s\" and \"%s\"",
1727 reqExtensionName, extensionName)));
1731 (
errmsg(
"installing required extension \"%s\"",
1732 reqExtensionName)));
1753 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1754 errmsg(
"required extension \"%s\" is not installed",
1757 errhint(
"Use CREATE EXTENSION ... CASCADE to install required extensions too.") : 0));
1760 return reqExtensionOid;
1770 DefElem *d_new_version = NULL;
1772 char *schemaName = NULL;
1773 char *versionName = NULL;
1774 bool cascade =
false;
1788 if (
stmt->if_not_exists)
1792 errmsg(
"extension \"%s\" already exists, skipping",
1799 errmsg(
"extension \"%s\" already exists",
1809 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1810 errmsg(
"nested CREATE EXTENSION is not supported")));
1813 foreach(lc,
stmt->options)
1817 if (strcmp(defel->
defname,
"schema") == 0)
1824 else if (strcmp(defel->
defname,
"new_version") == 0)
1828 d_new_version = defel;
1831 else if (strcmp(defel->
defname,
"cascade") == 0)
1866 Oid schemaOid,
bool relocatable,
const char *extVersion,
1868 List *requiredExtensions)
1873 bool nulls[Natts_pg_extension];
1886 memset(nulls, 0,
sizeof(nulls));
1889 Anum_pg_extension_oid);
1891 values[Anum_pg_extension_extname - 1] =
1899 nulls[Anum_pg_extension_extconfig - 1] =
true;
1901 values[Anum_pg_extension_extconfig - 1] = extConfig;
1904 nulls[Anum_pg_extension_extcondition - 1] =
true;
1906 values[Anum_pg_extension_extcondition - 1] = extCondition;
1927 foreach(lc, requiredExtensions)
1973 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1974 errmsg(
"cannot drop extension \"%s\" because it is being modified",
1980 Anum_pg_extension_oid,
2024 if (dir == NULL && errno == ENOENT)
2030 while ((de =
ReadDir(dir, location)) != NULL)
2041 extname =
pstrdup(de->d_name);
2042 *strrchr(extname,
'.') =
'\0';
2045 if (strstr(extname,
"--"))
2051 memset(nulls, 0,
sizeof(nulls));
2104 if (dir == NULL && errno == ENOENT)
2110 while ((de =
ReadDir(dir, location)) != NULL)
2119 extname =
pstrdup(de->d_name);
2120 *strrchr(extname,
'.') =
'\0';
2123 if (strstr(extname,
"--"))
2156 foreach(lc, evi_list)
2173 memset(nulls, 0,
sizeof(nulls));
2187 if (control->
schema == NULL)
2210 foreach(lc2, evi_list)
2261 bool result =
false;
2273 if (dir == NULL && errno == ENOENT)
2279 while ((de =
ReadDir(dir, location)) != NULL)
2288 *strrchr(extname,
'.') =
'\0';
2291 if (strstr(extname,
"--"))
2295 if (strcmp(extname, extensionName) == 0)
2322 foreach(lc, requires)
2324 char *curreq = (
char *)
lfirst(lc);
2359 foreach(lc1, evi_list)
2364 foreach(lc2, evi_list)
2379 memset(nulls, 0,
sizeof(nulls));
2398 char *versionName = (
char *)
lfirst(lcv);
2437 Datum repl_val[Natts_pg_extension];
2438 bool repl_null[Natts_pg_extension];
2439 bool repl_repl[Natts_pg_extension];
2448 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2449 errmsg(
"%s can only be called from an SQL script executed by CREATE EXTENSION",
2450 "pg_extension_config_dump()")));
2458 if (tablename == NULL)
2461 errmsg(
"OID %u does not refer to a table", tableoid)));
2465 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2466 errmsg(
"table \"%s\" is not a member of the extension being created",
2481 Anum_pg_extension_oid,
2491 elog(
ERROR,
"could not find tuple for extension %u",
2494 memset(repl_val, 0,
sizeof(repl_val));
2495 memset(repl_null,
false,
sizeof(repl_null));
2496 memset(repl_repl,
false,
sizeof(repl_repl));
2501 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2525 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2528 arrayIndex = arrayLength + 1;
2530 for (
i = 0;
i < arrayLength;
i++)
2532 if (arrayData[
i] == tableoid)
2548 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2553 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2557 if (arrayLength != 0)
2558 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2570 elog(
ERROR,
"extcondition is not a 1-D text array");
2572 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2584 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2587 repl_val, repl_null, repl_repl);
2616 Datum repl_val[Natts_pg_extension];
2617 bool repl_null[Natts_pg_extension];
2618 bool repl_repl[Natts_pg_extension];
2625 Anum_pg_extension_oid,
2635 elog(
ERROR,
"could not find tuple for extension %u",
2639 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2661 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2666 for (
i = 0;
i < arrayLength;
i++)
2668 if (arrayData[
i] == tableoid)
2685 memset(repl_val, 0,
sizeof(repl_val));
2686 memset(repl_null,
false,
sizeof(repl_null));
2687 memset(repl_repl,
false,
sizeof(repl_repl));
2689 if (arrayLength <= 1)
2692 repl_null[Anum_pg_extension_extconfig - 1] =
true;
2704 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2705 dvalues[
i] = dvalues[
i + 1];
2711 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2714 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2718 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2728 elog(
ERROR,
"extcondition is not a 1-D text array");
2730 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2733 if (arrayLength <= 1)
2736 repl_null[Anum_pg_extension_extcondition - 1] =
true;
2748 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2749 dvalues[
i] = dvalues[
i + 1];
2755 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2758 repl_val, repl_null, repl_repl);
2811 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2812 errmsg(
"cannot move extension \"%s\" into schema \"%s\" "
2813 "because the extension contains the schema",
2814 extensionName, newschema)));
2820 Anum_pg_extension_oid,
2830 elog(
ERROR,
"could not find tuple for extension %u",
2843 if (extForm->extnamespace == nspOid)
2850 if (!extForm->extrelocatable)
2852 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2853 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2859 oldNspOid = extForm->extnamespace;
2868 Anum_pg_depend_refclassid,
2872 Anum_pg_depend_refobjid,
2895 pg_depend->classid == ExtensionRelationId)
2904 char *nrextname = (
char *)
lfirst(lc);
2906 if (strcmp(nrextname,
NameStr(extForm->extname)) == 0)
2909 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2910 errmsg(
"cannot SET SCHEMA of extension \"%s\" because other extensions prevent it",
2912 errdetail(
"Extension \"%s\" requests no relocation of extension \"%s\".",
2927 dep.
classId = pg_depend->classid;
2932 elog(
ERROR,
"extension should not have a sub-object dependency");
2944 if (dep_oldNspOid !=
InvalidOid && dep_oldNspOid != oldNspOid)
2946 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2947 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2949 errdetail(
"%s is not in the extension's schema \"%s\"",
2956 *oldschema = oldNspOid;
2963 extForm->extnamespace = nspOid;
2971 NamespaceRelationId, oldNspOid, nspOid) != 1)
2972 elog(
ERROR,
"could not change schema dependency for extension %s",
2988 DefElem *d_new_version = NULL;
2990 char *oldVersionName;
2997 List *updateVersions;
3009 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3010 errmsg(
"nested ALTER EXTENSION is not supported")));
3018 Anum_pg_extension_extname,
3029 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3030 errmsg(
"extension \"%s\" does not exist",
3038 datum =
heap_getattr(extTup, Anum_pg_extension_extversion,
3063 foreach(lc,
stmt->options)
3067 if (strcmp(defel->
defname,
"new_version") == 0)
3071 d_new_version = defel;
3080 if (d_new_version && d_new_version->
arg)
3081 versionName =
strVal(d_new_version->
arg);
3087 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3088 errmsg(
"version to install must be specified")));
3096 if (strcmp(oldVersionName, versionName) == 0)
3099 (
errmsg(
"version \"%s\" of extension \"%s\" is already installed",
3100 versionName,
stmt->extname)));
3116 oldVersionName, updateVersions,
3117 NULL,
false,
false);
3135 const char *initialVersion,
3136 List *updateVersions,
3137 char *origSchemaName,
3141 const char *oldVersionName = initialVersion;
3144 foreach(lcv, updateVersions)
3146 char *versionName = (
char *)
lfirst(lcv);
3150 List *requiredExtensions;
3151 List *requiredSchemas;
3158 bool nulls[Natts_pg_extension];
3159 bool repl[Natts_pg_extension];
3172 Anum_pg_extension_oid,
3182 elog(
ERROR,
"could not find tuple for extension %u",
3190 schemaOid = extForm->extnamespace;
3197 memset(nulls, 0,
sizeof(nulls));
3198 memset(repl, 0,
sizeof(repl));
3200 values[Anum_pg_extension_extrelocatable - 1] =
3202 repl[Anum_pg_extension_extrelocatable - 1] =
true;
3203 values[Anum_pg_extension_extversion - 1] =
3205 repl[Anum_pg_extension_extversion - 1] =
true;
3221 requiredExtensions =
NIL;
3222 requiredSchemas =
NIL;
3225 char *curreq = (
char *)
lfirst(lc);
3236 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
3237 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
3244 ExtensionRelationId,
3247 myself.
classId = ExtensionRelationId;
3251 foreach(lc, requiredExtensions)
3256 otherext.
classId = ExtensionRelationId;
3269 oldVersionName, versionName,
3271 schemaName, schemaOid);
3278 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);
3357 if (
stmt->action > 0)
3364 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3365 errmsg(
"%s is already a member of extension \"%s\"",
3373 if (
object.classId == NamespaceRelationId &&
3376 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3377 errmsg(
"cannot add schema \"%s\" to extension \"%s\" "
3378 "because the schema contains the extension",
3402 if (oldExtension != extension.
objectId)
3404 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3405 errmsg(
"%s is not a member of extension \"%s\"",
3413 ExtensionRelationId,
3415 elog(
ERROR,
"unexpected number of extension dependency records");
3421 if (
object.classId == RelationRelationId)
3443 if (relation != NULL)
3460 size_t bytes_to_read;
3470 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
3472 bytes_to_read = (size_t) fst.
st_size;
3477 errmsg(
"could not open file \"%s\" for reading: %m",
3480 buf = (
char *)
palloc(bytes_to_read + 1);
3482 *length = fread(
buf, 1, bytes_to_read, file);
3491 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
elog(ERROR, "%s: %s", p2, msg)
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,...)
int pg_valid_server_encoding(const char *name)
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)
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_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
HeapTuple heap_copytuple(HeapTuple tuple)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
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
char * get_namespace_name(Oid nspid)
char * get_rel_name(Oid relid)
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)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#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 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,...)
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, Datum *values, 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