PostgreSQL Source Code  git master
pgbench.h File Reference
Include dependency graph for pgbench.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PgBenchValue
 
struct  PgBenchExpr
 
struct  PgBenchExprLink
 
struct  PgBenchExprList
 

Macros

#define yyscan_t   void *
 

Typedefs

typedef enum PgBenchExprType PgBenchExprType
 
typedef enum PgBenchFunction PgBenchFunction
 
typedef struct PgBenchExpr PgBenchExpr
 
typedef struct PgBenchExprLink PgBenchExprLink
 
typedef struct PgBenchExprList PgBenchExprList
 

Enumerations

enum  PgBenchValueType {
  PGBT_NO_VALUE = 0 , PGBT_NULL , PGBT_INT , PGBT_DOUBLE ,
  PGBT_BOOLEAN
}
 
enum  PgBenchExprType { ENODE_CONSTANT , ENODE_VARIABLE , ENODE_FUNCTION }
 
enum  PgBenchFunction {
  PGBENCH_ADD , PGBENCH_SUB , PGBENCH_MUL , PGBENCH_DIV ,
  PGBENCH_MOD , PGBENCH_DEBUG , PGBENCH_ABS , PGBENCH_LEAST ,
  PGBENCH_GREATEST , PGBENCH_INT , PGBENCH_DOUBLE , PGBENCH_PI ,
  PGBENCH_SQRT , PGBENCH_LN , PGBENCH_EXP , PGBENCH_RANDOM ,
  PGBENCH_RANDOM_GAUSSIAN , PGBENCH_RANDOM_EXPONENTIAL , PGBENCH_RANDOM_ZIPFIAN , PGBENCH_POW ,
  PGBENCH_AND , PGBENCH_OR , PGBENCH_NOT , PGBENCH_BITAND ,
  PGBENCH_BITOR , PGBENCH_BITXOR , PGBENCH_LSHIFT , PGBENCH_RSHIFT ,
  PGBENCH_EQ , PGBENCH_NE , PGBENCH_LE , PGBENCH_LT ,
  PGBENCH_IS , PGBENCH_CASE , PGBENCH_HASH_FNV1A , PGBENCH_HASH_MURMUR2 ,
  PGBENCH_PERMUTE
}
 

Functions

int expr_yyparse (yyscan_t yyscanner)
 
int expr_yylex (union YYSTYPE *yylval_param, yyscan_t yyscanner)
 
void expr_yyerror (yyscan_t yyscanner, const char *message) pg_attribute_noreturn()
 
void expr_yyerror_more (yyscan_t yyscanner, const char *message, const char *more) pg_attribute_noreturn()
 
bool expr_lex_one_word (PsqlScanState state, PQExpBuffer word_buf, int *offset)
 
yyscan_t expr_scanner_init (PsqlScanState state, const char *source, int lineno, int start_offset, const char *command)
 
void expr_scanner_finish (yyscan_t yyscanner)
 
int expr_scanner_offset (PsqlScanState state)
 
char * expr_scanner_get_substring (PsqlScanState state, int start_offset, int end_offset, bool chomp)
 
int expr_scanner_get_lineno (PsqlScanState state, int offset)
 
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()
 
bool strtoint64 (const char *str, bool errorOK, int64 *result)
 
bool strtodouble (const char *str, bool errorOK, double *dv)
 

Variables

PgBenchExprexpr_parse_result
 

Macro Definition Documentation

◆ yyscan_t

#define yyscan_t   void *

Definition at line 23 of file pgbench.h.

Typedef Documentation

◆ PgBenchExpr

typedef struct PgBenchExpr PgBenchExpr

Definition at line 1 of file pgbench.h.

◆ PgBenchExprLink

Definition at line 1 of file pgbench.h.

◆ PgBenchExprList

Definition at line 1 of file pgbench.h.

◆ PgBenchExprType

◆ PgBenchFunction

Enumeration Type Documentation

◆ PgBenchExprType

Enumerator
ENODE_CONSTANT 
ENODE_VARIABLE 
ENODE_FUNCTION 

Definition at line 57 of file pgbench.h.

58 {
PgBenchExprType
Definition: pgbench.h:58
@ ENODE_VARIABLE
Definition: pgbench.h:60
@ ENODE_CONSTANT
Definition: pgbench.h:59
@ ENODE_FUNCTION
Definition: pgbench.h:61

◆ PgBenchFunction

Enumerator
PGBENCH_ADD 
PGBENCH_SUB 
PGBENCH_MUL 
PGBENCH_DIV 
PGBENCH_MOD 
PGBENCH_DEBUG 
PGBENCH_ABS 
PGBENCH_LEAST 
PGBENCH_GREATEST 
PGBENCH_INT 
PGBENCH_DOUBLE 
PGBENCH_PI 
PGBENCH_SQRT 
PGBENCH_LN 
PGBENCH_EXP 
PGBENCH_RANDOM 
PGBENCH_RANDOM_GAUSSIAN 
PGBENCH_RANDOM_EXPONENTIAL 
PGBENCH_RANDOM_ZIPFIAN 
PGBENCH_POW 
PGBENCH_AND 
PGBENCH_OR 
PGBENCH_NOT 
PGBENCH_BITAND 
PGBENCH_BITOR 
PGBENCH_BITXOR 
PGBENCH_LSHIFT 
PGBENCH_RSHIFT 
PGBENCH_EQ 
PGBENCH_NE 
PGBENCH_LE 
PGBENCH_LT 
PGBENCH_IS 
PGBENCH_CASE 
PGBENCH_HASH_FNV1A 
PGBENCH_HASH_MURMUR2 
PGBENCH_PERMUTE 

Definition at line 65 of file pgbench.h.

66 {
78  PGBENCH_PI,
80  PGBENCH_LN,
88  PGBENCH_OR,
95  PGBENCH_EQ,
96  PGBENCH_NE,
97  PGBENCH_LE,
98  PGBENCH_LT,
99  PGBENCH_IS,
100  PGBENCH_CASE,
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

◆ PgBenchValueType

Enumerator
PGBT_NO_VALUE 
PGBT_NULL 
PGBT_INT 
PGBT_DOUBLE 
PGBT_BOOLEAN 

Definition at line 34 of file pgbench.h.

35 {
36  PGBT_NO_VALUE = 0,
37  PGBT_NULL,
38  PGBT_INT,
41  /* add other types here */
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

Function Documentation

◆ expr_lex_one_word()

bool expr_lex_one_word ( PsqlScanState  state,
PQExpBuffer  word_buf,
int *  offset 
)

◆ expr_scanner_finish()

void expr_scanner_finish ( yyscan_t  yyscanner)

◆ expr_scanner_get_lineno()

int expr_scanner_get_lineno ( PsqlScanState  state,
int  offset 
)

◆ expr_scanner_get_substring()

char* expr_scanner_get_substring ( PsqlScanState  state,
int  start_offset,
int  end_offset,
bool  chomp 
)

◆ expr_scanner_init()

yyscan_t expr_scanner_init ( PsqlScanState  state,
const char *  source,
int  lineno,
int  start_offset,
const char *  command 
)

◆ expr_scanner_offset()

int expr_scanner_offset ( PsqlScanState  state)

◆ expr_yyerror()

void expr_yyerror ( yyscan_t  yyscanner,
const char *  message 
)

◆ expr_yyerror_more()

void expr_yyerror_more ( yyscan_t  yyscanner,
const char *  message,
const char *  more 
)

◆ expr_yylex()

int expr_yylex ( union YYSTYPE *  yylval_param,
yyscan_t  yyscanner 
)

◆ expr_yyparse()

int expr_yyparse ( yyscan_t  yyscanner)

◆ strtodouble()

bool strtodouble ( const char *  str,
bool  errorOK,
double *  dv 
)

Definition at line 1055 of file pgbench.c.

1057 {
1058  char *end;
1059 
1060  errno = 0;
1061  *dv = strtod(str, &end);
1062 
1063  if (unlikely(errno != 0))
1064  {
1065  if (!errorOK)
1066  pg_log_error("value \"%s\" is out of range for type double", str);
1067  return false;
1068  }
1069 
1070  if (unlikely(end == str || *end != '\0'))
1071  {
1072  if (!errorOK)
1073  pg_log_error("invalid input syntax for type double: \"%s\"", str);
1074  return false;
1075  }
1076  return true;
#define unlikely(x)
Definition: c.h:300
#define pg_log_error(...)
Definition: logging.h:106

References pg_log_error, generate_unaccent_rules::str, and unlikely.

Referenced by makeVariableValue().

◆ strtoint64()

bool strtoint64 ( const char *  str,
bool  errorOK,
int64 *  result 
)

Definition at line 984 of file pgbench.c.

986 {
987  const char *ptr = str;
988  int64 tmp = 0;
989  bool neg = false;
990 
991  /*
992  * Do our own scan, rather than relying on sscanf which might be broken
993  * for long long.
994  *
995  * As INT64_MIN can't be stored as a positive 64 bit integer, accumulate
996  * value as a negative number.
997  */
998 
999  /* skip leading spaces */
1000  while (*ptr && isspace((unsigned char) *ptr))
1001  ptr++;
1002 
1003  /* handle sign */
1004  if (*ptr == '-')
1005  {
1006  ptr++;
1007  neg = true;
1008  }
1009  else if (*ptr == '+')
1010  ptr++;
1011 
1012  /* require at least one digit */
1013  if (unlikely(!isdigit((unsigned char) *ptr)))
1014  goto invalid_syntax;
1015 
1016  /* process digits */
1017  while (*ptr && isdigit((unsigned char) *ptr))
1018  {
1019  int8 digit = (*ptr++ - '0');
1020 
1021  if (unlikely(pg_mul_s64_overflow(tmp, 10, &tmp)) ||
1022  unlikely(pg_sub_s64_overflow(tmp, digit, &tmp)))
1023  goto out_of_range;
1024  }
1025 
1026  /* allow trailing whitespace, but not other trailing chars */
1027  while (*ptr != '\0' && isspace((unsigned char) *ptr))
1028  ptr++;
1029 
1030  if (unlikely(*ptr != '\0'))
1031  goto invalid_syntax;
1032 
1033  if (!neg)
1034  {
1035  if (unlikely(tmp == PG_INT64_MIN))
1036  goto out_of_range;
1037  tmp = -tmp;
1038  }
1039 
1040  *result = tmp;
1041  return true;
1042 
1043 out_of_range:
1044  if (!errorOK)
1045  pg_log_error("value \"%s\" is out of range for type bigint", str);
1046  return false;
1047 
1048 invalid_syntax:
1049  if (!errorOK)
1050  pg_log_error("invalid input syntax for type bigint: \"%s\"", str);
1051  return false;
signed char int8
Definition: c.h:481
#define PG_INT64_MIN
Definition: c.h:580
static bool pg_mul_s64_overflow(int64 a, int64 b, int64 *result)
Definition: int.h:215
static bool pg_sub_s64_overflow(int64 a, int64 b, int64 *result)
Definition: int.h:188

References PG_INT64_MIN, pg_log_error, pg_mul_s64_overflow(), pg_sub_s64_overflow(), generate_unaccent_rules::str, and unlikely.

Referenced by makeVariableValue().

◆ syntax_error()

void syntax_error ( const char *  source,
int  lineno,
const char *  line,
const char *  command,
const char *  msg,
const char *  more,
int  column 
)

Definition at line 5444 of file pgbench.c.

5448 {
5450 
5451  initPQExpBuffer(&buf);
5452 
5453  printfPQExpBuffer(&buf, "%s:%d: %s", source, lineno, msg);
5454  if (more != NULL)
5455  appendPQExpBuffer(&buf, " (%s)", more);
5456  if (column >= 0 && line == NULL)
5457  appendPQExpBuffer(&buf, " at column %d", column + 1);
5458  if (command != NULL)
5459  appendPQExpBuffer(&buf, " in command \"%s\"", command);
5460 
5461  pg_log_error("%s", buf.data);
5462 
5463  termPQExpBuffer(&buf);
5464 
5465  if (line != NULL)
5466  {
5467  fprintf(stderr, "%s\n", line);
5468  if (column >= 0)
5469  fprintf(stderr, "%*c error found here\n", column + 1, '^');
5470  }
5471 
5472  exit(1);
exit(1)
static rewind_source * source
Definition: pg_rewind.c:89
static char * buf
Definition: pg_test_fsync.c:67
#define fprintf
Definition: port.h:242
void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
Definition: pqexpbuffer.c:235
void initPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:90
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
Definition: pqexpbuffer.c:265
void termPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:129

References appendPQExpBuffer(), buf, exit(), fprintf, initPQExpBuffer(), pg_log_error, printfPQExpBuffer(), source, and termPQExpBuffer().

Referenced by ParseScript(), process_backslash_command(), and string_to_uuid().

Variable Documentation

◆ expr_parse_result

PgBenchExpr* expr_parse_result
extern