commit 1260947446ed6d5629dd8164640bf156c7fa7e5b (HEAD, praiskup_testsuite)
Author:     Pavel Raiskup <praiskup@redhat.com>
AuthorDate: Thu May 22 18:34:44 2014 +0200
Commit:     Pavel Raiskup <praiskup@redhat.com>
CommitDate: Fri May 23 07:28:51 2014 +0200

    Do not wrap STMT_TYPE_SPECIAL statement by PREPARE
    
    Having UseServerSidePrepare=1 (default) caused failing the
    commands-tests.c testcase.  Seems like inquireHowToPrepare
    function should detect STMT_TYPE_SPECIAL statements and mark them
    as PREPARE_BY_THE_DRIVER (causes HowToPrepareBeforeExec return
    doNothing).
    
    Adjust also corresponding testcase to test having
    UseServerSidePrepare set explicitly to 0 and 1.

diff --git a/execute.c b/execute.c
index 1cc4f04..623a598 100644
--- a/execute.c
+++ b/execute.c
@@ -214,6 +214,7 @@ inquireHowToPrepare(const StatementClass *stmt)
 	conn = SC_get_conn(stmt);
 	ci = &(conn->connInfo);
 	if (!ci->use_server_side_prepare ||
+		stmt->statement_type == STMT_TYPE_SPECIAL ||
 		PG_VERSION_LT(conn, 7.3))
 	{
 		/* Do prepare operations by the driver itself */
diff --git a/test/expected/commands.out b/test/expected/commands.out
index 58058c3..d1f60bf 100644
--- a/test/expected/commands.out
+++ b/test/expected/commands.out
@@ -1,4 +1,21 @@
 \! ./src/commands-test
+~> Running with UseServerSidePrepare=0
+connected
+Testing VACUUM with SQLExecDirect...
+Testing VACUUM with SQLPrepare/SQLExecute...
+Disabling autocommit...
+Testing VACUUM with SQLExecDirect...
+Testing VACUUM with SQLPrepare/SQLExecute...
+disconnecting
+~> Running with UseServerSidePrepare=1
+connected
+Testing VACUUM with SQLExecDirect...
+Testing VACUUM with SQLPrepare/SQLExecute...
+Disabling autocommit...
+Testing VACUUM with SQLExecDirect...
+Testing VACUUM with SQLPrepare/SQLExecute...
+disconnecting
+~> Running with NULL (default)
 connected
 Testing VACUUM with SQLExecDirect...
 Testing VACUUM with SQLPrepare/SQLExecute...
diff --git a/test/src/commands-test.c b/test/src/commands-test.c
index 96ca7ad..0bc36df 100644
--- a/test/src/commands-test.c
+++ b/test/src/commands-test.c
@@ -12,7 +12,18 @@ int main(int argc, char **argv)
 	char *sqlend;
 	int i;
 
-	test_connect();
+	const char *conn_strings[] = {
+		"UseServerSidePrepare=0",
+		"UseServerSidePrepare=1",
+		NULL,
+	};
+
+	const char **connstr;
+
+	for (connstr = conn_strings; ; connstr++) {
+		printf("~> Running with %s\n", *connstr ? *connstr : "NULL (default)");
+		test_connect_ext(*connstr);
+
 
 		rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt);
 		if (!SQL_SUCCEEDED(rc))
@@ -78,4 +89,8 @@ int main(int argc, char **argv)
 
 		/* Clean up */
 		test_disconnect();
+
+		if (!*connstr)
+			break;
+	}
 }
diff --git a/test/src/common.c b/test/src/common.c
index 2423ad0..70a79bd 100644
--- a/test/src/common.c
+++ b/test/src/common.c
@@ -24,7 +24,7 @@ print_diag(char *msg, SQLSMALLINT htype, SQLHANDLE handle)
 }
 
 void
-test_connect_ext(char *extraparams)
+test_connect_ext(const char *extraparams)
 {
 	SQLRETURN ret;
 	SQLCHAR str[1024];
diff --git a/test/src/common.h b/test/src/common.h
index 34ad156..e63eada 100644
--- a/test/src/common.h
+++ b/test/src/common.h
@@ -24,7 +24,7 @@ extern SQLHDBC conn;
     }
 
 extern void print_diag(char *msg, SQLSMALLINT htype, SQLHANDLE handle);
-extern void test_connect_ext(char *extraparams);
+extern void test_connect_ext(const char *extraparams);
 extern void test_connect(void);
 extern void test_disconnect(void);
 extern void print_result_meta_series(HSTMT hstmt,
