pgpool2.git / summary / log / commit / refs

commit    70c0585cf4b11ff01f22b04f2bd9fc680230b88e
Author:   Tatsuo Ishii <ishii@sraoss.co.jp>
Date:     Tue Jul 07 03:35:10 2020 +0000

    Fix lazy coding of ereport in pgpool_adm extension.
    
    Before it was coded that ereport's "domain" parameters were just "0".
    This generated lots of compiler warning. To fix this give plausible
    error codes to each ereport call.


src/sql/pgpool_adm/pgpool_adm.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/sql/pgpool_adm/pgpool_adm.c b/src/sql/pgpool_adm/pgpool_adm.c index f2295d908..ff6cd04f0 100644 --- a/src/sql/pgpool_adm/pgpool_adm.c +++ b/src/sql/pgpool_adm/pgpool_adm.c @@ -51,7 +51,7 @@ connect_to_server(char *host, int port, char *user, char *pass) pcpConnInfo = pcp_connect(host, port, user, pass, NULL); if (PCPConnectionStatus(pcpConnInfo) != PCP_CONNECTION_OK) - ereport(ERROR, (0, + ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), errmsg("connection to PCP server failed."), errdetail("%s\n", pcp_get_last_error(pcpConnInfo) ? pcp_get_last_error(pcpConnInfo) : "unknown reason"))); @@ -138,7 +138,7 @@ _pcp_node_info(PG_FUNCTION_ARGS) char datebuf[20]; if (nodeID < 0 || nodeID >= MAX_NUM_BACKENDS) - ereport(ERROR, (0, errmsg("NodeID is out of range."))); + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("NodeID is out of range."))); if (PG_NARGS() == 5) { @@ -157,7 +157,7 @@ _pcp_node_info(PG_FUNCTION_ARGS) } else { - ereport(ERROR, (0, errmsg("Wrong number of argument."))); + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument."))); } pcpResInfo = pcp_node_info(pcpConnInfo, nodeID); @@ -167,7 +167,7 @@ _pcp_node_info(PG_FUNCTION_ARGS) pcp_disconnect(pcpConnInfo); pcp_free_connection(pcpConnInfo); - ereport(ERROR, (0, + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to get node information"), errdetail("%s\n", error ? error : "unknown reason"))); } @@ -297,7 +297,7 @@ _pcp_pool_status(PG_FUNCTION_ARGS) else { MemoryContextSwitchTo(oldcontext); - ereport(ERROR, (0, errmsg("Wrong number of argument."))); + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument."))); } pcpResInfo = pcp_pool_status(pcpConnInfo); @@ -309,7 +309,7 @@ _pcp_pool_status(PG_FUNCTION_ARGS) pcp_free_connection(pcpConnInfo); MemoryContextSwitchTo(oldcontext); - ereport(ERROR, (0, + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to get pool status"), errdetail("%s\n", error ? error : "unknown reason"))); } @@ -421,7 +421,7 @@ _pcp_node_count(PG_FUNCTION_ARGS) } else { - ereport(ERROR, (0, errmsg("Wrong number of argument."))); + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument."))); } pcpResInfo = pcp_node_count(pcpConnInfo); @@ -432,7 +432,7 @@ _pcp_node_count(PG_FUNCTION_ARGS) pcp_disconnect(pcpConnInfo); pcp_free_connection(pcpConnInfo); - ereport(ERROR, (0, + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to get node count"), errdetail("%s\n", error ? error : "unknown reason"))); } @@ -462,7 +462,7 @@ _pcp_attach_node(PG_FUNCTION_ARGS) PCPResultInfo *pcpResInfo; if (nodeID < 0 || nodeID >= MAX_NUM_BACKENDS) - ereport(ERROR, (0, errmsg("NodeID is out of range."))); + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("NodeID is out of range."))); if (PG_NARGS() == 5) { @@ -481,7 +481,7 @@ _pcp_attach_node(PG_FUNCTION_ARGS) } else { - ereport(ERROR, (0, errmsg("Wrong number of argument."))); + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument."))); } pcpResInfo = pcp_attach_node(pcpConnInfo, nodeID); @@ -492,7 +492,7 @@ _pcp_attach_node(PG_FUNCTION_ARGS) pcp_disconnect(pcpConnInfo); pcp_free_connection(pcpConnInfo); - ereport(ERROR, (0, + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to attach node"), errdetail("%s\n", error ? error : "unknown reason"))); } @@ -523,7 +523,7 @@ _pcp_detach_node(PG_FUNCTION_ARGS) PCPResultInfo *pcpResInfo; if (nodeID < 0 || nodeID >= MAX_NUM_BACKENDS) - ereport(ERROR, (0, errmsg("NodeID is out of range."))); + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("NodeID is out of range."))); if (PG_NARGS() == 6) { @@ -542,7 +542,7 @@ _pcp_detach_node(PG_FUNCTION_ARGS) } else { - ereport(ERROR, (0, errmsg("Wrong number of argument."))); + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument."))); } if (gracefully) @@ -560,7 +560,7 @@ _pcp_detach_node(PG_FUNCTION_ARGS) pcp_disconnect(pcpConnInfo); pcp_free_connection(pcpConnInfo); - ereport(ERROR, (0, + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to detach node"), errdetail("%s\n", error ? error : "unknown reason"))); } @@ -597,7 +597,7 @@ _pcp_health_check_stats(PG_FUNCTION_ARGS) int i; if (nodeID < 0 || nodeID >= MAX_NUM_BACKENDS) - ereport(ERROR, (0, errmsg("NodeID is out of range."))); + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("NodeID is out of range."))); if (PG_NARGS() == 5) { @@ -616,7 +616,7 @@ _pcp_health_check_stats(PG_FUNCTION_ARGS) } else { - ereport(ERROR, (0, errmsg("Wrong number of argument."))); + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument."))); } pcpResInfo = pcp_health_check_stats(pcpConnInfo, nodeID); @@ -626,7 +626,7 @@ _pcp_health_check_stats(PG_FUNCTION_ARGS) pcp_disconnect(pcpConnInfo); pcp_free_connection(pcpConnInfo); - ereport(ERROR, (0, + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to get node information"), errdetail("%s\n", error ? error : "unknown reason"))); } [parent: cb34604d621f]