Add a call for SQLDescribeCol() before SQLExecute() to prepare-test.
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Mon, 19 Apr 2021 00:12:07 +0000 (09:12 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Wed, 21 Apr 2021 10:49:59 +0000 (19:49 +0900)
The diff of the result was reported by Mangold Fabian and will be fixed in the later commit.

test/expected/prepare.out
test/src/prepare-test.c

index 0afb1bff1173f1a8dea9ff685e73926890e19558..af390ffed1bbfd23e4467cc7d3d2a2ab932b9eb8 100644 (file)
@@ -111,6 +111,8 @@ Result set:
 1  @ 1 day one day
 2  @ 10 secs   ten secs
 # of result cols: 2
+col:1 name=id type=4 len=10
+col:2 name=t type=12 len=25
 Result set:
 2  bar
 disconnecting
index 874911666f0c41bd18f8c3605868772ef9b827d3..c4aefee63bd95c5c0606e7e0319b7ba66d671399 100644 (file)
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
 
    rc = SQLExecDirect(hstmt, (SQLCHAR *) "SET intervalstyle=postgres_verbose", SQL_NTS);
    /* Prepare a statement */
-   rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1 WHERE t = ?", SQL_NTS);
+   rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t::varchar(25) FROM testtab1 WHERE t = ?", SQL_NTS);
    CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
 
    /* bind param  */
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
     */
 
    /* Prepare a statement */
-   rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1 WHERE id = ?", SQL_NTS);
+   rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t::varchar(25) FROM testtab1 WHERE id = ?", SQL_NTS);
    CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
 
    /* bind param  */
@@ -219,10 +219,20 @@ int main(int argc, char **argv)
                          &cbParam1     /* StrLen_or_IndPtr */);
    CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
 
-   /* Test SQLNumResultCols, called before SQLExecute() */
+   /* Test SQLNumResultCols/SQLDescribeCol, called before SQLExecute() */
    rc = SQLNumResultCols(hstmt, &colcount);
    CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt);
    printf("# of result cols: %d\n", colcount);
+   for (i = 1; i <= colcount; i++)
+   {
+       SQLCHAR     colname[64];
+       SQLSMALLINT collen, type, scale;
+       SQLULEN     len;
+
+       rc = SQLDescribeCol(hstmt, i, colname, sizeof(colname), &collen, &type, &len, &scale, NULL);
+       CHECK_STMT_RESULT(rc, "SQLDescribeCol failed", hstmt);
+       printf("col:%d name=%s type=%d len=%d\n", i, colname, type, (int) len);
+   }
 
    /* Execute */
    rc = SQLExecute(hstmt);