PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

char* format_operator ( Oid  operator_oid)

Definition at line 904 of file regproc.c.

References format_operator_internal().

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

905 {
906  return format_operator_internal(operator_oid, false);
907 }
static char * format_operator_internal(Oid operator_oid, bool force_qualify)
Definition: regproc.c:840
void format_operator_parts ( Oid  operator_oid,
List **  objnames,
List **  objargs 
)

Definition at line 916 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().

917 {
918  HeapTuple opertup;
919  Form_pg_operator oprForm;
920 
921  opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operator_oid));
922  if (!HeapTupleIsValid(opertup))
923  elog(ERROR, "cache lookup failed for operator with OID %u",
924  operator_oid);
925 
926  oprForm = (Form_pg_operator) GETSTRUCT(opertup);
927  *objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
928  pstrdup(NameStr(oprForm->oprname)));
929  *objargs = NIL;
930  if (oprForm->oprleft)
931  *objargs = lappend(*objargs,
932  format_type_be_qualified(oprForm->oprleft));
933  if (oprForm->oprright)
934  *objargs = lappend(*objargs,
935  format_type_be_qualified(oprForm->oprright));
936 
937  ReleaseSysCache(opertup);
938 }
#define list_make2(x1, x2)
Definition: pg_list.h:134
#define NIL
Definition: pg_list.h:69
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1165
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
List * lappend(List *list, void *datum)
Definition: list.c:128
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:104
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3030
#define NameStr(name)
Definition: c.h:495
#define elog
Definition: elog.h:219
char* format_operator_qualified ( Oid  operator_oid)

Definition at line 910 of file regproc.c.

References format_operator_internal().

Referenced by getObjectIdentityParts().

911 {
912  return format_operator_internal(operator_oid, true);
913 }
static char * format_operator_internal(Oid operator_oid, bool force_qualify)
Definition: regproc.c:840
char* format_procedure ( Oid  procedure_oid)

Definition at line 367 of file regproc.c.

References format_procedure_internal().

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

368 {
369  return format_procedure_internal(procedure_oid, false);
370 }
static char * format_procedure_internal(Oid procedure_oid, bool force_qualify)
Definition: regproc.c:386
void format_procedure_parts ( Oid  operator_oid,
List **  objnames,
List **  objargs 
)

Definition at line 451 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().

452 {
453  HeapTuple proctup;
454  Form_pg_proc procform;
455  int nargs;
456  int i;
457 
458  proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procedure_oid));
459 
460  if (!HeapTupleIsValid(proctup))
461  elog(ERROR, "cache lookup failed for procedure with OID %u", procedure_oid);
462 
463  procform = (Form_pg_proc) GETSTRUCT(proctup);
464  nargs = procform->pronargs;
465 
466  *objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
467  pstrdup(NameStr(procform->proname)));
468  *objargs = NIL;
469  for (i = 0; i < nargs; i++)
470  {
471  Oid thisargtype = procform->proargtypes.values[i];
472 
473  *objargs = lappend(*objargs, format_type_be_qualified(thisargtype));
474  }
475 
476  ReleaseSysCache(proctup);
477 }
#define list_make2(x1, x2)
Definition: pg_list.h:134
#define NIL
Definition: pg_list.h:69
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1165
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
List * lappend(List *list, void *datum)
Definition: list.c:128
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:104
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3030
int i
#define NameStr(name)
Definition: c.h:495
#define elog
Definition: elog.h:219
char* format_procedure_qualified ( Oid  procedure_oid)

Definition at line 373 of file regproc.c.

References format_procedure_internal().

Referenced by getObjectIdentityParts().

374 {
375  return format_procedure_internal(procedure_oid, true);
376 }
static char * format_procedure_internal(Oid procedure_oid, bool force_qualify)
Definition: regproc.c:386
List* stringToQualifiedNameList ( const char *  string)

Definition at line 1830 of file regproc.c.

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

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

1831 {
1832  char *rawname;
1833  List *result = NIL;
1834  List *namelist;
1835  ListCell *l;
1836 
1837  /* We need a modifiable copy of the input string. */
1838  rawname = pstrdup(string);
1839 
1840  if (!SplitIdentifierString(rawname, '.', &namelist))
1841  ereport(ERROR,
1842  (errcode(ERRCODE_INVALID_NAME),
1843  errmsg("invalid name syntax")));
1844 
1845  if (namelist == NIL)
1846  ereport(ERROR,
1847  (errcode(ERRCODE_INVALID_NAME),
1848  errmsg("invalid name syntax")));
1849 
1850  foreach(l, namelist)
1851  {
1852  char *curname = (char *) lfirst(l);
1853 
1854  result = lappend(result, makeString(pstrdup(curname)));
1855  }
1856 
1857  pfree(rawname);
1858  list_free(namelist);
1859 
1860  return result;
1861 }
Value * makeString(char *str)
Definition: value.c:53
#define NIL
Definition: pg_list.h:69
char * pstrdup(const char *in)
Definition: mcxt.c:1165
int errcode(int sqlerrcode)
Definition: elog.c:575
void pfree(void *pointer)
Definition: mcxt.c:992
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3129
#define ereport(elevel, rest)
Definition: elog.h:122
List * lappend(List *list, void *datum)
Definition: list.c:128
#define lfirst(lc)
Definition: pg_list.h:106
int errmsg(const char *fmt,...)
Definition: elog.c:797
void list_free(List *list)
Definition: list.c:1133
Definition: pg_list.h:45