forked from orafce/orafce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orafunc.h
76 lines (64 loc) · 1.97 KB
/
orafunc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef __ORAFUNC__
#define __ORAFUNC__
#include "postgres.h"
#include "catalog/catversion.h"
#include "nodes/pg_list.h"
#include <sys/time.h>
#include "utils/datetime.h"
#include "utils/datum.h"
#ifndef PG_VERSION_NUM
#define PG_VERSION_NUM 80100 /* assume 8.1. */
#endif
#define TextPCopy(t) \
DatumGetTextP(datumCopy(PointerGetDatum(t), false, -1))
#define PG_GETARG_IF_EXISTS(n, type, defval) \
((PG_NARGS() > (n) && !PG_ARGISNULL(n)) ? PG_GETARG_##type(n) : (defval))
/* alignment of this struct must fit for all types */
typedef union vardata
{
char c;
short s;
int i;
long l;
float f;
double d;
void *p;
} vardata;
int ora_instr(text *txt, text *pattern, int start, int nth);
int ora_mb_strlen(text *str, char **sizes, int **positions);
int ora_mb_strlen1(text *str);
/*
* Version compatibility
*/
#if PG_VERSION_NUM >= 80400
extern Oid equality_oper_funcid(Oid argtype);
#endif
#if PG_VERSION_NUM < 80400
#define CStringGetTextDatum(c) \
DirectFunctionCall1(textin, CStringGetDatum(c))
#define text_to_cstring(t) \
DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(t)))
#define cstring_to_text(c) \
DatumGetTextP(CStringGetTextDatum(c))
text *cstring_to_text_with_len(const char *c, int n);
#endif
#if PG_VERSION_NUM < 80300
#define PGDLLIMPORT DLLIMPORT
#define session_timezone global_timezone
#define DatumGetTextPP(p) DatumGetTextP(p)
#define SET_VARSIZE(PTR, len) (VARATT_SIZEP((PTR)) = (len))
#define PG_GETARG_TEXT_PP(n) PG_GETARG_TEXT_P((n))
#define VARDATA_ANY(PTR) VARDATA((PTR))
#define VARSIZE_ANY_EXHDR(PTR) (VARSIZE((PTR)) - VARHDRSZ)
#define att_align_nominal(cur_offset, attalign) \
att_align((cur_offset), (attalign))
#define att_addlength_pointer(cur_offset, attlen, attptr) \
att_addlength((cur_offset), (attlen), (attptr))
#define stringToQualifiedNameList(string) \
stringToQualifiedNameList((string), "")
typedef void *SPIPlanPtr;
#endif
#if PG_VERSION_NUM < 80200
#define ARR_NULLBITMAP(a) (NULL)
#endif
#endif