MCPcopy Create free account
hub / github.com/MariaDB/server / log_statement_ex

Function log_statement_ex

plugin/server_audit/server_audit.cc:1510–1634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1508
1509
1510static int log_statement_ex(struct connection_info *cn,
1511 time_t ev_time, unsigned long thd_id, int sql_cmd,
1512 const char *query, unsigned int query_len,
1513 int error_code, const char *type, int take_lock)
1514{
1515 size_t csize;
1516 char raw_message_loc[MAX_AUDIT_QUERY_LENGTH + TIMESTAMP_OUTPUT_LENGTH];
1517 char *message= raw_message_loc + TIMESTAMP_OUTPUT_LENGTH;
1518 size_t message_size= MAX_AUDIT_QUERY_LENGTH;
1519 char *uh_buffer;
1520 size_t uh_buffer_size;
1521 const char *db;
1522 unsigned int db_length;
1523 long long query_id;
1524 int result;
1525 char *big_buffer= NULL;
1526 int cmdtype= sql_command_to_cmdtype(sql_cmd);
1527
1528 if ((db= cn->db))
1529 db_length= cn->db_length;
1530 else
1531 {
1532 db= "";
1533 db_length= 0;
1534 }
1535
1536 if (!(query_id= cn->query_id))
1537 query_id= query_counter++;
1538
1539 if (query == 0)
1540 {
1541 /* Can happen after the error in mysqld_prepare_stmt() */
1542 query= cn->query;
1543 query_len= cn->query_length;
1544 if (query == 0 || query_len == 0)
1545 return 0;
1546 }
1547
1548 if (query && !(events & EVENT_QUERY_ALL) &&
1549 (events & EVENT_QUERY && !cn->log_always))
1550 {
1551 if (!(events & cmdtype &
1552 (EVENT_QUERY_DDL | EVENT_QUERY_DML | EVENT_QUERY_DML_NO_SELECT |
1553 EVENT_QUERY_DCL)))
1554 return 0;
1555 }
1556
1557 csize= log_header(message, message_size-1,
1558 servhost, servhost_len,
1559 cn->user, cn->user_length,cn->host, cn->host_length,
1560 cn->ip, cn->ip_length, thd_id, cn->port, query_id, type);
1561
1562 csize+= my_snprintf(message+csize, message_size - 1 - csize,
1563 ",%.*s,\'", db_length, db);
1564
1565 if (query_log_limit > 0 && query_len > query_log_limit)
1566 query_len= query_log_limit;
1567

Callers 2

log_statementFunction · 0.85
log_current_queryFunction · 0.85

Calls 8

sql_command_to_cmdtypeFunction · 0.85
log_headerFunction · 0.85
my_snprintfFunction · 0.85
write_log_maybe_lockFunction · 0.85
logger_syncFunction · 0.85
freeFunction · 0.85
escape_stringFunction · 0.70

Tested by

no test coverage detected