Fix a bug about pre-execute behavior in case of protocol v2 or earlier.
authorHiroshi Inoue <inoue@tpf.co.jp>
Sun, 7 Feb 2010 12:51:25 +0000 (12:51 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Sun, 7 Feb 2010 12:51:25 +0000 (12:51 +0000)
execute.c
version.h

index 9cb24d17fc8782339f6e0855d281e5bd45b9ec9c..a239880e2d16cdccd4e4833ae835913f1229d2b0 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -228,7 +228,7 @@ inquireHowToPrepare(const StatementClass *stmt)
        if (stmt->multi_statement < 0)
            PGAPI_NumParams((StatementClass *) stmt, &num_params);
        if (stmt->multi_statement > 0) /* would divide the query into multiple commands and apply V3 parse requests for each of them */
-           ret = PARSE_REQ_FOR_INFO;
+           ret = PROTOCOL_74(ci) ? PARSE_REQ_FOR_INFO : PREPARE_BY_THE_DRIVER;
        else if (PROTOCOL_74(ci))
        {
            if (SC_returns_rows(stmt))
@@ -249,8 +249,10 @@ inquireHowToPrepare(const StatementClass *stmt)
                (SQL_CURSOR_FORWARD_ONLY != stmt->options.cursor_type ||
                ci->drivers.use_declarefetch))
                ret = PREPARE_BY_THE_DRIVER;
-           else
+           else if (SC_is_prepare_statement(stmt))
                ret = USING_PREPARE_COMMAND;
+           else
+               ret = PREPARE_BY_THE_DRIVER;
        }
    }
    if (SC_is_prepare_statement(stmt) && (PARSE_TO_EXEC_ONCE == ret))
@@ -316,7 +318,7 @@ int HowToPrepareBeforeExec(StatementClass *stmt, BOOL checkOnly)
        switch (how_to_prepare)
        {
            case USING_PREPARE_COMMAND:
-               return usingCommand;
+               return checkOnly ? doNothing : usingCommand;
            case NAMED_PARSE_REQUEST:
                return shouldParse;
            case PARSE_TO_EXEC_ONCE:
@@ -336,7 +338,8 @@ int HowToPrepareBeforeExec(StatementClass *stmt, BOOL checkOnly)
                return doNothing;
        }
    }
-   if (PG_VERSION_LE(conn, 7.3))
+   if (PG_VERSION_LE(conn, 7.3) ||
+       !PROTOCOL_74(ci))
        return nCallParse;
 
    if (num_params > 0)
index 25c78d7a89d3f63656643d7da6f21886245eb161..24f48fc1d901d2b233d70449183e11ad3e893e79 100644 (file)
--- a/version.h
+++ b/version.h
@@ -12,6 +12,6 @@
 #define POSTGRESDRIVERVERSION      "08.04.0201"
 #define POSTGRES_RESOURCE_VERSION  "08.04.0201\0"
 #define PG_DRVFILE_VERSION     8,4,02,01
-#define PG_BUILD_VERSION       "201001240001"
+#define PG_BUILD_VERSION       "201002070002"
 
 #endif