PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
extensible.c File Reference
#include "postgres.h"
#include "nodes/extensible.h"
#include "utils/hsearch.h"
Include dependency graph for extensible.c:

Go to the source code of this file.

Data Structures

struct  ExtensibleNodeEntry
 

Functions

static void RegisterExtensibleNodeEntry (HTAB **p_htable, const char *htable_label, const char *extnodename, const void *extnodemethods)
 
void RegisterExtensibleNodeMethods (const ExtensibleNodeMethods *methods)
 
void RegisterCustomScanMethods (const CustomScanMethods *methods)
 
static const void * GetExtensibleNodeEntry (HTAB *htable, const char *extnodename, bool missing_ok)
 
const ExtensibleNodeMethodsGetExtensibleNodeMethods (const char *extnodename, bool missing_ok)
 
const CustomScanMethodsGetCustomScanMethods (const char *CustomName, bool missing_ok)
 

Variables

static HTABextensible_node_methods = NULL
 
static HTABcustom_scan_methods = NULL
 

Function Documentation

const CustomScanMethods* GetCustomScanMethods ( const char *  CustomName,
bool  missing_ok 
)

Definition at line 137 of file extensible.c.

References GetExtensibleNodeEntry().

Referenced by _readCustomScan().

138 {
139  return (const CustomScanMethods *)
141  CustomName,
142  missing_ok);
143 }
static const void * GetExtensibleNodeEntry(HTAB *htable, const char *extnodename, bool missing_ok)
Definition: extensible.c:100
static HTAB * custom_scan_methods
Definition: extensible.c:27
static const void* GetExtensibleNodeEntry ( HTAB htable,
const char *  extnodename,
bool  missing_ok 
)
static

Definition at line 100 of file extensible.c.

References ereport, errcode(), errmsg(), ERROR, ExtensibleNodeEntry::extnodemethods, HASH_FIND, hash_search(), and NULL.

Referenced by GetCustomScanMethods(), and GetExtensibleNodeMethods().

101 {
102  ExtensibleNodeEntry *entry = NULL;
103 
104  if (htable != NULL)
105  entry = (ExtensibleNodeEntry *) hash_search(htable,
106  extnodename,
107  HASH_FIND, NULL);
108  if (!entry)
109  {
110  if (missing_ok)
111  return NULL;
112  ereport(ERROR,
113  (errcode(ERRCODE_UNDEFINED_OBJECT),
114  errmsg("ExtensibleNodeMethods \"%s\" was not registered",
115  extnodename)));
116  }
117 
118  return entry->extnodemethods;
119 }
const void * extnodemethods
Definition: extensible.c:32
int errcode(int sqlerrcode)
Definition: elog.c:575
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:903
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
#define NULL
Definition: c.h:229
int errmsg(const char *fmt,...)
Definition: elog.c:797
const ExtensibleNodeMethods* GetExtensibleNodeMethods ( const char *  extnodename,
bool  missing_ok 
)

Definition at line 125 of file extensible.c.

References GetExtensibleNodeEntry().

Referenced by _copyExtensibleNode(), _equalExtensibleNode(), _outExtensibleNode(), and _readExtensibleNode().

126 {
127  return (const ExtensibleNodeMethods *)
129  extnodename,
130  missing_ok);
131 }
static HTAB * extensible_node_methods
Definition: extensible.c:26
static const void * GetExtensibleNodeEntry(HTAB *htable, const char *extnodename, bool missing_ok)
Definition: extensible.c:100
void RegisterCustomScanMethods ( const CustomScanMethods methods)

Definition at line 88 of file extensible.c.

References CustomScanMethods::CustomName, and RegisterExtensibleNodeEntry().

89 {
91  "Custom Scan Methods",
92  methods->CustomName,
93  methods);
94 }
static void RegisterExtensibleNodeEntry(HTAB **p_htable, const char *htable_label, const char *extnodename, const void *extnodemethods)
Definition: extensible.c:39
static HTAB * custom_scan_methods
Definition: extensible.c:27
const char * CustomName
Definition: extensible.h:107
static void RegisterExtensibleNodeEntry ( HTAB **  p_htable,
const char *  htable_label,
const char *  extnodename,
const void *  extnodemethods 
)
static

Definition at line 39 of file extensible.c.

References elog, HASHCTL::entrysize, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, ExtensibleNodeEntry::extnodemethods, EXTNODENAME_MAX_LEN, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HASHCTL::keysize, and NULL.

Referenced by RegisterCustomScanMethods(), and RegisterExtensibleNodeMethods().

42 {
43  ExtensibleNodeEntry *entry;
44  bool found;
45 
46  if (*p_htable == NULL)
47  {
48  HASHCTL ctl;
49 
50  memset(&ctl, 0, sizeof(HASHCTL));
52  ctl.entrysize = sizeof(ExtensibleNodeEntry);
53 
54  *p_htable = hash_create(htable_label, 100, &ctl, HASH_ELEM);
55  }
56 
57  if (strlen(extnodename) >= EXTNODENAME_MAX_LEN)
58  elog(ERROR, "extensible node name is too long");
59 
60  entry = (ExtensibleNodeEntry *) hash_search(*p_htable,
61  extnodename,
62  HASH_ENTER, &found);
63  if (found)
64  ereport(ERROR,
66  errmsg("extensible node type \"%s\" already exists",
67  extnodename)));
68 
69  entry->extnodemethods = extnodemethods;
70 }
const void * extnodemethods
Definition: extensible.c:32
#define HASH_ELEM
Definition: hsearch.h:87
Size entrysize
Definition: hsearch.h:73
int errcode(int sqlerrcode)
Definition: elog.c:575
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:903
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
Definition: dynahash.c:316
Size keysize
Definition: hsearch.h:72
#define NULL
Definition: c.h:229
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define elog
Definition: elog.h:219
#define EXTNODENAME_MAX_LEN
Definition: extensible.h:24
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:32
void RegisterExtensibleNodeMethods ( const ExtensibleNodeMethods methods)

Definition at line 76 of file extensible.c.

References ExtensibleNodeMethods::extnodename, and RegisterExtensibleNodeEntry().

77 {
79  "Extensible Node Methods",
80  methods->extnodename,
81  methods);
82 }
const char * extnodename
Definition: extensible.h:62
static void RegisterExtensibleNodeEntry(HTAB **p_htable, const char *htable_label, const char *extnodename, const void *extnodemethods)
Definition: extensible.c:39
static HTAB * extensible_node_methods
Definition: extensible.c:26

Variable Documentation

HTAB* custom_scan_methods = NULL
static

Definition at line 27 of file extensible.c.

HTAB* extensible_node_methods = NULL
static

Definition at line 26 of file extensible.c.