Bug fix: don't forget to set parameter numbers while handling escaped ODBC
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sun, 19 May 2019 03:55:16 +0000 (12:55 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sun, 19 May 2019 03:55:17 +0000 (12:55 +0900)
functions.
Report and patch by Grant Shirreiffs.

convert.c
test/expected/odbc-escapes.out
test/src/odbc-escapes-test.c

index 577f08493222511b3747e1cb529c78f02fe7616b..9698398bbd2cd0e9374cf70055d5265bf2da0256 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -5769,6 +5769,7 @@ MYLOG(0, FORMAT_LEN "-" FORMAT_LEN " num=%s SQL_BIT=%d\n", to, from, num, SQL_BI
        if (SQL_ERROR != retval)
        {
            qb->param_number = nqb.param_number;
+           qb->dollar_number = nqb.dollar_number;
            qb->flags = nqb.flags;
        }
    }
index 9f8116516d8994f1e0616892592bdc988b3f6b93..0452adc04737b1777ffaa2e83d0d3c6b13dadfad 100644 (file)
@@ -14,6 +14,12 @@ Param 2: this is a needle in an ol' haystack
 Result set:
 11
 
+Query: SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) }
+Param 1: needle
+Param 2: this is a needle in an ol' haystack
+Result set:
+10
+
 Query: SELECT 'x' || {fn SPACE(10) } || 'x'
 Result set:
 x          x
@@ -79,6 +85,12 @@ Param 2: this is a needle in an ol' haystack
 Result set:
 11
 
+Query: SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) }
+Param 1: needle
+Param 2: this is a needle in an ol' haystack
+Result set:
+10
+
 Query: SELECT 'x' || {fn SPACE(10) } || 'x'
 Result set:
 x          x
index affc1d83b3c7c93953bc3b57c012f51c5ae97689..d2e2baad85c80568d38f29fa1aa46bc29bc6b5db 100644 (file)
@@ -100,6 +100,13 @@ static void    escape_test(HSTMT hstmt)
    bindParamString(hstmt, 2, "this is a needle in an ol' haystack");
    executeQuery(hstmt);
 
+   /* LOCATE(SUBSTRING, SUBSTRING) */
+   prepareQuery(hstmt, "SELECT {fn LOCATE({fn SUBSTRING(?, 2, 4)}, {fn SUBSTRING(?, 3)}, 3) }");
+   /* using the same parameters */
+   bindParamString(hstmt, 1, "needle");
+   bindParamString(hstmt, 2, "this is a needle in an ol' haystack");
+   executeQuery(hstmt);
+
    /* SPACE */
    prepareQuery(hstmt, "SELECT 'x' || {fn SPACE(10) } || 'x'");
    executeQuery(hstmt);