From 4a62ea3fe4e3d3a6d2fbb35b8ff2c781a2118aa4 Mon Sep 17 00:00:00 2001 From: chanukya Date: Mon, 22 May 2023 18:46:50 +0530 Subject: [PATCH 1/3] code cleanup for check_systemtables() --- bin/pg_repack.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index bed8427d..f3e22712 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -424,7 +424,6 @@ is_superuser(void) bool check_systemtables() - { PGresult *query_result = NULL; int num; @@ -454,12 +453,11 @@ check_systemtables() { if (PQntuples(query_result) >= 1) { + CLEARPGRES(query_result); return true; } } - CLEARPGRES(query_result); - return false; } @@ -529,12 +527,6 @@ preliminary_checks(char *errbuf, size_t errsize){ goto cleanup; } - if (check_systemtables()) { - if (errbuf) - snprintf(errbuf, errsize, "For System Tables Use VACUUM FULL."); - goto cleanup; - } - /* Query the extension version. Exit if no match */ res = execute_elevel("select repack.version(), repack.version_sql()", 0, NULL, DEBUG2); @@ -622,6 +614,12 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ int num_relations; SimpleStringListCell *cell; + if (check_systemtables()) { + if (errbuf) + snprintf(errbuf, errsize,"For System tables use VACUUM FULL."); + return false; + } + num_relations = simple_string_list_size(parent_table_list) + simple_string_list_size(table_list); From 3af859bb81e3bbc1b4ec681559855d6d9da5ff24 Mon Sep 17 00:00:00 2001 From: chanukya Date: Mon, 22 May 2023 19:26:27 +0530 Subject: [PATCH 2/3] check_systemtables code cleanup --- bin/pg_repack.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index f3e22712..881ee966 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -614,6 +614,7 @@ is_requested_relation_exists(char *errbuf, size_t errsize){ int num_relations; SimpleStringListCell *cell; + /*Handling system tables to return meaningful error message*/ if (check_systemtables()) { if (errbuf) snprintf(errbuf, errsize,"For System tables use VACUUM FULL."); From 15cd30ebea5a0bcc24b30767108bc6d2c5902fa0 Mon Sep 17 00:00:00 2001 From: chanukya Date: Tue, 23 May 2023 10:22:59 +0530 Subject: [PATCH 3/3] comments added for better understanding --- bin/pg_repack.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 881ee966..674dce0b 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -422,6 +422,10 @@ is_superuser(void) return false; } + /* + * Check if the tables are System tables releated to pg_catalog or information_schema + * throw a meaning full error to use VACUUM FULL for those tables. + */ bool check_systemtables() {