I've got CI setup and building and the tests now pass, I was missing a CASCADE in my test. New patch attached:
On Thu, 30 Jun 2022 at 10:50, Michel Pelletier <mic...@supabase.io> wrote: > On Thu, 30 Jun 2022 at 09:51, Justin Pryzby <pry...@telsasoft.com> wrote: > >> On Thu, Jun 30, 2022 at 09:09:17AM -0700, Michel Pelletier wrote: >> > This change was originally authored by Alexander Korotkov, I have >> updated >> > it and added a test to the pgbench runner. I'm hoping to make the >> deadline >> > for this currently open Commit Fest? >> >> This is failing check-world >> http://cfbot.cputube.org/michel-pelletier.html >> >> BTW, you can test your patches the same as cfbot does (before mailing the >> list) >> on 4 OSes by pushing a branch to a github account. See >> ./src/tools/ci/README >> >> Ah that's very helpful thank you! This is my first patch submission so > sorry for any mixups. > > -Michel >
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index fbb74bdc4c..80b57e8a87 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -223,6 +223,11 @@ double throttle_delay = 0; */ int64 latency_limit = 0; +/* + * tableam selection + */ +char *tableam = NULL; + /* * tablespace selection */ @@ -890,6 +895,7 @@ usage(void) " --partition-method=(range|hash)\n" " partition pgbench_accounts with this method (default: range)\n" " --partitions=NUM partition pgbench_accounts into NUM parts (default: 0)\n" + " --tableam=TABLEAM create tables using the specified Table Access Method\n" " --tablespace=TABLESPACE create tables in the specified tablespace\n" " --unlogged-tables create tables as unlogged tables\n" "\nOptions to select what to run:\n" @@ -4705,14 +4711,34 @@ createPartitions(PGconn *con) appendPQExpBufferStr(&query, "maxvalue"); appendPQExpBufferChar(&query, ')'); + + if (tableam != NULL) + { + char *escape_tableam; + + escape_tableam = PQescapeIdentifier(con, tableam, strlen(tableam)); + appendPQExpBuffer(&query, " using %s", escape_tableam); + PQfreemem(escape_tableam); + } } else if (partition_method == PART_HASH) + { printfPQExpBuffer(&query, "create%s table pgbench_accounts_%d\n" " partition of pgbench_accounts\n" " for values with (modulus %d, remainder %d)", unlogged_tables ? " unlogged" : "", p, partitions, p - 1); + + if (tableam != NULL) + { + char *escape_tableam; + + escape_tableam = PQescapeIdentifier(con, tableam, strlen(tableam)); + appendPQExpBuffer(&query, " using %s", escape_tableam); + PQfreemem(escape_tableam); + } + } else /* cannot get there */ Assert(0); @@ -4799,10 +4825,20 @@ initCreateTables(PGconn *con) if (partition_method != PART_NONE && strcmp(ddl->table, "pgbench_accounts") == 0) appendPQExpBuffer(&query, " partition by %s (aid)", PARTITION_METHOD[partition_method]); - else if (ddl->declare_fillfactor) + else { + if (tableam != NULL) + { + char *escape_tableam; + + escape_tableam = PQescapeIdentifier(con, tableam, strlen(tableam)); + appendPQExpBuffer(&query, " using %s", escape_tableam); + PQfreemem(escape_tableam); + } + /* fillfactor is only expected on actual tables */ - appendPQExpBuffer(&query, " with (fillfactor=%d)", fillfactor); + if (ddl->declare_fillfactor) + appendPQExpBuffer(&query, " with (fillfactor=%d)", fillfactor); } if (tablespace != NULL) @@ -6556,6 +6592,7 @@ main(int argc, char **argv) {"failures-detailed", no_argument, NULL, 13}, {"max-tries", required_argument, NULL, 14}, {"verbose-errors", no_argument, NULL, 15}, + {"tableam", required_argument, NULL, 16}, {NULL, 0, NULL, 0} }; @@ -6898,6 +6935,10 @@ main(int argc, char **argv) benchmarking_option_set = true; verbose_errors = true; break; + case 16: /* tableam */ + initialization_option_set = true; + tableam = pg_strdup(optarg); + break; default: /* getopt_long already emitted a complaint */ pg_log_error_hint("Try \"%s --help\" for more information.", progname); diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index 2c0dc36965..c33df7b829 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -1418,6 +1418,23 @@ SELECT pg_advisory_unlock_all(); # Clean up $node->safe_psql('postgres', 'DROP TABLE first_client_table, xy;'); +# Test table access method +$node->safe_psql('postgres', 'CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler;'); + +# Initialize pgbench table am +$node->pgbench( + '-i --tableam=heap2', 0, + [qr{^$}], + [ + qr{creating tables}, + qr{vacuuming}, + qr{creating primary keys}, + qr{done in \d+\.\d\d s } + ], + 'pgbench test tableam options'); + +# Clean up +$node->safe_psql('postgres', 'DROP ACCESS METHOD heap2 CASCADE;'); # done $node->safe_psql('postgres', 'DROP TABLESPACE regress_pgbench_tap_1_ts');