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 {
104 
105 typedef struct PgBenchExpr PgBenchExpr;
108 
110 {
112  union
113  {
115  struct
116  {
117  char *varname;
118  } variable;
119  struct
120  {
121  PgBenchFunction function;
123  } function;
124  } u;
125 };
126 
127 /* List of expression nodes */
129 {
132 };
133 
135 {
138 };
139 
141 
142 extern int expr_yyparse(yyscan_t yyscanner);
143 extern int expr_yylex(union YYSTYPE *lvalp, yyscan_t yyscanner);
144 extern void expr_yyerror(yyscan_t yyscanner, const char *str) pg_attribute_noreturn();
145 extern void expr_yyerror_more(yyscan_t yyscanner, const char *str,
146  const char *more) pg_attribute_noreturn();
147 extern bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf,
148  int *offset);
150  const char *source, int lineno, int start_offset,
151  const char *command);
155  int start_offset, int end_offset,
156  bool chomp);
157 extern int expr_scanner_get_lineno(PsqlScanState state, int offset);
158 
159 extern void syntax_error(const char *source, int lineno, const char *line,
160  const char *cmd, const char *msg,
161  const char *more, int col) pg_attribute_noreturn();
162 
163 extern int64 strtoint64(const char *str);
164 
165 #endif /* PGBENCH_H */
PgBenchExprLink * args
Definition: pgbench.h:122
PgBenchValueType
Definition: pgbench.h:34
PgBenchValue constant
Definition: pgbench.h:114
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:3930
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:117
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:136
double dval
Definition: pgbench.h:50
PgBenchExprLink * tail
Definition: pgbench.h:137
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:147
static core_yyscan_t yyscanner
Definition: pl_scanner.c:216
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:634
void expr_yyerror(yyscan_t yyscanner, const char *str) pg_attribute_noreturn()
PgBenchExprType etype
Definition: pgbench.h:111
int expr_yylex(union YYSTYPE *lvalp, yyscan_t yyscanner)