@@ -3629,7 +3629,7 @@ initDropTables(PGconn *con)
36293629 * with a known size, so we choose to partition it.
36303630 */
36313631static void
3632- createPartitions (PGconn * con )
3632+ createPartitions (PGconn * con , const char * tablename )
36333633{
36343634 char ff [64 ];
36353635
@@ -3644,7 +3644,8 @@ createPartitions(PGconn *con)
36443644 /* we must have to create some partitions */
36453645 Assert (partitions > 0 );
36463646
3647- fprintf (stderr , "creating %d partitions...\n" , partitions );
3647+ fprintf (stderr , "creating %d partitions for relation %s...\n" ,
3648+ partitions , tablename );
36483649
36493650 for (int p = 1 ; p <= partitions ; p ++ )
36503651 {
@@ -3673,18 +3674,20 @@ createPartitions(PGconn *con)
36733674 sprintf (maxvalue , "maxvalue" );
36743675
36753676 snprintf (query , sizeof (query ),
3676- "create%s table pgbench_accounts_ %d\n"
3677- " partition of pgbench_accounts \n"
3677+ "create%s table %s_ %d\n"
3678+ " partition of %s \n"
36783679 " for values from (%s) to (%s)%s\n" ,
3679- unlogged_tables ? " unlogged" : "" , p ,
3680+ unlogged_tables ? " unlogged" : "" ,
3681+ tablename , p , tablename ,
36803682 minvalue , maxvalue , ff );
36813683 }
36823684 else if (partition_method == PART_HASH )
36833685 snprintf (query , sizeof (query ),
3684- "create%s table pgbench_accounts_ %d\n"
3685- " partition of pgbench_accounts \n"
3686+ "create%s table %s_ %d\n"
3687+ " partition of %s \n"
36863688 " for values with (modulus %d, remainder %d)%s\n" ,
3687- unlogged_tables ? " unlogged" : "" , p ,
3689+ unlogged_tables ? " unlogged" : "" ,
3690+ tablename , p , tablename ,
36883691 partitions , p - 1 , ff );
36893692 else /* cannot get there */
36903693 Assert (0 );
@@ -3753,14 +3756,25 @@ initCreateTables(PGconn *con)
37533756 char buffer [256 ];
37543757 const struct ddlinfo * ddl = & DDLs [i ];
37553758 const char * cols ;
3759+ const char * partcolname ;
37563760
37573761 /* Construct new create table statement. */
37583762 opts [0 ] = '\0' ;
37593763
37603764 /* Partition pgbench_accounts table */
3761- if (partition_method != PART_NONE && strcmp (ddl -> table , "pgbench_accounts" ) == 0 )
3765+ if (partition_method != PART_NONE && strcmp (ddl -> table , "pgbench_history" ) != 0 )
3766+ {
3767+ if (strcmp (ddl -> table , "pgbench_accounts" ) == 0 )
3768+ partcolname = "aid" ;
3769+ else if (strcmp (ddl -> table , "pgbench_branches" ) == 0 )
3770+ partcolname = "bid" ;
3771+ else if (strcmp (ddl -> table , "pgbench_tellers" ) == 0 )
3772+ partcolname = "tid" ;
3773+
37623774 snprintf (opts + strlen (opts ), sizeof (opts ) - strlen (opts ),
3763- " partition by %s (aid)" , PARTITION_METHOD [partition_method ]);
3775+ " partition by %s (%s)" ,
3776+ PARTITION_METHOD [partition_method ], partcolname );
3777+ }
37643778 else if (ddl -> declare_fillfactor )
37653779 /* fillfactor is only expected on actual tables */
37663780 append_fillfactor (opts , sizeof (opts ));
@@ -3783,10 +3797,11 @@ initCreateTables(PGconn *con)
37833797 ddl -> table , cols , opts );
37843798
37853799 executeStatement (con , buffer );
3786- }
37873800
3788- if (partition_method != PART_NONE )
3789- createPartitions (con );
3801+ if (partition_method != PART_NONE &&
3802+ strcmp (ddl -> table , "pgbench_history" ) != 0 )
3803+ createPartitions (con , ddl -> table );
3804+ }
37903805}
37913806
37923807/*
0 commit comments