From 7a858e240e74ba9dcd4291a72e9169e23794b45f Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Sun, 29 Oct 2023 23:22:38 +0200 Subject: [PATCH] Implement #7818 : Extend rdb$get_context('SYSTEM', '***') with other info from MON$ATTACHMENT --- doc/sql.extensions/README.context_variables2 | 4 ++++ src/jrd/SysFunction.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/doc/sql.extensions/README.context_variables2 b/doc/sql.extensions/README.context_variables2 index 4dca3805ff..9d5b8ddb2b 100644 --- a/doc/sql.extensions/README.context_variables2 +++ b/doc/sql.extensions/README.context_variables2 @@ -70,10 +70,14 @@ Usage: CLIENT_HOST | The wire protocol host name of remote client. Value is | returned for all supported protocols. | + CLIENT_OS_USER | Remote OS user name + | CLIENT_PID | Process ID of remote client application | CLIENT_PROCESS | Process name of remote client application | + CLIENT_VERSION | Version of the client library used by client application + | DB_NAME | Canonical name of current database. It is either alias | name if connectivity via file names is not allowed or | fully expanded database file name otherwise. diff --git a/src/jrd/SysFunction.cpp b/src/jrd/SysFunction.cpp index 2cd6ee977b..0b19b45601 100644 --- a/src/jrd/SysFunction.cpp +++ b/src/jrd/SysFunction.cpp @@ -388,8 +388,10 @@ const char WIRE_CRYPT_PLUGIN_NAME[] = "WIRE_CRYPT_PLUGIN", CLIENT_ADDRESS_NAME[] = "CLIENT_ADDRESS", CLIENT_HOST_NAME[] = "CLIENT_HOST", + CLIENT_OS_USER_NAME[] = "CLIENT_OS_USER", CLIENT_PID_NAME[] = "CLIENT_PID", CLIENT_PROCESS_NAME[] = "CLIENT_PROCESS", + CLIENT_VERSION_NAME[] = "CLIENT_VERSION", CURRENT_USER_NAME[] = "CURRENT_USER", CURRENT_ROLE_NAME[] = "CURRENT_ROLE", SESSION_IDLE_TIMEOUT[] = "SESSION_IDLE_TIMEOUT", @@ -4641,6 +4643,13 @@ dsc* evlGetContext(thread_db* tdbb, const SysFunction*, const NestValueArray& ar resultStr = attachment->att_remote_host; } + else if (nameStr == CLIENT_OS_USER_NAME) + { + if (attachment->att_remote_os_user.isEmpty()) + return NULL; + + resultStr = attachment->att_remote_os_user; + } else if (nameStr == CLIENT_PID_NAME) { if (!attachment->att_remote_pid) @@ -4655,6 +4664,13 @@ dsc* evlGetContext(thread_db* tdbb, const SysFunction*, const NestValueArray& ar resultStr = attachment->att_remote_process.ToString(); } + else if (nameStr == CLIENT_VERSION_NAME) + { + if (attachment->att_client_version.isEmpty()) + return NULL; + + resultStr = attachment->att_client_version.ToString(); + } else if (nameStr == CURRENT_USER_NAME) { const MetaString& user = attachment->getUserName();