Commit ac02f540 authored by unknown's avatar unknown

Removed some not used files

Remove the 'fs' file systems as this is not maintained.
Moved programs from client to tests


tests/deadlock_test.c:
  Rename: div/deadlock_test.c -> tests/deadlock_test.c
BitKeeper/deleted/.del-CorbaFS.idl~719ba9d93c206620:
  Delete: fs/CorbaFS.idl
BitKeeper/deleted/.del-Makefile.am~95f21e278745904c:
  Delete: fs/Makefile.am
BitKeeper/deleted/.del-RunServer.sh~34ea2653535fbb5c:
  Delete: fs/RunServer.sh
BitKeeper/deleted/.del-database.c~af098622e818ce0d:
  Delete: fs/database.c
BitKeeper/deleted/.del-dump.sql~68646092f0c5bc96:
  Delete: fs/dump.sql
BitKeeper/deleted/.del-korbit-kernel-2.4.1-patch~742e5e67c1132b2e:
  Delete: fs/korbit-kernel-2.4.1-patch
BitKeeper/deleted/.del-libmysqlfs.c~70cc07d61deedd16:
  Delete: fs/libmysqlfs.c
BitKeeper/deleted/.del-libmysqlfs.h~7b60f308be50370e:
  Delete: fs/libmysqlfs.h
BitKeeper/deleted/.del-my.cnf~bbd975fd6377e704:
  Delete: fs/my.cnf
BitKeeper/deleted/.del-mysqlcorbafs.c~fc58c116eeea996a:
  Delete: fs/mysqlcorbafs.c
BitKeeper/deleted/.del-mysqlcorbafs.h~414821d6836e655a:
  Delete: fs/mysqlcorbafs.h
BitKeeper/deleted/.del-mysqlcorbafs_test.c~8bb3afa230542e05:
  Delete: fs/mysqlcorbafs_test.c
BitKeeper/deleted/.del-README~b9f437fbd6dce7a5:
  Delete: fs/README
BitKeeper/deleted/.del-mysqlfsck~247a2d2b9729b95e:
  Delete: fs/mysqlfsck
tests/insert_test.c:
  Rename: client/insert_test.c -> tests/insert_test.c
tests/list_test.c:
  Rename: client/list_test.c -> tests/list_test.c
tests/select_test.c:
  Rename: client/select_test.c -> tests/select_test.c
BitKeeper/deleted/.del-thimble.cc~3fa3754a4c639242:
  Delete: client/thimble.cc
tests/thread_test.c:
  Rename: client/thread_test.c -> tests/thread_test.c
tests/connect_test.c:
  Rename: client/connect_test.c -> tests/connect_test.c
tests/showdb_test.c:
  Rename: client/showdb_test.c -> tests/showdb_test.c
tests/ssl_test.c:
  Rename: client/ssl_test.c -> tests/ssl_test.c
BitKeeper/deleted/.del-mysql_install.c~8c089740d79a92:
  Delete: extra/mysql_install.c
BitKeeper/deleted/.del-cache_manager.cc~c506b365b140d30c:
  Delete: sql/cache_manager.cc
BitKeeper/deleted/.del-cache_manager.h~adb8639e510c6f6e:
  Delete: sql/cache_manager.h
client/Makefile.am:
  Move insert_test, select_test and thread_test under 'tests'
extra/Makefile.am:
  Remove not used program mysql_install
sql/item_strfunc.cc:
  Simple optimization
sql/item_sum.cc:
  Simple code cleanup.
tests/Makefile.am:
  Added test programs
