PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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)
 
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

#define yyscan_t   void *

Definition at line 23 of file pgbench.h.

Typedef Documentation

Definition at line 81 of file pgbench.h.

Definition at line 82 of file pgbench.h.

Definition at line 83 of file pgbench.h.

Enumeration Type Documentation

Enumerator
ENODE_CONSTANT 
ENODE_VARIABLE 
ENODE_FUNCTION 

Definition at line 53 of file pgbench.h.

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.

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

bool expr_lex_one_word ( PsqlScanState  state,
PQExpBuffer  word_buf,
int *  offset 
)
void expr_scanner_finish ( yyscan_t  yyscanner)
int expr_scanner_get_lineno ( PsqlScanState  state,
int  offset 
)
char* expr_scanner_get_substring ( PsqlScanState  state,
int  start_offset,
int  end_offset 
)
yyscan_t expr_scanner_init ( PsqlScanState  state,
const char *  source,
int  lineno,
int  start_offset,
const char *  command 
)
int expr_scanner_offset ( PsqlScanState  state)
void expr_yyerror ( yyscan_t  yyscanner,
const char *  str 
)
void expr_yyerror_more ( yyscan_t  yyscanner,
const char *  str,
const char *  more 
)
int expr_yylex ( union YYSTYPE *  lvalp,
yyscan_t  yyscanner 
)
int expr_yyparse ( yyscan_t  yyscanner)
int64 strtoint64 ( const char *  str)

Definition at line 564 of file pgbench.c.

References PG_INT64_MIN, result, and sign.

Referenced by makeVariableNumeric().

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

References i, and NULL.

Referenced by process_backslash_command(), and string_to_uuid().

2923 {
2924  fprintf(stderr, "%s:%d: %s", source, lineno, msg);
2925  if (more != NULL)
2926  fprintf(stderr, " (%s)", more);
2927  if (column >= 0 && line == NULL)
2928  fprintf(stderr, " at column %d", column + 1);
2929  if (command != NULL)
2930  fprintf(stderr, " in command \"%s\"", command);
2931  fprintf(stderr, "\n");
2932  if (line != NULL)
2933  {
2934  fprintf(stderr, "%s\n", line);
2935  if (column >= 0)
2936  {
2937  int i;
2938 
2939  for (i = 0; i < column; i++)
2940  fprintf(stderr, " ");
2941  fprintf(stderr, "^ error found here\n");
2942  }
2943  }
2944  exit(1);
2945 }
#define NULL
Definition: c.h:229
int i

Variable Documentation

PgBenchExpr* expr_parse_result