62 #include "utils/fmgroids.h"
111 bool reject_indirect,
115 char *origSchemaName,
125 const char *initialVersion,
126 List *updateVersions,
127 char *origSchemaName,
151 Anum_pg_extension_extname,
172 (
errcode(ERRCODE_UNDEFINED_OBJECT),
173 errmsg(
"extension \"%s\" does not exist",
196 Anum_pg_extension_oid,
235 Anum_pg_extension_oid,
263 int namelen = strlen(extensionname);
271 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
272 errmsg(
"invalid extension name: \"%s\"", extensionname),
273 errdetail(
"Extension names must not be empty.")));
278 if (strstr(extensionname,
"--"))
280 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
281 errmsg(
"invalid extension name: \"%s\"", extensionname),
282 errdetail(
"Extension names must not contain \"--\".")));
290 if (extensionname[0] ==
'-' || extensionname[namelen - 1] ==
'-')
292 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
293 errmsg(
"invalid extension name: \"%s\"", extensionname),
294 errdetail(
"Extension names must not begin or end with \"-\".")));
302 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
303 errmsg(
"invalid extension name: \"%s\"", extensionname),
304 errdetail(
"Extension names must not contain directory separator characters.")));
310 int namelen = strlen(versionname);
318 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
319 errmsg(
"invalid extension version name: \"%s\"", versionname),
320 errdetail(
"Version names must not be empty.")));
325 if (strstr(versionname,
"--"))
327 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
328 errmsg(
"invalid extension version name: \"%s\"", versionname),
329 errdetail(
"Version names must not contain \"--\".")));
334 if (versionname[0] ==
'-' || versionname[namelen - 1] ==
'-')
336 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
337 errmsg(
"invalid extension version name: \"%s\"", versionname),
338 errdetail(
"Version names must not begin or end with \"-\".")));
346 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
347 errmsg(
"invalid extension version name: \"%s\"", versionname),
348 errdetail(
"Version names must not contain directory separator characters.")));
357 const char *extension = strrchr(
filename,
'.');
359 return (extension != NULL) && (strcmp(extension,
".control") == 0);
365 const char *extension = strrchr(
filename,
'.');
367 return (extension != NULL) && (strcmp(extension,
".sql") == 0);
431 scriptdir, control->
name, version);
440 const char *from_version,
const char *version)
450 scriptdir, control->
name, from_version, version);
453 scriptdir, control->
name, version);
501 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
502 errmsg(
"extension \"%s\" is not available", control->
name),
503 errdetail(
"Could not open extension control file \"%s\": %m.",
505 errhint(
"The extension must first be installed on the system where PostgreSQL is running.")));
509 errmsg(
"could not open extension control file \"%s\": %m",
524 for (item = head; item != NULL; item = item->
next)
526 if (strcmp(item->
name,
"directory") == 0)
530 (
errcode(ERRCODE_SYNTAX_ERROR),
531 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
536 else if (strcmp(item->
name,
"default_version") == 0)
540 (
errcode(ERRCODE_SYNTAX_ERROR),
541 errmsg(
"parameter \"%s\" cannot be set in a secondary extension control file",
546 else if (strcmp(item->
name,
"module_pathname") == 0)
550 else if (strcmp(item->
name,
"comment") == 0)
554 else if (strcmp(item->
name,
"schema") == 0)
558 else if (strcmp(item->
name,
"relocatable") == 0)
562 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
563 errmsg(
"parameter \"%s\" requires a Boolean value",
566 else if (strcmp(item->
name,
"superuser") == 0)
570 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
571 errmsg(
"parameter \"%s\" requires a Boolean value",
574 else if (strcmp(item->
name,
"trusted") == 0)
578 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
579 errmsg(
"parameter \"%s\" requires a Boolean value",
582 else if (strcmp(item->
name,
"encoding") == 0)
587 (
errcode(ERRCODE_UNDEFINED_OBJECT),
588 errmsg(
"\"%s\" is not a valid encoding name",
591 else if (strcmp(item->
name,
"requires") == 0)
601 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
602 errmsg(
"parameter \"%s\" must be a list of extension names",
608 (
errcode(ERRCODE_SYNTAX_ERROR),
609 errmsg(
"unrecognized parameter \"%s\" in file \"%s\"",
617 (
errcode(ERRCODE_SYNTAX_ERROR),
618 errmsg(
"parameter \"schema\" cannot be specified when \"relocatable\" is true")));
722 List *raw_parsetree_list;
739 foreach(lc1, raw_parsetree_list)
751 per_parsetree_context =
753 "execute_sql_string per-statement context",
767 foreach(lc2, stmt_list)
782 dest, NULL, NULL, 0);
795 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
796 errmsg(
"transaction control statements are not allowed within an extension script")));
848 const char *from_version,
850 List *requiredSchemas,
851 const char *schemaName,
Oid schemaOid)
853 bool switch_to_superuser =
false;
856 int save_sec_context = 0;
869 switch_to_superuser =
true;
870 else if (from_version == NULL)
872 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
873 errmsg(
"permission denied to create extension \"%s\"",
876 ?
errhint(
"Must have CREATE privilege on current database to create this extension.")
877 :
errhint(
"Must be superuser to create this extension.")));
880 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
881 errmsg(
"permission denied to update extension \"%s\"",
884 ?
errhint(
"Must have CREATE privilege on current database to update this extension.")
885 :
errhint(
"Must be superuser to update this extension.")));
890 if (from_version == NULL)
891 elog(
DEBUG1,
"executing extension script for \"%s\" version '%s'", control->
name, version);
893 elog(
DEBUG1,
"executing extension script for \"%s\" update from version '%s' to '%s'", control->
name, from_version, version);
900 if (switch_to_superuser)
951 foreach(lc, requiredSchemas)
956 if (reqname && strcmp(reqname,
"pg_catalog") != 0)
995 if (strstr(c_sql,
"@extowner@"))
997 Oid uid = switch_to_superuser ? save_userid :
GetUserId();
1059 if (switch_to_superuser)
1077 foreach(lc, *evi_list)
1080 if (strcmp(evi->
name, versionname) == 0)
1093 *evi_list =
lappend(*evi_list, evi);
1110 foreach(lc, evi_list)
1136 int extnamelen = strlen(control->
name);
1143 while ((de =
ReadDir(dir, location)) != NULL)
1155 if (strncmp(de->
d_name, control->
name, extnamelen) != 0 ||
1156 de->
d_name[extnamelen] !=
'-' ||
1157 de->
d_name[extnamelen + 1] !=
'-')
1162 *strrchr(vername,
'.') =
'\0';
1163 vername2 = strstr(vername,
"--");
1175 if (strstr(vername2,
"--"))
1197 const char *oldVersion,
const char *newVersion)
1216 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1217 errmsg(
"extension \"%s\" has no update path from version \"%s\" to version \"%s\"",
1218 control->
name, oldVersion, newVersion)));
1242 bool reject_indirect,
1250 Assert(evi_start != evi_target);
1256 foreach(lc, evi_list)
1272 if (evi == evi_target)
1283 if (newdist < evi2->distance)
1288 else if (newdist == evi2->
distance &&
1311 for (evi = evi_target; evi != evi_start; evi = evi->
previous)
1348 foreach(lc, evi_list)
1365 if (evi_start == NULL ||
1368 strcmp(evi_start->
name, evi1->
name) < 0))
1389 const char *versionName,
1394 char *origSchemaName = schemaName;
1401 List *updateVersions;
1402 List *requiredExtensions;
1403 List *requiredSchemas;
1418 if (versionName == NULL)
1424 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1425 errmsg(
"version to install must be specified")));
1439 updateVersions =
NIL;
1459 if (evi_start == NULL)
1461 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1462 errmsg(
"extension \"%s\" has no installation script nor update path for version \"%s\"",
1463 pcontrol->
name, versionName)));
1466 versionName = evi_start->
name;
1483 if (control->
schema != NULL)
1492 if (schemaName && strcmp(control->
schema, schemaName) != 0 &&
1495 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1496 errmsg(
"extension \"%s\" must be installed in schema \"%s\"",
1501 schemaName = control->
schema;
1533 if (search_path ==
NIL)
1535 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1536 errmsg(
"no schema has been selected to create in")));
1539 if (schemaName == NULL)
1541 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
1542 errmsg(
"no schema has been selected to create in")));
1567 requiredExtensions =
NIL;
1568 requiredSchemas =
NIL;
1571 char *curreq = (
char *)
lfirst(lc);
1582 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
1583 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
1594 requiredExtensions);
1609 schemaName, schemaOid);
1616 versionName, updateVersions,
1617 origSchemaName, cascade, is_create);
1627 char *extensionName,
1628 char *origSchemaName,
1633 Oid reqExtensionOid;
1642 List *cascade_parents;
1649 foreach(lc, parents)
1651 char *pname = (
char *)
lfirst(lc);
1653 if (strcmp(pname, reqExtensionName) == 0)
1655 (
errcode(ERRCODE_INVALID_RECURSION),
1656 errmsg(
"cyclic dependency detected between extensions \"%s\" and \"%s\"",
1657 reqExtensionName, extensionName)));
1661 (
errmsg(
"installing required extension \"%s\"",
1662 reqExtensionName)));
1683 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1684 errmsg(
"required extension \"%s\" is not installed",
1687 errhint(
"Use CREATE EXTENSION ... CASCADE to install required extensions too.") : 0));
1690 return reqExtensionOid;
1700 DefElem *d_new_version = NULL;
1702 char *schemaName = NULL;
1703 char *versionName = NULL;
1704 bool cascade =
false;
1722 errmsg(
"extension \"%s\" already exists, skipping",
1729 errmsg(
"extension \"%s\" already exists",
1739 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1740 errmsg(
"nested CREATE EXTENSION is not supported")));
1747 if (strcmp(defel->
defname,
"schema") == 0)
1754 else if (strcmp(defel->
defname,
"new_version") == 0)
1758 d_new_version = defel;
1761 else if (strcmp(defel->
defname,
"cascade") == 0)
1796 Oid schemaOid,
bool relocatable,
const char *extVersion,
1798 List *requiredExtensions)
1803 bool nulls[Natts_pg_extension];
1816 memset(nulls, 0,
sizeof(nulls));
1819 Anum_pg_extension_oid);
1821 values[Anum_pg_extension_extname - 1] =
1829 nulls[Anum_pg_extension_extconfig - 1] =
true;
1831 values[Anum_pg_extension_extconfig - 1] = extConfig;
1834 nulls[Anum_pg_extension_extcondition - 1] =
true;
1836 values[Anum_pg_extension_extcondition - 1] = extCondition;
1857 foreach(lc, requiredExtensions)
1903 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1904 errmsg(
"cannot drop extension \"%s\" because it is being modified",
1910 Anum_pg_extension_oid,
1954 if (dir == NULL && errno == ENOENT)
1960 while ((de =
ReadDir(dir, location)) != NULL)
1971 extname =
pstrdup(de->d_name);
1972 *strrchr(extname,
'.') =
'\0';
1975 if (strstr(extname,
"--"))
1981 memset(nulls, 0,
sizeof(nulls));
2034 if (dir == NULL && errno == ENOENT)
2040 while ((de =
ReadDir(dir, location)) != NULL)
2049 extname =
pstrdup(de->d_name);
2050 *strrchr(extname,
'.') =
'\0';
2053 if (strstr(extname,
"--"))
2086 foreach(lc, evi_list)
2103 memset(nulls, 0,
sizeof(nulls));
2117 if (control->
schema == NULL)
2140 foreach(lc2, evi_list)
2191 bool result =
false;
2203 if (dir == NULL && errno == ENOENT)
2209 while ((de =
ReadDir(dir, location)) != NULL)
2218 *strrchr(extname,
'.') =
'\0';
2221 if (strstr(extname,
"--"))
2225 if (strcmp(extname, extensionName) == 0)
2252 foreach(lc, requires)
2254 char *curreq = (
char *)
lfirst(lc);
2289 foreach(lc1, evi_list)
2294 foreach(lc2, evi_list)
2309 memset(nulls, 0,
sizeof(nulls));
2328 char *versionName = (
char *)
lfirst(lcv);
2367 Datum repl_val[Natts_pg_extension];
2368 bool repl_null[Natts_pg_extension];
2369 bool repl_repl[Natts_pg_extension];
2378 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2379 errmsg(
"%s can only be called from an SQL script executed by CREATE EXTENSION",
2380 "pg_extension_config_dump()")));
2388 if (tablename == NULL)
2391 errmsg(
"OID %u does not refer to a table", tableoid)));
2395 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2396 errmsg(
"table \"%s\" is not a member of the extension being created",
2411 Anum_pg_extension_oid,
2421 elog(
ERROR,
"could not find tuple for extension %u",
2424 memset(repl_val, 0,
sizeof(repl_val));
2425 memset(repl_null,
false,
sizeof(repl_null));
2426 memset(repl_repl,
false,
sizeof(repl_repl));
2431 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2455 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2458 arrayIndex = arrayLength + 1;
2460 for (
i = 0;
i < arrayLength;
i++)
2462 if (arrayData[
i] == tableoid)
2478 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2483 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2487 if (arrayLength != 0)
2488 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2500 elog(
ERROR,
"extcondition is not a 1-D text array");
2502 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2514 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2517 repl_val, repl_null, repl_repl);
2546 Datum repl_val[Natts_pg_extension];
2547 bool repl_null[Natts_pg_extension];
2548 bool repl_repl[Natts_pg_extension];
2555 Anum_pg_extension_oid,
2565 elog(
ERROR,
"could not find tuple for extension %u",
2569 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extconfig,
2591 elog(
ERROR,
"extconfig is not a 1-D Oid array");
2596 for (
i = 0;
i < arrayLength;
i++)
2598 if (arrayData[
i] == tableoid)
2615 memset(repl_val, 0,
sizeof(repl_val));
2616 memset(repl_null,
false,
sizeof(repl_null));
2617 memset(repl_repl,
false,
sizeof(repl_repl));
2619 if (arrayLength <= 1)
2622 repl_null[Anum_pg_extension_extconfig - 1] =
true;
2634 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2635 dvalues[
i] = dvalues[
i + 1];
2641 repl_repl[Anum_pg_extension_extconfig - 1] =
true;
2644 arrayDatum =
heap_getattr(extTup, Anum_pg_extension_extcondition,
2648 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2658 elog(
ERROR,
"extcondition is not a 1-D text array");
2660 elog(
ERROR,
"extconfig and extcondition arrays do not match");
2663 if (arrayLength <= 1)
2666 repl_null[Anum_pg_extension_extcondition - 1] =
true;
2678 for (
i = arrayIndex;
i < arrayLength - 1;
i++)
2679 dvalues[
i] = dvalues[
i + 1];
2685 repl_repl[Anum_pg_extension_extcondition - 1] =
true;
2688 repl_val, repl_null, repl_repl);
2741 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2742 errmsg(
"cannot move extension \"%s\" into schema \"%s\" "
2743 "because the extension contains the schema",
2744 extensionName, newschema)));
2750 Anum_pg_extension_oid,
2760 elog(
ERROR,
"could not find tuple for extension %u",
2773 if (extForm->extnamespace == nspOid)
2780 if (!extForm->extrelocatable)
2782 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2783 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2795 Anum_pg_depend_refclassid,
2799 Anum_pg_depend_refobjid,
2820 dep.
classId = pg_depend->classid;
2825 elog(
ERROR,
"extension should not have a sub-object dependency");
2837 oldNspOid = dep_oldNspOid;
2843 if (dep_oldNspOid !=
InvalidOid && dep_oldNspOid != oldNspOid)
2845 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2846 errmsg(
"extension \"%s\" does not support SET SCHEMA",
2848 errdetail(
"%s is not in the extension's schema \"%s\"",
2855 *oldschema = oldNspOid;
2862 extForm->extnamespace = nspOid;
2870 NamespaceRelationId, oldNspOid, nspOid);
2885 DefElem *d_new_version = NULL;
2887 char *oldVersionName;
2894 List *updateVersions;
2906 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2907 errmsg(
"nested ALTER EXTENSION is not supported")));
2915 Anum_pg_extension_extname,
2926 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2927 errmsg(
"extension \"%s\" does not exist",
2935 datum =
heap_getattr(extTup, Anum_pg_extension_extversion,
2964 if (strcmp(defel->
defname,
"new_version") == 0)
2968 d_new_version = defel;
2977 if (d_new_version && d_new_version->
arg)
2978 versionName =
strVal(d_new_version->
arg);
2984 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2985 errmsg(
"version to install must be specified")));
2993 if (strcmp(oldVersionName, versionName) == 0)
2996 (
errmsg(
"version \"%s\" of extension \"%s\" is already installed",
2997 versionName, stmt->
extname)));
3013 oldVersionName, updateVersions,
3014 NULL,
false,
false);
3032 const char *initialVersion,
3033 List *updateVersions,
3034 char *origSchemaName,
3038 const char *oldVersionName = initialVersion;
3041 foreach(lcv, updateVersions)
3043 char *versionName = (
char *)
lfirst(lcv);
3047 List *requiredExtensions;
3048 List *requiredSchemas;
3055 bool nulls[Natts_pg_extension];
3056 bool repl[Natts_pg_extension];
3069 Anum_pg_extension_oid,
3079 elog(
ERROR,
"could not find tuple for extension %u",
3087 schemaOid = extForm->extnamespace;
3094 memset(nulls, 0,
sizeof(nulls));
3095 memset(repl, 0,
sizeof(repl));
3097 values[Anum_pg_extension_extrelocatable - 1] =
3099 repl[Anum_pg_extension_extrelocatable - 1] =
true;
3100 values[Anum_pg_extension_extversion - 1] =
3102 repl[Anum_pg_extension_extversion - 1] =
true;
3118 requiredExtensions =
NIL;
3119 requiredSchemas =
NIL;
3122 char *curreq = (
char *)
lfirst(lc);
3133 requiredExtensions =
lappend_oid(requiredExtensions, reqext);
3134 requiredSchemas =
lappend_oid(requiredSchemas, reqschema);
3141 ExtensionRelationId,
3144 myself.
classId = ExtensionRelationId;
3148 foreach(lc, requiredExtensions)
3153 otherext.
classId = ExtensionRelationId;
3166 oldVersionName, versionName,
3168 schemaName, schemaOid);
3175 oldVersionName = versionName;
3207 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3208 errmsg(
"cannot add an object of this type to an extension")));
3241 Assert(
object.objectSubId == 0);
3261 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3262 errmsg(
"%s is already a member of extension \"%s\"",
3270 if (
object.classId == NamespaceRelationId &&
3273 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3274 errmsg(
"cannot add schema \"%s\" to extension \"%s\" "
3275 "because the schema contains the extension",
3299 if (oldExtension != extension.
objectId)
3301 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3302 errmsg(
"%s is not a member of extension \"%s\"",
3310 ExtensionRelationId,
3312 elog(
ERROR,
"unexpected number of extension dependency records");
3318 if (
object.classId == RelationRelationId)
3340 if (relation != NULL)
3357 size_t bytes_to_read;
3367 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
3369 bytes_to_read = (size_t) fst.
st_size;
3374 errmsg(
"could not open file \"%s\" for reading: %m",
3377 buf = (
char *)
palloc(bytes_to_read + 1);
3379 *length = fread(
buf, 1, bytes_to_read, file);
3388 buf[*length] =
'\0';
AclResult pg_namespace_aclcheck(Oid nsp_oid, Oid roleid, AclMode mode)
bool pg_extension_ownercheck(Oid ext_oid, Oid roleid)
void recordExtObjInitPriv(Oid objoid, Oid classoid)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult pg_database_aclcheck(Oid db_oid, Oid roleid, AclMode mode)
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)
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)
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 Oid get_extension_schema(Oid ext_oid)
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 SetSingleFuncCall(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]
bool check_function_bodies
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)
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)
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)
#define CStringGetDatum(X)
#define ObjectIdGetDatum(X)
#define PointerGetDatum(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)
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 PopActiveSnapshot(void)
void PushActiveSnapshot(Snapshot snap)
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