Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

This commit fixes several bugs:

1. --status does not work
2. Failed to set xc_maintenance_mode. () message is printed.

First of all, now --status is a submode of --verbose.   It was modified
to handle --status as --verbose.   This is a quick fix and should improve
in the next major release.

Second was caused by SET XC_MAINTENANCE_MODE = ON to template0.  It is
not correct and now template0 was skipped.
  • Loading branch information...
commit 87cdc18b19a6b24b09123fc745b7e9ef4596402b 1 parent e4c3390
Koichi Suzuki authored
Showing with 26 additions and 7 deletions.
  1. +21 −2 contrib/pgxc_clean/pgxc_clean.c
  2. +5 −5 contrib/pgxc_clean/txninfo.c
23 contrib/pgxc_clean/pgxc_clean.c
View
@@ -44,6 +44,7 @@
#include <stdio.h>
#include <pwd.h>
#include <errno.h>
+#include <string.h>
#include "libpq-fe.h"
#include "pg_config.h"
#include "getopt_long.h"
@@ -223,6 +224,9 @@ int main(int argc, char *argv[])
fprintf(outf, "no-clean: %s\n", no_clean_opt ? "on" : "off");
}
+ /* Tweak options --> should be improved in the next releases */
+ if (status_opt)
+ verbose_opt = true;
/* Connect to XC server */
if (verbose_opt)
{
@@ -259,7 +263,8 @@ int main(int argc, char *argv[])
* If such node-subset database is found to be used widely, pgxc_clean may need
* an extension to deal with this case.
*/
- getDatabaseList(coord_conn);
+ if (clean_all_databases)
+ getDatabaseList(coord_conn);
if (verbose_opt)
{
database_info *cur_database;
@@ -762,6 +767,7 @@ getDatabaseList(PGconn *conn)
int database_count;
int ii;
PGresult *res;
+ char *dbname;
/* SQL Statement */
static const char *STMT_GET_DATABASE_LIST = "SELECT DATNAME FROM PG_DATABASE;";
@@ -778,7 +784,13 @@ getDatabaseList(PGconn *conn)
}
database_count = PQntuples(res);
for(ii = 0; ii < database_count; ii++)
- add_database_info(PQgetvalue(res, ii, 0));
+ {
+ dbname = PQgetvalue(res, ii, 0);
+ if (strcmp(dbname, "template0") == 0)
+ /* Skip template0 database */
+ continue;
+ add_database_info(dbname);
+ }
PQclear(res);
}
@@ -979,7 +991,14 @@ parse_pgxc_clean_options(int argc, char *argv[])
while (argc - optind >= 1)
{
if (head_database_names == NULL)
+ {
+ if (strcmp(argv[optind], "template0") == 0)
+ {
+ fprintf(stderr, "%s: You should not clean template0 database.\n", progname);
+ exit(1);
+ }
add_to_database_list(argv[optind]);
+ }
if (username == NULL)
username = argv[optind];
else
10 contrib/pgxc_clean/txninfo.c
View
@@ -152,7 +152,7 @@ make_txn_info(char *dbname, TransactionId gxid, char *xid, char *owner)
txn->txn_stat = (TXN_STATUS *)malloc(sizeof(TXN_STATUS) * pgxc_clean_node_count);
if (txn->txn_stat == NULL)
return(NULL);
- memset(txn->txn_stat, sizeof(TXN_STATUS) * pgxc_clean_node_count, 0);
+ memset(txn->txn_stat, 0, sizeof(TXN_STATUS) * pgxc_clean_node_count);
return txn;
}
@@ -171,7 +171,7 @@ txn_info *init_txn_info(char *database_name, TransactionId gxid)
database->head_txn_info = database->last_txn_info = (txn_info *)malloc(sizeof(txn_info));
if (database->head_txn_info == NULL)
return NULL;
- memset(database->head_txn_info, sizeof(txn_info), 0);
+ memset(database->head_txn_info, 0, sizeof(txn_info));
return database->head_txn_info;
}
for(cur_txn_info = database->head_txn_info; cur_txn_info; cur_txn_info = cur_txn_info->next)
@@ -182,10 +182,10 @@ txn_info *init_txn_info(char *database_name, TransactionId gxid)
cur_txn_info->next = database->last_txn_info = (txn_info *)malloc(sizeof(txn_info));
if (cur_txn_info->next == NULL)
return(NULL);
- memset(cur_txn_info->next, sizeof(txn_info), 0);
+ memset(cur_txn_info->next, 0, sizeof(txn_info));
if ((cur_txn_info->next->txn_stat = (TXN_STATUS *)malloc(sizeof(TXN_STATUS) * pgxc_clean_node_count)) == NULL)
return(NULL);
- memset(cur_txn_info->next->txn_stat, sizeof(TXN_STATUS) * pgxc_clean_node_count, 0);
+ memset(cur_txn_info->next->txn_stat, 0, sizeof(TXN_STATUS) * pgxc_clean_node_count);
return cur_txn_info->next;
}
@@ -249,7 +249,7 @@ TXN_STATUS check_txn_global_status(txn_info *txn)
return TXN_STATUS_INITIAL;
for (ii = 0; ii < pgxc_clean_node_count; ii++)
{
- if (txn->txn_stat[ii] == TXN_STATUS_INITIAL)
+ if (txn->txn_stat[ii] == TXN_STATUS_INITIAL || txn->txn_stat[ii] == TXN_STATUS_UNKNOWN)
continue;
else if (txn->txn_stat[ii] == TXN_STATUS_PREPARED)
check_flag |= TXN_PREPARED;
Please sign in to comment.
Something went wrong with that request. Please try again.