1 /*-------------------------------------------------------------------------
5 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
8 *-------------------------------------------------------------------------
14 #include "fe_utils/psqlscan.h"
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".
23 #define yyscan_t void *
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.
32 * Variable types used in parser.
41 /* add other types here */
46 PgBenchValueType type
;
52 /* add other types here */
56 /* Types of expression nodes */
57 typedef enum PgBenchExprType
64 /* List of operators and callable functions */
65 typedef enum PgBenchFunction
83 PGBENCH_RANDOM_GAUSSIAN
,
84 PGBENCH_RANDOM_EXPONENTIAL
,
85 PGBENCH_RANDOM_ZIPFIAN
,
102 PGBENCH_HASH_MURMUR2
,
106 typedef struct PgBenchExpr PgBenchExpr
;
107 typedef struct PgBenchExprLink PgBenchExprLink
;
108 typedef struct PgBenchExprList PgBenchExprList
;
112 PgBenchExprType etype
;
115 PgBenchValue constant
;
122 PgBenchFunction function
;
123 PgBenchExprLink
*args
;
128 /* List of expression nodes */
129 struct PgBenchExprLink
132 PgBenchExprLink
*next
;
135 struct PgBenchExprList
137 PgBenchExprLink
*head
;
138 PgBenchExprLink
*tail
;
141 extern PgBenchExpr
*expr_parse_result
;
143 extern int expr_yyparse(yyscan_t yyscanner
);
144 extern int expr_yylex(union YYSTYPE
*yylval_param
, yyscan_t yyscanner
);
145 extern void expr_yyerror(yyscan_t yyscanner
, const char *message
) pg_attribute_noreturn();
146 extern void expr_yyerror_more(yyscan_t yyscanner
, const char *message
,
147 const char *more
) pg_attribute_noreturn();
148 extern bool expr_lex_one_word(PsqlScanState state
, PQExpBuffer word_buf
,
150 extern yyscan_t
expr_scanner_init(PsqlScanState state
,
151 const char *source
, int lineno
, int start_offset
,
152 const char *command
);
153 extern void expr_scanner_finish(yyscan_t yyscanner
);
154 extern int expr_scanner_offset(PsqlScanState state
);
155 extern char *expr_scanner_get_substring(PsqlScanState state
,
156 int start_offset
, int end_offset
,
158 extern int expr_scanner_get_lineno(PsqlScanState state
, int offset
);
160 extern void syntax_error(const char *source
, int lineno
, const char *line
,
161 const char *command
, const char *msg
,
162 const char *more
, int column
) pg_attribute_noreturn();
164 extern bool strtoint64(const char *str
, bool errorOK
, int64
*result
);
165 extern bool strtodouble(const char *str
, bool errorOK
, double *dv
);
167 #endif /* PGBENCH_H */