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-2018, 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 {
102 
103 typedef struct PgBenchExpr PgBenchExpr;
106 
108 {
110  union
111  {
113  struct
114  {
115  char *varname;
116  } variable;
117  struct
118  {
119  PgBenchFunction function;
121  } function;
122  } u;
123 };
124 
125 /* List of expression nodes */
127 {
130 };
131 
133 {
136 };
137 
139 
140 extern int expr_yyparse(yyscan_t yyscanner);
141 extern int expr_yylex(union YYSTYPE *lvalp, yyscan_t yyscanner);
142 extern void expr_yyerror(yyscan_t yyscanner, const char *str) pg_attribute_noreturn();
143 extern void expr_yyerror_more(yyscan_t yyscanner, const char *str,
144  const char *more) pg_attribute_noreturn();
145 extern bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf,
146  int *offset);
148  const char *source, int lineno, int start_offset,
149  const char *command);
153  int start_offset, int end_offset,
154  bool chomp);
155 extern int expr_scanner_get_lineno(PsqlScanState state, int offset);
156 
157 extern void syntax_error(const char *source, int lineno, const char *line,
158  const char *cmd, const char *msg,
159  const char *more, int col) pg_attribute_noreturn();
160 
161 extern int64 strtoint64(const char *str);
162 
163 #endif /* PGBENCH_H */
PgBenchExprLink * args
Definition: pgbench.h:120
PgBenchValueType
Definition: pgbench.h:34
PgBenchValue constant
Definition: pgbench.h:112
void expr_scanner_finish(yyscan_t yyscanner)
int expr_yyparse(yyscan_t yyscanner)
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:3664
yyscan_t expr_scanner_init(PsqlScanState state, const char *source, int lineno, int start_offset, const char *command)
struct PgBenchExpr::@40::@41 variable
char * varname
Definition: pgbench.h:115
int expr_scanner_get_lineno(PsqlScanState state, int offset)
void expr_yyerror_more(yyscan_t yyscanner, const char *str, const char *more) pg_attribute_noreturn()
PgBenchExpr * expr_parse_result
int expr_scanner_offset(PsqlScanState state)
PgBenchExprType
Definition: pgbench.h:57
PgBenchExprLink * head
Definition: pgbench.h:134
double dval
Definition: pgbench.h:50
PgBenchExprLink * tail
Definition: pgbench.h:135
void * yyscan_t
Definition: psqlscan_int.h:60
Definition: regguts.h:298
char * expr_scanner_get_substring(PsqlScanState state, int start_offset, int end_offset, bool chomp)
#define pg_attribute_noreturn()
Definition: c.h:146
static core_yyscan_t yyscanner
Definition: pl_scanner.c:210
bool bval
Definition: pgbench.h:51
PgBenchValueType type
Definition: pgbench.h:46
PgBenchFunction
Definition: pgbench.h:65
int64 ival
Definition: pgbench.h:49
bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset)
union PgBenchExpr::@40 u
int64 strtoint64(const char *str)
Definition: pgbench.c:610
void expr_yyerror(yyscan_t yyscanner, const char *str) pg_attribute_noreturn()
PgBenchExprType etype
Definition: pgbench.h:109
int expr_yylex(union YYSTYPE *lvalp, yyscan_t yyscanner)