@@ -3629,7 +3629,7 @@ initDropTables(PGconn *con)
3629
3629
* with a known size, so we choose to partition it.
3630
3630
*/
3631
3631
static void
3632
- createPartitions (PGconn * con )
3632
+ createPartitions (PGconn * con , const char * tablename )
3633
3633
{
3634
3634
char ff [64 ];
3635
3635
@@ -3644,7 +3644,8 @@ createPartitions(PGconn *con)
3644
3644
/* we must have to create some partitions */
3645
3645
Assert (partitions > 0 );
3646
3646
3647
- fprintf (stderr , "creating %d partitions...\n" , partitions );
3647
+ fprintf (stderr , "creating %d partitions for relation %s...\n" ,
3648
+ partitions , tablename );
3648
3649
3649
3650
for (int p = 1 ; p <= partitions ; p ++ )
3650
3651
{
@@ -3673,18 +3674,20 @@ createPartitions(PGconn *con)
3673
3674
sprintf (maxvalue , "maxvalue" );
3674
3675
3675
3676
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"
3678
3679
" for values from (%s) to (%s)%s\n" ,
3679
- unlogged_tables ? " unlogged" : "" , p ,
3680
+ unlogged_tables ? " unlogged" : "" ,
3681
+ tablename , p , tablename ,
3680
3682
minvalue , maxvalue , ff );
3681
3683
}
3682
3684
else if (partition_method == PART_HASH )
3683
3685
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"
3686
3688
" for values with (modulus %d, remainder %d)%s\n" ,
3687
- unlogged_tables ? " unlogged" : "" , p ,
3689
+ unlogged_tables ? " unlogged" : "" ,
3690
+ tablename , p , tablename ,
3688
3691
partitions , p - 1 , ff );
3689
3692
else /* cannot get there */
3690
3693
Assert (0 );
@@ -3753,14 +3756,25 @@ initCreateTables(PGconn *con)
3753
3756
char buffer [256 ];
3754
3757
const struct ddlinfo * ddl = & DDLs [i ];
3755
3758
const char * cols ;
3759
+ const char * partcolname ;
3756
3760
3757
3761
/* Construct new create table statement. */
3758
3762
opts [0 ] = '\0' ;
3759
3763
3760
3764
/* 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
+
3762
3774
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
+ }
3764
3778
else if (ddl -> declare_fillfactor )
3765
3779
/* fillfactor is only expected on actual tables */
3766
3780
append_fillfactor (opts , sizeof (opts ));
@@ -3783,10 +3797,11 @@ initCreateTables(PGconn *con)
3783
3797
ddl -> table , cols , opts );
3784
3798
3785
3799
executeStatement (con , buffer );
3786
- }
3787
3800
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
+ }
3790
3805
}
3791
3806
3792
3807
/*
0 commit comments