Commit 89e77b65 authored by unknown's avatar unknown
Browse files

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/cps/mysql/devel/im/mysql-5.0-im

parents 04ddb612 f7ef17dd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ myisam/test2.MYD
myisam/test2.MYI
mysql-4.0.2-alpha-pc-linux-gnu-i686.tar.gz
mysql-4.0.2-alpha.tar.gz
mysql-5.0.2-alpha.tar.gz
mysql-max-4.0.2-alpha-pc-linux-gnu-i686.tar.gz
mysql-test/gmon.out
mysql-test/install_test_db
@@ -816,7 +817,11 @@ scripts/mysqldumpslow
scripts/mysqlhotcopy
scripts/safe_mysqld
select_test
server-tools/instance-manager/client.c
server-tools/instance-manager/client_settings.h
server-tools/instance-manager/errmsg.c
server-tools/instance-manager/mysqlmanager
server-tools/instance-manager/thr_alarm.c
sql-bench/Results-linux/ATIS-mysql_bdb-Linux_2.2.14_my_SMP_i686
sql-bench/bench-count-distinct
sql-bench/bench-init.pl
+75 −13
Original line number Diff line number Diff line
# Copyright (C) 2004 MySQL AB
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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

INCLUDES= -I$(top_srcdir)/include

DEFS= -DMYSQL_INSTANCE_MANAGER -DMYSQL_SERVER

# As all autoconf variables depend from ${prefix} and being resolved only when
# make is run, we can't put these defines to a header file (e.g. to
# make is run, we can not put these defines to a header file (e.g. to
# default_options.h, generated from default_options.h.in)
# See automake/autoconf docs for details

noinst_LIBRARIES= liboptions.a
noinst_LIBRARIES= liboptions.a libnet.a

liboptions_a_CPPFLAGS= $(CPPFLAGS) \
	-DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
	-DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager.log" \
	-DDEFAULT_SOCKET_FILE_NAME="$(localstatedir)/mysqlmanager.sock"
	-DDEFAULT_SOCKET_FILE_NAME="$(localstatedir)/mysqlmanager.sock" \
	-DDEFAULT_PASSWORD_FILE_NAME="$(sysconfdir)/mysqlmanager.passwd" \
	-DDEFAULT_MYSQLD_PATH="$(bindir)/mysqld$(EXEEXT)" \
	-DDEFAULT_USER="root" \
	-DDEFAULT_PASSWORD="" \
	-DDEFAULT_MONITORING_INTERVAL="5" \
	-DDEFAULT_PORT="33006" \
	-DPROTOCOL_VERSION=@PROTOCOL_VERSION@

liboptions_a_SOURCES= options.h options.cc priv.h priv.cc

# MySQL sometimes uses symlinks to reuse code 
# All symlinked files are grouped in libnet.a

liboptions_a_SOURCES= options.h options.cc
nodist_libnet_a_SOURCES= net_serv.cc client_settings.h
libnet_a_LIBADD= $(top_builddir)/sql/password.$(OBJEXT) \
	$(top_builddir)/sql/pack.$(OBJEXT) \
	$(top_builddir)/sql/sql_state.$(OBJEXT) \
	$(top_builddir)/sql/mini_client_errors.$(OBJEXT)\
	$(top_builddir)/sql/client.$(OBJEXT)

CLEANFILES= net_serv.cc client_settings.h

net_serv.cc: Makefile
	rm -f $(srcdir)/net_serv.cc
	@LN_CP_F@ $(top_srcdir)/sql/net_serv.cc $(srcdir)/net_serv.cc

client_settings.h: Makefile
	rm -f $(srcdir)/client_settings.h
	@LN_CP_F@ $(top_srcdir)/sql/client_settings.h $(srcdir)/client_settings.h

bin_PROGRAMS= mysqlmanager

mysqlmanager_SOURCES= mysqlmanager.cc manager.h manager.cc log.h log.cc \
		      listener.h listener.cc \
		      thread_repository.h thread_repository.cc
mysqlmanager_SOURCES=	command.cc command.h mysqlmanager.cc \
			manager.h manager.cc log.h log.cc \
			thread_registry.h thread_registry.cc \
			listener.h listener.cc protocol.h protocol.cc \
			mysql_connection.h mysql_connection.cc \
			user_map.h user_map.cc \
			messages.h messages.cc \
			commands.h commands.cc \
			factory.h factory.cc \
			instance.h instance.cc \
			instance_map.h instance_map.cc\
			instance_options.h instance_options.cc \
			buffer.h buffer.cc parse.cc parse.h \
			guardian.cc guardian.h \
                        mysql_manager_error.h client_func.c

