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