Changeset: c2a94e952e57 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c2a94e952e57 Branch: label Log Message:
merged with default diffs (truncated from 770 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -717,11 +717,11 @@ int64_t mapi_rows_affected(MapiHdl hdl) MapiMsg mapi_seek_row(MapiHdl hdl, int64_t rowne, int whence) __attribute__((__nonnull__(1))); MapiHdl mapi_send(Mapi mid, const char *cmd) __attribute__((__nonnull__(1))); MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit) __attribute__((__nonnull__(1))); -void mapi_set_application_name(const char *name); MapiMsg mapi_set_columnar_protocol(Mapi mid, bool columnar_protocol) __attribute__((__nonnull__(1))); MapiMsg mapi_set_size_header(Mapi mid, bool value) __attribute__((__nonnull__(1))); MapiMsg mapi_set_time_zone(Mapi mid, int seconds_east_of_utc) __attribute__((__nonnull__(1))); MapiMsg mapi_set_timeout(Mapi mid, unsigned int timeout, bool (*callback)(void *), void *callback_data) __attribute__((__nonnull__(1))); +void mapi_setclientprefix(Mapi mid, const char *prefix); void mapi_setfilecallback(Mapi mid, char *(*getfunc)(void *priv, const char *filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void *priv, const char *filename, const void *data, size_t size), void *priv) __attribute__((__nonnull__(1))); void mapi_setfilecallback2(Mapi mid, char *(*getfunc)(void *priv, const char *filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void *priv, const char *filename, bool binary, const void *data, size_t size), void *priv) __attribute__((__nonnull__(1))); Mapi mapi_settings(msettings *settings) __attribute__((__nonnull__(1))); diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -3682,7 +3682,6 @@ main(int argc, char **argv) } else { mid = mapi_mapi(host, port, user, passwd, language, dbname); } - mapi_set_application_name("mclient"); free(user_allocated); user_allocated = NULL; free(passwd_allocated); diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c --- a/clients/mapiclient/msqldump.c +++ b/clients/mapiclient/msqldump.c @@ -237,7 +237,6 @@ main(int argc, char **argv) } else { mid = mapi_mapi(host, port, user, passwd, "sql", dbname); } - mapi_set_application_name("msqldump"); free(user_allocated); user_allocated = NULL; free(passwd_allocated); diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c --- a/clients/mapilib/connect.c +++ b/clients/mapilib/connect.c @@ -385,6 +385,7 @@ static void send_all_clientinfo(Mapi mid) { msettings *mp = mid->settings; + void *free_this = NULL; if (!mid->clientinfo_supported) return; if (!msetting_bool(mp, MP_CLIENT_INFO)) @@ -398,9 +399,13 @@ send_all_clientinfo(Mapi mid) hostname[sizeof(hostname) - 1] = '\0'; } const char *application_name = msetting_string(mp, MP_CLIENT_APPLICATION); - if (!application_name[0]) - application_name = mapi_application_name; - const char *client_library = "libmapi " MONETDB_VERSION; + if (!application_name[0]) { + application_name = get_bin_path(); + if (application_name) { + free_this = strdup(application_name); + application_name = (const char*) basename((char*)application_name); + } + } const char *client_remark = msetting_string(mp, MP_CLIENT_REMARK); long pid = getpid(); @@ -411,7 +416,10 @@ send_all_clientinfo(Mapi mid) reallocprintf(&buf, &pos, &cap, "ClientHostName=%s\n", hostname); if (application_name[0]) reallocprintf(&buf, &pos, &cap, "ApplicationName=%s\n", application_name); - reallocprintf(&buf, &pos, &cap, "ClientLibrary=%s\n", client_library); + reallocprintf(&buf, &pos, &cap, "ClientLibrary="); + if (mid->clientprefix) + reallocprintf(&buf, &pos, &cap, "%s / ", mid->clientprefix); + reallocprintf(&buf, &pos, &cap, "libmapi %s\n", MONETDB_VERSION); if (client_remark[0]) reallocprintf(&buf, &pos, &cap, "ClientRemark=%s\n", client_remark); if (pid > 0) @@ -425,7 +433,9 @@ send_all_clientinfo(Mapi mid) if (pos <= cap) mapi_Xcommand(mid, "clientinfo", buf); + free(buf); + free(free_this); } static MapiMsg diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -794,8 +794,6 @@ static void mapi_store_bind(struct MapiR static ATOMIC_FLAG mapi_initialized = ATOMIC_FLAG_INIT; -char mapi_application_name[256] = { 0 }; - /* * Blocking * -------- @@ -2023,6 +2021,7 @@ mapi_destroy(Mapi mid) free(mid->noexplain); if (mid->errorstr && mid->errorstr != mapi_nomem) free(mid->errorstr); + free(mid->clientprefix); msettings_destroy(mid->settings); @@ -2121,15 +2120,6 @@ mapi_disconnect(Mapi mid) return MOK; } -void -mapi_set_application_name(const char *name) -{ - if (name) - strncpy(mapi_application_name, name, sizeof(mapi_application_name)-1); - else - mapi_application_name[0] = '\0'; -} - /* Set callback function to retrieve or send file content for COPY * INTO queries. * @@ -2257,6 +2247,17 @@ mapi_setfilecallback(Mapi mid, mid->filecontentprivate_old = filecontentprivate; } +void +mapi_setclientprefix(Mapi mid, const char *prefix) +{ + free(mid->clientprefix); + if (prefix == NULL) + mid->clientprefix = NULL; + else + mid->clientprefix = strdup(prefix); + +} + #define testBinding(hdl,fnr) \ do { \ mapi_hdl_check(hdl); \ diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h --- a/clients/mapilib/mapi.h +++ b/clients/mapilib/mapi.h @@ -76,9 +76,6 @@ extern "C" { # endif #endif -/* global state */ -mapi_export void mapi_set_application_name(const char *name); - /* connection-oriented functions */ mapi_export Mapi mapi_mapi(const char *host, int port, const char *username, const char *password, const char *lang, const char *dbname); mapi_export Mapi mapi_mapiuri(const char *url, const char *user, const char *pass, const char *lang); @@ -108,6 +105,7 @@ mapi_export void mapi_setfilecallback( const void *data, size_t size), void *priv) __attribute__((__nonnull__(1))); +mapi_export void mapi_setclientprefix(Mapi mid, const char *prefix); mapi_export MapiMsg mapi_error(Mapi mid) __attribute__((__nonnull__(1))); diff --git a/clients/mapilib/mapi_intern.h b/clients/mapilib/mapi_intern.h --- a/clients/mapilib/mapi_intern.h +++ b/clients/mapilib/mapi_intern.h @@ -238,6 +238,7 @@ struct MapiStruct { MapiMsg error; /* Error occurred */ char *errorstr; /* error from server */ const char *action; /* pointer to constant string */ + char *clientprefix; /* prefix for 'client' clientinfo; NULL or allocated string */ struct BlockCache blk; bool connected; @@ -310,8 +311,6 @@ MapiMsg mapi_Xcommand(Mapi mid, const ch extern const struct MapiStruct MapiStructDefaults; -extern char mapi_application_name[]; - // 'settings' will be newly allocated if NULL Mapi mapi_new(msettings *settings); diff --git a/clients/odbc/driver/ODBCAttrs.c b/clients/odbc/driver/ODBCAttrs.c --- a/clients/odbc/driver/ODBCAttrs.c +++ b/clients/odbc/driver/ODBCAttrs.c @@ -47,6 +47,9 @@ const struct attr_setting attr_settings[ { "LOGFILE", "Log File", MP_LOGFILE }, { "LOGINTIMEOUT", "Login Timeout", MP_CONNECT_TIMEOUT}, { "CONNECTIONTIMEOUT", "Connection Timeout", MP_REPLY_TIMEOUT}, + { "CLIENTINFO", "Send Client Info", MP_CLIENT_INFO }, + { "APPNAME", "Application Name", MP_CLIENT_APPLICATION }, + { "CLIENTREMARK", "Client Remark", MP_CLIENT_REMARK }, }; const int attr_setting_count = sizeof(attr_settings) / sizeof(attr_settings[0]); diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c --- a/clients/odbc/driver/SQLConnect.c +++ b/clients/odbc/driver/SQLConnect.c @@ -481,6 +481,7 @@ MNDBConnectSettings(ODBCDbc *dbc, const Mapi mid = mapi_settings(settings); if (mid) { settings = NULL; // will be free'd as part of 'mid' now + mapi_setclientprefix(mid, "ODBC " MONETDB_VERSION); mapi_setAutocommit(mid, dbc->sql_attr_autocommit == SQL_AUTOCOMMIT_ON); mapi_set_size_header(mid, true); mapi_reconnect(mid); diff --git a/clients/odbc/tests/ODBCStmtAttr.c b/clients/odbc/tests/ODBCStmtAttr.c --- a/clients/odbc/tests/ODBCStmtAttr.c +++ b/clients/odbc/tests/ODBCStmtAttr.c @@ -17,6 +17,9 @@ #include <stdlib.h> #include <stdint.h> #include <string.h> + +/**** Define the ODBC Version our ODBC driver complies with ****/ +#define ODBCVER 0x0352 /* Important: this must be defined before include of sql.h and sqlext.h */ #include <sql.h> #include <sqlext.h> diff --git a/clients/odbc/tests/ODBCgetInfo.c b/clients/odbc/tests/ODBCgetInfo.c --- a/clients/odbc/tests/ODBCgetInfo.c +++ b/clients/odbc/tests/ODBCgetInfo.c @@ -19,10 +19,8 @@ #include <stdbool.h> #include <string.h> -/**** Define the ODBC Version this ODBC driver complies with ****/ -/* also see ODBCGlobal.h */ +/**** Define the ODBC Version our ODBC driver complies with ****/ #define ODBCVER 0x0352 /* Important: this must be defined before include of sqlext.h */ - #include <sql.h> #include <sqlext.h> diff --git a/clients/odbc/tests/ODBCmetadata.c b/clients/odbc/tests/ODBCmetadata.c --- a/clients/odbc/tests/ODBCmetadata.c +++ b/clients/odbc/tests/ODBCmetadata.c @@ -36,6 +36,8 @@ #include <stdlib.h> #include <stdint.h> #include <inttypes.h> + +/**** Define the ODBC Version our ODBC driver complies with ****/ #define ODBCVER 0x0352 /* Important: this must be defined before include of sql.h and sqlext.h */ #include <sql.h> #include <sqlext.h> diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c --- a/clients/odbc/tests/ODBCtester.c +++ b/clients/odbc/tests/ODBCtester.c @@ -17,12 +17,15 @@ #include <stdlib.h> #include <stdint.h> #include <string.h> -#include <sql.h> -#include <sqlext.h> #include <ctype.h> #include <inttypes.h> #include <wchar.h> +/**** Define the ODBC Version our ODBC driver complies with ****/ +#define ODBCVER 0x0352 /* Important: this must be defined before include of sql.h and sqlext.h */ +#include <sql.h> +#include <sqlext.h> + static void prerr(SQLSMALLINT tpe, SQLHANDLE hnd, const char *func, const char *pref) { diff --git a/clients/odbc/winsetup/setup.c b/clients/odbc/winsetup/setup.c --- a/clients/odbc/winsetup/setup.c +++ b/clients/odbc/winsetup/setup.c @@ -188,6 +188,18 @@ DialogProc(HWND hwndDlg, UINT uMsg, WPAR free(datap->dsn); datap->dsn = strdup(buf); } + /* validate entered string values */ + GetDlgItemText(hwndDlg, IDC_EDIT_AUTOCOMMIT, buf, sizeof(buf)); + if (strcmp("on", buf) != 0 && strcmp("off", buf) != 0) { + MessageBox(hwndDlg, "Autocommit must be set to on or off. Default is on.", NULL, MB_ICONERROR); + return TRUE; + } + GetDlgItemText(hwndDlg, IDC_EDIT_USETLS, buf, sizeof(buf)); + if (strcmp("on", buf) != 0 && strcmp("off", buf) != 0) { + MessageBox(hwndDlg, "TLS Encrypt must be set to on or off. Default is off.", NULL, MB_ICONERROR); + return TRUE; + } + GetDlgItemText(hwndDlg, IDC_EDIT_DESC, buf, sizeof(buf)); if (datap->desc) free(datap->desc); @@ -265,9 +277,11 @@ DialogProc(HWND hwndDlg, UINT uMsg, WPAR EndDialog(hwndDlg, LOWORD(wParam)); return TRUE; case IDC_BUTTON_TEST: + // TODO call SQLDriverConnect() MessageBox(hwndDlg, "Test Connection not yet implemented", NULL, MB_ICONERROR); return TRUE; case IDC_BUTTON_HELP: + // TODO invoke webbrowser with url to webpage decribing this dialog. MessageBox(hwndDlg, "Help not yet implemented", NULL, MB_ICONERROR); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org