|
1 | 1 | /*
|
2 |
| - * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.27 2003/09/27 19:15:34 wieck Exp $ |
| 2 | + * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.28 2003/11/26 06:53:18 ishii Exp $ |
3 | 3 | *
|
4 | 4 | * pgbench: a simple TPC-B like benchmark program for PostgreSQL
|
5 | 5 | * written by Tatsuo Ishii
|
6 | 6 | *
|
7 |
| - * Copyright (c) 2000-2002 Tatsuo Ishii |
| 7 | + * Copyright (c) 2000-2003 Tatsuo Ishii |
8 | 8 | *
|
9 | 9 | * Permission to use, copy, modify, and distribute this software and
|
10 | 10 | * its documentation for any purpose and without fee is hereby
|
@@ -482,13 +482,19 @@ init(void)
|
482 | 482 | PGresult *res;
|
483 | 483 | static char *DDLs[] = {
|
484 | 484 | "drop table branches",
|
485 |
| - "create table branches(bid int, primary key(bid),bbalance int,filler char(88))", |
| 485 | + "create table branches(bid int not null,bbalance int,filler char(88))", |
486 | 486 | "drop table tellers",
|
487 |
| - "create table tellers(tid int, primary key(tid),bid int,tbalance int,filler char(84))", |
| 487 | + "create table tellers(tid int not null,bid int,tbalance int,filler char(84))", |
488 | 488 | "drop table accounts",
|
489 |
| - "create table accounts(aid int,primary key(aid),bid int,abalance int,filler char(84))", |
| 489 | + "create table accounts(aid int not null,bid int,abalance int,filler char(84))", |
490 | 490 | "drop table history",
|
491 | 491 | "create table history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22))"};
|
| 492 | + static char *DDLAFTERs[] = { |
| 493 | + "alter table branches add primary key (bid)", |
| 494 | + "alter table tellers add primary key (tid)", |
| 495 | + "alter table accounts add primary key (aid)"}; |
| 496 | + |
| 497 | + |
492 | 498 | char sql[256];
|
493 | 499 |
|
494 | 500 | int i;
|
@@ -608,6 +614,17 @@ init(void)
|
608 | 614 | #endif /* NOT_USED */
|
609 | 615 | }
|
610 | 616 | }
|
| 617 | + fprintf(stderr, "set primary key...\n"); |
| 618 | + for (i = 0; i < (sizeof(DDLAFTERs) / sizeof(char *)); i++) |
| 619 | + { |
| 620 | + res = PQexec(con, DDLAFTERs[i]); |
| 621 | + if (strncmp(DDLs[i], "drop", 4) && PQresultStatus(res) != PGRES_COMMAND_OK) |
| 622 | + { |
| 623 | + fprintf(stderr, "%s", PQerrorMessage(con)); |
| 624 | + exit(1); |
| 625 | + } |
| 626 | + PQclear(res); |
| 627 | + } |
611 | 628 |
|
612 | 629 | /* vacuum */
|
613 | 630 | fprintf(stderr, "vacuum...");
|
|
0 commit comments