1) Change SQLParamOptions to count errors as processed rows
authorHiroshi Inoue <inoue@tpf.co.jp>
Wed, 30 Oct 2002 09:45:12 +0000 (09:45 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Wed, 30 Oct 2002 09:45:12 +0000 (09:45 +0000)
   per bug report from Barry Cohen..
2) Fix a bug about date/time escape string per bug report
   from Janet BorSchowa.

convert.c
execute.c

index e1cc297bcd29317dba2b4d598a55643eedc29e12..1f7e0e6e18f69fc7805d43338a6e0e56c206bce3 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -2782,7 +2782,7 @@ convert_escape(QueryParse *qp, QueryBuild *qb)
 {
    static const char *func = "convert_escape";
    RETCODE retval = SQL_SUCCESS;
-   char        buf[1024], key[65];
+   char        buf[1024], buf_small[128], key[65];
    unsigned char   ucv;
    UInt4       prtlen;
  
@@ -2838,25 +2838,25 @@ convert_escape(QueryParse *qp, QueryBuild *qb)
    if (strcmp(key, "d") == 0)
    {
        /* Literal; return the escape part adding type cast */
-       F_ExtractOldTo(qp, buf, '}', sizeof(buf));
-       prtlen = snprintf(buf, sizeof(buf), "%s::date ", buf);
+       F_ExtractOldTo(qp, buf_small, '}', sizeof(buf_small));
+       prtlen = snprintf(buf, sizeof(buf), "%s::date ", buf_small);
        CVT_APPEND_DATA(qb, buf, prtlen);
    }
    else if (strcmp(key, "t") == 0)
    {
        /* Literal; return the escape part adding type cast */
-       F_ExtractOldTo(qp, buf, '}', sizeof(buf));
-       prtlen = snprintf(buf, sizeof(buf), "%s::time", buf);
+       F_ExtractOldTo(qp, buf_small, '}', sizeof(buf_small));
+       prtlen = snprintf(buf, sizeof(buf), "%s::time", buf_small);
        CVT_APPEND_DATA(qb, buf, prtlen);
    }
    else if (strcmp(key, "ts") == 0)
    {
        /* Literal; return the escape part adding type cast */
-       F_ExtractOldTo(qp, buf, '}', sizeof(buf));
+       F_ExtractOldTo(qp, buf_small, '}', sizeof(buf_small));
        if (PG_VERSION_LT(qb->conn, 7.1))
-           prtlen = snprintf(buf, sizeof(buf), "%s::datetime", buf);
+           prtlen = snprintf(buf, sizeof(buf), "%s::datetime", buf_small);
        else
-           prtlen = snprintf(buf, sizeof(buf), "%s::timestamp", buf);
+           prtlen = snprintf(buf, sizeof(buf), "%s::timestamp", buf_small);
        CVT_APPEND_DATA(qb, buf, prtlen);
    }
    else if (strcmp(key, "oj") == 0) /* {oj syntax support for 7.1 * servers */
index 3c0f52f81fe156c8cc3dc36145b7aeecee4d5a5a..b2b8bb3e062528c35d05e9261d4d926a040fd33e 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -48,7 +48,7 @@ PGAPI_Prepare(HSTMT hstmt,
    }
 
    /*
-    * According to the ODBC specs it is valid to call SQLPrepare mulitple
+    * According to the ODBC specs it is valid to call SQLPrepare multiple
     * times. In that case, the bound SQL statement is replaced by the new
     * one
     */
@@ -303,6 +303,16 @@ PGAPI_Execute(
    {
        if (ipdopts->param_processed_ptr)
            *ipdopts->param_processed_ptr = 0;
+#if (ODBCVER >= 0x0300)
+       /*
+        *  Initialize the param_status_ptr 
+        */
+       if (ipdopts->param_status_ptr)
+       {
+           for (i = 0; i <= end_row; i++)
+               ipdopts->param_status_ptr[i] = SQL_PARAM_UNUSED;
+       }
+#endif /* ODBCVER */
        SC_recycle_statement(stmt);
    }
 
@@ -312,8 +322,6 @@ next_param_row:
    {
        while (opts->param_operation_ptr[stmt->exec_current_row] == SQL_PARAM_IGNORE)
        {
-           if (ipdopts->param_status_ptr)
-               ipdopts->param_status_ptr[stmt->exec_current_row] = SQL_PARAM_UNUSED;
            if (stmt->exec_current_row >= end_row)
            {
                stmt->exec_current_row = -1;
@@ -322,6 +330,11 @@ next_param_row:
            ++stmt->exec_current_row;
        }
    }
+   /*
+    *  Initialize the current row status 
+    */
+   if (ipdopts->param_status_ptr)
+       ipdopts->param_status_ptr[stmt->exec_current_row] = SQL_PARAM_ERROR;
 #endif /* ODBCVER */
    /*
     * Check if statement has any data-at-execute parameters when it is
@@ -338,6 +351,11 @@ next_param_row:
        Int4    bind_size = opts->param_bind_type;
        Int4    current_row = stmt->exec_current_row < 0 ? 0 : stmt->exec_current_row;
 
+       /*
+        *  Increment the  number of currently processed rows 
+        */
+       if (ipdopts->param_processed_ptr)
+           (*ipdopts->param_processed_ptr)++;
        stmt->data_at_exec = -1;
        for (i = 0; i < opts->allocated; i++)
        {
@@ -393,8 +411,6 @@ next_param_row:
        retval = SC_execute(stmt);
        if (retval != SQL_ERROR)
        {
-           if (ipdopts->param_processed_ptr)
-               (*ipdopts->param_processed_ptr)++;
            /* special handling of result for keyset driven cursors */
            if (SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type &&
                SQL_CONCUR_READ_ONLY != stmt->options.scroll_concurrency)
@@ -783,11 +799,6 @@ PGAPI_ParamData(
        stmt->current_exec_param = -1;
 
        retval = SC_execute(stmt);
-       if (retval != SQL_ERROR)
-       {
-           if (ipdopts->param_processed_ptr)
-               (*ipdopts->param_processed_ptr)++;
-       }
 #if (ODBCVER >= 0x0300)
        if (ipdopts->param_status_ptr)
        {