PostgreSQL Source Code  git master
pgbench.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pgbench.h
4  *
5  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
6  * Portions Copyright (c) 1994, Regents of the University of California
7  *
8  *-------------------------------------------------------------------------
9  */
10 
11 #ifndef PGBENCH_H
12 #define PGBENCH_H
13 
14 #include "fe_utils/psqlscan.h"
15 
16 /*
17  * This file is included outside exprscan.l, in places where we can't see
18  * flex's definition of typedef yyscan_t. Fortunately, it's documented as
19  * being "void *", so we can use a macro to keep the function declarations
20  * here looking like the definitions in exprscan.l. exprparse.y and
21  * pgbench.c also use this to be able to declare things as "yyscan_t".
22  */
23 #define yyscan_t void *
24 
25 /*
26  * Likewise, we can't see exprparse.y's definition of union YYSTYPE here,
27  * but for now there's no need to know what the union contents are.
28  */
29 union YYSTYPE;
30 
31 /*
32  * Variable types used in parser.
33  */
34 typedef enum
35 {
41  /* add other types here */
43 
44 typedef struct
45 {
47  union
48  {
49  int64 ival;
50  double dval;
51  bool bval;
52  /* add other types here */
53  } u;
54 } PgBenchValue;
55 
56 /* Types of expression nodes */
57 typedef enum PgBenchExprType
58 {
63 
64 /* List of operators and callable functions */
65 typedef enum PgBenchFunction
66 {
105 
106 typedef struct PgBenchExpr PgBenchExpr;
107 typedef struct PgBenchExprLink PgBenchExprLink;
108 typedef struct PgBenchExprList PgBenchExprList;
109 
111 {
113  union
114  {
116  struct
117  {
118  char *varname;
120  struct
121  {
122  PgBenchFunction function;
124  } function;
125  } u;
126 };
127 
128 /* List of expression nodes */
130 {
133 };
134 
136 {
139 };
140 
142 
144 extern int expr_yylex(union YYSTYPE *lvalp, yyscan_t yyscanner);
146 extern void expr_yyerror_more(yyscan_t yyscanner, const char *str,
147  const char *more) pg_attribute_noreturn();
149  int *offset);
151  const char *source, int lineno, int start_offset,
152  const char *command);
156  int start_offset, int end_offset,
157  bool chomp);
159 
160 extern void syntax_error(const char *source, int lineno, const char *line,
161  const char *cmd, const char *msg,
162  const char *more, int col) pg_attribute_noreturn();
163 
164 extern bool strtoint64(const char *str, bool errorOK, int64 *pi);
165 extern bool strtodouble(const char *str, bool errorOK, double *pd);
166 
167 #endif /* PGBENCH_H */
#define pg_attribute_noreturn()
Definition: c.h:179
static rewind_source * source
Definition: pg_rewind.c:81
PgBenchExprType
Definition: pgbench.h:58
@ ENODE_VARIABLE
Definition: pgbench.h:60
@ ENODE_CONSTANT
Definition: pgbench.h:59
@ ENODE_FUNCTION
Definition: pgbench.h:61
PgBenchValueType
Definition: pgbench.h:35
@ PGBT_NO_VALUE
Definition: pgbench.h:36
@ PGBT_INT
Definition: pgbench.h:38
@ PGBT_NULL
Definition: pgbench.h:37
@ PGBT_DOUBLE
Definition: pgbench.h:39
@ PGBT_BOOLEAN
Definition: pgbench.h:40
int expr_scanner_offset(PsqlScanState state)
PgBenchFunction
Definition: pgbench.h:66
@ PGBENCH_DIV
Definition: pgbench.h:70
@ PGBENCH_AND
Definition: pgbench.h:87
@ PGBENCH_DOUBLE
Definition: pgbench.h:77
@ PGBENCH_LT
Definition: pgbench.h:98
@ PGBENCH_LN
Definition: pgbench.h:80
@ PGBENCH_RANDOM_EXPONENTIAL
Definition: pgbench.h:84
@ PGBENCH_RSHIFT
Definition: pgbench.h:94
@ PGBENCH_DEBUG
Definition: pgbench.h:72
@ PGBENCH_MOD
Definition: pgbench.h:71
@ PGBENCH_GREATEST
Definition: pgbench.h:75
@ PGBENCH_BITXOR
Definition: pgbench.h:92
@ PGBENCH_RANDOM_ZIPFIAN
Definition: pgbench.h:85
@ PGBENCH_INT
Definition: pgbench.h:76
@ PGBENCH_NE
Definition: pgbench.h:96
@ PGBENCH_OR
Definition: pgbench.h:88
@ PGBENCH_LE
Definition: pgbench.h:97
@ PGBENCH_EXP
Definition: pgbench.h:81
@ PGBENCH_PI
Definition: pgbench.h:78
@ PGBENCH_ADD
Definition: pgbench.h:67
@ PGBENCH_EQ
Definition: pgbench.h:95
@ PGBENCH_LSHIFT
Definition: pgbench.h:93
@ PGBENCH_RANDOM
Definition: pgbench.h:82
@ PGBENCH_POW
Definition: pgbench.h:86
@ PGBENCH_IS
Definition: pgbench.h:99
@ PGBENCH_SUB
Definition: pgbench.h:68
@ PGBENCH_HASH_MURMUR2
Definition: pgbench.h:102
@ PGBENCH_ABS
Definition: pgbench.h:73
@ PGBENCH_BITOR
Definition: pgbench.h:91
@ PGBENCH_SQRT
Definition: pgbench.h:79
@ PGBENCH_LEAST
Definition: pgbench.h:74
@ PGBENCH_PERMUTE
Definition: pgbench.h:103
@ PGBENCH_HASH_FNV1A
Definition: pgbench.h:101
@ PGBENCH_NOT
Definition: pgbench.h:89
@ PGBENCH_BITAND
Definition: pgbench.h:90
@ PGBENCH_RANDOM_GAUSSIAN
Definition: pgbench.h:83
@ PGBENCH_MUL
Definition: pgbench.h:69
@ PGBENCH_CASE
Definition: pgbench.h:100
bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset)
bool strtodouble(const char *str, bool errorOK, double *pd)
Definition: pgbench.c:1053
int expr_yylex(union YYSTYPE *lvalp, yyscan_t yyscanner)
void expr_yyerror(yyscan_t yyscanner, const char *str) pg_attribute_noreturn()
void expr_yyerror_more(yyscan_t yyscanner, const char *str, const char *more) pg_attribute_noreturn()
int expr_yyparse(yyscan_t yyscanner)
int expr_scanner_get_lineno(PsqlScanState state, int offset)
bool strtoint64(const char *str, bool errorOK, int64 *pi)
Definition: pgbench.c:982
void syntax_error(const char *source, int lineno, const char *line, const char *cmd, const char *msg, const char *more, int col) pg_attribute_noreturn()
Definition: pgbench.c:5375
PgBenchExpr * expr_parse_result
void expr_scanner_finish(yyscan_t yyscanner)
yyscan_t expr_scanner_init(PsqlScanState state, const char *source, int lineno, int start_offset, const char *command)
char * expr_scanner_get_substring(PsqlScanState state, int start_offset, int end_offset, bool chomp)
static core_yyscan_t yyscanner
Definition: pl_scanner.c:106
void * yyscan_t
Definition: psqlscan_int.h:60
PgBenchExprLink * head
Definition: pgbench.h:137
PgBenchExprLink * tail
Definition: pgbench.h:138
PgBenchExprLink * args
Definition: pgbench.h:123
PgBenchValue constant
Definition: pgbench.h:115
char * varname
Definition: pgbench.h:118
union PgBenchExpr::@35 u
struct PgBenchExpr::@35::@36 variable
PgBenchExprType etype
Definition: pgbench.h:112
PgBenchValueType type
Definition: pgbench.h:46
bool bval
Definition: pgbench.h:51
int64 ival
Definition: pgbench.h:49
double dval
Definition: pgbench.h:50
Definition: regguts.h:318