parent 43f1511a
......@@ -22,7 +22,6 @@ LIBS = @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc mysqlmanager-pwgen
noinst_PROGRAMS = insert_test select_test thread_test
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \
client_priv.h
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc
......@@ -34,8 +33,6 @@ mysqlcheck_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqlshow_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqldump_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqlimport_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqltest_SOURCES= mysqltest.c
mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqlbinlog_SOURCES = mysqlbinlog.cc
......@@ -53,8 +50,5 @@ link_sources:
@LN_CP_F@ $(top_srcdir)/sql/$$f $(srcdir)/$$f; \
done;
thread_test.o: thread_test.c
$(COMPILE) -c @MT_INCLUDES@ $(INCLUDES) $<
# Don't update the files from bitkeeper
%::SCCS/s.%
/* Copyright (C) 2000 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 <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "my_my_global.h"
static void spawn_stern_thread(pthread_t *t);
static int act_goofy(void);
static void *be_stern(void *);
static struct {
pthread_mutex_t lock;
pthread_cond_t cond;
int msg;
} comm = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0 };
int
main(void)
{
pthread_t t;
spawn_stern_thread(&t);
while (act_goofy() != 0)
/* do nothing */;
pthread_exit(NULL);
/* notreached */
return EXIT_SUCCESS;
}
static void spawn_stern_thread(pthread_t *t)
{
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (pthread_create(t, &attr, be_stern, NULL) != 0)
exit(EXIT_FAILURE);
pthread_attr_destroy(&attr);
}
static int act_goofy(void)
{
int ret;
char buf[30];
fputs("Are you ready to act goofy (Y/n)? ", stdout); fflush(stdout);
fgets(buf, sizeof(buf), stdin);
pthread_mutex_lock(&comm.lock);
if (buf[0] == 'y' || buf[0] == '\n') {
fputs("** Waawlwalkwwwaa!!\n", stdout); fflush(stdout);
++comm.msg;
ret = 1;
}
else {
fputs("OK, I hate you. Let me go.\n", stdout); fflush(stdout);
comm.msg = -1;
ret = 0;
}
pthread_mutex_unlock(&comm.lock);
pthread_cond_signal(&comm.cond);
return ret;
}
static void *be_stern(void *v __attribute__((unused)))
{
int msg;
for (;;) {
pthread_mutex_lock(&comm.lock);
while (comm.msg == 0)
pthread_cond_wait(&comm.cond, &comm.lock);
msg = comm.msg;
comm.msg = 0;
pthread_mutex_unlock(&comm.lock);
if (msg < 0)
break; /* the goofy one learned a lesson! */
fputs("I HAVE TO BE STERN WITH YOU!\n", stderr);
fprintf(stderr, "I should give you %d lashes.\n", msg);
sleep(msg);
}
fputs("You are NOTHING!\n", stderr);
return NULL;
}
......@@ -18,7 +18,7 @@ INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
../dbug/libdbug.a ../strings/libmystrings.a
bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \
resolve_stack_dump mysql_install mysql_waitpid
resolve_stack_dump mysql_waitpid
# Don't update the files from bitkeeper
%::SCCS/s.%
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* Install or upgrade MySQL server. By Sasha Pachev <sasha@mysql.com>
*/
#define INSTALL_VERSION "1.2"
#define DONT_USE_RAID
#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
#include <my_getopt.h>
#define ANSWERS_CHUNCK 32
int have_gui=0;
static struct my_option my_long_options[] =
{
{"help", '?', "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
/* For now, not much exciting here, but we'll add more once
we add GUI support
*/
typedef struct
{
FILE* out;
FILE* in;
const char* question;
int default_ind;
DYNAMIC_ARRAY answers;
} QUESTION_WIDGET;
static void usage();
static void die(const char* fmt, ...);
static void print_version(void);
static char get_answer_char(int ans_ind);
static int ask_user(const char* question,int default_ind, ...);
static void add_answer(QUESTION_WIDGET* w, const char* ans);
static void display_question(QUESTION_WIDGET* w);
static int init_question_widget(QUESTION_WIDGET* w, const char* question,
int default_ind);
static void end_question_widget(QUESTION_WIDGET* w);
static int get_answer(QUESTION_WIDGET* w);
static char answer_from_char(char c);
static void invalid_answer(QUESTION_WIDGET* w);
enum {IMODE_STANDARD=0,IMODE_CUSTOM,IMODE_UPGRAGE} install_mode
= IMODE_STANDARD;
static char get_answer_char(int ans_ind)
{
return 'a' + ans_ind;
}
static void invalid_answer(QUESTION_WIDGET* w)
{
if (!have_gui)
{
fprintf(w->out, "ERROR: invalid answer, try again...\a\n");
}
}
static char answer_from_char(char c)
{
return c - 'a';
}
static void die(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
fprintf(stderr, "%s: ", my_progname);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
exit(1);
}
static void display_question(QUESTION_WIDGET* w)
{
if (!have_gui)
{
uint i,num_answers=w->answers.elements;
DYNAMIC_ARRAY* answers = &w->answers;
fprintf(w->out,"\n%s\n\n",w->question);
for (i=0; i<num_answers; i++)
{
char* ans;
get_dynamic(answers,(gptr)&ans,i);
fprintf(w->out,"%c - %s\n",get_answer_char(i),ans);
}
fprintf(w->out,"q - Abort Install/Upgrade\n\n");
}
}
static void add_answer(QUESTION_WIDGET* w, const char* ans)
{
insert_dynamic(&w->answers,(gptr)&ans);
}
static int init_question_widget(QUESTION_WIDGET* w, const char* question,
int default_ind)
{
if (have_gui)
{
w->in = w->out = 0;
}
else
{
w->out = stdout;
w->in = stdin;
}
w->question = question;
w->default_ind = default_ind;
if (my_init_dynamic_array(&w->answers,sizeof(char*),
ANSWERS_CHUNCK,ANSWERS_CHUNCK))
die("Out of memory");
return 0;
}
static void end_question_widget(QUESTION_WIDGET* w)
{
delete_dynamic(&w->answers);
}
static int get_answer(QUESTION_WIDGET* w)
{
if (!have_gui)
{
char buf[32];
int ind;
char c;
if (!fgets(buf,sizeof(buf),w->in))
die("Failed fgets on input stream");
switch ((c=my_tolower(&my_charset_latin1,*buf)))
{
case '\n':
return w->default_ind;
case 'q':
die("Install/Upgrade aborted");
default:
ind = answer_from_char(c);
if (ind >= 0 && ind < (int)w->answers.elements)
return ind;
}
}
return -1;
}
static int ask_user(const char* question,int default_ind, ...)
{
va_list args;
char* opt;
QUESTION_WIDGET w;
int ans;
va_start(args,default_ind);
init_question_widget(&w,question,default_ind);
for (;(opt=va_arg(args,char*));)
{
add_answer(&w,opt);
}
for (;;)
{
display_question(&w);
if ((ans = get_answer(&w)) >= 0)
break;
invalid_answer(&w);
}
end_question_widget(&w);
va_end(args);
return ans;
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
switch(optid) {
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
static int parse_args(int argc, char **argv)
{
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
return 0;
}
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,INSTALL_VERSION,
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
print_version();
printf("MySQL AB, by Sasha Pachev\n");
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Install or upgrade MySQL server.\n\n");
printf("Usage: %s [OPTIONS] \n", my_progname);
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
int main(int argc, char** argv)
{
MY_INIT(argv[0]);
parse_args(argc,argv);
install_mode = ask_user("Please select install/upgrade mode",
install_mode, "Standard Install",
"Custom Install", "Upgrade",0);
printf("mode=%d\n", install_mode);
return 0;
}
// -----------------------------------------------------------------------------
// CorbaDS Module - Implement Kernel functionality in korbit
// -----------------------------------------------------------------------------
//
// Main source of information:
// http://www.cse.unsw.edu.au/~neilb/oss/linux-commentary/vfs.html
//
module CorbaFS {
struct dirent
{
long inode; // inode number
string name; // file name (null-terminated)
};
typedef sequence<dirent> DirEntSeq;
typedef sequence<octet> Buffer;
interface Inode {
void getStatus(out unsigned short mode, out unsigned long uid, out unsigned long gid,
out unsigned long size, out unsigned long inodeNum, out unsigned short numLinks,
out long atime, out long mtime, out long ctime);
void readpage(out Buffer buffer, in long size, in long offset);
void release();
};
interface FileSystem {
Inode getInode(in string path);
// DirectoryInode getStatus implementation must have S_IFDIR in the S_IFMT
// field of the mode value.
DirEntSeq readdir(in string path);
// SymlinkInode getStatus implementation must have S_IFLNK in the S_IFMT
// field of the mode value.
string readlink(in string filename);
};
};
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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
#called from the top level Makefile
CFLAGS = $(ORBIT_CFLAGS) -g
LFLAGS = $(ORBIT_LIBS)
orbit_idl = @orbit_idl@
orbit_includes = @orbit_includes@
orbit_libs = @orbit_libs@
DISTCLEANFILES = CorbaFS-common.* CorbaFS-stubs.* CorbaFS-skels.* CorbaFS.h
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include \
-I$(top_srcdir)/regex $(orbit_includes)
WRAPLIBS= @WRAPLIBS@
libexec_PROGRAMS = mysqlcorbafsd
noinst_PROGRAMS =mysqlfs_test
LDADD = ../libmysql/libmysqlclient.la $(orbit_libs)
mysqlcorbafsd_LDADD = $(LDADD) $(CXXLDFLAGS)
noinst_HEADERS =
mysqlfs_test_SOURCES = mysqlcorbafs_test.c CorbaFS-common.c CorbaFS-stubs.c libmysqlfs.c
mysqlcorbafsd_SOURCES = mysqlcorbafs.c CorbaFS-skels.c database.c CorbaFS-common.c libmysqlfs.c
DEFS = -DMYSQL_SERVER \
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
@DEFS@
# Don't put lex_hash.h in BUILT_SOURCES as this will give infinite recursion
BUILT_SOURCES = CorbaFS-common.c CorbaFS-stubs.c CorbaFS-skels.c CorbaFS.h
EXTRA_DIST = $(BUILT_SOURCES)
#YFLAGS = -d
OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\
__math.h time.h __time.h unistd.h __unistd.h types.h \
xtypes.h ac-types.h posix.h string.h __string.h \
errno.h socket.h inet.h dirent.h netdb.h \
cleanup.h cond.h debug_out.h fd.h kernel.h mutex.h \
prio_queue.h pthread_attr.h pthread_once.h queue.h\
sleep.h specific.h version.h pwd.h timers.h uio.h \
cdefs.h machdep.h signal.h __signal.h util.h lex.h \
wait.h
link_sources:
rm -f mini_client_errors.c
@LN_CP_F@ ../libmysql/errmsg.c mini_client_errors.c
# Don't update the files from bitkeeper
%::SCCS/s.%
idltargets : CorbaFS.idl
$(ORBIT_IDL) CorbaFS.idl
$(orbit_idl) CorbaFS.idl
# individual rules
CorbaFS-stubs.c : CorbaFS.idl
$(orbit_idl) CorbaFS.idl
CorbaFS-common.c : CorbaFS.idl
$(orbit_idl) CorbaFS.idl
CorbaFS-skels.c : CorbaFS.idl
$(orbit_idl) CorbaFS.idl
#CorbaFS-client.c : CorbaFS.h
#CorbaFS-server.c : CorbaFS.h
CorbaFS.h : CorbaFS.idl
$(orbit_idl) CorbaFS.idl
MySQL Filesystem
Tnu Samuel - tonu@mysql.com
Some additional information is available on http://no.spam.ee/~tonu/mysqlfs.html
WARNING: Experimental code and known to crash computer.
Instructions, how to get this stuff working:
1. Make sure you have ORBit, includeing development libraries installed. They should be version 0.5.3 or later.
- I am lazy man and use default ones included with my RedHat:
[root@localhost /root]# rpm -qa | grep ORBit
ORBit-0.5.3-2
ORBit-devel-0.5.3-2
[root@localhost /root]#
2. Prepare kernel to include korbit:
- Get Linux 2.4.1 kernel source. (very possibly this patch works on 2.4.0 without modifications too)
- unpack it
- apply patch named "korbit-kernel-2.4.1-patch" on it.
- make menuconfig
- In section "Networking options":
...
[*] Kernel ORB (EXPERIMENTAL)
...
<M> CORBA User-space FileSystem (EXPERIMENTAL)
...
- make dep ; make bzlilo ; make modules ; make modules_install
- reboot
- Execute: insmod /lib/modules/$(uname -r)/kernel/net/korbit/modules/CorbaFS/client/corba-corbafs-client.o
You should see "gethostname() = localhost". Look at known bug 3 in the end of this doc.
3. Make sure MySQL server is working on your system
- On my RedHat 7.0 I execute "/etc/init.d/mysqld start"
4. Prepare MySQL FS daemon
- Get MySQL 4.0 from repository OR get MySQL FS source from http://no.spam.ee/~tonu/mysqlfs.html
- unpack it. In MySQL 4.0 source this is located in directory named "fs". cd into it.
- make
- Execute command "./RunServer"
5. mount MySQL server to disk tree
- Execute command "mkdir /mnt/mysql"
- Execute command "mount -t corbafs -o `cat /tmp/mysqlcorbafs.ior` none /mnt/mysql/"
- Check you SQL server content by executing "ls -la /mnt/mysql/"
Known bugs:
1. User bugs. fix user ;)
2. MySQL FS daemon will crash or will be stopped when cobrafs is mounted, then there is no way
to unmount disks anymore. This is korbit business to handle such cases and I had no time to dig
into korbit code.
3. host name returned by gethostname() should be "localhost" or korbit will crash. Also "localhost"
must be first string after 127.0.0.1 in /etc/hosts
.libs/mysqlcorbafsd -ORBIIOPUSock=0 -ORBIIOPIPv4=1 --debug='d:t:o,~/mysqlfsd.trace' $*
#.libs/mysqlcorbafsd -ORBIIOPUSock=0 -ORBIIOPIPv4=1 $*
This diff is collapsed.
# MySQL dump 8.12
#
# Host: localhost Database: mysqlfs
#--------------------------------------------------------
# Server version 3.23.33
#
# Table structure for table 'functions'
#
CREATE TABLE functions (
type enum('server','database','table','field','key') NOT NULL default 'server',
name char(20) NOT NULL default '',
sql char(128) NOT NULL default '',
PRIMARY KEY (type,name)
) TYPE=MyISAM;
#
# Dumping data for table 'functions'
#
INSERT INTO functions VALUES ('server','uptime','SHOW STATUS like \'Uptime\'');
INSERT INTO functions VALUES ('server','version','SELECT VERSION()');
INSERT INTO functions VALUES ('table','count','SELECT COUNT(*) FROM `%table`');
INSERT INTO functions VALUES ('key','min','SELECT MIN(%key) FROM `%table`');
INSERT INTO functions VALUES ('key','max','SELECT MAX(%key) FROM `%table`');
INSERT INTO functions VALUES ('key','avg','SELECT AVG(%key) FROM `%table`');
This diff is collapsed.
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 "libmysqlfs.h"
int search_and_replace(char *search, char* replace, char* string)
{
char buff[1024];
int found=0;
char *ptr1;
const char *ptr2=buff;
char *strptr=string;
DBUG_ENTER("search_and_replace");
DBUG_PRINT("enter",("search: '%s' replace:'%s' string:'%s'",search,replace,string));
strcpy(buff,string);
while(ptr1=strstr(ptr2,search))
{
strncpy(strptr,ptr2,ptr1-buff);
strptr+=ptr1-buff;
ptr2+=ptr1-buff+strlen(search);
strcpy(strptr,replace);
strptr+=strlen(replace);
found++;
}
DBUG_RETURN(found);
}
int show_functions(char *b, function_type type)
{
int i=0,j=0;
struct func_st func;
DBUG_ENTER("show_functions");
get_dynamic(&functions_array,(gptr)&func,i);
while(func.length) {
if (func.type == type)
strcpy(&b[j++*BUFLEN],func.filename);
get_dynamic(&functions_array,(gptr)&func,++i);
}
DBUG_RETURN(j);
}
struct func_st * check_if_function(char *name, function_type type)
{
int pathlen;
int j,i=0, len;
static struct func_st function;
char buffer[BUFLEN];
DBUG_ENTER("check_if_function");
DBUG_PRINT("enter",("name: '%s' type: '%d'", name, type));
pathlen=strlen(name);
/* We try to compare last element in path to function names */
get_dynamic(&functions_array,(gptr)&function,i);
while(function.length) {
function.continuous ?
(j=!strncasecmp(function.filename, name, function.length))
: (j=!strcasecmp(function.filename,name));
if(j) { /* This happens when function was matched */
DBUG_PRINT("info",("Function %s detected!",function.filename));
break;
}
get_dynamic(&functions_array,(gptr)&function,++i);
}
/* Copy path to buffer and trip function name (if found) from it */
if(function.length != 0)
{
DBUG_RETURN(&function);
} else {
DBUG_RETURN(0);
}
}
/*
* parse - splits "path" into different variables
* in way "/server/database/table/(field|key)/(value|function)". If path is shorter,
* then other fields will be NULL. If path is longer than four levels or
* shorter than one level, FS_NOTEXIST is returned.
*/
int parse(const char * path, char *server, char * database, char *table,
char* field, char* value, struct func_st **funce)
{
char buffer[BUFLEN];
char *p=buffer;
char *x;
int len;
DBUG_ENTER("parse");
DBUG_PRINT("enter",("path: '%s'", path));
*server=*database=*table=*field=*value='\0';
/* Search for first slash and drop it */
strcpy(buffer,path);
x=strtok_r(p,"/",&p);
if(x)
{
strcpy(server,x); /* First argument is server name */
if(*p)
strcpy(database,strtok_r(p,"/",&p)); /* Second is database */
if(p && *p)
strcpy(table ,strtok_r(p,"/",&p)); /* Third is table name */
if(p && *p)
strcpy(field ,strtok_r(p,"/",&p)); /* Fourth is field or key name */
if(p && *p)
strcpy(value ,strtok_r(p,"/",&p)); /* Fifth is field/key value or function */
}
/* We have to find if last argument is function,
* In which case we clear it
*/
if(*value) {
*funce=check_if_function(value,VALUE_FUNCTION);
if(*funce) *value='\0';
} else if (*field) {
*funce=check_if_function(field,FIELD_FUNCTION);
if(*funce) *field='\0';
} else if (*table) {
*funce=check_if_function(table,TABLE_FUNCTION);
if(*funce) *table='\0';
} else if (*database) {
*funce=check_if_function(database,DATABASE_FUNCTION);
if(*funce) *database='\0';
} else if (*server) {
*funce=check_if_function(server,SERVER_FUNCTION);
if(*funce) *server='\0';
} else
*funce=NULL;
DBUG_PRINT("info",("path: '%s', server: '%s', db: '%s', table: '%s', field: '%s', value: '%s', function: '%x'",
buffer, server, database, table, field, value, funce ));
if(p && *p) /* Something is in buffer - too deep in levels */
DBUG_RETURN(-1)
else
DBUG_RETURN(0)
}
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 "CorbaFS.h"
#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
#include "mysql.h"
#define BUFLEN 1024
#define MAXDIRS 1024
typedef enum {
FUNC_NONE,
FUNC_SERVER_UPTIME,
FUNC_SERVER_THREADS,
FUNC_SERVER_VERSION,
FUNC_DATABASE_CREATED,
FUNC_TABLE_COUNT,
FUNC_TABLE_CREATED,
FUNC_FIELD_LENGTH,
FUNC_KEY_AVG,
FUNC_KEY_SUM,
FUNC_KEY_MAX,
FUNC_KEY_MIN
} func_enum;
typedef enum {
NONE_FUNCTION,
ROOT_FUNCTION,
SERVER_FUNCTION,
DATABASE_FUNCTION,
TABLE_FUNCTION,
KEY_FUNCTION,
FIELD_FUNCTION,
VALUE_FUNCTION
} function_type;
struct func_st {
char type_s[20];
char filename[20];
char function[80];
function_type type;
int length;
my_bool continuous;
} ;
int parse(const char* path,
char* root,
char* database,
char* table,
char* key,
char* field,
struct func_st **func
);
gptr db_load_functions();
int db_function(char *b,const char *server, const char *database,const char *table,const char *field,
const char *value, const char *path, struct func_st *function);
int fix_filenames(char *buf);
DYNAMIC_ARRAY functions_array;
[mysqlcorbafs]
socket=/var/lib/mysql/mysql.sock
host=127.0.0.1
user=root
#password=xxxxxx
This diff is collapsed.
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 "CorbaFS.h"
#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
#include "mysql.h"
#define QUOTE_CHAR '`'
/* Exit codes */
#define EX_USAGE 1
#define EX_MYSQLERR 2
#define EX_CONSCHECK 3
#define EX_EOM 4
#define CORBAFS_VERSION "0.01"
typedef struct
{
POA_CorbaFS_Inode servant;
PortableServer_POA poa;
CORBA_char *path;
CORBA_unsigned_long inodeNum;
#if 0
CORBA_unsigned_short mode;
CORBA_unsigned_long uid;
CORBA_unsigned_long gid;
CORBA_unsigned_long size;
CORBA_unsigned_short numLinks;
CORBA_long atime;
CORBA_long mtime;
CORBA_long ctime;
#endif
}
impl_POA_CorbaFS_Inode;
typedef struct
{
POA_CorbaFS_FileSystem servant;
PortableServer_POA poa;
}
impl_POA_CorbaFS_FileSystem;
/*** Implementation stub prototypes ***/
CorbaFS_FileSystem
impl_FileSystem__create(PortableServer_POA poa, CORBA_Environment * ev);
static void
impl_Inode__destroy(impl_POA_CorbaFS_Inode * servant,
CORBA_Environment * ev);
static void
impl_Inode_getStatus(impl_POA_CorbaFS_Inode * servant,
CORBA_unsigned_short * mode,
CORBA_unsigned_long * uid,
CORBA_unsigned_long * gid,
CORBA_unsigned_long * size,
CORBA_unsigned_long * inodeNum,
CORBA_unsigned_short * numLinks,
CORBA_long * atime,
CORBA_long * mtime,
CORBA_long * ctime, CORBA_Environment * ev);
static void
impl_Inode_readpage(impl_POA_CorbaFS_Inode * servant,
CorbaFS_Buffer ** buffer,
CORBA_long size,
CORBA_long offset, CORBA_Environment * ev);
static void
impl_Inode_release(impl_POA_CorbaFS_Inode * servant,
CORBA_Environment * ev);
static void impl_FileSystem__destroy(impl_POA_CorbaFS_FileSystem *
servant, CORBA_Environment * ev);
static CorbaFS_Inode
impl_FileSystem_getInode(impl_POA_CorbaFS_FileSystem * servant,
CORBA_char * path, CORBA_Environment * ev);
static CorbaFS_DirEntSeq *
impl_FileSystem_readdir(impl_POA_CorbaFS_FileSystem * servant,
CORBA_char * path,
CORBA_Environment * ev);
static CORBA_char *
impl_FileSystem_readlink(impl_POA_CorbaFS_FileSystem * servant,
CORBA_char * filename,
CORBA_Environment * ev);
static my_bool verbose,opt_compress;
static uint opt_mysql_port=0;
static my_string opt_mysql_unix_port=0;
static int first_error=0;
static MYSQL connection, *sock=0;
extern uint opt_mysql_port;
extern my_string opt_mysql_unix_port,host,user,password;
static struct format {
char *tablestart;
char *headerrowstart;
char *headercellstart;
char *headercellseparator;
char *headercellend;
char *headerrowend;
int headerformat; /* 0 - simple, 1 - left padded, 2 - right padded */
char *contentrowstart;
char *contentcellstart;
char *contentcellseparator;
char *contentcellend;
char *contentrowend;
int contentformat;
char *footerrowstart;
char *footercellstart;
char *footercellseparator;
char *footercellend;
char *footerrowend;
int footerformat;
char *tableend;
char *leftuppercorner;
char *rightuppercorner;
char *leftdowncorner;
char *rightdowncorner;
char *leftcross;
char *rightcross;
char *topcross;
char *middlecross;
char *bottomcross;
} Human, HTML, CSF, XML;
#include <stdio.h>
#include <stdlib.h>
#include <orb/orbit.h>
#include "CorbaFS.h"
CorbaFS_FileSystem fs;
int
main (int argc, char *argv[])
{
CORBA_Environment ev;
CORBA_ORB orb;
CorbaFS_Inode inode;
CorbaFS_Buffer *buffer;
CorbaFS_DirEntSeq *dirents;
CorbaFS_dirent *dirent;
CORBA_unsigned_short mode;
CORBA_unsigned_long uid;
CORBA_unsigned_long gid;
CORBA_unsigned_long size;
CORBA_unsigned_long inodeNum;
CORBA_unsigned_short numLinks;
CORBA_long atime;
CORBA_long mtime;
CORBA_long ctime;
int i;
int niters = 10;
CORBA_exception_init(&ev);
orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
if(argc < 2)
{
printf("Need a binding ID thing as argv[1]\n");
return 1;
}
fs = CORBA_ORB_string_to_object(orb, argv[1], &ev);
if (!fs) {
printf("Cannot bind to %s\n", argv[1]);
return 1;
}
if (argc >= 3)
inode = CorbaFS_FileSystem_getInode(fs, argv[2], &ev);
else
inode = CorbaFS_FileSystem_getInode(fs, "/proc/cpuinfo", &ev);
if (!inode)
{
printf("Cannot get inode\n");
}
CorbaFS_Inode_getStatus(inode,
&mode,
&uid,
&gid,
&size,
&inodeNum,
&numLinks,
&atime,
&mtime,
&ctime,
&ev);
printf("inode = %x\n", inode);
CorbaFS_Inode_readpage(inode, &buffer, 100000, 100, &ev);
printf("readpage got %d bytes\n", buffer->_length);
printf("readpage returned : %s\n", buffer->_buffer);
if (argc >= 3)
dirents = CorbaFS_FileSystem_readdir(fs, argv[2], &ev);
else
dirents = CorbaFS_FileSystem_readdir(fs, "/", &ev);
dirent = dirents->_buffer;
for (i = 0; i < dirents->_length; i++)
{
printf("%d = %s\n", dirent->inode, dirent->name);
dirent++;
}
CORBA_Object_release(fs, &ev);
CORBA_Object_release((CORBA_Object)orb, &ev);
return 0;
}
#!/bin/sh
mountpoint=$*
if [#($mountpoint) -eq "0"];
then
exit;
fi
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 /* gcc: Class implementation */
#endif
#include <my_global.h>
#include <my_sys.h>
#include "cache_manager.h"
/*
cache_manager.cc
-----------------------------------------------------------------------
The cache_manager class manages a number of blocks (which are allocatable
units of memory).
-----------------------------------------------------------------------
*/
#define HEADER_LENGTH ALIGN_SIZE(8)
#define SUFFIX_LENGTH 4
#define ALLOC_MASK 0x3FFFFFFFL
#define FREE_BIT (1L << 31)
#define LOCK_BIT (1L << 30)
#define SMALLEST_BLOCK 32
/*
** Internal Methods
** --------------------
*/
/* list manipulation methods */
void *cache_manager::init_list(void)
{
return;
}
void *cache_manager::link_into_abs(void *ptr)
{
for (int i(0); (*abs_list)[i] != NULL; i++);
(*abs_list)[i] = ptr;
return (abs_list)[i]; // ???
}
bool *cache_manager::unlink_from_abs(void *ptr)
{
(*ptr) = NULL;
return;
}
/* memory allocation methods */
void *cache_manager::find_in_llist(uint)
{
return;
}
void cache_manager::defrag(void)
{
printf("Defragging: ..........");
return;
}
/*
** Public Methods
** ------------------
*/
cache_manager::cache_manager(uint size)
{
base_ptr = my_malloc(size, MY_WME); /* MY_WME = write mesg on err */
return;
}
cache_manager::~cache_manager(void)
{
free(base_ptr);
delete base_ptr;
return;
}
void *cache_manager::alloc(uint size)
{
void *llist;
void *abs_ptr;
size=ALIGN_SIZE(size+HEADER_LENGTH+SUFFIX_LENGTH);
if (!(llist = find_in_llist(size)))
{
//defrag();
if (!(llist = find_in_llist(size)))
return 0; /* return null pointer, buffer exhausted! */
}
size_of_found_block=int4korr((char*) llist) & ALLOC_MASK;
// if (size_of_found_block < SMALLEST_BLOCK)
abs_ptr = link_into_abs(llist);
return abs_ptr;
}
void cache_manager::dealloc(void)
{
printf("Deallocating: ..........\n");
return;
}
void cache_manager::clear(void)
{
// reset the internal linked list, forgetting all pointers to mem blks
return;
}
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 interface /* gcc class implementation */
#endif
#ifndef _CACHE_MANAGER_H_
#define _CACHE_MANAGER_H_
#endif
/*
cache_manager.h
-----------------------------------------------------------------------
The cache_manager class manages a number of blocks (which are allocatable
units of memory).
-----------------------------------------------------------------------
*/
class cache_manager {
void **abs_list; /* List holding block abstraction ptrs */
typedef struct free_blks {
struct free_blks *next, **prev;
uint Size;
} FREE_BLKS;
FREE_BLKS *base_ptr; /* Pointer to newly allocated sys mem */
/* list manipulation methods */
void *link_into_abs(void *); /* Return an abstract pointer to blk */
bool *unlink_from_abs(void *); /* Used to dealloc a blk */
void *find_in_fblist(uint); /* */
/* memory allocation methods */
void defrag(void); /* Defragment the cache */
bool *init_blk(void *); /* Return a pointer to new list */
public:
cache_manager(uint); /* Get allocation of size from system */
~cache_manager(void); /* Destructor; return the cache */
void *alloc(uint); /* Alloc size bytes from the cache */
bool *dealloc(void *); /* Deallocate blocks (with *ptr_arg) */
void clear(void); /* Clear the cache */
};
......@@ -1457,11 +1457,13 @@ String *Item_func_user::val_str(String *str)
{
THD *thd=current_thd;
CHARSET_INFO *cs= default_charset();
const char *host=thd->host ? thd->host : thd->ip ? thd->ip : "";
const char *host= thd->host_or_ip;
uint res_length;
// For system threads (e.g. replication SQL thread) user may be empty
if (!thd->user)
return &empty_string;
uint32 res_length=(strlen(thd->user)+strlen(host)+2) * cs->mbmaxlen;
res_length= (strlen(thd->user)+strlen(host)+2) * cs->mbmaxlen;
if (str->alloc(res_length))
{
......
......@@ -1404,9 +1404,10 @@ static int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2)
GROUP_CONCAT(DISTINCT expr,... ORDER BY col,... )
*/
static int group_concat_key_cmp_with_distinct_and_order(void* arg, byte* key1, byte* key2)
static int group_concat_key_cmp_with_distinct_and_order(void* arg,
byte* key1,
byte* key2)
{
Item_func_group_concat* item= (Item_func_group_concat*)arg;
if (!group_concat_key_cmp_with_distinct(arg,key1,key2))
return 0;
return(group_concat_key_cmp_with_order(arg,key1,key2));
......@@ -1631,7 +1632,7 @@ void Item_func_group_concat::reset_field()
bool
Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
int i; /* for loop variable */
uint i; /* for loop variable */
if (!thd->allow_sum_func)
{
......@@ -1641,11 +1642,11 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
thd->allow_sum_func= 0;
maybe_null= 0;
for (uint ui= 0 ; ui < arg_count ; ui++)
for (i= 0 ; i < arg_count ; i++)
{
if (args[ui]->fix_fields(thd, tables, args + ui) || args[ui]->check_cols(1))
if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1))
return 1;
maybe_null |= args[ui]->maybe_null;
maybe_null |= args[i]->maybe_null;
}
for (i= 0 ; i < arg_count_field ; i++)
{
......
......@@ -26,6 +26,8 @@ EXTRA_DIST = auto_increment.res auto_increment.tst \
pmail.pl mail_to_db.pl table_types.pl \
udf_test udf_test.res myisam-big-rows.tst
noinst_PROGRAMS = insert_test select_test thread_test
#
# C Test for 4.1 protocol
#
......@@ -36,6 +38,11 @@ noinst_PROGRAMS = client_test
client_test_LDADD= $(LDADD) $(CXXLDFLAGS)
client_test_SOURCES= client_test.c
client_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
thread_test.o: thread_test.c
$(COMPILE) -c @MT_INCLUDES@ $(INCLUDES) $<
# Don't update the files from bitkeeper
%::SCCS/s.%
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment