mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 09:23:03 +01:00
Presenting the SHOW USERS command in society (documenting it when user types HELP or ?)
:-)
This commit is contained in:
parent
7038077b06
commit
83192cd8c9
@ -245,10 +245,14 @@ const int NO_SECCLASS = 151; // There are no security classes
|
|||||||
const int NO_DB_WIDE_SECCLASS = 152; // There is no database-wide security class
|
const int NO_DB_WIDE_SECCLASS = 152; // There is no database-wide security class
|
||||||
const int CANNOT_GET_SRV_VER = 153; // Cannot get server version without database connection
|
const int CANNOT_GET_SRV_VER = 153; // Cannot get server version without database connection
|
||||||
const int BULK_PROMPT = 156; // "BULK> "
|
const int BULK_PROMPT = 156; // "BULK> "
|
||||||
|
const int NO_CONNECTED_USERS = 157; // There are no connected users
|
||||||
|
const int USERS_IN_DB = 158; // Users in the database
|
||||||
|
const int OUTPUT_TRUNCATED = 159; // Output was truncated
|
||||||
|
|
||||||
// Initialize types
|
// Initialize types
|
||||||
|
|
||||||
struct sqltypes {
|
struct sqltypes
|
||||||
|
{
|
||||||
SSHORT type;
|
SSHORT type;
|
||||||
SCHAR type_name[WORDLENGTH];
|
SCHAR type_name[WORDLENGTH];
|
||||||
};
|
};
|
||||||
|
@ -344,8 +344,10 @@ ShowOptions::show_commands ShowOptions::getCommand(const char* cmd)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < FB_NELEM(options); ++i)
|
for (int i = 0; i < FB_NELEM(options); ++i)
|
||||||
{
|
{
|
||||||
|
// As long as we know our input is already uppercased, the call to
|
||||||
|
// fb_utils::strnicmp as been replaced by strncmp until the need arises.
|
||||||
size_t swlen = strlen(cmd);
|
size_t swlen = strlen(cmd);
|
||||||
if (swlen >= options[i].abbrlen && !fb_utils::strnicmp(cmd, options[i].text, swlen))
|
if (swlen >= options[i].abbrlen && !strncmp(cmd, options[i].text, swlen))
|
||||||
return options[i].kw;
|
return options[i].kw;
|
||||||
}
|
}
|
||||||
return wrong;
|
return wrong;
|
||||||
@ -1542,7 +1544,9 @@ processing_state SHOW_metadata(const SCHAR* const* cmd,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ShowOptions::users:
|
case ShowOptions::users:
|
||||||
show_users();
|
ret = show_users();
|
||||||
|
if (ret == OBJECT_NOT_FOUND) // It seems impossible, but...
|
||||||
|
key = NO_CONNECTED_USERS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -4526,7 +4530,7 @@ static processing_state show_users()
|
|||||||
isc_info_end
|
isc_info_end
|
||||||
};
|
};
|
||||||
|
|
||||||
//TEXT msg[MSG_LENGTH]; // When messages can be translated.
|
TEXT msg[MSG_LENGTH]; // When messages can be translated.
|
||||||
|
|
||||||
char my_user[128] = "";
|
char my_user[128] = "";
|
||||||
XSQLDA osqlda; // XSQLDA comes with one XSQLVAR inside.
|
XSQLDA osqlda; // XSQLDA comes with one XSQLVAR inside.
|
||||||
@ -4538,10 +4542,23 @@ static processing_state show_users()
|
|||||||
ovar.sqlind = 0;
|
ovar.sqlind = 0;
|
||||||
ovar.sqldata = my_user;
|
ovar.sqldata = my_user;
|
||||||
ovar.sqltype = SQL_VARYING;
|
ovar.sqltype = SQL_VARYING;
|
||||||
ovar.sqllen = sizeof(my_user);
|
ovar.sqllen = sizeof(my_user) - 3;
|
||||||
const char* getuser = isqlGlob.major_ods < ODS_VERSION10 ?
|
const char* getuser = isqlGlob.major_ods < ODS_VERSION10 ?
|
||||||
"select user from rdb$database" : "select current_user from rdb$database";
|
"select user from rdb$database" : "select current_user from rdb$database";
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifdef TRUSTED_AUTH
|
||||||
|
//if (Trusted_auth)
|
||||||
|
{
|
||||||
|
if (isqlGlob.major_ods > ODS_VERSION11
|
||||||
|
|| isqlGlob.major_ods == ODS_VERSION11 && isqlGlob.minor_ods > 1)
|
||||||
|
{
|
||||||
|
getuser = "select system_user from rdb$database";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
if (isc_dsql_exec_immed2(isc_status, &DB, &gds_trans, 0,
|
if (isc_dsql_exec_immed2(isc_status, &DB, &gds_trans, 0,
|
||||||
getuser,
|
getuser,
|
||||||
isqlGlob.SQL_dialect, NULL, &osqlda))
|
isqlGlob.SQL_dialect, NULL, &osqlda))
|
||||||
@ -4566,11 +4583,11 @@ static processing_state show_users()
|
|||||||
|
|
||||||
bool newline = false;
|
bool newline = false;
|
||||||
processing_state rc = OBJECT_NOT_FOUND;
|
processing_state rc = OBJECT_NOT_FOUND;
|
||||||
for (const UCHAR* d = buffer; *d != isc_info_end;)
|
for (const UCHAR* data = buffer; *data != isc_info_end;)
|
||||||
{
|
{
|
||||||
const UCHAR item = *d++;
|
const UCHAR item = *data++;
|
||||||
const int length = gds__vax_integer(d, 2);
|
const int length = gds__vax_integer(data, 2);
|
||||||
d += 2;
|
data += 2;
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@ -4580,20 +4597,26 @@ static processing_state show_users()
|
|||||||
case isc_info_user_names:
|
case isc_info_user_names:
|
||||||
{
|
{
|
||||||
if (rc == OBJECT_NOT_FOUND)
|
if (rc == OBJECT_NOT_FOUND)
|
||||||
printf("%s\n", "Users in the database");
|
{
|
||||||
|
// First time in the loop, print title.
|
||||||
|
ISQL_msg_get(USERS_IN_DB, msg);
|
||||||
|
isqlGlob.printf("%s\n", msg);
|
||||||
|
rc = SKIP; // We found at least one user.
|
||||||
|
}
|
||||||
|
|
||||||
int len = *d;
|
int len = *data;
|
||||||
fb_assert(len == length - 1);
|
fb_assert(len == length - 1);
|
||||||
if (len == avary->vary_length && !memcmp(avary->vary_string, d + 1, len))
|
const UCHAR* uname = data + 1;
|
||||||
isqlGlob.printf("# %-37.*s", len, d + 1);
|
// Let's mark all attachments with our same user with a # prefix.
|
||||||
|
if (len == avary->vary_length && !memcmp(avary->vary_string, uname, len))
|
||||||
|
isqlGlob.printf("# %-37.*s", len, uname);
|
||||||
else
|
else
|
||||||
isqlGlob.printf(" %-37.*s", len, d + 1);
|
isqlGlob.printf(" %-37.*s", len, uname);
|
||||||
|
|
||||||
if (newline)
|
if (newline)
|
||||||
isqlGlob.printf("\n");
|
isqlGlob.printf("\n");
|
||||||
|
|
||||||
newline = !newline;
|
newline = !newline;
|
||||||
rc = SKIP;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4601,12 +4624,13 @@ static processing_state show_users()
|
|||||||
if (newline)
|
if (newline)
|
||||||
isqlGlob.printf("\n");
|
isqlGlob.printf("\n");
|
||||||
|
|
||||||
isqlGlob.printf("Output was truncated\n");
|
ISQL_msg_get(OUTPUT_TRUNCATED, msg);
|
||||||
|
isqlGlob.printf("%s\n", msg);
|
||||||
return rc; // If we got some items, we are (partially) successful.
|
return rc; // If we got some items, we are (partially) successful.
|
||||||
}
|
}
|
||||||
|
|
||||||
d += length;
|
data += length;
|
||||||
if (d >= buffer + sizeof(buffer))
|
if (data >= buffer + sizeof(buffer))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4615,3 +4639,4 @@ static processing_state show_users()
|
|||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM
|
|||||||
--
|
--
|
||||||
--('1996-11-07 13:38:43', 'GJRN', 16, 241)
|
--('1996-11-07 13:38:43', 'GJRN', 16, 241)
|
||||||
--
|
--
|
||||||
('2007-02-25 08:33:07', 'ISQL', 17, 157)
|
('2007-10-02 05:56:56', 'ISQL', 17, 160)
|
||||||
('2007-05-22 13:11:00', 'GSEC', 18, 93)
|
('2007-05-22 13:11:00', 'GSEC', 18, 93)
|
||||||
('2002-03-05 02:30:12', 'LICENSE', 19, 60)
|
('2002-03-05 02:30:12', 'LICENSE', 19, 60)
|
||||||
('2002-03-05 02:31:54', 'DOS', 20, 74)
|
('2002-03-05 02:31:54', 'DOS', 20, 74)
|
||||||
|
@ -1188,6 +1188,7 @@ Fetches = !f', NULL, NULL, 'c_pg');
|
|||||||
(1183, 'cvc', '2006-08-31 04:21:42', 8, 43, 'column %s is used in table %s (local name %s) and cannot be dropped', NULL, NULL, 'c_pg');
|
(1183, 'cvc', '2006-08-31 04:21:42', 8, 43, 'column %s is used in table %s (local name %s) and cannot be dropped', NULL, NULL, 'c_pg');
|
||||||
(1184, 'cvc', '2006-10-01 03:18:30', 8, 18, 'could not find UNIQUE or PRIMARY KEY constraint with specified columns', NULL, NULL, 'c_pg');
|
(1184, 'cvc', '2006-10-01 03:18:30', 8, 18, 'could not find UNIQUE or PRIMARY KEY constraint with specified columns', NULL, NULL, 'c_pg');
|
||||||
(1185, 'cvc', '2006-10-01 03:20:51', 8, 20, 'could not find PRIMARY KEY index in specified table', NULL, NULL, 'c_pg');
|
(1185, 'cvc', '2006-10-01 03:20:51', 8, 20, 'could not find PRIMARY KEY index in specified table', NULL, NULL, 'c_pg');
|
||||||
|
(1186, 'cvc', '2007-10-03 05:28:09', 17, 102, ' TRIGGER, VERSION, VIEW', NULL, NULL, 'c_pg');
|
||||||
stop
|
stop
|
||||||
|
|
||||||
COMMIT WORK;
|
COMMIT WORK;
|
||||||
|
@ -2832,7 +2832,7 @@ Fetches = !f', NULL, NULL);
|
|||||||
('NO_GRANT_ON_ROL', 'SHOW_metadata', 'show.e', NULL, 17, 97, NULL, 'There is no membership privilege granted on @1 in this database', NULL, NULL);
|
('NO_GRANT_ON_ROL', 'SHOW_metadata', 'show.e', NULL, 17, 97, NULL, 'There is no membership privilege granted on @1 in this database', NULL, NULL);
|
||||||
('UNEXPECTED_EOF', 'do_isql', 'isql.e', NULL, 17, 98, NULL, 'Expected end of statement, encountered EOF', NULL, NULL);
|
('UNEXPECTED_EOF', 'do_isql', 'isql.e', NULL, 17, 98, NULL, 'Expected end of statement, encountered EOF', NULL, NULL);
|
||||||
('TIME_ERR', 'add_row()', 'isql.e', NULL, 17, 101, NULL, 'Bad TIME: @1', NULL, NULL);
|
('TIME_ERR', 'add_row()', 'isql.e', NULL, 17, 101, NULL, 'Bad TIME: @1', NULL, NULL);
|
||||||
('HLP_OBJTYPE3', 'help', 'isql.e', NULL, 17, 102, NULL, ' TRIGGER, VERSION, VIEW', NULL, NULL);
|
('HLP_OBJTYPE3', 'help', 'isql.epp', NULL, 17, 102, NULL, ' TRIGGER, VERSION, USERS, VIEW', NULL, NULL);
|
||||||
('', 'SHOW_metadata', 'show.e', NULL, 17, 103, NULL, 'There is no role @1 in this database', NULL, NULL);
|
('', 'SHOW_metadata', 'show.e', NULL, 17, 103, NULL, 'There is no role @1 in this database', NULL, NULL);
|
||||||
('USAGE_BAIL', 'ISQL_main', 'isql.epp', NULL, 17, 104, NULL, ' -b(ail) bail on errors (set bail on)', NULL, NULL);
|
('USAGE_BAIL', 'ISQL_main', 'isql.epp', NULL, 17, 104, NULL, ' -b(ail) bail on errors (set bail on)', NULL, NULL);
|
||||||
('', 'create_db', 'isql.e', NULL, 17, 105, NULL, 'Incomplete string in @1', NULL, NULL);
|
('', 'create_db', 'isql.e', NULL, 17, 105, NULL, 'Incomplete string in @1', NULL, NULL);
|
||||||
@ -2889,6 +2889,9 @@ Fetches = !f', NULL, NULL);
|
|||||||
('BULK_PROMPT', 'bulk_insert_hack', 'isql.epp', NULL, 17, 156, NULL, 'BULK> ', NULL, NULL);
|
('BULK_PROMPT', 'bulk_insert_hack', 'isql.epp', NULL, 17, 156, NULL, 'BULK> ', NULL, NULL);
|
||||||
-- Do not change the arguments of the previous ISQL messages.
|
-- Do not change the arguments of the previous ISQL messages.
|
||||||
-- Write the new ISQL messages here.
|
-- Write the new ISQL messages here.
|
||||||
|
('NO_CONNECTED_USERS', 'SHOW_metadata', 'show.epp', NULL, 17, 157, NULL, 'There are no connected users', NULL, NULL);
|
||||||
|
('USERS_IN_DB', 'SHOW_metadata', 'show.epp', NULL, 17, 158, NULL, 'Users in the database', NULL, NULL);
|
||||||
|
('OUTPUT_TRUNCATED', 'SHOW_metadata', 'show.epp', NULL, 17, 159, NULL, 'Output was truncated', NULL, NULL);
|
||||||
-- GSEC
|
-- GSEC
|
||||||
('GsecMsg1', 'get_line', 'gsec.e', NULL, 18, 1, NULL, 'GSEC>', NULL, NULL);
|
('GsecMsg1', 'get_line', 'gsec.e', NULL, 18, 1, NULL, 'GSEC>', NULL, NULL);
|
||||||
('GsecMsg2', 'printhelp', 'gsec.e', 'This message is used in the Help display. It should be the same as number 1 (but in lower case).', 18, 2, NULL, 'gsec', NULL, NULL);
|
('GsecMsg2', 'printhelp', 'gsec.e', 'This message is used in the Help display. It should be the same as number 1 (but in lower case).', 18, 2, NULL, 'gsec', NULL, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user