1) Fix a bug on SQLSetStmtAttr(.., SQL_CONCURRENCY) reported by Shachar Shemesh.
authorHiroshi Inoue <inoue@tpf.co.jp>
Wed, 27 Aug 2003 10:17:53 +0000 (10:17 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Wed, 27 Aug 2003 10:17:53 +0000 (10:17 +0000)
2) Apply a patch to changes the storage type of the debug "func" variables
   to be stored in the constant area of the program(Shachar Shemesh).
3) Correct the column size in case of bytea as LO.

30 files changed:
bind.c
connection.c
connection.h
convert.c
dlg_specific.c
dlg_specific.h
dlg_wingui.c
drvconn.c
environ.c
environ.h
execute.c
info.c
info30.c
misc.c
misc.h
multibyte.c
odbcapi.c
odbcapi30.c
odbcapi30w.c
odbcapiw.c
options.c
parse.c
pgapi30.c
pgtypes.c
psqlodbc.h
results.c
statement.c
statement.h
version.h
win_unicode.c

diff --git a/bind.c b/bind.c
index 34cd81ca42896705d37a5e0cabeeefae073b649c..84f8f6dbd2f77a5de6396d5d071b7882eeaf61ec 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -41,7 +41,7 @@ PGAPI_BindParameter(
                    SDWORD FAR * pcbValue)
 {
    StatementClass *stmt = (StatementClass *) hstmt;
-   static char *func = "PGAPI_BindParameter";
+   CSTR func = "PGAPI_BindParameter";
    APDFields   *apdopts;
    IPDFields   *ipdopts;
 
@@ -141,7 +141,7 @@ PGAPI_BindCol(
              SDWORD FAR * pcbValue)
 {
    StatementClass *stmt = (StatementClass *) hstmt;
-   static char *func = "PGAPI_BindCol";
+   CSTR func = "PGAPI_BindCol";
    ARDFields   *opts;
 
    mylog("%s: entering...\n", func);
@@ -276,7 +276,7 @@ PGAPI_DescribeParam(
                    SWORD FAR * pfNullable)
 {
    StatementClass *stmt = (StatementClass *) hstmt;
-   static char *func = "PGAPI_DescribeParam";
+   CSTR func = "PGAPI_DescribeParam";
    APDFields   *apdopts;
    IPDFields   *ipdopts;
 
@@ -328,7 +328,7 @@ PGAPI_ParamOptions(
                   UDWORD crow,
                   UDWORD FAR * pirow)
 {
-   static char *func = "PGAPI_ParamOptions";
+   CSTR func = "PGAPI_ParamOptions";
    StatementClass *stmt = (StatementClass *) hstmt;
    APDFields   *apdopts;
 
@@ -358,7 +358,7 @@ PGAPI_NumParams(
    StatementClass *stmt = (StatementClass *) hstmt;
    char        in_quote = FALSE;
    unsigned int i;
-   static char *func = "PGAPI_NumParams";
+   CSTR func = "PGAPI_NumParams";
 
    mylog("%s: entering...\n", func);
 
@@ -431,7 +431,7 @@ create_empty_bindings(int num_columns)
 void
 extend_parameter_bindings(APDFields *self, int num_params)
 {
-   static char *func = "extend_parameter_bindings";
+   CSTR func = "extend_parameter_bindings";
    ParameterInfoClass *new_bindings;
 
    mylog("%s: entering ... self=%u, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params);
@@ -464,7 +464,7 @@ extend_parameter_bindings(APDFields *self, int num_params)
 void
 extend_iparameter_bindings(IPDFields *self, int num_params)
 {
-   static char *func = "extend_iparameter_bindings";
+   CSTR func = "extend_iparameter_bindings";
    ParameterImplClass *new_bindings;
 
    mylog("%s: entering ... self=%u, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params);
@@ -497,7 +497,7 @@ extend_iparameter_bindings(IPDFields *self, int num_params)
 void
 reset_a_parameter_binding(APDFields *self, int ipar)
 {
-   static char *func = "reset_a_parameter_binding";
+   CSTR func = "reset_a_parameter_binding";
 
    mylog("%s: entering ... self=%u, parameters_allocated=%d, ipar=%d\n", func, self, self->allocated, ipar);
 
@@ -530,7 +530,7 @@ reset_a_parameter_binding(APDFields *self, int ipar)
 void
 reset_a_iparameter_binding(IPDFields *self, int ipar)
 {
-   static char *func = "reset_a_iparameter_binding";
+   CSTR func = "reset_a_iparameter_binding";
 
    mylog("%s: entering ... self=%u, parameters_allocated=%d, ipar=%d\n", func, self, self->allocated, ipar);
 
@@ -610,7 +610,7 @@ IPD_free_params(IPDFields *ipdopts, char option)
 void
 extend_column_bindings(ARDFields *self, int num_columns)
 {
-   static char *func = "extend_column_bindings";
+   CSTR func = "extend_column_bindings";
    BindInfoClass *new_bindings;
    int         i;
 
@@ -664,7 +664,7 @@ extend_column_bindings(ARDFields *self, int num_columns)
 void
 reset_a_column_binding(ARDFields *self, int icol)
 {
-   static char *func = "reset_a_column_binding";
+   CSTR func = "reset_a_column_binding";
 
    mylog("%s: entering ... self=%u, bindings_allocated=%d, icol=%d\n", func, self, self->allocated, icol);
 
index 1823aada7942dd6d5718f42247f1727d66b0ac66..07ddcdb7cce5f8bcf3a519a43d567cf291e2baa8 100644 (file)
@@ -50,7 +50,7 @@ PGAPI_AllocConnect(
 {
    EnvironmentClass *env = (EnvironmentClass *) henv;
    ConnectionClass *conn;
-   static char *func = "PGAPI_AllocConnect";
+   CSTR func = "PGAPI_AllocConnect";
 
    mylog("%s: entering...\n", func);
 
@@ -95,7 +95,7 @@ PGAPI_Connect(
 {
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    ConnInfo   *ci;
-   static char *func = "PGAPI_Connect";
+   CSTR func = "PGAPI_Connect";
 
    mylog("%s: entering...\n", func);
 
@@ -150,7 +150,7 @@ PGAPI_BrowseConnect(
                    SWORD cbConnStrOutMax,
                    SWORD FAR * pcbConnStrOut)
 {
-   static char *func = "PGAPI_BrowseConnect";
+   CSTR func = "PGAPI_BrowseConnect";
 
    mylog("%s: entering...\n", func);
 
@@ -164,7 +164,7 @@ PGAPI_Disconnect(
                 HDBC hdbc)
 {
    ConnectionClass *conn = (ConnectionClass *) hdbc;
-   static char *func = "PGAPI_Disconnect";
+   CSTR func = "PGAPI_Disconnect";
 
 
    mylog("%s: entering...\n", func);
@@ -202,7 +202,7 @@ PGAPI_FreeConnect(
                  HDBC hdbc)
 {
    ConnectionClass *conn = (ConnectionClass *) hdbc;
-   static char *func = "PGAPI_FreeConnect";
+   CSTR func = "PGAPI_FreeConnect";
 
    mylog("%s: entering...\n", func);
    mylog("**** in %s: hdbc=%u\n", func, hdbc);
@@ -623,7 +623,7 @@ CC_connect(ConnectionClass *self, char password_req, char *salt_para)
    int         beresp;
    char        msgbuffer[ERROR_MSG_LENGTH];
    char        salt[5], notice[512];
-   static char *func = "CC_connect";
+   CSTR        func = "CC_connect";
    char       *encoding;
 
    mylog("%s: entering...\n", func);
@@ -1786,7 +1786,7 @@ CC_send_settings(ConnectionClass *self)
 #ifdef HAVE_STRTOK_R
    char    *last;
 #endif /* HAVE_STRTOK_R */
-   static char *func = "CC_send_settings";
+   CSTR func = "CC_send_settings";
 
 
    mylog("%s: entering...\n", func);
@@ -1915,7 +1915,7 @@ CC_lookup_lo(ConnectionClass *self)
    HSTMT       hstmt;
    StatementClass *stmt;
    RETCODE     result;
-   static char *func = "CC_lookup_lo";
+   CSTR func = "CC_lookup_lo";
 
    mylog("%s: entering...\n", func);
 
@@ -2000,7 +2000,7 @@ CC_lookup_pg_version(ConnectionClass *self)
    char        szVersion[32];
    int         major,
                minor;
-   static char *func = "CC_lookup_pg_version";
+   CSTR        func = "CC_lookup_pg_version";
 
    mylog("%s: entering...\n", func);
 
index b7cd8722c993823708b19ff272815fd1d41eb8b6..51b048ce07f0b8f55b396a3678607c350d2d0694 100644 (file)
@@ -203,6 +203,7 @@ typedef struct
    signed char int8_as;
    signed char bytea_as_longvarbinary;
    signed char use_server_side_prepare;
+   signed char lower_case_identifier;
    GLOBAL_VALUES drivers;      /* moved from driver's option */
 } ConnInfo;
 
@@ -347,7 +348,6 @@ struct ConnectionClass_
 #define CC_get_username(x)                 (x->connInfo.username)
 #define CC_is_onlyread(x)                  (x->connInfo.onlyread[0] == '1')
 
-
 /* for CC_DSN_info */
 #define CONN_DONT_OVERWRITE        0
 #define CONN_OVERWRITE         1
index 40323e070b3414d2917c3adee1a5923b74aa3e73..24c64986230a72393bf7e48c95118cded0af3d5b 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -365,7 +365,7 @@ int
 copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType,
                       PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue)
 {
-   static char *func = "copy_and_convert_field";
+   CSTR func = "copy_and_convert_field";
    ARDFields   *opts = SC_get_ARD(stmt);
    Int4        len = 0,
                copy_len = 0;
@@ -1558,7 +1558,7 @@ static int
 enlarge_query_statement(QueryBuild *qb, unsigned int newsize)
 {
    unsigned int newalsize = INIT_MIN_ALLOC;
-   static char *func = "enlarge_statement";
+   CSTR func = "enlarge_statement";
 
    if (qb->str_size_limit > 0 && qb->str_size_limit < (int) newsize)
    {
@@ -1773,7 +1773,7 @@ insert_without_target(const char *stmt, int *endpos)
 static int
 Prepare_and_convert(StatementClass *stmt, QueryParse *qp, QueryBuild *qb)
 {
-   const static char *func = "Prepare_and_convert";
+   CSTR func = "Prepare_and_convert";
    char    *new_statement, *exe_statement = NULL;
    int retval;
 
@@ -1880,7 +1880,7 @@ Prepare_and_convert(StatementClass *stmt, QueryParse *qp, QueryBuild *qb)
 int
 copy_statement_with_parameters(StatementClass *stmt, BOOL buildPrepareStatement)
 {
-   static char *func = "copy_statement_with_parameters";
+   CSTR        func = "copy_statement_with_parameters";
    RETCODE     retval;
    QueryParse  query_org, *qp;
    QueryBuild  query_crt, *qb;
@@ -2084,7 +2084,7 @@ copy_statement_with_parameters(StatementClass *stmt, BOOL buildPrepareStatement)
 static int
 inner_process_tokens(QueryParse *qp, QueryBuild *qb)
 {
-   static char *func = "inner_process_tokens";
+   CSTR func = "inner_process_tokens";
    BOOL    lf_conv = qb->lf_conv;
 
    RETCODE retval;
@@ -2386,6 +2386,8 @@ ResolveNumericParam(const SQL_NUMERIC_STRUCT *ns, char *chrform)
        for (; i >= 0; i--)
            chrform[newlen++] = calv[i] + '0';
    }
+   if (0 == len)
+       chrform[newlen++] = '0';
    chrform[newlen] = '\0';
    return TRUE;
 }
@@ -2397,7 +2399,7 @@ ResolveNumericParam(const SQL_NUMERIC_STRUCT *ns, char *chrform)
 static int
 ResolveOneParam(QueryBuild *qb)
 {
-   const char *func = "ResolveOneParam";
+   CSTR func = "ResolveOneParam";
 
    ConnectionClass *conn = qb->conn;
    ConnInfo   *ci = &(conn->connInfo);
@@ -2566,7 +2568,7 @@ ResolveOneParam(QueryBuild *qb)
            allocbuf = malloc(2 * (used + 1));
            used = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buffer,
                used, (LPWSTR) allocbuf, used + 1);
-           buf = ucs2_to_utf8((SQLWCHAR *) allocbuf, used, &used);
+           buf = ucs2_to_utf8((SQLWCHAR *) allocbuf, used, &used, FALSE);
            free(allocbuf);
            allocbuf = buf;
 #else
@@ -2576,7 +2578,7 @@ ResolveOneParam(QueryBuild *qb)
 
 #ifdef UNICODE_SUPPORT
        case SQL_C_WCHAR:
-           buf = allocbuf = ucs2_to_utf8((SQLWCHAR *) buffer, used / 2, &used);
+           buf = allocbuf = ucs2_to_utf8((SQLWCHAR *) buffer, used / 2, &used, FALSE);
            used *= 2;
            break;
 #endif /* UNICODE_SUPPORT */
@@ -2997,7 +2999,7 @@ static int
 processParameters(QueryParse *qp, QueryBuild *qb,
        UInt4 *output_count, Int4 param_pos[][2])
 {
-   static const char *func = "processParameters";
+   CSTR func = "processParameters";
    int retval, innerParenthesis, param_count;
    BOOL stop;
 
@@ -3092,7 +3094,7 @@ processParameters(QueryParse *qp, QueryBuild *qb,
 static int
 convert_escape(QueryParse *qp, QueryBuild *qb)
 {
-   static const char *func = "convert_escape";
+   CSTR func = "convert_escape";
    RETCODE retval = SQL_SUCCESS;
    char        buf[1024], buf_small[128], key[65];
    unsigned char   ucv;
index 638c3579eea941805ca28529e564f6566beb2378..9627a30d9d6053d28e3911b2db5dd9bca71f1796 100644 (file)
@@ -121,7 +121,9 @@ makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
                INI_BYTEAASLONGVARBINARY,
                ci->bytea_as_longvarbinary,
                INI_USESERVERSIDEPREPARE,
-               ci->use_server_side_prepare);
+               ci->use_server_side_prepare,
+               INI_LOWERCASEIDENTIFIER,
+               ci->lower_case_identifier);
    /* Abbrebiation is needed ? */
    if (abbrev || strlen(connect_string) >= len)
    {
@@ -183,6 +185,8 @@ makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
            flag |= BIT_BYTEAASLONGVARBINARY;
        if (ci->use_server_side_prepare)
            flag |= BIT_USESERVERSIDEPREPARE;
+       if (ci->lower_case_identifier)
+           flag |= BIT_LOWERCASEIDENTIFIER;
 
        sprintf(&connect_string[hlen],
                ";A6=%s;A7=%d;A8=%d;B0=%d;B1=%d;%s=%d;C2=%s;CX=%02x%lx",
@@ -254,6 +258,7 @@ unfoldCXAttribute(ConnInfo *ci, const char *value)
    ci->true_is_minus1 = (char)((flag & BIT_TRUEISMINUS1) != 0);
    ci->bytea_as_longvarbinary = (char)((flag & BIT_BYTEAASLONGVARBINARY) != 0);
    ci->use_server_side_prepare = (char)((flag & BIT_USESERVERSIDEPREPARE) != 0);
+   ci->lower_case_identifier = (char)((flag & BIT_LOWERCASEIDENTIFIER) != 0);
 }
 void
 copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
@@ -316,6 +321,8 @@ copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
        ci->bytea_as_longvarbinary = atoi(value);
    else if (stricmp(attribute, INI_USESERVERSIDEPREPARE) == 0)
        ci->use_server_side_prepare = atoi(value);
+   else if (stricmp(attribute, INI_LOWERCASEIDENTIFIER) == 0)
+       ci->lower_case_identifier = atoi(value);
    else if (stricmp(attribute, "CX") == 0)
        unfoldCXAttribute(ci, value);
 
@@ -423,6 +430,8 @@ getDSNdefaults(ConnInfo *ci)
        ci->bytea_as_longvarbinary = DEFAULT_BYTEAASLONGVARBINARY;
    if (ci->use_server_side_prepare < 0)
        ci->use_server_side_prepare = DEFAULT_USESERVERSIDEPREPARE;
+   if (ci->lower_case_identifier < 0)
+       ci->lower_case_identifier = DEFAULT_LOWERCASEIDENTIFIER;
 }
 
 int
@@ -560,6 +569,13 @@ getDSNinfo(ConnInfo *ci, char overwrite)
            ci->use_server_side_prepare = atoi(temp);
    }
 
+   if (ci->lower_case_identifier < 0 || overwrite)
+   {
+       SQLGetPrivateProfileString(DSN, INI_LOWERCASEIDENTIFIER, "", temp, sizeof(temp), ODBC_INI);
+       if (temp[0])
+           ci->lower_case_identifier = atoi(temp);
+   }
+
    /* Allow override of odbcinst.ini parameters here */
    getCommonDefaults(DSN, ODBC_INI, ci);
 
@@ -787,6 +803,11 @@ writeDSNinfo(const ConnInfo *ci)
                                 INI_USESERVERSIDEPREPARE,
                                 temp,
                                 ODBC_INI);
+   sprintf(temp, "%d", ci->lower_case_identifier);
+   SQLWritePrivateProfileString(DSN,
+                                INI_LOWERCASEIDENTIFIER,
+                                temp,
+                                ODBC_INI);
 }
 
 
index b0ea70f47101e545015960ff1a859a39af1f4e09..4208b1e0f04f0ab169570063397a998d3a892d9e 100644 (file)
 #define INI_INT8AS             "BI"
 #define INI_BYTEAASLONGVARBINARY       "ByteaAsLongVarBinary"
 #define INI_USESERVERSIDEPREPARE       "UseServerSidePrepare"
+#define INI_LOWERCASEIDENTIFIER            "LowerCaseIdentifier"
 /* Bit representaion for abbreviated connection strings */
 #define BIT_LFCONVERSION           (1L)
 #define BIT_UPDATABLECURSORS           (1L<<1)
 #define BIT_TRUEISMINUS1           (1L<<23)
 #define BIT_BYTEAASLONGVARBINARY       (1L<<24)
 #define BIT_USESERVERSIDEPREPARE       (1L<<25)
+#define BIT_LOWERCASEIDENTIFIER            (1L<<26)
 
-#define EFFECTIVE_BIT_COUNT            26
+#define EFFECTIVE_BIT_COUNT            27
 
 
 /* Connection Defaults */
 #define DEFAULT_INT8AS         0
 #define DEFAULT_BYTEAASLONGVARBINARY   0
 #define DEFAULT_USESERVERSIDEPREPARE   0
+#define DEFAULT_LOWERCASEIDENTIFIER    0
 
 /* prototypes */
 void       getCommonDefaults(const char *section, const char *filename, ConnInfo *ci);
index ca7666d15008f1fa674656a8f6b34f4d2b348dfc..c13decbaeddd841903a13b07e5211628235b684d 100644 (file)
@@ -462,6 +462,7 @@ ds_options2Proc(HWND hdlg,
 #endif /* DRIVER_CURSOR_IMPLEMENT */
            CheckDlgButton(hdlg, DS_SERVERSIDEPREPARE, ci->use_server_side_prepare);
            CheckDlgButton(hdlg, DS_BYTEAASLONGVARBINARY, ci->bytea_as_longvarbinary);
+           /*CheckDlgButton(hdlg, DS_LOWERCASEIDENTIFIER, ci->lower_case_identifier);*/
 
            EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), atoi(ci->show_oid_column));
 
@@ -520,6 +521,7 @@ ds_options2Proc(HWND hdlg,
 #endif /* DRIVER_CURSOR_IMPLEMENT */
                    ci->use_server_side_prepare = IsDlgButtonChecked(hdlg, DS_SERVERSIDEPREPARE);
                    ci->bytea_as_longvarbinary = IsDlgButtonChecked(hdlg, DS_BYTEAASLONGVARBINARY);
+                   /*ci->lower_case_identifier = IsDlgButtonChecked(hdlg, DS_LOWERCASEIDENTIFIER);*/
 
                    /* OID Options */
                    sprintf(ci->fake_oid_index, "%d", IsDlgButtonChecked(hdlg, DS_FAKEOIDINDEX));
index 25494f3a0a5e7901122c86bc7adf94a2b461c153..48f843bd7894b68c948615ee5f9a2a7092e0d7bb 100644 (file)
--- a/drvconn.c
+++ b/drvconn.c
@@ -87,7 +87,7 @@ PGAPI_DriverConnect(
                    SWORD FAR * pcbConnStrOut,
                    UWORD fDriverCompletion)
 {
-   static char *func = "PGAPI_DriverConnect";
+   CSTR func = "PGAPI_DriverConnect";
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    ConnInfo   *ci;
 
index dd3c3883a053ecd28fd05446b2e327ee8edb429c..a37ff1890a53e51cea22862826a47450861c9daa 100644 (file)
--- a/environ.c
+++ b/environ.c
@@ -36,7 +36,7 @@ pthread_mutex_t     conns_cs;
 RETCODE        SQL_API
 PGAPI_AllocEnv(HENV FAR * phenv)
 {
-   static char *func = "PGAPI_AllocEnv";
+   CSTR func = "PGAPI_AllocEnv";
 
    mylog("**** in PGAPI_AllocEnv ** \n");
 
@@ -66,7 +66,7 @@ PGAPI_AllocEnv(HENV FAR * phenv)
 RETCODE        SQL_API
 PGAPI_FreeEnv(HENV henv)
 {
-   static char *func = "PGAPI_FreeEnv";
+   CSTR func = "PGAPI_FreeEnv";
    EnvironmentClass *env = (EnvironmentClass *) henv;
 
    mylog("**** in PGAPI_FreeEnv: env = %u ** \n", env);
@@ -672,7 +672,7 @@ EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn)
 
 
 void
-EN_log_error(char *func, char *desc, EnvironmentClass *self)
+EN_log_error(const char *func, char *desc, EnvironmentClass *self)
 {
    if (self)
        qlog("ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg);
index 70cf54dad0bdf50d7a9ec4282c20b0f7a01f4cc0..e94f74f8940abfe723d551bbc00cfa19f0219811 100644 (file)
--- a/environ.h
+++ b/environ.h
@@ -36,7 +36,7 @@ char      EN_Destructor(EnvironmentClass *self);
 char       EN_get_error(EnvironmentClass *self, int *number, char **message);
 char       EN_add_connection(EnvironmentClass *self, ConnectionClass *conn);
 char       EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn);
-void       EN_log_error(char *func, char *desc, EnvironmentClass *self);
+void       EN_log_error(const char *func, char *desc, EnvironmentClass *self);
 
 #define    EN_OV_ODBC2 1L
 #define    EN_CONN_POOLING (1L<<1)
index 6b987540095b446bf1145ed31e9076cdb608e1a1..1d263eee7f2f381ee859842fc231fcf5741b94e7 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -36,10 +36,10 @@ PGAPI_Prepare(HSTMT hstmt,
              UCHAR FAR * szSqlStr,
              SDWORD cbSqlStr)
 {
-   static char *func = "PGAPI_Prepare";
+   CSTR func = "PGAPI_Prepare";
    StatementClass *self = (StatementClass *) hstmt;
 
-   mylog("%s: entering...\n", func);
+   mylog("%s: entering... len=%d\n", func, cbSqlStr);
 
    if (!self)
    {
@@ -134,7 +134,7 @@ PGAPI_ExecDirect(
 {
    StatementClass *stmt = (StatementClass *) hstmt;
    RETCODE     result;
-   static char *func = "PGAPI_ExecDirect";
+   CSTR func = "PGAPI_ExecDirect";
 
    mylog("%s: entering...\n", func);
 
@@ -195,7 +195,7 @@ PGAPI_ExecDirect(
 static
 RETCODE    Exec_with_parameters_resolved(StatementClass *stmt, BOOL *exec_end)
 {
-   static const char *func = "Exec_with_parameters_resolved";
+   CSTR func = "Exec_with_parameters_resolved";
    RETCODE     retval;
    int     end_row, cursor_type, scroll_concurrency;
    ConnectionClass *conn;
@@ -374,7 +374,7 @@ RETCODE     SQL_API
 PGAPI_Execute(
              HSTMT hstmt)
 {
-   static char *func = "PGAPI_Execute";
+   CSTR func = "PGAPI_Execute";
    StatementClass *stmt = (StatementClass *) hstmt;
    APDFields   *apdopts;
    IPDFields   *ipdopts;
@@ -606,7 +606,7 @@ PGAPI_Transact(
               HDBC hdbc,
               UWORD fType)
 {
-   static char *func = "PGAPI_Transact";
+   CSTR func = "PGAPI_Transact";
    extern ConnectionClass *conns[];
    ConnectionClass *conn;
    QResultClass *res;
@@ -684,7 +684,7 @@ RETCODE     SQL_API
 PGAPI_Cancel(
             HSTMT hstmt)       /* Statement to cancel. */
 {
-   static char *func = "PGAPI_Cancel";
+   CSTR func = "PGAPI_Cancel";
    StatementClass *stmt = (StatementClass *) hstmt;
    ConnectionClass *conn;
    RETCODE     result;
@@ -775,7 +775,7 @@ PGAPI_NativeSql(
                SDWORD cbSqlStrMax,
                SDWORD FAR * pcbSqlStr)
 {
-   static char *func = "PGAPI_NativeSql";
+   CSTR func = "PGAPI_NativeSql";
    int         len = 0;
    char       *ptr;
    ConnectionClass *conn = (ConnectionClass *) hdbc;
@@ -824,7 +824,7 @@ PGAPI_ParamData(
                HSTMT hstmt,
                PTR FAR * prgbValue)
 {
-   static char *func = "PGAPI_ParamData";
+   CSTR func = "PGAPI_ParamData";
    StatementClass *stmt = (StatementClass *) hstmt;
    APDFields   *apdopts;
    IPDFields   *ipdopts;
@@ -921,7 +921,7 @@ PGAPI_PutData(
              PTR rgbValue,
              SDWORD cbValue)
 {
-   static char *func = "PGAPI_PutData";
+   CSTR func = "PGAPI_PutData";
    StatementClass *stmt = (StatementClass *) hstmt;
    ConnectionClass *conn;
    APDFields   *apdopts;
diff --git a/info.c b/info.c
index cdf2b55a6224fb3cf91b9363aae4c8749d557ab3..d31e0c33d416ff15bed791ea7f6cfcbd9f579dc7 100644 (file)
--- a/info.c
+++ b/info.c
@@ -59,7 +59,7 @@ PGAPI_GetInfo(
              SWORD cbInfoValueMax,
              SWORD FAR * pcbInfoValue)
 {
-   static char *func = "PGAPI_GetInfo";
+   CSTR func = "PGAPI_GetInfo";
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    ConnInfo   *ci;
    char       *p = NULL,
@@ -790,7 +790,7 @@ PGAPI_GetTypeInfo(
                  HSTMT hstmt,
                  SWORD fSqlType)
 {
-   static char *func = "PGAPI_GetTypeInfo";
+   CSTR func = "PGAPI_GetTypeInfo";
    StatementClass *stmt = (StatementClass *) hstmt;
    QResultClass    *res;
    TupleNode  *row;
@@ -929,7 +929,7 @@ PGAPI_GetFunctions(
                   UWORD fFunction,
                   UWORD FAR * pfExists)
 {
-   static char *func = "PGAPI_GetFunctions";
+   CSTR func = "PGAPI_GetFunctions";
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    ConnInfo   *ci = &(conn->connInfo);
 
@@ -1285,7 +1285,7 @@ PGAPI_Tables(
             UCHAR FAR * szTableType,
             SWORD cbTableType)
 {
-   static char *func = "PGAPI_Tables";
+   CSTR func = "PGAPI_Tables";
    StatementClass *stmt = (StatementClass *) hstmt;
    StatementClass *tbl_stmt;
    QResultClass    *res;
@@ -1314,6 +1314,7 @@ PGAPI_Tables(
                systable;
    int         i;
    SWORD           internal_asis_type = SQL_C_CHAR;
+   const char *likeeq = "like";
 
    mylog("%s: entering...stmt=%u scnm=%x len=%d\n", func, stmt, szTableOwner, cbTableOwner);
 
@@ -1362,10 +1363,10 @@ PGAPI_Tables(
    }
 
    if (conn->schema_support)
-       schema_strcat(tables_query, " and nspname like '%.*s'", szTableOwner, cbTableOwner, szTableName, cbTableName, conn);
+       schema_strcat1(tables_query, " and nspname %s '%.*s'", likeeq, szTableOwner, cbTableOwner, szTableName, cbTableName, conn);
    else
-       my_strcat(tables_query, " and usename like '%.*s'", szTableOwner, cbTableOwner);
-   my_strcat(tables_query, " and relname like '%.*s'", szTableName, cbTableName);
+       my_strcat1(tables_query, " and usename %s '%.*s'", likeeq, szTableOwner, cbTableOwner);
+   my_strcat1(tables_query, " and relname %s '%.*s'", likeeq, szTableName, cbTableName);
 
    /* Parse the extra systable prefix  */
    strcpy(prefixes, ci->drivers.extra_systable_prefixes);
@@ -1705,7 +1706,7 @@ PGAPI_Columns(
              SWORD cbColumnName,
              UWORD flag)
 {
-   static char *func = "PGAPI_Columns";
+   CSTR func = "PGAPI_Columns";
    StatementClass *stmt = (StatementClass *) hstmt;
    QResultClass    *res;
    TupleNode  *row;
@@ -1734,7 +1735,9 @@ PGAPI_Columns(
    ConnInfo   *ci;
    ConnectionClass *conn;
    SWORD       internal_asis_type = SQL_C_CHAR;
-
+   const char *likeeq = "like";
+   const char *mzTableOwner = szTableOwner, *mzTableName = szTableName,
+       *mzColumnName = szColumnName;
 
    mylog("%s: entering...stmt=%u scnm=%x len=%d\n", func, stmt, szTableOwner, cbTableOwner);
 
@@ -1777,12 +1780,19 @@ PGAPI_Columns(
 
    if ((flag & PODBC_NOT_SEARCH_PATTERN) != 0) 
    {
-       my_strcat(columns_query, " and c.relname = '%.*s'", szTableName, cbTableName);
+       likeeq = "=";
+   }
+   else
+   {
+   }
+   if ((flag & PODBC_NOT_SEARCH_PATTERN) != 0) 
+   {
+       my_strcat1(columns_query, " and c.relname %s '%.*s'", likeeq, mzTableName, cbTableName);
        if (conn->schema_support)
-           schema_strcat(columns_query, " and u.nspname = '%.*s'", szTableOwner, cbTableOwner, szTableName, cbTableName, conn);
+           schema_strcat1(columns_query, " and u.nspname %s '%.*s'", likeeq, mzTableOwner, cbTableOwner, mzTableName, cbTableName, conn);
        else
-           my_strcat(columns_query, " and u.usename = '%.*s'", szTableOwner, cbTableOwner);
-       my_strcat(columns_query, " and a.attname = '%.*s'", szColumnName, cbColumnName);
+           my_strcat1(columns_query, " and u.usename %s '%.*s'", likeeq, mzTableOwner, cbTableOwner);
+       my_strcat1(columns_query, " and a.attname %s '%.*s'", likeeq, mzColumnName, cbColumnName);
    }
    else
    {
@@ -1790,12 +1800,13 @@ PGAPI_Columns(
        int escTbnamelen;
 
        escTbnamelen = reallyEscapeCatalogEscapes(szTableName, cbTableName, esc_table_name, sizeof(esc_table_name), conn->ccsc);
-       my_strcat(columns_query, " and c.relname like '%.*s'", esc_table_name, escTbnamelen);
+       mzTableName = esc_table_name;
+       my_strcat1(columns_query, " and c.relname %s '%.*s'", likeeq, mzTableName, escTbnamelen);
        if (conn->schema_support)
-           schema_strcat(columns_query, " and u.nspname like '%.*s'", szTableOwner, cbTableOwner, szTableName, cbTableName, conn);
+           schema_strcat1(columns_query, " and u.nspname %s '%.*s'", likeeq, szTableOwner, cbTableOwner, mzTableName, cbTableName, conn);
        else
-           my_strcat(columns_query, " and u.usename like '%.*s'", szTableOwner, cbTableOwner);
-       my_strcat(columns_query, " and a.attname like '%.*s'", szColumnName, cbColumnName);
+           my_strcat1(columns_query, " and u.usename %s '%.*s'", likeeq, mzTableOwner, cbTableOwner);
+       my_strcat1(columns_query, " and a.attname %s '%.*s'", likeeq, mzColumnName, cbColumnName);
    }
 
    /*
@@ -2242,7 +2253,7 @@ PGAPI_SpecialColumns(
                     UWORD fScope,
                     UWORD fNullable)
 {
-   static char *func = "PGAPI_SpecialColumns";
+   CSTR func = "PGAPI_SpecialColumns";
    TupleNode  *row;
    StatementClass *stmt = (StatementClass *) hstmt;
    ConnectionClass *conn;
@@ -2461,7 +2472,7 @@ PGAPI_Statistics(
                 UWORD fUnique,
                 UWORD fAccuracy)
 {
-   static char *func = "PGAPI_Statistics";
+   CSTR func = "PGAPI_Statistics";
    StatementClass *stmt = (StatementClass *) hstmt;
    ConnectionClass *conn;
    QResultClass    *res;
@@ -2901,7 +2912,7 @@ PGAPI_ColumnPrivileges(
                       UCHAR FAR * szColumnName,
                       SWORD cbColumnName)
 {
-   static char *func = "PGAPI_ColumnPrivileges";
+   CSTR func = "PGAPI_ColumnPrivileges";
    StatementClass  *stmt = (StatementClass *) hstmt;
 
    mylog("%s: entering...\n", func);
@@ -2929,7 +2940,7 @@ PGAPI_PrimaryKeys(
                  UCHAR FAR * szTableName,
                  SWORD cbTableName)
 {
-   static char *func = "PGAPI_PrimaryKeys";
+   CSTR func = "PGAPI_PrimaryKeys";
    StatementClass *stmt = (StatementClass *) hstmt;
    QResultClass    *res;
    ConnectionClass *conn;
@@ -3410,7 +3421,7 @@ PGAPI_ForeignKeys(
                  UCHAR FAR * szFkTableName,
                  SWORD cbFkTableName)
 {
-   static char *func = "PGAPI_ForeignKeys";
+   CSTR func = "PGAPI_ForeignKeys";
    StatementClass *stmt = (StatementClass *) hstmt;
    QResultClass    *res;
    TupleNode  *row;
@@ -4262,7 +4273,7 @@ PGAPI_ProcedureColumns(
                       UCHAR FAR * szColumnName,
                       SWORD cbColumnName)
 {
-   static char *func = "PGAPI_ProcedureColumns";
+   CSTR func = "PGAPI_ProcedureColumns";
    StatementClass  *stmt = (StatementClass *) hstmt;
    ConnectionClass *conn = SC_get_conn(stmt);
    char        proc_query[INFO_INQUIRY_LEN];
@@ -4271,6 +4282,7 @@ PGAPI_ProcedureColumns(
    char        *schema_name, *procname, *params;
    QResultClass *res, *tres;
    Int4        tcount, paramcount, i, j, pgtype;
+   const char *likeeq = "like";
 
    mylog("%s: entering...\n", func);
 
@@ -4289,8 +4301,8 @@ PGAPI_ProcedureColumns(
                "pg_catalog.pg_namespace, pg_catalog.pg_proc where "
                "pg_proc.pronamespace = pg_namespace.oid "
                "and (not proretset)");
-       schema_strcat(proc_query, " and nspname like '%.*s'", szProcOwner, cbProcOwner, szProcName, cbProcName, conn);
-       my_strcat(proc_query, " and proname like '%.*s'", szProcName, cbProcName);
+       schema_strcat1(proc_query, " and nspname %s '%.*s'", likeeq, szProcOwner, cbProcOwner, szProcName, cbProcName, conn);
+       my_strcat1(proc_query, " and proname %s '%.*s'", likeeq, szProcName, cbProcName);
        strcat(proc_query, " order by nspname, proname, proretset");
    }
    else
@@ -4298,7 +4310,7 @@ PGAPI_ProcedureColumns(
        strcpy(proc_query, "select proname, proretset, prorettype, "
                "pronargs, proargtypes from pg_proc where "
                "(not proretset)");
-       my_strcat(proc_query, " and proname like '%.*s'", szProcName, cbProcName);
+       my_strcat1(proc_query, " and proname %s '%.*s'", likeeq, szProcName, cbProcName);
        strcat(proc_query, " order by proname, proretset");
    }
    if (tres = CC_send_query(conn, proc_query, NULL, CLEAR_RESULT_ON_ABORT), !tres)
@@ -4450,11 +4462,12 @@ PGAPI_Procedures(
                 UCHAR FAR * szProcName,
                 SWORD cbProcName)
 {
-   static char *func = "PGAPI_Procedures";
+   CSTR func = "PGAPI_Procedures";
    StatementClass *stmt = (StatementClass *) hstmt;
    ConnectionClass *conn = SC_get_conn(stmt);
    char        proc_query[INFO_INQUIRY_LEN];
    QResultClass *res;
+   const char *likeeq = "like";
 
    mylog("%s: entering... scnm=%x len=%d\n", func, szProcOwner, cbProcOwner);
 
@@ -4480,8 +4493,8 @@ PGAPI_Procedures(
           " as "         "PROCEDURE_TYPE" " from pg_catalog.pg_namespace,"
           " pg_catalog.pg_proc"
          " where pg_proc.pronamespace = pg_namespace.oid");
-       schema_strcat(proc_query, " and nspname like '%.*s'", szProcOwner, cbProcOwner, szProcName, cbProcName, conn);
-       my_strcat(proc_query, " and proname like '%.*s'", szProcName, cbProcName);
+       schema_strcat1(proc_query, " and nspname %s '%.*s'", likeeq, szProcOwner, cbProcOwner, szProcName, cbProcName, conn);
+       my_strcat1(proc_query, " and proname %s '%.*s'", likeeq, szProcName, cbProcName);
    }
    else
    {
@@ -4490,7 +4503,7 @@ PGAPI_Procedures(
           " '' as " "NUM_OUTPUT_PARAMS" ", '' as " "NUM_RESULT_SETS" ","
           " '' as " "REMARKS" ","
           " case when prorettype = 0 then 1::int2 else 2::int2 end as " "PROCEDURE_TYPE" " from pg_proc");
-       my_strcat(proc_query, " where proname like '%.*s'", szProcName, cbProcName);
+       my_strcat1(proc_query, " where proname %s '%.*s'", likeeq, szProcName, cbProcName);
    }
 
    if (res = CC_send_query(conn, proc_query, NULL, CLEAR_RESULT_ON_ABORT), !res)
@@ -4573,7 +4586,7 @@ PGAPI_TablePrivileges(
                      UWORD flag)
 {
    StatementClass *stmt = (StatementClass *) hstmt;
-   static char *func = "PGAPI_TablePrivileges";
+   CSTR func = "PGAPI_TablePrivileges";
    ConnectionClass *conn = SC_get_conn(stmt);
    Int2        result_cols;
    char        proc_query[INFO_INQUIRY_LEN];
@@ -4583,6 +4596,7 @@ PGAPI_TablePrivileges(
    BOOL        grpauth, sys, su;
    char        (*useracl)[ACLMAX], *acl, *user, *delim, *auth;
    char        *reln, *owner, *priv, *schnm = NULL;
+   const char *likeeq = "like";
 
    mylog("%s: entering... scnm=%x len-%d\n", func, szTableOwner, cbTableOwner);
    if (!SC_recycle_statement(stmt))
@@ -4640,10 +4654,10 @@ PGAPI_TablePrivileges(
        if (conn->schema_support)
        {
            escTbnamelen = reallyEscapeCatalogEscapes(szTableOwner, cbTableOwner, esc_table_name, sizeof(esc_table_name), conn->ccsc);
-           schema_strcat(proc_query, " nspname like '%.*s' and", esc_table_name, escTbnamelen, szTableName, cbTableName, conn);
+           schema_strcat1(proc_query, " nspname %s '%.*s' and", likeeq, esc_table_name, escTbnamelen, szTableName, cbTableName, conn);
        }
        escTbnamelen = reallyEscapeCatalogEscapes(szTableName, cbTableName, esc_table_name, sizeof(esc_table_name), conn->ccsc);
-       my_strcat(proc_query, " relname like '%.*s' and", esc_table_name, escTbnamelen);
+       my_strcat1(proc_query, " relname %s '%.*s' and", likeeq, esc_table_name, escTbnamelen);
    }
    if (conn->schema_support)
        strcat(proc_query, " pg_namespace.oid = relnamespace and");
index cf2fad2ce2f96462436639efd361a1131ab6bfe8..026fddea0cc459320c4779455af5256e08a598bf 100644 (file)
--- a/info30.c
+++ b/info30.c
@@ -16,7 +16,7 @@ RETCODE       SQL_API
 PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
                SWORD cbInfoValueMax, SWORD FAR * pcbInfoValue)
 {
-   static char *func = "PGAPI_GetInfo30";
+   CSTR func = "PGAPI_GetInfo30";
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    ConnInfo    *ci = &(conn->connInfo);
    char       *p = NULL;
diff --git a/misc.c b/misc.c
index 493a3d49e597a778617574051e673e9e38ea7cc0..c9a65417c1d6fcc134d85b1f4407f5ef6a144438 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -27,6 +27,7 @@
                                 * of getpid ? */
 #endif
 #include "connection.h"
+#include "multibyte.h"
 
 extern GLOBAL_VALUES globals;
 void       generate_filename(const char *, const char *, char *);
@@ -289,6 +290,55 @@ make_string(const char *s, int len, char *buf)
    return NULL;
 }
 
+/*------
+ * Create a null terminated lower-case string if the
+ * original string contains upper-case characters.
+ * The SQL_NTS length is considered.
+ *------
+ */
+char *
+make_lstring_ifneeded(ConnectionClass *conn, const char *s, int len, BOOL ifallupper)
+{
+   int length = len;
+   char       *str = NULL;
+
+   if (s && (len > 0 || (len == SQL_NTS && (length = strlen(s)) > 0)))
+   {
+       int i;
+       const char *ptr;
+       encoded_str encstr;
+
+       make_encoded_str(&encstr, conn, s);
+       for (i = 0, ptr = s; i < length; i++, ptr++)
+       {
+           encoded_nextchar(&encstr);
+           if (ENCODE_STATUS(encstr) != 0)
+               continue;
+           if (ifallupper && islower(*ptr))
+           {
+               if (str)
+               {
+                   free(str);
+                   str = NULL;
+               }
+               break;
+           } 
+           if (tolower(*ptr) != *ptr)
+           {
+               if (!str)
+               {
+                   str = malloc(length + 1);
+                   memcpy(str, s, length);
+                   str[length] = '\0';
+               }
+               str[i] = tolower(*ptr);
+           }
+       }
+   }
+
+   return str;
+}
+
 
 /*
  * Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing.
@@ -358,3 +408,33 @@ trim(char *s)
 
    return s;
 }
+
+char *
+my_strcat1(char *buf, const char *fmt, const char *s1, const char *s, int len)
+{
+   int length = len;
+
+   if (s && (len > 0 || (len == SQL_NTS && (length = strlen(s)) > 0)))
+   {
+       int pos = strlen(buf);
+
+       if (s1)
+           sprintf(&buf[pos], fmt, s1, length, s);
+       else
+           sprintf(&buf[pos], fmt, length, s);
+       return buf;
+   }
+   return NULL;
+}
+
+char *
+schema_strcat1(char *buf, const char *fmt, const char *s1, const char *s, int len, const char *tbname, int tbnmlen, ConnectionClass *conn)
+{
+   if (!s || 0 == len)
+   {
+       if (conn->schema_support && tbname && (tbnmlen > 0 || tbnmlen == SQL_NTS))
+           return my_strcat1(buf, fmt, s1, CC_get_current_schema(conn), SQL_NTS);
+       return NULL;
+   }
+   return my_strcat1(buf, fmt, s1, s, len);
+}
diff --git a/misc.h b/misc.h
index 7ae9e09ee551bd8aebb5869c1ea5f2cc5cbbcf59..58d6ee9d20ea8c23679d50b23f40681dd7e60c26 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -120,9 +120,14 @@ void       remove_newlines(char *string);
 char      *strncpy_null(char *dst, const char *src, int len);
 char      *trim(char *string);
 char      *make_string(const char *s, int len, char *buf);
+char      *make_lstring_ifneeded(ConnectionClass *, const char *s, int len, BOOL);
 char      *my_strcat(char *buf, const char *fmt, const char *s, int len);
 char      *schema_strcat(char *buf, const char *fmt, const char *s, int len,
        const char *, int, ConnectionClass *conn);
+char      *my_strcat1(char *buf, const char *fmt, const char *s1, const char *s, int len);
+char      *schema_strcat1(char *buf, const char *fmt, const char *s1,
+               const char *s, int len,
+               const char *, int, ConnectionClass *conn);
 /* #define GET_SCHEMA_NAME(nspname)    (stricmp(nspname, "public") ? nspname : "") */
 #define    GET_SCHEMA_NAME(nspname)    (nspname)
 
@@ -133,5 +138,8 @@ char       *schema_strcat(char *buf, const char *fmt, const char *s, int len,
 #define STRCPY_NULL            (-2)
 
 int            my_strcpy(char *dst, int dst_len, const char *src, int src_len);
+\r
+/* Define a type for defining a constant string expression */\r
+#define CSTR static const char * const\r
 
 #endif
index f661d74f4a65a620d17e473ee2c9912c7189b0d7..c4ac9e832cbd1718fd1fcc86a8a0a916fbff6c2c 100644 (file)
@@ -366,7 +366,7 @@ void
 CC_lookup_characterset(ConnectionClass *self)
 {
    char        *encstr;
-   static char *func = "CC_lookup_characterset";
+   CSTR func = "CC_lookup_characterset";
 
    mylog("%s: entering...\n", func);
    if (PG_VERSION_LT(self, 7.2))
index 025ef203c22ca7abe7408959439bc08a13be703a..1cbea25b94e892723f18774131c9ecb12b8a2a2c 100644 (file)
--- a/odbcapi.c
+++ b/odbcapi.c
@@ -34,6 +34,7 @@
 #include "environ.h"
 #include "connection.h"
 #include "statement.h"
+#include "qresult.h"
 
 #if (ODBCVER < 0x0300)
 RETCODE        SQL_API
@@ -111,13 +112,58 @@ SQLColumns(HSTMT StatementHandle,
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) StatementHandle;
+   SQLCHAR *ctName = CatalogName, *scName = SchemaName,
+       *tbName = TableName, *clName = ColumnName;
 
    mylog("[SQLColumns]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_Columns(StatementHandle, CatalogName, NameLength1,
-                   SchemaName, NameLength2, TableName, NameLength3,
-                   ColumnName, NameLength4, 0);
+   ret = PGAPI_Columns(StatementHandle, ctName, NameLength1,
+               scName, NameLength2, tbName, NameLength3,
+               clName, NameLength4, 0);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt = NULL, *newSc = NULL, *newTb = NULL, *newCl = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }   
+       if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper))
+       {
+           tbName = newTb;
+           reexec = TRUE;
+       }
+       if (newCl = make_lstring_ifneeded(conn, ColumnName, NameLength4, ifallupper))
+       {
+           clName = newCl;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_Columns(StatementHandle, ctName, NameLength1,
+               scName, NameLength2, tbName, NameLength3,
+               clName, NameLength4, 0);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newTb)
+               free(newTb);
+           if (newCl)
+               free(newCl);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -288,7 +334,7 @@ SQLExecute(HSTMT StatementHandle)
 RETCODE        SQL_API
 SQLFetch(HSTMT StatementHandle)
 {
-   static char *func = "SQLFetch";
+   CSTR func = "SQLFetch";
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
@@ -641,13 +687,50 @@ SQLSpecialColumns(HSTMT StatementHandle,
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) StatementHandle;
+   SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
 
    mylog("[SQLSpecialColumns]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, CatalogName,
-           NameLength1, SchemaName, NameLength2, TableName, NameLength3,
-                               Scope, Nullable);
+   ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName,
+           NameLength1, scName, NameLength2, tbName, NameLength3,
+                           Scope, Nullable);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt =NULL, *newSc = NULL, *newTb = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper))
+       {
+           tbName = newTb;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName,
+           NameLength1, scName, NameLength2, tbName, NameLength3,
+                           Scope, Nullable);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newTb)
+               free(newTb);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -661,13 +744,50 @@ SQLStatistics(HSTMT StatementHandle,
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) StatementHandle;
+   SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
 
    mylog("[SQLStatistics]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_Statistics(StatementHandle, CatalogName, NameLength1,
-                SchemaName, NameLength2, TableName, NameLength3, Unique,
-                           Reserved);
+   ret = PGAPI_Statistics(StatementHandle, ctName, NameLength1,
+                scName, NameLength2, tbName, NameLength3,
+                Unique, Reserved);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt =NULL, *newSc = NULL, *newTb = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper))
+       {
+           tbName = newTb;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_Statistics(StatementHandle, ctName, NameLength1,
+                scName, NameLength2, tbName, NameLength3,
+                Unique, Reserved);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newTb)
+               free(newTb);
+       }   
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -681,13 +801,50 @@ SQLTables(HSTMT StatementHandle,
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) StatementHandle;
+   SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
 
    mylog("[SQLTables]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_Tables(StatementHandle, CatalogName, NameLength1,
-                       SchemaName, NameLength2, TableName, NameLength3,
+   ret = PGAPI_Tables(StatementHandle, ctName, NameLength1,
+               scName, NameLength2, tbName, NameLength3,
                        TableType, NameLength4);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt =NULL, *newSc = NULL, *newTb = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper))
+       {
+           tbName = newTb;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_Tables(StatementHandle, ctName, NameLength1,
+               scName, NameLength2, tbName, NameLength3,
+                       TableType, NameLength4);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newTb)
+               free(newTb);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -749,13 +906,58 @@ SQLColumnPrivileges(
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) hstmt;
+   SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
+       *tbName = szTableName, *clName = szColumnName;
 
    mylog("[SQLColumnPrivileges]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_ColumnPrivileges(hstmt, szCatalogName, cbCatalogName,
-                   szSchemaName, cbSchemaName, szTableName, cbTableName,
-                                 szColumnName, cbColumnName);
+   ret = PGAPI_ColumnPrivileges(hstmt, ctName, cbCatalogName,
+               scName, cbSchemaName, tbName, cbTableName,
+                       clName, cbColumnName);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt = NULL, *newSc = NULL, *newTb = NULL, *newCl = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper))
+       {
+           tbName = newTb;
+           reexec = TRUE;
+       }
+       if (newCl = make_lstring_ifneeded(conn, szColumnName, cbColumnName, ifallupper))
+       {
+           clName = newCl;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_ColumnPrivileges(hstmt, ctName, cbCatalogName,
+               scName, cbSchemaName, tbName, cbTableName,
+                       clName, cbColumnName);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newTb)
+               free(newTb);
+           if (newCl)
+               free(newCl);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -819,14 +1021,76 @@ SQLForeignKeys(
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) hstmt;
+   SQLCHAR *pkctName = szPkCatalogName, *pkscName = szPkSchemaName,
+       *pktbName = szPkTableName, *fkctName = szFkCatalogName,
+       *fkscName = szFkSchemaName, *fktbName = szFkTableName;
 
    mylog("[SQLForeignKeys]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_ForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName,
-                          szPkSchemaName, cbPkSchemaName, szPkTableName,
-                        cbPkTableName, szFkCatalogName, cbFkCatalogName,
-          szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
+   ret = PGAPI_ForeignKeys(hstmt, pkctName, cbPkCatalogName,
+           pkscName, cbPkSchemaName, pktbName, cbPkTableName,
+           fkctName, cbFkCatalogName, fkscName, cbFkSchemaName,
+           fktbName, cbFkTableName);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newPkct = NULL, *newPksc = NULL, *newPktb = NULL,
+           *newFkct = NULL, *newFksc = NULL, *newFktb = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newPkct = make_lstring_ifneeded(conn, szPkCatalogName, cbPkCatalogName, ifallupper))
+       {
+           pkctName = newPkct;
+           reexec = TRUE;
+       }
+       if (newPksc = make_lstring_ifneeded(conn, szPkSchemaName, cbPkSchemaName, ifallupper))
+       {
+           pkscName = newPksc;
+           reexec = TRUE;
+       }
+       if (newPktb = make_lstring_ifneeded(conn, szPkTableName, cbPkTableName, ifallupper))
+       {
+           pktbName = newPktb;
+           reexec = TRUE;
+       }
+       if (newFkct = make_lstring_ifneeded(conn, szFkCatalogName, cbFkCatalogName, ifallupper))
+       {
+           fkctName = newFkct;
+           reexec = TRUE;
+       }
+       if (newFksc = make_lstring_ifneeded(conn, szFkSchemaName, cbFkSchemaName, ifallupper))
+       {
+           fkscName = newFksc;
+           reexec = TRUE;
+       }
+       if (newFktb = make_lstring_ifneeded(conn, szFkTableName, cbFkTableName, ifallupper))
+       {
+           fktbName = newFktb;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_ForeignKeys(hstmt, pkctName, cbPkCatalogName,
+           pkscName, cbPkSchemaName, pktbName, cbPkTableName,
+           fkctName, cbFkCatalogName, fkscName, cbFkSchemaName,
+           fktbName, cbFkTableName);
+           if (newPkct)
+               free(newPkct);
+           if (newPksc)
+               free(newPksc);
+           if (newPktb)
+               free(newPktb);
+           if (newFkct)
+               free(newFkct);
+           if (newFksc)
+               free(newFksc);
+           if (newFktb)
+               free(newFktb);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -911,12 +1175,49 @@ SQLPrimaryKeys(
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) hstmt;
+   SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
+       *tbName = szTableName;
 
    mylog("[SQLPrimaryKeys]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_PrimaryKeys(hstmt, szCatalogName, cbCatalogName,
-                  szSchemaName, cbSchemaName, szTableName, cbTableName);
+   ret = PGAPI_PrimaryKeys(hstmt, ctName, cbCatalogName,
+           scName, cbSchemaName, tbName, cbTableName);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt = NULL, *newSc = NULL, *newTb = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper))
+       {
+           tbName = newTb;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_PrimaryKeys(hstmt, ctName, cbCatalogName,
+           scName, cbSchemaName, tbName, cbTableName);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newTb)
+               free(newTb);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -935,13 +1236,58 @@ SQLProcedureColumns(
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) hstmt;
+   SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
+       *prName = szProcName, *clName = szColumnName;
 
    mylog("[SQLProcedureColumns]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_ProcedureColumns(hstmt, szCatalogName, cbCatalogName,
-                     szSchemaName, cbSchemaName, szProcName, cbProcName,
-                                 szColumnName, cbColumnName);
+   ret = PGAPI_ProcedureColumns(hstmt, ctName, cbCatalogName,
+               scName, cbSchemaName, prName, cbProcName,
+                   clName, cbColumnName);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt = NULL, *newSc = NULL, *newPr = NULL, *newCl = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newPr = make_lstring_ifneeded(conn, szProcName, cbProcName, ifallupper))
+       {
+           prName = newPr;
+           reexec = TRUE;
+       }
+       if (newCl = make_lstring_ifneeded(conn, szColumnName, cbColumnName, ifallupper))
+       {
+           clName = newCl;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_ProcedureColumns(hstmt, ctName, cbCatalogName,
+               scName, cbSchemaName, prName, cbProcName,
+                   clName, cbColumnName);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newPr)
+               free(newPr);
+           if (newCl)
+               free(newCl);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -958,12 +1304,49 @@ SQLProcedures(
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) hstmt;
+   SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
+       *prName = szProcName;
 
    mylog("[SQLProcedures]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_Procedures(hstmt, szCatalogName, cbCatalogName,
-                    szSchemaName, cbSchemaName, szProcName, cbProcName);
+   ret = PGAPI_Procedures(hstmt, ctName, cbCatalogName,
+                    scName, cbSchemaName, prName, cbProcName);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt = NULL, *newSc = NULL, *newPr = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newPr = make_lstring_ifneeded(conn, szProcName, cbProcName, ifallupper))
+       {
+           prName = newPr;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_Procedures(hstmt, ctName, cbCatalogName,
+                    scName, cbSchemaName, prName, cbProcName);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newPr)
+               free(newPr);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
@@ -998,12 +1381,49 @@ SQLTablePrivileges(
 {
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) hstmt;
+   SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
+       *tbName = szTableName;
 
    mylog("[SQLTablePrivileges]");
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
-   ret = PGAPI_TablePrivileges(hstmt, szCatalogName, cbCatalogName,
-                  szSchemaName, cbSchemaName, szTableName, cbTableName, 0);
+   ret = PGAPI_TablePrivileges(hstmt, ctName, cbCatalogName,
+           scName, cbSchemaName, tbName, cbTableName, 0);
+   if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 
+   {
+       BOOL    ifallupper = TRUE, reexec = FALSE;
+       char *newCt = NULL, *newSc = NULL, *newTb = NULL;
+       ConnectionClass *conn = SC_get_conn(stmt);
+
+       if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
+           ifallupper = FALSE;
+       if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper))
+       {
+           ctName = newCt;
+           reexec = TRUE;
+       }
+       if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper))
+       {
+           scName = newSc;
+           reexec = TRUE;
+       }
+       if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper))
+       {
+           tbName = newTb;
+           reexec = TRUE;
+       }
+       if (reexec)
+       {
+           ret = PGAPI_TablePrivileges(hstmt, ctName, cbCatalogName,
+           scName, cbSchemaName, tbName, cbTableName, 0);
+           if (newCt)
+               free(newCt);
+           if (newSc)
+               free(newSc);
+           if (newTb)
+               free(newTb);
+       }
+   }
    LEAVE_STMT_CS(stmt);
    return ret;
 }
index 75612fddd8c7da062c6cd8732513870c25d01e83..c6846eaa3b37003326e670608755d17b18122742 100644 (file)
@@ -196,7 +196,7 @@ RETCODE     SQL_API
 SQLFetchScroll(HSTMT StatementHandle,
               SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
 {
-   static char *func = "SQLFetchScroll";
+   CSTR func = "SQLFetchScroll";
    StatementClass *stmt = (StatementClass *) StatementHandle;
    RETCODE     ret = SQL_SUCCESS;
    IRDFields   *irdopts = SC_get_IRD(stmt);
@@ -376,7 +376,7 @@ SQLGetStmtAttr(HSTMT StatementHandle,
               SQLINTEGER BufferLength, SQLINTEGER *StringLength)
 {
    RETCODE ret;
-   static char *func = "SQLGetStmtAttr";
+   CSTR func = "SQLGetStmtAttr";
 
    mylog("[[%s]] Handle=%u %d\n", func, StatementHandle, Attribute);
    ENTER_STMT_CS((StatementClass *) StatementHandle);
@@ -428,7 +428,7 @@ SQLSetDescRec(SQLHDESC DescriptorHandle,
              PTR Data, SQLINTEGER *StringLength,
              SQLINTEGER *Indicator)
 {
-   const char *func = "SQLSetDescRec";
+   CSTR func = "SQLSetDescRec";
 
    mylog("[[SQLSetDescRec]]\n");
    mylog("Error not implemented\n");
@@ -502,7 +502,7 @@ SQLSetStmtAttr(HSTMT StatementHandle,
               SQLINTEGER Attribute, PTR Value,
               SQLINTEGER StringLength)
 {
-   static char *func = "SQLSetStmtAttr";
+   CSTR func = "SQLSetStmtAttr";
    StatementClass *stmt = (StatementClass *) StatementHandle;
    RETCODE ret;
 
@@ -640,7 +640,7 @@ RETCODE SQL_API
 SQLBulkOperations(HSTMT hstmt, SQLSMALLINT operation)
 {
    RETCODE ret;
-   static char *func = "SQLBulkOperations";
+   CSTR func = "SQLBulkOperations";
    StatementClass  *stmt = (StatementClass *) hstmt;
 
    ENTER_STMT_CS(stmt);
index 017774c22ab154020346183fb357a28a32e0a6aa..512e768cc7a2744709e38a2f3501cc49ba183702 100644 (file)
@@ -116,7 +116,7 @@ SQLSetDescFieldW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber,
            case SQL_DESC_SCHEMA_NAME:
            case SQL_DESC_TABLE_NAME:
            case SQL_DESC_TYPE_NAME:
-               uval = ucs2_to_utf8(Value, BufferLength / 2, &vallen);
+               uval = ucs2_to_utf8(Value, BufferLength / 2, &vallen, FALSE);
                val_alloced = TRUE;
            break;
        }
index acc9e1ec8b0a9347ac9fe18cb601f47d611ba892..ba2123d7cb1aed903577760d95ed1c3ae5e033d2 100644 (file)
@@ -34,17 +34,22 @@ RETCODE  SQL_API SQLColumnsW(HSTMT StatementHandle,
    RETCODE ret;
    char    *ctName, *scName, *tbName, *clName;
    UInt4   nmlen1, nmlen2, nmlen3, nmlen4;
+   StatementClass *stmt = (StatementClass *) StatementHandle;
+   ConnectionClass *conn;
+   BOOL    lower_id; 
 
    mylog("[SQLColumnsW]");
-   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
-   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
-   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
-   clName = ucs2_to_utf8(ColumnName, NameLength4, &nmlen4);
-   ENTER_STMT_CS((StatementClass *) StatementHandle);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
+   clName = ucs2_to_utf8(ColumnName, NameLength4, &nmlen4, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_Columns(StatementHandle, ctName, (SWORD) nmlen1,
                scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
                clName, (SWORD) nmlen4, 0);
-   LEAVE_STMT_CS((StatementClass *) StatementHandle);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -69,9 +74,9 @@ RETCODE  SQL_API SQLConnectW(HDBC ConnectionHandle,
    mylog("[SQLConnectW]");
    ENTER_CONN_CS((ConnectionClass *) ConnectionHandle);
    ((ConnectionClass *) ConnectionHandle)->unicode = 1;
-   svName = ucs2_to_utf8(ServerName, NameLength1, &nmlen1);
-   usName = ucs2_to_utf8(UserName, NameLength2, &nmlen2);
-   auth = ucs2_to_utf8(Authentication, NameLength3, &nmlen3);
+   svName = ucs2_to_utf8(ServerName, NameLength1, &nmlen1, FALSE);
+   usName = ucs2_to_utf8(UserName, NameLength2, &nmlen2, FALSE);
+   auth = ucs2_to_utf8(Authentication, NameLength3, &nmlen3, FALSE);
    ret = PGAPI_Connect(ConnectionHandle, svName, (SWORD) nmlen1,
                usName, (SWORD) nmlen2, auth, (SWORD) nmlen3);
    LEAVE_CONN_CS((ConnectionClass *) ConnectionHandle);
@@ -101,7 +106,7 @@ RETCODE SQL_API SQLDriverConnectW(HDBC hdbc,
    mylog("[SQLDriverConnectW]");
    ENTER_CONN_CS((ConnectionClass *) hdbc);
    ((ConnectionClass *) hdbc)->unicode = 1;
-   szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen);
+   szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE);
    obuflen = cbConnStrOutMax + 1;
    szOut = malloc(obuflen);
    ret = PGAPI_DriverConnect(hdbc, hwnd, szIn, (SWORD) inlen,
@@ -134,7 +139,7 @@ RETCODE SQL_API SQLBrowseConnectW(
    mylog("[SQLBrowseConnectW]");
    ENTER_CONN_CS((ConnectionClass *) hdbc);
    ((ConnectionClass *) hdbc)->unicode = 1;
-   szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen);
+   szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE);
    obuflen = cbConnStrOutMax + 1;
    szOut = malloc(obuflen);
    ret = PGAPI_BrowseConnect(hdbc, szIn, (SWORD) inlen,
@@ -209,7 +214,7 @@ RETCODE  SQL_API SQLExecDirectW(HSTMT StatementHandle,
    UInt4   slen;
 
    mylog("[SQLExecDirectW]");
-   stxt = ucs2_to_utf8(StatementText, TextLength, &slen);
+   stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE);
    ENTER_STMT_CS((StatementClass *) StatementHandle);
    ret = PGAPI_ExecDirect(StatementHandle, stxt, slen);
    LEAVE_STMT_CS((StatementClass *) StatementHandle);
@@ -291,7 +296,7 @@ RETCODE  SQL_API SQLPrepareW(HSTMT StatementHandle,
    UInt4   slen;
 
    mylog("[SQLPrepareW]");
-   stxt = ucs2_to_utf8(StatementText, TextLength, &slen);
+   stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE);
    ENTER_STMT_CS((StatementClass *) StatementHandle);
    ret = PGAPI_Prepare(StatementHandle, stxt, slen);
    LEAVE_STMT_CS((StatementClass *) StatementHandle);
@@ -308,7 +313,7 @@ RETCODE  SQL_API SQLSetCursorNameW(HSTMT StatementHandle,
    UInt4   nlen;
 
    mylog("[SQLSetCursorNameW]");
-   crName = ucs2_to_utf8(CursorName, NameLength, &nlen);
+   crName = ucs2_to_utf8(CursorName, NameLength, &nlen, FALSE);
    ENTER_STMT_CS((StatementClass *) StatementHandle);
    ret = PGAPI_SetCursorName(StatementHandle, crName, (SWORD) nlen);
    LEAVE_STMT_CS((StatementClass *) StatementHandle);
@@ -327,16 +332,21 @@ RETCODE  SQL_API SQLSpecialColumnsW(HSTMT StatementHandle,
    RETCODE ret;
    char    *ctName, *scName, *tbName;
    UInt4   nmlen1, nmlen2, nmlen3;
+   StatementClass *stmt = (StatementClass *) StatementHandle;
+   ConnectionClass *conn;
+   BOOL lower_id;
    
    mylog("[SQLSpecialColumnsW]");
-   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
-   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
-   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
-   ENTER_STMT_CS((StatementClass *) StatementHandle);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName,
            (SWORD) nmlen1, scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
        Scope, Nullable);
-   LEAVE_STMT_CS((StatementClass *) StatementHandle);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -355,16 +365,21 @@ RETCODE  SQL_API SQLStatisticsW(HSTMT StatementHandle,
    RETCODE ret;
    char    *ctName, *scName, *tbName;
    UInt4   nmlen1, nmlen2, nmlen3;
+   StatementClass *stmt = (StatementClass *) StatementHandle;
+   ConnectionClass *conn;
+   BOOL lower_id;
 
    mylog("[SQLStatisticsW]");
-   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
-   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
-   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
-   ENTER_STMT_CS((StatementClass *) StatementHandle);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_Statistics(StatementHandle, ctName, (SWORD) nmlen1,
            scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3, Unique,
        Reserved);
-   LEAVE_STMT_CS((StatementClass *) StatementHandle);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -383,17 +398,22 @@ RETCODE  SQL_API SQLTablesW(HSTMT StatementHandle,
    RETCODE ret;
    char    *ctName, *scName, *tbName, *tbType;
    UInt4   nmlen1, nmlen2, nmlen3, nmlen4;
+   StatementClass *stmt = (StatementClass *) StatementHandle;
+   ConnectionClass *conn;
+   BOOL lower_id;
 
    mylog("[SQLTablesW]");
-   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1);
-   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2);
-   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3);
-   tbType = ucs2_to_utf8(TableType, NameLength4, &nmlen4);
-   ENTER_STMT_CS((StatementClass *) StatementHandle);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
+   tbType = ucs2_to_utf8(TableType, NameLength4, &nmlen4, FALSE);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_Tables(StatementHandle, ctName, (SWORD) nmlen1,
            scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
            tbType, (SWORD) nmlen4);
-   LEAVE_STMT_CS((StatementClass *) StatementHandle);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -419,17 +439,22 @@ RETCODE SQL_API SQLColumnPrivilegesW(
    RETCODE ret;
    char    *ctName, *scName, *tbName, *clName;
    UInt4   nmlen1, nmlen2, nmlen3, nmlen4;
+   StatementClass *stmt = (StatementClass *) hstmt;
+   ConnectionClass *conn;
+   BOOL    lower_id; 
 
    mylog("[SQLColumnPrivilegesW]");
-   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
-   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
-   tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3);
-   clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4);
-   ENTER_STMT_CS((StatementClass *) hstmt);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id);
+   clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_ColumnPrivileges(hstmt, ctName, (SWORD) nmlen1,
        scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
        clName, (SWORD) nmlen4);
-   LEAVE_STMT_CS((StatementClass *) hstmt);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -459,20 +484,25 @@ RETCODE SQL_API SQLForeignKeysW(
    RETCODE ret;
    char    *ctName, *scName, *tbName, *fkctName, *fkscName, *fktbName;
    UInt4   nmlen1, nmlen2, nmlen3, nmlen4, nmlen5, nmlen6;
+   StatementClass *stmt = (StatementClass *) hstmt;
+   ConnectionClass *conn;
+   BOOL    lower_id; 
 
    mylog("[SQLForeignKeysW]");
-   ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1);
-   scName = ucs2_to_utf8(szPkSchemaName, cbPkSchemaName, &nmlen2);
-   tbName = ucs2_to_utf8(szPkTableName, cbPkTableName, &nmlen3);
-   fkctName = ucs2_to_utf8(szFkCatalogName, cbFkCatalogName, &nmlen4);
-   fkscName = ucs2_to_utf8(szFkSchemaName, cbFkSchemaName, &nmlen5);
-   fktbName = ucs2_to_utf8(szFkTableName, cbFkTableName, &nmlen6);
-   ENTER_STMT_CS((StatementClass *) hstmt);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(szPkSchemaName, cbPkSchemaName, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(szPkTableName, cbPkTableName, &nmlen3, lower_id);
+   fkctName = ucs2_to_utf8(szFkCatalogName, cbFkCatalogName, &nmlen4, lower_id);
+   fkscName = ucs2_to_utf8(szFkSchemaName, cbFkSchemaName, &nmlen5, lower_id);
+   fktbName = ucs2_to_utf8(szFkTableName, cbFkTableName, &nmlen6, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_ForeignKeys(hstmt, ctName, (SWORD) nmlen1,
        scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3,
        fkctName, (SWORD) nmlen4, fkscName, (SWORD) nmlen5,
        fktbName, (SWORD) nmlen6);
-   LEAVE_STMT_CS((StatementClass *) hstmt);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -504,7 +534,7 @@ RETCODE SQL_API SQLNativeSqlW(
    mylog("[SQLNativeSqlW]");
    ENTER_CONN_CS((ConnectionClass *) hdbc);
    ((ConnectionClass *) hdbc)->unicode = 1;
-   szIn = ucs2_to_utf8(szSqlStrIn, cbSqlStrIn, &slen);
+   szIn = ucs2_to_utf8(szSqlStrIn, cbSqlStrIn, &slen, FALSE);
    buflen = 3 * cbSqlStrMax + 1;
    szOut = malloc(buflen);
    ret = PGAPI_NativeSql(hdbc, szIn, (SQLINTEGER) slen,
@@ -541,15 +571,20 @@ RETCODE SQL_API SQLPrimaryKeysW(
    RETCODE ret;
    char    *ctName, *scName, *tbName;
    UInt4   nmlen1, nmlen2, nmlen3;
+   StatementClass *stmt = (StatementClass *) hstmt;
+   ConnectionClass *conn;
+   BOOL    lower_id; 
 
    mylog("[SQLPrimaryKeysW]");
-   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
-   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
-   tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3);
-   ENTER_STMT_CS((StatementClass *) hstmt);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_PrimaryKeys(hstmt, ctName, (SWORD) nmlen1,
        scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3);
-   LEAVE_STMT_CS((StatementClass *) hstmt);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -573,17 +608,22 @@ RETCODE SQL_API SQLProcedureColumnsW(
    RETCODE ret;
    char    *ctName, *scName, *prName, *clName;
    UInt4   nmlen1, nmlen2, nmlen3, nmlen4;
+   StatementClass *stmt = (StatementClass *) hstmt;
+   ConnectionClass *conn;
+   BOOL    lower_id; 
 
    mylog("[SQLProcedureColumnsW]");
-   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
-   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
-   prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3);
-   clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4);
-   ENTER_STMT_CS((StatementClass *) hstmt);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
+   prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id);
+   clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_ProcedureColumns(hstmt, ctName, (SWORD) nmlen1,
        scName, (SWORD) nmlen2, prName, (SWORD) nmlen3,
        clName, (SWORD) nmlen4);
-   LEAVE_STMT_CS((StatementClass *) hstmt);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -607,15 +647,20 @@ RETCODE SQL_API SQLProceduresW(
    RETCODE ret;
    char    *ctName, *scName, *prName;
    UInt4   nmlen1, nmlen2, nmlen3;
+   StatementClass *stmt = (StatementClass *) hstmt;
+   ConnectionClass *conn;
+   BOOL    lower_id; 
 
    mylog("[SQLProceduresW]");
-   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
-   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
-   prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3);
-   ENTER_STMT_CS((StatementClass *) hstmt);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
+   prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id);
+   ENTER_STMT_CS(stmt);
    ret = PGAPI_Procedures(hstmt, ctName, (SWORD) nmlen1,
        scName, (SWORD) nmlen2, prName, (SWORD) nmlen3);
-   LEAVE_STMT_CS((StatementClass *) hstmt);
+   LEAVE_STMT_CS(stmt);
    if (ctName)
        free(ctName);
    if (scName)
@@ -637,11 +682,16 @@ RETCODE SQL_API SQLTablePrivilegesW(
    RETCODE ret;
    char    *ctName, *scName, *tbName;
    UInt4   nmlen1, nmlen2, nmlen3;
+   StatementClass *stmt = (StatementClass *) hstmt;
+   ConnectionClass *conn;
+   BOOL    lower_id; 
 
    mylog("[SQLTablePrivilegesW]");
-   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1);
-   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2);
-   tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3);
+   conn = SC_get_conn(stmt);
+   lower_id = SC_is_lower_case(stmt, conn);
+   ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
+   scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
+   tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id);
    ENTER_STMT_CS((StatementClass *) hstmt);
    ret = PGAPI_TablePrivileges(hstmt, ctName, (SWORD) nmlen1,
        scName, (SWORD) nmlen2, tbName, (SWORD) nmlen3, 0);
index b69beb742c9663da13ecadd3492ba1c66b6e9fcf..b9fcc1bd572a7063043f8cb76f54e91f14cd75ba 100644 (file)
--- a/options.c
+++ b/options.c
@@ -36,7 +36,7 @@ set_statement_option(ConnectionClass *conn,
                     UWORD fOption,
                     UDWORD vParam)
 {
-   static char *func = "set_statement_option";
+   CSTR func = "set_statement_option";
    char        changed = FALSE;
    ConnInfo   *ci = NULL;
    UDWORD      setval;
@@ -68,7 +68,7 @@ set_statement_option(ConnectionClass *conn,
            setval = SQL_CONCUR_READ_ONLY;
            if (SQL_CONCUR_READ_ONLY == vParam)
                ;
-           if (ci->drivers.lie)
+           else if (ci->drivers.lie)
                setval = vParam;
            else if (ci->updatable_cursors)
                setval = SQL_CONCUR_ROWVER;
@@ -305,7 +305,7 @@ PGAPI_SetConnectOption(
                       UWORD fOption,
                       UDWORD vParam)
 {
-   static char *func = "PGAPI_SetConnectOption";
+   CSTR func = "PGAPI_SetConnectOption";
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    char        changed = FALSE;
    RETCODE     retval;
@@ -480,7 +480,7 @@ PGAPI_SetConnectOption(
                    char *asPara;
                    if (conn->unicode)
                    {
-                       asPara = ucs2_to_utf8((SQLWCHAR *) vParam, -1, NULL);
+                       asPara = ucs2_to_utf8((SQLWCHAR *) vParam, -1, NULL, FALSE);
                        cmp = strcmp(asPara, "Microsoft Jet");
                        free(asPara);
                    }
@@ -517,7 +517,7 @@ PGAPI_GetConnectOption(
                       UWORD fOption,
                       PTR pvParam)
 {
-   static char *func = "PGAPI_GetConnectOption";
+   CSTR func = "PGAPI_GetConnectOption";
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    ConnInfo   *ci = &(conn->connInfo);
 
@@ -603,7 +603,7 @@ PGAPI_SetStmtOption(
                    UWORD fOption,
                    UDWORD vParam)
 {
-   static char *func = "PGAPI_SetStmtOption";
+   CSTR func = "PGAPI_SetStmtOption";
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("%s: entering...\n", func);
@@ -629,7 +629,7 @@ PGAPI_GetStmtOption(
                    UWORD fOption,
                    PTR pvParam)
 {
-   static char *func = "PGAPI_GetStmtOption";
+   CSTR func = "PGAPI_GetStmtOption";
    StatementClass *stmt = (StatementClass *) hstmt;
    QResultClass *res;
    ConnInfo   *ci = &(SC_get_conn(stmt)->connInfo);
diff --git a/parse.c b/parse.c
index aad02e10f12039d7526130a503155a7426bf3e93..b418d6d0faa03a8b4f39353ba09bd528105dde0d 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -309,9 +309,7 @@ void lower_the_name(char *name, ConnectionClass *conn, BOOL dquote)
        for (ptr = name; *ptr; ptr++)
        {
            encoded_nextchar(&encstr);
-           if (ENCODE_STATUS(encstr) != 0)
-               ptr++;
-           else
+           if (ENCODE_STATUS(encstr) == 0)
                *ptr = tolower((unsigned char) *ptr);
        }
    }
@@ -320,7 +318,7 @@ void lower_the_name(char *name, ConnectionClass *conn, BOOL dquote)
 char
 parse_statement(StatementClass *stmt)
 {
-   static char *func = "parse_statement";
+   CSTR        func = "parse_statement";
    char        token[256], stoken[256];
    char        delim,
                quote,
index 10ce40e4845526dc11c89ad53681cac53e55af70..9eaa50732297f1ef95182853a78c4ad126bf01db 100644 (file)
--- a/pgapi30.c
+++ b/pgapi30.c
@@ -36,7 +36,7 @@ PGAPI_GetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
        SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
 {
    RETCODE     ret;
-   static const char *func = "PGAPI_GetDiagRec";
+   CSTR func = "PGAPI_GetDiagRec";
 
    mylog("%s entering rec=%d", func, RecNumber);
    switch (HandleType)
@@ -85,7 +85,7 @@ PGAPI_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
    StatementClass  *stmt;
    SDWORD      rc;
    SWORD       pcbErrm;
-   static const char *func = "PGAPI_GetDiagField";
+   CSTR func = "PGAPI_GetDiagField";
 
    mylog("%s entering rec=%d", func, RecNumber);
    switch (HandleType)
@@ -362,7 +362,7 @@ PGAPI_GetConnectAttr(HDBC ConnectionHandle,
            SQLINTEGER Attribute, PTR Value,
            SQLINTEGER BufferLength, SQLINTEGER *StringLength)
 {
-   static const char *func = "PGAPI_GetConnectAttr";
+   CSTR func = "PGAPI_GetConnectAttr";
    ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
    RETCODE ret = SQL_SUCCESS;
    SQLINTEGER  len = 4;
@@ -383,9 +383,8 @@ PGAPI_GetConnectAttr(HDBC ConnectionHandle,
            *((SQLUINTEGER *) Value) = 0;
            break;
        case SQL_ATTR_METADATA_ID:
-           CC_set_error(conn, STMT_INVALID_OPTION_IDENTIFIER, "Unsupported connect attribute (Get)");
-           CC_log_error(func, "", conn);
-           return SQL_ERROR;
+           *((SQLUINTEGER *) Value) = conn->stmtOptions.metadata_id;
+           break;
        default:
            ret = PGAPI_GetConnectOption(ConnectionHandle, (UWORD) Attribute, Value);
    }
@@ -1409,7 +1408,7 @@ PGAPI_GetStmtAttr(HSTMT StatementHandle,
        SQLINTEGER Attribute, PTR Value,
        SQLINTEGER BufferLength, SQLINTEGER *StringLength)
 {
-   static char *func = "PGAPI_GetStmtAttr";
+   CSTR func = "PGAPI_GetStmtAttr";
    StatementClass *stmt = (StatementClass *) StatementHandle;
    RETCODE     ret = SQL_SUCCESS;
    int         len = 0;
@@ -1487,15 +1486,12 @@ PGAPI_GetStmtAttr(HSTMT StatementHandle,
            else
                *((SQLUINTEGER *) Value) = SQL_UNSPECIFIED;
            break;
+       case SQL_ATTR_METADATA_ID:      /* 10014 */
+           *((SQLUINTEGER *) Value) = stmt->options.metadata_id;
+           break;
        case SQL_ATTR_AUTO_IPD: /* 10001 */
            /* case SQL_ATTR_ROW_BIND_TYPE: ** == SQL_BIND_TYPE(ODBC2.0) */
        case SQL_ATTR_ENABLE_AUTO_IPD:  /* 15 */
-       case SQL_ATTR_METADATA_ID:      /* 10014 */
-
-           /*
-            * case SQL_ATTR_PREDICATE_PTR: case
-            * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR:
-            */
            SC_set_error(stmt, STMT_INVALID_OPTION_IDENTIFIER, "Unsupported statement option (Get)");
            SC_log_error(func, "", stmt);
            return SQL_ERROR;
@@ -1520,11 +1516,13 @@ PGAPI_SetConnectAttr(HDBC ConnectionHandle,
    mylog("PGAPI_SetConnectAttr %d\n", Attribute);
    switch (Attribute)
    {
+       case SQL_ATTR_METADATA_ID:
+           conn->stmtOptions.metadata_id = (SQLUINTEGER) Value;
+           break;
        case SQL_ATTR_ASYNC_ENABLE:
        case SQL_ATTR_AUTO_IPD:
        case SQL_ATTR_CONNECTION_DEAD:
        case SQL_ATTR_CONNECTION_TIMEOUT:
-       case SQL_ATTR_METADATA_ID:
        case SQL_ATTR_ENLIST_IN_DTC:
            CC_set_error(conn, STMT_OPTION_NOT_FOR_THE_DRIVER, "Unsupported connect attribute (Set)");
            return SQL_ERROR;
@@ -1545,7 +1543,7 @@ PGAPI_GetDescField(SQLHDESC DescriptorHandle,
    HSTMT       hstmt;
    SQLUINTEGER descType;
    StatementClass *stmt;
-   static const char *func = "PGAPI_GetDescField";
+   CSTR func = "PGAPI_GetDescField";
 
    mylog("%s h=%u rec=%d field=%d blen=%d\n", func, DescriptorHandle, RecNumber, FieldIdentifier, BufferLength);
    hstmt = statementHandleFromDescHandle(DescriptorHandle, &descType);
@@ -1600,7 +1598,7 @@ PGAPI_SetDescField(SQLHDESC DescriptorHandle,
    HSTMT       hstmt;
    SQLUINTEGER descType;
    StatementClass *stmt;
-   static const char *func = "PGAPI_SetDescField";
+   CSTR func = "PGAPI_SetDescField";
 
    mylog("%s h=%u rec=%d field=%d val=%x,%d\n", func, DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
    hstmt = statementHandleFromDescHandle(DescriptorHandle, &descType);
@@ -1651,7 +1649,7 @@ PGAPI_SetStmtAttr(HSTMT StatementHandle,
        SQLINTEGER Attribute, PTR Value,
        SQLINTEGER StringLength)
 {
-   static char *func = "PGAPI_SetStmtAttr";
+   CSTR func = "PGAPI_SetStmtAttr";
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("%s Handle=%u %d,%u\n", func, StatementHandle, Attribute, Value);
@@ -1668,7 +1666,6 @@ PGAPI_SetStmtAttr(HSTMT StatementHandle,
        /* case SQL_ATTR_ROW_BIND_TYPE: ** == SQL_BIND_TYPE(ODBC2.0) */
        case SQL_ATTR_IMP_ROW_DESC: /* 10012 (read-only) */
        case SQL_ATTR_IMP_PARAM_DESC:   /* 10013 (read-only) */
-       case SQL_ATTR_METADATA_ID:      /* 10014 */
 
            /*
             * case SQL_ATTR_PREDICATE_PTR: case
@@ -1678,6 +1675,9 @@ PGAPI_SetStmtAttr(HSTMT StatementHandle,
            SC_log_error(func, "", stmt);
            return SQL_ERROR;
 
+       case SQL_ATTR_METADATA_ID:      /* 10014 */
+           stmt->options.metadata_id = (SQLUINTEGER) Value;
+           break;
        case SQL_ATTR_FETCH_BOOKMARK_PTR:       /* 16 */
            stmt->options.bookmark_ptr = Value;
            break;
@@ -1728,7 +1728,7 @@ PGAPI_SetStmtAttr(HSTMT StatementHandle,
 RETCODE    SQL_API
 PGAPI_BulkOperations(HSTMT hstmt, SQLSMALLINT operation)
 {
-   static char *func = "PGAPI_BulkOperations";
+   CSTR func = "PGAPI_BulkOperations";
    StatementClass  *stmt = (StatementClass *) hstmt;
    ARDFields   *opts = SC_get_ARD(stmt);
    RETCODE     ret;
index 75233e49793264817e7bf459625c3776bd45b567..b39ff01b1466ca575f08ca2160b896fe71caf05a 100644 (file)
--- a/pgtypes.c
+++ b/pgtypes.c
@@ -819,6 +819,7 @@ Int4
 pgtype_column_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as)
 {
    ConnectionClass *conn = SC_get_conn(stmt);
+   ConnInfo    *ci = &(conn->connInfo);
 
    switch (type)
    {
@@ -882,7 +883,7 @@ pgtype_column_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_
            return getTimestampColumnSize(stmt, type, col);
 
        case PG_TYPE_BOOL:
-           return conn->connInfo.true_is_minus1 ? 2 : 1;
+           return ci->true_is_minus1 ? 2 : 1;
 
        case PG_TYPE_LO_UNDEFINED:
            return SQL_NO_TOTAL;
@@ -892,6 +893,8 @@ pgtype_column_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_
            if (type == stmt->hdbc->lobj_type)  /* hack until permanent
                                                 * type is available */
                return SQL_NO_TOTAL;
+           if (PG_TYPE_BYTEA == type && ci->bytea_as_longvarbinary)
+               return SQL_NO_TOTAL;
 
            /* Handle Character types and unknown types */
            return getCharColumnSize(stmt, type, col, handle_unknown_size_as);
index 22ed32b44c1f342c47fe1267fe2ac9adaf6929c1..0949531650dcab8cc268f64d8e95d5e5f1a4423b 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Comments:       See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.77 2003/05/14 18:16:16 dpage Exp $
+ * $Id: psqlodbc.h,v 1.78 2003/08/27 10:17:53 hinoue Exp $
  *
  */
 
@@ -242,6 +242,9 @@ typedef struct StatementOptions_
    int         retrieve_data;
    int         use_bookmarks;
    void            *bookmark_ptr;
+#if (ODBCVER >= 0x0300)
+   int         metadata_id;
+#endif /* ODBCVER */
 } StatementOptions;
 
 /* Used to pass extra query info to send_query */
@@ -278,7 +281,7 @@ void        logs_on_off(int cnopen, int, int);
 
 #ifdef UNICODE_SUPPORT
 UInt4  ucs2strlen(const SQLWCHAR *ucs2str);
-char   *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen);
+char   *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen, BOOL tolower);
 UInt4  utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen);
 #define    utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen)
 #endif /* UNICODE_SUPPORT */
index 1df279e3a0b41ff9d1d164e913e4613ab9d4f349..8f11c200b75e8c6e335ab689a44e0c9db11420ad 100644 (file)
--- a/results.c
+++ b/results.c
@@ -38,7 +38,7 @@ PGAPI_RowCount(
               HSTMT hstmt,
               SDWORD FAR * pcrow)
 {
-   static char *func = "PGAPI_RowCount";
+   CSTR func = "PGAPI_RowCount";
    StatementClass *stmt = (StatementClass *) hstmt;
    QResultClass *res;
    ConnInfo   *ci;
@@ -98,7 +98,7 @@ PGAPI_NumResultCols(
                    HSTMT hstmt,
                    SWORD FAR * pccol)
 {
-   static char *func = "PGAPI_NumResultCols";
+   CSTR func = "PGAPI_NumResultCols";
    StatementClass *stmt = (StatementClass *) hstmt;
    QResultClass *result;
    char        parse_ok;
@@ -168,7 +168,7 @@ PGAPI_DescribeCol(
                  SWORD FAR * pibScale,
                  SWORD FAR * pfNullable)
 {
-   static char *func = "PGAPI_DescribeCol";
+   CSTR func = "PGAPI_DescribeCol";
 
    /* gets all the information about a specific column */
    StatementClass *stmt = (StatementClass *) hstmt;
@@ -382,7 +382,7 @@ PGAPI_ColAttributes(
                    SWORD FAR * pcbDesc,
                    SDWORD FAR * pfDesc)
 {
-   static char *func = "PGAPI_ColAttributes";
+   CSTR func = "PGAPI_ColAttributes";
    StatementClass *stmt = (StatementClass *) hstmt;
    IRDFields   *irdflds;
    Int4        col_idx, field_type = 0;
@@ -780,7 +780,7 @@ PGAPI_GetData(
              SDWORD cbValueMax,
              SDWORD FAR * pcbValue)
 {
-   static char *func = "PGAPI_GetData";
+   CSTR func = "PGAPI_GetData";
    QResultClass *res;
    StatementClass *stmt = (StatementClass *) hstmt;
    int         num_cols,
@@ -975,7 +975,7 @@ RETCODE     SQL_API
 PGAPI_Fetch(
            HSTMT hstmt)
 {
-   static char *func = "PGAPI_Fetch";
+   CSTR func = "PGAPI_Fetch";
    StatementClass *stmt = (StatementClass *) hstmt;
    ARDFields   *opts;
    QResultClass *res;
@@ -1130,7 +1130,7 @@ PGAPI_ExtendedFetch(
                    SQLINTEGER bookmark_offset,
                    SQLINTEGER rowsetSize)
 {
-   static char *func = "PGAPI_ExtendedFetch";
+   CSTR func = "PGAPI_ExtendedFetch";
    StatementClass *stmt = (StatementClass *) hstmt;
    ARDFields   *opts;
    QResultClass *res;
@@ -1556,7 +1556,7 @@ RETCODE       SQL_API
 PGAPI_MoreResults(
                  HSTMT hstmt)
 {
-   const char *func = "PGAPI_MoreResults";
+   CSTR func = "PGAPI_MoreResults";
    StatementClass  *stmt = (StatementClass *) hstmt;
    QResultClass    *res;
 
@@ -2750,7 +2750,7 @@ PGAPI_SetPos(
             UWORD fOption,
             UWORD fLock)
 {
-   static char *func = "PGAPI_SetPos";
+   CSTR func = "PGAPI_SetPos";
    RETCODE ret;
    StatementClass *stmt = (StatementClass *) hstmt;
    ConnectionClass *conn = SC_get_conn(stmt);
@@ -2911,7 +2911,7 @@ PGAPI_SetScrollOptions( HSTMT hstmt,
                SDWORD crowKeyset,
                UWORD crowRowset)
 {
-   static char *func = "PGAPI_SetScrollOptions";
+   CSTR func = "PGAPI_SetScrollOptions";
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("PGAPI_SetScrollOptions fConcurrency=%d crowKeyset=%d crowRowset=%d\n",
@@ -2930,7 +2930,7 @@ PGAPI_SetCursorName(
                    UCHAR FAR * szCursor,
                    SWORD cbCursor)
 {
-   static char *func = "PGAPI_SetCursorName";
+   CSTR func = "PGAPI_SetCursorName";
    StatementClass *stmt = (StatementClass *) hstmt;
    int         len;
 
@@ -2964,7 +2964,7 @@ PGAPI_GetCursorName(
                    SWORD cbCursorMax,
                    SWORD FAR * pcbCursor)
 {
-   static char *func = "PGAPI_GetCursorName";
+   CSTR func = "PGAPI_GetCursorName";
    StatementClass *stmt = (StatementClass *) hstmt;
    int         len = 0;
    RETCODE     result;
index eeb735c92a90eb1fb4354c0c2f6f68dad5272cd8..2b4119bd4d1f872a222d66123aab1bc125e68c43 100644 (file)
@@ -81,7 +81,7 @@ RETCODE       SQL_API
 PGAPI_AllocStmt(HDBC hdbc,
                HSTMT FAR * phstmt)
 {
-   static char *func = "PGAPI_AllocStmt";
+   CSTR func = "PGAPI_AllocStmt";
    ConnectionClass *conn = (ConnectionClass *) hdbc;
    StatementClass *stmt;
 
@@ -135,7 +135,7 @@ RETCODE     SQL_API
 PGAPI_FreeStmt(HSTMT hstmt,
               UWORD fOption)
 {
-   static char *func = "PGAPI_FreeStmt";
+   CSTR func = "PGAPI_FreeStmt";
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("%s: entering...hstmt=%u, fOption=%d\n", func, hstmt, fOption);
@@ -218,6 +218,9 @@ InitializeStatementOptions(StatementOptions *opt)
    opt->cursor_type = SQL_CURSOR_FORWARD_ONLY;
    opt->retrieve_data = SQL_RD_ON;
    opt->use_bookmarks = SQL_UB_OFF;
+#if (ODBCVER >= 0x0300)
+   opt->metadata_id = SQL_FALSE;
+#endif /* ODBCVER */
 }
 
 
@@ -845,7 +848,7 @@ SC_get_bookmark(StatementClass *self)
 RETCODE
 SC_fetch(StatementClass *self)
 {
-   static char *func = "SC_fetch";
+   CSTR func = "SC_fetch";
    QResultClass *res = SC_get_Curres(self);
    ARDFields   *opts;
    int         retval,
@@ -1024,7 +1027,7 @@ SC_fetch(StatementClass *self)
 RETCODE
 SC_execute(StatementClass *self)
 {
-   static char *func = "SC_execute";
+   CSTR func = "SC_execute";
    ConnectionClass *conn;
    APDFields   *apdopts;
    char        was_ok, was_nonfatal, was_rows_affected = 1;
index de8f8abe34e0f5143a8533ea52e8473cf2b52c3d..cd7fb9f45356f54d4e83a8d9ed9652616c95688e 100644 (file)
@@ -227,6 +227,11 @@ struct StatementClass_
 #define    SC_get_errornumber(a) (a->__error_number)
 #define    SC_set_errornumber(a, n) (a->__error_number = n)
 #define    SC_get_errormsg(a) (a->__error_message)
+#if (ODBCVER >= 0x0300)
+#define    SC_is_lower_case(a, b) (a->options.metadata_id || b->connInfo.lower_case_identifier)
+#else
+#define    SC_is_lower_case(a, b) (b->connInfo.lower_case_identifier)
+#endif /* ODBCVER */
 
 /* options for SC_free_params() */
 #define STMT_FREE_PARAMS_ALL               0
index e13886419d2a18ce85281be12ef2580cebd15e0c..096e049db310a990eda2ed554b31c242151d37a5 100644 (file)
--- a/version.h
+++ b/version.h
@@ -9,8 +9,8 @@
 #ifndef __VERSION_H__
 #define __VERSION_H__
 
-#define POSTGRESDRIVERVERSION      "07.03.0111"
-#define POSTGRES_RESOURCE_VERSION  "07.03.0111\0"
-#define PG_DRVFILE_VERSION     7,3,1,11
+#define POSTGRESDRIVERVERSION      "07.03.0113"
+#define POSTGRES_RESOURCE_VERSION  "07.03.0113\0"
+#define PG_DRVFILE_VERSION     7,3,1,13
 
 #endif
index 112ea18be195c7c7520c1d3120ed43f8146c7177..ff1ef29bef4d19ca6cf77017517451f5e4679f72 100644 (file)
@@ -27,7 +27,7 @@ UInt4 ucs2strlen(const SQLWCHAR *ucs2str)
        ;
    return len;
 }
-char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen)
+char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen, BOOL lower_identifier)
 {
    char *  utf8str;
 /*mylog("ucs2_to_utf8 %x ilen=%d ", ucs2str, ilen);*/
@@ -49,8 +49,13 @@ char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen)
        {
            if (!*wstr)
                break;
-           else if (0 == (*wstr & 0xff80))
-               utf8str[len++] = (char) *wstr;
+           else if (0 == (*wstr & 0xff80)) /* ASCII */
+           {
+               if (lower_identifier)
+                   utf8str[len++] = (char) tolower(*wstr);
+               else
+                   utf8str[len++] = (char) *wstr;
+           }
            else if ((*wstr & byte3check) == 0)
            {
                byte2code = byte2_base |