From 978f6486dc9585f21df2d5dd4919d73e19e501e5 Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Sun, 5 Jan 2020 11:05:57 +0900 Subject: [PATCH] Fix param-conversion and error-rollback regression test in PG12. Old param-conversions.out was renamed param-conversions_2.out. Old param-conversions_1.out was renamed param-conversions_3.out. Old error-rollback.out was renamed error-rollback_1.out. --- test/expected/error-rollback.out | 10 +- test/expected/error-rollback_1.out | 57 +++++++++ test/expected/param-conversions.out | 14 +-- test/expected/param-conversions_1.out | 14 +-- test/expected/param-conversions_2.out | 160 ++++++++++++++++++++++++++ test/expected/param-conversions_3.out | 159 +++++++++++++++++++++++++ 6 files changed, 395 insertions(+), 19 deletions(-) create mode 100644 test/expected/error-rollback_1.out create mode 100644 test/expected/param-conversions_2.out create mode 100644 test/expected/param-conversions_3.out diff --git a/test/expected/error-rollback.out b/test/expected/error-rollback.out index 99eb359..24cc4a9 100644 --- a/test/expected/error-rollback.out +++ b/test/expected/error-rollback.out @@ -3,7 +3,7 @@ connected Executing query that will succeed Executing query that will fail Failed to execute statement -22P02=ERROR: invalid input syntax for integer: "fail1"; +22P02=ERROR: invalid input syntax for type integer: "fail1"; Error while executing the query Rolling back with SQLEndTran Executing query that will succeed @@ -15,7 +15,7 @@ connected Executing query that will succeed Executing query that will fail Failed to execute statement -22P02=ERROR: invalid input syntax for integer: "fail1"; +22P02=ERROR: invalid input syntax for type integer: "fail1"; Error while executing the query Executing query that will succeed Result set: @@ -27,17 +27,17 @@ Executing query that will succeed Executing query that will succeed Executing query that will fail Failed to execute statement -22P02=ERROR: invalid input syntax for integer: "fail-1"; +22P02=ERROR: invalid input syntax for type integer: "fail-1"; Error while executing the query Executing query that will succeed Executing query that will succeed Executing query that will fail Failed to execute statement -22P02=ERROR: invalid input syntax for integer: "fail-1"; +22P02=ERROR: invalid input syntax for type integer: "fail-1"; Error while executing the query Executing query that will fail Failed to execute statement -22P02=ERROR: invalid input syntax for integer: "fail-1"; +22P02=ERROR: invalid input syntax for type integer: "fail-1"; Error while executing the query Executing query that will succeed Executing procedure call that will fail diff --git a/test/expected/error-rollback_1.out b/test/expected/error-rollback_1.out new file mode 100644 index 0000000..99eb359 --- /dev/null +++ b/test/expected/error-rollback_1.out @@ -0,0 +1,57 @@ +Test for rollback protocol 0 +connected +Executing query that will succeed +Executing query that will fail +Failed to execute statement +22P02=ERROR: invalid input syntax for integer: "fail1"; +Error while executing the query +Rolling back with SQLEndTran +Executing query that will succeed +Result set: +1 +disconnecting +Test for rollback protocol 1 +connected +Executing query that will succeed +Executing query that will fail +Failed to execute statement +22P02=ERROR: invalid input syntax for integer: "fail1"; +Error while executing the query +Executing query that will succeed +Result set: +1 +disconnecting +Test for rollback protocol 2 +connected +Executing query that will succeed +Executing query that will succeed +Executing query that will fail +Failed to execute statement +22P02=ERROR: invalid input syntax for integer: "fail-1"; +Error while executing the query +Executing query that will succeed +Executing query that will succeed +Executing query that will fail +Failed to execute statement +22P02=ERROR: invalid input syntax for integer: "fail-1"; +Error while executing the query +Executing query that will fail +Failed to execute statement +22P02=ERROR: invalid input syntax for integer: "fail-1"; +Error while executing the query +Executing query that will succeed +Executing procedure call that will fail +Failed to execute procedure call +42883=ERROR: function invalidfunction() does not exist; +Error while executing the query +Executing query that will succeed +Executing query that will succeed +Result set: +1 +2 +3 +4 +5 +6 +7 +disconnecting diff --git a/test/expected/param-conversions.out b/test/expected/param-conversions.out index 777cc94..c67c47b 100644 --- a/test/expected/param-conversions.out +++ b/test/expected/param-conversions.out @@ -27,7 +27,7 @@ Result set: Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "5 escapes: \ and '"; +22P02=ERROR: invalid input syntax for type integer: "5 escapes: \ and '"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... @@ -62,12 +62,12 @@ Error while executing the query Testing conversions with invalid values... Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +22P02=ERROR: invalid input syntax for type integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +22P02=ERROR: invalid input syntax for type smallint: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... @@ -86,12 +86,12 @@ Result set: Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "-"; +22P02=ERROR: invalid input syntax for type integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: ""; +22P02=ERROR: invalid input syntax for type integer: ""; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... @@ -100,12 +100,12 @@ Result set: Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "-"; +22P02=ERROR: invalid input syntax for type smallint: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: ""; +22P02=ERROR: invalid input syntax for type smallint: ""; Error while executing the query Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... diff --git a/test/expected/param-conversions_1.out b/test/expected/param-conversions_1.out index 8c8e003..5a39477 100644 --- a/test/expected/param-conversions_1.out +++ b/test/expected/param-conversions_1.out @@ -27,7 +27,7 @@ Result set: Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "5 escapes: \ and '"; +22P02=ERROR: invalid input syntax for type integer: "5 escapes: \ and '"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... @@ -61,12 +61,12 @@ Result set: Testing conversions with invalid values... Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +22P02=ERROR: invalid input syntax for type integer: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +22P02=ERROR: invalid input syntax for type smallint: "2, 'injected, BAD!'"; Error while executing the query Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... @@ -85,12 +85,12 @@ Result set: Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "-"; +22P02=ERROR: invalid input syntax for type integer: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: ""; +22P02=ERROR: invalid input syntax for type integer: ""; Error while executing the query Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... @@ -99,12 +99,12 @@ Result set: Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: "-"; +22P02=ERROR: invalid input syntax for type smallint: "-"; Error while executing the query Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... SQLExecDirect failed -22P02=ERROR: invalid input syntax for integer: ""; +22P02=ERROR: invalid input syntax for type smallint: ""; Error while executing the query Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... diff --git a/test/expected/param-conversions_2.out b/test/expected/param-conversions_2.out new file mode 100644 index 0000000..777cc94 --- /dev/null +++ b/test/expected/param-conversions_2.out @@ -0,0 +1,160 @@ +connected + +Testing conversions... +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-2"... +Result set: +1 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-2"... +Result set: +1 + +Testing "SELECT 2.2 > ?" with SQL_C_CHAR -> SQL_FLOAT param "2.3"... +Result set: +0 + +Testing "SELECT 3.3 > ?" with SQL_C_CHAR -> SQL_DOUBLE param "3.01"... +Result set: +1 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "5 escapes: \ and '"; +Error while executing the query + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-32768"... +Result set: +1 + + +Testing conversions whose result depend on whether the +parameter is treated as a string or an integer... +Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_INTEGER param "6"... +Result set: +1 + +Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_SMALLINT param "6"... +Result set: +1 + +Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_CHAR param "6"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "99999999999999999999999"... +SQLExecDirect failed +22003=ERROR: value "99999999999999999999999" is out of range for type integer; +Error while executing the query + + +Testing conversions with invalid values... +Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +Error while executing the query + +Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +Error while executing the query + +Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for type numeric: "3', 'injected, BAD!', '1"; +Error while executing the query + +Testing "SELECT 1.4 > ?" with SQL_C_CHAR -> SQL_FLOAT param "4 \'bad', '1"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for type numeric: "4 \'bad', '1"; +Error while executing the query + +Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_INTEGER param "-1"... +Result set: +2 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "-"; +Error while executing the query + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: ""; +Error while executing the query + +Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... +Result set: +2 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "-"; +Error while executing the query + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: ""; +Error while executing the query + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... +Result set: +-1234 + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param -1234... +Result set: +1234 + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param 1234... +Result set: +-1234 + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param -1234... +Result set: +1234 + + +Testing bytea conversions +Testing "SELECT ?" with SQL_C_BINARY -> SQL_BINARY param... +Result set: +666f6f0a5c62617200 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_BINARY param "666f6f0001"... +Result set: +666f6f0001 + +Testing "SELECT ?::text" with SQL_C_BINARY -> SQL_CHAR param... +Result set: +foo +\bar + + +Testing datetime conversions +Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "04-22-2011 01:23:45"... +Result set: +2011-04-22 01:23:45 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "{ts '2011-04-22 01:23:45'}"... +Result set: +2011-04-22 01:23:45 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIME param "{t '01:23:45'}"... +Result set: +01:23:45 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_DATE param "{d '2011-04-22'}"... +Result set: +2011-04-22 + +disconnecting diff --git a/test/expected/param-conversions_3.out b/test/expected/param-conversions_3.out new file mode 100644 index 0000000..8c8e003 --- /dev/null +++ b/test/expected/param-conversions_3.out @@ -0,0 +1,159 @@ +connected + +Testing conversions... +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-2"... +Result set: +1 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-2"... +Result set: +1 + +Testing "SELECT 2.2 > ?" with SQL_C_CHAR -> SQL_FLOAT param "2.3"... +Result set: +0 + +Testing "SELECT 3.3 > ?" with SQL_C_CHAR -> SQL_DOUBLE param "3.01"... +Result set: +1 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_CHAR param "5 escapes: \ and '"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "5 escapes: \ and '"; +Error while executing the query + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "32767"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-32768"... +Result set: +1 + + +Testing conversions whose result depend on whether the +parameter is treated as a string or an integer... +Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_INTEGER param "6"... +Result set: +1 + +Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_SMALLINT param "6"... +Result set: +1 + +Testing "SELECT '555' > ?" with SQL_C_CHAR -> SQL_CHAR param "6"... +Result set: +0 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "99999999999999999999999"... +Result set: +0 + + +Testing conversions with invalid values... +Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_INTEGER param "2, 'injected, BAD!'"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +Error while executing the query + +Testing "SELECT 2 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "2, 'injected, BAD!'"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "2, 'injected, BAD!'"; +Error while executing the query + +Testing "SELECT 1.3 > ?" with SQL_C_CHAR -> SQL_FLOAT param "3', 'injected, BAD!', '1"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for type double precision: "3', 'injected, BAD!', '1"; +Error while executing the query + +Testing "SELECT 1.4 > ?" with SQL_C_CHAR -> SQL_FLOAT param "4 \'bad', '1"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for type double precision: "4 \'bad', '1"; +Error while executing the query + +Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_INTEGER param "-1"... +Result set: +2 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param "-"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "-"; +Error while executing the query + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_INTEGER param ""... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: ""; +Error while executing the query + +Testing "SELECT 1-?" with SQL_C_CHAR -> SQL_SMALLINT param "-1"... +Result set: +2 + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param "-"... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: "-"; +Error while executing the query + +Testing "SELECT 1 > ?" with SQL_C_CHAR -> SQL_SMALLINT param ""... +SQLExecDirect failed +22P02=ERROR: invalid input syntax for integer: ""; +Error while executing the query + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param 1234... +Result set: +-1234 + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_INTEGER param -1234... +Result set: +1234 + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param 1234... +Result set: +-1234 + +Testing "SELECT 0-?" with SQL_C_SLONG -> SQL_SMALLINT param -1234... +Result set: +1234 + + +Testing bytea conversions +Testing "SELECT ?" with SQL_C_BINARY -> SQL_BINARY param... +Result set: +\x666F6F0A5C62617200 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_BINARY param "666f6f0001"... +Result set: +\x666F6F0001 + +Testing "SELECT ?::text" with SQL_C_BINARY -> SQL_CHAR param... +Result set: +foo +\bar + + +Testing datetime conversions +Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "04-22-2011 01:23:45"... +Result set: +2011-04-22 01:23:45 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIMESTAMP param "{ts '2011-04-22 01:23:45'}"... +Result set: +2011-04-22 01:23:45 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_TIME param "{t '01:23:45'}"... +Result set: +01:23:45 + +Testing "SELECT ?" with SQL_C_CHAR -> SQL_DATE param "{d '2011-04-22'}"... +Result set: +2011-04-22 + +disconnecting -- 2.39.5