]> granicus.if.org Git - postgresql/commitdiff
1) Improve literal handling in parse_statement().
authorHiroshi Inoue <inoue@tpf.co.jp>
Sat, 3 Nov 2001 06:53:50 +0000 (06:53 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Sat, 3 Nov 2001 06:53:50 +0000 (06:53 +0000)
2) Remove some no longer valid comments.
3) Fix an option dialog setting bug.
4) Fix ODBCVER handling errors.

src/interfaces/odbc/dlg_specific.c
src/interfaces/odbc/dlg_specific.h
src/interfaces/odbc/odbcapi.c
src/interfaces/odbc/odbcapi30.c
src/interfaces/odbc/options.c
src/interfaces/odbc/parse.c
src/interfaces/odbc/psqlodbc.rc

index e73c47e314e60e44fbc6eddadad49bfb09bb6c11..d26482161aebb4ec33724d615d2dca8d8cc271e5 100644 (file)
@@ -439,15 +439,18 @@ updateCommons(const ConnInfo *ci)
                                                                 INI_KSQO, tmp, fileName);
 
        /*
-        * Never update the onlyread, unique_index from this module
-        * sprintf(tmp, "%d", comval->unique_index);
-        * SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp,
-        * fileName);
-        *
-        * sprintf(tmp, "%d", comval->onlyread);
-        * SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp,
-        * fileName);
+        * Never update the onlyread, unique_index from this module.
         */
+       if (!ci)
+       {
+               sprintf(tmp, "%d", comval->unique_index);
+               SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp,
+                       fileName);
+
+               sprintf(tmp, "%d", comval->onlyread);
+               SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp,
+                       fileName);
+       }
 
        sprintf(tmp, "%d", comval->use_declarefetch);
        SQLWritePrivateProfileString(sectionName,
index 5a8c7514852ba68b2489fb5fcd69b64375e0c925..3d9985794daef61be314d6c3d999eb78c8157184 100644 (file)
@@ -93,7 +93,7 @@
 
 /*     Connection Defaults */
 #define DEFAULT_PORT                                   "5432"
-#define DEFAULT_READONLY                               1
+#define DEFAULT_READONLY                               0
 #define DEFAULT_PROTOCOL                               "6.4"   /* the latest protocol is
                                                                                                 * the default */
 #define DEFAULT_USEDECLAREFETCH                        0
 #define DEFAULT_BOOLSASCHAR                            1
 #define DEFAULT_OPTIMIZER                              1               /* disable */
 #define DEFAULT_KSQO                                   1               /* on */
-#define DEFAULT_UNIQUEINDEX                            0               /* dont recognize */
+#define DEFAULT_UNIQUEINDEX                            1               /* dont recognize */
 #define DEFAULT_COMMLOG                                        0               /* dont log */
 #define DEFAULT_DEBUG                                  0
 #define DEFAULT_UNKNOWNSIZES                   UNKNOWNS_AS_MAX
index 4604c14157e7580a20cd063b3b80c1e1854933aa..a87c35850c4a6a203d15cce6cb725ab317866f47 100644 (file)
@@ -26,9 +26,6 @@
  *-------
  */
 
-#ifdef WIN32
-#define ODBCVER_REP 0x3000
-#endif
 #include "psqlodbc.h"
 #include <stdio.h>
 #include <string.h>
@@ -200,7 +197,7 @@ SQLFetch(HSTMT StatementHandle)
 {
        static char *func = "SQLFetch";
 
-#if (ODBCVER >= 0x3000)
+#if (ODBCVER >= 0x0300)
        StatementClass *stmt = (StatementClass *) StatementHandle;
        ConnectionClass *conn = SC_get_conn(stmt);
 
@@ -273,7 +270,7 @@ SQLGetFunctions(HDBC ConnectionHandle,
                                SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
 {
        mylog("[SQLGetFunctions]");
-#if (ODBCVER >= 0x3000)
+#if (ODBCVER >= 0x0300)
        if (FunctionId == SQL_API_ODBC3_ALL_FUNCTIONS)
                return PGAPI_GetFunctions30(ConnectionHandle, FunctionId, Supported);
 #endif
@@ -284,14 +281,14 @@ SQLGetInfo(HDBC ConnectionHandle,
                   SQLUSMALLINT InfoType, PTR InfoValue,
                   SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
 {
-#if (ODBCVER >= 0x3000)
+#if (ODBCVER >= 0x0300)
        RETCODE         ret;
 
        mylog("[SQLGetInfo(30)]");
        if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
                                                         BufferLength, StringLength)) == SQL_ERROR)
        {
-               if (((ConnectionClass *) ConnectionHandle)->driver_version >= 0x3000)
+               if (((ConnectionClass *) ConnectionHandle)->driver_version >= 0x0300)
                        return PGAPI_GetInfo30(ConnectionHandle, InfoType, InfoValue,
                                                                   BufferLength, StringLength);
        }
index 161940aed877d65e412904508e4724cefb2cb50b..5a63748bf501fc23eedb1f951757cb6550269a71 100644 (file)
@@ -18,7 +18,9 @@
  *-------
  */
 
+#ifndef ODBCVER_REP
 #define ODBCVER_REP 0x0300
+#endif
 #include "psqlodbc.h"
 #include <stdio.h>
 #include <string.h>
@@ -532,7 +534,7 @@ PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR * pfExists)
 {
        if (fFunction != SQL_API_ODBC3_ALL_FUNCTIONS)
                return SQL_ERROR;
-       memset(pfExists, 0, sizeof(UWORD) * 250);
+       memset(pfExists, 0, sizeof(UWORD) * SQL_API_ODBC3_ALL_FUNCTIONS_SIZE);
 
        /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCCONNECT); 1 deprecated */
        /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCENV); 2 deprecated */
index 04331456c91a1871fdad3e0b16bb1a762918af94..bf2707f4dae33b1359414eb14df15828f184883a 100644 (file)
@@ -178,7 +178,7 @@ set_statement_option(ConnectionClass *conn,
                        /* "0" returned in SQLGetStmtOption */
                        break;
 
-               case SQL_RETRIEVE_DATA: /* ignored, but saved */
+               case SQL_RETRIEVE_DATA:
                        mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", vParam);
                        if (conn)
                                conn->stmtOptions.retrieve_data = vParam;
@@ -636,7 +636,7 @@ PGAPI_GetStmtOption(
                        *((SDWORD *) pvParam) = 0;
                        break;
 
-               case SQL_RETRIEVE_DATA: /* NOT SUPPORTED, but saved */
+               case SQL_RETRIEVE_DATA:
                        *((SDWORD *) pvParam) = stmt->options.retrieve_data;
                        break;
 
index 8a90cce35a5ca923efac0fb680bb456ff4579721..27d1e95af2db74f458fd6809673f50633ff841e0 100644 (file)
@@ -378,18 +378,19 @@ parse_statement(StatementClass *stmt)
                {
                        /* just eat the expression */
                        mylog("in_expr=%d or func=%d\n", in_expr, in_func);
-                       if (!unquoted)
-                               continue;
 
-                       if (token[0] == '(')
-                       {
-                               blevel++;
-                               mylog("blevel++ = %d\n", blevel);
-                       }
-                       else if (token[0] == ')')
+                       if (unquoted)
                        {
-                               blevel--;
-                               mylog("blevel-- = %d\n", blevel);
+                               if (token[0] == '(')
+                               {
+                                       blevel++;
+                                       mylog("blevel++ = %d\n", blevel);
+                               }
+                               else if (token[0] == ')')
+                               {
+                                       blevel--;
+                                       mylog("blevel-- = %d\n", blevel);
+                               }
                        }
                        if (blevel == 0)
                        {
@@ -400,7 +401,7 @@ parse_statement(StatementClass *stmt)
                                        in_expr = FALSE;
                                        in_field = FALSE;
                                }
-                               else if (!stricmp(token, "as"))
+                               else if (unquoted && !stricmp(token, "as"))
                                {
                                        mylog("got AS in_expr\n");
                                        in_func = FALSE;
@@ -474,9 +475,8 @@ parse_statement(StatementClass *stmt)
 
                                if (quote)
                                {
-                                       fi[stmt->nfld++]->quote = TRUE;
-                                       in_expr = TRUE;
-                                       continue;
+                                       fi[stmt->nfld]->quote = TRUE;
+                                       fi[stmt->nfld]->precision = strlen(token);
                                }
                                else if (numeric)
                                {
@@ -573,6 +573,7 @@ parse_statement(StatementClass *stmt)
                        in_expr = TRUE;
                        fi[stmt->nfld - 1]->expr = TRUE;
                        fi[stmt->nfld - 1]->name[0] = '\0';
+                       fi[stmt->nfld - 1]->precision = 0;
                        mylog("*** setting expression\n");
                }
 
@@ -661,7 +662,12 @@ parse_statement(StatementClass *stmt)
                         * following may be better
                         */
                        fi[i]->type = PG_TYPE_UNKNOWN;
-                       fi[i]->precision = 254;
+                       if (fi[i]->precision == 0)
+                       {
+                               fi[i]->type = PG_TYPE_VARCHAR;
+                               fi[i]->precision = 254;
+                       }
+                       fi[i]->length = fi[i]->precision;
                        continue;
                }
                /* it's a dot, resolve to table or alias */
index 499734f16b77302ab19afba36366cbbccae92295..a6c9b23bc929568af93936c4e165d140052724db 100644 (file)
@@ -104,7 +104,7 @@ BEGIN
                     BS_AUTOCHECKBOX | WS_TABSTOP,13,47,84,10
     CONTROL         "Cancel as FreeStmt (Exp)",DRV_CANCELASFREESTMT,"Button",
                     BS_AUTOCHECKBOX | WS_TABSTOP,164,50,112,10
-    CONTROL         "Mylog(Debug ouput",DRV_DEBUG,"Button",
+    CONTROL         "Mylog(Debug ouput)",DRV_DEBUG,"Button",
                     BS_AUTOCHECKBOX | WS_TABSTOP,164,63,112,10
     GROUPBOX        "Unknown Sizes",IDC_STATIC,13,76,175,24
     CONTROL         "Maximum",DRV_UNKNOWN_MAX,"Button",BS_AUTORADIOBUTTON | 
@@ -150,7 +150,7 @@ BEGIN
     CONTROL         "Show System &Tables",DS_SHOWSYSTEMTABLES,"Button",
                     BS_AUTOCHECKBOX | WS_TABSTOP,45,28,88,10
     CONTROL         "Disallow &Premature",DS_DISALLOWPREMATURE,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,149,28,72,10
+                    BS_AUTOCHECKBOX | WS_TABSTOP,149,28,86,10
     GROUPBOX        "Protocol",IDC_STATIC,43,44,180,25
     CONTROL         "7.X,6.4+",DS_PG64,"Button",BS_AUTORADIOBUTTON | 
                     WS_GROUP,53,54,47,10