Now per connection Debug/Commlog info are handled in getDSNinfo().
Global Debug/Commlog info are get/set using functions get(set)GlobalDebug(Commlog)().
static void LIBPQ_update_transaction_status(ConnectionClass *self);
-extern GLOBAL_VALUES globals;
-
static void CC_set_error_if_not_set(ConnectionClass *self, int errornumber, const char *errormsg, const char *func)
{
{
mylog("calling getDSNdefaults\n");
+ if (ci->drivers.debug < 0)
+ ci->drivers.debug = DEFAULT_DEBUG;
+ if (ci->drivers.commlog < 0)
+ ci->drivers.commlog = DEFAULT_COMMLOG;
+
if (ci->onlyread[0] == '\0')
sprintf(ci->onlyread, "%d", globals.onlyread);
return SQLGetPrivateProfileString(ODBC_DATASOURCES, dsn, "", driver_name, namelen, ODBC_INI);
}
-int
-getLogDir(char *dir, int dirmax)
-{
- return SQLGetPrivateProfileString(DBMS_NAME, INI_LOGDIR, "", dir, dirmax, ODBCINST_INI);
-}
-
-int
-setLogDir(const char *dir)
-{
- return SQLWritePrivateProfileString(DBMS_NAME, INI_LOGDIR, dir, ODBCINST_INI);
-}
void
getDSNinfo(ConnInfo *ci, char overwrite)
if (ci->port[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->port), ODBC_INI);
+ /* It's appropriate to handle debug and commlog here */
+ if (ci->drivers.debug < 0 || overwrite)
+ {
+ SQLGetPrivateProfileString(DSN, INI_DEBUG, "", temp, sizeof(temp), ODBC_INI);
+ if (temp[0])
+ ci->drivers.debug = atoi(temp);
+ }
+ if (ci->drivers.commlog < 0 || overwrite)
+ {
+ SQLGetPrivateProfileString(DSN, INI_COMMLOG, "", temp, sizeof(temp), ODBC_INI);
+ if (temp[0])
+ ci->drivers.commlog = atoi(temp);
+ }
+
if (ci->onlyread[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->onlyread, sizeof(ci->onlyread), ODBC_INI);
sectionName = DBMS_NAME;
}
+ if (stricmp(ODBCINST_INI, fileName) == 0)
+ return errc;
+
sprintf(tmp, "%d", comval->commlog);
if (!SQLWritePrivateProfileString(sectionName, INI_COMMLOG, tmp, fileName))
errc--;
if (!SQLWritePrivateProfileString(sectionName, INI_DEBUG, tmp, fileName))
errc--;
- if (stricmp(ODBCINST_INI, fileName) == 0)
- return errc;
-
sprintf(tmp, "%d", comval->fetch_max);
if (!SQLWritePrivateProfileString(sectionName, INI_FETCH, tmp, fileName))
errc--;
BOOL inst_position = (stricmp(filename, ODBCINST_INI) == 0);
const char *drivername = (inst_position ? section : ci->drivername);
- mylog("%s:setting %s position of %p\n", func, filename, ci);
+ mylog("%s:setting %s position of %s(%p)\n", func, filename, section, ci);
if (ci)
comval = &(ci->drivers);
else
comval = &globals;
/*
- * globals.debug or globals.commlog means whether take mylog or commlog
- * out of the connection time or not but doesn't mean the default of
- * ci->drivers.debug(commlog).
+ * It's not appropriate to handle debug or commlog here.
+ * Now they are handled in getDSNinfo().
*/
- /* Debug is stored in the driver section */
- SQLGetPrivateProfileString(section, INI_DEBUG, "",
- temp, sizeof(temp), filename);
- if (temp[0])
- {
- if (inst_position && ci)
- ;
- else
- comval->debug = atoi(temp);
- }
- else if (inst_position)
- comval->debug = DEFAULT_DEBUG;
-
- /* CommLog is stored in the driver section */
- SQLGetPrivateProfileString(section, INI_COMMLOG, "",
- temp, sizeof(temp), filename);
- if (temp[0])
- {
- if (inst_position && ci)
- ;
- else
- comval->commlog = atoi(temp);
- }
- else if (inst_position)
- comval->commlog = DEFAULT_COMMLOG;
-
- if (!ci)
- logs_on_off(0, 0, 0);
/*
* If inst_position of xxxxxx is present(usually not present),
if (0 != (CLEANUP_FOR_REUSE & option))
CC_conninfo_release(conninfo);
memset(conninfo, 0, sizeof(ConnInfo));
+
conninfo->allow_keyset = -1;
conninfo->lf_conversion = -1;
conninfo->true_is_minus1 = -1;
#endif /* _HANDLE_ENLIST_IN_DTC_ */
if (0 != (COPY_GLOBALS & option))
copy_globals(&(conninfo->drivers), &globals);
+ conninfo->drivers.debug = -1;
+ conninfo->drivers.commlog = -1;
}
#define CORR_STRCPY(item) strncpy_null(to->item, from->item, sizeof(to->item))
BOOL copyAttributes(ConnInfo *ci, const char *attribute, const char *value);
BOOL copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value);
int getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen);
-int getLogDir(char *dir, int dirmax);
-int setLogDir(const char *dir);
UInt4 getExtraOptions(const ConnInfo *);
BOOL setExtraOptions(ConnInfo *, const char *str, const char *format);
char *extract_extra_attribute_setting(const pgNAME setting, const char *attr);
{
case WM_INITDIALOG:
SetWindowLongPtr(hdlg, DWLP_USER, lParam); /* save for test etc */
- CheckDlgButton(hdlg, DRV_COMMLOG, globals.commlog);
- CheckDlgButton(hdlg, DRV_DEBUG, globals.debug);
+ CheckDlgButton(hdlg, DRV_COMMLOG, getGlobalCommlog());
+ CheckDlgButton(hdlg, DRV_DEBUG, getGlobalDebug());
getLogDir(logdir, sizeof(logdir));
SetDlgItemText(hdlg, DS_LOGDIR, logdir);
#ifdef _HANDLE_ENLIST_IN_DTC_
MessageBox(hdlg, "Folder for logging error", logmsg, MB_ICONEXCLAMATION | MB_OK);
break;
}
- globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
- globals.debug = IsDlgButtonChecked(hdlg, DRV_DEBUG);
+ setGlobalCommlog(IsDlgButtonChecked(hdlg, DRV_COMMLOG));
+ setGlobalDebug(IsDlgButtonChecked(hdlg, DRV_DEBUG));
+ writeGlobalLogs();
if (writeDriverCommoninfo(ODBCINST_INI, ci->drivername, &globals) < 0)
MessageBox(hdlg, "Sorry, impossible to update the values\nWrite permission seems to be needed", "Update Error", MB_ICONEXCLAMATION | MB_OK);
setLogDir(logdir[0] ? logdir : NULL);
static const char *next_name_token(const char *s, size_t *len);
-/*extern GLOBAL_VALUES globals;*/
-
-
/* Perform a Prepare on the SQL statement */
RETCODE SQL_API
PGAPI_Prepare(HSTMT hstmt,
#define TRIGGER_DELETE 0x01
#define TRIGGER_UPDATE 0x02
-/* extern GLOBAL_VALUES globals; */
-
static const SQLCHAR *pubstr = (SQLCHAR *) "public";
static const char *likeop = "like";
static const char *eqop = "=";
}
else if (mylog_off_count > 0)
mylog_on = 0;
- else if (globals.debug > 0)
- mylog_on = globals.debug;
+ else if (getGlobalDebug() > 0)
+ mylog_on = getGlobalDebug();
if (qlog_onoff)
qlog_on_count += cnopen;
else
qlog_on = 1;
else if (qlog_off_count > 0)
qlog_on = 0;
- else if (globals.commlog > 0)
- qlog_on = globals.commlog;
+ else if (getGlobalCommlog() > 0)
+ qlog_on = getGlobalCommlog();
LEAVE_QLOG_CS;
LEAVE_MYLOG_CS;
}
DELETE_QLOG_CS;
}
+static int globalDebug = -1;
+int
+getGlobalDebug()
+{
+ char temp[16];
+
+ if (globalDebug >=0)
+ return globalDebug;
+ /* Debug is stored in the driver section */
+ SQLGetPrivateProfileString(DBMS_NAME, INI_DEBUG, "", temp, sizeof(temp), ODBCINST_INI);
+ if (temp[0])
+ globalDebug = atoi(temp);
+ else
+ globalDebug = DEFAULT_DEBUG;
+
+ return globalDebug;
+}
+
+int
+setGlobalDebug(int val)
+{
+ return (globalDebug = val);
+}
+
+static int globalCommlog = -1;
+int
+getGlobalCommlog()
+{
+ char temp[16];
+
+ if (globalCommlog >= 0)
+ return globalCommlog;
+ /* Commlog is stored in the driver section */
+ SQLGetPrivateProfileString(DBMS_NAME, INI_COMMLOG, "", temp, sizeof(temp), ODBCINST_INI);
+ if (temp[0])
+ globalCommlog = atoi(temp);
+ else
+ globalCommlog = DEFAULT_COMMLOG;
+
+ return globalCommlog;
+}
+
+int
+setGlobalCommlog(int val)
+{
+ return (globalCommlog = val);
+}
+
+int
+writeGlobalLogs()
+{
+ char temp[10];
+
+ sprintf(temp, "%d", globalDebug);
+ SQLWritePrivateProfileString(DBMS_NAME, INI_DEBUG, temp, ODBCINST_INI);
+ sprintf(temp, "%d", globalCommlog);
+ SQLWritePrivateProfileString(DBMS_NAME, INI_COMMLOG, temp, ODBCINST_INI);
+ return 0;
+}
+
+int
+getLogDir(char *dir, int dirmax)
+{
+ return SQLGetPrivateProfileString(DBMS_NAME, INI_LOGDIR, "", dir, dirmax, ODBCINST_INI);
+}
+
+int
+setLogDir(const char *dir)
+{
+ return SQLWritePrivateProfileString(DBMS_NAME, INI_LOGDIR, dir, ODBCINST_INI);
+}
+
+/*
+ * This function starts a logging out of connections according the ODBCINST.INI
+ * portion of the DBMS_NAME registry.
+ */
+static void
+start_logging()
+{
+ /*
+ * GlobalDebug or GlobalCommlog means whether take mylog or commlog
+ * out of the connection time or not but doesn't mean the default of
+ * ci->drivers.debug(commlog).
+ */
+ logs_on_off(0, 0, 0);
+ mylog("\t%s:Global.debug&commlog=%d&%d\n", __FUNCTION__, getGlobalDebug(), getGlobalCommlog());
+}
+
void InitializeLogging(void)
{
char dir[PATH_MAX];
logdir = strdup(dir);
mylog_initialize();
qlog_initialize();
+ start_logging();
}
void FinalizeLogging(void)
int get_qlog(void);
int get_mylog(void);
+int getGlobalDebug();
+int setGlobalDebug(int val);
+int getGlobalCommlog();
+int setGlobalCommlog(int val);
+int writeGlobalLogs();
+int getLogDir(char *dir, int dirmax);
+int setLogDir(const char *dir);
+
void InitializeLogging(void);
void FinalizeLogging(void);
#ifdef POSIX_THREADMUTEX_SUPPORT
getMutexAttr();
#endif /* POSIX_THREADMUTEX_SUPPORT */
- InitializeLogging();
memset(&globals, 0, sizeof(globals));
+ globals.debug = globals.commlog = -1;
+ InitializeLogging();
INIT_CONNS_CS;
INIT_COMMON_CS;
if (!init)
return 0;
init = 0;
- InitializeLogging();
memset(&globals, 0, sizeof(globals));
+ globals.debug = globals.commlog = -1;
+ InitializeLogging();
return 0;
}