mysqlmanager_LDADD=	liboptions.a \
			libnet.a \
			$(top_builddir)/vio/libvio.a \
			$(top_builddir)/mysys/libmysys.a \
			$(top_builddir)/strings/libmystrings.a \
		    $(top_builddir)/dbug/libdbug.a
			$(top_builddir)/dbug/libdbug.a \
			@openssl_libs@ @ZLIB_LIBS@


tags:
	ctags -R *.h *.cc
+97 −0
Original line number Diff line number Diff line
/* Copyright (C) 2004 MySQL AB

   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; either version 2 of the License, or
   (at your option) any later version.

   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 */

#ifdef __GNUC__
#pragma implementation
#endif

#include "buffer.h"
#include <m_string.h>


/*
  Puts the given string to the buffer.

  SYNOPSYS
    append()
    position          start position in the buffer
    string            string to be put in the buffer
    len_arg           the length of the string. This way we can avoid some
                      strlens.

  DESCRIPTION

    The method puts a string into the buffer, starting from position .
    In the case when the buffer is too small it reallocs the buffer. The
    total size of the buffer is restricted with 16.

  RETURN
    0 - ok
    1 - The buffer came to 16Mb barrier
*/

int Buffer::append(uint position, const char *string, uint len_arg)
{
  if (reserve(position, len_arg))
    return 1;

  strnmov(buffer + position, string, len_arg);
  return 0;
}


/*
  Checks whether the current buffer size is ok to put a string of the length
  "len_arg" starting from "position" and reallocs it if no.

  SYNOPSYS
    reserve()
    position          the number starting byte on the buffer to store a buffer
    len_arg           the length of the string.

  DESCRIPTION

    The method checks whether it is possible to pus a string of teh "len_arg"
    length into the buffer, starting from "position" byte. In the case when the
    buffer is too small it reallocs the buffer. The total size of the buffer is
    restricted with 16 Mb.

  RETURN
    0 - ok
    1 - The buffer came to 16Mb barrier
*/

int Buffer::reserve(uint position, uint len_arg)
{
  if (position + len_arg >= MAX_BUFFER_SIZE)
    goto err;

  if (position + len_arg>= buffer_size)
  {
    buffer= (char *) realloc(buffer,
                             min(MAX_BUFFER_SIZE,
                                 max((uint) (buffer_size*1.5),
                                     position + len_arg)));
    if (buffer= NULL)
      goto err;
    buffer_size= (uint) (buffer_size*1.5);
  }
  return 0;

err:
  return 1;
}
+57 −0
Original line number Diff line number Diff line
#ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_BUFFER_H
#define INCLUDES_MYSQL_INSTANCE_MANAGER_BUFFER_H
/* Copyright (C) 2004 MySQL AB

   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; either version 2 of the License, or
   (at your option) any later version.

   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 */

#include <my_global.h>

#ifdef __GNUC__
#pragma interface
#endif

/*
  This class is a simple implementation of the buffer of varying size.
  It is used to store MySQL client-server protocol packets. This is why
  the maximum buffer size if 16Mb. (See internals manual section
  7. MySQL Client/Server Protocol)
*/

class Buffer
{
private:
  enum { BUFFER_INITIAL_SIZE= 4096 };
  /* maximum buffer size is 16Mb */
  enum { MAX_BUFFER_SIZE= 16777216 };
  size_t buffer_size;
public:
  Buffer()
  {
    buffer=(char *) malloc(BUFFER_INITIAL_SIZE);
    buffer_size= BUFFER_INITIAL_SIZE;
  }

  ~Buffer()
  {
    free(buffer);
  }

public:
  char *buffer;
  int append(uint position, const char *string, uint len_arg);
  int reserve(uint position, uint len_arg);
};

#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_BUFFER_H */
+32 −0
Original line number Diff line number Diff line
#include <my_global.h>
#include <my_sys.h>
#include <mysql.h>

/*
  Currently we cannot use libmysqlclient directly becouse of the linking
  issues. Here we provide needed libmysqlclient functions.
  TODO: to think how to use libmysqlclient code instead of copy&paste.
  The other possible solution is to use simple_command directly.
*/

const char * STDCALL
mysql_get_server_info(MYSQL *mysql)
{
  return((char*) mysql->server_version);
}

int STDCALL
mysql_ping(MYSQL *mysql)
{
  DBUG_ENTER("mysql_ping");
  DBUG_RETURN(simple_command(mysql,COM_PING,0,0,0));
}

int STDCALL
mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level)
{
  uchar level[1];
  DBUG_ENTER("mysql_shutdown");
  level[0]= (uchar) shutdown_level;
  DBUG_RETURN(simple_command(mysql, COM_SHUTDOWN, (char *)level, 1, 0));
}
Loading