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-2025, 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 */
29union YYSTYPE;
30
31/*
32 * Variable types used in parser.
33 */
34typedef enum
35{
41 /* add other types here */
43
44typedef struct
45{
47 union
48 {
50 double dval;
51 bool bval;
52 /* add other types here */
53 } u;
55
56/* Types of expression nodes */
57typedef enum PgBenchExprType
58{
63
64/* List of operators and callable functions */
65typedef enum PgBenchFunction
66{
105
109
111{
113 union
114 {
116 struct
117 {
118 char *varname;
120 struct
121 {
125 } u;
126};
127
128/* List of expression nodes */
130{
133};
134
136{
139};
140
141extern int expr_yyparse(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner);
142extern int expr_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner);
143extern void expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn();
144extern void expr_yyerror_more(yyscan_t yyscanner, const char *message,
145 const char *more) pg_attribute_noreturn();
147 int *offset);
149 const char *source, int lineno, int start_offset,
150 const char *command);
151extern void expr_scanner_finish(yyscan_t yyscanner);
154 int start_offset, int end_offset,
155 bool chomp);
156extern int expr_scanner_get_lineno(PsqlScanState state, int offset);
157
158extern void syntax_error(const char *source, int lineno, const char *line,
159 const char *command, const char *msg,
160 const char *more, int column) pg_attribute_noreturn();
161
162extern bool strtoint64(const char *str, bool errorOK, int64 *result);
163extern bool strtodouble(const char *str, bool errorOK, double *dv);
164
165#endif /* PGBENCH_H */
int64_t int64
Definition: c.h:485
#define pg_attribute_noreturn()
Definition: c.h:239
void * yyscan_t
Definition: cubedata.h:67
const char * str
static rewind_source * source
Definition: pg_rewind.c:89
bool strtodouble(const char *str, bool errorOK, double *dv)
Definition: pgbench.c:1085
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)
Definition: exprscan.l:415
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
char * expr_scanner_get_substring(PsqlScanState state, int start_offset, int end_offset, bool chomp)
Definition: exprscan.l:426
bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset)
Definition: exprscan.l:315
void expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn()
Definition: exprscan.l:304
int expr_yyparse(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner)
void syntax_error(const char *source, int lineno, const char *line, const char *command, const char *msg, const char *more, int column) pg_attribute_noreturn()
Definition: pgbench.c:5522
void expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) pg_attribute_noreturn()
Definition: exprscan.l:271
int expr_scanner_get_lineno(PsqlScanState state, int offset)
Definition: exprscan.l:456
bool strtoint64(const char *str, bool errorOK, int64 *result)
Definition: pgbench.c:1014
int expr_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner)
void expr_scanner_finish(yyscan_t yyscanner)
Definition: exprscan.l:396
yyscan_t expr_scanner_init(PsqlScanState state, const char *source, int lineno, int start_offset, const char *command)
Definition: exprscan.l:364
int YYSTYPE
Definition: psqlscanslash.l:39
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
PgBenchFunction function
Definition: pgbench.h:122
PgBenchExprType etype
Definition: pgbench.h:112
struct PgBenchExpr::@36::@37 variable
union PgBenchExpr::@36 u
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:323