Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XELl6-0002Jn-7j for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Aug 2014 17:09:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XELl4-0005Rs-Qb for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Aug 2014 17:09:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XELUV-0004vo-E2 for pgsql-bugs@postgresql.org; Mon, 04 Aug 2014 16:52:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XELUR-0008JU-Fv for pgsql-bugs@postgresql.org; Mon, 04 Aug 2014 16:52:06 +0000 MIME-Version: 1.0 Subject: BUG #11121: Error not properly reported when calling PQputCopyData with a column missing To: pgsql-bugs@postgresql.org From: menotyou@gmail.com Date: Mon, 04 Aug 2014 16:51:07 +0000 Message-ID: <20140804165107.2707.2545@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 11121 Logged by: Jay Carlson Email address: menotyou@gmail.com PostgreSQL version: 9.3.4 Operating system: Windows 7 (64 Bit) Description: The short version: After successfully calling calling PQexec to COPY_IN from STDIN, I noticed calling PQputCopyData with a buffer that does not contain all of the required columns and an incorrectly formatted column, an error is not generated and PQputCopyEnd will not leave PGRES_COPY_IN mode. An error for this situation is only ennunciated after PQputCopyData is called again AFTER calling PQputCopyEnd. THE DETAILS: Here is the format of the status_data table: ++ test_id: integer ++ device_id: integer ++ time_stamp: timestamp with time zone ++ mem_map_detail_id: integer ++ value: text First I'm successfully calling PQexec with "COPY status_data (test_id, device_id, time_stamp, mem_map_detail_id, value) FROM STDIN" ---------------------------------- PQputCopyData 1: (No error expected) If I call PQputCopyData with the following the result is 1 (Success): "1\t3\t07/25/2014\t48811\tHey1\n" At this point after calling PQgetResult: PQresultStatus returns 4 (PGRES_COPY_IN) PQerrorMessage returns no error. ---------------------------------- PQputCopyData 2: (Expected Error) If I call PQputCopyData with the following (missing the tab before "Hey2"), the result is 1 (Success): "1\t3\t07/25/2014\t48811Hey2\n" At this point after calling PQgetResult: PQresultStatus returns 4 (PGRES_COPY_IN) PQerrorMessage returns no error. **An error should have been generated here because we are calling PQputCopyData with the incorrect number of columns AND an incorrect format for one of the columns. ---------------------------------- PQputCopyData 3: (No error expected) If I call PQputCopyData with the following the result is 1 (Success): "1\t3\t07/25/2014\t48811\tHey3\n" At this point after calling PQgetResult: PQresultStatus returns 4 (PGRES_COPY_IN) PQerrorMessage returns no error. ** There is STILL no error generated! ---------------------------------- If I then call PQputCopyEnd it returns 1 (Success) and an error message = (null). At this point after calling PQgetResult: PQresultStatus returns 4 (PGRES_COPY_IN) So far no error has been returned at all but PQputCopyEnd did not leave the PGRES_COPY_IN state. ---------------------------------- PQputCopyData 4: Now, AFTER CALLING PQputCopyEnd, if I call PQputCopyData with the following valid buffer string I FINALLY see an error even though the string I'm sending is kosher: "1\t3\t07/25/2014\t48811\tHey4\n" At this point after calling PQgetResult: PQresultStatus returns 7 (PGRES_FATAL_ERROR) PQerrorMessage returns: 'ERROR: invalid input syntax for integer: "48811Hey2" CONTEXT: COPY status_data, line 2, column mem_map_detail_id: "48811Hey2"' -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs