Unify use of error codes across all exit statements

This commit is contained in:
Greg Smith
2011-02-10 17:49:34 -05:00
parent 7e7c45c61d
commit 78b925ea54
8 changed files with 49 additions and 25 deletions

View File

@@ -36,7 +36,7 @@ establishDBConnection(const char *conninfo, const bool exit_on_error)
if (exit_on_error)
{
PQfinish(conn);
exit(1);
exit(ERR_DB_CON);
}
}
@@ -57,7 +57,7 @@ is_standby(PGconn *conn)
fprintf(stderr, "Can't query server mode: %s", PQerrorMessage(conn));
PQclear(res);
PQfinish(conn);
exit(1);
exit(ERR_NO_DB_CON);
}
if (strcmp(PQgetvalue(res, 0, 0), "f") == 0)
@@ -89,7 +89,7 @@ pg_version(PGconn *conn, char* major_version)
fprintf(stderr, "PQexec failed: %s", PQerrorMessage(conn));
PQclear(res);
PQfinish(conn);
exit(1);
exit(ERR_DB_QUERY);
}
major_version1 = atoi(PQgetvalue(res, 0, 0));
major_version2 = PQgetvalue(res, 0, 1);
@@ -123,7 +123,7 @@ guc_setted(PGconn *conn, const char *parameter, const char *op, const char *valu
fprintf(stderr, "PQexec failed: %s", PQerrorMessage(conn));
PQclear(res);
PQfinish(conn);
exit(1);
exit(ERR_DB_QUERY);
}
if (PQntuples(res) == 0)
{
@@ -152,7 +152,7 @@ get_cluster_size(PGconn *conn)
fprintf(stderr, "PQexec failed: %s", PQerrorMessage(conn));
PQclear(res);
PQfinish(conn);
exit(1);
exit(ERR_DB_QUERY);
}
size = PQgetvalue(res, 0, 0);
PQclear(res);
@@ -184,7 +184,7 @@ getMasterConnection(PGconn *standby_conn, int id, char *cluster, int *master_id)
fprintf(stderr, "Can't get nodes info: %s\n", PQerrorMessage(standby_conn));
PQclear(res1);
PQfinish(standby_conn);
exit(1);
exit(ERR_DB_QUERY);
}
for (i = 0; i < PQntuples(res1); i++)