PCPConnInfo* pcpConnInfo;
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")));
HeapTuple tuple;
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)
{
}
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);
char *error = pcp_get_last_error(pcpConnInfo)? pstrdup(pcp_get_last_error(pcpConnInfo)):NULL;
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")));
}
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);
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")));
}
}
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);
char *error = pcp_get_last_error(pcpConnInfo)? pstrdup(pcp_get_last_error(pcpConnInfo)):NULL;
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")));
}
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)
{
}
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);
char *error = pcp_get_last_error(pcpConnInfo)? pstrdup(pcp_get_last_error(pcpConnInfo)):NULL;
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")));
}
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)
{
}
else
{
- ereport(ERROR, (0, errmsg("Wrong number of argument.")));
+ ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument.")));
}
if (gracefully)
char *error = pcp_get_last_error(pcpConnInfo)? pstrdup(pcp_get_last_error(pcpConnInfo)):NULL;
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")));
}
PG_RETURN_BOOL(true);
}
+