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 820 of file regproc.c.

References format_operator_internal().

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

821 {
822  return format_operator_internal(operator_oid, false);
823 }
static char * format_operator_internal(Oid operator_oid, bool force_qualify)
Definition: regproc.c:755
void format_operator_parts ( Oid  operator_oid,
List **  objnames,
List **  objargs 
)

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

833 {
834  HeapTuple opertup;
835  Form_pg_operator oprForm;
836 
837  opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operator_oid));
838  if (!HeapTupleIsValid(opertup))
839  elog(ERROR, "cache lookup failed for operator with OID %u",
840  operator_oid);
841 
842  oprForm = (Form_pg_operator) GETSTRUCT(opertup);
843  *objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace),
844  pstrdup(NameStr(oprForm->oprname)));
845  *objargs = NIL;
846  if (oprForm->oprleft)
847  *objargs = lappend(*objargs,
848  format_type_be_qualified(oprForm->oprleft));
849  if (oprForm->oprright)
850  *objargs = lappend(*objargs,
851  format_type_be_qualified(oprForm->oprright));
852 
853  ReleaseSysCache(opertup);
854 }
#define list_make2(x1, x2)
Definition: pg_list.h:140
#define NIL
Definition: pg_list.h:69
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:156
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
List * lappend(List *list, void *datum)
Definition: list.c:128
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1117
#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:3057
#define NameStr(name)
Definition: c.h:499
#define elog
Definition: elog.h:219
char* format_operator_qualified ( Oid  operator_oid)

Definition at line 826 of file regproc.c.

References format_operator_internal().

Referenced by getObjectIdentityParts().

827 {
828  return format_operator_internal(operator_oid, true);
829 }
static char * format_operator_internal(Oid operator_oid, bool force_qualify)
Definition: regproc.c:755
char* format_procedure ( Oid  procedure_oid)

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

324 {
325  return format_procedure_internal(procedure_oid, false);
326 }
static char * format_procedure_internal(Oid procedure_oid, bool force_qualify)
Definition: regproc.c:342
void format_procedure_parts ( Oid  operator_oid,
List **  objnames,
List **  objargs 
)

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

409 {
410  HeapTuple proctup;
411  Form_pg_proc procform;
412  int nargs;
413  int i;
414 
415  proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procedure_oid));
416 
417  if (!HeapTupleIsValid(proctup))
418  elog(ERROR, "cache lookup failed for procedure with OID %u", procedure_oid);
419 
420  procform = (Form_pg_proc) GETSTRUCT(proctup);
421  nargs = procform->pronargs;
422 
423  *objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace),
424  pstrdup(NameStr(procform->proname)));
425  *objargs = NIL;
426  for (i = 0; i < nargs; i++)
427  {
428  Oid thisargtype = procform->proargtypes.values[i];
429 
430  *objargs = lappend(*objargs, format_type_be_qualified(thisargtype));
431  }
432 
433  ReleaseSysCache(proctup);
434 }
#define list_make2(x1, x2)
Definition: pg_list.h:140
#define NIL
Definition: pg_list.h:69
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:156
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
List * lappend(List *list, void *datum)
Definition: list.c:128
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1117
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:3057
int i
#define NameStr(name)
Definition: c.h:499
#define elog
Definition: elog.h:219
char* format_procedure_qualified ( Oid  procedure_oid)

Definition at line 329 of file regproc.c.

References format_procedure_internal().

Referenced by getObjectIdentityParts().

330 {
331  return format_procedure_internal(procedure_oid, true);
332 }
static char * format_procedure_internal(Oid procedure_oid, bool force_qualify)
Definition: regproc.c:342
List* stringToQualifiedNameList ( const char *  string)

Definition at line 1687 of file regproc.c.

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

Referenced by call_pltcl_start_proc(), 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().

1688 {
1689  char *rawname;
1690  List *result = NIL;
1691  List *namelist;
1692  ListCell *l;
1693 
1694  /* We need a modifiable copy of the input string. */
1695  rawname = pstrdup(string);
1696 
1697  if (!SplitIdentifierString(rawname, '.', &namelist))
1698  ereport(ERROR,
1699  (errcode(ERRCODE_INVALID_NAME),
1700  errmsg("invalid name syntax")));
1701 
1702  if (namelist == NIL)
1703  ereport(ERROR,
1704  (errcode(ERRCODE_INVALID_NAME),
1705  errmsg("invalid name syntax")));
1706 
1707  foreach(l, namelist)
1708  {
1709  char *curname = (char *) lfirst(l);
1710 
1711  result = lappend(result, makeString(pstrdup(curname)));
1712  }
1713 
1714  pfree(rawname);
1715  list_free(namelist);
1716 
1717  return result;
1718 }
Value * makeString(char *str)
Definition: value.c:53
#define NIL
Definition: pg_list.h:69
char * pstrdup(const char *in)
Definition: mcxt.c:1077
int errcode(int sqlerrcode)
Definition: elog.c:575
return result
Definition: formatting.c:1632
void pfree(void *pointer)
Definition: mcxt.c:950
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3247
#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