PostgreSQL Source Code  git master
regproc.h File Reference
#include "nodes/pg_list.h"
Include dependency graph for regproc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ListstringToQualifiedNameList (const char *string)
 
char * format_procedure (Oid procedure_oid)
 
char * format_procedure_qualified (Oid procedure_oid)
 
void format_procedure_parts (Oid operator_oid, List **objnames, List **objargs)
 
char * format_operator (Oid operator_oid)
 
char * format_operator_qualified (Oid operator_oid)
 
void format_operator_parts (Oid operator_oid, List **objnames, List **objargs)
 

Function Documentation

◆ format_operator()

char* format_operator ( Oid  operator_oid)

Definition at line 821 of file regproc.c.

References format_operator_internal().

Referenced by blvalidate(), brinvalidate(), btvalidate(), ComputeIndexAttrs(), getObjectDescription(), ginvalidate(), gistvalidate(), hashvalidate(), regoperatorout(), and spgvalidate().

822 {
823  return format_operator_internal(operator_oid, false);
824 }
static char * format_operator_internal(Oid operator_oid, bool force_qualify)
Definition: regproc.c:756

◆ format_operator_parts()

void format_operator_parts ( Oid  operator_oid,
List **  objnames,
List **  objargs 
)

Definition at line 833 of file regproc.c.

References elog, ERROR, format_type_be_qualified(), get_namespace_name_or_temp(), GETSTRUCT, HeapTupleIsValid, lappend(), list_make2, NameStr, NIL, ObjectIdGetDatum, OPEROID, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by getObjectIdentityParts().

834 {
835  HeapTuple opertup;
836  Form_pg_operator oprForm;
837 
838  opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operator_oid));
839  if (!HeapTupleIsValid(opertup))
840  elog(ERROR, "cache lookup failed for operator with OID %u",
841  operator_oid);
842 
843  oprForm = (Form_pg_operator) GETSTRUCT(opertup);
844  *objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
845  pstrdup(NameStr(oprForm->oprname)));
846  *objargs = NIL;
847  if (oprForm->oprleft)
848  *objargs = lappend(*objargs,
849  format_type_be_qualified(oprForm->oprleft));
850  if (oprForm->oprright)
851  *objargs = lappend(*objargs,
852  format_type_be_qualified(oprForm->oprright));
853 
854  ReleaseSysCache(opertup);
855 }
#define list_make2(x1, x2)
Definition: pg_list.h:229
#define NIL
Definition: pg_list.h:65
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1186
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
List * lappend(List *list, void *datum)
Definition: list.c:321
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:337
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3179
#define elog(elevel,...)
Definition: elog.h:214
#define NameStr(name)
Definition: c.h:615

◆ format_operator_qualified()

char* format_operator_qualified ( Oid  operator_oid)

Definition at line 827 of file regproc.c.

References format_operator_internal().

Referenced by getObjectIdentityParts().

828 {
829  return format_operator_internal(operator_oid, true);
830 }
static char * format_operator_internal(Oid operator_oid, bool force_qualify)
Definition: regproc.c:756

◆ format_procedure()

char* format_procedure ( Oid  procedure_oid)

Definition at line 324 of file regproc.c.

References format_procedure_internal().

Referenced by blvalidate(), brinvalidate(), btvalidate(), do_compile(), getObjectDescription(), ginvalidate(), gistvalidate(), hashvalidate(), initialize_peragg(), pg_logical_slot_get_changes_guts(), ProcedureCreate(), regprocedureout(), and spgvalidate().

325 {
326  return format_procedure_internal(procedure_oid, false);
327 }
static char * format_procedure_internal(Oid procedure_oid, bool force_qualify)
Definition: regproc.c:343

◆ format_procedure_parts()

void format_procedure_parts ( Oid  operator_oid,
List **  objnames,
List **  objargs 
)

Definition at line 409 of file regproc.c.

