Skip to content

Commit

Permalink
Fixed bug #7962: Remove system functions from isql SHOW FUNC output (#…
Browse files Browse the repository at this point in the history
…7971)


---------

Co-authored-by: Artyom Ivanov <[email protected]>
  • Loading branch information
TreeHunter9 and Artyom Ivanov authored Jan 22, 2024
1 parent dc900b7 commit 917f1ad
Showing 1 changed file with 15 additions and 52 deletions.
67 changes: 15 additions & 52 deletions src/isql/show.epp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ static processing_state show_dialect();
static processing_state show_domains(const SCHAR*);
static processing_state show_exceptions(const SCHAR*);
static processing_state show_filters(const SCHAR*);
static processing_state show_functions(const SCHAR*, bool);
static processing_state show_sys_functions(const char* msg);
static processing_state show_functions(const SCHAR* funcname, bool quoted, bool system, const SCHAR* msg = nullptr);
static processing_state show_func_legacy(const MetaString&);
static processing_state show_func(const MetaString&, const MetaString&);
static processing_state show_generators(const SCHAR*);
Expand Down Expand Up @@ -2303,7 +2302,7 @@ processing_state SHOW_metadata(const SCHAR* const* cmd, SCHAR** lcmd)
break;

case ShowOptions::function:
show_sys_functions(NULL);
show_functions(nullptr, false, true);
break;

case ShowOptions::table:
Expand Down Expand Up @@ -2337,7 +2336,7 @@ processing_state SHOW_metadata(const SCHAR* const* cmd, SCHAR** lcmd)
isqlGlob.printf("%s%s", msg, NEWLINE);
show_all_tables(1);
IUTILS_msg_get(MSG_FUNCTIONS, msg);
show_sys_functions(msg);
show_functions(nullptr, false, true, msg);
IUTILS_msg_get(MSG_PROCEDURES, msg);
show_proc(NULL, false, true, msg);
IUTILS_msg_get(MSG_PACKAGES, msg);
Expand Down Expand Up @@ -2442,10 +2441,10 @@ processing_state SHOW_metadata(const SCHAR* const* cmd, SCHAR** lcmd)
if (*cmd[2] == '"')
{
remove_delimited_double_quotes(lcmd[2]);
ret = show_functions(lcmd[2], true);
ret = show_functions(lcmd[2], true, false);
}
else
ret = show_functions(cmd[2], false);
ret = show_functions(cmd[2], false, false);

if (ret == OBJECT_NOT_FOUND)
{
Expand Down Expand Up @@ -4300,49 +4299,7 @@ static processing_state show_filters(const SCHAR* object)
}


static processing_state show_sys_functions(const SCHAR* msg)
{
/**************************************
*
* s h o w _ s y s _ f u n c t i o n s
*
**************************************
*
* Functional description
* Show system functions.
*
**************************************/

bool first = true;

FOR FUN IN RDB$FUNCTIONS
WITH FUN.RDB$SYSTEM_FLAG EQ 1
SORTED BY FUN.RDB$PACKAGE_NAME, FUN.RDB$FUNCTION_NAME
{
if (first)
{
first = false;
if (msg)
isqlGlob.printf("%s%s", msg, NEWLINE);
}

// Strip trailing blanks
MetaString package(FUN.RDB$PACKAGE_NAME);
MetaString function(FUN.RDB$FUNCTION_NAME);

isqlGlob.printf("%s%s%s%s", package.c_str(), package.hasData() ? "." : "", function.c_str(), NEWLINE);
}
END_FOR
ON_ERROR
ISQL_errmsg(fbStatus);
return ps_ERR;
END_ERROR;

return SKIP;
}


static processing_state show_functions(const SCHAR* funcname, bool quoted)
static processing_state show_functions(const SCHAR* funcname, bool quoted, bool system, const SCHAR* msg)
{
/**************************************
*
Expand All @@ -4355,8 +4312,9 @@ static processing_state show_functions(const SCHAR* funcname, bool quoted)
*
**************************************/

// If no function name was given, just list the functions
int systemFlag = system ? 1 : 0;

// If no function name was given, just list the functions
if (!funcname || !strlen(funcname))
{
bool first = true;
Expand All @@ -4365,9 +4323,15 @@ static processing_state show_functions(const SCHAR* funcname, bool quoted)
// gets all the dependencies if any

FOR FUN IN RDB$FUNCTIONS
WITH FUN.RDB$SYSTEM_FLAG EQ systemFlag
SORTED BY FUN.RDB$PACKAGE_NAME, FUN.RDB$FUNCTION_NAME
{
first = false;
if (first)
{
first = false;
if (msg)
isqlGlob.printf("%s%s", msg, NEWLINE);
}

MetaString package(FUN.RDB$PACKAGE_NAME);
MetaString function(FUN.RDB$FUNCTION_NAME);
Expand Down Expand Up @@ -4420,7 +4384,6 @@ static processing_state show_functions(const SCHAR* funcname, bool quoted)

processing_state return_state = OBJECT_NOT_FOUND;

bool first = true;
MetaString package, function;
if (quoted)
function = funcname;
Expand Down

0 comments on commit 917f1ad

Please sign in to comment.