← Back to team overview

maria-developers team mailing list archive

Re: Rev 3876: MDEV-4472 Audit-plugin. Server-related part of the task

 

03.09.2013 16:02, Sergei Golubchik wrote:
Hi, Holyfoot!

    unsigned long long general_rows;
+  /* Added for 0x302 */
A bit confusing. Better "Added in version 0x0302"

Fixed.


+  long long query_id;
should it rather be unsigned?

For the THD structure we have:
typedef int64 query_id_t;
So that it's originally unsigned.


+  char *local_mysql_data_home;
+#ifdef _WIN32
+  local_mysql_data_home= (char *)GetProcAddress(0, "mysql_data_home");
+#else
+  local_mysql_data_home= mysql_data_home;
+#endif /*_WIN32*/
You shouldn't need it, file_logger.c is part of the server, not a
dynamically loaded plugin.

For now the plugin supposed to handle older Maria's and even MySQL.
So we have to include the file-logger code in there.


/*
      I don't think we ever need more rotations,
=== modified file 'sql/sql_audit.h'
--- a/sql/sql_audit.h	2013-04-19 10:50:16 +0000
+++ b/sql/sql_audit.h	2013-09-03 08:25:21 +0000
@@ -93,7 +93,8 @@ void mysql_audit_general_log(THD *thd, t
mysql_audit_notify(thd, MYSQL_AUDIT_GENERAL_CLASS, MYSQL_AUDIT_GENERAL_LOG,
                         0, time, user, userlen, cmd, cmdlen,
-                       query, querylen, clientcs, 0);
+                       query, querylen, clientcs, (ha_rows) 0,
+                       thd->db, thd->db_length);
no query_id?

    }
  }
@@ -139,7 +140,8 @@ void mysql_audit_general(THD *thd, uint mysql_audit_notify(thd, MYSQL_AUDIT_GENERAL_CLASS, event_subtype,
                         error_code, time, user, userlen, msg, msglen,
-                       query.str(), query.length(), query.charset(), rows);
+                       query.str(), query.length(), query.charset(), rows,
+                       thd->db, thd->db_length);
no query_id?

No query_id.
An appropriate 'handler' is called inside the mysql_audit_notify for each type of events, receiving
the 'thd' as a parameter.
There the event->query_id is actually set. See general_class_handler() in sql/sql_audit.cc for example.



    }
  }
=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2013-06-13 18:19:11 +0000
+++ b/sql/sql_plugin.cc	2013-09-03 08:25:21 +0000
@@ -2645,13 +2647,16 @@ static void update_func_longlong(THD *th
  static void update_func_str(THD *thd, struct st_mysql_sys_var *var,
                               void *tgt, const void *save)
  {
-  char *old= *(char **) tgt;
-  *(char **)tgt= *(char **) save;
+  char *value= *(char**) save;
    if (var->flags & PLUGIN_VAR_MEMALLOC)
    {
-    *(char **)tgt= my_strdup(*(char **) save, MYF(0));
+    char *old= *(char**) tgt;
+    if (value)
+      *(char**) tgt= my_strdup(value, MYF(0));
add

        else
          *(char**) tgt= 0;

      my_free(old);
    }
+  else
+    *(char**) tgt= value;
  }


Added.

Best regards.
HF





Follow ups

References