From 2a2bf643b36ddaacf8faf7fd92a2b4362ce64891 Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Sun, 28 May 2023 23:16:43 +0530 Subject: [PATCH 01/10] initial commit for --exclude-table -X --- bin/pg_repack.c | 52 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 88cd626a..1296252a 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -243,6 +243,7 @@ static bool alldb = false; static bool noorder = false; static SimpleStringList parent_table_list = {NULL, NULL}; static SimpleStringList table_list = {NULL, NULL}; +static SimpleStringList exclude_table_list = {NULL, NULL}; static SimpleStringList schema_list = {NULL, NULL}; static char *orderby = NULL; static char *tablespace = NULL; @@ -287,6 +288,7 @@ static pgut_option options[] = { 'b', 'D', "no-kill-backend", &no_kill_backend }, { 'b', 'k', "no-superuser-check", &no_superuser_check }, { 'l', 'C', "exclude-extension", &exclude_extension_list }, + { 'l', 'X', "exclude-table", &exclude_table_list }, { 'b', 2, "error-on-invalid-index", &error_on_invalid_index }, { 'i', 1, "switch-threshold", &switch_threshold }, { 0 }, @@ -333,6 +335,9 @@ main(int argc, char *argv[]) else if (only_indexes && exclude_extension_list.head) ereport(ERROR, (errcode(EINVAL), errmsg("cannot specify --only-indexes (-x) and --exclude-extension (-C)"))); + else if ((only_indexes || r_index.head) && exclude_table_list.head) + ereport(ERROR, (errcode(EINVAL), + errmsg("cannot specify --only-indexes (-x) or --index (-i) with --exclude-table (-X)"))); else if (alldb) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack specific index(es) in all databases"))); @@ -357,10 +362,15 @@ main(int argc, char *argv[]) } else { - if (schema_list.head && (table_list.head || parent_table_list.head)) + if (schema_list.head && (table_list.head || parent_table_list.head || exclude_table_list.head)) ereport(ERROR, (errcode(EINVAL), - errmsg("cannot repack specific table(s) in schema, use schema.table notation instead"))); + errmsg("cannot repack/exclude specific table(s) in schema, use schema.table notation instead"))); + + if (exclude_table_list.head && (table_list.head || parent_table_list.head || exclude_extension_list.head)) + ereport(ERROR, + (errcode(EINVAL), + errmsg("cannot specify --exclude-table (-X) along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); if (exclude_extension_list.head && table_list.head) ereport(ERROR, @@ -385,6 +395,10 @@ main(int argc, char *argv[]) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack specific schema(s) in all databases"))); + if (exclude_table_list.head) + ereport(ERROR, + (errcode(EINVAL), + errmsg("cannot exclude specific tables(s) in all databases"))); repack_all_databases(orderby); } else @@ -579,7 +593,8 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ SimpleStringListCell *cell; num_relations = simple_string_list_size(parent_table_list) + - simple_string_list_size(table_list); + simple_string_list_size(table_list)+ + simple_string_list_size(exclude_table_list); /* nothing was implicitly requested, so nothing to do here */ if (num_relations == 0) @@ -600,6 +615,13 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ if (iparam < num_relations) appendStringInfoChar(&sql, ','); } + for (cell = exclude_table_list.head; cell; cell = cell->next) + { + appendStringInfo(&sql, "($%d, 'r')", iparam + 1); + params[iparam++] = cell->val; + if (iparam < num_relations) + appendStringInfoChar(&sql, ','); + } for (cell = parent_table_list.head; cell; cell = cell->next) { appendStringInfo(&sql, "($%d, 'p')", iparam + 1); @@ -749,18 +771,21 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) num_tables, num_schemas, num_params, - num_excluded_extensions; + num_excluded_extensions, + num_excluded_tables; num_parent_tables = simple_string_list_size(parent_table_list); num_tables = simple_string_list_size(table_list); num_schemas = simple_string_list_size(schema_list); num_excluded_extensions = simple_string_list_size(exclude_extension_list); + num_excluded_tables = simple_string_list_size(exclude_table_list); /* 1st param is the user-specified tablespace */ num_params = num_excluded_extensions + num_parent_tables + num_tables + - num_schemas + 1; + num_schemas + + num_excluded_tables + 1; params = pgut_malloc(num_params * sizeof(char *)); initStringInfo(&sql); @@ -836,6 +861,20 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) } appendStringInfoString(&sql, ")"); } + else if (num_excluded_tables) + { + appendStringInfoString(&sql, "("); + for (cell = exclude_table_list.head; cell; cell = cell->next) + { + /* Construct exclude table name placeholders to be used by PQexecParams */ + appendStringInfo(&sql, "relid <> $%d::regclass", iparam + 1); + params[iparam++] = cell->val; + elog(INFO, "skipping table \"%s\"", cell->val); + if (cell->next) + appendStringInfoString(&sql, " AND "); + } + appendStringInfoString(&sql, ")"); + } else { appendStringInfoString(&sql, "pkid IS NOT NULL"); @@ -2392,6 +2431,7 @@ pgut_help(bool details) printf(" -Z, --no-analyze don't analyze at end\n"); printf(" -k, --no-superuser-check skip superuser checks in client\n"); printf(" -C, --exclude-extension don't repack tables which belong to specific extension\n"); + printf(" -X, --exclude-table don't repack specific table\n"); printf(" --error-on-invalid-index don't repack tables which belong to specific extension\n"); - printf(" --switch-threshold switch tables when that many tuples are left to catchup\n"); + printf(" --switch-threshold switch tables when that many tuples are left to catchup\n"); } From 5ee5bac4005b983dfa491399110faa597141dbb9 Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Sun, 28 May 2023 23:16:43 +0530 Subject: [PATCH 02/10] initial commit for --exclude-table -X option --- bin/pg_repack.c | 52 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 88cd626a..1296252a 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -243,6 +243,7 @@ static bool alldb = false; static bool noorder = false; static SimpleStringList parent_table_list = {NULL, NULL}; static SimpleStringList table_list = {NULL, NULL}; +static SimpleStringList exclude_table_list = {NULL, NULL}; static SimpleStringList schema_list = {NULL, NULL}; static char *orderby = NULL; static char *tablespace = NULL; @@ -287,6 +288,7 @@ static pgut_option options[] = { 'b', 'D', "no-kill-backend", &no_kill_backend }, { 'b', 'k', "no-superuser-check", &no_superuser_check }, { 'l', 'C', "exclude-extension", &exclude_extension_list }, + { 'l', 'X', "exclude-table", &exclude_table_list }, { 'b', 2, "error-on-invalid-index", &error_on_invalid_index }, { 'i', 1, "switch-threshold", &switch_threshold }, { 0 }, @@ -333,6 +335,9 @@ main(int argc, char *argv[]) else if (only_indexes && exclude_extension_list.head) ereport(ERROR, (errcode(EINVAL), errmsg("cannot specify --only-indexes (-x) and --exclude-extension (-C)"))); + else if ((only_indexes || r_index.head) && exclude_table_list.head) + ereport(ERROR, (errcode(EINVAL), + errmsg("cannot specify --only-indexes (-x) or --index (-i) with --exclude-table (-X)"))); else if (alldb) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack specific index(es) in all databases"))); @@ -357,10 +362,15 @@ main(int argc, char *argv[]) } else { - if (schema_list.head && (table_list.head || parent_table_list.head)) + if (schema_list.head && (table_list.head || parent_table_list.head || exclude_table_list.head)) ereport(ERROR, (errcode(EINVAL), - errmsg("cannot repack specific table(s) in schema, use schema.table notation instead"))); + errmsg("cannot repack/exclude specific table(s) in schema, use schema.table notation instead"))); + + if (exclude_table_list.head && (table_list.head || parent_table_list.head || exclude_extension_list.head)) + ereport(ERROR, + (errcode(EINVAL), + errmsg("cannot specify --exclude-table (-X) along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); if (exclude_extension_list.head && table_list.head) ereport(ERROR, @@ -385,6 +395,10 @@ main(int argc, char *argv[]) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack specific schema(s) in all databases"))); + if (exclude_table_list.head) + ereport(ERROR, + (errcode(EINVAL), + errmsg("cannot exclude specific tables(s) in all databases"))); repack_all_databases(orderby); } else @@ -579,7 +593,8 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ SimpleStringListCell *cell; num_relations = simple_string_list_size(parent_table_list) + - simple_string_list_size(table_list); + simple_string_list_size(table_list)+ + simple_string_list_size(exclude_table_list); /* nothing was implicitly requested, so nothing to do here */ if (num_relations == 0) @@ -600,6 +615,13 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ if (iparam < num_relations) appendStringInfoChar(&sql, ','); } + for (cell = exclude_table_list.head; cell; cell = cell->next) + { + appendStringInfo(&sql, "($%d, 'r')", iparam + 1); + params[iparam++] = cell->val; + if (iparam < num_relations) + appendStringInfoChar(&sql, ','); + } for (cell = parent_table_list.head; cell; cell = cell->next) { appendStringInfo(&sql, "($%d, 'p')", iparam + 1); @@ -749,18 +771,21 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) num_tables, num_schemas, num_params, - num_excluded_extensions; + num_excluded_extensions, + num_excluded_tables; num_parent_tables = simple_string_list_size(parent_table_list); num_tables = simple_string_list_size(table_list); num_schemas = simple_string_list_size(schema_list); num_excluded_extensions = simple_string_list_size(exclude_extension_list); + num_excluded_tables = simple_string_list_size(exclude_table_list); /* 1st param is the user-specified tablespace */ num_params = num_excluded_extensions + num_parent_tables + num_tables + - num_schemas + 1; + num_schemas + + num_excluded_tables + 1; params = pgut_malloc(num_params * sizeof(char *)); initStringInfo(&sql); @@ -836,6 +861,20 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) } appendStringInfoString(&sql, ")"); } + else if (num_excluded_tables) + { + appendStringInfoString(&sql, "("); + for (cell = exclude_table_list.head; cell; cell = cell->next) + { + /* Construct exclude table name placeholders to be used by PQexecParams */ + appendStringInfo(&sql, "relid <> $%d::regclass", iparam + 1); + params[iparam++] = cell->val; + elog(INFO, "skipping table \"%s\"", cell->val); + if (cell->next) + appendStringInfoString(&sql, " AND "); + } + appendStringInfoString(&sql, ")"); + } else { appendStringInfoString(&sql, "pkid IS NOT NULL"); @@ -2392,6 +2431,7 @@ pgut_help(bool details) printf(" -Z, --no-analyze don't analyze at end\n"); printf(" -k, --no-superuser-check skip superuser checks in client\n"); printf(" -C, --exclude-extension don't repack tables which belong to specific extension\n"); + printf(" -X, --exclude-table don't repack specific table\n"); printf(" --error-on-invalid-index don't repack tables which belong to specific extension\n"); - printf(" --switch-threshold switch tables when that many tuples are left to catchup\n"); + printf(" --switch-threshold switch tables when that many tuples are left to catchup\n"); } From 835f49b4b02e0477e719a1b7cd654f9a7259e78c Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Mon, 29 May 2023 21:39:01 +0530 Subject: [PATCH 03/10] adding --exclude-parent-table option --- bin/pg_repack.c | 72 ++++++++++++++++++++++++++++++++++++----------- doc/pg_repack.rst | 20 +++++++++++++ 2 files changed, 76 insertions(+), 16 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 1296252a..af2d134d 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -244,6 +244,7 @@ static bool noorder = false; static SimpleStringList parent_table_list = {NULL, NULL}; static SimpleStringList table_list = {NULL, NULL}; static SimpleStringList exclude_table_list = {NULL, NULL}; +static SimpleStringList exclude_parent_table_list = {NULL, NULL}; static SimpleStringList schema_list = {NULL, NULL}; static char *orderby = NULL; static char *tablespace = NULL; @@ -289,6 +290,7 @@ static pgut_option options[] = { 'b', 'k', "no-superuser-check", &no_superuser_check }, { 'l', 'C', "exclude-extension", &exclude_extension_list }, { 'l', 'X', "exclude-table", &exclude_table_list }, + { 'l', 'Y', "exclude-parent-table", &exclude_parent_table_list }, { 'b', 2, "error-on-invalid-index", &error_on_invalid_index }, { 'i', 1, "switch-threshold", &switch_threshold }, { 0 }, @@ -362,7 +364,7 @@ main(int argc, char *argv[]) } else { - if (schema_list.head && (table_list.head || parent_table_list.head || exclude_table_list.head)) + if (schema_list.head && (table_list.head || parent_table_list.head || exclude_table_list.head || exclude_parent_table_list.head )) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack/exclude specific table(s) in schema, use schema.table notation instead"))); @@ -395,7 +397,7 @@ main(int argc, char *argv[]) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack specific schema(s) in all databases"))); - if (exclude_table_list.head) + if (exclude_table_list.head || exclude_parent_table_list.head) ereport(ERROR, (errcode(EINVAL), errmsg("cannot exclude specific tables(s) in all databases"))); @@ -594,7 +596,8 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ num_relations = simple_string_list_size(parent_table_list) + simple_string_list_size(table_list)+ - simple_string_list_size(exclude_table_list); + simple_string_list_size(exclude_table_list)+ + simple_string_list_size(exclude_parent_table_list); /* nothing was implicitly requested, so nothing to do here */ if (num_relations == 0) @@ -629,6 +632,13 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ if (iparam < num_relations) appendStringInfoChar(&sql, ','); } + for (cell = exclude_parent_table_list.head; cell; cell = cell->next) + { + appendStringInfo(&sql, "($%d, 'p')", iparam + 1); + params[iparam++] = cell->val; + if (iparam < num_relations) + appendStringInfoChar(&sql, ','); + } appendStringInfoString(&sql, ") AS given_t(r,kind) WHERE" /* regular --table relation or inherited --parent-table */ @@ -772,20 +782,25 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) num_schemas, num_params, num_excluded_extensions, - num_excluded_tables; + num_excluded_tables, + num_excluded__parent_tables; + + num_parent_tables = simple_string_list_size(parent_table_list); num_tables = simple_string_list_size(table_list); num_schemas = simple_string_list_size(schema_list); num_excluded_extensions = simple_string_list_size(exclude_extension_list); num_excluded_tables = simple_string_list_size(exclude_table_list); + num_excluded__parent_tables = simple_string_list_size(exclude_parent_table_list); /* 1st param is the user-specified tablespace */ num_params = num_excluded_extensions + num_parent_tables + num_tables + num_schemas + - num_excluded_tables + 1; + num_excluded_tables + + num_excluded__parent_tables + 1; params = pgut_malloc(num_params * sizeof(char *)); initStringInfo(&sql); @@ -861,19 +876,43 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) } appendStringInfoString(&sql, ")"); } - else if (num_excluded_tables) + else if (num_excluded_tables || num_excluded__parent_tables) { - appendStringInfoString(&sql, "("); - for (cell = exclude_table_list.head; cell; cell = cell->next) - { - /* Construct exclude table name placeholders to be used by PQexecParams */ - appendStringInfo(&sql, "relid <> $%d::regclass", iparam + 1); - params[iparam++] = cell->val; - elog(INFO, "skipping table \"%s\"", cell->val); - if (cell->next) - appendStringInfoString(&sql, " AND "); + if (exclude_table_list.head) + { + appendStringInfoString(&sql, "("); + for (cell = exclude_table_list.head; cell; cell = cell->next) + { + /* Construct exclude table name placeholders to be used by PQexecParams */ + appendStringInfo(&sql, "relid <> $%d::regclass", iparam + 1); + params[iparam++] = cell->val; + elog(INFO, "skipping table \"%s\"", cell->val); + if (cell->next) + appendStringInfoString(&sql, " AND "); + } + appendStringInfoString(&sql, ")"); } - appendStringInfoString(&sql, ")"); + if (exclude_parent_table_list.head) + { + if (exclude_table_list.head) + appendStringInfoString(&sql, "AND ("); + else + appendStringInfoString(&sql, " ("); + for (cell = exclude_parent_table_list.head; cell; cell = cell->next) + { + /* Construct table name placeholders to be used by PQexecParams */ + appendStringInfo(&sql, + "relid <> ALL(repack.get_table_and_inheritors($%d::regclass))", + iparam + 1); + params[iparam++] = cell->val; + elog(INFO, "skipping parent table \"%s\" with its inheritors", cell->val); + if (cell->next) + appendStringInfoString(&sql, " AND "); + } + appendStringInfoString(&sql, ")"); + } + + } else { @@ -2432,6 +2471,7 @@ pgut_help(bool details) printf(" -k, --no-superuser-check skip superuser checks in client\n"); printf(" -C, --exclude-extension don't repack tables which belong to specific extension\n"); printf(" -X, --exclude-table don't repack specific table\n"); + printf(" -Y, --exclude-parent-table don't repack specific table and its inheritors\n"); printf(" --error-on-invalid-index don't repack tables which belong to specific extension\n"); printf(" --switch-threshold switch tables when that many tuples are left to catchup\n"); } diff --git a/doc/pg_repack.rst b/doc/pg_repack.rst index 35eddc3e..b2eeac48 100644 --- a/doc/pg_repack.rst +++ b/doc/pg_repack.rst @@ -123,6 +123,8 @@ Options: -Z, --no-analyze don't analyze at end -k, --no-superuser-check skip superuser checks in client -C, --exclude-extension don't repack tables which belong to specific extension + -X, --exclude-table don't repack specific table + -Y, --exclude-parent-table don't repack specific table and its inheritors --error-on-invalid-index don't repack when invalid index is found --switch-threshold switch tables when that many tuples are left to catchup @@ -226,6 +228,14 @@ Reorg Options Skip tables that belong to the specified extension(s). Some extensions may heavily depend on such tables at planning time etc. +``-X``, ``--exclude-table`` + Skip the specified table(s) only to repack. Multiple tables may be skipped by + writing multiple ``-X`` switches. + +``-Y``, ``--exclude-parent-table`` + Skip the specified parent table(s) and its inheritors to repack. Multiple tables + may be skipped by writing multiple ``-Y`` switches. + ``--switch-threshold`` Switch tables when that many tuples are left in log table. This setting can be used to avoid the inability to catchup with write-heavy tables. @@ -326,6 +336,16 @@ Move the specified index to tablespace ``tbs``:: $ pg_repack -d test --index idx --tablespace tbs +Skip the specified table(s) to repack ``foo`` in schema ``schema`` in +the database ``test``:: + + $ pg_repack -d test -X schema.foo + +Skip the specified parent table(s) and its inheritors to repack ``foo`` in +schema ``schema`` in the database ``test``:: + + $ pg_repack -d test -Y schema.foo + Diagnostics ----------- From f86e852fb601313deb85f0835e54c1ca8d580fc6 Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Mon, 29 May 2023 21:54:25 +0530 Subject: [PATCH 04/10] meaning full info for options --- bin/pg_repack.c | 2 +- doc/pg_repack.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index af2d134d..e7a3b228 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -2471,7 +2471,7 @@ pgut_help(bool details) printf(" -k, --no-superuser-check skip superuser checks in client\n"); printf(" -C, --exclude-extension don't repack tables which belong to specific extension\n"); printf(" -X, --exclude-table don't repack specific table\n"); - printf(" -Y, --exclude-parent-table don't repack specific table and its inheritors\n"); + printf(" -Y, --exclude-parent-table don't repack specific parent table and its inheritors\n"); printf(" --error-on-invalid-index don't repack tables which belong to specific extension\n"); printf(" --switch-threshold switch tables when that many tuples are left to catchup\n"); } diff --git a/doc/pg_repack.rst b/doc/pg_repack.rst index b2eeac48..a7f319b5 100644 --- a/doc/pg_repack.rst +++ b/doc/pg_repack.rst @@ -124,7 +124,7 @@ Options: -k, --no-superuser-check skip superuser checks in client -C, --exclude-extension don't repack tables which belong to specific extension -X, --exclude-table don't repack specific table - -Y, --exclude-parent-table don't repack specific table and its inheritors + -Y, --exclude-parent-table don't repack specific parent table and its inheritors --error-on-invalid-index don't repack when invalid index is found --switch-threshold switch tables when that many tuples are left to catchup From 740a7ce81dfc7d3df50aa368dc136d297d4d5be7 Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Mon, 29 May 2023 22:23:07 +0530 Subject: [PATCH 05/10] adding necessary checks --- bin/pg_repack.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index e7a3b228..6f9411bb 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -373,6 +373,11 @@ main(int argc, char *argv[]) ereport(ERROR, (errcode(EINVAL), errmsg("cannot specify --exclude-table (-X) along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); + + if (exclude_parent_table_list.head && (table_list.head || parent_table_list.head || exclude_extension_list.head)) + ereport(ERROR, + (errcode(EINVAL), + errmsg("cannot specify --exclude-parent-table (-Y) along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); if (exclude_extension_list.head && table_list.head) ereport(ERROR, From e51501da8ee73072632d3289214cfad208aa586e Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Wed, 21 Jun 2023 16:14:11 +0530 Subject: [PATCH 06/10] if condition checking split --- bin/pg_repack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 6f9411bb..4ec13f72 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -364,10 +364,15 @@ main(int argc, char *argv[]) } else { - if (schema_list.head && (table_list.head || parent_table_list.head || exclude_table_list.head || exclude_parent_table_list.head )) + if (schema_list.head && (table_list.head || parent_table_list.head )) ereport(ERROR, (errcode(EINVAL), - errmsg("cannot repack/exclude specific table(s) in schema, use schema.table notation instead"))); + errmsg("cannot repack specific table(s) in schema, use schema.table notation instead"))); + + if (schema_list.head && ( exclude_table_list.head || exclude_parent_table_list.head )) + ereport(ERROR, + (errcode(EINVAL), + errmsg("cannot exclude specific table(s) in schema, use schema.table notation instead"))); if (exclude_table_list.head && (table_list.head || parent_table_list.head || exclude_extension_list.head)) ereport(ERROR, From 2ecdf37d9c0e2e3558411be7f92be30a22f6484b Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Tue, 18 Jul 2023 15:02:18 +0530 Subject: [PATCH 07/10] clearing white spaces --- bin/pg_repack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 4ec13f72..bfb3d485 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -364,7 +364,7 @@ main(int argc, char *argv[]) } else { - if (schema_list.head && (table_list.head || parent_table_list.head )) + if (schema_list.head && (table_list.head || parent_table_list.head)) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack specific table(s) in schema, use schema.table notation instead"))); From 9a0ce6d2bfdaaa9abc6de4e536fc9c54d723339c Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Tue, 18 Jul 2023 15:39:03 +0530 Subject: [PATCH 08/10] providing only long option names --- bin/pg_repack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index bfb3d485..c2f8dc04 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -289,8 +289,8 @@ static pgut_option options[] = { 'b', 'D', "no-kill-backend", &no_kill_backend }, { 'b', 'k', "no-superuser-check", &no_superuser_check }, { 'l', 'C', "exclude-extension", &exclude_extension_list }, - { 'l', 'X', "exclude-table", &exclude_table_list }, - { 'l', 'Y', "exclude-parent-table", &exclude_parent_table_list }, + { 'l', 4, "exclude-table", &exclude_table_list }, + { 'l', 3, "exclude-parent-table", &exclude_parent_table_list }, { 'b', 2, "error-on-invalid-index", &error_on_invalid_index }, { 'i', 1, "switch-threshold", &switch_threshold }, { 0 }, @@ -2480,8 +2480,8 @@ pgut_help(bool details) printf(" -Z, --no-analyze don't analyze at end\n"); printf(" -k, --no-superuser-check skip superuser checks in client\n"); printf(" -C, --exclude-extension don't repack tables which belong to specific extension\n"); - printf(" -X, --exclude-table don't repack specific table\n"); - printf(" -Y, --exclude-parent-table don't repack specific parent table and its inheritors\n"); + printf(" --exclude-table don't repack specific table\n"); + printf(" --exclude-parent-table don't repack specific parent table and its inheritors\n"); printf(" --error-on-invalid-index don't repack tables which belong to specific extension\n"); printf(" --switch-threshold switch tables when that many tuples are left to catchup\n"); } From 62449b6ebfc8f4a556427a36301a3f47f62374f3 Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Tue, 18 Jul 2023 17:55:43 +0530 Subject: [PATCH 09/10] documentation update --- doc/pg_repack.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/pg_repack.rst b/doc/pg_repack.rst index a7f319b5..2fbb4d7b 100644 --- a/doc/pg_repack.rst +++ b/doc/pg_repack.rst @@ -123,8 +123,8 @@ Options: -Z, --no-analyze don't analyze at end -k, --no-superuser-check skip superuser checks in client -C, --exclude-extension don't repack tables which belong to specific extension - -X, --exclude-table don't repack specific table - -Y, --exclude-parent-table don't repack specific parent table and its inheritors + --exclude-table don't repack specific table + --exclude-parent-table don't repack specific parent table and its inheritors --error-on-invalid-index don't repack when invalid index is found --switch-threshold switch tables when that many tuples are left to catchup @@ -228,13 +228,13 @@ Reorg Options Skip tables that belong to the specified extension(s). Some extensions may heavily depend on such tables at planning time etc. -``-X``, ``--exclude-table`` +``--exclude-table`` Skip the specified table(s) only to repack. Multiple tables may be skipped by - writing multiple ``-X`` switches. + writing multiple ``--exclude-table`` switches. -``-Y``, ``--exclude-parent-table`` +``--exclude-parent-table`` Skip the specified parent table(s) and its inheritors to repack. Multiple tables - may be skipped by writing multiple ``-Y`` switches. + may be skipped by writing multiple ``--exclude-parent-table`` switches. ``--switch-threshold`` Switch tables when that many tuples are left in log table. @@ -339,12 +339,12 @@ Move the specified index to tablespace ``tbs``:: Skip the specified table(s) to repack ``foo`` in schema ``schema`` in the database ``test``:: - $ pg_repack -d test -X schema.foo + $ pg_repack -d test --exclude-table schema.foo Skip the specified parent table(s) and its inheritors to repack ``foo`` in schema ``schema`` in the database ``test``:: - $ pg_repack -d test -Y schema.foo + $ pg_repack -d test --exclude-parent-table schema.foo Diagnostics From a3e32bde62ea36f9cf1c2f2864cdc34e94b1e6f2 Mon Sep 17 00:00:00 2001 From: chanukyasds Date: Wed, 19 Jul 2023 13:19:35 +0530 Subject: [PATCH 10/10] code cleanup --- bin/pg_repack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index c2f8dc04..1702a4fd 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -339,7 +339,7 @@ main(int argc, char *argv[]) errmsg("cannot specify --only-indexes (-x) and --exclude-extension (-C)"))); else if ((only_indexes || r_index.head) && exclude_table_list.head) ereport(ERROR, (errcode(EINVAL), - errmsg("cannot specify --only-indexes (-x) or --index (-i) with --exclude-table (-X)"))); + errmsg("cannot specify --only-indexes (-x) or --index (-i) with --exclude-table"))); else if (alldb) ereport(ERROR, (errcode(EINVAL), errmsg("cannot repack specific index(es) in all databases"))); @@ -377,12 +377,12 @@ main(int argc, char *argv[]) if (exclude_table_list.head && (table_list.head || parent_table_list.head || exclude_extension_list.head)) ereport(ERROR, (errcode(EINVAL), - errmsg("cannot specify --exclude-table (-X) along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); + errmsg("cannot specify --exclude-table along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); if (exclude_parent_table_list.head && (table_list.head || parent_table_list.head || exclude_extension_list.head)) ereport(ERROR, (errcode(EINVAL), - errmsg("cannot specify --exclude-parent-table (-Y) along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); + errmsg("cannot specify --exclude-parent-table along with --table (-t), --parent-table (-I) and --exclude-extension (-C)"))); if (exclude_extension_list.head && table_list.head) ereport(ERROR,