mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 22:43:04 +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
@ -200,7 +200,7 @@ const int NO_PROCS = 88; // There are no stored procedures in this database
|
||||
const int NO_TRIGGERS_ON_REL = 89; // There are no triggers on table %s in this database
|
||||
const int NO_REL_OR_TRIGGER = 90; // There is no table or trigger %s in this database
|
||||
const int NO_TRIGGERS = 91; // There are no triggers in this database
|
||||
const int NO_TRIGGER = 121; // There is no trigger %s in this database
|
||||
const int NO_TRIGGER = 121; // There is no trigger %s in this database
|
||||
const int NO_CHECKS_ON_REL = 92; // There are no check constraints on table %s in this database
|
||||
const int NO_COMMENTS = 115; // There are no comments for objects in this database.
|
||||
const int BUFFER_OVERFLOW = 94; // An isql command exceeded maximum buffer size
|
||||
@ -241,14 +241,18 @@ const int NO_DEPENDENCIES = 147; // No dependencies for %s were found
|
||||
const int NO_COLLATION = 148; // There is no collation %s in this database
|
||||
const int NO_COLLATIONS = 149; // There are no collations in this database
|
||||
const int MSG_COLLATIONS = 150; // Collations:
|
||||
const int NO_SECCLASS = 151; // There are no security classes for %s
|
||||
const int NO_DB_WIDE_SECCLASS = 152; // There is no database-wide security class
|
||||
const int NO_SECCLASS = 151; // There are no security classes for %s
|
||||
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 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
|
||||
|
||||
struct sqltypes {
|
||||
struct sqltypes
|
||||
{
|
||||
SSHORT type;
|
||||
SCHAR type_name[WORDLENGTH];
|
||||
};
|
||||
@ -269,7 +273,7 @@ const int BLOB_ID = 45;
|
||||
const int BLOB = 261;
|
||||
//const int SQL_DATE = 12;
|
||||
//const int SQL_TIME = 13;
|
||||
const int BIGINT = 16;
|
||||
const int BIGINT = 16;
|
||||
|
||||
static const sqltypes Column_types[] = {
|
||||
{SMALLINT, "SMALLINT"}, // NTX: keyword
|
||||
@ -333,7 +337,7 @@ static const char* UDF_param_types[] = {
|
||||
" BY DESCRIPTOR", // keyword in FB, internally VMS descriptor
|
||||
"", // BY ISC_DESCRIPTOR => BLOB
|
||||
" BY SCALAR_ARRAY", // keyword in FB v2
|
||||
" NULL", // BY REFERENCE WITH NULL, but only appends NULL to the type
|
||||
" NULL", // BY REFERENCE WITH NULL, but only appends NULL to the type
|
||||
" ERROR-type-unknown"
|
||||
};
|
||||
|
||||
|
@ -344,8 +344,10 @@ ShowOptions::show_commands ShowOptions::getCommand(const char* cmd)
|
||||
{
|
||||
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);
|
||||
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 wrong;
|
||||
@ -1542,7 +1544,9 @@ processing_state SHOW_metadata(const SCHAR* const* cmd,
|
||||
break;
|
||||
|
||||
case ShowOptions::users:
|
||||
show_users();
|
||||
ret = show_users();
|
||||
if (ret == OBJECT_NOT_FOUND) // It seems impossible, but...
|
||||
key = NO_CONNECTED_USERS;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -4526,7 +4530,7 @@ static processing_state show_users()
|
||||
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] = "";
|
||||
XSQLDA osqlda; // XSQLDA comes with one XSQLVAR inside.
|
||||
@ -4538,9 +4542,22 @@ static processing_state show_users()
|
||||
ovar.sqlind = 0;
|
||||
ovar.sqldata = my_user;
|
||||
ovar.sqltype = SQL_VARYING;
|
||||
ovar.sqllen = sizeof(my_user);
|
||||
ovar.sqllen = sizeof(my_user) - 3;
|
||||
const char* getuser = isqlGlob.major_ods < ODS_VERSION10 ?
|
||||
"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,
|
||||
getuser,
|
||||
@ -4566,11 +4583,11 @@ static processing_state show_users()
|
||||
|
||||
bool newline = false;
|
||||
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 int length = gds__vax_integer(d, 2);
|
||||
d += 2;
|
||||
const UCHAR item = *data++;
|
||||
const int length = gds__vax_integer(data, 2);
|
||||
data += 2;
|
||||
|
||||
switch (item)
|
||||
{
|
||||
@ -4580,20 +4597,26 @@ static processing_state show_users()
|
||||
case isc_info_user_names:
|
||||
{
|
||||
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);
|
||||
if (len == avary->vary_length && !memcmp(avary->vary_string, d + 1, len))
|
||||
isqlGlob.printf("# %-37.*s", len, d + 1);
|
||||
const UCHAR* uname = data + 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
|
||||
isqlGlob.printf(" %-37.*s", len, d + 1);
|
||||
isqlGlob.printf(" %-37.*s", len, uname);
|
||||
|
||||
if (newline)
|
||||
isqlGlob.printf("\n");
|
||||
|
||||
newline = !newline;
|
||||
rc = SKIP;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4601,12 +4624,13 @@ static processing_state show_users()
|
||||
if (newline)
|
||||
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.
|
||||
}
|
||||
|
||||
d += length;
|
||||
if (d >= buffer + sizeof(buffer))
|
||||
data += length;
|
||||
if (data >= buffer + sizeof(buffer))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4615,3 +4639,4 @@ static processing_state show_users()
|
||||
|
||||
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)
|
||||
--
|
||||
('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)
|
||||
('2002-03-05 02:30:12', 'LICENSE', 19, 60)
|
||||
('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');
|
||||
(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');
|
||||
(1186, 'cvc', '2007-10-03 05:28:09', 17, 102, ' TRIGGER, VERSION, VIEW', NULL, NULL, 'c_pg');
|
||||
stop
|
||||
|
||||
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);
|
||||
('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);
|
||||
('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);
|
||||
('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);
|
||||
@ -2889,6 +2889,9 @@ Fetches = !f', 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.
|
||||
-- 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
|
||||
('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);
|
||||
|
Loading…
Reference in New Issue
Block a user