- Update to 0.7.1

PR:		ports/134042
This commit is contained in:
Cheng-Lung Sung 2009-07-09 02:49:52 +00:00
parent 6ef5ef58e9
commit f8680edbe5
9 changed files with 436 additions and 47 deletions

View file

@ -6,8 +6,7 @@
#
PORTNAME= mysql-proxy
PORTVERSION= 0.6.1
PORTREVISION= 3
PORTVERSION= 0.7.1
CATEGORIES= databases
MASTER_SITES= ${MASTER_SITE_MYSQL}
MASTER_SITE_SUBDIR= MySQL-Proxy
@ -18,13 +17,14 @@ COMMENT= Monitor, analyze or transform the communication of MySQL
LIB_DEPENDS= event-1.4:${PORTSDIR}/devel/libevent \
glib:${PORTSDIR}/devel/glib20
CONFIGURE_ARGS+= --with-lua=lua-5.1 --with-mysql
CONFIGURE_ENV+= CFLAGS="-I${LOCALBASE}/include -I${LUA_INCDIR}" \
LDFLAGS="-L${LOCALBASE}/lib -L${LUA_LIBDIR}" \
CONFIGURE_ARGS+= --with-lua=lua-5.1 --with-mysql --docdir=${DATADIR} --enable-self-contained
CFLAGS+= -I${LOCALBASE}/include
CONFIGURE_ENV+= LDFLAGS="-L${LOCALBASE}/lib -L${LUA_LIBDIR}" \
PKG_CONFIG_PATH="${LUA_PREFIX}/share/doc/${LUA_SUBDIR}/etc"
GNU_CONFIGURE= yes
USE_GNOME= gnometarget pkgconfig
USE_ICONV= yes
USE_LDCONFIG= yes
USE_LUA= 5.1+
USE_MYSQL= yes
USE_RC_SUBR= mysql-proxy.sh

View file

@ -1,3 +1,3 @@
MD5 (mysql-proxy-0.6.1.tar.gz) = f5b003f069c294002ae37c6df3a7a0a5
SHA256 (mysql-proxy-0.6.1.tar.gz) = 7b9cb689bb718441d56dfd3d71c46c0bff577330440b8f8e7305766c373f02cc
SIZE (mysql-proxy-0.6.1.tar.gz) = 510223
MD5 (mysql-proxy-0.7.1.tar.gz) = 009bc3e669fe42f5f8ac634d20226cf4
SHA256 (mysql-proxy-0.7.1.tar.gz) = 4a1593b6f95f95f88c9fba9b3135d15893e0ac5be992d5887f724a8c31ef753e
SIZE (mysql-proxy-0.7.1.tar.gz) = 689251

View file

@ -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"

View file

@ -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

View file

@ -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 \

View file

@ -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
+
+--]]
+
+

View file

@ -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 \

View file

@ -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

View file

@ -1,28 +1,76 @@
@comment $FreeBSD$
sbin/mysql-proxy
bin/mysql-binlog-dump
bin/mysql-myisam-dump
libexec/mysql-proxy
libexec/mysql-binlog-dump
libexec/mysql-myisam-dump
lib/libmysql-chassis.so.0
lib/libmysql-chassis.so
lib/libmysql-chassis.la
lib/libmysql-proxy.so.0
lib/libmysql-proxy.so
lib/libmysql-proxy.la
lib/mysql-proxy/lua/lfs.so
lib/mysql-proxy/lua/lfs.la
lib/mysql-proxy/lua/glib2.so
lib/mysql-proxy/lua/glib2.la
lib/mysql-proxy/lua/chassis.so
lib/mysql-proxy/lua/chassis.la
lib/mysql-proxy/lua/mysql.so
lib/mysql-proxy/lua/mysql.la
lib/mysql-proxy/lua/lpeg.so
lib/mysql-proxy/lua/lpeg.la
lib/mysql-proxy/lua/posix.so
lib/mysql-proxy/lua/posix.la
lib/mysql-proxy/plugins/libadmin.so
lib/mysql-proxy/plugins/libadmin.la
lib/mysql-proxy/plugins/libproxy.so
lib/mysql-proxy/plugins/libproxy.la
lib/mysql-proxy/plugins/libreplicant.so
lib/mysql-proxy/plugins/libreplicant.la
lib/mysql-proxy/plugins/libdebug.so
lib/mysql-proxy/plugins/libdebug.la
%%DATADIR%%/active-queries.lua
%%DATADIR%%/active-transactions.lua
%%DATADIR%%/admin-sql.lua
%%DATADIR%%/admin.lua
%%DATADIR%%/analyze-query.lua
%%DATADIR%%/auditing.lua
%%DATADIR%%/commit-obfuscator.lua
%%DATADIR%%/commit-obfuscator.msc
%%DATADIR%%/histogram.lua
%%DATADIR%%/proxy/auto-config.lua
%%DATADIR%%/proxy/balance.lua
%%DATADIR%%/proxy/commands.lua
%%DATADIR%%/proxy/parser.lua
%%DATADIR%%/proxy/tokenizer.lua
%%DATADIR%%/load-multi.lua
%%DATADIR%%/reporter.lua
%%DATADIR%%/ro-balance.lua
%%DATADIR%%/ro-pooling.lua
%%DATADIR%%/rw-splitting.lua
%%DATADIR%%/xtab.lua
%%DATADIR%%/lua/proxy/auto-config.lua
%%DATADIR%%/lua/proxy/balance.lua
%%DATADIR%%/lua/proxy/commands.lua
%%DATADIR%%/lua/proxy/parser.lua
%%DATADIR%%/lua/proxy/tokenizer.lua
%%DATADIR%%/lua/proxy/test.lua
%%EXAMPLESDIR%%/tutorial-basic.lua
%%EXAMPLESDIR%%/tutorial-constants.lua
%%EXAMPLESDIR%%/tutorial-inject.lua
%%EXAMPLESDIR%%/tutorial-keepalive.lua
%%EXAMPLESDIR%%/tutorial-load-multi.lua
%%EXAMPLESDIR%%/tutorial-monitor.lua
%%EXAMPLESDIR%%/tutorial-packets.lua
%%EXAMPLESDIR%%/tutorial-query-time.lua
%%EXAMPLESDIR%%/tutorial-resultset.lua
%%EXAMPLESDIR%%/tutorial-rewrite.lua
%%EXAMPLESDIR%%/tutorial-routing.lua
%%EXAMPLESDIR%%/tutorial-states.lua
%%EXAMPLESDIR%%/tutorial-tokenize.lua
%%EXAMPLESDIR%%/tutorial-union.lua
%%EXAMPLESDIR%%/tutorial-warnings.lua
sbin/mysql-proxy
@dirrmtry lib/mysql-proxy/plugins
@dirrmtry lib/mysql-proxy/lua
@dirrmtry lib/mysql-proxy
@dirrmtry %%EXAMPLESDIR%%
@dirrmtry %%DATADIR%%/proxy
@dirrmtry %%DATADIR%%/lua/proxy
@dirrmtry %%DATADIR%%/lua
@dirrmtry %%DATADIR%%
@dirrmtry %%DOCSDIR%%