References elog, ERROR, format_type_be_qualified(), get_namespace_name_or_temp(), GETSTRUCT, HeapTupleIsValid, i, lappend(), list_make2, NameStr, NIL, ObjectIdGetDatum, PROCOID, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by getObjectIdentityParts().

410 {
411  HeapTuple proctup;
412  Form_pg_proc procform;
413  int nargs;
414  int i;
415 
416  proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procedure_oid));
417 
418  if (!HeapTupleIsValid(proctup))
419  elog(ERROR, "cache lookup failed for procedure with OID %u", procedure_oid);
420 
421  procform = (Form_pg_proc) GETSTRUCT(proctup);
422  nargs = procform->pronargs;
423 
424  *objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
425  pstrdup(NameStr(procform->proname)));
426  *objargs = NIL;
427  for (i = 0; i < nargs; i++)
428  {
429  Oid thisargtype = procform->proargtypes.values[i];
430 
431  *objargs = lappend(*objargs, format_type_be_qualified(thisargtype));
432  }
433 
434  ReleaseSysCache(proctup);
435 }
#define list_make2(x1, x2)
Definition: pg_list.h:229
#define NIL
Definition: pg_list.h:65
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1186
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
List * lappend(List *list, void *datum)
Definition: list.c:321
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:337
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3179
#define elog(elevel,...)
Definition: elog.h:214
int i
#define NameStr(name)
Definition: c.h:615

◆ format_procedure_qualified()

char* format_procedure_qualified ( Oid  procedure_oid)

Definition at line 330 of file regproc.c.

References format_procedure_internal().

Referenced by getObjectIdentityParts().

331 {
332  return format_procedure_internal(procedure_oid, true);
333 }
static char * format_procedure_internal(Oid procedure_oid, bool force_qualify)
Definition: regproc.c:343

◆ stringToQualifiedNameList()

List* stringToQualifiedNameList ( const char *  string)

Definition at line 1840 of file regproc.c.

References ereport, errcode(), errmsg(), ERROR, lappend(), lfirst, list_free(), makeString(), NIL, pfree(), pstrdup(), and SplitIdentifierString().

Referenced by call_pltcl_start_proc(), check_TSCurrentConfig(), getTSCurrentConfig(), parseNameAndArgTypes(), regclassin(), regcollationin(), regconfigin(), regdictionaryin(), regnamespacein(), regoperin(), regprocin(), regrolein(), RelationNameGetTupleDesc(), thesaurus_init(), to_regclass(), to_regcollation(), to_regnamespace(), to_regoper(), to_regproc(), to_regrole(), and tsvector_update_trigger().

1841 {
1842  char *rawname;
1843  List *result = NIL;
1844  List *namelist;
1845  ListCell *l;
1846 
1847  /* We need a modifiable copy of the input string. */
1848  rawname = pstrdup(string);
1849 
1850  if (!SplitIdentifierString(rawname, '.', &namelist))
1851  ereport(ERROR,
1852  (errcode(ERRCODE_INVALID_NAME),
1853  errmsg("invalid name syntax")));
1854 
1855  if (namelist == NIL)
1856  ereport(ERROR,
1857  (errcode(ERRCODE_INVALID_NAME),
1858  errmsg("invalid name syntax")));
1859 
1860  foreach(l, namelist)
1861  {
1862  char *curname = (char *) lfirst(l);
1863 
1864  result = lappend(result, makeString(pstrdup(curname)));
1865  }
1866 
1867  pfree(rawname);
1868  list_free(namelist);
1869 
1870  return result;
1871 }
Value * makeString(char *str)
Definition: value.c:53
#define NIL
Definition: pg_list.h:65
char * pstrdup(const char *in)
Definition: mcxt.c:1186
int errcode(int sqlerrcode)
Definition: elog.c:610
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3686
List * lappend(List *list, void *datum)
Definition: list.c:321
#define ereport(elevel,...)
Definition: elog.h:144
#define lfirst(lc)
Definition: pg_list.h:190
int errmsg(const char *fmt,...)
Definition: elog.c:824
void list_free(List *list)
Definition: list.c:1376
Definition: pg_list.h:50