1 | // this is a bit of a mess from c.h, port.h and some others. Upside is it makes the parser compile with minimal |
2 | // dependencies. |
3 | |
4 | #pragma once |
5 | |
6 | #include <limits.h> |
7 | #include <stdbool.h> |
8 | #include <stddef.h> |
9 | #include <stdint.h> |
10 | #include <stdio.h> |
11 | |
12 | typedef uintptr_t PGDatum; |
13 | typedef uint64_t PGSize; |
14 | |
15 | typedef uint32_t PGIndex; |
16 | typedef uint32_t PGOid; |
17 | |
18 | #define InvalidOid ((PGOid)0) |
19 | |
20 | #ifndef _MSC_VER |
21 | #include <assert.h> |
22 | #define Assert(a) assert(a); |
23 | #define AssertMacro(p) ((void)assert(p)) |
24 | #else |
25 | #define Assert(a) (a); |
26 | #define AssertMacro(p) ((void)(p)) |
27 | #endif |
28 | #define _(a) (a) |
29 | |
30 | #define lengthof(array) (sizeof(array) / sizeof((array)[0])) |
31 | #define CppConcat(x, y) x##y |
32 | |
33 | #define HIGHBIT (0x80) |
34 | #define IS_HIGHBIT_SET(ch) ((unsigned char)(ch)&HIGHBIT) |
35 | |
36 | #define NAMEDATALEN 64 |
37 | #define FUNC_MAX_ARGS 100 |
38 | #define FLEXIBLE_ARRAY_MEMBER |
39 | |
40 | #define DEFAULT_INDEX_TYPE "art" |
41 | #define INTERVAL_MASK(b) (1 << (b)) |
42 | |
43 | #ifdef _MSC_VER |
44 | #define __thread __declspec(thread) |
45 | #endif |
46 | |
47 | typedef struct { |
48 | int32_t vl_len_; /* these fields must match ArrayType! */ |
49 | int ndim; /* always 1 for PGint2vector */ |
50 | int32_t dataoffset; /* always 0 for PGint2vector */ |
51 | PGOid elemtype; |
52 | int dim1; |
53 | int lbound1; |
54 | int16_t values[]; |
55 | } PGint2vector; |
56 | |
57 | typedef struct PGNameData { |
58 | char data[NAMEDATALEN]; |
59 | } PGNameData; |
60 | typedef PGNameData *Name; |
61 | |
62 | struct pg_varlena { |
63 | char vl_len_[4]; /* Do not touch this field directly! */ |
64 | char vl_dat[1]; /* Data content is here */ |
65 | }; |
66 | |
67 | typedef struct pg_varlena bytea; |
68 | |
69 | typedef int PGMemoryContext; |
70 | |
71 | typedef enum PGPostgresParserErrors { |
72 | PG_ERRCODE_SYNTAX_ERROR, |
73 | PG_ERRCODE_FEATURE_NOT_SUPPORTED, |
74 | PG_ERRCODE_INVALID_PARAMETER_VALUE, |
75 | PG_ERRCODE_WINDOWING_ERROR, |
76 | PG_ERRCODE_RESERVED_NAME, |
77 | PG_ERRCODE_INVALID_ESCAPE_SEQUENCE, |
78 | PG_ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER, |
79 | ERRCODE_NAME_TOO_LONG |
80 | } PGPostgresParserErrors; |
81 | |
82 | typedef enum PGPostgresRelPersistence { |
83 | PG_RELPERSISTENCE_TEMP, |
84 | PG_RELPERSISTENCE_UNLOGGED, |
85 | RELPERSISTENCE_PERMANENT |
86 | } PGPostgresRelPersistence; |
87 | |
88 | typedef enum PGPostgresErrorLevel { |
89 | PGUNDEFINED, |
90 | PGNOTICE, |
91 | PGWARNING, |
92 | ERROR |
93 | } PGPostgresErrorLevel; |
94 | |
95 | typedef enum PGPostgresAttributIdentityTypes { |
96 | PG_ATTRIBUTE_IDENTITY_ALWAYS, |
97 | ATTRIBUTE_IDENTITY_BY_DEFAULT |
98 | } PGPostgresAttributIdentityTypes; |
99 | |