PostgreSQL Source Code  git master
regproc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * regproc.c
4  * Functions for the built-in types regproc, regclass, regtype, etc.
5  *
6  * These types are all binary-compatible with type Oid, and rely on Oid
7  * for comparison and so forth. Their only interesting behavior is in
8  * special I/O conversion routines.
9  *
10  *
11  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
12  * Portions Copyright (c) 1994, Regents of the University of California
13  *
14  *
15  * IDENTIFICATION
16  * src/backend/utils/adt/regproc.c
17  *
18  *-------------------------------------------------------------------------
19  */
20 #include "postgres.h"
21 
22 #include <ctype.h>
23 
24 #include "access/htup_details.h"
25 #include "catalog/namespace.h"
26 #include "catalog/pg_class.h"
27 #include "catalog/pg_collation.h"
28 #include "catalog/pg_operator.h"
29 #include "catalog/pg_proc.h"
30 #include "catalog/pg_ts_config.h"
31 #include "catalog/pg_ts_dict.h"
32 #include "catalog/pg_type.h"
33 #include "lib/stringinfo.h"
34 #include "miscadmin.h"
35 #include "parser/parse_type.h"
36 #include "parser/scansup.h"
37 #include "utils/acl.h"
38 #include "utils/builtins.h"
39 #include "utils/lsyscache.h"
40 #include "utils/regproc.h"
41 #include "utils/syscache.h"
42 #include "utils/varlena.h"
43 
44 static void parseNameAndArgTypes(const char *string, bool allowNone,
45  List **names, int *nargs, Oid *argtypes);
46 
47 
48 /*****************************************************************************
49  * USER I/O ROUTINES *
50  *****************************************************************************/
51 
52 /*
53  * regprocin - converts "proname" to proc OID
54  *
55  * We also accept a numeric OID, for symmetry with the output routine.
56  *
57  * '-' signifies unknown (OID 0). In all other cases, the input must
58  * match an existing pg_proc entry.
59  */
60 Datum
62 {
63  char *pro_name_or_oid = PG_GETARG_CSTRING(0);
64  RegProcedure result = InvalidOid;
65  List *names;
66  FuncCandidateList clist;
67 
68  /* '-' ? */
69  if (strcmp(pro_name_or_oid, "-") == 0)
71 
72  /* Numeric OID? */
73  if (pro_name_or_oid[0] >= '0' &&
74  pro_name_or_oid[0] <= '9' &&
75  strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid))
76  {
78  CStringGetDatum(pro_name_or_oid)));
79  PG_RETURN_OID(result);
80  }
81 
82  /* Else it's a name, possibly schema-qualified */
83 
84  /*
85  * We should never get here in bootstrap mode, as all references should
86  * have been resolved by genbki.pl.
87  */
89  elog(ERROR, "regproc values must be OIDs in bootstrap mode");
90 
91  /*
92  * Normal case: parse the name into components and see if it matches any
93  * pg_proc entries in the current search path.
94  */
95  names = stringToQualifiedNameList(pro_name_or_oid);
96  clist = FuncnameGetCandidates(names, -1, NIL, false, false, false);
97 
98  if (clist == NULL)
99  ereport(ERROR,
100  (errcode(ERRCODE_UNDEFINED_FUNCTION),
101  errmsg("function \"%s\" does not exist", pro_name_or_oid)));
102  else if (clist->next != NULL)
103  ereport(ERROR,
104  (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
105  errmsg("more than one function named \"%s\"",
106  pro_name_or_oid)));
107 
108  result = clist->oid;
109 
110  PG_RETURN_OID(result);
111 }
112 
113 /*
114  * to_regproc - converts "proname" to proc OID
115  *
116  * If the name is not found, we return NULL.
117  */
118 Datum
120 {
121  char *pro_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
122  List *names;
123  FuncCandidateList clist;
124 
125  /*
126  * Parse the name into components and see if it matches any pg_proc
127  * entries in the current search path.
128  */
129  names = stringToQualifiedNameList(pro_name);
130  clist = FuncnameGetCandidates(names, -1, NIL, false, false, true);
131 
132  if (clist == NULL || clist->next != NULL)
133  PG_RETURN_NULL();
134 
135  PG_RETURN_OID(clist->oid);
136 }
137 
138 /*
139  * regprocout - converts proc OID to "pro_name"
140  */
141 Datum
143 {
144  RegProcedure proid = PG_GETARG_OID(0);
145  char *result;
146  HeapTuple proctup;
147 
148  if (proid == InvalidOid)
149  {
150  result = pstrdup("-");
151  PG_RETURN_CSTRING(result);
152  }
153 
154  proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(proid));
155 
156  if (HeapTupleIsValid(proctup))
157  {
158  Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
159  char *proname = NameStr(procform->proname);
160 
161  /*
162  * In bootstrap mode, skip the fancy namespace stuff and just return
163  * the proc name. (This path is only needed for debugging output
164  * anyway.)
165  */
167  result = pstrdup(proname);
168  else
169  {
170  char *nspname;
171  FuncCandidateList clist;
172 
173  /*
174  * Would this proc be found (uniquely!) by regprocin? If not,
175  * qualify it.
176  */
177  clist = FuncnameGetCandidates(list_make1(makeString(proname)),
178  -1, NIL, false, false, false);
179  if (clist != NULL && clist->next == NULL &&
180  clist->oid == proid)
181  nspname = NULL;
182  else
183  nspname = get_namespace_name(procform->pronamespace);
184 
185  result = quote_qualified_identifier(nspname, proname);
186  }
187 
188  ReleaseSysCache(proctup);
189  }
190  else
191  {
192  /* If OID doesn't match any pg_proc entry, return it numerically */
193  result = (char *) palloc(NAMEDATALEN);
194  snprintf(result, NAMEDATALEN, "%u", proid);
195  }
196 
197  PG_RETURN_CSTRING(result);
198 }
199 
200 /*
201  * regprocrecv - converts external binary format to regproc
202  */
203 Datum
205 {
206  /* Exactly the same as oidrecv, so share code */
207  return oidrecv(fcinfo);
208 }
209 
210 /*
211  * regprocsend - converts regproc to binary format
212  */
213 Datum
215 {
216  /* Exactly the same as oidsend, so share code */
217  return oidsend(fcinfo);
218 }
219 
220 
221 /*
222  * regprocedurein - converts "proname(args)" to proc OID
223  *
224  * We also accept a numeric OID, for symmetry with the output routine.
225  *
226  * '-' signifies unknown (OID 0). In all other cases, the input must
227  * match an existing pg_proc entry.
228  */
229 Datum
231 {
232  char *pro_name_or_oid = PG_GETARG_CSTRING(0);
233  RegProcedure result = InvalidOid;
234  List *names;
235  int nargs;
236  Oid argtypes[FUNC_MAX_ARGS];
237  FuncCandidateList clist;
238 
239  /* '-' ? */
240  if (strcmp(pro_name_or_oid, "-") == 0)
242 
243  /* Numeric OID? */
244  if (pro_name_or_oid[0] >= '0' &&
245  pro_name_or_oid[0] <= '9' &&
246  strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid))
247  {
249  CStringGetDatum(pro_name_or_oid)));
250  PG_RETURN_OID(result);
251  }
252 
253  /* The rest of this wouldn't work in bootstrap mode */
255  elog(ERROR, "regprocedure values must be OIDs in bootstrap mode");
256 
257  /*
258  * Else it's a name and arguments. Parse the name and arguments, look up
259  * potential matches in the current namespace search list, and scan to see
260  * which one exactly matches the given argument types. (There will not be
261  * more than one match.)
262  */
263  parseNameAndArgTypes(pro_name_or_oid, false, &names, &nargs, argtypes);
264 
265  clist = FuncnameGetCandidates(names, nargs, NIL, false, false, false);
266 
267  for (; clist; clist = clist->next)
268  {
269  if (memcmp(clist->args, argtypes, nargs * sizeof(Oid)) == 0)
270  break;
271  }
272 
273  if (clist == NULL)
274  ereport(ERROR,
275  (errcode(ERRCODE_UNDEFINED_FUNCTION),
276  errmsg("function \"%s\" does not exist", pro_name_or_oid)));
277 
278  result = clist->oid;
279 
280  PG_RETURN_OID(result);
281 }
282 
283 /*
284  * to_regprocedure - converts "proname(args)" to proc OID
285  *
286  * If the name is not found, we return NULL.
287  */
288 Datum
290 {
291  char *pro_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
292  List *names;
293  int nargs;
294  Oid argtypes[FUNC_MAX_ARGS];
295  FuncCandidateList clist;
296 
297  /*
298  * Parse the name and arguments, look up potential matches in the current
299  * namespace search list, and scan to see which one exactly matches the
300  * given argument types. (There will not be more than one match.)
301  */
302  parseNameAndArgTypes(pro_name, false, &names, &nargs, argtypes);
303 
304  clist = FuncnameGetCandidates(names, nargs, NIL, false, false, true);
305 
306  for (; clist; clist = clist->next)
307  {
308  if (memcmp(clist->args, argtypes, nargs * sizeof(Oid)) == 0)
309  PG_RETURN_OID(clist->oid);
310  }
311 
312  PG_RETURN_NULL();
313 }
314 
315 /*
316  * format_procedure - converts proc OID to "pro_name(args)"
317  *
318  * This exports the useful functionality of regprocedureout for use
319  * in other backend modules. The result is a palloc'd string.
320  */
321 char *
322 format_procedure(Oid procedure_oid)
323 {
324  return format_procedure_extended(procedure_oid, 0);
325 }
326 
327 char *
329 {
331 }
332 
333 /*
334  * format_procedure_extended - converts procedure OID to "pro_name(args)"
335  *
336  * This exports the useful functionality of regprocedureout for use
337  * in other backend modules. The result is a palloc'd string, or NULL.
338  *
339  * Routine to produce regprocedure names; see format_procedure above.
340  *
341  * The following bits in 'flags' modify the behavior:
342  * - FORMAT_PROC_INVALID_AS_NULL
343  * if the procedure OID is invalid or unknown, return NULL instead
344  * of the numeric OID.
345  * - FORMAT_PROC_FORCE_QUALIFY
346  * always schema-qualify procedure names, regardless of search_path
347  */
348 char *
349 format_procedure_extended(Oid procedure_oid, bits16 flags)
350 {
351  char *result;
352  HeapTuple proctup;
353 
354  proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procedure_oid));
355 
356  if (HeapTupleIsValid(proctup))
357  {
358  Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
359  char *proname = NameStr(procform->proname);
360  int nargs = procform->pronargs;
361  int i;
362  char *nspname;
364 
365  /* XXX no support here for bootstrap mode */
367 
368  initStringInfo(&buf);
369 
370  /*
371  * Would this proc be found (given the right args) by regprocedurein?
372  * If not, or if caller requests it, we need to qualify it.
373  */
374  if ((flags & FORMAT_PROC_FORCE_QUALIFY) == 0 &&
375  FunctionIsVisible(procedure_oid))
376  nspname = NULL;
377  else
378  nspname = get_namespace_name(procform->pronamespace);
379 
380  appendStringInfo(&buf, "%s(",
381  quote_qualified_identifier(nspname, proname));
382  for (i = 0; i < nargs; i++)
383  {
384  Oid thisargtype = procform->proargtypes.values[i];
385 
386  if (i > 0)
387  appendStringInfoChar(&buf, ',');
389  (flags & FORMAT_PROC_FORCE_QUALIFY) != 0 ?
390  format_type_be_qualified(thisargtype) :
391  format_type_be(thisargtype));
392  }
393  appendStringInfoChar(&buf, ')');
394 
395  result = buf.data;
396 
397  ReleaseSysCache(proctup);
398  }
399  else if ((flags & FORMAT_PROC_INVALID_AS_NULL) != 0)
400  {
401  /* If object is undefined, return NULL as wanted by caller */
402  result = NULL;
403  }
404  else
405  {
406  /* If OID doesn't match any pg_proc entry, return it numerically */
407  result = (char *) palloc(NAMEDATALEN);
408  snprintf(result, NAMEDATALEN, "%u", procedure_oid);
409  }
410 
411  return result;
412 }
413 
414 /*
415  * Output an objname/objargs representation for the procedure with the
416  * given OID. If it doesn't exist, an error is thrown.
417  *
418  * This can be used to feed get_object_address.
419  */
420 void
421 format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs,
422  bool missing_ok)
423 {
424  HeapTuple proctup;
425  Form_pg_proc procform;
426  int nargs;
427  int i;
428 
429  proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procedure_oid));
430 
431  if (!HeapTupleIsValid(proctup))
432  {
433  if (!missing_ok)
434  elog(ERROR, "cache lookup failed for procedure with OID %u", procedure_oid);
435  return;
436  }
437 
438  procform = (Form_pg_proc) GETSTRUCT(proctup);
439  nargs = procform->pronargs;
440 
441  *objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
442  pstrdup(NameStr(procform->proname)));
443  *objargs = NIL;
444  for (i = 0; i < nargs; i++)
445  {
446  Oid thisargtype = procform->proargtypes.values[i];
447 
448  *objargs = lappend(*objargs, format_type_be_qualified(thisargtype));
449  }
450 
451  ReleaseSysCache(proctup);
452 }
453 
454 /*
455  * regprocedureout - converts proc OID to "pro_name(args)"
456  */
457 Datum
459 {
460  RegProcedure proid = PG_GETARG_OID(0);
461  char *result;
462 
463  if (proid == InvalidOid)
464  result = pstrdup("-");
465  else
466  result = format_procedure(proid);
467 
468  PG_RETURN_CSTRING(result);
469 }
470 
471 /*
472  * regprocedurerecv - converts external binary format to regprocedure
473  */
474 Datum
476 {
477  /* Exactly the same as oidrecv, so share code */
478  return oidrecv(fcinfo);
479 }
480 
481 /*
482  * regproceduresend - converts regprocedure to binary format
483  */
484 Datum
486 {
487  /* Exactly the same as oidsend, so share code */
488  return oidsend(fcinfo);
489 }
490 
491 
492 /*
493  * regoperin - converts "oprname" to operator OID
494  *
495  * We also accept a numeric OID, for symmetry with the output routine.
496  *
497  * '0' signifies unknown (OID 0). In all other cases, the input must
498  * match an existing pg_operator entry.
499  */
500 Datum
502 {
503  char *opr_name_or_oid = PG_GETARG_CSTRING(0);
504  Oid result = InvalidOid;
505  List *names;
506  FuncCandidateList clist;
507 
508  /* '0' ? */
509  if (strcmp(opr_name_or_oid, "0") == 0)
511 
512  /* Numeric OID? */
513  if (opr_name_or_oid[0] >= '0' &&
514  opr_name_or_oid[0] <= '9' &&
515  strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid))
516  {
518  CStringGetDatum(opr_name_or_oid)));
519  PG_RETURN_OID(result);
520  }
521 
522  /* Else it's a name, possibly schema-qualified */
523 
524  /* The rest of this wouldn't work in bootstrap mode */
526  elog(ERROR, "regoper values must be OIDs in bootstrap mode");
527 
528  /*
529  * Normal case: parse the name into components and see if it matches any
530  * pg_operator entries in the current search path.
531  */
532  names = stringToQualifiedNameList(opr_name_or_oid);
533  clist = OpernameGetCandidates(names, '\0', false);
534 
535  if (clist == NULL)
536  ereport(ERROR,
537  (errcode(ERRCODE_UNDEFINED_FUNCTION),
538  errmsg("operator does not exist: %s", opr_name_or_oid)));
539  else if (clist->next != NULL)
540  ereport(ERROR,
541  (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
542  errmsg("more than one operator named %s",
543  opr_name_or_oid)));
544 
545  result = clist->oid;
546 
547  PG_RETURN_OID(result);
548 }
549 
550 /*
551  * to_regoper - converts "oprname" to operator OID
552  *
553  * If the name is not found, we return NULL.
554  */
555 Datum
557 {
558  char *opr_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
559  List *names;
560  FuncCandidateList clist;
561 
562  /*
563  * Parse the name into components and see if it matches any pg_operator
564  * entries in the current search path.
565  */
566  names = stringToQualifiedNameList(opr_name);
567  clist = OpernameGetCandidates(names, '\0', true);
568 
569  if (clist == NULL || clist->next != NULL)
570  PG_RETURN_NULL();
571 
572  PG_RETURN_OID(clist->oid);
573 }
574 
575 /*
576  * regoperout - converts operator OID to "opr_name"
577  */
578 Datum
580 {
581  Oid oprid = PG_GETARG_OID(0);
582  char *result;
583  HeapTuple opertup;
584 
585  if (oprid == InvalidOid)
586  {
587  result = pstrdup("0");
588  PG_RETURN_CSTRING(result);
589  }
590 
591  opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(oprid));
592 
593  if (HeapTupleIsValid(opertup))
594  {
595  Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
596  char *oprname = NameStr(operform->oprname);
597 
598  /*
599  * In bootstrap mode, skip the fancy namespace stuff and just return
600  * the oper name. (This path is only needed for debugging output
601  * anyway.)
602  */
604  result = pstrdup(oprname);
605  else
606  {
607  FuncCandidateList clist;
608 
609  /*
610  * Would this oper be found (uniquely!) by regoperin? If not,
611  * qualify it.
612  */
613  clist = OpernameGetCandidates(list_make1(makeString(oprname)),
614  '\0', false);
615  if (clist != NULL && clist->next == NULL &&
616  clist->oid == oprid)
617  result = pstrdup(oprname);
618  else
619  {
620  const char *nspname;
621 
622  nspname = get_namespace_name(operform->oprnamespace);
623  nspname = quote_identifier(nspname);
624  result = (char *) palloc(strlen(nspname) + strlen(oprname) + 2);
625  sprintf(result, "%s.%s", nspname, oprname);
626  }
627  }
628 
629  ReleaseSysCache(opertup);
630  }
631  else
632  {
633  /*
634  * If OID doesn't match any pg_operator entry, return it numerically
635  */
636  result = (char *) palloc(NAMEDATALEN);
637  snprintf(result, NAMEDATALEN, "%u", oprid);
638  }
639 
640  PG_RETURN_CSTRING(result);
641 }
642 
643 /*
644  * regoperrecv - converts external binary format to regoper
645  */
646 Datum
648 {
649  /* Exactly the same as oidrecv, so share code */
650  return oidrecv(fcinfo);
651 }
652 
653 /*
654  * regopersend - converts regoper to binary format
655  */
656 Datum
658 {
659  /* Exactly the same as oidsend, so share code */
660  return oidsend(fcinfo);
661 }
662 
663 
664 /*
665  * regoperatorin - converts "oprname(args)" to operator OID
666  *
667  * We also accept a numeric OID, for symmetry with the output routine.
668  *
669  * '0' signifies unknown (OID 0). In all other cases, the input must
670  * match an existing pg_operator entry.
671  */
672 Datum
674 {
675  char *opr_name_or_oid = PG_GETARG_CSTRING(0);
676  Oid result;
677  List *names;
678  int nargs;
679  Oid argtypes[FUNC_MAX_ARGS];
680 
681  /* '0' ? */
682  if (strcmp(opr_name_or_oid, "0") == 0)
684 
685  /* Numeric OID? */
686  if (opr_name_or_oid[0] >= '0' &&
687  opr_name_or_oid[0] <= '9' &&
688  strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid))
689  {
691  CStringGetDatum(opr_name_or_oid)));
692  PG_RETURN_OID(result);
693  }
694 
695  /* The rest of this wouldn't work in bootstrap mode */
697  elog(ERROR, "regoperator values must be OIDs in bootstrap mode");
698 
699  /*
700  * Else it's a name and arguments. Parse the name and arguments, look up
701  * potential matches in the current namespace search list, and scan to see
702  * which one exactly matches the given argument types. (There will not be
703  * more than one match.)
704  */
705  parseNameAndArgTypes(opr_name_or_oid, true, &names, &nargs, argtypes);
706  if (nargs == 1)
707  ereport(ERROR,
708  (errcode(ERRCODE_UNDEFINED_PARAMETER),
709  errmsg("missing argument"),
710  errhint("Use NONE to denote the missing argument of a unary operator.")));
711  if (nargs != 2)
712  ereport(ERROR,
713  (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
714  errmsg("too many arguments"),
715  errhint("Provide two argument types for operator.")));
716 
717  result = OpernameGetOprid(names, argtypes[0], argtypes[1]);
718 
719  if (!OidIsValid(result))
720  ereport(ERROR,
721  (errcode(ERRCODE_UNDEFINED_FUNCTION),
722  errmsg("operator does not exist: %s", opr_name_or_oid)));
723 
724  PG_RETURN_OID(result);
725 }
726 
727 /*
728  * to_regoperator - converts "oprname(args)" to operator OID
729  *
730  * If the name is not found, we return NULL.
731  */
732 Datum
734 {
735  char *opr_name_or_oid = text_to_cstring(PG_GETARG_TEXT_PP(0));
736  Oid result;
737  List *names;
738  int nargs;
739  Oid argtypes[FUNC_MAX_ARGS];
740 
741  /*
742  * Parse the name and arguments, look up potential matches in the current
743  * namespace search list, and scan to see which one exactly matches the
744  * given argument types. (There will not be more than one match.)
745  */
746  parseNameAndArgTypes(opr_name_or_oid, true, &names, &nargs, argtypes);
747  if (nargs == 1)
748  ereport(ERROR,
749  (errcode(ERRCODE_UNDEFINED_PARAMETER),
750  errmsg("missing argument"),
751  errhint("Use NONE to denote the missing argument of a unary operator.")));
752  if (nargs != 2)
753  ereport(ERROR,
754  (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
755  errmsg("too many arguments"),
756  errhint("Provide two argument types for operator.")));
757 
758  result = OpernameGetOprid(names, argtypes[0], argtypes[1]);
759 
760  if (!OidIsValid(result))
761  PG_RETURN_NULL();
762 
763  PG_RETURN_OID(result);
764 }
765 
766 /*
767  * format_operator_extended - converts operator OID to "opr_name(args)"
768  *
769  * This exports the useful functionality of regoperatorout for use
770  * in other backend modules. The result is a palloc'd string, or NULL.
771  *
772  * The following bits in 'flags' modify the behavior:
773  * - FORMAT_OPERATOR_INVALID_AS_NULL
774  * if the operator OID is invalid or unknown, return NULL instead
775  * of the numeric OID.
776  * - FORMAT_OPERATOR_FORCE_QUALIFY
777  * always schema-qualify operator names, regardless of search_path
778  */
779 char *
780 format_operator_extended(Oid operator_oid, bits16 flags)
781 {
782  char *result;
783  HeapTuple opertup;
784 
785  opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operator_oid));
786 
787  if (HeapTupleIsValid(opertup))
788  {
789  Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup);
790  char *oprname = NameStr(operform->oprname);
791  char *nspname;
793 
794  /* XXX no support here for bootstrap mode */
796 
797  initStringInfo(&buf);
798 
799  /*
800  * Would this oper be found (given the right args) by regoperatorin?
801  * If not, or if caller explicitly requests it, we need to qualify it.
802  */
803  if ((flags & FORMAT_OPERATOR_FORCE_QUALIFY) != 0 ||
804  !OperatorIsVisible(operator_oid))
805  {
806  nspname = get_namespace_name(operform->oprnamespace);
807  appendStringInfo(&buf, "%s.",
808  quote_identifier(nspname));
809  }
810 
811  appendStringInfo(&buf, "%s(", oprname);
812 
813  if (operform->oprleft)
814  appendStringInfo(&buf, "%s,",
815  (flags & FORMAT_OPERATOR_FORCE_QUALIFY) != 0 ?
816  format_type_be_qualified(operform->oprleft) :
817  format_type_be(operform->oprleft));
818  else
819  appendStringInfoString(&buf, "NONE,");
820 
821  if (operform->oprright)
822  appendStringInfo(&buf, "%s)",
823  (flags & FORMAT_OPERATOR_FORCE_QUALIFY) != 0 ?
824  format_type_be_qualified(operform->oprright) :
825  format_type_be(operform->oprright));
826  else
827  appendStringInfoString(&buf, "NONE)");
828 
829  result = buf.data;
830 
831  ReleaseSysCache(opertup);
832  }
833  else if ((flags & FORMAT_OPERATOR_INVALID_AS_NULL) != 0)
834  {
835  /* If object is undefined, return NULL as wanted by caller */
836  result = NULL;
837  }
838  else
839  {
840  /*
841  * If OID doesn't match any pg_operator entry, return it numerically
842  */
843  result = (char *) palloc(NAMEDATALEN);
844  snprintf(result, NAMEDATALEN, "%u", operator_oid);
845  }
846 
847  return result;
848 }
849 
850 char *
851 format_operator(Oid operator_oid)
852 {
853  return format_operator_extended(operator_oid, 0);
854 }
855 
856 char *
858 {
859  return format_operator_extended(operator_oid,
861 }
862 
863 void
864 format_operator_parts(Oid operator_oid, List **objnames, List **objargs,
865  bool missing_ok)
866 {
867  HeapTuple opertup;
868  Form_pg_operator oprForm;
869 
870  opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operator_oid));
871  if (!HeapTupleIsValid(opertup))
872  {
873  if (!missing_ok)
874  elog(ERROR, "cache lookup failed for operator with OID %u",
875  operator_oid);
876  return;
877  }
878 
879  oprForm = (Form_pg_operator) GETSTRUCT(opertup);
880  *objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
881  pstrdup(NameStr(oprForm->oprname)));
882  *objargs = NIL;
883  if (oprForm->oprleft)
884  *objargs = lappend(*objargs,
885  format_type_be_qualified(oprForm->oprleft));
886  if (oprForm->oprright)
887  *objargs = lappend(*objargs,
888  format_type_be_qualified(oprForm->oprright));
889 
890  ReleaseSysCache(opertup);
891 }
892 
893 /*
894  * regoperatorout - converts operator OID to "opr_name(args)"
895  */
896 Datum
898 {
899  Oid oprid = PG_GETARG_OID(0);
900  char *result;
901 
902  if (oprid == InvalidOid)
903  result = pstrdup("0");
904  else
905  result = format_operator(oprid);
906 
907  PG_RETURN_CSTRING(result);
908 }
909 
910 /*
911  * regoperatorrecv - converts external binary format to regoperator
912  */
913 Datum
915 {
916  /* Exactly the same as oidrecv, so share code */
917  return oidrecv(fcinfo);
918 }
919 
920 /*
921  * regoperatorsend - converts regoperator to binary format
922  */
923 Datum
925 {
926  /* Exactly the same as oidsend, so share code */
927  return oidsend(fcinfo);
928 }
929 
930 
931 /*
932  * regclassin - converts "classname" to class OID
933  *
934  * We also accept a numeric OID, for symmetry with the output routine.
935  *
936  * '-' signifies unknown (OID 0). In all other cases, the input must
937  * match an existing pg_class entry.
938  */
939 Datum
941 {
942  char *class_name_or_oid = PG_GETARG_CSTRING(0);
943  Oid result = InvalidOid;
944  List *names;
945 
946  /* '-' ? */
947  if (strcmp(class_name_or_oid, "-") == 0)
949 
950  /* Numeric OID? */
951  if (class_name_or_oid[0] >= '0' &&
952  class_name_or_oid[0] <= '9' &&
953  strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid))
954  {
956  CStringGetDatum(class_name_or_oid)));
957  PG_RETURN_OID(result);
958  }
959 
960  /* Else it's a name, possibly schema-qualified */
961 
962  /* The rest of this wouldn't work in bootstrap mode */
964  elog(ERROR, "regclass values must be OIDs in bootstrap mode");
965 
966  /*
967  * Normal case: parse the name into components and see if it matches any
968  * pg_class entries in the current search path.
969  */
970  names = stringToQualifiedNameList(class_name_or_oid);
971 
972  /* We might not even have permissions on this relation; don't lock it. */
973  result = RangeVarGetRelid(makeRangeVarFromNameList(names), NoLock, false);
974 
975  PG_RETURN_OID(result);
976 }
977 
978 /*
979  * to_regclass - converts "classname" to class OID
980  *
981  * If the name is not found, we return NULL.
982  */
983 Datum
985 {
987  Oid result;
988  List *names;
989 
990  /*
991  * Parse the name into components and see if it matches any pg_class
992  * entries in the current search path.
993  */
994  names = stringToQualifiedNameList(class_name);
995 
996  /* We might not even have permissions on this relation; don't lock it. */
997  result = RangeVarGetRelid(makeRangeVarFromNameList(names), NoLock, true);
998 
999  if (OidIsValid(result))
1000  PG_RETURN_OID(result);
1001  else
1002  PG_RETURN_NULL();
1003 }
1004 
1005 /*
1006  * regclassout - converts class OID to "class_name"
1007  */
1008 Datum
1010 {
1011  Oid classid = PG_GETARG_OID(0);
1012  char *result;
1013  HeapTuple classtup;
1014 
1015  if (classid == InvalidOid)
1016  {
1017  result = pstrdup("-");
1018  PG_RETURN_CSTRING(result);
1019  }
1020 
1021  classtup = SearchSysCache1(RELOID, ObjectIdGetDatum(classid));
1022 
1023  if (HeapTupleIsValid(classtup))
1024  {
1025  Form_pg_class classform = (Form_pg_class) GETSTRUCT(classtup);
1026  char *classname = NameStr(classform->relname);
1027 
1028  /*
1029  * In bootstrap mode, skip the fancy namespace stuff and just return
1030  * the class name. (This path is only needed for debugging output
1031  * anyway.)
1032  */
1034  result = pstrdup(classname);
1035  else
1036  {
1037  char *nspname;
1038 
1039  /*
1040  * Would this class be found by regclassin? If not, qualify it.
1041  */
1042  if (RelationIsVisible(classid))
1043  nspname = NULL;
1044  else
1045  nspname = get_namespace_name(classform->relnamespace);
1046 
1047  result = quote_qualified_identifier(nspname, classname);
1048  }
1049 
1050  ReleaseSysCache(classtup);
1051  }
1052  else
1053  {
1054  /* If OID doesn't match any pg_class entry, return it numerically */
1055  result = (char *) palloc(NAMEDATALEN);
1056  snprintf(result, NAMEDATALEN, "%u", classid);
1057  }
1058 
1059  PG_RETURN_CSTRING(result);
1060 }
1061 
1062 /*
1063  * regclassrecv - converts external binary format to regclass
1064  */
1065 Datum
1067 {
1068  /* Exactly the same as oidrecv, so share code */
1069  return oidrecv(fcinfo);
1070 }
1071 
1072 /*
1073  * regclasssend - converts regclass to binary format
1074  */
1075 Datum
1077 {
1078  /* Exactly the same as oidsend, so share code */
1079  return oidsend(fcinfo);
1080 }
1081 
1082 
1083 /*
1084  * regcollationin - converts "collationname" to collation OID
1085  *
1086  * We also accept a numeric OID, for symmetry with the output routine.
1087  *
1088  * '-' signifies unknown (OID 0). In all other cases, the input must
1089  * match an existing pg_collation entry.
1090  */
1091 Datum
1093 {
1094  char *collation_name_or_oid = PG_GETARG_CSTRING(0);
1095  Oid result = InvalidOid;
1096  List *names;
1097 
1098  /* '-' ? */
1099  if (strcmp(collation_name_or_oid, "-") == 0)
1101 
1102  /* Numeric OID? */
1103  if (collation_name_or_oid[0] >= '0' &&
1104  collation_name_or_oid[0] <= '9' &&
1105  strspn(collation_name_or_oid, "0123456789") == strlen(collation_name_or_oid))
1106  {
1108  CStringGetDatum(collation_name_or_oid)));
1109  PG_RETURN_OID(result);
1110  }
1111 
1112  /* Else it's a name, possibly schema-qualified */
1113 
1114  /* The rest of this wouldn't work in bootstrap mode */
1116  elog(ERROR, "regcollation values must be OIDs in bootstrap mode");
1117 
1118  /*
1119  * Normal case: parse the name into components and see if it matches any
1120  * pg_collation entries in the current search path.
1121  */
1122  names = stringToQualifiedNameList(collation_name_or_oid);
1123 
1124  result = get_collation_oid(names, false);
1125 
1126  PG_RETURN_OID(result);
1127 }
1128 
1129 /*
1130  * to_regcollation - converts "collationname" to collation OID
1131  *
1132  * If the name is not found, we return NULL.
1133  */
1134 Datum
1136 {
1137  char *collation_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
1138  Oid result;
1139  List *names;
1140 
1141  /*
1142  * Parse the name into components and see if it matches any pg_collation
1143  * entries in the current search path.
1144  */
1145  names = stringToQualifiedNameList(collation_name);
1146 
1147  /* We might not even have permissions on this relation; don't lock it. */
1148  result = get_collation_oid(names, true);
1149 
1150  if (OidIsValid(result))
1151  PG_RETURN_OID(result);
1152  else
1153  PG_RETURN_NULL();
1154 }
1155 
1156 /*
1157  * regcollationout - converts collation OID to "collation_name"
1158  */
1159 Datum
1161 {
1162  Oid collationid = PG_GETARG_OID(0);
1163  char *result;
1164  HeapTuple collationtup;
1165 
1166  if (collationid == InvalidOid)
1167  {
1168  result = pstrdup("-");
1169  PG_RETURN_CSTRING(result);
1170  }
1171 
1172  collationtup = SearchSysCache1(COLLOID, ObjectIdGetDatum(collationid));
1173 
1174  if (HeapTupleIsValid(collationtup))
1175  {
1176  Form_pg_collation collationform = (Form_pg_collation) GETSTRUCT(collationtup);
1177  char *collationname = NameStr(collationform->collname);
1178 
1179  /*
1180  * In bootstrap mode, skip the fancy namespace stuff and just return
1181  * the collation name. (This path is only needed for debugging output
1182  * anyway.)
1183  */
1185  result = pstrdup(collationname);
1186  else
1187  {
1188  char *nspname;
1189 
1190  /*
1191  * Would this collation be found by regcollationin? If not,
1192  * qualify it.
1193  */
1194  if (CollationIsVisible(collationid))
1195  nspname = NULL;
1196  else
1197  nspname = get_namespace_name(collationform->collnamespace);
1198 
1199  result = quote_qualified_identifier(nspname, collationname);
1200  }
1201 
1202  ReleaseSysCache(collationtup);
1203  }
1204  else
1205  {
1206  /* If OID doesn't match any pg_collation entry, return it numerically */
1207  result = (char *) palloc(NAMEDATALEN);
1208  snprintf(result, NAMEDATALEN, "%u", collationid);
1209  }
1210 
1211  PG_RETURN_CSTRING(result);
1212 }
1213 
1214 /*
1215  * regcollationrecv - converts external binary format to regcollation
1216  */
1217 Datum
1219 {
1220  /* Exactly the same as oidrecv, so share code */
1221  return oidrecv(fcinfo);
1222 }
1223 
1224 /*
1225  * regcollationsend - converts regcollation to binary format
1226  */
1227 Datum
1229 {
1230  /* Exactly the same as oidsend, so share code */
1231  return oidsend(fcinfo);
1232 }
1233 
1234 
1235 /*
1236  * regtypein - converts "typename" to type OID
1237  *
1238  * The type name can be specified using the full type syntax recognized by
1239  * the parser; for example, DOUBLE PRECISION and INTEGER[] will work and be
1240  * translated to the correct type names. (We ignore any typmod info
1241  * generated by the parser, however.)
1242  *
1243  * We also accept a numeric OID, for symmetry with the output routine,
1244  * and for possible use in bootstrap mode.
1245  *
1246  * '-' signifies unknown (OID 0). In all other cases, the input must
1247  * match an existing pg_type entry.
1248  */
1249 Datum
1251 {
1252  char *typ_name_or_oid = PG_GETARG_CSTRING(0);
1253  Oid result = InvalidOid;
1254  int32 typmod;
1255 
1256  /* '-' ? */
1257  if (strcmp(typ_name_or_oid, "-") == 0)
1259 
1260  /* Numeric OID? */
1261  if (typ_name_or_oid[0] >= '0' &&
1262  typ_name_or_oid[0] <= '9' &&
1263  strspn(typ_name_or_oid, "0123456789") == strlen(typ_name_or_oid))
1264  {
1266  CStringGetDatum(typ_name_or_oid)));
1267  PG_RETURN_OID(result);
1268  }
1269 
1270  /* Else it's a type name, possibly schema-qualified or decorated */
1271 
1272  /* The rest of this wouldn't work in bootstrap mode */
1274  elog(ERROR, "regtype values must be OIDs in bootstrap mode");
1275 
1276  /*
1277  * Normal case: invoke the full parser to deal with special cases such as
1278  * array syntax.
1279  */
1280  parseTypeString(typ_name_or_oid, &result, &typmod, false);
1281 
1282  PG_RETURN_OID(result);
1283 }
1284 
1285 /*
1286  * to_regtype - converts "typename" to type OID
1287  *
1288  * If the name is not found, we return NULL.
1289  */
1290 Datum
1292 {
1293  char *typ_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
1294  Oid result;
1295  int32 typmod;
1296 
1297  /*
1298  * Invoke the full parser to deal with special cases such as array syntax.
1299  */
1300  parseTypeString(typ_name, &result, &typmod, true);
1301 
1302  if (OidIsValid(result))
1303  PG_RETURN_OID(result);
1304  else
1305  PG_RETURN_NULL();
1306 }
1307 
1308 /*
1309  * regtypeout - converts type OID to "typ_name"
1310  */
1311 Datum
1313 {
1314  Oid typid = PG_GETARG_OID(0);
1315  char *result;
1316  HeapTuple typetup;
1317 
1318  if (typid == InvalidOid)
1319  {
1320  result = pstrdup("-");
1321  PG_RETURN_CSTRING(result);
1322  }
1323 
1324  typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
1325 
1326  if (HeapTupleIsValid(typetup))
1327  {
1328  Form_pg_type typeform = (Form_pg_type) GETSTRUCT(typetup);
1329 
1330  /*
1331  * In bootstrap mode, skip the fancy namespace stuff and just return
1332  * the type name. (This path is only needed for debugging output
1333  * anyway.)
1334  */
1336  {
1337  char *typname = NameStr(typeform->typname);
1338 
1339  result = pstrdup(typname);
1340  }
1341  else
1342  result = format_type_be(typid);
1343 
1344  ReleaseSysCache(typetup);
1345  }
1346  else
1347  {
1348  /* If OID doesn't match any pg_type entry, return it numerically */
1349  result = (char *) palloc(NAMEDATALEN);
1350  snprintf(result, NAMEDATALEN, "%u", typid);
1351  }
1352 
1353  PG_RETURN_CSTRING(result);
1354 }
1355 
1356 /*
1357  * regtyperecv - converts external binary format to regtype
1358  */
1359 Datum
1361 {
1362  /* Exactly the same as oidrecv, so share code */
1363  return oidrecv(fcinfo);
1364 }
1365 
1366 /*
1367  * regtypesend - converts regtype to binary format
1368  */
1369 Datum
1371 {
1372  /* Exactly the same as oidsend, so share code */
1373  return oidsend(fcinfo);
1374 }
1375 
1376 
1377 /*
1378  * regconfigin - converts "tsconfigname" to tsconfig OID
1379  *
1380  * We also accept a numeric OID, for symmetry with the output routine.
1381  *
1382  * '-' signifies unknown (OID 0). In all other cases, the input must
1383  * match an existing pg_ts_config entry.
1384  */
1385 Datum
1387 {
1388  char *cfg_name_or_oid = PG_GETARG_CSTRING(0);
1389  Oid result;
1390  List *names;
1391 
1392  /* '-' ? */
1393  if (strcmp(cfg_name_or_oid, "-") == 0)
1395 
1396  /* Numeric OID? */
1397  if (cfg_name_or_oid[0] >= '0' &&
1398  cfg_name_or_oid[0] <= '9' &&
1399  strspn(cfg_name_or_oid, "0123456789") == strlen(cfg_name_or_oid))
1400  {
1402  CStringGetDatum(cfg_name_or_oid)));
1403  PG_RETURN_OID(result);
1404  }
1405 
1406  /* The rest of this wouldn't work in bootstrap mode */
1408  elog(ERROR, "regconfig values must be OIDs in bootstrap mode");
1409 
1410  /*
1411  * Normal case: parse the name into components and see if it matches any
1412  * pg_ts_config entries in the current search path.
1413  */
1414  names = stringToQualifiedNameList(cfg_name_or_oid);
1415 
1416  result = get_ts_config_oid(names, false);
1417 
1418  PG_RETURN_OID(result);
1419 }
1420 
1421 /*
1422  * regconfigout - converts tsconfig OID to "tsconfigname"
1423  */
1424 Datum
1426 {
1427  Oid cfgid = PG_GETARG_OID(0);
1428  char *result;
1429  HeapTuple cfgtup;
1430 
1431  if (cfgid == InvalidOid)
1432  {
1433  result = pstrdup("-");
1434  PG_RETURN_CSTRING(result);
1435  }
1436 
1437  cfgtup = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgid));
1438 
1439  if (HeapTupleIsValid(cfgtup))
1440  {
1441  Form_pg_ts_config cfgform = (Form_pg_ts_config) GETSTRUCT(cfgtup);
1442  char *cfgname = NameStr(cfgform->cfgname);
1443  char *nspname;
1444 
1445  /*
1446  * Would this config be found by regconfigin? If not, qualify it.
1447  */
1448  if (TSConfigIsVisible(cfgid))
1449  nspname = NULL;
1450  else
1451  nspname = get_namespace_name(cfgform->cfgnamespace);
1452 
1453  result = quote_qualified_identifier(nspname, cfgname);
1454 
1455  ReleaseSysCache(cfgtup);
1456  }
1457  else
1458  {
1459  /* If OID doesn't match any pg_ts_config row, return it numerically */
1460  result = (char *) palloc(NAMEDATALEN);
1461  snprintf(result, NAMEDATALEN, "%u", cfgid);
1462  }
1463 
1464  PG_RETURN_CSTRING(result);
1465 }
1466 
1467 /*
1468  * regconfigrecv - converts external binary format to regconfig
1469  */
1470 Datum
1472 {
1473  /* Exactly the same as oidrecv, so share code */
1474  return oidrecv(fcinfo);
1475 }
1476 
1477 /*
1478  * regconfigsend - converts regconfig to binary format
1479  */
1480 Datum
1482 {
1483  /* Exactly the same as oidsend, so share code */
1484  return oidsend(fcinfo);
1485 }
1486 
1487 
1488 /*
1489  * regdictionaryin - converts "tsdictionaryname" to tsdictionary OID
1490  *
1491  * We also accept a numeric OID, for symmetry with the output routine.
1492  *
1493  * '-' signifies unknown (OID 0). In all other cases, the input must
1494  * match an existing pg_ts_dict entry.
1495  */
1496 Datum
1498 {
1499  char *dict_name_or_oid = PG_GETARG_CSTRING(0);
1500  Oid result;
1501  List *names;
1502 
1503  /* '-' ? */
1504  if (strcmp(dict_name_or_oid, "-") == 0)
1506 
1507  /* Numeric OID? */
1508  if (dict_name_or_oid[0] >= '0' &&
1509  dict_name_or_oid[0] <= '9' &&
1510  strspn(dict_name_or_oid, "0123456789") == strlen(dict_name_or_oid))
1511  {
1513  CStringGetDatum(dict_name_or_oid)));
1514  PG_RETURN_OID(result);
1515  }
1516 
1517  /* The rest of this wouldn't work in bootstrap mode */
1519  elog(ERROR, "regdictionary values must be OIDs in bootstrap mode");
1520 
1521  /*
1522  * Normal case: parse the name into components and see if it matches any
1523  * pg_ts_dict entries in the current search path.
1524  */
1525  names = stringToQualifiedNameList(dict_name_or_oid);
1526 
1527  result = get_ts_dict_oid(names, false);
1528 
1529  PG_RETURN_OID(result);
1530 }
1531 
1532 /*
1533  * regdictionaryout - converts tsdictionary OID to "tsdictionaryname"
1534  */
1535 Datum
1537 {
1538  Oid dictid = PG_GETARG_OID(0);
1539  char *result;
1540  HeapTuple dicttup;
1541 
1542  if (dictid == InvalidOid)
1543  {
1544  result = pstrdup("-");
1545  PG_RETURN_CSTRING(result);
1546  }
1547 
1548  dicttup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictid));
1549 
1550  if (HeapTupleIsValid(dicttup))
1551  {
1552  Form_pg_ts_dict dictform = (Form_pg_ts_dict) GETSTRUCT(dicttup);
1553  char *dictname = NameStr(dictform->dictname);
1554  char *nspname;
1555 
1556  /*
1557  * Would this dictionary be found by regdictionaryin? If not, qualify
1558  * it.
1559  */
1560  if (TSDictionaryIsVisible(dictid))
1561  nspname = NULL;
1562  else
1563  nspname = get_namespace_name(dictform->dictnamespace);
1564 
1565  result = quote_qualified_identifier(nspname, dictname);
1566 
1567  ReleaseSysCache(dicttup);
1568  }
1569  else
1570  {
1571  /* If OID doesn't match any pg_ts_dict row, return it numerically */
1572  result = (char *) palloc(NAMEDATALEN);
1573  snprintf(result, NAMEDATALEN, "%u", dictid);
1574  }
1575 
1576  PG_RETURN_CSTRING(result);
1577 }
1578 
1579 /*
1580  * regdictionaryrecv - converts external binary format to regdictionary
1581  */
1582 Datum
1584 {
1585  /* Exactly the same as oidrecv, so share code */
1586  return oidrecv(fcinfo);
1587 }
1588 
1589 /*
1590  * regdictionarysend - converts regdictionary to binary format
1591  */
1592 Datum
1594 {
1595  /* Exactly the same as oidsend, so share code */
1596  return oidsend(fcinfo);
1597 }
1598 
1599 /*
1600  * regrolein - converts "rolename" to role OID
1601  *
1602  * We also accept a numeric OID, for symmetry with the output routine.
1603  *
1604  * '-' signifies unknown (OID 0). In all other cases, the input must
1605  * match an existing pg_authid entry.
1606  */
1607 Datum
1609 {
1610  char *role_name_or_oid = PG_GETARG_CSTRING(0);
1611  Oid result;
1612  List *names;
1613 
1614  /* '-' ? */
1615  if (strcmp(role_name_or_oid, "-") == 0)
1617 
1618  /* Numeric OID? */
1619  if (role_name_or_oid[0] >= '0' &&
1620  role_name_or_oid[0] <= '9' &&
1621  strspn(role_name_or_oid, "0123456789") == strlen(role_name_or_oid))
1622  {
1624  CStringGetDatum(role_name_or_oid)));
1625  PG_RETURN_OID(result);
1626  }
1627 
1628  /* The rest of this wouldn't work in bootstrap mode */
1630  elog(ERROR, "regrole values must be OIDs in bootstrap mode");
1631 
1632  /* Normal case: see if the name matches any pg_authid entry. */
1633  names = stringToQualifiedNameList(role_name_or_oid);
1634 
1635  if (list_length(names) != 1)
1636  ereport(ERROR,
1637  (errcode(ERRCODE_INVALID_NAME),
1638  errmsg("invalid name syntax")));
1639 
1640  result = get_role_oid(strVal(linitial(names)), false);
1641 
1642  PG_RETURN_OID(result);
1643 }
1644 
1645 /*
1646  * to_regrole - converts "rolename" to role OID
1647  *
1648  * If the name is not found, we return NULL.
1649  */
1650 Datum
1652 {
1653  char *role_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
1654  Oid result;
1655  List *names;
1656 
1657  names = stringToQualifiedNameList(role_name);
1658 
1659  if (list_length(names) != 1)
1660  ereport(ERROR,
1661  (errcode(ERRCODE_INVALID_NAME),
1662  errmsg("invalid name syntax")));
1663 
1664  result = get_role_oid(strVal(linitial(names)), true);
1665 
1666  if (OidIsValid(result))
1667  PG_RETURN_OID(result);
1668  else
1669  PG_RETURN_NULL();
1670 }
1671 
1672 /*
1673  * regroleout - converts role OID to "role_name"
1674  */
1675 Datum
1677 {
1678  Oid roleoid = PG_GETARG_OID(0);
1679  char *result;
1680 
1681  if (roleoid == InvalidOid)
1682  {
1683  result = pstrdup("-");
1684  PG_RETURN_CSTRING(result);
1685  }
1686 
1687  result = GetUserNameFromId(roleoid, true);
1688 
1689  if (result)
1690  {
1691  /* pstrdup is not really necessary, but it avoids a compiler warning */
1692  result = pstrdup(quote_identifier(result));
1693  }
1694  else
1695  {
1696  /* If OID doesn't match any role, return it numerically */
1697  result = (char *) palloc(NAMEDATALEN);
1698  snprintf(result, NAMEDATALEN, "%u", roleoid);
1699  }
1700 
1701  PG_RETURN_CSTRING(result);
1702 }
1703 
1704 /*
1705  * regrolerecv - converts external binary format to regrole
1706  */
1707 Datum
1709 {
1710  /* Exactly the same as oidrecv, so share code */
1711  return oidrecv(fcinfo);
1712 }
1713 
1714 /*
1715  * regrolesend - converts regrole to binary format
1716  */
1717 Datum
1719 {
1720  /* Exactly the same as oidsend, so share code */
1721  return oidsend(fcinfo);
1722 }
1723 
1724 /*
1725  * regnamespacein - converts "nspname" to namespace OID
1726  *
1727  * We also accept a numeric OID, for symmetry with the output routine.
1728  *
1729  * '-' signifies unknown (OID 0). In all other cases, the input must
1730  * match an existing pg_namespace entry.
1731  */
1732 Datum
1734 {
1735  char *nsp_name_or_oid = PG_GETARG_CSTRING(0);
1736  Oid result;
1737  List *names;
1738 
1739  /* '-' ? */
1740  if (strcmp(nsp_name_or_oid, "-") == 0)
1742 
1743  /* Numeric OID? */
1744  if (nsp_name_or_oid[0] >= '0' &&
1745  nsp_name_or_oid[0] <= '9' &&
1746  strspn(nsp_name_or_oid, "0123456789") == strlen(nsp_name_or_oid))
1747  {
1749  CStringGetDatum(nsp_name_or_oid)));
1750  PG_RETURN_OID(result);
1751  }
1752 
1753  /* The rest of this wouldn't work in bootstrap mode */
1755  elog(ERROR, "regnamespace values must be OIDs in bootstrap mode");
1756 
1757  /* Normal case: see if the name matches any pg_namespace entry. */
1758  names = stringToQualifiedNameList(nsp_name_or_oid);
1759 
1760  if (list_length(names) != 1)
1761  ereport(ERROR,
1762  (errcode(ERRCODE_INVALID_NAME),
1763  errmsg("invalid name syntax")));
1764 
1765  result = get_namespace_oid(strVal(linitial(names)), false);
1766 
1767  PG_RETURN_OID(result);
1768 }
1769 
1770 /*
1771  * to_regnamespace - converts "nspname" to namespace OID
1772  *
1773  * If the name is not found, we return NULL.
1774  */
1775 Datum
1777 {
1778  char *nsp_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
1779  Oid result;
1780  List *names;
1781 
1782  names = stringToQualifiedNameList(nsp_name);
1783 
1784  if (list_length(names) != 1)
1785  ereport(ERROR,
1786  (errcode(ERRCODE_INVALID_NAME),
1787  errmsg("invalid name syntax")));
1788 
1789  result = get_namespace_oid(strVal(linitial(names)), true);
1790 
1791  if (OidIsValid(result))
1792  PG_RETURN_OID(result);
1793  else
1794  PG_RETURN_NULL();
1795 }
1796 
1797 /*
1798  * regnamespaceout - converts namespace OID to "nsp_name"
1799  */
1800 Datum
1802 {
1803  Oid nspid = PG_GETARG_OID(0);
1804  char *result;
1805 
1806  if (nspid == InvalidOid)
1807  {
1808  result = pstrdup("-");
1809  PG_RETURN_CSTRING(result);
1810  }
1811 
1812  result = get_namespace_name(nspid);
1813 
1814  if (result)
1815  {
1816  /* pstrdup is not really necessary, but it avoids a compiler warning */
1817  result = pstrdup(quote_identifier(result));
1818  }
1819  else
1820  {
1821  /* If OID doesn't match any namespace, return it numerically */
1822  result = (char *) palloc(NAMEDATALEN);
1823  snprintf(result, NAMEDATALEN, "%u", nspid);
1824  }
1825 
1826  PG_RETURN_CSTRING(result);
1827 }
1828 
1829 /*
1830  * regnamespacerecv - converts external binary format to regnamespace
1831  */
1832 Datum
1834 {
1835  /* Exactly the same as oidrecv, so share code */
1836  return oidrecv(fcinfo);
1837 }
1838 
1839 /*
1840  * regnamespacesend - converts regnamespace to binary format
1841  */
1842 Datum
1844 {
1845  /* Exactly the same as oidsend, so share code */
1846  return oidsend(fcinfo);
1847 }
1848 
1849 /*
1850  * text_regclass: convert text to regclass
1851  *
1852  * This could be replaced by CoerceViaIO, except that we need to treat
1853  * text-to-regclass as an implicit cast to support legacy forms of nextval()
1854  * and related functions.
1855  */
1856 Datum
1858 {
1860  Oid result;
1861  RangeVar *rv;
1862 
1864 
1865  /* We might not even have permissions on this relation; don't lock it. */
1866  result = RangeVarGetRelid(rv, NoLock, false);
1867 
1868  PG_RETURN_OID(result);
1869 }
1870 
1871 
1872 /*
1873  * Given a C string, parse it into a qualified-name list.
1874  */
1875 List *
1876 stringToQualifiedNameList(const char *string)
1877 {
1878  char *rawname;
1879  List *result = NIL;
1880  List *namelist;
1881  ListCell *l;
1882 
1883  /* We need a modifiable copy of the input string. */
1884  rawname = pstrdup(string);
1885 
1886  if (!SplitIdentifierString(rawname, '.', &namelist))
1887  ereport(ERROR,
1888  (errcode(ERRCODE_INVALID_NAME),
1889  errmsg("invalid name syntax")));
1890 
1891  if (namelist == NIL)
1892  ereport(ERROR,
1893  (errcode(ERRCODE_INVALID_NAME),
1894  errmsg("invalid name syntax")));
1895 
1896  foreach(l, namelist)
1897  {
1898  char *curname = (char *) lfirst(l);
1899 
1900  result = lappend(result, makeString(pstrdup(curname)));
1901  }
1902 
1903  pfree(rawname);
1904  list_free(namelist);
1905 
1906  return result;
1907 }
1908 
1909 /*****************************************************************************
1910  * SUPPORT ROUTINES *
1911  *****************************************************************************/
1912 
1913 /*
1914  * Given a C string, parse it into a qualified function or operator name
1915  * followed by a parenthesized list of type names. Reduce the
1916  * type names to an array of OIDs (returned into *nargs and *argtypes;
1917  * the argtypes array should be of size FUNC_MAX_ARGS). The function or
1918  * operator name is returned to *names as a List of Strings.
1919  *
1920  * If allowNone is true, accept "NONE" and return it as InvalidOid (this is
1921  * for unary operators).
1922  */
1923 static void
1924 parseNameAndArgTypes(const char *string, bool allowNone, List **names,
1925  int *nargs, Oid *argtypes)
1926 {
1927  char *rawname;
1928  char *ptr;
1929  char *ptr2;
1930  char *typename;
1931  bool in_quote;
1932  bool had_comma;
1933  int paren_count;
1934  Oid typeid;
1935  int32 typmod;
1936 
1937  /* We need a modifiable copy of the input string. */
1938  rawname = pstrdup(string);
1939 
1940  /* Scan to find the expected left paren; mustn't be quoted */
1941  in_quote = false;
1942  for (ptr = rawname; *ptr; ptr++)
1943  {
1944  if (*ptr == '"')
1945  in_quote = !in_quote;
1946  else if (*ptr == '(' && !in_quote)
1947  break;
1948  }
1949  if (*ptr == '\0')
1950  ereport(ERROR,
1951  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1952  errmsg("expected a left parenthesis")));
1953 
1954  /* Separate the name and parse it into a list */
1955  *ptr++ = '\0';
1956  *names = stringToQualifiedNameList(rawname);
1957 
1958  /* Check for the trailing right parenthesis and remove it */
1959  ptr2 = ptr + strlen(ptr);
1960  while (--ptr2 > ptr)
1961  {
1962  if (!scanner_isspace(*ptr2))
1963  break;
1964  }
1965  if (*ptr2 != ')')
1966  ereport(ERROR,
1967  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1968  errmsg("expected a right parenthesis")));
1969 
1970  *ptr2 = '\0';
1971 
1972  /* Separate the remaining string into comma-separated type names */
1973  *nargs = 0;
1974  had_comma = false;
1975 
1976  for (;;)
1977  {
1978  /* allow leading whitespace */
1979  while (scanner_isspace(*ptr))
1980  ptr++;
1981  if (*ptr == '\0')
1982  {
1983  /* End of string. Okay unless we had a comma before. */
1984  if (had_comma)
1985  ereport(ERROR,
1986  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1987  errmsg("expected a type name")));
1988  break;
1989  }
1990  typename = ptr;
1991  /* Find end of type name --- end of string or comma */
1992  /* ... but not a quoted or parenthesized comma */
1993  in_quote = false;
1994  paren_count = 0;
1995  for (; *ptr; ptr++)
1996  {
1997  if (*ptr == '"')
1998  in_quote = !in_quote;
1999  else if (*ptr == ',' && !in_quote && paren_count == 0)
2000  break;
2001  else if (!in_quote)
2002  {
2003  switch (*ptr)
2004  {
2005  case '(':
2006  case '[':
2007  paren_count++;
2008  break;
2009  case ')':
2010  case ']':
2011  paren_count--;
2012  break;
2013  }
2014  }
2015  }
2016  if (in_quote || paren_count != 0)
2017  ereport(ERROR,
2018  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
2019  errmsg("improper type name")));
2020 
2021  ptr2 = ptr;
2022  if (*ptr == ',')
2023  {
2024  had_comma = true;
2025  *ptr++ = '\0';
2026  }
2027  else
2028  {
2029  had_comma = false;
2030  Assert(*ptr == '\0');
2031  }
2032  /* Lop off trailing whitespace */
2033  while (--ptr2 >= typename)
2034  {
2035  if (!scanner_isspace(*ptr2))
2036  break;
2037  *ptr2 = '\0';
2038  }
2039 
2040  if (allowNone && pg_strcasecmp(typename, "none") == 0)
2041  {
2042  /* Special case for NONE */
2043  typeid = InvalidOid;
2044  typmod = -1;
2045  }
2046  else
2047  {
2048  /* Use full parser to resolve the type name */
2049  parseTypeString(typename, &typeid, &typmod, false);
2050  }
2051  if (*nargs >= FUNC_MAX_ARGS)
2052  ereport(ERROR,
2053  (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2054  errmsg("too many arguments")));
2055 
2056  argtypes[*nargs] = typeid;
2057  (*nargs)++;
2058  }
2059 
2060  pfree(rawname);
2061 }
#define list_make2(x1, x2)
Definition: pg_list.h:208
Value * makeString(char *str)
Definition: value.c:53
#define NIL
Definition: pg_list.h:65
Datum regoperatorrecv(PG_FUNCTION_ARGS)
Definition: regproc.c:914
Datum regnamespaceout(PG_FUNCTION_ARGS)
Definition: regproc.c:1801
Datum regoperatorin(PG_FUNCTION_ARGS)
Definition: regproc.c:673
Datum regconfigsend(PG_FUNCTION_ARGS)
Definition: regproc.c:1481
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3042
int errhint(const char *fmt,...)
Definition: elog.c:1071
NameData proname
Definition: pg_proc.h:35
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Datum regclassin(PG_FUNCTION_ARGS)
Definition: regproc.c:940
Datum regcollationin(PG_FUNCTION_ARGS)
Definition: regproc.c:1092
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:10709
FormData_pg_ts_config * Form_pg_ts_config
Definition: pg_ts_config.h:48
Oid oprid(Operator op)
Definition: parse_oper.c:250
uint16 bits16
Definition: c.h:382
Datum regroleout(PG_FUNCTION_ARGS)
Definition: regproc.c:1676
Datum regrolesend(PG_FUNCTION_ARGS)
Definition: regproc.c:1718
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Definition: namespace.h:78
Datum regoperout(PG_FUNCTION_ARGS)
Definition: regproc.c:579
Datum regdictionaryout(PG_FUNCTION_ARGS)
Definition: regproc.c:1536
#define DatumGetObjectId(X)
Definition: postgres.h:500
char * pstrdup(const char *in)
Definition: mcxt.c:1187
Datum to_regrole(PG_FUNCTION_ARGS)
Definition: regproc.c:1651
regproc RegProcedure
Definition: c.h:518
Datum to_regcollation(PG_FUNCTION_ARGS)
Definition: regproc.c:1135
Datum regoperin(PG_FUNCTION_ARGS)
Definition: regproc.c:501
#define strVal(v)
Definition: value.h:54
int errcode(int sqlerrcode)
Definition: elog.c:610
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2678
Datum regrolerecv(PG_FUNCTION_ARGS)
Definition: regproc.c:1708
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1746
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
char * format_operator(Oid operator_oid)
Definition: regproc.c:851
Datum to_regoper(PG_FUNCTION_ARGS)
Definition: regproc.c:556
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1413
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3061
Datum regtypeout(PG_FUNCTION_ARGS)
Definition: regproc.c:1312
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:624
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
NameData relname
Definition: pg_class.h:38
unsigned int Oid
Definition: postgres_ext.h:31
Datum regopersend(PG_FUNCTION_ARGS)
Definition: regproc.c:657
#define OidIsValid(objectId)
Definition: c.h:651
Datum regtyperecv(PG_FUNCTION_ARGS)
Definition: regproc.c:1360
Datum regprocin(PG_FUNCTION_ARGS)
Definition: regproc.c:61
char * format_operator_extended(Oid operator_oid, bits16 flags)
Definition: regproc.c:780
signed int int32
Definition: c.h:362
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1586
Datum oidsend(PG_FUNCTION_ARGS)
Definition: oid.c:151
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:308
Oid get_role_oid(const char *rolname, bool missing_ok)
Definition: acl.c:5175
Datum regconfigout(PG_FUNCTION_ARGS)
Definition: regproc.c:1425
#define FUNC_MAX_ARGS
#define list_make1(x1)
Definition: pg_list.h:206
#define NAMEDATALEN
Datum text_regclass(PG_FUNCTION_ARGS)
Definition: regproc.c:1857
Datum regprocedureout(PG_FUNCTION_ARGS)
Definition: regproc.c:458
Datum oidrecv(PG_FUNCTION_ARGS)
Definition: oid.c:140
#define sprintf
Definition: port.h:195
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1483
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2425
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:37
void pfree(void *pointer)
Definition: mcxt.c:1057
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
#define linitial(l)
Definition: pg_list.h:174
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
Datum regprocedurein(PG_FUNCTION_ARGS)
Definition: regproc.c:230
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2736
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool missing_ok)
Definition: namespace.c:942
Datum regproceduresend(PG_FUNCTION_ARGS)
Definition: regproc.c:485
char * format_operator_qualified(Oid operator_oid)
Definition: regproc.c:857
Datum to_regprocedure(PG_FUNCTION_ARGS)
Definition: regproc.c:289
Datum regprocout(PG_FUNCTION_ARGS)
Definition: regproc.c:142
FormData_pg_ts_dict * Form_pg_ts_dict
Definition: pg_ts_dict.h:52
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
Datum regtypesend(PG_FUNCTION_ARGS)
Definition: regproc.c:1370
Datum to_regproc(PG_FUNCTION_ARGS)
Definition: regproc.c:119
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3191
#define NoLock
Definition: lockdefs.h:34
static char * buf
Definition: pg_test_fsync.c:68
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3702
Datum regclasssend(PG_FUNCTION_ARGS)
Definition: regproc.c:1076
#define CStringGetDatum(X)
Definition: postgres.h:578
Datum regrolein(PG_FUNCTION_ARGS)
Definition: regproc.c:1608
Datum regprocrecv(PG_FUNCTION_ARGS)
Definition: regproc.c:204
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2047
Datum regdictionarysend(PG_FUNCTION_ARGS)
Definition: regproc.c:1593
Datum regprocsend(PG_FUNCTION_ARGS)
Definition: regproc.c:214
struct _FuncCandidateList * next
Definition: namespace.h:30
char * format_procedure_qualified(Oid procedure_oid)
Definition: regproc.c:328
Datum to_regtype(PG_FUNCTION_ARGS)
Definition: regproc.c:1291
List * textToQualifiedNameList(text *textval)
Definition: varlena.c:3644
List * lappend(List *list, void *datum)
Definition: list.c:321
NameData typname
Definition: pg_type.h:41
Datum regcollationout(PG_FUNCTION_ARGS)
Definition: regproc.c:1160
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:188
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2483
char * quote_qualified_identifier(const char *qualifier, const char *ident)
Definition: ruleutils.c:10793
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
Datum regtypein(PG_FUNCTION_ARGS)
Definition: regproc.c:1250
#define FORMAT_OPERATOR_INVALID_AS_NULL
Definition: regproc.h:24
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
char * format_procedure_extended(Oid procedure_oid, bits16 flags)
Definition: regproc.c:349
bool scanner_isspace(char ch)
Definition: scansup.c:210
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
void parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok)
Definition: parse_type.c:832
void format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs, bool missing_ok)
Definition: regproc.c:421
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:144
char * format_procedure(Oid procedure_oid)
Definition: regproc.c:322
#define FORMAT_PROC_INVALID_AS_NULL
Definition: regproc.h:19
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
char * GetUserNameFromId(Oid roleid, bool noerr)
Definition: miscinit.c:891
#define Assert(condition)
Definition: c.h:745
#define lfirst(lc)
Definition: pg_list.h:169
static void parseNameAndArgTypes(const char *string, bool allowNone, List **names, int *nargs, Oid *argtypes)
Definition: regproc.c:1924
Datum regclassout(PG_FUNCTION_ARGS)
Definition: regproc.c:1009
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:349
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:361
const char * class_name
Definition: selinux.c:32
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
static int list_length(const List *l)
Definition: pg_list.h:149
Datum regnamespacesend(PG_FUNCTION_ARGS)
Definition: regproc.c:1843
Datum to_regnamespace(PG_FUNCTION_ARGS)
Definition: regproc.c:1776
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83
Datum regprocedurerecv(PG_FUNCTION_ARGS)
Definition: regproc.c:475
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:393
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
char * text_to_cstring(const text *t)
Definition: varlena.c:221
#define FORMAT_PROC_FORCE_QUALIFY
Definition: regproc.h:20
List * stringToQualifiedNameList(const char *string)
Definition: regproc.c:1876
Datum regdictionaryin(PG_FUNCTION_ARGS)
Definition: regproc.c:1497
Datum regnamespacerecv(PG_FUNCTION_ARGS)
Definition: regproc.c:1833
void format_operator_parts(Oid operator_oid, List **objnames, List **objargs, bool missing_ok)
Definition: regproc.c:864
void * palloc(Size size)
Definition: mcxt.c:950
int errmsg(const char *fmt,...)
Definition: elog.c:824
bool RelationIsVisible(Oid relid)
Definition: namespace.c:708
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3215
void list_free(List *list)
Definition: list.c:1376
#define elog(elevel,...)
Definition: elog.h:214
Datum regoperatorout(PG_FUNCTION_ARGS)
Definition: regproc.c:897
int i
#define NameStr(name)
Definition: c.h:622
Datum to_regoperator(PG_FUNCTION_ARGS)
Definition: regproc.c:733
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:277
Definition: c.h:562
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
Datum oidin(PG_FUNCTION_ARGS)
Definition: oid.c:117
Datum regconfigrecv(PG_FUNCTION_ARGS)
Definition: regproc.c:1471
Datum regdictionaryrecv(PG_FUNCTION_ARGS)
Definition: regproc.c:1583
Datum regoperrecv(PG_FUNCTION_ARGS)
Definition: regproc.c:647
Datum regnamespacein(PG_FUNCTION_ARGS)
Definition: regproc.c:1733
Datum regconfigin(PG_FUNCTION_ARGS)
Definition: regproc.c:1386
Datum regcollationsend(PG_FUNCTION_ARGS)
Definition: regproc.c:1228
Oid get_collation_oid(List *name, bool missing_ok)
Definition: namespace.c:3600
Definition: pg_list.h:50
#define PG_RETURN_OID(x)
Definition: fmgr.h:359
#define snprintf
Definition: port.h:193
Datum regoperatorsend(PG_FUNCTION_ARGS)
Definition: regproc.c:924
#define PG_RETURN_NULL()
Definition: fmgr.h:344
#define FORMAT_OPERATOR_FORCE_QUALIFY
Definition: regproc.h:25
Datum to_regclass(PG_FUNCTION_ARGS)
Definition: regproc.c:984
Datum regcollationrecv(PG_FUNCTION_ARGS)
Definition: regproc.c:1218
Datum regclassrecv(PG_FUNCTION_ARGS)
Definition: regproc.c:1066