Changeset: 3c34f826c698 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3c34f826c698
Modified Files:
sql/backends/monet5/sql.c
Branch: label
Log Message:
merged with default
diffs (truncated from 2274 to 300 lines):
diff --git a/clients/Tests/MAL-signatures-hge.test
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -44629,6 +44629,11 @@ unsafe pattern clients.setScenario(X_0:s
CLTsetScenario;
Switch to other scenario handler, return previous one.
clients
+setinfo
+unsafe pattern clients.setinfo(X_0:str, X_1:str):str
+CLTsetClientInfo;
+set a clientinfo property
+clients
setmemorylimit
unsafe pattern clients.setmemorylimit(X_0:int):void
CLTsetmemorylimit;
@@ -49640,7 +49645,7 @@ SQLrow_number;
return the row_numer-ed groups
sql
sessions
-pattern sql.sessions() (X_0:bat[:int], X_1:bat[:str], X_2:bat[:timestamp],
X_3:bat[:timestamp], X_4:bat[:str], X_5:bat[:int], X_6:bat[:int],
X_7:bat[:int], X_8:bat[:int])
+pattern sql.sessions() (X_0:bat[:int], X_1:bat[:str], X_2:bat[:timestamp],
X_3:bat[:timestamp], X_4:bat[:str], X_5:bat[:int], X_6:bat[:int],
X_7:bat[:int], X_8:bat[:int], X_9:bat[:str], X_10:bat[:str], X_11:bat[:str],
X_12:bat[:str], X_13:bat[:str], X_14:bat[:lng], X_15:bat[:str])
sql_sessions_wrap;
SQL export table of active sessions, their timeouts and idle status
sql
diff --git a/clients/Tests/MAL-signatures.test
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -33164,6 +33164,11 @@ unsafe pattern clients.setScenario(X_0:s
CLTsetScenario;
Switch to other scenario handler, return previous one.
clients
+setinfo
+unsafe pattern clients.setinfo(X_0:str, X_1:str):str
+CLTsetClientInfo;
+set a clientinfo property
+clients
setmemorylimit
unsafe pattern clients.setmemorylimit(X_0:int):void
CLTsetmemorylimit;
@@ -38060,7 +38065,7 @@ SQLrow_number;
return the row_numer-ed groups
sql
sessions
-pattern sql.sessions() (X_0:bat[:int], X_1:bat[:str], X_2:bat[:timestamp],
X_3:bat[:timestamp], X_4:bat[:str], X_5:bat[:int], X_6:bat[:int],
X_7:bat[:int], X_8:bat[:int])
+pattern sql.sessions() (X_0:bat[:int], X_1:bat[:str], X_2:bat[:timestamp],
X_3:bat[:timestamp], X_4:bat[:str], X_5:bat[:int], X_6:bat[:int],
X_7:bat[:int], X_8:bat[:int], X_9:bat[:str], X_10:bat[:str], X_11:bat[:str],
X_12:bat[:str], X_13:bat[:str], X_14:bat[:lng], X_15:bat[:str])
sql_sessions_wrap;
SQL export table of active sessions, their timeouts and idle status
sql
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,6 +717,7 @@ 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)));
@@ -810,6 +811,7 @@ void MCcloseClient(Client c);
Client MCgetClient(int id);
Client MCinitClient(oid user, bstream *fin, stream *fout);
int MCpushClientInput(Client c, bstream *new_input, int listing, const char
*prompt);
+void MCsetClientInfo(Client c, const char *property, const char *value);
void MCstopClients(Client c);
str MCsuspendClient(int id);
int MCvalid(Client c);
@@ -818,7 +820,7 @@ str MSinitClientPrg(Client cntxt, const
void MSresetInstructions(MalBlkPtr mb, int start);
void MSresetStack(Client cntxt, MalBlkPtr mb, MalStkPtr glb);
void MSresetVariables(MalBlkPtr mb);
-void MSscheduleClient(str command, str challenge, bstream *fin, stream *fout,
protocol_version protocol, size_t blocksize);
+void MSscheduleClient(str command, str peer, str challenge, bstream *fin,
stream *fout, protocol_version protocol, size_t blocksize);
str OIDXcreateImplementation(Client cntxt, int tpe, BAT *b, int pieces);
str OIDXdropImplementation(Client cntxt, BAT *b);
str QLOGcalls(BAT **r);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3682,6 +3682,7 @@ 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,6 +237,7 @@ 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
@@ -24,6 +24,7 @@
#ifdef HAVE_SYS_SOCKET_H
# include <arpa/inet.h> /* addr_in */
+# include <unistd.h> /* gethostname() */
#else /* UNIX specific */
#ifdef HAVE_WINSOCK_H /* Windows specific */
# include <winsock.h>
@@ -380,6 +381,53 @@ connect_socket_tcp_addr(Mapi mid, struct
return s;
}
+static void
+send_all_clientinfo(Mapi mid)
+{
+ msettings *mp = mid->settings;
+ if (!mid->clientinfo_supported)
+ return;
+ if (!msetting_bool(mp, MP_CLIENT_INFO))
+ return;
+
+
+ static char hostname[120] = { 0 };
+ if (hostname[0] == '\0') {
+ if (gethostname(hostname, sizeof(hostname)) != 0)
+ hostname[0] = '\0';
+ 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;
+ const char *client_remark = msetting_string(mp, MP_CLIENT_REMARK);
+ long pid = getpid();
+
+ char *buf = NULL;
+ size_t pos = 0, cap = 200;
+
+ if (hostname[0])
+ 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);
+ if (client_remark[0])
+ reallocprintf(&buf, &pos, &cap, "ClientRemark=%s\n",
client_remark);
+ if (pid > 0)
+ reallocprintf(&buf, &pos, &cap, "ClientPid=%ld\n", pid);
+
+ if (pos > 1) {
+ assert(buf[pos - 1] == '\n');
+ pos--;
+ buf[pos] = '\0';
+ }
+
+ if (pos <= cap)
+ mapi_Xcommand(mid, "clientinfo", buf);
+ free(buf);
+}
+
static MapiMsg
mapi_handshake(Mapi mid)
{
@@ -489,15 +537,22 @@ mapi_handshake(Mapi mid)
}
}
- /* search for OOBINTR option,
- * NOTE this consumes the rest of the challenge */
- char *rest = strtok_r(NULL, ":", &strtok_state);
- while (rest != NULL) {
- if (strcmp(rest, "OOBINTR=1") == 0) {
+ /* skip the binary option */
+ char *binary = strtok_r(NULL, ":", &strtok_state);
+ (void)binary;
+
+ char *oobintr = strtok_r(NULL, ":", &strtok_state);
+ if (oobintr) {
+ if (strcmp(oobintr, "OOBINTR=1") == 0) {
mid->oobintr = true;
- break;
}
- rest = strtok_r(NULL, ":", &strtok_state);
+ }
+
+ char *clientinfo = strtok_r(NULL, ":", &strtok_state);
+ if (clientinfo) {
+ if (strcmp(oobintr, "OOBINTR=1") == 0) {
+ mid->clientinfo_supported = true;
+ }
}
/* hash password, if not already */
@@ -811,6 +866,9 @@ mapi_handshake(Mapi mid)
mapi_set_time_zone(mid, msetting_long(mid->settings,
MP_TIMEZONE));
}
+ if (mid->error == MOK)
+ send_all_clientinfo(mid);
+
return mid->error;
}
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -793,6 +793,9 @@ static int mapi_slice_row(struct MapiRes
static void mapi_store_bind(struct MapiResultSet *result, int cr);
static ATOMIC_FLAG mapi_initialized = ATOMIC_FLAG_INIT;
+
+char mapi_application_name[256] = { 0 };
+
/*
* Blocking
* --------
@@ -2118,6 +2121,15 @@ 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.
*
diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h
--- a/clients/mapilib/mapi.h
+++ b/clients/mapilib/mapi.h
@@ -76,6 +76,9 @@ 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);
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
@@ -246,6 +246,7 @@ struct MapiStruct {
bool columnar_protocol;
bool sizeheader;
bool oobintr;
+ bool clientinfo_supported;
MapiHdl first; /* start of doubly-linked list */
MapiHdl active; /* set when not all rows have been received */
@@ -309,6 +310,8 @@ 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/mapilib/msettings.c b/clients/mapilib/msettings.c
--- a/clients/mapilib/msettings.c
+++ b/clients/mapilib/msettings.c
@@ -84,6 +84,9 @@ by_name[] = {
{ .name="binary", .parm=MP_BINARY },
{ .name="cert", .parm=MP_CERT },
{ .name="certhash", .parm=MP_CERTHASH },
+ { .name="client_application", .parm=MP_CLIENT_APPLICATION },
+ { .name="client_info", .parm=MP_CLIENT_INFO },
+ { .name="client_remark", .parm=MP_CLIENT_REMARK },
{ .name="clientcert", .parm=MP_CLIENTCERT },
{ .name="clientkey", .parm=MP_CLIENTKEY },
{ .name="connect_timeout", .parm=MP_CONNECT_TIMEOUT },
@@ -93,8 +96,8 @@ by_name[] = {
{ .name="map_to_long_varchar", .parm=MP_MAPTOLONGVARCHAR },
{ .name="password", .parm=MP_PASSWORD },
{ .name="port", .parm=MP_PORT },
+ { .name="reply_timeout", .parm=MP_REPLY_TIMEOUT },
{ .name="replysize", .parm=MP_REPLYSIZE },
- { .name="reply_timeout", .parm=MP_REPLY_TIMEOUT },
{ .name="fetchsize", .parm=MP_REPLYSIZE },
{ .name="schema", .parm=MP_SCHEMA },
{ .name="sock", .parm=MP_SOCK },
@@ -140,6 +143,9 @@ mparm_name(mparm parm)
case MP_BINARY: return "binary";
case MP_CERT: return "cert";
case MP_CERTHASH: return "certhash";
+ case MP_CLIENT_APPLICATION: return "client_application";
+ case MP_CLIENT_INFO: return "client_info";
+ case MP_CLIENT_REMARK: return "client_remark";
case MP_CLIENTCERT: return "clientcert";
case MP_CLIENTKEY: return "clientkey";
case MP_CONNECT_TIMEOUT: return "connect_timeout";
@@ -190,6 +196,7 @@ struct msettings {
bool dummy_start_bool;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]