231 bool missing_ok,
bool nowait,
246 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
247 errmsg(
"cross-database references are not implemented: \"%s.%s.%s\"",
303 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
304 errmsg(
"temporary tables cannot specify a schema name")));
338 callback(relation, relId, oldRelId, callback_arg);
361 if (relId == oldRelId)
382 (
errcode(ERRCODE_LOCK_NOT_AVAILABLE),
383 errmsg(
"could not obtain lock on relation \"%s.%s\"",
387 (
errcode(ERRCODE_LOCK_NOT_AVAILABLE),
388 errmsg(
"could not obtain lock on relation \"%s\"",
411 (
errcode(ERRCODE_UNDEFINED_TABLE),
412 errmsg(
"relation \"%s.%s\" does not exist",
416 (
errcode(ERRCODE_UNDEFINED_TABLE),
417 errmsg(
"relation \"%s\" does not exist",
444 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
445 errmsg(
"cross-database references are not implemented: \"%s.%s.%s\"",
453 if (strcmp(newRelation->
schemaname,
"pg_temp") == 0)
484 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
485 errmsg(
"no schema has been selected to create in")));
522 Oid *existing_relation_id)
538 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
539 errmsg(
"cross-database references are not implemented: \"%s.%s.%s\"",
559 if (existing_relation_id !=
NULL)
581 if (relid == oldrelid && nspid == oldnspid)
584 if (nspid != oldnspid)
593 if (nspid != oldnspid)
602 if (relid != oldrelid)
617 if (existing_relation_id !=
NULL)
618 *existing_relation_id = relid;
636 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
637 errmsg(
"cannot create relations in temporary schemas of other sessions")));
640 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
641 errmsg(
"cannot create temporary relation in non-temporary schema")));
649 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
650 errmsg(
"cannot create relations in temporary schemas of other sessions")));
655 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
656 errmsg(
"only temporary relations may be created in temporary schemas")));
673 foreach(l, activeSearchPath)
703 elog(
ERROR,
"cache lookup failed for relation %u", relid);
713 relnamespace = relform->relnamespace;
724 char *relname =
NameStr(relform->relname);
728 foreach(l, activeSearchPath)
732 if (namespaceId == relnamespace)
767 foreach(l, activeSearchPath)
798 elog(
ERROR,
"cache lookup failed for type %u", typid);
808 typnamespace = typform->typnamespace;
819 char *typname =
NameStr(typform->typname);
823 foreach(l, activeSearchPath)
827 if (namespaceId == typnamespace)
916 bool expand_variadic,
bool expand_defaults,
920 bool any_special =
false;
928 Assert(nargs >= 0 || !(expand_variadic | expand_defaults));
954 int pronargs = procform->pronargs;
960 int *argnumbers =
NULL;
966 if (procform->pronamespace != namespaceId)
977 foreach(nsp, activeSearchPath)
979 if (procform->pronamespace ==
lfirst_oid(nsp) &&
997 if (
OidIsValid(procform->provariadic) && expand_variadic)
1007 if (pronargs > nargs && expand_defaults)
1010 if (nargs + procform->pronargdefaults < pronargs)
1012 use_defaults =
true;
1015 use_defaults =
false;
1018 if (pronargs != nargs && !use_defaults)
1038 if (pronargs <= nargs && expand_variadic)
1040 va_elem_type = procform->provariadic;
1042 any_special |= variadic;
1053 if (pronargs > nargs && expand_defaults)
1056 if (nargs + procform->pronargdefaults < pronargs)
1058 use_defaults =
true;
1062 use_defaults =
false;
1065 if (nargs >= 0 && pronargs != nargs && !variadic && !use_defaults)
1075 effective_nargs =
Max(pronargs, nargs);
1078 + effective_nargs *
sizeof(
Oid));
1081 newResult->
nargs = effective_nargs;
1086 Oid *proargtypes = procform->proargtypes.values;
1089 for (i = 0; i < pronargs; i++)
1090 newResult->
args[i] = proargtypes[argnumbers[i]];
1095 memcpy(newResult->
args, procform->proargtypes.values,
1096 pronargs *
sizeof(
Oid));
1102 newResult->
nvargs = effective_nargs - pronargs + 1;
1104 for (i = pronargs - 1; i < effective_nargs; i++)
1105 newResult->
args[i] = va_elem_type;
1109 newResult->
ndargs = use_defaults ? pronargs - nargs : 0;
1119 if (resultList !=
NULL &&
1135 if (catlist->
ordered && !any_special)
1138 if (effective_nargs == resultList->
nargs &&
1139 memcmp(newResult->
args,
1141 effective_nargs *
sizeof(
Oid)) == 0)
1142 prevResult = resultList;
1148 int cmp_nargs = newResult->
nargs - newResult->
ndargs;
1150 for (prevResult = resultList;
1152 prevResult = prevResult->
next)
1154 if (cmp_nargs == prevResult->
nargs - prevResult->
ndargs &&
1155 memcmp(newResult->
args,
1157 cmp_nargs *
sizeof(
Oid)) == 0)
1173 if (pathpos != prevResult->
pathpos)
1178 preference = pathpos - prevResult->
pathpos;
1180 else if (variadic && prevResult->
nvargs == 0)
1190 else if (!variadic && prevResult->
nvargs > 0)
1214 else if (preference < 0)
1217 if (prevResult == resultList)
1218 resultList = prevResult->
next;
1223 for (prevPrevResult = resultList;
1225 prevPrevResult = prevPrevResult->
next)
1227 if (prevResult == prevPrevResult->
next)
1229 prevPrevResult->
next = prevResult->
next;
1251 newResult->
next = resultList;
1252 resultList = newResult;
1282 int pronargs = procform->pronargs;
1296 Assert(nargs <= pronargs);
1306 &p_argtypes, &p_argnames, &p_argmodes);
1310 *argnumbers = (
int *)
palloc(pronargs *
sizeof(
int));
1311 memset(arggiven,
false, pronargs *
sizeof(
bool));
1314 for (ap = 0; ap < numposargs; ap++)
1316 (*argnumbers)[ap] = ap;
1317 arggiven[ap] =
true;
1321 foreach(lc, argnames)
1323 char *argname = (
char *)
lfirst(lc);
1329 for (i = 0; i < pronallargs; i++)
1337 if (p_argnames[i] && strcmp(p_argnames[i], argname) == 0)
1342 arggiven[pp] =
true;
1343 (*argnumbers)[ap] = pp;
1359 if (nargs < pronargs)
1361 int first_arg_with_default = pronargs - procform->pronargdefaults;
1363 for (pp = numposargs; pp < pronargs; pp++)
1368 if (pp < first_arg_with_default)
1370 (*argnumbers)[ap++] = pp;
1395 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1405 pronamespace = procform->pronamespace;
1417 char *proname =
NameStr(procform->proname);
1418 int nargs = procform->pronargs;
1424 nargs,
NIL,
false,
false,
false);
1426 for (; clist; clist = clist->
next)
1428 if (memcmp(clist->
args, procform->proargtypes.values,
1429 nargs *
sizeof(
Oid)) == 0)
1432 visible = (clist->
oid == funcid);
1514 foreach(l, activeSearchPath)
1522 for (i = 0; i < catlist->
n_members; i++)
1527 if (operform->oprnamespace == namespaceId)
1562 char *resultSpace =
NULL;
1597 #define SPACE_PER_OP MAXALIGN(sizeof(struct _FuncCandidateList) + sizeof(Oid))
1602 for (i = 0; i < catlist->
n_members; i++)
1610 if (oprkind && operform->oprkind != oprkind)
1616 if (operform->oprnamespace != namespaceId)
1628 foreach(nsp, activeSearchPath)
1630 if (operform->oprnamespace ==
lfirst_oid(nsp) &&
1655 if (operform->oprleft == resultList->
args[0] &&
1656 operform->oprright == resultList->
args[1])
1657 prevResult = resultList;
1663 for (prevResult = resultList;
1665 prevResult = prevResult->
next)
1667 if (operform->oprleft == prevResult->
args[0] &&
1668 operform->oprright == prevResult->
args[1])
1676 if (pathpos > prevResult->
pathpos)
1679 prevResult->
pathpos = pathpos;
1694 newResult->
nargs = 2;
1698 newResult->
args[0] = operform->oprleft;
1699 newResult->
args[1] = operform->oprright;
1700 newResult->
next = resultList;
1701 resultList = newResult;
1725 elog(
ERROR,
"cache lookup failed for operator %u", oprid);
1735 oprnamespace = oprform->oprnamespace;
1747 char *oprname =
NameStr(oprform->oprname);
1750 oprform->oprleft, oprform->oprright)
1776 foreach(l, activeSearchPath)
1811 elog(
ERROR,
"cache lookup failed for opclass %u", opcid);
1821 opcnamespace = opcform->opcnamespace;
1833 char *opcname =
NameStr(opcform->opcname);
1859 foreach(l, activeSearchPath)
1894 elog(
ERROR,
"cache lookup failed for opfamily %u", opfid);
1904 opfnamespace = opfform->opfnamespace;
1916 char *opfname =
NameStr(opfform->opfname);
1939 foreach(l, activeSearchPath)
1984 elog(
ERROR,
"cache lookup failed for collation %u", collid);
1994 collnamespace = collform->collnamespace;
2006 char *collname =
NameStr(collform->collname);
2032 foreach(l, activeSearchPath)
2066 elog(
ERROR,
"cache lookup failed for conversion %u", conid);
2076 connamespace = conform->connamespace;
2088 char *conname =
NameStr(conform->conname);
2131 foreach(l, activeSearchPath)
2148 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2149 errmsg(
"text search parser \"%s\" does not exist",
2171 elog(
ERROR,
"cache lookup failed for text search parser %u", prsId);
2181 namespace = form->prsnamespace;
2196 foreach(l, activeSearchPath)
2203 if (namespaceId ==
namespace)
2257 foreach(l, activeSearchPath)
2274 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2275 errmsg(
"text search dictionary \"%s\" does not exist",
2297 elog(
ERROR,
"cache lookup failed for text search dictionary %u",
2308 namespace = form->dictnamespace;
2323 foreach(l, activeSearchPath)
2330 if (namespaceId ==
namespace)
2360 char *template_name;
2384 foreach(l, activeSearchPath)
2401 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2402 errmsg(
"text search template \"%s\" does not exist",
2424 elog(
ERROR,
"cache lookup failed for text search template %u", tmplId);
2434 namespace = form->tmplnamespace;
2449 foreach(l, activeSearchPath)
2456 if (namespaceId ==
namespace)
2510 foreach(l, activeSearchPath)
2527 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2528 errmsg(
"text search configuration \"%s\" does not exist",
2550 elog(
ERROR,
"cache lookup failed for text search configuration %u",
2561 namespace = form->cfgnamespace;
2576 foreach(l, activeSearchPath)
2583 if (namespaceId ==
namespace)
2618 char *schemaname =
NULL;
2619 char *objname =
NULL;
2640 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2641 errmsg(
"cross-database references are not implemented: %s",
2646 (
errcode(ERRCODE_SYNTAX_ERROR),
2647 errmsg(
"improper qualified name (too many dotted names): %s",
2652 *nspname_p = schemaname;
2653 *objname_p = objname;
2670 if (strcmp(nspname,
"pg_temp") == 0)
2703 if (strcmp(nspname,
"pg_temp") == 0)
2746 if (strcmp(nspname,
"pg_temp") == 0)
2774 if (oldNspOid == nspOid)
2777 errcode(ERRCODE_DUPLICATE_TABLE) :
2779 errcode(ERRCODE_DUPLICATE_FUNCTION) :
2780 errcode(ERRCODE_DUPLICATE_OBJECT),
2781 errmsg(
"%s is already in schema \"%s\"",
2788 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2789 errmsg(
"cannot move objects into or out of temporary schemas")));
2794 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2795 errmsg(
"cannot move objects into or out of TOAST schema")));
2822 if (strcmp(schemaname,
"pg_temp") == 0)
2846 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
2847 errmsg(
"no schema has been selected to create in")));
2867 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
2868 errmsg(
"schema \"%s\" does not exist", nspname)));
2898 (
errcode(ERRCODE_SYNTAX_ERROR),
2899 errmsg(
"improper relation name (too many dotted names): %s",
2932 if (
IsA(name, String))
2937 elog(
ERROR,
"unexpected node type in name list: %d",
3020 result = (strncmp(nspname,
"pg_temp_", 8) == 0) ||
3021 (strncmp(nspname,
"pg_toast_temp_", 14) == 0);
3059 if (strncmp(nspname,
"pg_temp_", 8) == 0)
3060 result = atoi(nspname + 8);
3061 else if (strncmp(nspname,
"pg_toast_temp_", 14) == 0)
3062 result = atoi(nspname + 14);
3221 overrideStack =
lcons(entry, overrideStack);
3243 if (overrideStack ==
NIL)
3244 elog(
ERROR,
"bogus PopOverrideSearchPath call");
3247 elog(
ERROR,
"bogus PopOverrideSearchPath call");
3279 char *collation_name;
3314 foreach(l, activeSearchPath)
3339 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3340 errmsg(
"collation \"%s\" for encoding \"%s\" does not exist",
3352 char *conversion_name;
3376 foreach(l, activeSearchPath)
3394 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3395 errmsg(
"conversion \"%s\" does not exist",
3411 foreach(l, activeSearchPath)
3469 temp_missing =
false;
3470 foreach(l, namelist)
3472 char *curname = (
char *)
lfirst(l);
3475 if (strcmp(curname,
"$user") == 0)
3496 else if (strcmp(curname,
"pg_temp") == 0)
3509 temp_missing =
true;
3557 baseSearchPath = newpath;
3602 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3603 errmsg(
"permission denied to create temporary tables in database \"%s\"",
3618 (
errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
3619 errmsg(
"cannot create temporary tables during recovery")));
3653 snprintf(namespaceName,
sizeof(namespaceName),
"pg_toast_temp_%d",
3714 while (overrideStack)
3761 while (overrideStack)
3810 object.objectId = tempNamespaceId;
3811 object.objectSubId = 0;
3979 if (!includeImplicit)
4006 foreach(l, activeSearchPath)
4013 if (count < sarray_len)
4014 sarray[count] = namespaceId;