From f8680edbe563af3785dbcf7b47f9a5b08f6616c2 Mon Sep 17 00:00:00 2001 From: Cheng-Lung Sung Date: Thu, 9 Jul 2009 02:49:52 +0000 Subject: - Update to 0.7.1 PR: ports/134042 --- databases/mysql-proxy/files/mysql-proxy.sh.in | 6 +- .../mysql-proxy/files/patch-examples-Makefile.in | 56 +++--- databases/mysql-proxy/files/patch-lib-Makefile.in | 29 +++ databases/mysql-proxy/files/patch-lib-admin.lua | 208 +++++++++++++++++++++ .../mysql-proxy/files/patch-lib-proxy-Makefile.in | 22 +++ databases/mysql-proxy/files/patch-lib-reporter.lua | 82 ++++++++ 6 files changed, 372 insertions(+), 31 deletions(-) create mode 100644 databases/mysql-proxy/files/patch-lib-Makefile.in create mode 100644 databases/mysql-proxy/files/patch-lib-admin.lua create mode 100644 databases/mysql-proxy/files/patch-lib-proxy-Makefile.in create mode 100644 databases/mysql-proxy/files/patch-lib-reporter.lua (limited to 'databases/mysql-proxy/files') diff --git a/databases/mysql-proxy/files/mysql-proxy.sh.in b/databases/mysql-proxy/files/mysql-proxy.sh.in index d1815ed13d57..491887a231ac 100644 --- a/databases/mysql-proxy/files/mysql-proxy.sh.in +++ b/databases/mysql-proxy/files/mysql-proxy.sh.in @@ -1,6 +1,6 @@ #!/bin/sh # -# $FreeBSD: /tmp/pcvs/ports/databases/mysql-proxy/files/Attic/mysql-proxy.sh.in,v 1.1 2008-03-27 02:05:18 clsung Exp $ +# $FreeBSD: /tmp/pcvs/ports/databases/mysql-proxy/files/Attic/mysql-proxy.sh.in,v 1.2 2009-07-09 02:49:52 clsung Exp $ # # PROVIDE: mysql-proxy @@ -41,9 +41,9 @@ load_rc_config $name : ${mysql_proxy_pid_file="/var/run/mysql-proxy.pid"} pidfile="${mysql_proxy_pid_file}" -command=%%PREFIX%%/sbin/mysql-proxy +command=%%PREFIX%%/libexec/mysql-proxy command_args="--admin-address=${mysql_proxy_admin_address} --proxy-address=${mysql_proxy_address} --proxy-backend-addresses=${mysql_proxy_backend_addresses} ${mysql_proxy_args} --daemon --pid-file=${mysql_proxy_pid_file}" -procname=%%PREFIX%%/sbin/mysql-proxy +procname=%%PREFIX%%/libexec/mysql-proxy run_rc_command "$1" diff --git a/databases/mysql-proxy/files/patch-examples-Makefile.in b/databases/mysql-proxy/files/patch-examples-Makefile.in index 41791d09666c..0276e0035a74 100644 --- a/databases/mysql-proxy/files/patch-examples-Makefile.in +++ b/databases/mysql-proxy/files/patch-examples-Makefile.in @@ -1,45 +1,45 @@ ---- examples/Makefile.in.orig 2007-09-12 00:55:20.000000000 +0800 -+++ examples/Makefile.in 2007-09-22 07:50:30.000000000 +0800 -@@ -157,6 +157,7 @@ - build_os = @build_os@ +--- examples/Makefile.in.orig 2009-05-18 22:15:02.000000000 +0800 ++++ examples/Makefile.in 2009-07-09 08:39:44.000000000 +0800 +@@ -162,6 +162,7 @@ build_vendor = @build_vendor@ + builddir = @builddir@ datadir = @datadir@ -+examplesdir = @datadir@/examples/mysql-proxy - exec_prefix = @exec_prefix@ - host = @host@ - host_alias = @host_alias@ -@@ -236,20 +237,20 @@ - uninstall-info-am: - install-dist_dataDATA: $(dist_data_DATA) ++exampledir = @datadir@/examples/mysql-proxy + datarootdir = @datarootdir@ + docdir = @docdir@ + dvidir = @dvidir@ +@@ -257,20 +258,20 @@ + -rm -rf .libs _libs + install-dist_docDATA: $(dist_doc_DATA) @$(NORMAL_INSTALL) -- test -z "$(datadir)" || $(mkdir_p) "$(DESTDIR)$(datadir)" -+ test -z "$(examplesdir)" || $(mkdir_p) "$(DESTDIR)$(examplesdir)" - @list='$(dist_data_DATA)'; for p in $$list; do \ +- test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" ++ test -z "$(exampledir)" || $(MKDIR_P) "$(DESTDIR)$(exampledir)" + @list='$(dist_doc_DATA)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ -- echo " $(dist_dataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(datadir)/$$f'"; \ -- $(dist_dataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(datadir)/$$f"; \ -+ echo " $(dist_dataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(examplesdir)/$$f'"; \ -+ $(dist_dataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(examplesdir)/$$f"; \ +- echo " $(dist_docDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(docdir)/$$f'"; \ +- $(dist_docDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; \ ++ echo " $(dist_docDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(exampledir)/$$f'"; \ ++ $(dist_docDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(exampledir)/$$f"; \ done - uninstall-dist_dataDATA: + uninstall-dist_docDATA: @$(NORMAL_UNINSTALL) - @list='$(dist_data_DATA)'; for p in $$list; do \ + @list='$(dist_doc_DATA)'; for p in $$list; do \ f=$(am__strip_dir) \ -- echo " rm -f '$(DESTDIR)$(datadir)/$$f'"; \ -- rm -f "$(DESTDIR)$(datadir)/$$f"; \ -+ echo " rm -f '$(DESTDIR)$(examplesdir)/$$f'"; \ -+ rm -f "$(DESTDIR)$(examplesdir)/$$f"; \ +- echo " rm -f '$(DESTDIR)$(docdir)/$$f'"; \ +- rm -f "$(DESTDIR)$(docdir)/$$f"; \ ++ echo " rm -f '$(DESTDIR)$(exampledir)/$$f'"; \ ++ rm -f "$(DESTDIR)$(exampledir)/$$f"; \ done tags: TAGS TAGS: -@@ -289,7 +290,7 @@ +@@ -309,7 +310,7 @@ check: check-am all-am: Makefile $(DATA) installdirs: -- for dir in "$(DESTDIR)$(datadir)"; do \ -+ for dir in "$(DESTDIR)$(examplesdir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ +- for dir in "$(DESTDIR)$(docdir)"; do \ ++ for dir in "$(DESTDIR)$(exampledir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am diff --git a/databases/mysql-proxy/files/patch-lib-Makefile.in b/databases/mysql-proxy/files/patch-lib-Makefile.in new file mode 100644 index 000000000000..0dbd3373e433 --- /dev/null +++ b/databases/mysql-proxy/files/patch-lib-Makefile.in @@ -0,0 +1,29 @@ +--- lib/Makefile.in.orig 2009-04-04 20:32:01.000000000 +0600 ++++ lib/Makefile.in 2009-05-05 17:02:50.000000000 +0600 +@@ -126,9 +126,9 @@ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive + am__dist_doc_DATA_DIST = active-queries.lua active-transactions.lua \ +- admin-sql.lua analyze-query.lua auditing.lua \ ++ admin-sql.lua admin.lua analyze-query.lua auditing.lua \ + commit-obfuscator.lua commit-obfuscator.msc histogram.lua \ +- load-multi.lua ro-balance.lua ro-pooling.lua rw-splitting.lua \ ++ load-multi.lua reporter.lua ro-balance.lua ro-pooling.lua rw-splitting.lua \ + xtab.lua + dist_docDATA_INSTALL = $(INSTALL_DATA) + DATA = $(dist_doc_DATA) +@@ -278,12 +278,14 @@ + active-queries.lua \ + active-transactions.lua \ + admin-sql.lua \ ++ admin.lua \ + analyze-query.lua \ + auditing.lua \ + commit-obfuscator.lua \ + commit-obfuscator.msc \ + histogram.lua \ + load-multi.lua \ ++ reporter.lua \ + ro-balance.lua \ + ro-pooling.lua \ + rw-splitting.lua \ diff --git a/databases/mysql-proxy/files/patch-lib-admin.lua b/databases/mysql-proxy/files/patch-lib-admin.lua new file mode 100644 index 000000000000..0ab588d8e448 --- /dev/null +++ b/databases/mysql-proxy/files/patch-lib-admin.lua @@ -0,0 +1,208 @@ +--- lib/admin.lua.orig 2009-05-05 16:55:08.000000000 +0600 ++++ lib/admin.lua 2009-05-05 16:56:11.000000000 +0600 +@@ -0,0 +1,205 @@ ++--[[ $%BEGINLICENSE%$ ++ Copyright (C) 2009 MySQL AB, 2008 Sun Microsystems, Inc ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; version 2 of the License. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ ++ $%ENDLICENSE%$ --]] ++ ++-- admin-1.lua ++ ++--[[ ++ ++ See http://forge.mysql.com/tools/tool.php?id=78 ++ (Thanks to Jan Kneschke) ++ See http://www.chriscalender.com/?p=41 ++ (Thanks to Chris Calender) ++ See http://datacharmer.blogspot.com/2009/01/mysql-proxy-is-back.html ++ (Thanks Giuseppe Maxia) ++ ++--]] ++ ++ ++function set_error(errmsg) ++ proxy.response = { ++ type = proxy.MYSQLD_PACKET_ERR, ++ errmsg = errmsg or "error" ++ } ++end ++ ++function read_query(packet) ++ if packet:byte() ~= proxy.COM_QUERY then ++ set_error("[admin] we only handle text-based queries (COM_QUERY)") ++ return proxy.PROXY_SEND_RESULT ++ end ++ ++ local query = packet:sub(2) ++ local rows = { } ++ local fields = { } ++ ++ -- try to match the string up to the first non-alphanum ++ local f_s, f_e, command = string.find(packet, "^%s*(%w+)", 2) ++ local option ++ ++ if f_e then ++ -- if that match, take the next sub-string as option ++ f_s, f_e, option = string.find(packet, "^%s+(%w+)", f_e + 1) ++ end ++ ++ -- we got our commands, execute it ++ if command == "show" and option == "querycounter" then ++ --- ++ -- proxy.PROXY_SEND_RESULT requires ++ -- ++ -- proxy.response.type to be either ++ -- * proxy.MYSQLD_PACKET_OK or ++ -- * proxy.MYSQLD_PACKET_ERR ++ -- ++ -- for proxy.MYSQLD_PACKET_OK you need a resultset ++ -- * fields ++ -- * rows ++ -- ++ -- for proxy.MYSQLD_PACKET_ERR ++ -- * errmsg ++ proxy.response.type = proxy.MYSQLD_PACKET_OK ++ proxy.response.resultset = { ++ fields = { ++ { type = proxy.MYSQL_TYPE_LONG, name = "query_counter", }, ++ }, ++ rows = { ++ { proxy.global.query_counter } ++ } ++ } ++ ++ -- we have our result, send it back ++ return proxy.PROXY_SEND_RESULT ++ elseif command == "show" and option == "myerror" then ++ proxy.response.type = proxy.MYSQLD_PACKET_ERR ++ proxy.response.errmsg = "my first error" ++ ++ return proxy.PROXY_SEND_RESULT ++ ++ elseif string.sub(packet, 2):lower() == 'select help' then ++ return show_process_help() ++ ++ elseif string.sub(packet, 2):lower() == 'show proxy processlist' then ++ return show_process_table() ++ ++ elseif query == "SELECT * FROM backends" then ++ fields = { ++ { name = "backend_ndx", ++ type = proxy.MYSQL_TYPE_LONG }, ++ ++ { name = "address", ++ type = proxy.MYSQL_TYPE_STRING }, ++ { name = "state", ++ type = proxy.MYSQL_TYPE_STRING }, ++ { name = "type", ++ type = proxy.MYSQL_TYPE_STRING }, ++ } ++ ++ for i = 1, #proxy.global.backends do ++ local b = proxy.global.backends[i] ++ ++ rows[#rows + 1] = { ++ i, b.dst.name, b.state, b.type ++ } ++ end ++ else ++ set_error() ++ return proxy.PROXY_SEND_RESULT ++ end ++ ++ proxy.response = { ++ type = proxy.MYSQLD_PACKET_OK, ++ resultset = { ++ fields = fields, ++ rows = rows ++ } ++ } ++ return proxy.PROXY_SEND_RESULT ++end ++ ++ ++function make_dataset (header, dataset) ++ proxy.response.type = proxy.MYSQLD_PACKET_OK ++ ++ proxy.response.resultset = { ++ fields = {}, ++ rows = {} ++ } ++ for i,v in pairs (header) do ++ table.insert(proxy.response.resultset.fields, {type = proxy.MYSQL_TYPE_STRING, name = v}) ++ end ++ for i,v in pairs (dataset) do ++ table.insert(proxy.response.resultset.rows, v ) ++ end ++ return proxy.PROXY_SEND_RESULT ++end ++ ++function show_process_table() ++ local dataset = {} ++ local header = { 'Id', 'IP Address', 'Time' } ++ local rows = {} ++ for t_i, t_v in pairs (proxy.global.process) do ++ for s_i, s_v in pairs ( t_v ) do ++ table.insert(rows, { t_i, s_v.ip, os.date('%c',s_v.ts) }) ++ end ++ end ++ return make_dataset(header,rows) ++end ++ ++function show_process_help() ++ local dataset = {} ++ local header = { 'command', 'description' } ++ local rows = { ++ {'SELECT HELP', 'This command.'}, ++ {'SHOW PROXY PROCESSLIST', 'Show all connections and their true IP Address.'}, ++ } ++ return make_dataset(header,rows) ++end ++ ++function dump_process_table() ++ proxy.global.initialize_process_table() ++ print('current contents of process table') ++ for t_i, t_v in pairs (proxy.global.process) do ++ print ('session id: ', t_i) ++ for s_i, s_v in pairs ( t_v ) do ++ print ( '\t', s_i, s_v.ip, s_v.ts ) ++ end ++ end ++ print ('---END PROCESS TABLE---') ++end ++ ++ ++ ++ ++--[[ Help ++ ++we use a simple string-match to split commands are word-boundaries ++ ++mysql> show querycounter ++ ++is split into ++command = "show" ++option = "querycounter" ++ ++spaces are ignored, the case has to be as is. ++ ++mysql> show myerror ++ ++returns a error-packet ++ ++--]] ++ ++ diff --git a/databases/mysql-proxy/files/patch-lib-proxy-Makefile.in b/databases/mysql-proxy/files/patch-lib-proxy-Makefile.in new file mode 100644 index 000000000000..a5c1e66bf551 --- /dev/null +++ b/databases/mysql-proxy/files/patch-lib-proxy-Makefile.in @@ -0,0 +1,22 @@ +--- lib/proxy/Makefile.in.orig 2009-04-04 20:13:04.000000000 +0600 ++++ lib/proxy/Makefile.in 2009-05-05 12:48:40.000000000 +0600 +@@ -16,7 +16,7 @@ + + VPATH = @srcdir@ + pkgdatadir = $(datadir)/@PACKAGE@ +-pkglibdir = $(libdir)/@PACKAGE@ ++pkglibdir = $(datadir)/@PACKAGE@ + pkgincludedir = $(includedir)/@PACKAGE@ + am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd + install_sh_DATA = $(install_sh) -c -m 644 +--- lib/proxy/Makefile.in.orig 2009-05-18 22:15:03.000000000 +0800 ++++ lib/proxy/Makefile.in 2009-07-08 17:41:43.000000000 +0800 +@@ -192,7 +192,7 @@ + top_build_prefix = @top_build_prefix@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ +-luaextdir = ${pkglibdir}/lua/ ++luaextdir = ${pkgdatadir}/lua/ + pkglib_proxydir = $(luaextdir)/proxy + dist_pkglib_proxy_DATA = \ + auto-config.lua \ diff --git a/databases/mysql-proxy/files/patch-lib-reporter.lua b/databases/mysql-proxy/files/patch-lib-reporter.lua new file mode 100644 index 000000000000..b113d913e97d --- /dev/null +++ b/databases/mysql-proxy/files/patch-lib-reporter.lua @@ -0,0 +1,82 @@ +--- lib/reporter.lua.orig 2009-05-05 16:54:45.000000000 +0600 ++++ lib/reporter.lua 2009-05-05 16:56:21.000000000 +0600 +@@ -0,0 +1,79 @@ ++--[[ ++ ++ Copyright (C) 2009 MySQL AB, 2008 Sun Microsystems, Inc ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; version 2 of the License. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ ++--]] ++ ++-- reporter.lua ++ ++--[[ ++ ++ See http://forge.mysql.com/tools/tool.php?id=78 ++ (Thanks to Jan Kneschke) ++ See http://www.chriscalender.com/?p=41 ++ (Thanks to Chris Calender) ++ See http://datacharmer.blogspot.com/2009/01/mysql-proxy-is-back.html ++ (Thanks Giuseppe Maxia) ++ ++--]] ++ ++proxy.global.query_counter = proxy.global.query_counter or 0 ++ ++function proxy.global.initialize_process_table() ++ if proxy.global.process == nil then ++ proxy.global.process = {} ++ end ++ if proxy.global.process[proxy.connection.server.thread_id] == nil then ++ proxy.global.process[proxy.connection.server.thread_id] = {} ++ end ++end ++ ++function read_auth_result( auth ) ++ local state = auth.packet:byte() ++ if state == proxy.MYSQLD_PACKET_OK then ++ proxy.global.initialize_process_table() ++ table.insert( proxy.global.process[proxy.connection.server.thread_id], ++ { ip = proxy.connection.client.src.name, ts = os.time() } ) ++ end ++end ++ ++function disconnect_client() ++ local connection_id = proxy.connection.server.thread_id ++ if connection_id then ++ -- client has disconnected, set this to nil ++ proxy.global.process[connection_id] = nil ++ end ++end ++ ++ ++--- ++-- read_query() can return a resultset ++-- ++-- You can use read_query() to return a result-set. ++-- ++-- @param packet the mysql-packet sent by the client ++-- ++-- @return ++-- * nothing to pass on the packet as is, ++-- * proxy.PROXY_SEND_QUERY to send the queries from the proxy.queries queue ++-- * proxy.PROXY_SEND_RESULT to send your own result-set ++-- ++function read_query( packet ) ++ -- a new query came in in this connection ++ -- using proxy.global.* to make it available to the admin plugin ++ proxy.global.query_counter = proxy.global.query_counter + 1 ++ ++end -- cgit v1.2.3