PostgreSQL Source Code  git master
pg_config.c File Reference
#include "postgres.h"
#include "catalog/pg_type.h"
#include "common/config_info.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "port.h"
#include "utils/builtins.h"
Include dependency graph for pg_config.c:

Go to the source code of this file.

Functions

Datum pg_config (PG_FUNCTION_ARGS)
 

Function Documentation

◆ pg_config()

Datum pg_config ( PG_FUNCTION_ARGS  )

Definition at line 25 of file pg_config.c.

26 {
27  ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
28  ConfigData *configdata;
29  size_t configdata_len;
30  int i = 0;
31 
32  /* initialize our tuplestore */
33  SetSingleFuncCall(fcinfo, 0);
34 
35  configdata = get_configdata(my_exec_path, &configdata_len);
36  for (i = 0; i < configdata_len; i++)
37  {
38  Datum values[2];
39  bool nulls[2];
40 
41  memset(values, 0, sizeof(values));
42  memset(nulls, 0, sizeof(nulls));
43 
44  values[0] = CStringGetTextDatum(configdata[i].name);
45  values[1] = CStringGetTextDatum(configdata[i].setting);
46 
47  tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
48  }
49 
50  return (Datum) 0;
51 }
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define CStringGetTextDatum(s)
Definition: builtins.h:85
ConfigData * get_configdata(const char *my_exec_path, size_t *configdata_len)
Definition: config_info.c:33
const char * name
Definition: encode.c:561
void SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
Definition: funcapi.c:76
char my_exec_path[MAXPGPATH]
Definition: globals.c:76
int i
Definition: isn.c:73
uintptr_t Datum
Definition: postgres.h:411
TupleDesc setDesc
Definition: execnodes.h:317
Tuplestorestate * setResult
Definition: execnodes.h:316
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
Definition: tuplestore.c:750

References CStringGetTextDatum, get_configdata(), i, my_exec_path, name, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SetSingleFuncCall(), tuplestore_putvalues(), and values.