Percona-Lab / sysbench-tpcc

Sysbench scripts to generate a tpcc-like workload for MySQL and PostgreSQL
Apache License 2.0
292 stars 104 forks source link

Fix force_pk in PostgreSQL #41

Open nuno-faria opened 3 years ago

nuno-faria commented 3 years ago

The current implementation of the auto incremented primary key in the History table uses id int NOT NULL AUTO_INCREMENT for all database engines. However, the correct code for PostgreSQL should be id serial NOT NULL, as can be confirmed in the docs.

Currently, the prepare results in the following error:

FATAL: PQexec() failed: 7 syntax error at or near "AUTO_INCREMENT"
FATAL: failed query was:        create table IF NOT EXISTS history1 (
        id int NOT NULL AUTO_INCREMENT,
        h_c_id int,
        h_c_d_id smallint,
        h_c_w_id smallint,
        h_d_id smallint,
        h_w_id smallint,
        h_date timestamp,
        h_amount decimal(6,2),
        h_data varchar(24) ,PRIMARY KEY(id)
        )
FATAL: `sysbench.cmdline.call_command' function failed: ./tpcc_common.lua:242: SQL error, errno = 0, state = '42601': syntax error at or near "AUTO_INCREMENT"

This commit fixes this error.