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_INT, PGBT_DOUBLE }
 
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_RANDOM, PGBENCH_RANDOM_GAUSSIAN, PGBENCH_RANDOM_EXPONENTIAL
}
 

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()
 
int64 strtoint64 (const char *str)
 

Variables

PgBenchExprexpr_parse_result
 

Macro Definition Documentation

◆ yyscan_t

#define yyscan_t   void *

Definition at line 23 of file pgbench.h.

Typedef Documentation

◆ PgBenchExpr

Definition at line 81 of file pgbench.h.

◆ PgBenchExprLink

Definition at line 82 of file pgbench.h.

◆ PgBenchExprList

Definition at line 83 of file pgbench.h.

◆ PgBenchExprType

◆ PgBenchFunction

Enumeration Type Documentation

◆ PgBenchExprType

Enumerator
ENODE_CONSTANT 
ENODE_VARIABLE 
ENODE_FUNCTION 

Definition at line 53 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_RANDOM 
PGBENCH_RANDOM_GAUSSIAN 
PGBENCH_RANDOM_EXPONENTIAL 

Definition at line 61 of file pgbench.h.

◆ PgBenchValueType

Enumerator
PGBT_INT 
PGBT_DOUBLE 

Definition at line 34 of file pgbench.h.

35 {
36  PGBT_INT,
38  /* 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)

◆ strtoint64()

int64 strtoint64 ( const char *  str)

Definition at line 573 of file pgbench.c.

References PG_INT64_MIN, sign, and generate_unaccent_rules::str.

Referenced by makeVariableNumeric().

574 {
575  const char *ptr = str;
576  int64 result = 0;
577  int sign = 1;
578 
579  /*
580  * Do our own scan, rather than relying on sscanf which might be broken
581  * for long long.
582  */
583 
584  /* skip leading spaces */
585  while (*ptr && isspace((unsigned char) *ptr))
586  ptr++;
587 
588  /* handle sign */
589  if (*ptr == '-')
590  {
591  ptr++;
592 
593  /*
594  * Do an explicit check for INT64_MIN. Ugly though this is, it's
595  * cleaner than trying to get the loop below to handle it portably.
596  */
597  if (strncmp(ptr, "9223372036854775808", 19) == 0)
598  {
599  result = PG_INT64_MIN;
600  ptr += 19;
601  goto gotdigits;
602  }
603  sign = -1;
604  }
605  else if (*ptr == '+')
606  ptr++;
607 
608  /* require at least one digit */
609  if (!isdigit((unsigned char) *ptr))
610  fprintf(stderr, "invalid input syntax for integer: \"%s\"\n", str);
611 
612  /* process digits */
613  while (*ptr && isdigit((unsigned char) *ptr))
614  {
615  int64 tmp = result * 10 + (*ptr++ - '0');
616 
617  if ((tmp / 10) != result) /* overflow? */
618  fprintf(stderr, "value \"%s\" is out of range for type bigint\n", str);
619  result = tmp;
620  }
621 
622 gotdigits:
623 
624  /* allow trailing whitespace, but not other trailing chars */
625  while (*ptr != '\0' && isspace((unsigned char) *ptr))
626  ptr++;
627 
628  if (*ptr != '\0')
629  fprintf(stderr, "invalid input syntax for integer: \"%s\"\n", str);
630 
631  return ((sign < 0) ? -result : result);
632 }
char sign
Definition: informix.c:693
#define PG_INT64_MIN
Definition: c.h:381

◆ 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 3117 of file pgbench.c.

References i.

Referenced by process_backslash_command(), and string_to_uuid().

3120 {
3121  fprintf(stderr, "%s:%d: %s", source, lineno, msg);
3122  if (more != NULL)
3123  fprintf(stderr, " (%s)", more);
3124  if (column >= 0 && line == NULL)
3125  fprintf(stderr, " at column %d", column + 1);
3126  if (command != NULL)
3127  fprintf(stderr, " in command \"%s\"", command);
3128  fprintf(stderr, "\n");
3129  if (line != NULL)
3130  {
3131  fprintf(stderr, "%s\n", line);
3132  if (column >= 0)
3133  {
3134  int i;
3135 
3136  for (i = 0; i < column; i++)
3137  fprintf(stderr, " ");
3138  fprintf(stderr, "^ error found here\n");
3139  }
3140  }
3141  exit(1);
3142 }
int i

Variable Documentation

◆ expr_parse_result

PgBenchExpr* expr_parse_result