From 892d46e7d053df7e29468d9cd5077a05c0d74905 Mon Sep 17 00:00:00 2001
From: Hiroshi Inoue <inoue@tpf.co.jp>
Date: Tue, 1 May 2001 00:47:06 +0000
Subject: [PATCH] 1) fix bugs reported by Andrea Aime. 2) fix a bug reported by
 Jan Wieck. psqlodbc is 7.01.0005 now.

---
 src/interfaces/odbc/parse.c     | 22 +++++++++++++++++++---
 src/interfaces/odbc/psqlodbc.h  |  4 ++--
 src/interfaces/odbc/psqlodbc.rc |  8 ++++----
 src/interfaces/odbc/qresult.c   |  2 +-
 4 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/interfaces/odbc/parse.c b/src/interfaces/odbc/parse.c
index 075ca95947d..991be1cabb4 100644
--- a/src/interfaces/odbc/parse.c
+++ b/src/interfaces/odbc/parse.c
@@ -228,15 +228,21 @@ getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k)
 char
 searchColInfo(COL_INFO *col_info, FIELD_INFO *fi)
 {
-	int			k;
-	char	   *col;
+	int		k, cmp;
+	char		*col;
 
 
 	for (k = 0; k < QR_get_num_tuples(col_info->result); k++)
 	{
 		col = QR_get_value_manual(col_info->result, k, 3);
-		if (!strcmp(col, fi->name))
+		if (fi->dquote)
+			cmp = strcmp(col, fi->name);
+		else
+			cmp = stricmp(col, fi->name);
+		if (!cmp)
 		{
+			if (!fi->dquote)
+				strcpy(fi->name, col);
 			getColInfo(col_info, fi, k);
 
 			mylog("PARSE: searchColInfo: \n");
@@ -393,6 +399,9 @@ parse_statement(StatementClass *stmt)
 				{
 					blevel--;
 					mylog("blevel-- = %d\n", blevel);
+				}
+				if (blevel == 0)
+				{
 					if (delim == ',')
 					{
 						in_func = FALSE;
@@ -569,6 +578,13 @@ parse_statement(StatementClass *stmt)
 				ti[stmt->ntab]->alias[0] = '\0';
 
 				strcpy(ti[stmt->ntab]->name, token);
+				if (!dquote)
+				{
+					char *ptr;
+					/* lower case table name */
+					for (ptr = ti[stmt->ntab]->name; *ptr; ptr++)
+						*ptr = tolower((unsigned char) *ptr);
+				}
 				mylog("got table = '%s'\n", ti[stmt->ntab]->name);
 
 				if (delim == ',')
diff --git a/src/interfaces/odbc/psqlodbc.h b/src/interfaces/odbc/psqlodbc.h
index ecad03b4777..9d39fdc7ffe 100644
--- a/src/interfaces/odbc/psqlodbc.h
+++ b/src/interfaces/odbc/psqlodbc.h
@@ -5,7 +5,7 @@
  *
  * Comments:		See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.41 2001/03/27 04:00:54 momjian Exp $
+ * $Id: psqlodbc.h,v 1.42 2001/05/01 00:47:06 inoue Exp $
  *
  */
 
@@ -42,7 +42,7 @@ typedef UInt4 Oid;
 #define DRIVERNAME					"PostgreSQL ODBC"
 #define DBMS_NAME					"PostgreSQL"
 
-#define POSTGRESDRIVERVERSION		"07.01.0004"
+#define POSTGRESDRIVERVERSION		"07.01.0005"
 
 #ifdef WIN32
 #define DRIVER_FILE_NAME			"PSQLODBC.DLL"
diff --git a/src/interfaces/odbc/psqlodbc.rc b/src/interfaces/odbc/psqlodbc.rc
index 750d32113d8..6f42f402da6 100644
--- a/src/interfaces/odbc/psqlodbc.rc
+++ b/src/interfaces/odbc/psqlodbc.rc
@@ -342,8 +342,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 7,1,0,4
- PRODUCTVERSION 7,1,0,4
+ FILEVERSION 7,1,0,5
+ PRODUCTVERSION 7,1,0,5
  FILEFLAGSMASK 0x3L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -365,14 +365,14 @@ BEGIN
             VALUE "CompanyName", "Insight Distribution Systems\0"
 #endif
             VALUE "FileDescription", "PostgreSQL Driver\0"
-            VALUE "FileVersion", " 07.01.0004\0"
+            VALUE "FileVersion", " 07.01.0005\0"
             VALUE "InternalName", "psqlodbc\0"
             VALUE "LegalCopyright", "\0"
             VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation.  Microsoft� is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0"
             VALUE "OriginalFilename", "psqlodbc.dll\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "Microsoft Open Database Connectivity\0"
-            VALUE "ProductVersion", " 07.01.0004\0"
+            VALUE "ProductVersion", " 07.01.0005\0"
             VALUE "SpecialBuild", "\0"
         END
     END
diff --git a/src/interfaces/odbc/qresult.c b/src/interfaces/odbc/qresult.c
index 8299b960f58..ac5f9e1c239 100644
--- a/src/interfaces/odbc/qresult.c
+++ b/src/interfaces/odbc/qresult.c
@@ -330,7 +330,7 @@ QR_close(QResultClass *self)
 		QR_Destructor(res);
 
 		/* End the transaction if there are no cursors left on this conn */
-		if (CC_cursor_count(self->conn) == 0)
+		if (CC_is_in_autocommit(self->conn) && CC_cursor_count(self->conn) == 0)
 		{
 			mylog("QResult: END transaction on conn=%u\n", self->conn);
 
-- 
GitLab