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, 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
}
 

Functions

int expr_yyparse (yyscan_t yyscanner)
 
int expr_yylex (union YYSTYPE *lvalp, yyscan_t yyscanner)
 
void expr_yyerror (yyscan_t yyscanner, const char *str) pg_attribute_noreturn()
 
void expr_yyerror_more (yyscan_t yyscanner, const char *str, 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 *cmd, const char *msg, const char *more, int col) pg_attribute_noreturn()
 
bool strtoint64 (const char *str, bool errorOK, int64 *pi)
 
bool strtodouble (const char *str, bool errorOK, double *pd)
 

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 105 of file pgbench.h.

◆ PgBenchExprLink

Definition at line 106 of file pgbench.h.

◆ PgBenchExprList

Definition at line 107 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.

◆ 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 

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:65

◆ PgBenchValueType

Enumerator
PGBT_NO_VALUE 
PGBT_NULL 
PGBT_INT 
PGBT_DOUBLE 
PGBT_BOOLEAN 

Definition at line 34 of file pgbench.h.

35 {
37  PGBT_NULL,
38  PGBT_INT,
41  /* add other types here */
PgBenchValueType
Definition: pgbench.h:34

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 *  str 
)

◆ expr_yyerror_more()

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

◆ expr_yylex()

int expr_yylex ( union YYSTYPE *  lvalp,
yyscan_t  yyscanner 
)

◆ expr_yyparse()

int expr_yyparse ( yyscan_t  yyscanner)

◆ strtodouble()

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

Definition at line 803 of file pgbench.c.

References fprintf, and unlikely.

Referenced by makeVariableValue().

804 {
805  char *end;
806 
807  errno = 0;
808  *dv = strtod(str, &end);
809 
810  if (unlikely(errno != 0))
811  {
812  if (!errorOK)
813  fprintf(stderr,
814  "value \"%s\" is out of range for type double\n", str);
815  return false;
816  }
817 
818  if (unlikely(end == str || *end != '\0'))
819  {
820  if (!errorOK)
821  fprintf(stderr,
822  "invalid input syntax for type double: \"%s\"\n", str);
823  return false;
824  }
825  return true;
826 }
#define fprintf
Definition: port.h:196
#define unlikely(x)
Definition: c.h:208

◆ strtoint64()

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

Definition at line 730 of file pgbench.c.

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

Referenced by makeVariableValue().

731 {
732  const char *ptr = str;
733  int64 tmp = 0;
734  bool neg = false;
735 
736  /*
737  * Do our own scan, rather than relying on sscanf which might be broken
738  * for long long.
739  *
740  * As INT64_MIN can't be stored as a positive 64 bit integer, accumulate
741  * value as a negative number.
742  */
743 
744  /* skip leading spaces */
745  while (*ptr && isspace((unsigned char) *ptr))
746  ptr++;
747 
748  /* handle sign */
749  if (*ptr == '-')
750  {
751  ptr++;
752  neg = true;
753  }
754  else if (*ptr == '+')
755  ptr++;
756 
757  /* require at least one digit */
758  if (unlikely(!isdigit((unsigned char) *ptr)))
759  goto invalid_syntax;
760 
761  /* process digits */
762  while (*ptr && isdigit((unsigned char) *ptr))
763  {
764  int8 digit = (*ptr++ - '0');
765 
766  if (unlikely(pg_mul_s64_overflow(tmp, 10, &tmp)) ||
767  unlikely(pg_sub_s64_overflow(tmp, digit, &tmp)))
768  goto out_of_range;
769  }
770 
771  /* allow trailing whitespace, but not other trailing chars */
772  while (*ptr != '\0' && isspace((unsigned char) *ptr))
773  ptr++;
774 
775  if (unlikely(*ptr != '\0'))
776  goto invalid_syntax;
777 
778  if (!neg)
779  {
780  if (unlikely(tmp == PG_INT64_MIN))
781  goto out_of_range;
782  tmp = -tmp;
783  }
784 
785  *result = tmp;
786  return true;
787 
788 out_of_range:
789  if (!errorOK)
790  fprintf(stderr,
791  "value \"%s\" is out of range for type bigint\n", str);
792  return false;
793 
794 invalid_syntax:
795  if (!errorOK)
796  fprintf(stderr,
797  "invalid input syntax for type bigint: \"%s\"\n", str);
798  return false;
799 }
static bool pg_sub_s64_overflow(int64 a, int64 b, int64 *result)
Definition: int.h:188
#define fprintf
Definition: port.h:196
#define PG_INT64_MIN
Definition: c.h:444
signed char int8
Definition: c.h:345
static bool pg_mul_s64_overflow(int64 a, int64 b, int64 *result)
Definition: int.h:215
#define unlikely(x)
Definition: c.h:208

◆ syntax_error()

void syntax_error ( const char *  source,
int  lineno,
const char *  line,
const char *  cmd,
const char *  msg,
const char *  more,
int  col 
)

Definition at line 4378 of file pgbench.c.

References fprintf, and i.

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

4381 {
4382  fprintf(stderr, "%s:%d: %s", source, lineno, msg);
4383  if (more != NULL)
4384  fprintf(stderr, " (%s)", more);
4385  if (column >= 0 && line == NULL)
4386  fprintf(stderr, " at column %d", column + 1);
4387  if (command != NULL)
4388  fprintf(stderr, " in command \"%s\"", command);
4389  fprintf(stderr, "\n");
4390  if (line != NULL)
4391  {
4392  fprintf(stderr, "%s\n", line);
4393  if (column >= 0)
4394  {
4395  int i;
4396 
4397  for (i = 0; i < column; i++)
4398  fprintf(stderr, " ");
4399  fprintf(stderr, "^ error found here\n");
4400  }
4401  }
4402  exit(1);
4403 }
#define fprintf
Definition: port.h:196
int i

Variable Documentation

◆ expr_parse_result

PgBenchExpr* expr_parse_result