Skip to content
/ server Public

Commit 4e674a2

Browse files
tonychen2001vuvova
authored andcommitted
Simplify event filtering logic in server_audit plugin
Replace if-else chain with a single bitwise AND check when filtering query events by type (DDL, DML, DCL, etc.). The removes the need for the goto statements. Additionally, we remove the orig_query variable as it served no purpose. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license
1 parent c12e94a commit 4e674a2

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

plugin/server_audit/server_audit.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,20 +1686,10 @@ static int log_statement_ex(const struct connection_info *cn,
16861686
if (query && !(events & EVENT_QUERY_ALL) &&
16871687
(events & EVENT_QUERY && !cn->log_always))
16881688
{
1689-
const char *orig_query= query;
1690-
1691-
if (events & EVENT_QUERY_DDL && cmdtype & EVENT_QUERY_DDL)
1692-
goto do_log_query;
1693-
if (events & EVENT_QUERY_DML && cmdtype & EVENT_QUERY_DML)
1694-
goto do_log_query;
1695-
if (events & EVENT_QUERY_DML_NO_SELECT && cmdtype & EVENT_QUERY_DML_NO_SELECT)
1696-
goto do_log_query;
1697-
if (events & EVENT_QUERY_DCL && cmdtype & EVENT_QUERY_DCL)
1698-
goto do_log_query;
1699-
1700-
return 0;
1701-
do_log_query:
1702-
query= orig_query;
1689+
if (!(events & cmdtype &
1690+
(EVENT_QUERY_DDL | EVENT_QUERY_DML | EVENT_QUERY_DML_NO_SELECT |
1691+
EVENT_QUERY_DCL)))
1692+
return 0;
17031693
}
17041694

17051695
csize= log_header(message, message_size-1, &ev_time,

0 commit comments

Comments
 (0)