Merge lp:~percona-dev/percona-server/release-5.1.49-12-mysql-syslog into lp:percona-server/release-5.1.49-12

Proposed by Oleg Tsarev
Status: Merged
Approved by: Percona
Approved revision: no longer in the source branch.
Merged at revision: 105
Proposed branch: lp:~percona-dev/percona-server/release-5.1.49-12-mysql-syslog
Merge into: lp:percona-server/release-5.1.49-12
Diff against target: 137 lines (+125/-0)
2 files modified
mysql-syslog.patch (+124/-0)
series (+1/-0)
To merge this branch: bzr merge lp:~percona-dev/percona-server/release-5.1.49-12-mysql-syslog
Reviewer Review Type Date Requested Status
Percona developers Pending
Review via email: mp+33729@code.launchpad.net

Description of the change

mysql syslog propogated

To post a comment you must log in.
Revision history for this message
Yasufumi Kinoshita (yasufumi-kinoshita) wrote :

Who did review it?
"proposed" and "approved" are almost same time.
Don't review by your self.
I have distrust to the current development activity...

Revision history for this message
Oleg Tsarev (tsarev) wrote :

Yasufumi, Vadim reviewed this and approved.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'mysql-syslog.patch'
2--- mysql-syslog.patch 1970-01-01 00:00:00 +0000
3+++ mysql-syslog.patch 2010-08-26 04:04:40 +0000
4@@ -0,0 +1,124 @@
5+# name : mysql-syslog.patch
6+# introduced : 12
7+# maintainer : Oleg
8+#
9+#!!! notice !!!
10+# Any small change to this file in the main branch
11+# should be done or reviewed by the maintainer!
12+
13+diff -Nur a/client/client_priv.h b/client/client_priv.h
14+--- a/client/client_priv.h 2010-08-08 14:12:42.229338865 +0400
15++++ b/client/client_priv.h 2010-08-08 14:12:43.068089277 +0400
16+@@ -90,6 +90,7 @@
17+ OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
18+ OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
19+ OPT_WRITE_BINLOG, OPT_DUMP_DATE,
20++ OPT_SYSLOG,
21+ OPT_FIRST_SLAVE,
22+ OPT_ALL,
23+ OPT_MAX_CLIENT_OPTION,
24+diff -Nur a/client/mysql.cc b/client/mysql.cc
25+--- a/client/mysql.cc 2010-08-08 14:12:42.229338865 +0400
26++++ b/client/mysql.cc 2010-08-08 14:12:43.488088866 +0400
27+@@ -43,6 +43,9 @@
28+ #include "my_readline.h"
29+ #include <signal.h>
30+ #include <violite.h>
31++#ifndef __WIN__
32++#include "syslog.h"
33++#endif
34+
35+ #if defined(USE_LIBEDIT_INTERFACE) && defined(HAVE_LOCALE_H)
36+ #include <locale.h>
37+@@ -154,7 +157,7 @@
38+ default_charset_used= 0, opt_secure_auth= 0,
39+ default_pager_set= 0, opt_sigint_ignore= 0,
40+ show_warnings= 0, executing_query= 0, interrupted_query= 0,
41+- ignore_spaces= 0;
42++ opt_syslog=0, ignore_spaces= 0;
43+ static my_bool debug_info_flag, debug_check_flag;
44+ static my_bool column_types_flag;
45+ static my_bool preserve_comments= 0;
46+@@ -209,6 +212,7 @@
47+ void tee_fputs(const char *s, FILE *file);
48+ void tee_puts(const char *s, FILE *file);
49+ void tee_putc(int c, FILE *file);
50++void write_syslog(char *line);
51+ static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
52+ /* The names of functions that actually do the manipulation. */
53+ static int get_options(int argc,char **argv);
54+@@ -1568,6 +1572,10 @@
55+ {"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
56+ &show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG,
57+ 0, 0, 0, 0, 0, 0},
58++#ifndef __WIN__
59++ {"syslog", OPT_SYSLOG, "Logs all queries to syslog", 0, 0, 0, GET_NO_ARG,
60++ NO_ARG, 0, 0, 0, 0, 0, 0},
61++#endif
62+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
63+ };
64+
65+@@ -1691,6 +1699,12 @@
66+ opt->name);
67+ #endif
68+ break;
69++ case OPT_SYSLOG:
70++ /*if (connect_flag == CLIENT_INTERACTIVE){
71++ printf("Logging queries to syslog.\n");
72++ }*/
73++ opt_syslog = 1;
74++ break;
75+ case OPT_SERVER_ARG:
76+ #ifdef EMBEDDED_LIBRARY
77+ /*
78+@@ -2067,6 +2081,39 @@
79+ DBUG_RETURN((COMMANDS *) 0);
80+ }
81+
82++void write_syslog(char *line){
83++#ifndef __WIN__
84++ char buff[901];
85++ int i, buff_pos=0;
86++ for (i=0;i < strlen(line); i++){
87++ buff[buff_pos] = line[i];
88++ buff_pos++;
89++ if (buff_pos >= 900){
90++ buff[900] = NULL;
91++ buff_pos = 0;
92++ syslog(LOG_INFO, "SYSTEM_USER:%s, MYSQL_USER:%s, CONNECTION_ID:%lu, DB_SERVER:%s, DB:%s, QUERY:%s",
93++ getenv("SUDO_USER") ? getenv("SUDO_USER") :
94++ getenv("USER") ? getenv("USER") : "--",
95++ current_user ? current_user : "--",
96++ mysql_thread_id(&mysql),
97++ current_host ? current_host : "--",
98++ current_db ? current_db : "--",
99++ buff);
100++ }
101++ }
102++ if (buff_pos > 0){
103++ buff[buff_pos] = NULL;
104++ syslog(LOG_INFO, "SYSTEM_USER:%s, MYSQL_USER:%s, CONNECTION_ID:%lu, DB_SERVER:%s, DB:%s, QUERY:%s",
105++ getenv("SUDO_USER") ? getenv("SUDO_USER") :
106++ getenv("USER") ? getenv("USER") : "--",
107++ current_user ? current_user : "--",
108++ mysql_thread_id(&mysql),
109++ current_host ? current_host : "--",
110++ current_db ? current_db : "--",
111++ buff);
112++ }
113++#endif
114++}
115+
116+ static bool add_line(String &buffer,char *line,char *in_string,
117+ bool *ml_comment, bool truncated)
118+@@ -3038,6 +3085,11 @@
119+ fix_history(buffer);
120+ }
121+ #endif
122++#ifndef __WIN__
123++ if (opt_syslog && buffer->length() && connect_flag == CLIENT_INTERACTIVE){
124++ write_syslog(buffer->c_ptr());
125++ }
126++#endif
127+
128+ buffer->length(0);
129
130=== modified file 'series'
131--- series 2010-08-10 13:49:35 +0000
132+++ series 2010-08-26 04:04:40 +0000
133@@ -51,3 +51,4 @@
134 show_engines.patch
135 error_pad.patch
136 query_cache_totally_disable.patch
137+mysql-syslog.patch

Subscribers

People subscribed via source and target branches

to all changes: