From 7968bd3cc545bb5e0793e3b833d03fdd0cf2a860 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Mon, 7 Sep 2015 22:24:29 +0900 Subject: [PATCH 3/3] Remove dead code of libpq protocol 3 getRowDescriptions and getAnotherTuple contained a code path that could be used to stop message parsing which is visibly a copy/paste of the equivalent code if protocol 2, however it has never been used. --- src/interfaces/libpq/fe-protocol3.c | 46 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c index e98f99b..9ce791f 100644 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@ -44,9 +44,9 @@ static void handleSyncLoss(PGconn *conn, char id, int msgLength); -static int getRowDescriptions(PGconn *conn, int msgLength); +static void getRowDescriptions(PGconn *conn, int msgLength); static int getParamDescriptions(PGconn *conn, int msgLength); -static int getAnotherTuple(PGconn *conn, int msgLength); +static void getAnotherTuple(PGconn *conn, int msgLength); static int getParameterStatus(PGconn *conn); static int getNotify(PGconn *conn); static int getCopyStart(PGconn *conn, @@ -284,8 +284,7 @@ pqParseInput3(PGconn *conn) conn->queryclass == PGQUERY_DESCRIBE) { /* First 'T' in a query sequence */ - if (getRowDescriptions(conn, msgLength)) - return; + getRowDescriptions(conn, msgLength); /* getRowDescriptions() moves inStart itself */ continue; } @@ -340,8 +339,7 @@ pqParseInput3(PGconn *conn) conn->result->resultStatus == PGRES_TUPLES_OK) { /* Read another tuple of a normal query response */ - if (getAnotherTuple(conn, msgLength)) - return; + getAnotherTuple(conn, msgLength); /* getAnotherTuple() moves inStart itself */ continue; } @@ -461,11 +459,10 @@ handleSyncLoss(PGconn *conn, char id, int msgLength) * parseInput subroutine to read a 'T' (row descriptions) message. * We'll build a new PGresult structure (unless called for a Describe * command for a prepared statement) containing the attribute data. - * Returns: 0 if processed message successfully, EOF to suspend parsing - * (the latter case is not actually used currently). - * In either case, conn->inStart has been advanced past the message. + * This routine assumes that message is always processed successfully + * and conn->inStart is advanced past the message. */ -static int +static void getRowDescriptions(PGconn *conn, int msgLength) { PGresult *result; @@ -588,7 +585,7 @@ getRowDescriptions(PGconn *conn, int msgLength) if (conn->queryclass == PGQUERY_DESCRIBE) { conn->asyncStatus = PGASYNC_READY; - return 0; + return; } /* @@ -597,7 +594,7 @@ getRowDescriptions(PGconn *conn, int msgLength) */ /* And we're done. */ - return 0; + return; advance_and_error: /* Discard unsaved result, if any */ @@ -626,11 +623,11 @@ advance_and_error: pqSaveErrorResult(conn); /* - * Return zero to allow input parsing to continue. Subsequent "D" - * messages will be ignored until we get to end of data, since an error - * result is already set up. + * Return to allow input parsing to continue. Subsequent "D" messages + * will be ignored until we get to end of data, since an error result + * is already set up. */ - return 0; + return; } /* @@ -726,11 +723,10 @@ advance_and_error: /* * parseInput subroutine to read a 'D' (row data) message. * We fill rowbuf with column pointers and then call the row processor. - * Returns: 0 if processed message successfully, EOF to suspend parsing - * (the latter case is not actually used currently). - * In either case, conn->inStart has been advanced past the message. + * This routine always considers that the message has been processed + * successfully, and conn->inStart is advanced past the message. */ -static int +static void getAnotherTuple(PGconn *conn, int msgLength) { PGresult *result = conn->result; @@ -814,7 +810,7 @@ getAnotherTuple(PGconn *conn, int msgLength) /* Process the collected row */ errmsg = NULL; if (pqRowProcessor(conn, &errmsg)) - return 0; /* normal, successful exit */ + return; /* normal, successful exit */ goto set_error_result; /* pqRowProcessor failed, report it */ @@ -843,11 +839,11 @@ set_error_result: pqSaveErrorResult(conn); /* - * Return zero to allow input parsing to continue. Subsequent "D" - * messages will be ignored until we get to end of data, since an error - * result is already set up. + * Return to allow input parsing to continue. Subsequent "D" messages + * will be ignored until we get to end of data, since an error result + * is already set up. */ - return 0; + return; } -- 2.5.1