PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <signal.h>
#include <time.h>
#include <sys/resource.h>
#include <sys/select.h>
#include "common/int.h"
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/string.h"
#include "common/username.h"
#include "fe_utils/cancel.h"
#include "fe_utils/conditional.h"
#include "fe_utils/option_utils.h"
#include "fe_utils/string_utils.h"
#include "getopt_long.h"
#include "libpq-fe.h"
#include "pgbench.h"
#include "port/pg_bitutils.h"
#include "portability/instr_time.h"
#include "port/pg_pthread.h"
Go to the source code of this file.
Data Structures | |
struct | socket_set |
struct | Variable |
struct | Variables |
struct | SimpleStats |
struct | StatsData |
struct | CState |
struct | TState |
struct | Command |
struct | ParsedScript |
struct | BuiltinScript |
Macros | |
#define | POLL_USING_SELECT |
#define | M_PI 3.14159265358979323846 |
#define | ERRCODE_T_R_SERIALIZATION_FAILURE "40001" |
#define | ERRCODE_T_R_DEADLOCK_DETECTED "40P01" |
#define | ERRCODE_UNDEFINED_TABLE "42P01" |
#define | FNV_PRIME UINT64CONST(0x100000001b3) |
#define | FNV_OFFSET_BASIS UINT64CONST(0xcbf29ce484222325) |
#define | MM2_MUL UINT64CONST(0xc6a4a7935bd1e995) |
#define | MM2_MUL_TIMES_8 UINT64CONST(0x35253c9ade8f4ca8) |
#define | MM2_ROT 47 |
#define | SOCKET_WAIT_METHOD "select" |
#define | THREAD_T pthread_t |
#define | THREAD_FUNC_RETURN_TYPE void * |
#define | THREAD_FUNC_RETURN return NULL |
#define | THREAD_FUNC_CC |
#define | THREAD_CREATE(handle, function, arg) pthread_create((handle), NULL, (function), (arg)) |
#define | THREAD_JOIN(handle) pthread_join((handle), NULL) |
#define | THREAD_BARRIER_T pthread_barrier_t |
#define | THREAD_BARRIER_INIT(barrier, n) pthread_barrier_init((barrier), NULL, (n)) |
#define | THREAD_BARRIER_WAIT(barrier) pthread_barrier_wait((barrier)) |
#define | THREAD_BARRIER_DESTROY(barrier) pthread_barrier_destroy((barrier)) |
#define | DEFAULT_INIT_STEPS "dtgvp" /* default -I setting */ |
#define | ALL_INIT_STEPS "dtgGvpf" /* all possible steps */ |
#define | LOG_STEP_SECONDS 5 /* seconds between log messages */ |
#define | DEFAULT_NXACTS 10 /* default nxacts */ |
#define | MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */ |
#define | MIN_ZIPFIAN_PARAM 1.001 /* minimum parameter for zipfian */ |
#define | MAX_ZIPFIAN_PARAM 1000.0 /* maximum parameter for zipfian */ |
#define | nbranches |
#define | ntellers 10 |
#define | naccounts 100000 |
#define | SCALE_32BIT_THRESHOLD 20000 |
#define | WSEP '@' /* weight separator */ |
#define | VARIABLES_ALLOC_MARGIN 8 |
#define | MAX_SCRIPTS 128 /* max number of SQL scripts allowed */ |
#define | SHELL_COMMAND_SIZE 256 /* maximum size allowed for shell command */ |
#define | SQL_COMMAND 1 |
#define | META_COMMAND 2 |
#define | MAX_ARGS 256 |
#define | PG_TIME_GET_DOUBLE(t) (0.000001 * (t)) |
#define | PARAMS_ARRAY_SIZE 7 |
#define | MAX_FARGS 16 |
#define | COMMANDS_ALLOC_NUM 128 |
Typedefs | |
typedef struct socket_set | socket_set |
typedef struct SimpleStats | SimpleStats |
typedef int64 | pg_time_usec_t |
typedef struct StatsData | StatsData |
typedef enum EStatus | EStatus |
typedef enum TStatus | TStatus |
typedef enum MetaCommand | MetaCommand |
typedef enum QueryMode | QueryMode |
typedef struct Command | Command |
typedef struct ParsedScript | ParsedScript |
typedef struct BuiltinScript | BuiltinScript |
typedef void(* | initRowMethod) (PQExpBufferData *sql, int64 curr) |
Enumerations | |
enum | partition_method_t { PART_NONE , PART_RANGE , PART_HASH } |
enum | EStatus { ESTATUS_NO_ERROR = 0 , ESTATUS_META_COMMAND_ERROR , ESTATUS_SERIALIZATION_ERROR , ESTATUS_DEADLOCK_ERROR , ESTATUS_OTHER_SQL_ERROR } |
enum | TStatus { TSTATUS_IDLE , TSTATUS_IN_BLOCK , TSTATUS_CONN_ERROR , TSTATUS_OTHER_ERROR } |
enum | ConnectionStateEnum { CSTATE_CHOOSE_SCRIPT , CSTATE_START_TX , CSTATE_PREPARE_THROTTLE , CSTATE_THROTTLE , CSTATE_START_COMMAND , CSTATE_WAIT_RESULT , CSTATE_SLEEP , CSTATE_END_COMMAND , CSTATE_SKIP_COMMAND , CSTATE_ERROR , CSTATE_WAIT_ROLLBACK_RESULT , CSTATE_RETRY , CSTATE_FAILURE , CSTATE_END_TX , CSTATE_ABORTED , CSTATE_FINISHED } |
enum | MetaCommand { META_NONE , META_SET , META_SETSHELL , META_SHELL , META_SLEEP , META_GSET , META_ASET , META_IF , META_ELIF , META_ELSE , META_ENDIF , META_STARTPIPELINE , META_SYNCPIPELINE , META_ENDPIPELINE } |
enum | QueryMode { QUERY_SIMPLE , QUERY_EXTENDED , QUERY_PREPARED , NUM_QUERYMODE } |
Functions | |
static void | setNullValue (PgBenchValue *pv) |
static void | setBoolValue (PgBenchValue *pv, bool bval) |
static void | setIntValue (PgBenchValue *pv, int64 ival) |
static void | setDoubleValue (PgBenchValue *pv, double dval) |
static bool | evaluateExpr (CState *st, PgBenchExpr *expr, PgBenchValue *retval) |
static ConnectionStateEnum | executeMetaCommand (CState *st, pg_time_usec_t *now) |
static void | doLog (TState *thread, CState *st, StatsData *agg, bool skipped, double latency, double lag) |
static void | processXactStats (TState *thread, CState *st, pg_time_usec_t *now, bool skipped, StatsData *agg) |
static void | addScript (const ParsedScript *script) |
static THREAD_FUNC_RETURN_TYPE THREAD_FUNC_CC | threadRun (void *arg) |
static void | finishCon (CState *st) |
static void | setalarm (int seconds) |
static socket_set * | alloc_socket_set (int count) |
static void | free_socket_set (socket_set *sa) |
static void | clear_socket_set (socket_set *sa) |
static void | add_socket_to_set (socket_set *sa, int fd, int idx) |
static int | wait_on_socket_set (socket_set *sa, int64 usecs) |
static bool | socket_has_input (socket_set *sa, int fd, int idx) |
static pg_time_usec_t | pg_time_now (void) |
static void | pg_time_now_lazy (pg_time_usec_t *now) |
static void | usage (void) |
static bool | is_an_int (const char *str) |
bool | strtoint64 (const char *str, bool errorOK, int64 *result) |
bool | strtodouble (const char *str, bool errorOK, double *dv) |
static void | initRandomState (pg_prng_state *state) |
static int64 | getrand (pg_prng_state *state, int64 min, int64 max) |
static int64 | getExponentialRand (pg_prng_state *state, int64 min, int64 max, double parameter) |
static int64 | getGaussianRand (pg_prng_state *state, int64 min, int64 max, double parameter) |
static int64 | getPoissonRand (pg_prng_state *state, double center) |
static int64 | computeIterativeZipfian (pg_prng_state *state, int64 n, double s) |
static int64 | getZipfianRand (pg_prng_state *state, int64 min, int64 max, double s) |
static int64 | getHashFnv1a (int64 val, uint64 seed) |
static int64 | getHashMurmur2 (int64 val, uint64 seed) |
static int64 | permute (const int64 val, const int64 isize, const int64 seed) |
static void | initSimpleStats (SimpleStats *ss) |
static void | addToSimpleStats (SimpleStats *ss, double val) |
static void | mergeSimpleStats (SimpleStats *acc, SimpleStats *ss) |
static void | initStats (StatsData *sd, pg_time_usec_t start) |
static void | accumStats (StatsData *stats, bool skipped, double lat, double lag, EStatus estatus, int64 tries) |
static void | executeStatement (PGconn *con, const char *sql) |
static void | tryExecuteStatement (PGconn *con, const char *sql) |
static PGconn * | doConnect (void) |
static int | compareVariableNames (const void *v1, const void *v2) |
static Variable * | lookupVariable (Variables *variables, char *name) |
static char * | getVariable (Variables *variables, char *name) |
static bool | makeVariableValue (Variable *var) |
static bool | valid_variable_name (const char *name) |
static void | enlargeVariables (Variables *variables, int needed) |
static Variable * | lookupCreateVariable (Variables *variables, const char *context, char *name) |
static bool | putVariable (Variables *variables, const char *context, char *name, const char *value) |
static bool | putVariableValue (Variables *variables, const char *context, char *name, const PgBenchValue *value) |
static bool | putVariableInt (Variables *variables, const char *context, char *name, int64 value) |
static char * | parseVariable (const char *sql, int *eaten) |
static char * | replaceVariable (char **sql, char *param, int len, char *value) |
static char * | assignVariables (Variables *variables, char *sql) |
static void | getQueryParams (Variables *variables, const Command *command, const char **params) |
static char * | valueTypeName (PgBenchValue *pval) |
static bool | coerceToBool (PgBenchValue *pval, bool *bval) |
static bool | valueTruth (PgBenchValue *pval) |
static bool | coerceToInt (PgBenchValue *pval, int64 *ival) |
static bool | coerceToDouble (PgBenchValue *pval, double *dval) |
static bool | isLazyFunc (PgBenchFunction func) |
static bool | evalLazyFunc (CState *st, PgBenchFunction func, PgBenchExprLink *args, PgBenchValue *retval) |
static bool | evalStandardFunc (CState *st, PgBenchFunction func, PgBenchExprLink *args, PgBenchValue *retval) |
static bool | evalFunc (CState *st, PgBenchFunction func, PgBenchExprLink *args, PgBenchValue *retval) |
static MetaCommand | getMetaCommand (const char *cmd) |
static bool | runShellCommand (Variables *variables, char *variable, char **argv, int argc) |
static void | commandFailed (CState *st, const char *cmd, const char *message) |
static void | commandError (CState *st, const char *message) |
static int | chooseScript (TState *thread) |
static void | allocCStatePrepared (CState *st) |
static void | prepareCommand (CState *st, int command_num) |
static void | prepareCommandsInPipeline (CState *st) |
static bool | sendCommand (CState *st, Command *command) |
static EStatus | getSQLErrorStatus (const char *sqlState) |
static bool | canRetryError (EStatus estatus) |
static bool | readCommandResponse (CState *st, MetaCommand meta, char *varprefix) |
static bool | evaluateSleep (Variables *variables, int argc, char **argv, int *usecs) |
static bool | doRetry (CState *st, pg_time_usec_t *now) |
static int | discardUntilSync (CState *st) |
static TStatus | getTransactionStatus (PGconn *con) |
static void | printVerboseErrorMessages (CState *st, pg_time_usec_t *now, bool is_retry) |
static void | advanceConnectionState (TState *thread, CState *st, StatsData *agg) |
static int64 | getFailures (const StatsData *stats) |
static const char * | getResultString (bool skipped, EStatus estatus) |
static void | disconnect_all (CState *state, int length) |
static void | initDropTables (PGconn *con) |
static void | createPartitions (PGconn *con) |
static void | initCreateTables (PGconn *con) |
static void | initTruncateTables (PGconn *con) |
static void | initBranch (PQExpBufferData *sql, int64 curr) |
static void | initTeller (PQExpBufferData *sql, int64 curr) |
static void | initAccount (PQExpBufferData *sql, int64 curr) |
static void | initPopulateTable (PGconn *con, const char *table, int64 base, initRowMethod init_row) |
static void | initGenerateDataClientSide (PGconn *con) |
static void | initGenerateDataServerSide (PGconn *con) |
static void | initVacuum (PGconn *con) |
static void | initCreatePKeys (PGconn *con) |
static void | initCreateFKeys (PGconn *con) |
static void | checkInitSteps (const char *initialize_steps) |
static void | runInitSteps (const char *initialize_steps) |
static void | GetTableInfo (PGconn *con, bool scale_given) |
static bool | parseQuery (Command *cmd) |
void | syntax_error (const char *source, int lineno, const char *line, const char *command, const char *msg, const char *more, int column) |
static char * | skip_sql_comments (char *sql_command) |
static Command * | create_sql_command (PQExpBuffer buf, const char *source) |
static void | free_command (Command *command) |
static void | postprocess_sql_command (Command *my_command) |
static Command * | process_backslash_command (PsqlScanState sstate, const char *source) |
static void | ConditionError (const char *desc, int cmdn, const char *msg) |
static void | CheckConditional (const ParsedScript *ps) |
static void | ParseScript (const char *script, const char *desc, int weight) |
static char * | read_file_contents (FILE *fd) |
static void | process_file (const char *filename, int weight) |
static void | process_builtin (const BuiltinScript *bi, int weight) |
static void | listAvailableScripts (void) |
static const BuiltinScript * | findBuiltin (const char *name) |
static int | parseScriptWeight (const char *option, char **script) |
static void | printProgressReport (TState *threads, int64 test_start, pg_time_usec_t now, StatsData *last, int64 *last_report) |
static void | printSimpleStats (const char *prefix, SimpleStats *ss) |
static void | printVersion (PGconn *con) |
static void | printResults (StatsData *total, pg_time_usec_t total_duration, pg_time_usec_t conn_total_duration, pg_time_usec_t conn_elapsed_duration, int64 latency_late) |
static bool | set_random_seed (const char *seed) |
int | main (int argc, char **argv) |
static void | handle_sig_alarm (SIGNAL_ARGS) |
Variables | |
static int | nxacts = 0 |
static int | duration = 0 |
static int64 | end_time = 0 |
static int | scale = 1 |
static int | fillfactor = 100 |
static bool | unlogged_tables = false |
static double | sample_rate = 0.0 |
static double | throttle_delay = 0 |
static int64 | latency_limit = 0 |
static char * | tablespace = NULL |
static char * | index_tablespace = NULL |
static int | partitions = 0 |
static partition_method_t | partition_method = PART_NONE |
static const char *const | PARTITION_METHOD [] = {"none", "range", "hash"} |
static int64 | random_seed = -1 |
static bool | use_log |
static bool | use_quiet |
static int | agg_interval |
static bool | per_script_stats = false |
static int | progress = 0 |
static bool | progress_timestamp = false |
static int | nclients = 1 |
static int | nthreads = 1 |
static bool | is_connect |
static bool | report_per_command = false |
static int | main_pid |
static uint32 | max_tries = 1 |
static bool | failures_detailed = false |
static const char * | pghost = NULL |
static const char * | pgport = NULL |
static const char * | username = NULL |
static const char * | dbName = NULL |
static char * | logfile_prefix = NULL |
static const char * | progname |
static volatile sig_atomic_t | timer_exceeded = false |
static pg_time_usec_t | epoch_shift |
static pg_prng_state | base_random_sequence |
static THREAD_BARRIER_T | barrier |
static QueryMode | querymode = QUERY_SIMPLE |
static const char *const | QUERYMODE [] = {"simple", "extended", "prepared"} |
static ParsedScript | sql_script [MAX_SCRIPTS] |
static int | num_scripts |
static int64 | total_weight = 0 |
static bool | verbose_errors = false |
static bool | exit_on_abort = false |
static const BuiltinScript | builtin_script [] |
static const PsqlScanCallbacks | pgbench_callbacks |
#define COMMANDS_ALLOC_NUM 128 |
#define DEFAULT_INIT_STEPS "dtgvp" /* default -I setting */ |
#define LOG_STEP_SECONDS 5 /* seconds between log messages */ |
#define MAX_SCRIPTS 128 /* max number of SQL scripts allowed */ |
#define MAX_ZIPFIAN_PARAM 1000.0 /* maximum parameter for zipfian */ |
#define MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */ |
#define MIN_ZIPFIAN_PARAM 1.001 /* minimum parameter for zipfian */ |
#define nbranches |
#define PARAMS_ARRAY_SIZE 7 |
#define THREAD_BARRIER_DESTROY | ( | barrier | ) | pthread_barrier_destroy((barrier)) |
#define THREAD_BARRIER_INIT | ( | barrier, | |
n | |||
) | pthread_barrier_init((barrier), NULL, (n)) |
#define THREAD_BARRIER_T pthread_barrier_t |
#define THREAD_BARRIER_WAIT | ( | barrier | ) | pthread_barrier_wait((barrier)) |
#define THREAD_JOIN | ( | handle | ) | pthread_join((handle), NULL) |
typedef struct BuiltinScript BuiltinScript |
typedef void(* initRowMethod) (PQExpBufferData *sql, int64 curr) |
typedef enum MetaCommand MetaCommand |
typedef struct ParsedScript ParsedScript |
typedef int64 pg_time_usec_t |
typedef struct SimpleStats SimpleStats |
typedef struct socket_set socket_set |
enum ConnectionStateEnum |
Definition at line 485 of file pgbench.c.
enum EStatus |
enum MetaCommand |
enum partition_method_t |
enum QueryMode |
enum TStatus |
|
static |
Definition at line 1451 of file pgbench.c.
References addToSimpleStats(), StatsData::cnt, StatsData::deadlock_failures, ESTATUS_DEADLOCK_ERROR, ESTATUS_NO_ERROR, ESTATUS_SERIALIZATION_ERROR, StatsData::lag, StatsData::latency, pg_fatal, StatsData::retried, StatsData::retries, StatsData::serialization_failures, StatsData::skipped, and throttle_delay.
Referenced by doLog(), and processXactStats().
|
static |
Definition at line 7879 of file pgbench.c.
References exit(), fd(), pg_log_error, and pg_log_error_hint.
Referenced by threadRun().
|
static |
Definition at line 6193 of file pgbench.c.
References CheckConditional(), ParsedScript::commands, ParsedScript::desc, MAX_SCRIPTS, num_scripts, pg_fatal, and sql_script.
Referenced by ParseScript().
|
static |
Definition at line 1403 of file pgbench.c.
References SimpleStats::count, SimpleStats::max, SimpleStats::min, SimpleStats::sum, SimpleStats::sum2, and val.
Referenced by accumStats(), and advanceConnectionState().
Definition at line 3589 of file pgbench.c.
References addToSimpleStats(), Assert, canRetryError(), chooseScript(), CState::cnt, CState::command, commandFailed(), ParsedScript::commands, CState::con, conditional_active(), conditional_stack_empty(), conditional_stack_peek(), conditional_stack_poke(), conditional_stack_pop(), conditional_stack_push(), conditional_stack_reset(), TState::conn_duration, CState::cs_func_rs, CState::cstack, CSTATE_ABORTED, CSTATE_CHOOSE_SCRIPT, CSTATE_END_COMMAND, CSTATE_END_TX, CSTATE_ERROR, CSTATE_FAILURE, CSTATE_FINISHED, CSTATE_PREPARE_THROTTLE, CSTATE_RETRY, CSTATE_SKIP_COMMAND, CSTATE_SLEEP, CSTATE_START_COMMAND, CSTATE_START_TX, CSTATE_THROTTLE, CSTATE_WAIT_RESULT, CSTATE_WAIT_ROLLBACK_RESULT, ParsedScript::desc, discardUntilSync(), doConnect(), doRetry(), duration, end_time, CState::estatus, ESTATUS_META_COMMAND_ERROR, ESTATUS_NO_ERROR, executeMetaCommand(), Command::failures, finishCon(), getPoissonRand(), getTransactionStatus(), CState::id, IFSTATE_ELSE_FALSE, IFSTATE_ELSE_TRUE, IFSTATE_FALSE, IFSTATE_IGNORED, IFSTATE_NONE, IFSTATE_TRUE, is_connect, latency_limit, Command::meta, META_ASET, META_COMMAND, META_ELIF, META_ELSE, META_ENDIF, META_GSET, META_IF, now(), nxacts, pg_free(), pg_log_debug, pg_log_error, PG_TIME_GET_DOUBLE, pg_time_now(), pg_time_now_lazy(), PGRES_COMMAND_OK, PQ_PIPELINE_OFF, PQ_PIPELINE_ON, PQclear(), PQconsumeInput(), PQerrorMessage(), PQgetResult(), PQisBusy(), PQpipelineStatus(), PQresultStatus(), PQsendQuery(), CState::prepared, printVerboseErrorMessages(), processXactStats(), CState::random_state, readCommandResponse(), report_per_command, res, Command::retries, sendCommand(), SQL_COMMAND, sql_script, start, CState::state, Command::stats, CState::stmt_begin, throttle_delay, TState::throttle_trigger, timer_exceeded, CState::tries, TState::ts_throttle_rs, TSTATUS_CONN_ERROR, TSTATUS_IDLE, TSTATUS_IN_BLOCK, CState::txn_begin, CState::txn_scheduled, Command::type, CState::use_file, Command::varprefix, and verbose_errors.
Referenced by threadRun().
|
static |
Definition at line 7860 of file pgbench.c.
References pg_malloc0().
Referenced by threadRun().
|
static |
Definition at line 3069 of file pgbench.c.
References Assert, ParsedScript::commands, i, num_scripts, pg_malloc(), pg_malloc0(), CState::prepared, and sql_script.
Referenced by prepareCommand(), and prepareCommandsInPipeline().
|
static |
Definition at line 1936 of file pgbench.c.
References free, getVariable(), name, parseVariable(), replaceVariable(), and val.
Referenced by sendCommand().
Definition at line 3225 of file pgbench.c.
References ESTATUS_DEADLOCK_ERROR, and ESTATUS_SERIALIZATION_ERROR.
Referenced by advanceConnectionState(), doRetry(), and readCommandResponse().
|
static |
Definition at line 5855 of file pgbench.c.
References conditional_stack_create(), conditional_stack_destroy(), conditional_stack_empty(), conditional_stack_peek(), conditional_stack_poke(), conditional_stack_pop(), conditional_stack_push(), ConditionError(), i, IFSTATE_ELSE_FALSE, IFSTATE_FALSE, Command::meta, META_COMMAND, META_ELIF, META_ELSE, META_ENDIF, META_IF, ps, and Command::type.
Referenced by addScript().
|
static |
Definition at line 5203 of file pgbench.c.
References ALL_INIT_STEPS, exit(), pg_fatal, pg_log_error, and pg_log_error_detail.
Referenced by main().
|
static |
Definition at line 3047 of file pgbench.c.
References getrand(), i, num_scripts, sql_script, total_weight, TState::ts_choose_rs, and ParsedScript::weight.
Referenced by advanceConnectionState().
|
static |
Definition at line 7872 of file pgbench.c.
Referenced by threadRun().
|
static |
Definition at line 2004 of file pgbench.c.
References PgBenchValue::bval, pg_log_error, PGBT_BOOLEAN, PgBenchValue::type, PgBenchValue::u, and valueTypeName().
Referenced by evalLazyFunc(), and evalStandardFunc().
|
static |
Definition at line 2073 of file pgbench.c.
References PgBenchValue::dval, PgBenchValue::ival, pg_log_error, PGBT_DOUBLE, PGBT_INT, PgBenchValue::type, PgBenchValue::u, and valueTypeName().
Referenced by evalStandardFunc().
|
static |
Definition at line 2045 of file pgbench.c.
References PgBenchValue::dval, FLOAT8_FITS_IN_INT64, PgBenchValue::ival, pg_log_error, PGBT_DOUBLE, PGBT_INT, PgBenchValue::type, PgBenchValue::u, and valueTypeName().
Referenced by evalStandardFunc().
|
static |
Definition at line 3038 of file pgbench.c.
References Assert, CState::command, ParsedScript::commands, CState::id, pg_log_info, SQL_COMMAND, sql_script, Command::type, and CState::use_file.
Referenced by readCommandResponse().
|
static |
Definition at line 3028 of file pgbench.c.
References CState::command, CState::id, pg_log_error, and CState::use_file.
Referenced by advanceConnectionState(), and executeMetaCommand().
|
static |
Definition at line 1596 of file pgbench.c.
References name.
Referenced by lookupVariable().
|
static |
Definition at line 1201 of file pgbench.c.
References b, pg_prng_double(), and x.
Referenced by getZipfianRand().
|
static |
|
static |
Definition at line 5549 of file pgbench.c.
References appendPQExpBufferStr(), Command::argc, Command::argv, buf, Command::expr, Command::failures, Command::first_line, initPQExpBuffer(), initSimpleStats(), Command::lines, Command::meta, META_NONE, pg_malloc(), Command::prepname, Command::retries, skip_sql_comments(), SQL_COMMAND, Command::stats, Command::type, and Command::varprefix.
Referenced by ParseScript().
|
static |
Definition at line 4739 of file pgbench.c.
References appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), Assert, PQExpBufferData::data, executeStatement(), fillfactor, fprintf, initPQExpBuffer(), INT64_FORMAT, naccounts, PART_HASH, PART_RANGE, partition_method, partitions, printfPQExpBuffer(), scale, termPQExpBuffer(), and unlogged_tables.
Referenced by initCreateTables().
|
static |
Definition at line 3474 of file pgbench.c.
References Assert, CState::con, CState::id, pg_log_error, PGRES_PIPELINE_SYNC, PQclear(), PQexitPipelineMode(), PQgetResult(), PQpipelineSync(), PQresultStatus(), and res.
Referenced by advanceConnectionState().
|
static |
|
static |
Definition at line 1531 of file pgbench.c.
References conn, CONNECTION_BAD, dbName, PARAMS_ARRAY_SIZE, password, pg_log_error, pghost, pgport, PQconnectdbParams(), PQconnectionNeedsPassword(), PQerrorMessage(), PQfinish(), PQstatus(), progname, simple_prompt(), username, and values.
Referenced by advanceConnectionState(), main(), runInitSteps(), and threadRun().
|
static |
Definition at line 4546 of file pgbench.c.
References accumStats(), agg_interval, Assert, StatsData::cnt, CState::cnt, StatsData::deadlock_failures, epoch_shift, CState::estatus, ESTATUS_NO_ERROR, failures_detailed, fprintf, getResultString(), CState::id, initStats(), INT64_FORMAT, StatsData::lag, StatsData::latency, latency_limit, TState::logfile, logfile, SimpleStats::max, max_tries, SimpleStats::min, next, now(), pg_prng_double(), pg_time_now(), StatsData::retried, StatsData::retries, sample_rate, StatsData::serialization_failures, StatsData::skipped, StatsData::start_time, SimpleStats::sum, SimpleStats::sum2, throttle_delay, CState::tries, TState::ts_sample_rs, CState::use_file, and use_log.
Referenced by processXactStats(), and threadRun().
|
static |
Definition at line 3428 of file pgbench.c.
References Assert, canRetryError(), duration, CState::estatus, ESTATUS_NO_ERROR, latency_limit, max_tries, now(), pg_time_now_lazy(), timer_exceeded, CState::tries, and CState::txn_scheduled.
Referenced by advanceConnectionState().
|
static |
Definition at line 1773 of file pgbench.c.
References Variables::max_vars, Variables::nvars, pg_realloc(), VARIABLES_ALLOC_MARGIN, and Variables::vars.
Referenced by lookupCreateVariable().
|
static |
Definition at line 2821 of file pgbench.c.
References generate_unaccent_rules::args, evalLazyFunc(), evalStandardFunc(), and isLazyFunc().
Referenced by evaluateExpr().
|
static |
Definition at line 2132 of file pgbench.c.
References a1, a2, generate_unaccent_rules::args, Assert, coerceToBool(), evaluateExpr(), isLazyFunc(), PGBENCH_AND, PGBENCH_CASE, PGBENCH_OR, PGBT_NULL, setBoolValue(), setNullValue(), and valueTruth().
Referenced by evalFunc().
|
static |
Definition at line 2249 of file pgbench.c.
References generate_unaccent_rules::args, Assert, b, PgBenchValue::bval, coerceToBool(), coerceToDouble(), coerceToInt(), CState::command, CState::cs_func_rs, PgBenchValue::dval, evaluateExpr(), PgBenchExprLink::expr, fprintf, getExponentialRand(), getGaussianRand(), getHashFnv1a(), getHashMurmur2(), getrand(), getZipfianRand(), i, INT64_FORMAT, PgBenchValue::ival, M_PI, Max, MAX_FARGS, MAX_ZIPFIAN_PARAM, Min, MIN_GAUSSIAN_PARAM, MIN_ZIPFIAN_PARAM, PgBenchExprLink::next, permute(), pg_add_s64_overflow(), PG_INT64_MIN, pg_log_error, pg_mul_s64_overflow(), pg_sub_s64_overflow(), PGBENCH_ABS, PGBENCH_ADD, PGBENCH_BITAND, PGBENCH_BITOR, PGBENCH_BITXOR, PGBENCH_DEBUG, PGBENCH_DIV, PGBENCH_DOUBLE, PGBENCH_EQ, PGBENCH_EXP, PGBENCH_GREATEST, PGBENCH_HASH_FNV1A, PGBENCH_HASH_MURMUR2, PGBENCH_INT, PGBENCH_IS, PGBENCH_LE, PGBENCH_LEAST, PGBENCH_LN, PGBENCH_LSHIFT, PGBENCH_LT, PGBENCH_MOD, PGBENCH_MUL, PGBENCH_NE, PGBENCH_NOT, PGBENCH_PERMUTE, PGBENCH_PI, PGBENCH_POW, PGBENCH_RANDOM, PGBENCH_RANDOM_EXPONENTIAL, PGBENCH_RANDOM_GAUSSIAN, PGBENCH_RANDOM_ZIPFIAN, PGBENCH_RSHIFT, PGBENCH_SQRT, PGBENCH_SUB, PGBT_BOOLEAN, PGBT_DOUBLE, PGBT_INT, PGBT_NULL, res, setBoolValue(), setDoubleValue(), setIntValue(), setNullValue(), size, type, PgBenchValue::type, PgBenchValue::u, unlikely, CState::use_file, and val.
Referenced by evalFunc().
|
static |
Definition at line 2837 of file pgbench.c.
References PgBenchExpr::constant, ENODE_CONSTANT, ENODE_FUNCTION, ENODE_VARIABLE, PgBenchExpr::etype, evalFunc(), PgBenchExpr::function, lookupVariable(), makeVariableValue(), pg_fatal, pg_log_error, PgBenchExpr::u, Variable::value, PgBenchExpr::variable, and CState::variables.
Referenced by evalLazyFunc(), evalStandardFunc(), and executeMetaCommand().
Definition at line 3383 of file pgbench.c.
References getVariable(), pg_log_error, and pg_strcasecmp().
Referenced by executeMetaCommand().
|
static |
Definition at line 4285 of file pgbench.c.
References __pg_log_level, appendPQExpBuffer(), Command::argc, Command::argv, Assert, buf, CState::command, commandFailed(), ParsedScript::commands, CState::con, conditional_stack_empty(), conditional_stack_peek(), conditional_stack_poke(), conditional_stack_pop(), conditional_stack_push(), CState::cstack, CSTATE_ABORTED, CSTATE_END_COMMAND, CSTATE_SLEEP, CSTATE_WAIT_RESULT, evaluateExpr(), evaluateSleep(), Command::expr, i, CState::id, IFSTATE_ELSE_FALSE, IFSTATE_ELSE_TRUE, IFSTATE_FALSE, IFSTATE_IGNORED, IFSTATE_NONE, IFSTATE_TRUE, initPQExpBuffer(), Command::meta, META_COMMAND, META_ELIF, META_ELSE, META_ENDIF, META_ENDPIPELINE, META_IF, META_SET, META_SETSHELL, META_SHELL, META_SLEEP, META_STARTPIPELINE, META_SYNCPIPELINE, now(), CState::num_syncs, PG_LOG_DEBUG, pg_log_debug, pg_time_now_lazy(), PQ_PIPELINE_OFF, PQ_PIPELINE_ON, PQenterPipelineMode(), PQpipelineStatus(), PQpipelineSync(), PQsendPipelineSync(), prepareCommandsInPipeline(), printfPQExpBuffer(), putVariableValue(), QUERY_PREPARED, QUERY_SIMPLE, querymode, runShellCommand(), CState::sleep_until, sql_script, termPQExpBuffer(), Command::type, unlikely, CState::use_file, valueTruth(), and CState::variables.
Referenced by advanceConnectionState().
|
static |
Definition at line 1500 of file pgbench.c.
References exit(), pg_log_error, pg_log_error_detail, PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQexec(), PQresultStatus(), and res.
Referenced by createPartitions(), initCreateFKeys(), initCreatePKeys(), initCreateTables(), initDropTables(), initGenerateDataClientSide(), initGenerateDataServerSide(), initTruncateTables(), and initVacuum().
|
static |
Definition at line 6120 of file pgbench.c.
References builtin_script, exit(), i, len, lengthof, listAvailableScripts(), name, and pg_log_error.
Referenced by main().
|
static |
Definition at line 7695 of file pgbench.c.
References CState::con, and PQfinish().
Referenced by advanceConnectionState(), and disconnect_all().
|
static |
Definition at line 5578 of file pgbench.c.
References Command::argc, Command::argv, Command::first_line, i, Command::lines, pg_free(), termPQExpBuffer(), and Command::varprefix.
Referenced by ParseScript().
|
static |
|
static |
Definition at line 1113 of file pgbench.c.
References Assert, and pg_prng_double().
Referenced by evalStandardFunc().
|
static |
Definition at line 4504 of file pgbench.c.
References StatsData::deadlock_failures, and StatsData::serialization_failures.
Referenced by printProgressReport(), and printResults().
|
static |
Definition at line 1137 of file pgbench.c.
References Assert, MIN_GAUSSIAN_PARAM, and pg_prng_double_normal().
Referenced by evalStandardFunc().
|
static |
Definition at line 1245 of file pgbench.c.
References FNV_OFFSET_BASIS, FNV_PRIME, i, and val.
Referenced by evalStandardFunc().
|
static |
Definition at line 1270 of file pgbench.c.
References MM2_MUL, MM2_MUL_TIMES_8, MM2_ROT, and val.
Referenced by evalStandardFunc().
|
static |
Definition at line 2880 of file pgbench.c.
References META_ASET, META_ELIF, META_ELSE, META_ENDIF, META_ENDPIPELINE, META_GSET, META_IF, META_NONE, META_SET, META_SETSHELL, META_SHELL, META_SLEEP, META_STARTPIPELINE, META_SYNCPIPELINE, and pg_strcasecmp().
Referenced by process_backslash_command().
|
static |
Definition at line 1179 of file pgbench.c.
References pg_prng_double().
Referenced by advanceConnectionState().
|
static |
Definition at line 1972 of file pgbench.c.
References Command::argc, Command::argv, getVariable(), and i.
Referenced by sendCommand().
|
static |
Definition at line 1102 of file pgbench.c.
References pg_prng_uint64_range().
Referenced by chooseScript(), and evalStandardFunc().
Definition at line 4515 of file pgbench.c.
References ESTATUS_DEADLOCK_ERROR, ESTATUS_SERIALIZATION_ERROR, failures_detailed, and pg_fatal.
Referenced by doLog().
|
static |
Definition at line 3208 of file pgbench.c.
References ERRCODE_T_R_DEADLOCK_DETECTED, ERRCODE_T_R_SERIALIZATION_FAILURE, ESTATUS_DEADLOCK_ERROR, ESTATUS_OTHER_SQL_ERROR, and ESTATUS_SERIALIZATION_ERROR.
Referenced by readCommandResponse().
Definition at line 5308 of file pgbench.c.
References Assert, ERRCODE_UNDEFINED_TABLE, exit(), PART_HASH, PART_NONE, PART_RANGE, partition_method, partitions, PG_DIAG_SQLSTATE, pg_fatal, pg_log_error, pg_log_error_hint, pg_log_warning, PGRES_TUPLES_OK, PQclear(), PQdb(), PQerrorMessage(), PQexec(), PQgetisnull(), PQgetvalue(), PQntuples(), PQresultErrorField(), PQresultStatus(), ps, res, and scale.
Referenced by main().
Definition at line 3514 of file pgbench.c.
References Assert, CONNECTION_BAD, pg_log_error, PQstatus(), PQTRANS_ACTIVE, PQTRANS_IDLE, PQTRANS_INERROR, PQTRANS_INTRANS, PQTRANS_UNKNOWN, PQtransactionStatus(), TSTATUS_CONN_ERROR, TSTATUS_IDLE, TSTATUS_IN_BLOCK, and TSTATUS_OTHER_ERROR.
Referenced by advanceConnectionState().
|
static |
Definition at line 1631 of file pgbench.c.
References Assert, PgBenchValue::bval, PgBenchValue::dval, INT64_FORMAT, PgBenchValue::ival, lookupVariable(), name, pg_strdup(), PGBT_BOOLEAN, PGBT_DOUBLE, PGBT_INT, PGBT_NO_VALUE, PGBT_NULL, snprintf, Variable::svalue, PgBenchValue::type, PgBenchValue::u, and Variable::value.
Referenced by assignVariables(), evaluateSleep(), getQueryParams(), and runShellCommand().
|
static |
Definition at line 1231 of file pgbench.c.
References Assert, computeIterativeZipfian(), MAX_ZIPFIAN_PARAM, and MIN_ZIPFIAN_PARAM.
Referenced by evalStandardFunc().
|
static |
|
static |
Definition at line 4931 of file pgbench.c.
References INT64_FORMAT, naccounts, and printfPQExpBuffer().
Referenced by initGenerateDataClientSide().
|
static |
Definition at line 4913 of file pgbench.c.
References INT64_FORMAT, and printfPQExpBuffer().
Referenced by initGenerateDataClientSide().
|
static |
Definition at line 5177 of file pgbench.c.
References executeStatement(), fprintf, i, and lengthof.
Referenced by runInitSteps().
|
static |
Definition at line 5139 of file pgbench.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), PQExpBufferData::data, executeStatement(), fprintf, i, index_tablespace, initPQExpBuffer(), lengthof, PQescapeIdentifier(), PQfreemem(), resetPQExpBuffer(), and termPQExpBuffer().
Referenced by runInitSteps().
|
static |
Definition at line 4808 of file pgbench.c.
References appendPQExpBuffer(), createPartitions(), PQExpBufferData::data, executeStatement(), fillfactor, fprintf, i, initPQExpBuffer(), lengthof, PART_NONE, partition_method, PARTITION_METHOD, PQescapeIdentifier(), PQfreemem(), printfPQExpBuffer(), scale, SCALE_32BIT_THRESHOLD, tablespace, termPQExpBuffer(), and unlogged_tables.
Referenced by runInitSteps().
|
static |
Definition at line 4717 of file pgbench.c.
References executeStatement(), and fprintf.
Referenced by runInitSteps().
|
static |
Definition at line 5049 of file pgbench.c.
References executeStatement(), fprintf, initAccount(), initBranch(), initPopulateTable(), initTeller(), initTruncateTables(), naccounts, nbranches, and ntellers.
Referenced by runInitSteps().