提交 9b7fea9b 编写于 作者: G Gang Xiong

Remove dead code

上级 5d408fc1
......@@ -514,29 +514,30 @@ void setQEIdentifier(SegmentDatabaseDescriptor *segdbDesc,
{
CdbComponentDatabaseInfo *cdbinfo = segdbDesc->segment_database_info;
MemoryContext oldContext = MemoryContextSwitchTo(mcxt);
StringInfo string = makeStringInfo();
StringInfoData string;
initStringInfo(&string);
/* Format the identity of the segment db. */
if (segdbDesc->segindex >= 0)
{
appendStringInfo(string, "seg%d", segdbDesc->segindex);
appendStringInfo(&string, "seg%d", segdbDesc->segindex);
/* Format the slice index. */
if (sliceIndex > 0)
appendStringInfo(string, " slice%d", sliceIndex);
appendStringInfo(&string, " slice%d", sliceIndex);
}
else
appendStringInfo(string, SEGMENT_IS_ACTIVE_PRIMARY(cdbinfo) ? "entry db" : "mirror entry db");
appendStringInfo(&string, SEGMENT_IS_ACTIVE_PRIMARY(cdbinfo) ? "entry db" : "mirror entry db");
/* Format the connection info. */
appendStringInfo(string, " %s:%d", cdbinfo->hostip, cdbinfo->port);
appendStringInfo(&string, " %s:%d", cdbinfo->hostip, cdbinfo->port);
/* If connected, format the QE's process id. */
if (segdbDesc->backendPid != 0)
appendStringInfo(string, " pid=%d", segdbDesc->backendPid);
appendStringInfo(&string, " pid=%d", segdbDesc->backendPid);
segdbDesc->whoami = string->data;
pfree(string);
segdbDesc->whoami = string.data;
MemoryContextSwitchTo(oldContext);
}
......@@ -202,7 +202,7 @@ cdbdisp_finishCommand(struct CdbDispatcherState *ds,
* Format error messages from the primary gang.
*/
initStringInfo(&buf);
cdbdisp_dumpDispatchResults(ds->primaryResults, &buf, false);
cdbdisp_dumpDispatchResults(ds->primaryResults, &buf);
cdbdisp_destroyDispatcherState(ds);
......
......@@ -510,11 +510,11 @@ cdbdisp_debugDispatchResult(CdbDispatchResult * dispatchResult,
/*
* Format a CdbDispatchResult into a StringInfo buffer provided by caller.
* If verbose = true, reports all info; else reports at most one error.
* It reports at most one error.
*/
void
cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
bool verbose, struct StringInfoData *buf)
struct StringInfoData *buf)
{
int ires;
int nres;
......@@ -540,59 +540,46 @@ cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
resultStatus == PGRES_COPY_IN ||
resultStatus == PGRES_COPY_OUT ||
resultStatus == PGRES_EMPTY_QUERY)
{
if (verbose)
{
char *cmdStatus = PQcmdStatus(pgresult);
oneTrailingNewline(buf);
appendStringInfo(buf, "ok: %s", cmdStatus ? cmdStatus : "");
if (whoami)
appendStringInfo(buf, " (%s)", whoami);
}
}
continue;
/*
* QE error or libpq error
*/
char *pri = PQresultErrorField(pgresult, PG_DIAG_MESSAGE_PRIMARY);
char *dtl = PQresultErrorField(pgresult, PG_DIAG_MESSAGE_DETAIL);
char *ctx = PQresultErrorField(pgresult, PG_DIAG_CONTEXT);
oneTrailingNewline(buf);
if (pri)
{
appendStringInfoString(buf, pri);
}
else
{
char *pri = PQresultErrorField(pgresult, PG_DIAG_MESSAGE_PRIMARY);
char *dtl = PQresultErrorField(pgresult, PG_DIAG_MESSAGE_DETAIL);
char *ctx = PQresultErrorField(pgresult, PG_DIAG_CONTEXT);
elog(LOG, "No primary message?");
appendStringInfoString(buf, PQresultErrorMessage(pgresult));
}
if (whoami)
{
noTrailingNewline(buf);
appendStringInfo(buf, " (%s)", whoami);
}
if (dtl)
{
oneTrailingNewline(buf);
if (pri)
{
appendStringInfoString(buf, pri);
}
else
{
elog(LOG, "No primary message?");
appendStringInfoString(buf, PQresultErrorMessage(pgresult));
}
if (whoami)
{
noTrailingNewline(buf);
appendStringInfo(buf, " (%s)", whoami);
}
if (dtl)
{
oneTrailingNewline(buf);
appendStringInfo(buf, "%s", dtl);
}
if (ctx)
{
oneTrailingNewline(buf);
appendStringInfo(buf, "%s", ctx);
}
if (!verbose)
goto done;
appendStringInfo(buf, "%s", dtl);
}
if (ctx)
{
oneTrailingNewline(buf);
appendStringInfo(buf, "%s", ctx);
}
noTrailingNewline(buf);
return;
}
/*
......@@ -603,12 +590,8 @@ cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
{
oneTrailingNewline(buf);
appendStringInfoString(buf, dispatchResult->error_message->data);
if (!verbose)
goto done;
noTrailingNewline(buf);
}
done:
noTrailingNewline(buf);
}
/*
......@@ -619,7 +602,7 @@ done:
*/
int
cdbdisp_dumpDispatchResults(struct CdbDispatchResults *meleeResults,
struct StringInfoData *buffer, bool verbose)
struct StringInfoData *buffer)
{
CdbDispatchResult *dispatchResult;
......@@ -643,24 +626,7 @@ cdbdisp_dumpDispatchResults(struct CdbDispatchResults *meleeResults,
/*
* Format one QE's result.
*/
cdbdisp_dumpDispatchResult(dispatchResult, verbose, buffer);
/*
* Optionally, format results from the rest of the QEs that got errors.
*/
if (verbose)
{
int i;
for (i = 0; i < meleeResults->resultCount; ++i)
{
dispatchResult = &meleeResults->resultArray[i];
if (i == meleeResults->iFirstError)
continue;
if (dispatchResult->errcode)
cdbdisp_dumpDispatchResult(dispatchResult, verbose, buffer);
}
}
cdbdisp_dumpDispatchResult(dispatchResult, buffer);
return meleeResults->errcode;
}
......@@ -877,7 +843,7 @@ cdbdisp_returnResults(CdbDispatchResults * primaryResults,
/*
* Append error messages to caller's buffer.
*/
cdbdisp_dumpDispatchResult(dispatchResult, false, errmsgbuf);
cdbdisp_dumpDispatchResult(dispatchResult, errmsgbuf);
/*
* Take ownership of this QE's PGresult object(s).
......
......@@ -103,7 +103,7 @@ typedef struct DoConnectParms
int gangId;
/* connect options. GUC etc. */
StringInfo connectOptions;
char *connectOptions;
/* The pthread_t thread handle. */
pthread_t thread;
......@@ -125,7 +125,7 @@ static void disconnectAndDestroyGang(Gang *gp);
static void disconnectAndDestroyAllReaderGangs(bool destroyAllocated);
static bool isTargetPortal(const char *p1, const char *p2);
static void addOptions(StringInfo string, bool iswriter);
static char *makeOptions(bool iswriter);
static bool cleanupGang(Gang * gp);
static void resetSessionForPrimaryGangLoss(void);
static const char* gangTypeToString(GangType);
......@@ -549,7 +549,7 @@ thread_DoConnect(void *arg)
pParms->gangId);
/* check the result in createGang */
cdbconn_doConnect(segdbDesc, gpqeid, pParms->connectOptions->data);
cdbconn_doConnect(segdbDesc, gpqeid, pParms->connectOptions);
}
return (NULL);
......@@ -930,21 +930,25 @@ static void addOneOption(StringInfo string, struct config_generic * guc)
/*
* Add GUCs to option string.
*/
static void addOptions(StringInfo string, bool iswriter)
static char*
makeOptions(bool iswriter)
{
struct config_generic **gucs = get_guc_variables();
int ngucs = get_num_guc_variables();
CdbComponentDatabaseInfo *qdinfo = NULL;
StringInfoData string;
int i;
initStringInfo(&string);
Assert (Gp_role == GP_ROLE_DISPATCH);
LOG_GANG_DEBUG(LOG, "addOptions: iswriter %d", iswriter);
LOG_GANG_DEBUG(LOG, "makeOptions: iswriter %d", iswriter);
qdinfo = &cdb_component_dbs->entry_db_info[0];
appendStringInfo(string, " -c gp_qd_hostname=%s", qdinfo->hostip);
appendStringInfo(string, " -c gp_qd_port=%d", qdinfo->port);
appendStringInfo(&string, " -c gp_qd_hostname=%s", qdinfo->hostip);
appendStringInfo(&string, " -c gp_qd_port=%d", qdinfo->port);
appendStringInfo(string, " -c gp_qd_callback_info=port=%d", PostPortNumber);
appendStringInfo(&string, " -c gp_qd_callback_info=port=%d", PostPortNumber);
/*
* Transactions are tricky.
......@@ -961,13 +965,13 @@ static void addOptions(StringInfo string, bool iswriter)
if (DefaultXactIsoLevel != XACT_READ_COMMITTED)
{
if (DefaultXactIsoLevel == XACT_SERIALIZABLE)
appendStringInfo(string, " -c default_transaction_isolation=serializable");
appendStringInfo(&string, " -c default_transaction_isolation=serializable");
}
if (XactIsoLevel != XACT_READ_COMMITTED)
{
if (XactIsoLevel == XACT_SERIALIZABLE)
appendStringInfo(string, " -c transaction_isolation=serializable");
appendStringInfo(&string, " -c transaction_isolation=serializable");
}
for (i = 0; i < ngucs; ++i)
......@@ -975,8 +979,10 @@ static void addOptions(StringInfo string, bool iswriter)
struct config_generic *guc = gucs[i];
if ((guc->flags & GUC_GPDB_ADDOPT) && (guc->context == PGC_USERSET || procRoleIsSuperuser()))
addOneOption(string, guc);
addOneOption(&string, guc);
}
return string.data;
}
/*
......@@ -989,12 +995,9 @@ static DoConnectParms* makeConnectParms(int parmsCount, GangType type, int gangI
DoConnectParms *doConnectParmsAr = (DoConnectParms*) palloc0(
parmsCount * sizeof(DoConnectParms));
DoConnectParms* pParms = NULL;
StringInfo pOptions = makeStringInfo();
int segdbPerThread = gp_connections_per_thread;
int i = 0;
addOptions(pOptions, type == GANGTYPE_PRIMARY_WRITER);
for (i = 0; i < parmsCount; i++)
{
pParms = &doConnectParmsAr[i];
......@@ -1003,7 +1006,7 @@ static DoConnectParms* makeConnectParms(int parmsCount, GangType type, int gangI
MemSet(&pParms->thread, 0, sizeof(pthread_t));
pParms->db_count = 0;
pParms->type = type;
pParms->connectOptions = pOptions;
pParms->connectOptions = makeOptions(type == GANGTYPE_PRIMARY_WRITER);
pParms->gangId = gangId;
}
return doConnectParmsAr;
......@@ -1020,13 +1023,11 @@ static void destroyConnectParms(DoConnectParms *doConnectParmsAr, int count)
for (i = 0; i < count; i++)
{
DoConnectParms *pParms = &doConnectParmsAr[i];
StringInfo pOptions = pParms->connectOptions;
if (pOptions->data != NULL)
if (pParms->connectOptions != NULL)
{
pfree(pOptions->data);
pOptions->data = NULL;
pfree(pParms->connectOptions);
pParms->connectOptions = NULL;
}
pParms->connectOptions = NULL;
pfree(pParms->segdbDescPtrArray);
pParms->segdbDescPtrArray = NULL;
......
......@@ -244,11 +244,10 @@ cdbdisp_debugDispatchResult(CdbDispatchResult *dispatchResult,
/*
* Format a CdbDispatchResult into a StringInfo buffer provided by caller.
* If verbose = true, reports all results; else reports at most one error.
* It reports at most one error.
*/
void
cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
bool verbose,
struct StringInfoData *buf);
/*
......@@ -259,8 +258,7 @@ cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
*/
int
cdbdisp_dumpDispatchResults(struct CdbDispatchResults *gangResults,
struct StringInfoData *buffer,
bool verbose);
struct StringInfoData *buffer);
/*
* Return sum of the cmdTuples values from CdbDispatchResult
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册