From eb7515366b050a0fceed63e27e89e89c95483242 Mon Sep 17 00:00:00 2001 From: "wax@kishkin.ru" <> Date: Thu, 16 Sep 2004 00:47:45 +0600 Subject: [PATCH 001/101] WL#964 porting mysql_test_run on Linux and Windows --- client/mysqltest.c | 36 +- mysql-test/Makefile.am | 5 + mysql-test/my_manage.c | 860 ++++++++++++ mysql-test/my_manage.h | 135 ++ mysql-test/mysql_test_run.c | 1728 +++++++++++++++++++++++++ mysql-test/r/fulltext.result | 6 +- mysql-test/r/fulltext_cache.result | 36 +- mysql-test/r/fulltext_multi.result | 30 +- mysql-test/r/fulltext_order_by.result | 54 +- mysql-test/r/type_float.result | 4 +- mysql-test/t/fulltext.test | 2 +- mysql-test/t/fulltext_cache.test | 4 +- mysql-test/t/fulltext_multi.test | 6 +- mysql-test/t/fulltext_order_by.test | 12 +- mysql-test/t/innodb.test | 1 + mysql-test/t/insert.test | 11 + mysql-test/t/type_float.test | 3 + mysql-test/t/variables.test | 1 + 18 files changed, 2842 insertions(+), 92 deletions(-) create mode 100644 mysql-test/my_manage.c create mode 100644 mysql-test/my_manage.h create mode 100644 mysql-test/mysql_test_run.c diff --git a/client/mysqltest.c b/client/mysqltest.c index f638053b515..a42b4698b3c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -180,9 +180,9 @@ typedef struct int alloced; } VAR; -#ifdef __NETWARE__ +#if defined(__NETWARE__) || defined(__WIN__) /* - Netware doesn't proved environment variable substitution that is done + Netware and Windows don't proved environment variable substitution that is done by the shell in unix environments. We do this in the following function: */ @@ -479,7 +479,7 @@ static void free_used_memory() free_defaults(default_argv); mysql_server_end(); my_end(MY_CHECK_ERROR); - DBUG_VOID_RETURN; +// DBUG_VOID_RETURN; } static void die(const char* fmt, ...) @@ -885,8 +885,8 @@ int do_exec(struct st_query* q) char buf[1024]; FILE *res_file; char *cmd= q->first_argument; + DBUG_ENTER("do_exec"); - while (*cmd && my_isspace(charset_info, *cmd)) cmd++; if (!*cmd) @@ -935,8 +935,11 @@ int do_exec(struct st_query* q) if (ds == &ds_tmp) dynstr_free(&ds_tmp); } +#ifndef __WIN__ pclose(res_file); - +#else + _pclose(res_file); +#endif DBUG_RETURN(error); } @@ -1517,8 +1520,8 @@ void init_manager() die("Failed in mysql_manager_init()"); if (!mysql_manager_connect(manager,manager_host,manager_user, manager_pass,manager_port)) - die("Could not connect to MySQL manager: %s(%d)",manager->last_error, - manager->last_errno); + die("Could not connect to MySQL manager: %s(%d) %d",manager->last_error, + manager->last_errno, manager_port); } #endif @@ -1575,7 +1578,7 @@ int do_connect(struct st_query* q) if (*con_port_str == '$') { if (!(var_port = var_get(con_port_str, 0, 0, 0))) - die("Unknown variable '%s'", con_port_str+1); + die("Unknown variable '%s'", con_port_str+1); con_port = var_port->int_val; } else @@ -1584,9 +1587,9 @@ int do_connect(struct st_query* q) if (*con_sock == '$') { if (!(var_sock = var_get(con_sock, 0, 0, 0))) - die("Unknown variable '%s'", con_sock+1); + die("Unknown variable '%s'", con_sock+1); if (!(con_sock = (char*)my_malloc(var_sock->str_val_len+1, MYF(0)))) - die("Out of memory"); + die("Out of memory"); free_con_sock = 1; memcpy(con_sock, var_sock->str_val, var_sock->str_val_len); con_sock[var_sock->str_val_len] = 0; @@ -1617,8 +1620,8 @@ int do_connect(struct st_query* q) if ((safe_connect(&next_con->mysql, con_host, con_user, con_pass, con_db, con_port, con_sock ? con_sock: 0))) - die("Could not open connection '%s': %s", con_name, - mysql_error(&next_con->mysql)); + die("Could not open connection '%s': %s %d", con_name, + mysql_error(&next_con->mysql),con_port); if (!(next_con->name = my_strdup(con_name, MYF(MY_WME)))) die(NullS); @@ -3686,8 +3689,7 @@ static void get_replace_column(struct st_query *q) my_free(start, MYF(0)); } -#ifdef __NETWARE__ - +#if defined(__NETWARE__) || defined(__WIN__) /* Substitute environment variables with text. @@ -3778,9 +3780,13 @@ FILE *my_popen(const char *cmd, const char *mode __attribute__((unused))) FILE *res_file; subst_cmd= subst_env_var(cmd); +#ifndef __WIN__ res_file= popen(subst_cmd, "r0"); +#else + res_file= _popen(subst_cmd, "r0"); +#endif my_free(subst_cmd, MYF(0)); return res_file; } -#endif /* __NETWARE__ */ +#endif /* __NETWARE__ or __WIN__*/ diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 6ec8c293a9c..1f57dedc4c5 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -29,6 +29,11 @@ test_SCRIPTS = mysql-test-run install_test_db test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem CLEANFILES = $(test_SCRIPTS) $(test_DATA) +INCLUDES = -I$(srcdir)/../include -I../include -I.. +bin_PROGRAMS = mysql_test_run +mysql_test_run_SOURCES= mysql_test_run.c my_manage.c + + dist-hook: mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \ $(distdir)/std_data diff --git a/mysql-test/my_manage.c b/mysql-test/my_manage.c new file mode 100644 index 00000000000..e23d4f2227e --- /dev/null +++ b/mysql-test/my_manage.c @@ -0,0 +1,860 @@ +/* + Copyright (c) 2003 Novell, Inc. All Rights Reserved. + + 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 +#include +#ifndef __WIN__ +#include +#endif +#include +#ifdef __NETWARE__ +#include +#include +#else +#include +#ifndef __WIN__ +#include +#include +#else +#include +#include +#include +#endif +#endif +#include +#include +#include +#include + +#include "my_manage.h" + +#ifndef __NETWARE__ +#define ASSERT assert +extern char **environ; +#endif + + + +/****************************************************************************** + + macros + +******************************************************************************/ + +/****************************************************************************** + + global variables + +******************************************************************************/ + +/****************************************************************************** + + functions + +******************************************************************************/ + +/****************************************************************************** + + init_args() + + Init an argument list. + +******************************************************************************/ +void init_args(arg_list_t *al) +{ + ASSERT(al != NULL); + + al->argc = 0; + al->size = ARG_BUF; + al->argv = malloc(al->size * sizeof(char *)); + ASSERT(al->argv != NULL); + + return; +} + +/****************************************************************************** + + add_arg() + + Add an argument to a list. + +******************************************************************************/ +void add_arg(arg_list_t *al, const char *format, ...) +{ + va_list ap; + char temp[PATH_MAX]; + + ASSERT(al != NULL); + + // increase size + if (al->argc >= (int)al->size) + { + al->size += ARG_BUF; + al->argv = realloc(al->argv, al->size * sizeof(char *)); + ASSERT(al->argv != NULL); + } + + if (format) + { + va_start(ap, format); + vsprintf(temp, format, ap); + va_end(ap); + + al->argv[al->argc] = malloc(strlen(temp)+1); + ASSERT(al->argv[al->argc] != NULL); + strcpy(al->argv[al->argc], temp); + + ++(al->argc); + } + else + { + al->argv[al->argc] = NULL; + } + + return; +} + +/****************************************************************************** + + free_args() + + Free an argument list. + +******************************************************************************/ +void free_args(arg_list_t *al) +{ + int i; + + ASSERT(al != NULL); + + for(i = 0; i < al->argc; i++) + { + ASSERT(al->argv[i] != NULL); + free(al->argv[i]); + al->argv[i] = NULL; + } + + free(al->argv); + al->argc = 0; + al->argv = NULL; + + return; +} + +/****************************************************************************** + + sleep_until_file_deleted() + + Sleep until the given file is no longer found. + +******************************************************************************/ +#ifndef __WIN__ +int sleep_until_file_deleted(char *pid_file) +#else +int sleep_until_file_deleted(HANDLE pid_file) +#endif +{ + int err; +#ifndef __WIN__ + struct stat buf; + int i; + + for(i = 0; (i < TRY_MAX) && (err = !stat(pid_file, &buf)); i++) sleep(1); + + if (err != 0) err = errno; +#else + err= (WaitForSingleObject(pid_file, TRY_MAX*1000) == WAIT_TIMEOUT); +#endif + return err; +} + +/****************************************************************************** + + sleep_until_file_exists() + + Sleep until the given file exists. + +******************************************************************************/ +#ifndef __WIN__ +int sleep_until_file_exists(char *pid_file) +#else +int sleep_until_file_exists(HANDLE pid_file) +#endif +{ + int err; +#ifndef __WIN__ + struct stat buf; + int i; + + for(i = 0; (i < TRY_MAX) && (err = stat(pid_file, &buf)); i++) sleep(1); + + if (err != 0) err = errno; +#else + err= (WaitForSingleObject(pid_file, TRY_MAX*1000) == WAIT_TIMEOUT); +#endif + return err; +} + +/****************************************************************************** + + wait_for_server_start() + + Wait for the server on the given port to start. + +******************************************************************************/ +int wait_for_server_start(char *bin_dir, char *mysqladmin_file, char *user, char *password, int port,char *tmp_dir) +{ + arg_list_t al; + int err, i; + char trash[PATH_MAX]; + + // mysqladmin file + snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); + + // args + init_args(&al); + add_arg(&al, "%s", mysqladmin_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--port=%u", port); + add_arg(&al, "--user=%s", user); + add_arg(&al, "--password=%s", password); + add_arg(&al, "--silent"); + +//#ifdef NOT_USED +#ifndef __NETWARE__ + add_arg(&al, "-O"); + add_arg(&al, "connect_timeout=10"); + add_arg(&al, "-w"); +#endif + + add_arg(&al, "--host=localhost"); +#ifndef __NETWARE__ + add_arg(&al, "--protocol=tcp"); +#endif + add_arg(&al, "ping"); + + // NetWare does not support the connect timeout in the TCP/IP stack + // -- we will try the ping multiple times +#ifndef __WIN__ + for(i = 0; (i < TRY_MAX) + && (err = spawn(mysqladmin_file, &al, TRUE, NULL, + trash, NULL, NULL)); i++) sleep(1); +#else + err = spawn(mysqladmin_file, &al, TRUE, NULL,trash, NULL, NULL); +#endif + + // free args + free_args(&al); + + return err; +} + +/****************************************************************************** + + spawn() + + Spawn the given path with the given arguments. + +******************************************************************************/ +#ifdef __NETWARE__ +int spawn(char *path, arg_list_t *al, int join, char *input, + char *output, char *error, char *pid_file) +{ + pid_t pid; + int result = 0; + wiring_t wiring = { FD_UNUSED, FD_UNUSED, FD_UNUSED }; + unsigned long flags = PROC_CURRENT_SPACE | PROC_INHERIT_CWD; + + // open wiring + if (input) + wiring.infd = open(input, O_RDONLY); + + if (output) + wiring.outfd = open(output, O_WRONLY | O_CREAT | O_TRUNC); + + if (error) + wiring.errfd = open(error, O_WRONLY | O_CREAT | O_TRUNC); + + // procve requires a NULL + add_arg(al, NULL); + + // go + pid = procve(path, flags, NULL, &wiring, NULL, NULL, 0, + NULL, (const char **)al->argv); + + // close wiring + if (wiring.infd != -1) + close(wiring.infd); + + if (wiring.outfd != -1) + close(wiring.outfd); + + if (wiring.errfd != -1) + close(wiring.errfd); + + return result; +} +#elif __WIN__ + +int spawn(char *path, arg_list_t *al, int join, char *input, + char *output, char *error, HANDLE *pid) +{ + intptr_t result; + int i; + STARTUPINFO startup_info; + PROCESS_INFORMATION process_information; + DWORD exit_code; + char win_args[1024]= ""; + char command_line[1024]= ""; + + /* + Skip the first parameter + */ + for(i = 1; i < al->argc; i++) + { + ASSERT(al->argv[i] != NULL); + strcat(win_args,al->argv[i]); + strcat(win_args," "); + } + + memset(&startup_info,0,sizeof(STARTUPINFO)); + startup_info.cb = sizeof(STARTUPINFO); + + if (input) + freopen(input, "rb", stdin); + + if (output) + freopen(output, "wb", stdout); + + if (error) + freopen(error, "wb", stderr); + + result= CreateProcess( + path, + (LPSTR)&win_args, + NULL, + NULL, + TRUE, + 0, + NULL, + NULL, + &startup_info, + &process_information + ); + + if (result && process_information.hProcess) + { + if (join) + { + if (WaitForSingleObject(process_information.hProcess, mysqld_timeout) == WAIT_TIMEOUT) + { + exit_code= -1; + } + else + { + GetExitCodeProcess(process_information.hProcess, &exit_code); + } + CloseHandle(process_information.hProcess); + } + else + { + exit_code= 0; + } + if (pid != NULL) + *pid= process_information.hProcess; + } + else + { + exit_code= -1; + } + if (input) + freopen("CONIN$","rb",stdin); + if (output) + freopen("CONOUT$","wb",stdout); + if (error) + freopen("CONOUT$","wb",stderr); + + return exit_code; +} +#else +int spawn(char *path, arg_list_t *al, int join, char *input, + char *output, char *error, char *pid_file) +{ + pid_t pid; + int res_exec = 0; + int result = 0; + + pid = fork(); + + if (pid == -1) + { + fprintf(stderr, "fork was't created\n"); + /* + We can't create the fork...exit with error + */ + return EXIT_FAILURE; + } + + if (pid > 0) + { + /* + The parent process is waiting for child process if join is not zero + */ + if (join) + { + waitpid(pid, &result, 0); + if (WIFEXITED(result) != 0) + { + result = WEXITSTATUS(result); + } + else + { + result = EXIT_FAILURE; + } + } + } + else + { + + /* + Child process + */ + + add_arg(al, NULL); + + + /* + Reassign streams + */ + if (input) + freopen(input, "r", stdin); + + + if (output) + freopen(output, "w", stdout); + + + if (error) + freopen(error, "w", stderr); + + /* Spawn the process */ + if ((res_exec = execve(path, al->argv, environ)) < 0) + { + exit(EXIT_FAILURE); + } + + /* + Restore streams + */ + if (input) + freopen("/dev/tty", "r", stdin); + + if (output) + freopen("/dev/tty", "w", stdout); + + if (error) + freopen("/dev/tty", "w", stderr); + + exit(0); + } + + return result; +} +#endif +/****************************************************************************** + + stop_server() + + Stop the server with the given port and pid file. + +******************************************************************************/ +#ifndef __WIN__ +int stop_server(char *bin_dir, char *mysqladmin_file, char *user, char *password, int port, + char *pid_file,char *tmp_dir) +#else +int stop_server(char *bin_dir, char *mysqladmin_file, char *user, char *password, int port, + HANDLE pid_file,char *tmp_dir) +#endif +{ + arg_list_t al; + int err = 0; + char trash[PATH_MAX]; + + snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); + + // args + init_args(&al); + add_arg(&al, "%s", mysqladmin_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--port=%u", port); + add_arg(&al, "--user=%s", user); + add_arg(&al, "--password=%s", password); + add_arg(&al, "-O"); + add_arg(&al, "shutdown_timeout=20"); +#ifndef __NETWARE__ + add_arg(&al, "--protocol=tcp"); +#endif + add_arg(&al, "shutdown"); + + // spawn + if ((err = spawn(mysqladmin_file, &al, TRUE, NULL, + trash, NULL, NULL)) == 0) + { + sleep_until_file_deleted(pid_file); + } + else + { +#ifndef __WIN__ + pid_t pid = get_server_pid(pid_file); + + // shutdown failed - kill server + kill_server(pid); + + sleep(TRY_MAX); + + // remove pid file if possible + err = remove(pid_file); +#else + TerminateProcess(pid_file,err); +#endif + } + + // free args + free_args(&al); + + return err; +} + +/****************************************************************************** + + get_server_pid() + + Get the VM id with the given pid file. + +******************************************************************************/ +#ifndef __WIN__ +pid_t get_server_pid(char *pid_file) +{ + char buf[PATH_MAX]; + int fd, err; + char *p; + pid_t id = 0; + + // discover id + fd = open(pid_file, O_RDONLY); + + err = read(fd, buf, PATH_MAX); + + close(fd); + + if (err > 0) + { + // terminate string + if ((p = strchr(buf, '\n')) != NULL) + { + *p = '\0'; + + // check for a '\r' + if ((p = strchr(buf, '\r')) != NULL) + { + *p = '\0'; + } + } + else + { + buf[err] = '\0'; + } + + id = strtol(buf, NULL, 0); + } + + return id; +} + +/****************************************************************************** + + kill_server() + + Force a kill of the server with the given pid. + +******************************************************************************/ +void kill_server(pid_t pid) +{ + if (pid > 0) + { +#if !defined(__NETWARE__) + /* Send SIGTERM to pid */ + kill(pid, SIGTERM); +#else /* __NETWARE__ */ + /* destroy vm */ + NXVmDestroy(pid); +#endif + } +} +#endif +/****************************************************************************** + + del_tree() + + Delete the directory and subdirectories. + +******************************************************************************/ +void del_tree(char *dir) +{ +#ifndef __WIN__ + DIR *parent = opendir(dir); + struct dirent *entry; + char temp[PATH_MAX]; + + if (parent == NULL) + { + return; + } + + while((entry = readdir(parent)) != NULL) + { + // create long name + snprintf(temp, PATH_MAX, "%s/%s", dir, entry->d_name); + + if (entry->d_name[0] == '.') + { + // Skip + } + else + if (S_ISDIR(entry->d_type)) + { + // delete subdirectory + del_tree(temp); + } + else + { + // remove file + remove(temp); + } + } + // remove directory + rmdir(dir); +#else + struct _finddata_t parent; + intptr_t handle; + char temp[PATH_MAX]; + char mask[PATH_MAX]; + + snprintf(mask,MAX_PATH,"%s/*.*",dir); + + if ((handle=_findfirst(mask,&parent)) == -1L) + { + return; + } + + do + { + // create long name + snprintf(temp, PATH_MAX, "%s/%s", dir, parent.name); + if (parent.name[0] == '.') + { + // Skip + } + else + if (parent.attrib & _A_SUBDIR) + { + // delete subdirectory + del_tree(temp); + } + else + { + // remove file + remove(temp); + } + } while (_findnext(handle,&parent) == 0); + + _findclose(handle); + + // remove directory + _rmdir(dir); +#endif +} + +/****************************************************************************** + + removef() + +******************************************************************************/ +int removef(const char *format, ...) +{ +#ifdef __NETWARE__ + va_list ap; + char path[PATH_MAX]; + + va_start(ap, format); + + vsnprintf(path, PATH_MAX, format, ap); + + va_end(ap); + return remove(path); + +#eldef __WIN__ + { + va_list ap; + char path[PATH_MAX]; + struct _finddata_t parent; + intptr_t handle; + char temp[PATH_MAX]; + char *p; + + va_start(ap, format); + + vsnprintf(path, PATH_MAX, format, ap); + + va_end(ap); + + p = path + strlen(path); + while (*p != '\\' && *p != '/' && p > path) p--; + + if ((handle=_findfirst(path,&parent)) == -1L) + { + /* + if there is not files....it's ok. + */ + return 0; + } + + *p = '\0'; + + do + { + if (! (parent.attrib & _A_SUBDIR)) + { + snprintf(temp, PATH_MAX, "%s/%s", path, parent.name); + remove(temp); + } + }while (_findnext(handle,&parent) == 0); + + _findclose(handle); + } +#else + DIR *parent; + struct dirent *entry; + char temp[PATH_MAX]; + va_list ap; + char path[PATH_MAX]; + char *p; + /* + Get path with mask + */ + va_start(ap, format); + + vsnprintf(path, PATH_MAX, format, ap); + + va_end(ap); + + p = path + strlen(path); + while (*p != '\\' && *p != '/' && p > path) p--; + *p = '\0'; + p++; + + parent = opendir(path); + + if (parent == NULL) + { + return; + } + + while((entry = readdir(parent)) != NULL) + { + /* + entry is not directory and entry matches with mask + */ + if (!S_ISDIR(entry->d_type) && !fnmatch(p, entry->d_name,0)) + { + // create long name + snprintf(temp, PATH_MAX, "%s/%s", path, entry->d_name); + // Delete only files + remove(temp); + } + } +#endif + return 0; +} + +/****************************************************************************** + + get_basedir() + +******************************************************************************/ +void get_basedir(char *argv0, char *basedir) +{ + char temp[PATH_MAX]; + char *p; + int position; + + ASSERT(argv0 != NULL); + ASSERT(basedir != NULL); + + strcpy(temp, strlwr(argv0)); + while((p = strchr(temp, '\\')) != NULL) *p = '/'; + + if ((position = strinstr(temp, "/bin/")) != 0) + { + p = temp + position; + *p = '\0'; + strcpy(basedir, temp); + } +} + +#if !defined(__NETWARE__) && !defined(__WIN__) +char *strlwr(const char *s) +{ + return s; +} +#endif + +uint strinstr(reg1 const char *str,reg4 const char *search) +{ + reg2 my_string i,j; + my_string start = (my_string) str; + + skipp: + while (*str != '\0') + { + if (*str++ == *search) + { + i=(my_string) str; j= (my_string) search+1; + while (*j) + if (*i++ != *j++) goto skipp; + return ((uint) (str - start)); + } + } + return (0); +} + +/****************************************************************************** + + remove_empty_file() + +******************************************************************************/ +void remove_empty_file(const char *file_name) +{ + struct stat file; + + if (!stat(file_name,&file)) + { + if (!file.st_size) + remove(file_name); + } +} diff --git a/mysql-test/my_manage.h b/mysql-test/my_manage.h new file mode 100644 index 00000000000..56ba7ce0496 --- /dev/null +++ b/mysql-test/my_manage.h @@ -0,0 +1,135 @@ +/* + Copyright (c) 2002 Novell, Inc. All Rights Reserved. + + 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 +*/ + +#ifndef _MY_MANAGE +#define _MY_MANAGE + +/****************************************************************************** + + includes + +******************************************************************************/ + +#include +#ifndef __WIN__ +#include +#endif +#ifndef __NETWARE__ +#include +#include +#include + +#ifndef __WIN__ +#define strnicmp strncasecmp +char *strlwr(const char *s); +#else +int my_vsnprintf_(char *to, size_t n, const char* value, ...); +#endif +#endif + +/****************************************************************************** + + macros + +******************************************************************************/ + +#define ARG_BUF 10 +#define TRY_MAX 5 + +#ifdef __WIN__ +#define PATH_MAX _MAX_PATH +#define NAME_MAX _MAX_FNAME +#define kill(A,B) TerminateProcess((HANDLE)A,0) +#define NOT_NEED_PID 0 +#define MASTER_PID 1 +#define SLAVE_PID 2 +#define mysqld_timeout 60000 + +int pid_mode; +bool run_server; +bool skip_first_param; + +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#endif + + +/****************************************************************************** + + structures + +******************************************************************************/ + +typedef struct +{ + + int argc; + char **argv; + + size_t size; + +} arg_list_t; + +#ifdef __WIN__ +typedef int pid_t; +#endif +/****************************************************************************** + + global variables + +******************************************************************************/ + +/****************************************************************************** + + prototypes + +******************************************************************************/ + +void init_args(arg_list_t *); +void add_arg(arg_list_t *, const char *, ...); +void free_args(arg_list_t *); + +#ifndef __WIN__ +int sleep_until_file_exists(char *); +int sleep_until_file_deleted(char *); +#else +int sleep_until_file_exists(HANDLE); +int sleep_until_file_deleted(HANDLE); +#endif +int wait_for_server_start(char *, char *, char *, char *, int,char *); + +#ifndef __WIN__ +int spawn(char *, arg_list_t *, int, char *, char *, char *, char *); +#else +int spawn(char *, arg_list_t *, int , char *, char *, char *, HANDLE *); +#endif + +#ifndef __WIN__ +int stop_server(char *, char *, char *, char *, int, char *,char *); +pid_t get_server_pid(char *); +void kill_server(pid_t pid); +#else +int stop_server(char *, char *, char *, char *, int, HANDLE,char *); +#endif +void del_tree(char *); +int removef(const char *, ...); + +void get_basedir(char *, char *); +void remove_empty_file(const char *file_name); + +#endif /* _MY_MANAGE */ diff --git a/mysql-test/mysql_test_run.c b/mysql-test/mysql_test_run.c new file mode 100644 index 00000000000..6f388fc4a45 --- /dev/null +++ b/mysql-test/mysql_test_run.c @@ -0,0 +1,1728 @@ +/* + Copyright (c) 2002, 2003 Novell, Inc. All Rights Reserved. + + 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 +#include +#include +#ifndef __WIN__ +#include +#endif +#include +#ifdef __NETWARE__ +#include +#include +#endif +#include +#include +#ifndef __WIN__ +#include +#endif +#include +#ifdef __NETWARE__ +#include +#endif +#ifdef __WIN__ +#include +#include +#endif + +#include "my_manage.h" + +/****************************************************************************** + + macros + +******************************************************************************/ + +#define HEADER "TEST RESULT \n" +#define DASH "-------------------------------------------------------\n" + +#define NW_TEST_SUFFIX ".nw-test" +#define NW_RESULT_SUFFIX ".nw-result" +#define TEST_SUFFIX ".test" +#define RESULT_SUFFIX ".result" +#define REJECT_SUFFIX ".reject" +#define OUT_SUFFIX ".out" +#define ERR_SUFFIX ".err" + +const char *TEST_PASS = "[ pass ]"; +const char *TEST_SKIP = "[ skip ]"; +const char *TEST_FAIL = "[ fail ]"; +const char *TEST_BAD = "[ bad ]"; +const char *TEST_IGNORE = "[ignore]"; + +/****************************************************************************** + + global variables + +******************************************************************************/ +#ifdef __NETWARE__ +static char base_dir[PATH_MAX] = "sys:/mysql"; +#else +static char base_dir[PATH_MAX] = ".."; +#endif +static char db[PATH_MAX] = "test"; +static char user[PATH_MAX] = "root"; +static char password[PATH_MAX] = ""; + +int master_port = 9306; +int slave_port = 9307; + +#if !defined(__NETWARE__) && !defined(__WIN__) +static char master_socket[PATH_MAX] = "./var/tmp/master.sock"; +static char slave_socket[PATH_MAX] = "./var/tmp/slave.sock"; +#endif + +// comma delimited list of tests to skip or empty string +#ifndef __WIN__ +static char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix "; +#else +/* + The most ignore testes contain the calls of system command +*/ +#define MAX_COUNT_TESTES 1024 +/* + lowercase_table3 is disabled by Gerg + system_mysql_db_fix is disabled by Gerg + sp contains a command system + rpl_EE_error contains a command system + rpl_loaddatalocal contains a command system + ndb_autodiscover contains a command system + rpl_rotate_logs contains a command system + repair contains a command system + rpl_trunc_binlog contains a command system + mysqldump contains a command system + rpl000001 makes non-exit loop...temporary skiped +*/ +static char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix , sp , rpl_EE_error , rpl_loaddatalocal , ndb_autodiscover , rpl_rotate_logs , repair , rpl_trunc_binlog , mysqldump , rpl000001 "; +#endif +static char ignore_test[PATH_MAX] = ""; + +static char bin_dir[PATH_MAX]; +static char mysql_test_dir[PATH_MAX]; +static char test_dir[PATH_MAX]; +static char mysql_tmp_dir[PATH_MAX]; +static char result_dir[PATH_MAX]; +static char master_dir[PATH_MAX]; +static char slave_dir[PATH_MAX]; +static char lang_dir[PATH_MAX]; +static char char_dir[PATH_MAX]; + +static char mysqladmin_file[PATH_MAX]; +static char mysqld_file[PATH_MAX]; +static char mysqltest_file[PATH_MAX]; +#ifndef __WIN__ +static char master_pid[PATH_MAX]; +static char slave_pid[PATH_MAX]; +static char sh_file[PATH_MAX] = "/bin/sh"; +#else +static HANDLE master_pid; +static HANDLE slave_pid; +#endif + +static char master_opt[PATH_MAX] = ""; +static char slave_opt[PATH_MAX] = ""; + +static char slave_master_info[PATH_MAX] = ""; + +static char master_init_script[PATH_MAX] = ""; +static char slave_init_script[PATH_MAX] = ""; + +// OpenSSL +static char ca_cert[PATH_MAX]; +static char server_cert[PATH_MAX]; +static char server_key[PATH_MAX]; +static char client_cert[PATH_MAX]; +static char client_key[PATH_MAX]; + +int total_skip = 0; +int total_pass = 0; +int total_fail = 0; +int total_test = 0; + +int total_ignore = 0; + +int use_openssl = FALSE; +int master_running = FALSE; +int slave_running = FALSE; +int skip_slave = TRUE; +int single_test = TRUE; + +int restarts = 0; + +FILE *log_fd = NULL; + +/****************************************************************************** + + functions + +******************************************************************************/ + +/****************************************************************************** + + prototypes + +******************************************************************************/ + +void report_stats(); +void install_db(char *); +void mysql_install_db(); +void start_master(); +void start_slave(); +void mysql_start(); +void stop_slave(); +void stop_master(); +void mysql_stop(); +void mysql_restart(); +int read_option(char *, char *); +void run_test(char *); +void setup(char *); +void vlog(const char *, va_list); +void mlog(const char *, ...); +void log_info(const char *, ...); +void log_error(const char *, ...); +void log_errno(const char *, ...); +void die(const char *); +char *str_tok(char *string, const char *delim); +#ifndef __WIN__ +void run_init_script(const char *script_name); +#endif +/****************************************************************************** + + report_stats() + + Report the gathered statistics. + +******************************************************************************/ +void report_stats() +{ + if (total_fail == 0) + { + mlog("\nAll %d test(s) were successful.\n", total_test); + } + else + { + double percent = ((double)total_pass / total_test) * 100; + + mlog("\nFailed %u/%u test(s), %.02f%% successful.\n", + total_fail, total_test, percent); + mlog("\nThe .out and .err files in %s may give you some\n", result_dir); + mlog("hint of what when wrong.\n"); + mlog("\nIf you want to report this error, please first read the documentation\n"); + mlog("at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html\n"); + } +} + +/****************************************************************************** + + install_db() + + Install the a database. + +******************************************************************************/ +void install_db(char *datadir) +{ + arg_list_t al; + int err; + char input[PATH_MAX]; + char output[PATH_MAX]; + char error[PATH_MAX]; + + // input file +#ifdef __NETWARE__ + snprintf(input, PATH_MAX, "%s/bin/init_db.sql", base_dir); +#else + snprintf(input, PATH_MAX, "%s/mysql-test/init_db.sql", base_dir); +#endif + snprintf(output, PATH_MAX, "%s/install.out", datadir); + snprintf(error, PATH_MAX, "%s/install.err", datadir); + + // args + init_args(&al); + add_arg(&al, mysqld_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--bootstrap"); + add_arg(&al, "--skip-grant-tables"); + add_arg(&al, "--basedir=%s", base_dir); + add_arg(&al, "--datadir=%s", datadir); + add_arg(&al, "--skip-innodb"); + add_arg(&al, "--skip-bdb"); +#ifndef __NETWARE__ + add_arg(&al, "--character-sets-dir=%s", char_dir); + add_arg(&al, "--language=%s", lang_dir); +#endif + + // spawn + if ((err = spawn(mysqld_file, &al, TRUE, input, output, error, NULL)) != 0) + { + die("Unable to create database."); + } + + // free args + free_args(&al); +} + +/****************************************************************************** + + mysql_install_db() + + Install the test databases. + +******************************************************************************/ +void mysql_install_db() +{ + char temp[PATH_MAX]; + + // var directory + snprintf(temp, PATH_MAX, "%s/var", mysql_test_dir); + + // clean up old direcotry + del_tree(temp); + + // create var directory +#ifndef __WIN__ + mkdir(temp, S_IRWXU); + // create subdirectories + mlog("Creating test-suite folders...\n"); + snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); + mkdir(temp, S_IRWXU); +#else + mkdir(temp); + // create subdirectories + mlog("Creating test-suite folders...\n"); + snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); + mkdir(temp); +#endif + + // install databases + mlog("Creating test databases for master... \n"); + install_db(master_dir); + mlog("Creating test databases for slave... \n"); + install_db(slave_dir); +} + +/****************************************************************************** + + start_master() + + Start the master server. + +******************************************************************************/ +void start_master() +{ + arg_list_t al; + int err; + char master_out[PATH_MAX]; + char master_err[PATH_MAX]; +// char temp[PATH_MAX]; + char temp2[PATH_MAX]; + + // remove old berkeley db log files that can confuse the server + removef("%s/log.*", master_dir); + + // remove stale binary logs + removef("%s/var/log/*-bin.*", mysql_test_dir); + + // remove stale binary logs + removef("%s/var/log/*.index", mysql_test_dir); + + // remove master.info file + removef("%s/master.info", master_dir); + + // remove relay files + removef("%s/var/log/*relay*", mysql_test_dir); + + // remove relay-log.info file + removef("%s/relay-log.info", master_dir); + + // init script + if (master_init_script[0] != 0) + { +#ifdef __NETWARE__ + // TODO: use the scripts + if (strinstr(master_init_script, "repair_part2-master.sh") != 0) + { + FILE *fp; + + // create an empty index file + snprintf(temp, PATH_MAX, "%s/test/t1.MYI", master_dir); + fp = fopen(temp, "wb+"); + + fputs("1", fp); + + fclose(fp); + } +#elif !defined(__WIN__) + run_init_script(master_init_script); +#endif + } + + // redirection files + snprintf(master_out, PATH_MAX, "%s/var/run/master%u.out", + mysql_test_dir, restarts); + snprintf(master_err, PATH_MAX, "%s/var/run/master%u.err", + mysql_test_dir, restarts); +#ifndef __WIN__ + snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); + mkdir(temp2,S_IRWXU); + snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); + mkdir(temp2,S_IRWXU); +#else + snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); + mkdir(temp2); + snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); + mkdir(temp2); +#endif + // args + init_args(&al); + add_arg(&al, "%s", mysqld_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--log-bin=%s/var/log/master-bin",mysql_test_dir); + add_arg(&al, "--server-id=1"); + add_arg(&al, "--basedir=%s", base_dir); + add_arg(&al, "--port=%u", master_port); +#if !defined(__NETWARE__) && !defined(__WIN__) + add_arg(&al, "--socket=%s",master_socket); +#endif + add_arg(&al, "--local-infile"); + add_arg(&al, "--core"); + add_arg(&al, "--datadir=%s", master_dir); +#ifndef __WIN__ + add_arg(&al, "--pid-file=%s", master_pid); +#endif + add_arg(&al, "--character-sets-dir=%s", char_dir); + add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); + add_arg(&al, "--language=%s", lang_dir); +#ifdef DEBUG //only for debug builds + add_arg(&al, "--debug"); +#endif + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", server_cert); + add_arg(&al, "--ssl-key=%s", server_key); + } + + // $MASTER_40_ARGS + add_arg(&al, "--rpl-recovery-rank=1"); + add_arg(&al, "--init-rpl-role=master"); + + // $SMALL_SERVER + add_arg(&al, "-O"); + add_arg(&al, "key_buffer_size=1M"); + add_arg(&al, "-O"); + add_arg(&al, "sort_buffer=256K"); + add_arg(&al, "-O"); + add_arg(&al, "max_heap_table_size=1M"); + + // $EXTRA_MASTER_OPT + if (master_opt[0] != 0) + { + char *p; + + p = (char *)str_tok(master_opt, " \t"); + if (!strstr(master_opt, "timezone")) + { + while (p) + { + add_arg(&al, "%s", p); + p = (char *)str_tok(NULL, " \t"); + } + } + } + + // remove the pid file if it exists +#ifndef __WIN__ + remove(master_pid); +#endif + + // spawn +#ifdef __WIN__ + if ((err= spawn(mysqld_file, &al, FALSE, NULL, master_out, master_err, &master_pid)) == 0) +#else + if ((err= spawn(mysqld_file, &al, FALSE, NULL, master_out, master_err, master_pid)) == 0) +#endif + { + sleep_until_file_exists(master_pid); + + if ((err = wait_for_server_start(bin_dir, mysqladmin_file, user, password, master_port, + mysql_tmp_dir)) == 0) + { + master_running = TRUE; + } + else + { + log_error("The master server went down early."); + } + } + else + { + log_error("Unable to start master server."); + } + + // free_args + free_args(&al); +} + +/****************************************************************************** + + start_slave() + + Start the slave server. + +******************************************************************************/ +void start_slave() +{ + arg_list_t al; + int err; + char slave_out[PATH_MAX]; + char slave_err[PATH_MAX]; + + // skip? + if (skip_slave) return; + + // remove stale binary logs + removef("%s/*-bin.*", slave_dir); + + // remove stale binary logs + removef("%s/*.index", slave_dir); + + // remove master.info file + removef("%s/master.info", slave_dir); + + // remove relay files + removef("%s/var/log/*relay*", mysql_test_dir); + + // remove relay-log.info file + removef("%s/relay-log.info", slave_dir); + + // init script + if (slave_init_script[0] != 0) + { +#ifdef __NETWARE__ + // TODO: use the scripts + if (strinstr(slave_init_script, "rpl000016-slave.sh") != 0) + { + // create empty master.info file + snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); + close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); + } + else if (strinstr(slave_init_script, "rpl000017-slave.sh") != 0) + { + FILE *fp; + + // create a master.info file + snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); + fp = fopen(temp, "wb+"); + + fputs("master-bin.000001\n", fp); + fputs("4\n", fp); + fputs("127.0.0.1\n", fp); + fputs("replicate\n", fp); + fputs("aaaaaaaaaaaaaaab\n", fp); + fputs("9306\n", fp); + fputs("1\n", fp); + fputs("0\n", fp); + + fclose(fp); + } + else if (strinstr(slave_init_script, "rpl_rotate_logs-slave.sh") != 0) + { + // create empty master.info file + snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); + close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); + } +#elif !defined(__WIN__) + run_init_script(slave_init_script); +#endif + } + + // redirection files + snprintf(slave_out, PATH_MAX, "%s/var/run/slave%u.out", + mysql_test_dir, restarts); + snprintf(slave_err, PATH_MAX, "%s/var/run/slave%u.err", + mysql_test_dir, restarts); + + // args + init_args(&al); + add_arg(&al, "%s", mysqld_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--log-bin=slave-bin"); + add_arg(&al, "--relay_log=slave-relay-bin"); + add_arg(&al, "--basedir=%s", base_dir); + add_arg(&al, "--port=%u", slave_port); +#if !defined(__NETWARE__) && !defined(__WIN__) + add_arg(&al, "--socket=%s",slave_socket); +#endif + add_arg(&al, "--datadir=%s", slave_dir); +#ifndef __WIN__ + add_arg(&al, "--pid-file=%s", slave_pid); +#endif + add_arg(&al, "--character-sets-dir=%s", char_dir); + add_arg(&al, "--core"); + add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); + add_arg(&al, "--language=%s", lang_dir); + + add_arg(&al, "--exit-info=256"); + add_arg(&al, "--log-slave-updates"); + add_arg(&al, "--init-rpl-role=slave"); + add_arg(&al, "--skip-innodb"); + add_arg(&al, "--skip-slave-start"); + add_arg(&al, "--slave-load-tmpdir=../../var/tmp"); + + add_arg(&al, "--report-user=%s", user); + add_arg(&al, "--report-host=127.0.0.1"); + add_arg(&al, "--report-port=%u", slave_port); + + add_arg(&al, "--master-retry-count=10"); + add_arg(&al, "-O"); + add_arg(&al, "slave_net_timeout=10"); +#ifdef DEBUG //only for debug builds + add_arg(&al, "--debug"); +#endif + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", server_cert); + add_arg(&al, "--ssl-key=%s", server_key); + } + + // slave master info + if (slave_master_info[0] != 0) + { + char *p; + + p = (char *)str_tok(slave_master_info, " \t"); + + while(p) + { + add_arg(&al, "%s", p); + + p = (char *)str_tok(NULL, " \t"); + } + } + else + { + add_arg(&al, "--master-user=%s", user); + add_arg(&al, "--master-password=%s", password); + add_arg(&al, "--master-host=127.0.0.1"); + add_arg(&al, "--master-port=%u", master_port); + add_arg(&al, "--master-connect-retry=1"); + add_arg(&al, "--server-id=2"); + add_arg(&al, "--rpl-recovery-rank=2"); + } + + // small server + add_arg(&al, "-O"); + add_arg(&al, "key_buffer_size=1M"); + add_arg(&al, "-O"); + add_arg(&al, "sort_buffer=256K"); + add_arg(&al, "-O"); + add_arg(&al, "max_heap_table_size=1M"); + + + // opt args + if (slave_opt[0] != 0) + { + char *p; + + p = (char *)str_tok(slave_opt, " \t"); + + while(p) + { + add_arg(&al, "%s", p); + + p = (char *)str_tok(NULL, " \t"); + } + } + + // remove the pid file if it exists +#ifndef __WIN__ + remove(slave_pid); +#endif + // spawn +#ifdef __WIN__ + if ((err = spawn(mysqld_file, &al, FALSE, NULL, slave_out, slave_err, &slave_pid)) == 0) +#else + if ((err = spawn(mysqld_file, &al, FALSE, NULL, slave_out, slave_err, slave_pid)) == 0) +#endif + { + sleep_until_file_exists(slave_pid); + + if ((err = wait_for_server_start(bin_dir, mysqladmin_file, user, password, slave_port, + mysql_tmp_dir)) == 0) + { + slave_running = TRUE; + } + else + { + log_error("The slave server went down early."); + } + } + else + { + log_error("Unable to start slave server."); + } + + // free args + free_args(&al); +} + +/****************************************************************************** + + mysql_start() + + Start the mysql servers. + +******************************************************************************/ +void mysql_start() +{ +// log_info("Starting the MySQL server(s): %u", ++restarts); + start_master(); + + start_slave(); + + // activate the test screen +#ifdef __NETWARE__ + ActivateScreen(getscreenhandle()); +#endif +} + +/****************************************************************************** + + stop_slave() + + Stop the slave server. + +******************************************************************************/ +void stop_slave() +{ + int err; + + // running? + if (!slave_running) return; + + // stop + if ((err = stop_server(bin_dir, mysqladmin_file, user, password, slave_port, slave_pid, + mysql_tmp_dir)) == 0) + { + slave_running = FALSE; + } + else + { + log_error("Unable to stop slave server."); + } +} + +/****************************************************************************** + + stop_master() + + Stop the master server. + +******************************************************************************/ +void stop_master() +{ + int err; + + // running? + if (!master_running) return; + + if ((err = stop_server(bin_dir, mysqladmin_file, user, password, master_port, master_pid, + mysql_tmp_dir)) == 0) + { + master_running = FALSE; + } + else + { + log_error("Unable to stop master server."); + } +} + +/****************************************************************************** + + mysql_stop() + + Stop the mysql servers. + +******************************************************************************/ +void mysql_stop() +{ + + stop_master(); + + stop_slave(); + + // activate the test screen +#ifdef __NETWARE__ + ActivateScreen(getscreenhandle()); +#endif +} + +/****************************************************************************** + + mysql_restart() + + Restart the mysql servers. + +******************************************************************************/ +void mysql_restart() +{ +// log_info("Restarting the MySQL server(s): %u", ++restarts); + + mysql_stop(); + + mlog(DASH); + + mysql_start(); +} + +/****************************************************************************** + + read_option() + + Read the option file. + +******************************************************************************/ +int read_option(char *opt_file, char *opt) +{ + int fd, err; + char *p; + char buf[PATH_MAX]; + + // copy current option + strncpy(buf, opt, PATH_MAX); + + // open options file + fd = open(opt_file, O_RDONLY); + + err = read(fd, opt, PATH_MAX); + + close(fd); + + if (err > 0) + { + // terminate string + if ((p = strchr(opt, '\n')) != NULL) + { + *p = 0; + + // check for a '\r' + if ((p = strchr(opt, '\r')) != NULL) + { + *p = 0; + } + } + else + { + opt[err] = 0; + } + + // check for $MYSQL_TEST_DIR + if ((p = strstr(opt, "$MYSQL_TEST_DIR")) != NULL) + { + char temp[PATH_MAX]; + + *p = 0; + + strcpy(temp, p + strlen("$MYSQL_TEST_DIR")); + + strcat(opt, mysql_test_dir); + + strcat(opt, temp); + } + // Check for double backslash and replace it with single bakslash + if ((p = strstr(opt, "\\\\")) != NULL) + { + /* bmove is guranteed to work byte by byte */ + bmove(p, p+1, strlen(p+1)); + } + } + else + { + // clear option + *opt = 0; + } + + // compare current option with previous + return strcmp(opt, buf); +} + +/****************************************************************************** + + run_test() + + Run the given test case. + +******************************************************************************/ +void run_test(char *test) +{ + char temp[PATH_MAX]; + const char *rstr; + int skip = FALSE, ignore=FALSE; + int restart = FALSE; + int flag = FALSE; + struct stat info; + + // skip tests in the skip list + snprintf(temp, PATH_MAX, " %s ", test); + skip = (strinstr(skip_test, temp) != 0); + if (skip == FALSE) + ignore = (strinstr(ignore_test, temp) != 0); + + snprintf(master_init_script, PATH_MAX, "%s/%s-master.sh", test_dir, test); + snprintf(slave_init_script, PATH_MAX, "%s/%s-slave.sh", test_dir, test); +#ifdef __WIN__ + if (! stat(master_init_script, &info)) + skip = TRUE; + if (!stat(slave_init_script, &info)) + skip = TRUE; +#endif + if (ignore) + { + // show test + mlog("%-46s ", test); + + // ignore + rstr = TEST_IGNORE; + ++total_ignore; + } + else if (!skip) // skip test? + { + char test_file[PATH_MAX]; + char master_opt_file[PATH_MAX]; + char slave_opt_file[PATH_MAX]; + char slave_master_info_file[PATH_MAX]; + char result_file[PATH_MAX]; + char reject_file[PATH_MAX]; + char out_file[PATH_MAX]; + char err_file[PATH_MAX]; + int err; + arg_list_t al; +#ifdef __WIN__ + /* + Clean test database + */ + removef("%s/test/*.*", master_dir); + removef("%s/test/*.*", slave_dir); + removef("%s/mysqltest/*.*", master_dir); + removef("%s/mysqltest/*.*", slave_dir); + +#endif + // skip slave? + flag = skip_slave; + skip_slave = (strncmp(test, "rpl", 3) != 0); + if (flag != skip_slave) restart = TRUE; + + // create files + snprintf(master_opt_file, PATH_MAX, "%s/%s-master.opt", test_dir, test); + snprintf(slave_opt_file, PATH_MAX, "%s/%s-slave.opt", test_dir, test); + snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", test_dir, test); + snprintf(reject_file, PATH_MAX, "%s/%s%s", result_dir, test, REJECT_SUFFIX); + snprintf(out_file, PATH_MAX, "%s/%s%s", result_dir, test, OUT_SUFFIX); + snprintf(err_file, PATH_MAX, "%s/%s%s", result_dir, test, ERR_SUFFIX); + + // netware specific files + snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, NW_TEST_SUFFIX); + if (stat(test_file, &info)) + { + snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, TEST_SUFFIX); + if (access(test_file,0)) + { + printf("Invalid test name %s, %s file not found\n",test,test_file); + return; + } + } + + snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, NW_RESULT_SUFFIX); + if (stat(result_file, &info)) + { + snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, RESULT_SUFFIX); + } + + // init scripts + if (stat(master_init_script, &info)) + master_init_script[0] = 0; + else + restart = TRUE; + + if (stat(slave_init_script, &info)) + slave_init_script[0] = 0; + else + restart = TRUE; + + // read options + if (read_option(master_opt_file, master_opt)) restart = TRUE; + if (read_option(slave_opt_file, slave_opt)) restart = TRUE; + if (read_option(slave_master_info_file, slave_master_info)) restart = TRUE; + + // cleanup previous run + remove(reject_file); + remove(out_file); + remove(err_file); + + // start or restart? + if (!master_running) mysql_start(); + else if (restart) mysql_restart(); + + // let the system stabalize + sleep(1); + + // show test + mlog("%-46s ", test); + + + // args + init_args(&al); + add_arg(&al, "%s", mysqltest_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--port=%u", master_port); +#if !defined(__NETWARE__) && !defined(__WIN__) + add_arg(&al, "--socket=%s", master_socket); + add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); +#endif + add_arg(&al, "--database=%s", db); + add_arg(&al, "--user=%s", user); + add_arg(&al, "--password=%s", password); + add_arg(&al, "--silent"); + add_arg(&al, "--basedir=%s/", mysql_test_dir); + add_arg(&al, "--host=127.0.0.1"); + add_arg(&al, "-v"); + add_arg(&al, "-R"); + add_arg(&al, "%s", result_file); + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", client_cert); + add_arg(&al, "--ssl-key=%s", client_key); + } + + // spawn + err = spawn(mysqltest_file, &al, TRUE, test_file, out_file, err_file, NULL); + + // free args + free_args(&al); + + remove_empty_file(out_file); + remove_empty_file(err_file); + + if (err == 0) + { + // pass + rstr = TEST_PASS; + ++total_pass; + + // increment total + ++total_test; + } + else if (err == 2) + { + // skip + rstr = TEST_SKIP; + ++total_skip; + } + else if (err == 1) + { + // fail + rstr = TEST_FAIL; + ++total_fail; + + // increment total + ++total_test; + } + else + { + rstr = TEST_BAD; + } + } + else // early skips + { + // show test + mlog("%-46s ", test); + + // skip + rstr = TEST_SKIP; + ++total_skip; + } + + // result + mlog("%-14s\n", rstr); +} + +/****************************************************************************** + + vlog() + + Log the message. + +******************************************************************************/ +void vlog(const char *format, va_list ap) +{ + vfprintf(stdout, format, ap); + fflush(stdout); + + if (log_fd) + { + vfprintf(log_fd, format, ap); + fflush(log_fd); + } +} + +/****************************************************************************** + + log() + + Log the message. + +******************************************************************************/ +void mlog(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + vlog(format, ap); + + va_end(ap); +} + +/****************************************************************************** + + log_info() + + Log the given information. + +******************************************************************************/ +void log_info(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + mlog("-- INFO : "); + vlog(format, ap); + mlog("\n"); + + va_end(ap); +} + +/****************************************************************************** + + log_error() + + Log the given error. + +******************************************************************************/ +void log_error(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + mlog("-- ERROR: "); + vlog(format, ap); + mlog("\n"); + + va_end(ap); +} + +/****************************************************************************** + + log_errno() + + Log the given error and errno. + +******************************************************************************/ +void log_errno(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + mlog("-- ERROR: (%003u) ", errno); + vlog(format, ap); + mlog("\n"); + + va_end(ap); +} + +/****************************************************************************** + + die() + + Exit the application. + +******************************************************************************/ +void die(const char *msg) +{ + log_error(msg); +#ifdef __NETWARE__ + pressanykey(); +#endif + exit(-1); +} + +/****************************************************************************** + + setup() + + Setup the mysql test enviornment. + +******************************************************************************/ +void setup(char *file) +{ + char temp[PATH_MAX]; + char file_path[PATH_MAX*2]; + char *p; + int position; + + // set the timezone for the timestamp test +#ifdef __WIN__ + _putenv( "TZ=GMT-3" ); +#else + setenv("TZ", "GMT-3", TRUE); +#endif + // find base dir +#ifdef __NETWARE__ + strcpy(temp, strlwr(file)); + while((p = strchr(temp, '\\')) != NULL) *p = '/'; +#else + getcwd(temp, PATH_MAX); + position = strlen(temp); + temp[position] = '/'; + temp[position+1] = 0; +#ifdef __WIN__ + while((p = strchr(temp, '\\')) != NULL) *p = '/'; +#endif +#endif + + if ((position = strinstr(temp, "/mysql-test/")) != 0) + { + p = temp + position - 1; + *p = 0; + strcpy(base_dir, temp); + } + + log_info("Currect directory: %s",base_dir); + +#ifdef __NETWARE__ + // setup paths + snprintf(bin_dir, PATH_MAX, "%s/bin", base_dir); + snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); + snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); + snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); + snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); + snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); + snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); + snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); + +#ifdef HAVE_OPENSSL + use_openssl = TRUE; +#endif // HAVE_OPENSSL + + // OpenSSL paths + snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); + snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); + snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); + snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); + snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); + + // setup files + snprintf(mysqld_file, PATH_MAX, "%s/mysqld", bin_dir); + snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); + snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); + snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); + snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); +#elif __WIN__ + // setup paths +#ifdef _DEBUG + snprintf(bin_dir, PATH_MAX, "%s/client_debug", base_dir); +#else + snprintf(bin_dir, PATH_MAX, "%s/client_release", base_dir); +#endif + snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); + snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); + snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); + snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); + snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); + snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); + snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); + +#ifdef HAVE_OPENSSL + use_openssl = TRUE; +#endif // HAVE_OPENSSL + + // OpenSSL paths + snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); + snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); + snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); + snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); + snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); + + // setup files + snprintf(mysqld_file, PATH_MAX, "%s/mysqld.exe", bin_dir); + snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest.exe", bin_dir); + snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin.exe", bin_dir); +#else + // setup paths + snprintf(bin_dir, PATH_MAX, "%s/client", base_dir); + snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); + snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); + snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); + snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); + snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); + snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + snprintf(lang_dir, PATH_MAX, "%s/sql/share/english", base_dir); + snprintf(char_dir, PATH_MAX, "%s/sql/share/charsets", base_dir); + +#ifdef HAVE_OPENSSL + use_openssl = TRUE; +#endif // HAVE_OPENSSL + + // OpenSSL paths + snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); + snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); + snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); + snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); + snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); + + // setup files + snprintf(mysqld_file, PATH_MAX, "%s/sql/mysqld", base_dir); + snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); + snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); + snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); + snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); + + snprintf(master_socket,PATH_MAX, "%s/var/tmp/master.sock", mysql_test_dir); + snprintf(slave_socket,PATH_MAX, "%s/var/tmp/slave.sock", mysql_test_dir); + +#endif + // create log file + snprintf(temp, PATH_MAX, "%s/mysql-test-run.log", mysql_test_dir); + if ((log_fd = fopen(temp, "w+")) == NULL) + { + log_errno("Unable to create log file."); + } + + // prepare skip test list + while((p = strchr(skip_test, ',')) != NULL) *p = ' '; + strcpy(temp, strlwr(skip_test)); + snprintf(skip_test, PATH_MAX, " %s ", temp); + + // environment +#ifdef __NETWARE__ + setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); + snprintf(file_path, PATH_MAX*2, "%s/client/mysqldump --no-defaults -u root --port=%u", bin_dir, master_port); + setenv("MYSQL_DUMP", file_path, 1); + snprintf(file_path, PATH_MAX*2, "%s/client/mysqlbinlog --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + setenv("MYSQL_BINLOG", file_path, 1); +#elif __WIN__ + snprintf(file_path,MAX_PATH,"MYSQL_TEST_DIR=%s",mysql_test_dir); + _putenv(file_path); + snprintf(file_path, PATH_MAX*2, "MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u", bin_dir, master_port); + _putenv(file_path); + snprintf(file_path, PATH_MAX*2, "MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + _putenv(file_path); +#else + setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); + snprintf(file_path, PATH_MAX*2, "%s/mysqldump --no-defaults -u root --port=%u --socket=%s", bin_dir, master_port, master_socket); + setenv("MYSQL_DUMP", file_path, 1); + snprintf(file_path, PATH_MAX*2, "%s/mysqlbinlog --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + setenv("MYSQL_BINLOG", file_path, 1); +#endif + +#ifndef __WIN__ + setenv("MASTER_MYPORT", "9306", 1); + setenv("SLAVE_MYPORT", "9307", 1); + setenv("MYSQL_TCP_PORT", "3306", 1); +#else + _putenv("MASTER_MYPORT=9306"); + _putenv("SLAVE_MYPORT=9307"); + _putenv("MYSQL_TCP_PORT=3306"); +#endif + +} + +/****************************************************************************** + + main() + +******************************************************************************/ +int main(int argc, char **argv) +{ + int is_ignore_list = 0; + // setup + setup(argv[0]); + + /* The --ignore option is comma saperated list of test cases to skip and + should be very first command line option to the test suite. + + The usage is now: + mysql_test_run --ignore=test1,test2 test3 test4 + where test1 and test2 are test cases to ignore + and test3 and test4 are test cases to run. + */ + if (argc >= 2 && !strnicmp(argv[1], "--ignore=", sizeof("--ignore=")-1)) + { + char *temp, *token; + temp= strdup(strchr(argv[1],'=') + 1); + for (token=str_tok(temp, ","); token != NULL; token=str_tok(NULL, ",")) + { + if (strlen(ignore_test) + strlen(token) + 2 <= PATH_MAX-1) + sprintf(ignore_test+strlen(ignore_test), " %s ", token); + else + { + free(temp); + die("ignore list too long."); + } + } + free(temp); + is_ignore_list = 1; + } + // header +#ifndef __WIN__ + mlog("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); +#else + mlog("MySQL Server ---, for %s (%s)\n\n", SYSTEM_TYPE, MACHINE_TYPE); +#endif + + mlog("Initializing Tests...\n"); + + // install test databases + mysql_install_db(); + + mlog("Starting Tests...\n"); + + mlog("\n"); + mlog(HEADER); + mlog(DASH); + + if ( argc > 1 + is_ignore_list ) + { + int i; + + // single test + single_test = TRUE; + + for (i = 1 + is_ignore_list; i < argc; i++) + { + // run given test + run_test(argv[i]); + } + } + else + { + // run all tests +#ifndef __WIN__ + struct dirent **namelist; + int i,n; + char test[NAME_MAX]; + char *p; + int position; + + n = scandir(test_dir, &namelist, 0, alphasort); + if (n < 0) + die("Unable to open tests directory."); + else + { + for (i = 0; i < n; i++) + { + strcpy(test, strlwr(namelist[i]->d_name)); + // find the test suffix + if ((position = strinstr(test, TEST_SUFFIX)) != 0) + { + p = test + position - 1; + // null terminate at the suffix + *p = 0; + // run test + run_test(test); + } + free(namelist[n]); + } + free(namelist); + } +#else + struct _finddata_t dir; + intptr_t handle; + char test[NAME_MAX]; + char mask[PATH_MAX]; + char *p; + int position; + char **names = 0; + char **testes = 0; + int name_index; + int index; + + // single test + single_test = FALSE; + + snprintf(mask,MAX_PATH,"%s/*.test",test_dir); + + if ((handle=_findfirst(mask,&dir)) == -1L) + { + die("Unable to open tests directory."); + } + + names = malloc(MAX_COUNT_TESTES*4); + testes = names; + name_index = 0; + + do + { + if (!(dir.attrib & _A_SUBDIR)) + { + strcpy(test, strlwr(dir.name)); + + // find the test suffix + if ((position = strinstr(test, TEST_SUFFIX)) != 0) + { + p = test + position - 1; + // null terminate at the suffix + *p = 0; + + // insert test + *names = malloc(PATH_MAX); + strcpy(*names,test); + names++; + name_index++; + } + } + }while (_findnext(handle,&dir) == 0); + + _findclose(handle); + + qsort( (void *)testes, name_index, sizeof( char * ), compare ); + + for (index = 0; index <= name_index; index++) + { + run_test(testes[index]); + free(testes[index]); + } + + free(testes); +#endif + } + + // stop server + mysql_stop(); + + mlog(DASH); + mlog("\n"); + + mlog("Ending Tests...\n"); + + // report stats + report_stats(); + + // close log + if (log_fd) fclose(log_fd); + + // keep results up +#ifdef __NETWARE__ + pressanykey(); +#endif + return 0; +} + + +/* + Synopsis: + This function breaks the string into a sequence of tokens. The difference + between this function and strtok is that it respects the quoted string i.e. + it skips any delimiter character within the quoted part of the string. + It return tokens by eliminating quote character. It modifies the input string + passed. It will work with whitespace delimeter but may not work properly with + other delimeter. If the delimeter will contain any quote character, then + function will not tokenize and will return null string. + e.g. if input string is + --init-slave="set global max_connections=500" --skip-external-locking + then the output will two string i.e. + --init-slave=set global max_connections=500 + --skip-external-locking + +Arguments: + string: input string + delim: set of delimiter character +Output: + return the null terminated token of NULL. +*/ + + +char *str_tok(char *string, const char *delim) +{ + char *token; /* current token received from strtok */ + char *qt_token; /* token delimeted by the matching pair of quote */ + /* + if there are any quote chars found in the token then this variable + will hold the concatenated string to return to the caller + */ + char *ptr_token=NULL; + /* pointer to the quote character in the token from strtok */ + char *ptr_quote=NULL; + + /* See if the delimeter contains any quote character */ + if (strchr(delim,'\'') || strchr(delim,'\"')) + return NULL; + + /* repeate till we are getting some token from strtok */ + while ((token = (char*)strtok(string, delim) ) != NULL) + { + /* + make the input string NULL so that next time onward strtok can + be called with NULL input string. + */ + string = NULL; + /* + We don't need to remove any quote character for Windows version + */ +#ifndef __WIN__ + /* check if the current token contain double quote character*/ + if ((ptr_quote = (char*)strchr(token,'\"')) != NULL) + { + /* + get the matching the matching double quote in the remaining + input string + */ + qt_token = (char*)strtok(NULL,"\""); + } + /* check if the current token contain single quote character*/ + else if ((ptr_quote = (char*)strchr(token,'\'')) != NULL) + { + /* + get the matching the matching single quote in the remaining + input string + */ + qt_token = (char*)strtok(NULL,"\'"); + } +#endif + /* + if the current token does not contains any quote character then + return to the caller. + */ + if (ptr_quote == NULL) + { + /* + if there is any earlier token i.e. ptr_token then append the + current token in it and return it else return the current + token directly + */ + return ptr_token ? strcat(ptr_token,token) : token; + } + + /* + remove the quote character i.e. make NULL so that the token will + be devided in two part and later both part can be concatenated + and hence quote will be removed + */ + *ptr_quote= 0; + + /* check if ptr_token has been initialized or not */ + if (ptr_token == NULL) + { + /* initialize the ptr_token with current token */ + ptr_token= token; + /* copy entire string between matching pair of quote*/ + sprintf(ptr_token+strlen(ptr_token),"%s %s", ptr_quote+1, qt_token); + } + else + { + /* + copy the current token and entire string between matching pair + of quote + */ + if (qt_token == NULL) + { + sprintf(ptr_token+strlen(ptr_token),"%s%s", token, ptr_quote+1); + } + else + { + sprintf(ptr_token+strlen(ptr_token),"%s%s %s", token, ptr_quote+1, + qt_token ); + } + } + } + + /* return the concatenated token */ + return ptr_token; +} + +#ifndef __WIN__ + +/* + Synopsis: + This function run scripts files on Linux and Netware + +Arguments: + script_name: name of script file + +Output: + nothing +*/ +void run_init_script(const char *script_name) +{ + arg_list_t al; + int err; + + // args + init_args(&al); + add_arg(&al, sh_file); + add_arg(&al, script_name); + + // spawn + if ((err = spawn(sh_file, &al, TRUE, NULL, NULL, NULL, NULL)) != 0) + { + die("Unable to run script."); + } + + // free args + free_args(&al); +} +#endif diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index c86a379cccd..4d4b6eee9a4 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -352,9 +352,9 @@ t collation(t) aus Osnabrück utf8_general_ci SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); t collation(t) -SELECT t, collation(t),MATCH t AGAINST ('Osnabruck') FROM t1 WHERE MATCH t AGAINST ('Osnabruck'); -t collation(t) MATCH t AGAINST ('Osnabruck') -aus Osnabrück utf8_general_ci 1.591139793396 +SELECT t, collation(t),FORMAT(MATCH t AGAINST ('Osnabruck'),6) FROM t1 WHERE MATCH t AGAINST ('Osnabruck'); +t collation(t) FORMAT(MATCH t AGAINST ('Osnabruck'),6) +aus Osnabrück utf8_general_ci 1.591140 alter table t1 modify t varchar(200) collate latin1_german2_ci not null; SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); t collation(t) diff --git a/mysql-test/r/fulltext_cache.result b/mysql-test/r/fulltext_cache.result index c489bdefeb8..4c210b8a3cb 100644 --- a/mysql-test/r/fulltext_cache.result +++ b/mysql-test/r/fulltext_cache.result @@ -21,17 +21,17 @@ INSERT INTO t2 VALUES (5,2,'um copo de Vodka'); INSERT INTO t2 VALUES (6,2,'um chocolate Snickers'); INSERT INTO t2 VALUES (7,1,'Bife'); INSERT INTO t2 VALUES (8,1,'Pizza de Salmao'); -SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi') +SELECT t1.q, t2.item, t2.id, FORMAT(MATCH t2.item AGAINST ('sushi'),6) as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; q item id x -aaaaaaaaa dsaass de sushi 1 1.92378664016724 -aaaaaaaaa dsaass de Bolo de Chocolate 2 0 -aaaaaaaaa dsaass de Feijoada 3 0 -aaaaaaaaa dsaass de Mousse de Chocolate 4 0 -ssde df s fsda sad er um copo de Vodka 5 0 -ssde df s fsda sad er um chocolate Snickers 6 0 -aaaaaaaaa dsaass de Bife 7 0 -aaaaaaaaa dsaass de Pizza de Salmao 8 0 +aaaaaaaaa dsaass de sushi 1 1.923787 +aaaaaaaaa dsaass de Bolo de Chocolate 2 0.000000 +aaaaaaaaa dsaass de Feijoada 3 0.000000 +aaaaaaaaa dsaass de Mousse de Chocolate 4 0.000000 +ssde df s fsda sad er um copo de Vodka 5 0.000000 +ssde df s fsda sad er um chocolate Snickers 6 0.000000 +aaaaaaaaa dsaass de Bife 7 0.000000 +aaaaaaaaa dsaass de Pizza de Salmao 8 0.000000 SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; q item id x @@ -43,17 +43,17 @@ ssde df s fsda sad er um copo de Vodka 5 0 ssde df s fsda sad er um chocolate Snickers 6 0 aaaaaaaaa dsaass de Bife 7 0 aaaaaaaaa dsaass de Pizza de Salmao 8 0 -SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi') +SELECT t1.q, t2.item, t2.id, FORMAT(MATCH t2.item AGAINST ('sushi'),6) as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; q item id x -aaaaaaaaa dsaass de sushi 1 1.92378664016724 -aaaaaaaaa dsaass de Bolo de Chocolate 2 0 -aaaaaaaaa dsaass de Feijoada 3 0 -aaaaaaaaa dsaass de Mousse de Chocolate 4 0 -ssde df s fsda sad er um copo de Vodka 5 0 -ssde df s fsda sad er um chocolate Snickers 6 0 -aaaaaaaaa dsaass de Bife 7 0 -aaaaaaaaa dsaass de Pizza de Salmao 8 0 +aaaaaaaaa dsaass de sushi 1 1.923787 +aaaaaaaaa dsaass de Bolo de Chocolate 2 0.000000 +aaaaaaaaa dsaass de Feijoada 3 0.000000 +aaaaaaaaa dsaass de Mousse de Chocolate 4 0.000000 +ssde df s fsda sad er um copo de Vodka 5 0.000000 +ssde df s fsda sad er um chocolate Snickers 6 0.000000 +aaaaaaaaa dsaass de Bife 7 0.000000 +aaaaaaaaa dsaass de Pizza de Salmao 8 0.000000 SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; q item id x diff --git a/mysql-test/r/fulltext_multi.result b/mysql-test/r/fulltext_multi.result index 968b00020e2..426b104ae89 100644 --- a/mysql-test/r/fulltext_multi.result +++ b/mysql-test/r/fulltext_multi.result @@ -11,19 +11,19 @@ FULLTEXT KEY a(b,c) INSERT INTO t1 VALUES (1,'lala lolo lili','oooo aaaa pppp'); INSERT INTO t1 VALUES (2,'asdf fdsa','lkjh fghj'); INSERT INTO t1 VALUES (3,'qpwoei','zmxnvb'); -SELECT a, MATCH b AGAINST ('lala lkjh') FROM t1; -a MATCH b AGAINST ('lala lkjh') -1 0.67003107070923 -2 0 -3 0 -SELECT a, MATCH c AGAINST ('lala lkjh') FROM t1; -a MATCH c AGAINST ('lala lkjh') -1 0 -2 0.67756325006485 -3 0 -SELECT a, MATCH b,c AGAINST ('lala lkjh') FROM t1; -a MATCH b,c AGAINST ('lala lkjh') -1 0.64840710163116 -2 0.66266459226608 -3 0 +SELECT a, FORMAT(MATCH b AGAINST ('lala lkjh'),6) FROM t1; +a FORMAT(MATCH b AGAINST ('lala lkjh'),6) +1 0.670031 +2 0.000000 +3 0.000000 +SELECT a, FORMAT(MATCH c AGAINST ('lala lkjh'),6) FROM t1; +a FORMAT(MATCH c AGAINST ('lala lkjh'),6) +1 0.000000 +2 0.677563 +3 0.000000 +SELECT a, FORMAT(MATCH b,c AGAINST ('lala lkjh'),6) FROM t1; +a FORMAT(MATCH b,c AGAINST ('lala lkjh'),6) +1 0.648407 +2 0.662665 +3 0.000000 drop table t1; diff --git a/mysql-test/r/fulltext_order_by.result b/mysql-test/r/fulltext_order_by.result index bfee9eba280..c6c42fa2e8b 100644 --- a/mysql-test/r/fulltext_order_by.result +++ b/mysql-test/r/fulltext_order_by.result @@ -6,53 +6,53 @@ FULLTEXT(message) ) comment = 'original testcase by sroussey@network54.com'; INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"), ("steve"),("is"),("cool"),("steve is cool"); -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve'); -a MATCH (message) AGAINST ('steve') -4 0.90587323904037 -7 0.89568990468979 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve'); +a FORMAT(MATCH (message) AGAINST ('steve'),6) +4 0.905873 +7 0.895690 SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve'); a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) 4 1 7 1 -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); -a MATCH (message) AGAINST ('steve') -4 0.90587323904037 -7 0.89568990468979 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); +a FORMAT(MATCH (message) AGAINST ('steve'),6) +4 0.905873 +7 0.895690 SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) 4 1 7 1 -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a; -a MATCH (message) AGAINST ('steve') -4 0.90587323904037 -7 0.89568990468979 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a; +a FORMAT(MATCH (message) AGAINST ('steve'),6) +4 0.905873 +7 0.895690 SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a; a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) 4 1 7 1 -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC; -a MATCH (message) AGAINST ('steve') -7 0.89568990468979 -4 0.90587323904037 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC; +a FORMAT(MATCH (message) AGAINST ('steve'),6) +7 0.895690 +4 0.905873 SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC; a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) 7 1 4 1 -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1; -a MATCH (message) AGAINST ('steve') -7 0.89568990468979 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1; +a FORMAT(MATCH (message) AGAINST ('steve'),6) +7 0.895690 SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1; a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) 7 1 -SELECT a, MATCH (message) AGAINST ('steve') as rel FROM t1 ORDER BY rel; +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel; a rel -1 0 -2 0 -3 0 -5 0 -6 0 -7 0.89568990468979 -4 0.90587323904037 +1 0.000000 +2 0.000000 +3 0.000000 +5 0.000000 +6 0.000000 +7 0.895690 +4 0.905873 SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel; a rel 1 0 diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 30de1e62df7..38845fd08ca 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -22,14 +22,14 @@ select * from t1; f1 f2 10 10 100000 100000 -1.23457e+09 1234567890 +1.23457e+9 1234567890 1e+10 10000000000 1e+15 1e+15 1e+20 1e+20 3.40282e+38 1e+50 3.40282e+38 1e+150 -10 -10 -1e-05 1e-05 +1e-5 1e-5 1e-10 1e-10 1e-15 1e-15 1e-20 1e-20 diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 66df5b1cb92..13722d9732a 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -272,7 +272,7 @@ SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr SET NAMES latin1; SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); -SELECT t, collation(t),MATCH t AGAINST ('Osnabruck') FROM t1 WHERE MATCH t AGAINST ('Osnabruck'); +SELECT t, collation(t),FORMAT(MATCH t AGAINST ('Osnabruck'),6) FROM t1 WHERE MATCH t AGAINST ('Osnabruck'); #alter table t1 modify t text character set latin1 collate latin1_german2_ci not null; alter table t1 modify t varchar(200) collate latin1_german2_ci not null; SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); diff --git a/mysql-test/t/fulltext_cache.test b/mysql-test/t/fulltext_cache.test index 15f32fdb5a0..e8c2b4a7f74 100644 --- a/mysql-test/t/fulltext_cache.test +++ b/mysql-test/t/fulltext_cache.test @@ -29,13 +29,13 @@ INSERT INTO t2 VALUES (6,2,'um chocolate Snickers'); INSERT INTO t2 VALUES (7,1,'Bife'); INSERT INTO t2 VALUES (8,1,'Pizza de Salmao'); -SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi') +SELECT t1.q, t2.item, t2.id, FORMAT(MATCH t2.item AGAINST ('sushi'),6) as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; -SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi') +SELECT t1.q, t2.item, t2.id, FORMAT(MATCH t2.item AGAINST ('sushi'),6) as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) diff --git a/mysql-test/t/fulltext_multi.test b/mysql-test/t/fulltext_multi.test index c312a5938b2..437ce96794b 100644 --- a/mysql-test/t/fulltext_multi.test +++ b/mysql-test/t/fulltext_multi.test @@ -17,7 +17,7 @@ INSERT INTO t1 VALUES (1,'lala lolo lili','oooo aaaa pppp'); INSERT INTO t1 VALUES (2,'asdf fdsa','lkjh fghj'); INSERT INTO t1 VALUES (3,'qpwoei','zmxnvb'); -SELECT a, MATCH b AGAINST ('lala lkjh') FROM t1; -SELECT a, MATCH c AGAINST ('lala lkjh') FROM t1; -SELECT a, MATCH b,c AGAINST ('lala lkjh') FROM t1; +SELECT a, FORMAT(MATCH b AGAINST ('lala lkjh'),6) FROM t1; +SELECT a, FORMAT(MATCH c AGAINST ('lala lkjh'),6) FROM t1; +SELECT a, FORMAT(MATCH b,c AGAINST ('lala lkjh'),6) FROM t1; drop table t1; diff --git a/mysql-test/t/fulltext_order_by.test b/mysql-test/t/fulltext_order_by.test index f8afe49d95d..5856f68ec9e 100644 --- a/mysql-test/t/fulltext_order_by.test +++ b/mysql-test/t/fulltext_order_by.test @@ -10,25 +10,25 @@ CREATE TABLE t1 ( INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"), ("steve"),("is"),("cool"),("steve is cool"); # basic MATCH -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve'); +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve'); SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve'); -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); # MATCH + ORDER BY (with ft-ranges) -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a; +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a; SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a; # MATCH + ORDER BY (with normal ranges) + UNIQUE -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC; +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC; SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC; # MATCH + ORDER BY + UNIQUE (const_table) -SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1; +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1; SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1; # ORDER BY MATCH -SELECT a, MATCH (message) AGAINST ('steve') as rel FROM t1 ORDER BY rel; +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel; SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel; drop table t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index e0cc96ccb32..162e44c35ea 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1093,6 +1093,7 @@ show create table t2; drop table t2; # Test error handling +--replace_result \\ / --error 1005 create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index fd728c453aa..b03b77f0be8 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -97,46 +97,57 @@ create table t1(number int auto_increment primary key, original_value varchar(50 set @value= "aa"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "1aa"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "aa1"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "1e+1111111111a"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "-1e+1111111111a"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= 1e+1111111111; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= -1e+1111111111; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= 1e+111; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= -1e+111; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= 1; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= -1; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); +--replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() drop table t1; diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index d3ddecfc314..6497525424e 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -6,7 +6,9 @@ drop table if exists t1; --enable_warnings +--replace_result e-0 e- e+0 e+ SELECT 10,10.0,10.,.1e+2,100.0e-1; +--replace_result e-00 e-0 SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; @@ -14,6 +16,7 @@ create table t1 (f1 float(24),f2 float(52)); show full columns from t1; insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); +--replace_result e-0 e- e+0 e+ select * from t1; drop table t1; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 60ebeb045f5..eec08a7a776 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -8,6 +8,7 @@ drop table if exists t1,t2; set @`test`=1,@TEST=3,@select=2,@t5=1.23456; select @test,@`select`,@TEST,@not_used; set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL; +--replace_result e-0 e- e+0 e+ select @test_int,@test_double,@test_string,@test_string2,@select; set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello"; select @test_int,@test_double,@test_string,@test_string2; From 32880072357e53a77261f3a1a8321443119bc6c9 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Fri, 22 Oct 2004 15:43:22 +0300 Subject: [PATCH 002/101] fixed db/user privileges getting (BUG#5976) --- mysql-test/r/view.result | 7 +++++++ mysql-test/t/view.test | 18 ++++++++++++++++++ sql/sql_acl.cc | 5 +++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 9c89de4259e..caec33eb59b 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1628,3 +1628,10 @@ Field 3,'Field 4| |Field 6| | 'Field 7'| drop view v1; drop table t1; +create database mysqltest; +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +create view v1 as select * from t1; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 8e38b5616f8..a63086acd71 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1554,3 +1554,21 @@ select concat('|',a,'|'), concat('|',b,'|') from v1; drop view v1; drop table t1; +# +# user with global DB privileges +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; + +connection user1; +use mysqltest; +create view v1 as select * from t1; + + +connection root; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index df615383ec3..34aa0984798 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3889,12 +3889,13 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, /* global privileges */ grant->privilege= thd->master_access; + /* db privileges */ + grant->privilege|= acl_get(thd->host, thd->ip, thd->priv_user, db, 0); + /* if privileges ignored (--skip-grant-tables) above is enough */ if (!grant_option) return; - /* db privileges */ - grant->privilege|= acl_get(thd->host, thd->ip, thd->priv_user, db, 0); /* table privileges */ if (grant->version != grant_version) { From 497fe7f71ed60f3af92f0f915a5cbd42d24de8ac Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Fri, 22 Oct 2004 20:32:02 +0500 Subject: [PATCH 003/101] Fix for bug #6117 (Centroid() crashes server) I learned that one shouldn't use String::set in val_str() methods... --- mysql-test/r/gis.result | 74 ++++++++++++++++++++++++++++++++++++++++ mysql-test/t/gis.test | 75 +++++++++++++++++++++++++++++++++++++++++ sql/item_geofunc.cc | 6 ++-- sql/spatial.cc | 4 +-- 4 files changed, 153 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 2226c6e33c9..c51b07f09d6 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -581,3 +581,77 @@ t1 CREATE TABLE `t1` ( `POINT(1,3)` longblob NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo` +geometry NOT NULL default '') ENGINE=MyISAM ; +insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363 +36.305435,-114.992394 36.305202,-114.991219 36.305975,-114.991163 +36.306845,-114.989432 36.309452,-114.978275 36.312642,-114.977363 +36.311978,-114.975327 36.312344,-114.96502 36.31597,-114.963364 +36.313629,-114.961723 36.313721,-114.956398 36.316057,-114.951882 +36.320979,-114.947073 36.323475,-114.945207 36.326451,-114.945207 +36.326451,-114.944132 36.326061,-114.94003 36.326588,-114.924017 +36.334484,-114.923281 36.334146,-114.92564 36.331504,-114.94072 +36.319282,-114.945348 36.314812,-114.948091 36.314762,-114.951755 +36.316211,-114.952446 36.313883,-114.952644 36.309488,-114.944725 +36.313083,-114.93706 36.32043,-114.932478 36.323497,-114.924556 +36.327708,-114.922608 36.329715,-114.92009 36.328695,-114.912105 +36.323566,-114.901647 36.317952,-114.897436 36.313968,-114.895344 +36.309573,-114.891699 36.304398,-114.890569 36.303551,-114.886356 +36.302702,-114.885141 36.301351,-114.885709 36.297391,-114.892499 +36.290893,-114.902142 36.288974,-114.904941 36.288838,-114.905308 +36.289845,-114.906325 36.290395,-114.909916 36.289549,-114.914527 +36.287535,-114.918797 36.284423,-114.922982 36.279731,-114.924113 +36.277282,-114.924057 36.275817,-114.927733 36.27053,-114.929354 +36.269029,-114.929354 36.269029,-114.950856 36.268715,-114.950768 +36.264324,-114.960206 36.264293,-114.960301 36.268943,-115.006662 +36.268929,-115.008583 36.265619,-115.00665 36.264247,-115.006659 +36.246873,-115.006659 36.246873,-115.006838 36.247697,-115.010764 +36.247774,-115.015609 36.25113,-115.015765 36.254505,-115.029517 +36.254619,-115.038573 36.249317,-115.038573 36.249317,-115.023403 +36.25841,-115.023873 36.258994,-115.031845 36.259829,-115.03183 +36.261053,-115.025561 36.261095,-115.036417 36.274632,-115.033729 +36.276041,-115.032217 36.274851,-115.029845 36.273959,-115.029934 +36.274966,-115.025763 36.274896,-115.025406 36.281044,-115.028731 +36.284471,-115.036497 36.290377,-115.042071 36.291039,-115.026759 +36.298478,-115.008995 36.301966,-115.006363 36.305435),(-115.079835 +36.244369,-115.079735 36.260186,-115.076435 36.262369,-115.069758 +36.265,-115.070235 36.268757,-115.064542 36.268655,-115.061843 +36.269857,-115.062676 36.270693,-115.06305 36.272344,-115.059051 +36.281023,-115.05918 36.283008,-115.060591 36.285246,-115.061913 +36.290022,-115.062499 36.306353,-115.062499 36.306353,-115.060918 +36.30642,-115.06112 36.289779,-115.05713 36.2825,-115.057314 +36.279446,-115.060779 36.274659,-115.061366 36.27209,-115.057858 +36.26557,-115.055805 36.262883,-115.054688 36.262874,-115.047335 +36.25037,-115.044234 36.24637,-115.052434 36.24047,-115.061734 +36.23507,-115.061934 36.22677,-115.061934 36.22677,-115.061491 +36.225267,-115.062024 36.218194,-115.060134 36.218278,-115.060133 +36.210771,-115.057833 36.210771,-115.057433 36.196271,-115.062233 +36.196271,-115.062233 36.190371,-115.062233 36.190371,-115.065533 +36.190371,-115.071333 36.188571,-115.098331 36.188275,-115.098331 +36.188275,-115.098435 36.237569,-115.097535 36.240369,-115.097535 +36.240369,-115.093235 36.240369,-115.089135 36.240469,-115.083135 +36.240569,-115.083135 36.240569,-115.079835 +36.244369)))')),('85998',GeomFromText('MULTIPOLYGON(((-115.333107 +36.264587,-115.333168 36.280638,-115.333168 36.280638,-115.32226 +36.280643,-115.322538 36.274311,-115.327222 36.274258,-115.32733 +36.263026,-115.330675 36.262984,-115.332132 36.264673,-115.333107 +36.264587),(-115.247239 36.247066,-115.247438 36.218267,-115.247438 +36.218267,-115.278525 36.219263,-115.278525 36.219263,-115.301545 +36.219559,-115.332748 36.219197,-115.332757 36.220041,-115.332757 +36.220041,-115.332895 36.233514,-115.349023 36.233479,-115.351489 +36.234475,-115.353681 36.237021,-115.357106 36.239789,-115.36519 +36.243331,-115.368156 36.243487,-115.367389 36.244902,-115.364553 +36.246014,-115.359219 36.24616,-115.356186 36.248025,-115.353347 +36.248004,-115.350813 36.249507,-115.339673 36.25387,-115.333069 +36.255018,-115.333069 36.255018,-115.333042 36.247767,-115.279039 +36.248666,-115.263639 36.247466,-115.263839 36.252766,-115.261439 +36.252666,-115.261439 36.247366,-115.247239 36.247066)))')); +select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from +t1 where object_id=85998; +object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo)) +85998 MULTIPOLYGON 0 POINT(115.31877315203 -36.237472821022) +select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from +t1 where object_id=85984; +object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo)) +85984 MULTIPOLYGON 0 POINT(-114.87787186923 36.33101763469) +drop table t1; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 739fced1f29..86c34eacbc5 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -284,3 +284,78 @@ drop table t1; create table t1 select POINT(1,3); show create table t1; drop table t1; + +CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo` +geometry NOT NULL default '') ENGINE=MyISAM ; + +insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363 +36.305435,-114.992394 36.305202,-114.991219 36.305975,-114.991163 +36.306845,-114.989432 36.309452,-114.978275 36.312642,-114.977363 +36.311978,-114.975327 36.312344,-114.96502 36.31597,-114.963364 +36.313629,-114.961723 36.313721,-114.956398 36.316057,-114.951882 +36.320979,-114.947073 36.323475,-114.945207 36.326451,-114.945207 +36.326451,-114.944132 36.326061,-114.94003 36.326588,-114.924017 +36.334484,-114.923281 36.334146,-114.92564 36.331504,-114.94072 +36.319282,-114.945348 36.314812,-114.948091 36.314762,-114.951755 +36.316211,-114.952446 36.313883,-114.952644 36.309488,-114.944725 +36.313083,-114.93706 36.32043,-114.932478 36.323497,-114.924556 +36.327708,-114.922608 36.329715,-114.92009 36.328695,-114.912105 +36.323566,-114.901647 36.317952,-114.897436 36.313968,-114.895344 +36.309573,-114.891699 36.304398,-114.890569 36.303551,-114.886356 +36.302702,-114.885141 36.301351,-114.885709 36.297391,-114.892499 +36.290893,-114.902142 36.288974,-114.904941 36.288838,-114.905308 +36.289845,-114.906325 36.290395,-114.909916 36.289549,-114.914527 +36.287535,-114.918797 36.284423,-114.922982 36.279731,-114.924113 +36.277282,-114.924057 36.275817,-114.927733 36.27053,-114.929354 +36.269029,-114.929354 36.269029,-114.950856 36.268715,-114.950768 +36.264324,-114.960206 36.264293,-114.960301 36.268943,-115.006662 +36.268929,-115.008583 36.265619,-115.00665 36.264247,-115.006659 +36.246873,-115.006659 36.246873,-115.006838 36.247697,-115.010764 +36.247774,-115.015609 36.25113,-115.015765 36.254505,-115.029517 +36.254619,-115.038573 36.249317,-115.038573 36.249317,-115.023403 +36.25841,-115.023873 36.258994,-115.031845 36.259829,-115.03183 +36.261053,-115.025561 36.261095,-115.036417 36.274632,-115.033729 +36.276041,-115.032217 36.274851,-115.029845 36.273959,-115.029934 +36.274966,-115.025763 36.274896,-115.025406 36.281044,-115.028731 +36.284471,-115.036497 36.290377,-115.042071 36.291039,-115.026759 +36.298478,-115.008995 36.301966,-115.006363 36.305435),(-115.079835 +36.244369,-115.079735 36.260186,-115.076435 36.262369,-115.069758 +36.265,-115.070235 36.268757,-115.064542 36.268655,-115.061843 +36.269857,-115.062676 36.270693,-115.06305 36.272344,-115.059051 +36.281023,-115.05918 36.283008,-115.060591 36.285246,-115.061913 +36.290022,-115.062499 36.306353,-115.062499 36.306353,-115.060918 +36.30642,-115.06112 36.289779,-115.05713 36.2825,-115.057314 +36.279446,-115.060779 36.274659,-115.061366 36.27209,-115.057858 +36.26557,-115.055805 36.262883,-115.054688 36.262874,-115.047335 +36.25037,-115.044234 36.24637,-115.052434 36.24047,-115.061734 +36.23507,-115.061934 36.22677,-115.061934 36.22677,-115.061491 +36.225267,-115.062024 36.218194,-115.060134 36.218278,-115.060133 +36.210771,-115.057833 36.210771,-115.057433 36.196271,-115.062233 +36.196271,-115.062233 36.190371,-115.062233 36.190371,-115.065533 +36.190371,-115.071333 36.188571,-115.098331 36.188275,-115.098331 +36.188275,-115.098435 36.237569,-115.097535 36.240369,-115.097535 +36.240369,-115.093235 36.240369,-115.089135 36.240469,-115.083135 +36.240569,-115.083135 36.240569,-115.079835 +36.244369)))')),('85998',GeomFromText('MULTIPOLYGON(((-115.333107 +36.264587,-115.333168 36.280638,-115.333168 36.280638,-115.32226 +36.280643,-115.322538 36.274311,-115.327222 36.274258,-115.32733 +36.263026,-115.330675 36.262984,-115.332132 36.264673,-115.333107 +36.264587),(-115.247239 36.247066,-115.247438 36.218267,-115.247438 +36.218267,-115.278525 36.219263,-115.278525 36.219263,-115.301545 +36.219559,-115.332748 36.219197,-115.332757 36.220041,-115.332757 +36.220041,-115.332895 36.233514,-115.349023 36.233479,-115.351489 +36.234475,-115.353681 36.237021,-115.357106 36.239789,-115.36519 +36.243331,-115.368156 36.243487,-115.367389 36.244902,-115.364553 +36.246014,-115.359219 36.24616,-115.356186 36.248025,-115.353347 +36.248004,-115.350813 36.249507,-115.339673 36.25387,-115.333069 +36.255018,-115.333069 36.255018,-115.333042 36.247767,-115.279039 +36.248666,-115.263639 36.247466,-115.263839 36.252766,-115.261439 +36.252666,-115.261439 36.247366,-115.247239 36.247066)))')); + +select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from +t1 where object_id=85998; + +select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from +t1 where object_id=85984; + +drop table t1; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 935925c1e83..7c3319bbfea 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -148,9 +148,9 @@ String *Item_func_geometry_type::val_str(String *str) swkb->length() - SRID_SIZE))))) return 0; /* String will not move */ - str->set(geom->get_class_info()->m_name.str, - geom->get_class_info()->m_name.length, - default_charset()); + str->copy(geom->get_class_info()->m_name.str, + geom->get_class_info()->m_name.length, + default_charset()); return str; } diff --git a/sql/spatial.cc b/sql/spatial.cc index 0668dd2faab..bcfefd9dde8 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -828,9 +828,7 @@ int Gis_polygon::centroid_xy(double *x, double *y) const if (!first_loop) { - double d_area= res_area - cur_area; - if (d_area <= 0) - return 1; + double d_area= fabs(res_area - cur_area); res_cx= (res_area * res_cx - cur_area * cur_cx) / d_area; res_cy= (res_area * res_cy - cur_area * cur_cy) / d_area; } From 6a46a05a938ad22da18fdf3d9f07d360fd2898de Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Mon, 25 Oct 2004 13:33:36 +0300 Subject: [PATCH 004/101] removed temporary debugging print --- sql/item_subselect.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 25bb2701101..710a6515c8b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -323,8 +323,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join) SELECT_LEX *select_lex= join->select_lex; /* Juggle with current arena only if we're in prepared statement prepare */ - DBUG_PRINT("TANSF:", ("thd %p, select_lex->join->thd: %s", - thd, select_lex->join->thd)); Item_arena *arena= thd->current_arena; Item_arena backup; if (arena->is_conventional()) From 3d389a038ecf8d3c36530a04629452fe74c35f89 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Mon, 25 Oct 2004 17:32:28 +0300 Subject: [PATCH 005/101] fixed detection of updating table on which we select (BUG#6032) --- mysql-test/r/view.result | 13 +++++++++++++ mysql-test/t/view.test | 18 +++++++++++++++++- sql/sql_acl.cc | 8 +++++++- sql/sql_base.cc | 20 ++++++++++++++------ sql/sql_delete.cc | 2 +- sql/sql_insert.cc | 2 +- sql/sql_parse.cc | 2 +- sql/sql_update.cc | 2 +- sql/sql_view.cc | 40 ++++++++++++++++++++++++++++++---------- sql/table.h | 8 -------- 10 files changed, 85 insertions(+), 30 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index eb32a3eeb2b..18fa7c2e374 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1633,3 +1633,16 @@ use mysqltest; create view v1 as select * from t1; revoke all privileges on mysqltest.* from mysqltest_1@localhost; drop database mysqltest; +create table t1 (s1 smallint); +create view v1 as select * from t1 where 20 < (select (s1) from t1); +insert into v1 values (30); +ERROR HY000: The target table v1 of the INSERT is not updatable +create view v2 as select * from t1; +create view v3 as select * from t1 where 20 < (select (s1) from v2); +insert into v3 values (30); +ERROR HY000: The target table v3 of the INSERT is not updatable +create view v4 as select * from v2 where 20 < (select (s1) from t1); +insert into v4 values (30); +ERROR HY000: You can't specify target table 'v4' for update in FROM clause +drop view v4, v3, v2, v1; +drop table t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index a63086acd71..27b127a0093 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1568,7 +1568,23 @@ connection user1; use mysqltest; create view v1 as select * from t1; - connection root; revoke all privileges on mysqltest.* from mysqltest_1@localhost; drop database mysqltest; + +# +# Trys update table from which we select using views and subqueries +# +create table t1 (s1 smallint); +create view v1 as select * from t1 where 20 < (select (s1) from t1); +-- error 1288 +insert into v1 values (30); +create view v2 as select * from t1; +create view v3 as select * from t1 where 20 < (select (s1) from v2); +-- error 1288 +insert into v3 values (30); +create view v4 as select * from v2 where 20 < (select (s1) from t1); +-- error 1093 +insert into v4 values (30); +drop view v4, v3, v2, v1; +drop table t1; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 34aa0984798..e215c932599 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3886,13 +3886,19 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr) void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, const char *db, const char *table) { + /* --skip-grants */ + if (!initialized) + { + grant->privilege= ~NO_ACCESS; // everything is allowed + return; + } + /* global privileges */ grant->privilege= thd->master_access; /* db privileges */ grant->privilege|= acl_get(thd->host, thd->ip, thd->priv_user, db, 0); - /* if privileges ignored (--skip-grant-tables) above is enough */ if (!grant_option) return; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4f273fbd0c4..a453f91a70e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -593,7 +593,8 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, { if ((!strcmp(table->db, db_name) && !strcmp(table->real_name, table_name)) || - (table->view && + (table->view && // it is VIEW and + table->table->table_cache_key && // it is not temporary table !strcmp(table->table->table_cache_key, db_name) && !strcmp(table->table->table_name, table_name))) break; @@ -618,6 +619,8 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, TABLE_LIST* unique_table(TABLE_LIST *table, TABLE_LIST *table_list) { + DBUG_ENTER("unique_table"); + DBUG_PRINT("enter", ("table alias: %s", table->alias)); TABLE_LIST *res; const char *d_name= table->db, *t_name= table->real_name; char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME]; @@ -644,13 +647,18 @@ TABLE_LIST* unique_table(TABLE_LIST *table, TABLE_LIST *table_list) return 0; } } - if ((res= find_table_in_global_list(table_list, d_name, t_name)) && - res->table && res->table == table->table) + + DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name)); + for(;;) { - // we found entry of this table try again. - return find_table_in_global_list(res->next_global, d_name, t_name); + if (!(res= find_table_in_global_list(table_list, d_name, t_name)) || + !res->table || res->table != table->table) + break; + /* if we found entry of this table try again. */ + table_list= res->next_global; + DBUG_PRINT("info", ("found same copy of table")); } - return res; + DBUG_RETURN(res); } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f9dba49d2e3..7163bf10bcc 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -293,7 +293,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE"); DBUG_RETURN(-1); } - if (unique_table(table_list, table_list->next_independent())) + if (unique_table(table_list, table_list->next_global)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); DBUG_RETURN(-1); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d9002c2da29..7457858d192 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -641,7 +641,7 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, setup_fields(thd, 0, table_list, update_values, 0, 0, 0)))) DBUG_RETURN(-1); - if (unique_table(table_list, table_list->next_independent())) + if (unique_table(table_list, table_list->next_global)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); DBUG_RETURN(-1); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 079d8994549..d40a992337e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2810,7 +2810,7 @@ unsent_create_error: Is table which we are changing used somewhere in other parts of query */ - if (unique_table(first_table, all_tables->next_independent())) + if (unique_table(first_table, all_tables->next_global)) { /* Using same table for INSERT and SELECT */ select_lex->options |= OPTION_BUFFER_RESULT; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 00e70ccb484..d96f40365b0 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -529,7 +529,7 @@ int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, DBUG_RETURN(-1); /* Check that we are not using table that we are updating in a sub select */ - if (unique_table(table_list, table_list->next_independent())) + if (unique_table(table_list, table_list->next_global)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); DBUG_RETURN(-1); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 4cdbfe9728b..f745db3e3ff 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -382,6 +382,7 @@ static LEX_STRING view_file_type[]= {{(char*)"VIEW", 4}}; static int mysql_register_view(THD *thd, TABLE_LIST *view, enum_view_create_mode mode) { + LEX *lex= thd->lex; char buff[4096]; String str(buff,(uint32) sizeof(buff), system_charset_info); char md5[33]; @@ -395,7 +396,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, { ulong sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES; thd->variables.sql_mode&= ~MODE_ANSI_QUOTES; - thd->lex->unit.print(&str); + lex->unit.print(&str); thd->variables.sql_mode|= sql_mode; } str.append('\0'); @@ -474,21 +475,21 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, view->calc_md5(md5); view->md5.str= md5; view->md5.length= 32; - can_be_merged= thd->lex->can_be_merged(); - if (thd->lex->create_view_algorithm == VIEW_ALGORITHM_MERGE && - !thd->lex->can_be_merged()) + can_be_merged= lex->can_be_merged(); + if (lex->create_view_algorithm == VIEW_ALGORITHM_MERGE && + !lex->can_be_merged()) { push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_VIEW_MERGE, ER(ER_WARN_VIEW_MERGE)); - thd->lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; + lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; } - view->algorithm= thd->lex->create_view_algorithm; - view->with_check= thd->lex->create_view_check; + view->algorithm= lex->create_view_algorithm; + view->with_check= lex->create_view_check; if ((view->updatable_view= (can_be_merged && view->algorithm != VIEW_ALGORITHM_TMPTABLE))) { /* TODO: change here when we will support UNIONs */ - for (TABLE_LIST *tbl= (TABLE_LIST *)thd->lex->select_lex.table_list.first; + for (TABLE_LIST *tbl= (TABLE_LIST *)lex->select_lex.table_list.first; tbl; tbl= tbl->next_local) { @@ -500,6 +501,26 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, } } + /* + Check that table of main select do not used in subqueries. + + This test can catch only very simple cases of such non-updateable views, + all other will be detected before updating commands execution. + (it is more optimisation then real check) + + NOTE: this skip cases of using table via VIEWs, joined VIEWs, VIEWs with + UNION + */ + if (view->updatable_view && + !lex->select_lex.next_select() && + !((TABLE_LIST*)lex->select_lex.table_list.first)->next_local && + find_table_in_global_list(lex->query_tables->next_global, + lex->query_tables->db, + lex->query_tables->real_name)) + { + view->updatable_view= 0; + } + if (view->with_check != VIEW_CHECK_NONE && !view->updatable_view) { @@ -698,13 +719,12 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) tables just after VIEW instead of tail of list, to be able check that table is unique. Also we store old next table for the same purpose. */ - table->old_next= table->next_global; if (view_tables) { if (table->next_global) { + view_tables_tail->next_global= table->next_global; table->next_global->prev_global= &view_tables_tail->next_global; - view_tables_tail->next_global= table->old_next; } else { diff --git a/sql/table.h b/sql/table.h index 3e2a61d5a21..de048e7cc5c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -232,8 +232,6 @@ typedef struct st_table_list st_table_list *ancestor; /* most upper view this table belongs to */ st_table_list *belong_to_view; - /* next_global before adding VIEW tables */ - st_table_list *old_next; Item *where; /* VIEW WHERE clause condition */ Item *check_option; /* WITH CHECK OPTION condition */ LEX_STRING query; /* text of (CRETE/SELECT) statement */ @@ -286,12 +284,6 @@ typedef struct st_table_list bool setup_ancestor(THD *thd, Item **conds, uint8 check_option); bool placeholder() {return derived || view; } void print(THD *thd, String *str); - inline st_table_list *next_independent() - { - if (view) - return old_next; - return next_global; - } } TABLE_LIST; class Item; From cee5d36be8f37fdba0df14f1445a3804d7c0d915 Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Wed, 27 Oct 2004 17:54:10 +0200 Subject: [PATCH 006/101] Change 'Build-tools/mysql-copyright' to ensure the receiving machines will build without trying to re-run autotools. (Backport from 4.1.7 for 4.0.22) --- Build-tools/mysql-copyright | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Build-tools/mysql-copyright b/Build-tools/mysql-copyright index 251a6c78d23..81d6d761498 100755 --- a/Build-tools/mysql-copyright +++ b/Build-tools/mysql-copyright @@ -3,7 +3,7 @@ # Untar a MySQL distribution, change the copyright texts, # pack it up again to a given directory -$VER="1.4"; +$VER="1.5"; use Cwd; use File::Basename; @@ -103,9 +103,8 @@ sub main unlink("$destdir/PUBLIC", "$destdir/README"); unlink("$destdir/COPYING", "$destdir/EXCEPTIONS-CLIENT"); copy("$WD/Docs/MySQLEULA.txt", "$destdir"); - + # remove subdirectories 'bdb', 'cmd-line-utils/readline' - # (latter does not apply to 4.0, but is in different place there!) my @extra_fat= ('bdb', 'cmd-line-utils/readline'); foreach my $fat (@extra_fat) @@ -116,7 +115,7 @@ sub main # fix file copyrights &fix_usage_copyright(); &add_copyright(); - + # fix LICENSE tag in include/mysql_version.h &fix_mysql_version(); @@ -135,7 +134,6 @@ sub main # remove temporary directory chdir($WD) or print "$! Unable to move up one dir\n"; - `cd $WD`; my $cwd = getcwd(); print "current dir is $cwd\n" if $opt_verbose ; if (-e $dir) { @@ -146,7 +144,7 @@ sub main } } exit(0); -} +} #### #### This function will s/GPL/Commercial/ in include/mysql_version.h for the @@ -175,6 +173,7 @@ sub fix_mysql_version #### This function will remove unwanted parts of a src tree for the mysqlcom #### distributions. #### + sub trim_the_fat { my $the_fat= shift; @@ -219,6 +218,7 @@ sub trim_the_fat #### #### This function will run the autotools on the reduced source tree. #### + sub run_autotools { my $cwd= getcwd(); @@ -230,7 +230,14 @@ sub run_autotools # File "configure.in" has already been modified by "trim_the_fat()" - `aclocal && autoheader && aclocal && automake && autoconf`; + # It must be ensured that the timestamps of the relevant files are really + # ascending, for otherwise the Makefile may cause a re-run of these + # autotools. Experience shows that deletion is the only safe way. + unlink ("config.h.in") or die "Can't delete $destdir/config.h.in: $!\n"; + unlink ("aclocal.m4") or die "Can't delete $destdir/aclocal.m4: $!\n"; + + # These sleep commands also ensure the ascending order. + `aclocal && sleep 2 && autoheader && sleep 2 && automake && sleep 2 && autoconf`; die "'./configure' was not produced!" unless (-f "configure"); if (-d "autom4te.cache") { From 6a6ab95c66279f635523e8ff4c40dc9e8fde6837 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 27 Oct 2004 17:30:12 +0000 Subject: [PATCH 007/101] Implemented fragmented signal from API primarily to enable creation of tables with more attributes than 91 (up to 128) Intermediate push for testing CHUNK_SZ will be set higher in real implementation and API_TRACE added --- ndb/src/ndbapi/TransporterFacade.cpp | 113 +++++++++++++++++++++++++-- ndb/src/ndbapi/TransporterFacade.hpp | 3 +- 2 files changed, 108 insertions(+), 8 deletions(-) diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index bc24110ea14..0377cf0c84b 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -475,7 +475,8 @@ TransporterFacade::TransporterFacade() : theTransporterRegistry(0), theStopReceive(0), theSendThread(NULL), - theReceiveThread(NULL) + theReceiveThread(NULL), + m_fragmented_signal_id(0) { theOwnId = 0; @@ -833,6 +834,105 @@ TransporterFacade::sendSignalUnCond(NdbApiSignal * aSignal, NodeId aNode){ return (ss == SEND_OK ? 0 : -1); } +#define CHUNK_SZ 100u +int +TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, + LinearSectionPtr ptr[3], Uint32 secs){ + NdbApiSignal tmp_signal(*(SignalHeader*)aSignal); + LinearSectionPtr tmp_ptr[3]; + Uint32 unique_id= m_fragmented_signal_id++; // next unique id + unsigned i; + for (i= 0; i < secs; i++) + tmp_ptr[i]= ptr[i]; + + unsigned start_i= 0; + unsigned chunk_sz= 0; + unsigned fragment_info= 0; + Uint32 *tmp_data= tmp_signal.getDataPtrSend(); + for (i= 0; i < secs;) { + unsigned save_sz= tmp_ptr[i].sz; + tmp_data[i-start_i]= i; + if (chunk_sz + save_sz > CHUNK_SZ) { + // truncate + unsigned send_sz= CHUNK_SZ - chunk_sz; + tmp_ptr[i].sz= send_sz; + if (fragment_info < 2) + fragment_info++; + + // send tmp_signal + tmp_data[i-start_i+1]= unique_id; + tmp_signal.setLength(i-start_i+2); + tmp_signal.m_fragmentInfo= fragment_info; + // do prepare send + { + int ret; + if(getIsNodeSendable(aNode) == true){ + SendStatus ss = theTransporterRegistry->prepareSend + (&tmp_signal, + 1, // JBB + tmp_signal.getDataPtrSend(), + aNode, + &ptr[start_i]); + assert(ss != SEND_MESSAGE_TOO_BIG); + ret = (ss == SEND_OK ? 0 : -1); + } else + ret = -1; + if (ret != SEND_OK) + return ret; + } + + // setup variables for next signal + start_i= i; + chunk_sz= 0; + tmp_ptr[i].sz= save_sz-send_sz; + tmp_ptr[i].p+= send_sz; + } + else + { + chunk_sz+= save_sz; + i++; + } + } + + unsigned a_sz= aSignal->getLength(); + + if (fragment_info > 0) { + // update the original signal to include section info + Uint32 *a_data= aSignal->getDataPtrSend(); + unsigned tmp_sz= i-start_i; + memcpy(a_data+a_sz, + tmp_data, + tmp_sz*sizeof(Uint32)); + a_data[a_sz+tmp_sz]= unique_id; + aSignal->setLength(a_sz+tmp_sz+1); + + // send last fragment + aSignal->m_fragmentInfo= 3; + aSignal->m_noOfSections= i-start_i; + } else { + aSignal->m_noOfSections= secs; + } + + // send aSignal + int ret; + if(getIsNodeSendable(aNode) == true){ + SendStatus ss = theTransporterRegistry->prepareSend + (aSignal, + 1, // JBB + aSignal->getDataPtrSend(), + aNode, + &ptr[start_i]); + assert(ss != SEND_MESSAGE_TOO_BIG); + ret = (ss == SEND_OK ? 0 : -1); + } else + ret = -1; + aSignal->m_noOfSections = 0; + aSignal->m_fragmentInfo = 0; + aSignal->setLength(a_sz); + return ret; +} + +#if 0 int TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, LinearSectionPtr ptr[3], Uint32 secs){ @@ -864,7 +964,7 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, aSignal->m_noOfSections = 0; return -1; } - +#endif int @@ -886,11 +986,10 @@ TransporterFacade::sendFragmentedSignalUnCond(NdbApiSignal* aSignal, aSignal->theSendersBlockRef = tmp; } #endif - SendStatus ss = theTransporterRegistry->prepareSend(aSignal, - 1, // JBB - aSignal->getDataPtrSend(), - aNode, - ptr); + SendStatus ss = + theTransporterRegistry->prepareSend(aSignal, 1, // JBB + aSignal->getDataPtrSend(), + aNode, ptr); assert(ss != SEND_MESSAGE_TOO_BIG); aSignal->m_noOfSections = 0; return (ss == SEND_OK ? 0 : -1); diff --git a/ndb/src/ndbapi/TransporterFacade.hpp b/ndb/src/ndbapi/TransporterFacade.hpp index 5f473975585..b288e2ee8e6 100644 --- a/ndb/src/ndbapi/TransporterFacade.hpp +++ b/ndb/src/ndbapi/TransporterFacade.hpp @@ -224,7 +224,8 @@ private: } m_threads; Uint32 m_max_trans_id; - + Uint32 m_fragmented_signal_id; + /** * execute function */ From 8e53b2d602b9dc190bd82afddb4f6e8eb77dbad1 Mon Sep 17 00:00:00 2001 From: "paul@kite-hub.kitebird.com" <> Date: Wed, 27 Oct 2004 13:44:31 -0500 Subject: [PATCH 008/101] texi2html: Updated version of texi2html so that 4.0.22 HTML manual doesn't turn out all goofy. --- Docs/Support/texi2html | 98 +++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/Docs/Support/texi2html b/Docs/Support/texi2html index 8067d8f72ce..f13c006c7dc 100755 --- a/Docs/Support/texi2html +++ b/Docs/Support/texi2html @@ -1,4 +1,4 @@ -#!PATH_TO_PERL -*- perl -*- +#!/usr/bin/perl # Add path to perl on the previous line and make this executable # if you want to use this as a normal script. 'di '; @@ -12,7 +12,7 @@ #-############################################################################## # @(#)texi2html 1.52 971230 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch -# Enhanced by David Axmark, david@detron.se +# Enhanced by David Axmark # The man page for this program is included at the end of this file and can be # viewed using the command 'nroff -man texi2html'. @@ -40,8 +40,7 @@ $NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names $XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE) $ERROR = "***"; # prefix for errors and warnings -$THISPROG = "texi2html 1.52 (hacked by david\@detron.se)"; # program name and version -$HOMEPAGE = "http://www.mathematik.uni-kl.de/~obachman/Texi2html/"; # program home page +$THISPROG = "texi2html 1.52 (with additions by MySQL AB)"; # program name and version $TODAY = &pretty_date; # like "20 September 1993" $SPLITTAG = "\n"; # tag to know where to split $PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections @@ -114,10 +113,12 @@ $html2_doctype = '", # HTML+ + "*", "
", # HTML+ " ", " ", "\n", "\n", "|", "", @@ -134,6 +135,8 @@ $html2_doctype = '', # paragraph break + 'br', '

', # paragraph break 'bullet', '*', 'copyright', '(C)', + 'registeredsymbol', '(R)', 'dots', '...', 'equiv', '==', 'error', 'error-->', @@ -161,27 +165,28 @@ $html2_doctype = '\n", __LINE__)); + push(@lines, &debug("\n", __LINE__)); } else { warn "$ERROR Bad table line: $_"; } @@ -873,7 +887,7 @@ READ_LINE: while ($_ = &next_line) &simple_substitutions; s/\@value{($VARRE)}/$value{$1}/eg; s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4 - s|\s+\@tab\s*| \n", __LINE__)) unless $html_element eq 'TABLE'; &html_pop_if('TR'); - $what =~ s|\s+\@tab\s*|
|g if ($in_multitable); + s/(^|\s+)\@tab\s*/ <\/TD> /g if ($in_multitable); # # analyze the tag again @@ -885,7 +899,7 @@ READ_LINE: while ($_ = &next_line) $name =~ s/\s+$//; $level = $sec2level{$tag}; $name = &update_sec_num($tag, $level) . " $name" - if $number_sections && $tag !~ /^unnumbered/; + if $number_sections && $tag !~ /^unnumbered/ && $tag ne 'subsubheading'; if ($tag =~ /heading$/) { push(@lines, &html_debug("\n", __LINE__)); if ($html_element ne 'body') { @@ -1079,7 +1093,7 @@ EOC push(@lines, &debug("
|g; + $what =~ s/(^|\s+)\@tab\s*/ <\/TD> /g; push(@lines, &debug("
$what\n", __LINE__)); &html_push('TR'); if ($deferred_ref) @@ -1463,11 +1477,7 @@ print "# end of pass 4\n" if $verbose; # # #---############################################################################ -$header = < -EOT - + $header = ''; $full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; $title = $value{'_settitle'} || $full_title; $_ = &substitute_style($full_title); @@ -1815,8 +1825,10 @@ sub fix_image die "error in image: '$text'" unless defined($1); $arg1 = $1; $arg1 =~ s/@@/@/g; - $ext = "jpg" if -f "$arg1.jpg"; - $ext = "gif" if -f "$arg1.gif"; + foreach (@include_dirs) { + $ext = "jpg" if -f "$_/$arg1.jpg"; + $ext = "gif" if -f "$_/$arg1.gif"; + } if (defined($ext)) { ""; @@ -2010,7 +2022,7 @@ sub print_toplevel_header { local($_); - &print_header; # pass given arg... + &print_header unless $opt_empty_headers; # pass given arg... print FILE $full_title; if ($value{'_subtitle'}) { $value{'_subtitle'} =~ s/\n+$//; @@ -2042,13 +2054,7 @@ EOT sub print_toplevel_footer { - &print_ruler; - print FILE <texi2html -translator version 1.52 (extended by davida\@detron.se).

-EOT - &print_footer; + &print_footer unless $opt_empty_headers; } sub protect_texi @@ -2065,8 +2071,10 @@ sub protect_html { local($what) = @_; # protect & < > - # Avoid loop in & replacement. This instead bugs out for &# in text.. - $what =~ s/\&([^#]|$)/\&\#38;$1/g; + # hack for the two entity-like variable reference in existing examples + $what =~ s/\&(length|ts);/\&\#38;$1;/g; + # this leaves alone entities, but encodes standalone ampersands + $what =~ s/\&(?!([a-z0-9]+|#\d+);)/\&\#38;/ig; $what =~ s/\/\&\#62;/g; # but recognize some HTML things From 6b720d93be6c63b4f340ef1add6db4cb96f90fe2 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 27 Oct 2004 21:51:27 +0200 Subject: [PATCH 009/101] - Applied some Windows portability fixes for myisampack.c and sql_handler.cc (backports from fixes made in 4.1) --- myisam/myisampack.c | 2 +- sql/sql_handler.cc | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 0dde1916f03..9f4e3bde65a 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -2047,7 +2047,7 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length, share->state.dellink= HA_OFFSET_ERROR; share->state.split=(ha_rows) mrg->records; share->state.version=(ulong) time((time_t*) 0); - if (share->state.key_map != (1ULL << share->base.keys) - 1) + if (share->state.key_map != (((ulonglong)1) << share->base.keys) - 1) { /* Some indexes are disabled, cannot use current key_file_length value diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 44ffb713dcc..5bfcc897fc7 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -265,8 +265,6 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables) { TABLE_LIST *hash_tables; TABLE **table_ptr; - bool was_flushed= FALSE; - bool not_opened; DBUG_ENTER("mysql_ha_close"); DBUG_PRINT("enter",("'%s'.'%s' as '%s'", tables->db, tables->real_name, tables->alias)); @@ -363,7 +361,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, int err; int keyno=-1; uint num_rows; - bool was_flushed; MYSQL_LOCK *lock; DBUG_ENTER("mysql_ha_read"); DBUG_PRINT("enter",("'%s'.'%s' as '%s'", @@ -615,10 +612,8 @@ err0: int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags) { - TABLE_LIST **tmp_tables_p; TABLE_LIST *tmp_tables; TABLE **table_ptr; - bool was_flushed; DBUG_ENTER("mysql_ha_flush"); DBUG_PRINT("enter", ("tables: %p mode_flags: 0x%02x", tables, mode_flags)); @@ -692,14 +687,13 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags) { TABLE_LIST *hash_tables; TABLE *table= *table_ptr; - bool was_flushed; DBUG_ENTER("mysql_ha_flush_table"); DBUG_PRINT("enter",("'%s'.'%s' as '%s' flags: 0x%02x", table->table_cache_key, table->real_name, table->table_name, mode_flags)); if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (*table_ptr)->table_name, + (byte*) (*table_ptr)->table_name, strlen((*table_ptr)->table_name) + 1))) { if (! (mode_flags & MYSQL_HA_REOPEN_ON_USAGE)) From a206cb757450b3c807ec2204e060792b8e4b66d5 Mon Sep 17 00:00:00 2001 From: "joreland@mysql.com" <> Date: Thu, 28 Oct 2004 10:50:39 +0200 Subject: [PATCH 010/101] Fix for aix4 which defines clock_gettime, but it only returns ENOSYS --- configure.in | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 979782fe511..9376f8748ee 100644 --- a/configure.in +++ b/configure.in @@ -1913,7 +1913,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bzero chsize cuserid fchmod fcntl \ getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \ getpwuid getrlimit getrusage getwd gmtime_r index initgroups isnan \ localtime_r locking longjmp lrand48 madvise mallinfo memcpy memmove \ - mkstemp mlockall perror poll pread pthread_attr_create clock_gettime \ + mkstemp mlockall perror poll pread pthread_attr_create \ pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \ pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \ pthread_key_delete pthread_rwlock_rdlock pthread_setprio \ @@ -1922,6 +1922,18 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bzero chsize cuserid fchmod fcntl \ snprintf socket stpcpy strcasecmp strerror strnlen strpbrk strstr strtol \ strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr) +# +# +# +case "$target" in + *-*-aix4*) + # (grr) aix 4.3 has a stub for clock_gettime, (returning ENOSYS) + # and using AC_TRY_RUN is hard when cross-compiling + ;; + *) AC_CHECK_FUNCS(clock_gettime) + ;; +esac + # isinf() could be a function or a macro (HPUX) AC_MSG_CHECKING(for isinf with ) AC_TRY_LINK([#include ], [float f = 0.0; isinf(f)], From 0003a8d5a0b541563888ca667d86ee5ea3964940 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 28 Oct 2004 11:19:51 +0000 Subject: [PATCH 011/101] added test for max limit of 128 attributes in table new define for long signal section size bumbed up limit for attributes to 128 use new define in SectionSegment some bug fixing of send fragmented signal + make chunk size a multiple the dew define for SectionSegment size --- mysql-test/r/ndb_basic.result | 131 ++++++++++++++++++++++++++ mysql-test/t/ndb_basic.test | 136 +++++++++++++++++++++++++++ ndb/include/kernel/ndb_limits.h | 5 + ndb/include/ndbapi/ndbapi_limits.h | 2 +- ndb/src/kernel/vm/LongSignal.hpp | 2 +- ndb/src/ndbapi/TransporterFacade.cpp | 64 +++++++------ 6 files changed, 311 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index abe1b98b536..37083beac89 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -414,3 +414,134 @@ select * from t1 where b IS NOT NULL; a b 1 drop table t1; +create table t1 ( +c1 int, +c2 int, +c3 int, +c4 int, +c5 int, +c6 int, +c7 int, +c8 int, +c9 int, +c10 int, +c11 int, +c12 int, +c13 int, +c14 int, +c15 int, +c16 int, +c17 int, +c18 int, +c19 int, +c20 int, +c21 int, +c22 int, +c23 int, +c24 int, +c25 int, +c26 int, +c27 int, +c28 int, +c29 int, +c30 int, +c31 int, +c32 int, +c33 int, +c34 int, +c35 int, +c36 int, +c37 int, +c38 int, +c39 int, +c40 int, +c41 int, +c42 int, +c43 int, +c44 int, +c45 int, +c46 int, +c47 int, +c48 int, +c49 int, +c50 int, +c51 int, +c52 int, +c53 int, +c54 int, +c55 int, +c56 int, +c57 int, +c58 int, +c59 int, +c60 int, +c61 int, +c62 int, +c63 int, +c64 int, +c65 int, +c66 int, +c67 int, +c68 int, +c69 int, +c70 int, +c71 int, +c72 int, +c73 int, +c74 int, +c75 int, +c76 int, +c77 int, +c78 int, +c79 int, +c80 int, +c81 int, +c82 int, +c83 int, +c84 int, +c85 int, +c86 int, +c87 int, +c88 int, +c89 int, +c90 int, +c91 int, +c92 int, +c93 int, +c94 int, +c95 int, +c96 int, +c97 int, +c98 int, +c99 int, +c100 int, +c101 int, +c102 int, +c103 int, +c104 int, +c105 int, +c106 int, +c107 int, +c108 int, +c109 int, +c110 int, +c111 int, +c112 int, +c113 int, +c114 int, +c115 int, +c116 int, +c117 int, +c118 int, +c119 int, +c120 int, +c121 int, +c122 int, +c123 int, +c124 int, +c125 int, +c126 int, +c127 int, +c128 int, +primary key(c1)) engine=ndb; +drop table t1; diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index e79815bbeb1..0d4bffce80d 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -371,3 +371,139 @@ select * from t1 order by b; select * from t1 where b IS NULL; select * from t1 where b IS NOT NULL; drop table t1; + +# +# test the limit of no of attributes in one table +# + +create table t1 ( +c1 int, +c2 int, +c3 int, +c4 int, +c5 int, +c6 int, +c7 int, +c8 int, +c9 int, +c10 int, +c11 int, +c12 int, +c13 int, +c14 int, +c15 int, +c16 int, +c17 int, +c18 int, +c19 int, +c20 int, +c21 int, +c22 int, +c23 int, +c24 int, +c25 int, +c26 int, +c27 int, +c28 int, +c29 int, +c30 int, +c31 int, +c32 int, +c33 int, +c34 int, +c35 int, +c36 int, +c37 int, +c38 int, +c39 int, +c40 int, +c41 int, +c42 int, +c43 int, +c44 int, +c45 int, +c46 int, +c47 int, +c48 int, +c49 int, +c50 int, +c51 int, +c52 int, +c53 int, +c54 int, +c55 int, +c56 int, +c57 int, +c58 int, +c59 int, +c60 int, +c61 int, +c62 int, +c63 int, +c64 int, +c65 int, +c66 int, +c67 int, +c68 int, +c69 int, +c70 int, +c71 int, +c72 int, +c73 int, +c74 int, +c75 int, +c76 int, +c77 int, +c78 int, +c79 int, +c80 int, +c81 int, +c82 int, +c83 int, +c84 int, +c85 int, +c86 int, +c87 int, +c88 int, +c89 int, +c90 int, +c91 int, +c92 int, +c93 int, +c94 int, +c95 int, +c96 int, +c97 int, +c98 int, +c99 int, +c100 int, +c101 int, +c102 int, +c103 int, +c104 int, +c105 int, +c106 int, +c107 int, +c108 int, +c109 int, +c110 int, +c111 int, +c112 int, +c113 int, +c114 int, +c115 int, +c116 int, +c117 int, +c118 int, +c119 int, +c120 int, +c121 int, +c122 int, +c123 int, +c124 int, +c125 int, +c126 int, +c127 int, +c128 int, +primary key(c1)) engine=ndb; +drop table t1; diff --git a/ndb/include/kernel/ndb_limits.h b/ndb/include/kernel/ndb_limits.h index 88fcff22da7..48a56c019bb 100644 --- a/ndb/include/kernel/ndb_limits.h +++ b/ndb/include/kernel/ndb_limits.h @@ -117,4 +117,9 @@ */ #define NDB_BLOB_HEAD_SIZE 2 /* sizeof(NdbBlob::Head) >> 2 */ +/* + * Long signals + */ +#define NDB_SECTION_SEGMENT_SZ 60 + #endif diff --git a/ndb/include/ndbapi/ndbapi_limits.h b/ndb/include/ndbapi/ndbapi_limits.h index 1cf2d9b342d..6b8787d587d 100644 --- a/ndb/include/ndbapi/ndbapi_limits.h +++ b/ndb/include/ndbapi/ndbapi_limits.h @@ -22,7 +22,7 @@ #define NDB_MAX_DATABASE_NAME_SIZE 128 #define NDB_MAX_SCHEMA_NAME_SIZE 128 #define NDB_MAX_TAB_NAME_SIZE 128 -#define NDB_MAX_ATTRIBUTES_IN_TABLE 91 +#define NDB_MAX_ATTRIBUTES_IN_TABLE 128 #define NDB_MAX_TUPLE_SIZE_IN_WORDS 1023 #define NDB_MAX_KEYSIZE_IN_WORDS 1023 diff --git a/ndb/src/kernel/vm/LongSignal.hpp b/ndb/src/kernel/vm/LongSignal.hpp index f9ed443d995..9818358011f 100644 --- a/ndb/src/kernel/vm/LongSignal.hpp +++ b/ndb/src/kernel/vm/LongSignal.hpp @@ -25,7 +25,7 @@ */ struct SectionSegment { - STATIC_CONST( DataLength = 60 ); + STATIC_CONST( DataLength = NDB_SECTION_SEGMENT_SZ ); Uint32 m_ownerRef; Uint32 m_sz; diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 0377cf0c84b..6495fee444a 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -34,6 +34,7 @@ #include #include #include +#include //#define REPORT_TRANSPORTER //#define API_TRACE; @@ -834,10 +835,14 @@ TransporterFacade::sendSignalUnCond(NdbApiSignal * aSignal, NodeId aNode){ return (ss == SEND_OK ? 0 : -1); } -#define CHUNK_SZ 100u +#define CHUNK_SZ NDB_SECTION_SEGMENT_SZ*1 int TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, - LinearSectionPtr ptr[3], Uint32 secs){ + LinearSectionPtr ptr[3], Uint32 secs) +{ + if(getIsNodeSendable(aNode) != true) + return -1; + NdbApiSignal tmp_signal(*(SignalHeader*)aSignal); LinearSectionPtr tmp_ptr[3]; Uint32 unique_id= m_fragmented_signal_id++; // next unique id @@ -855,41 +860,47 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, if (chunk_sz + save_sz > CHUNK_SZ) { // truncate unsigned send_sz= CHUNK_SZ - chunk_sz; + if (i != start_i) // first piece of a new section has to be a multiple of NDB_SECTION_SEGMENT_SZ + { + send_sz= + NDB_SECTION_SEGMENT_SZ + *(send_sz+NDB_SECTION_SEGMENT_SZ-1) + /NDB_SECTION_SEGMENT_SZ; + if (send_sz > save_sz) + send_sz= save_sz; + } tmp_ptr[i].sz= send_sz; - if (fragment_info < 2) + + if (fragment_info < 2) // 1 = first fragment, 2 = middle fragments fragment_info++; // send tmp_signal tmp_data[i-start_i+1]= unique_id; tmp_signal.setLength(i-start_i+2); tmp_signal.m_fragmentInfo= fragment_info; + tmp_signal.m_noOfSections= i-start_i+1; // do prepare send { - int ret; - if(getIsNodeSendable(aNode) == true){ - SendStatus ss = theTransporterRegistry->prepareSend - (&tmp_signal, - 1, // JBB - tmp_signal.getDataPtrSend(), - aNode, - &ptr[start_i]); - assert(ss != SEND_MESSAGE_TOO_BIG); - ret = (ss == SEND_OK ? 0 : -1); - } else - ret = -1; - if (ret != SEND_OK) - return ret; + SendStatus ss = theTransporterRegistry->prepareSend + (&tmp_signal, + 1, /*JBB*/ + tmp_data, + aNode, + &tmp_ptr[start_i]); + assert(ss != SEND_MESSAGE_TOO_BIG); + if (ss != SEND_OK) return -1; } - // setup variables for next signal start_i= i; chunk_sz= 0; tmp_ptr[i].sz= save_sz-send_sz; tmp_ptr[i].p+= send_sz; + if (tmp_ptr[i].sz == 0) + i++; } else { - chunk_sz+= save_sz; + chunk_sz+=save_sz; i++; } } @@ -907,7 +918,7 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, aSignal->setLength(a_sz+tmp_sz+1); // send last fragment - aSignal->m_fragmentInfo= 3; + aSignal->m_fragmentInfo= 3; // 3 = last fragment aSignal->m_noOfSections= i-start_i; } else { aSignal->m_noOfSections= secs; @@ -915,17 +926,16 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, // send aSignal int ret; - if(getIsNodeSendable(aNode) == true){ + { SendStatus ss = theTransporterRegistry->prepareSend - (aSignal, - 1, // JBB + (aSignal, + 1/*JBB*/, aSignal->getDataPtrSend(), - aNode, - &ptr[start_i]); + aNode, + &tmp_ptr[start_i]); assert(ss != SEND_MESSAGE_TOO_BIG); ret = (ss == SEND_OK ? 0 : -1); - } else - ret = -1; + } aSignal->m_noOfSections = 0; aSignal->m_fragmentInfo = 0; aSignal->setLength(a_sz); From 2d455470b695f91a6bcec0f440a488b44e5dd262 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 28 Oct 2004 11:24:59 +0000 Subject: [PATCH 012/101] ndbapi_limits.h: corrected define for NDB_MAX_TUPLE_SIZE_IN_WORDS --- ndb/include/ndbapi/ndbapi_limits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/include/ndbapi/ndbapi_limits.h b/ndb/include/ndbapi/ndbapi_limits.h index 6b8787d587d..b3577119e33 100644 --- a/ndb/include/ndbapi/ndbapi_limits.h +++ b/ndb/include/ndbapi/ndbapi_limits.h @@ -24,7 +24,7 @@ #define NDB_MAX_TAB_NAME_SIZE 128 #define NDB_MAX_ATTRIBUTES_IN_TABLE 128 -#define NDB_MAX_TUPLE_SIZE_IN_WORDS 1023 +#define NDB_MAX_TUPLE_SIZE_IN_WORDS 2013 #define NDB_MAX_KEYSIZE_IN_WORDS 1023 #define NDB_MAX_KEY_SIZE NDB_MAX_KEYSIZE_IN_WORDS*sizeof(Uint32) #define NDB_MAX_TUPLE_SIZE NDB_MAX_TUPLE_SIZE_IN_WORDS*sizeof(uint32) From af5f0b95c4cd308b21187131dddc77cedace619a Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 28 Oct 2004 11:56:09 +0000 Subject: [PATCH 013/101] Dbdict.cpp: changed to using fragmented signals for CREATE_TABLE_REQ --- ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index d1a8128ea7f..882557daae1 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -3661,9 +3661,8 @@ Dbdict::execCREATE_FRAGMENTATION_CONF(Signal* signal){ req->tableId = tabPtr.i; req->tableVersion = tabEntry->m_tableVersion + 1; - sendSignal(rg, GSN_CREATE_TAB_REQ, signal, - CreateTabReq::SignalLength, JBB); - + sendFragmentedSignal(rg, GSN_CREATE_TAB_REQ, signal, + CreateTabReq::SignalLength, JBB); return; } From 1f646ecc7ce9347eca5548729172d59a31d5e095 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 28 Oct 2004 13:50:46 +0000 Subject: [PATCH 014/101] set set "CHUNK_SZ" for fragmented signal to real value added API_TRACE code removed old implementation of fragmented signal --- ndb/src/ndbapi/TransporterFacade.cpp | 80 +++++----------------------- 1 file changed, 14 insertions(+), 66 deletions(-) diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 6495fee444a..2bf2b39f9a6 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -835,7 +835,7 @@ TransporterFacade::sendSignalUnCond(NdbApiSignal * aSignal, NodeId aNode){ return (ss == SEND_OK ? 0 : -1); } -#define CHUNK_SZ NDB_SECTION_SEGMENT_SZ*1 +#define CHUNK_SZ NDB_SECTION_SEGMENT_SZ*64 // related to MAX_MESSAGE_SIZE int TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, LinearSectionPtr ptr[3], Uint32 secs) @@ -843,6 +843,19 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, if(getIsNodeSendable(aNode) != true) return -1; +#ifdef API_TRACE + if(setSignalLog() && TRACE_GSN(aSignal->theVerId_signalNumber)){ + Uint32 tmp = aSignal->theSendersBlockRef; + aSignal->theSendersBlockRef = numberToRef(tmp, theOwnId); + signalLogger.sendSignal(* aSignal, + 1, + aSignal->getDataPtrSend(), + aNode, + ptr, secs); + aSignal->theSendersBlockRef = tmp; + } +#endif + NdbApiSignal tmp_signal(*(SignalHeader*)aSignal); LinearSectionPtr tmp_ptr[3]; Uint32 unique_id= m_fragmented_signal_id++; // next unique id @@ -942,71 +955,6 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, return ret; } -#if 0 -int -TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, - LinearSectionPtr ptr[3], Uint32 secs){ - aSignal->m_noOfSections = secs; - if(getIsNodeSendable(aNode) == true){ -#ifdef API_TRACE - if(setSignalLog() && TRACE_GSN(aSignal->theVerId_signalNumber)){ - Uint32 tmp = aSignal->theSendersBlockRef; - aSignal->theSendersBlockRef = numberToRef(tmp, theOwnId); - signalLogger.sendSignal(* aSignal, - 1, - aSignal->getDataPtrSend(), - aNode, - ptr, secs); - signalLogger.flushSignalLog(); - aSignal->theSendersBlockRef = tmp; - } -#endif - SendStatus ss = theTransporterRegistry->prepareSend - (aSignal, - 1, // JBB - aSignal->getDataPtrSend(), - aNode, - ptr); - assert(ss != SEND_MESSAGE_TOO_BIG); - aSignal->m_noOfSections = 0; - return (ss == SEND_OK ? 0 : -1); - } - aSignal->m_noOfSections = 0; - return -1; -} -#endif - - -int -TransporterFacade::sendFragmentedSignalUnCond(NdbApiSignal* aSignal, - NodeId aNode, - LinearSectionPtr ptr[3], - Uint32 secs){ - aSignal->m_noOfSections = secs; - -#ifdef API_TRACE - if(setSignalLog() && TRACE_GSN(aSignal->theVerId_signalNumber)){ - Uint32 tmp = aSignal->theSendersBlockRef; - aSignal->theSendersBlockRef = numberToRef(tmp, theOwnId); - signalLogger.sendSignal(* aSignal, - 1, - aSignal->getDataPtrSend(), - aNode, - ptr, secs); - aSignal->theSendersBlockRef = tmp; - } -#endif - SendStatus ss = - theTransporterRegistry->prepareSend(aSignal, 1, // JBB - aSignal->getDataPtrSend(), - aNode, ptr); - assert(ss != SEND_MESSAGE_TOO_BIG); - aSignal->m_noOfSections = 0; - return (ss == SEND_OK ? 0 : -1); -} - - - /****************************************************************************** * CONNECTION METHODS Etc ******************************************************************************/ From bbe970beabf0439fc11ffbea60d60e98755fdbac Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 28 Oct 2004 14:49:40 +0000 Subject: [PATCH 015/101] scan should not send fragmented signal use new sendSignal method instead new send signal method which sends segments remove unused method sendFragmentedSignalUnCond --- ndb/src/ndbapi/NdbScanOperation.cpp | 4 ++-- ndb/src/ndbapi/TransporterFacade.cpp | 32 ++++++++++++++++++++++++++++ ndb/src/ndbapi/TransporterFacade.hpp | 7 ++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index fd63ce96f25..86bac7deb16 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -612,7 +612,7 @@ NdbScanOperation::send_next_scan(Uint32 cnt, bool stopScanFlag){ LinearSectionPtr ptr[3]; ptr[0].p = prep_array; ptr[0].sz = cnt; - ret = tp->sendFragmentedSignal(&tSignal, nodeId, ptr, 1); + ret = tp->sendSignal(&tSignal, nodeId, ptr, 1); } else { tSignal.setLength(4+cnt); ret = tp->sendSignal(&tSignal, nodeId); @@ -803,7 +803,7 @@ NdbScanOperation::doSendScan(int aProcessorId) LinearSectionPtr ptr[3]; ptr[0].p = m_prepared_receivers; ptr[0].sz = theParallelism; - if (tp->sendFragmentedSignal(tSignal, aProcessorId, ptr, 1) == -1) { + if (tp->sendSignal(tSignal, aProcessorId, ptr, 1) == -1) { setErrorCode(4002); return -1; } diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 2bf2b39f9a6..dfb090c8416 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -955,6 +955,38 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, return ret; } +int +TransporterFacade::sendSignal(NdbApiSignal* aSignal, NodeId aNode, + LinearSectionPtr ptr[3], Uint32 secs){ + aSignal->m_noOfSections = secs; + if(getIsNodeSendable(aNode) == true){ +#ifdef API_TRACE + if(setSignalLog() && TRACE_GSN(aSignal->theVerId_signalNumber)){ + Uint32 tmp = aSignal->theSendersBlockRef; + aSignal->theSendersBlockRef = numberToRef(tmp, theOwnId); + signalLogger.sendSignal(* aSignal, + 1, + aSignal->getDataPtrSend(), + aNode, + ptr, secs); + signalLogger.flushSignalLog(); + aSignal->theSendersBlockRef = tmp; + } +#endif + SendStatus ss = theTransporterRegistry->prepareSend + (aSignal, + 1, // JBB + aSignal->getDataPtrSend(), + aNode, + ptr); + assert(ss != SEND_MESSAGE_TOO_BIG); + aSignal->m_noOfSections = 0; + return (ss == SEND_OK ? 0 : -1); + } + aSignal->m_noOfSections = 0; + return -1; +} + /****************************************************************************** * CONNECTION METHODS Etc ******************************************************************************/ diff --git a/ndb/src/ndbapi/TransporterFacade.hpp b/ndb/src/ndbapi/TransporterFacade.hpp index b288e2ee8e6..5680e3a6f03 100644 --- a/ndb/src/ndbapi/TransporterFacade.hpp +++ b/ndb/src/ndbapi/TransporterFacade.hpp @@ -69,14 +69,11 @@ public: // Only sends to nodes which are alive int sendSignal(NdbApiSignal * signal, NodeId nodeId); + int sendSignal(NdbApiSignal*, NodeId, + LinearSectionPtr ptr[3], Uint32 secs); int sendFragmentedSignal(NdbApiSignal*, NodeId, LinearSectionPtr ptr[3], Uint32 secs); - //Dirrrrty - int sendFragmentedSignalUnCond(NdbApiSignal*, NodeId, - LinearSectionPtr ptr[3], Uint32 secs); - - // Is node available for running transactions bool get_node_alive(NodeId nodeId) const; bool get_node_stopping(NodeId nodeId) const; From 289f68a1b97d5e2236efc9d05e8aba94490791ac Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 28 Oct 2004 15:35:06 +0000 Subject: [PATCH 016/101] test that attribute name truncation works exposed the attribute name size limit for handler added field name truncation to ndb handler --- mysql-test/t/ndb_basic.test | 15 +++++++++++++++ ndb/include/ndbapi/ndbapi_limits.h | 1 + sql/ha_ndbcluster.cc | 21 ++++++++++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 0d4bffce80d..f5bed3dcdff 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -507,3 +507,18 @@ c127 int, c128 int, primary key(c1)) engine=ndb; drop table t1; + +# +# test max size of attribute name and truncation +# + +create table t1 ( +a1234567890123456789012345678901234567890 int primary key, +a12345678901234567890123456789a1234567890 int, +index(a12345678901234567890123456789a1234567890) +) engine=ndb; +show tables; +insert into t1 values (1,1),(2,1),(3,1),(4,1),(5,2),(6,1),(7,1); +explain select * from t1 where a12345678901234567890123456789a1234567890=2; +select * from t1 where a12345678901234567890123456789a1234567890=2; +drop table t1; diff --git a/ndb/include/ndbapi/ndbapi_limits.h b/ndb/include/ndbapi/ndbapi_limits.h index b3577119e33..05556ab2f5f 100644 --- a/ndb/include/ndbapi/ndbapi_limits.h +++ b/ndb/include/ndbapi/ndbapi_limits.h @@ -22,6 +22,7 @@ #define NDB_MAX_DATABASE_NAME_SIZE 128 #define NDB_MAX_SCHEMA_NAME_SIZE 128 #define NDB_MAX_TAB_NAME_SIZE 128 +#define NDB_MAX_ATTR_NAME_SIZE 32 #define NDB_MAX_ATTRIBUTES_IN_TABLE 128 #define NDB_MAX_TUPLE_SIZE_IN_WORDS 2013 diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 044cb85b913..838cf69855a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1393,8 +1393,13 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, // Set bound if not cancelled via type -1 if (p.bound_type != -1) - if (op->setBound(field->field_name, p.bound_type, p.bound_ptr)) + { + char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE]; + strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name)); + truncated_field_name[sizeof(truncated_field_name)-1]= '\0'; + if (op->setBound(truncated_field_name, p.bound_type, p.bound_ptr)) ERR_RETURN(op->getNdbError()); + } } } @@ -3102,7 +3107,12 @@ static int create_ndb_column(NDBCOL &col, HA_CREATE_INFO *info) { // Set name - col.setName(field->field_name); + { + char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE]; + strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name)); + truncated_field_name[sizeof(truncated_field_name)-1]= '\0'; + col.setName(truncated_field_name); + } // Get char set CHARSET_INFO *cs= field->charset(); // Set type and sizes @@ -3430,7 +3440,12 @@ int ha_ndbcluster::create_index(const char *name, { Field *field= key_part->field; DBUG_PRINT("info", ("attr: %s", field->field_name)); - ndb_index.addColumnName(field->field_name); + { + char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE]; + strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name)); + truncated_field_name[sizeof(truncated_field_name)-1]= '\0'; + ndb_index.addColumnName(truncated_field_name); + } } if (dict->createIndex(ndb_index)) From 54e72c72071972d4051d8e6f96ed25ad688483ff Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 28 Oct 2004 15:43:16 +0000 Subject: [PATCH 017/101] ndb_basic.result: forgot to commit new result --- mysql-test/r/ndb_basic.result | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 37083beac89..604084a72c2 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -545,3 +545,19 @@ c127 int, c128 int, primary key(c1)) engine=ndb; drop table t1; +create table t1 ( +a1234567890123456789012345678901234567890 int primary key, +a12345678901234567890123456789a1234567890 int, +index(a12345678901234567890123456789a1234567890) +) engine=ndb; +show tables; +Tables_in_test +t1 +insert into t1 values (1,1),(2,1),(3,1),(4,1),(5,2),(6,1),(7,1); +explain select * from t1 where a12345678901234567890123456789a1234567890=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a12345678901234567890123456789a1234567890 a12345678901234567890123456789a1234567890 5 const 10 Using where +select * from t1 where a12345678901234567890123456789a1234567890=2; +a1234567890123456789012345678901234567890 a12345678901234567890123456789a1234567890 +5 2 +drop table t1; From 8894a6bb73be7cfdc649a97e08c0ad4888cc14f3 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Thu, 28 Oct 2004 21:14:00 +0300 Subject: [PATCH 018/101] close table before next iteration of table proccesing in mysql_admin_table (to allow open next table) --- sql/sql_table.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8190e31bc0b..65690e56039 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1268,9 +1268,13 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, if (prepare_func) { switch ((*prepare_func)(thd, table, check_opt)) { - case 1: continue; // error, message written to net - case -1: goto err; // error, message could be written to net - default: ; // should be 0 otherwise + case 1: // error, message written to net + close_thread_tables(thd); + continue; + case -1: // error, message could be written to net + goto err; + default: // should be 0 otherwise + ; } } From 35e8670301f854b5b1541cd39deaab2f0c046bbd Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 29 Oct 2004 09:24:21 +0200 Subject: [PATCH 019/101] - bumped up version number from 4.0.22 to 4.0.23 in configure.in - tagged ChangeSet@1.2048.1.2 as "mysql-4.0.22" --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index d4073ea441b..d4ede468435 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.22) +AM_INIT_AUTOMAKE(mysql, 4.0.23) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 19bc50957fdc53d3df7f803ed7b8202b6a18c2e4 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Fri, 29 Oct 2004 09:49:04 +0000 Subject: [PATCH 020/101] Tru64 cxx compiler fix cxx does not include -I/ust/include.dtk as it should removed dependency on ndb_types --- configure.in | 3 ++- ndb/include/ndbapi/ndbapi_limits.h | 4 ++-- sql/ha_ndbcluster.h | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 656af354607..ec003b55cb5 100644 --- a/configure.in +++ b/configure.in @@ -1144,7 +1144,8 @@ dnl Is this the right match for DEC OSF on alpha? # gethostbyname_r is deprecated and doesn't work ok on OSF1 CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R" CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R" - ndb_cxxflags_fix="$ndb_cxxflags_fix -I/usr/include.dtk" + # fix to handle include of correctly on OSF1 with cxx compiler + CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include.dtk" ;; *netware*) # No need for curses library so set it to null diff --git a/ndb/include/ndbapi/ndbapi_limits.h b/ndb/include/ndbapi/ndbapi_limits.h index 1cf2d9b342d..f812fa2d69d 100644 --- a/ndb/include/ndbapi/ndbapi_limits.h +++ b/ndb/include/ndbapi/ndbapi_limits.h @@ -26,8 +26,8 @@ #define NDB_MAX_TUPLE_SIZE_IN_WORDS 1023 #define NDB_MAX_KEYSIZE_IN_WORDS 1023 -#define NDB_MAX_KEY_SIZE NDB_MAX_KEYSIZE_IN_WORDS*sizeof(Uint32) -#define NDB_MAX_TUPLE_SIZE NDB_MAX_TUPLE_SIZE_IN_WORDS*sizeof(uint32) +#define NDB_MAX_KEY_SIZE (NDB_MAX_KEYSIZE_IN_WORDS*4) +#define NDB_MAX_TUPLE_SIZE (NDB_MAX_TUPLE_SIZE_IN_WORDS*4) #define NDB_MAX_ACTIVE_EVENTS 100 #endif diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 8224d1c4167..b33a0657d4f 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -26,7 +26,6 @@ #endif #include -#include class Ndb; // Forward declaration class NdbOperation; // Forward declaration From ea49a5181ae9ae0b0bca6d1b9e1ca26023a68b4c Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 29 Oct 2004 16:00:03 +0500 Subject: [PATCH 021/101] Allow to convert to non-Unicode charset when mixing a string constant with a column. The string is converted into the column character set. It conversion doesn't lose data, then operation is possible. Otherwise, give an error, as it was earlier. --- mysql-test/r/ctype_recoding.result | 12 +++ mysql-test/t/ctype_recoding.test | 22 ++++++ sql/item.cc | 81 +++++++++++++++----- sql/item.h | 16 +++- sql/item_cmpfunc.cc | 118 +++++++++++++++++------------ sql/item_func.cc | 8 +- sql/item_func.h | 4 +- 7 files changed, 187 insertions(+), 74 deletions(-) diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index 72d19885101..dc1f4c12e25 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -174,3 +174,15 @@ Warnings: Warning 1265 Data truncated for column 'a' at row 1 Warning 1265 Data truncated for column 'b' at row 1 drop table t1; +set names koi8r; +create table t1 (a char(10) character set cp1251); +insert into t1 values (_koi8r'×ÁÓÑ'); +select * from t1 where a=_koi8r'×ÁÓÑ'; +a +×ÁÓÑ +select * from t1 where a=concat(_koi8r'×ÁÓÑ'); +ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation '=' +select * from t1 where a=_latin1'×ÁÓÑ'; +ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '=' +drop table t1; +set names latin1; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 5f417352d95..dab898e9f2c 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -131,3 +131,25 @@ create table t1 (a char(10) character set koi8r, b text character set koi8r); insert into t1 values ('test','test'); insert into t1 values ('ÊÃÕË','ÊÃÕË'); drop table t1; + +# +# Try to apply an automatic conversion in some cases: +# E.g. when mixing a column to a string, the string +# is converted into the column character set. +# If conversion loses data, then error. Otherwise, +# the string is replaced by its converted representation +# +set names koi8r; +create table t1 (a char(10) character set cp1251); +insert into t1 values (_koi8r'×ÁÓÑ'); +# this is possible: +select * from t1 where a=_koi8r'×ÁÓÑ'; +# this is not possible, because we have a function, not just a constant: +--error 1267 +select * from t1 where a=concat(_koi8r'×ÁÓÑ'); +# this is not posible, cannot convert _latin1'×ÁÓÑ' into cp1251: +--error 1267 +select * from t1 where a=_latin1'×ÁÓÑ'; +drop table t1; +set names latin1; + diff --git a/sql/item.cc b/sql/item.cc index b4c416e7741..18025d6d689 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -259,7 +259,43 @@ CHARSET_INFO *Item::default_charset() return current_thd->variables.collation_connection; } -bool DTCollation::aggregate(DTCollation &dt, bool superset_conversion) + +/* + Aggregate two collations together taking + into account their coercibility (aka derivation): + + 0 == DERIVATION_EXPLICIT - an explicitely written COLLATE clause + 1 == DERIVATION_NONE - a mix of two different collations + 2 == DERIVATION_IMPLICIT - a column + 3 == DERIVATION_COERCIBLE - a string constant + + The most important rules are: + + 1. If collations are the same: + chose this collation, and the strongest derivation. + + 2. If collations are different: + - Character sets may differ, but only if conversion without + data loss is possible. The caller provides flags whether + character set conversion attempts should be done. If no + flags are substituted, then the character sets must be the same. + Currently processed flags are: + MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset + MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value + - two EXPLICIT collations produce an error, e.g. this is wrong: + CONCAT(expr1 collate latin1_swedish_ci, expr2 collate latin1_german_ci) + - the side with smaller derivation value wins, + i.e. a column is stronger than a string constant, + an explicit COLLATE clause is stronger than a column. + - if derivations are the same, we have DERIVATION_NONE, + we'll wait for an explicit COLLATE clause which possibly can + come from another argument later: for example, this is valid, + but we don't know yet when collecting the first two arguments: + CONCAT(latin1_swedish_ci_column, + latin1_german1_ci_column, + expr COLLATE latin1_german2_ci) +*/ +bool DTCollation::aggregate(DTCollation &dt, uint flags) { nagg++; if (!my_charset_same(collation, dt.collation)) @@ -290,28 +326,37 @@ bool DTCollation::aggregate(DTCollation &dt, bool superset_conversion) else ; // Do nothing } - else if (superset_conversion) + else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && + derivation < dt.derivation && + collation->state & MY_CS_UNICODE) { - if (derivation < dt.derivation && - collation->state & MY_CS_UNICODE) - ; // Do nothing - else if (dt.derivation < derivation && - dt.collation->state & MY_CS_UNICODE) - { - set(dt); - strong= nagg; - } - else - { - // Cannot convert to superset - set(0, DERIVATION_NONE); - return 1; - } + // Do nothing + } + else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && + dt.derivation < derivation && + dt.collation->state & MY_CS_UNICODE) + { + set(dt); + strong= nagg; + } + else if ((flags & MY_COLL_ALLOW_COERCIBLE_CONV) && + derivation < dt.derivation && + dt.derivation == DERIVATION_COERCIBLE) + { + // Do nothing; + } + else if ((flags & MY_COLL_ALLOW_COERCIBLE_CONV) && + dt.derivation < derivation && + derivation == DERIVATION_COERCIBLE) + { + set(dt); + strong= nagg; } else { + // Cannot apply conversion set(0, DERIVATION_NONE); - return 1; + return 1; } } else if (derivation < dt.derivation) diff --git a/sql/item.h b/sql/item.h index e22cef7ba7f..2c0c3306c44 100644 --- a/sql/item.h +++ b/sql/item.h @@ -37,6 +37,16 @@ enum Derivation DERIVATION_EXPLICIT= 0 }; +/* + Flags for collation aggregation modes: + allow conversion to a superset + allow conversion of a coercible value (i.e. constant). +*/ + +#define MY_COLL_ALLOW_SUPERSET_CONV 1 +#define MY_COLL_ALLOW_COERCIBLE_CONV 2 + + class DTCollation { public: CHARSET_INFO *collation; @@ -72,9 +82,9 @@ public: { collation= collation_arg; } void set(Derivation derivation_arg) { derivation= derivation_arg; } - bool aggregate(DTCollation &dt, bool superset_conversion= FALSE); - bool set(DTCollation &dt1, DTCollation &dt2, bool superset_conversion= FALSE) - { set(dt1); return aggregate(dt2, superset_conversion); } + bool aggregate(DTCollation &dt, uint flags= 0); + bool set(DTCollation &dt1, DTCollation &dt2, uint flags= 0) + { set(dt1); return aggregate(dt2, flags); } const char *derivation_name() const { switch(derivation) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index c9396aaa67c..dc0377c791f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -174,62 +174,87 @@ void Item_bool_func2::fix_length_and_dec() return; /* - We allow to convert to Unicode character sets in some cases. + We allow to apply automatic character set conversion in some cases. The conditions when conversion is possible are: - arguments A and B have different charsets - A wins according to coercibility rules - - character set of A is superset for character set of B - + (i.e. a column is stronger than a string constant, + an explicit COLLATE clause is stronger than a column) + - character set of A is either superset for character set of B, + or B is a string constant which can be converted into the + character set of A without data loss. + If all of the above is true, then it's possible to convert B into the character set of A, and then compare according to the collation of A. */ - if (args[0] && args[1]) - { - uint strong= 0; - uint weak= 0; - uint32 dummy_offset; - DTCollation coll; + uint32 dummy_offset; + DTCollation coll; - if (args[0]->result_type() == STRING_RESULT && - args[1]->result_type() == STRING_RESULT && - String::needs_conversion(0, args[0]->collation.collation, - args[1]->collation.collation, - &dummy_offset) && - !coll.set(args[0]->collation, args[1]->collation, TRUE)) + if (args[0]->result_type() == STRING_RESULT && + args[1]->result_type() == STRING_RESULT && + String::needs_conversion(0, args[0]->collation.collation, + args[1]->collation.collation, + &dummy_offset) && + !coll.set(args[0]->collation, args[1]->collation, + MY_COLL_ALLOW_SUPERSET_CONV | + MY_COLL_ALLOW_COERCIBLE_CONV)) + { + Item* conv= 0; + Item_arena *arena= thd->current_arena, backup; + uint strong= coll.strong; + uint weak= strong ? 0 : 1; + /* + In case we're in statement prepare, create conversion item + in its memory: it will be reused on each execute. + */ + if (arena->is_stmt_prepare()) + thd->set_n_backup_item_arena(arena, &backup); + if (args[weak]->type() == STRING_ITEM) { - Item* conv= 0; - Item_arena *arena= thd->current_arena, backup; - strong= coll.strong; - weak= strong ? 0 : 1; - /* - In case we're in statement prepare, create conversion item - in its memory: it will be reused on each execute. - */ - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); - if (args[weak]->type() == STRING_ITEM) + uint conv_errors; + String tmp, cstr, *ostr= args[weak]->val_str(&tmp); + cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), + args[strong]->collation.collation, &conv_errors); + if (conv_errors) { - String tmp, cstr; - String *ostr= args[weak]->val_str(&tmp); - cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), - args[strong]->collation.collation); - conv= new Item_string(cstr.ptr(),cstr.length(),cstr.charset(), - args[weak]->collation.derivation); - ((Item_string*)conv)->str_value.copy(); + /* + We could not convert a string into the character set + of the stronger side of the operation without data loss. + It can happen if we tried to combine a column with a string + constant, and the column charset does not cover all the + characters from the string. Operation cannot be done + correctly. Return an error. + */ + my_coll_agg_error(args[0]->collation, args[1]->collation, + func_name()); + return; } - else - { - conv= new Item_func_conv_charset(args[weak], - args[strong]->collation.collation); - conv->collation.set(args[weak]->collation.derivation); - conv->fix_fields(thd, 0, &conv); - } - if (arena->is_stmt_prepare()) - thd->restore_backup_item_arena(arena, &backup); - args[weak]= conv ? conv : args[weak]; + conv= new Item_string(cstr.ptr(),cstr.length(),cstr.charset(), + args[weak]->collation.derivation); + ((Item_string*)conv)->str_value.copy(); } + else + { + if (!(coll.collation->state & MY_CS_UNICODE)) + { + /* + Don't allow automatic conversion to non-Unicode charsets, + as it potentially loses data. + */ + my_coll_agg_error(args[0]->collation, args[1]->collation, + func_name()); + return; + } + conv= new Item_func_conv_charset(args[weak], + args[strong]->collation.collation); + conv->collation.set(args[weak]->collation.derivation); + conv->fix_fields(thd, 0, &conv); + } + if (arena->is_stmt_prepare()) + thd->restore_backup_item_arena(arena, &backup); + args[weak]= conv ? conv : args[weak]; } // Make a special case of compare with fields to get nicer DATE comparisons @@ -1782,14 +1807,13 @@ void Item_func_in::fix_length_and_dec() via creating Item_func_conv_charset(). */ - if (agg_arg_collations_for_comparison(cmp_collation, - args, arg_count, TRUE)) + if (agg_arg_collations_for_comparison(cmp_collation, args, arg_count, + MY_COLL_ALLOW_SUPERSET_CONV)) return; if ((!my_charset_same(args[0]->collation.collation, cmp_collation.collation) || !const_itm)) { - if (agg_arg_collations_for_comparison(cmp_collation, - args, arg_count, FALSE)) + if (agg_arg_collations_for_comparison(cmp_collation, args, arg_count)) return; } else diff --git a/sql/item_func.cc b/sql/item_func.cc index 879c0b36bdd..3cb125d2868 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -76,7 +76,7 @@ static void my_coll_agg_error(Item** args, uint count, const char *fname) bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count, - bool allow_superset_conversion) + uint flags) { uint i; c.nagg= 0; @@ -84,7 +84,7 @@ bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count, c.set(av[0]->collation); for (i= 1; i < count; i++) { - if (c.aggregate(av[i]->collation, allow_superset_conversion)) + if (c.aggregate(av[i]->collation, flags)) { my_coll_agg_error(av, count, func_name()); return TRUE; @@ -96,9 +96,9 @@ bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count, bool Item_func::agg_arg_collations_for_comparison(DTCollation &c, Item **av, uint count, - bool allow_superset_conv) + uint flags) { - if (agg_arg_collations(c, av, count, allow_superset_conv)) + if (agg_arg_collations(c, av, count, flags)) return TRUE; if (c.derivation == DERIVATION_NONE) diff --git a/sql/item_func.h b/sql/item_func.h index 6e43d66a32d..963038227a2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -141,10 +141,10 @@ public: Item *get_tmp_table_item(THD *thd); bool agg_arg_collations(DTCollation &c, Item **items, uint nitems, - bool allow_superset_conversion= FALSE); + uint flags= 0); bool agg_arg_collations_for_comparison(DTCollation &c, Item **items, uint nitems, - bool allow_superset_comversion= FALSE); + uint flags= 0); bool walk(Item_processor processor, byte *arg); }; From 0a3d9a43b246cdaf57afa725134344d74e7ff07b Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Fri, 29 Oct 2004 11:06:06 +0000 Subject: [PATCH 022/101] configure.in: -I/usr/include needed for cxx on Tru64 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 7c6b9ff7b51..a361e11935c 100644 --- a/configure.in +++ b/configure.in @@ -1145,7 +1145,7 @@ dnl Is this the right match for DEC OSF on alpha? CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R" CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R" # fix to handle include of correctly on OSF1 with cxx compiler - CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include.dtk" + CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include -I/usr/include.dtk" ;; *netware*) # No need for curses library so set it to null From 64c59b37f899e520f6ba3ff8d0f9724423eb9b88 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 29 Oct 2004 16:06:51 +0500 Subject: [PATCH 023/101] item_strfunc.cc: Unnecessary code was removed. --- sql/item_strfunc.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c51894afde4..2d9f7e7bff8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -643,7 +643,12 @@ void Item_func_concat_ws::fix_length_and_dec() if (agg_arg_collations(collation, args, arg_count)) return; - max_length= arg_count > 1 ? args[0]->max_length * (arg_count - 2) : 0; + /* + arg_count cannot be less than 2, + it is done on parser level in sql_yacc.yy + so, (arg_count - 2) is safe here. + */ + max_length= args[0]->max_length * (arg_count - 2); for (uint i=1 ; i < arg_count ; i++) max_length+=args[i]->max_length; From d6481499cfb822c1891d1f7fc2c3f2f4b780f1ab Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Fri, 29 Oct 2004 11:25:16 +0000 Subject: [PATCH 024/101] bumped up version for ndb protocal change in create table, now allows for more than 91 attributes upgrade compatability with 3.5.3 --- configure.in | 2 +- ndb/src/common/util/version.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 9901ef5d4fd..392aaba2cda 100644 --- a/configure.in +++ b/configure.in @@ -15,7 +15,7 @@ SHARED_LIB_VERSION=14:0:0 # ndb version NDB_VERSION_MAJOR=3 NDB_VERSION_MINOR=5 -NDB_VERSION_BUILD=3 +NDB_VERSION_BUILD=4 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? diff --git a/ndb/src/common/util/version.c b/ndb/src/common/util/version.c index e2515b243b1..f2b3d5bd522 100644 --- a/ndb/src/common/util/version.c +++ b/ndb/src/common/util/version.c @@ -74,6 +74,7 @@ struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { }; struct NdbUpGradeCompatible ndbCompatibleTable_upgrade[] = { + { MAKE_VERSION(3,5,4), MAKE_VERSION(3,5,3), UG_Exact }, { 0, 0, UG_Null } }; From 7577c8bfc9efb21b8a8a3c08e342054e754370ab Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 29 Oct 2004 17:00:39 +0500 Subject: [PATCH 025/101] A fix according to Monty's request: "uint *errors" is now a non-optional parameter in String:copy() and copy_and_convert(). --- sql/field.cc | 15 ++++++++++----- sql/item.cc | 4 +++- sql/item_cmpfunc.cc | 3 ++- sql/item_create.cc | 5 ++++- sql/item_func.cc | 3 ++- sql/item_strfunc.cc | 9 ++++++--- sql/item_timefunc.cc | 4 +++- sql/protocol.cc | 3 ++- sql/sql_class.cc | 6 ++++-- sql/sql_parse.cc | 17 ++++++++++++----- sql/sql_show.cc | 6 ++++-- sql/sql_string.cc | 25 ++++++++++++++----------- sql/sql_string.h | 4 ++-- sql/thr_malloc.cc | 5 ++++- 14 files changed, 72 insertions(+), 37 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 261494d2125..4b833874221 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -531,7 +531,8 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) /* Convert character set if the old one is multi byte */ if (cs->mbmaxlen > 1) { - tmp.copy(from, len, cs, &my_charset_bin); + uint dummy_errors; + tmp.copy(from, len, cs, &my_charset_bin, &dummy_errors); from= tmp.ptr(); len= tmp.length(); } @@ -5502,7 +5503,8 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) /* Convert character set if nesessary */ if (String::needs_conversion(length, cs, field_charset, ¬_used)) { - tmpstr.copy(from, length, cs, field_charset); + uint dummy_errors; + tmpstr.copy(from, length, cs, field_charset, &dummy_errors); from= tmpstr.ptr(); length= tmpstr.length(); } @@ -5650,10 +5652,11 @@ void Field_enum::sql_type(String &res) const bool flag=0; for (const char **pos= typelib->type_names; *pos; pos++) { + uint dummy_errors; if (flag) res.append(','); /* convert to res.charset() == utf8, then quote */ - enum_item.copy(*pos, strlen(*pos), charset(), res.charset()); + enum_item.copy(*pos, strlen(*pos), charset(), res.charset(), &dummy_errors); append_unescaped(&res, enum_item.ptr(), enum_item.length()); flag= 1; } @@ -5684,7 +5687,8 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs) /* Convert character set if nesessary */ if (String::needs_conversion(length, cs, field_charset, ¬_used_offset)) { - tmpstr.copy(from, length, cs, field_charset); + uint dummy_errors; + tmpstr.copy(from, length, cs, field_charset, &dummy_errors); from= tmpstr.ptr(); length= tmpstr.length(); } @@ -5760,10 +5764,11 @@ void Field_set::sql_type(String &res) const bool flag=0; for (const char **pos= typelib->type_names; *pos; pos++) { + uint dummy_errors; if (flag) res.append(','); /* convert to res.charset() == utf8, then quote */ - set_item.copy(*pos, strlen(*pos), charset(), res.charset()); + set_item.copy(*pos, strlen(*pos), charset(), res.charset(), &dummy_errors); append_unescaped(&res, set_item.ptr(), set_item.length()); flag= 1; } diff --git a/sql/item.cc b/sql/item.cc index 18025d6d689..46215fd78ed 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -818,7 +818,9 @@ bool Item_param::set_str(const char *str, ulong length) Assign string with no conversion: data is converted only after it's been written to the binary log. */ - if (str_value.copy(str, length, &my_charset_bin, &my_charset_bin)) + uint dummy_errors; + if (str_value.copy(str, length, &my_charset_bin, &my_charset_bin, + &dummy_errors)) DBUG_RETURN(TRUE); state= STRING_VALUE; maybe_null= 0; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index dc0377c791f..d9db07e2289 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1832,8 +1832,9 @@ void Item_func_in::fix_length_and_dec() { Item_string *conv; String tmp, cstr, *ostr= arg[0]->val_str(&tmp); + uint dummy_errors; cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), - cmp_collation.collation); + cmp_collation.collation, &dummy_errors); conv= new Item_string(cstr.ptr(),cstr.length(), cstr.charset(), arg[0]->collation.derivation); conv->str_value.copy(); diff --git a/sql/item_create.cc b/sql/item_create.cc index c98c7892c26..800489a6a72 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -377,7 +377,10 @@ Item *create_func_space(Item *a) { sp= new Item_string("",0,cs); if (sp) - sp->str_value.copy(" ",1,&my_charset_latin1,cs); + { + uint dummy_errors; + sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); + } } else { diff --git a/sql/item_func.cc b/sql/item_func.cc index 3cb125d2868..50843d3bf76 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2906,8 +2906,9 @@ void Item_func_match::init_search(bool no_order) if (ft_tmp->charset() != cmp_collation.collation) { + uint dummy_errors; search_value.copy(ft_tmp->ptr(), ft_tmp->length(), ft_tmp->charset(), - cmp_collation.collation); + cmp_collation.collation, &dummy_errors); ft_tmp= &search_value; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 2d9f7e7bff8..5eda89ef21e 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2160,13 +2160,14 @@ String *Item_func_conv_charset::val_str(String *str) { DBUG_ASSERT(fixed == 1); String *arg= args[0]->val_str(str); + uint dummy_errors; if (!arg) { null_value=1; return 0; } null_value= str_value.copy(arg->ptr(),arg->length(),arg->charset(), - conv_charset); + conv_charset, &dummy_errors); return null_value ? 0 : &str_value; } @@ -2249,11 +2250,12 @@ String *Item_func_charset::val_str(String *str) { DBUG_ASSERT(fixed == 1); String *res = args[0]->val_str(str); + uint dummy_errors; if ((null_value=(args[0]->null_value || !res->charset()))) return 0; str->copy(res->charset()->csname,strlen(res->charset()->csname), - &my_charset_latin1, collation.collation); + &my_charset_latin1, collation.collation, &dummy_errors); return str; } @@ -2261,11 +2263,12 @@ String *Item_func_collation::val_str(String *str) { DBUG_ASSERT(fixed == 1); String *res = args[0]->val_str(str); + uint dummy_errors; if ((null_value=(args[0]->null_value || !res->charset()))) return 0; str->copy(res->charset()->name,strlen(res->charset()->name), - &my_charset_latin1, collation.collation); + &my_charset_latin1, collation.collation, &dummy_errors); return str; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 3c8dbb013a9..f621953a5bc 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2121,8 +2121,10 @@ String *Item_char_typecast::val_str(String *str) else { // Convert character set if differ + uint dummy_errors; if (!(res1= args[0]->val_str(&tmp_value)) || - str->copy(res1->ptr(), res1->length(),res1->charset(), cast_cs)) + str->copy(res1->ptr(), res1->length(), res1->charset(), + cast_cs, &dummy_errors)) { null_value= 1; return 0; diff --git a/sql/protocol.cc b/sql/protocol.cc index 887177c0a19..598d102ec29 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -713,7 +713,8 @@ bool Protocol::store_string_aux(const char *from, uint length, fromcs != &my_charset_bin && tocs != &my_charset_bin) { - return convert->copy(from, length, fromcs, tocs) || + uint dummy_errors; + return convert->copy(from, length, fromcs, tocs, &dummy_errors) || net_store_data(convert->ptr(), convert->length()); } return net_store_data(from, length); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index abe00027b07..7ad20967de0 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -508,13 +508,14 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs, { DBUG_ENTER("convert_string"); size_s new_length= to_cs->mbmaxlen * from_length; + uint dummy_errors; if (!(to->str= alloc(new_length+1))) { to->length= 0; // Safety fix DBUG_RETURN(1); // EOM } to->length= copy_and_convert((char*) to->str, new_length, to_cs, - from, from_length, from_cs); + from, from_length, from_cs, &dummy_errors); to->str[to->length]=0; // Safety DBUG_RETURN(0); } @@ -537,7 +538,8 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs, bool THD::convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs) { - if (convert_buffer.copy(s->ptr(), s->length(), from_cs, to_cs)) + uint dummy_errors; + if (convert_buffer.copy(s->ptr(), s->length(), from_cs, to_cs, &dummy_errors)) return TRUE; /* If convert_buffer >> s copying is more efficient long term */ if (convert_buffer.alloced_length() >= convert_buffer.length() * 2 || diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d1f460d918e..dce32720184 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -882,18 +882,20 @@ static int check_connection(THD *thd) /* Since 4.1 all database names are stored in utf8 */ if (db) { + uint dummy_errors; db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, db, strlen(db), - thd->charset())]= 0; + thd->charset(), &dummy_errors)]= 0; db= db_buff; } if (user) { + uint dummy_errors; user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1, system_charset_info, user, strlen(user), - thd->charset())]= '\0'; + thd->charset(), &dummy_errors)]= '\0'; user= user_buff; } @@ -1380,9 +1382,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } #endif /* Convert database name to utf8 */ + uint dummy_errors; db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, db, strlen(db), - thd->charset())]= 0; + thd->charset(), &dummy_errors)]= 0; db= db_buff; /* Save user and privileges */ @@ -2066,8 +2069,12 @@ mysql_execute_command(THD *thd) } if (need_conversion) - query_len= copy_and_convert(query_str, query_len, to_cs, pstr->ptr(), - pstr->length(), pstr->charset()); + { + uint dummy_errors; + query_len= copy_and_convert(query_str, query_len, to_cs, + pstr->ptr(), pstr->length(), + pstr->charset(), &dummy_errors); + } else memcpy(query_str, pstr->ptr(), pstr->length()); query_str[query_len]= 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3bf11c0d6b8..2af4cb3fc23 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -752,8 +752,9 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, String def(tmp1,sizeof(tmp1), system_charset_info); type.set(tmp, sizeof(tmp), field->charset()); field->val_str(&type); + uint dummy_errors; def.copy(type.ptr(), type.length(), type.charset(), - system_charset_info); + system_charset_info, &dummy_errors); protocol->store(def.ptr(), def.length(), def.charset()); } else if (field->unireg_check == Field::NEXT_NUMBER || @@ -1338,9 +1339,10 @@ store_create_info(THD *thd, TABLE *table, String *packet) if (type.length()) { String def_val; + uint dummy_errors; /* convert to system_charset_info == utf8 */ def_val.copy(type.ptr(), type.length(), field->charset(), - system_charset_info); + system_charset_info, &dummy_errors); append_unescaped(packet, def_val.ptr(), def_val.length()); } else diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 30559496fde..6b2bb07fb8c 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -121,12 +121,13 @@ bool String::set(ulonglong num, CHARSET_INFO *cs) bool String::set(double num,uint decimals, CHARSET_INFO *cs) { char buff[331]; + uint dummy_errors; str_charset=cs; if (decimals >= NOT_FIXED_DEC) { uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME - return copy(buff, len, &my_charset_latin1, cs); + return copy(buff, len, &my_charset_latin1, cs, &dummy_errors); } #ifdef HAVE_FCONVERT int decpt,sign; @@ -191,7 +192,8 @@ end: #else sprintf(buff,"%.*f",(int) decimals,num); #endif - return copy(buff,(uint32) strlen(buff), &my_charset_latin1, cs); + return copy(buff,(uint32) strlen(buff), &my_charset_latin1, cs, + &dummy_errors); #endif } @@ -336,14 +338,12 @@ bool String::copy(const char *str, uint32 arg_length, uint32 offset; if (!needs_conversion(arg_length, from_cs, to_cs, &offset)) { - if (errors) - *errors= 0; + *errors= 0; return copy(str, arg_length, to_cs); } if ((from_cs == &my_charset_bin) && offset) { - if (errors) - *errors= 0; + *errors= 0; return copy_aligned(str, arg_length, offset, to_cs); } uint32 new_length= to_cs->mbmaxlen*arg_length; @@ -382,7 +382,8 @@ bool String::set_ascii(const char *str, uint32 arg_length) set(str, arg_length, str_charset); return 0; } - return copy(str, arg_length, &my_charset_latin1, str_charset); + uint dummy_errors; + return copy(str, arg_length, &my_charset_latin1, str_charset, &dummy_errors); } @@ -436,10 +437,12 @@ bool String::append(const char *s,uint32 arg_length) if (str_charset->mbminlen > 1) { uint32 add_length=arg_length * str_charset->mbmaxlen; + uint dummy_errors; if (realloc(str_length+ add_length)) return TRUE; str_length+= copy_and_convert(Ptr+str_length, add_length, str_charset, - s, arg_length, &my_charset_latin1); + s, arg_length, &my_charset_latin1, + &dummy_errors); return FALSE; } @@ -476,10 +479,11 @@ bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs) if (needs_conversion(arg_length, cs, str_charset, &dummy_offset)) { uint32 add_length= arg_length / cs->mbminlen * str_charset->mbmaxlen; + uint dummy_errors; if (realloc(str_length + add_length)) return TRUE; str_length+= copy_and_convert(Ptr+str_length, add_length, str_charset, - s, arg_length, cs); + s, arg_length, cs, &dummy_errors); } else { @@ -816,8 +820,7 @@ outp: else break; } - if (errors) - *errors= error_count; + *errors= error_count; return (uint32) (to - to_start); } diff --git a/sql/sql_string.h b/sql/sql_string.h index de8f4af58d9..a8fb9574c0b 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -29,7 +29,7 @@ int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); uint32 copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs, const char *from, uint32 from_length, - CHARSET_INFO *from_cs, uint *errors= 0); + CHARSET_INFO *from_cs, uint *errors); class String { @@ -199,7 +199,7 @@ public: CHARSET_INFO *cs); bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs); bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom, - CHARSET_INFO *csto, uint *errors= 0); + CHARSET_INFO *csto, uint *errors); bool append(const String &s); bool append(const char *s); bool append(const char *s,uint32 arg_length); diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index fa678ec7de2..0df60858bcb 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -108,8 +108,11 @@ char *sql_strmake_with_convert(const char *str, uint32 arg_length, memcpy(pos, str, new_length); } else + { + uint dummy_errors; new_length= copy_and_convert((char*) pos, new_length, to_cs, str, - arg_length, from_cs); + arg_length, from_cs, &dummy_errors); + } pos[new_length]= 0; *result_length= new_length; return pos; From d2bfefc3c1e71c32fb4cad8f4c83efcd91c04e38 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 29 Oct 2004 14:24:06 +0200 Subject: [PATCH 026/101] proper max_records estimation for sort-repair of fulltext indexes --- myisam/mi_check.c | 2 +- mysql-test/r/fulltext.result | 3 +++ mysql-test/t/ctype_utf8.test | 1 + mysql-test/t/fulltext.test | 9 ++++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 4da388af1c7..1df518a2712 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -2037,7 +2037,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT* sort_param.keyinfo->seg->charset->mbmaxlen; sort_info.max_records= - (ha_rows) (sort_info.filelength/ft_max_word_len_for_sort+1); + (ha_rows) (sort_info.filelength/ft_min_word_len+1); sort_param.key_read=sort_ft_key_read; sort_param.key_write=sort_ft_key_write; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 30c4c75f3d1..65f88932d54 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -330,6 +330,9 @@ t1_id name t2_id t1_id name select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode); t2_id t1_id name drop table t1,t2; +create table t1 (a text, fulltext key (a)); +insert into t1 select "xxxx yyyy zzzz"; +drop table t1; SET NAMES latin1; CREATE TABLE t1 (t text character set utf8 not null, fulltext(t)); INSERT t1 VALUES ('Mit freundlichem Grüß'), ('aus Osnabrück'); diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 0c8bdd6a94d..c75b1dee63c 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -645,6 +645,7 @@ insert into t1 values(1,'foo'),(2,'foobar'); select * from t1 where b like 'foob%'; --disable_warnings alter table t1 engine=bdb; +--enable_warnings select * from t1 where b like 'foob%'; drop table t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 66df5b1cb92..5af2575ddc4 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -253,9 +253,16 @@ select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against(' # bug with many short (< ft_min_word_len) words in boolean search # select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode); - drop table t1,t2; +# +# bug with repair-by-sort and incorrect records estimation +# + +create table t1 (a text, fulltext key (a)); +insert into t1 select "xxxx yyyy zzzz"; +drop table t1; + # # UTF8 # From 86143bc83262e6460a1e3f20b69d9cb1c1de4e27 Mon Sep 17 00:00:00 2001 From: "mleich@mysql.com" <> Date: Fri, 29 Oct 2004 14:51:56 +0200 Subject: [PATCH 027/101] These modifications are the result of WL#2067 add features to mysqltest: "disable_error_abort" + "$mysql_errno" $mysql_errno is a new builtin variable of mysqltest and contains the return code of the last command send to the server. "--disable_abort_on_error" switches the abort of mysqltest after "unmasked" failing statements off. "--enable_abort_on_error" switches the abort of mysqltest after "unmasked" failing statements on. (default) "Maskings" are !$ and --error in the line before the statement to be checked. The benefit of the option "--disable_abort_on_error" is that - all statements after the failing statement are executed - a r/.reject will be produced - it is possible to write test cases, which perform code sequences depending on the return code of a single statement --- client/mysqltest.c | 30 ++++- mysql-test/r/mysqltest.result | 128 ++++++++++++++++++++ mysql-test/t/mysqltest.test | 219 ++++++++++++++++++++++++++++++++++ 3 files changed, 376 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 4c87561ab84..21f93b1fc6a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -243,6 +243,8 @@ VAR var_reg[10]; HASH var_hash; my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0; my_bool disable_info= 1; /* By default off */ +/* default for disable_abort_on_error: false = abort on unmasked error */ +my_bool disable_abort_on_error= 0; struct connection cons[MAX_CONS]; struct connection* cur_con, *next_con, *cons_end; @@ -274,6 +276,7 @@ Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, Q_ENABLE_INFO, Q_DISABLE_INFO, Q_ENABLE_METADATA, Q_DISABLE_METADATA, Q_EXEC, Q_DELIMITER, +Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR, Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_START_TIMER, Q_END_TIMER, @@ -352,6 +355,8 @@ const char *command_names[]= "disable_metadata", "exec", "delimiter", + "disable_abort_on_error", + "enable_abort_on_error", "vertical_results", "horizontal_results", "query_vertical", @@ -1239,6 +1244,18 @@ int do_let(struct st_query* q) return var_set(var_name, var_name_end, var_val_start, q->end); } +/* Store an integer (typically the returncode of the last SQL) */ +/* statement in the mysqltest builtin variable $mysql_errno, by */ +/* simulating of a user statement "let $mysql_errno= " */ +int var_set_errno(int sql_errno ) +{ + char var_name[] = "$mysql_errno", var_val[30]; + sprintf(var_val, "%d", sql_errno); + /* On some odd systems, the return value from sprintf() isn't */ + /* always the length of the string, so we use strlen() */ + return var_set(var_name, var_name + 12, var_val, var_val + strlen(var_val)); +} + int do_rpl_probe(struct st_query* q __attribute__((unused))) { DBUG_ENTER("do_rpl_probe"); @@ -1996,7 +2013,7 @@ int read_query(struct st_query** q_ptr) memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, sizeof(global_expected_errno)); q->expected_errors= global_expected_errors; - q->abort_on_error= global_expected_errors == 0; + q->abort_on_error= (global_expected_errors == 0 && !disable_abort_on_error); bzero((gptr) global_expected_errno, sizeof(global_expected_errno)); global_expected_errors=0; if (p[0] == '-' && p[1] == '-') @@ -2642,6 +2659,10 @@ end: dynstr_free(&ds_tmp); if (q->type == Q_EVAL) dynstr_free(&eval_query); + /* We save the return code (mysql_errno(mysql)) from the last call sent */ + /* to the server into the mysqltest builtin variable $mysql_errno. This */ + /* variable then can be used from the test case itself. */ + var_set_errno(mysql_errno(mysql)); DBUG_RETURN(error); } @@ -3395,6 +3416,11 @@ int main(int argc, char **argv) init_var_hash(&cur_con->mysql); + /* Initialize $mysql_errno with -1, so we can */ + /* - distinguish it from valid values ( >= 0 ) and */ + /* - detect if there was never a command sent to the server */ + var_set_errno(-1); + while (!read_query(&q)) { int current_line_inc = 1, processed = 0; @@ -3414,6 +3440,8 @@ int main(int argc, char **argv) case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break; case Q_ENABLE_QUERY_LOG: disable_query_log=0; break; case Q_DISABLE_QUERY_LOG: disable_query_log=1; break; + case Q_ENABLE_ABORT_ON_ERROR: disable_abort_on_error=0; break; + case Q_DISABLE_ABORT_ON_ERROR: disable_abort_on_error=1; break; case Q_ENABLE_RESULT_LOG: disable_result_log=0; break; case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 4e30d5bc110..5dc9ede1ca6 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -1,3 +1,6 @@ +select -1 as "before_use_test" ; +before_use_test +-1 select otto from (select 1 as otto) as t1; otto 1 @@ -21,3 +24,128 @@ select friedrich from (select 1 as otto) as t1; ERROR 42S22: Unknown column 'friedrich' in 'field list' select friedrich from (select 1 as otto) as t1; ERROR 42S22: Unknown column 'friedrich' in 'field list' +select otto from (select 1 as otto) as t1; +otto +1 +select 0 as "after_successful_stmt_errno" ; +after_successful_stmt_errno +0 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 1064 as "after_wrong_syntax_errno" ; +after_wrong_syntax_errno +1064 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 1064 as "after_let_var_equal_value" ; +after_let_var_equal_value +1064 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +set @my_var= 'abc' ; +select 0 as "after_set_var_equal_value" ; +after_set_var_equal_value +0 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 1064 as "after_disable_warnings_command" ; +after_disable_warnings_command +1064 +drop table if exists t1 ; +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +drop table if exists t1 ; +select 0 as "after_disable_warnings" ; +after_disable_warnings +0 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 3 from t1 ; +ERROR 42S02: Table 'test.t1' doesn't exist +select 1146 as "after_minus_masked" ; +after_minus_masked +1146 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 3 from t1 ; +ERROR 42S02: Table 'test.t1' doesn't exist +select 1146 as "after_!_masked" ; +after_!_masked +1146 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select -1 as "after_let_errno_equal_value" ; +after_let_errno_equal_value +-1 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +prepare stmt from "select 3 from t1" ; +ERROR 42S02: Table 'test.t1' doesn't exist +select 1146 as "after_failing_prepare" ; +after_failing_prepare +1146 +create table t1 ( f1 char(10)); +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +prepare stmt from "select 3 from t1" ; +select 0 as "after_successful_prepare" ; +after_successful_prepare +0 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +execute stmt; +3 +select 0 as "after_successful_execute" ; +after_successful_execute +0 +drop table t1; +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +execute stmt; +ERROR 42S02: Table 'test.t1' doesn't exist +select 1146 as "after_failing_execute" ; +after_failing_execute +1146 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +execute __stmt_; +ERROR HY000: Unknown prepared statement handler (__stmt_) given to EXECUTE +select 1243 as "after_failing_execute" ; +after_failing_execute +1243 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +deallocate prepare stmt; +select 0 as "after_successful_deallocate" ; +after_successful_deallocate +0 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +deallocate prepare __stmt_; +ERROR HY000: Unknown prepared statement handler (__stmt_) given to DEALLOCATE PREPARE +select 1243 as "after_failing_deallocate" ; +after_failing_deallocate +1243 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 1064 as "after_--disable_abort_on_error" ; +after_--disable_abort_on_error +1064 +select 3 from t1 ; +ERROR 42S02: Table 'test.t1' doesn't exist +select 3 from t1 ; +ERROR 42S02: Table 'test.t1' doesn't exist +select 3 from t1 ; +ERROR 42S02: Table 'test.t1' doesn't exist +select 1146 as "after_!errno_masked_error" ; +after_!errno_masked_error +1146 +garbage ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 1064 as "after_--enable_abort_on_error" ; +after_--enable_abort_on_error +1064 +select 3 from t1 ; +ERROR 42S02: Table 'test.t1' doesn't exist +select 3 from t1 ; +ERROR 42S02: Table 'test.t1' doesn't exist diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index c18dfe1e25c..b7007e1a519 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -5,6 +5,15 @@ # # ============================================================================ +# ---------------------------------------------------------------------------- +# $mysql_errno contains the return code of the last command +# send to the server. +# ---------------------------------------------------------------------------- +# get $mysql_errno before the first statement +# $mysql_errno should be -1 +eval select $mysql_errno as "before_use_test" ; + + # ---------------------------------------------------------------------------- # Positive case(statement) # ---------------------------------------------------------------------------- @@ -76,3 +85,213 @@ select friedrich from (select 1 as otto) as t1; #--error S00000 #select friedrich from (select 1 as otto) as t1; + +# ---------------------------------------------------------------------------- +# test cases for $mysql_errno +# +# $mysql_errno is a builtin variable of mysqltest and contains the return code +# of the last command send to the server. +# +# The following test cases often initialize $mysql_errno to 1064 by +# a command with wrong syntax. +# Example: !$1064 To prevent the abort after the error. +# garbage ; +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# 1. check mysql_errno = 0 after successful statement +# ---------------------------------------------------------------------------- +select otto from (select 1 as otto) as t1; +eval select $mysql_errno as "after_successful_stmt_errno" ; + +#---------------------------------------------------------------------------- +# 2. check mysql_errno = 1064 after statement with wrong syntax +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +eval select $mysql_errno as "after_wrong_syntax_errno" ; + +# ---------------------------------------------------------------------------- +# 3. check if let $my_var= 'abc' ; affects $mysql_errno +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +let $my_var= 'abc' ; +eval select $mysql_errno as "after_let_var_equal_value" ; + +# ---------------------------------------------------------------------------- +# 4. check if set @my_var= 'abc' ; affects $mysql_errno +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +set @my_var= 'abc' ; +eval select $mysql_errno as "after_set_var_equal_value" ; + +# ---------------------------------------------------------------------------- +# 5. check if the setting of --disable-warnings itself affects $mysql_errno +# (May be -- modifies $mysql_errno.) +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +--disable_warnings +eval select $mysql_errno as "after_disable_warnings_command" ; + +# ---------------------------------------------------------------------------- +# 6. check if --disable-warnings + command with warning affects the errno +# stored within $mysql_errno +# (May be disabled warnings affect $mysql_errno.) +# ---------------------------------------------------------------------------- +drop table if exists t1 ; +!$1064 +garbage ; +drop table if exists t1 ; +eval select $mysql_errno as "after_disable_warnings" ; +--enable_warnings + +# ---------------------------------------------------------------------------- +# 7. check if masked errors affect $mysql_errno +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +--error 1146 +select 3 from t1 ; +eval select $mysql_errno as "after_minus_masked" ; +!$1064 +garbage ; +!$1146 +select 3 from t1 ; +eval select $mysql_errno as "after_!_masked" ; + +# ---------------------------------------------------------------------------- +# 8. Will manipulations of $mysql_errno be possible and visible ? +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +let $mysql_errno= -1; +eval select $mysql_errno as "after_let_errno_equal_value" ; + +# ---------------------------------------------------------------------------- +# 9. How affect actions on prepared statements $mysql_errno ? +# ---------------------------------------------------------------------------- +# failing prepare +!$1064 +garbage ; +!$1146 +prepare stmt from "select 3 from t1" ; +eval select $mysql_errno as "after_failing_prepare" ; +create table t1 ( f1 char(10)); + +# successful prepare +!$1064 +garbage ; +prepare stmt from "select 3 from t1" ; +eval select $mysql_errno as "after_successful_prepare" ; + +# successful execute +!$1064 +garbage ; +execute stmt; +eval select $mysql_errno as "after_successful_execute" ; + +# failing execute (table dropped) +drop table t1; +!$1064 +garbage ; +!$1146 +execute stmt; +eval select $mysql_errno as "after_failing_execute" ; + +# failing execute (unknown statement) +!$1064 +garbage ; +!$1243 +execute __stmt_; +eval select $mysql_errno as "after_failing_execute" ; + +# successful deallocate +!$1064 +garbage ; +deallocate prepare stmt; +eval select $mysql_errno as "after_successful_deallocate" ; + +# failing deallocate ( statement handle does not exist ) +!$1064 +garbage ; +!$1243 +deallocate prepare __stmt_; +eval select $mysql_errno as "after_failing_deallocate" ; + + +# ---------------------------------------------------------------------------- +# test cases for "--disable_abort_on_error" +# +# "--disable_abort_on_error" switches the abort of mysqltest +# after "unmasked" failing statements off. +# +# The default is "--enable_abort_on_error". +# +# "Maskings" are +# !$ and --error +# in the line before the failing statement. +# +# There are some additional test case for $mysql_errno +# because "--disable_abort_on_error" enables a new situation. +# Example: "unmasked" statement fails + analysis of $mysql_errno +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# 1. Switch the abort on error off and check the effect on $mysql_errno +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +--disable_abort_on_error +eval select $mysql_errno as "after_--disable_abort_on_error" ; + +# ---------------------------------------------------------------------------- +# 2. "unmasked" failing statement should not cause an abort +# ---------------------------------------------------------------------------- +select 3 from t1 ; + +# ---------------------------------------------------------------------------- +# 3. masked failing statements +# ---------------------------------------------------------------------------- +# expected error = response +--error 1146 +select 3 from t1 ; +!$1146 +select 3 from t1 ; +eval select $mysql_errno as "after_!errno_masked_error" ; +# expected error <> response +# --error 1000 +# select 3 from t1 ; +# !$1000 +# select 3 from t1 ; + +# ---------------------------------------------------------------------------- +# 4. Switch the abort on error on and check the effect on $mysql_errno +# ---------------------------------------------------------------------------- +!$1064 +garbage ; +--enable_abort_on_error +eval select $mysql_errno as "after_--enable_abort_on_error" ; + +# ---------------------------------------------------------------------------- +# 5. masked failing statements +# ---------------------------------------------------------------------------- +# expected error = response +--error 1146 +select 3 from t1 ; +!$1146 +select 3 from t1 ; + +# ---------------------------------------------------------------------------- +# 6. check that the old default behaviour is not changed +# Please remove the '#' to get the abort on error +# ---------------------------------------------------------------------------- +#--error 1064 +#select 3 from t1 ; +# +#!$1064 +#select 3 from t1 ; +# +#select 3 from t1 ; From 24d38aea13f12e977b19b1430474f5eff2abddb7 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Fri, 29 Oct 2004 13:59:40 +0000 Subject: [PATCH 028/101] added define flag SNPRINTF_RETURN_ZERO to indicate that snprintf returns zero if buffer too small use flag SNPRINTF_RETURN_ZERO emulate snprintf behavior by writing to _big_ buffer if set use my_vsnprintf if HAVE_SNPRINTF is not set and set SNPRINTF_RETURN_ZERO in that case --- configure.in | 4 ++-- ndb/src/common/util/basestring_vsnprintf.c | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 392aaba2cda..353e455dbac 100644 --- a/configure.in +++ b/configure.in @@ -1142,8 +1142,8 @@ dnl Is this the right match for DEC OSF on alpha? fi echo "Adding defines for OSF1" # gethostbyname_r is deprecated and doesn't work ok on OSF1 - CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R" - CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R" + CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_ZERO" + CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_ZERO" # fix to handle include of correctly on OSF1 with cxx compiler CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include -I/usr/include.dtk" ;; diff --git a/ndb/src/common/util/basestring_vsnprintf.c b/ndb/src/common/util/basestring_vsnprintf.c index 10932226d18..87ffb8ad146 100644 --- a/ndb/src/common/util/basestring_vsnprintf.c +++ b/ndb/src/common/util/basestring_vsnprintf.c @@ -18,6 +18,7 @@ #define _XOPEN_SOURCE 500 #include #include +#include int basestring_snprintf(char *str, size_t size, const char *format, ...) @@ -30,8 +31,27 @@ basestring_snprintf(char *str, size_t size, const char *format, ...) return(ret); } +#ifdef HAVE_SNPRINTF + #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) +#else + #define SNPRINTF_RETURN_ZERO + #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d) + extern int my_vsnprintf(char *str, size_t size, const char *format, va_list ap); +#endif + +#ifdef SNPRINTF_RETURN_ZERO +static char basestring_vsnprintf_buf[16*1024]; +#endif int basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap) { - return(vsnprintf(str, size, format, ap)); + int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap); +#ifdef SNPRINTF_RETURN_ZERO + if (ret == 0 && format != 0 && format[0] != '\0') { + ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf, + sizeof(basestring_vsnprintf_buf), + format, ap); + } +#endif + return ret; } From e97a79f2ee590c8f135d60d8470bcff2a90a3ef9 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Sat, 30 Oct 2004 17:17:52 +0400 Subject: [PATCH 029/101] Enable REPLACE ... SELECT in prepared statements. --- mysql-test/include/ps_modify.inc | 5 ++++- mysql-test/r/ps_2myisam.result | 4 +++- mysql-test/r/ps_3innodb.result | 4 +++- mysql-test/r/ps_4heap.result | 4 +++- mysql-test/r/ps_5merge.result | 8 ++++++-- mysql-test/r/ps_6bdb.result | 4 +++- mysql-test/r/ps_7ndb.result | 1 - mysql-test/t/ps_7ndb.test | 2 +- sql/sql_prepare.cc | 1 + 9 files changed, 24 insertions(+), 9 deletions(-) diff --git a/mysql-test/include/ps_modify.inc b/mysql-test/include/ps_modify.inc index 9cf11709e69..eb6820934f3 100644 --- a/mysql-test/include/ps_modify.inc +++ b/mysql-test/include/ps_modify.inc @@ -322,8 +322,11 @@ select a,b from t1 where a >= 1000 order by a ; delete from t1 where a >= 1000 ; ## replace ---error 1295 prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; +execute stmt1; +execute stmt1; +execute stmt1; + ## multi table statements diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 40b2516f0b9..efb12561950 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1581,7 +1581,9 @@ a b 1200 x1000_1updatedupdated delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet +execute stmt1; +execute stmt1; +execute stmt1; test_sequence ------ multi table tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 11669b131a7..cb096882d13 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1564,7 +1564,9 @@ a b 1200 x1000_1updatedupdated delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet +execute stmt1; +execute stmt1; +execute stmt1; test_sequence ------ multi table tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index a3837650e0e..ac9946ef070 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1565,7 +1565,9 @@ a b 1200 x1000_1updatedupdated delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet +execute stmt1; +execute stmt1; +execute stmt1; test_sequence ------ multi table tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 619b59e4e3d..15e707959ca 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1607,7 +1607,9 @@ a b 1200 x1000_1updatedupdated delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet +execute stmt1; +execute stmt1; +execute stmt1; test_sequence ------ multi table tests ------ delete from t1 ; @@ -4615,7 +4617,9 @@ a b 1200 x1000_1updatedupdated delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet +execute stmt1; +execute stmt1; +execute stmt1; test_sequence ------ multi table tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index 5c23a574f51..3dd9c200510 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -1564,7 +1564,9 @@ a b 1200 x1000_1updatedupdated delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet +execute stmt1; +execute stmt1; +execute stmt1; test_sequence ------ multi table tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index cf567750b85..85e51df776f 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -1543,7 +1543,6 @@ a b 1000 x1000_1 delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet test_sequence ------ multi table tests ------ delete from t1 ; diff --git a/mysql-test/t/ps_7ndb.test b/mysql-test/t/ps_7ndb.test index af669a26400..22370a7f3ac 100644 --- a/mysql-test/t/ps_7ndb.test +++ b/mysql-test/t/ps_7ndb.test @@ -339,8 +339,8 @@ select a,b from t1 where a >= 1000 order by a ; delete from t1 where a >= 1000 ; ## replace ---error 1295 prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; +--error 1031 ## multi table statements --disable_query_log diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index bccf517466d..b5e12c4d208 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1442,6 +1442,7 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) break; case SQLCOM_INSERT_SELECT: + case SQLCOM_REPLACE_SELECT: res= mysql_test_insert_select(stmt, tables); break; From d22a24d871bc3bfaec17621d23352f2da9473569 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Sun, 31 Oct 2004 15:43:29 +0200 Subject: [PATCH 030/101] row0mysql.c, pars0pars.c, eval0eval.c, dict0load.c, dict0dict.c, dict0crea.c: Fix bug #3478: InnoDB's FOREIGN KEY tables treated table and database names as case-insensitive; RENAME TABLE t to T would hang in an endless loop if t had a foreign key constraint defined on it dict0dict.c: Fix bug #3478: InnoDB's FOREIGN KEY tables treated table and database names as case-insensitive; RENAME TABLE t to T would hang in an endless loop if t had a foreign key constraint defined on it; fix also a hang that would occur if one tried in ALTER TABLE or RENAME TABLE to create a foreign key constraint name that collided with another existing name --- innobase/dict/dict0crea.c | 16 +++++++++++++++- innobase/dict/dict0dict.c | 4 ++-- innobase/dict/dict0load.c | 21 ++++++++++++++++++--- innobase/eval/eval0eval.c | 18 +++++++++++++++++- innobase/pars/pars0pars.c | 8 ++++++-- innobase/row/row0mysql.c | 15 +++++++++++---- 6 files changed, 69 insertions(+), 13 deletions(-) diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c index 31a601e68b0..e8261ab1e91 100644 --- a/innobase/dict/dict0crea.c +++ b/innobase/dict/dict0crea.c @@ -1011,6 +1011,12 @@ dict_create_or_check_foreign_constraint_tables(void) there are 2 secondary indexes on SYS_FOREIGN, and they are defined just like below */ + /* NOTE: when designing InnoDB's foreign key support in 2001, we made + an error and made the table names and the foreign key id of type + 'CHAR' (internally, really a VARCHAR). We should have made the type + VARBINARY, like in other InnoDB system tables, to get a clean + design. */ + str = (char *) "PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n" "BEGIN\n" @@ -1227,9 +1233,17 @@ loop: fputs(".\nA foreign key constraint of name ", ef); ut_print_name(ef, foreign->id); fputs("\nalready exists." - " (Note that internally InnoDB adds 'databasename/'\n" + " (Note that internally InnoDB adds 'databasename/'\n" "in front of the user-defined constraint name).\n", ef); + fputs("Note that InnoDB's FOREIGN KEY system tables store\n" + "constraint names as case-insensitive, with the\n" + "MySQL standard latin1_swedish_ci collation. If you\n" + "create tables or databases whose names differ only in\n" + "the character case, then collisions in constraint\n" + "names can occur. Workaround: name your constraints\n" + "explicitly with unique names.\n", + ef); mutex_exit(&dict_foreign_err_mutex); diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 4340934ab3d..5ca31ecd422 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -132,7 +132,7 @@ dict_index_build_internal_non_clust( dict_index_t* index); /* in: user representation of a non-clustered index */ /************************************************************************** -Removes a foreign constraint struct from the dictionet cache. */ +Removes a foreign constraint struct from the dictionary cache. */ static void dict_foreign_remove_from_cache( @@ -581,7 +581,7 @@ dict_table_get_on_id( dict_table_t* table; if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0 - || trx->dict_operation) { + || trx->dict_operation_lock_mode == RW_X_LATCH) { /* It is a system table which will always exist in the table cache: we avoid acquiring the dictionary mutex, because if we are doing a rollback to handle an error in TABLE diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index 6a4d4c86824..a4637e09d07 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -19,6 +19,7 @@ Created 4/24/1996 Heikki Tuuri #include "mach0data.h" #include "dict0dict.h" #include "dict0boot.h" +#include "rem0cmp.h" /************************************************************************ Finds the first table name in the given database. */ @@ -1121,12 +1122,26 @@ loop: rec = btr_pcur_get_rec(&pcur); field = rec_get_nth_field(rec, 0, &len); - /* Check if the table name in record is the one searched for */ - if (len != ut_strlen(table_name) - || 0 != ut_memcmp(field, table_name, len)) { + /* Check if the table name in the record is the one searched for; the + following call does the comparison in the latin1_swedish_ci + charset-collation, in a case-insensitive way. */ + if (0 != cmp_data_data(dfield_get_type(dfield), + dfield_get_data(dfield), dfield_get_len(dfield), + field, len)) { + goto load_next_index; } + + /* Since table names in SYS_FOREIGN are stored in a case-insensitive + order, we have to check that the table name matches also in a binary + string comparison. On Unix, MySQL allows table names that only differ + in character case. */ + + if (0 != ut_memcmp(field, table_name, len)) { + + goto next_rec; + } if (rec_get_deleted_flag(rec)) { diff --git a/innobase/eval/eval0eval.c b/innobase/eval/eval0eval.c index ebb6cb1b7d9..5b2d1f857b1 100644 --- a/innobase/eval/eval0eval.c +++ b/innobase/eval/eval0eval.c @@ -627,7 +627,11 @@ eval_concat( } /********************************************************************* -Evaluates a predefined function node. */ +Evaluates a predefined function node. If the first argument is an integer, +this function looks at the second argument which is the integer length in +bytes, and converts the integer to a VARCHAR. +If the first argument is of some other type, this function converts it to +BINARY. */ UNIV_INLINE void eval_to_binary( @@ -638,12 +642,24 @@ eval_to_binary( que_node_t* arg2; dfield_t* dfield; byte* str1; + ulint len; ulint len1; arg1 = func_node->args; str1 = dfield_get_data(que_node_get_val(arg1)); + if (dtype_get_mtype(que_node_get_data_type(arg1)) != DATA_INT) { + + len = dfield_get_len(que_node_get_val(arg1)); + + dfield = que_node_get_val(func_node); + + dfield_set_data(dfield, str1, len); + + return; + } + arg2 = que_node_get_next(arg1); len1 = (ulint)eval_node_get_int_val(arg2); diff --git a/innobase/pars/pars0pars.c b/innobase/pars/pars0pars.c index a4124672df0..5be0e52d0c8 100644 --- a/innobase/pars/pars0pars.c +++ b/innobase/pars/pars0pars.c @@ -259,9 +259,13 @@ pars_resolve_func_data_type( dtype_set(que_node_get_data_type(node), DATA_VARCHAR, DATA_ENGLISH, 0, 0); } else if (func == PARS_TO_BINARY_TOKEN) { - ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT); - dtype_set(que_node_get_data_type(node), DATA_VARCHAR, + if (dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT) { + dtype_set(que_node_get_data_type(node), DATA_VARCHAR, DATA_ENGLISH, 0, 0); + } else { + dtype_set(que_node_get_data_type(node), DATA_BINARY, + 0, 0, 0); + } } else if (func == PARS_TO_NUMBER_TOKEN) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_VARCHAR); diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 78b2aa8e28f..2e8f7121d2c 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1981,7 +1981,8 @@ row_drop_table_for_mysql( "WHILE found = 1 LOOP\n" " SELECT ID INTO foreign_id\n" " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = table_name;\n" + " WHERE FOR_NAME = table_name\n" + " AND TO_BINARY(FOR_NAME) = TO_BINARY(table_name);\n" " IF (SQL % NOTFOUND) THEN\n" " found := 0;\n" " ELSE" @@ -2381,7 +2382,8 @@ row_rename_table_for_mysql( "WHILE found = 1 LOOP\n" " SELECT ID INTO foreign_id\n" " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = old_table_name;\n" + " WHERE FOR_NAME = old_table_name\n" + " AND TO_BINARY(FOR_NAME) = TO_BINARY(old_table_name);\n" " IF (SQL % NOTFOUND) THEN\n" " found := 0;\n" " ELSE\n" @@ -2414,7 +2416,8 @@ row_rename_table_for_mysql( " END IF;\n" "END LOOP;\n" "UPDATE SYS_FOREIGN SET REF_NAME = new_table_name\n" - "WHERE REF_NAME = old_table_name;\n"; + "WHERE REF_NAME = old_table_name\n" + " AND TO_BINARY(REF_NAME) = TO_BINARY(old_table_name);\n"; static const char str5[] = "END;\n"; @@ -2602,7 +2605,11 @@ row_rename_table_for_mysql( if (err == DB_DUPLICATE_KEY) { ut_print_timestamp(stderr); - fputs(" InnoDB: Error: table ", stderr); + fputs( + " InnoDB: Error; possible reasons:\n" + "InnoDB: 1) Table rename would cause two FOREIGN KEY constraints\n" + "InnoDB: to have the same internal name in case-insensitive comparison.\n" + "InnoDB: 2) table ", stderr); ut_print_name(stderr, new_name); fputs(" exists in the InnoDB internal data\n" "InnoDB: dictionary though MySQL is trying rename table ", stderr); From 066964675234bde4abaca6f7d9283f626affd825 Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Sun, 31 Oct 2004 15:33:56 +0100 Subject: [PATCH 031/101] NDB bug-6018 support writeTuple with blobs --- mysql-test/r/ndb_blob.result | 269 ++++++++++------- mysql-test/t/ndb_blob.test | 180 ++++++++---- ndb/include/ndbapi/NdbBlob.hpp | 47 ++- ndb/include/ndbapi/NdbConnection.hpp | 4 +- ndb/include/ndbapi/NdbIndexOperation.hpp | 4 + ndb/include/ndbapi/NdbOperation.hpp | 9 +- ndb/src/ndbapi/NdbBlob.cpp | 359 ++++++++++++++++------- ndb/src/ndbapi/NdbConnection.cpp | 15 +- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 9 +- ndb/src/ndbapi/NdbIndexOperation.cpp | 26 +- ndb/src/ndbapi/NdbOperation.cpp | 4 +- ndb/src/ndbapi/NdbOperationExec.cpp | 14 +- ndb/test/ndbapi/testBlobs.cpp | 201 +++++++++---- 13 files changed, 754 insertions(+), 387 deletions(-) diff --git a/mysql-test/r/ndb_blob.result b/mysql-test/r/ndb_blob.result index cf64ec41ae3..1f2cf33f57d 100644 --- a/mysql-test/r/ndb_blob.result +++ b/mysql-test/r/ndb_blob.result @@ -1,25 +1,5 @@ drop table if exists t1; -drop database if exists mysqltest; -create table t1 ( -a int not null primary key, -b tinytext -) engine=ndbcluster; -insert into t1 values(1, 'x'); -update t1 set b = 'y'; -select * from t1; -a b -1 y -delete from t1; -drop table t1; -create table t1 ( -a int not null primary key, -b text not null -) engine=ndbcluster; -insert into t1 values(1, ''); -select * from t1; -a b -1 -drop table t1; +drop database if exists test2; set autocommit=0; create table t1 ( a int not null primary key, @@ -102,6 +82,53 @@ commit; select count(*) from t1; count(*) 0 +replace t1 set a=1,b=@b1,c=111,d=@d1; +replace t1 set a=2,b=@b2,c=222,d=@d2; +commit; +explain select * from t1 where a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=1; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=2; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +2 20000 b2 30000 dd2 +replace t1 set a=1,b=@b2,c=111,d=@d2; +replace t1 set a=2,b=@b1,c=222,d=@d1; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=1; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +1 20000 b2 30000 dd2 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=2; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +2 2256 b1 3000 dd1 +replace t1 set a=1,b=concat(@b2,@b2),c=111,d=concat(@d2,@d2); +replace t1 set a=2,b=concat(@b1,@b1),c=222,d=concat(@d1,@d1); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where a=1; +a length(b) substr(b,1+4*9000,2) length(d) substr(d,1+6*9000,3) +1 40000 b2 60000 dd2 +select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) +from t1 where a=2; +a length(b) substr(b,1+4*900,2) length(d) substr(d,1+6*900,3) +2 4512 b1 6000 dd1 +replace t1 set a=1,b='xyz',c=111,d=null; +commit; +select a,b from t1 where d is null; +a b +1 xyz +delete from t1 where a=1; +delete from t1 where a=2; +commit; +select count(*) from t1; +count(*) +0 insert into t1 values(1,@b1,111,@d1); insert into t1 values(2,@b2,222,@d2); commit; @@ -241,90 +268,6 @@ a b c d 7 7xb7 777 7xdd7 8 8xb8 888 8xdd8 9 9xb9 999 9xdd9 -select * from t1 order by a; -a b c d -1 1xb1 111 1xdd1 -2 2xb2 222 2xdd2 -3 3xb3 333 3xdd3 -4 4xb4 444 4xdd4 -5 5xb5 555 5xdd5 -6 6xb6 666 6xdd6 -7 7xb7 777 7xdd7 -8 8xb8 888 8xdd8 -9 9xb9 999 9xdd9 -alter table t1 add x int; -select * from t1 order by a; -a b c d x -1 1xb1 111 1xdd1 NULL -2 2xb2 222 2xdd2 NULL -3 3xb3 333 3xdd3 NULL -4 4xb4 444 4xdd4 NULL -5 5xb5 555 5xdd5 NULL -6 6xb6 666 6xdd6 NULL -7 7xb7 777 7xdd7 NULL -8 8xb8 888 8xdd8 NULL -9 9xb9 999 9xdd9 NULL -alter table t1 drop x; -select * from t1 order by a; -a b c d -1 1xb1 111 1xdd1 -2 2xb2 222 2xdd2 -3 3xb3 333 3xdd3 -4 4xb4 444 4xdd4 -5 5xb5 555 5xdd5 -6 6xb6 666 6xdd6 -7 7xb7 777 7xdd7 -8 8xb8 888 8xdd8 -9 9xb9 999 9xdd9 -create database mysqltest; -use mysqltest; -CREATE TABLE t2 ( -a bigint unsigned NOT NULL PRIMARY KEY, -b int unsigned not null, -c int unsigned -) engine=ndbcluster; -insert into t2 values (1,1,1),(2,2,2); -select * from test.t1,t2 where test.t1.a = t2.a order by test.t1.a; -a b c d a b c -1 1xb1 111 1xdd1 1 1 1 -2 2xb2 222 2xdd2 2 2 2 -drop table t2; -use test; -select * from t1 order by a; -a b c d -1 1xb1 111 1xdd1 -2 2xb2 222 2xdd2 -3 3xb3 333 3xdd3 -4 4xb4 444 4xdd4 -5 5xb5 555 5xdd5 -6 6xb6 666 6xdd6 -7 7xb7 777 7xdd7 -8 8xb8 888 8xdd8 -9 9xb9 999 9xdd9 -alter table t1 add x int; -select * from t1 order by a; -a b c d x -1 1xb1 111 1xdd1 NULL -2 2xb2 222 2xdd2 NULL -3 3xb3 333 3xdd3 NULL -4 4xb4 444 4xdd4 NULL -5 5xb5 555 5xdd5 NULL -6 6xb6 666 6xdd6 NULL -7 7xb7 777 7xdd7 NULL -8 8xb8 888 8xdd8 NULL -9 9xb9 999 9xdd9 NULL -alter table t1 drop x; -select * from t1 order by a; -a b c d -1 1xb1 111 1xdd1 -2 2xb2 222 2xdd2 -3 3xb3 333 3xdd3 -4 4xb4 444 4xdd4 -5 5xb5 555 5xdd5 -6 6xb6 666 6xdd6 -7 7xb7 777 7xdd7 -8 8xb8 888 8xdd8 -9 9xb9 999 9xdd9 delete from t1 where c >= 100; commit; select count(*) from t1; @@ -375,8 +318,122 @@ rollback; select count(*) from t1; count(*) 0 +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +alter table t1 add x int; +select * from t1 order by a; +a b c d x +1 b1 111 dd1 NULL +2 b2 222 dd2 NULL +3 b3 333 dd3 NULL +4 b4 444 dd4 NULL +5 b5 555 dd5 NULL +6 b6 666 dd6 NULL +7 b7 777 dd7 NULL +8 b8 888 dd8 NULL +9 b9 999 dd9 NULL +alter table t1 drop x; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +create database test2; +use test2; +CREATE TABLE t2 ( +a bigint unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +insert into t2 values (1,1,1),(2,2,2); +select * from test.t1,t2 where test.t1.a = t2.a order by test.t1.a; +a b c d a b c +1 b1 111 dd1 1 1 1 +2 b2 222 dd2 2 2 2 +drop table t2; +use test; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +alter table t1 add x int; +select * from t1 order by a; +a b c d x +1 b1 111 dd1 NULL +2 b2 222 dd2 NULL +3 b3 333 dd3 NULL +4 b4 444 dd4 NULL +5 b5 555 dd5 NULL +6 b6 666 dd6 NULL +7 b7 777 dd7 NULL +8 b8 888 dd8 NULL +9 b9 999 dd9 NULL +alter table t1 drop x; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +drop table t1; +drop database test2; +create table t1 ( +a int not null primary key, +b tinytext +) engine=ndbcluster; +insert into t1 values(1, 'x'); +update t1 set b = 'y'; +select * from t1; +a b +1 x +delete from t1; +drop table t1; +create table t1 ( +a int not null primary key, +b text not null +) engine=ndbcluster; +insert into t1 values(1, ''); +select * from t1; +a b +1 drop table t1; -drop database mysqltest; set autocommit=1; use test; CREATE TABLE t1 ( diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index 5454dd91d26..ba5f089b17b 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -2,7 +2,7 @@ --disable_warnings drop table if exists t1; -drop database if exists mysqltest; +drop database if exists test2; --enable_warnings # @@ -12,31 +12,7 @@ drop database if exists mysqltest; # A prerequisite for this handler test is that "testBlobs" succeeds. # -# -- bug-5252 tinytext crashes -- - -create table t1 ( - a int not null primary key, - b tinytext -) engine=ndbcluster; - -insert into t1 values(1, 'x'); -update t1 set b = 'y'; -select * from t1; -delete from t1; -drop table t1; - -# -- bug-5013 insert empty string to text -- - -create table t1 ( - a int not null primary key, - b text not null -) engine=ndbcluster; - -insert into t1 values(1, ''); -select * from t1; -drop table t1; - --- general test starts -- +# -- general test starts -- # make test harder with autocommit off set autocommit=0; @@ -117,7 +93,6 @@ from t1 where a=2; # pk update to null update t1 set d=null where a=1; commit; -# FIXME now fails at random due to weird mixup between the 2 rows select a from t1 where d is null; # pk delete @@ -126,6 +101,49 @@ delete from t1 where a=2; commit; select count(*) from t1; +# -- replace ( bug-6018 ) -- + +# insert +replace t1 set a=1,b=@b1,c=111,d=@d1; +replace t1 set a=2,b=@b2,c=222,d=@d2; +commit; +explain select * from t1 where a = 1; + +# pk read +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=1; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=2; + +# update +replace t1 set a=1,b=@b2,c=111,d=@d2; +replace t1 set a=2,b=@b1,c=222,d=@d1; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=1; +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=2; + +# update +replace t1 set a=1,b=concat(@b2,@b2),c=111,d=concat(@d2,@d2); +replace t1 set a=2,b=concat(@b1,@b1),c=222,d=concat(@d1,@d1); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where a=1; +select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) +from t1 where a=2; + +# update to null +replace t1 set a=1,b='xyz',c=111,d=null; +commit; +select a,b from t1 where d is null; + +# pk delete +delete from t1 where a=1; +delete from t1 where a=2; +commit; +select count(*) from t1; + # -- hash index ops -- insert into t1 values(1,@b1,111,@d1); @@ -231,39 +249,6 @@ where c >= 100; commit; select * from t1 where c >= 100 order by a; -# alter table - -select * from t1 order by a; -alter table t1 add x int; -select * from t1 order by a; -alter table t1 drop x; -select * from t1 order by a; - -# multi db - -create database mysqltest; -use mysqltest; - -CREATE TABLE t2 ( - a bigint unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - -insert into t2 values (1,1,1),(2,2,2); -select * from test.t1,t2 where test.t1.a = t2.a order by test.t1.a; - -drop table t2; -use test; - -# alter table - -select * from t1 order by a; -alter table t1 add x int; -select * from t1 order by a; -alter table t1 drop x; -select * from t1 order by a; - # range scan delete delete from t1 where c >= 100; commit; @@ -306,10 +291,77 @@ select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) from t1 order by a; rollback; select count(*) from t1; -drop table t1; -drop database mysqltest; -# bug #5349 +# -- alter table and multi db -- + +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; + +select * from t1 order by a; +alter table t1 add x int; +select * from t1 order by a; +alter table t1 drop x; +select * from t1 order by a; + +create database test2; +use test2; + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + +insert into t2 values (1,1,1),(2,2,2); +select * from test.t1,t2 where test.t1.a = t2.a order by test.t1.a; + +drop table t2; +use test; + +select * from t1 order by a; +alter table t1 add x int; +select * from t1 order by a; +alter table t1 drop x; +select * from t1 order by a; + +# -- end general test -- + +drop table t1; +drop database test2; + +# -- bug-5252 tinytext crashes -- + +create table t1 ( + a int not null primary key, + b tinytext +) engine=ndbcluster; + +insert into t1 values(1, 'x'); +update t1 set b = 'y'; +select * from t1; +delete from t1; +drop table t1; + +# -- bug-5013 insert empty string to text -- + +create table t1 ( + a int not null primary key, + b text not null +) engine=ndbcluster; + +insert into t1 values(1, ''); +select * from t1; +drop table t1; + +# -- bug #5349 -- set autocommit=1; use test; CREATE TABLE t1 ( @@ -327,7 +379,7 @@ select * from t1 order by a; alter table t1 engine=ndb; select * from t1 order by a; -# bug #5872 +# -- bug #5872 -- alter table t1 engine=myisam; select * from t1 order by a; drop table t1; diff --git a/ndb/include/ndbapi/NdbBlob.hpp b/ndb/include/ndbapi/NdbBlob.hpp index 22e393b6c5d..b3c28c9e950 100644 --- a/ndb/include/ndbapi/NdbBlob.hpp +++ b/ndb/include/ndbapi/NdbBlob.hpp @@ -36,7 +36,7 @@ class NdbColumnImpl; * Blob data is stored in 2 places: * * - "header" and "inline bytes" stored in the blob attribute - * - "blob parts" stored in a separate table NDB$BLOB___ + * - "blob parts" stored in a separate table NDB$BLOB__ * * Inline and part sizes can be set via NdbDictionary::Column methods * when the table is created. @@ -74,23 +74,21 @@ class NdbColumnImpl; * NdbBlob methods return -1 on error and 0 on success, and use output * parameters when necessary. * - * Notes: - * - table and its blob part tables are not created atomically - * - scan must use the "new" interface NdbScanOperation - * - to update a blob in a read op requires exclusive tuple lock - * - update op in scan must do its own getBlobHandle - * - delete creates implicit, not-accessible blob handles - * - NdbOperation::writeTuple does not support blobs - * - there is no support for an asynchronous interface + * Operation types: + * - insertTuple must use setValue if blob column is non-nullable + * - readTuple with exclusive lock can also update existing value + * - updateTuple can overwrite with setValue or update existing value + * - writeTuple always overwrites and must use setValue if non-nullable + * - deleteTuple creates implicit non-accessible blob handles + * - scan with exclusive lock can also update existing value + * - scan "lock takeover" update op must do its own getBlobHandle * * Bugs / limitations: - * - scan must use exclusive locking for now - * - * Todo: - * - add scan method hold-read-lock + return-keyinfo - * - check keyinfo length when setting keys - * - check allowed blob ops vs locking mode - * - overload control (too many pending ops) + * - lock mode upgrade should be handled automatically + * - lock mode vs allowed operation is not checked + * - too many pending blob ops can blow up i/o buffers + * - table and its blob part tables are not created atomically + * - there is no support for an asynchronous interface */ class NdbBlob { public: @@ -172,19 +170,11 @@ public: * read in the in/out bytes parameter. */ int readData(void* data, Uint32& bytes); - /** - * Read at given position. Does not use or update current position. - */ - int readData(Uint64 pos, void* data, Uint32& bytes); /** * Write at current position and set new position to first byte after * the data written. A write past blob end extends the blob value. */ int writeData(const void* data, Uint32 bytes); - /** - * Write at given position. Does not use or update current position. - */ - int writeData(Uint64 pos, const void* data, Uint32 bytes); /** * Return the blob column. */ @@ -266,14 +256,17 @@ private: Buf(); ~Buf(); void alloc(unsigned n); + void copyfrom(const Buf& src); }; Buf theKeyBuf; Buf theAccessKeyBuf; Buf theHeadInlineBuf; + Buf theHeadInlineCopyBuf; // for writeTuple Buf thePartBuf; Head* theHead; char* theInlineData; NdbRecAttr* theHeadInlineRecAttr; + NdbOperation* theHeadInlineReadOp; bool theHeadInlineUpdateFlag; // length and read/write position int theNullFlag; @@ -294,6 +287,7 @@ private: bool isReadOp(); bool isInsertOp(); bool isUpdateOp(); + bool isWriteOp(); bool isDeleteOp(); bool isScanOp(); // computations @@ -309,12 +303,13 @@ private: void getHeadFromRecAttr(); int setHeadInlineValue(NdbOperation* anOp); // data operations - int readDataPrivate(Uint64 pos, char* buf, Uint32& bytes); - int writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes); + int readDataPrivate(char* buf, Uint32& bytes); + int writeDataPrivate(const char* buf, Uint32 bytes); int readParts(char* buf, Uint32 part, Uint32 count); int insertParts(const char* buf, Uint32 part, Uint32 count); int updateParts(const char* buf, Uint32 part, Uint32 count); int deleteParts(Uint32 part, Uint32 count); + int deletePartsUnknown(Uint32 part); // pending ops int executePendingBlobReads(); int executePendingBlobWrites(); diff --git a/ndb/include/ndbapi/NdbConnection.hpp b/ndb/include/ndbapi/NdbConnection.hpp index 92b940e96f7..7af5d27b922 100644 --- a/ndb/include/ndbapi/NdbConnection.hpp +++ b/ndb/include/ndbapi/NdbConnection.hpp @@ -526,7 +526,7 @@ private: int sendCOMMIT(); // Send a TC_COMMITREQ signal; void setGCI(int GCI); // Set the global checkpoint identity - int OpCompleteFailure(Uint8 abortoption); + int OpCompleteFailure(Uint8 abortoption, bool setFailure = true); int OpCompleteSuccess(); void CompletedOperations(); // Move active ops to list of completed @@ -552,7 +552,7 @@ private: void setOperationErrorCode(int anErrorCode); // Indicate something went wrong in the definition phase - void setOperationErrorCodeAbort(int anErrorCode); + void setOperationErrorCodeAbort(int anErrorCode, int abortOption = -1); int checkMagicNumber(); // Verify correct object NdbOperation* getNdbOperation(const class NdbTableImpl* aTable, diff --git a/ndb/include/ndbapi/NdbIndexOperation.hpp b/ndb/include/ndbapi/NdbIndexOperation.hpp index 7612fe54d1b..1472f1b249e 100644 --- a/ndb/include/ndbapi/NdbIndexOperation.hpp +++ b/ndb/include/ndbapi/NdbIndexOperation.hpp @@ -49,6 +49,9 @@ public: * @{ */ + /** insert is not allowed */ + int insertTuple(); + /** * Define the NdbIndexOperation to be a standard operation of type readTuple. * When calling NdbConnection::execute, this operation @@ -193,6 +196,7 @@ private: // Private attributes const NdbIndexImpl* m_theIndex; + const NdbTableImpl* m_thePrimaryTable; Uint32 m_theIndexDefined[NDB_MAX_ATTRIBUTES_IN_INDEX][3]; Uint32 m_theIndexLen; // Length of the index in words Uint32 m_theNoOfIndexDefined; // The number of index attributes diff --git a/ndb/include/ndbapi/NdbOperation.hpp b/ndb/include/ndbapi/NdbOperation.hpp index 8e0294e41e6..46d4ddab0f5 100644 --- a/ndb/include/ndbapi/NdbOperation.hpp +++ b/ndb/include/ndbapi/NdbOperation.hpp @@ -918,6 +918,13 @@ protected: // Blobs in this operation NdbBlob* theBlobList; + /* + * Abort option per operation, used by blobs. Default -1. If set, + * overrides abort option on connection level. If set to IgnoreError, + * does not cause execute() to return failure. This is different from + * IgnoreError on connection level. + */ + Int8 m_abortOption; }; #ifdef NDB_NO_DROPPED_SIGNAL @@ -1160,5 +1167,3 @@ NdbOperation::setValue(Uint32 anAttrId, double aPar) } #endif - - diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index feab95d8ca5..5b193870558 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -33,21 +33,24 @@ ndbout << prefix << " " << hex << (void*)this << " " << cname; \ ndbout << " " << dec << __LINE__ << " " << x << " " << *this << endl; \ } while (0) -#else -#define DBG(x) -#endif static char* ndb_blob_debug(const Uint32* data, unsigned size) { - static char buf[128 + 1]; // MT irrelevant + static char buf[200]; // MT irrelevant buf[0] = 0; - for (unsigned i = 0; i < size && i < 128 / 4; i++) { - sprintf(buf + strlen(buf), "%*s%08x", i != 0, "", data[i]); + for (unsigned i = 0; i < size; i++) { + unsigned n = strlen(buf); + if (n + 10 < sizeof(buf)) + sprintf(buf + n, "%*s%08x", i != 0, "", data[i]); } return buf; } +#else +#define DBG(x) +#endif + /* * Reading index table directly (as a table) is faster but there are * bugs or limitations. Keep the code and make possible to choose. @@ -162,6 +165,7 @@ NdbBlob::init() theHead = NULL; theInlineData = NULL; theHeadInlineRecAttr = NULL; + theHeadInlineReadOp = NULL; theHeadInlineUpdateFlag = false; theNullFlag = -1; theLength = 0; @@ -206,6 +210,13 @@ NdbBlob::Buf::alloc(unsigned n) #endif } +void +NdbBlob::Buf::copyfrom(const NdbBlob::Buf& src) +{ + assert(size == src.size); + memcpy(data, src.data, size); +} + // classify operations (inline) inline bool @@ -226,6 +237,7 @@ NdbBlob::isKeyOp() return theNdbOp->theOperationType == NdbOperation::InsertRequest || theNdbOp->theOperationType == NdbOperation::UpdateRequest || + theNdbOp->theOperationType == NdbOperation::WriteRequest || theNdbOp->theOperationType == NdbOperation::ReadRequest || theNdbOp->theOperationType == NdbOperation::ReadExclusive || theNdbOp->theOperationType == NdbOperation::DeleteRequest; @@ -253,6 +265,13 @@ NdbBlob::isUpdateOp() theNdbOp->theOperationType == NdbOperation::UpdateRequest; } +inline bool +NdbBlob::isWriteOp() +{ + return + theNdbOp->theOperationType == NdbOperation::WriteRequest; +} + inline bool NdbBlob::isDeleteOp() { @@ -289,7 +308,7 @@ inline Uint32 NdbBlob::getDistKey(Uint32 part) { assert(theStripeSize != 0); - return (part / theStripeSize) % theStripeSize; + return part / theStripeSize; } // getters and setters @@ -401,7 +420,7 @@ NdbBlob::getHeadFromRecAttr() theNullFlag = theHeadInlineRecAttr->isNULL(); assert(theNullFlag != -1); theLength = ! theNullFlag ? theHead->length : 0; - DBG("getHeadFromRecAttr out"); + DBG("getHeadFromRecAttr [out]"); } int @@ -453,7 +472,7 @@ NdbBlob::setValue(const void* data, Uint32 bytes) setErrorCode(ErrState); return -1; } - if (! isInsertOp() && ! isUpdateOp()) { + if (! isInsertOp() && ! isUpdateOp() && ! isWriteOp()) { setErrorCode(ErrUsage); return -1; } @@ -466,11 +485,12 @@ NdbBlob::setValue(const void* data, Uint32 bytes) theGetSetBytes = bytes; if (isInsertOp()) { // write inline part now - if (theSetBuf != 0) { - unsigned n = theGetSetBytes; + if (theSetBuf != NULL) { + Uint32 n = theGetSetBytes; if (n > theInlineSize) n = theInlineSize; - if (writeDataPrivate(0, theSetBuf, n) == -1) + assert(thePos == 0); + if (writeDataPrivate(theSetBuf, n) == -1) return -1; } else { theNullFlag = true; @@ -555,7 +575,7 @@ NdbBlob::getLength(Uint64& len) int NdbBlob::truncate(Uint64 length) { - DBG("truncate length=" << length); + DBG("truncate [in] length=" << length); if (theNullFlag == -1) { setErrorCode(ErrState); return -1; @@ -573,7 +593,10 @@ NdbBlob::truncate(Uint64 length) } theLength = length; theHeadInlineUpdateFlag = true; + if (thePos > length) + thePos = length; } + DBG("truncate [out]"); return 0; } @@ -609,33 +632,21 @@ NdbBlob::setPos(Uint64 pos) int NdbBlob::readData(void* data, Uint32& bytes) -{ - if (readData(thePos, data, bytes) == -1) - return -1; - thePos += bytes; - assert(thePos <= theLength); - return 0; -} - -int -NdbBlob::readData(Uint64 pos, void* data, Uint32& bytes) { if (theState != Active) { setErrorCode(ErrState); return -1; } char* buf = static_cast(data); - return readDataPrivate(pos, buf, bytes); + return readDataPrivate(buf, bytes); } int -NdbBlob::readDataPrivate(Uint64 pos, char* buf, Uint32& bytes) +NdbBlob::readDataPrivate(char* buf, Uint32& bytes) { - DBG("readData pos=" << pos << " bytes=" << bytes); - if (pos > theLength) { - setErrorCode(ErrSeek); - return -1; - } + DBG("readData [in] bytes=" << bytes); + assert(thePos <= theLength); + Uint64 pos = thePos; if (bytes > theLength - pos) bytes = theLength - pos; Uint32 len = bytes; @@ -709,38 +720,29 @@ NdbBlob::readDataPrivate(Uint64 pos, char* buf, Uint32& bytes) len -= n; } assert(len == 0); + thePos = pos; + assert(thePos <= theLength); + DBG("readData [out]"); return 0; } int NdbBlob::writeData(const void* data, Uint32 bytes) -{ - if (writeData(thePos, data, bytes) == -1) - return -1; - thePos += bytes; - assert(thePos <= theLength); - return 0; -} - -int -NdbBlob::writeData(Uint64 pos, const void* data, Uint32 bytes) { if (theState != Active) { setErrorCode(ErrState); return -1; } const char* buf = static_cast(data); - return writeDataPrivate(pos, buf, bytes); + return writeDataPrivate(buf, bytes); } int -NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) +NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) { - DBG("writeData pos=" << pos << " bytes=" << bytes); - if (pos > theLength) { - setErrorCode(ErrSeek); - return -1; - } + DBG("writeData [in] bytes=" << bytes); + assert(thePos <= theLength); + Uint64 pos = thePos; Uint32 len = bytes; // any write makes blob not NULL if (theNullFlag) { @@ -778,7 +780,7 @@ NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reafs"); + DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; Uint32 n = thePartSize - off; @@ -855,14 +857,16 @@ NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) theLength = pos; theHeadInlineUpdateFlag = true; } - DBG("writeData out"); + thePos = pos; + assert(thePos <= theLength); + DBG("writeData [out]"); return 0; } int NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) { - DBG("readParts part=" << part << " count=" << count); + DBG("readParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -873,6 +877,7 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; buf += thePartSize; n++; thePendingBlobOps |= (1 << NdbOperation::ReadRequest); @@ -884,7 +889,7 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) int NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) { - DBG("insertParts part=" << part << " count=" << count); + DBG("insertParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -895,6 +900,7 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; buf += thePartSize; n++; thePendingBlobOps |= (1 << NdbOperation::InsertRequest); @@ -906,7 +912,7 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) int NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) { - DBG("updateParts part=" << part << " count=" << count); + DBG("updateParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -917,6 +923,7 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; buf += thePartSize; n++; thePendingBlobOps |= (1 << NdbOperation::UpdateRequest); @@ -928,7 +935,7 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) int NdbBlob::deleteParts(Uint32 part, Uint32 count) { - DBG("deleteParts part=" << part << " count=" << count); + DBG("deleteParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -938,6 +945,7 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; n++; thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); theNdbCon->thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); @@ -945,6 +953,57 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count) return 0; } +/* + * Number of blob parts not known. Used to check for race condition + * when writeTuple is used for insert. Deletes all parts found. + */ +int +NdbBlob::deletePartsUnknown(Uint32 part) +{ + DBG("deletePartsUnknown [in] part=" << part << " count=all"); + static const unsigned maxbat = 256; + static const unsigned minbat = 1; + unsigned bat = minbat; + NdbOperation* tOpList[maxbat]; + Uint32 count = 0; + while (true) { + Uint32 n; + n = 0; + while (n < bat) { + NdbOperation*& tOp = tOpList[n]; // ref + tOp = theNdbCon->getNdbOperation(theBlobTable); + if (tOp == NULL || + tOp->deleteTuple() == -1 || + setPartKeyValue(tOp, part + count + n) == -1) { + setErrorCode(tOp); + return -1; + } + tOp->m_abortOption = IgnoreError; + n++; + if (theNdbCon->executeNoBlobs(NoCommit) == -1) + return -1; + } + n = 0; + while (n < bat) { + NdbOperation* tOp = tOpList[n]; + if (tOp->theError.code != 0) { + if (tOp->theError.code != 626) { + setErrorCode(tOp); + return -1; + } + // first non-existent part + DBG("deletePartsUnknown [out] count=" << count); + return 0; + } + n++; + count++; + } + bat *= 4; + if (bat > maxbat) + bat = maxbat; + } +} + // pending ops int @@ -1007,7 +1066,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* theTable = anOp->m_currentTable; theAccessTable = anOp->m_accessTable; theColumn = aColumn; - DBG("atPrepare"); + DBG("atPrepare [in]"); NdbDictionary::Column::Type partType = NdbDictionary::Column::Undefined; switch (theColumn->getType()) { case NdbDictionary::Column::Blob: @@ -1046,6 +1105,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* theKeyBuf.alloc(theTable->m_sizeOfKeysInWords << 2); theAccessKeyBuf.alloc(theAccessTable->m_sizeOfKeysInWords << 2); theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize); + theHeadInlineCopyBuf.alloc(sizeof(Head) + theInlineSize); thePartBuf.alloc(thePartSize); theHead = (Head*)theHeadInlineBuf.data; theInlineData = theHeadInlineBuf.data + sizeof(Head); @@ -1080,6 +1140,12 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* theNullFlag = true; theLength = 0; } + if (isWriteOp()) { + // becomes NULL unless set before execute + theNullFlag = true; + theLength = 0; + theHeadInlineUpdateFlag = true; + } supportedOp = true; } if (isScanOp()) { @@ -1093,19 +1159,21 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* return -1; } setState(Prepared); - DBG("atPrepare out"); + DBG("atPrepare [out]"); return 0; } /* * Before execute of prepared operation. May add new operations before * this one. May ask that this operation and all before it (a "batch") - * is executed immediately in no-commit mode. + * is executed immediately in no-commit mode. In this case remaining + * prepared operations are saved in a separate list. They are added + * back after postExecute. */ int NdbBlob::preExecute(ExecType anExecType, bool& batch) { - DBG("preExecute"); + DBG("preExecute [in]"); if (theState == Invalid) return -1; assert(theState == Prepared); @@ -1120,11 +1188,11 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) if (isInsertOp()) { if (theSetFlag && theGetSetBytes > theInlineSize) { // add ops to write rest of a setValue - assert(theSetBuf != 0); - Uint64 pos = theInlineSize; + assert(theSetBuf != NULL); const char* buf = theSetBuf + theInlineSize; Uint32 bytes = theGetSetBytes - theInlineSize; - if (writeDataPrivate(pos, buf, bytes) == -1) + assert(thePos == theInlineSize); + if (writeDataPrivate(buf, bytes) == -1) return -1; if (theHeadInlineUpdateFlag) { // add an operation to update head+inline @@ -1136,11 +1204,12 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) setErrorCode(ErrAbort); return -1; } + DBG("add op to update head+inline"); } } } if (isTableOp()) { - if (isUpdateOp() || isDeleteOp()) { + if (isUpdateOp() || isWriteOp() || isDeleteOp()) { // add operation before this one to read head+inline NdbOperation* tOp = theNdbCon->getNdbOperation(theTable, theNdbOp); if (tOp == NULL || @@ -1150,8 +1219,13 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) setErrorCode(tOp); return -1; } + if (isWriteOp()) { + tOp->m_abortOption = IgnoreError; + } + theHeadInlineReadOp = tOp; // execute immediately batch = true; + DBG("add op before to read head+inline"); } } if (isIndexOp()) { @@ -1180,6 +1254,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) } } } + DBG("added op before to read table key"); if (isUpdateOp() || isDeleteOp()) { // add op before this one to read head+inline via index NdbIndexOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); @@ -1190,15 +1265,43 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) setErrorCode(tOp); return -1; } + if (isWriteOp()) { + tOp->m_abortOption = IgnoreError; + } + theHeadInlineReadOp = tOp; // execute immediately batch = true; + DBG("added index op before to read head+inline"); + } + if (isWriteOp()) { + // XXX until IgnoreError fixed for index op + batch = true; + } + } + if (isWriteOp()) { + if (theSetFlag) { + // write head+inline now + theNullFlag = true; + theLength = 0; + if (theSetBuf != NULL) { + Uint32 n = theGetSetBytes; + if (n > theInlineSize) + n = theInlineSize; + assert(thePos == 0); + if (writeDataPrivate(theSetBuf, n) == -1) + return -1; + } + if (setHeadInlineValue(theNdbOp) == -1) + return -1; + // the read op before us may overwrite + theHeadInlineCopyBuf.copyfrom(theHeadInlineBuf); } } if (theActiveHook != NULL) { // need blob head for callback batch = true; } - DBG("preExecute out batch=" << batch); + DBG("preExecute [out] batch=" << batch); return 0; } @@ -1211,15 +1314,16 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) int NdbBlob::postExecute(ExecType anExecType) { - DBG("postExecute type=" << anExecType); + DBG("postExecute [in] type=" << anExecType); if (theState == Invalid) return -1; if (theState == Active) { setState(anExecType == NoCommit ? Active : Closed); - DBG("postExecute skip"); + DBG("postExecute [skip]"); return 0; } assert(theState == Prepared); + setState(anExecType == NoCommit ? Active : Closed); assert(isKeyOp()); if (isIndexOp()) { NdbBlob* tFirstBlob = theNdbOp->theBlobList; @@ -1231,22 +1335,13 @@ NdbBlob::postExecute(ExecType anExecType) } if (isReadOp()) { getHeadFromRecAttr(); - if (theGetFlag && theGetSetBytes > 0) { - // copy inline bytes to user buffer - assert(theGetBuf != NULL); - unsigned n = theGetSetBytes; - if (n > theInlineSize) - n = theInlineSize; - memcpy(theGetBuf, theInlineData, n); - } - if (theGetFlag && theGetSetBytes > theInlineSize) { - // add ops to read rest of a getValue - assert(anExecType == NoCommit); - assert(theGetBuf != 0); - Uint64 pos = theInlineSize; - char* buf = theGetBuf + theInlineSize; - Uint32 bytes = theGetSetBytes - theInlineSize; - if (readDataPrivate(pos, buf, bytes) == -1) + if (setPos(0) == -1) + return -1; + if (theGetFlag) { + assert(theGetSetBytes == 0 || theGetBuf != 0); + assert(theGetSetBytes <= theInlineSize || anExecType == NoCommit); + Uint32 bytes = theGetSetBytes; + if (readDataPrivate(theGetBuf, bytes) == -1) return -1; } } @@ -1255,10 +1350,11 @@ NdbBlob::postExecute(ExecType anExecType) getHeadFromRecAttr(); if (theSetFlag) { // setValue overwrites everything - if (theSetBuf != 0) { + if (theSetBuf != NULL) { if (truncate(0) == -1) return -1; - if (writeDataPrivate(0, theSetBuf, theGetSetBytes) == -1) + assert(thePos == 0); + if (writeDataPrivate(theSetBuf, theGetSetBytes) == -1) return -1; } else { if (setNull() == -1) @@ -1266,6 +1362,57 @@ NdbBlob::postExecute(ExecType anExecType) } } } + if (isWriteOp() && isTableOp()) { + assert(anExecType == NoCommit); + if (theHeadInlineReadOp->theError.code == 0) { + int tNullFlag = theNullFlag; + Uint64 tLength = theLength; + Uint64 tPos = thePos; + getHeadFromRecAttr(); + DBG("tuple found"); + if (truncate(0) == -1) + return -1; + // restore previous head+inline + theHeadInlineBuf.copyfrom(theHeadInlineCopyBuf); + theNullFlag = tNullFlag; + theLength = tLength; + thePos = tPos; + } else { + if (theHeadInlineReadOp->theError.code != 626) { + setErrorCode(theHeadInlineReadOp); + return -1; + } + DBG("tuple not found"); + /* + * Read found no tuple but it is possible that a tuple was + * created after the read by another transaction. Delete all + * blob parts which may exist. + */ + if (deletePartsUnknown(0) == -1) + return -1; + } + if (theSetFlag && theGetSetBytes > theInlineSize) { + assert(theSetBuf != NULL); + const char* buf = theSetBuf + theInlineSize; + Uint32 bytes = theGetSetBytes - theInlineSize; + assert(thePos == theInlineSize); + if (writeDataPrivate(buf, bytes) == -1) + return -1; + } + } + if (isWriteOp() && isIndexOp()) { + // XXX until IgnoreError fixed for index op + if (deletePartsUnknown(0) == -1) + return -1; + if (theSetFlag && theGetSetBytes > theInlineSize) { + assert(theSetBuf != NULL); + const char* buf = theSetBuf + theInlineSize; + Uint32 bytes = theGetSetBytes - theInlineSize; + assert(thePos == theInlineSize); + if (writeDataPrivate(buf, bytes) == -1) + return -1; + } + } if (isDeleteOp()) { assert(anExecType == NoCommit); getHeadFromRecAttr(); @@ -1278,7 +1425,7 @@ NdbBlob::postExecute(ExecType anExecType) if (invokeActiveHook() == -1) return -1; } - DBG("postExecute out"); + DBG("postExecute [out]"); return 0; } @@ -1289,12 +1436,12 @@ NdbBlob::postExecute(ExecType anExecType) int NdbBlob::preCommit() { - DBG("preCommit"); + DBG("preCommit [in]"); if (theState == Invalid) return -1; assert(theState == Active); assert(isKeyOp()); - if (isInsertOp() || isUpdateOp()) { + if (isInsertOp() || isUpdateOp() || isWriteOp()) { if (theHeadInlineUpdateFlag) { // add an operation to update head+inline NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); @@ -1305,9 +1452,11 @@ NdbBlob::preCommit() setErrorCode(ErrAbort); return -1; } + tOp->m_abortOption = AbortOnError; + DBG("added op to update head+inline"); } } - DBG("preCommit out"); + DBG("preCommit [out]"); return 0; } @@ -1317,13 +1466,10 @@ NdbBlob::preCommit() int NdbBlob::atNextResult() { - DBG("atNextResult"); + DBG("atNextResult [in]"); if (theState == Invalid) return -1; assert(isScanOp()); - getHeadFromRecAttr(); - // reset position - thePos = 0; // get primary key { Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_sizeOfKeysInWords; @@ -1332,26 +1478,14 @@ NdbBlob::atNextResult() return -1; } } - if (! theNullFlag) { - if (theGetFlag && theGetSetBytes > 0) { - // copy inline bytes to user buffer - assert(theGetBuf != NULL); - unsigned n = theGetSetBytes; - if (n > theLength) - n = theLength; - if (n > theInlineSize) - n = theInlineSize; - memcpy(theGetBuf, theInlineData, n); - } - if (theGetFlag && theGetSetBytes > theInlineSize && theLength > theInlineSize) { - // add ops to read rest of a getValue - assert(theGetBuf != 0); - Uint64 pos = theInlineSize; - char* buf = theGetBuf + theInlineSize; - Uint32 bytes = theGetSetBytes - theInlineSize; - if (readDataPrivate(pos, buf, bytes) == -1) - return -1; - } + getHeadFromRecAttr(); + if (setPos(0) == -1) + return -1; + if (theGetFlag) { + assert(theGetSetBytes == 0 || theGetBuf != 0); + Uint32 bytes = theGetSetBytes; + if (readDataPrivate(theGetBuf, bytes) == -1) + return -1; } setState(Active); // activation callback @@ -1359,7 +1493,7 @@ NdbBlob::atNextResult() if (invokeActiveHook() == -1) return -1; } - DBG("atNextResult out"); + DBG("atNextResult [out]"); return 0; } @@ -1444,7 +1578,8 @@ operator<<(NdbOut& out, const NdbBlob& blob) ndbout << dec << " n=" << blob.theNullFlag;; ndbout << dec << " l=" << blob.theLength; ndbout << dec << " p=" << blob.thePos; - ndbout << dec << " u=" << (Uint32) blob.theHeadInlineUpdateFlag; + ndbout << dec << " u=" << (Uint32)blob.theHeadInlineUpdateFlag; + ndbout << dec << " g=" << (Uint32)blob.theGetSetBytes; return out; } #endif diff --git a/ndb/src/ndbapi/NdbConnection.cpp b/ndb/src/ndbapi/NdbConnection.cpp index 1457792cf28..c21a85fd24d 100644 --- a/ndb/src/ndbapi/NdbConnection.cpp +++ b/ndb/src/ndbapi/NdbConnection.cpp @@ -170,12 +170,14 @@ Remark: Sets an error code on the connection object from an operation object. *****************************************************************************/ void -NdbConnection::setOperationErrorCodeAbort(int error) +NdbConnection::setOperationErrorCodeAbort(int error, int abortOption) { DBUG_ENTER("NdbConnection::setOperationErrorCodeAbort"); + if (abortOption == -1) + abortOption = m_abortOption; if (theTransactionIsStarted == false) { theCommitStatus = Aborted; - } else if ((m_abortOption == AbortOnError) && + } else if ((abortOption == AbortOnError) && (theCommitStatus != Committed) && (theCommitStatus != Aborted)) { theCommitStatus = NeedAbort; @@ -335,8 +337,11 @@ NdbConnection::execute(ExecType aTypeOfExec, tOp = tOp->next(); } } + if (executeNoBlobs(tExecType, abortOption, forceSend) == -1) ret = -1; + assert(theFirstOpInList == NULL && theLastOpInList == NULL); + { NdbOperation* tOp = theCompletedFirstOp; while (tOp != NULL) { @@ -360,6 +365,7 @@ NdbConnection::execute(ExecType aTypeOfExec, theLastOpInList->next(tRestOp); theLastOpInList = tLastOp; } + assert(theFirstOpInList == NULL || tExecType == NoCommit); } while (theFirstOpInList != NULL || tExecType != aTypeOfExec); DBUG_RETURN(ret); @@ -1806,11 +1812,12 @@ Parameters: aErrorCode: The error code. Remark: An operation was completed with failure. *******************************************************************************/ int -NdbConnection::OpCompleteFailure(Uint8 abortOption) +NdbConnection::OpCompleteFailure(Uint8 abortOption, bool setFailure) { Uint32 tNoComp = theNoOfOpCompleted; Uint32 tNoSent = theNoOfOpSent; - theCompletionStatus = NdbConnection::CompletedFailure; + if (setFailure) + theCompletionStatus = NdbConnection::CompletedFailure; tNoComp++; theNoOfOpCompleted = tNoComp; if (tNoComp == tNoSent) { diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index cf51a30fe0b..76854cabcd7 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -47,13 +47,15 @@ * Column */ NdbColumnImpl::NdbColumnImpl() - : NdbDictionary::Column(* this), m_facade(this) + : NdbDictionary::Column(* this), m_facade(this), + m_attrId(-1) { init(); } NdbColumnImpl::NdbColumnImpl(NdbDictionary::Column & f) - : NdbDictionary::Column(* this), m_facade(&f) + : NdbDictionary::Column(* this), m_facade(&f), + m_attrId(-1) { init(); } @@ -93,8 +95,7 @@ NdbColumnImpl::init(Type t) { // do not use default_charset_info as it may not be initialized yet // use binary collation until NDB tests can handle charsets - CHARSET_INFO* default_cs = &my_charset_latin1_bin; - m_attrId = -1; + CHARSET_INFO* default_cs = &my_charset_bin; m_type = t; switch (m_type) { case Tinyint: diff --git a/ndb/src/ndbapi/NdbIndexOperation.cpp b/ndb/src/ndbapi/NdbIndexOperation.cpp index 9abde639914..3f174a61b64 100644 --- a/ndb/src/ndbapi/NdbIndexOperation.cpp +++ b/ndb/src/ndbapi/NdbIndexOperation.cpp @@ -71,6 +71,7 @@ NdbIndexOperation::indxInit(const NdbIndexImpl * anIndex, return -1; } m_theIndex = anIndex; + m_thePrimaryTable = aTable; m_accessTable = anIndex->m_table; m_theIndexLen = 0; m_theNoOfIndexDefined = 0; @@ -102,6 +103,12 @@ int NdbIndexOperation::readTuple(NdbOperation::LockMode lm) }; } +int NdbIndexOperation::insertTuple() +{ + setErrorCode(4200); + return -1; +} + int NdbIndexOperation::readTuple() { // First check that index is unique @@ -341,12 +348,11 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, theDistrGroupIndicator = 1; }//if /************************************************************************** - * If the operation is an insert request and the attribute is stored then + * If the operation is a write request and the attribute is stored then * we also set the value in the stored part through putting the * information in the INDXATTRINFO signals. *************************************************************************/ - if ((tOpType == InsertRequest) || - (tOpType == WriteRequest)) { + if ((tOpType == WriteRequest)) { if (!tAttrInfo->m_indexOnly){ // invalid data can crash kernel if (cs != NULL && @@ -357,7 +363,13 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, goto equal_error4; Uint32 ahValue; Uint32 sz = totalSizeInWords; - AttributeHeader::init(&ahValue, tAttrId, sz); + /* + * XXX should be linked in metadata but cannot now because + * things can be defined in arbitrary order + */ + const NdbColumnImpl* primaryCol = m_thePrimaryTable->getColumn(tAttrInfo->m_name.c_str()); + assert(primaryCol != NULL); + AttributeHeader::init(&ahValue, primaryCol->m_attrId, sz); insertATTRINFO( ahValue ); insertATTRINFOloop((Uint32*)aValueToWrite, sizeInWords); if (bitsInLastWord != 0) { @@ -369,7 +381,6 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, }//if }//if }//if - /************************************************************************** * Store the Key information in the TCINDXREQ and INDXKEYINFO signals. *************************************************************************/ @@ -734,13 +745,10 @@ NdbIndexOperation::receiveTCINDXREF( NdbApiSignal* aSignal) }//if theStatus = Finished; - + theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; Uint32 errorCode = tcIndxRef->errorCode; theError.code = errorCode; theNdbCon->setOperationErrorCodeAbort(errorCode); return theNdbCon->OpCompleteFailure(theNdbCon->m_abortOption); }//NdbIndexOperation::receiveTCINDXREF() - - - diff --git a/ndb/src/ndbapi/NdbOperation.cpp b/ndb/src/ndbapi/NdbOperation.cpp index b0b95d0ff43..88d8a000d50 100644 --- a/ndb/src/ndbapi/NdbOperation.cpp +++ b/ndb/src/ndbapi/NdbOperation.cpp @@ -78,7 +78,8 @@ NdbOperation::NdbOperation(Ndb* aNdb) : m_tcReqGSN(GSN_TCKEYREQ), m_keyInfoGSN(GSN_KEYINFO), m_attrInfoGSN(GSN_ATTRINFO), - theBlobList(NULL) + theBlobList(NULL), + m_abortOption(-1) { theReceiver.init(NdbReceiver::NDB_OPERATION, this); theError.code = 0; @@ -167,6 +168,7 @@ NdbOperation::init(const NdbTableImpl* tab, NdbConnection* myConnection){ theTotalNrOfKeyWordInSignal = 8; theMagicNumber = 0xABCDEF01; theBlobList = NULL; + m_abortOption = -1; tSignal = theNdb->getSignal(); if (tSignal == NULL) diff --git a/ndb/src/ndbapi/NdbOperationExec.cpp b/ndb/src/ndbapi/NdbOperationExec.cpp index f1338ae01e4..fa46e93a57f 100644 --- a/ndb/src/ndbapi/NdbOperationExec.cpp +++ b/ndb/src/ndbapi/NdbOperationExec.cpp @@ -191,7 +191,8 @@ NdbOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransId) Uint8 tDirtyIndicator = theDirtyIndicator; OperationType tOperationType = theOperationType; Uint32 tTupKeyLen = theTupKeyLen; - Uint8 abortOption = theNdbCon->m_abortOption; + Uint8 abortOption = + m_abortOption != -1 ? m_abortOption : theNdbCon->m_abortOption; tcKeyReq->setDirtyFlag(tReqInfo, tDirtyIndicator); tcKeyReq->setOperationType(tReqInfo, tOperationType); @@ -541,17 +542,20 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal) return -1; }//if - AbortOption ao = (AbortOption)theNdbCon->m_abortOption; + AbortOption ao = (AbortOption) + (m_abortOption != -1 ? m_abortOption : theNdbCon->m_abortOption); theReceiver.m_received_result_length = ~0; theStatus = Finished; - theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; + // blobs want this + if (m_abortOption != IgnoreError) + theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; theError.code = aSignal->readData(4); - theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4)); + theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4), ao); if(theOperationType != ReadRequest || !theSimpleIndicator) // not simple read - return theNdbCon->OpCompleteFailure(ao); + return theNdbCon->OpCompleteFailure(ao, m_abortOption != IgnoreError); /** * If TCKEYCONF has arrived diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index 41bb82f3e06..f7ee7921229 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -48,7 +48,7 @@ struct Opt { unsigned m_rows; unsigned m_seed; const char* m_skip; - const char* m_style; + const char* m_test; // metadata const char* m_tname; const char* m_x1name; // hash index @@ -71,8 +71,8 @@ struct Opt { m_parts(10), m_rows(100), m_seed(0), - m_skip(""), - m_style("012"), + m_skip(0), + m_test(0), // metadata m_tname("TBLOB1"), m_x1name("TBLOB1X1"), @@ -101,45 +101,44 @@ printusage() << " -dbg print debug" << endl << " -dbgall print also NDB API debug (if compiled in)" << endl << " -full read/write only full blob values" << endl - << " -inline read/write only blobs which fit inline" << endl << " -loop N loop N times 0=forever [" << d.m_loop << "]" << endl << " -parts N max parts in blob value [" << d.m_parts << "]" << endl << " -rows N number of rows [" << d.m_rows << "]" << endl << " -seed N random seed 0=loop number [" << d.m_seed << "]" << endl - << " -skip xxx skip these tests (see list) [" << d.m_skip << endl - << " -style xxx access styles to test (see list) [" << d.m_style << "]" << endl + << " -skip xxx skip given tests (see list) [no tests]" << endl + << " -test xxx only given tests (see list) [all tests]" << endl << "metadata" << endl << " -pk2len N length of PK2 [" << d.m_pk2len << "/" << g_max_pk2len <<"]" << endl << " -oneblob only 1 blob attribute [default 2]" << endl - << "testcases for -skip" << endl + << "testcases for test/skip" << endl << " k primary key ops" << endl << " i hash index ops" << endl << " s table scans" << endl << " r ordered index scans" << endl - << " u update blob value" << endl - << "access styles for -style" << endl + << "additional flags for test/skip" << endl + << " u update existing blob value" << endl + << " n normal insert and update" << endl + << " w insert and update using writeTuple" << endl << " 0 getValue / setValue" << endl << " 1 setActiveHook" << endl << " 2 readData / writeData" << endl << "bug tests (no blob test)" << endl << " -bug 4088 ndb api hang with mixed ops on index table" << endl - << " -bug 2222 delete + write gives 626" << endl - << " -bug 3333 acc crash on delete and long key" << endl + << " -bug nnnn delete + write gives 626" << endl + << " -bug nnnn acc crash on delete and long key" << endl ; } static Opt g_opt; static bool -skipcase(int x) +testcase(char x) { - return strchr(g_opt.m_skip, x) != 0; -} - -static bool -skipstyle(int x) -{ - return strchr(g_opt.m_style, '0' + x) == 0; + if (x < 10) + x += '0'; + return + (g_opt.m_test == 0 || strchr(g_opt.m_test, x) != 0) && + (g_opt.m_skip == 0 || strchr(g_opt.m_skip, x) == 0); } static Ndb* g_ndb = 0; @@ -435,7 +434,9 @@ getBlobLength(NdbBlob* h, unsigned& len) CHK(h->getLength(len2) == 0); len = (unsigned)len2; assert(len == len2); - DBG("getBlobLength " << h->getColumn()->getName() << " len=" << len); + bool isNull; + CHK(h->getNull(isNull) == 0); + DBG("getBlobLength " << h->getColumn()->getName() << " len=" << len << " null=" << isNull); return 0; } @@ -911,6 +912,41 @@ updatePk(int style) return 0; } +static int +writePk(int style) +{ + DBG("--- writePk " << stylename[style] << " ---"); + for (unsigned k = 0; k < g_opt.m_rows; k++) { + Tup& tup = g_tups[k]; + DBG("writePk pk1=" << hex << tup.m_pk1); + CHK((g_con = g_ndb->startTransaction()) != 0); + CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0); + CHK(g_opr->writeTuple() == 0); + CHK(g_opr->equal("PK1", tup.m_pk1) == 0); + if (g_opt.m_pk2len != 0) + CHK(g_opr->equal("PK2", tup.m_pk2) == 0); + CHK(getBlobHandles(g_opr) == 0); + if (style == 0) { + CHK(setBlobValue(tup) == 0); + } else if (style == 1) { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); + CHK(setBlobWriteHook(tup) == 0); + } else { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); + CHK(g_con->execute(NoCommit) == 0); + CHK(writeBlobData(tup) == 0); + } + CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); + g_opr = 0; + g_con = 0; + tup.m_exists = true; + } + return 0; +} + static int deletePk() { @@ -995,6 +1031,35 @@ updateIdx(int style) return 0; } +static int +writeIdx(int style) +{ + DBG("--- writeIdx " << stylename[style] << " ---"); + for (unsigned k = 0; k < g_opt.m_rows; k++) { + Tup& tup = g_tups[k]; + DBG("writeIdx pk1=" << hex << tup.m_pk1); + CHK((g_con = g_ndb->startTransaction()) != 0); + CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0); + CHK(g_opx->writeTuple() == 0); + CHK(g_opx->equal("PK2", tup.m_pk2) == 0); + CHK(getBlobHandles(g_opx) == 0); + if (style == 0) { + CHK(setBlobValue(tup) == 0); + } else if (style == 1) { + CHK(setBlobWriteHook(tup) == 0); + } else { + CHK(g_con->execute(NoCommit) == 0); + CHK(writeBlobData(tup) == 0); + } + CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); + g_opx = 0; + g_con = 0; + tup.m_exists = true; + } + return 0; +} + static int deleteIdx() { @@ -1170,7 +1235,6 @@ deleteScan(bool idx) static int testmain() { - int style; g_ndb = new Ndb("TEST_DB"); CHK(g_ndb->init() == 0); CHK(g_ndb->waitUntilReady() == 0); @@ -1194,55 +1258,88 @@ testmain() if (g_opt.m_seed != 0) srandom(g_opt.m_seed); for (g_loop = 0; g_opt.m_loop == 0 || g_loop < g_opt.m_loop; g_loop++) { + int style; DBG("=== loop " << g_loop << " ==="); if (g_opt.m_seed == 0) srandom(g_loop); // pk for (style = 0; style <= 2; style++) { - if (skipcase('k') || skipstyle(style)) + if (! testcase('k') || ! testcase(style)) continue; DBG("--- pk ops " << stylename[style] << " ---"); - calcTups(false); - CHK(insertPk(style) == 0); - CHK(verifyBlob() == 0); - CHK(readPk(style) == 0); - if (! skipcase('u')) { - calcTups(style); - CHK(updatePk(style) == 0); + if (testcase('n')) { + calcTups(false); + CHK(insertPk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(updatePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + } + CHK(deletePk() == 0); + CHK(verifyBlob() == 0); + } + if (testcase('w')) { + calcTups(false); + CHK(writePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(writePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + } + CHK(deletePk() == 0); CHK(verifyBlob() == 0); } - CHK(readPk(style) == 0); - CHK(deletePk() == 0); - CHK(verifyBlob() == 0); } // hash index for (style = 0; style <= 2; style++) { - if (skipcase('i') || skipstyle(style)) + if (! testcase('i') || ! testcase(style)) continue; DBG("--- idx ops " << stylename[style] << " ---"); - calcTups(false); - CHK(insertPk(style) == 0); - CHK(verifyBlob() == 0); - CHK(readIdx(style) == 0); - calcTups(style); - if (! skipcase('u')) { - CHK(updateIdx(style) == 0); + if (testcase('n')) { + calcTups(false); + CHK(insertPk(style) == 0); CHK(verifyBlob() == 0); CHK(readIdx(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(updateIdx(style) == 0); + CHK(verifyBlob() == 0); + CHK(readIdx(style) == 0); + } + CHK(deleteIdx() == 0); + CHK(verifyBlob() == 0); + } + if (testcase('w')) { + calcTups(false); + CHK(writePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readIdx(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(writeIdx(style) == 0); + CHK(verifyBlob() == 0); + CHK(readIdx(style) == 0); + } + CHK(deleteIdx() == 0); + CHK(verifyBlob() == 0); } - CHK(deleteIdx() == 0); - CHK(verifyBlob() == 0); } // scan table for (style = 0; style <= 2; style++) { - if (skipcase('s') || skipstyle(style)) + if (! testcase('s') || ! testcase(style)) continue; DBG("--- table scan " << stylename[style] << " ---"); calcTups(false); CHK(insertPk(style) == 0); CHK(verifyBlob() == 0); CHK(readScan(style, false) == 0); - if (! skipcase('u')) { + if (testcase('u')) { CHK(updateScan(style, false) == 0); CHK(verifyBlob() == 0); } @@ -1251,14 +1348,14 @@ testmain() } // scan index for (style = 0; style <= 2; style++) { - if (skipcase('r') || skipstyle(style)) + if (! testcase('r') || ! testcase(style)) continue; DBG("--- index scan " << stylename[style] << " ---"); calcTups(false); CHK(insertPk(style) == 0); CHK(verifyBlob() == 0); CHK(readScan(style, true) == 0); - if (! skipcase('u')) { + if (testcase('u')) { CHK(updateScan(style, true) == 0); CHK(verifyBlob() == 0); } @@ -1331,9 +1428,7 @@ static struct { int m_bug; int (*m_test)(); } g_bugtest[] = { - { 4088, bugtest_4088 }, - { 2222, bugtest_2222 }, - { 3333, bugtest_3333 } + { 4088, bugtest_4088 } }; NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) @@ -1395,9 +1490,9 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) continue; } } - if (strcmp(arg, "-style") == 0) { + if (strcmp(arg, "-test") == 0) { if (++argv, --argc > 0) { - g_opt.m_style = strdup(argv[0]); + g_opt.m_test = strdup(argv[0]); continue; } } @@ -1433,7 +1528,9 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) } if (g_opt.m_pk2len == 0) { char b[100]; - strcpy(b, g_opt.m_skip); + b[0] = 0; + if (g_opt.m_skip != 0) + strcpy(b, g_opt.m_skip); strcat(b, "i"); strcat(b, "r"); g_opt.m_skip = strdup(b); From ef167e52bf680523ffa9d8c1f72bc798f2be3808 Mon Sep 17 00:00:00 2001 From: "joreland@mysql.com" <> Date: Mon, 1 Nov 2004 10:38:27 +0100 Subject: [PATCH 032/101] Fixed hanging ndb_mgmd on various platforms Move init of node-init-mutex to before alloc node id --- ndb/src/mgmsrv/MgmtSrvr.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 29df10630f3..01dae3aeddb 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -480,6 +480,13 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, _ownNodeId= 0; NodeId tmp= nodeId; BaseString error_string; + + if ((m_node_id_mutex = NdbMutex_Create()) == 0) + { + ndbout << "mutex creation failed line = " << __LINE__ << endl; + exit(-1); + } + #if 0 char my_hostname[256]; struct sockaddr_in tmp_addr; @@ -512,7 +519,6 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, #endif _ownNodeId = tmp; - { DBUG_PRINT("info", ("verifyConfig")); ConfigRetriever cr(m_local_config, NDB_VERSION, NDB_MGM_NODE_TYPE_MGM); @@ -534,12 +540,6 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, m_statisticsListner.m_logLevel = se.m_logLevel; } - if ((m_node_id_mutex = NdbMutex_Create()) == 0) - { - ndbout << "mutex creation failed line = " << __LINE__ << endl; - exit(-1); - } - DBUG_VOID_RETURN; } From f8e15a41f512cc471749a38b9bcfc27003a9d6e0 Mon Sep 17 00:00:00 2001 From: "joreland@mysql.com" <> Date: Mon, 1 Nov 2004 12:49:38 +0100 Subject: [PATCH 033/101] Removed old not used/illegal declaration --- ndb/include/kernel/signaldata/DictTabInfo.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 6b4a3f34553..ae78c023c2a 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -51,7 +51,6 @@ class DictTabInfo { friend class Trix; friend class DbUtil; // API - friend class Table; friend class NdbSchemaOp; /** From 6da0dd791f45ae32626fa6958142dac0124a35bc Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Mon, 1 Nov 2004 13:01:20 +0100 Subject: [PATCH 034/101] NDB blob fixes. INCOMPATIBLE with existing blobs --- ndb/src/ndbapi/NdbBlob.cpp | 43 ++++++++++++++++++----------------- ndb/test/ndbapi/testBlobs.cpp | 7 ++++++ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index 5b193870558..13532a413bb 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -97,6 +97,14 @@ NdbBlob::getBlobTable(NdbTableImpl& bt, const NdbTableImpl* t, const NdbColumnIm bt.setName(btname); bt.setLogging(t->getLogging()); bt.setFragmentType(t->getFragmentType()); + { NdbDictionary::Column bc("PK"); + bc.setType(NdbDictionary::Column::Unsigned); + assert(t->m_sizeOfKeysInWords != 0); + bc.setLength(t->m_sizeOfKeysInWords); + bc.setPrimaryKey(true); + bc.setDistributionKey(true); + bt.addColumn(bc); + } { NdbDictionary::Column bc("DIST"); bc.setType(NdbDictionary::Column::Unsigned); bc.setPrimaryKey(true); @@ -108,13 +116,6 @@ NdbBlob::getBlobTable(NdbTableImpl& bt, const NdbTableImpl* t, const NdbColumnIm bc.setPrimaryKey(true); bt.addColumn(bc); } - { NdbDictionary::Column bc("PK"); - bc.setType(NdbDictionary::Column::Unsigned); - assert(t->m_sizeOfKeysInWords != 0); - bc.setLength(t->m_sizeOfKeysInWords); - bc.setPrimaryKey(true); - bt.addColumn(bc); - } { NdbDictionary::Column bc("DATA"); switch (c->m_type) { case NdbDictionary::Column::Blob: @@ -392,9 +393,9 @@ NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_sizeOfKeysInWords; DBG("setPartKeyValue dist=" << getDistKey(part) << " part=" << part << " key=" << ndb_blob_debug(data, size)); - if (anOp->equal((Uint32)0, getDistKey(part)) == -1 || - anOp->equal((Uint32)1, part) == -1 || - anOp->equal((Uint32)2, theKeyBuf.data) == -1) { + if (anOp->equal((Uint32)0, theKeyBuf.data) == -1 || + anOp->equal((Uint32)1, getDistKey(part)) == -1 || + anOp->equal((Uint32)2, part) == -1) { setErrorCode(anOp); return -1; } @@ -676,7 +677,6 @@ NdbBlob::readDataPrivate(char* buf, Uint32& bytes) if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; Uint32 n = thePartSize - off; @@ -710,7 +710,6 @@ NdbBlob::readDataPrivate(char* buf, Uint32& bytes) if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; memcpy(buf, thePartBuf.data, len); @@ -773,14 +772,12 @@ NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) if (off != 0) { DBG("partial first block pos=" << pos << " len=" << len); // flush writes to guarantee correct read - DBG("execute pending part writes"); if (executePendingBlobWrites() == -1) return -1; Uint32 part = (pos - theInlineSize) / thePartSize; if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; Uint32 n = thePartSize - off; @@ -824,13 +821,11 @@ NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) Uint32 part = (pos - theInlineSize) / thePartSize; if (theLength > pos + len) { // flush writes to guarantee correct read - DBG("execute pending part writes"); if (executePendingBlobWrites() == -1) return -1; if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; memcpy(thePartBuf.data, buf, len); @@ -980,9 +975,11 @@ NdbBlob::deletePartsUnknown(Uint32 part) } tOp->m_abortOption = IgnoreError; n++; - if (theNdbCon->executeNoBlobs(NoCommit) == -1) - return -1; } + DBG("deletePartsUnknown: executeNoBlobs [in] bat=" << bat); + if (theNdbCon->executeNoBlobs(NoCommit) == -1) + return -1; + DBG("deletePartsUnknown: executeNoBlobs [out]"); n = 0; while (n < bat) { NdbOperation* tOp = tOpList[n]; @@ -1011,8 +1008,10 @@ NdbBlob::executePendingBlobReads() { Uint8 flags = (1 << NdbOperation::ReadRequest); if (thePendingBlobOps & flags) { + DBG("executePendingBlobReads: executeNoBlobs [in]"); if (theNdbCon->executeNoBlobs(NoCommit) == -1) return -1; + DBG("executePendingBlobReads: executeNoBlobs [out]"); thePendingBlobOps = 0; theNdbCon->thePendingBlobOps = 0; } @@ -1024,8 +1023,10 @@ NdbBlob::executePendingBlobWrites() { Uint8 flags = 0xFF & ~(1 << NdbOperation::ReadRequest); if (thePendingBlobOps & flags) { + DBG("executePendingBlobWrites: executeNoBlobs [in]"); if (theNdbCon->executeNoBlobs(NoCommit) == -1) return -1; + DBG("executePendingBlobWrites: executeNoBlobs [out]"); thePendingBlobOps = 0; theNdbCon->thePendingBlobOps = 0; } @@ -1037,10 +1038,10 @@ NdbBlob::executePendingBlobWrites() int NdbBlob::invokeActiveHook() { - DBG("invokeActiveHook"); + DBG("invokeActiveHook [in]"); assert(theState == Active && theActiveHook != NULL); int ret = (*theActiveHook)(this, theActiveHookArg); - DBG("invokeActiveHook ret=" << ret); + DBG("invokeActiveHook [out] ret=" << ret); if (ret != 0) { // no error is set on blob level return -1; @@ -1244,7 +1245,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) return -1; } } else { - NdbOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); + NdbIndexOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); if (tOp == NULL || tOp->readTuple() == -1 || setAccessKeyValue(tOp) == -1 || diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index f7ee7921229..08bf8a2fd4b 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -1232,6 +1232,13 @@ deleteScan(bool idx) // main +// from here on print always +#undef DBG +#define DBG(x) \ + do { \ + ndbout << "line " << __LINE__ << " " << x << endl; \ + } while (0) + static int testmain() { From 41e39c7be32fa27484375762296f900cc21eec17 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Mon, 1 Nov 2004 13:55:43 +0000 Subject: [PATCH 035/101] aligned ndb versioning with mysql changed define SNPRINTF_RETURN_ZERO to SNPRINTF_RETURN_TRUNC added define NDB_INIT removed getarg, strlcat, strlcpy aligned ndb version with mysql version cpcd: removed old way of reading config file and replaced with mysql load_defaults changed from using getarg to my_getopts use mysql my_progname moved getarg to test --- configure.in | 11 +- ndb/include/ndb_global.h | 9 +- ndb/include/util/ndb_opts.h | 57 ++++++ ndb/src/common/editline/sysunix.c | 9 +- ndb/src/common/util/Makefile.am | 4 +- ndb/src/common/util/basestring_vsnprintf.c | 9 +- ndb/src/common/util/socket_io.cpp | 39 ++-- ndb/src/common/util/strlcat.c | 48 ----- ndb/src/common/util/strlcpy.c | 57 ------ ndb/src/common/util/version.c | 1 + ndb/src/cw/cpcd/common.cpp | 63 ------- ndb/src/cw/cpcd/common.hpp | 3 +- ndb/src/cw/cpcd/main.cpp | 75 ++++---- ndb/src/kernel/blocks/backup/restore/main.cpp | 178 ++++++++++-------- ndb/src/kernel/error/ErrorReporter.cpp | 2 +- ndb/src/kernel/main.cpp | 8 +- ndb/src/kernel/vm/Configuration.cpp | 140 +++++++------- ndb/src/kernel/vm/Configuration.hpp | 2 +- ndb/src/mgmclient/main.cpp | 77 +++++--- ndb/src/mgmsrv/main.cpp | 114 ++++++----- ndb/src/ndbapi/Ndb.cpp | 7 +- ndb/{include/util => test/include}/getarg.h | 0 ndb/test/run-test/Makefile.am | 2 +- ndb/test/src/Makefile.am | 2 +- ndb/{src/common/util => test/src}/getarg.c | 32 +++- ndb/tools/delete_all.cpp | 73 ++++--- ndb/tools/desc.cpp | 82 +++++--- ndb/tools/drop_index.cpp | 70 ++++--- ndb/tools/drop_tab.cpp | 78 +++++--- ndb/tools/listTables.cpp | 106 ++++++----- ndb/tools/select_all.cpp | 122 +++++++----- ndb/tools/select_count.cpp | 82 +++++--- ndb/tools/waiter.cpp | 79 +++++--- 33 files changed, 918 insertions(+), 723 deletions(-) create mode 100644 ndb/include/util/ndb_opts.h delete mode 100644 ndb/src/common/util/strlcat.c delete mode 100644 ndb/src/common/util/strlcpy.c rename ndb/{include/util => test/include}/getarg.h (100%) rename ndb/{src/common/util => test/src}/getarg.c (97%) diff --git a/configure.in b/configure.in index 353e455dbac..fe487b15557 100644 --- a/configure.in +++ b/configure.in @@ -4,6 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! +# remember to also change ndb version below and update version.c in ndb AM_INIT_AUTOMAKE(mysql, 4.1.8) AM_CONFIG_HEADER(config.h) @@ -13,9 +14,9 @@ DOT_FRM_VERSION=6 SHARED_LIB_VERSION=14:0:0 # ndb version -NDB_VERSION_MAJOR=3 -NDB_VERSION_MINOR=5 -NDB_VERSION_BUILD=4 +NDB_VERSION_MAJOR=4 +NDB_VERSION_MINOR=1 +NDB_VERSION_BUILD=8 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? @@ -1142,8 +1143,8 @@ dnl Is this the right match for DEC OSF on alpha? fi echo "Adding defines for OSF1" # gethostbyname_r is deprecated and doesn't work ok on OSF1 - CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_ZERO" - CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_ZERO" + CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_TRUNC" + CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_TRUNC" # fix to handle include of correctly on OSF1 with cxx compiler CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include -I/usr/include.dtk" ;; diff --git a/ndb/include/ndb_global.h b/ndb/include/ndb_global.h index 09559f6ddff..bdd4e503cc5 100644 --- a/ndb/include/ndb_global.h +++ b/ndb/include/ndb_global.h @@ -82,19 +82,12 @@ extern "C" { /* call in main() - does not return on error */ extern int ndb_init(void); extern void ndb_end(int); +#define NDB_INIT(prog_name) {my_progname=(prog_name); ndb_init();} #ifndef HAVE_STRDUP extern char * strdup(const char *s); #endif -#ifndef HAVE_STRLCPY -extern size_t strlcpy (char *dst, const char *src, size_t dst_sz); -#endif - -#ifndef HAVE_STRLCAT -extern size_t strlcat (char *dst, const char *src, size_t dst_sz); -#endif - #ifndef HAVE_STRCASECMP extern int strcasecmp(const char *s1, const char *s2); extern int strncasecmp(const char *s1, const char *s2, size_t n); diff --git a/ndb/include/util/ndb_opts.h b/ndb/include/util/ndb_opts.h new file mode 100644 index 00000000000..6cba9c04449 --- /dev/null +++ b/ndb/include/util/ndb_opts.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2003 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 */ + +#ifndef _NDB_OPTS_H +#define _NDB_OPTS_H + +#include +#include +#include +#include + +#ifndef DBUG_OFF +#define NDB_STD_OPTS(prog_name) \ + { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \ + 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \ + { "usage", '?', "Display this help and exit.", \ + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ + { "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 }, \ + { "connect-string", 'c', \ + "Set connect string for connecting to ndb_mgmd. " \ + "=\"host=[;nodeid=]\". " \ + "Overides specifying entries in NDB_CONNECTSTRING and config file", \ + (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \ + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 } +#else +#define NDB_STD_OPTS(prog_name) \ + { "usage", '?', "Display this help and exit.", \ + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ + { "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 }, \ + { "connect-string", 'c', \ + "Set connect string for connecting to ndb_mgmd. " \ + "=\"host=[;nodeid=]\". " \ + "Overides specifying entries in NDB_CONNECTSTRING and config file", \ + (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \ + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 } +#endif + +#endif /*_NDB_OPTS_H */ diff --git a/ndb/src/common/editline/sysunix.c b/ndb/src/common/editline/sysunix.c index 000bca78dfc..1339e5769e2 100644 --- a/ndb/src/common/editline/sysunix.c +++ b/ndb/src/common/editline/sysunix.c @@ -138,6 +138,11 @@ rl_add_slash(char *path, char *p, size_t p_len) { struct stat Sb; - if (stat(path, &Sb) >= 0) - (void)strlcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ", p_len); + if (stat(path, &Sb) >= 0) { + int len= strlen(p); + if (len+1 < p_len) { + p[len]= S_ISDIR(Sb.st_mode) ? '/' : ' '; + p[len+1]= 0; + } + } } diff --git a/ndb/src/common/util/Makefile.am b/ndb/src/common/util/Makefile.am index 0235adae7c9..61fd7992002 100644 --- a/ndb/src/common/util/Makefile.am +++ b/ndb/src/common/util/Makefile.am @@ -7,8 +7,8 @@ libgeneral_la_SOURCES = \ SocketServer.cpp SocketClient.cpp SocketAuthenticator.cpp\ OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \ NdbSqlUtil.cpp new.cpp \ - uucode.c random.c getarg.c version.c \ - strdup.c strlcat.c strlcpy.c \ + uucode.c random.c version.c \ + strdup.c \ ConfigValues.cpp ndb_init.c basestring_vsnprintf.c include $(top_srcdir)/ndb/config/common.mk.am diff --git a/ndb/src/common/util/basestring_vsnprintf.c b/ndb/src/common/util/basestring_vsnprintf.c index 87ffb8ad146..c96d1a300e1 100644 --- a/ndb/src/common/util/basestring_vsnprintf.c +++ b/ndb/src/common/util/basestring_vsnprintf.c @@ -34,20 +34,19 @@ basestring_snprintf(char *str, size_t size, const char *format, ...) #ifdef HAVE_SNPRINTF #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) #else - #define SNPRINTF_RETURN_ZERO + #define SNPRINTF_RETURN_TRUNC #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d) extern int my_vsnprintf(char *str, size_t size, const char *format, va_list ap); #endif - -#ifdef SNPRINTF_RETURN_ZERO +#ifdef SNPRINTF_RETURN_TRUNC static char basestring_vsnprintf_buf[16*1024]; #endif int basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap) { int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap); -#ifdef SNPRINTF_RETURN_ZERO - if (ret == 0 && format != 0 && format[0] != '\0') { +#ifdef SNPRINTF_RETURN_TRUNC + if (ret == size-1) { ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf, sizeof(basestring_vsnprintf_buf), format, ap); diff --git a/ndb/src/common/util/socket_io.cpp b/ndb/src/common/util/socket_io.cpp index 6f4c7e63684..83a546de773 100644 --- a/ndb/src/common/util/socket_io.cpp +++ b/ndb/src/common/util/socket_io.cpp @@ -172,22 +172,21 @@ vprint_socket(NDB_SOCKET_TYPE socket, int timeout_millis, const char * fmt, va_list ap){ char buf[1000]; char *buf2 = buf; - size_t size = sizeof(buf); + size_t size; - if (fmt != 0) { + if (fmt != 0 && fmt[0] != 0) { size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap); /* Check if the output was truncated */ - if(size >= sizeof(buf)) { - buf2 = (char *)malloc(size+1); + if(size > sizeof(buf)) { + buf2 = (char *)malloc(size); if(buf2 == NULL) return -1; BaseString::vsnprintf(buf2, size, fmt, ap); - } else - size = sizeof(buf); + } } else - buf[0] = 0; + return 0; - int ret = write_socket(socket, timeout_millis, buf2, strlen(buf2)); + int ret = write_socket(socket, timeout_millis, buf2, size); if(buf2 != buf) free(buf2); return ret; @@ -199,23 +198,23 @@ vprintln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, const char * fmt, va_list ap){ char buf[1000]; char *buf2 = buf; - size_t size = sizeof(buf); + size_t size; - if (fmt != 0) { - size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap); + if (fmt != 0 && fmt[0] != 0) { + size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap)+1;// extra byte for '/n' /* Check if the output was truncated */ - if(size >= sizeof(buf)-1) { - buf2 = (char *)malloc(size+2); + if(size > sizeof(buf)) { + buf2 = (char *)malloc(size); if(buf2 == NULL) return -1; - BaseString::vsnprintf(buf2, size+1, fmt, ap); - } else - size = sizeof(buf); - } else - buf[0] = 0; - strlcat(buf2, "\n", size+2); + BaseString::vsnprintf(buf2, size, fmt, ap); + } + } else { + size = 1; + } + buf2[size-1]='\n'; - int ret = write_socket(socket, timeout_millis, buf2, strlen(buf2)); + int ret = write_socket(socket, timeout_millis, buf2, size); if(buf2 != buf) free(buf2); return ret; diff --git a/ndb/src/common/util/strlcat.c b/ndb/src/common/util/strlcat.c deleted file mode 100644 index aa282abe48d..00000000000 --- a/ndb/src/common/util/strlcat.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* RCSID("$KTH: strlcat.c,v 1.1 2000/08/16 01:23:47 lha Exp $"); */ - - -#ifndef HAVE_STRLCAT - -size_t -strlcat (char *dst, const char *src, size_t dst_sz) -{ - size_t len = strlen(dst); - - return len + strlcpy (dst + len, src, dst_sz - len); -} -#endif diff --git a/ndb/src/common/util/strlcpy.c b/ndb/src/common/util/strlcpy.c deleted file mode 100644 index 97cff177d48..00000000000 --- a/ndb/src/common/util/strlcpy.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* RCSID("$KTH: strlcpy.c,v 1.1 2000/08/16 01:23:48 lha Exp $"); */ - -#ifndef HAVE_STRLCPY - -size_t -strlcpy (char *dst, const char *src, size_t dst_sz) -{ - size_t n; - char *p; - - for (p = dst, n = 0; - n + 1 < dst_sz && *src != '\0'; - ++p, ++src, ++n) - *p = *src; - *p = '\0'; - if (*src == '\0') - return n; - else - return n + strlen (src); -} - -#endif diff --git a/ndb/src/common/util/version.c b/ndb/src/common/util/version.c index f2b3d5bd522..82acd949c46 100644 --- a/ndb/src/common/util/version.c +++ b/ndb/src/common/util/version.c @@ -70,6 +70,7 @@ struct NdbUpGradeCompatible { #ifndef TEST_VERSION struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { { MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact }, + { MAKE_VERSION(4,1,8), MAKE_VERSION(3,5,4), UG_Exact }, /* Aligned version with MySQL */ { 0, 0, UG_Null } }; diff --git a/ndb/src/cw/cpcd/common.cpp b/ndb/src/cw/cpcd/common.cpp index cb1c0c37183..53c0e4d5a64 100644 --- a/ndb/src/cw/cpcd/common.cpp +++ b/ndb/src/cw/cpcd/common.cpp @@ -96,66 +96,3 @@ insert_file(const char * filename, class Properties& p){ if(f) fclose(f); return res; } - -int -parse_config_file(struct getargs args[], int num_arg, const Properties& p){ - Properties::Iterator it(&p); - for(const char * name = it.first(); name != 0; name = it.next()){ - bool found = false; - for(int i = 0; i #include +#if 0 #include +#endif extern int debug; @@ -30,6 +32,5 @@ int insert(const char * pair, class Properties & p); int insert_file(const char * filename, class Properties&); int insert_file(FILE *, class Properties&, bool break_on_empty = false); -int parse_config_file(struct getargs args[], int num_arg, const Properties& p); #endif /* ! __CPCD_COMMON_HPP_INCLUDED__ */ diff --git a/ndb/src/cw/cpcd/main.cpp b/ndb/src/cw/cpcd/main.cpp index 207b81bfa89..300b51d7b5a 100644 --- a/ndb/src/cw/cpcd/main.cpp +++ b/ndb/src/cw/cpcd/main.cpp @@ -15,13 +15,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include /* Needed for mkdir(2) */ +#include #include "CPCD.hpp" #include "APIService.hpp" #include #include #include -#include #include #include #include @@ -29,28 +29,44 @@ #include "common.hpp" static const char *work_dir = CPCD_DEFAULT_WORK_DIR; -static int port = CPCD_DEFAULT_TCP_PORT; -static int use_syslog = 0; +static int port; +static int use_syslog; static const char *logfile = NULL; static const char *config_file = CPCD_DEFAULT_CONFIG_FILE; static const char *user = 0; -static struct getargs args[] = { - { "work-dir", 'w', arg_string, &work_dir, - "Work directory", "directory" }, - { "port", 'p', arg_integer, &port, - "TCP port to listen on", "port" }, - { "syslog", 'S', arg_flag, &use_syslog, - "Log events to syslog", NULL}, - { "logfile", 'L', arg_string, &logfile, - "File to log events to", "file"}, - { "debug", 'D', arg_flag, &debug, - "Enable debug mode", NULL}, - { "config", 'c', arg_string, &config_file, "Config file", NULL }, - { "user", 'u', arg_string, &user, "Run as user", NULL } +static struct my_option my_long_options[] = +{ + { "work-dir", 'w', "Work directory", + (gptr*) &work_dir, (gptr*) &work_dir, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "port", 'p', "TCP port to listen on", + (gptr*) &port, (gptr*) &port, 0, + GET_INT, REQUIRED_ARG, CPCD_DEFAULT_TCP_PORT, 0, 0, 0, 0, 0 }, + { "syslog", 'S', "Log events to syslog", + (gptr*) &use_syslog, (gptr*) &use_syslog, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "logfile", 'L', "File to log events to", + (gptr*) &logfile, (gptr*) &logfile, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "debug", 'D', "Enable debug mode", + (gptr*) &debug, (gptr*) &debug, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "config", 'c', "Config file", + (gptr*) &config_file, (gptr*) &config_file, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "user", 'u', "Run as user", + (gptr*) &user, (gptr*) &user, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static const int num_args = sizeof(args) / sizeof(args[0]); +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return 0; +} static CPCD * g_cpcd = 0; #if 0 @@ -59,23 +75,16 @@ extern "C" static void sig_child(int signo, siginfo_t*, void*); const char *progname = "ndb_cpcd"; -NDB_MAIN(ndb_cpcd){ - int optind = 0; +int main(int argc, char** argv){ + int save_argc= argc; + char** save_argv= argv; + const char *load_default_groups[]= { "ndb_cpcd",0 }; + MY_INIT(argv[0]); - if(getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, ""); - exit(1); - } - - Properties p; - insert_file(config_file, p); - if(parse_config_file(args, num_args, p)){ - ndbout_c("Invalid config file: %s", config_file); - exit(1); - } - - if(getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, ""); + load_defaults("ndb_cpcd",load_default_groups,&argc,&argv); + if (handle_options(&argc, &argv, my_long_options, get_one_option)) { + my_print_help(my_long_options); + my_print_variables(my_long_options); exit(1); } diff --git a/ndb/src/kernel/blocks/backup/restore/main.cpp b/ndb/src/kernel/blocks/backup/restore/main.cpp index f7b1479cc93..482212911cb 100644 --- a/ndb/src/kernel/blocks/backup/restore/main.cpp +++ b/ndb/src/kernel/blocks/backup/restore/main.cpp @@ -14,7 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include +#include #include #include #include @@ -35,80 +36,107 @@ static Vector g_consumers; static const char* ga_backupPath = "." DIR_SEPARATOR; -static const char* ga_connect_NDB = NULL; +static const char* opt_connect_str= NULL; /** * print and restore flags */ static bool ga_restore = false; static bool ga_print = false; -bool -readArguments(const int argc, const char** argv) +static int _print = 0; +static int _print_meta = 0; +static int _print_data = 0; +static int _print_log = 0; +static int _restore_data = 0; +static int _restore_meta = 0; + +static struct my_option my_long_options[] = { + NDB_STD_OPTS("ndb_restore"), + { "connect", 'c', "same as --connect-string", + (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "nodeid", 'n', "Backup files from node with id", + (gptr*) &ga_nodeId, (gptr*) &ga_nodeId, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "backupid", 'b', "Backup id", + (gptr*) &ga_backupId, (gptr*) &ga_backupId, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "restore_data", 'r', + "Restore table data/logs into NDB Cluster using NDBAPI", + (gptr*) &_restore_data, (gptr*) &_restore_data, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "restore_meta", 'm', + "Restore meta data into NDB Cluster using NDBAPI", + (gptr*) &_restore_meta, (gptr*) &_restore_meta, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "parallelism", 'p', + "No of parallel transactions during restore of data." + "(parallelism can be 1 to 1024)", + (gptr*) &ga_nParallelism, (gptr*) &ga_nParallelism, 0, + GET_INT, REQUIRED_ARG, 128, 0, 0, 0, 0, 0 }, + { "print", 256, "Print data and log to stdout", + (gptr*) &_print, (gptr*) &_print, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "print_data", 257, "Print data to stdout", + (gptr*) &_print_data, (gptr*) &_print_data, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "print_meta", 258, "Print meta data to stdout", + (gptr*) &_print_meta, (gptr*) &_print_meta, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "print_log", 259, "Print log to stdout", + (gptr*) &_print_log, (gptr*) &_print_log, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "dont_ignore_systab_0", 'f', + "Experimental. Do not ignore system table during restore.", + (gptr*) &ga_dont_ignore_systab_0, (gptr*) &ga_dont_ignore_systab_0, 0, + GET_BOOL, 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} +}; - int _print = 0; - int _print_meta = 0; - int _print_data = 0; - int _print_log = 0; - int _restore_data = 0; - int _restore_meta = 0; - - - struct getargs args[] = - { - { "connect", 'c', arg_string, &ga_connect_NDB, - "NDB Cluster connection", "\"nodeid=;host=\""}, - { "nodeid", 'n', arg_integer, &ga_nodeId, - "Backup files from node", "db node id"}, - { "backupid", 'b',arg_integer, &ga_backupId, "Backup id", "backup id"}, - { "print", '\0', arg_flag, &_print, - "Print data and log to stdout", "print data and log"}, - { "print_data", '\0', arg_flag, &_print_data, - "Print data to stdout", "print data"}, - { "print_meta", '\0', arg_flag, &_print_meta, - "Print meta data to stdout", "print meta data"}, - { "print_log", '\0', arg_flag, &_print_log, - "Print log to stdout", "print log"}, - { "restore_data", 'r', arg_flag, &_restore_data, - "Restore table data/logs into NDB Cluster using NDBAPI", - "Restore table data/log"}, - { "restore_meta", 'm', arg_flag, &_restore_meta, - "Restore meta data into NDB Cluster using NDBAPI", "Restore meta data"}, - { "parallelism", 'p', arg_integer, &ga_nParallelism, - "No of parallel transactions during restore of data." - "(parallelism can be 1 to 1024)", - "Parallelism"}, -#ifdef USE_MYSQL - { "use_mysql", '\0', arg_flag, &use_mysql, - "Restore meta data via mysql. Systab will be ignored. Data is restored " - "using NDBAPI.", "use mysql"}, - { "user", '\0', arg_string, &ga_user, "MySQL user", "Default: root"}, - { "password", '\0', arg_string, &ga_password, "MySQL user's password", - "Default: \"\" "}, - { "host", '\0', arg_string, &ga_host, "Hostname of MySQL server", - "Default: localhost"}, - { "socket", '\0', arg_string, &ga_socket, "Path to MySQL server socket file", - "Default: /tmp/mysql.sock"}, - { "port", '\0', arg_integer, &ga_port, "Port number of MySQL server", - "Default: 3306"}, -#endif - { "dont_ignore_systab_0", 'f', arg_flag, &ga_dont_ignore_systab_0, - "Experimental. Do not ignore system table during restore.", - "dont_ignore_systab_0"} - - }; - - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; - - if (getarg(args, num_args, argc, argv, &optind) || +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS] []\n", my_progname); +} +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ + short_usage_sub(); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_restore.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} +bool +readArguments(int *pargc, char*** pargv) +{ + const char *load_default_groups[]= { "ndb_tools","ndb_restore",0 }; + load_defaults("my",load_default_groups,pargc,pargv); + if (handle_options(pargc, pargv, my_long_options, get_one_option) || ga_nodeId == 0 || ga_backupId == 0 || ga_nParallelism < 1 || - ga_nParallelism >1024) - { - arg_printusage(args, num_args, argv[0], "\n"); - return false; + ga_nParallelism >1024) { + exit(1); } BackupPrinter* printer = new BackupPrinter(); @@ -122,10 +150,6 @@ readArguments(const int argc, const char** argv) return false; } - /** - * Got segmentation fault when using the printer's attributes directly - * in getargs... Do not have the time to found out why... this is faster... - */ if (_print) { ga_print = true; @@ -169,15 +193,14 @@ readArguments(const int argc, const char** argv) g_consumers.push_back(c); } // Set backup file path - if (argv[optind] != NULL) + if (*pargv[0] != NULL) { - ga_backupPath = argv[optind]; + ga_backupPath = *pargv[0]; } return true; } - void clearConsumers() { @@ -204,19 +227,16 @@ free_data_callback() } int -main(int argc, const char** argv) +main(int argc, char** argv) { - ndb_init(); - if (!readArguments(argc, argv)) + NDB_INIT(argv[0]); + + if (!readArguments(&argc, &argv)) { return -1; } - if (ga_connect_NDB != NULL) - { - // Use connection string - Ndb::setConnectString(ga_connect_NDB); - } + Ndb::setConnectString(opt_connect_str); /** * we must always load meta data, even if we will only print it to stdout diff --git a/ndb/src/kernel/error/ErrorReporter.cpp b/ndb/src/kernel/error/ErrorReporter.cpp index 35c99b30994..35cd3f099d9 100644 --- a/ndb/src/kernel/error/ErrorReporter.cpp +++ b/ndb/src/kernel/error/ErrorReporter.cpp @@ -137,7 +137,7 @@ ErrorReporter::formatMessage(ErrorCategory type, faultID, (problemData == NULL) ? "" : problemData, objRef, - programName, + my_progname, processId, theNameOfTheTraceFile ? theNameOfTheTraceFile : ""); diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index fa44704807d..926647838c9 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -53,11 +53,9 @@ extern "C" void handler_error(int signum); // for process signal handling void systemInfo(const Configuration & conf, const LogLevel & ll); -const char programName[] = "NDB Kernel"; - -NDB_MAIN(ndb_kernel){ - - ndb_init(); +int main(int argc, char** argv) +{ + NDB_INIT(argv[0]); // Print to stdout/console g_eventLogger.createConsoleHandler(); g_eventLogger.setCategory("NDB"); diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 706f60fd9cf..b3a436275f7 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include "Configuration.hpp" @@ -28,8 +29,6 @@ #include #include -#include - #include #include #include @@ -47,81 +46,86 @@ extern "C" { #include extern EventLogger g_eventLogger; -bool -Configuration::init(int argc, const char** argv){ - - /** - * Default values for arguments - */ - int _no_start = 0; - int _initial = 0; - const char* _connect_str = NULL; - int _daemon = 1; - int _no_daemon = 0; - int _help = 0; - int _print_version = 0; -#ifndef DBUG_OFF - const char *debug_option= 0; -#endif - - /** - * Arguments to NDB process - */ - - struct getargs args[] = { - { "version", 'v', arg_flag, &_print_version, "Print ndbd version", "" }, - { "nostart", 'n', arg_flag, &_no_start, - "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", "" }, - { "daemon", 'd', arg_flag, &_daemon, "Start ndbd as daemon (default)", "" }, - { "nodaemon", 0, arg_flag, &_no_daemon, "Do not start ndbd as daemon, provided for testing purposes", "" }, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options" }, -#endif - { "initial", 0, arg_flag, &_initial, - "Perform initial start of ndbd, including cleaning the file system. Consult documentation before using this", "" }, - - { "connect-string", 'c', arg_string, &_connect_str, - "Set connect string for connecting to ndb_mgmd. =\"host=[;nodeid=]\". Overides specifying entries in NDB_CONNECTSTRING and config file", - "" }, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; - char desc[] = - "The MySQL Cluster kernel"; - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, argv[0], desc); - for (int i = 0; i < argc; i++) { - if (strcmp("-i",argv[i]) == 0) { - printf("flag depricated %s, use %s\n", "-i", "--initial"); - } - } - return false; +static const char* opt_connect_str= 0; +static int _daemon, _no_daemon, _initial, _no_start; +/** + * Arguments to NDB process + */ +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndbd"), + { "initial", 256, + "Perform initial start of ndbd, including cleaning the file system. " + "Consult documentation before using this", + (gptr*) &_initial, (gptr*) &_initial, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "nostart", 'n', + "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", + (gptr*) &_no_start, (gptr*) &_no_start, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "daemon", 'd', "Start ndbd as daemon (default)", + (gptr*) &_daemon, (gptr*) &_daemon, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, + { "nodaemon", 257, + "Do not start ndbd as daemon, provided for testing purposes", + (gptr*) &_no_daemon, (gptr*) &_no_daemon, 0, + GET_BOOL, 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} +}; +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS]\n", my_progname); +} +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ + short_usage_sub(); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndbd.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); } + return 0; +} + +bool +Configuration::init(int argc, char** argv) +{ + const char *load_default_groups[]= { "ndbd",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + exit(ho_error); + if (_no_daemon) { _daemon= 0; } - // check for depricated flag '-i' - -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif DBUG_PRINT("info", ("no_start=%d", _no_start)); DBUG_PRINT("info", ("initial=%d", _initial)); DBUG_PRINT("info", ("daemon=%d", _daemon)); - DBUG_PRINT("info", ("connect_str=%s", _connect_str)); + DBUG_PRINT("info", ("connect_str=%s", opt_connect_str)); ndbSetOwnVersion(); - if (_print_version) { - ndbPrintVersion(); - return false; - } - // Check the start flag if (_no_start) globalData.theRestartFlag = initial_state; @@ -133,8 +137,8 @@ Configuration::init(int argc, const char** argv){ _initialStart = true; // Check connectstring - if (_connect_str) - _connectString = strdup(_connect_str); + if (opt_connect_str) + _connectString = strdup(opt_connect_str); // Check daemon flag if (_daemon) diff --git a/ndb/src/kernel/vm/Configuration.hpp b/ndb/src/kernel/vm/Configuration.hpp index 2ea32ffea37..e4cd64f5ca8 100644 --- a/ndb/src/kernel/vm/Configuration.hpp +++ b/ndb/src/kernel/vm/Configuration.hpp @@ -31,7 +31,7 @@ public: /** * Returns false if arguments are invalid */ - bool init(int argc, const char** argv); + bool init(int argc, char** argv); void fetch_configuration(LocalConfig &local_config); void setupConfiguration(); diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index cc6d4bf600e..a37214d366b 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -15,11 +15,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include -#include #include +#include #include #include "CommandInterpreter.hpp" @@ -43,28 +44,62 @@ handler(int sig){ } } -int main(int argc, const char** argv){ - ndb_init(); - int optind = 0; + +static unsigned _try_reconnect; +static char *opt_connect_str= 0; + +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_mgm"), + { "try-reconnect", 't', + "Specify number of retries for connecting to ndb_mgmd, default infinite", + (gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0, + GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS] [hostname [port]]\n", my_progname); +} +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ + short_usage_sub(); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgm.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); const char *_host = 0; int _port = 0; - int _help = 0; - int _try_reconnect = 0; - - struct getargs args[] = { - { "try-reconnect", 't', arg_integer, &_try_reconnect, "Specify number of retries for connecting to ndb_mgmd, default infinite", "#" }, - { "usage", '?', arg_flag, &_help, "Print help", "" }, - }; - int num_args = sizeof(args) / sizeof(args[0]); /* Number of arguments */ - - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, progname, "[host [port]]"); - exit(1); - } + const char *load_default_groups[]= { "ndb_mgm",0 }; - argv += optind; - argc -= optind; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + exit(ho_error); LocalConfig cfg; @@ -74,7 +109,7 @@ int main(int argc, const char** argv){ _port = atoi(argv[1]); } } else { - if(cfg.init(0, 0) && cfg.ids.size() > 0 && cfg.ids[0].type == MgmId_TCP){ + if(cfg.init(opt_connect_str, 0) && cfg.ids.size() > 0 && cfg.ids[0].type == MgmId_TCP){ _host = cfg.ids[0].name.c_str(); _port = cfg.ids[0].port; } else { diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 5ee48e4cfcc..c1876f68ea2 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include "MgmtSrvr.hpp" #include "EventLogger.hpp" @@ -33,7 +34,6 @@ #include #include #include -#include #include @@ -97,41 +97,70 @@ bool g_StopServer; extern EventLogger g_EventLogger; extern int global_mgmt_server_check; -int _print_version = 0; -#ifndef DBUG_OFF -const char *debug_option= 0; -#endif +static char *opt_connect_str= 0; -struct getargs args[] = { - { "version", 'v', arg_flag, &_print_version, - "Print ndb_mgmd version",""}, - { "config-file", 'c', arg_string, &glob.config_filename, - "Specify cluster configuration file (default config.ini if available)", - "filename"}, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options"}, -#endif - { "daemon", 'd', arg_flag, &glob.daemon, - "Run ndb_mgmd in daemon mode (default)",""}, - { NULL, 'l', arg_string, &glob.local_config_filename, - "Specify configuration file connect string (default Ndb.cfg if available)", - "filename"}, - { "interactive", 0, arg_flag, &glob.interactive, - "Run interactive. Not supported but provided for testing purposes", ""}, - { "no-nodeid-checks", 0, arg_flag, &g_no_nodeid_checks, - "Do not provide any node id checks", ""}, - { "nodaemon", 0, arg_flag, &glob.non_interactive, - "Don't run as daemon, but don't read from stdin", "non-interactive"} +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_mgmd"), + { "config-file", 'c', "Specify cluster configuration file", + (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)", + (gptr*) &glob.daemon, (gptr*) &glob.daemon, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, + { "l", 'l', "Specify configuration file connect string (default Ndb.cfg if available)", + (gptr*) &glob.local_config_filename, (gptr*) &glob.local_config_filename, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "interactive", 256, "Run interactive. Not supported but provided for testing purposes", + (gptr*) &glob.interactive, (gptr*) &glob.interactive, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "no-nodeid-checks", 257, "Do not provide any node id checks", + (gptr*) &g_no_nodeid_checks, (gptr*) &g_no_nodeid_checks, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "nodaemon", 258, "Don't run as daemon, but don't read from stdin", + (gptr*) &glob.non_interactive, (gptr*) &glob.non_interactive, 0, + GET_BOOL, 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} }; - -int num_args = sizeof(args) / sizeof(args[0]); +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS]\n", my_progname); +} +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ + short_usage_sub(); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgmd.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} /* * MAIN */ -NDB_MAIN(mgmsrv){ - ndb_init(); +int main(int argc, char** argv) +{ + NDB_INIT(argv[0]); /** * OSE specific. Enable shared ownership of file system resources. @@ -143,31 +172,20 @@ NDB_MAIN(mgmsrv){ #endif global_mgmt_server_check = 1; + glob.config_filename= "config.ini"; - int optind = 0; - if(getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, ""); - exit(1); - } + const char *load_default_groups[]= { "ndb_mgmd",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + exit(ho_error); if (glob.interactive || glob.non_interactive) { glob.daemon= 0; } -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif - - if (_print_version) { - ndbPrintVersion(); - exit(0); - } - - if(glob.config_filename == NULL) { - glob.config_filename= "config.ini"; - } glob.socketServer = new SocketServer(); MgmApiService * mapi = new MgmApiService(); diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index d7b8a695fe2..75ae539fc8b 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -1386,6 +1386,7 @@ Ndb::printState(const char* fmt, ...) va_end(ap); NdbMutex_Lock(ndb_print_state_mutex); bool dups = false; + unsigned i; ndbout << buf << " ndb=" << hex << this << dec; #ifndef NDB_WIN32 ndbout << " thread=" << (int)pthread_self(); @@ -1406,21 +1407,21 @@ Ndb::printState(const char* fmt, ...) ndbout << "!! DUPS !!" << endl; dups = true; } - for (unsigned i = 0; i < theNoOfPreparedTransactions; i++) + for (i = 0; i < theNoOfPreparedTransactions; i++) thePreparedTransactionsArray[i]->printState(); ndbout << "sent: " << theNoOfSentTransactions<< endl; if (checkdups(theSentTransactionsArray, theNoOfSentTransactions)) { ndbout << "!! DUPS !!" << endl; dups = true; } - for (unsigned i = 0; i < theNoOfSentTransactions; i++) + for (i = 0; i < theNoOfSentTransactions; i++) theSentTransactionsArray[i]->printState(); ndbout << "completed: " << theNoOfCompletedTransactions<< endl; if (checkdups(theCompletedTransactionsArray, theNoOfCompletedTransactions)) { ndbout << "!! DUPS !!" << endl; dups = true; } - for (unsigned i = 0; i < theNoOfCompletedTransactions; i++) + for (i = 0; i < theNoOfCompletedTransactions; i++) theCompletedTransactionsArray[i]->printState(); NdbMutex_Unlock(ndb_print_state_mutex); } diff --git a/ndb/include/util/getarg.h b/ndb/test/include/getarg.h similarity index 100% rename from ndb/include/util/getarg.h rename to ndb/test/include/getarg.h diff --git a/ndb/test/run-test/Makefile.am b/ndb/test/run-test/Makefile.am index 3bf2edde47a..80e9e05eef7 100644 --- a/ndb/test/run-test/Makefile.am +++ b/ndb/test/run-test/Makefile.am @@ -11,7 +11,7 @@ test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh atrt_SOURCES = main.cpp -INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmclient +INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include -I$(top_srcdir)/ndb/src/mgmclient LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CpcClient.o \ $(top_builddir)/ndb/src/libndbclient.la \ $(top_builddir)/dbug/libdbug.a \ diff --git a/ndb/test/src/Makefile.am b/ndb/test/src/Makefile.am index a513086dc33..a8f34a0ea22 100644 --- a/ndb/test/src/Makefile.am +++ b/ndb/test/src/Makefile.am @@ -9,7 +9,7 @@ libNDBT_a_SOURCES = \ HugoAsynchTransactions.cpp UtilTransactions.cpp \ NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \ NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp \ - NdbSchemaCon.cpp NdbSchemaOp.cpp + NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c INCLUDES_LOC = -I$(top_srcdir)/ndb/src/common/mgmcommon -I$(top_srcdir)/ndb/include/mgmcommon -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/src/mgmapi diff --git a/ndb/src/common/util/getarg.c b/ndb/test/src/getarg.c similarity index 97% rename from ndb/src/common/util/getarg.c rename to ndb/test/src/getarg.c index 99b2840a5a6..9f03af69824 100644 --- a/ndb/src/common/util/getarg.c +++ b/ndb/test/src/getarg.c @@ -36,15 +36,33 @@ #include "getarg.h" -#define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag) - #ifndef HAVE_STRLCPY -extern size_t strlcpy (char *dst, const char *src, size_t dst_sz); -#endif /* !HAVE_STRLCPY */ - +static size_t +strlcpy (char *dst, const char *src, size_t dst_sz) +{ + size_t n; + char *p; + for (p = dst, n = 0; + n + 1 < dst_sz && *src != '\0'; + ++p, ++src, ++n) + *p = *src; + *p = '\0'; + if (*src == '\0') + return n; + else + return n + strlen (src); +} +#endif #ifndef HAVE_STRLCAT -extern size_t strlcat (char *dst, const char *src, size_t dst_sz); -#endif /* !HAVE_STRLCAT */ +static size_t +strlcat (char *dst, const char *src, size_t dst_sz) +{ + size_t len = strlen(dst); + return len + strlcpy (dst + len, src, dst_sz - len); +} +#endif + +#define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag) #ifndef max #define max(a, b) (a) > (b) ? (a) : (b) diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp index aa5798376ae..a4fd73a5128 100644 --- a/ndb/tools/delete_all.cpp +++ b/ndb/tools/delete_all.cpp @@ -15,41 +15,65 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include #include #include -#include - static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); -int main(int argc, const char** argv){ - ndb_init(); - - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _help = 0; - - struct getargs args[] = { - { "usage", '?', arg_flag, &_help, "Print help", "" }, - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"} - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* opt_connect_str= 0; +static const char* _dbname = "TEST_DB"; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ char desc[] = "tabname\n"\ "This program will delete all records in the specified table using scan delete.\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help) { - arg_printusage(args, num_args, argv[0], desc); - return NDBT_ProgramExit(NDBT_WRONGARGS); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_delete_all.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); } - _tabname = argv[optind]; + return 0; +} +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); @@ -64,13 +88,12 @@ int main(int argc, const char** argv){ // Check if table exists in db int res = NDBT_OK; - for(int i = optind; i +#include +#include #include #include - - - -int main(int argc, const char** argv){ - ndb_init(); - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _unqualified = 0; - int _help = 0; - - struct getargs args[] = { - { "unqualified", 'u', arg_flag, &_unqualified, "unqualified", - "Use unqualified table names"}, - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* opt_connect_str= 0; +static const char* _dbname = "TEST_DB"; +static int _unqualified = 0; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "unqualified", 'u', "Use unqualified table names", + (gptr*) &_unqualified, (gptr*) &_unqualified, 0, + GET_BOOL, 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} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ char desc[] = "tabname\n"\ "This program list all properties of table(s) in NDB Cluster.\n"\ - " ex: desc T1 T2 T4\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL ||_help) { - arg_printusage(args, num_args, argv[0], desc); - return NDBT_ProgramExit(NDBT_WRONGARGS); + " ex: desc T1 T2 T4\n"; + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_desc.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); } - _tabname = argv[optind]; + return 0; +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + + Ndb::setConnectString(opt_connect_str); Ndb* pMyNdb; pMyNdb = new Ndb(_dbname); @@ -60,7 +86,7 @@ int main(int argc, const char** argv){ ndbout << endl; NdbDictionary::Dictionary * dict = pMyNdb->getDictionary(); - for (int i = optind; i < argc; i++) { + for (int i = 0; i < argc; i++) { NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]); if (pTab != 0){ ndbout << (* pTab) << endl; diff --git a/ndb/tools/drop_index.cpp b/ndb/tools/drop_index.cpp index 70c29461c23..1d4b454682f 100644 --- a/ndb/tools/drop_index.cpp +++ b/ndb/tools/drop_index.cpp @@ -15,38 +15,66 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include #include -#include - -int main(int argc, const char** argv){ - ndb_init(); - - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _help = 0; - - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* opt_connect_str= 0; +static const char* _dbname = "TEST_DB"; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ char desc[] = "+\n"\ "This program will drop index(es) in Ndb\n"; + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_index.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help){ - arg_printusage(args, num_args, argv[0], desc); +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if (argc < 1) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); if(MyNdb.init() != 0){ @@ -58,7 +86,7 @@ int main(int argc, const char** argv){ ndbout << "Waiting for ndb to become ready..." << endl; int res = 0; - for(int i = optind; idropIndex(argv[i], 0)) != 0){ diff --git a/ndb/tools/drop_tab.cpp b/ndb/tools/drop_tab.cpp index 15c229cb0fb..428730419fa 100644 --- a/ndb/tools/drop_tab.cpp +++ b/ndb/tools/drop_tab.cpp @@ -15,43 +15,67 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include #include -#include - -int main(int argc, const char** argv){ - ndb_init(); - - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - const char* _connectstr = NULL; - int _help = 0; - - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "connstr", 'c', arg_string, &_connectstr, "connect string", - "How to connect to NDB"}, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* opt_connect_str= 0; +static const char* _dbname = "TEST_DB"; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + ndbPrintVersion(); +} +static void usage() +{ char desc[] = "tabname\n"\ "This program will drop one table in Ndb\n"; + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help){ - arg_printusage(args, num_args, argv[0], desc); +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if (argc < 1) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; - - if (_connectstr) - Ndb::setConnectString(_connectstr); + + Ndb::setConnectString(opt_connect_str); Ndb MyNdb(_dbname); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); @@ -62,7 +86,7 @@ int main(int argc, const char** argv){ ndbout << "Waiting for ndb to become ready..." << endl; int res = 0; - for(int i = optind; idropTable(argv[i])) != 0){ diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp index 4fc5bcd7f21..2fc34394a9c 100644 --- a/ndb/tools/listTables.cpp +++ b/ndb/tools/listTables.cpp @@ -22,7 +22,7 @@ */ #include -#include +#include #include #include @@ -161,39 +161,34 @@ list(const char * tabname, } } -#ifndef DBUG_OFF -const char *debug_option= 0; -#endif - -int main(int argc, const char** argv){ - ndb_init(); - int _loops = 1; - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _type = 0; - int _help = 0; - const char* _connect_str = NULL; - - struct getargs args[] = { - { "loops", 'l', arg_integer, &_loops, "loops", - "Number of times to run(default = 1)" }, - { "unqualified", 'u', arg_flag, &_unqualified, "unqualified", - "Use unqualified table names"}, - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "type", 't', arg_integer, &_type, "type", - "Type of objects to show, see NdbDictionary.hpp for numbers(default = 0)" }, - { "connect-string", 'c', arg_string, &_connect_str, - "Set connect string for connecting to ndb_mgmd. =\"host=[;nodeid=]\". Overides specifying entries in NDB_CONNECTSTRING and config file", - "" }, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options" }, -#endif - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* opt_connect_str= 0; +static const char* _dbname = "TEST_DB"; +static int _loops; +static int _type; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "loops", 'l', "loops", + (gptr*) &_loops, (gptr*) &_loops, 0, + GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 }, + { "type", 't', "type", + (gptr*) &_type, (gptr*) &_type, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "unqualified", 'u', "Use unqualified table names", + (gptr*) &_unqualified, (gptr*) &_unqualified, 0, + GET_BOOL, 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} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + ndbPrintVersion(); +} +static void usage() +{ char desc[] = "tabname\n"\ "This program list all system objects in NDB Cluster.\n"\ @@ -201,19 +196,42 @@ int main(int argc, const char** argv){ " ex: list_tables -t 2 would show all UserTables\n"\ "To show all indexes for a table write table name as final argument\n"\ " ex: list_tables T1\n"; - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, argv[0], desc); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_show_tables.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char* _tabname; + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if ((_tabname = argv[0]) == 0) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; - -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif - ndb_cluster_connection = new Ndb_cluster_connection(_connect_str); + ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str); ndb = new Ndb(ndb_cluster_connection, _dbname); if (ndb->init() != 0) fatal("init"); diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp index 9f8108d9f32..758c1e48c88 100644 --- a/ndb/tools/select_all.cpp +++ b/ndb/tools/select_all.cpp @@ -16,6 +16,7 @@ #include +#include #include @@ -23,13 +24,8 @@ #include #include #include -#include #include -#ifndef DBUG_OFF -const char *debug_option= 0; -#endif - int scanReadRecords(Ndb*, const NdbDictionary::Table*, const NdbDictionary::Index*, @@ -40,39 +36,44 @@ int scanReadRecords(Ndb*, char delim, bool orderby); -int main(int argc, const char** argv){ - ndb_init(); - int _parallelism = 240; - const char* _delimiter = "\t"; - int _header = true; - int _useHexFormat = false; - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _help = 0; - int _lock = 0; - int _order = 0; +static const char* opt_connect_str= 0; +static const char* _dbname = "TEST_DB"; +static const char* _delimiter = "\t"; +static int _unqualified, _header, _parallelism, _useHexFormat, _lock, + _order; - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "parallelism", 'p', arg_integer, &_parallelism, "parallelism", - "parallelism" }, - { "header", 'h', arg_flag, &_header, "Print header", "header" }, - { "useHexFormat", 'x', arg_flag, &_useHexFormat, - "Output numbers in hexadecimal format", "useHexFormat" }, - { "delimiter", 'd', arg_string, &_delimiter, "Column delimiter", - "delimiter" }, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options" }, -#endif - { "usage", '?', arg_flag, &_help, "Print help", "" }, - { "lock", 'l', arg_integer, &_lock, - "Read(0), Read-hold(1), Exclusive(2)", "lock"}, - { "order", 'o', arg_flag, &_order, "Sort resultset according to index", ""} - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "parallelism", 'p', "parallelism", + (gptr*) &_parallelism, (gptr*) &_parallelism, 0, + GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 }, + { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", + (gptr*) &_lock, (gptr*) &_lock, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "order", 'o', "Sort resultset according to index", + (gptr*) &_order, (gptr*) &_order, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "header", 'h', "Print header", + (gptr*) &_header, (gptr*) &_header, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, + { "useHexFormat", 'x', "Output numbers in hexadecimal format", + (gptr*) &_useHexFormat, (gptr*) &_useHexFormat, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "delimiter", 'D', "Column delimiter", + (gptr*) &_delimiter, (gptr*) &_delimiter, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ char desc[] = "tabname\n"\ "This program reads all records from one table in NDB Cluster\n"\ @@ -80,19 +81,42 @@ int main(int argc, const char** argv){ "(It only print error messages if it encounters a permanent error.)\n"\ "It can also be used to dump the content of a table to file \n"\ " ex: select_all --no-header --delimiter=';' T4 > T4.data\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help) { - arg_printusage(args, num_args, argv[0], desc); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_all.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + const char* _tabname; + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if ((_tabname = argv[0]) == 0) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; - -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); @@ -108,8 +132,8 @@ int main(int argc, const char** argv){ // Check if table exists in db const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname); const NdbDictionary::Index * pIdx = 0; - if(optind+1 < argc){ - pIdx = MyNdb.getDictionary()->getIndex(argv[optind+1], _tabname); + if(argc > 1){ + pIdx = MyNdb.getDictionary()->getIndex(argv[0], _tabname); } if(pTab == NULL){ diff --git a/ndb/tools/select_count.cpp b/ndb/tools/select_count.cpp index 6650421e637..6ee49ddbff0 100644 --- a/ndb/tools/select_count.cpp +++ b/ndb/tools/select_count.cpp @@ -16,6 +16,7 @@ #include +#include #include @@ -23,7 +24,6 @@ #include #include #include -#include #include static int @@ -32,34 +32,68 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int* count_rows, UtilTransactions::ScanLock lock); -int main(int argc, const char** argv){ - ndb_init(); - const char* _dbname = "TEST_DB"; - int _parallelism = 240; - int _help = 0; - int _lock = 0; - - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "parallelism", 's', arg_integer, &_parallelism, "parallelism", "parallelism" }, - { "usage", '?', arg_flag, &_help, "Print help", "" }, - { "lock", 'l', arg_integer, &_lock, - "Read(0), Read-hold(1), Exclusive(2)", "lock"} - - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* opt_connect_str= 0; +static const char* _dbname = "TEST_DB"; +static int _parallelism = 240; +static int _lock = 0; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "parallelism", 'p', "parallelism", + (gptr*) &_parallelism, (gptr*) &_parallelism, 0, + GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 }, + { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", + (gptr*) &_lock, (gptr*) &_lock, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} +static void usage() +{ char desc[] = "tabname1 ... tabnameN\n"\ "This program will count the number of records in tables\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help) { - arg_printusage(args, num_args, argv[0], desc); + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_count.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); + } + return 0; +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if (argc < 1) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); @@ -72,7 +106,7 @@ int main(int argc, const char** argv){ while(MyNdb.waitUntilReady() != 0) ndbout << "Waiting for ndb to become ready..." << endl; - for(int i = optind; i +#include + #include #include #include #include -#include #include #include "../include/mgmcommon/LocalConfig.hpp" @@ -29,34 +30,60 @@ int waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout); -int main(int argc, const char** argv){ - ndb_init(); - - const char* _hostName = NULL; - int _no_contact = 0; - int _help = 0; - int _timeout = 120; - - struct getargs args[] = { - { "timeout", 0, arg_integer, &_timeout, "Timeout to wait", "#" }, - { "no-contact", 0, arg_flag, &_no_contact, "Wait for cluster no contact", "" }, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; - char desc[] = - "hostname:port\n"\ - "This program will connect to the mgmsrv of a NDB cluster.\n"\ - "It will then wait for all nodes to be started\n"; - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, argv[0], desc); - return NDBT_ProgramExit(NDBT_WRONGARGS); +static const char* opt_connect_str= 0; +static int _no_contact = 0; +static int _timeout = 120; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "no-contact", 'n', "Wait for cluster no contact", + (gptr*) &_no_contact, (gptr*) &_no_contact, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "timeout", 't', "Timeout to wait", + (gptr*) &_timeout, (gptr*) &_timeout, 0, + GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + ndbPrintVersion(); +} +static void usage() +{ + print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch (optid) { + case '#': + DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace"); + break; + case 'V': + print_version(); + exit(0); + case '?': + usage(); + exit(0); } + return 0; +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "ndb_tools",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + const char* _hostName = NULL; + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); char buf[255]; - _hostName = argv[optind]; + _hostName = argv[0]; if (_hostName == NULL){ LocalConfig lcfg; From d129fffe572089b3008f694c3cface0f35aff16e Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Mon, 1 Nov 2004 14:25:07 +0000 Subject: [PATCH 036/101] configure.in: added flag on sun forte, -instances=static (check is only made for "non-gcc", hopefully enough) --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index fe487b15557..95d241ad669 100644 --- a/configure.in +++ b/configure.in @@ -975,7 +975,7 @@ case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc in CXXFLAGS="$CXXFLAGS -DBIG_TABLES" ;; # workaround for Sun Forte compile problem for ndb - *solaris2.10*-sparc-no) + *solaris2.*-no) ndb_cxxflags_fix="$ndb_cxxflags_fix -instances=static" ;; *) ;; From 1827256ac55dd195fff309c8475541bc335aa7ec Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Mon, 1 Nov 2004 14:43:53 +0000 Subject: [PATCH 037/101] fix call of string::copy() if HAVE_FCONVERT is set --- sql/sql_string.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 6b2bb07fb8c..c1701e7e9bf 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -142,7 +142,8 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs) buff[0]='-'; pos=buff; } - return copy(pos,(uint32) strlen(pos), &my_charset_latin1, cs); + uint dummy_errors; + return copy(pos,(uint32) strlen(pos), &my_charset_latin1, cs, &dummy_errors); } if (alloc((uint32) ((uint32) decpt+3+decimals))) return TRUE; From ff7e440bb04280a19ece143c27eed793c3f57755 Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Mon, 1 Nov 2004 16:04:36 +0100 Subject: [PATCH 038/101] NDB blobs restore backwards compatibility --- ndb/src/ndbapi/NdbBlob.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index 13532a413bb..731f32ba916 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -97,14 +97,6 @@ NdbBlob::getBlobTable(NdbTableImpl& bt, const NdbTableImpl* t, const NdbColumnIm bt.setName(btname); bt.setLogging(t->getLogging()); bt.setFragmentType(t->getFragmentType()); - { NdbDictionary::Column bc("PK"); - bc.setType(NdbDictionary::Column::Unsigned); - assert(t->m_sizeOfKeysInWords != 0); - bc.setLength(t->m_sizeOfKeysInWords); - bc.setPrimaryKey(true); - bc.setDistributionKey(true); - bt.addColumn(bc); - } { NdbDictionary::Column bc("DIST"); bc.setType(NdbDictionary::Column::Unsigned); bc.setPrimaryKey(true); @@ -116,6 +108,13 @@ NdbBlob::getBlobTable(NdbTableImpl& bt, const NdbTableImpl* t, const NdbColumnIm bc.setPrimaryKey(true); bt.addColumn(bc); } + { NdbDictionary::Column bc("PK"); + bc.setType(NdbDictionary::Column::Unsigned); + assert(t->m_sizeOfKeysInWords != 0); + bc.setLength(t->m_sizeOfKeysInWords); + bc.setPrimaryKey(true); + bt.addColumn(bc); + } { NdbDictionary::Column bc("DATA"); switch (c->m_type) { case NdbDictionary::Column::Blob: @@ -309,7 +308,7 @@ inline Uint32 NdbBlob::getDistKey(Uint32 part) { assert(theStripeSize != 0); - return part / theStripeSize; + return (part / theStripeSize) % theStripeSize; } // getters and setters @@ -393,9 +392,9 @@ NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_sizeOfKeysInWords; DBG("setPartKeyValue dist=" << getDistKey(part) << " part=" << part << " key=" << ndb_blob_debug(data, size)); - if (anOp->equal((Uint32)0, theKeyBuf.data) == -1 || - anOp->equal((Uint32)1, getDistKey(part)) == -1 || - anOp->equal((Uint32)2, part) == -1) { + if (anOp->equal((Uint32)0, getDistKey(part)) == -1 || + anOp->equal((Uint32)1, part) == -1 || + anOp->equal((Uint32)2, theKeyBuf.data) == -1) { setErrorCode(anOp); return -1; } From 96829a4639dec81803fa32c7e98d9641b81cea25 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Mon, 1 Nov 2004 19:01:50 +0300 Subject: [PATCH 039/101] Remove support for obsolete 4.1.1 prepared statements C API names: having approval for it since 4.1.4, I also have some assurance that very few people actually used this: to enable these calls a user had to #define HAVE_DEPRECATED_411_API and recompile the client library. --- include/mysql.h | 17 ----------------- libmysql/libmysql.c | 16 ---------------- 2 files changed, 33 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 1c886020fdb..156d749234b 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -642,23 +642,6 @@ typedef struct st_mysql_methods #endif } MYSQL_METHODS; -#ifdef HAVE_DEPRECATED_411_API -/* Deprecated calls (since MySQL 4.1.2) */ - -/* Use mysql_stmt_init + mysql_stmt_prepare instead */ -MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query, - unsigned long length); -#define mysql_execute mysql_stmt_execute -#define mysql_fetch mysql_stmt_fetch -#define mysql_fetch_column mysql_stmt_fetch_column -#define mysql_bind_param mysql_stmt_bind_param -#define mysql_bind_result mysql_stmt_bind_result -#define mysql_param_count mysql_stmt_param_count -#define mysql_param_result mysql_stmt_param_metadata -#define mysql_get_metadata mysql_stmt_result_metadata -#define mysql_send_long_data mysql_stmt_send_long_data - -#endif /* HAVE_DEPRECATED_411_API */ MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql); int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9195f0a5bc5..88f46ce19e7 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1886,22 +1886,6 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) DBUG_RETURN(0); } -#ifdef HAVE_DEPRECATED_411_API -MYSQL_STMT * STDCALL mysql_prepare(MYSQL *mysql, const char *query, - unsigned long query_length) -{ - MYSQL_STMT *stmt; - DBUG_ENTER("mysql_prepare"); - - stmt= mysql_stmt_init(mysql); - if (stmt && mysql_stmt_prepare(stmt, query, query_length)) - { - mysql_stmt_close(stmt); - DBUG_RETURN(0); - } - DBUG_RETURN(stmt); -} -#endif /* Allocate memory and init prepared statement structure. From ebd0ee4a0dfe60b8e2a97691980283025765037c Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Mon, 1 Nov 2004 18:21:57 +0000 Subject: [PATCH 040/101] fix for solaris forte -instances=static added libNDBT.a removed printout fixed error that ndb_show_tables required table name --- configure.in | 5 ++++- ndb/test/run-test/Makefile.am | 1 + ndb/tools/drop_tab.cpp | 1 - ndb/tools/listTables.cpp | 6 +----- ndb/tools/waiter.cpp | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index 95d241ad669..d63859720a3 100644 --- a/configure.in +++ b/configure.in @@ -974,8 +974,11 @@ case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc in CFLAGS="$CFLAGS -DBIG_TABLES" CXXFLAGS="$CXXFLAGS -DBIG_TABLES" ;; + *) ;; +esac +case $SYSTEM_TYPE-$ac_cv_prog_gcc in # workaround for Sun Forte compile problem for ndb - *solaris2.*-no) + *solaris*-no) ndb_cxxflags_fix="$ndb_cxxflags_fix -instances=static" ;; *) ;; diff --git a/ndb/test/run-test/Makefile.am b/ndb/test/run-test/Makefile.am index 80e9e05eef7..1eac96e7ac7 100644 --- a/ndb/test/run-test/Makefile.am +++ b/ndb/test/run-test/Makefile.am @@ -13,6 +13,7 @@ test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ atrt_SOURCES = main.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include -I$(top_srcdir)/ndb/src/mgmclient LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CpcClient.o \ + $(top_builddir)/ndb/test/src/libNDBT.a \ $(top_builddir)/ndb/src/libndbclient.la \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/mysys/libmysys.a \ diff --git a/ndb/tools/drop_tab.cpp b/ndb/tools/drop_tab.cpp index 428730419fa..3362c7de47b 100644 --- a/ndb/tools/drop_tab.cpp +++ b/ndb/tools/drop_tab.cpp @@ -34,7 +34,6 @@ static struct my_option my_long_options[] = static void print_version() { printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); - ndbPrintVersion(); } static void usage() { diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp index 2fc34394a9c..05e864a35c4 100644 --- a/ndb/tools/listTables.cpp +++ b/ndb/tools/listTables.cpp @@ -185,7 +185,6 @@ static struct my_option my_long_options[] = static void print_version() { printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); - ndbPrintVersion(); } static void usage() { @@ -226,10 +225,7 @@ int main(int argc, char** argv){ int ho_error; if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); - if ((_tabname = argv[0]) == 0) { - usage(); - return NDBT_ProgramExit(NDBT_WRONGARGS); - } + _tabname = argv[0]; ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str); ndb = new Ndb(ndb_cluster_connection, _dbname); diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp index 1ff852b90cb..c9e76bb8ed3 100644 --- a/ndb/tools/waiter.cpp +++ b/ndb/tools/waiter.cpp @@ -47,7 +47,6 @@ static struct my_option my_long_options[] = static void print_version() { printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); - ndbPrintVersion(); } static void usage() { From 4768c8387243226194aada0db2fce68611f7aa5f Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Mon, 1 Nov 2004 22:27:29 +0000 Subject: [PATCH 041/101] removed unused member variable (probably causing some of the problems we've seen with ndb_mgmd) --- ndb/src/mgmsrv/MgmtSrvr.cpp | 1 - ndb/src/mgmsrv/MgmtSrvr.hpp | 1 - 2 files changed, 2 deletions(-) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 01dae3aeddb..2e30d73290b 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -407,7 +407,6 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, // signals to other management servers. _ownReference(0), m_local_config(local_config), - m_allocated_resources(*this), theSignalIdleList(NULL), theWaitState(WAIT_SUBSCRIBE_CONF), m_statisticsListner(this) diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index a5f21b6bc4a..c796e1e9219 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -534,7 +534,6 @@ private: Uint32 m_nextConfigGenerationNumber; NodeBitmask m_reserved_nodes; - Allocated_resources m_allocated_resources; struct in_addr m_connect_address[MAX_NODES]; //************************************************************************** From bc6bbebbc8ddde60cd2430987377d7122842f88a Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Tue, 2 Nov 2004 09:00:46 +0400 Subject: [PATCH 042/101] ctype_sjis.result, ctype_sjis.test, ctype-sjis.c: Bug #6223 Japanese half-width kana characters get truncated. Bytes 0xA1..0xDF were not treated as a single byte sequence in a mistake. --- mysql-test/r/ctype_sjis.result | 11 +++++++++++ mysql-test/t/ctype_sjis.test | 11 +++++++++++ strings/ctype-sjis.c | 9 +++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result index b0edbed1a41..944fa0602a9 100644 --- a/mysql-test/r/ctype_sjis.result +++ b/mysql-test/r/ctype_sjis.result @@ -60,3 +60,14 @@ hex(c) 9353 9373 drop table t1; +SET NAMES sjis; +CREATE TABLE t1 ( +c char(16) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=sjis; +insert into t1 values(0xb1),(0xb2),(0xb3); +select hex(c) from t1; +hex(c) +B1 +B2 +B3 +drop table t1; diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test index c910812ef8a..a3a44789975 100644 --- a/mysql-test/t/ctype_sjis.test +++ b/mysql-test/t/ctype_sjis.test @@ -51,3 +51,14 @@ insert into t1 values (0x9353); insert into t1 values (0x9373); select hex(c) from t1; drop table t1; + +# +# Bug #6223 Japanese half-width kana characters get truncated +# +SET NAMES sjis; +CREATE TABLE t1 ( + c char(16) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=sjis; +insert into t1 values(0xb1),(0xb2),(0xb3); +select hex(c) from t1; +drop table t1; diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 4176ff2e538..a8b5394f8c5 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4581,14 +4581,19 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), */ if (((int8)b[0]) >= 0) { - /* Single byte character */ - b+= 1; + /* Single byte ascii character */ + b++; } else if (issjishead((uchar)*b) && (e-b)>1 && issjistail((uchar)b[1])) { /* Double byte character */ b+= 2; } + else if (((uchar)*b) >= 0xA1 && ((uchar)*b) <= 0xDF) + { + /* Half width kana */ + b++; + } else { /* Wrong byte sequence */ From c0061627d8b1c04cf96d82366cc91f2b742b309a Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 2 Nov 2004 09:46:23 +0200 Subject: [PATCH 043/101] dict0load.c: Raise fatal semaphore wait timeout to 2 hours when we are printing the InnoDB table monitor output --- innobase/dict/dict0load.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index d430eadc97b..c2b778f77c3 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -20,6 +20,7 @@ Created 4/24/1996 Heikki Tuuri #include "dict0dict.h" #include "dict0boot.h" #include "srv0start.h" +#include "srv0srv.h" /************************************************************************ Finds the first table name in the given database. */ @@ -123,6 +124,13 @@ dict_print(void) ulint len; mtr_t mtr; + /* Enlarge the fatal semaphore wait timeout during the InnoDB table + monitor printout */ + + mutex_enter(&kernel_mutex); + srv_fatal_semaphore_wait_threshold += 7200; /* 2 hours */ + mutex_exit(&kernel_mutex); + mutex_enter(&(dict_sys->mutex)); mtr_start(&mtr); @@ -145,6 +153,12 @@ loop: mutex_exit(&(dict_sys->mutex)); + /* Restore the fatal semaphore wait timeout */ + + mutex_enter(&kernel_mutex); + srv_fatal_semaphore_wait_threshold -= 7200; /* 2 hours */ + mutex_exit(&kernel_mutex); + return; } From e1979f25800de279b7135972dc4e1bd596293769 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Tue, 2 Nov 2004 13:14:07 +0400 Subject: [PATCH 044/101] A fix (bug #6309: myisamchk compiled without debug support , --help shows vise versa bug #6380: mysqlcheck --help prints wrong --debug msg for non-debug version). --- client/mysqlcheck.c | 5 +++++ myisam/myisamchk.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 8182b95fb83..c670b84db44 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -81,8 +81,13 @@ static struct my_option my_long_options[] = "To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.", (gptr*) &opt_databases, (gptr*) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, +#ifdef DBUG_OFF + {"debug", '#', "This is a non-debug version. Catch this and exit.", + 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, +#else {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, +#endif {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (gptr*) &default_charset, (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 648e29e1e9e..c89abca9cad 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -354,8 +354,12 @@ static void usage(void) puts("Description, check and repair of MyISAM tables."); puts("Used without options all tables on the command will be checked for errors"); printf("Usage: %s [OPTIONS] tables[.MYI]\n", my_progname_short); - printf("\nGlobal options:\n\ - -#, --debug=... Output debug log. Often this is 'd:t:o,filename'.\n\ + printf("\nGlobal options:\n"); +#ifndef DBUG_OFF + printf("\ + -#, --debug=... Output debug log. Often this is 'd:t:o,filename'.\n"); +#endif + printf("\ -?, --help Display this help and exit.\n\ -O, --set-variable var=option.\n\ Change the value of a variable. Please note that\n\ From c68ea1665cffe0b8af1308942e0de0cc6baa4852 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 2 Nov 2004 13:34:11 +0200 Subject: [PATCH 045/101] ha_innodb.cc: Correct English grammar --- sql/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 8d9ecb95fc0..0bcb7062437 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2464,7 +2464,7 @@ ha_innobase::write_row( NOTE that a REPLACE command and LOAD DATA INFILE REPLACE handles a duplicate key error itself, and we must not decrement the autoinc counter - if we are performing a those statements. + if we are performing those statements. NOTE 2: if there was an error, for example a deadlock, which caused InnoDB to roll back the whole transaction already in the call of row_insert_for_mysql(), we may no From 6a3b1d443fc461210235d2ea5237ab30a77eb8ef Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Tue, 2 Nov 2004 16:02:12 +0400 Subject: [PATCH 046/101] Many files: Allow mixing of different character sets for more SQL functions. item_func.h: Allow mixing of different character sets for more SQL functions.. --- mysql-test/r/ctype_recoding.result | 54 +++++++++++++++ mysql-test/t/ctype_recoding.test | 26 +++++++ sql/item.cc | 41 +++++++++++ sql/item.h | 18 ++++- sql/item_cmpfunc.cc | 96 +++----------------------- sql/item_func.cc | 105 +++++++++++++++++++++++++---- sql/item_func.h | 3 +- sql/item_strfunc.cc | 58 +++++++++------- 8 files changed, 274 insertions(+), 127 deletions(-) diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index dc1f4c12e25..1c75988fd21 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -186,3 +186,57 @@ select * from t1 where a=_latin1' ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '=' drop table t1; set names latin1; +set names koi8r; +create table t1 (c1 char(10) character set cp1251); +insert into t1 values ('ß'); +select c1 from t1 where c1 between 'ß' and 'ß'; +c1 +ß +select ifnull(c1,'ß'), ifnull(null,c1) from t1; +ifnull(c1,'ß') ifnull(null,c1) +ß ß +select if(1,c1,'ö'), if(0,c1,'ö') from t1; +if(1,c1,'ö') if(0,c1,'ö') +ß ö +select coalesce('ö',c1), coalesce(null,c1) from t1; +coalesce('ö',c1) coalesce(null,c1) +ö ß +select least(c1,'ö'), greatest(c1,'ö') from t1; +least(c1,'ö') greatest(c1,'ö') +ö ß +select locate(c1,'ß'), locate('ß',c1) from t1; +locate(c1,'ß') locate('ß',c1) +1 1 +select field(c1,'ß'),field('ß',c1) from t1; +field(c1,'ß') field('ß',c1) +1 1 +select concat(c1,'ö'), concat('ö',c1) from t1; +concat(c1,'ö') concat('ö',c1) +ßö öß +select concat_ws(c1,'ö','ß'), concat_ws('ö',c1,'ß') from t1; +concat_ws(c1,'ö','ß') concat_ws('ö',c1,'ß') +ößß ßöß +select replace(c1,'ß','ö'), replace('ß',c1,'ö') from t1; +replace(c1,'ß','ö') replace('ß',c1,'ö') +ö ö +select substring_index(c1,'öößß',2) from t1; +substring_index(c1,'öößß',2) +ß +select elt(1,c1,'ö'),elt(1,'ö',c1) from t1; +elt(1,c1,'ö') elt(1,'ö',c1) +ß ö +select make_set(3,c1,'ö'), make_set(3,'ö',c1) from t1; +make_set(3,c1,'ö') make_set(3,'ö',c1) +ß,ö ö,ß +select insert(c1,1,2,'ö'),insert('ö',1,2,c1) from t1; +insert(c1,1,2,'ö') insert('ö',1,2,c1) +ö ß +select trim(c1 from 'ß'),trim('ß' from c1) from t1; +trim(c1 from 'ß') trim('ß' from c1) + +select lpad(c1,3,'ö'), lpad('ö',3,c1) from t1; +lpad(c1,3,'ö') lpad('ö',3,c1) +ööß ßßö +select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1; +rpad(c1,3,'ö') rpad('ö',3,c1) +ßöö ößß diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index dab898e9f2c..0e5e954c720 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -153,3 +153,29 @@ select * from t1 where a=_latin1' drop table t1; set names latin1; +# +# Check more automatic conversion +# +set names koi8r; +create table t1 (c1 char(10) character set cp1251); +insert into t1 values ('ß'); +select c1 from t1 where c1 between 'ß' and 'ß'; +select ifnull(c1,'ß'), ifnull(null,c1) from t1; +select if(1,c1,'ö'), if(0,c1,'ö') from t1; +select coalesce('ö',c1), coalesce(null,c1) from t1; +select least(c1,'ö'), greatest(c1,'ö') from t1; +select locate(c1,'ß'), locate('ß',c1) from t1; +select field(c1,'ß'),field('ß',c1) from t1; +select concat(c1,'ö'), concat('ö',c1) from t1; +select concat_ws(c1,'ö','ß'), concat_ws('ö',c1,'ß') from t1; +select replace(c1,'ß','ö'), replace('ß',c1,'ö') from t1; +select substring_index(c1,'öößß',2) from t1; +select elt(1,c1,'ö'),elt(1,'ö',c1) from t1; +select make_set(3,c1,'ö'), make_set(3,'ö',c1) from t1; +select insert(c1,1,2,'ö'),insert('ö',1,2,c1) from t1; +select trim(c1 from 'ß'),trim('ß' from c1) from t1; +select lpad(c1,3,'ö'), lpad('ö',3,c1) from t1; +select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1; +# TODO +#select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1; +#select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1; diff --git a/sql/item.cc b/sql/item.cc index 46215fd78ed..7dc7e9e542c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -205,6 +205,41 @@ bool Item::eq(const Item *item, bool binary_cmp) const } +Item *Item::safe_charset_converter(CHARSET_INFO *tocs) +{ + /* + Don't allow automatic conversion to non-Unicode charsets, + as it potentially loses data. + */ + if (!(tocs->state & MY_CS_UNICODE)) + return NULL; // safe conversion is not possible + return new Item_func_conv_charset(this, tocs); +} + + +Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs) +{ + Item_string *conv; + uint conv_errors; + String tmp, cstr, *ostr= val_str(&tmp); + cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors); + if (conv_errors || !(conv= new Item_string(cstr.ptr(), cstr.length(), + cstr.charset(), + collation.derivation))) + { + /* + Safe conversion is not possible (or EOM). + We could not convert a string into the requested character set + without data loss. The target charset does not cover all the + characters from the string. Operation cannot be done correctly. + */ + return NULL; + } + conv->str_value.copy(); + return conv; +} + + bool Item_string::eq(const Item *item, bool binary_cmp) const { if (type() == item->type()) @@ -723,6 +758,12 @@ String *Item_null::val_str(String *str) } +Item *Item_null::safe_charset_converter(CHARSET_INFO *tocs) +{ + collation.set(tocs); + return this; +} + /*********************** Item_param related ******************************/ /* diff --git a/sql/item.h b/sql/item.h index 2c0c3306c44..fea3aa010a8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -39,13 +39,22 @@ enum Derivation /* Flags for collation aggregation modes: - allow conversion to a superset - allow conversion of a coercible value (i.e. constant). + MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset + MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value + (i.e. constant). + MY_COLL_ALLOW_CONV - allow any kind of conversion + (combintion of the above two) + MY_COLL_DISALLOW_NONE - don't allow return DERIVATION_NONE + (e.g. when aggregating for comparison) + MY_COLL_CMP_CONV - combination of MY_COLL_ALLOW_CONV + and MY_COLL_DISALLOW_NONE */ #define MY_COLL_ALLOW_SUPERSET_CONV 1 #define MY_COLL_ALLOW_COERCIBLE_CONV 2 - +#define MY_COLL_ALLOW_CONV 3 +#define MY_COLL_DISALLOW_NONE 4 +#define MY_COLL_CMP_CONV 7 class DTCollation { public: @@ -302,6 +311,7 @@ public: Field *tmp_table_field_from_field_type(TABLE *table); virtual Item *neg_transformer(THD *thd) { return NULL; } + virtual Item *safe_charset_converter(CHARSET_INFO *tocs); void delete_self() { cleanup(); @@ -447,6 +457,7 @@ public: Item *new_item() { return new Item_null(name); } bool is_null() { return 1; } void print(String *str) { str->append("NULL", 4); } + Item *safe_charset_converter(CHARSET_INFO *tocs); }; @@ -717,6 +728,7 @@ public: return new Item_string(name, str_value.ptr(), str_value.length(), &my_charset_bin); } + Item *safe_charset_converter(CHARSET_INFO *tocs); String *const_string() { return &str_value; } inline void append(char *str, uint length) { str_value.append(str, length); } void print(String *str); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d9db07e2289..701894cacb5 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -173,89 +173,11 @@ void Item_bool_func2::fix_length_and_dec() if (!args[0] || !args[1]) return; - /* - We allow to apply automatic character set conversion in some cases. - The conditions when conversion is possible are: - - arguments A and B have different charsets - - A wins according to coercibility rules - (i.e. a column is stronger than a string constant, - an explicit COLLATE clause is stronger than a column) - - character set of A is either superset for character set of B, - or B is a string constant which can be converted into the - character set of A without data loss. - - If all of the above is true, then it's possible to convert - B into the character set of A, and then compare according - to the collation of A. - */ - - uint32 dummy_offset; DTCollation coll; - if (args[0]->result_type() == STRING_RESULT && args[1]->result_type() == STRING_RESULT && - String::needs_conversion(0, args[0]->collation.collation, - args[1]->collation.collation, - &dummy_offset) && - !coll.set(args[0]->collation, args[1]->collation, - MY_COLL_ALLOW_SUPERSET_CONV | - MY_COLL_ALLOW_COERCIBLE_CONV)) - { - Item* conv= 0; - Item_arena *arena= thd->current_arena, backup; - uint strong= coll.strong; - uint weak= strong ? 0 : 1; - /* - In case we're in statement prepare, create conversion item - in its memory: it will be reused on each execute. - */ - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); - if (args[weak]->type() == STRING_ITEM) - { - uint conv_errors; - String tmp, cstr, *ostr= args[weak]->val_str(&tmp); - cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), - args[strong]->collation.collation, &conv_errors); - if (conv_errors) - { - /* - We could not convert a string into the character set - of the stronger side of the operation without data loss. - It can happen if we tried to combine a column with a string - constant, and the column charset does not cover all the - characters from the string. Operation cannot be done - correctly. Return an error. - */ - my_coll_agg_error(args[0]->collation, args[1]->collation, - func_name()); - return; - } - conv= new Item_string(cstr.ptr(),cstr.length(),cstr.charset(), - args[weak]->collation.derivation); - ((Item_string*)conv)->str_value.copy(); - } - else - { - if (!(coll.collation->state & MY_CS_UNICODE)) - { - /* - Don't allow automatic conversion to non-Unicode charsets, - as it potentially loses data. - */ - my_coll_agg_error(args[0]->collation, args[1]->collation, - func_name()); - return; - } - conv= new Item_func_conv_charset(args[weak], - args[strong]->collation.collation); - conv->collation.set(args[weak]->collation.derivation); - conv->fix_fields(thd, 0, &conv); - } - if (arena->is_stmt_prepare()) - thd->restore_backup_item_arena(arena, &backup); - args[weak]= conv ? conv : args[weak]; - } + agg_arg_charsets(coll, args, 2, MY_COLL_CMP_CONV)) + return; // Make a special case of compare with fields to get nicer DATE comparisons @@ -871,7 +793,7 @@ void Item_func_between::fix_length_and_dec() return; agg_cmp_type(&cmp_type, args, 3); if (cmp_type == STRING_RESULT && - agg_arg_collations_for_comparison(cmp_collation, args, 3)) + agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV)) return; /* @@ -987,7 +909,7 @@ Item_func_ifnull::fix_length_and_dec() decimals=max(args[0]->decimals,args[1]->decimals); agg_result_type(&cached_result_type, args, 2); if (cached_result_type == STRING_RESULT) - agg_arg_collations(collation, args, arg_count); + agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV); else if (cached_result_type != REAL_RESULT) decimals= 0; @@ -1083,7 +1005,7 @@ Item_func_if::fix_length_and_dec() agg_result_type(&cached_result_type, args+1, 2); if (cached_result_type == STRING_RESULT) { - if (agg_arg_collations(collation, args+1, 2)) + if (agg_arg_charsets(collation, args+1, 2, MY_COLL_ALLOW_CONV)) return; } else @@ -1354,7 +1276,7 @@ void Item_func_case::fix_length_and_dec() agg_result_type(&cached_result_type, agg, nagg); if ((cached_result_type == STRING_RESULT) && - agg_arg_collations(collation, agg, nagg)) + agg_arg_charsets(collation, agg, nagg, MY_COLL_ALLOW_CONV)) return; @@ -1370,7 +1292,7 @@ void Item_func_case::fix_length_and_dec() nagg++; agg_cmp_type(&cmp_type, agg, nagg); if ((cmp_type == STRING_RESULT) && - agg_arg_collations_for_comparison(cmp_collation, agg, nagg)) + agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV)) return; } @@ -1477,7 +1399,7 @@ void Item_func_coalesce::fix_length_and_dec() set_if_bigger(decimals,args[i]->decimals); } if (cached_result_type == STRING_RESULT) - agg_arg_collations(collation, args, arg_count); + agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV); else if (cached_result_type != REAL_RESULT) decimals= 0; } @@ -2423,7 +2345,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) max_length= 1; decimals= 0; - if (agg_arg_collations(cmp_collation, args, 2)) + if (agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV)) return 1; used_tables_cache=args[0]->used_tables() | args[1]->used_tables(); diff --git a/sql/item_func.cc b/sql/item_func.cc index 50843d3bf76..09d7e50eaa3 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -90,6 +90,12 @@ bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count, return TRUE; } } + if ((flags & MY_COLL_DISALLOW_NONE) && + c.derivation == DERIVATION_NONE) + { + my_coll_agg_error(av, count, func_name()); + return TRUE; + } return FALSE; } @@ -98,15 +104,7 @@ bool Item_func::agg_arg_collations_for_comparison(DTCollation &c, Item **av, uint count, uint flags) { - if (agg_arg_collations(c, av, count, flags)) - return TRUE; - - if (c.derivation == DERIVATION_NONE) - { - my_coll_agg_error(av, count, func_name()); - return TRUE; - } - return FALSE; + return (agg_arg_collations(c, av, count, flags | MY_COLL_DISALLOW_NONE)); } @@ -119,6 +117,89 @@ eval_const_cond(COND *cond) } + +/* + Collect arguments' character sets together. + We allow to apply automatic character set conversion in some cases. + The conditions when conversion is possible are: + - arguments A and B have different charsets + - A wins according to coercibility rules + (i.e. a column is stronger than a string constant, + an explicit COLLATE clause is stronger than a column) + - character set of A is either superset for character set of B, + or B is a string constant which can be converted into the + character set of A without data loss. + + If all of the above is true, then it's possible to convert + B into the character set of A, and then compare according + to the collation of A. + + For functions with more than two arguments: + + collect(A,B,C) ::= collect(collect(A,B),C) +*/ + +bool Item_func::agg_arg_charsets(DTCollation &coll, + Item **args, uint nargs, uint flags) +{ + Item **arg, **last, *safe_args[2]; + if (agg_arg_collations(coll, args, nargs, flags)) + return TRUE; + + /* + For better error reporting: save the first and the second argument. + We need this only if the the number of args is 3 or 2: + - for a longer argument list, "Illegal mix of collations" + doesn't display each argument's characteristics. + - if nargs is 1, then this error cannot happen. + */ + if (nargs >=2 && nargs <= 3) + { + safe_args[0]= args[0]; + safe_args[1]= args[1]; + } + + THD *thd= current_thd; + Item_arena *arena= thd->current_arena, backup; + bool res= FALSE; + /* + In case we're in statement prepare, create conversion item + in its memory: it will be reused on each execute. + */ + if (arena->is_stmt_prepare()) + thd->set_n_backup_item_arena(arena, &backup); + + for (arg= args, last= args + nargs; arg < last; arg++) + { + Item* conv; + uint dummy_offset; + if (!String::needs_conversion(0, coll.collation, + (*arg)->collation.collation, + &dummy_offset)) + continue; + + if (!(conv= (*arg)->safe_charset_converter(coll.collation))) + { + if (nargs >=2 && nargs <= 3) + { + /* restore the original arguments for better error message */ + args[0]= safe_args[0]; + args[1]= safe_args[1]; + } + my_coll_agg_error(args, nargs, func_name()); + res= TRUE; + break; // we cannot return here, we need to restore "arena". + } + conv->fix_fields(thd, 0, &conv); + *arg= conv; + } + if (arena->is_stmt_prepare()) + thd->restore_backup_item_arena(arena, &backup); + return res; +} + + + void Item_func::set_arguments(List &list) { allowed_arg_cols= 1; @@ -1105,7 +1186,7 @@ void Item_func_min_max::fix_length_and_dec() cmp_type=item_cmp_type(cmp_type,args[i]->result_type()); } if (cmp_type == STRING_RESULT) - agg_arg_collations_for_comparison(collation, args, arg_count); + agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV); } @@ -1259,7 +1340,7 @@ longlong Item_func_coercibility::val_int() void Item_func_locate::fix_length_and_dec() { maybe_null=0; max_length=11; - agg_arg_collations_for_comparison(cmp_collation, args, 2); + agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV); } @@ -1358,7 +1439,7 @@ void Item_func_field::fix_length_and_dec() for (uint i=1; i < arg_count ; i++) cmp_type= item_cmp_type(cmp_type, args[i]->result_type()); if (cmp_type == STRING_RESULT) - agg_arg_collations_for_comparison(cmp_collation, args, arg_count); + agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV); } diff --git a/sql/item_func.h b/sql/item_func.h index 963038227a2..ce2b34499d6 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -145,7 +145,8 @@ public: bool agg_arg_collations_for_comparison(DTCollation &c, Item **items, uint nitems, uint flags= 0); - + bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems, + uint flags= 0); bool walk(Item_processor processor, byte *arg); }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5eda89ef21e..81fff899ec7 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -346,7 +346,7 @@ void Item_func_concat::fix_length_and_dec() { max_length=0; - if (agg_arg_collations(collation, args, arg_count)) + if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV)) return; for (uint i=0 ; i < arg_count ; i++) @@ -640,7 +640,7 @@ void Item_func_concat_ws::fix_length_and_dec() { max_length=0; - if (agg_arg_collations(collation, args, arg_count)) + if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV)) return; /* @@ -848,7 +848,7 @@ void Item_func_replace::fix_length_and_dec() maybe_null=1; } - if (agg_arg_collations_for_comparison(collation, args, 3)) + if (agg_arg_charsets(collation, args, 3, MY_COLL_CMP_CONV)) return; } @@ -893,11 +893,13 @@ null: void Item_func_insert::fix_length_and_dec() { - if (collation.set(args[0]->collation, args[3]->collation)) - { - my_coll_agg_error(args[0]->collation, args[3]->collation, func_name()); - return; - } + Item *cargs[2]; + cargs[0]= args[0]; + cargs[1]= args[3]; + if (agg_arg_charsets(collation, cargs, 2, MY_COLL_ALLOW_CONV)) + return; + args[0]= cargs[0]; + args[3]= cargs[1]; max_length=args[0]->max_length+args[3]->max_length; if (max_length > MAX_BLOB_WIDTH) { @@ -1063,7 +1065,7 @@ void Item_func_substr_index::fix_length_and_dec() { max_length= args[0]->max_length; - if (agg_arg_collations_for_comparison(collation, args, 2)) + if (agg_arg_charsets(collation, args, 2, MY_COLL_CMP_CONV)) return; } @@ -1355,10 +1357,14 @@ void Item_func_trim::fix_length_and_dec() remove.set_ascii(" ",1); } else - if (collation.set(args[1]->collation, args[0]->collation) || - collation.derivation == DERIVATION_NONE) { - my_coll_agg_error(args[1]->collation, args[0]->collation, func_name()); + Item *cargs[2]; + cargs[0]= args[1]; + cargs[1]= args[0]; + if (agg_arg_charsets(collation, cargs, 2, MY_COLL_CMP_CONV)) + return; + args[0]= cargs[1]; + args[1]= cargs[0]; } } @@ -1679,7 +1685,7 @@ void Item_func_elt::fix_length_and_dec() max_length=0; decimals=0; - if (agg_arg_collations(collation, args+1, arg_count-1)) + if (agg_arg_charsets(collation, args+1, arg_count-1, MY_COLL_ALLOW_CONV)) return; for (uint i= 1 ; i < arg_count ; i++) @@ -1755,7 +1761,7 @@ void Item_func_make_set::fix_length_and_dec() { max_length=arg_count-1; - if (agg_arg_collations(collation, args, arg_count)) + if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV)) return; for (uint i=0 ; i < arg_count ; i++) @@ -1963,12 +1969,13 @@ err: void Item_func_rpad::fix_length_and_dec() { - if (collation.set(args[0]->collation, args[2]->collation)) - { - my_coll_agg_error(args[0]->collation, args[2]->collation, func_name()); + Item *cargs[2]; + cargs[0]= args[0]; + cargs[1]= args[2]; + if (agg_arg_charsets(collation, cargs, 2, MY_COLL_ALLOW_CONV)) return; - } - + args[0]= cargs[0]; + args[2]= cargs[1]; if (args[1]->const_item()) { uint32 length= (uint32) args[1]->val_int() * collation.collation->mbmaxlen; @@ -2047,11 +2054,13 @@ String *Item_func_rpad::val_str(String *str) void Item_func_lpad::fix_length_and_dec() { - if (collation.set(args[0]->collation, args[2]->collation)) - { - my_coll_agg_error(args[0]->collation, args[2]->collation, func_name()); + Item *cargs[2]; + cargs[0]= args[0]; + cargs[1]= args[2]; + if (agg_arg_charsets(collation, cargs, 2, MY_COLL_ALLOW_CONV)) return; - } + args[0]= cargs[0]; + args[2]= cargs[1]; if (args[1]->const_item()) { @@ -2495,7 +2504,8 @@ void Item_func_export_set::fix_length_and_dec() uint sep_length=(arg_count > 3 ? args[3]->max_length : 1); max_length=length*64+sep_length*63; - if (agg_arg_collations(collation, args+1, min(4,arg_count)-1)) + if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1), + MY_COLL_ALLOW_CONV) return; } From 6563fa1c8be4844f205b9cba2726927ac7abd844 Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Tue, 2 Nov 2004 13:15:55 +0100 Subject: [PATCH 047/101] NDB fix blob parts distribution - backwards compatible --- ndb/src/ndbapi/NdbBlob.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index 731f32ba916..9d21304939a 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -97,6 +97,14 @@ NdbBlob::getBlobTable(NdbTableImpl& bt, const NdbTableImpl* t, const NdbColumnIm bt.setName(btname); bt.setLogging(t->getLogging()); bt.setFragmentType(t->getFragmentType()); + { NdbDictionary::Column bc("PK"); + bc.setType(NdbDictionary::Column::Unsigned); + assert(t->m_sizeOfKeysInWords != 0); + bc.setLength(t->m_sizeOfKeysInWords); + bc.setPrimaryKey(true); + bc.setDistributionKey(true); + bt.addColumn(bc); + } { NdbDictionary::Column bc("DIST"); bc.setType(NdbDictionary::Column::Unsigned); bc.setPrimaryKey(true); @@ -106,13 +114,7 @@ NdbBlob::getBlobTable(NdbTableImpl& bt, const NdbTableImpl* t, const NdbColumnIm { NdbDictionary::Column bc("PART"); bc.setType(NdbDictionary::Column::Unsigned); bc.setPrimaryKey(true); - bt.addColumn(bc); - } - { NdbDictionary::Column bc("PK"); - bc.setType(NdbDictionary::Column::Unsigned); - assert(t->m_sizeOfKeysInWords != 0); - bc.setLength(t->m_sizeOfKeysInWords); - bc.setPrimaryKey(true); + bc.setDistributionKey(false); bt.addColumn(bc); } { NdbDictionary::Column bc("DATA"); @@ -392,9 +394,10 @@ NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_sizeOfKeysInWords; DBG("setPartKeyValue dist=" << getDistKey(part) << " part=" << part << " key=" << ndb_blob_debug(data, size)); - if (anOp->equal((Uint32)0, getDistKey(part)) == -1 || - anOp->equal((Uint32)1, part) == -1 || - anOp->equal((Uint32)2, theKeyBuf.data) == -1) { + // TODO use attr ids after compatibility with 4.1.7 not needed + if (anOp->equal("PK", theKeyBuf.data) == -1 || + anOp->equal("DIST", getDistKey(part)) == -1 || + anOp->equal("PART", part) == -1) { setErrorCode(anOp); return -1; } From 8d34e2d45bec2583ad67cc6d6e76bcc85b4d8ba7 Mon Sep 17 00:00:00 2001 From: "joreland@mysql.com" <> Date: Tue, 2 Nov 2004 13:58:22 +0100 Subject: [PATCH 048/101] build issue Fix so that signed/unsigned char does not matter in comparision --- ndb/src/ndbapi/NdbOperationExec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndb/src/ndbapi/NdbOperationExec.cpp b/ndb/src/ndbapi/NdbOperationExec.cpp index fa46e93a57f..6d7a3817e04 100644 --- a/ndb/src/ndbapi/NdbOperationExec.cpp +++ b/ndb/src/ndbapi/NdbOperationExec.cpp @@ -192,7 +192,7 @@ NdbOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransId) OperationType tOperationType = theOperationType; Uint32 tTupKeyLen = theTupKeyLen; Uint8 abortOption = - m_abortOption != -1 ? m_abortOption : theNdbCon->m_abortOption; + m_abortOption != (Int8)-1 ? m_abortOption : theNdbCon->m_abortOption; tcKeyReq->setDirtyFlag(tReqInfo, tDirtyIndicator); tcKeyReq->setOperationType(tReqInfo, tOperationType); @@ -543,7 +543,7 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal) }//if AbortOption ao = (AbortOption) - (m_abortOption != -1 ? m_abortOption : theNdbCon->m_abortOption); + (m_abortOption != (Int8)-1 ? m_abortOption : theNdbCon->m_abortOption); theReceiver.m_received_result_length = ~0; theStatus = Finished; From 1b94652bded12ff0cc61638299c6c93cede24de1 Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Tue, 2 Nov 2004 15:09:57 +0100 Subject: [PATCH 049/101] Test expansion: "MOD" on non-integral first operand. --- mysql-test/r/ps_10nestset.result | 11 +++++++++++ mysql-test/t/ps_10nestset.test | 13 ++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/ps_10nestset.result b/mysql-test/r/ps_10nestset.result index 68f58a03674..ff63485a5f9 100644 --- a/mysql-test/r/ps_10nestset.result +++ b/mysql-test/r/ps_10nestset.result @@ -62,4 +62,15 @@ id emp salary l r 4 Donna 1064.80 5 6 5 Eddie 931.70 7 8 6 Fred 798.60 9 10 +prepare st_round from 'update t1 set salary = salary + ? - ( salary MOD ? )'; +set @arg_round= 50; +execute st_round using @arg_round, @arg_round; +select * from t1; +id emp salary l r +1 Jerry 1350.00 1 12 +2 Bert 1200.00 2 3 +3 Chuck 1250.00 4 11 +4 Donna 1100.00 5 6 +5 Eddie 950.00 7 8 +6 Fred 800.00 9 10 drop table t1; diff --git a/mysql-test/t/ps_10nestset.test b/mysql-test/t/ps_10nestset.test index d2adaca689e..53e84f7a47d 100644 --- a/mysql-test/t/ps_10nestset.test +++ b/mysql-test/t/ps_10nestset.test @@ -61,12 +61,11 @@ while ($1) select * from t1; -# Waiting for the resolution of bug#6138 -# # Now, increase salary to a multiple of 50 -# prepare st_round from 'update t1 set salary = salary + ? - ( salary MOD ? )'; -# set @arg_round= 50; -# execute st_round using @arg_round, @arg_round; -# -# select * from t1; +# Now, increase salary to a multiple of 50 (checks for bug#6138) +prepare st_round from 'update t1 set salary = salary + ? - ( salary MOD ? )'; +set @arg_round= 50; +execute st_round using @arg_round, @arg_round; + +select * from t1; drop table t1; From 86b33f360bd002ef4848de6666feacaae7f1d1dd Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Tue, 2 Nov 2004 19:48:37 +0400 Subject: [PATCH 050/101] A fix (bug #6331: INSERT IGNORE .. SELECT breaks subsequent inserts). --- mysql-test/r/ndb_insert.result | 29 +++++++++++++++++++++++++++++ mysql-test/t/ndb_insert.test | 15 +++++++++++++++ sql/ha_ndbcluster.cc | 3 ++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_insert.result b/mysql-test/r/ndb_insert.result index cdc445558b9..16c76f39680 100644 --- a/mysql-test/r/ndb_insert.result +++ b/mysql-test/r/ndb_insert.result @@ -557,3 +557,32 @@ select * from t1 where pk1=1; pk1 b c 1 2 3 DROP TABLE t1; +CREATE TABLE t1(a INT) ENGINE=ndb; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +SELECT * FROM t1; +a +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1; diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index 310c16de3d8..c3da4641014 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -583,3 +583,18 @@ INSERT INTO t1 VALUES(1,1,1) ON DUPLICATE KEY UPDATE b=79; select * from t1 where pk1=1; DROP TABLE t1; + +# +# Bug #6331: problem with 'insert ignore' +# + +CREATE TABLE t1(a INT) ENGINE=ndb; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 838cf69855a..4f0bd1f99ec 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2650,7 +2650,8 @@ int ha_ndbcluster::extra(enum ha_extra_function operation) m_use_write= TRUE; } else { - m_ignore_dup_key_not_supported= TRUE; + if (table->keys) + m_ignore_dup_key_not_supported= TRUE; } break; case HA_EXTRA_NO_IGNORE_DUP_KEY: From 8b472a76059e7286a1fcf862b9d877bf13e6151b Mon Sep 17 00:00:00 2001 From: "rburnett@build.mysql.com" <> Date: Tue, 2 Nov 2004 18:18:21 +0100 Subject: [PATCH 051/101] Bug# 5303 Windows --log-error option doesn't work correctly --- sql/mysqld.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7062334edbb..2159fd5e402 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2918,11 +2918,10 @@ we force server id to 2, but this MySQL server will not act as a slave."); exit(1); #ifdef __WIN__ -#define MYSQL_ERR_FILE "mysql.err" if (!opt_console) { - freopen(MYSQL_ERR_FILE,"a+",stdout); - freopen(MYSQL_ERR_FILE,"a+",stderr); + freopen(log_error_file,"a+",stdout); + freopen(log_error_file,"a+",stderr); FreeConsole(); // Remove window } #endif From 2185f1a56c72a6bab11335277232ee87abdcaa54 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 2 Nov 2004 20:13:27 +0200 Subject: [PATCH 052/101] Remove usage of !$ from mysql-tests Added protocol::flush() for easier embedded-server code Increase block allocation variables a bit as they where a bit too small for MySQL 4.1 Added option --silent to client_test --- client/mysqltest.c | 90 +-- include/mysql_com.h | 6 - mysql-test/r/mysqltest.result | 7 - mysql-test/t/client_test.test | 2 +- mysql-test/t/comments.test | 3 +- mysql-test/t/join_outer.test | 15 +- mysql-test/t/key.test | 3 +- mysql-test/t/mysqltest.test | 97 ++- mysql-test/t/show_check.test | 3 +- mysql-test/t/temp_table.test | 6 +- mysql-test/t/type_ranges.test | 3 +- sql/mysqld.cc | 4 +- sql/net_serv.cc | 12 +- sql/protocol.cc | 9 + sql/protocol.h | 1 + sql/sql_prepare.cc | 26 +- sql/sql_show.cc | 6 +- tests/client_test.c | 1105 ++++++++++++++++++++------------- 18 files changed, 836 insertions(+), 562 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 21f93b1fc6a..aef36823dfc 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -42,7 +42,7 @@ **********************************************************************/ -#define MTEST_VERSION "2.3" +#define MTEST_VERSION "2.4" #include #include @@ -243,8 +243,7 @@ VAR var_reg[10]; HASH var_hash; my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0; my_bool disable_info= 1; /* By default off */ -/* default for disable_abort_on_error: false = abort on unmasked error */ -my_bool disable_abort_on_error= 0; +my_bool abort_on_error= 1; struct connection cons[MAX_CONS]; struct connection* cur_con, *next_con, *cons_end; @@ -370,7 +369,7 @@ const char *command_names[]= }; TYPELIB command_typelib= {array_elements(command_names),"", - command_names}; + command_names, 0}; DYNAMIC_STRING ds_res; static void die(const char *fmt, ...); @@ -744,7 +743,7 @@ err: DBUG_RETURN(0); } -static VAR* var_obtain(char* name, int len) +static VAR *var_obtain(const char* name, int len) { VAR* v; if ((v = (VAR*)hash_search(&var_hash, name, len))) @@ -754,28 +753,33 @@ static VAR* var_obtain(char* name, int len) return v; } -int var_set(char* var_name, char* var_name_end, char* var_val, - char* var_val_end) +int var_set(const char *var_name, const char *var_name_end, + const char *var_val, const char *var_val_end) { int digit; VAR* v; + DBUG_ENTER("var_set"); + DBUG_PRINT("enter", ("var_name: '%.*s' = '%.*s' (length: %d)", + (int) (var_name_end - var_name), var_name, + (int) (var_val_end - var_val), var_val, + (int) (var_val_end - var_val))); + if (*var_name++ != '$') - { - --var_name; - *var_name_end = 0; - die("Variable name in %s does not start with '$'", var_name); - } + { + var_name--; + die("Variable name in %s does not start with '$'", var_name); + } digit = *var_name - '0'; if (!(digit < 10 && digit >= 0)) - { - v = var_obtain(var_name, var_name_end - var_name); - } + { + v = var_obtain(var_name, (uint) (var_name_end - var_name)); + } else - v = var_reg + digit; - + v = var_reg + digit; return eval_expr(v, var_val, (const char**)&var_val_end); } + int open_file(const char* name) { char buff[FN_REFLEN]; @@ -1244,18 +1248,22 @@ int do_let(struct st_query* q) return var_set(var_name, var_name_end, var_val_start, q->end); } -/* Store an integer (typically the returncode of the last SQL) */ -/* statement in the mysqltest builtin variable $mysql_errno, by */ -/* simulating of a user statement "let $mysql_errno= " */ -int var_set_errno(int sql_errno ) + +/* + Store an integer (typically the returncode of the last SQL) + statement in the mysqltest builtin variable $mysql_errno, by + simulating of a user statement "let $mysql_errno= " +*/ + +int var_set_errno(int sql_errno) { - char var_name[] = "$mysql_errno", var_val[30]; - sprintf(var_val, "%d", sql_errno); - /* On some odd systems, the return value from sprintf() isn't */ - /* always the length of the string, so we use strlen() */ - return var_set(var_name, var_name + 12, var_val, var_val + strlen(var_val)); + const char *var_name= "$mysql_errno"; + char var_val[21]; + uint length= my_sprintf(var_val, (var_val, "%d", sql_errno)); + return var_set(var_name, var_name + 12, var_val, var_val + length); } + int do_rpl_probe(struct st_query* q __attribute__((unused))) { DBUG_ENTER("do_rpl_probe"); @@ -1264,12 +1272,14 @@ int do_rpl_probe(struct st_query* q __attribute__((unused))) DBUG_RETURN(0); } + int do_enable_rpl_parse(struct st_query* q __attribute__((unused))) { mysql_enable_rpl_parse(&cur_con->mysql); return 0; } + int do_disable_rpl_parse(struct st_query* q __attribute__((unused))) { mysql_disable_rpl_parse(&cur_con->mysql); @@ -2013,7 +2023,7 @@ int read_query(struct st_query** q_ptr) memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, sizeof(global_expected_errno)); q->expected_errors= global_expected_errors; - q->abort_on_error= (global_expected_errors == 0 && !disable_abort_on_error); + q->abort_on_error= (global_expected_errors == 0 && abort_on_error); bzero((gptr) global_expected_errno, sizeof(global_expected_errno)); global_expected_errors=0; if (p[0] == '-' && p[1] == '-') @@ -2422,7 +2432,7 @@ static int run_query(MYSQL *mysql, struct st_query *q, int flags) if (ps_protocol_enabled && disable_info && (flags & QUERY_SEND) && (flags & QUERY_REAP) && ps_match_re(q->query)) - return run_query_stmt (mysql, q, flags); + return run_query_stmt(mysql, q, flags); return run_query_normal(mysql, q, flags); } @@ -2659,9 +2669,12 @@ end: dynstr_free(&ds_tmp); if (q->type == Q_EVAL) dynstr_free(&eval_query); - /* We save the return code (mysql_errno(mysql)) from the last call sent */ - /* to the server into the mysqltest builtin variable $mysql_errno. This */ - /* variable then can be used from the test case itself. */ + + /* + We save the return code (mysql_errno(mysql)) from the last call sent + to the server into the mysqltest builtin variable $mysql_errno. This + variable then can be used from the test case itself. + */ var_set_errno(mysql_errno(mysql)); DBUG_RETURN(error); } @@ -3012,6 +3025,7 @@ end: dynstr_free(&ds_tmp); if (q->type == Q_EVAL) dynstr_free(&eval_query); + var_set_errno(mysql_stmt_errno(stmt)); mysql_stmt_close(stmt); DBUG_RETURN(error); } @@ -3319,7 +3333,7 @@ static VAR* var_from_env(const char *name, const char *def_val) if (!(tmp = getenv(name))) tmp = def_val; - v = var_init(0, name, 0, tmp, 0); + v = var_init(0, name, strlen(name), tmp, strlen(tmp)); my_hash_insert(&var_hash, (byte*)v); return v; } @@ -3416,9 +3430,11 @@ int main(int argc, char **argv) init_var_hash(&cur_con->mysql); - /* Initialize $mysql_errno with -1, so we can */ - /* - distinguish it from valid values ( >= 0 ) and */ - /* - detect if there was never a command sent to the server */ + /* + Initialize $mysql_errno with -1, so we can + - distinguish it from valid values ( >= 0 ) and + - detect if there was never a command sent to the server + */ var_set_errno(-1); while (!read_query(&q)) @@ -3440,8 +3456,8 @@ int main(int argc, char **argv) case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break; case Q_ENABLE_QUERY_LOG: disable_query_log=0; break; case Q_DISABLE_QUERY_LOG: disable_query_log=1; break; - case Q_ENABLE_ABORT_ON_ERROR: disable_abort_on_error=0; break; - case Q_DISABLE_ABORT_ON_ERROR: disable_abort_on_error=1; break; + case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break; + case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break; case Q_ENABLE_RESULT_LOG: disable_result_log=0; break; case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; diff --git a/include/mysql_com.h b/include/mysql_com.h index 4686acc098f..6a6136bd974 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -282,13 +282,7 @@ void my_net_local_init(NET *net); void net_end(NET *net); void net_clear(NET *net); my_bool net_realloc(NET *net, unsigned long length); - -#ifndef EMBEDDED_LIBRARY /* To be removed by HF */ my_bool net_flush(NET *net); -#else -#define net_flush(A) -#endif - my_bool my_net_write(NET *net,const char *packet,unsigned long len); my_bool net_write_command(NET *net,unsigned char command, const char *header, unsigned long head_len, diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 5dc9ede1ca6..d75dbd5d00c 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -7,11 +7,6 @@ otto select otto from (select 1 as otto) as t1; otto 1 -select otto from (select 1 as otto) as t1; -otto -1 -select friedrich from (select 1 as otto) as t1; -ERROR 42S22: Unknown column 'friedrich' in 'field list' select friedrich from (select 1 as otto) as t1; ERROR 42S22: Unknown column 'friedrich' in 'field list' select otto from (select 1 as otto) as t1; @@ -147,5 +142,3 @@ after_--enable_abort_on_error 1064 select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist -select 3 from t1 ; -ERROR 42S02: Table 'test.t1' doesn't exist diff --git a/mysql-test/t/client_test.test b/mysql-test/t/client_test.test index b56e8038d9b..830c5f1b8a2 100644 --- a/mysql-test/t/client_test.test +++ b/mysql-test/t/client_test.test @@ -1,2 +1,2 @@ --disable_result_log ---exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT +--exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent diff --git a/mysql-test/t/comments.test b/mysql-test/t/comments.test index 2fc6237907c..087df60f3f5 100644 --- a/mysql-test/t/comments.test +++ b/mysql-test/t/comments.test @@ -5,7 +5,8 @@ select 1+2/*hello*/+3; select 1 /* long multi line comment */; -!$1065 ; +--error 1065 + ; select 1 /*!32301 +1 */; select 1 /*!52301 +1 */; select 1--1; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 0c4c9614d88..bc96318ae2e 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -34,11 +34,14 @@ explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); # The next query should rearange the left joins to get this to work -!$1120 explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); -!$1120 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +--error 1120 +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +--error 1120 +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); # The next query should give an error in MySQL -!$1120 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +--error 1120 +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); # Test of inner join select t1.*,t2.* from t1 inner join t2 using (a); @@ -94,7 +97,8 @@ WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); -!$1062 INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +--error 1062 +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); #3rd select should show that one record is returned with null entries for the @@ -288,7 +292,8 @@ insert into t3 values (1); insert into t4 values (1,1); insert into t5 values (1,1); -!$1120 explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +--error 1120 +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; drop table t1,t2,t3,t4,t5; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index 4be34cac30e..5ee2f68ab83 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -146,7 +146,8 @@ create table t1 ); INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); INSERT INTO t1 VALUES (1, 1, 1, 1, 'b'); -!$1062 INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); +--error 1062 +INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); drop table t1; # diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index b7007e1a519..0802c18ed6c 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -20,12 +20,10 @@ eval select $mysql_errno as "before_use_test" ; select otto from (select 1 as otto) as t1; # expectation = response -!$0 select otto from (select 1 as otto) as t1; --error 0 select otto from (select 1 as otto) as t1; # expectation <> response --- // !$1054 select otto from (select 1 as otto) as t1; -- // --error 1054 -- // select otto from (select 1 as otto) as t1; @@ -38,12 +36,10 @@ select otto from (select 1 as otto) as t1; # ---------------------------------------------------------------------------- # expectation <> response -#!$0 select friedrich from (select 1 as otto) as t1; #--error 0 #select friedrich from (select 1 as otto) as t1; # expectation = response -!$1054 select friedrich from (select 1 as otto) as t1; --error 1054 select friedrich from (select 1 as otto) as t1; @@ -94,130 +90,130 @@ select friedrich from (select 1 as otto) as t1; # # The following test cases often initialize $mysql_errno to 1064 by # a command with wrong syntax. -# Example: !$1064 To prevent the abort after the error. +# Example: --error 1064 To prevent the abort after the error. # garbage ; # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# 1. check mysql_errno = 0 after successful statement +# check mysql_errno = 0 after successful statement # ---------------------------------------------------------------------------- select otto from (select 1 as otto) as t1; eval select $mysql_errno as "after_successful_stmt_errno" ; #---------------------------------------------------------------------------- -# 2. check mysql_errno = 1064 after statement with wrong syntax +# check mysql_errno = 1064 after statement with wrong syntax # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; eval select $mysql_errno as "after_wrong_syntax_errno" ; # ---------------------------------------------------------------------------- -# 3. check if let $my_var= 'abc' ; affects $mysql_errno +# check if let $my_var= 'abc' ; affects $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; let $my_var= 'abc' ; eval select $mysql_errno as "after_let_var_equal_value" ; # ---------------------------------------------------------------------------- -# 4. check if set @my_var= 'abc' ; affects $mysql_errno +# check if set @my_var= 'abc' ; affects $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; set @my_var= 'abc' ; eval select $mysql_errno as "after_set_var_equal_value" ; # ---------------------------------------------------------------------------- -# 5. check if the setting of --disable-warnings itself affects $mysql_errno -# (May be -- modifies $mysql_errno.) +# check if the setting of --disable-warnings itself affects $mysql_errno +# (May be -- modifies $mysql_errno.) # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --disable_warnings eval select $mysql_errno as "after_disable_warnings_command" ; # ---------------------------------------------------------------------------- -# 6. check if --disable-warnings + command with warning affects the errno -# stored within $mysql_errno -# (May be disabled warnings affect $mysql_errno.) +# check if --disable-warnings + command with warning affects the errno +# stored within $mysql_errno +# (May be disabled warnings affect $mysql_errno.) # ---------------------------------------------------------------------------- drop table if exists t1 ; -!$1064 +--error 1064 garbage ; drop table if exists t1 ; eval select $mysql_errno as "after_disable_warnings" ; --enable_warnings # ---------------------------------------------------------------------------- -# 7. check if masked errors affect $mysql_errno +# check if masked errors affect $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --error 1146 select 3 from t1 ; eval select $mysql_errno as "after_minus_masked" ; -!$1064 +--error 1064 garbage ; -!$1146 +--error 1146 select 3 from t1 ; eval select $mysql_errno as "after_!_masked" ; # ---------------------------------------------------------------------------- -# 8. Will manipulations of $mysql_errno be possible and visible ? +# Will manipulations of $mysql_errno be possible and visible ? # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; let $mysql_errno= -1; eval select $mysql_errno as "after_let_errno_equal_value" ; # ---------------------------------------------------------------------------- -# 9. How affect actions on prepared statements $mysql_errno ? +# How affect actions on prepared statements $mysql_errno ? # ---------------------------------------------------------------------------- # failing prepare -!$1064 +--error 1064 garbage ; -!$1146 +--error 1146 prepare stmt from "select 3 from t1" ; eval select $mysql_errno as "after_failing_prepare" ; create table t1 ( f1 char(10)); # successful prepare -!$1064 +--error 1064 garbage ; prepare stmt from "select 3 from t1" ; eval select $mysql_errno as "after_successful_prepare" ; # successful execute -!$1064 +--error 1064 garbage ; execute stmt; eval select $mysql_errno as "after_successful_execute" ; # failing execute (table dropped) drop table t1; -!$1064 +--error 1064 garbage ; -!$1146 +--error 1146 execute stmt; eval select $mysql_errno as "after_failing_execute" ; # failing execute (unknown statement) -!$1064 +--error 1064 garbage ; -!$1243 +--error 1243 execute __stmt_; eval select $mysql_errno as "after_failing_execute" ; # successful deallocate -!$1064 +--error 1064 garbage ; deallocate prepare stmt; eval select $mysql_errno as "after_successful_deallocate" ; # failing deallocate ( statement handle does not exist ) -!$1064 +--error 1064 garbage ; -!$1243 +--error 1243 deallocate prepare __stmt_; eval select $mysql_errno as "after_failing_deallocate" ; @@ -231,7 +227,7 @@ eval select $mysql_errno as "after_failing_deallocate" ; # The default is "--enable_abort_on_error". # # "Maskings" are -# !$ and --error +# --error and --error # in the line before the failing statement. # # There are some additional test case for $mysql_errno @@ -240,58 +236,53 @@ eval select $mysql_errno as "after_failing_deallocate" ; # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# 1. Switch the abort on error off and check the effect on $mysql_errno +# Switch the abort on error off and check the effect on $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --disable_abort_on_error eval select $mysql_errno as "after_--disable_abort_on_error" ; # ---------------------------------------------------------------------------- -# 2. "unmasked" failing statement should not cause an abort +# "unmasked" failing statement should not cause an abort # ---------------------------------------------------------------------------- select 3 from t1 ; # ---------------------------------------------------------------------------- -# 3. masked failing statements +# masked failing statements # ---------------------------------------------------------------------------- # expected error = response --error 1146 select 3 from t1 ; -!$1146 +--error 1146 select 3 from t1 ; eval select $mysql_errno as "after_!errno_masked_error" ; # expected error <> response # --error 1000 # select 3 from t1 ; -# !$1000 +# --error 1000 # select 3 from t1 ; # ---------------------------------------------------------------------------- -# 4. Switch the abort on error on and check the effect on $mysql_errno +# Switch the abort on error on and check the effect on $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --enable_abort_on_error eval select $mysql_errno as "after_--enable_abort_on_error" ; # ---------------------------------------------------------------------------- -# 5. masked failing statements +# masked failing statements # ---------------------------------------------------------------------------- # expected error = response --error 1146 select 3 from t1 ; -!$1146 -select 3 from t1 ; # ---------------------------------------------------------------------------- -# 6. check that the old default behaviour is not changed +# check that the old default behaviour is not changed # Please remove the '#' to get the abort on error # ---------------------------------------------------------------------------- #--error 1064 #select 3 from t1 ; # -#!$1064 -#select 3 from t1 ; -# #select 3 from t1 ; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 681127eab5e..efbe2e9371d 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -21,7 +21,8 @@ check table t1 changed; check table t1 medium; check table t1 extended; show index from t1; -!$1062 insert into t1 values (5,5,5); +--error 1062 +insert into t1 values (5,5,5); optimize table t1; optimize table t1; drop table t1; diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 2181d3eb74c..74276c7668c 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -20,8 +20,10 @@ create TEMPORARY TABLE t2 engine=heap select * from t1; create TEMPORARY TABLE IF NOT EXISTS t2 (a int) engine=heap; # This should give errors -!$1050 CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null); -!$1050 ALTER TABLE t1 RENAME t2; +--error 1050 +CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null); +--error 1050 +ALTER TABLE t1 RENAME t2; select * from t2; alter table t2 add primary key (a,b); diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test index 09b5867e7a8..572dc0af313 100644 --- a/mysql-test/t/type_ranges.test +++ b/mysql-test/t/type_ranges.test @@ -135,7 +135,8 @@ drop table t1,t2; create table t1 (c int); insert into t1 values(1),(2); create table t2 select * from t1; -!$1060 create table t3 select * from t1, t2; # Should give an error +--error 1060 +create table t3 select * from t1, t2; # Should give an error create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2; show full columns from t3; drop table t1,t2,t3; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7062334edbb..d06aba3387e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5026,12 +5026,12 @@ The minimum value for this variable is 4096.", "Persistent buffer for query parsing and execution", (gptr*) &global_system_variables.query_prealloc_size, (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG, - REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0}, + REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 16384, ~0L, 0, 1024, 0}, {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE, "Allocation block size for storing ranges during optimization", (gptr*) &global_system_variables.range_alloc_block_size, (gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG, - REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, + REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 4096, ~0L, 0, 1024, 0}, {"read_buffer_size", OPT_RECORD_BUFFER, "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.", (gptr*) &global_system_variables.read_buff_size, diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 457b2052a45..5985cf63ed6 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -53,19 +53,9 @@ #include #ifdef EMBEDDED_LIBRARY - #undef MYSQL_SERVER - -#ifndef MYSQL_CLIENT +#undef MYSQL_CLIENT #define MYSQL_CLIENT -#endif - -#undef net_flush - -extern "C" { -my_bool net_flush(NET *net); -} - #endif /*EMBEDDED_LIBRARY */ diff --git a/sql/protocol.cc b/sql/protocol.cc index 598d102ec29..eaa0fd55b25 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -470,6 +470,15 @@ void Protocol::init(THD *thd_arg) } +bool Protocol::flush() +{ +#ifndef EMBEDDED_LIBRARY + return net_flush(&thd->net); +#else + return 0; +#endif +} + /* Send name and type of result to client. diff --git a/sql/protocol.h b/sql/protocol.h index d7ce5425ad1..a3b6da55da3 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -75,6 +75,7 @@ public: field_count=item_list->elements; return 0; } + virtual bool flush(); virtual void prepare_for_resend()=0; virtual bool store_null()=0; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index b5e12c4d208..4ae69e40342 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -153,6 +153,8 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) { NET *net= &stmt->thd->net; char buff[9]; + DBUG_ENTER("send_prep_stmt"); + buff[0]= 0; /* OK packet indicator */ int4store(buff+1, stmt->id); int2store(buff+5, columns); @@ -161,12 +163,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) Send types and names of placeholders to the client XXX: fix this nasty upcast from List to List */ - return my_net_write(net, buff, sizeof(buff)) || - (stmt->param_count && - stmt->thd->protocol_simple.send_fields((List *) - &stmt->lex->param_list, 0)) || - net_flush(net); - return 0; + DBUG_RETURN(my_net_write(net, buff, sizeof(buff)) || + (stmt->param_count && + stmt->thd->protocol_simple.send_fields((List *) + &stmt->lex->param_list, + 0))); } #else static bool send_prep_stmt(Prepared_statement *stmt, @@ -1088,7 +1089,7 @@ static int mysql_test_select(Prepared_statement *stmt, { if (lex->describe) { - if (send_prep_stmt(stmt, 0)) + if (send_prep_stmt(stmt, 0) || thd->protocol->flush()) goto err_prep; } else @@ -1106,11 +1107,8 @@ static int mysql_test_select(Prepared_statement *stmt, prepared in unit->prepare call above. */ if (send_prep_stmt(stmt, lex->result->field_count(fields)) || - lex->result->send_fields(fields, 0) -#ifndef EMBEDDED_LIBRARY - || net_flush(&thd->net) -#endif - ) + lex->result->send_fields(fields, 0) || + thd->protocol->flush()) goto err_prep; } } @@ -1389,7 +1387,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) enum enum_sql_command sql_command= lex->sql_command; int res= 0; DBUG_ENTER("send_prepare_results"); - DBUG_PRINT("enter",("command: %d, param_count: %ld", sql_command, stmt->param_count)); @@ -1475,7 +1472,8 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) goto error; } if (res == 0) - DBUG_RETURN(text_protocol? 0 : send_prep_stmt(stmt, 0)); + DBUG_RETURN(text_protocol? 0 : (send_prep_stmt(stmt, 0) || + thd->protocol->flush())); error: if (res < 0) send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 0); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2af4cb3fc23..bda490e2916 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1081,7 +1081,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) restore_record(table,default_values); // Get empty record if (thd->protocol->send_fields(&field_list,2)) DBUG_VOID_RETURN; - net_flush(&thd->net); + thd->protocol->flush(); DBUG_VOID_RETURN; } @@ -1098,13 +1098,11 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) if (store_create_info(thd, table, packet)) DBUG_RETURN(-1); - //if (protocol->convert) - // protocol->convert->convert((char*) packet->ptr(), packet->length()); if (fd < 0) { if (protocol->write()) DBUG_RETURN(-1); - net_flush(&thd->net); + protocol->flush(); } else { diff --git a/tests/client_test.c b/tests/client_test.c index 48676ae7e12..70e1b26aeaa 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (C) 2003-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 @@ -27,6 +27,7 @@ #include #include +#define VER "2.0" #define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */ /* set default options */ @@ -37,7 +38,7 @@ static char *opt_password= 0; static char *opt_host= 0; static char *opt_unix_socket= 0; static unsigned int opt_port; -static my_bool tty_password= 0; +static my_bool tty_password= 0, opt_silent= 0; static MYSQL *mysql= 0; static char query[MAX_TEST_QUERY_LENGTH]; @@ -52,6 +53,7 @@ static double total_time; const char *default_dbug_option= "d:t:o,/tmp/client_test.trace"; #define myheader(str) \ +if (opt_silent < 2) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%d of (%d/%d): %s", test_count++, iter_count, \ @@ -59,6 +61,7 @@ const char *default_dbug_option= "d:t:o,/tmp/client_test.trace"; fprintf(stdout, " \n#####################################\n"); \ } #define myheader_r(str) \ +if (!opt_silent) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%s", str); \ @@ -144,32 +147,39 @@ DIE_UNLESS(stmt == 0);\ static void print_error(const char *msg) { - if (mysql && mysql_errno(mysql)) + if (!opt_silent) { - if (mysql->server_version) - fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); - else - fprintf(stdout, "\n [MySQL]"); - fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + if (mysql && mysql_errno(mysql)) + { + if (mysql->server_version) + fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); + else + fprintf(stdout, "\n [MySQL]"); + fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + } + else if (msg) + fprintf(stderr, " [MySQL] %s\n", msg); } - else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } static void print_st_error(MYSQL_STMT *stmt, const char *msg) { - if (stmt && mysql_stmt_errno(stmt)) + if (!opt_silent) { - if (stmt->mysql && stmt->mysql->server_version) - fprintf(stdout, "\n [MySQL-%s]", stmt->mysql->server_version); - else - fprintf(stdout, "\n [MySQL]"); + if (stmt && mysql_stmt_errno(stmt)) + { + if (stmt->mysql && stmt->mysql->server_version) + fprintf(stdout, "\n [MySQL-%s]", stmt->mysql->server_version); + else + fprintf(stdout, "\n [MySQL]"); - fprintf(stdout, "[%d] %s\n", mysql_stmt_errno(stmt), - mysql_stmt_error(stmt)); + fprintf(stdout, "[%d] %s\n", mysql_stmt_errno(stmt), + mysql_stmt_error(stmt)); + } + else if (msg) + fprintf(stderr, " [MySQL] %s\n", msg); } - else if (msg) - fprintf(stderr, " [MySQL] %s\n", msg); } @@ -198,8 +208,9 @@ static void client_connect() int rc; myheader_r("client_connect"); - fprintf(stdout, "\n Establishing a connection to '%s' ...", - opt_host ? opt_host : ""); + if (!opt_silent) + fprintf(stdout, "\n Establishing a connection to '%s' ...", + opt_host ? opt_host : ""); if (!(mysql= mysql_init(NULL))) { @@ -217,12 +228,14 @@ static void client_connect() exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); /* set AUTOCOMMIT to ON*/ mysql_autocommit(mysql, TRUE); - fprintf(stdout, "\n Creating a test database '%s' ...", current_db); + if (!opt_silent) + fprintf(stdout, "\n Creating a test database '%s' ...", current_db); strxmov(query, "CREATE DATABASE IF NOT EXISTS ", current_db, NullS); rc= mysql_query(mysql, query); @@ -232,7 +245,8 @@ static void client_connect() rc= mysql_query(mysql, query); myquery(rc); - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); } @@ -244,13 +258,16 @@ static void client_disconnect() if (mysql) { - fprintf(stdout, "\n dropping the test database '%s' ...", current_db); + if (!opt_silent) + fprintf(stdout, "\n dropping the test database '%s' ...", current_db); strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); mysql_query(mysql, query); - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); - fprintf(stdout, "\n closing the connection ..."); + if (!opt_silent) + fprintf(stdout, "\n closing the connection ..."); mysql_close(mysql); fprintf(stdout, " OK\n"); } @@ -331,8 +348,11 @@ static void my_print_result_metadata(MYSQL_RES *result) unsigned int field_count; mysql_field_seek(result, 0); - fputc('\n', stdout); - fputc('\n', stdout); + if (!opt_silent) + { + fputc('\n', stdout); + fputc('\n', stdout); + } field_count= mysql_num_fields(result); for(i= 0; i< field_count; i++) @@ -345,18 +365,25 @@ static void my_print_result_metadata(MYSQL_RES *result) j= 4; field->max_length= j; } - my_print_dashes(result); - fputc('\t', stdout); - fputc('|', stdout); + if (!opt_silent) + { + my_print_dashes(result); + fputc('\t', stdout); + fputc('|', stdout); + } mysql_field_seek(result, 0); for(i= 0; i< field_count; i++) { field= mysql_fetch_field(result); - fprintf(stdout, " %-*s |", (int) field->max_length, field->name); + if (!opt_silent) + fprintf(stdout, " %-*s |", (int) field->max_length, field->name); + } + if (!opt_silent) + { + fputc('\n', stdout); + my_print_dashes(result); } - fputc('\n', stdout); - my_print_dashes(result); } @@ -377,31 +404,43 @@ int my_process_result_set(MYSQL_RES *result) while ((row= mysql_fetch_row(result)) != NULL) { mysql_field_seek(result, 0); - fputc('\t', stdout); - fputc('|', stdout); + if (!opt_silent) + { + fputc('\t', stdout); + fputc('|', stdout); + } for(i= 0; i< mysql_num_fields(result); i++) { field= mysql_fetch_field(result); - if (row[i] == NULL) - fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); - else if (IS_NUM(field->type)) - fprintf(stdout, " %*s |", (int) field->max_length, row[i]); - else - fprintf(stdout, " %-*s |", (int) field->max_length, row[i]); + if (!opt_silent) + { + if (row[i] == NULL) + fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); + else if (IS_NUM(field->type)) + fprintf(stdout, " %*s |", (int) field->max_length, row[i]); + else + fprintf(stdout, " %-*s |", (int) field->max_length, row[i]); + } + } + if (!opt_silent) + { + fputc('\t', stdout); + fputc('\n', stdout); } - fputc('\t', stdout); - fputc('\n', stdout); row_count++; } - if (row_count) - my_print_dashes(result); + if (!opt_silent) + { + if (row_count) + my_print_dashes(result); - if (mysql_errno(mysql) != 0) - fprintf(stderr, "\n\tmysql_fetch_row() failed\n"); - else - fprintf(stdout, "\n\t%d %s returned\n", row_count, - row_count == 1 ? "row" : "rows"); + if (mysql_errno(mysql) != 0) + fprintf(stderr, "\n\tmysql_fetch_row() failed\n"); + else + fprintf(stdout, "\n\t%d %s returned\n", row_count, + row_count == 1 ? "row" : "rows"); + } return row_count; } @@ -470,34 +509,44 @@ int my_process_stmt_result(MYSQL_STMT *stmt) mysql_field_seek(result, 0); while (mysql_stmt_fetch(stmt) == 0) { - fputc('\t', stdout); - fputc('|', stdout); - + if (!opt_silent) + { + fputc('\t', stdout); + fputc('|', stdout); + } mysql_field_seek(result, 0); for (i= 0; i < field_count; i++) { field= mysql_fetch_field(result); - if (is_null[i]) - fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); - else if (length[i] == 0) + if (!opt_silent) { - data[i][0]= '\0'; /* unmodified buffer */ - fprintf(stdout, " %*s |", (int) field->max_length, data[i]); + if (is_null[i]) + fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); + else if (length[i] == 0) + { + data[i][0]= '\0'; /* unmodified buffer */ + fprintf(stdout, " %*s |", (int) field->max_length, data[i]); + } + else if (IS_NUM(field->type)) + fprintf(stdout, " %*s |", (int) field->max_length, data[i]); + else + fprintf(stdout, " %-*s |", (int) field->max_length, data[i]); } - else if (IS_NUM(field->type)) - fprintf(stdout, " %*s |", (int) field->max_length, data[i]); - else - fprintf(stdout, " %-*s |", (int) field->max_length, data[i]); } - fputc('\t', stdout); - fputc('\n', stdout); + if (!opt_silent) + { + fputc('\t', stdout); + fputc('\n', stdout); + } row_count++; } - if (row_count) - my_print_dashes(result); - - fprintf(stdout, "\n\t%d %s returned\n", row_count, - row_count == 1 ? "row" : "rows"); + if (!opt_silent) + { + if (row_count) + my_print_dashes(result); + fprintf(stdout, "\n\t%d %s returned\n", row_count, + row_count == 1 ? "row" : "rows"); + } mysql_free_result(result); return row_count; } @@ -511,7 +560,8 @@ int my_stmt_result(const char *buff) int row_count; int rc; - fprintf(stdout, "\n\n %s", buff); + if (!opt_silent) + fprintf(stdout, "\n\n %s", buff); stmt= mysql_simple_prepare(mysql, buff); check_stmt(stmt); @@ -537,7 +587,8 @@ static void verify_col_data(const char *table, const char *col, if (table && col) { strxmov(query, "SELECT ", col, " FROM ", table, " LIMIT 1", NullS); - fprintf(stdout, "\n %s", query); + if (!opt_silent) + fprintf(stdout, "\n %s", query); rc= mysql_query(mysql, query); myquery(rc); @@ -565,10 +616,12 @@ static void verify_col_data(const char *table, const char *col, /* Utility function to verify the field members */ static void verify_prepare_field(MYSQL_RES *result, - unsigned int no, const char *name, const char *org_name, - enum enum_field_types type, const char *table, - const char *org_table, const char *db, - unsigned long length, const char *def) + unsigned int no, const char *name, + const char *org_name, + enum enum_field_types type, + const char *table, + const char *org_table, const char *db, + unsigned long length, const char *def) { MYSQL_FIELD *field; @@ -577,23 +630,26 @@ static void verify_prepare_field(MYSQL_RES *result, fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***"); exit(1); } - fprintf(stdout, "\n field[%d]:", no); - fprintf(stdout, "\n name :`%s`\t(expected: `%s`)", field->name, name); - fprintf(stdout, "\n org_name :`%s`\t(expected: `%s`)", - field->org_name, org_name); - fprintf(stdout, "\n type :`%d`\t(expected: `%d`)", field->type, type); - fprintf(stdout, "\n table :`%s`\t(expected: `%s`)", - field->table, table); - fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)", - field->org_table, org_table); - fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); - fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)", - field->length, length); - fprintf(stdout, "\n maxlength:`%ld`", field->max_length); - fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); - fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", - field->def ? field->def : "(null)", def ? def: "(null)"); - fprintf(stdout, "\n"); + if (!opt_silent) + { + fprintf(stdout, "\n field[%d]:", no); + fprintf(stdout, "\n name :`%s`\t(expected: `%s`)", field->name, name); + fprintf(stdout, "\n org_name :`%s`\t(expected: `%s`)", + field->org_name, org_name); + fprintf(stdout, "\n type :`%d`\t(expected: `%d`)", field->type, type); + fprintf(stdout, "\n table :`%s`\t(expected: `%s`)", + field->table, table); + fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)", + field->org_table, org_table); + fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); + fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)", + field->length, length); + fprintf(stdout, "\n maxlength:`%ld`", field->max_length); + fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); + fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", + field->def ? field->def : "(null)", def ? def: "(null)"); + fprintf(stdout, "\n"); + } DIE_UNLESS(strcmp(field->name, name) == 0); DIE_UNLESS(strcmp(field->org_name, org_name) == 0); DIE_UNLESS(field->type == type); @@ -611,8 +667,9 @@ static void verify_prepare_field(MYSQL_RES *result, static void verify_param_count(MYSQL_STMT *stmt, long exp_count) { long param_count= mysql_stmt_param_count(stmt); - fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)", - param_count, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)", + param_count, exp_count); DIE_UNLESS(param_count == exp_count); } @@ -622,8 +679,9 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count) static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) { ulonglong affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", - affected_rows, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", + affected_rows, exp_count); DIE_UNLESS(affected_rows == exp_count); } @@ -633,7 +691,8 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) static void verify_affected_rows(ulonglong exp_count) { ulonglong affected_rows= mysql_affected_rows(mysql); - fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", + if (!opt_silent) + fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); DIE_UNLESS(affected_rows == exp_count); } @@ -644,8 +703,9 @@ static void verify_affected_rows(ulonglong exp_count) static void verify_field_count(MYSQL_RES *result, uint exp_count) { uint field_count= mysql_num_fields(result); - fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)", - field_count, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)", + field_count, exp_count); DIE_UNLESS(field_count == exp_count); } @@ -665,8 +725,9 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) myquery(rc); affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", - affected_rows, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", + affected_rows, exp_count); DIE_UNLESS(affected_rows == exp_count); mysql_stmt_close(stmt); @@ -722,7 +783,8 @@ static my_bool thread_query(char *query) my_bool error; error= 0; - fprintf(stdout, "\n in thread_query(%s)", query); + if (!opt_silent) + fprintf(stdout, "\n in thread_query(%s)", query); if (!(l_mysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -753,6 +815,7 @@ end: static void test_debug_example() { + DBUG_ENTER("fill_tables"); int rc; MYSQL_RES *result; @@ -1033,7 +1096,8 @@ static void test_prepare_field_result() my_print_result_metadata(result); - fprintf(stdout, "\n\n field attributes:\n"); + if (!opt_silent) + fprintf(stdout, "\n\n field attributes:\n"); verify_prepare_field(result, 0, "int_c", "int_c", MYSQL_TYPE_LONG, "t1", "test_prepare_field_result", current_db, 11, 0); verify_prepare_field(result, 1, "var_c", "var_c", MYSQL_TYPE_VAR_STRING, @@ -1207,17 +1271,20 @@ static void test_prepare() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n"); + if (!opt_silent) + { + fprintf(stdout, "\n"); - fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data, length[0]); - fprintf(stdout, "\n\t short : %d (%lu)", small_data, length[3]); - fprintf(stdout, "\n\t int : %d (%lu)", int_data, length[2]); - fprintf(stdout, "\n\t big : %lld (%lu)", big_data, length[4]); + fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data, length[0]); + fprintf(stdout, "\n\t short : %d (%lu)", small_data, length[3]); + fprintf(stdout, "\n\t int : %d (%lu)", int_data, length[2]); + fprintf(stdout, "\n\t big : %lld (%lu)", big_data, length[4]); - fprintf(stdout, "\n\t float : %f (%lu)", real_data, length[5]); - fprintf(stdout, "\n\t double : %f (%lu)", double_data, length[6]); + fprintf(stdout, "\n\t float : %f (%lu)", real_data, length[5]); + fprintf(stdout, "\n\t double : %f (%lu)", double_data, length[6]); - fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); + fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); + } DIE_UNLESS(tiny_data == o_tiny_data); DIE_UNLESS(is_null[0] == 0); @@ -1578,11 +1645,13 @@ static void test_fetch_null() rc++; for (i= 0; i < 10; i++) { - fprintf(stdout, "\n data[%d] : %s", i, - is_null[i] ? "NULL" : "NOT NULL"); + if (!opt_silent) + fprintf(stdout, "\n data[%d] : %s", i, + is_null[i] ? "NULL" : "NOT NULL"); DIE_UNLESS(is_null[i]); } - fprintf(stdout, "\n data[%d]: %d", i, nData); + if (!opt_silent) + fprintf(stdout, "\n data[%d]: %d", i, nData); DIE_UNLESS(nData == 1000 || nData == 88 || nData == 389789); DIE_UNLESS(is_null[i] == 0); DIE_UNLESS(length[i] == 4); @@ -2367,7 +2436,8 @@ static void test_long_data() /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); rc= mysql_commit(mysql); @@ -2450,7 +2520,8 @@ static void test_long_data_str() } /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); mysql_stmt_close(stmt); @@ -2541,7 +2612,8 @@ static void test_long_data_str1() /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); mysql_stmt_close(stmt); @@ -2692,7 +2764,8 @@ static void test_long_data_bin() } /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); mysql_stmt_close(stmt); @@ -2999,7 +3072,8 @@ static void test_bind_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1); DIE_UNLESS(nData == 10); DIE_UNLESS(strcmp(szData, "venu") == 0); DIE_UNLESS(length1 == 4); @@ -3007,7 +3081,8 @@ static void test_bind_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1); DIE_UNLESS(nData == 20); DIE_UNLESS(strcmp(szData, "MySQL") == 0); DIE_UNLESS(length1 == 5); @@ -3016,7 +3091,7 @@ static void test_bind_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - if (is_null[0]) + if (!opt_silent && is_null[0]) fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); DIE_UNLESS(is_null[0]); DIE_UNLESS(strcmp(szData, "monty") == 0); @@ -3114,19 +3189,21 @@ static void test_bind_result_ext() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data (tiny) : %d", t_data); - fprintf(stdout, "\n data (short) : %d", s_data); - fprintf(stdout, "\n data (int) : %d", i_data); - fprintf(stdout, "\n data (big) : %lld", b_data); + if (!opt_silent) + { + fprintf(stdout, "\n data (tiny) : %d", t_data); + fprintf(stdout, "\n data (short) : %d", s_data); + fprintf(stdout, "\n data (int) : %d", i_data); + fprintf(stdout, "\n data (big) : %lld", b_data); - fprintf(stdout, "\n data (float) : %f", f_data); - fprintf(stdout, "\n data (double) : %f", d_data); + fprintf(stdout, "\n data (float) : %f", f_data); + fprintf(stdout, "\n data (double) : %f", d_data); - fprintf(stdout, "\n data (str) : %s(%lu)", szData, szLength); - - bData[bLength]= '\0'; /* bData is binary */ - fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); + fprintf(stdout, "\n data (str) : %s(%lu)", szData, szLength); + bData[bLength]= '\0'; /* bData is binary */ + fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); + } DIE_UNLESS(t_data == 19); DIE_UNLESS(s_data == 2999); @@ -3234,16 +3311,19 @@ static void test_bind_result_ext1() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data (tiny) : %s(%lu)", t_data, length[0]); - fprintf(stdout, "\n data (short) : %f(%lu)", s_data, length[1]); - fprintf(stdout, "\n data (int) : %d(%lu)", i_data, length[2]); - fprintf(stdout, "\n data (big) : %d(%lu)", b_data, length[3]); + if (!opt_silent) + { + fprintf(stdout, "\n data (tiny) : %s(%lu)", t_data, length[0]); + fprintf(stdout, "\n data (short) : %f(%lu)", s_data, length[1]); + fprintf(stdout, "\n data (int) : %d(%lu)", i_data, length[2]); + fprintf(stdout, "\n data (big) : %d(%lu)", b_data, length[3]); - fprintf(stdout, "\n data (float) : %d(%lu)", f_data, length[4]); - fprintf(stdout, "\n data (double) : %s(%lu)", d_data, length[5]); + fprintf(stdout, "\n data (float) : %d(%lu)", f_data, length[4]); + fprintf(stdout, "\n data (double) : %s(%lu)", d_data, length[5]); - fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); - fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); + fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); + fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); + } DIE_UNLESS(strcmp(t_data, "120") == 0); DIE_UNLESS(i_data == 3999); @@ -3368,15 +3448,17 @@ static void bind_fetch(int row_count) rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n"); - fprintf(stdout, "\n tiny : %ld(%lu)", (ulong) i8_data, length[0]); - fprintf(stdout, "\n short : %ld(%lu)", (ulong) i16_data, length[1]); - fprintf(stdout, "\n int : %ld(%lu)", (ulong) i32_data, length[2]); - fprintf(stdout, "\n longlong : %ld(%lu)", (ulong) i64_data, length[3]); - fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]); - fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]); - fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]); - + if (!opt_silent) + { + fprintf(stdout, "\n"); + fprintf(stdout, "\n tiny : %ld(%lu)", (ulong) i8_data, length[0]); + fprintf(stdout, "\n short : %ld(%lu)", (ulong) i16_data, length[1]); + fprintf(stdout, "\n int : %ld(%lu)", (ulong) i32_data, length[2]); + fprintf(stdout, "\n longlong : %ld(%lu)", (ulong) i64_data, length[3]); + fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]); + fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]); + fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]); + } rc= 10+row_count; /* TINY */ @@ -3518,13 +3600,16 @@ static void test_fetch_date() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n date : %s(%lu)", date, d_length); - fprintf(stdout, "\n time : %s(%lu)", time, t_length); - fprintf(stdout, "\n ts : %s(%lu)", ts, ts_length); - fprintf(stdout, "\n year : %d(%lu)", year, y_length); - fprintf(stdout, "\n dt : %s(%lu)", dt, dt_length); - fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); - fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); + if (!opt_silent) + { + fprintf(stdout, "\n date : %s(%lu)", date, d_length); + fprintf(stdout, "\n time : %s(%lu)", time, t_length); + fprintf(stdout, "\n ts : %s(%lu)", ts, ts_length); + fprintf(stdout, "\n year : %d(%lu)", year, y_length); + fprintf(stdout, "\n dt : %s(%lu)", dt, dt_length); + fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); + fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); + } DIE_UNLESS(strcmp(date, "2002-01-02") == 0); DIE_UNLESS(d_length == 10); @@ -3851,7 +3936,8 @@ static void test_field_names() myheader("test_field_names"); - fprintf(stdout, "\n %d, %d, %d", MYSQL_TYPE_DECIMAL, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_ENUM); + if (!opt_silent) + fprintf(stdout, "\n %d, %d, %d", MYSQL_TYPE_DECIMAL, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_ENUM); rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names1"); myquery(rc); @@ -3902,7 +3988,8 @@ static void test_warnings() rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists"); myquery(rc); - fprintf(stdout, "\n total warnings: %d", mysql_warning_count(mysql)); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", mysql_warning_count(mysql)); rc= mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -4084,23 +4171,27 @@ static void test_field_flags() mytest(result); mysql_field_seek(result, 0); - fputc('\n', stdout); + if (!opt_silent) + fputc('\n', stdout); for(i= 0; i< mysql_num_fields(result); i++) { field= mysql_fetch_field(result); - fprintf(stdout, "\n field:%d", i); - if (field->flags & NOT_NULL_FLAG) - fprintf(stdout, "\n NOT_NULL_FLAG"); - if (field->flags & PRI_KEY_FLAG) - fprintf(stdout, "\n PRI_KEY_FLAG"); - if (field->flags & UNIQUE_KEY_FLAG) - fprintf(stdout, "\n UNIQUE_KEY_FLAG"); - if (field->flags & MULTIPLE_KEY_FLAG) - fprintf(stdout, "\n MULTIPLE_KEY_FLAG"); - if (field->flags & AUTO_INCREMENT_FLAG) - fprintf(stdout, "\n AUTO_INCREMENT_FLAG"); + if (!opt_silent) + { + fprintf(stdout, "\n field:%d", i); + if (field->flags & NOT_NULL_FLAG) + fprintf(stdout, "\n NOT_NULL_FLAG"); + if (field->flags & PRI_KEY_FLAG) + fprintf(stdout, "\n PRI_KEY_FLAG"); + if (field->flags & UNIQUE_KEY_FLAG) + fprintf(stdout, "\n UNIQUE_KEY_FLAG"); + if (field->flags & MULTIPLE_KEY_FLAG) + fprintf(stdout, "\n MULTIPLE_KEY_FLAG"); + if (field->flags & AUTO_INCREMENT_FLAG) + fprintf(stdout, "\n AUTO_INCREMENT_FLAG"); + } } mysql_free_result(result); } @@ -4119,7 +4210,8 @@ static void test_stmt_close() myheader("test_stmt_close"); - fprintf(stdout, "\n Establishing a test connection ..."); + if (!opt_silent) + fprintf(stdout, "\n Establishing a test connection ..."); if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -4132,7 +4224,8 @@ static void test_stmt_close() myerror("connection failed"); exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); /* set AUTOCOMMIT to ON*/ @@ -4169,7 +4262,8 @@ static void test_stmt_close() verify_param_count(stmt2, 1); rc= mysql_stmt_close(stmt1); - fprintf(stdout, "\n mysql_close_stmt(1) returned: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n mysql_close_stmt(1) returned: %d", rc); DIE_UNLESS(rc == 0); /* @@ -4203,7 +4297,8 @@ static void test_stmt_close() verify_st_affected_rows(stmt_x, 1); rc= mysql_stmt_close(stmt_x); - fprintf(stdout, "\n mysql_close_stmt(x) returned: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n mysql_close_stmt(x) returned: %d", rc); DIE_UNLESS( rc == 0); rc= mysql_query(mysql, "SELECT id FROM test_stmt_close"); @@ -4262,7 +4357,8 @@ static void test_set_variable() rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); - fprintf(stdout, "\n max_error_count(default): %d", get_count); + if (!opt_silent) + fprintf(stdout, "\n max_error_count(default): %d", get_count); def_count= get_count; DIE_UNLESS(strcmp(var, "max_error_count") == 0); @@ -4292,7 +4388,8 @@ static void test_set_variable() rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); - fprintf(stdout, "\n max_error_count : %d", get_count); + if (!opt_silent) + fprintf(stdout, "\n max_error_count : %d", get_count); DIE_UNLESS(get_count == set_count); rc= mysql_stmt_fetch(stmt1); @@ -4309,7 +4406,8 @@ static void test_set_variable() rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); - fprintf(stdout, "\n max_error_count(default): %d", get_count); + if (!opt_silent) + fprintf(stdout, "\n max_error_count(default): %d", get_count); DIE_UNLESS(get_count == set_count); rc= mysql_stmt_fetch(stmt1); @@ -4367,12 +4465,14 @@ static void test_insert_meta() mysql_field_seek(result, 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); + if (!opt_silent) + fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); DIE_UNLESS(strcmp(field->name, "col1") == 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); + if (!opt_silent) + fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); DIE_UNLESS(strcmp(field->name, "col3") == 0); field= mysql_fetch_field(result); @@ -4429,15 +4529,21 @@ static void test_update_meta() mysql_field_seek(result, 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + } DIE_UNLESS(strcmp(field->name, "col1") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + } DIE_UNLESS(strcmp(field->name, "col3") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0); @@ -4493,15 +4599,21 @@ static void test_select_meta() mysql_field_seek(result, 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + } DIE_UNLESS(strcmp(field->name, "col1") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + } DIE_UNLESS(strcmp(field->name, "col2") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0); @@ -4545,8 +4657,9 @@ static void test_func_fields() field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, - "test_dateformat"); + if (!opt_silent) + fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, + "test_dateformat"); DIE_UNLESS(strcmp(field->table, "test_dateformat") == 0); field= mysql_fetch_field(result); @@ -4563,7 +4676,8 @@ static void test_func_fields() field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, ""); + if (!opt_silent) + fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, ""); DIE_UNLESS(field->table[0] == '\0'); field= mysql_fetch_field(result); @@ -4580,8 +4694,11 @@ static void test_func_fields() field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); - fprintf(stdout, "\n field org name: `%s` (expected: `%s`)", field->org_name, ""); + if (!opt_silent) + { + printf("\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); + printf("\n field org name: `%s` (expected: `%s`)", field->org_name, ""); + } DIE_UNLESS(strcmp(field->name, "YEAR") == 0); DIE_UNLESS(field->org_name[0] == '\0'); @@ -4658,8 +4775,11 @@ static void test_multi_stmt() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); - fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + if (!opt_silent) + { + fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); + fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + } DIE_UNLESS(id == 10); DIE_UNLESS(strcmp(name, "mysql") == 0); @@ -4687,8 +4807,11 @@ static void test_multi_stmt() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); - fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + if (!opt_silent) + { + fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); + fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + } DIE_UNLESS(id == 10); DIE_UNLESS(strcmp(name, "updated") == 0); @@ -4762,12 +4885,14 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_error(mysql)); exit(1); } - fprintf(stdout, "\n prepare, insert successful"); + if (!opt_silent) + fprintf(stdout, "\n prepare, insert successful"); /* Get the parameter count from the statement */ param_count= mysql_stmt_param_count(stmt); - fprintf(stdout, "\n total parameters in insert: %d", param_count); + if (!opt_silent) + fprintf(stdout, "\n total parameters in insert: %d", param_count); if (param_count != 3) /* validate parameter count */ { fprintf(stderr, "\n invalid parameter count returned by MySQL"); @@ -4823,7 +4948,8 @@ static void test_manual_sample() /* Get the total rows affected */ affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: %lld", affected_rows); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: %lld", affected_rows); if (affected_rows != 1) /* validate affected rows */ { fprintf(stderr, "\n invalid affected rows by MySQL"); @@ -4847,7 +4973,8 @@ static void test_manual_sample() /* Get the total rows affected */ affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: %lld", affected_rows); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: %lld", affected_rows); if (affected_rows != 1) /* validate affected rows */ { fprintf(stderr, "\n invalid affected rows by MySQL"); @@ -4871,7 +4998,8 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_error(mysql)); exit(1); } - fprintf(stdout, "Success !!!"); + if (!opt_silent) + fprintf(stdout, "Success !!!"); } @@ -4993,13 +5121,14 @@ DROP TABLE IF EXISTS test_multi_tab"; for (count= 0 ; count < array_elements(rows) ; count++) { - fprintf(stdout, "\n Query %d: ", count); + if (!opt_silent) + fprintf(stdout, "\n Query %d: ", count); if ((result= mysql_store_result(mysql_local))) { (void) my_process_result_set(result); mysql_free_result(result); } - else + else if (!opt_silent) fprintf(stdout, "OK, %lld row(s) affected, %d warning(s)\n", mysql_affected_rows(mysql_local), mysql_warning_count(mysql_local)); @@ -5007,7 +5136,7 @@ DROP TABLE IF EXISTS test_multi_tab"; exp_value= (uint) mysql_affected_rows(mysql_local); if (rows[count] != exp_value) { - fprintf(stdout, "row %d had affected rows: %d, should be %d\n", + fprintf(stderr, "row %d had affected rows: %d, should be %d\n", count, exp_value, rows[count]); exit(1); } @@ -5083,7 +5212,7 @@ static void test_prepare_multi_statements() if (!(mysql_local= mysql_init(NULL))) { - fprintf(stdout, "\n mysql_init() failed"); + fprintf(stderr, "\n mysql_init() failed"); exit(1); } @@ -5091,7 +5220,7 @@ static void test_prepare_multi_statements() opt_password, current_db, opt_port, opt_unix_socket, CLIENT_MULTI_STATEMENTS))) { - fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local)); + fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local)); exit(1); } strmov(query, "select 1; select 'another value'"); @@ -5159,7 +5288,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 10); DIE_UNLESS(strcmp(szData, "venu") == 0); DIE_UNLESS(length1 == 4); @@ -5167,7 +5297,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 20); DIE_UNLESS(strcmp(szData, "mysql") == 0); DIE_UNLESS(length1 == 5); @@ -5176,7 +5307,7 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - if (is_null[0]) + if (!opt_silent && is_null[0]) fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); DIE_UNLESS(is_null[0]); DIE_UNLESS(strcmp(szData, "monty") == 0); @@ -5194,7 +5325,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 10); DIE_UNLESS(strcmp(szData, "venu") == 0); DIE_UNLESS(length1 == 4); @@ -5202,7 +5334,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 20); DIE_UNLESS(strcmp(szData, "mysql") == 0); DIE_UNLESS(length1 == 5); @@ -5211,7 +5344,7 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - if (is_null[0]) + if (!opt_silent && is_null[0]) fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); DIE_UNLESS(is_null[0]); DIE_UNLESS(strcmp(szData, "monty") == 0); @@ -5260,7 +5393,8 @@ static void test_store_result1() rc= 0; while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; - fprintf(stdout, "\n total rows: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows: %d", rc); DIE_UNLESS(rc == 3); rc= mysql_stmt_execute(stmt); @@ -5272,7 +5406,8 @@ static void test_store_result1() rc= 0; while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; - fprintf(stdout, "\n total rows: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows: %d", rc); DIE_UNLESS(rc == 3); mysql_stmt_close(stmt); @@ -5338,7 +5473,8 @@ static void test_store_result2() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", nData); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", nData); DIE_UNLESS(nData == 10); rc= mysql_stmt_fetch(stmt); @@ -5355,7 +5491,8 @@ static void test_store_result2() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", nData); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", nData); DIE_UNLESS(nData == 20); rc= mysql_stmt_fetch(stmt); @@ -5458,7 +5595,8 @@ static void test_subselect() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", id); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", id); DIE_UNLESS(id == 1); rc= mysql_stmt_fetch(stmt); @@ -5471,7 +5609,8 @@ static void test_subselect() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", id); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", id); DIE_UNLESS(id == 0); rc= mysql_stmt_fetch(stmt); @@ -5587,21 +5726,21 @@ static void test_bind_date_conv(uint row_count) rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n"); + if (!opt_silent) + fprintf(stdout, "\n"); for (i= 0; i < array_elements(bind); i++) { - fprintf(stdout, "\n"); - fprintf(stdout, " time[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", - i, tm[i].year, tm[i].month, tm[i].day, - tm[i].hour, tm[i].minute, tm[i].second, - tm[i].second_part); - + if (!opt_silent) + fprintf(stdout, "\ntime[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", + i, tm[i].year, tm[i].month, tm[i].day, + tm[i].hour, tm[i].minute, tm[i].second, + tm[i].second_part); DIE_UNLESS(tm[i].year == 0 || tm[i].year == year+count); DIE_UNLESS(tm[i].month == 0 || tm[i].month == month+count); DIE_UNLESS(tm[i].day == 0 || tm[i].day == day+count); DIE_UNLESS(tm[i].hour == 0 || tm[i].hour == hour+count); -#if 0 +#ifdef NOT_USED /* minute causes problems from date<->time, don't assert, instead validate separatly in another routine @@ -5856,7 +5995,8 @@ static void test_buffers() buffer[1]= 'X'; rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(buffer[0] == 'M'); DIE_UNLESS(buffer[1] == 'X'); DIE_UNLESS(length == 5); @@ -5867,7 +6007,8 @@ static void test_buffers() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(strncmp(buffer, "Database", 8) == 0); DIE_UNLESS(length == 8); @@ -5877,7 +6018,8 @@ static void test_buffers() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(strcmp(buffer, "Open-Source") == 0); DIE_UNLESS(length == 11); @@ -5887,7 +6029,8 @@ static void test_buffers() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(strncmp(buffer, "Popula", 6) == 0); DIE_UNLESS(length == 7); @@ -6018,7 +6161,8 @@ static void test_fetch_nobuffs() while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; - fprintf(stdout, "\n total rows : %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows : %d", rc); DIE_UNLESS(rc == 1); bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -6041,12 +6185,16 @@ static void test_fetch_nobuffs() while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) { rc++; - fprintf(stdout, "\n CURRENT_DATABASE(): %s", str[0]); - fprintf(stdout, "\n CURRENT_USER() : %s", str[1]); - fprintf(stdout, "\n CURRENT_DATE() : %s", str[2]); - fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); + if (!opt_silent) + { + fprintf(stdout, "\n CURRENT_DATABASE(): %s", str[0]); + fprintf(stdout, "\n CURRENT_USER() : %s", str[1]); + fprintf(stdout, "\n CURRENT_DATE() : %s", str[2]); + fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); + } } - fprintf(stdout, "\n total rows : %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows : %d", rc); DIE_UNLESS(rc == 1); mysql_stmt_close(stmt); @@ -6113,10 +6261,13 @@ static void test_ushort_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length); - fprintf(stdout, "\n ulong : %lu (%ld)", (ulong) long_value, l_length); - fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + if (!opt_silent) + { + fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n ulong : %lu (%ld)", (ulong) long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + } DIE_UNLESS(short_value == 35999); DIE_UNLESS(s_length == 2); @@ -6197,10 +6348,13 @@ static void test_sshort_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); - fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); - fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + if (!opt_silent) + { + fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + } DIE_UNLESS(short_value == -5999); DIE_UNLESS(s_length == 2); @@ -6281,10 +6435,13 @@ static void test_stiny_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); - fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); - fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + if (!opt_silent) + { + fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + } DIE_UNLESS(short_value == -128); DIE_UNLESS(s_length == 2); @@ -6373,7 +6530,8 @@ static void test_field_misc() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length); + if (!opt_silent) + fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); @@ -6493,7 +6651,8 @@ static void test_set_option() rc= mysql_query(mysql, "INSERT INTO test_limit VALUES(10), (20), (30), (40)"); myquery(rc); - fprintf(stdout, "\n with SQL_SELECT_LIMIT= 2 (direct)"); + if (!opt_silent) + fprintf(stdout, "\n with SQL_SELECT_LIMIT= 2 (direct)"); rc= mysql_query(mysql, "SELECT * FROM test_limit"); myquery(rc); @@ -6505,7 +6664,8 @@ static void test_set_option() mysql_free_result(result); - fprintf(stdout, "\n with SQL_SELECT_LIMIT=2 (prepare)"); + if (!opt_silent) + fprintf(stdout, "\n with SQL_SELECT_LIMIT=2 (prepare)"); stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_limit"); check_stmt(stmt); @@ -6518,7 +6678,8 @@ static void test_set_option() mysql_stmt_close(stmt); /* RESET the LIMIT the rows count to 0 */ - fprintf(stdout, "\n with SQL_SELECT_LIMIT=DEFAULT (prepare)"); + if (!opt_silent) + fprintf(stdout, "\n with SQL_SELECT_LIMIT=DEFAULT (prepare)"); rc= mysql_query(mysql, "SET OPTION SQL_SELECT_LIMIT=DEFAULT"); myquery(rc); @@ -6576,7 +6737,8 @@ static void test_prepare_grant() MYSQL *org_mysql= mysql, *lmysql; MYSQL_STMT *stmt; - fprintf(stdout, "\n Establishing a test connection ..."); + if (!opt_silent) + fprintf(stdout, "\n Establishing a test connection ..."); if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -6590,7 +6752,8 @@ static void test_prepare_grant() mysql_close(lmysql); exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO test_grant VALUES(NULL)"); @@ -6677,14 +6840,16 @@ static void test_frm_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data directory: %s", data_dir); + if (!opt_silent) + fprintf(stdout, "\n data directory: %s", data_dir); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); strxmov(test_frm, data_dir, "/", current_db, "/", "test_frm_bug.frm", NullS); - fprintf(stdout, "\n test_frm: %s", test_frm); + if (!opt_silent) + fprintf(stdout, "\n test_frm: %s", test_frm); if (!(test_file= my_fopen(test_frm, (int) (O_RDWR | O_CREAT), MYF(MY_WME)))) { @@ -6692,7 +6857,8 @@ static void test_frm_bug() fprintf(stdout, "\n test cancelled"); exit(1); } - fprintf(test_file, "this is a junk file for test"); + if (!opt_silent) + fprintf(test_file, "this is a junk file for test"); rc= mysql_query(mysql, "SHOW TABLE STATUS like 'test_frm_bug'"); myquery(rc); @@ -6708,7 +6874,8 @@ static void test_frm_bug() row= mysql_fetch_row(result); mytest(row); - fprintf(stdout, "\n Comment: %s", row[17]); + if (!opt_silent) + fprintf(stdout, "\n Comment: %s", row[17]); DIE_UNLESS(row[17] != 0); mysql_free_result(result); @@ -6771,7 +6938,8 @@ static void test_decimal_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s", data); + if (!opt_silent) + fprintf(stdout, "\n data: %s", data); DIE_UNLESS(strcmp(data, "8.00") == 0); rc= mysql_stmt_fetch(stmt); @@ -6788,7 +6956,8 @@ static void test_decimal_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s", data); + if (!opt_silent) + fprintf(stdout, "\n data: %s", data); DIE_UNLESS(strcmp(data, "5.61") == 0); rc= mysql_stmt_fetch(stmt); @@ -6812,7 +6981,8 @@ static void test_decimal_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s", data); + if (!opt_silent) + fprintf(stdout, "\n data: %s", data); DIE_UNLESS(strcmp(data, "10.22") == 0); rc= mysql_stmt_fetch(stmt); @@ -6852,8 +7022,9 @@ static void test_explain_bug() result= mysql_stmt_result_metadata(stmt); mytest(result); - fprintf(stdout, "\n total fields in the result: %d", - mysql_num_fields(result)); + if (!opt_silent) + fprintf(stdout, "\n total fields in the result: %d", + mysql_num_fields(result)); DIE_UNLESS(6 == mysql_num_fields(result)); verify_prepare_field(result, 0, "Field", "", MYSQL_TYPE_VAR_STRING, @@ -6889,8 +7060,9 @@ static void test_explain_bug() result= mysql_stmt_result_metadata(stmt); mytest(result); - fprintf(stdout, "\n total fields in the result: %d", - mysql_num_fields(result)); + if (!opt_silent) + fprintf(stdout, "\n total fields in the result: %d", + mysql_num_fields(result)); DIE_UNLESS(10 == mysql_num_fields(result)); verify_prepare_field(result, 0, "id", "", MYSQL_TYPE_LONGLONG, @@ -6911,8 +7083,12 @@ static void test_explain_bug() verify_prepare_field(result, 5, "key", "", MYSQL_TYPE_VAR_STRING, "", "", "", NAME_LEN, 0); - verify_prepare_field(result, 6, "key_len", "", MYSQL_TYPE_LONGLONG, - "", "", "", 3, 0); + verify_prepare_field(result, 6, "key_len", "", + (mysql_get_server_version(mysql) <= 50000 ? + MYSQL_TYPE_LONGLONG : MYSQL_TYPE_VAR_STRING), + "", "", "", + (mysql_get_server_version(mysql) <= 50000 ? 3 : 4096), + 0); verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, "", "", "", NAME_LEN*16, 0); @@ -6938,11 +7114,14 @@ static void test_explain_bug() static void check_errcode(const unsigned int err) { - if (mysql->server_version) - fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); - else - fprintf(stdout, "\n [MySQL]"); - fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + if (!opt_silent || mysql_errno(mysql) != err) + { + if (mysql->server_version) + fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); + else + fprintf(stdout, "\n [MySQL]"); + fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + } DIE_UNLESS(mysql_errno(mysql) == err); } @@ -6988,7 +7167,8 @@ static void test_drop_temp() { MYSQL *org_mysql= mysql, *lmysql; - fprintf(stdout, "\n Establishing a test connection ..."); + if (!opt_silent) + fprintf(stdout, "\n Establishing a test connection ..."); if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -7007,7 +7187,8 @@ static void test_drop_temp() mysql_close(lmysql); exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO t1 VALUES(10, 'C')"); @@ -7076,14 +7257,16 @@ static void test_cuted_rows() myquery(rc); count= mysql_warning_count(mysql); - fprintf(stdout, "\n total warnings: %d", count); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", count); DIE_UNLESS(count == 0); rc= mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); myquery(rc); count= mysql_warning_count(mysql); - fprintf(stdout, "\n total warnings: %d", count); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", count); DIE_UNLESS(count == 2); rc= mysql_query(mysql, "SHOW WARNINGS"); @@ -7100,7 +7283,8 @@ static void test_cuted_rows() myquery(rc); count= mysql_warning_count(mysql); - fprintf(stdout, "\n total warnings: %d", count); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", count); DIE_UNLESS(count == 2); rc= mysql_query(mysql, "SHOW WARNINGS"); @@ -7213,8 +7397,11 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n id : %d", id); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + { + fprintf(stdout, "\n id : %d", id); + fprintf(stdout, "\n name : %s(%ld)", data, length); + } DIE_UNLESS(id == 9876); DIE_UNLESS(length == 19); /* Due to VARCHAR(20) */ @@ -7223,7 +7410,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 1); DIE_UNLESS(strcmp(data, "'") == 0); @@ -7231,7 +7419,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 1); DIE_UNLESS(strcmp(data, "\"") == 0); @@ -7239,7 +7428,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 7); DIE_UNLESS(strcmp(data, "my\'sql\'") == 0); @@ -7247,7 +7437,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 7); /*DIE_UNLESS(strcmp(data, "my\"sql\"") == 0); */ @@ -7293,7 +7484,8 @@ static void test_nstmts() for (i= 0; i < total_stmts; i++) { - fprintf(stdout, "\r stmt: %d", i); + if (!opt_silent) + fprintf(stdout, "\r stmt: %d", i); strmov(query, "insert into test_nstmts values(?)"); stmt= mysql_simple_prepare(mysql, query); @@ -7320,7 +7512,8 @@ static void test_nstmts() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n total rows: %d", i); + if (!opt_silent) + fprintf(stdout, "\n total rows: %d", i); DIE_UNLESS( i == total_stmts); rc= mysql_stmt_fetch(stmt); @@ -7386,7 +7579,8 @@ static void test_fetch_seek() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); row= mysql_stmt_row_tell(stmt); @@ -7395,21 +7589,24 @@ static void test_fetch_seek() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); row= mysql_stmt_row_seek(stmt, row); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); mysql_stmt_data_seek(stmt, 0); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); @@ -7477,17 +7674,20 @@ static void test_fetch_offset() data[0]= '\0'; rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s (%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "abcd", 4) == 0 && length == 10); rc= mysql_stmt_fetch_column(stmt, bind, 0, 5); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s (%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "fg", 2) == 0 && length == 10); rc= mysql_stmt_fetch_column(stmt, bind, 0, 9); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %s (%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n col 0: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "j", 1) == 0 && length == 10); rc= mysql_stmt_fetch(stmt); @@ -7560,7 +7760,8 @@ static void test_fetch_column() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %d, %s", bc1, bc2); + if (!opt_silent) + fprintf(stdout, "\n row 0: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7571,13 +7772,15 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "venu", 4) == 0 && l2 == 4); c2[0]= '\0'; l2= 0; rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strcmp(c2, "venu") == 0 && l2 == 4); c1= 0; @@ -7589,13 +7792,15 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); DIE_UNLESS(c1 == 1 && l1 == 4); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d, %s", bc1, bc2); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7606,13 +7811,15 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "mysq", 4) == 0 && l2 == 5); c2[0]= '\0'; l2= 0; rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); DIE_UNLESS(strcmp(c2, "mysql") == 0 && l2 == 5); c1= 0; @@ -7624,7 +7831,8 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); DIE_UNLESS(c1 == 2 && l1 == 4); rc= mysql_stmt_fetch(stmt); @@ -7678,7 +7886,6 @@ static void test_mem_overun() MYSQL_RES *field_res; int rc, i, length; - myheader("test_mem_overun"); /* @@ -7728,7 +7935,8 @@ static void test_mem_overun() field_res= mysql_stmt_result_metadata(stmt); mytest(field_res); - fprintf(stdout, "\n total fields : %d", mysql_num_fields(field_res)); + if (!opt_silent) + fprintf(stdout, "\n total fields : %d", mysql_num_fields(field_res)); DIE_UNLESS( 1000 == mysql_num_fields(field_res)); rc= mysql_stmt_store_result(stmt); @@ -7795,7 +8003,8 @@ static void test_free_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1); rc= mysql_stmt_fetch(stmt); @@ -7810,7 +8019,8 @@ static void test_free_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); DIE_UNLESS(c1 == 2 && l2 == 4); rc= mysql_query(mysql, "drop table test_free_result"); @@ -7877,7 +8087,8 @@ static void test_free_store_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1); rc= mysql_stmt_fetch(stmt); @@ -7892,7 +8103,8 @@ static void test_free_store_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); DIE_UNLESS(c1 == 2 && l2 == 4); rc= mysql_stmt_free_result(stmt); @@ -7924,16 +8136,19 @@ static void test_sqlmode() /* PIPES_AS_CONCAT */ strcpy(query, "SET SQL_MODE= \"PIPES_AS_CONCAT\""); - fprintf(stdout, "\n With %s", query); + if (!opt_silent) + fprintf(stdout, "\n With %s", query); rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "INSERT INTO test_piping VALUES(?||?)"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); + if (!opt_silent) + fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); /* We need to bzero bind structure because mysql_stmt_bind_param checks all @@ -7963,21 +8178,25 @@ static void test_sqlmode() myquery(rc); strcpy(query, "SELECT connection_id ()"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt_r(stmt); /* ANSI */ strcpy(query, "SET SQL_MODE= \"ANSI\""); - fprintf(stdout, "\n With %s", query); + if (!opt_silent) + fprintf(stdout, "\n With %s", query); rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "INSERT INTO test_piping VALUES(?||?)"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); + if (!opt_silent) + fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); @@ -7991,7 +8210,8 @@ static void test_sqlmode() /* ANSI mode spaces ... */ strcpy(query, "SELECT connection_id ()"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); @@ -8003,18 +8223,21 @@ static void test_sqlmode() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); - fprintf(stdout, "\n returned 1 row\n"); + if (!opt_silent) + fprintf(stdout, "\n returned 1 row\n"); mysql_stmt_close(stmt); /* IGNORE SPACE MODE */ strcpy(query, "SET SQL_MODE= \"IGNORE_SPACE\""); - fprintf(stdout, "\n With %s", query); + if (!opt_silent) + fprintf(stdout, "\n With %s", query); rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "SELECT connection_id ()"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); @@ -8026,7 +8249,8 @@ static void test_sqlmode() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); - fprintf(stdout, "\n returned 1 row"); + if (!opt_silent) + fprintf(stdout, "\n returned 1 row"); mysql_stmt_close(stmt); } @@ -8118,7 +8342,8 @@ static void test_ts() sprintf(query, "SELECT a, b, c FROM test_ts WHERE %c=?", name); - fprintf(stdout, "\n %s", query); + if (!opt_silent) + fprintf(stdout, "\n %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); @@ -8131,7 +8356,8 @@ static void test_ts() while (mysql_stmt_fetch(stmt) == 0) row_count++; - fprintf(stdout, "\n returned '%d' rows", row_count); + if (!opt_silent) + fprintf(stdout, "\n returned '%d' rows", row_count); DIE_UNLESS(row_count == 2); mysql_stmt_close(stmt); } @@ -8273,7 +8499,8 @@ static void test_bug1946() check_stmt(stmt); rc= mysql_real_query(mysql, query, strlen(query)); DIE_UNLESS(rc != 0); - fprintf(stdout, "Got error (as expected):\n"); + if (!opt_silent) + fprintf(stdout, "Got error (as expected):\n"); myerror(NULL); mysql_stmt_close(stmt); @@ -8291,19 +8518,23 @@ static void test_parse_error_and_bad_length() rc= mysql_query(mysql, "SHOW DATABAAAA"); DIE_UNLESS(rc); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); rc= mysql_real_query(mysql, "SHOW DATABASES", 100); DIE_UNLESS(rc); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); stmt= mysql_simple_prepare(mysql, "SHOW DATABAAAA"); DIE_UNLESS(!stmt); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); stmt= mysql_stmt_init(mysql); DIE_UNLESS(stmt); rc= mysql_stmt_prepare(stmt, "SHOW DATABASES", 100); DIE_UNLESS(rc != 0); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); mysql_stmt_close(stmt); } @@ -8324,7 +8555,8 @@ static void test_bug2247() myheader("test_bug2247"); - fprintf(stdout, "\nChecking if stmt_affected_rows is not affected by\n" + if (!opt_silent) + fprintf(stdout, "\nChecking if stmt_affected_rows is not affected by\n" "mysql_query ... "); /* create table and insert few rows */ rc= mysql_query(mysql, drop); @@ -8381,7 +8613,8 @@ static void test_bug2247() DIE_UNLESS(mysql_stmt_affected_rows(stmt) == exp_count); mysql_stmt_close(stmt); - fprintf(stdout, "OK"); + if (!opt_silent) + fprintf(stdout, "OK"); } @@ -8659,7 +8892,8 @@ static void test_bug3117() check_execute(stmt, rc); DIE_UNLESS(is_null == 0 && lii == 1); - fprintf(stdout, "\n\tLAST_INSERT_ID()= 1 ok\n"); + if (!opt_silent) + fprintf(stdout, "\n\tLAST_INSERT_ID()= 1 ok\n"); rc= mysql_query(mysql, "INSERT INTO t1 VALUES (NULL)"); myquery(rc); @@ -8671,7 +8905,8 @@ static void test_bug3117() check_execute(stmt, rc); DIE_UNLESS(is_null == 0 && lii == 2); - fprintf(stdout, "\tLAST_INSERT_ID()= 2 ok\n"); + if (!opt_silent) + fprintf(stdout, "\tLAST_INSERT_ID()= 2 ok\n"); mysql_stmt_close(stmt); @@ -8821,7 +9056,8 @@ static void test_create_drop() { rc= mysql_stmt_execute(stmt_create); check_execute(stmt_create, rc); - fprintf(stdout, "created %i\n", i); + if (!opt_silent) + fprintf(stdout, "created %i\n", i); rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); @@ -8830,11 +9066,13 @@ static void test_create_drop() rc= mysql_stmt_execute(stmt_drop); check_execute(stmt_drop, rc); - fprintf(stdout, "droped %i\n", i); + if (!opt_silent) + fprintf(stdout, "droped %i\n", i); rc= mysql_stmt_execute(stmt_create_select); check_execute(stmt_create, rc); - fprintf(stdout, "created select %i\n", i); + if (!opt_silent) + fprintf(stdout, "created select %i\n", i); rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); @@ -8843,7 +9081,8 @@ static void test_create_drop() rc= mysql_stmt_execute(stmt_drop); check_execute(stmt_drop, rc); - fprintf(stdout, "droped %i\n", i); + if (!opt_silent) + fprintf(stdout, "droped %i\n", i); } mysql_stmt_close(stmt_create); @@ -8874,25 +9113,29 @@ static void test_rename() rc= mysql_stmt_execute(stmt); check_execute_r(stmt, rc); - fprintf(stdout, "rename without t3\n"); + if (!opt_silent) + fprintf(stdout, "rename without t3\n"); rc= mysql_query(mysql, "create table t3 (a int)"); myquery(rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - fprintf(stdout, "rename with t3\n"); + if (!opt_silent) + fprintf(stdout, "rename with t3\n"); rc= mysql_stmt_execute(stmt); check_execute_r(stmt, rc); - fprintf(stdout, "rename renamed\n"); + if (!opt_silent) + fprintf(stdout, "rename renamed\n"); rc= mysql_query(mysql, "rename table t2 to t1, t4 to t3"); myquery(rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - fprintf(stdout, "rename reverted\n"); + if (!opt_silent) + fprintf(stdout, "rename reverted\n"); mysql_stmt_close(stmt); @@ -8926,10 +9169,12 @@ static void test_do_set() { rc= mysql_stmt_execute(stmt_do); check_execute(stmt_do, rc); - fprintf(stdout, "do %i\n", i); + if (!opt_silent) + fprintf(stdout, "do %i\n", i); rc= mysql_stmt_execute(stmt_set); check_execute(stmt_set, rc); - fprintf(stdout, "set %i\n", i); + if (!opt_silent) + fprintf(stdout, "set %i\n", i); } mysql_stmt_close(stmt_do); @@ -8995,11 +9240,13 @@ static void test_multi() rc= mysql_stmt_execute(stmt_update); check_execute(stmt_update, rc); - fprintf(stdout, "update %ld\n", (long) param); + if (!opt_silent) + fprintf(stdout, "update %ld\n", (long) param); rc= mysql_stmt_execute(stmt_delete); check_execute(stmt_delete, rc); - fprintf(stdout, "delete %ld\n", (long) param); + if (!opt_silent) + fprintf(stdout, "delete %ld\n", (long) param); rc= mysql_stmt_execute(stmt_select1); check_execute(stmt_select1, rc); @@ -9055,7 +9302,8 @@ static void test_insert_select() { rc= mysql_stmt_execute(stmt_insert); check_execute(stmt_insert, rc); - fprintf(stdout, "insert %u\n", i); + if (!opt_silent) + fprintf(stdout, "insert %u\n", i); rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); @@ -9915,7 +10163,8 @@ static void test_bug3796() mysql_stmt_bind_result(stmt, bind); rc= mysql_stmt_fetch(stmt); - printf("Concat result: '%s'\n", out_buff); + if (!opt_silent) + printf("Concat result: '%s'\n", out_buff); check_execute(stmt, rc); strcpy(canonical_buff, concat_arg0); strcat(canonical_buff, "ONE"); @@ -9927,7 +10176,8 @@ static void test_bug3796() strcpy(canonical_buff + strlen(concat_arg0), "TWO"); DIE_UNLESS(strlen(canonical_buff) == out_length && strncmp(out_buff, canonical_buff, out_length) == 0); - printf("Concat result: '%s'\n", out_buff); + if (!opt_silent) + printf("Concat result: '%s'\n", out_buff); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); @@ -10001,12 +10251,15 @@ static void test_bug4026() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, - time_out.second_part); - printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, - datetime_out.day, datetime_out.hour, - datetime_out.minute, datetime_out.second, - datetime_out.second_part); + if (!opt_silent) + { + printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, + time_out.second_part); + printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, + datetime_out.day, datetime_out.hour, + datetime_out.minute, datetime_out.second, + datetime_out.second_part); + } DIE_UNLESS(memcmp(&time_in, &time_out, sizeof(time_in)) == 0); DIE_UNLESS(memcmp(&datetime_in, &datetime_out, sizeof(datetime_in)) == 0); mysql_stmt_close(stmt); @@ -10049,8 +10302,9 @@ static void test_bug4079() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc != 0 && rc != MYSQL_NO_DATA); - printf("Got error from mysql_stmt_fetch (as expected):\n%s\n", - mysql_stmt_error(stmt)); + if (!opt_silent) + printf("Got error from mysql_stmt_fetch (as expected):\n%s\n", + mysql_stmt_error(stmt)); /* buggy version of libmysql hanged up here */ mysql_stmt_close(stmt); } @@ -10144,13 +10398,16 @@ static void test_bug4030() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, - time_out.second_part); - printf("%d-%d-%d\n", date_out.year, date_out.month, date_out.day); - printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, - datetime_out.day, datetime_out.hour, - datetime_out.minute, datetime_out.second, - datetime_out.second_part); + if (!opt_silent) + { + printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, + time_out.second_part); + printf("%d-%d-%d\n", date_out.year, date_out.month, date_out.day); + printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, + datetime_out.day, datetime_out.hour, + datetime_out.minute, datetime_out.second, + datetime_out.second_part); + } DIE_UNLESS(memcmp(&time_canonical, &time_out, sizeof(time_out)) == 0); DIE_UNLESS(memcmp(&date_canonical, &date_out, sizeof(date_out)) == 0); DIE_UNLESS(memcmp(&datetime_canonical, &datetime_out, sizeof(datetime_out)) == 0); @@ -10200,7 +10457,8 @@ static void test_bug5126() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); DIE_UNLESS(c1 == 8386608 && c2 == 1); - printf("%ld, %ld\n", (long) c1, (long) c2); + if (!opt_silent) + printf("%ld, %ld\n", (long) c1, (long) c2); mysql_stmt_close(stmt); } @@ -10306,7 +10564,8 @@ static void test_bug5399() check_execute(*stmt, rc); mysql_stmt_bind_result(*stmt, bind); } - printf("%d statements prepared.\n", NUM_OF_USED_STMT); + if (!opt_silent) + printf("%d statements prepared.\n", NUM_OF_USED_STMT); for (stmt= stmt_list; stmt != stmt_list + NUM_OF_USED_STMT; ++stmt) { @@ -10478,15 +10737,17 @@ static void test_bug5194() rc= mysql_stmt_prepare(stmt, query, query_ptr - query); if (rc && nrows * COLUMN_COUNT > uint16_max) { - printf("Failed to prepare a statement with %d placeholders " - "(as expected).\n", nrows * COLUMN_COUNT); + if (!opt_silent) + printf("Failed to prepare a statement with %d placeholders " + "(as expected).\n", nrows * COLUMN_COUNT); break; } else check_execute(stmt, rc); - printf("Insert: query length= %d, row count= %d, param count= %lu\n", - strlen(query), nrows, mysql_stmt_param_count(stmt)); + if (!opt_silent) + printf("Insert: query length= %d, row count= %d, param count= %lu\n", + strlen(query), nrows, mysql_stmt_param_count(stmt)); /* bind the parameter array and execute the query */ rc= mysql_stmt_bind_param(stmt, bind); @@ -10522,7 +10783,10 @@ static void test_bug5315() rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc != 0); if (rc) - printf("Got error (as expected):\n%s", mysql_stmt_error(stmt)); + { + if (!opt_silent) + printf("Got error (as expected):\n%s", mysql_stmt_error(stmt)); + } /* check that connection is OK */ mysql_stmt_close(stmt); stmt= mysql_stmt_init(mysql); @@ -10570,8 +10834,11 @@ static void test_bug6049() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("Result from query: %s\n", row[0]); - printf("Result from prepared statement: %s\n", (char*) buffer); + if (!opt_silent) + { + printf("Result from query: %s\n", row[0]); + printf("Result from prepared statement: %s\n", (char*) buffer); + } DIE_UNLESS(strcmp(row[0], (char*) buffer) == 0); @@ -10616,8 +10883,11 @@ static void test_bug6058() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("Result from query: %s\n", row[0]); - printf("Result from prepared statement: %s\n", buffer); + if (!opt_silent) + { + printf("Result from query: %s\n", row[0]); + printf("Result from prepared statement: %s\n", buffer); + } DIE_UNLESS(strcmp(row[0], buffer) == 0); @@ -10656,17 +10926,17 @@ static void test_bug6046() stmt_text= "DROP TABLE IF EXISTS t1"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - stmt_text= "CREATE TABLE a1 (a int, b int)"; + stmt_text= "CREATE TABLE t1 (a int, b int)"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - stmt_text= "INSERT INTO a1 VALUES (1,1),(2,2),(3,1),(4,2)"; + stmt_text= "INSERT INTO t1 VALUES (1,1),(2,2),(3,1),(4,2)"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); stmt= mysql_stmt_init(mysql); - stmt_text= "SELECT a1.a FROM a1 NATURAL JOIN a1 as X1 " - "WHERE a1.b > ? ORDER BY a1.a"; + stmt_text= "SELECT t1.a FROM t1 NATURAL JOIN t1 as X1 " + "WHERE t1.b > ? ORDER BY t1.a"; rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); @@ -10772,22 +11042,25 @@ static void test_bug6096() /* Print out and check the metadata */ - printf(" ---------------------------------------------------------------\n"); - printf(" | Metadata \n"); - printf(" ---------------------------------------------------------------\n"); - printf(" | Query | Prepared statement \n"); - printf(" ---------------------------------------------------------------\n"); - printf(" field name | length | max_length | length | max_length \n"); - printf(" ---------------------------------------------------------------\n"); - - for (i= 0; i < query_field_count; ++i) + if (!opt_silent) { - MYSQL_FIELD *f1= &query_field_list[i], *f2= &stmt_field_list[i]; - printf(" %-11s | %9lu | %10lu | %9lu | %10lu \n", - f1->name, f1->length, f1->max_length, f2->length, f2->max_length); - DIE_UNLESS(f1->length == f2->length); + printf(" ------------------------------------------------------------\n"); + printf(" | Metadata \n"); + printf(" ------------------------------------------------------------\n"); + printf(" | Query | Prepared statement \n"); + printf(" ------------------------------------------------------------\n"); + printf(" field name | length | max_length | length | max_length\n"); + printf(" ------------------------------------------------------------\n"); + + for (i= 0; i < query_field_count; ++i) + { + MYSQL_FIELD *f1= &query_field_list[i], *f2= &stmt_field_list[i]; + printf(" %-11s | %9lu | %10lu | %9lu | %10lu \n", + f1->name, f1->length, f1->max_length, f2->length, f2->max_length); + DIE_UNLESS(f1->length == f2->length); + } + printf(" ---------------------------------------------------------------\n"); } - printf(" ---------------------------------------------------------------\n"); /* Bind and fetch the data */ @@ -10842,6 +11115,8 @@ static struct my_option client_test_long_options[] = #endif {"port", 'P', "Port number to use for connection", (char **) &opt_port, (char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"silent", 's', "Be more silent", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, + 0}, {"socket", 'S', "Socket file to use for connection", (char **) &opt_unix_socket, (char **) &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"testcase", 'c', "May disable some code when runs as mysql-test-run testcase.", @@ -10851,36 +11126,25 @@ static struct my_option client_test_long_options[] = { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void client_test_print_version(void) -{ - fprintf(stdout, "%s Distrib %s, for %s (%s)\n\n", - my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); -} - static void usage(void) { - /* - * show the usage string when the user asks for this - */ + /* show the usage string when the user asks for this */ putc('\n', stdout); - puts("***********************************************************************\n"); - puts(" Test for client-server protocol 4.1"); - puts(" By Monty & Venu \n"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software, "); - puts("and you are welcome to modify and redistribute it under the GPL license\n"); - puts(" Copyright (C) 1995-2003 MySQL AB "); - puts("-----------------------------------------------------------------------\n"); - client_test_print_version(); - fprintf(stdout, "Usage: %s [OPTIONS]\n\n", my_progname); - + printf("%s Ver %s Distrib %s, for %s (%s)\n", + my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); + puts("By Monty, Venu, Kent and others\n"); + printf("\ +Copyright (C) 2002-2004 MySQL AB\n\ +This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ +and you are welcome to modify and redistribute it under the GPL license\n"); + printf("Usage: %s [OPTIONS]\n", my_progname); my_print_help(client_test_long_options); print_defaults("my", client_test_load_default_groups); my_print_variables(client_test_long_options); - - puts("***********************************************************************\n"); } + static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) @@ -10905,6 +11169,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else tty_password= 1; break; + case 's': + if (argument == disabled_my_option) + opt_silent= 0; + else + opt_silent++; + break; case '?': case 'I': /* Info */ usage(); @@ -10933,14 +11203,17 @@ static void get_options(int argc, char **argv) static void print_test_output() { - fprintf(stdout, "\n\n"); - fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)", - test_count-1, opt_count); - fprintf(stdout, "\n Total execution time: %g SECS", total_time); - if (opt_count > 1) - fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count); + if (opt_silent < 3) + { + fprintf(stdout, "\n\n"); + fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)", + test_count-1, opt_count); + fprintf(stdout, "\n Total execution time: %g SECS", total_time); + if (opt_count > 1) + fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count); - fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); + fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); + } } From ded5595cb2d21ffbb886b03767084f1d4a81a231 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Tue, 2 Nov 2004 19:40:10 +0000 Subject: [PATCH 053/101] add compile flad -DSNPRINTF_RETURN_TRUNC on hp ux 11 remove compiler warning patch for my_vsnprintf not dully implemented patch for platfroms that return -1 on snprintf overflow compile fix for hpux --- configure.in | 4 ++-- ndb/src/common/editline/sysunix.c | 2 +- ndb/src/common/util/basestring_vsnprintf.c | 8 ++++++-- ndb/src/kernel/vm/Emulator.hpp | 1 + ndb/src/mgmsrv/Services.cpp | 22 ++++++++-------------- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 6 ++---- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/configure.in b/configure.in index d63859720a3..71adaa747f5 100644 --- a/configure.in +++ b/configure.in @@ -1039,8 +1039,8 @@ case $SYSTEM_TYPE in ;; *hpux11.*) echo "Enabling workarounds for hpux 11" - CFLAGS="$CFLAGS -DHPUX11 -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" - CXXFLAGS="$CXXFLAGS -DHPUX11 -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" + CFLAGS="$CFLAGS -DHPUX11 -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" + CXXFLAGS="$CXXFLAGS -DHPUX11 -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" if test "$with_named_thread" = "no" then echo "Using --with-named-thread=-lpthread" diff --git a/ndb/src/common/editline/sysunix.c b/ndb/src/common/editline/sysunix.c index 1339e5769e2..d7437f6a9c7 100644 --- a/ndb/src/common/editline/sysunix.c +++ b/ndb/src/common/editline/sysunix.c @@ -139,7 +139,7 @@ rl_add_slash(char *path, char *p, size_t p_len) struct stat Sb; if (stat(path, &Sb) >= 0) { - int len= strlen(p); + size_t len= strlen(p); if (len+1 < p_len) { p[len]= S_ISDIR(Sb.st_mode) ? '/' : ' '; p[len+1]= 0; diff --git a/ndb/src/common/util/basestring_vsnprintf.c b/ndb/src/common/util/basestring_vsnprintf.c index c96d1a300e1..7307279f345 100644 --- a/ndb/src/common/util/basestring_vsnprintf.c +++ b/ndb/src/common/util/basestring_vsnprintf.c @@ -35,7 +35,11 @@ basestring_snprintf(char *str, size_t size, const char *format, ...) #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) #else #define SNPRINTF_RETURN_TRUNC - #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d) + /* #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d) + * we would like to use my_vsnprintf but it does not have enough features + * Let's hope vsnprintf works anyways + */ + #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) extern int my_vsnprintf(char *str, size_t size, const char *format, va_list ap); #endif #ifdef SNPRINTF_RETURN_TRUNC @@ -46,7 +50,7 @@ basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap) { int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap); #ifdef SNPRINTF_RETURN_TRUNC - if (ret == size-1) { + if (ret == size-1 || ret == -1) { ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf, sizeof(basestring_vsnprintf_buf), format, ap); diff --git a/ndb/src/kernel/vm/Emulator.hpp b/ndb/src/kernel/vm/Emulator.hpp index bd240f8679b..b3c64830802 100644 --- a/ndb/src/kernel/vm/Emulator.hpp +++ b/ndb/src/kernel/vm/Emulator.hpp @@ -25,6 +25,7 @@ // //=========================================================================== #include +#include extern class JobTable globalJobTable; extern class TimeQueue globalTimeQueue; diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 5b552836955..2672d8c9d4b 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -773,8 +773,10 @@ MgmApiSession::setClusterLogLevel(Parser::Context &, /* XXX should use constants for this value */ if(level > 15) { - errorString.assign("Invalied loglevel"); - goto error; + m_output->println("set cluster loglevel reply"); + m_output->println("result: Invalid loglevel"); + m_output->println(""); + return; } EventSubscribeReq req; @@ -786,11 +788,6 @@ MgmApiSession::setClusterLogLevel(Parser::Context &, m_output->println("set cluster loglevel reply"); m_output->println("result: Ok"); m_output->println(""); - return; -error: - m_output->println("set cluster loglevel reply"); - m_output->println("result: %s", errorString.c_str()); - m_output->println(""); } void @@ -807,8 +804,10 @@ MgmApiSession::setLogLevel(Parser::Context &, /* XXX should use constants for this value */ if(level > 15) { - errorString.assign("Invalied loglevel"); - goto error; + m_output->println("set loglevel reply"); + m_output->println("result: Invalid loglevel", errorString.c_str()); + m_output->println(""); + return; } EventSubscribeReq req; @@ -820,11 +819,6 @@ MgmApiSession::setLogLevel(Parser::Context &, m_output->println("set loglevel reply"); m_output->println("result: Ok"); m_output->println(""); - return; - error: - m_output->println("set loglevel reply"); - m_output->println("result: %s", errorString.c_str()); - m_output->println(""); } void diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 76854cabcd7..304d1b904d4 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -47,15 +47,13 @@ * Column */ NdbColumnImpl::NdbColumnImpl() - : NdbDictionary::Column(* this), m_facade(this), - m_attrId(-1) + : NdbDictionary::Column(* this), m_attrId(-1), m_facade(this) { init(); } NdbColumnImpl::NdbColumnImpl(NdbDictionary::Column & f) - : NdbDictionary::Column(* this), m_facade(&f), - m_attrId(-1) + : NdbDictionary::Column(* this), m_attrId(-1), m_facade(&f) { init(); } From dd5486a5999d27c204e128aaafb3cb3f9076372b Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 2 Nov 2004 22:46:55 +0100 Subject: [PATCH 054/101] one more name clash in public includes fixed http://lists.mysql.com/internals/18149 --- include/my_list.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/my_list.h b/include/my_list.h index 789bbb50f97..f786621e311 100644 --- a/include/my_list.h +++ b/include/my_list.h @@ -33,8 +33,8 @@ extern LIST *list_delete(LIST *root,LIST *element); extern LIST *list_cons(void *data,LIST *root); extern LIST *list_reverse(LIST *root); extern void list_free(LIST *root,unsigned int free_data); -extern unsigned int list_length(LIST *list); -extern int list_walk(LIST *list,list_walk_action action,gptr argument); +extern unsigned int list_length(LIST *); +extern int list_walk(LIST *,list_walk_action action,gptr argument); #define rest(a) ((a)->next) #define list_push(a,b) (a)=list_cons((b),(a)) From 4650f0acab425e08b5f3f7f7bee9612f81387b6e Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 2 Nov 2004 23:34:40 +0100 Subject: [PATCH 055/101] bad automerge (?) fixed --- tests/client_test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/client_test.c b/tests/client_test.c index 70e1b26aeaa..227f7e29ef2 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -815,7 +815,6 @@ end: static void test_debug_example() { - DBUG_ENTER("fill_tables"); int rc; MYSQL_RES *result; From 45451568bfabaaf42d5f55c05c57a716ceb42798 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Wed, 3 Nov 2004 15:22:33 +0400 Subject: [PATCH 056/101] opt_range.cc, range.result, range.test: Bug #6045: Binary Comparison regression in MySQL 4.1 Binary searches didn't use a case insensitive index, now they do. --- mysql-test/r/range.result | 16 ++++++++++++++++ mysql-test/t/range.test | 14 ++++++++++++++ sql/opt_range.cc | 15 ++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 4ca96316800..17ed9513653 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -561,3 +561,19 @@ select count(*) from t1 where x = 18446744073709551601; count(*) 1 drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 11 const 2 Using where +explain select * from t1 where a=binary 'aaa'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 11 NULL 2 Using where +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 11 NULL 2 Using where +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 9 Using where diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index cd6620f7126..44f55da5722 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -431,3 +431,17 @@ select count(*) from t1 where x = 18446744073709551601; drop table t1; +# +# Bug #6045: Binary Comparison regression in MySQL 4.1 +# Binary searches didn't use a case insensitive index. +# +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +# all these three can be optimized +explain select * from t1 where a='aaa'; +explain select * from t1 where a=binary 'aaa'; +explain select * from t1 where a='aaa' collate latin1_bin; +# this one cannot: +explain select * from t1 where a='aaa' collate latin1_german1_ci; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 541acc69ec7..c9528af7d98 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1013,13 +1013,22 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, } /* - We can't use an index when comparing strings of - different collations + 1. Usually we can't use an index if the column collation + differ from the operation collation. + + 2. However, we can reuse a case insensitive index for + the binary searches: + + WHERE latin1_swedish_ci_column = 'a' COLLATE lati1_bin; + + WHERE latin1_swedish_ci_colimn = BINARY 'a ' + */ if (field->result_type() == STRING_RESULT && value->result_type() == STRING_RESULT && key_part->image_type == Field::itRAW && - ((Field_str*)field)->charset() != conf_func->compare_collation()) + ((Field_str*)field)->charset() != conf_func->compare_collation() && + !(conf_func->compare_collation()->state & MY_CS_BINSORT)) DBUG_RETURN(0); if (type == Item_func::LIKE_FUNC) From 2356c9f9959d2487dbf615d4a064df4f6c77b792 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 3 Nov 2004 11:43:46 +0000 Subject: [PATCH 057/101] mysql-master-run does not need to start second mysqld with innodb, add --skip-innodb --- mysql-test/mysql-test-run.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 6b40fb3e974..65be9bf9c8e 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -994,9 +994,11 @@ start_master() if [ -n "$1" ] ; then id=`$EXPR $1 + 101`; this_master_myport=`$EXPR $MASTER_MYPORT + $1` + NOT_FIRST_MASTER_EXTRA_OPTS="--skip-innodb" else id=1; this_master_myport=$MASTER_MYPORT + NOT_FIRST_MASTER_EXTRA_OPTS="" fi if [ -z "$DO_BENCH" ] then @@ -1020,7 +1022,8 @@ start_master() --open-files-limit=1024 \ $MASTER_40_ARGS \ $SMALL_SERVER \ - $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT" + $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \ + $NOT_FIRST_MASTER_EXTRA_OPTS" else master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin$1 \ --server-id=$id --rpl-recovery-rank=1 \ @@ -1039,7 +1042,8 @@ start_master() --innodb_data_file_path=ibdata1:50M \ $MASTER_40_ARGS \ $SMALL_SERVER \ - $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT" + $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \ + $NOT_FIRST_MASTER_EXTRA_OPTS" fi CUR_MYERR=$MASTER_MYERR From 0fd9d08c0189592edd8fb1651f15ceb48f3c08d6 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 3 Nov 2004 14:34:21 +0000 Subject: [PATCH 058/101] changed to use the future-proof option to ndb_mgmd there was a clash in using -c, added -f as the future proof switch --- mysql-test/ndb/ndbcluster.sh | 2 +- ndb/src/mgmsrv/main.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index 294d32ac4be..9d83a291f3d 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -146,7 +146,7 @@ fi rm -f "$cfgfile" 2>&1 | cat > /dev/null rm -f "$fs_ndb/$cfgfile" 2>&1 | cat > /dev/null -if ( cd "$fs_ndb" ; $exec_mgmtsrvr -c config.ini ) ; then :; else +if ( cd "$fs_ndb" ; $exec_mgmtsrvr -f config.ini ) ; then :; else echo "Unable to start $exec_mgmtsrvr from `pwd`" exit 1 fi diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index c1876f68ea2..15767e4766d 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -101,8 +101,23 @@ static char *opt_connect_str= 0; static struct my_option my_long_options[] = { - NDB_STD_OPTS("ndb_mgmd"), - { "config-file", 'c', "Specify cluster configuration file", +#ifndef DBUG_OFF + { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", + 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, +#endif + { "usage", '?', "Display this help and exit.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "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 }, + { "connect-string", 1023, + "Set connect string for connecting to ndb_mgmd. " + "=\"host=[;nodeid=]\". " + "Overides specifying entries in NDB_CONNECTSTRING and config file", + (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "config-file", 'f', "Specify cluster configuration file", (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)", @@ -120,6 +135,11 @@ static struct my_option my_long_options[] = { "nodaemon", 258, "Don't run as daemon, but don't read from stdin", (gptr*) &glob.non_interactive, (gptr*) &glob.non_interactive, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "config-file", 'c', + "-c provided for backwards compatability, will be removed in 5.0." + " Use -f instead", + (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void short_usage_sub(void) @@ -148,6 +168,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'V': print_version(); exit(0); + case 'c': + printf("Warning: -c will be removed in 5.0, use -f instead\n"); + break; case '?': usage(); exit(0); From 700da5791803d49291ab1729dc4dc9053b16d72f Mon Sep 17 00:00:00 2001 From: "mskold@mysql.com" <> Date: Wed, 3 Nov 2004 15:53:26 +0100 Subject: [PATCH 059/101] Fix for bug#6398 update of primary key fails --- mysql-test/r/ndb_basic.result | 5 ++ mysql-test/t/ndb_basic.test | 2 + sql/ha_ndbcluster.cc | 155 ++++++++++++++++++---------------- sql/ha_ndbcluster.h | 23 ++--- 4 files changed, 99 insertions(+), 86 deletions(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 604084a72c2..ba8ee820ad9 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -40,6 +40,11 @@ SELECT * FROM t1 ORDER BY pk1; pk1 attr1 attr2 attr3 3 1 NULL 9412 9412 9413 17 9413 +UPDATE t1 SET pk1=4 WHERE pk1 = 3; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +4 1 NULL 9412 +9412 9413 17 9413 DELETE FROM t1; SELECT * FROM t1; pk1 attr1 attr2 attr3 diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index f5bed3dcdff..b62d2a8e0e1 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -36,6 +36,8 @@ UPDATE t1 SET pk1=2 WHERE attr1=1; SELECT * FROM t1 ORDER BY pk1; UPDATE t1 SET pk1=pk1 + 1; SELECT * FROM t1 ORDER BY pk1; +UPDATE t1 SET pk1=4 WHERE pk1 = 3; +SELECT * FROM t1 ORDER BY pk1; # Delete the record DELETE FROM t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 838cf69855a..ec00f09e5c5 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -324,7 +324,7 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans) DBUG_PRINT("info", ("transformed ndbcluster error %d to mysql error %d", err.code, res)); if (res == HA_ERR_FOUND_DUPP_KEY) - dupkey= table->primary_key; + m_dupkey= table->primary_key; DBUG_RETURN(res); } @@ -551,7 +551,7 @@ int ha_ndbcluster::get_ndb_blobs_value(NdbBlob *last_ndb_blob) blob_size+= 8 - blob_size % 8; if (loop == 1) { - char *buf= blobs_buffer + offset; + char *buf= m_blobs_buffer + offset; uint32 len= 0xffffffff; // Max uint32 DBUG_PRINT("value", ("read blob ptr=%x len=%u", (uint)buf, (uint)blob_len)); @@ -563,15 +563,15 @@ int ha_ndbcluster::get_ndb_blobs_value(NdbBlob *last_ndb_blob) offset+= blob_size; } } - if (loop == 0 && offset > blobs_buffer_size) + if (loop == 0 && offset > m_blobs_buffer_size) { - my_free(blobs_buffer, MYF(MY_ALLOW_ZERO_PTR)); - blobs_buffer_size= 0; + my_free(m_blobs_buffer, MYF(MY_ALLOW_ZERO_PTR)); + m_blobs_buffer_size= 0; DBUG_PRINT("value", ("allocate blobs buffer size %u", offset)); - blobs_buffer= my_malloc(offset, MYF(MY_WME)); - if (blobs_buffer == NULL) + m_blobs_buffer= my_malloc(offset, MYF(MY_WME)); + if (m_blobs_buffer == NULL) DBUG_RETURN(-1); - blobs_buffer_size= offset; + m_blobs_buffer_size= offset; } } DBUG_RETURN(0); @@ -854,7 +854,7 @@ int ha_ndbcluster::get_ndb_lock_type(enum thr_lock_type type) { if (type >= TL_WRITE_ALLOW_WRITE) return NdbOperation::LM_Exclusive; - else if (uses_blob_value(retrieve_all_fields)) + else if (uses_blob_value(m_retrieve_all_fields)) return NdbOperation::LM_Read; else return NdbOperation::LM_CommittedRead; @@ -1018,7 +1018,7 @@ int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf) { Field *field= table->field[i]; if ((thd->query_id == field->query_id) || - retrieve_all_fields) + m_retrieve_all_fields) { if (get_ndb_value(op, field, i, buf)) ERR_RETURN(trans->getNdbError()); @@ -1055,7 +1055,7 @@ int ha_ndbcluster::complemented_pk_read(const byte *old_data, byte *new_data) THD *thd= current_thd; DBUG_ENTER("complemented_pk_read"); - if (retrieve_all_fields) + if (m_retrieve_all_fields) // We have allready retrieved all fields, nothing to complement DBUG_RETURN(0); @@ -1192,12 +1192,12 @@ inline int ha_ndbcluster::next_result(byte *buf) /* We can only handle one tuple with blobs at a time. */ - if (ops_pending && blobs_pending) + if (m_ops_pending && m_blobs_pending) { if (execute_no_commit(this,trans) != 0) DBUG_RETURN(ndb_err(trans)); - ops_pending= 0; - blobs_pending= FALSE; + m_ops_pending= 0; + m_blobs_pending= FALSE; } check= cursor->nextResult(contact_ndb); if (check == 0) @@ -1219,8 +1219,8 @@ inline int ha_ndbcluster::next_result(byte *buf) all pending update or delete operations should be sent to NDB */ - DBUG_PRINT("info", ("ops_pending: %d", ops_pending)); - if (ops_pending) + DBUG_PRINT("info", ("ops_pending: %d", m_ops_pending)); + if (m_ops_pending) { if (current_thd->transaction.on) { @@ -1234,7 +1234,7 @@ inline int ha_ndbcluster::next_result(byte *buf) int res= trans->restart(); DBUG_ASSERT(res == 0); } - ops_pending= 0; + m_ops_pending= 0; } contact_ndb= (check == 2); @@ -1423,7 +1423,7 @@ int ha_ndbcluster::define_read_attrs(byte* buf, NdbOperation* op) Field *field= table->field[i]; if ((thd->query_id == field->query_id) || (field->flags & PRI_KEY_FLAG) || - retrieve_all_fields) + m_retrieve_all_fields) { if (get_ndb_value(op, field, i, buf)) ERR_RETURN(op->getNdbError()); @@ -1666,9 +1666,9 @@ int ha_ndbcluster::write_row(byte *record) if (has_auto_increment) { - skip_auto_increment= FALSE; + m_skip_auto_increment= FALSE; update_auto_increment(); - skip_auto_increment= !auto_increment_column_changed; + m_skip_auto_increment= !auto_increment_column_changed; } if ((res= set_primary_key(op))) @@ -1683,7 +1683,7 @@ int ha_ndbcluster::write_row(byte *record) if (!(field->flags & PRI_KEY_FLAG) && set_ndb_value(op, field, i, &set_blob_value)) { - skip_auto_increment= TRUE; + m_skip_auto_increment= TRUE; ERR_RETURN(op->getNdbError()); } } @@ -1695,25 +1695,25 @@ int ha_ndbcluster::write_row(byte *record) to NoCommit the transaction between each row. Find out how this is detected! */ - rows_inserted++; + m_rows_inserted++; no_uncommitted_rows_update(1); - bulk_insert_not_flushed= TRUE; - if ((rows_to_insert == 1) || - ((rows_inserted % bulk_insert_rows) == 0) || + m_bulk_insert_not_flushed= TRUE; + if ((m_rows_to_insert == 1) || + ((m_rows_inserted % m_bulk_insert_rows) == 0) || set_blob_value) { THD *thd= current_thd; // Send rows to NDB DBUG_PRINT("info", ("Sending inserts to NDB, "\ "rows_inserted:%d, bulk_insert_rows: %d", - (int)rows_inserted, (int)bulk_insert_rows)); + (int)m_rows_inserted, (int)m_bulk_insert_rows)); - bulk_insert_not_flushed= FALSE; + m_bulk_insert_not_flushed= FALSE; if (thd->transaction.on) { if (execute_no_commit(this,trans) != 0) { - skip_auto_increment= TRUE; + m_skip_auto_increment= TRUE; no_uncommitted_rows_execute_failure(); DBUG_RETURN(ndb_err(trans)); } @@ -1722,7 +1722,7 @@ int ha_ndbcluster::write_row(byte *record) { if (execute_commit(this,trans) != 0) { - skip_auto_increment= TRUE; + m_skip_auto_increment= TRUE; no_uncommitted_rows_execute_failure(); DBUG_RETURN(ndb_err(trans)); } @@ -1730,7 +1730,7 @@ int ha_ndbcluster::write_row(byte *record) DBUG_ASSERT(res == 0); } } - if ((has_auto_increment) && (skip_auto_increment)) + if ((has_auto_increment) && (m_skip_auto_increment)) { Uint64 next_val= (Uint64) table->next_number_field->val_int() + 1; DBUG_PRINT("info", @@ -1740,7 +1740,7 @@ int ha_ndbcluster::write_row(byte *record) DBUG_PRINT("info", ("Setting next auto increment value to %u", next_val)); } - skip_auto_increment= TRUE; + m_skip_auto_increment= TRUE; DBUG_RETURN(0); } @@ -1820,7 +1820,9 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) } // Delete old row DBUG_PRINT("info", ("insert succeded")); + m_primary_key_update= TRUE; delete_res= delete_row(old_data); + m_primary_key_update= FALSE; if (delete_res) { DBUG_PRINT("info", ("delete failed")); @@ -1843,9 +1845,9 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) DBUG_PRINT("info", ("Calling updateTuple on cursor")); if (!(op= cursor->updateTuple())) ERR_RETURN(trans->getNdbError()); - ops_pending++; + m_ops_pending++; if (uses_blob_value(FALSE)) - blobs_pending= TRUE; + m_blobs_pending= TRUE; } else { @@ -1921,7 +1923,7 @@ int ha_ndbcluster::delete_row(const byte *record) DBUG_PRINT("info", ("Calling deleteTuple on cursor")); if (cursor->deleteTuple() != 0) ERR_RETURN(trans->getNdbError()); - ops_pending++; + m_ops_pending++; no_uncommitted_rows_update(-1); @@ -1951,8 +1953,10 @@ int ha_ndbcluster::delete_row(const byte *record) else { int res; - if ((res= set_primary_key(op))) - return res; + if ((res= (m_primary_key_update ? + set_primary_key_from_old_data(op, record) + : set_primary_key(op)))) + return res; } } @@ -2411,18 +2415,18 @@ int ha_ndbcluster::close_scan() DBUG_RETURN(1); - if (ops_pending) + if (m_ops_pending) { /* Take over any pending transactions to the deleteing/updating transaction before closing the scan */ - DBUG_PRINT("info", ("ops_pending: %d", ops_pending)); + DBUG_PRINT("info", ("ops_pending: %d", m_ops_pending)); if (execute_no_commit(this,trans) != 0) { no_uncommitted_rows_execute_failure(); DBUG_RETURN(ndb_err(trans)); } - ops_pending= 0; + m_ops_pending= 0; } cursor->close(); @@ -2555,7 +2559,7 @@ void ha_ndbcluster::info(uint flag) if (flag & HA_STATUS_ERRKEY) { DBUG_PRINT("info", ("HA_STATUS_ERRKEY")); - errkey= dupkey; + errkey= m_dupkey; } if (flag & HA_STATUS_AUTO) DBUG_PRINT("info", ("HA_STATUS_AUTO")); @@ -2663,7 +2667,7 @@ int ha_ndbcluster::extra(enum ha_extra_function operation) where field->query_id is the same as the current query id */ DBUG_PRINT("info", ("HA_EXTRA_RETRIEVE_ALL_COLS")); - retrieve_all_fields= TRUE; + m_retrieve_all_fields= TRUE; break; case HA_EXTRA_PREPARE_FOR_DELETE: DBUG_PRINT("info", ("HA_EXTRA_PREPARE_FOR_DELETE")); @@ -2707,8 +2711,8 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows) DBUG_ENTER("start_bulk_insert"); DBUG_PRINT("enter", ("rows: %d", (int)rows)); - rows_inserted= 0; - rows_to_insert= rows; + m_rows_inserted= 0; + m_rows_to_insert= rows; /* Calculate how many rows that should be inserted @@ -2722,7 +2726,7 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows) batch= bytesperbatch/bytes; batch= batch == 0 ? 1 : batch; DBUG_PRINT("info", ("batch: %d, bytes: %d", batch, bytes)); - bulk_insert_rows= batch; + m_bulk_insert_rows= batch; DBUG_VOID_RETURN; } @@ -2736,22 +2740,22 @@ int ha_ndbcluster::end_bulk_insert() DBUG_ENTER("end_bulk_insert"); // Check if last inserts need to be flushed - if (bulk_insert_not_flushed) + if (m_bulk_insert_not_flushed) { NdbConnection *trans= m_active_trans; // Send rows to NDB DBUG_PRINT("info", ("Sending inserts to NDB, "\ "rows_inserted:%d, bulk_insert_rows: %d", - rows_inserted, bulk_insert_rows)); - bulk_insert_not_flushed= FALSE; + m_rows_inserted, m_bulk_insert_rows)); + m_bulk_insert_not_flushed= FALSE; if (execute_no_commit(this,trans) != 0) { no_uncommitted_rows_execute_failure(); my_errno= error= ndb_err(trans); } } - rows_inserted= 0; - rows_to_insert= 1; + m_rows_inserted= 0; + m_rows_to_insert= 1; DBUG_RETURN(error); } @@ -2937,8 +2941,8 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) (NdbConnection*)thd->transaction.stmt.ndb_tid; DBUG_ASSERT(m_active_trans); // Start of transaction - retrieve_all_fields= FALSE; - ops_pending= 0; + m_retrieve_all_fields= FALSE; + m_ops_pending= 0; { NDBDICT *dict= m_ndb->getDictionary(); const NDBTAB *tab; @@ -2986,13 +2990,13 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) DBUG_PRINT("warning", ("m_active_cursor != NULL")); m_active_cursor= NULL; - if (blobs_pending) + if (m_blobs_pending) DBUG_PRINT("warning", ("blobs_pending != 0")); - blobs_pending= 0; + m_blobs_pending= 0; - if (ops_pending) + if (m_ops_pending) DBUG_PRINT("warning", ("ops_pending != 0L")); - ops_pending= 0; + m_ops_pending= 0; } DBUG_RETURN(error); } @@ -3029,8 +3033,8 @@ int ha_ndbcluster::start_stmt(THD *thd) m_active_trans= trans; // Start of statement - retrieve_all_fields= FALSE; - ops_pending= 0; + m_retrieve_all_fields= FALSE; + m_ops_pending= 0; DBUG_RETURN(error); } @@ -3571,13 +3575,13 @@ longlong ha_ndbcluster::get_auto_increment() DBUG_ENTER("get_auto_increment"); DBUG_PRINT("enter", ("m_tabname: %s", m_tabname)); int cache_size= - (rows_to_insert - rows_inserted < autoincrement_prefetch) ? - rows_to_insert - rows_inserted - : (rows_to_insert > autoincrement_prefetch) ? - rows_to_insert + (m_rows_to_insert - m_rows_inserted < autoincrement_prefetch) ? + m_rows_to_insert - m_rows_inserted + : (m_rows_to_insert > autoincrement_prefetch) ? + m_rows_to_insert : autoincrement_prefetch; Uint64 auto_value= - (skip_auto_increment) ? + (m_skip_auto_increment) ? m_ndb->readAutoIncrementValue((const NDBTAB *) m_table) : m_ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size); DBUG_RETURN((longlong)auto_value); @@ -3602,17 +3606,18 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_share(0), m_use_write(FALSE), m_ignore_dup_key_not_supported(FALSE), - retrieve_all_fields(FALSE), - rows_to_insert(1), - rows_inserted(0), - bulk_insert_rows(1024), - bulk_insert_not_flushed(FALSE), - ops_pending(0), - skip_auto_increment(TRUE), - blobs_pending(0), - blobs_buffer(0), - blobs_buffer_size(0), - dupkey((uint) -1) + m_primary_key_update(FALSE), + m_retrieve_all_fields(FALSE), + m_rows_to_insert(1), + m_rows_inserted(0), + m_bulk_insert_rows(1024), + m_bulk_insert_not_flushed(FALSE), + m_ops_pending(0), + m_skip_auto_increment(TRUE), + m_blobs_pending(0), + m_blobs_buffer(0), + m_blobs_buffer_size(0), + m_dupkey((uint) -1) { int i; @@ -3646,8 +3651,8 @@ ha_ndbcluster::~ha_ndbcluster() if (m_share) free_share(m_share); release_metadata(); - my_free(blobs_buffer, MYF(MY_ALLOW_ZERO_PTR)); - blobs_buffer= 0; + my_free(m_blobs_buffer, MYF(MY_ALLOW_ZERO_PTR)); + m_blobs_buffer= 0; // Check for open cursor/transaction if (m_active_cursor) { diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index b33a0657d4f..2121228a869 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -243,18 +243,19 @@ class ha_ndbcluster: public handler NdbValue m_value[NDB_MAX_ATTRIBUTES_IN_TABLE]; bool m_use_write; bool m_ignore_dup_key_not_supported; - bool retrieve_all_fields; - ha_rows rows_to_insert; - ha_rows rows_inserted; - ha_rows bulk_insert_rows; - bool bulk_insert_not_flushed; - ha_rows ops_pending; - bool skip_auto_increment; - bool blobs_pending; + bool m_primary_key_update; + bool m_retrieve_all_fields; + ha_rows m_rows_to_insert; + ha_rows m_rows_inserted; + ha_rows m_bulk_insert_rows; + bool m_bulk_insert_not_flushed; + ha_rows m_ops_pending; + bool m_skip_auto_increment; + bool m_blobs_pending; // memory for blobs in one tuple - char *blobs_buffer; - uint32 blobs_buffer_size; - uint dupkey; + char *m_blobs_buffer; + uint32 m_blobs_buffer_size; + uint m_dupkey; void set_rec_per_key(); void records_update(); From 485de9cbb7585b5eb1ac97ca92248e1fa1704825 Mon Sep 17 00:00:00 2001 From: "lars@mysql.com" <> Date: Wed, 3 Nov 2004 18:23:58 +0100 Subject: [PATCH 060/101] Fix for bug#5551 (Version 4). The idea of the fix is that the administrative statements OPTIMIZE TABLE, REPAIR TABLE and ANALYZE TABLE should not generate binlog errors if there is no errors on the master. --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/rpl_failed_optimize.result | 15 +++++++++++++++ mysql-test/t/rpl_failed_optimize-master.opt | 1 + mysql-test/t/rpl_failed_optimize.test | 18 ++++++++++++++++++ sql/sql_parse.cc | 3 +++ sql/sql_table.cc | 6 ++++++ 6 files changed, 44 insertions(+) create mode 100644 mysql-test/r/rpl_failed_optimize.result create mode 100644 mysql-test/t/rpl_failed_optimize-master.opt create mode 100644 mysql-test/t/rpl_failed_optimize.test diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 953ddf7b564..ac02fa84bbc 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -95,6 +95,7 @@ kaj@work.mysql.com kent@mysql.com konstantin@mysql.com kostja@oak.local +lars@mysql.com lenz@kallisto.mysql.com lenz@mysql.com magnus@neptunus.(none) diff --git a/mysql-test/r/rpl_failed_optimize.result b/mysql-test/r/rpl_failed_optimize.result new file mode 100644 index 00000000000..1576ec60500 --- /dev/null +++ b/mysql-test/r/rpl_failed_optimize.result @@ -0,0 +1,15 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CREATE TABLE t1 ( a int ) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES (1); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status Operation failed +OPTIMIZE TABLE non_existing; +Table Op Msg_type Msg_text +test.non_existing optimize error Table 'test.non_existing' doesn't exist diff --git a/mysql-test/t/rpl_failed_optimize-master.opt b/mysql-test/t/rpl_failed_optimize-master.opt new file mode 100644 index 00000000000..a6ef074a120 --- /dev/null +++ b/mysql-test/t/rpl_failed_optimize-master.opt @@ -0,0 +1 @@ +--innodb-lock-wait-timeout=1 diff --git a/mysql-test/t/rpl_failed_optimize.test b/mysql-test/t/rpl_failed_optimize.test new file mode 100644 index 00000000000..d245d1bacbb --- /dev/null +++ b/mysql-test/t/rpl_failed_optimize.test @@ -0,0 +1,18 @@ +source include/have_innodb.inc; +source include/master-slave.inc; + +# +# BUG#5551 "Failed OPTIMIZE TABLE is logged to binary log" +# Replication should work when OPTIMIZE TABLE timeouts, and +# when OPTIMIZE TABLE is executed on a non-existing table +# + +CREATE TABLE t1 ( a int ) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES (1); + +connection master1; +OPTIMIZE TABLE t1; + +OPTIMIZE TABLE non_existing; +sync_slave_with_master; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index dce32720184..f5b9bc0638f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2610,6 +2610,7 @@ unsent_create_error: mysql_update_log.write(thd, thd->query, thd->query_length); if (mysql_bin_log.is_open()) { + thd->clear_error(); // No binlog error generated Query_log_event qinfo(thd, thd->query, thd->query_length, 0); mysql_bin_log.write(&qinfo); } @@ -2638,6 +2639,7 @@ unsent_create_error: mysql_update_log.write(thd, thd->query, thd->query_length); if (mysql_bin_log.is_open()) { + thd->clear_error(); // No binlog error generated Query_log_event qinfo(thd, thd->query, thd->query_length, 0); mysql_bin_log.write(&qinfo); } @@ -2660,6 +2662,7 @@ unsent_create_error: mysql_update_log.write(thd, thd->query, thd->query_length); if (mysql_bin_log.is_open()) { + thd->clear_error(); // No binlog error generated Query_log_event qinfo(thd, thd->query, thd->query_length, 0); mysql_bin_log.write(&qinfo); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2f7a5f32d01..c69235a5647 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1734,6 +1734,12 @@ end: } +/* + RETURN VALUES + 0 Message sent to net (admin operation went ok) + -1 Message should be sent by caller + (admin operation or network communication failed) +*/ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt, const char *operator_name, From b9ec6803ae39367dad8d3b716c59c1c741b2c91b Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Wed, 3 Nov 2004 20:21:56 +0100 Subject: [PATCH 061/101] NDB blobs - try to handle insert-update-delete under autocommit=0 --- mysql-test/r/ndb_blob.result | 9 ++++++++- mysql-test/t/ndb_blob.test | 8 +++++++- ndb/src/ndbapi/NdbBlob.cpp | 12 ++++++++++++ ndb/src/ndbapi/NdbConnection.cpp | 5 +++++ ndb/src/ndbapi/NdbOperationExec.cpp | 2 +- ndb/src/ndbapi/ndberror.c | 2 +- ndb/test/ndbapi/testBlobs.cpp | 16 ++++++++++++++++ 7 files changed, 50 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/ndb_blob.result b/mysql-test/r/ndb_blob.result index 1f2cf33f57d..156c2d570a4 100644 --- a/mysql-test/r/ndb_blob.result +++ b/mysql-test/r/ndb_blob.result @@ -414,6 +414,7 @@ a b c d 9 b9 999 dd9 drop table t1; drop database test2; +set autocommit=0; create table t1 ( a int not null primary key, b tinytext @@ -422,9 +423,13 @@ insert into t1 values(1, 'x'); update t1 set b = 'y'; select * from t1; a b -1 x +1 y delete from t1; +select * from t1; +a b +commit; drop table t1; +set autocommit=0; create table t1 ( a int not null primary key, b text not null @@ -433,6 +438,7 @@ insert into t1 values(1, ''); select * from t1; a b 1 +commit; drop table t1; set autocommit=1; use test; @@ -454,6 +460,7 @@ select * from t1 order by a; a b 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +set autocommit=1; alter table t1 engine=myisam; select * from t1 order by a; a b diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index ba5f089b17b..06ecbc66d97 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -337,8 +337,9 @@ select * from t1 order by a; drop table t1; drop database test2; -# -- bug-5252 tinytext crashes -- +# -- bug-5252 tinytext crashes plus no-commit result -- +set autocommit=0; create table t1 ( a int not null primary key, b tinytext @@ -348,10 +349,13 @@ insert into t1 values(1, 'x'); update t1 set b = 'y'; select * from t1; delete from t1; +select * from t1; +commit; drop table t1; # -- bug-5013 insert empty string to text -- +set autocommit=0; create table t1 ( a int not null primary key, b text not null @@ -359,6 +363,7 @@ create table t1 ( insert into t1 values(1, ''); select * from t1; +commit; drop table t1; # -- bug #5349 -- @@ -380,6 +385,7 @@ alter table t1 engine=ndb; select * from t1 order by a; # -- bug #5872 -- +set autocommit=1; alter table t1 engine=myisam; select * from t1 order by a; drop table t1; diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index 9d21304939a..53c0a0e07f9 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -1428,6 +1428,18 @@ NdbBlob::postExecute(ExecType anExecType) if (invokeActiveHook() == -1) return -1; } + if (anExecType == NoCommit && theHeadInlineUpdateFlag) { + NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); + if (tOp == NULL || + tOp->updateTuple() == -1 || + setTableKeyValue(tOp) == -1 || + setHeadInlineValue(tOp) == -1) { + setErrorCode(ErrAbort); + return -1; + } + tOp->m_abortOption = AbortOnError; + DBG("added op to update head+inline"); + } DBG("postExecute [out]"); return 0; } diff --git a/ndb/src/ndbapi/NdbConnection.cpp b/ndb/src/ndbapi/NdbConnection.cpp index c21a85fd24d..4f6468eb4ae 100644 --- a/ndb/src/ndbapi/NdbConnection.cpp +++ b/ndb/src/ndbapi/NdbConnection.cpp @@ -340,7 +340,12 @@ NdbConnection::execute(ExecType aTypeOfExec, if (executeNoBlobs(tExecType, abortOption, forceSend) == -1) ret = -1; +#ifndef VM_TRACE + // can happen in complex abort cases + theFirstOpInList = theLastOpInList = NULL; +#else assert(theFirstOpInList == NULL && theLastOpInList == NULL); +#endif { NdbOperation* tOp = theCompletedFirstOp; diff --git a/ndb/src/ndbapi/NdbOperationExec.cpp b/ndb/src/ndbapi/NdbOperationExec.cpp index 6d7a3817e04..13664794dcd 100644 --- a/ndb/src/ndbapi/NdbOperationExec.cpp +++ b/ndb/src/ndbapi/NdbOperationExec.cpp @@ -552,7 +552,7 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal) theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; theError.code = aSignal->readData(4); - theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4), ao); + theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4), m_abortOption); if(theOperationType != ReadRequest || !theSimpleIndicator) // not simple read return theNdbCon->OpCompleteFailure(ao, m_abortOption != IgnoreError); diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index 20661b89517..17a80082023 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -150,7 +150,7 @@ ErrorBundle ErrorCodes[] = { { 623, IS, "623" }, { 624, IS, "624" }, { 625, IS, "Out of memory in Ndb Kernel, index part" }, - { 826, IS, "826" }, + { 826, IS, "Too many tables and attributes (increase MaxNoOfAttributes)" }, { 827, IS, "Out of memory in Ndb Kernel, data part" }, { 832, IS, "832" }, diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index 08bf8a2fd4b..efa0811aa39 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -42,6 +42,7 @@ struct Opt { bool m_core; bool m_dbg; bool m_dbgall; + const char* m_dbug; bool m_full; unsigned m_loop; unsigned m_parts; @@ -66,6 +67,7 @@ struct Opt { m_core(false), m_dbg(false), m_dbgall(false), + m_dbug(0), m_full(false), m_loop(1), m_parts(10), @@ -100,6 +102,7 @@ printusage() << " -core dump core on error" << endl << " -dbg print debug" << endl << " -dbgall print also NDB API debug (if compiled in)" << endl + << " -dbug opt dbug options" << endl << " -full read/write only full blob values" << endl << " -loop N loop N times 0=forever [" << d.m_loop << "]" << endl << " -parts N max parts in blob value [" << d.m_parts << "]" << endl @@ -1046,8 +1049,12 @@ writeIdx(int style) if (style == 0) { CHK(setBlobValue(tup) == 0); } else if (style == 1) { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); CHK(setBlobWriteHook(tup) == 0); } else { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); CHK(g_con->execute(NoCommit) == 0); CHK(writeBlobData(tup) == 0); } @@ -1463,6 +1470,12 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) putenv(strdup("NDB_BLOB_DEBUG=1")); continue; } + if (strcmp(arg, "-dbug") == 0) { + if (++argv, --argc > 0) { + g_opt.m_dbug = strdup(argv[0]); + continue; + } + } if (strcmp(arg, "-full") == 0) { g_opt.m_full = true; continue; @@ -1533,6 +1546,9 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) printusage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } + if (g_opt.m_dbug != 0) { + DBUG_PUSH(g_opt.m_dbug); + } if (g_opt.m_pk2len == 0) { char b[100]; b[0] = 0; From fd069e2bb36a3c1c1f26d65dd298b07e6d83ac8b Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Wed, 3 Nov 2004 21:32:48 +0200 Subject: [PATCH 062/101] InnoDB: commit after every 10000 rows in ALTER TABLE --- innobase/include/lock0lock.h | 8 ++++++++ innobase/include/row0mysql.h | 6 +++++- innobase/lock/lock0lock.c | 13 +++++++++++++ innobase/row/row0mysql.c | 14 +++++++++++--- sql/ha_innodb.cc | 26 +++++++++++++++++++++++++- sql/ha_innodb.h | 4 +++- 6 files changed, 65 insertions(+), 6 deletions(-) diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h index 9f525042dcc..f8435e14d97 100644 --- a/innobase/include/lock0lock.h +++ b/innobase/include/lock0lock.h @@ -463,6 +463,14 @@ lock_rec_hash( ulint space, /* in: space */ ulint page_no);/* in: page number */ /************************************************************************* +Gets the table covered by an IX table lock. */ + +dict_table_t* +lock_get_ix_table( +/*==============*/ + /* out: the table covered by the lock */ + lock_t* lock); /* in: table lock */ +/************************************************************************* Checks that a transaction id is sensible, i.e., not in the future. */ ibool diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h index 9437ed4b6ee..73f41dea0da 100644 --- a/innobase/include/row0mysql.h +++ b/innobase/include/row0mysql.h @@ -175,8 +175,12 @@ int row_lock_table_for_mysql( /*=====================*/ /* out: error code or DB_SUCCESS */ - row_prebuilt_t* prebuilt); /* in: prebuilt struct in the MySQL + row_prebuilt_t* prebuilt, /* in: prebuilt struct in the MySQL table handle */ + dict_table_t* table); /* in: table to LOCK_IX, or NULL + if prebuilt->table should be + locked as LOCK_TABLE_EXP | + prebuilt->select_lock_type */ /************************************************************************* Does an insert for MySQL. */ diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 68073647248..6f2d58b72c3 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -395,6 +395,19 @@ lock_rec_get_nth_bit( return(ut_bit_get_nth(b, bit_index)); } +/************************************************************************* +Gets the table covered by an IX table lock. */ + +dict_table_t* +lock_get_ix_table( +/*==============*/ + /* out: the table covered by the lock */ + lock_t* lock) /* in: table lock */ +{ + ut_a(lock->type_mode == (LOCK_TABLE | LOCK_IX)); + return(lock->un_member.tab_lock.table); +} + /*************************************************************************/ #define lock_mutex_enter_kernel() mutex_enter(&kernel_mutex) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 241ddc310e8..3e780138261 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -779,8 +779,12 @@ int row_lock_table_for_mysql( /*=====================*/ /* out: error code or DB_SUCCESS */ - row_prebuilt_t* prebuilt) /* in: prebuilt struct in the MySQL + row_prebuilt_t* prebuilt, /* in: prebuilt struct in the MySQL table handle */ + dict_table_t* table) /* in: table to LOCK_IX, or NULL + if prebuilt->table should be + locked as LOCK_TABLE_EXP | + prebuilt->select_lock_type */ { trx_t* trx = prebuilt->trx; que_thr_t* thr; @@ -813,8 +817,12 @@ run_again: trx_start_if_not_started(trx); - err = lock_table(LOCK_TABLE_EXP, prebuilt->table, - prebuilt->select_lock_type, thr); + if (table) { + err = lock_table(0, table, LOCK_IX, thr); + } else { + err = lock_table(LOCK_TABLE_EXP, prebuilt->table, + prebuilt->select_lock_type, thr); + } trx->error_state = err; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 0bcb7062437..25a0f154c25 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2314,7 +2314,31 @@ ha_innobase::write_row( if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) table->timestamp_field->set_time(); + num_write_row++; + + if (user_thd->lex->sql_command == SQLCOM_ALTER_TABLE + && num_write_row > 10000) { + /* ALTER TABLE is COMMITted at every 10000 copied rows. + The IX table lock for the original table has to be re-issued. + As this method will be called on a temporary table where the + contents of the original table is being copied to, it is + a bit tricky to determine the source table. The cursor + position in the source table need not be adjusted after the + intermediate COMMIT, since writes by other transactions are + being blocked by a MySQL table lock TL_WRITE_ALLOW_READ. */ + ut_a(prebuilt->trx->mysql_n_tables_locked == 2); + ut_a(UT_LIST_GET_LEN(prebuilt->trx->trx_locks) >= 2); + dict_table_t* table = lock_get_ix_table( + UT_LIST_GET_FIRST(prebuilt->trx->trx_locks)); + num_write_row = 0; + innobase_commit(user_thd, prebuilt->trx); + user_thd->transaction.all.innodb_active_trans = 1; + row_lock_table_for_mysql(prebuilt, table); + goto new_trx; + } + if (last_query_id != user_thd->query_id) { + new_trx: prebuilt->sql_stat_start = TRUE; last_query_id = user_thd->query_id; @@ -4986,7 +5010,7 @@ ha_innobase::external_lock( if (thd->in_lock_tables && thd->variables.innodb_table_locks) { ulint error; - error = row_lock_table_for_mysql(prebuilt); + error = row_lock_table_for_mysql(prebuilt, 0); if (error != DB_SUCCESS) { error = convert_error_code_to_mysql( diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index c10beacac1b..e76a966c6b9 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -64,6 +64,7 @@ class ha_innobase: public handler uint last_match_mode;/* match mode of the latest search: ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX, or undefined */ + uint num_write_row; /* number of write_row() calls */ longlong auto_inc_counter_for_this_stat; ulong max_supported_row_length(const byte *buf); @@ -85,7 +86,8 @@ class ha_innobase: public handler HA_PRIMARY_KEY_IN_READ_INDEX | HA_TABLE_SCAN_ON_INDEX), last_dup_key((uint) -1), - start_of_scan(0) + start_of_scan(0), + num_write_row(0) { } ~ha_innobase() {} From 13a60a76312d3035005d90a94fd2442456ce0f77 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Thu, 4 Nov 2004 00:10:00 +0200 Subject: [PATCH 063/101] ibuf0ibuf.c: Do not print to .err log about discarding ibuf entries in DISCARD TABLESPACE; removed compiler warning about unused variable --- innobase/ibuf/ibuf0ibuf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c index b3c8ade2414..2191cdc0ee6 100644 --- a/innobase/ibuf/ibuf0ibuf.c +++ b/innobase/ibuf/ibuf0ibuf.c @@ -2866,6 +2866,8 @@ ibuf_delete_rec( #ifdef UNIV_IBUF_DEBUG ibuf_count_set(space, page_no, ibuf_count_get(space, page_no) - 1); +#else + UT_NOT_USED(space); #endif ibuf_data_sizes_update(ibuf_data, root, mtr); @@ -3267,11 +3269,11 @@ leave_loop: ibuf_data->n_merged_recs += n_inserts; mutex_exit(&ibuf_mutex); - + /* fprintf(stderr, "InnoDB: Discarded %lu ibuf entries for space %lu\n", (ulong) n_inserts, (ulong) space); - + */ ibuf_exit(); mem_heap_free(heap); From f979603cf2c292b80fae7cc47f75ea34769f146f Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 4 Nov 2004 08:50:07 +0400 Subject: [PATCH 064/101] field.cc, sql_mode.result, sql_mode.test: "SHOW CREATE TABLE" mysql-4.0 and mysql-3.23 compatibiliry mode change: Check that a binary collation adds 'binary' suffix into a char() column definition in mysql40 and mysql2323 modes. This allows not to lose the column's case sensitivity when loading the dump in pre-4.1 servers. --- mysql-test/r/sql_mode.result | 30 ++++++++++++++++++++++++++++++ mysql-test/t/sql_mode.test | 31 +++++++++++++++++++++++++++++++ sql/field.cc | 4 ++++ 3 files changed, 65 insertions(+) diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result index e54dd217f8c..c18be2df403 100644 --- a/mysql-test/r/sql_mode.result +++ b/mysql-test/r/sql_mode.result @@ -85,6 +85,36 @@ t1 CREATE TABLE "t1" ( UNIQUE KEY "email" ("email") ) drop table t1; +CREATE TABLE t1 ( +a char(10), +b char(10) collate latin1_bin, +c binary(10) +) character set latin1; +set @@sql_mode=""; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL, + `b` char(10) character set latin1 collate latin1_bin default NULL, + `c` binary(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +set @@sql_mode="mysql323"; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL, + `b` char(10) binary default NULL, + `c` binary(10) default NULL +) TYPE=MyISAM +set @@sql_mode="mysql40"; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL, + `b` char(10) binary default NULL, + `c` binary(10) default NULL +) TYPE=MyISAM +drop table t1; set session sql_mode = ''; create table t1 ( min_num dec(6,6) default .000001); show create table t1; diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test index 63a5d6d3671..f841d36e837 100644 --- a/mysql-test/t/sql_mode.test +++ b/mysql-test/t/sql_mode.test @@ -29,6 +29,37 @@ select @@sql_mode; show create table t1; drop table t1; +# +# Check that a binary collation adds 'binary' +# suffix into a char() column definition in +# mysql40 and mysql2323 modes. This allows +# not to lose the column's case sensitivity +# when loading the dump in pre-4.1 servers. +# +# Thus, in 4.0 and 3.23 modes we dump: +# +# 'char(10) collate xxx_bin' as 'char(10) binary' +# 'binary(10)' as 'binary(10)' +# +# In mysql-4.1 these types are different, and they will +# be recreated differently. +# +# In mysqld-4.0 the the above two types were the same, +# so it will create a 'char(10) binary' column for both definitions. +# +CREATE TABLE t1 ( + a char(10), + b char(10) collate latin1_bin, + c binary(10) +) character set latin1; +set @@sql_mode=""; +show create table t1; +set @@sql_mode="mysql323"; +show create table t1; +set @@sql_mode="mysql40"; +show create table t1; +drop table t1; + # # BUG#5318 - failure: 'IGNORE_SPACE' affects numeric values after DEFAULT # diff --git a/sql/field.cc b/sql/field.cc index 4b833874221..24bd0c48c92 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4417,6 +4417,7 @@ void Field_string::sort_string(char *to,uint length) void Field_string::sql_type(String &res) const { + THD *thd= table->in_use; CHARSET_INFO *cs=res.charset(); ulong length= cs->cset->snprintf(cs,(char*) res.ptr(), res.alloced_length(), "%s(%d)", @@ -4427,6 +4428,9 @@ void Field_string::sql_type(String &res) const (has_charset() ? "char" : "binary")), (int) field_length / charset()->mbmaxlen); res.length(length); + if ((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) && + has_charset() && (charset()->state & MY_CS_BINSORT)) + res.append(" binary"); } char *Field_string::pack(char *to, const char *from, uint max_length) From e14817d8f5cdef9c82f672675ac8c6f97506db99 Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Thu, 4 Nov 2004 12:14:19 +0100 Subject: [PATCH 065/101] DbaccMain.cpp: ugly fix for 'quadita2' ia64 icc -O1 --- ndb/src/kernel/blocks/dbacc/DbaccMain.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index 9a1bbd86562..c275e5382f7 100644 --- a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -4501,6 +4501,17 @@ void Dbacc::getdirindex(Signal* signal) /* BUCKET, AND SERCH FOR ELEMENT.THE PRIMARY KEYS WHICH IS SAVED */ /* IN THE OPERATION REC ARE THE CHECK ITEMS IN THE SEARCHING. */ /* --------------------------------------------------------------------------------- */ + +#if __ia64 == 1 +#if __INTEL_COMPILER == 810 +int ndb_acc_ia64_icc810_dummy_var = 0; +void ndb_acc_ia64_icc810_dummy_func() +{ + ndb_acc_ia64_icc810_dummy_var++; +} +#endif +#endif + void Dbacc::getElement(Signal* signal) { DirRangePtr geOverflowrangeptr; @@ -4595,6 +4606,12 @@ void Dbacc::getElement(Signal* signal) /* WE HAVE FOUND THE ELEMENT. GET THE LOCK INDICATOR AND RETURN FOUND. */ /* --------------------------------------------------------------------------------- */ jam(); +#if __ia64 == 1 +#if __INTEL_COMPILER == 810 + // prevents SIGSEGV under icc -O1 + ndb_acc_ia64_icc810_dummy_func(); +#endif +#endif tgeLocked = ElementHeader::getLocked(gePageptr.p->word32[tgeElementptr]); tgeResult = ZTRUE; TdataIndex = tgeElementptr + tgeForward; From f5e5dfb2f779cbb5468d63d94d659fa3d6a17e8a Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 4 Nov 2004 13:06:22 +0000 Subject: [PATCH 066/101] just do kill instead ok kill -9 --- mysql-test/ndb/ndbcluster.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index 9d83a291f3d..d7b115d71b6 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -212,8 +212,8 @@ if [ -f "$fs_ndb/$pidfile" ] ; then attempt=`expr $attempt + 1` done if [ "$kill_pids" != "" ] ; then - echo "Failed to shutdown ndbcluster, executing kill -9 "$kill_pids - kill -9 $kill_pids + echo "Failed to shutdown ndbcluster, executing kill "$kill_pids + kill $kill_pids fi rm "$fs_ndb/$pidfile" fi From 7d2047994e9793409d10b4f063d0ff118142c6eb Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Thu, 4 Nov 2004 14:06:24 +0100 Subject: [PATCH 067/101] NDB bug #6426 fix --- ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index cd15ad0c3b2..af1131e5e55 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -8725,7 +8725,7 @@ void Dblqh::sendKeyinfo20(Signal* signal, sendSignal(ref, GSN_KEYINFO20, signal, 25, JBB); src += KeyInfo20::DataLength;; keyLen -= KeyInfo20::DataLength; - } while(keyLen >= KeyInfo20::DataLength); + } MEMCOPY_NO_WORDS(keyInfo->keyData, src, keyLen); sendSignal(ref, GSN_KEYINFO20, signal, From 1e82a08734d744e67134035a34ff1bdb08b00ed8 Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Thu, 4 Nov 2004 15:57:54 +0200 Subject: [PATCH 068/101] ha_innodb.cc: write_row(): document the ALTER TABLE tweak better, and commit every n*10000 rows, not n*10000-1 rows. --- sql/ha_innodb.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 25a0f154c25..6e08fc680b2 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2314,10 +2314,8 @@ ha_innobase::write_row( if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) table->timestamp_field->set_time(); - num_write_row++; - if (user_thd->lex->sql_command == SQLCOM_ALTER_TABLE - && num_write_row > 10000) { + && num_write_row >= 10000) { /* ALTER TABLE is COMMITted at every 10000 copied rows. The IX table lock for the original table has to be re-issued. As this method will be called on a temporary table where the @@ -2331,14 +2329,20 @@ ha_innobase::write_row( dict_table_t* table = lock_get_ix_table( UT_LIST_GET_FIRST(prebuilt->trx->trx_locks)); num_write_row = 0; + /* Commit the transaction. This will release the table + locks, so they have to be acquired again. */ innobase_commit(user_thd, prebuilt->trx); + /* Note that this transaction is still active. */ user_thd->transaction.all.innodb_active_trans = 1; + /* Re-acquire the IX table lock on the source table. */ row_lock_table_for_mysql(prebuilt, table); - goto new_trx; + /* We will need an IX lock on the destination table. */ + prebuilt->sql_stat_start = TRUE; } + num_write_row++; + if (last_query_id != user_thd->query_id) { - new_trx: prebuilt->sql_stat_start = TRUE; last_query_id = user_thd->query_id; From 08b25e990172af198153f0a87b37adf7b6209989 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 4 Nov 2004 15:57:29 +0000 Subject: [PATCH 069/101] updated start script for ndbcluster to make better cleanup changed to use new switch --- mysql-test/ndb/ndbcluster.sh | 60 +++++++++++++++++++++++++++++++----- ndb/test/run-test/main.cpp | 2 +- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index d7b115d71b6..9894e70c788 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -102,12 +102,43 @@ if [ ! -x "$exec_mgmtsrvr" ]; then echo "$exec_mgmtsrvr missing" exit 1 fi +if [ ! -x "$exec_waiter" ]; then + echo "$exec_waiter missing" + exit 1 +fi + +exec_mgmtclient="$exec_mgmtclient --no-defaults" +exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults" +exec_ndb="$exec_ndb --no-defaults" +exec_waiter="$exec_waiter --no-defaults" ndb_host="localhost" ndb_mgmd_port=$port_base NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port" export NDB_CONNECTSTRING +sleep_until_file_created () { + file=$1 + loop=$2 + org_time=$2 + message=$3 + while (test $loop -gt 0) + do + if [ -r $file ] + then + return 0 + fi + sleep 1 + loop=`expr $loop - 1` + done + if [ $message ] + then + echo $message + fi + echo "ERROR: $file was not created in $org_time seconds; Aborting" + return 1; +} + start_default_ndbcluster() { # do some checks @@ -127,8 +158,8 @@ port_transporter=`expr $ndb_mgmd_port + 2` # Start management server as deamon # Edit file system path and ports in config file - if [ $initial_ndb ] ; then + rm -f $fs_ndb/ndb_* sed \ -e s,"CHOOSE_MaxNoOfOrderedIndexes","$ndb_no_ord",g \ -e s,"CHOOSE_MaxNoOfConcurrentOperations","$ndb_con_op",g \ @@ -150,21 +181,32 @@ if ( cd "$fs_ndb" ; $exec_mgmtsrvr -f config.ini ) ; then :; else echo "Unable to start $exec_mgmtsrvr from `pwd`" exit 1 fi - +if sleep_until_file_created $fs_ndb/ndb_3.pid 30 +then :; else + exit 1 +fi cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" # Start database node echo "Starting ndbd" ( cd "$fs_ndb" ; $exec_ndb $flags_ndb & ) - +if sleep_until_file_created $fs_ndb/ndb_1.pid 30 +then :; else + stop_default_ndbcluster + exit 1 +fi cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" # Start database node echo "Starting ndbd" ( cd "$fs_ndb" ; $exec_ndb $flags_ndb & ) - +if sleep_until_file_created $fs_ndb/ndb_2.pid 30 +then :; else + stop_default_ndbcluster + exit 1 +fi cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" # test if Ndb Cluster starts properly @@ -172,6 +214,7 @@ cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" echo "Waiting for started..." if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK"; then :; else echo "Ndbcluster startup failed" + stop_default_ndbcluster exit 1 fi @@ -198,10 +241,12 @@ if [ -f "$fs_ndb/$pidfile" ] ; then attempt=0 while [ $attempt -lt 10 ] ; do new_kill_pid="" + kill_pids2="" for p in $kill_pids ; do kill -0 $p 2> /dev/null if [ $? -eq 0 ] ; then new_kill_pid="$p $new_kill_pid" + kill_pids2="-$p $kill_pids2" fi done kill_pids=$new_kill_pid @@ -211,9 +256,10 @@ if [ -f "$fs_ndb/$pidfile" ] ; then sleep 1 attempt=`expr $attempt + 1` done - if [ "$kill_pids" != "" ] ; then - echo "Failed to shutdown ndbcluster, executing kill "$kill_pids - kill $kill_pids + if [ "$kill_pids2" != "" ] ; then + do_command="kill -9 $kill_pids2" + echo "Failed to shutdown ndbcluster, executing "$do_command + $do_command fi rm "$fs_ndb/$pidfile" fi diff --git a/ndb/test/run-test/main.cpp b/ndb/test/run-test/main.cpp index 22799a9a1b2..e5f73bc6a5c 100644 --- a/ndb/test/run-test/main.cpp +++ b/ndb/test/run-test/main.cpp @@ -459,7 +459,7 @@ setup_config(atrt_config& config){ proc.m_type = atrt_process::NDB_MGM; proc.m_proc.m_name.assfmt("%d-%s", index, "ndb_mgmd"); proc.m_proc.m_path.assign(dir).append("/libexec/ndb_mgmd"); - proc.m_proc.m_args = "--nodaemon -c initconfig.txt"; + proc.m_proc.m_args = "--nodaemon -f config.ini"; proc.m_proc.m_cwd.appfmt("%d.ndb_mgmd", index); connect_string.appfmt("host=%s:%d;", proc.m_hostname.c_str(), proc.m_ndb_mgm_port); From b8e9a612b3c9bc7ddc75779741f7bf275f6d2522 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 4 Nov 2004 16:24:41 +0000 Subject: [PATCH 070/101] to make sure we get the kill right on the different platforms --- mysql-test/ndb/ndbcluster.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index 9894e70c788..9c6b6093b93 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -257,9 +257,13 @@ if [ -f "$fs_ndb/$pidfile" ] ; then attempt=`expr $attempt + 1` done if [ "$kill_pids2" != "" ] ; then - do_command="kill -9 $kill_pids2" - echo "Failed to shutdown ndbcluster, executing "$do_command - $do_command + echo "Failed to shutdown ndbcluster, executing kill "$kill_pids2 + kill -9 -- $kill_pids2 2> /dev/null + /bin/kill -9 -- $kill_pids2 2> /dev/null + /usr/bin/kill -9 -- $kill_pids2 2> /dev/null + kill -9 $kill_pids2 2> /dev/null + /bin/kill -9 $kill_pids2 2> /dev/null + /usr/bin/kill -9 $kill_pids2 2> /dev/null fi rm "$fs_ndb/$pidfile" fi From 26f3926efd94684295933dbc868f91cb0ce77f5e Mon Sep 17 00:00:00 2001 From: "wax@mysql.com" <> Date: Thu, 4 Nov 2004 21:25:50 +0500 Subject: [PATCH 071/101] autocommit From ff32313dd5d308f028e5bf0c342cc5d7221be126 Mon Sep 17 00:00:00 2001 From: "wax@kishkin.ru" <> Date: Thu, 4 Nov 2004 21:25:51 +0500 Subject: [PATCH 072/101] autocommit and changed name mysql_test_run_new --- client/mysqltest.c | 5 +- mysql-test/Makefile.am | 4 +- mysql-test/init_db.sql | 26 + mysql-test/mysql_test_run_new.c | 1728 +++++++++++++++++++++++++++++++ 4 files changed, 1760 insertions(+), 3 deletions(-) create mode 100644 mysql-test/init_db.sql create mode 100644 mysql-test/mysql_test_run_new.c diff --git a/client/mysqltest.c b/client/mysqltest.c index a635b5bdd11..df80fc7bb66 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -949,8 +949,11 @@ static void do_exec(struct st_query* q) while (fgets(buf, sizeof(buf), res_file)) replace_dynstr_append_mem(ds, buf, strlen(buf)); } - +#ifndef __WIN__ error= pclose(res_file); +#else + error= _pclose(res_file); +#endif if (error != 0) die("command \"%s\" failed", cmd); diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 906ff4b72bf..4e8601f1b88 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -37,8 +37,8 @@ test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem CLEANFILES = $(test_SCRIPTS) $(test_DATA) INCLUDES = -I$(srcdir)/../include -I../include -I.. -bin_PROGRAMS = mysql_test_run -mysql_test_run_SOURCES= mysql_test_run.c my_manage.c +bin_PROGRAMS = mysql_test_run_new +mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c dist-hook: diff --git a/mysql-test/init_db.sql b/mysql-test/init_db.sql new file mode 100644 index 00000000000..4613e5c0274 --- /dev/null +++ b/mysql-test/init_db.sql @@ -0,0 +1,26 @@ +CREATE DATABASE mysql; +CREATE DATABASE test; + +USE mysql; + +CREATE TABLE db (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL, References_priv enum('N','Y') DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User)) comment='Database privileges'; + +INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); +INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); + +CREATE TABLE host (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL, References_priv enum('N','Y') DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db)) comment='Host privileges; Merged with database privileges'; + +CREATE TABLE user (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(45) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, File_priv enum('N','Y') DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL, References_priv enum('N','Y') DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, PRIMARY KEY Host (Host,User)) comment='Users and global privileges'; + +INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); +INSERT INTO user VALUES ('','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); + +INSERT INTO user (host,user) values ('localhost',''); +INSERT INTO user (host,user) values ('',''); + +CREATE TABLE func (name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') NOT NULL, PRIMARY KEY (name)) comment='User defined functions'; + +CREATE TABLE tables_priv (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(60) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor)) comment='Table privileges'; + +CREATE TABLE columns_priv (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name)) comment='Column privileges'; + diff --git a/mysql-test/mysql_test_run_new.c b/mysql-test/mysql_test_run_new.c new file mode 100644 index 00000000000..6f388fc4a45 --- /dev/null +++ b/mysql-test/mysql_test_run_new.c @@ -0,0 +1,1728 @@ +/* + Copyright (c) 2002, 2003 Novell, Inc. All Rights Reserved. + + 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 +#include +#include +#ifndef __WIN__ +#include +#endif +#include +#ifdef __NETWARE__ +#include +#include +#endif +#include +#include +#ifndef __WIN__ +#include +#endif +#include +#ifdef __NETWARE__ +#include +#endif +#ifdef __WIN__ +#include +#include +#endif + +#include "my_manage.h" + +/****************************************************************************** + + macros + +******************************************************************************/ + +#define HEADER "TEST RESULT \n" +#define DASH "-------------------------------------------------------\n" + +#define NW_TEST_SUFFIX ".nw-test" +#define NW_RESULT_SUFFIX ".nw-result" +#define TEST_SUFFIX ".test" +#define RESULT_SUFFIX ".result" +#define REJECT_SUFFIX ".reject" +#define OUT_SUFFIX ".out" +#define ERR_SUFFIX ".err" + +const char *TEST_PASS = "[ pass ]"; +const char *TEST_SKIP = "[ skip ]"; +const char *TEST_FAIL = "[ fail ]"; +const char *TEST_BAD = "[ bad ]"; +const char *TEST_IGNORE = "[ignore]"; + +/****************************************************************************** + + global variables + +******************************************************************************/ +#ifdef __NETWARE__ +static char base_dir[PATH_MAX] = "sys:/mysql"; +#else +static char base_dir[PATH_MAX] = ".."; +#endif +static char db[PATH_MAX] = "test"; +static char user[PATH_MAX] = "root"; +static char password[PATH_MAX] = ""; + +int master_port = 9306; +int slave_port = 9307; + +#if !defined(__NETWARE__) && !defined(__WIN__) +static char master_socket[PATH_MAX] = "./var/tmp/master.sock"; +static char slave_socket[PATH_MAX] = "./var/tmp/slave.sock"; +#endif + +// comma delimited list of tests to skip or empty string +#ifndef __WIN__ +static char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix "; +#else +/* + The most ignore testes contain the calls of system command +*/ +#define MAX_COUNT_TESTES 1024 +/* + lowercase_table3 is disabled by Gerg + system_mysql_db_fix is disabled by Gerg + sp contains a command system + rpl_EE_error contains a command system + rpl_loaddatalocal contains a command system + ndb_autodiscover contains a command system + rpl_rotate_logs contains a command system + repair contains a command system + rpl_trunc_binlog contains a command system + mysqldump contains a command system + rpl000001 makes non-exit loop...temporary skiped +*/ +static char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix , sp , rpl_EE_error , rpl_loaddatalocal , ndb_autodiscover , rpl_rotate_logs , repair , rpl_trunc_binlog , mysqldump , rpl000001 "; +#endif +static char ignore_test[PATH_MAX] = ""; + +static char bin_dir[PATH_MAX]; +static char mysql_test_dir[PATH_MAX]; +static char test_dir[PATH_MAX]; +static char mysql_tmp_dir[PATH_MAX]; +static char result_dir[PATH_MAX]; +static char master_dir[PATH_MAX]; +static char slave_dir[PATH_MAX]; +static char lang_dir[PATH_MAX]; +static char char_dir[PATH_MAX]; + +static char mysqladmin_file[PATH_MAX]; +static char mysqld_file[PATH_MAX]; +static char mysqltest_file[PATH_MAX]; +#ifndef __WIN__ +static char master_pid[PATH_MAX]; +static char slave_pid[PATH_MAX]; +static char sh_file[PATH_MAX] = "/bin/sh"; +#else +static HANDLE master_pid; +static HANDLE slave_pid; +#endif + +static char master_opt[PATH_MAX] = ""; +static char slave_opt[PATH_MAX] = ""; + +static char slave_master_info[PATH_MAX] = ""; + +static char master_init_script[PATH_MAX] = ""; +static char slave_init_script[PATH_MAX] = ""; + +// OpenSSL +static char ca_cert[PATH_MAX]; +static char server_cert[PATH_MAX]; +static char server_key[PATH_MAX]; +static char client_cert[PATH_MAX]; +static char client_key[PATH_MAX]; + +int total_skip = 0; +int total_pass = 0; +int total_fail = 0; +int total_test = 0; + +int total_ignore = 0; + +int use_openssl = FALSE; +int master_running = FALSE; +int slave_running = FALSE; +int skip_slave = TRUE; +int single_test = TRUE; + +int restarts = 0; + +FILE *log_fd = NULL; + +/****************************************************************************** + + functions + +******************************************************************************/ + +/****************************************************************************** + + prototypes + +******************************************************************************/ + +void report_stats(); +void install_db(char *); +void mysql_install_db(); +void start_master(); +void start_slave(); +void mysql_start(); +void stop_slave(); +void stop_master(); +void mysql_stop(); +void mysql_restart(); +int read_option(char *, char *); +void run_test(char *); +void setup(char *); +void vlog(const char *, va_list); +void mlog(const char *, ...); +void log_info(const char *, ...); +void log_error(const char *, ...); +void log_errno(const char *, ...); +void die(const char *); +char *str_tok(char *string, const char *delim); +#ifndef __WIN__ +void run_init_script(const char *script_name); +#endif +/****************************************************************************** + + report_stats() + + Report the gathered statistics. + +******************************************************************************/ +void report_stats() +{ + if (total_fail == 0) + { + mlog("\nAll %d test(s) were successful.\n", total_test); + } + else + { + double percent = ((double)total_pass / total_test) * 100; + + mlog("\nFailed %u/%u test(s), %.02f%% successful.\n", + total_fail, total_test, percent); + mlog("\nThe .out and .err files in %s may give you some\n", result_dir); + mlog("hint of what when wrong.\n"); + mlog("\nIf you want to report this error, please first read the documentation\n"); + mlog("at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html\n"); + } +} + +/****************************************************************************** + + install_db() + + Install the a database. + +******************************************************************************/ +void install_db(char *datadir) +{ + arg_list_t al; + int err; + char input[PATH_MAX]; + char output[PATH_MAX]; + char error[PATH_MAX]; + + // input file +#ifdef __NETWARE__ + snprintf(input, PATH_MAX, "%s/bin/init_db.sql", base_dir); +#else + snprintf(input, PATH_MAX, "%s/mysql-test/init_db.sql", base_dir); +#endif + snprintf(output, PATH_MAX, "%s/install.out", datadir); + snprintf(error, PATH_MAX, "%s/install.err", datadir); + + // args + init_args(&al); + add_arg(&al, mysqld_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--bootstrap"); + add_arg(&al, "--skip-grant-tables"); + add_arg(&al, "--basedir=%s", base_dir); + add_arg(&al, "--datadir=%s", datadir); + add_arg(&al, "--skip-innodb"); + add_arg(&al, "--skip-bdb"); +#ifndef __NETWARE__ + add_arg(&al, "--character-sets-dir=%s", char_dir); + add_arg(&al, "--language=%s", lang_dir); +#endif + + // spawn + if ((err = spawn(mysqld_file, &al, TRUE, input, output, error, NULL)) != 0) + { + die("Unable to create database."); + } + + // free args + free_args(&al); +} + +/****************************************************************************** + + mysql_install_db() + + Install the test databases. + +******************************************************************************/ +void mysql_install_db() +{ + char temp[PATH_MAX]; + + // var directory + snprintf(temp, PATH_MAX, "%s/var", mysql_test_dir); + + // clean up old direcotry + del_tree(temp); + + // create var directory +#ifndef __WIN__ + mkdir(temp, S_IRWXU); + // create subdirectories + mlog("Creating test-suite folders...\n"); + snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); + mkdir(temp, S_IRWXU); + snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); + mkdir(temp, S_IRWXU); +#else + mkdir(temp); + // create subdirectories + mlog("Creating test-suite folders...\n"); + snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); + mkdir(temp); + snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); + mkdir(temp); +#endif + + // install databases + mlog("Creating test databases for master... \n"); + install_db(master_dir); + mlog("Creating test databases for slave... \n"); + install_db(slave_dir); +} + +/****************************************************************************** + + start_master() + + Start the master server. + +******************************************************************************/ +void start_master() +{ + arg_list_t al; + int err; + char master_out[PATH_MAX]; + char master_err[PATH_MAX]; +// char temp[PATH_MAX]; + char temp2[PATH_MAX]; + + // remove old berkeley db log files that can confuse the server + removef("%s/log.*", master_dir); + + // remove stale binary logs + removef("%s/var/log/*-bin.*", mysql_test_dir); + + // remove stale binary logs + removef("%s/var/log/*.index", mysql_test_dir); + + // remove master.info file + removef("%s/master.info", master_dir); + + // remove relay files + removef("%s/var/log/*relay*", mysql_test_dir); + + // remove relay-log.info file + removef("%s/relay-log.info", master_dir); + + // init script + if (master_init_script[0] != 0) + { +#ifdef __NETWARE__ + // TODO: use the scripts + if (strinstr(master_init_script, "repair_part2-master.sh") != 0) + { + FILE *fp; + + // create an empty index file + snprintf(temp, PATH_MAX, "%s/test/t1.MYI", master_dir); + fp = fopen(temp, "wb+"); + + fputs("1", fp); + + fclose(fp); + } +#elif !defined(__WIN__) + run_init_script(master_init_script); +#endif + } + + // redirection files + snprintf(master_out, PATH_MAX, "%s/var/run/master%u.out", + mysql_test_dir, restarts); + snprintf(master_err, PATH_MAX, "%s/var/run/master%u.err", + mysql_test_dir, restarts); +#ifndef __WIN__ + snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); + mkdir(temp2,S_IRWXU); + snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); + mkdir(temp2,S_IRWXU); +#else + snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); + mkdir(temp2); + snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); + mkdir(temp2); +#endif + // args + init_args(&al); + add_arg(&al, "%s", mysqld_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--log-bin=%s/var/log/master-bin",mysql_test_dir); + add_arg(&al, "--server-id=1"); + add_arg(&al, "--basedir=%s", base_dir); + add_arg(&al, "--port=%u", master_port); +#if !defined(__NETWARE__) && !defined(__WIN__) + add_arg(&al, "--socket=%s",master_socket); +#endif + add_arg(&al, "--local-infile"); + add_arg(&al, "--core"); + add_arg(&al, "--datadir=%s", master_dir); +#ifndef __WIN__ + add_arg(&al, "--pid-file=%s", master_pid); +#endif + add_arg(&al, "--character-sets-dir=%s", char_dir); + add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); + add_arg(&al, "--language=%s", lang_dir); +#ifdef DEBUG //only for debug builds + add_arg(&al, "--debug"); +#endif + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", server_cert); + add_arg(&al, "--ssl-key=%s", server_key); + } + + // $MASTER_40_ARGS + add_arg(&al, "--rpl-recovery-rank=1"); + add_arg(&al, "--init-rpl-role=master"); + + // $SMALL_SERVER + add_arg(&al, "-O"); + add_arg(&al, "key_buffer_size=1M"); + add_arg(&al, "-O"); + add_arg(&al, "sort_buffer=256K"); + add_arg(&al, "-O"); + add_arg(&al, "max_heap_table_size=1M"); + + // $EXTRA_MASTER_OPT + if (master_opt[0] != 0) + { + char *p; + + p = (char *)str_tok(master_opt, " \t"); + if (!strstr(master_opt, "timezone")) + { + while (p) + { + add_arg(&al, "%s", p); + p = (char *)str_tok(NULL, " \t"); + } + } + } + + // remove the pid file if it exists +#ifndef __WIN__ + remove(master_pid); +#endif + + // spawn +#ifdef __WIN__ + if ((err= spawn(mysqld_file, &al, FALSE, NULL, master_out, master_err, &master_pid)) == 0) +#else + if ((err= spawn(mysqld_file, &al, FALSE, NULL, master_out, master_err, master_pid)) == 0) +#endif + { + sleep_until_file_exists(master_pid); + + if ((err = wait_for_server_start(bin_dir, mysqladmin_file, user, password, master_port, + mysql_tmp_dir)) == 0) + { + master_running = TRUE; + } + else + { + log_error("The master server went down early."); + } + } + else + { + log_error("Unable to start master server."); + } + + // free_args + free_args(&al); +} + +/****************************************************************************** + + start_slave() + + Start the slave server. + +******************************************************************************/ +void start_slave() +{ + arg_list_t al; + int err; + char slave_out[PATH_MAX]; + char slave_err[PATH_MAX]; + + // skip? + if (skip_slave) return; + + // remove stale binary logs + removef("%s/*-bin.*", slave_dir); + + // remove stale binary logs + removef("%s/*.index", slave_dir); + + // remove master.info file + removef("%s/master.info", slave_dir); + + // remove relay files + removef("%s/var/log/*relay*", mysql_test_dir); + + // remove relay-log.info file + removef("%s/relay-log.info", slave_dir); + + // init script + if (slave_init_script[0] != 0) + { +#ifdef __NETWARE__ + // TODO: use the scripts + if (strinstr(slave_init_script, "rpl000016-slave.sh") != 0) + { + // create empty master.info file + snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); + close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); + } + else if (strinstr(slave_init_script, "rpl000017-slave.sh") != 0) + { + FILE *fp; + + // create a master.info file + snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); + fp = fopen(temp, "wb+"); + + fputs("master-bin.000001\n", fp); + fputs("4\n", fp); + fputs("127.0.0.1\n", fp); + fputs("replicate\n", fp); + fputs("aaaaaaaaaaaaaaab\n", fp); + fputs("9306\n", fp); + fputs("1\n", fp); + fputs("0\n", fp); + + fclose(fp); + } + else if (strinstr(slave_init_script, "rpl_rotate_logs-slave.sh") != 0) + { + // create empty master.info file + snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); + close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); + } +#elif !defined(__WIN__) + run_init_script(slave_init_script); +#endif + } + + // redirection files + snprintf(slave_out, PATH_MAX, "%s/var/run/slave%u.out", + mysql_test_dir, restarts); + snprintf(slave_err, PATH_MAX, "%s/var/run/slave%u.err", + mysql_test_dir, restarts); + + // args + init_args(&al); + add_arg(&al, "%s", mysqld_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--log-bin=slave-bin"); + add_arg(&al, "--relay_log=slave-relay-bin"); + add_arg(&al, "--basedir=%s", base_dir); + add_arg(&al, "--port=%u", slave_port); +#if !defined(__NETWARE__) && !defined(__WIN__) + add_arg(&al, "--socket=%s",slave_socket); +#endif + add_arg(&al, "--datadir=%s", slave_dir); +#ifndef __WIN__ + add_arg(&al, "--pid-file=%s", slave_pid); +#endif + add_arg(&al, "--character-sets-dir=%s", char_dir); + add_arg(&al, "--core"); + add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); + add_arg(&al, "--language=%s", lang_dir); + + add_arg(&al, "--exit-info=256"); + add_arg(&al, "--log-slave-updates"); + add_arg(&al, "--init-rpl-role=slave"); + add_arg(&al, "--skip-innodb"); + add_arg(&al, "--skip-slave-start"); + add_arg(&al, "--slave-load-tmpdir=../../var/tmp"); + + add_arg(&al, "--report-user=%s", user); + add_arg(&al, "--report-host=127.0.0.1"); + add_arg(&al, "--report-port=%u", slave_port); + + add_arg(&al, "--master-retry-count=10"); + add_arg(&al, "-O"); + add_arg(&al, "slave_net_timeout=10"); +#ifdef DEBUG //only for debug builds + add_arg(&al, "--debug"); +#endif + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", server_cert); + add_arg(&al, "--ssl-key=%s", server_key); + } + + // slave master info + if (slave_master_info[0] != 0) + { + char *p; + + p = (char *)str_tok(slave_master_info, " \t"); + + while(p) + { + add_arg(&al, "%s", p); + + p = (char *)str_tok(NULL, " \t"); + } + } + else + { + add_arg(&al, "--master-user=%s", user); + add_arg(&al, "--master-password=%s", password); + add_arg(&al, "--master-host=127.0.0.1"); + add_arg(&al, "--master-port=%u", master_port); + add_arg(&al, "--master-connect-retry=1"); + add_arg(&al, "--server-id=2"); + add_arg(&al, "--rpl-recovery-rank=2"); + } + + // small server + add_arg(&al, "-O"); + add_arg(&al, "key_buffer_size=1M"); + add_arg(&al, "-O"); + add_arg(&al, "sort_buffer=256K"); + add_arg(&al, "-O"); + add_arg(&al, "max_heap_table_size=1M"); + + + // opt args + if (slave_opt[0] != 0) + { + char *p; + + p = (char *)str_tok(slave_opt, " \t"); + + while(p) + { + add_arg(&al, "%s", p); + + p = (char *)str_tok(NULL, " \t"); + } + } + + // remove the pid file if it exists +#ifndef __WIN__ + remove(slave_pid); +#endif + // spawn +#ifdef __WIN__ + if ((err = spawn(mysqld_file, &al, FALSE, NULL, slave_out, slave_err, &slave_pid)) == 0) +#else + if ((err = spawn(mysqld_file, &al, FALSE, NULL, slave_out, slave_err, slave_pid)) == 0) +#endif + { + sleep_until_file_exists(slave_pid); + + if ((err = wait_for_server_start(bin_dir, mysqladmin_file, user, password, slave_port, + mysql_tmp_dir)) == 0) + { + slave_running = TRUE; + } + else + { + log_error("The slave server went down early."); + } + } + else + { + log_error("Unable to start slave server."); + } + + // free args + free_args(&al); +} + +/****************************************************************************** + + mysql_start() + + Start the mysql servers. + +******************************************************************************/ +void mysql_start() +{ +// log_info("Starting the MySQL server(s): %u", ++restarts); + start_master(); + + start_slave(); + + // activate the test screen +#ifdef __NETWARE__ + ActivateScreen(getscreenhandle()); +#endif +} + +/****************************************************************************** + + stop_slave() + + Stop the slave server. + +******************************************************************************/ +void stop_slave() +{ + int err; + + // running? + if (!slave_running) return; + + // stop + if ((err = stop_server(bin_dir, mysqladmin_file, user, password, slave_port, slave_pid, + mysql_tmp_dir)) == 0) + { + slave_running = FALSE; + } + else + { + log_error("Unable to stop slave server."); + } +} + +/****************************************************************************** + + stop_master() + + Stop the master server. + +******************************************************************************/ +void stop_master() +{ + int err; + + // running? + if (!master_running) return; + + if ((err = stop_server(bin_dir, mysqladmin_file, user, password, master_port, master_pid, + mysql_tmp_dir)) == 0) + { + master_running = FALSE; + } + else + { + log_error("Unable to stop master server."); + } +} + +/****************************************************************************** + + mysql_stop() + + Stop the mysql servers. + +******************************************************************************/ +void mysql_stop() +{ + + stop_master(); + + stop_slave(); + + // activate the test screen +#ifdef __NETWARE__ + ActivateScreen(getscreenhandle()); +#endif +} + +/****************************************************************************** + + mysql_restart() + + Restart the mysql servers. + +******************************************************************************/ +void mysql_restart() +{ +// log_info("Restarting the MySQL server(s): %u", ++restarts); + + mysql_stop(); + + mlog(DASH); + + mysql_start(); +} + +/****************************************************************************** + + read_option() + + Read the option file. + +******************************************************************************/ +int read_option(char *opt_file, char *opt) +{ + int fd, err; + char *p; + char buf[PATH_MAX]; + + // copy current option + strncpy(buf, opt, PATH_MAX); + + // open options file + fd = open(opt_file, O_RDONLY); + + err = read(fd, opt, PATH_MAX); + + close(fd); + + if (err > 0) + { + // terminate string + if ((p = strchr(opt, '\n')) != NULL) + { + *p = 0; + + // check for a '\r' + if ((p = strchr(opt, '\r')) != NULL) + { + *p = 0; + } + } + else + { + opt[err] = 0; + } + + // check for $MYSQL_TEST_DIR + if ((p = strstr(opt, "$MYSQL_TEST_DIR")) != NULL) + { + char temp[PATH_MAX]; + + *p = 0; + + strcpy(temp, p + strlen("$MYSQL_TEST_DIR")); + + strcat(opt, mysql_test_dir); + + strcat(opt, temp); + } + // Check for double backslash and replace it with single bakslash + if ((p = strstr(opt, "\\\\")) != NULL) + { + /* bmove is guranteed to work byte by byte */ + bmove(p, p+1, strlen(p+1)); + } + } + else + { + // clear option + *opt = 0; + } + + // compare current option with previous + return strcmp(opt, buf); +} + +/****************************************************************************** + + run_test() + + Run the given test case. + +******************************************************************************/ +void run_test(char *test) +{ + char temp[PATH_MAX]; + const char *rstr; + int skip = FALSE, ignore=FALSE; + int restart = FALSE; + int flag = FALSE; + struct stat info; + + // skip tests in the skip list + snprintf(temp, PATH_MAX, " %s ", test); + skip = (strinstr(skip_test, temp) != 0); + if (skip == FALSE) + ignore = (strinstr(ignore_test, temp) != 0); + + snprintf(master_init_script, PATH_MAX, "%s/%s-master.sh", test_dir, test); + snprintf(slave_init_script, PATH_MAX, "%s/%s-slave.sh", test_dir, test); +#ifdef __WIN__ + if (! stat(master_init_script, &info)) + skip = TRUE; + if (!stat(slave_init_script, &info)) + skip = TRUE; +#endif + if (ignore) + { + // show test + mlog("%-46s ", test); + + // ignore + rstr = TEST_IGNORE; + ++total_ignore; + } + else if (!skip) // skip test? + { + char test_file[PATH_MAX]; + char master_opt_file[PATH_MAX]; + char slave_opt_file[PATH_MAX]; + char slave_master_info_file[PATH_MAX]; + char result_file[PATH_MAX]; + char reject_file[PATH_MAX]; + char out_file[PATH_MAX]; + char err_file[PATH_MAX]; + int err; + arg_list_t al; +#ifdef __WIN__ + /* + Clean test database + */ + removef("%s/test/*.*", master_dir); + removef("%s/test/*.*", slave_dir); + removef("%s/mysqltest/*.*", master_dir); + removef("%s/mysqltest/*.*", slave_dir); + +#endif + // skip slave? + flag = skip_slave; + skip_slave = (strncmp(test, "rpl", 3) != 0); + if (flag != skip_slave) restart = TRUE; + + // create files + snprintf(master_opt_file, PATH_MAX, "%s/%s-master.opt", test_dir, test); + snprintf(slave_opt_file, PATH_MAX, "%s/%s-slave.opt", test_dir, test); + snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", test_dir, test); + snprintf(reject_file, PATH_MAX, "%s/%s%s", result_dir, test, REJECT_SUFFIX); + snprintf(out_file, PATH_MAX, "%s/%s%s", result_dir, test, OUT_SUFFIX); + snprintf(err_file, PATH_MAX, "%s/%s%s", result_dir, test, ERR_SUFFIX); + + // netware specific files + snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, NW_TEST_SUFFIX); + if (stat(test_file, &info)) + { + snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, TEST_SUFFIX); + if (access(test_file,0)) + { + printf("Invalid test name %s, %s file not found\n",test,test_file); + return; + } + } + + snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, NW_RESULT_SUFFIX); + if (stat(result_file, &info)) + { + snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, RESULT_SUFFIX); + } + + // init scripts + if (stat(master_init_script, &info)) + master_init_script[0] = 0; + else + restart = TRUE; + + if (stat(slave_init_script, &info)) + slave_init_script[0] = 0; + else + restart = TRUE; + + // read options + if (read_option(master_opt_file, master_opt)) restart = TRUE; + if (read_option(slave_opt_file, slave_opt)) restart = TRUE; + if (read_option(slave_master_info_file, slave_master_info)) restart = TRUE; + + // cleanup previous run + remove(reject_file); + remove(out_file); + remove(err_file); + + // start or restart? + if (!master_running) mysql_start(); + else if (restart) mysql_restart(); + + // let the system stabalize + sleep(1); + + // show test + mlog("%-46s ", test); + + + // args + init_args(&al); + add_arg(&al, "%s", mysqltest_file); + add_arg(&al, "--no-defaults"); + add_arg(&al, "--port=%u", master_port); +#if !defined(__NETWARE__) && !defined(__WIN__) + add_arg(&al, "--socket=%s", master_socket); + add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); +#endif + add_arg(&al, "--database=%s", db); + add_arg(&al, "--user=%s", user); + add_arg(&al, "--password=%s", password); + add_arg(&al, "--silent"); + add_arg(&al, "--basedir=%s/", mysql_test_dir); + add_arg(&al, "--host=127.0.0.1"); + add_arg(&al, "-v"); + add_arg(&al, "-R"); + add_arg(&al, "%s", result_file); + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", client_cert); + add_arg(&al, "--ssl-key=%s", client_key); + } + + // spawn + err = spawn(mysqltest_file, &al, TRUE, test_file, out_file, err_file, NULL); + + // free args + free_args(&al); + + remove_empty_file(out_file); + remove_empty_file(err_file); + + if (err == 0) + { + // pass + rstr = TEST_PASS; + ++total_pass; + + // increment total + ++total_test; + } + else if (err == 2) + { + // skip + rstr = TEST_SKIP; + ++total_skip; + } + else if (err == 1) + { + // fail + rstr = TEST_FAIL; + ++total_fail; + + // increment total + ++total_test; + } + else + { + rstr = TEST_BAD; + } + } + else // early skips + { + // show test + mlog("%-46s ", test); + + // skip + rstr = TEST_SKIP; + ++total_skip; + } + + // result + mlog("%-14s\n", rstr); +} + +/****************************************************************************** + + vlog() + + Log the message. + +******************************************************************************/ +void vlog(const char *format, va_list ap) +{ + vfprintf(stdout, format, ap); + fflush(stdout); + + if (log_fd) + { + vfprintf(log_fd, format, ap); + fflush(log_fd); + } +} + +/****************************************************************************** + + log() + + Log the message. + +******************************************************************************/ +void mlog(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + vlog(format, ap); + + va_end(ap); +} + +/****************************************************************************** + + log_info() + + Log the given information. + +******************************************************************************/ +void log_info(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + mlog("-- INFO : "); + vlog(format, ap); + mlog("\n"); + + va_end(ap); +} + +/****************************************************************************** + + log_error() + + Log the given error. + +******************************************************************************/ +void log_error(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + mlog("-- ERROR: "); + vlog(format, ap); + mlog("\n"); + + va_end(ap); +} + +/****************************************************************************** + + log_errno() + + Log the given error and errno. + +******************************************************************************/ +void log_errno(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + mlog("-- ERROR: (%003u) ", errno); + vlog(format, ap); + mlog("\n"); + + va_end(ap); +} + +/****************************************************************************** + + die() + + Exit the application. + +******************************************************************************/ +void die(const char *msg) +{ + log_error(msg); +#ifdef __NETWARE__ + pressanykey(); +#endif + exit(-1); +} + +/****************************************************************************** + + setup() + + Setup the mysql test enviornment. + +******************************************************************************/ +void setup(char *file) +{ + char temp[PATH_MAX]; + char file_path[PATH_MAX*2]; + char *p; + int position; + + // set the timezone for the timestamp test +#ifdef __WIN__ + _putenv( "TZ=GMT-3" ); +#else + setenv("TZ", "GMT-3", TRUE); +#endif + // find base dir +#ifdef __NETWARE__ + strcpy(temp, strlwr(file)); + while((p = strchr(temp, '\\')) != NULL) *p = '/'; +#else + getcwd(temp, PATH_MAX); + position = strlen(temp); + temp[position] = '/'; + temp[position+1] = 0; +#ifdef __WIN__ + while((p = strchr(temp, '\\')) != NULL) *p = '/'; +#endif +#endif + + if ((position = strinstr(temp, "/mysql-test/")) != 0) + { + p = temp + position - 1; + *p = 0; + strcpy(base_dir, temp); + } + + log_info("Currect directory: %s",base_dir); + +#ifdef __NETWARE__ + // setup paths + snprintf(bin_dir, PATH_MAX, "%s/bin", base_dir); + snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); + snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); + snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); + snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); + snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); + snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); + snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); + +#ifdef HAVE_OPENSSL + use_openssl = TRUE; +#endif // HAVE_OPENSSL + + // OpenSSL paths + snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); + snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); + snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); + snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); + snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); + + // setup files + snprintf(mysqld_file, PATH_MAX, "%s/mysqld", bin_dir); + snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); + snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); + snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); + snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); +#elif __WIN__ + // setup paths +#ifdef _DEBUG + snprintf(bin_dir, PATH_MAX, "%s/client_debug", base_dir); +#else + snprintf(bin_dir, PATH_MAX, "%s/client_release", base_dir); +#endif + snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); + snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); + snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); + snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); + snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); + snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); + snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); + +#ifdef HAVE_OPENSSL + use_openssl = TRUE; +#endif // HAVE_OPENSSL + + // OpenSSL paths + snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); + snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); + snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); + snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); + snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); + + // setup files + snprintf(mysqld_file, PATH_MAX, "%s/mysqld.exe", bin_dir); + snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest.exe", bin_dir); + snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin.exe", bin_dir); +#else + // setup paths + snprintf(bin_dir, PATH_MAX, "%s/client", base_dir); + snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); + snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); + snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); + snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); + snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); + snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); + snprintf(lang_dir, PATH_MAX, "%s/sql/share/english", base_dir); + snprintf(char_dir, PATH_MAX, "%s/sql/share/charsets", base_dir); + +#ifdef HAVE_OPENSSL + use_openssl = TRUE; +#endif // HAVE_OPENSSL + + // OpenSSL paths + snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); + snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); + snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); + snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); + snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); + + // setup files + snprintf(mysqld_file, PATH_MAX, "%s/sql/mysqld", base_dir); + snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); + snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); + snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); + snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); + + snprintf(master_socket,PATH_MAX, "%s/var/tmp/master.sock", mysql_test_dir); + snprintf(slave_socket,PATH_MAX, "%s/var/tmp/slave.sock", mysql_test_dir); + +#endif + // create log file + snprintf(temp, PATH_MAX, "%s/mysql-test-run.log", mysql_test_dir); + if ((log_fd = fopen(temp, "w+")) == NULL) + { + log_errno("Unable to create log file."); + } + + // prepare skip test list + while((p = strchr(skip_test, ',')) != NULL) *p = ' '; + strcpy(temp, strlwr(skip_test)); + snprintf(skip_test, PATH_MAX, " %s ", temp); + + // environment +#ifdef __NETWARE__ + setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); + snprintf(file_path, PATH_MAX*2, "%s/client/mysqldump --no-defaults -u root --port=%u", bin_dir, master_port); + setenv("MYSQL_DUMP", file_path, 1); + snprintf(file_path, PATH_MAX*2, "%s/client/mysqlbinlog --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + setenv("MYSQL_BINLOG", file_path, 1); +#elif __WIN__ + snprintf(file_path,MAX_PATH,"MYSQL_TEST_DIR=%s",mysql_test_dir); + _putenv(file_path); + snprintf(file_path, PATH_MAX*2, "MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u", bin_dir, master_port); + _putenv(file_path); + snprintf(file_path, PATH_MAX*2, "MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + _putenv(file_path); +#else + setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); + snprintf(file_path, PATH_MAX*2, "%s/mysqldump --no-defaults -u root --port=%u --socket=%s", bin_dir, master_port, master_socket); + setenv("MYSQL_DUMP", file_path, 1); + snprintf(file_path, PATH_MAX*2, "%s/mysqlbinlog --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + setenv("MYSQL_BINLOG", file_path, 1); +#endif + +#ifndef __WIN__ + setenv("MASTER_MYPORT", "9306", 1); + setenv("SLAVE_MYPORT", "9307", 1); + setenv("MYSQL_TCP_PORT", "3306", 1); +#else + _putenv("MASTER_MYPORT=9306"); + _putenv("SLAVE_MYPORT=9307"); + _putenv("MYSQL_TCP_PORT=3306"); +#endif + +} + +/****************************************************************************** + + main() + +******************************************************************************/ +int main(int argc, char **argv) +{ + int is_ignore_list = 0; + // setup + setup(argv[0]); + + /* The --ignore option is comma saperated list of test cases to skip and + should be very first command line option to the test suite. + + The usage is now: + mysql_test_run --ignore=test1,test2 test3 test4 + where test1 and test2 are test cases to ignore + and test3 and test4 are test cases to run. + */ + if (argc >= 2 && !strnicmp(argv[1], "--ignore=", sizeof("--ignore=")-1)) + { + char *temp, *token; + temp= strdup(strchr(argv[1],'=') + 1); + for (token=str_tok(temp, ","); token != NULL; token=str_tok(NULL, ",")) + { + if (strlen(ignore_test) + strlen(token) + 2 <= PATH_MAX-1) + sprintf(ignore_test+strlen(ignore_test), " %s ", token); + else + { + free(temp); + die("ignore list too long."); + } + } + free(temp); + is_ignore_list = 1; + } + // header +#ifndef __WIN__ + mlog("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); +#else + mlog("MySQL Server ---, for %s (%s)\n\n", SYSTEM_TYPE, MACHINE_TYPE); +#endif + + mlog("Initializing Tests...\n"); + + // install test databases + mysql_install_db(); + + mlog("Starting Tests...\n"); + + mlog("\n"); + mlog(HEADER); + mlog(DASH); + + if ( argc > 1 + is_ignore_list ) + { + int i; + + // single test + single_test = TRUE; + + for (i = 1 + is_ignore_list; i < argc; i++) + { + // run given test + run_test(argv[i]); + } + } + else + { + // run all tests +#ifndef __WIN__ + struct dirent **namelist; + int i,n; + char test[NAME_MAX]; + char *p; + int position; + + n = scandir(test_dir, &namelist, 0, alphasort); + if (n < 0) + die("Unable to open tests directory."); + else + { + for (i = 0; i < n; i++) + { + strcpy(test, strlwr(namelist[i]->d_name)); + // find the test suffix + if ((position = strinstr(test, TEST_SUFFIX)) != 0) + { + p = test + position - 1; + // null terminate at the suffix + *p = 0; + // run test + run_test(test); + } + free(namelist[n]); + } + free(namelist); + } +#else + struct _finddata_t dir; + intptr_t handle; + char test[NAME_MAX]; + char mask[PATH_MAX]; + char *p; + int position; + char **names = 0; + char **testes = 0; + int name_index; + int index; + + // single test + single_test = FALSE; + + snprintf(mask,MAX_PATH,"%s/*.test",test_dir); + + if ((handle=_findfirst(mask,&dir)) == -1L) + { + die("Unable to open tests directory."); + } + + names = malloc(MAX_COUNT_TESTES*4); + testes = names; + name_index = 0; + + do + { + if (!(dir.attrib & _A_SUBDIR)) + { + strcpy(test, strlwr(dir.name)); + + // find the test suffix + if ((position = strinstr(test, TEST_SUFFIX)) != 0) + { + p = test + position - 1; + // null terminate at the suffix + *p = 0; + + // insert test + *names = malloc(PATH_MAX); + strcpy(*names,test); + names++; + name_index++; + } + } + }while (_findnext(handle,&dir) == 0); + + _findclose(handle); + + qsort( (void *)testes, name_index, sizeof( char * ), compare ); + + for (index = 0; index <= name_index; index++) + { + run_test(testes[index]); + free(testes[index]); + } + + free(testes); +#endif + } + + // stop server + mysql_stop(); + + mlog(DASH); + mlog("\n"); + + mlog("Ending Tests...\n"); + + // report stats + report_stats(); + + // close log + if (log_fd) fclose(log_fd); + + // keep results up +#ifdef __NETWARE__ + pressanykey(); +#endif + return 0; +} + + +/* + Synopsis: + This function breaks the string into a sequence of tokens. The difference + between this function and strtok is that it respects the quoted string i.e. + it skips any delimiter character within the quoted part of the string. + It return tokens by eliminating quote character. It modifies the input string + passed. It will work with whitespace delimeter but may not work properly with + other delimeter. If the delimeter will contain any quote character, then + function will not tokenize and will return null string. + e.g. if input string is + --init-slave="set global max_connections=500" --skip-external-locking + then the output will two string i.e. + --init-slave=set global max_connections=500 + --skip-external-locking + +Arguments: + string: input string + delim: set of delimiter character +Output: + return the null terminated token of NULL. +*/ + + +char *str_tok(char *string, const char *delim) +{ + char *token; /* current token received from strtok */ + char *qt_token; /* token delimeted by the matching pair of quote */ + /* + if there are any quote chars found in the token then this variable + will hold the concatenated string to return to the caller + */ + char *ptr_token=NULL; + /* pointer to the quote character in the token from strtok */ + char *ptr_quote=NULL; + + /* See if the delimeter contains any quote character */ + if (strchr(delim,'\'') || strchr(delim,'\"')) + return NULL; + + /* repeate till we are getting some token from strtok */ + while ((token = (char*)strtok(string, delim) ) != NULL) + { + /* + make the input string NULL so that next time onward strtok can + be called with NULL input string. + */ + string = NULL; + /* + We don't need to remove any quote character for Windows version + */ +#ifndef __WIN__ + /* check if the current token contain double quote character*/ + if ((ptr_quote = (char*)strchr(token,'\"')) != NULL) + { + /* + get the matching the matching double quote in the remaining + input string + */ + qt_token = (char*)strtok(NULL,"\""); + } + /* check if the current token contain single quote character*/ + else if ((ptr_quote = (char*)strchr(token,'\'')) != NULL) + { + /* + get the matching the matching single quote in the remaining + input string + */ + qt_token = (char*)strtok(NULL,"\'"); + } +#endif + /* + if the current token does not contains any quote character then + return to the caller. + */ + if (ptr_quote == NULL) + { + /* + if there is any earlier token i.e. ptr_token then append the + current token in it and return it else return the current + token directly + */ + return ptr_token ? strcat(ptr_token,token) : token; + } + + /* + remove the quote character i.e. make NULL so that the token will + be devided in two part and later both part can be concatenated + and hence quote will be removed + */ + *ptr_quote= 0; + + /* check if ptr_token has been initialized or not */ + if (ptr_token == NULL) + { + /* initialize the ptr_token with current token */ + ptr_token= token; + /* copy entire string between matching pair of quote*/ + sprintf(ptr_token+strlen(ptr_token),"%s %s", ptr_quote+1, qt_token); + } + else + { + /* + copy the current token and entire string between matching pair + of quote + */ + if (qt_token == NULL) + { + sprintf(ptr_token+strlen(ptr_token),"%s%s", token, ptr_quote+1); + } + else + { + sprintf(ptr_token+strlen(ptr_token),"%s%s %s", token, ptr_quote+1, + qt_token ); + } + } + } + + /* return the concatenated token */ + return ptr_token; +} + +#ifndef __WIN__ + +/* + Synopsis: + This function run scripts files on Linux and Netware + +Arguments: + script_name: name of script file + +Output: + nothing +*/ +void run_init_script(const char *script_name) +{ + arg_list_t al; + int err; + + // args + init_args(&al); + add_arg(&al, sh_file); + add_arg(&al, script_name); + + // spawn + if ((err = spawn(sh_file, &al, TRUE, NULL, NULL, NULL, NULL)) != 0) + { + die("Unable to run script."); + } + + // free args + free_args(&al); +} +#endif From 31962735902dfee0c8983af504c024926f7d3824 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Thu, 4 Nov 2004 21:26:36 +0300 Subject: [PATCH 073/101] Fix for Bug#6408 "configure checking for custom zlib fails because code check is wrong". --- acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 7f25b447f10..671e279a9f3 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -208,7 +208,7 @@ INCLUDES="$INCLUDES $ZLIB_INCLUDES" LIBS="$LIBS $ZLIB_LIBS" AC_CACHE_VAL([mysql_cv_compress], [AC_TRY_LINK([#include ], - [int link_test() { return compress(0, (unsigned long*) 0, "", 0); }], + [return compress(0, (unsigned long*) 0, "", 0);], [mysql_cv_compress="yes" AC_MSG_RESULT([ok])], [mysql_cv_compress="no"]) From c1dc0975c6e430c9dc7cc68af2f8953fe26a52e7 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Fri, 5 Nov 2004 00:45:41 +0300 Subject: [PATCH 074/101] A test case for Bug#4172 "Floating point conversion looses precision (prepared staements)": adding the test case to close the bug (the bug was fixed along with other conversion incompatibilities in 4.1.7) --- tests/client_test.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/client_test.c b/tests/client_test.c index 227f7e29ef2..004f076c6df 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -11082,12 +11082,77 @@ static void test_bug6096() free(bind[i].buffer); mysql_stmt_close(stmt); mysql_free_result(query_result); + mysql_free_result(stmt_metadata); stmt_text= "drop table t1"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); } +static void test_bug4172() +{ + MYSQL_STMT *stmt; + MYSQL_BIND bind[3]; + const char *stmt_text; + MYSQL_RES *res; + MYSQL_ROW row; + int rc; + char f[100], d[100], e[100]; + long f_len, d_len, e_len; + + myheader("test_bug4172"); + + mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + mysql_query(mysql, "CREATE TABLE t1 (f float, d double, e decimal(10,4))"); + mysql_query(mysql, "INSERT INTO t1 VALUES (12345.1234, 123456.123456, " + "123456.1234)"); + + stmt= mysql_stmt_init(mysql); + stmt_text= "SELECT f, d, e FROM t1"; + + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + bzero(bind, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= f; + bind[0].buffer_length= sizeof(f); + bind[0].length= &f_len; + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= d; + bind[1].buffer_length= sizeof(d); + bind[1].length= &d_len; + bind[2].buffer_type= MYSQL_TYPE_STRING; + bind[2].buffer= e; + bind[2].buffer_length= sizeof(e); + bind[2].length= &e_len; + + mysql_stmt_bind_result(stmt, bind); + + mysql_stmt_store_result(stmt); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); + + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + res= mysql_store_result(mysql); + row= mysql_fetch_row(res); + + printf("Binary protocol: float=%s, double=%s, decimal(10,4)=%s\n", + f, d, e); + printf("Text protocol: float=%s, double=%s, decimal(10,4)=%s\n", + row[0], row[1], row[2]); + + DIE_UNLESS(!strcmp(f, row[0]) && !strcmp(d, row[1]) && !strcmp(e, row[2])); + + mysql_free_result(res); + mysql_stmt_close(stmt); +} + + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -11404,6 +11469,8 @@ int main(int argc, char **argv) test_bug6046(); /* NATURAL JOIN transformation works in PS */ test_bug6081(); /* test of mysql_create_db()/mysql_rm_db() */ test_bug6096(); /* max_length for numeric columns */ + test_bug4172(); /* floating point conversions in libmysql */ + /* XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. From 1a6889bb5c48349db5615188a2f6eda1aa07bfab Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 5 Nov 2004 08:08:38 +0400 Subject: [PATCH 075/101] mysqladmin.c: Missing initialized for "lengths" element. , --- client/mysqladmin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqladmin.c b/client/mysqladmin.c index bccbf29ef83..6258b9685a5 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -108,7 +108,7 @@ static const char *command_names[]= { }; static TYPELIB command_typelib= -{ array_elements(command_names)-1,"commands", command_names}; +{ array_elements(command_names)-1,"commands", command_names, NULL}; static struct my_option my_long_options[] = { From 4df18b1aaebc408c1f60a8c155121d7350e28c94 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Thu, 4 Nov 2004 20:39:52 -0800 Subject: [PATCH 076/101] func_in.result, func_in.test: Added a case for bug #6365. item_cmpfunc.cc: Fixed bug #6365 : Server crashed when list of values in IN predicate contains NULL while the tested field is of the character type and not of the default set; e.g. when f in 'f IN (NULL,'aa') belongs to binary character set, while the default character set is latin1. --- mysql-test/r/func_in.result | 6 ++++++ mysql-test/t/func_in.test | 7 +++++++ sql/item_cmpfunc.cc | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 374affce8c5..daeda51a12a 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -179,3 +179,9 @@ select 1 in ('1.1',2); select 1 in ('1.1',2.0); 1 in ('1.1',2.0) 0 +create table t1 (a char(20) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 22079377ad2..3cd8c064817 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -89,3 +89,10 @@ select 1 in ('1.0',2.0); select 1 in (1.0,'2.0'); select 1 in ('1.1',2); select 1 in ('1.1',2.0); + +# Test case for bug #6365 + +create table t1 (a char(20) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +drop table t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 701894cacb5..a28f0f5d4a9 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1749,7 +1749,8 @@ void Item_func_in::fix_length_and_dec() thd->set_n_backup_item_arena(arena, &backup); for (arg= args+1, arg_end= args+arg_count; arg < arg_end; arg++) { - if (!my_charset_same(cmp_collation.collation, + if (!arg[0]->null_value && + !my_charset_same(cmp_collation.collation, arg[0]->collation.collation)) { Item_string *conv; From 27fcb9f6af4f16640f519c10d4df54792ac5de4e Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 5 Nov 2004 08:44:40 +0400 Subject: [PATCH 077/101] libmysql.def, libmysql.c: Minor clean-ups --- libmysql/libmysql.c | 3 ++- libmysql/libmysql.def | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 88f46ce19e7..a57c82e6424 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1563,7 +1563,8 @@ void my_net_local_init(NET *net) trailing '. The caller must supply whichever of those is desired. */ -ulong mysql_hex_string(char *to, const char *from, ulong length) +ulong STDCALL +mysql_hex_string(char *to, const char *from, ulong length) { char *to0= to; const char *end; diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index bc91e90a41c..c9ff70f208d 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -47,6 +47,7 @@ EXPORTS mysql_errno mysql_error mysql_escape_string + mysql_hex_string mysql_stmt_execute mysql_stmt_fetch mysql_stmt_fetch_column From 7253d4c4f6a0073572582cf2f09a10df5fbaeb4d Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 5 Nov 2004 08:54:52 +0400 Subject: [PATCH 078/101] mysqldump.c: - 'mysqldump --help' comment that --xeh-blob doesn't work with --extended-inserts was removed. It does work now. Thanks to Lachlan who noticed this wrong help message. - Switched to use the recently introduced mysql_hex_string() instead of slow sprintf(). Thanks to Sinisa for the idea. - 'mysqldump --hex-blob' dumps in HEX not only BLOBs but also BINARY(x) columns. Thanks to Paul. --- client/mysqldump.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 1686278096b..a8db8ab440b 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -124,7 +124,7 @@ const char *compatible_mode_names[]= (1<<10) /* ANSI */\ ) TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1, - "", compatible_mode_names}; + "", compatible_mode_names, NULL}; static struct my_option my_long_options[] = @@ -317,7 +317,7 @@ static struct my_option my_long_options[] = {"comments", 'i', "Write additional information.", (gptr*) &opt_comments, (gptr*) &opt_comments, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"hex-blob", OPT_HEXBLOB, "Dump BLOBs in HEX. this mode does not work with extended-insert", + {"hex-blob", OPT_HEXBLOB, "Dump BLOBs in HEX.", (gptr*) &opt_hex_blob, (gptr*) &opt_hex_blob, 0, GET_BOOL, 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} }; @@ -1523,10 +1523,11 @@ static void dumpTable(uint numFields, char *table) /* 63 is my_charset_bin. If charsetnr is not 63, we have not a BLOB but a TEXT column. - we'll dump it in hex only BLOB columns. + we'll dump in hex only BLOB columns. */ is_blob= (opt_hex_blob && field->charsetnr == 63 && - (field->type == FIELD_TYPE_BLOB || + (field->type == FIELD_TYPE_STRING || + field->type == FIELD_TYPE_BLOB || field->type == FIELD_TYPE_LONG_BLOB || field->type == FIELD_TYPE_MEDIUM_BLOB || field->type == FIELD_TYPE_TINY_BLOB)) ? 1 : 0; @@ -1544,6 +1545,13 @@ static void dumpTable(uint numFields, char *table) { if (!IS_NUM_FIELD(field)) { + /* + "length * 2 + 2" is OK for both HEX and non-HEX modes: + - In HEX mode we need exactly 2 bytes per character + plus 2 bytes for '0x' prefix. + - In non-HEX mode we need up to 2 bytes per character, + plus 2 bytes for leading and trailing '\'' characters. + */ if (dynstr_realloc(&extended_row,length * 2+2)) { fputs("Aborting dump (out of memory)",stderr); @@ -1552,15 +1560,11 @@ static void dumpTable(uint numFields, char *table) } if (opt_hex_blob && is_blob) { - ulong counter; - unsigned char *ptr= row[i]; dynstr_append(&extended_row, "0x"); - for (counter = 0; counter < lengths[i]; counter++) - { - char xx[3]; - sprintf(xx, "%02X", ptr[counter]); - dynstr_append(&extended_row, xx); - } + extended_row.length+= mysql_hex_string(extended_row.str + + extended_row.length, + row[i], length); + extended_row.str[extended_row.length]= '\0'; } else { From ae5c3ae0bab9d386b462e23900e0e2fc4009db8c Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 5 Nov 2004 10:12:33 +0400 Subject: [PATCH 079/101] ps.result, ctype_ucs.result, ctype_ucs.test, ps.test: Bug #6351 make test failure "Unknown character set" UCS2 related tests were moved into ctype_ucs. --- mysql-test/r/ctype_ucs.result | 7 +++++++ mysql-test/r/ps.result | 6 ------ mysql-test/t/ctype_ucs.test | 8 ++++++++ mysql-test/t/ps.test | 4 ---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 1d3deb0b09a..0e36b00a670 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -480,3 +480,10 @@ a 0061 b 0062 c 0063 drop table t1; +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using ucs2); +prepare stmt1 from @str2; +execute stmt1 using @ivar; +? +1234 diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 6cad58282a2..6d9cfabb5a7 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -106,12 +106,6 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp set @fvar= 123.4567; prepare stmt1 from @fvar; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '123.4567' at line 1 -set @str1 = 'select ?'; -set @str2 = convert(@str1 using ucs2); -prepare stmt1 from @str2; -execute stmt1 using @ivar; -? -1234 drop table t1,t2; PREPARE stmt1 FROM "select _utf8 'A' collate utf8_bin = ?"; set @var='A'; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index d9ef91496e9..4c6d1bbebef 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -315,3 +315,11 @@ alter table t1 modify a char(5); select a, hex(a) from t1; drop table t1; +# +# Check prepare statement from an UCS2 string +# +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using ucs2); +prepare stmt1 from @str2; +execute stmt1 using @ivar; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 978ce2bc2c3..2b3e961fc28 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -110,10 +110,6 @@ set @fvar= 123.4567; --error 1064 prepare stmt1 from @fvar; -set @str1 = 'select ?'; -set @str2 = convert(@str1 using ucs2); -prepare stmt1 from @str2; -execute stmt1 using @ivar; drop table t1,t2; # From 5543f312b046045d7cdbd0e3357ba4ea0efe3842 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 5 Nov 2004 13:37:36 +0400 Subject: [PATCH 080/101] As it is wrong and confusing to associate any character set with NULL, @a should be latin2 after this query sequence: SET @a=_latin2'string'; SET @a=NULL; I.e. the second query should not change the charset to the current default value, but should keep the original value assigned during the first query. In order to do it, we don't copy charset from the argument if the argument is NULL and the variable has previously been initialized. --- mysql-test/r/ps_2myisam.result | 76 ++++++++--------- mysql-test/r/ps_3innodb.result | 76 ++++++++--------- mysql-test/r/ps_4heap.result | 108 +++++++++++------------ mysql-test/r/ps_5merge.result | 152 ++++++++++++++++----------------- mysql-test/r/ps_6bdb.result | 76 ++++++++--------- mysql-test/r/ps_7ndb.result | 108 +++++++++++------------ sql/item_func.cc | 21 ++++- 7 files changed, 317 insertions(+), 300 deletions(-) diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index efb12561950..345929d8104 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1793,7 +1793,7 @@ t5 CREATE TABLE `t5` ( `const12` char(0) default NULL, `param12` bigint(20) default NULL, `param13` double default NULL, - `param14` longblob, + `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t5 ; @@ -1823,7 +1823,7 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 0 0 8 def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 def test t5 t5 param13 param13 5 20 0 Y 32768 31 63 -def test t5 t5 param14 param14 252 16777215 0 Y 144 0 63 +def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63 const01 8 param01 8 @@ -1976,19 +1976,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2066,19 +2066,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2158,19 +2158,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2242,19 +2242,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index cb096882d13..45a3af8e6fa 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1776,7 +1776,7 @@ t5 CREATE TABLE `t5` ( `const12` char(0) default NULL, `param12` bigint(20) default NULL, `param13` double default NULL, - `param14` longblob, + `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t5 ; @@ -1806,7 +1806,7 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 0 0 8 def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 def test t5 t5 param13 param13 5 20 0 Y 32768 31 63 -def test t5 t5 param14 param14 252 16777215 0 Y 144 0 63 +def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63 const01 8 param01 8 @@ -1959,19 +1959,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2049,19 +2049,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2141,19 +2141,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2225,19 +2225,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index ac9946ef070..995224fcd21 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1777,7 +1777,7 @@ t5 CREATE TABLE `t5` ( `const12` char(0) default NULL, `param12` bigint(20) default NULL, `param13` double default NULL, - `param14` longblob, + `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t5 ; @@ -1807,7 +1807,7 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 0 0 8 def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 def test t5 t5 param13 param13 5 20 0 Y 32768 31 63 -def test t5 t5 param14 param14 252 16777215 0 Y 144 0 63 +def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63 const01 8 param01 8 @@ -1960,19 +1960,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2050,19 +2050,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2142,19 +2142,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2226,19 +2226,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 15e707959ca..7a0191b186a 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1716,7 +1716,7 @@ t5 CREATE TABLE `t5` ( `const12` char(0) default NULL, `param12` bigint(20) default NULL, `param13` double default NULL, - `param14` longblob, + `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t5 ; @@ -1746,7 +1746,7 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 0 0 8 def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 def test t5 t5 param13 param13 5 20 0 Y 32768 31 63 -def test t5 t5 param14 param14 252 16777215 0 Y 144 0 63 +def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63 const01 8 param01 8 @@ -1899,19 +1899,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -1989,19 +1989,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2081,19 +2081,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2165,19 +2165,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; @@ -4726,7 +4726,7 @@ t5 CREATE TABLE `t5` ( `const12` char(0) default NULL, `param12` bigint(20) default NULL, `param13` double default NULL, - `param14` longblob, + `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t5 ; @@ -4756,7 +4756,7 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 0 0 8 def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 def test t5 t5 param13 param13 5 20 0 Y 32768 31 63 -def test t5 t5 param14 param14 252 16777215 0 Y 144 0 63 +def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63 const01 8 param01 8 @@ -4909,19 +4909,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -4999,19 +4999,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -5091,19 +5091,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -5175,19 +5175,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index 3dd9c200510..d0549503bfe 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -1776,7 +1776,7 @@ t5 CREATE TABLE `t5` ( `const12` char(0) default NULL, `param12` bigint(20) default NULL, `param13` double default NULL, - `param14` longblob, + `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t5 ; @@ -1806,7 +1806,7 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 0 0 8 def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 def test t5 t5 param13 param13 5 20 0 Y 32768 31 63 -def test t5 t5 param14 param14 252 16777215 0 Y 144 0 63 +def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63 const01 8 param01 8 @@ -1959,19 +1959,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2049,19 +2049,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2141,19 +2141,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2225,19 +2225,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 +def @arg24 254 8192 0 Y 0 31 8 def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 +def @arg26 254 8192 0 Y 0 31 8 def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 +def @arg28 254 8192 0 Y 0 31 8 def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 85e51df776f..e90eff5d1cd 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -1752,7 +1752,7 @@ t5 CREATE TABLE `t5` ( `const12` char(0) default NULL, `param12` bigint(20) default NULL, `param13` double default NULL, - `param14` longblob, + `param14` longtext, `param15` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t5 ; @@ -1782,7 +1782,7 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 0 0 8 def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 def test t5 t5 param13 param13 5 20 0 Y 32768 31 63 -def test t5 t5 param14 param14 252 16777215 0 Y 144 0 63 +def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63 const01 8 param01 8 @@ -1935,19 +1935,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2025,19 +2025,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2117,19 +2117,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2201,19 +2201,19 @@ def @arg16 254 8192 0 Y 128 31 63 def @arg17 254 20 0 Y 128 31 63 def @arg18 254 20 0 Y 128 31 63 def @arg19 254 20 0 Y 128 31 63 -def @arg20 254 8192 0 Y 128 31 63 -def @arg21 254 8192 0 Y 128 31 63 -def @arg22 254 8192 0 Y 128 31 63 -def @arg23 254 8192 0 Y 128 31 63 -def @arg24 254 8192 0 Y 128 31 63 -def @arg25 254 8192 0 Y 128 31 63 -def @arg26 254 8192 0 Y 128 31 63 -def @arg27 254 8192 0 Y 128 31 63 -def @arg28 254 8192 0 Y 128 31 63 -def @arg29 254 8192 0 Y 128 31 63 -def @arg30 254 8192 0 Y 128 31 63 -def @arg31 254 8192 0 Y 128 31 63 -def @arg32 254 8192 0 Y 128 31 63 +def @arg20 254 8192 0 Y 0 31 8 +def @arg21 254 8192 0 Y 0 31 8 +def @arg22 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 0 31 8 +def @arg24 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 0 31 8 +def @arg26 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 0 31 8 +def @arg28 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 0 31 8 +def @arg30 254 8192 0 Y 0 31 8 +def @arg31 254 8192 0 Y 0 31 8 +def @arg32 254 8192 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/sql/item_func.cc b/sql/item_func.cc index 09d7e50eaa3..b382dbf7bf9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2340,6 +2340,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, entry->value=0; entry->length=0; entry->update_query_id=0; + entry->collation.set(NULL, DERIVATION_NONE); /* If we are here, we were called from a SET or a query which sets a variable. Imagine it is this: @@ -2381,7 +2382,24 @@ bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables, is different from query_id). */ entry->update_query_id= thd->query_id; - entry->collation.set(args[0]->collation); + /* + As it is wrong and confusing to associate any + character set with NULL, @a should be latin2 + after this query sequence: + + SET @a=_latin2'string'; + SET @a=NULL; + + I.e. the second query should not change the charset + to the current default value, but should keep the + original value assigned during the first query. + In order to do it, we don't copy charset + from the argument if the argument is NULL + and the variable has previously been initialized. + */ + if (!entry->collation.collation || !args[0]->null_value) + entry->collation.set(args[0]->collation); + collation.set(entry->collation); cached_result_type= args[0]->result_type(); return 0; } @@ -2409,7 +2427,6 @@ bool Item_func_set_user_var::update_hash(void *ptr, uint length, my_free(entry->value,MYF(0)); entry->value=0; entry->length=0; - entry->collation.set(cs, dv); } else { From f7553251dcd1eb0365221a025a0bd88bd9b747c8 Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Fri, 5 Nov 2004 10:42:37 +0100 Subject: [PATCH 081/101] The new "Bootstrap" pushed in 4.0 with changeset "joerg:1.2057" is used for building _all_ versions. It tries to remove "Docs/Images/Makefile*" as part of the actions to correct bug number 6350. If the source tree does not contain a dummy file matching that pattern, this "rm" will fail, and so "Bootstrap" will fail. The "Makefile.am" introduced with this changeset is identical to the one that will arrive here when "joerg:1.2057" is propagated from 4.0, so this separate introduction here is just to allow "Bootstraps" in the meantime. --- Docs/Images/Makefile.am | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Docs/Images/Makefile.am diff --git a/Docs/Images/Makefile.am b/Docs/Images/Makefile.am new file mode 100644 index 00000000000..b57d701d8a0 --- /dev/null +++ b/Docs/Images/Makefile.am @@ -0,0 +1,35 @@ +# 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 + +## Process this file with automake to create Makefile.in + +# This is a dummy file to satisfy the hierarchy of Makefiles. +# When a release is built, the true Makefile will be copied +# together with the "real" files in this directory. + +EXTRA_DIST = + +# Nothing to create in this dummy directory. +all: + : + +# Nothing to cleanup in this dummy directory. +clean: + : + +# Don't update the files from bitkeeper +%::SCCS/s.% From 813b2f3357a15dd31f03af075e0b207fba41ef0f Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 5 Nov 2004 14:07:12 +0400 Subject: [PATCH 082/101] user_var.result, user_var.test: My previous change that "set @a=NULL" doesn't change charset fixed 'Bug #6321' as well. Prove with a new test that FIELD(, ...) now works fine too. --- mysql-test/r/user_var.result | 4 ++++ mysql-test/t/user_var.test | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 2750478c1c5..659c392e153 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -195,3 +195,7 @@ SET @`v`:=_ucs2 0x006100620063 COLLATE ucs2_general_ci; SET TIMESTAMP=10000; insert into t2 values (@v); drop table t1, t2; +set @var= NULL ; +select FIELD( @var,'1it','Hit') as my_column; +my_column +0 diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 601724e68c8..3816af42c55 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -120,3 +120,9 @@ show binlog events from 79; drop table t1, t2; +# +# Bug #6321 strange error: +# string function FIELD(, ...) +# +set @var= NULL ; +select FIELD( @var,'1it','Hit') as my_column; From 16b280b11dbfa9dc29e2773e9214283a3dc283bf Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Fri, 5 Nov 2004 15:50:53 +0100 Subject: [PATCH 083/101] Ensure that even the (relatively new) "mysql-test/Makefile.am" gets into the source tar-ball. --- .bzrignore | 1 + mysql-test/Makefile.am | 1 + 2 files changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index 27fb593c662..1e89b903ac7 100644 --- a/.bzrignore +++ b/.bzrignore @@ -922,3 +922,4 @@ Docs/Images/mydsn-test-success.txt Docs/Images/mydsn-trace.txt Docs/Images/mydsn.txt Docs/Images/myflowchart.txt +mysql-test/mysql_test_run_new diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 4e8601f1b88..ad02d304d1b 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -38,6 +38,7 @@ CLEANFILES = $(test_SCRIPTS) $(test_DATA) INCLUDES = -I$(srcdir)/../include -I../include -I.. bin_PROGRAMS = mysql_test_run_new +noinst_HEADERS = my_manage.h mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c From 954f88db9f04a9114fea7f169cbdc2425573654f Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 5 Nov 2004 20:35:56 +0400 Subject: [PATCH 084/101] mysqldump.c: in 4.1: Dump only VARBINARY() in hex, while VARCHAR() COLLATE xxx_bin as a string. --- client/mysqldump.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/mysqldump.c b/client/mysqldump.c index a8db8ab440b..e1388aa0f85 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1527,6 +1527,7 @@ static void dumpTable(uint numFields, char *table) */ is_blob= (opt_hex_blob && field->charsetnr == 63 && (field->type == FIELD_TYPE_STRING || + field->type == FIELD_TYPE_VAR_STRING || field->type == FIELD_TYPE_BLOB || field->type == FIELD_TYPE_LONG_BLOB || field->type == FIELD_TYPE_MEDIUM_BLOB || From eeeb342b3ca5180c58fbf0e6d3ccde442e5cadc7 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Fri, 5 Nov 2004 21:02:12 +0300 Subject: [PATCH 085/101] A fix and test case for the bug reported by Reggie: if character set of client equals to character set of connection, possibly required conversion to character set of column is not performed (prepared statements, data is supplied using placeholders). --- sql/item.cc | 4 +++ tests/client_test.c | 71 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/sql/item.cc b/sql/item.cc index 7dc7e9e542c..b4e7322b7cc 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1218,6 +1218,10 @@ bool Item_param::convert_str_value(THD *thd) value.cs_info.character_set_client, value.cs_info.final_character_set_of_str_value); } + else + str_value.set_charset(value.cs_info.final_character_set_of_str_value); + /* Here str_value is guaranteed to be in final_character_set_of_str_value */ + max_length= str_value.length(); decimals= 0; /* diff --git a/tests/client_test.c b/tests/client_test.c index 004f076c6df..d373f57c1de 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -11152,6 +11152,73 @@ static void test_bug4172() } +static void test_conversion() +{ + MYSQL_STMT *stmt; + const char *stmt_text; + int rc; + MYSQL_BIND bind[1]; + char buff[4]; + ulong length; + + myheader("test_conversion"); + + stmt_text= "DROP TABLE IF EXISTS t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + stmt_text= "CREATE TABLE t1 (a TEXT) DEFAULT CHARSET latin1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + stmt_text= "SET character_set_connection=utf8, character_set_client=utf8, " + " character_set_results=latin1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + + stmt_text= "INSERT INTO t1 (a) VALUES (?)"; + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + + bzero(bind, sizeof(bind)); + bind[0].buffer= buff; + bind[0].length= &length; + bind[0].buffer_type= MYSQL_TYPE_STRING; + + mysql_stmt_bind_param(stmt, bind); + + buff[0]= 0xC3; + buff[1]= 0xA0; + length= 2; + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + stmt_text= "SELECT a FROM t1"; + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + bind[0].buffer_length= sizeof(buff); + mysql_stmt_bind_result(stmt, bind); + + rc= mysql_stmt_fetch(stmt); + DIE_UNLESS(rc == 0); + DIE_UNLESS(length == 1); + DIE_UNLESS((uchar) buff[0] == 0xE0); + rc= mysql_stmt_fetch(stmt); + DIE_UNLESS(rc == MYSQL_NO_DATA); + + mysql_stmt_close(stmt); + stmt_text= "DROP TABLE t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + stmt_text= "SET NAMES DEFAULT"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); +} + /* Read and parse arguments and MySQL options from my.cnf @@ -11471,6 +11538,10 @@ int main(int argc, char **argv) test_bug6096(); /* max_length for numeric columns */ test_bug4172(); /* floating point conversions in libmysql */ + test_conversion(); /* placeholder value is not converted to + character set of column if character set + of connection equals to character set of + client */ /* XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. From 362febbf29cfbb48b85b9a01a269be84dd4b25ad Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Fri, 5 Nov 2004 23:59:06 +0000 Subject: [PATCH 086/101] removed a bunch of "dead" files from the ndb src tree --- ndb/home/bin/cvschk | 569 ----- ndb/src/common/util/getarg.3 | 315 --- ndb/src/common/util/getarg.3.ps | 458 ---- ndb/src/common/util/md5-rfc1321.txt | 1179 --------- ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs | 58 - ndb/src/cw/cpcc-win32/vb6/frmSplash.frm | 159 -- ndb/src/external/LINUX.x86/sci/include/list.h | 56 - .../LINUX.x86/sci/include/os/inttypes.h | 53 - .../external/LINUX.x86/sci/include/rmlib.h | 212 -- .../LINUX.x86/sci/include/sci_errno.h | 216 -- .../LINUX.x86/sci/include/sci_types.h | 300 --- .../LINUX.x86/sci/include/sisci_api.h | 2170 ---------------- .../LINUX.x86/sci/include/sisci_demolib.h | 226 -- .../LINUX.x86/sci/include/sisci_error.h | 89 - .../LINUX.x86/sci/include/sisci_types.h | 133 - .../LINUX.x86/sci/include/sisci_version.h | 91 - .../external/LINUX.x86/sci/include/version.h | 25 - .../SOLARIS.SPARC/sci/include/sisci_api.h | 2148 ---------------- .../SOLARIS.SPARC/sci/include/sisci_error.h | 89 - .../SOLARIS.SPARC/sci/include/sisci_types.h | 133 - .../SOLARIS.SPARC/sci/include/sisci_version.h | 91 - .../external/WIN32.x86/sci/include/rmlib.h | 212 -- .../external/WIN32.x86/sci/include/scilib.h | 330 --- .../WIN32.x86/sci/include/sisci_api.h | 2217 ----------------- .../WIN32.x86/sci/include/sisci_demolib.h | 226 -- .../WIN32.x86/sci/include/sisci_error.h | 94 - .../WIN32.x86/sci/include/sisci_types.h | 133 - ndb/test/odbc/tpcb/Makefile | 30 - ndb/test/odbc/tpcb/Makefile_mysql | 33 - ndb/test/odbc/tpcb/Makefile_ndb | 30 - ndb/test/odbc/tpcb/readme.txt | 15 - ndb/test/odbc/tpcb/timesten.h | 188 -- ndb/test/odbc/tpcb/tpcb.cpp | 1415 ----------- ndb/test/odbc/tpcb/ttTime.c | 366 --- ndb/test/odbc/tpcb/ttTime.h | 125 - 35 files changed, 14184 deletions(-) delete mode 100755 ndb/home/bin/cvschk delete mode 100644 ndb/src/common/util/getarg.3 delete mode 100644 ndb/src/common/util/getarg.3.ps delete mode 100644 ndb/src/common/util/md5-rfc1321.txt delete mode 100644 ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs delete mode 100644 ndb/src/cw/cpcc-win32/vb6/frmSplash.frm delete mode 100644 ndb/src/external/LINUX.x86/sci/include/list.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/os/inttypes.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/rmlib.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/sci_errno.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/sci_types.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/sisci_api.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/sisci_demolib.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/sisci_error.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/sisci_types.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/sisci_version.h delete mode 100644 ndb/src/external/LINUX.x86/sci/include/version.h delete mode 100644 ndb/src/external/SOLARIS.SPARC/sci/include/sisci_api.h delete mode 100644 ndb/src/external/SOLARIS.SPARC/sci/include/sisci_error.h delete mode 100644 ndb/src/external/SOLARIS.SPARC/sci/include/sisci_types.h delete mode 100644 ndb/src/external/SOLARIS.SPARC/sci/include/sisci_version.h delete mode 100644 ndb/src/external/WIN32.x86/sci/include/rmlib.h delete mode 100644 ndb/src/external/WIN32.x86/sci/include/scilib.h delete mode 100644 ndb/src/external/WIN32.x86/sci/include/sisci_api.h delete mode 100644 ndb/src/external/WIN32.x86/sci/include/sisci_demolib.h delete mode 100644 ndb/src/external/WIN32.x86/sci/include/sisci_error.h delete mode 100644 ndb/src/external/WIN32.x86/sci/include/sisci_types.h delete mode 100644 ndb/test/odbc/tpcb/Makefile delete mode 100644 ndb/test/odbc/tpcb/Makefile_mysql delete mode 100644 ndb/test/odbc/tpcb/Makefile_ndb delete mode 100644 ndb/test/odbc/tpcb/readme.txt delete mode 100644 ndb/test/odbc/tpcb/timesten.h delete mode 100644 ndb/test/odbc/tpcb/tpcb.cpp delete mode 100644 ndb/test/odbc/tpcb/ttTime.c delete mode 100644 ndb/test/odbc/tpcb/ttTime.h diff --git a/ndb/home/bin/cvschk b/ndb/home/bin/cvschk deleted file mode 100755 index 4510cc30888..00000000000 --- a/ndb/home/bin/cvschk +++ /dev/null @@ -1,569 +0,0 @@ -#!/usr/bin/perl -w -# -# cvschk -- fast offline check for new files and modifications of files - -# cvschk : A perl program which checks the status of the CVS controlled -# files and gives an ASCII table sorted after the status of files. -# -# If you have used CVS, then you know that it is hard to -# get a good overview the CVS-status of the files in you -# directories. Any new files? Any files changes? -# cvschk will help the programmer get the overview in the -# situation, where we do not have access to the CVS repository. -# -# Note that the program does only local checks of the files -# If you have fast access to the CVS repositiory, then consider -# the cvsstat-program - which additionally can tell if other -# people have made newer versions of the files. -# -# The program requires Perl 5.004 (maybe previous versions also work). -# -# It is tuned to parse the output of cvs(1) version 1.9. -# Earlier and later versions may require modifications to the script. -# -# ** Note that the first line might be wrong depending ** -# ** on the location of your perl program. ** -# -# Sample output: -# The directory ./mytempdir is not under CVS control -# -# Changed files -# --------------- -# ./cvs2html -# ./cvschk -# ./cvsstat -# -# New files -# --------------- -# ./.#cvschk -# ./XX -# ./cvs2html.ok -# -# Deleted files -# --------------- -# (none) - -# Changelog: -# -# Ver Date Author Changelog -# --- ---------- -------------------- ------------------------------------- -# 1.12 2002-01-04 Michael Kohne Fixed a $foo=<> warning for -# 5.004_01 with defined($foo=<>) -# Added a --tabular|-t switch -# -# 1.11 2001-12-27 Michael Kohne Added cvsignore functionality -# Handling of 'dummy timestamp' -# Handling of 'Result of Merge' -# -# 1.10 2001-11-06 Michael Kohne Added -r and -l options -# -# 1.9 2001-08-03 Lars G. T. Jørgensen Hack to allow special entry-line -# -# 1.8 2001-06-07 Peter Toft Back to the same as 1.6 -# CVS is my friend -# -# 1.7 2001-06-04 Peter Toft Peter was very tired and -# applied a wrong patch - -# version 1.7 is crap -# -# 1.6 2000-12-17 Peter Toft Better description added -# -# 1.5 2000-11-04 Peter Toft URL of cvsstat changed -# -# 1.4 2000-09-20 Peter Toft Must show deleted files also -# as the default -# -# 1.3 2000-08-08 Ole Tange and Initial version -# Peter Toft -# ---- ---------- -------------------- ------------------------------------- -# -# ----------------------------------------------------------------------------- -# -# This program is protected by the GPL, and all modifications of -# general interest should be emailed to the maintainer (pto@sslug.dk). -# -# This program also uses code parts from cvsstat -# (same homepage as cvschk) -# -# Copyright 2000,2001 by Peter Toft and Ole Tange -# as well as -# Lars G. T. Jørgensen -# -# The URL of the home page of cvschk is shown below. - - -use Time::Local; -use strict; -use Getopt::Long; - -my $startdir = "."; - -my $debug = 0; -my (%files,%filesok,%seen,%skip); - - -# Michael Kohne 12/16/01 -# -# Simulation of .cvsignore as CVS does it... -# -# using .cvsignore handling makes cvschk take from 2 to 3 times -# longer to run over the same set of files. -# in my tests, disabling cvsignore altogether, cvschk takes .2 -# seconds on my working directory. Adding cvsignore,takes -# .4 seconds. -# Note that I do not use individual .cvsignore files - if there -# are a lot of them in your directory tree, it will add run time -# -# variables used for .cvsignore handling -my $initcvsignoreregex;# regex holding all startup cvsignore pattersn (no ()) -my $cvsignoreregex;# one regex holding all current cvsignore patterns -my $disable_cvsignore=0;# set to 1 to disable cvsignore emulation - # (available in case it's REALLY screwed up) -my $disable_ind_cvsignore=0;# set to 1 to disable finding .cvsignore files - # in each directory. -my $debug_cvsignore = 0; # For debugging .cvsignore problems - -my %mon; -@mon{qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)}= - 0..11; # Perl months are 0 .. 11 - -my ($version) = ('$Revision: 1.12 $ ' =~ /^\$\w+: (.*) \$ $/); -my $URL = "http://cvs.sslug.dk/cvs2html"; -my $version_line = "cvschk version $version (see $URL)\n"; - -my $opt_all; -my $restrict; -my $local; -my $tabular; - -my $opt_restrict; - -sub show_version {print $version_line} - -sub die_version {die $version_line} - -sub die_usage { - my $bundled = ($] > 5.00399 - ? "can be bundled" - : "can't be bundled, because your Perl is too old"); - die < 5.00399) { # This requires 5.004, so silently skip it for older Perls. - eval {Getopt::Long::config("bundling")}; # avoid 5.003 compilation error - warn $@ if $@; # For Perl 5.004+ we do want to see any compilation error -} - - -GetOptions( "all|a" => \$opt_all, - "tabular|t" => \$tabular, - "restrict|r" => \$restrict, - "local|l" => \$local, - "help|h" => \&die_help, - "debug|d" => \$debug, - "version|V" => \&die_version, - ) or die_usage; - -sub cvs_changed_in_dir($); #define prototype (for recursion) - -# functions for .cvsignore handling - -# converts a given filename pattern -# (of the sort that sh(1) takes) to -# a perl regex of similar meaning. -# -# It works by doing the following: -# -# change: -# . to \. -# $ to \$ -# * to .* -# ? to . -# -sub fpat_to_regex($) -{ - my $fexp; - $fexp = shift; - $fexp =~ s/\./\\\./g;#change . to \. - $fexp =~ s/\$/\\\$/g;#change dollar sign to \dollar sign - $fexp =~ s/\*/.*/g;# change * to .* - $fexp =~ s/\?/./g; # change ? to . - return $fexp; -} - -# copy the input list to one single regex, -# items seperated by | symbols. -# return the regex string -sub do_regex_convert -{ - my $rx = ""; - my $first = 1;#true for first element only - - - # convert each element of cvsignore into a regex - # this makes the patterns usable in perl - my $cp; - foreach $cp (@_) { - if (not $first) { $rx = $rx . "|"; } - if ($first) { $first = 0; } - $rx = $rx . fpat_to_regex($cp); - } - - return $rx; -} - -# first parameter is a reference to the array -# to be loaded -# the rest of the parameters are just items -# that need to be loaded into the array. -# Note that if a ! is found, the list is -# emptied, then further items are added. -# returns true if a ! was found -sub load_list_from_list -{ - my $arref = shift;# get reference to array from front - my $item; - my $ret=0;#false means no ! found - - chomp @_;#kill newlines - foreach $item (@_) { - $item =~ s/^\s*(.*?)\s*$/$1/;#kill leading/trailing whitespace - if ($item) { # empty string is false - push @$arref,$item; - } - if ($item eq "!") { - @$arref = ();# '!' causes list to clear - $ret = 1;# ! found - } - } - - return $ret; -} - -# loads the given list with lines from the -# specified file. Note that if a '!' is found -# all prior patterns are removed from the list -# before the following patterns are loaded -# first param is the filename, -# second param is a reference to an array -# that the data is to go into -# returns true if a ! was found -sub load_list_from_file -{ - my @inlist; - my $fname = shift;#filename to read from - #if (not -e $fname) { return; } - my $arref = shift;#array to store into - open CVSIGNORE,"$fname" or return;#file might not exist, that's OK - @inlist = ; - close CVSIGNORE; - return load_list_from_list($arref,@inlist); -} - -# loads $cvsignoreregex from -# $initcvsignoreregex and the .cvsignore file -# in the local directory -sub load_cvsignore -{ - if ($disable_ind_cvsignore) {return;}#don't look for local .cvsignore files - if ($disable_cvsignore) {return;}#don't do anything - - my $dir = shift; - my @cvsignore; - - # bang will be true if a ! was found. In such cases, I need - # to not use the pre-exisitng regex list. - my $bang = load_list_from_file("$dir/.cvsignore",\@cvsignore); - - # if we get a local cvsignore list, then... - my $rx = do_regex_convert(@cvsignore); - if ($rx) { - $cvsignoreregex = "("; - if (not $bang) {$cvsignoreregex = $cvsignoreregex . $initcvsignoreregex . "|";} - $cvsignoreregex = $cvsignoreregex . $rx . ")"; - } else { - if ($bang) {$cvsignoreregex = "";} - else {$cvsignoreregex = "(" . $initcvsignoreregex . ")";} - } - - if ($debug_cvsignore) {print $dir,":",$cvsignoreregex, "\n";} -} - - -# loads all of the cvsignore patterns that -# can be loaded at script startup -sub load_initial_cvsignore() -{ - #load the default patterns - # (taken from http://www.gnu.org/manual/cvs-1.9/html_node/cvs_141.html#IDX399) - # - # this gives you the patterns that cvs normally starts with - my @initcvsignore; - push @initcvsignore,("RCS"); - push @initcvsignore,("SCCS"); - push @initcvsignore,("CVS"); - push @initcvsignore,("CVS.adm"); - push @initcvsignore,("RCSLOG"); - push @initcvsignore,("cvslog.*"); - push @initcvsignore,("tags"); - push @initcvsignore,("TAGS"); - push @initcvsignore,(".make.state"); - push @initcvsignore,(".nse_depinfo"); - push @initcvsignore,("*~"); - push @initcvsignore,("\#*"); - push @initcvsignore,(".\#*"); - push @initcvsignore,("\,*"); - push @initcvsignore,("_\$\*"); - push @initcvsignore,("*\$"); - push @initcvsignore,("*.old"); - push @initcvsignore,("*.bak"); - push @initcvsignore,("*.BAK"); - push @initcvsignore,("*.orig"); - push @initcvsignore,("*.rej"); - push @initcvsignore,(".del-*"); - push @initcvsignore,("*.a"); - push @initcvsignore,("*.olb"); - push @initcvsignore,("*.o"); - push @initcvsignore,("*.obj"); - push @initcvsignore,("*.so"); - push @initcvsignore,("*.exe"); - push @initcvsignore,("*.Z"); - push @initcvsignore,("*.elc"); - push @initcvsignore,("*.ln"); - push @initcvsignore,("core"); - - - # now, load (in proper order!) - # each of the possible cvsignore files - - # there are 4 possible .cvsignore files: - - # $CVSROOT/CVSROOT/cvsignore - # ~/.cvsignore - # $CVSIGNORE environment variable - # .cvsignore in current directory - - # The first (CVSROOT/cvsignore) would require calling cvs, so - # we won't do that one. - # The last (.cvsignore in current directory) is done - # for each directory. It's handled in the load_cvsignore routine. - - # ~/.cvsignore - my @inlist; - my $item; - my $HOME=$ENV{"HOME"}; - if (not $HOME) {$HOME = ".";} - load_list_from_file("$HOME/.cvsignore",\@initcvsignore); - - # $CVSIGNORE environment variable - my $igstr = $ENV{"CVSIGNORE"}; # get env var - if ($igstr) { - my @iglist = split(/\s+/, $igstr); #if it exists, convert to list - load_list_from_list(\@initcvsignore,@iglist); - } - - # now that @initcvsignore is setup, - # turn it into a regex string - $initcvsignoreregex = do_regex_convert(@initcvsignore); - - # now preset the cvsignore regex string to match - # @initcvsignore. That way, if we aren't using local - # cvsignore files, we do nothing. - $cvsignoreregex = "(" . $initcvsignoreregex . ")"; -} -# routine to see if the given name is in the cvsignore regex -# returns true if it is, false if it's not -sub ignore_file($) -{ - #allow user to disable the cvsignore stuff - if ($disable_cvsignore) {return 0;} - if (not $cvsignoreregex) {return 0;}# if regex is empty, nothing matches the regex - my $filename = shift; - - if ($debug_cvsignore) {print "ignore_file:",$filename,"\n";} - - if ($filename =~ $cvsignoreregex) { - if ($debug_cvsignore) {print $filename," matches\n";} - return 1; - } - - if ($debug_cvsignore) {print $filename," doesn't match\n";} - return 0; -} - -sub cvs_changed_in_dir($) { - my $dir = shift; - - my ($line,$filename,$version,$mtime,$date, - $dir_filename,$cvstime,@subdirs, - @new_in_dir,$i); - - # Examine status of files in CVS/Entries - if(not open(ENTRIES,"$dir/CVS/Entries")) { - if ($tabular) { - push @{$files{Unknown}}, $dir; - } - else { - warn "The directory $dir is not under CVS control\n"; - } - } else { - load_cvsignore($dir);#load up proper cvsignore for given directory - - while(defined ($line=)) { - # Parse CVS/Entries-line - $line=~m!^/(.*)/(.*)/(.*)/.*/! or do { - $debug and warn("Skipping entry-line $line"); - next; - }; - ($filename,$version,$date) = ($1,$2,$3); - $dir_filename=$dir."/".$filename; - - # Mark this file as seen - $seen{$dir_filename}=1; - - # if not exists: Deleted - if(not -e $dir_filename) { - push @{$files{Deleted}}, $dir_filename; next; - } - # if dir: save name for recursion - -d $dir_filename and do { - push @subdirs, $dir_filename; next; - }; - - # modification time of $dir_filename - $mtime= (stat $dir_filename)[9]; - - - if($date eq "dummy timestamp") { - # dummy timestamp means it's new to the repository. - push @{$files{Changed}}, $dir_filename; - if ($debug) { - print "$dir_filename is changed\n"; - } - } - elsif($date eq "Result of merge") { - # result of merge means it's changed, then updated. - push @{$files{Changed}}, $dir_filename; - if ($debug) { - print "$dir_filename is changed\n"; - } - } - elsif(not - $date=~/... (...)\s+(\d+)\s+(\d+):(\d+):(\d+) (\d{4})/) - { - #bogus entry in Entires - warn "Warning: $dir_filename -> '$date' ". - "not in ctime(3) format\n"; - } else { - $cvstime=timegm($5,$4,$3,$2,$mon{$1},$6); - if($cvstime != $mtime) { - push @{$files{Changed}}, $dir_filename; - if ($debug) { - print "$dir_filename is changed\n"; - } - } else { - push @{$files{Unchanged}}, $dir_filename; - if ($debug) { - print "$dir_filename is Unchanged\n"; - } - } - } - } - close ENTRIES; - - # Locate any new files/dirs - if(not opendir(D,$dir)) { - warn("Cannot open $dir"); - @new_in_dir= (); - } else { - @skip{qw(. .. CVS)}=1..3; # Filenames that that we want to ignore - #(note: these are exact filenames) - @new_in_dir= - (grep { not $seen{$_} } # files we have not already processed - map { $dir."/".$_ } # map from file to dir/file - grep { not ignore_file($_) } # ignore files in the cvsignore list - grep { not $skip{$_} } # skip files to be ignored - readdir(D)); - closedir(D); - } - - # Remember new files (actually non-directories) - push @{$files{New}}, grep { not -d $_ } @new_in_dir; - if ($debug) { print "@{$files{New}} are new in $dir\n"; } - - # Remember new subdirs - push @subdirs, grep { -d $_ } @new_in_dir; - - # Recurse all subdirs - if (not $local) { - for $i (@subdirs) { cvs_changed_in_dir($i); } - } - } -} - -sub print_status() -{ - my $k; - my %show_these_states = ("Changed" => 1); - if(not $restrict) { - $show_these_states{"New"} = 1; - $show_these_states{"Deleted"} = 1; - } - - if($opt_all) { $show_these_states{"Unchanged"} = 1; } - - if ($tabular) { - my %allfiles; # key: filesname, value: state - my ($file, $state, $statefiles); - - $show_these_states{"Unknown"} = 1; - while (($state, $statefiles) = each %files) { - for my $f (@{$statefiles}) { - $allfiles{$f} = $state; - } - } - for $file (sort keys %allfiles) { - $state = $allfiles{$file}; - printf("%-10s %s\n", $state, $file) if $show_these_states{$state}; - } - } - else { - print "\n"; - for $k (keys %show_these_states) { - if(not $files{$k} or not @{$files{$k}}) { - # no files - $files{$k}=["(none)"]; - } - print("$k files\n", - "---------------\n", - map { "$_\n" } sort @{$files{$k}}); - print "\n"; - } - } -} - -load_initial_cvsignore(); -if ($debug_cvsignore) {print "initial regex:",$cvsignoreregex,"\n";} -cvs_changed_in_dir($startdir); -print_status(); - diff --git a/ndb/src/common/util/getarg.3 b/ndb/src/common/util/getarg.3 deleted file mode 100644 index 43aae5d7b31..00000000000 --- a/ndb/src/common/util/getarg.3 +++ /dev/null @@ -1,315 +0,0 @@ -.\" Copyright (c) 1999 Kungliga Tekniska Högskolan -.\" $KTH: getarg.3,v 1.1.4.1 2001/07/26 19:54:45 lha Exp $ -.Dd September 24, 1999 -.Dt GETARG 3 -.Os ROKEN -.Sh NAME -.Nm getarg , -.Nm arg_printusage -.Nd collect command line options -.Sh SYNOPSIS -.Fd #include - -.Ft int -.Fn getarg "struct getargs *args" "size_t num_args" "int argc" "char **argv" "int *optind" - -.Ft void -.Fn arg_printusage "struct getargs *args" "size_t num_args" "const char *progname" "const char *extra_string" - -.Sh DESCRIPTION -.Fn getarg -collects any command line options given to a program in an easily used way. -.Fn arg_printusage -pretty-prints the available options, with a short help text. -.Pp -.Fa args -is the option specification to use, and it's an array of -.Fa struct getargs -elements. -.Fa num_args -is the size of -.Fa args -(in elements). -.Fa argc -and -.Fa argv -are the argument count and argument vector to extract option from. -.Fa optind -is a pointer to an integer where the index to the last processed -argument is stored, it must be initialised to the first index (minus -one) to process (normally 0) before the first call. -.Pp -.Fa arg_printusage -take the same -.Fa args -and -.Fa num_args -as getarg; -.Fa progname is the name of the program (to be used in the help text), and -.Fa extra_string -is a string to print after the actual options to indicate more -arguments. The usefulness of this function is realised only be people -who has used programs that has help strings that doesn't match what -the code does. -.Pp -The -.Fa getargs -struct has the following elements. - -.Bd -literal -struct getargs{ - const char *long_name; - char short_name; - enum { arg_integer, - arg_string, - arg_flag, - arg_negative_flag, - arg_strings, - arg_double, - arg_collect - } type; - void *value; - const char *help; - const char *arg_help; -}; -.Ed -.Pp -.Fa long_name -is the long name of the option, it can be -.Dv NULL , -if you don't want a long name. -.Fa short_name -is the characted to use as short option, it can be zero. If the option -has a value the -.Fa value -field gets filled in with that value interpreted as specified by the -.Fa type -field. -.Fa help -is a longer help string for the option as a whole, if it's -.Dv NULL -the help text for the option is omitted (but it's still displayed in -the synopsis). -.Fa arg_help -is a description of the argument, if -.Dv NULL -a default value will be used, depending on the type of the option: -.Pp -.Bl -hang -width arg_negative_flag -.It arg_integer -the argument is a signed integer, and -.Fa value -should point to an -.Fa int . -.It Fa arg_string -the argument is a string, and -.Fa value -should point to a -.Fa char* . -.It Fa arg_flag -the argument is a flag, and -.Fa value -should point to a -.Fa int . -It gets filled in with either zero or one, depending on how the option -is given, the normal case beeing one. Note that if the option isn't -given, the value isn't altered, so it should be initialised to some -useful default. -.It Fa arg_negative_flag -this is the same as -.Fa arg_flag -but it reverses the meaning of the flag (a given short option clears -the flag), and the synopsis of a long option is negated. -.It Fa arg_strings -the argument can be given multiple times, and the values are collected -in an array; -.Fa value -should be a pointer to a -.Fa struct getarg_strings -structure, which holds a length and a string pointer. -.It Fa arg_double -argument is a double precision floating point value, and -.Fa value -should point to a -.Fa double . -.It Fa arg_collect -allows more fine-grained control of the option parsing process. -.Fa value -should be a pointer to a -.Fa getarg_collect_info -structure: -.Bd -literal -typedef int (*getarg_collect_func)(int short_opt, - int argc, - char **argv, - int *optind, - int *optarg, - void *data); - -typedef struct getarg_collect_info { - getarg_collect_func func; - void *data; -} getarg_collect_info; -.Ed -.Pp -With the -.Fa func -member set to a function to call, and -.Fa data -to some application specific data. The parameters to the collect function are: -.Bl -inset -.It Fa short_flag -non-zero if this call is via a short option flag, zero otherwise -.It Fa argc , argv -the whole argument list -.It Fa optind -pointer to the index in argv where the flag is -.It Fa optarg -pointer to the index in argv[*optind] where the flag name starts -.It Fa data -application specific data -.El -.Pp -You can modify -.Fa *optind , -and -.Fa *optarg , -but to do this correct you (more or less) have to know about the inner -workings of getarg. - -You can skip parts of arguments by increasing -.Fa *optarg -(you could -implement the -.Fl z Ns Ar 3 -set of flags from -.Nm gzip -with this), or whole argument strings by increasing -.Fa *optind -(let's say you want a flag -.Fl c Ar x y z -to specify a coordinate); if you also have to set -.Fa *optarg -to a sane value. -.Pp -The collect function should return one of -.Dv ARG_ERR_NO_MATCH , ARG_ERR_BAD_ARG , ARG_ERR_NO_ARG -on error, zero otherwise. -.Pp -For your convenience there is a function, -.Fn getarg_optarg , -that returns the traditional argument string, and you pass it all -arguments, sans data, that where given to the collection function. -.Pp -Don't use this more this unless you absolutely have to. -.El -.Pp -Option parsing is similar to what -.Xr getopt -uses. Short options without arguments can be compressed -.Pf ( Fl xyz -is the same as -.Fl x y z ) , -and short -options with arguments take these as either the rest of the -argv-string or as the next option -.Pf ( Fl o Ns Ar foo , -or -.Fl o Ar foo ) . -.Pp -Long option names are prefixed with -- (double dash), and the value -with a = (equal), -.Fl -foo= Ns Ar bar . -Long option flags can either be specified as they are -.Pf ( Fl -help ) , -or with an (boolean parsable) option -.Pf ( Fl -help= Ns Ar yes , -.Fl -help= Ns Ar true , -or similar), or they can also be negated -.Pf ( Fl -no-help -is the same as -.Fl -help= Ns no ) , -and if you're really confused you can do it multiple times -.Pf ( Fl -no-no-help= Ns Ar false , -or even -.Fl -no-no-help= Ns Ar maybe ) . -.Sh EXAMPLE -.Bd -literal -#include -#include -#include - -char *source = "Ouagadougou"; -char *destination; -int weight; -int include_catalog = 1; -int help_flag; - -struct getargs args[] = { - { "source", 's', arg_string, &source, - "source of shippment", "city" }, - { "destination", 'd', arg_string, &destination, - "destination of shippment", "city" }, - { "weight", 'w', arg_integer, &weight, - "weight of shippment", "tons" }, - { "catalog", 'c', arg_negative_flag, &include_catalog, - "include product catalog" }, - { "help", 'h', arg_flag, &help_flag } -}; - -int num_args = sizeof(args) / sizeof(args[0]); /* number of elements in args */ - -const char *progname = "ship++"; - -int -main(int argc, char **argv) -{ - int optind = 0; - if (getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, "stuff..."); - exit (1); - } - if (help_flag) { - arg_printusage(args, num_args, progname, "stuff..."); - exit (0); - } - if (destination == NULL) { - fprintf(stderr, "%s: must specify destination\n", progname); - exit(1); - } - if (strcmp(source, destination) == 0) { - fprintf(stderr, "%s: destination must be different from source\n"); - exit(1); - } - /* include more stuff here ... */ - exit(2); -} -.Ed -.Pp -The output help output from this program looks like this: -.Bd -literal -$ ship++ --help -Usage: ship++ [--source=city] [-s city] [--destination=city] [-d city] - [--weight=tons] [-w tons] [--no-catalog] [-c] [--help] [-h] stuff... --s city, --source=city source of shippment --d city, --destination=city destination of shippment --w tons, --weight=tons weight of shippment --c, --no-catalog include product catalog -.Ed - -.Sh BUGS -It should be more flexible, so it would be possible to use other more -complicated option syntaxes, such as what -.Xr ps 1 , -and -.Xr tar 1 , -uses, or the AFS model where you can skip the flag names as long as -the options come in the correct order. -.Pp -Options with multiple arguments should be handled better. -.Pp -Should be integreated with SL. -.Pp -It's very confusing that the struct you pass in is called getargS. -.Sh SEE ALSO -.Xr getopt 3 diff --git a/ndb/src/common/util/getarg.3.ps b/ndb/src/common/util/getarg.3.ps deleted file mode 100644 index 146fb8e4961..00000000000 --- a/ndb/src/common/util/getarg.3.ps +++ /dev/null @@ -1,458 +0,0 @@ -%!PS-Adobe-3.0 -%%Creator: groff version 1.15 -%%CreationDate: Thu Nov 7 12:53:13 2002 -%%DocumentNeededResources: font Times-Roman -%%+ font Times-Bold -%%+ font Courier-Bold -%%+ font Courier-Oblique -%%+ font Symbol -%%+ font Courier -%%DocumentSuppliedResources: procset grops 1.15 0 -%%Pages: 4 -%%PageOrder: Ascend -%%Orientation: Portrait -%%EndComments -%%BeginProlog -%%BeginResource: procset grops 1.15 0 -/setpacking where{ -pop -currentpacking -true setpacking -}if -/grops 120 dict dup begin -/SC 32 def -/A/show load def -/B{0 SC 3 -1 roll widthshow}bind def -/C{0 exch ashow}bind def -/D{0 exch 0 SC 5 2 roll awidthshow}bind def -/E{0 rmoveto show}bind def -/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def -/G{0 rmoveto 0 exch ashow}bind def -/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/I{0 exch rmoveto show}bind def -/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def -/K{0 exch rmoveto 0 exch ashow}bind def -/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/M{rmoveto show}bind def -/N{rmoveto 0 SC 3 -1 roll widthshow}bind def -/O{rmoveto 0 exch ashow}bind def -/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/Q{moveto show}bind def -/R{moveto 0 SC 3 -1 roll widthshow}bind def -/S{moveto 0 exch ashow}bind def -/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/SF{ -findfont exch -[exch dup 0 exch 0 exch neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/MF{ -findfont -[5 2 roll -0 3 1 roll -neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/level0 0 def -/RES 0 def -/PL 0 def -/LS 0 def -/MANUAL{ -statusdict begin/manualfeed true store end -}bind def -/PLG{ -gsave newpath clippath pathbbox grestore -exch pop add exch pop -}bind def -/BP{ -/level0 save def -1 setlinecap -1 setlinejoin -72 RES div dup scale -LS{ -90 rotate -}{ -0 PL translate -}ifelse -1 -1 scale -}bind def -/EP{ -level0 restore -showpage -}bind def -/DA{ -newpath arcn stroke -}bind def -/SN{ -transform -.25 sub exch .25 sub exch -round .25 add exch round .25 add exch -itransform -}bind def -/DL{ -SN -moveto -SN -lineto stroke -}bind def -/DC{ -newpath 0 360 arc closepath -}bind def -/TM matrix def -/DE{ -TM currentmatrix pop -translate scale newpath 0 0 .5 0 360 arc closepath -TM setmatrix -}bind def -/RC/rcurveto load def -/RL/rlineto load def -/ST/stroke load def -/MT/moveto load def -/CL/closepath load def -/FL{ -currentgray exch setgray fill setgray -}bind def -/BL/fill load def -/LW/setlinewidth load def -/RE{ -findfont -dup maxlength 1 index/FontName known not{1 add}if dict begin -{ -1 index/FID ne{def}{pop pop}ifelse -}forall -/Encoding exch def -dup/FontName exch def -currentdict end definefont pop -}bind def -/DEFS 0 def -/EBEGIN{ -moveto -DEFS begin -}bind def -/EEND/end load def -/CNT 0 def -/level1 0 def -/PBEGIN{ -/level1 save def -translate -div 3 1 roll div exch scale -neg exch neg exch translate -0 setgray -0 setlinecap -1 setlinewidth -0 setlinejoin -10 setmiterlimit -[]0 setdash -/setstrokeadjust where{ -pop -false setstrokeadjust -}if -/setoverprint where{ -pop -false setoverprint -}if -newpath -/CNT countdictstack def -userdict begin -/showpage{}def -}bind def -/PEND{ -clear -countdictstack CNT sub{end}repeat -level1 restore -}bind def -end def -/setpacking where{ -pop -setpacking -}if -%%EndResource -%%IncludeResource: font Times-Roman -%%IncludeResource: font Times-Bold -%%IncludeResource: font Courier-Bold -%%IncludeResource: font Courier-Oblique -%%IncludeResource: font Symbol -%%IncludeResource: font Courier -grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 -def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron -/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent -/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen -/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon -/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O -/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex -/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y -/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft -/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl -/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut -/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash -/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen -/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft -/logicalnot/minus/registered/macron/degree/plusminus/twosuperior -/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior -/ordmasculine/guilsinglright/onequarter/onehalf/threequarters -/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE -/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex -/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis -/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn -/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla -/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis -/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash -/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def -/Courier@0 ENC0/Courier RE/Courier-Oblique@0 ENC0/Courier-Oblique RE -/Courier-Bold@0 ENC0/Courier-Bold RE/Times-Bold@0 ENC0/Times-Bold RE -/Times-Roman@0 ENC0/Times-Roman RE -%%EndProlog -%%Page: 1 1 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F/F1 10/Times-Bold@0 SF -.2(NA)72 108 S(ME).2 E -/F2 10/Courier-Bold@0 SF(getarg)102 120 Q F0(,)A F2(arg_printusage)2.5 E -F0 2.52.5 G(ollect command line options)-2.5 E F1(SYNOPSIS)72 144 -Q F2(#include )102 156 Q/F3 10/Courier-Oblique@0 SF(int)102 -186 Q F2(getarg)102 198 Q F0(\()A F3(struct getargs)A/F4 10/Symbol SF(*) -6 E F3(args)A F0(,)1.666 E F3(size_t num_args)4.166 E F0(,)1.666 E F3 -(int argc)4.166 E F0(,)1.666 E F3(char)4.166 E F4(**)6 E F3(argv)A F0(,) -1.666 E F3(int)151.666 210 Q F4(*)6 E F3(optind)A F0(\);)A F3(void)102 -240 Q F2(arg_printusage)102 252 Q F0(\()A F3(struct getargs)A F4(*)6 E -F3(args)A F0(,)1.666 E F3(size_t num_args)4.166 E F0(,)1.666 E F3 -(const char)4.166 E F4(*)6 E F3(progname)A F0(,)1.666 E F3(const char) -151.666 264 Q F4(*)6 E F3(extra_string)A F0(\);)A F1(DESCRIPTION)72 300 -Q F2(getarg)102 312 Q F0 2.721 1.666(\(\) c)D 6.053(ollects an)-1.666 F -8.553(yc)-.15 G 6.053(ommand line options gi)-8.553 F -.15(ve)-.25 G -8.552(nt).15 G 8.552(oap)-8.552 G 6.052(rogram in an easily used w) --8.552 F(ay)-.1 E(.)-.65 E F2(arg_printusage)102 324 Q F0 -3.332 1.666 -(\(\) p)D(retty-prints the a)-1.666 E -.25(va)-.2 G -(ilable options, with a short help te).25 E(xt.)-.15 E F3(args)102 342 Q -F0 .855(is the option speci\214cation to use, and it')3.355 F 3.356(sa) --.55 G 3.356(na)-3.356 G .856(rray of)-3.356 F F3 .856(struct getargs) -3.356 F F0(elements.)3.356 E F3(num_args)5.856 E F0(is)3.356 E .344 -(the size of)102 354 R F3(args)2.844 E F0 .344(\(in elements\).)2.844 F -F3(argc)5.344 E F0(and)2.844 E F3(argv)2.844 E F0 .344(are the ar)2.844 -F .344(gument count and ar)-.18 F .344(gument v)-.18 F .344(ector to e) --.15 F .343(xtract op-)-.15 F 1.127(tion from.)102 366 R F3(optind)6.127 -E F0 1.127(is a pointer to an inte)3.627 F 1.127(ger where the inde)-.15 -F 3.627(xt)-.15 G 3.628(ot)-3.627 G 1.128(he last processed ar)-3.628 F -1.128(gument is stored, it)-.18 F -(must be initialised to the \214rst inde)102 378 Q 2.5(x\()-.15 G -(minus one\) to process \(normally 0\) before the \214rst call.)-2.5 E -F3(arg_printusage)102 396 Q F0(tak)4.178 E 4.178(et)-.1 G 1.678(he same) --4.178 F F3(args)4.178 E F0(and)4.178 E F3(num_args)4.178 E F0 1.678 -(as getar)4.178 F(g;)-.18 E F3 1.677(progname is the name of)4.178 F -6.381(the program \(to be)102 408 R F0(progname0)12.381 E F3(0)12.381 E -F0(progname1)A F3(1)12.381 E F0(progname2)A F3(2)12.382 E F0(progname3)A -F3(3)12.382 E F0(progname4)A F3(4)102 420 Q F0(progname5)A F3 -(extra_string)3.404 E F0 .904 -(is a string to print after the actual options to indicate more ar)3.404 -F .904(guments. The)-.18 F .025(usefulness of this function is realised\ - only be people who has used programs that has help strings that doesn') -102 432 R(t)-.18 E(match what the code does.)102 444 Q(The)102 462 Q F3 -(getargs)2.5 E F0(struct has the follo)2.5 E(wing elements.)-.25 E/F5 10 -/Courier@0 SF(struct getargs{)102 504 Q(const char)126 516 Q F4(*)6 E F5 -(long_name;)A(char short_name;)126 528 Q(enum { arg_integer,)126 540 Q -(arg_string,)165 552 Q(arg_flag,)165 564 Q(arg_negative_flag,)165 576 Q -(arg_strings,)165 588 Q(arg_double,)165 600 Q(arg_collect)168 612 Q 6 -(}t)126 624 S(ype;)-6 E(void)126 636 Q F4(*)6 E F5(value;)A(const char) -126 648 Q F4(*)6 E F5(help;)A(const char)126 660 Q F4(*)6 E F5 -(arg_help;)A(};)102 672 Q F3(long_name)102 690 Q F0 .207 -(is the long name of the option, it can be)2.707 F F5(NULL)2.706 E F0 -2.706(,i)C 2.706(fy)-2.706 G .206(ou don')-2.706 F 2.706(tw)-.18 G .206 -(ant a long name.)-2.806 F F3(short_name)5.206 E F0 .397(is the charact\ -ed to use as short option, it can be zero. If the option has a v)102 702 -R .398(alue the)-.25 F F3(value)2.898 E F0 .398 -(\214eld gets \214lled in)2.898 F -.4(RO)77 750 S 152.325(KEN September) -.4 F(24, 1999)2.5 E(1)188.865 E EP -%%Page: 2 2 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F .737(with that v)102 96 R .737 -(alue interpreted as speci\214ed by the)-.25 F/F1 10/Courier-Oblique@0 -SF(type)3.237 E F0(\214eld.)3.237 E F1(help)5.737 E F0 .737 -(is a longer help string for the option as a)3.237 F 2.833 -(whole, if it')102 108 R(s)-.55 E/F2 10/Courier@0 SF(NULL)5.333 E F0 -2.833(the help te)5.333 F 2.833(xt for the option is omitted \(b)-.15 F -2.834(ut it')-.2 F 5.334(ss)-.55 G 2.834 -(till displayed in the synopsis\).)-5.334 F F1(arg_help)102 120 Q F0 -.391(is a description of the ar)2.891 F .391(gument, if)-.18 F F2(NULL) -2.891 E F0 2.891(ad)2.891 G(ef)-2.891 E .39(ault v)-.1 F .39 -(alue will be used, depending on the type of)-.25 F(the option:)102 132 -Q(ar)102 150 Q(g_inte)-.18 E 59.29(ger the)-.15 F(ar)2.5 E -(gument is a signed inte)-.18 E(ger)-.15 E 2.5(,a)-.4 G(nd)-2.5 E F1 -(value)2.5 E F0(should point to an)2.5 E F1(int)2.5 E F0(.)A F1 -(arg_string)102 168 Q F0(the ar)47 E(gument is a string, and)-.18 E F1 -(value)2.5 E F0(should point to a)2.5 E F1(char)2.5 E/F3 10/Symbol SF(*) -A F0(.)A F1(arg_flag)102 186 Q F0 .4(the ar)59 F .4 -(gument is a \215ag, and)-.18 F F1(value)2.9 E F0 .4(should point to a) -2.9 F F1(int)2.9 E F0 2.9(.I)C 2.9(tg)-2.9 G .4 -(ets \214lled in with ei-)-2.9 F 1.154 -(ther zero or one, depending on ho)209 198 R 3.654(wt)-.25 G 1.153 -(he option is gi)-3.654 F -.15(ve)-.25 G 1.153 -(n, the normal case beeing).15 F .526(one. Note that if the option isn') -209 210 R 3.026(tg)-.18 G -2.15 -.25(iv e)-3.026 H .526(n, the v).25 F -.526(alue isn')-.25 F 3.026(ta)-.18 G .527(ltered, so it should be ini-) --3.026 F(tialised to some useful def)209 222 Q(ault.)-.1 E F1 -(arg_negative_flag)102 240 Q F0 .058(this is the same as)2.558 F F1 -(arg_flag)2.558 E F0 -.2(bu)2.558 G 2.558(ti).2 G 2.558(tr)-2.558 G --2.15 -.25(ev e)-2.558 H .057(rses the meaning of the \215ag \(a gi).25 -F -.15(ve)-.25 G 2.557(ns).15 G(hort)-2.557 E -(option clears the \215ag\), and the synopsis of a long option is ne)209 -252 Q -.05(ga)-.15 G(ted.).05 E F1(arg_strings)102 270 Q F0 .195(the ar) -41 F .195(gument can be gi)-.18 F -.15(ve)-.25 G 2.695(nm).15 G .195 -(ultiple times, and the v)-2.695 F .195 -(alues are collected in an array;)-.25 F F1(value)209 282 Q F0 .947 -(should be a pointer to a)3.447 F F1 .947(struct getarg_strings)3.447 F -F0 .947(structure, which)3.447 F(holds a length and a string pointer)209 -294 Q(.)-.55 E F1(arg_double)102 312 Q F0(ar)47 E .538 -(gument is a double precision \215oating point v)-.18 F .539(alue, and) --.25 F F1(value)3.039 E F0 .539(should point to a)3.039 F F1(double)209 -324 Q F0(.)A F1(arg_collect)102 342 Q F0(allo)41 E .345 -(ws more \214ne-grained control of the option parsing process.)-.25 F F1 -(value)5.344 E F0 .344(should be)2.844 F 2.5(ap)209 354 S(ointer to a) --2.5 E F1(getarg_collect_info)2.5 E F0(structure:)2.5 E F2 -(typedef int \()209 372 Q F3(*)A F2 -(getarg_collect_func\)\(int short_opt,)A(int argc,)407 384 Q(char)407 -396 Q F3(**)6 E F2(argv,)A(int)407 408 Q F3(*)6 E F2(optind,)A(int)407 -420 Q F3(*)6 E F2(optarg,)A(void)407 432 Q F3(*)6 E F2(data\);)A -(typedef struct getarg_collect_info {)209 456 Q -(getarg_collect_func func;)233 468 Q(void)233 480 Q F3(*)6 E F2(data;)A -6(}g)209 492 S(etarg_collect_info;)-6 E F0 -.4(Wi)209 510 S 1.018 -(th the).4 F F1(func)3.518 E F0 1.019 -(member set to a function to call, and)3.518 F F1(data)3.519 E F0 1.019 -(to some application)3.519 F -(speci\214c data. The parameters to the collect function are:)209 522 Q -F1(short_flag)209 540 Q F0 -(non-zero if this call is via a short option \215ag, zero otherwise)2.5 -E F1(argc)209 558 Q F0(,)A F1(argv)6 E F0(the whole ar)2.5 E -(gument list)-.18 E F1(optind)209 576 Q F0(pointer to the inde)2.5 E 2.5 -(xi)-.15 G 2.5(na)-2.5 G -.18(rg)-2.5 G 2.5(vw).18 G(here the \215ag is) --2.5 E F1(optarg)209 594 Q F0(pointer to the inde)2.5 E 2.5(xi)-.15 G -2.5(na)-2.5 G -.18(rg)-2.5 G(v[).18 E F3(*)A F0 -(optind] where the \215ag name starts)A F1(data)209 612 Q F0 -(application speci\214c data)2.5 E -1.1(Yo)209 630 S 3.915(uc)1.1 G -1.415(an modify)-3.915 F F3(*)3.915 E F1(optind)A F0 3.915(,a)C(nd) --3.915 E F3(*)3.915 E F1(optarg)A F0 3.915(,b)C 1.414 -(ut to do this correct you \(more or)-4.115 F(less\) ha)209 642 Q .3 --.15(ve t)-.2 H 2.5(ok).15 G(no)-2.5 E 2.5(wa)-.25 G(bout the inner w) --2.5 E(orkings of getar)-.1 E(g.)-.18 E -1.1(Yo)209 666 S 3.604(uc)1.1 G -1.104(an skip parts of ar)-3.604 F 1.105(guments by increasing)-.18 F F3 -(*)3.605 E F1(optarg)A F0 1.105(\(you could implement)3.605 F(the)209 -678 Q/F4 10/Courier-Bold@0 SF4.567 E F1(3)A F0 .401 -(set of \215ags from)2.901 F F4(gzip)2.9 E F0 .4 -(with this\), or whole ar)2.9 F .4(gument strings by increas-)-.18 F -(ing)209 690 Q F3(*)3.275 E F1(optind)A F0(\(let')3.275 E 3.276(ss)-.55 -G .776(ay you w)-3.276 F .776(ant a \215ag)-.1 F F44.942 E F1 -6.776(xyz)6.776 G F0 .776(to specify a coordinate\); if)-3.5 F -(you also ha)209 702 Q .3 -.15(ve t)-.2 H 2.5(os).15 G(et)-2.5 E F3(*) -2.5 E F1(optarg)A F0(to a sane v)2.5 E(alue.)-.25 E -.4(RO)77 750 S -152.325(KEN September).4 F(24, 1999)2.5 E(2)188.865 E EP -%%Page: 3 3 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F 9.449 -(The collect function should return one of)209 96 R/F1 10/Courier@0 SF -(ARG_ERR_NO_MATCH)11.948 E F0(,)A F1(ARG_ERR_BAD_ARG)209 108 Q F0(,)A F1 -(ARG_ERR_NO_ARG)6 E F0(on error)2.5 E 2.5(,z)-.4 G(ero otherwise.)-2.5 E --.15(Fo)209 126 S 4.042(ry).15 G 1.542(our con)-4.042 F -.15(ve)-.4 G -1.542(nience there is a function,).15 F/F2 10/Courier-Bold@0 SF -(getarg_optarg)4.042 E F0 1.542(\(\), that returns the)B 1.251 -(traditional ar)209 138 R 1.251(gument string, and you pass it all ar) --.18 F 1.251(guments, sans data, that where)-.18 F(gi)209 150 Q -.15(ve) --.25 G 2.5(nt).15 G 2.5(ot)-2.5 G(he collection function.)-2.5 E(Don') -209 168 Q 2.5(tu)-.18 G(se this more this unless you absolutely ha)-2.5 -E .3 -.15(ve t)-.2 H(o.).15 E .213(Option parsing is similar to what)102 -186 R F1(getopt)2.713 E F0 .214(uses. Short options without ar)2.714 F -.214(guments can be compressed \()-.18 F F2(\255xyz)1.666 E F0 .207 -(is the same as)102 198 R F2 1.8734.373 F F0 .207 -(\), and short options with ar)B .207(guments tak)-.18 F 2.706(et)-.1 G -.206(hese as either the rest of the ar)-2.706 F(gv-string)-.18 E -(or as the ne)102 210 Q(xt option \()-.15 E F21.666 E/F3 10 -/Courier-Oblique@0 SF(foo)A F0 2.5(,o)C(r)-2.5 E F24.166 E F3(foo) -6 E F0(\).)A .78(Long option names are pre\214x)102 228 R .781 -(ed with -- \(double dash\), and the v)-.15 F .781 -(alue with a = \(equal\),)-.25 F F2(\255-foo=)4.947 E F3(bar)A F0 3.281 -(.L)C(ong)-3.281 E 3.815 -(option \215ags can either be speci\214ed as the)102 240 R 6.315(ya)-.15 -G 3.815(re \()-6.315 F F2(\255-help)1.666 E F0 3.815 -(\), or with an \(boolean parsable\) option)B(\()102 252 Q F2 -(\255-help=)1.666 E F3(yes)A F0(,)A F2(\255-help=)5.659 E F3(true)A F0 -3.993(,o)C 3.993(rs)-3.993 G 1.493(imilar\), or the)-3.993 F 3.993(yc) --.15 G 1.493(an also be ne)-3.993 F -.05(ga)-.15 G 1.493(ted \().05 F F2 -(\255-no-help)1.666 E F0 1.493(is the same as)3.993 F F2(\255-help=) -103.666 264 Q F0 1.363(no\), and if you')B 1.362 -(re really confused you can do it multiple times \()-.5 F F2 -(\255-no-no-help=)1.666 E F3(false)A F0 3.862(,o)C(r)-3.862 E -2.15 -.25 -(ev e)102 276 T(n).25 E F2(\255-no-no-help=)4.166 E F3(maybe)A F0(\).)A -/F4 10/Times-Bold@0 SF(EXAMPLE)72 300 Q F1(#include )102 330 Q -(#include )102 342 Q(#include )102 354 Q(char)102 -378 Q/F5 10/Symbol SF(*)6 E F1(source = "Ouagadougou";)A(char)102 390 Q -F5(*)6 E F1(destination;)A(int weight;)102 402 Q -(int include_catalog = 1;)102 414 Q(int help_flag;)102 426 Q -(struct getargs args[] = {)102 450 Q 6({")126 462 S 30(source", 's',)-6 -F 6(arg_string, &source,)6 F("source of shippment", "city" },)138 474 Q -6({")126 486 S(destination", 'd', arg_string,)-6 E(&destination,)12 E -("destination of shippment", "city" },)138 498 Q 6({")126 510 S 30 -(weight", 'w',)-6 F(arg_integer, &weight,)6 E -("weight of shippment", "tons" },)138 522 Q 6({")126 534 S 24 -(catalog", 'c',)-6 F(arg_negative_flag, &include_catalog,)6 E -("include product catalog" },)138 546 Q 6({")126 558 S 42(help", 'h',)-6 -F(arg_flag, &help_flag })6 E(};)102 570 Q -(int num_args = sizeof\(args\) / sizeof\(args[0]\); /)102 594 Q F5(*)A -F1(number of elements in args)6 E F5(*)6 E F1(/)A(const char)102 618 Q -F5(*)6 E F1(progname = "ship++";)A(int)102 642 Q(main\(int argc, char) -102 654 Q F5(**)6 E F1(argv\))A({)102 666 Q(int optind = 0;)126 678 Q -(if \(getarg\(args, num_args, argc, argv, &optind\)\) {)126 690 Q -(arg_printusage\(args, num_args, progname, "stuff..."\);)147 702 Q F0 --.4(RO)77 750 S 152.325(KEN September).4 F(24, 1999)2.5 E(3)188.865 E EP -%%Page: 4 4 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F/F1 10/Courier@0 SF(exit \(1\);)147 96 Q(})126 -108 Q(if \(help_flag\) {)126 120 Q -(arg_printusage\(args, num_args, progname, "stuff..."\);)147 132 Q -(exit \(0\);)147 144 Q(})126 156 Q(if \(destination == NULL\) {)126 168 -Q(fprintf\(stderr, "%s: must specify destination0, progname\);)147 180 Q -(exit\(1\);)147 192 Q(})126 204 Q -(if \(strcmp\(source, destination\) == 0\) {)126 216 Q -(fprintf\(stderr, "%s: destination must be different from source0\);)147 -228 Q(exit\(1\);)147 240 Q(})126 252 Q(/)126 264 Q/F2 10/Symbol SF(*)A -F1(include more stuff here ...)6 E F2(*)6 E F1(/)A(exit\(2\);)126 276 Q -(})102 288 Q F0(The output help output from this program looks lik)102 -306 Q 2.5(et)-.1 G(his:)-2.5 E F1 6($s)102 324 S(hip++ --help)-6 E -(Usage: ship++ [--source=city] [-s city] [--destination=city] [-d city]) -102 336 Q -([--weight=tons] [-w tons] [--no-catalog] [-c] [--help] [-h] stuff...) -120 348 Q(-s city, --source=city)102 360 Q(source of shippment)36 E -(-d city, --destination=city destination of shippment)102 372 Q -(-w tons, --weight=tons)102 384 Q(weight of shippment)36 E -(-c, --no-catalog)102 396 Q(include product catalog)72 E/F3 10 -/Times-Bold@0 SF -.1(BU)72 432 S(GS).1 E F0 .9(It should be more \215e) -102 444 R .9(xible, so it w)-.15 F .901 -(ould be possible to use other more complicated option syntax)-.1 F .901 -(es, such as)-.15 F(what)102 456 Q F1(ps)3.167 E F0 .667(\(1\), and)B F1 -(tar)3.167 E F0 .666(\(1\), uses, or the AFS model where you can skip t\ -he \215ag names as long as the options)B(come in the correct order)102 -468 Q(.)-.55 E(Options with multiple ar)102 486 Q -(guments should be handled better)-.18 E(.)-.55 E(Should be inte)102 504 -Q(greated with SL.)-.15 E(It')102 522 Q 2.5(sv)-.55 G -(ery confusing that the struct you pass in is called getar)-2.65 E(gS.) --.18 E F3 1.666(SEE ALSO)72 546 R F1(getopt)102 558 Q F0(\(3\))A -.4(RO) -77 750 S 152.325(KEN September).4 F(24, 1999)2.5 E(4)188.865 E EP -%%Trailer -end -%%EOF diff --git a/ndb/src/common/util/md5-rfc1321.txt b/ndb/src/common/util/md5-rfc1321.txt deleted file mode 100644 index c9e09e00cce..00000000000 --- a/ndb/src/common/util/md5-rfc1321.txt +++ /dev/null @@ -1,1179 +0,0 @@ - - - - - - -Network Working Group R. Rivest -Request for Comments: 1321 MIT Laboratory for Computer Science - and RSA Data Security, Inc. - April 1992 - - - The MD5 Message-Digest Algorithm - -Status of this Memo - - This memo provides information for the Internet community. It does - not specify an Internet standard. Distribution of this memo is - unlimited. - -Acknowlegements - - We would like to thank Don Coppersmith, Burt Kaliski, Ralph Merkle, - David Chaum, and Noam Nisan for numerous helpful comments and - suggestions. - -Table of Contents - - 1. Executive Summary 1 - 2. Terminology and Notation 2 - 3. MD5 Algorithm Description 3 - 4. Summary 6 - 5. Differences Between MD4 and MD5 6 - References 7 - APPENDIX A - Reference Implementation 7 - Security Considerations 21 - Author's Address 21 - -1. Executive Summary - - This document describes the MD5 message-digest algorithm. The - algorithm takes as input a message of arbitrary length and produces - as output a 128-bit "fingerprint" or "message digest" of the input. - It is conjectured that it is computationally infeasible to produce - two messages having the same message digest, or to produce any - message having a given prespecified target message digest. The MD5 - algorithm is intended for digital signature applications, where a - large file must be "compressed" in a secure manner before being - encrypted with a private (secret) key under a public-key cryptosystem - such as RSA. - - - - - - - -Rivest [Page 1] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - The MD5 algorithm is designed to be quite fast on 32-bit machines. In - addition, the MD5 algorithm does not require any large substitution - tables; the algorithm can be coded quite compactly. - - The MD5 algorithm is an extension of the MD4 message-digest algorithm - 1,2]. MD5 is slightly slower than MD4, but is more "conservative" in - design. MD5 was designed because it was felt that MD4 was perhaps - being adopted for use more quickly than justified by the existing - critical review; because MD4 was designed to be exceptionally fast, - it is "at the edge" in terms of risking successful cryptanalytic - attack. MD5 backs off a bit, giving up a little in speed for a much - greater likelihood of ultimate security. It incorporates some - suggestions made by various reviewers, and contains additional - optimizations. The MD5 algorithm is being placed in the public domain - for review and possible adoption as a standard. - - For OSI-based applications, MD5's object identifier is - - md5 OBJECT IDENTIFIER ::= - iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 5} - - In the X.509 type AlgorithmIdentifier [3], the parameters for MD5 - should have type NULL. - -2. Terminology and Notation - - In this document a "word" is a 32-bit quantity and a "byte" is an - eight-bit quantity. A sequence of bits can be interpreted in a - natural manner as a sequence of bytes, where each consecutive group - of eight bits is interpreted as a byte with the high-order (most - significant) bit of each byte listed first. Similarly, a sequence of - bytes can be interpreted as a sequence of 32-bit words, where each - consecutive group of four bytes is interpreted as a word with the - low-order (least significant) byte given first. - - Let x_i denote "x sub i". If the subscript is an expression, we - surround it in braces, as in x_{i+1}. Similarly, we use ^ for - superscripts (exponentiation), so that x^i denotes x to the i-th - power. - - Let the symbol "+" denote addition of words (i.e., modulo-2^32 - addition). Let X <<< s denote the 32-bit value obtained by circularly - shifting (rotating) X left by s bit positions. Let not(X) denote the - bit-wise complement of X, and let X v Y denote the bit-wise OR of X - and Y. Let X xor Y denote the bit-wise XOR of X and Y, and let XY - denote the bit-wise AND of X and Y. - - - - - -Rivest [Page 2] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -3. MD5 Algorithm Description - - We begin by supposing that we have a b-bit message as input, and that - we wish to find its message digest. Here b is an arbitrary - nonnegative integer; b may be zero, it need not be a multiple of - eight, and it may be arbitrarily large. We imagine the bits of the - message written down as follows: - - m_0 m_1 ... m_{b-1} - - The following five steps are performed to compute the message digest - of the message. - -3.1 Step 1. Append Padding Bits - - The message is "padded" (extended) so that its length (in bits) is - congruent to 448, modulo 512. That is, the message is extended so - that it is just 64 bits shy of being a multiple of 512 bits long. - Padding is always performed, even if the length of the message is - already congruent to 448, modulo 512. - - Padding is performed as follows: a single "1" bit is appended to the - message, and then "0" bits are appended so that the length in bits of - the padded message becomes congruent to 448, modulo 512. In all, at - least one bit and at most 512 bits are appended. - -3.2 Step 2. Append Length - - A 64-bit representation of b (the length of the message before the - padding bits were added) is appended to the result of the previous - step. In the unlikely event that b is greater than 2^64, then only - the low-order 64 bits of b are used. (These bits are appended as two - 32-bit words and appended low-order word first in accordance with the - previous conventions.) - - At this point the resulting message (after padding with bits and with - b) has a length that is an exact multiple of 512 bits. Equivalently, - this message has a length that is an exact multiple of 16 (32-bit) - words. Let M[0 ... N-1] denote the words of the resulting message, - where N is a multiple of 16. - -3.3 Step 3. Initialize MD Buffer - - A four-word buffer (A,B,C,D) is used to compute the message digest. - Here each of A, B, C, D is a 32-bit register. These registers are - initialized to the following values in hexadecimal, low-order bytes - first): - - - - -Rivest [Page 3] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - word A: 01 23 45 67 - word B: 89 ab cd ef - word C: fe dc ba 98 - word D: 76 54 32 10 - -3.4 Step 4. Process Message in 16-Word Blocks - - We first define four auxiliary functions that each take as input - three 32-bit words and produce as output one 32-bit word. - - F(X,Y,Z) = XY v not(X) Z - G(X,Y,Z) = XZ v Y not(Z) - H(X,Y,Z) = X xor Y xor Z - I(X,Y,Z) = Y xor (X v not(Z)) - - In each bit position F acts as a conditional: if X then Y else Z. - The function F could have been defined using + instead of v since XY - and not(X)Z will never have 1's in the same bit position.) It is - interesting to note that if the bits of X, Y, and Z are independent - and unbiased, the each bit of F(X,Y,Z) will be independent and - unbiased. - - The functions G, H, and I are similar to the function F, in that they - act in "bitwise parallel" to produce their output from the bits of X, - Y, and Z, in such a manner that if the corresponding bits of X, Y, - and Z are independent and unbiased, then each bit of G(X,Y,Z), - H(X,Y,Z), and I(X,Y,Z) will be independent and unbiased. Note that - the function H is the bit-wise "xor" or "parity" function of its - inputs. - - This step uses a 64-element table T[1 ... 64] constructed from the - sine function. Let T[i] denote the i-th element of the table, which - is equal to the integer part of 4294967296 times abs(sin(i)), where i - is in radians. The elements of the table are given in the appendix. - - Do the following: - - /* Process each 16-word block. */ - For i = 0 to N/16-1 do - - /* Copy block i into X. */ - For j = 0 to 15 do - Set X[j] to M[i*16+j]. - end /* of loop on j */ - - /* Save A as AA, B as BB, C as CC, and D as DD. */ - AA = A - BB = B - - - -Rivest [Page 4] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - CC = C - DD = D - - /* Round 1. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 0 7 1] [DABC 1 12 2] [CDAB 2 17 3] [BCDA 3 22 4] - [ABCD 4 7 5] [DABC 5 12 6] [CDAB 6 17 7] [BCDA 7 22 8] - [ABCD 8 7 9] [DABC 9 12 10] [CDAB 10 17 11] [BCDA 11 22 12] - [ABCD 12 7 13] [DABC 13 12 14] [CDAB 14 17 15] [BCDA 15 22 16] - - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 1 5 17] [DABC 6 9 18] [CDAB 11 14 19] [BCDA 0 20 20] - [ABCD 5 5 21] [DABC 10 9 22] [CDAB 15 14 23] [BCDA 4 20 24] - [ABCD 9 5 25] [DABC 14 9 26] [CDAB 3 14 27] [BCDA 8 20 28] - [ABCD 13 5 29] [DABC 2 9 30] [CDAB 7 14 31] [BCDA 12 20 32] - - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 5 4 33] [DABC 8 11 34] [CDAB 11 16 35] [BCDA 14 23 36] - [ABCD 1 4 37] [DABC 4 11 38] [CDAB 7 16 39] [BCDA 10 23 40] - [ABCD 13 4 41] [DABC 0 11 42] [CDAB 3 16 43] [BCDA 6 23 44] - [ABCD 9 4 45] [DABC 12 11 46] [CDAB 15 16 47] [BCDA 2 23 48] - - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 0 6 49] [DABC 7 10 50] [CDAB 14 15 51] [BCDA 5 21 52] - [ABCD 12 6 53] [DABC 3 10 54] [CDAB 10 15 55] [BCDA 1 21 56] - [ABCD 8 6 57] [DABC 15 10 58] [CDAB 6 15 59] [BCDA 13 21 60] - [ABCD 4 6 61] [DABC 11 10 62] [CDAB 2 15 63] [BCDA 9 21 64] - - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ - A = A + AA - B = B + BB - C = C + CC - D = D + DD - - end /* of loop on i */ - - - -Rivest [Page 5] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -3.5 Step 5. Output - - The message digest produced as output is A, B, C, D. That is, we - begin with the low-order byte of A, and end with the high-order byte - of D. - - This completes the description of MD5. A reference implementation in - C is given in the appendix. - -4. Summary - - The MD5 message-digest algorithm is simple to implement, and provides - a "fingerprint" or message digest of a message of arbitrary length. - It is conjectured that the difficulty of coming up with two messages - having the same message digest is on the order of 2^64 operations, - and that the difficulty of coming up with any message having a given - message digest is on the order of 2^128 operations. The MD5 algorithm - has been carefully scrutinized for weaknesses. It is, however, a - relatively new algorithm and further security analysis is of course - justified, as is the case with any new proposal of this sort. - -5. Differences Between MD4 and MD5 - - The following are the differences between MD4 and MD5: - - 1. A fourth round has been added. - - 2. Each step now has a unique additive constant. - - 3. The function g in round 2 was changed from (XY v XZ v YZ) to - (XZ v Y not(Z)) to make g less symmetric. - - 4. Each step now adds in the result of the previous step. This - promotes a faster "avalanche effect". - - 5. The order in which input words are accessed in rounds 2 and - 3 is changed, to make these patterns less like each other. - - 6. The shift amounts in each round have been approximately - optimized, to yield a faster "avalanche effect." The shifts in - different rounds are distinct. - - - - - - - - - - -Rivest [Page 6] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -References - - [1] Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT and - RSA Data Security, Inc., April 1992. - - [2] Rivest, R., "The MD4 message digest algorithm", in A.J. Menezes - and S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90 - Proceedings, pages 303-311, Springer-Verlag, 1991. - - [3] CCITT Recommendation X.509 (1988), "The Directory - - Authentication Framework." - -APPENDIX A - Reference Implementation - - This appendix contains the following files taken from RSAREF: A - Cryptographic Toolkit for Privacy-Enhanced Mail: - - global.h -- global header file - - md5.h -- header file for MD5 - - md5c.c -- source code for MD5 - - For more information on RSAREF, send email to . - - The appendix also includes the following file: - - mddriver.c -- test driver for MD2, MD4 and MD5 - - The driver compiles for MD5 by default but can compile for MD2 or MD4 - if the symbol MD is defined on the C compiler command line as 2 or 4. - - The implementation is portable and should work on many different - plaforms. However, it is not difficult to optimize the implementation - on particular platforms, an exercise left to the reader. For example, - on "little-endian" platforms where the lowest-addressed byte in a 32- - bit word is the least significant and there are no alignment - restrictions, the call to Decode in MD5Transform can be replaced with - a typecast. - -A.1 global.h - -/* GLOBAL.H - RSAREF types and constants - */ - -/* PROTOTYPES should be set to one if and only if the compiler supports - function argument prototyping. -The following makes PROTOTYPES default to 0 if it has not already - - - -Rivest [Page 7] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - been defined with C compiler flags. - */ -#ifndef PROTOTYPES -#define PROTOTYPES 0 -#endif - -/* POINTER defines a generic pointer type */ -typedef unsigned char *POINTER; - -/* UINT2 defines a two byte word */ -typedef unsigned short int UINT2; - -/* UINT4 defines a four byte word */ -typedef unsigned long int UINT4; - -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. -If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it - returns an empty list. - */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif - -A.2 md5.h - -/* MD5.H - header file for MD5C.C - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - - - - -Rivest [Page 8] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -/* MD5 context. */ -typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ -} MD5_CTX; - -void MD5Init PROTO_LIST ((MD5_CTX *)); -void MD5Update PROTO_LIST - ((MD5_CTX *, unsigned char *, unsigned int)); -void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); - -A.3 md5c.c - -/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -#include "global.h" -#include "md5.h" - -/* Constants for MD5Transform routine. - */ - - - -Rivest [Page 9] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64])); -static void Encode PROTO_LIST - ((unsigned char *, UINT4 *, unsigned int)); -static void Decode PROTO_LIST - ((UINT4 *, unsigned char *, unsigned int)); -static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int)); -static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int)); - -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* F, G, H and I are basic MD5 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits. - */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -Rotation is separate from addition to prevent recomputation. - */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - - - -Rivest [Page 10] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -/* MD5 initialization. Begins an MD5 operation, writing a new context. - */ -void MD5Init (context) -MD5_CTX *context; /* context */ -{ - context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. -*/ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; -} - -/* MD5 block update operation. Continues an MD5 message-digest - operation, processing another message block, and updating the - context. - */ -void MD5Update (context, input, inputLen) -MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ -{ - unsigned int i, index, partLen; - - /* Compute number of bytes mod 64 */ - index = (unsigned int)((context->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((context->count[0] += ((UINT4)inputLen << 3)) - - - -Rivest [Page 11] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); - - partLen = 64 - index; - - /* Transform as many times as possible. -*/ - if (inputLen >= partLen) { - MD5_memcpy - ((POINTER)&context->buffer[index], (POINTER)input, partLen); - MD5Transform (context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); - - index = 0; - } - else - i = 0; - - /* Buffer remaining input */ - MD5_memcpy - ((POINTER)&context->buffer[index], (POINTER)&input[i], - inputLen-i); -} - -/* MD5 finalization. Ends an MD5 message-digest operation, writing the - the message digest and zeroizing the context. - */ -void MD5Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ -{ - unsigned char bits[8]; - unsigned int index, padLen; - - /* Save number of bits */ - Encode (bits, context->count, 8); - - /* Pad out to 56 mod 64. -*/ - index = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update (context, PADDING, padLen); - - /* Append length (before padding) */ - MD5Update (context, bits, 8); - - - -Rivest [Page 12] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - /* Store state in digest */ - Encode (digest, context->state, 16); - - /* Zeroize sensitive information. -*/ - MD5_memset ((POINTER)context, 0, sizeof (*context)); -} - -/* MD5 basic transformation. Transforms state based on block. - */ -static void MD5Transform (state, block) -UINT4 state[4]; -unsigned char block[64]; -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - - - -Rivest [Page 13] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. - - - -Rivest [Page 14] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -*/ - MD5_memset ((POINTER)x, 0, sizeof (x)); -} - -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. - */ -static void Encode (output, input, len) -unsigned char *output; -UINT4 *input; -unsigned int len; -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } -} - -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. - */ -static void Decode (output, input, len) -UINT4 *output; -unsigned char *input; -unsigned int len; -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); -} - -/* Note: Replace "for loop" with standard memcpy if possible. - */ - -static void MD5_memcpy (output, input, len) -POINTER output; -POINTER input; -unsigned int len; -{ - unsigned int i; - - for (i = 0; i < len; i++) - - - -Rivest [Page 15] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - output[i] = input[i]; -} - -/* Note: Replace "for loop" with standard memset if possible. - */ -static void MD5_memset (output, value, len) -POINTER output; -int value; -unsigned int len; -{ - unsigned int i; - - for (i = 0; i < len; i++) - ((char *)output)[i] = (char)value; -} - -A.4 mddriver.c - -/* MDDRIVER.C - test driver for MD2, MD4 and MD5 - */ - -/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All -rights reserved. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -/* The following makes MD default to MD5 if it has not already been - defined with C compiler flags. - */ -#ifndef MD -#define MD MD5 -#endif - -#include -#include -#include -#include "global.h" -#if MD == 2 -#include "md2.h" -#endif -#if MD == 4 - - - -Rivest [Page 16] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -#include "md4.h" -#endif -#if MD == 5 -#include "md5.h" -#endif - -/* Length of test block, number of test blocks. - */ -#define TEST_BLOCK_LEN 1000 -#define TEST_BLOCK_COUNT 1000 - -static void MDString PROTO_LIST ((char *)); -static void MDTimeTrial PROTO_LIST ((void)); -static void MDTestSuite PROTO_LIST ((void)); -static void MDFile PROTO_LIST ((char *)); -static void MDFilter PROTO_LIST ((void)); -static void MDPrint PROTO_LIST ((unsigned char [16])); - -#if MD == 2 -#define MD_CTX MD2_CTX -#define MDInit MD2Init -#define MDUpdate MD2Update -#define MDFinal MD2Final -#endif -#if MD == 4 -#define MD_CTX MD4_CTX -#define MDInit MD4Init -#define MDUpdate MD4Update -#define MDFinal MD4Final -#endif -#if MD == 5 -#define MD_CTX MD5_CTX -#define MDInit MD5Init -#define MDUpdate MD5Update -#define MDFinal MD5Final -#endif - -/* Main driver. - -Arguments (may be any combination): - -sstring - digests string - -t - runs time trial - -x - runs test script - filename - digests file - (none) - digests standard input - */ -int main (argc, argv) -int argc; - - - -Rivest [Page 17] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -char *argv[]; -{ - int i; - - if (argc > 1) - for (i = 1; i < argc; i++) - if (argv[i][0] == '-' && argv[i][1] == 's') - MDString (argv[i] + 2); - else if (strcmp (argv[i], "-t") == 0) - MDTimeTrial (); - else if (strcmp (argv[i], "-x") == 0) - MDTestSuite (); - else - MDFile (argv[i]); - else - MDFilter (); - - return (0); -} - -/* Digests a string and prints the result. - */ -static void MDString (string) -char *string; -{ - MD_CTX context; - unsigned char digest[16]; - unsigned int len = strlen (string); - - MDInit (&context); - MDUpdate (&context, string, len); - MDFinal (digest, &context); - - printf ("MD%d (\"%s\") = ", MD, string); - MDPrint (digest); - printf ("\n"); -} - -/* Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte - blocks. - */ -static void MDTimeTrial () -{ - MD_CTX context; - time_t endTime, startTime; - unsigned char block[TEST_BLOCK_LEN], digest[16]; - unsigned int i; - - - - -Rivest [Page 18] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - printf - ("MD%d time trial. Digesting %d %d-byte blocks ...", MD, - TEST_BLOCK_LEN, TEST_BLOCK_COUNT); - - /* Initialize block */ - for (i = 0; i < TEST_BLOCK_LEN; i++) - block[i] = (unsigned char)(i & 0xff); - - /* Start timer */ - time (&startTime); - - /* Digest blocks */ - MDInit (&context); - for (i = 0; i < TEST_BLOCK_COUNT; i++) - MDUpdate (&context, block, TEST_BLOCK_LEN); - MDFinal (digest, &context); - - /* Stop timer */ - time (&endTime); - - printf (" done\n"); - printf ("Digest = "); - MDPrint (digest); - printf ("\nTime = %ld seconds\n", (long)(endTime-startTime)); - printf - ("Speed = %ld bytes/second\n", - (long)TEST_BLOCK_LEN * (long)TEST_BLOCK_COUNT/(endTime-startTime)); -} - -/* Digests a reference suite of strings and prints the results. - */ -static void MDTestSuite () -{ - printf ("MD%d test suite:\n", MD); - - MDString (""); - MDString ("a"); - MDString ("abc"); - MDString ("message digest"); - MDString ("abcdefghijklmnopqrstuvwxyz"); - MDString - ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); - MDString - ("1234567890123456789012345678901234567890\ -1234567890123456789012345678901234567890"); -} - -/* Digests a file and prints the result. - - - -Rivest [Page 19] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - */ -static void MDFile (filename) -char *filename; -{ - FILE *file; - MD_CTX context; - int len; - unsigned char buffer[1024], digest[16]; - - if ((file = fopen (filename, "rb")) == NULL) - printf ("%s can't be opened\n", filename); - - else { - MDInit (&context); - while (len = fread (buffer, 1, 1024, file)) - MDUpdate (&context, buffer, len); - MDFinal (digest, &context); - - fclose (file); - - printf ("MD%d (%s) = ", MD, filename); - MDPrint (digest); - printf ("\n"); - } -} - -/* Digests the standard input and prints the result. - */ -static void MDFilter () -{ - MD_CTX context; - int len; - unsigned char buffer[16], digest[16]; - - MDInit (&context); - while (len = fread (buffer, 1, 16, stdin)) - MDUpdate (&context, buffer, len); - MDFinal (digest, &context); - - MDPrint (digest); - printf ("\n"); -} - -/* Prints a message digest in hexadecimal. - */ -static void MDPrint (digest) -unsigned char digest[16]; -{ - - - -Rivest [Page 20] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - unsigned int i; - - for (i = 0; i < 16; i++) - printf ("%02x", digest[i]); -} - -A.5 Test suite - - The MD5 test suite (driver option "-x") should print the following - results: - -MD5 test suite: -MD5 ("") = d41d8cd98f00b204e9800998ecf8427e -MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661 -MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72 -MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0 -MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b -MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = -d174ab98d277d9f5a5611c2c9f419d9f -MD5 ("123456789012345678901234567890123456789012345678901234567890123456 -78901234567890") = 57edf4a22be3c955ac49da2e2107b67a - -Security Considerations - - The level of security discussed in this memo is considered to be - sufficient for implementing very high security hybrid digital- - signature schemes based on MD5 and a public-key cryptosystem. - -Author's Address - - Ronald L. Rivest - Massachusetts Institute of Technology - Laboratory for Computer Science - NE43-324 - 545 Technology Square - Cambridge, MA 02139-1986 - - Phone: (617) 253-5880 - EMail: rivest@theory.lcs.mit.edu - - - - - - - - - - - - -Rivest [Page 21] - diff --git a/ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs b/ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs deleted file mode 100644 index 9f89a3282c5..00000000000 --- a/ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] diff --git a/ndb/src/cw/cpcc-win32/vb6/frmSplash.frm b/ndb/src/cw/cpcc-win32/vb6/frmSplash.frm deleted file mode 100644 index 56ccbd79876..00000000000 --- a/ndb/src/cw/cpcc-win32/vb6/frmSplash.frm +++ /dev/null @@ -1,159 +0,0 @@ -VERSION 5.00 -Begin VB.Form frmSplash - BorderStyle = 3 'Fixed Dialog - ClientHeight = 4710 - ClientLeft = 45 - ClientTop = 45 - ClientWidth = 7455 - ControlBox = 0 'False - LinkTopic = "Form1" - MaxButton = 0 'False - MinButton = 0 'False - ScaleHeight = 4710 - ScaleWidth = 7455 - ShowInTaskbar = 0 'False - StartUpPosition = 2 'CenterScreen - Visible = 0 'False - Begin VB.Frame fraMainFrame - Height = 4590 - Left = 45 - TabIndex = 0 - Top = -15 - Width = 7380 - Begin VB.PictureBox picLogo - Height = 2385 - Left = 510 - Picture = "frmSplash.frx":0000 - ScaleHeight = 2325 - ScaleWidth = 1755 - TabIndex = 2 - Top = 855 - Width = 1815 - End - Begin VB.Label lblLicenseTo - Alignment = 1 'Right Justify - Caption = "LicenseTo" - Height = 255 - Left = 270 - TabIndex = 1 - Tag = "LicenseTo" - Top = 300 - Width = 6855 - End - Begin VB.Label lblProductName - AutoSize = -1 'True - Caption = "Product" - BeginProperty Font - Name = "MS Sans Serif" - Size = 29.25 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 720 - Left = 2670 - TabIndex = 9 - Tag = "Product" - Top = 1200 - Width = 2190 - End - Begin VB.Label lblCompanyProduct - AutoSize = -1 'True - Caption = "CompanyProduct" - BeginProperty Font - Name = "MS Sans Serif" - Size = 18 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 435 - Left = 2505 - TabIndex = 8 - Tag = "CompanyProduct" - Top = 765 - Width = 3000 - End - Begin VB.Label lblPlatform - Alignment = 1 'Right Justify - AutoSize = -1 'True - Caption = "Platform" - BeginProperty Font - Name = "MS Sans Serif" - Size = 13.5 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 360 - Left = 5865 - TabIndex = 7 - Tag = "Platform" - Top = 2400 - Width = 1140 - End - Begin VB.Label lblVersion - Alignment = 1 'Right Justify - AutoSize = -1 'True - Caption = "Version" - BeginProperty Font - Name = "MS Sans Serif" - Size = 12 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 300 - Left = 6075 - TabIndex = 6 - Tag = "Version" - Top = 2760 - Width = 930 - End - Begin VB.Label lblWarning - Caption = "Warning" - Height = 195 - Left = 300 - TabIndex = 3 - Tag = "Warning" - Top = 3720 - Width = 6855 - End - Begin VB.Label lblCompany - Caption = "Company" - Height = 255 - Left = 4710 - TabIndex = 5 - Tag = "Company" - Top = 3330 - Width = 2415 - End - Begin VB.Label lblCopyright - Caption = "Copyright" - Height = 255 - Left = 4710 - TabIndex = 4 - Tag = "Copyright" - Top = 3120 - Width = 2415 - End - End -End -Attribute VB_Name = "frmSplash" -Attribute VB_GlobalNameSpace = False -Attribute VB_Creatable = False -Attribute VB_PredeclaredId = True -Attribute VB_Exposed = False -Private Sub Form_Load() - lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision - lblProductName.Caption = App.Title -End Sub - diff --git a/ndb/src/external/LINUX.x86/sci/include/list.h b/ndb/src/external/LINUX.x86/sci/include/list.h deleted file mode 100644 index 81c467a461b..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/list.h +++ /dev/null @@ -1,56 +0,0 @@ -/* $Id: list.h,v 1.1 2002/12/13 12:17:20 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - - -#ifndef _LIST_H -#define _LIST_H -#include "sci_types.h" - - -typedef struct ListElement *ListElement_t; -typedef struct List *List_t; - -struct ListElement { - void *element; - u_vkaddr_t key; - ListElement_t prev,next; -}; - -void *Get_Element(ListElement_t el); -void Set_Element(ListElement_t el,void *elptr,u_vkaddr_t key); -void Create_Element(ListElement_t *el); -void Destroy_Element(ListElement_t *el); -void Create_List(List_t *list); -void Destroy_List(List_t *list); -void Add_Element(List_t list,ListElement_t el); -void Remove_Element(List_t list,ListElement_t el); -ListElement_t Find_Element(List_t list,u_vkaddr_t key); -scibool List_Empty(List_t); -scibool List_Elements(List_t); -ListElement_t First_Element(List_t list); -ListElement_t Last_Element(List_t list); -ListElement_t Next_Element(ListElement_t el); - -#endif /* _LIST_H */ diff --git a/ndb/src/external/LINUX.x86/sci/include/os/inttypes.h b/ndb/src/external/LINUX.x86/sci/include/os/inttypes.h deleted file mode 100644 index b9e5a6cb19f..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/os/inttypes.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $Id: inttypes.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - -#ifndef _SCI_OS_INTTYPES_H_ -#define _SCI_OS_INTTYPES_H_ - -/* - * -------------------------------------------------------------------------------------- - * Basic types of various sizes. - * -------------------------------------------------------------------------------------- - */ -typedef unsigned char unsigned8; -typedef unsigned short unsigned16; -typedef unsigned int unsigned32; -typedef unsigned long long unsigned64; - -typedef signed char signed8; -typedef signed short signed16; -typedef signed int signed32; -typedef signed long long signed64; - - -#ifdef CPU_WORD_IS_64_BIT -typedef unsigned64 uptr_t; -typedef signed64 iptr_t; -#else -typedef unsigned32 uptr_t; -typedef signed32 iptr_t; -#endif - -#endif /* _SCI_OS_INTTYPES_H_ */ diff --git a/ndb/src/external/LINUX.x86/sci/include/rmlib.h b/ndb/src/external/LINUX.x86/sci/include/rmlib.h deleted file mode 100644 index 9d2722e9798..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/rmlib.h +++ /dev/null @@ -1,212 +0,0 @@ -/* $Id: rmlib.h,v 1.1 2002/12/13 12:17:20 hin Exp $ */ - -/********************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *********************************************************************************/ - -/********************************************************************************/ -/* This header file contains the declarations of the SCI Reflective Memory */ -/* library rmlib. The implementation of the library functions is in rmlib.c. */ -/* The library contains all the functions that operate on the reflective */ -/* memory. */ -/* */ -/* NB! */ -/* */ -/* DOLPHIN'S SCI REFLECTIVE MEMORY FILES ARE UNDER DEVELOPMENT AND MAY CHANGE. */ -/* PLEASE CONTACT DOLPHIN FOR FURTHER INFORMATION. */ -/* */ -/* */ -/********************************************************************************/ - -#include "sisci_error.h" -#include "sisci_api.h" -#include "sisci_demolib.h" -#include "sisci_types.h" - -unsigned int seqerr, syncseqerr; - -#ifndef _RMLIB_H -#define _RMLIB_H - - -#if defined(_REENTRANT) - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_MT_ ## name - -#else - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_ST_ ## name - -#endif - -#ifdef __sparc -#define CACHE_SIZE 2097152 -#else -#define CACHE_SIZE 8192 -#endif - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define REFLECT_ERRCHECK 0x2 - -struct ReflectiveMemorySpace { - unsigned int localAdapterNo; - unsigned int localNodeId; - unsigned int remoteNodeId; - sci_desc_t sd; - sci_desc_t syncsd; - sci_map_t localMap; - sci_map_t remoteMap; - unsigned int localSegmentId; - unsigned int remoteSegmentId; - unsigned int syncSegmentId; - unsigned int sync_rSegmentId; - unsigned int segmentSize; - unsigned int *localMapAddr; - volatile unsigned int *remoteMapAddr; - sci_local_segment_t localSegment; - sci_remote_segment_t remoteSegment; - sci_local_segment_t syncSegment; - sci_remote_segment_t sync_rSegment; - sci_map_t syncMap; - sci_map_t sync_rMap; - sci_sequence_t syncsequence; - sci_sequence_t sequence; - unsigned int protection; - unsigned int retry_value; - sci_sequence_status_t sequenceStatus, syncsequenceStatus; - volatile unsigned int *syncMapAddr; - volatile unsigned int *sync_rMapAddr; -}; - -/*********************************************************************************/ -/* P R I N T R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectPrintParameters _RMLIB_EXPAND_NAME(ReflectPrintParameters) -void ReflectPrintParameters(FILE *stream, struct ReflectiveMemorySpace RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A S E T U P */ -/* */ -/*********************************************************************************/ -#define ReflectDmaSetup _RMLIB_EXPAND_NAME(ReflectDmaSetup) -sci_error_t ReflectDmaSetup(struct ReflectiveMemorySpace RM_space, sci_dma_queue_t *dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R E M O V E */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRemove _RMLIB_EXPAND_NAME(ReflectDmaRemove) -sci_error_t ReflectDmaRemove(sci_dma_queue_t dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R U N */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRun _RMLIB_EXPAND_NAME(ReflectDmaRun) -sci_error_t ReflectDmaRun(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - sci_dma_queue_t dmaQueue); -/*********************************************************************************/ -/* C L O S E R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectClose _RMLIB_EXPAND_NAME(ReflectClose) -sci_error_t ReflectClose(struct ReflectiveMemorySpace RM_space, unsigned int segment_no); - -/*********************************************************************************/ -/* O P E N R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectOpen _RMLIB_EXPAND_NAME(ReflectOpen) -sci_error_t ReflectOpen(struct ReflectiveMemorySpace *RM_space, - unsigned int size, - unsigned int segment_no, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int protection, - unsigned int retry_value); - -/*********************************************************************************/ -/* R E F L E C T G E T A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectGetAccess _RMLIB_EXPAND_NAME(ReflectGetAccess) -sci_error_t ReflectGetAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T R E L E A S E A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectReleaseAccess _RMLIB_EXPAND_NAME(ReflectReleaseAccess) -sci_error_t ReflectReleaseAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A */ -/* */ -/*********************************************************************************/ -#define ReflectDma _RMLIB_EXPAND_NAME(ReflectDma) -sci_error_t ReflectDma(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset); - -/*********************************************************************************/ -/* R E F L E C T M E M C O P Y */ -/* */ -/*********************************************************************************/ -#define ReflectMemCopy _RMLIB_EXPAND_NAME(ReflectMemCopy) -sci_error_t ReflectMemCopy(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - unsigned int flags); - -/*********************************************************************************/ -/* R E F L E C T S E T */ -/* */ -/*********************************************************************************/ -#define ReflectSet _RMLIB_EXPAND_NAME(ReflectSet) -sci_error_t ReflectSet(struct ReflectiveMemorySpace RM_space, - unsigned int value, - unsigned int size, - unsigned int offset, - unsigned int flags - ); - -/*********************************************************************************/ -/* R E F L E C T P R I N T */ -/* */ -/*********************************************************************************/ -#define ReflectPrint _RMLIB_EXPAND_NAME(ReflectPrint) -sci_error_t ReflectPrint(FILE *stream, - struct ReflectiveMemorySpace RM_space, - unsigned int size, - unsigned int offset - ); - - -#endif diff --git a/ndb/src/external/LINUX.x86/sci/include/sci_errno.h b/ndb/src/external/LINUX.x86/sci/include/sci_errno.h deleted file mode 100644 index 03f3256a86f..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sci_errno.h +++ /dev/null @@ -1,216 +0,0 @@ -/* $Id: sci_errno.h,v 1.1 2002/12/13 12:17:20 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - - -#ifndef _SCI_ERRNO_H_ -#define _SCI_ERRNO_H_ - - -/* - * SCI Error return values always have 30 bit set - * Remote errors should have bit 0 set - */ -#define SCI_ERR_MASK 0x40000000 -#define ESCI_REMOTE_MASK 0x01000000 - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) -#define _SCI_ERROR(x) ((x) | SCI_ERR_MASK) -#define _SCI_REMOTE_ERROR(x) ( _SCI_ERROR(x) | ESCI_REMOTE_MASK ) - -/* - * Error codes - */ -typedef enum { - ESCI_OK = 0x000, - ESCI_STILL_EXPORTED = _SCI_ERROR(0x800), - - ESCI_BUS_ERR = _SCI_ERROR(0x900), - ESCI_PEND_SCIERR = _SCI_ERROR(0x901), - ESCI_SCI_ERR = _SCI_ERROR(0x902), - - /* - * Specific SCI error responses: - */ - ESCI_SCI_ERR_DATA = _SCI_ERROR(0x9021), - ESCI_SCI_ERR_TYPE = _SCI_ERROR(0x9022), - ESCI_SCI_ERR_ADDR = _SCI_ERROR(0x9023), - - ESCI_LINK_TIMEOUT = _SCI_ERROR(0x903), - ESCI_EXDEV_TIMEOUT = _SCI_ERROR(0x904), - ESCI_REMOTE_ERR = _SCI_ERROR(0x905), - ESCI_MBX_BUSY = _SCI_ERROR(0x906), - ESCI_DMAERR = _SCI_ERROR(0x907), - ESCI_DMA_DISABLED = _SCI_ERROR(0x908), - ESCI_SW_MBX_SEND_FAILED = _SCI_ERROR(0x909), - ESCI_HW_MBX_SEND_FAILED = _SCI_ERROR(0x90A), - ESCI_HAS_NO_SESSION = _SCI_ERROR(0xA00), - ESCI_CONNREFUSED_SESSION = _SCI_ERROR(0xA01), - ESCI_SESSION_NOT_ESTABLISHED = _SCI_ERROR(0xA11), - ESCI_REMOTE_NO_VALID_SESSION = _SCI_ERROR(0xA02), - ESCI_SESSION_DISABLED = _SCI_ERROR(0xA03), - ESCI_NODE_CLOSED = _SCI_ERROR(0xA04), - ESCI_NODE_DISABLED = _SCI_ERROR(0xA05), - - ESCI_LOCAL_MASTER_ERR = _SCI_ERROR(0xA06), - ESCI_REMOTE_MASTER_ERR = _SCI_REMOTE_ERROR(0xA06), - - ESCI_ILLEGAL_CMD_RECEIVED = _SCI_ERROR(0xA08), - ESCI_ILLEGAL_CMD_SENT = _SCI_ERROR(0xA09), - - /* used above: ESCI_SESSION_NOT_ESTABLISHED = _SCI_ERROR(0xA11), */ - - /* - * Remote error codes - */ - ESCI_CONNREFUSED = _SCI_ERROR(0xB00), - ESCI_NODE_NOT_RESPONDING = _SCI_ERROR(0xB01), - ESCI_ISCONN = _SCI_ERROR(0xB02), - ESCI_HOSTUNREACH = _SCI_ERROR(0xB03), - ESCI_NO_SUCH_USER_ID = _SCI_ERROR(0xB04), - ESCI_REMOTE_NO_SUCH_USER_ID = _SCI_REMOTE_ERROR(0xB04), /* ESCI_NO_SUCH_USER_ID */ - ESCI_NO_SUCH_KEY = _SCI_ERROR(0xB04), /* ESCI_NO_SUCH_USER_ID */ - ESCI_REMOTE_NO_SUCH_KEY = _SCI_REMOTE_ERROR(0xB04), /* ESCI_REMOTE_NO_SUCH_USER_ID */ - ESCI_NODE_ERR = _SCI_ERROR(0xB06), - ESCI_REMOTE_NODE_ERR = _SCI_REMOTE_ERROR(0xB06), /* ESCI_NODE_ERR */ - ESCI_NOSPC = _SCI_ERROR(0xB08), - ESCI_REMOTE_NOSPC = _SCI_REMOTE_ERROR(0xB08), /* ESCI_NOSPC */ - ESCI_NODMASPC = _SCI_ERROR(0xB0A), - ESCI_REMOTE_NODMASPC = _SCI_REMOTE_ERROR(0xB0A), /* ESCI_NODMASPC */ - ESCI_NOTMAP = _SCI_ERROR(0xC00), - ESCI_ISMAP = _SCI_ERROR(0xC01), - ESCI_NOT_INITIALIZED = _SCI_ERROR(0xD00), - ESCI_REMOTE_NOT_INITIALIZED = _SCI_REMOTE_ERROR(ESCI_NOT_INITIALIZED), - /* - * ??? - */ - ESCI_PARAM_ERR = _SCI_ERROR(0xD01), - ESCI_NO_FREE_VC = _SCI_ERROR(0xD02), - ESCI_REMOTE_NO_FREE_VC = _SCI_REMOTE_ERROR(0xD02), /* ESCI_NO_FREE_VC */ - - /* - * Adapter state related error codes: - */ - ESCI_SUSPENDED = _SCI_ERROR(0xD03), - ESCI_NOT_SUSPENDED = _SCI_ERROR(0xD04), - ESCI_NOT_READY = _SCI_ERROR(0xD05), - ESCI_NOT_CONFIGURED = _SCI_ERROR(0xD06), - ESCI_INVALID_ADAPTERID = _SCI_ERROR(0xD07), /* if an adapter-id is out of range */ - ESCI_NONEXIST_ADAPTERID = _SCI_ERROR(0xD08), /* if adapter-id is valid but no adapter matches */ - ESCI_ADAPTERID_INUSE = _SCI_ERROR(0xD09), - - ESCI_INVALID_INSTANCE = _SCI_ERROR(0xD0A), - ESCI_NONEXIST_INSTANCE = _SCI_ERROR(0xD0B), - - ESCI_ADAPTER_INIT_FAILURE = _SCI_ERROR(0xD0C), - - ESCI_PAUSED = _SCI_ERROR(0xD0D), - ESCI_NOT_PAUSED = _SCI_ERROR(0xD0E), - ESCI_ADAPTER_NEED_RESET = _SCI_ERROR(0xD0F), - - ESCI_NONEXIST_SERIAL_NUMBER = _SCI_ERROR(0xD10), - ESCI_NOT_AVAILABLE = _SCI_ERROR(0xD11), - - ESCI_EACCESS = _SCI_ERROR(0xD12), - - /* - * Local error codes - */ - ESCI_NO_LOCAL_ACCESS = _SCI_ERROR(0xE00), - ESCI_LRESOURCE_BUSY = _SCI_ERROR(0xE01), - ESCI_LRESOURCE_EXIST = _SCI_ERROR(0xE02), - ESCI_NO_LRESOURCE = _SCI_ERROR(0xE03), - ESCI_NOTCONN = _SCI_ERROR(0xE04), - ESCI_LOCAL_ERR = _SCI_ERROR(0xE05), - ESCI_NOVAL_NODEID = _SCI_ERROR(0xE06), - ESCI_NOT_SUPPORTED = _SCI_ERROR(0xE07), - ESCI_TIMEOUT = _SCI_ERROR(0xE08), - ESCI_NO_LOCAL_LC_ACCESS = _SCI_ERROR(0xE0A), - ESCI_INVALID_ATT = _SCI_ERROR(0xE0B), - ESCI_BAD_CHECKSUM = _SCI_ERROR(0xE0C), - ESCI_INTERRUPT_FLAG_DISABLED = _SCI_ERROR(0xE0D), - ESCI_COND_INT_RACE_PROBLEM = _SCI_ERROR(0xE0E), - ESCI_OVERFLOW = _SCI_ERROR(0xE0F), - ESCI_BLINK_PARITY_ERROR = _SCI_ERROR(0xE10), - ESCI_FIRMWARE_VERSION_MISMATCH = _SCI_ERROR(0xE11), - - /* - * Link error codes - */ - ESCI_NO_LINK_ACCESS = _SCI_ERROR(0xF00), - ESCI_NO_REMOTE_LINK_ACCESS = _SCI_REMOTE_ERROR(0xF00), /* ESCI_NO_LINK_ACCESS */ - - ESCI_NO_SUCH_NODE = _SCI_ERROR(0xF02), - ESCI_USR_ACCESS_DISABLED = _SCI_ERROR(0xF03), - ESCI_HW_AVOID_DEADLOCK = _SCI_ERROR(0xF04), - ESCI_POTENTIAL_ERROR = _SCI_ERROR(0xF05), - - ESCI_FENCED = _SCI_ERROR(0xF06), - ESCI_SWITCH_HW_FAILURE = _SCI_ERROR(0xF07), - ESCI_SWITCH_WRONG_BLINK_ID = _SCI_ERROR(0xF08), - ESCI_SWITCH_WRONG_PORT_NUMB = _SCI_ERROR(0xF09), - ESCI_SWITCH_WRONG_INIT_TYPE = _SCI_ERROR(0xF0A), /* It is determined that the swith initialization - * do not match the local adapter initialization - */ - ESCI_SWITCH_WRONG_SWITCH_NUMB = _SCI_ERROR(0xF0B), /* It is determined that we are operationg on the - * wrong switch port - */ - ESCI_SWITCH_NOT_CONNECTED = _SCI_ERROR(0xF0C), - ESCI_SWITCH_NOT_RECOGNIZED = _SCI_ERROR(0xF0D), - ESCI_SWITCH_INIT_IN_PROGRESS = _SCI_ERROR(0xF0E), /* Switch TINI initialization in progress */ - - - ESCI_NO_BACKBONE_LINK_ACCESS = _SCI_ERROR(0xF20), - ESCI_BACKBONE_FENCED = _SCI_ERROR(0xF21), - ESCI_NO_BACKBONE_ACCESS = _SCI_ERROR(0xF22), - ESCI_BACKBONE_CABLE_PROBLEM = _SCI_ERROR(0xF23), - ESCI_BACKBONE_BLINK_PROBLEM = _SCI_ERROR(0xF24), - ESCI_BACKBONE_HWINIT_PROBLEM = _SCI_ERROR(0xF25), - ESCI_BACKBONE_ID_PROBLEM = _SCI_ERROR(0xF26), - ESCI_BACKBONE_STATE_PROBLEM = _SCI_ERROR(0xF27), - ESCI_BACKBONE_REQ_LINK_PROBLEM = _SCI_ERROR(0xF28), - ESCI_BACKBONE_UNFENCING = _SCI_ERROR(0xF29), /* Unfencing in progress */ - - /* - * added for pci port - */ - ESCI_AGAIN = _SCI_ERROR(0xF15), - ESCI_ORANGE = _SCI_ERROR(0xF16), /* Out of range */ - ESCI_NOSYS = _SCI_ERROR(0xF17), /* Used instead of ENOSYS. Means function not implemented */ - ESCI_REMOTE_NOSYS = _SCI_REMOTE_ERROR(ESCI_NOSYS), - ESCI_INTR = _SCI_ERROR(0xF18), /* Used instead of EINTR from sys/errno.h */ - ESCI_IO = _SCI_ERROR(0xF19), /* Used instead of EIO from sys/errno.h */ - ESCI_FAULT = _SCI_ERROR(0xF1A), /* Used instead of EFAULT from sys/errno.h */ - ESCI_BUSY = _SCI_ERROR(0xF1B), /* Used instead of EBUST from sys/errno.h */ - ESCI_INVAL = _SCI_ERROR(0xF1C), /* Used instead of EINVAL from sys/errno.h */ - ESCI_NXIO = _SCI_ERROR(0xF1D), /* Used instead of ENXIO from sys/errno.h */ - ESCI_EXIST = _SCI_ERROR(0xF1E) /* Used instead of EEXIST from sys/errno.h */ - -} scierror_t; - -#endif /* _SCI_ERRNO_H_ */ - - - - diff --git a/ndb/src/external/LINUX.x86/sci/include/sci_types.h b/ndb/src/external/LINUX.x86/sci/include/sci_types.h deleted file mode 100644 index 740b3a45cfd..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sci_types.h +++ /dev/null @@ -1,300 +0,0 @@ -/* $Id: sci_types.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - -#ifndef _SCI_TYPES_H_ -#define _SCI_TYPES_H_ - -/* - * Remains for the time being for backward compatibility .... - */ - -/* #define UNIQUE(type) struct { type x; } * */ -#ifndef UNIQUE -#define UNIQUE(type) type -#endif -#include "os/inttypes.h" - -#if defined(WIN32) -#if defined(_KERNEL) -#include -#else -#include -#endif /* _KERNEL */ -#else -#if defined(Linux) -#if defined(__KERNEL__) -#include -#else -#include -#endif -#else -#include -#endif -#ifdef SUNOS5 -#include -#include -#endif -#ifdef OS_IS_TRU64 -#include -#endif -#ifdef OS_IS_HP_UX11 -#if defined(_KERNEL) -#include <../wsio/wsio.h> -#else -#include -#endif -#endif -#endif - -/* See comments about "UNCONFIGURED_ADAPTERS" in config.h */ -#define UNCONFIGURED_ADAPTERS 100 - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef IN -#define IN -#endif - -#ifndef NOT -#define NOT ! -#endif - -/* - * -------------------------------------------------------------------------------------- - * Basic types of various sizes. - * -------------------------------------------------------------------------------------- - */ - -typedef signed32 scibool; -#ifndef OS_IS_VXWORKS -typedef signed32 BOOL; -#else -/* VXWORKS has already defined BOOL */ -#endif -typedef unsigned32 node_t; /* This is the logical nodeid */ -typedef unsigned32 sciNodeId_t; /* This is the physical 16 bit SCI nodeid */ - -/* - * -------------------------------------------------------------------------------------- - * Various register types. - * -------------------------------------------------------------------------------------- - */ -typedef volatile unsigned32 register32; - - -/* -Temporary for Windows NT, until we use only the above types. -*/ - -#ifdef WIN32 - -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned long u_long; -typedef unsigned int u_int; -typedef char * caddr_t; - -typedef long off_t; -typedef unsigned int size_t; - -#endif -#ifdef OS_IS_VXWORKS -#include -#endif - -/* - * -------------------------------------------------------------------------------------- - * Various address types. - * - * We are using a struct * instead of unsigned long (int) inorder to enforce strong - * type checking - * - * -------------------------------------------------------------------------------------- - */ -typedef UNIQUE(void *) vkaddr_t; /* Virtual kernel address */ -typedef UNIQUE(uptr_t) vuaddr_t; /* Virtual user address */ - -typedef UNIQUE(unsigned32) remaddr_t; /* Remote IO address (physical address on PCs) */ -typedef UNIQUE(unsigned32) sciofs_lo_t; /* Lower 32 bits of an SCI offset. */ -typedef UNIQUE(unsigned32) sciofs_hi_t; /* The upper 16 bits of an SCI offset. */ - -typedef UNIQUE(unsigned32) ioaddr_t; /* Local IO address (physical address on PCs) */ -typedef unsigned32 u_ioaddr_t; -typedef unsigned32 iooffset_t; -typedef unsigned32 iosize_t; - -typedef uptr_t vkoffset_t; -typedef uptr_t u_vkaddr_t; -typedef uptr_t u_vuaddr_t; -typedef unsigned32 u_sciofs_lo_t; -typedef unsigned32 u_sciofs_hi_t; -typedef unsigned32 u_remaddr_t; -typedef unsigned32 attOffset_t; /* Address displacement from start of ATT entry */ - -typedef unsigned32 adapterNo_t; - -typedef enum { - NO_NODE = 0, - AD_MEM_NODE = 1, - AD_ALT_NODE = 2, - AD_MBX_NODE = 3, - AD_LC_NODE = 4, - AD_LC_PORT_0 = 5, - AD_LC_PORT_1 = 6, - AD_LC_PORT_2 = 7, - PHYS_NODE = 8 -} node_type_t; - - -/* - * Currently we don't support more than 32 bit sizes. - */ -#define SIZEOF(x) ((unsigned32)sizeof(x)) - -#if defined(_KERNEL) - -/* - * -------------------------------------------------------------------------------------- - * Some small macros intended to ease the transition to more strongly typed address - * types. The intention is that they in the long run shall be removed ... - * -------------------------------------------------------------------------------------- - */ -#define P2SIZE_T(x) ((size_t)((uptr_t)(x))) /* Pointer to size_t */ -#define P2U32(x) ((unsigned32)((uptr_t)(x))) /* Pointer to Unsigned 32-bit int */ -#ifdef WIN32 -#define PHADDR(x) ((ioaddr_t)(x)) -#define HASV(x) (x) -#endif -#if 0 -static vkaddr_t VKPTR (void * ptr) { return (vkaddr_t)ptr; } -static vkaddr_t VKADDR(volatile void * ptr) { return (vkaddr_t)ptr; } -#else -#define VKPTR(ptr) (vkaddr_t)ptr -#define VKADDR(ptr) (vkaddr_t)ptr -#endif - -#ifdef KLOG -#define KLOG_LOG(n,m,v) ts_log((n),(m),(v)) -#else -#define KLOG_LOG(n,m,v) -#endif /* KLOG */ - - -/* - * -------------------------------------------------------------------------------------- - * - * M E M A R E A T - * - * Memory area descriptor. - * - * paddr -- Physical address (aligned) of memory area - * ual_vaddr -- (Kernel )Virtual address of the unaligned memory area - * vaddr -- (Kernel) Virtual address of memory area - * rsize -- Real (Physical) Size of memory area - * msize -- Mapped (Virtual) Size of memory area (Size of area mapped - * into virtual) memory - * - * -------------------------------------- - * | | <----- msize ----->| | - * |<------|------- rsize ------|------>| - * -------------------------------------- - * /|\ /|\ - * | | - * ual_vaddr vaddr/paddr - * - * -------------------------------------------------------------------------------------- - */ -struct _memarea_ { - ioaddr_t ioaddr; - vkaddr_t vaddr; - vkaddr_t ual_vaddr; - size_t rsize; - size_t msize; - char *id; - unsigned32 cookie; - - -#ifdef SUNOS5 -#ifdef _USE_NEW_SOLARIS_DDI_INTERFACE - ddi_acc_handle_t mem_handle; - ddi_dma_handle_t dma_handle; -#else - ddi_dma_handle_t handle; -#endif -#endif -#ifdef OS_IS_TRU64 - dma_handle_t dma_handle; -#endif - -#if OS_IS_LINUX - unsigned long ph_base_addr; -#endif - -#ifdef OS_IS_HP_UX11 - struct isc_table_type * isc; - wsio_shmem_attr_t type; -#endif -}; - -typedef struct _memarea_ memarea_t; - -#ifdef SCI_MALLOC_DEBUG -struct _maddr_ { - char *id; - size_t size; - struct _maddr_ *next; - struct _maddr_ **prev; - unsigned32 cookie; -}; - -typedef struct _maddr_ maddr_t; - -#define MALLOC_COOKIE 0xc3c3c3c3 - -#else - -typedef struct { void *p; } *maddr_t; - -#endif /* SCI_MALLOC_DEBUG */ - - -typedef struct { - scibool disabled; - unsigned32 disable_cnt; -} disable_info_t; - -#endif /* _KERNEL */ - -#endif /* _SCI_TYPES_H_ */ diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_api.h b/ndb/src/external/LINUX.x86/sci/include/sisci_api.h deleted file mode 100644 index 38fdf54125f..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_api.h +++ /dev/null @@ -1,2170 +0,0 @@ -/* $Id: sisci_api.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ -/******************************************************************************* - * * - * Copyright (C) 1993 - 2001 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *******************************************************************************/ - -#ifndef _SISCI_API_H -#define _SISCI_API_H - -#include "sisci_types.h" -#include "sisci_error.h" - - -#ifdef WIN32 -#ifdef API_DLL -#define DLL __declspec(dllexport) -#elif CLIENT_DLL -#define DLL __declspec(dllimport) -#endif -#endif /* WIN32 */ - - -#ifndef DLL -#define DLL -#endif - -#if defined(_REENTRANT) -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_MT_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_MT_ ## name -#else -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_ST_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_ST_ ## name -#endif -#define _SISCI_EXPANDE_CONSTANT_NAME(name) _SISCI_PUBLIC_CONST_ ## name - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCI_FLAG_FIXED_INTNO _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_INTNO) -extern const unsigned int SCI_FLAG_FIXED_INTNO; - -#define SCI_FLAG_SHARED_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_INT) -extern const unsigned int SCI_FLAG_SHARED_INT; - -#define SCI_FLAG_FIXED_MAP_ADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_MAP_ADDR) -extern const unsigned int SCI_FLAG_FIXED_MAP_ADDR; - -#define SCI_FLAG_READONLY_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READONLY_MAP) -extern const unsigned int SCI_FLAG_READONLY_MAP; - -#define SCI_FLAG_USE_CALLBACK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_USE_CALLBACK) -extern const unsigned int SCI_FLAG_USE_CALLBACK; - -#define SCI_FLAG_BLOCK_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_BLOCK_READ) -extern const unsigned int SCI_FLAG_BLOCK_READ; - -#define SCI_FLAG_THREAD_SAFE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_THREAD_SAFE) -extern const unsigned int SCI_FLAG_THREAD_SAFE; - -#define SCI_FLAG_ASYNCHRONOUS_CONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ASYNCHRONOUS_CONNECT) -extern const unsigned int SCI_FLAG_ASYNCHRONOUS_CONNECT; - -#define SCI_FLAG_EMPTY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_EMPTY) -extern const unsigned int SCI_FLAG_EMPTY; - -#define SCI_FLAG_PRIVATE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_PRIVATE) -extern const unsigned int SCI_FLAG_PRIVATE; - -#define SCI_FLAG_FORCE_DISCONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FORCE_DISCONNECT) -extern const unsigned int SCI_FLAG_FORCE_DISCONNECT; - -#define SCI_FLAG_NOTIFY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NOTIFY) -extern const unsigned int SCI_FLAG_NOTIFY; - -#define SCI_FLAG_DMA_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_READ) -extern const unsigned int SCI_FLAG_DMA_READ; - -#define SCI_FLAG_DMA_POST _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_POST) -extern const unsigned int SCI_FLAG_DMA_POST; - -#define SCI_FLAG_DMA_WAIT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_WAIT) -extern const unsigned int SCI_FLAG_DMA_WAIT; - -#define SCI_FLAG_DMA_RESET _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_RESET) -extern const unsigned int SCI_FLAG_DMA_RESET; - -#define SCI_FLAG_NO_FLUSH _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_FLUSH) -extern const unsigned int SCI_FLAG_NO_FLUSH; - -#define SCI_FLAG_NO_STORE_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_STORE_BARRIER) -extern const unsigned int SCI_FLAG_NO_STORE_BARRIER; - -#define SCI_FLAG_FAST_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FAST_BARRIER) -extern const unsigned int SCI_FLAG_FAST_BARRIER; - -#define SCI_FLAG_ERROR_CHECK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ERROR_CHECK) -extern const unsigned int SCI_FLAG_ERROR_CHECK; - -#define SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) -extern const unsigned int SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY; - -/* the FLUSH_CPU_BUFFERS_ONLY flag is for backwards compabillity only and should never be used */ -#define FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) - -#define SCI_FLAG_LOCK_OPERATION _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_LOCK_OPERATION) -extern const unsigned int SCI_FLAG_LOCK_OPERATION; - -#define SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP; - -#define SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP; - -#define SCI_FLAG_IO_MAP_IOSPACE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_IO_MAP_IOSPACE) -extern const unsigned int SCI_FLAG_IO_MAP_IOSPACE; - -#define SCI_FLAG_DMOVE_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMOVE_MAP) -extern const unsigned int SCI_FLAG_DMOVE_MAP; - -#define SCI_FLAG_WRITES_DISABLE_GATHER_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_WRITES_DISABLE_GATHER_MAP) -extern const unsigned int SCI_FLAG_WRITES_DISABLE_GATHER_MAP; - -#define SCI_FLAG_DISABLE_128_BYTES_PACKETS _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DISABLE_128_BYTES_PACKETS) -extern const unsigned int SCI_FLAG_DISABLE_128_BYTES_PACKETS; - -#define SCI_FLAG_SHARED_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_MAP) -extern const unsigned int SCI_FLAG_SHARED_MAP; - -#define SCI_FLAG_DMA_SOURCE_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_SOURCE_ONLY) -extern const unsigned int SCI_FLAG_DMA_SOURCE_ONLY; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT_MAP; - -#define SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP; - -#define SCI_FLAG_NO_MEMORY_LOOPBACK_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_MEMORY_LOOPBACK_MAP) -extern const unsigned int SCI_FLAG_NO_MEMORY_LOOPBACK_MAP; - -#if defined(OS_IS_LYNXOS) || defined(OS_IS_VXWORKS) -#define SCI_FLAG_WRITE_BACK_CACHE_MAP _SISCI_EXPANDE_CONSTANT_NAME(WRITE_BACK_CACHE_MAP) -extern const unsigned int SCI_FLAG_WRITE_BACK_CACHE_MAP; -#endif - -#define SCI_FLAG_DMA_PHDMA _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_PHDMA) -extern const unsigned int SCI_FLAG_DMA_PHDMA; - -/*********************************************************************************/ -/* GENERAL VALUES */ -/*********************************************************************************/ -#define SCI_LOCAL_HOST _SISCI_EXPANDE_CONSTANT_NAME(SCI_LOCAL_HOST) -extern const unsigned int SCI_LOCAL_HOST; - -#define SCI_INFINITE_TIMEOUT _SISCI_EXPANDE_CONSTANT_NAME(SCI_INFINITE_TIMEOUT) -extern const unsigned int SCI_INFINITE_TIMEOUT; - -/*********************************************************************************/ -/* GENERAL ERROR CODES */ -/* */ -/* SCI_ERR_ILLEGAL_FLAG - Illegal flag value. */ -/* SCI_ERR_FLAG_NOT_IMPLEMENTED - Flag legal but flag feature not implemented. */ -/* SCI_ERR_NOT_IMPLEMENTED - Function not implemented. */ -/* SCI_ERR_SYSTEM - A system error. Check errno. */ -/* SCI_ERR_NOSPC - Unable to allocate OS resources. */ -/* SCI_ERR_API_NOSPC - Unable to allocate API resources. */ -/* SCI_ERR_HW_NOSPC - Unable to allocate HW resources (Hardware) */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "ADAPTER" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_ADAPTERNO - Adapter number is legal but does not exist. */ -/* SCI_ERR_ILLEGAL_ADAPTERNO - Illegal local adapter number (i.e. outside */ -/* legal range). */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "NODEID" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_NODEID - The remote adapter identified by nodeId does */ -/* not respond, but the intermediate link(s) */ -/* seem(s) to be operational. */ -/* SCI_ERR_ILLEGAL_NODEID - Illegal NodeId. */ -/* */ -/*********************************************************************************/ - - - -/********************************************************************************* - * * - * S C I I N I T I A L I Z E * - * * - * This function initializes the SISCI library. * - * The function must be called before SCIOpen(). * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCIInitialize _SISCI_EXPANDE_FUNCTION_NAME(SCIInitialize) -DLL void SCIInitialize(unsigned int flags, - sci_error_t *error); -#if 0 -unsigned int __Internal_SISCI_version_var; -#endif - -/********************************************************************************* - * * - * S C I T E R M I N A T E * - * * - * This function terminates the SISCI library. * - * The function must be called after SCIClose(). * - * * - * * - *********************************************************************************/ -#define SCITerminate _SISCI_EXPANDE_FUNCTION_NAME(SCITerminate) -DLL void SCITerminate(void); - -/********************************************************************************* - * * - * S C I O P E N * - * * - * * - * Opens a SCI virtual device. * - * Caller must supply a pointer to a variable of type sci_desc_t to be * - * initialized. * - * * - * Flags * - * SCI_FLAG_THREAD_SAFE - Operations on resources associated with this * - * descriptor will be performed in a multithread-safe * - * manner. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INCONSISTENT_VERSIONS - Inconsistency between the SISCI library * - * and the SISCI driver versions. * - * * - * * - *********************************************************************************/ -#define SCIOpen _SISCI_EXPANDE_FUNCTION_NAME(SCIOpen) -DLL void SCIOpen(sci_desc_t *sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C L O S E * - * * - * This function closes an open SCI virtual device. * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - All resources are not deallocated. * - * * - *********************************************************************************/ -#define SCIClose _SISCI_EXPANDE_FUNCTION_NAME(SCIClose) -DLL void SCIClose(sci_desc_t sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S E G M E N T * - * * - * Connects to a remote shared memory segment located at with the * - * identifier . * - * The user may then call SCIMapRemoteSegment() to map shared memory * - * into user space. * - * * - * Flags * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_ASYNCHRONOUS_CONNECT * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_SEGMENT - Could not find the remote segment with the * - * given segmentId. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIConnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSegment) -DLL void SCIConnectSegment(sci_desc_t sd, - sci_remote_segment_t *segment, - unsigned int nodeId, - unsigned int segmentId, - unsigned int localAdapterNo, - sci_cb_remote_segment_t callback, - void *callbackArg, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T S E G M E N T * - * * - * Disconnects from the give mapped shared memory segment * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The segment is currently mapped or in use. * - * * - *********************************************************************************/ -#define SCIDisconnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectSegment) -DLL void SCIDisconnectSegment(sci_remote_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T R E M O T E S E G M E N T S I Z E * - * * - *********************************************************************************/ -#define SCIGetRemoteSegmentSize _SISCI_EXPANDE_FUNCTION_NAME(SCIGetRemoteSegmentSize) -DLL unsigned int SCIGetRemoteSegmentSize(sci_remote_segment_t segment); - - - -/********************************************************************************* - * * - * S C I W A I T F O R R E M O T E S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du * - * to a SCIDisconnectSegment() on the same * - * handle. The handle is invalid when this * - * error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForRemoteSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForRemoteSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForRemoteSegmentEvent( - sci_remote_segment_t segment, - sci_error_t *status, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P R E M O T E S E G M E N T * - * * - * This function is used to include a shared memory segment in the virtual * - * address space of the application. * - * * - * Flags: * - * * - * SCI_FLAG_SHARED_MAP - The low level physical map may be shared by * - * other applications. * - * * - * SCI_FLAG_FIXED_MAP_ADDR - Map at the suggested virtual address * - * SCI_FLAG_READONLY_MAP - The segment is mapped in read-only mode * - * SCI_FLAG_LOCK_OPERATION - Enable Lock operations (fetch and add) * - * SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP * - * - Enable aggressive prefetch with speculative * - * hold. * - * * - * SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP * - * - The PSB66 will prefetch 64 bytes. As soon * - * as the PCI read retry has been accepted, * - * the stream will change state to FREE, even * - * if less than 64 bytes were actually read. * - * * - * SCI_FLAG_IO_MAP_IOSPACE - Enable No Prefetch, no speculative hold. * - * * - * SCI_FLAG_DMOVE_MAP - Enable DMOVE packet type. The stream will be * - * set into FREE state immediately. * - * * - * SCI_FLAG_WRITES_DISABLE_GATHER_MAP * - * - Disable use of gather. * - * * - * SCI_FLAG_DISABLE_128_BYTES_PACKETS * - * - Disable use of 128-Byte packets * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an atomic "fetch-and-add-one" operation on * - * remote memory, but in addition an interrupt * - * will be generated if the target memory * - * location contained a "null value" before the * - * add operation was carried out. * - * The conditional interrupt flag must also be * - * specified in the SCIRegisterInterruptFlag() * - * function. * - * * - * SCI_FLAG_UNCONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an interrupt for the remote adapter * - * "in addition to" updating the corresponding * - * remote memory location with the data being * - * written. * - * The unconditional interrupt flag must also * - * be specified in the * - * SCIRegisterInterruptFlag() function. * - * * - * SCI_FLAG_WRITE_BACK_CACHE_MAP * - * - Enable cacheing of the mapped region. * - * Writes through this map will be written to a * - * write back cache, hence no remote SCI updates* - * until the cache line is flushed. The * - * application is responsible for the cache * - * flush operation. * - * The SCImemCopy() function will handle this * - * correctly by doing cache flushes internally. * - * This feature is architechture dependent and * - * not be available on all plattforms. * - * * - * SCI_FLAG_NO_MEMORY_LOOPBACK_MAP * - * - Forces a map to a remote segment located * - * in the local machine to be mapped using * - * SCI loopback. This is useful i.e. if you * - * want to use a regular map access to be * - * serialized with lock operations. * - * The default behaviour is to access a remte * - * segment located in the local machine as a * - * local MMU operation. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapRemoteSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapRemoteSegment) -DLL volatile void *SCIMapRemoteSegment( - sci_remote_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P L O C A L S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_FIXED_MAP_ADDR * - * SCI_FLAG_READONLY_MAP * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapLocalSegment) -DLL void *SCIMapLocalSegment(sci_local_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I U N M A P S E G M E N T * - * * - * This function unmaps pages of shared memory from the callers virtual * - * address space. * - * * - * Flags * - * None. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The map is currently in use. * - * * - *********************************************************************************/ -#define SCIUnmapSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIUnmapSegment) -DLL void SCIUnmapSegment(sci_map_t map, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E S E G M E N T * - * * - * Make the specified segment available for connections via the specified * - * adapter. If successful, the segment can be accessed from remote nodes * - * via the specified adapter. * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events * - * on this segment. * - * SCI_FLAG_EMPTY - No memory will be allocated for the segment. * - * SCI_FLAG_PRIVATE - The segment will be private meaning it will never * - * be any connections to it. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SEGMENTID_USED - The segment with this segmentId is already used * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * * - *********************************************************************************/ -#define SCICreateSegment _SISCI_EXPANDE_FUNCTION_NAME(SCICreateSegment) -DLL void SCICreateSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I W A I T F O R L O C A L S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du to a * - * SCIRemoveSegment() on the same handle. * - * The handle is invalid when this error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForLocalSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForLocalSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForLocalSegmentEvent( - sci_local_segment_t segment, - unsigned int *sourcenodeId, - unsigned int *localAdapterNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P R E P A R E S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_DMA_SOURCE_ONLY - The segment will be used as a source segment * - * for DMA operations. On some system types this * - * will enable the SISCI driver to use performance * - * improving features. * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIPrepareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIPrepareSegment) -DLL void SCIPrepareSegment(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E G M E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - Unable to remove the segment. The segment is currently * - * in use. * - * * - *********************************************************************************/ -#define SCIRemoveSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSegment) -DLL void SCIRemoveSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T A V A I L A B L E * - * * - * Flags * - * None. * - * * - * * - * SCI_ERR_SEGMENT_NOT_PREPARED - The segment has not been prepared for access * - * from this adapter. * - * SCI_ERR_ILLEGAL_OPERATION - The segment is created with the * - * SCI_FLAG_PRIVATE flag specified and * - * therefore has no segmentId. * - * * - *********************************************************************************/ -#define SCISetSegmentAvailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentAvailable) -DLL void SCISetSegmentAvailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T U N A V A I L A B L E * - * * - * Flags * - * * - * SCI_FLAG_FORCE_DISCONNECT * - * SCI_FLAG_NOTIFY * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * * - *********************************************************************************/ -#define SCISetSegmentUnavailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentUnavailable) -DLL void SCISetSegmentUnavailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E M A P S E Q U E N C E * - * * - * Flags: * - * * - * SCI_FLAG_FAST_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateMapSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICreateMapSequence) -DLL void SCICreateMapSequence(sci_map_t map, - sci_sequence_t *sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E Q U E N C E * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSequence) -DLL void SCIRemoveSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T A R T S E Q U E N C E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIStartSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIStartSequence) -DLL sci_sequence_status_t SCIStartSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I C H E C K S E Q U E N CE * - * * - * Flags * - * * - * SCI_FLAG_NO_FLUSH * - * SCI_FLAG_NO_STORE_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICheckSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICheckSequence) -DLL sci_sequence_status_t SCICheckSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T O R E B A R R I E R * - * * - * Flags * - * None. * - * * - * * - * * - *********************************************************************************/ -#define SCIStoreBarrier _SISCI_EXPANDE_FUNCTION_NAME(SCIStoreBarrier) -DLL void SCIStoreBarrier(sci_sequence_t sequence, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I F L U S H R E A D B U F F E R S * - * * - *********************************************************************************/ -#define SCIFlushReadBuffers _SISCI_EXPANDE_FUNCTION_NAME(SCIFlushReadBuffers) -DLL void SCIFlushReadBuffers(sci_sequence_t sequence); - - - - -/********************************************************************************* - * * - * S C I P R O B E N O D E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIProbeNode _SISCI_EXPANDE_FUNCTION_NAME(SCIProbeNode) -DLL int SCIProbeNode(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int nodeId, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIGetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCIGetCSRRegister) -DLL unsigned int SCIGetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCISetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCISetCSRRegister) -DLL void SCISetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I G E T L O C A L C S R * - * * - * SISCI Priveleged function * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIGetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCIGetLocalCSR) -DLL unsigned int SCIGetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T L O C A L C S R * - * * - * SISCI Priveleged function - * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCISetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCISetLocalCSR) -DLL void SCISetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A T T A C H P H Y S I C A L M E M O R Y * - * * - * SISCI Priveleged function * - * * - * Description: * - * * - * This function enables usage of physical devices and memory regions where the * - * Physical PCI bus address ( and mapped CPU address ) are already known. * - * The function will register the physical memory as a SISCI segment which can * - * be connected and mapped as a regular SISCI segment. * - * * - * Requirements: * - * * - * SCICreateSegment() with flag SCI_FLAG_EMPTY must have been called in advance * - * * - * Parameter description: * - * sci_ioaddr_t ioaddress : This is the address on the PCI bus that a PCI bus * - * master has to use to write to the specified memory * - * void * address : This is the (mapped) virtual address that the * - * application has to use to access the device. * - * This means that the device has to be mapped in * - * advance bye the devices own driver. * - * If the device is not to be accessed by the local * - * CPU, the address pointer shold be set to NULL * - * Flags * - * * - * None * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIAttachPhysicalMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachPhysicalMemory) -DLL void SCIAttachPhysicalMemory(sci_ioaddr_t ioaddress, - void *address, - unsigned int busNo, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I Q U E R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_QUERY - Unrecognized command. * - * * - *********************************************************************************/ -#define SCIQuery _SISCI_EXPANDE_FUNCTION_NAME(SCIQuery) -DLL void SCIQuery(unsigned int command, - void *data, - unsigned int flags, - sci_error_t *error); - - -/* MAJOR QUERY COMMANDS */ - -/* This command requires a pointer to a structure of type */ -/* "sci_query_string". The string will be filled in by the query. */ -#define SCI_Q_VENDORID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_VENDORID) -extern const unsigned int SCI_Q_VENDORID; - - -/* Same as for SCI_VENDOR_ID */ -#define SCI_Q_API _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_API) -extern const unsigned int SCI_Q_API; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_adapter" struct. */ -#define SCI_Q_ADAPTER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER) -extern const unsigned int SCI_Q_ADAPTER; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_system" struct. */ -#define SCI_Q_SYSTEM _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM) -extern const unsigned int SCI_Q_SYSTEM; - -#define SCI_Q_LOCAL_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT) -extern const unsigned int SCI_Q_LOCAL_SEGMENT; - -#define SCI_Q_REMOTE_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT) -extern const unsigned int SCI_Q_REMOTE_SEGMENT; - -#define SCI_Q_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP) -extern const unsigned int SCI_Q_MAP; - -typedef struct { - char *str; /* Pointer to a string of minimum "length" characters */ - unsigned int length; -} sci_query_string_t; - - -typedef struct { - unsigned int localAdapterNo; /* The adapter no. that the query concern. */ - unsigned int portNo; /* The SCI Link port number that the query concern. */ - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_adapter_t; - - -typedef struct { - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_system_t; - -typedef struct { - sci_local_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_local_segment_t; - -typedef struct { - sci_remote_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_remote_segment_t; - -typedef struct { - sci_map_t map; - unsigned int subcommand; - unsigned int data; -} sci_query_map_t; - -/* Minor query commands (sub-commands) for adapter specific information SCI_ADAPTER */ -#define SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_MTU _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_MTU) -extern const unsigned int SCI_Q_ADAPTER_DMA_MTU; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE; - -#define SCI_Q_ADAPTER_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NODEID) -extern const unsigned int SCI_Q_ADAPTER_NODEID; - -#define SCI_Q_ADAPTER_SERIAL_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SERIAL_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_SERIAL_NUMBER; - -#define SCI_Q_ADAPTER_CARD_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CARD_TYPE) -extern const unsigned int SCI_Q_ADAPTER_CARD_TYPE; - -#define SCI_Q_ADAPTER_NUMBER_OF_STREAMS _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER_OF_STREAMS) -extern const unsigned int SCI_Q_ADAPTER_NUMBER_OF_STREAMS; - -#define SCI_Q_ADAPTER_STREAM_BUFFER_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_STREAM_BUFFER_SIZE) -extern const unsigned int SCI_Q_ADAPTER_STREAM_BUFFER_SIZE; - -#define SCI_Q_ADAPTER_CONFIGURED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONFIGURED) -extern const unsigned int SCI_Q_ADAPTER_CONFIGURED; - -#define SCI_Q_ADAPTER_LINK_OPERATIONAL _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LINK_OPERATIONAL) -extern const unsigned int SCI_Q_ADAPTER_LINK_OPERATIONAL; - -#define SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK) -extern const unsigned int SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK; - -#define SCI_Q_ADAPTER_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_NUMBER; - -#define SCI_Q_ADAPTER_INSTANCE_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_INSTANCE_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_INSTANCE_NUMBER; - -#define SCI_Q_ADAPTER_FIRMWARE_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_FIRMWARE_OK) -extern const unsigned int SCI_Q_ADAPTER_FIRMWARE_OK; - -#define SCI_Q_ADAPTER_CONNECTED_TO_SWITCH _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_SWITCH) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_SWITCH; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER; - -#define SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT; - -#define SCI_Q_ADAPTER_ATT_PAGE_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_PAGE_SIZE) -extern const unsigned int SCI_Q_ADAPTER_ATT_PAGE_SIZE; - -#define SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES; - -#define SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES; - -#define SCI_Q_ADAPTER_PHYS_MEM_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MEM_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MEM_NODEID; - -#define SCI_Q_ADAPTER_PHYS_MBX_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MBX_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MBX_NODEID; - -#define SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID; - -#define SCI_Q_ADAPTER_SCI_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SCI_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_SCI_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_B_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_B_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_B_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_IO_BUS_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_IO_BUS_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_IO_BUS_FREQUENCY; - -/* Minor query commands (sub-commands) for adapter specific information SCI_SYSTEM */ -#define SCI_Q_SYSTEM_HOSTBRIDGE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_HOSTBRIDGE) -extern const unsigned int SCI_Q_SYSTEM_HOSTBRIDGE; - -#define SCI_Q_SYSTEM_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_POSTING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_POSTING_ENABLED; - -#define SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED; - -#define SCI_Q_LOCAL_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_LOCAL_SEGMENT_IOADDR; - -#define SCI_Q_REMOTE_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_REMOTE_SEGMENT_IOADDR; - -#define SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET; - -#define SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET; - -#define HOSTBRIDGE_NOT_AVAILABLE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_NOT_AVAILABLE) -extern const unsigned int HOSTBRIDGE_NOT_AVAILABLE; - -#define HOSTBRIDGE_UNKNOWN _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_UNKNOWN) -extern const unsigned int HOSTBRIDGE_UNKNOWN; - -#define HOSTBRIDGE_440FX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440FX) -extern const unsigned int HOSTBRIDGE_440FX; - -#define HOSTBRIDGE_440LX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440LX) -extern const unsigned int HOSTBRIDGE_440LX; - -#define HOSTBRIDGE_440BX_A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_A) -extern const unsigned int HOSTBRIDGE_440BX_A; - -#define HOSTBRIDGE_440BX_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_B) -extern const unsigned int HOSTBRIDGE_440BX_B; - -#define HOSTBRIDGE_440GX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440GX) -extern const unsigned int HOSTBRIDGE_440GX; - -#define HOSTBRIDGE_450KX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450KX) -extern const unsigned int HOSTBRIDGE_450KX; - -#define HOSTBRIDGE_430NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_430NX) -extern const unsigned int HOSTBRIDGE_430NX; - -#define HOSTBRIDGE_450NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX) -extern const unsigned int HOSTBRIDGE_450NX; - -#define HOSTBRIDGE_450NX_MICO _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_MICO) -extern const unsigned int HOSTBRIDGE_450NX_MICO; - -#define HOSTBRIDGE_450NX_PXB _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_PXB) -extern const unsigned int HOSTBRIDGE_450NX_PXB; - -#define HOSTBRIDGE_I810 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810) -extern const unsigned int HOSTBRIDGE_I810; - -#define HOSTBRIDGE_I810_DC100 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810_DC100) -extern const unsigned int HOSTBRIDGE_I810_DC100; - -#define HOSTBRIDGE_I810E _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810E) -extern const unsigned int HOSTBRIDGE_I810E; - -#define HOSTBRIDGE_I815 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I815) -extern const unsigned int HOSTBRIDGE_I815; - -#define HOSTBRIDGE_I840 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I840) -extern const unsigned int HOSTBRIDGE_I840; - -#define HOSTBRIDGE_I850 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I850) -extern const unsigned int HOSTBRIDGE_I850; - -#define HOSTBRIDGE_I860 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I860) -extern const unsigned int HOSTBRIDGE_I860; - -#define HOSTBRIDGE_INTEL_E7500 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_INTEL_E7500) -extern const unsigned int HOSTBRIDGE_INTEL_E7500; - -#define HOSTBRIDGE_VIA_KT133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KT133) -extern const unsigned int HOSTBRIDGE_VIA_KT133; - -#define HOSTBRIDGE_VIA_KX133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KX133) -extern const unsigned int HOSTBRIDGE_VIA_KX133; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_133A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_133A) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_133A; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_266 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_266) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_266; - -#define HOSTBRIDGE_AMD_760_MP _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_760_MP) -extern const unsigned int HOSTBRIDGE_AMD_760_MP; - -#define HOSTBRIDGE_AMD_HAMMER _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_HAMMER) -extern const unsigned int HOSTBRIDGE_AMD_HAMMER; - -#define HOSTBRIDGE_SERVERWORKS_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE; - -#define HOSTBRIDGE_SERVERWORKS_HE_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE_B) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE_B; - -#define HOSTBRIDGE_SERVERWORKS_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_HE; - -#define HOSTBRIDGE_SERVERWORKS_GC_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_WS _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_WS) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_WS; - -#define HOSTBRIDGE_SERVERWORKS_GC_SL _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_SL) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_SL; - - -#define HOSTBRIDGE_WRITE_POSTING_DISABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_DISABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_DISABLED; - -#define HOSTBRIDGE_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_ENABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_ENABLED; - - - - -/********************************************************************************* - * * - * S C I C R E A T E D M A Q U E U E * - * * - * Flags * - * * - * SCI_FLAG_DMA_PHDMA : Create physical DMA queue. Please note that this is an * - * priveleged operation. * - * * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCICreateDMAQueue) -DLL void SCICreateDMAQueue(sci_desc_t sd, - sci_dma_queue_t *dq, - unsigned int localAdapterNo, - unsigned int maxEntries, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Not allowed in this queue state. * - * * - *********************************************************************************/ -#define SCIRemoveDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveDMAQueue) -DLL void SCIRemoveDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I E N Q U E U E D M A T R A N S F E R * - * * - * Flags: * - * * - * SCI_FLAG_DMA_READ - The DMA will be remote --> local * - * (default is local --> remote) * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is larger * - * than the segment size or larger than max * - * DMA size. * - * SCI_ERR_MAX_ENTRIES - The DMA queue is full * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_SEGMENT_NOT_PREPARED - The local segment has not been prepared for * - * access from the adapter associated with the * - * queue. * - * SCI_ERR_SEGMENT_NOT_CONNECTED - The remote segment is not connected through * - * the adapter associated with the queue. * - *********************************************************************************/ -#define SCIEnqueueDMATransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIEnqueueDMATransfer) -DLL sci_dma_queue_state_t SCIEnqueueDMATransfer(sci_dma_queue_t dq, - sci_local_segment_t localSegment, - sci_remote_segment_t remoteSegment, - unsigned int localOffset, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P O S T D M A Q U E U E * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The end of the transfer will cause the callback * - * function to be invoked. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIPostDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIPostDMAQueue) -DLL void SCIPostDMAQueue(sci_dma_queue_t dq, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortDMAQueue) -DLL void SCIAbortDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I R E S E T D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIResetDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIResetDMAQueue) -DLL void SCIResetDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I D M A Q U E U E S T A T E * - * * - *********************************************************************************/ -#define SCIDMAQueueState _SISCI_EXPANDE_FUNCTION_NAME(SCIDMAQueueState) -DLL sci_dma_queue_state_t SCIDMAQueueState(sci_dma_queue_t dq); - - - -/********************************************************************************* - * * - * S C I W A I T F O R D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForDMAQueue) -DLL sci_dma_queue_state_t SCIWaitForDMAQueue(sci_dma_queue_t dq, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I P H D M A E N Q U E U E * - * * - * SISCI Priveleged function * - * * - * Flags * - * * - * SCI_FLAG_DMA_READ * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaEnqueue _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaEnqueue) -DLL void SCIphDmaEnqueue(sci_dma_queue_t dmaqueue, - unsigned int size, - sci_ioaddr_t localBusAddr, - unsigned int remote_nodeid, - unsigned int remote_highaddr, - unsigned int remote_lowaddr, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I P H D M A S T A R T * - * * - * Flags * - * * - * SCI_FLAG_DMA_WAIT * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_DMA_RESET * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaStart _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaStart) -DLL sci_dma_queue_state_t SCIphDmaStart(sci_dma_queue_t dmaqueue, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I C R E A T E I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateInterrupt) -DLL void SCICreateInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveInterrupt) -DLL void SCIRemoveInterrupt(sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait was interrupted by a call to * - * SCIRemoveInterrupt. * - * The handle is invalid when this error code is returned.* - * * - *********************************************************************************/ -#define SCIWaitForInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForInterrupt) -DLL void SCIWaitForInterrupt(sci_local_interrupt_t interrupt, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_INTNO - No such interrupt number. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIConnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectInterrupt) -DLL void SCIConnectInterrupt(sci_desc_t sd, - sci_remote_interrupt_t *interrupt, - unsigned int nodeId, - unsigned int localAdapterNo, - unsigned int interruptNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisconnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectInterrupt) -DLL void SCIDisconnectInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R I G G E R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCITriggerInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCITriggerInterrupt) -DLL void SCITriggerInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I R E G I S T E R I N T E R R U P T F L A G * - * * - * * - * This function register an "interrupt flag" that is identified as an unique * - * location within a local segment. If successful, the resulting interrupt * - * handle will have been associated with the specified local segment. * - * * - * It is up to the (remote) client(s) to set up an "interrupt mapping" for the * - * corresponding segment offset using either the * - * * - * - SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * * - * or the * - * * - * - SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP * - * * - * option to "SCIMapRemoteSegment()". - I.e. after having established a * - * connection to the corresponding segment. A trigger operation can then * - * be implemented using a store operation via the relevant "interrupt map". * - * * - * * - * * - * * - * * - * Flags: * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT - Triggering is to take place using * - * "conditional interrupts". * - * * - * * - * * - * Specific error codes for this function: * - * None. * - * * - *********************************************************************************/ -#define SCIRegisterInterruptFlag _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterInterruptFlag) -DLL void SCIRegisterInterruptFlag( - unsigned int localAdapterNo, - sci_local_interrupt_t *interrupt, - sci_local_segment_t segment, - unsigned int offset, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I E N A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * This function make sure that another HW interrupt will take place the next * - * time the corresponding interrupt flag is triggered by a * - * "conditional interrupt" operation. * - * * - * Default semantics: * - * * - * When successful, the client can rely on that the first subsequent trigger * - * operation will cause a HW interrupt and subsequently cause the client * - * handler function to be invoked. * - * * - * If an interrupt was triggered in parallell with the enable operation, then * - * the operation will fail (SCI_ERR_COND_INT_RACE_PROBLEM), and the client can * - * not rely on another trigger operation will lead to handler invocation. * - * Hence, any state checking normally associated with handling the * - * corresponding interrupt should take place before attempting to enable * - * again. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_COND_INT_RACE_PROBLEM - The enable operation failed because an * - * incomming trigger operation happened * - * concurrently. * - * * - *********************************************************************************/ -#define SCIEnableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIEnableConditionalInterrupt) -DLL void SCIEnableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I D I S A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * Prevent subsequent "conditional interrupt"trigger operations for * - * the specified interupt flag from causing HW interrupt and handler * - * invocations. * - * * - * * - * Default semantics: * - * * - * If successful, no subsequent HW interrupts will take place, but handler * - * invocations that have already been scheduled may still take place. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisableConditionalInterrupt) -DLL void SCIDisableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C O N D I T I O N A L I N T E R R U P T C O U N T E R * - * * - * * - * Returns a value that indicates the number of times this flag has * - * been trigged since the last time it was enabled or disabled. * - * Calling the SCIEnableConditionalInterrupt / SCIDisableConditionalInterrupt * - * functions will reset the counter value. * - * * - * Default semantics: * - * * - * If successful, the current trig count is returned in the * - * interruptTrigCounter parameter. * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OVERFLOW - The number of trig operations have exceeded the range * - * that can be counted. * - *********************************************************************************/ -#define SCIGetConditionalInterruptTrigCounter _SISCI_EXPANDE_FUNCTION_NAME(SCIGetConditionalInterruptTrigCounter) -DLL void SCIGetConditionalInterruptTrigCounter( - sci_local_interrupt_t interrupt, - unsigned int *interruptTrigCounter, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlock _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlock) -DLL void SCITransferBlock(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K A S Y N C * - * * - * Flags * - * * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_USE_CALLBACK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger than * - * the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlockAsync _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlockAsync) -DLL void SCITransferBlockAsync(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - sci_block_transfer_t *block, - sci_cb_block_transfer_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForBlockTransfer) -DLL void SCIWaitForBlockTransfer(sci_block_transfer_t block, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortBlockTransfer) -DLL void SCIAbortBlockTransfer(sci_block_transfer_t block, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M E M C P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - -#define SCIMemCpy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCpy) -DLL void SCIMemCpy(sci_sequence_t sequence, - void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I M E M C O P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - - -#define SCIMemCopy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCopy) -DLL void SCIMemCopy(void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E G I S T E R S E G M E N T M E M O R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_ILLEGAL_ADDRESS - Illegal address. * - * SCI_ERR_OUT_OF_RANGE - Size is larger than the maximum size for the * - * local segment. * - * * - *********************************************************************************/ -#define SCIRegisterSegmentMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterSegmentMemory) -DLL void SCIRegisterSegmentMemory(void *address, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S C I S P A C E * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * * - *********************************************************************************/ -#define SCIConnectSCISpace _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSCISpace) -DLL void SCIConnectSCISpace(sci_desc_t sd, - unsigned int localAdapterNo, - sci_remote_segment_t *segment, - sci_address_t address, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/* - * ===================================================================================== - * - * S C I A T T A C H L O C A L S E G M E N T - * Description: - * - * SCIAttachLocalSegment() permits an application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events - * on this segment. - * - * - * Specific error codes for this function: - * - * SCI_ERR_ACCESS - No such shared segment - * SCI_ERR_NO_SUCH_SEGMENT - No such segment - * Note: Current implenentation will return SCI_ERR_ACCESS for both cases. This will - * change from next release. Application should handle both cases. - * - * ===================================================================================== - */ -#define SCIAttachLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachLocalSegment) - -DLL void -SCIAttachLocalSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int *size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); -/* - * ===================================================================================== - * - * S C I S H A R E S E G M E N T - * - * Description: - * - * SCIShareSegment() permits other application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * none - * - * Specific error codes for this function: - * - * - * - * ===================================================================================== - */ -#define SCIShareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIShareSegment) - -DLL void -SCIShareSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I F L U S H * - * * - * This function will flush the CPU buffers and the PSB buffers. * - * * - * Flags * - * SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY : * - * Only flush CPU buffers ( Write combining * - * etc buffers). * - * * - *********************************************************************************/ - -#define SCIFlush _SISCI_EXPANDE_FUNCTION_NAME(SCIFlush) -DLL void SCIFlush(sci_sequence_t sequence, - unsigned int flags); - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - -#endif - - - - - - - - - - - diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_demolib.h b/ndb/src/external/LINUX.x86/sci/include/sisci_demolib.h deleted file mode 100644 index 4284fc5585c..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_demolib.h +++ /dev/null @@ -1,226 +0,0 @@ -/* $Id: sisci_demolib.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - -#ifndef _SISCI_DEMOLIB_H -#define _SISCI_DEMOLIB_H - - -#if defined(_REENTRANT) - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_MT_ ## name - -#else - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_ST_ ## name - -#endif - -/*********************************************************************************/ -/* Q U E R Y A D A P T E R */ -/* */ -/*********************************************************************************/ - -#define QueryAdapter _SISCI_DEMOLIB_EXPAND_NAME(QueryAdapter) - -sci_error_t QueryAdapter( - unsigned int subcommand, - unsigned int localAdapterNo, - unsigned int portNo, - unsigned int *data); - - -/*********************************************************************************/ -/* Q U E R Y S Y S T E M */ -/* */ -/*********************************************************************************/ - -#define QuerySystem _SISCI_DEMOLIB_EXPAND_NAME(QuerySystem) - -sci_error_t QuerySystem( - unsigned int subcommand, - unsigned int *data); - - -/*********************************************************************************/ -/* D E T E C T F I R S T A D A P T E R C A R D */ -/* */ -/*********************************************************************************/ - -#define DetectFirstAdapterCard _SISCI_DEMOLIB_EXPAND_NAME(DetectFirstAdapterCard) - -sci_error_t DetectFirstAdapterCard( - unsigned int *localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetAdapterType _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterType) - -sci_error_t GetAdapterType(unsigned int localAdapterNo, - unsigned int *adapterType); - - -/*********************************************************************************/ -/* G E T L O C A L N O D E I D */ -/* */ -/*********************************************************************************/ - -#define GetLocalNodeId _SISCI_DEMOLIB_EXPAND_NAME(GetLocalNodeId) - -sci_error_t GetLocalNodeId( - unsigned int localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R S E R I A L N U M B E R */ -/* */ -/*********************************************************************************/ - -#define GetAdapterSerialNumber _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterSerialNumber) - -sci_error_t GetAdapterSerialNumber( - unsigned int localAdapterNo, - unsigned int *serialNo); - - - -/*********************************************************************************/ -/* G E T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(GetHostbridgeType) - -sci_error_t GetHostbridgeType(unsigned int *hostbridgeType); - - - -/*********************************************************************************/ -/* P R I N T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define PrintHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(PrintHostbridgeType) - -void PrintHostbridgeType(unsigned int hostbridge); - - - -/*********************************************************************************/ -/* G E T A P I V E R S I O N S T R I N G */ -/* */ -/*********************************************************************************/ - -#define GetAPIVersionString _SISCI_DEMOLIB_EXPAND_NAME(GetAPIVersionString) - -sci_error_t GetAPIVersionString(char str[], unsigned int strLength); - - - -/*********************************************************************************/ -/* G E T A D A P T E R I O B U S F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterIoBusFrequency(unsigned int localAdapterNo, - unsigned int *ioBusFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R S C I L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterSciLinkFrequency(unsigned int localAdapterNo, - unsigned int *sciLinkFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R B L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterBlinkFrequency(unsigned int localAdapterNo, - unsigned int *bLinkFrequency); - - -/*********************************************************************************/ -/* S E N D I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define SendInterrupt _SISCI_DEMOLIB_EXPAND_NAME(SendInterrupt) - -sci_error_t SendInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int remoteNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* R E C E I V E I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define ReceiveInterrupt _SISCI_DEMOLIB_EXPAND_NAME(ReceiveInterrupt) - -sci_error_t ReceiveInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* E N D I A N S W A P */ -/* */ -/*********************************************************************************/ - -#define EndianSwap _SISCI_DEMOLIB_EXPAND_NAME(EndianSwap) - -unsigned int EndianSwap (unsigned int value); - - -/*********************************************************************************/ -/* S L E E P M I L L I S E C O N D S */ -/* */ -/*********************************************************************************/ - -#define SleepMilliseconds _SISCI_DEMOLIB_EXPAND_NAME(SleepMilliseconds) - -void SleepMilliseconds(int milliseconds); - - - - -#endif diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_error.h b/ndb/src/external/LINUX.x86/sci/include/sisci_error.h deleted file mode 100644 index c53fe8ad5d9..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_error.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $Id: sisci_error.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - - - -#ifndef _SISCI_ERROR_H_ -#define _SISCI_ERROR_H_ - - -/* SCI Error return values always have 30 bit set */ -#define SCI_ERR_MASK 0x40000000 -#define SCI_ERR_REMOTE_MASK 0x01 /* Remote errors should have bit 0 set */ - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) - -/* Error codes */ -typedef enum { - SCI_ERR_OK = 0x000, - - - SCI_ERR_BUSY = (0x900 | SCI_ERR_MASK), - SCI_ERR_FLAG_NOT_IMPLEMENTED = (0x901 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_FLAG = (0x902 | SCI_ERR_MASK), - SCI_ERR_NOSPC = (0x904 | SCI_ERR_MASK), - SCI_ERR_API_NOSPC = (0x905 | SCI_ERR_MASK), - SCI_ERR_HW_NOSPC = (0x906 | SCI_ERR_MASK), - SCI_ERR_NOT_IMPLEMENTED = (0x907 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADAPTERNO = (0x908 | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_ADAPTERNO = (0x909 | SCI_ERR_MASK), - SCI_ERR_TIMEOUT = (0x90A | SCI_ERR_MASK), - SCI_ERR_OUT_OF_RANGE = (0x90B | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_SEGMENT = (0x90C | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_NODEID = (0x90D | SCI_ERR_MASK), - SCI_ERR_CONNECTION_REFUSED = (0x90E | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_CONNECTED = (0x90F | SCI_ERR_MASK), - SCI_ERR_SIZE_ALIGNMENT = (0x910 | SCI_ERR_MASK), - SCI_ERR_OFFSET_ALIGNMENT = (0x911 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_PARAMETER = (0x912 | SCI_ERR_MASK), - SCI_ERR_MAX_ENTRIES = (0x913 | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_PREPARED = (0x914 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADDRESS = (0x915 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_OPERATION = (0x916 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_QUERY = (0x917 | SCI_ERR_MASK), - SCI_ERR_SEGMENTID_USED = (0x918 | SCI_ERR_MASK), - SCI_ERR_SYSTEM = (0x919 | SCI_ERR_MASK), - SCI_ERR_CANCELLED = (0x91A | SCI_ERR_MASK), - SCI_ERR_NOT_CONNECTED = (0x91B | SCI_ERR_MASK), - SCI_ERR_NOT_AVAILABLE = (0x91C | SCI_ERR_MASK), - SCI_ERR_INCONSISTENT_VERSIONS = (0x91D | SCI_ERR_MASK), - SCI_ERR_COND_INT_RACE_PROBLEM = (0x91E | SCI_ERR_MASK), - SCI_ERR_OVERFLOW = (0x91F | SCI_ERR_MASK), - SCI_ERR_NOT_INITIALIZED = (0x920 | SCI_ERR_MASK), - - SCI_ERR_ACCESS = (0x921 | SCI_ERR_MASK), - - SCI_ERR_NO_SUCH_NODEID = (0xA00 | SCI_ERR_MASK), - SCI_ERR_NODE_NOT_RESPONDING = (0xA02 | SCI_ERR_MASK), - SCI_ERR_NO_REMOTE_LINK_ACCESS = (0xA04 | SCI_ERR_MASK), - SCI_ERR_NO_LINK_ACCESS = (0xA05 | SCI_ERR_MASK), - SCI_ERR_TRANSFER_FAILED = (0xA06 | SCI_ERR_MASK) -} sci_error_t; - - -#endif /* _SCI_ERROR_H_ */ - - - diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_types.h b/ndb/src/external/LINUX.x86/sci/include/sisci_types.h deleted file mode 100644 index f4125fdec69..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_types.h +++ /dev/null @@ -1,133 +0,0 @@ -/* $Id: sisci_types.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - -#ifndef _SISCI_TYPES_H -#define _SISCI_TYPES_H - -#include "sisci_error.h" - -#ifndef IN -#define IN -#endif - -#ifndef OUT -#define OUT -#endif - -#ifndef IN_OUT -#define IN_OUT -#endif - -/* Opaque data types for descriptors/handles */ -typedef struct sci_desc *sci_desc_t; -typedef struct sci_local_segment *sci_local_segment_t; -typedef struct sci_remote_segment *sci_remote_segment_t; - -typedef struct sci_map *sci_map_t; -typedef struct sci_sequence *sci_sequence_t; -#ifndef KERNEL -typedef struct sci_dma_queue *sci_dma_queue_t; -#endif -typedef struct sci_remote_interrupt *sci_remote_interrupt_t; -typedef struct sci_local_interrupt *sci_local_interrupt_t; -typedef struct sci_block_transfer *sci_block_transfer_t; - -/* - * Constants defining reasons for segment callbacks: - */ - -typedef enum { - SCI_CB_CONNECT = 1, - SCI_CB_DISCONNECT, - SCI_CB_NOT_OPERATIONAL, - SCI_CB_OPERATIONAL, - SCI_CB_LOST -} sci_segment_cb_reason_t; - -#define MAX_CB_REASON SCI_CB_LOST - -/* dma_queue_states is identical to the dma_queue_state_t in genif.h, they must be consistent.*/ -typedef enum { - SCI_DMAQUEUE_IDLE, - SCI_DMAQUEUE_GATHER, - SCI_DMAQUEUE_POSTED, - SCI_DMAQUEUE_DONE, - SCI_DMAQUEUE_ABORTED, - SCI_DMAQUEUE_ERROR -} sci_dma_queue_state_t; - - -typedef enum { - SCI_SEQ_OK, - SCI_SEQ_RETRIABLE, - SCI_SEQ_NOT_RETRIABLE, - SCI_SEQ_PENDING -} sci_sequence_status_t; - - -typedef struct { - unsigned short nodeId; /* SCI Address bit 63 - 48 */ - unsigned short offsHi; /* SCI Address bit 47 - 32 */ - unsigned int offsLo; /* SCI Address bit 31 - 0 */ -} sci_address_t; - - -typedef unsigned int sci_ioaddr_t; - -typedef enum { - SCI_CALLBACK_CANCEL = 1, - SCI_CALLBACK_CONTINUE -} sci_callback_action_t; - -#ifndef KERNEL -typedef sci_callback_action_t (*sci_cb_local_segment_t)(void *arg, - sci_local_segment_t segment, - sci_segment_cb_reason_t reason, - unsigned int nodeId, - unsigned int localAdapterNo, - sci_error_t error); - -typedef sci_callback_action_t (*sci_cb_remote_segment_t)(void *arg, - sci_remote_segment_t segment, - sci_segment_cb_reason_t reason, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_dma_t)(void IN *arg, - sci_dma_queue_t queue, - sci_error_t status); - - -typedef int (*sci_cb_block_transfer_t)(void *arg, - sci_block_transfer_t block, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_interrupt_t)(void *arg, - sci_local_interrupt_t interrupt, - sci_error_t status); - -#endif /* KERNEL */ -#endif diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_version.h b/ndb/src/external/LINUX.x86/sci/include/sisci_version.h deleted file mode 100644 index f1807c33aa5..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_version.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: sisci_version.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *******************************************************************************/ - - -#ifndef SISCI_VERSION_H -#define SISCI_VERSION_H - - -#define SISCI_API_VER_MAJOR 0x01 -#define SISCI_API_VER_MAJORC "1" - -#define SISCI_API_VER_MINOR 0x010 -#define SISCI_API_VER_MINORC "10" -#define SISCI_API_VER_MICRO 0x005 -#define SISCI_API_VER_MICROC "5" - -#define SISCI_SIGN_VERSION_MASK 0xfffff000 /* used to mask off API_VER_MICRO */ - -#define SISCI_API_VERSION (SISCI_API_VER_MAJOR << 24 | SISCI_API_VER_MINOR << 12 | SISCI_API_VER_MICRO) - -/* the rules are: - * - * Changes in API_VER_MICRO should be binary compatible, New flags, functions added. No changes to user code - * required if new features is not needed. - * - * Changes in API_VER_MINOR requires recompilation of user code. - * - * Changes in the API_VER_MAJOR will most likely require changes to user code. This should not happen very - * often... - * - */ - -#ifndef BUILD_DATE -#define BUILD_DATE __DATE__ -#endif - -#ifndef BUILD_NAME -#define BUILD_NAME "" -#endif - -#define API_VERSION "SISCI API version " SISCI_API_VER_MAJORC "." SISCI_API_VER_MINORC "."SISCI_API_VER_MICROC " ( "BUILD_NAME" "BUILD_DATE" )" - -#endif - - -/* Version info: */ -/* */ -/* 1.5.2 First SISCI version */ -/* 1.5.3 Some bug fixes */ -/* 1.5.4 Some bug fixes */ -/* 1.5.5 No release */ -/* 1.5.6 Lock flag implemented in function SCIConnectSegment */ -/* 1.5.7 Expanded query functionality */ -/* 1.5.8 Updated error checking (sequence) functionality for D320 */ -/* 1.6.0 Updated error checking (sequence) D320 and IRM 1.9 support */ -/* 1.9.0 Ported to Solaris_sparc, Solaris_x86 and Linux. IRM 1.9. */ -/* 1.9.1 Some bug fixes */ -/* 1.9.2 Added more adapter queries */ -/* 1.9.3 Bug fix in SCIMapLocalSegment and SCIMapRemoteSegment */ -/* 1.9.4 NT Release Developers Kit 2.40 */ -/* 1.9.5 Added flush after data transfer in SCIMemCopy() */ -/* 1.9.5 NT Release Developers Kit 2.44 */ -/* 1.10.0: - * New SCIInitialize(), SCITerminate() functions. - * Support for D330 - * - * - */ - - diff --git a/ndb/src/external/LINUX.x86/sci/include/version.h b/ndb/src/external/LINUX.x86/sci/include/version.h deleted file mode 100644 index a0e1fa6c5cd..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/version.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _VERSION_H -#define _VERSION_H - - -/* -#define DEMO_VER_MAJOR "1" -#define DEMO_VER_MINOR "5" -#define DEMO_VER_MICRO "0" -*/ - -#ifndef BUILD_DATE -#define BUILD_DATE __DATE__ -#endif - -#ifndef BUILD_NAME -#define BUILD_NAME "" -#endif - -/* -#define DEMO_VERSION "version " DEMO_VER_MAJOR "." DEMO_VER_MINOR "."DEMO_VER_MICRO " ("BUILD_NAME" "BUILD_DATE" )" -*/ -#define DEMO_VERSION " ("BUILD_NAME" "BUILD_DATE" )" - - -#endif diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_api.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_api.h deleted file mode 100644 index d02d3aafe7f..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_api.h +++ /dev/null @@ -1,2148 +0,0 @@ -/* $Id: sisci_api.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ -/******************************************************************************* - * * - * Copyright (C) 1993 - 2001 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *******************************************************************************/ - -#ifndef _SISCI_API_H -#define _SISCI_API_H - -#include "sisci_types.h" -#include "sisci_error.h" - - -#ifdef WIN32 -#ifdef API_DLL -#define DLL __declspec(dllexport) -#elif CLIENT_DLL -#define DLL __declspec(dllimport) -#endif -#endif /* WIN32 */ - - -#ifndef DLL -#define DLL -#endif - -#if defined(_REENTRANT) -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_MT_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_MT_ ## name -#else -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_ST_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_ST_ ## name -#endif -#define _SISCI_EXPANDE_CONSTANT_NAME(name) _SISCI_PUBLIC_CONST_ ## name - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCI_FLAG_FIXED_INTNO _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_INTNO) -extern const unsigned int SCI_FLAG_FIXED_INTNO; - -#define SCI_FLAG_SHARED_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_INT) -extern const unsigned int SCI_FLAG_SHARED_INT; - -#define SCI_FLAG_FIXED_MAP_ADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_MAP_ADDR) -extern const unsigned int SCI_FLAG_FIXED_MAP_ADDR; - -#define SCI_FLAG_READONLY_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READONLY_MAP) -extern const unsigned int SCI_FLAG_READONLY_MAP; - -#define SCI_FLAG_USE_CALLBACK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_USE_CALLBACK) -extern const unsigned int SCI_FLAG_USE_CALLBACK; - -#define SCI_FLAG_BLOCK_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_BLOCK_READ) -extern const unsigned int SCI_FLAG_BLOCK_READ; - -#define SCI_FLAG_THREAD_SAFE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_THREAD_SAFE) -extern const unsigned int SCI_FLAG_THREAD_SAFE; - -#define SCI_FLAG_ASYNCHRONOUS_CONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ASYNCHRONOUS_CONNECT) -extern const unsigned int SCI_FLAG_ASYNCHRONOUS_CONNECT; - -#define SCI_FLAG_EMPTY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_EMPTY) -extern const unsigned int SCI_FLAG_EMPTY; - -#define SCI_FLAG_PRIVATE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_PRIVATE) -extern const unsigned int SCI_FLAG_PRIVATE; - -#define SCI_FLAG_FORCE_DISCONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FORCE_DISCONNECT) -extern const unsigned int SCI_FLAG_FORCE_DISCONNECT; - -#define SCI_FLAG_NOTIFY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NOTIFY) -extern const unsigned int SCI_FLAG_NOTIFY; - -#define SCI_FLAG_DMA_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_READ) -extern const unsigned int SCI_FLAG_DMA_READ; - -#define SCI_FLAG_DMA_POST _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_POST) -extern const unsigned int SCI_FLAG_DMA_POST; - -#define SCI_FLAG_DMA_WAIT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_WAIT) -extern const unsigned int SCI_FLAG_DMA_WAIT; - -#define SCI_FLAG_DMA_RESET _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_RESET) -extern const unsigned int SCI_FLAG_DMA_RESET; - -#define SCI_FLAG_NO_FLUSH _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_FLUSH) -extern const unsigned int SCI_FLAG_NO_FLUSH; - -#define SCI_FLAG_NO_STORE_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_STORE_BARRIER) -extern const unsigned int SCI_FLAG_NO_STORE_BARRIER; - -#define SCI_FLAG_FAST_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FAST_BARRIER) -extern const unsigned int SCI_FLAG_FAST_BARRIER; - -#define SCI_FLAG_ERROR_CHECK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ERROR_CHECK) -extern const unsigned int SCI_FLAG_ERROR_CHECK; - -#define SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) -extern const unsigned int SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY; - -/* the FLUSH_CPU_BUFFERS_ONLY flag is for backwards compabillity only and should never be used */ -#define FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) - -#define SCI_FLAG_LOCK_OPERATION _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_LOCK_OPERATION) -extern const unsigned int SCI_FLAG_LOCK_OPERATION; - -#define SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP; - -#define SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP; - -#define SCI_FLAG_IO_MAP_IOSPACE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_IO_MAP_IOSPACE) -extern const unsigned int SCI_FLAG_IO_MAP_IOSPACE; - -#define SCI_FLAG_DMOVE_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMOVE_MAP) -extern const unsigned int SCI_FLAG_DMOVE_MAP; - -#define SCI_FLAG_WRITES_DISABLE_GATHER_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_WRITES_DISABLE_GATHER_MAP) -extern const unsigned int SCI_FLAG_WRITES_DISABLE_GATHER_MAP; - -#define SCI_FLAG_DISABLE_128_BYTES_PACKETS _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DISABLE_128_BYTES_PACKETS) -extern const unsigned int SCI_FLAG_DISABLE_128_BYTES_PACKETS; - -#define SCI_FLAG_DMA_SOURCE_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_SOURCE_ONLY) -extern const unsigned int SCI_FLAG_DMA_SOURCE_ONLY; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT_MAP; - -#define SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP; - -#define SCI_FLAG_NO_MEMORY_LOOPBACK_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_MEMORY_LOOPBACK_MAP) -extern const unsigned int SCI_FLAG_NO_MEMORY_LOOPBACK_MAP; - -#if defined(OS_IS_LYNXOS) || defined(OS_IS_VXWORKS) -#define SCI_FLAG_WRITE_BACK_CACHE_MAP _SISCI_EXPANDE_CONSTANT_NAME(WRITE_BACK_CACHE_MAP) -extern const unsigned int SCI_FLAG_WRITE_BACK_CACHE_MAP; -#endif - -#define SCI_FLAG_DMA_PHDMA _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_PHDMA) -extern const unsigned int SCI_FLAG_DMA_PHDMA; - -/*********************************************************************************/ -/* GENERAL VALUES */ -/*********************************************************************************/ -#define SCI_LOCAL_HOST _SISCI_EXPANDE_CONSTANT_NAME(SCI_LOCAL_HOST) -extern const unsigned int SCI_LOCAL_HOST; - -#define SCI_INFINITE_TIMEOUT _SISCI_EXPANDE_CONSTANT_NAME(SCI_INFINITE_TIMEOUT) -extern const unsigned int SCI_INFINITE_TIMEOUT; - -/*********************************************************************************/ -/* GENERAL ERROR CODES */ -/* */ -/* SCI_ERR_ILLEGAL_FLAG - Illegal flag value. */ -/* SCI_ERR_FLAG_NOT_IMPLEMENTED - Flag legal but flag feature not implemented. */ -/* SCI_ERR_NOT_IMPLEMENTED - Function not implemented. */ -/* SCI_ERR_SYSTEM - A system error. Check errno. */ -/* SCI_ERR_NOSPC - Unable to allocate OS resources. */ -/* SCI_ERR_API_NOSPC - Unable to allocate API resources. */ -/* SCI_ERR_HW_NOSPC - Unable to allocate HW resources (Hardware) */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "ADAPTER" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_ADAPTERNO - Adapter number is legal but does not exist. */ -/* SCI_ERR_ILLEGAL_ADAPTERNO - Illegal local adapter number (i.e. outside */ -/* legal range). */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "NODEID" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_NODEID - The remote adapter identified by nodeId does */ -/* not respond, but the intermediate link(s) */ -/* seem(s) to be operational. */ -/* SCI_ERR_ILLEGAL_NODEID - Illegal NodeId. */ -/* */ -/*********************************************************************************/ - - - -/********************************************************************************* - * * - * S C I I N I T I A L I Z E * - * * - * This function initializes the SISCI library. * - * The function must be called before SCIOpen(). * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCIInitialize _SISCI_EXPANDE_FUNCTION_NAME(SCIInitialize) -DLL void SCIInitialize(unsigned int flags, - sci_error_t *error); -#if 0 -unsigned int __Internal_SISCI_version_var; -#endif - -/********************************************************************************* - * * - * S C I T E R M I N A T E * - * * - * This function terminates the SISCI library. * - * The function must be called after SCIClose(). * - * * - * * - *********************************************************************************/ -#define SCITerminate _SISCI_EXPANDE_FUNCTION_NAME(SCITerminate) -DLL void SCITerminate(void); - -/********************************************************************************* - * * - * S C I O P E N * - * * - * * - * Opens a SCI virtual device. * - * Caller must supply a pointer to a variable of type sci_desc_t to be * - * initialized. * - * * - * Flags * - * SCI_FLAG_THREAD_SAFE - Operations on resources associated with this * - * descriptor will be performed in a multithread-safe * - * manner. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INCONSISTENT_VERSIONS - Inconsistency between the SISCI library * - * and the SISCI driver versions. * - * * - * * - *********************************************************************************/ -#define SCIOpen _SISCI_EXPANDE_FUNCTION_NAME(SCIOpen) -DLL void SCIOpen(sci_desc_t *sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C L O S E * - * * - * This function closes an open SCI virtual device. * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - All resources are not deallocated. * - * * - *********************************************************************************/ -#define SCIClose _SISCI_EXPANDE_FUNCTION_NAME(SCIClose) -DLL void SCIClose(sci_desc_t sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S E G M E N T * - * * - * Connects to a remote shared memory segment located at with the * - * identifier . * - * The user may then call SCIMapRemoteSegment() to map shared memory * - * into user space. * - * * - * Flags * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_ASYNCHRONOUS_CONNECT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_SEGMENT - Could not find the remote segment with the * - * given segmentId. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIConnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSegment) -DLL void SCIConnectSegment(sci_desc_t sd, - sci_remote_segment_t *segment, - unsigned int nodeId, - unsigned int segmentId, - unsigned int localAdapterNo, - sci_cb_remote_segment_t callback, - void *callbackArg, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T S E G M E N T * - * * - * Disconnects from the give mapped shared memory segment * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The segment is currently mapped or in use. * - * * - *********************************************************************************/ -#define SCIDisconnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectSegment) -DLL void SCIDisconnectSegment(sci_remote_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T R E M O T E S E G M E N T S I Z E * - * * - *********************************************************************************/ -#define SCIGetRemoteSegmentSize _SISCI_EXPANDE_FUNCTION_NAME(SCIGetRemoteSegmentSize) -DLL unsigned int SCIGetRemoteSegmentSize(sci_remote_segment_t segment); - - - -/********************************************************************************* - * * - * S C I W A I T F O R R E M O T E S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du * - * to a SCIDisconnectSegment() on the same * - * handle. The handle is invalid when this * - * error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForRemoteSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForRemoteSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForRemoteSegmentEvent( - sci_remote_segment_t segment, - sci_error_t *status, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P R E M O T E S E G M E N T * - * * - * This function is used to include a shared memory segment in the virtual * - * address space of the application. * - * * - * Flags: * - * * - * SCI_FLAG_FIXED_MAP_ADDR - Map at the suggested virtual address * - * SCI_FLAG_READONLY_MAP - The segment is mapped in read-only mode * - * SCI_FLAG_LOCK_OPERATION - Enable Lock operations (fetch and add) * - * SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP * - * - Enable aggressive prefetch with speculative * - * hold. * - * * - * SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP * - * - The PSB66 will prefetch 64 bytes. As soon * - * as the PCI read retry has been accepted, * - * the stream will change state to FREE, even * - * if less than 64 bytes were actually read. * - * * - * SCI_FLAG_IO_MAP_IOSPACE - Enable No Prefetch, no speculative hold. * - * * - * SCI_FLAG_DMOVE_MAP - Enable DMOVE packet type. The stream will be * - * set into FREE state immediately. * - * * - * SCI_FLAG_WRITES_DISABLE_GATHER_MAP * - * - Disable use of gather. * - * * - * SCI_FLAG_DISABLE_128_BYTES_PACKETS * - * - Disable use of 128-Byte packets * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an atomic "fetch-and-add-one" operation on * - * remote memory, but in addition an interrupt * - * will be generated if the target memory * - * location contained a "null value" before the * - * add operation was carried out. * - * The conditional interrupt flag must also be * - * specified in the SCIRegisterInterruptFlag() * - * function. * - * * - * SCI_FLAG_UNCONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an interrupt for the remote adapter * - * "in addition to" updating the corresponding * - * remote memory location with the data being * - * written. * - * The unconditional interrupt flag must also * - * be specified in the * - * SCIRegisterInterruptFlag() function. * - * * - * SCI_FLAG_WRITE_BACK_CACHE_MAP * - * - Enable cacheing of the mapped region. * - * Writes through this map will be written to a * - * write back cache, hence no remote SCI updates* - * until the cache line is flushed. The * - * application is responsible for the cache * - * flush operation. * - * The SCImemCopy() function will handle this * - * correctly by doing cache flushes internally. * - * This feature is architechture dependent and * - * not be available on all plattforms. * - * * - * SCI_FLAG_NO_MEMORY_LOOPBACK_MAP * - * - Forces a map to a remote segment located * - * in the local machine to be mapped using * - * SCI loopback. This is useful i.e. if you * - * want to use a regular map access to be * - * serialized with lock operations. * - * The default behaviour is to access a remte * - * segment located in the local machine as a * - * local MMU operation. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapRemoteSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapRemoteSegment) -DLL volatile void *SCIMapRemoteSegment( - sci_remote_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P L O C A L S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_FIXED_MAP_ADDR * - * SCI_FLAG_READONLY_MAP * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapLocalSegment) -DLL void *SCIMapLocalSegment(sci_local_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I U N M A P S E G M E N T * - * * - * This function unmaps pages of shared memory from the callers virtual * - * address space. * - * * - * Flags * - * None. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The map is currently in use. * - * * - *********************************************************************************/ -#define SCIUnmapSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIUnmapSegment) -DLL void SCIUnmapSegment(sci_map_t map, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E S E G M E N T * - * * - * Make the specified segment available for connections via the specified * - * adapter. If successful, the segment can be accessed from remote nodes * - * via the specified adapter. * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events * - * on this segment. * - * SCI_FLAG_EMPTY - No memory will be allocated for the segment. * - * SCI_FLAG_PRIVATE - The segment will be private meaning it will never * - * be any connections to it. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SEGMENTID_USED - The segment with this segmentId is already used * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * * - *********************************************************************************/ -#define SCICreateSegment _SISCI_EXPANDE_FUNCTION_NAME(SCICreateSegment) -DLL void SCICreateSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I W A I T F O R L O C A L S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du to a * - * SCIRemoveSegment() on the same handle. * - * The handle is invalid when this error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForLocalSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForLocalSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForLocalSegmentEvent( - sci_local_segment_t segment, - unsigned int *sourcenodeId, - unsigned int *localAdapterNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P R E P A R E S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_DMA_SOURCE_ONLY - The segment will be used as a source segment * - * for DMA operations. On some system types this * - * will enable the SISCI driver to use performance * - * improving features. * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIPrepareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIPrepareSegment) -DLL void SCIPrepareSegment(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E G M E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - Unable to remove the segment. The segment is currently * - * in use. * - * * - *********************************************************************************/ -#define SCIRemoveSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSegment) -DLL void SCIRemoveSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T A V A I L A B L E * - * * - * Flags * - * None. * - * * - * * - * SCI_ERR_SEGMENT_NOT_PREPARED - The segment has not been prepared for access * - * from this adapter. * - * SCI_ERR_ILLEGAL_OPERATION - The segment is created with the * - * SCI_FLAG_PRIVATE flag specified and * - * therefore has no segmentId. * - * * - *********************************************************************************/ -#define SCISetSegmentAvailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentAvailable) -DLL void SCISetSegmentAvailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T U N A V A I L A B L E * - * * - * Flags * - * * - * SCI_FLAG_FORCE_DISCONNECT * - * SCI_FLAG_NOTIFY * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * * - *********************************************************************************/ -#define SCISetSegmentUnavailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentUnavailable) -DLL void SCISetSegmentUnavailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E M A P S E Q U E N C E * - * * - * Flags: * - * * - * SCI_FLAG_FAST_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateMapSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICreateMapSequence) -DLL void SCICreateMapSequence(sci_map_t map, - sci_sequence_t *sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E Q U E N C E * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSequence) -DLL void SCIRemoveSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T A R T S E Q U E N C E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIStartSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIStartSequence) -DLL sci_sequence_status_t SCIStartSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I C H E C K S E Q U E N CE * - * * - * Flags * - * * - * SCI_FLAG_NO_FLUSH * - * SCI_FLAG_NO_STORE_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICheckSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICheckSequence) -DLL sci_sequence_status_t SCICheckSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T O R E B A R R I E R * - * * - * Flags * - * None. * - * * - * * - * * - *********************************************************************************/ -#define SCIStoreBarrier _SISCI_EXPANDE_FUNCTION_NAME(SCIStoreBarrier) -DLL void SCIStoreBarrier(sci_sequence_t sequence, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I F L U S H R E A D B U F F E R S * - * * - *********************************************************************************/ -#define SCIFlushReadBuffers _SISCI_EXPANDE_FUNCTION_NAME(SCIFlushReadBuffers) -DLL void SCIFlushReadBuffers(sci_sequence_t sequence); - - - - -/********************************************************************************* - * * - * S C I P R O B E N O D E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIProbeNode _SISCI_EXPANDE_FUNCTION_NAME(SCIProbeNode) -DLL int SCIProbeNode(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int nodeId, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIGetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCIGetCSRRegister) -DLL unsigned int SCIGetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCISetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCISetCSRRegister) -DLL void SCISetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I G E T L O C A L C S R * - * * - * SISCI Priveleged function * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIGetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCIGetLocalCSR) -DLL unsigned int SCIGetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T L O C A L C S R * - * * - * SISCI Priveleged function - * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCISetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCISetLocalCSR) -DLL void SCISetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A T T A C H P H Y S I C A L M E M O R Y * - * * - * SISCI Priveleged function * - * * - * Description: * - * * - * This function enables usage of physical devices and memory regions where the * - * Physical PCI bus address ( and mapped CPU address ) are already known. * - * The function will register the physical memory as a SISCI segment which can * - * be connected and mapped as a regular SISCI segment. * - * * - * Requirements: * - * * - * SCICreateSegment() with flag SCI_FLAG_EMPTY must have been called in advance * - * * - * Parameter description: * - * sci_ioaddr_t ioaddress : This is the address on the PCI bus that a PCI bus * - * master has to use to write to the specified memory * - * void * address : This is the (mapped) virtual address that the * - * application has to use to access the device. * - * This means that the device has to be mapped in * - * advance bye the devices own driver. * - * If the device is not to be accessed by the local * - * CPU, the address pointer shold be set to NULL * - * Flags * - * * - * None * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIAttachPhysicalMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachPhysicalMemory) -DLL void SCIAttachPhysicalMemory(sci_ioaddr_t ioaddress, - void *address, - unsigned int busNo, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I Q U E R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_QUERY - Unrecognized command. * - * * - *********************************************************************************/ -#define SCIQuery _SISCI_EXPANDE_FUNCTION_NAME(SCIQuery) -DLL void SCIQuery(unsigned int command, - void *data, - unsigned int flags, - sci_error_t *error); - - -/* MAJOR QUERY COMMANDS */ - -/* This command requires a pointer to a structure of type */ -/* "sci_query_string". The string will be filled in by the query. */ -#define SCI_Q_VENDORID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_VENDORID) -extern const unsigned int SCI_Q_VENDORID; - - -/* Same as for SCI_VENDOR_ID */ -#define SCI_Q_API _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_API) -extern const unsigned int SCI_Q_API; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_adapter" struct. */ -#define SCI_Q_ADAPTER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER) -extern const unsigned int SCI_Q_ADAPTER; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_system" struct. */ -#define SCI_Q_SYSTEM _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM) -extern const unsigned int SCI_Q_SYSTEM; - -#define SCI_Q_LOCAL_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT) -extern const unsigned int SCI_Q_LOCAL_SEGMENT; - -#define SCI_Q_REMOTE_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT) -extern const unsigned int SCI_Q_REMOTE_SEGMENT; - -#define SCI_Q_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP) -extern const unsigned int SCI_Q_MAP; - -typedef struct { - char *str; /* Pointer to a string of minimum "length" characters */ - unsigned int length; -} sci_query_string_t; - - -typedef struct { - unsigned int localAdapterNo; /* The adapter no. that the query concern. */ - unsigned int portNo; /* The SCI Link port number that the query concern. */ - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_adapter_t; - - -typedef struct { - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_system_t; - -typedef struct { - sci_local_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_local_segment_t; - -typedef struct { - sci_remote_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_remote_segment_t; - -typedef struct { - sci_map_t map; - unsigned int subcommand; - unsigned int data; -} sci_query_map_t; - -/* Minor query commands (sub-commands) for adapter specific information SCI_ADAPTER */ -#define SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_MTU _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_MTU) -extern const unsigned int SCI_Q_ADAPTER_DMA_MTU; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE; - -#define SCI_Q_ADAPTER_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NODEID) -extern const unsigned int SCI_Q_ADAPTER_NODEID; - -#define SCI_Q_ADAPTER_SERIAL_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SERIAL_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_SERIAL_NUMBER; - -#define SCI_Q_ADAPTER_CARD_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CARD_TYPE) -extern const unsigned int SCI_Q_ADAPTER_CARD_TYPE; - -#define SCI_Q_ADAPTER_NUMBER_OF_STREAMS _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER_OF_STREAMS) -extern const unsigned int SCI_Q_ADAPTER_NUMBER_OF_STREAMS; - -#define SCI_Q_ADAPTER_STREAM_BUFFER_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_STREAM_BUFFER_SIZE) -extern const unsigned int SCI_Q_ADAPTER_STREAM_BUFFER_SIZE; - -#define SCI_Q_ADAPTER_CONFIGURED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONFIGURED) -extern const unsigned int SCI_Q_ADAPTER_CONFIGURED; - -#define SCI_Q_ADAPTER_LINK_OPERATIONAL _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LINK_OPERATIONAL) -extern const unsigned int SCI_Q_ADAPTER_LINK_OPERATIONAL; - -#define SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK) -extern const unsigned int SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK; - -#define SCI_Q_ADAPTER_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_NUMBER; - -#define SCI_Q_ADAPTER_INSTANCE_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_INSTANCE_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_INSTANCE_NUMBER; - -#define SCI_Q_ADAPTER_FIRMWARE_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_FIRMWARE_OK) -extern const unsigned int SCI_Q_ADAPTER_FIRMWARE_OK; - -#define SCI_Q_ADAPTER_CONNECTED_TO_SWITCH _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_SWITCH) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_SWITCH; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER; - -#define SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT; - -#define SCI_Q_ADAPTER_ATT_PAGE_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_PAGE_SIZE) -extern const unsigned int SCI_Q_ADAPTER_ATT_PAGE_SIZE; - -#define SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES; - -#define SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES; - -#define SCI_Q_ADAPTER_PHYS_MEM_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MEM_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MEM_NODEID; - -#define SCI_Q_ADAPTER_PHYS_MBX_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MBX_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MBX_NODEID; - -#define SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID; - -#define SCI_Q_ADAPTER_SCI_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SCI_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_SCI_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_B_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_B_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_B_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_IO_BUS_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_IO_BUS_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_IO_BUS_FREQUENCY; - -/* Minor query commands (sub-commands) for adapter specific information SCI_SYSTEM */ -#define SCI_Q_SYSTEM_HOSTBRIDGE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_HOSTBRIDGE) -extern const unsigned int SCI_Q_SYSTEM_HOSTBRIDGE; - -#define SCI_Q_SYSTEM_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_POSTING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_POSTING_ENABLED; - -#define SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED; - -#define SCI_Q_LOCAL_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_LOCAL_SEGMENT_IOADDR; - -#define SCI_Q_REMOTE_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_REMOTE_SEGMENT_IOADDR; - -#define SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET; - -#define SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET; - -#define HOSTBRIDGE_NOT_AVAILABLE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_NOT_AVAILABLE) -extern const unsigned int HOSTBRIDGE_NOT_AVAILABLE; - -#define HOSTBRIDGE_UNKNOWN _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_UNKNOWN) -extern const unsigned int HOSTBRIDGE_UNKNOWN; - -#define HOSTBRIDGE_440FX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440FX) -extern const unsigned int HOSTBRIDGE_440FX; - -#define HOSTBRIDGE_440LX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440LX) -extern const unsigned int HOSTBRIDGE_440LX; - -#define HOSTBRIDGE_440BX_A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_A) -extern const unsigned int HOSTBRIDGE_440BX_A; - -#define HOSTBRIDGE_440BX_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_B) -extern const unsigned int HOSTBRIDGE_440BX_B; - -#define HOSTBRIDGE_440GX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440GX) -extern const unsigned int HOSTBRIDGE_440GX; - -#define HOSTBRIDGE_450KX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450KX) -extern const unsigned int HOSTBRIDGE_450KX; - -#define HOSTBRIDGE_430NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_430NX) -extern const unsigned int HOSTBRIDGE_430NX; - -#define HOSTBRIDGE_450NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX) -extern const unsigned int HOSTBRIDGE_450NX; - -#define HOSTBRIDGE_450NX_MICO _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_MICO) -extern const unsigned int HOSTBRIDGE_450NX_MICO; - -#define HOSTBRIDGE_450NX_PXB _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_PXB) -extern const unsigned int HOSTBRIDGE_450NX_PXB; - -#define HOSTBRIDGE_I810 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810) -extern const unsigned int HOSTBRIDGE_I810; - -#define HOSTBRIDGE_I810_DC100 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810_DC100) -extern const unsigned int HOSTBRIDGE_I810_DC100; - -#define HOSTBRIDGE_I810E _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810E) -extern const unsigned int HOSTBRIDGE_I810E; - -#define HOSTBRIDGE_I815 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I815) -extern const unsigned int HOSTBRIDGE_I815; - -#define HOSTBRIDGE_I840 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I840) -extern const unsigned int HOSTBRIDGE_I840; - -#define HOSTBRIDGE_I850 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I850) -extern const unsigned int HOSTBRIDGE_I850; - -#define HOSTBRIDGE_I860 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I860) -extern const unsigned int HOSTBRIDGE_I860; - -#define HOSTBRIDGE_VIA_KT133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KT133) -extern const unsigned int HOSTBRIDGE_VIA_KT133; - -#define HOSTBRIDGE_VIA_KX133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KX133) -extern const unsigned int HOSTBRIDGE_VIA_KX133; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_133A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_133A) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_133A; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_266 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_266) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_266; - -#define HOSTBRIDGE_AMD_760_MP _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_760_MP) -extern const unsigned int HOSTBRIDGE_AMD_760_MP; - -#define HOSTBRIDGE_SERVERWORKS_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE; - -#define HOSTBRIDGE_SERVERWORKS_HE_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE_B) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE_B; - -#define HOSTBRIDGE_SERVERWORKS_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_LE; - - - -#define HOSTBRIDGE_WRITE_POSTING_DISABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_DISABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_DISABLED; - -#define HOSTBRIDGE_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_ENABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_ENABLED; - - - - -/********************************************************************************* - * * - * S C I C R E A T E D M A Q U E U E * - * * - * Flags * - * * - * SCI_FLAG_DMA_PHDMA : Create physical DMA queue. Please note that this is an * - * priveleged operation. * - * * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCICreateDMAQueue) -DLL void SCICreateDMAQueue(sci_desc_t sd, - sci_dma_queue_t *dq, - unsigned int localAdapterNo, - unsigned int maxEntries, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Not allowed in this queue state. * - * * - *********************************************************************************/ -#define SCIRemoveDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveDMAQueue) -DLL void SCIRemoveDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I E N Q U E U E D M A T R A N S F E R * - * * - * Flags: * - * * - * SCI_FLAG_DMA_READ - The DMA will be remote --> local * - * (default is local --> remote) * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is larger * - * than the segment size or larger than max * - * DMA size. * - * SCI_ERR_MAX_ENTRIES - The DMA queue is full * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_SEGMENT_NOT_PREPARED - The local segment has not been prepared for * - * access from the adapter associated with the * - * queue. * - * SCI_ERR_SEGMENT_NOT_CONNECTED - The remote segment is not connected through * - * the adapter associated with the queue. * - *********************************************************************************/ -#define SCIEnqueueDMATransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIEnqueueDMATransfer) -DLL sci_dma_queue_state_t SCIEnqueueDMATransfer(sci_dma_queue_t dq, - sci_local_segment_t localSegment, - sci_remote_segment_t remoteSegment, - unsigned int localOffset, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P O S T D M A Q U E U E * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The end of the transfer will cause the callback * - * function to be invoked. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIPostDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIPostDMAQueue) -DLL void SCIPostDMAQueue(sci_dma_queue_t dq, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortDMAQueue) -DLL void SCIAbortDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I R E S E T D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIResetDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIResetDMAQueue) -DLL void SCIResetDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I D M A Q U E U E S T A T E * - * * - *********************************************************************************/ -#define SCIDMAQueueState _SISCI_EXPANDE_FUNCTION_NAME(SCIDMAQueueState) -DLL sci_dma_queue_state_t SCIDMAQueueState(sci_dma_queue_t dq); - - - -/********************************************************************************* - * * - * S C I W A I T F O R D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForDMAQueue) -DLL sci_dma_queue_state_t SCIWaitForDMAQueue(sci_dma_queue_t dq, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I P H D M A E N Q U E U E * - * * - * SISCI Priveleged function * - * * - * Flags * - * * - * SCI_FLAG_DMA_READ * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaEnqueue _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaEnqueue) -DLL void SCIphDmaEnqueue(sci_dma_queue_t dmaqueue, - unsigned int size, - sci_ioaddr_t localBusAddr, - unsigned int remote_nodeid, - unsigned int remote_highaddr, - unsigned int remote_lowaddr, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I P H D M A S T A R T * - * * - * Flags * - * * - * SCI_FLAG_DMA_WAIT * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_DMA_RESET * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaStart _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaStart) -DLL sci_dma_queue_state_t SCIphDmaStart(sci_dma_queue_t dmaqueue, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I C R E A T E I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateInterrupt) -DLL void SCICreateInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveInterrupt) -DLL void SCIRemoveInterrupt(sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait was interrupted by a call to * - * SCIRemoveInterrupt. * - * The handle is invalid when this error code is returned.* - * * - *********************************************************************************/ -#define SCIWaitForInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForInterrupt) -DLL void SCIWaitForInterrupt(sci_local_interrupt_t interrupt, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_INTNO - No such interrupt number. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIConnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectInterrupt) -DLL void SCIConnectInterrupt(sci_desc_t sd, - sci_remote_interrupt_t *interrupt, - unsigned int nodeId, - unsigned int localAdapterNo, - unsigned int interruptNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisconnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectInterrupt) -DLL void SCIDisconnectInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R I G G E R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCITriggerInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCITriggerInterrupt) -DLL void SCITriggerInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I R E G I S T E R I N T E R R U P T F L A G * - * * - * * - * This function register an "interrupt flag" that is identified as an unique * - * location within a local segment. If successful, the resulting interrupt * - * handle will have been associated with the specified local segment. * - * * - * It is up to the (remote) client(s) to set up an "interrupt mapping" for the * - * corresponding segment offset using either the * - * * - * - SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * * - * or the * - * * - * - SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP * - * * - * option to "SCIMapRemoteSegment()". - I.e. after having established a * - * connection to the corresponding segment. A trigger operation can then * - * be implemented using a store operation via the relevant "interrupt map". * - * * - * * - * * - * * - * * - * Flags: * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT - Triggering is to take place using * - * "conditional interrupts". * - * * - * * - * * - * Specific error codes for this function: * - * None. * - * * - *********************************************************************************/ -#define SCIRegisterInterruptFlag _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterInterruptFlag) -DLL void SCIRegisterInterruptFlag( - unsigned int localAdapterNo, - sci_local_interrupt_t *interrupt, - sci_local_segment_t segment, - unsigned int offset, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I E N A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * This function make sure that another HW interrupt will take place the next * - * time the corresponding interrupt flag is triggered by a * - * "conditional interrupt" operation. * - * * - * Default semantics: * - * * - * When successful, the client can rely on that the first subsequent trigger * - * operation will cause a HW interrupt and subsequently cause the client * - * handler function to be invoked. * - * * - * If an interrupt was triggered in parallell with the enable operation, then * - * the operation will fail (SCI_ERR_COND_INT_RACE_PROBLEM), and the client can * - * not rely on another trigger operation will lead to handler invocation. * - * Hence, any state checking normally associated with handling the * - * corresponding interrupt should take place before attempting to enable * - * again. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_COND_INT_RACE_PROBLEM - The enable operation failed because an * - * incomming trigger operation happened * - * concurrently. * - * * - *********************************************************************************/ -#define SCIEnableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIEnableConditionalInterrupt) -DLL void SCIEnableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I D I S A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * Prevent subsequent "conditional interrupt"trigger operations for * - * the specified interupt flag from causing HW interrupt and handler * - * invocations. * - * * - * * - * Default semantics: * - * * - * If successful, no subsequent HW interrupts will take place, but handler * - * invocations that have already been scheduled may still take place. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisableConditionalInterrupt) -DLL void SCIDisableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C O N D I T I O N A L I N T E R R U P T C O U N T E R * - * * - * * - * Returns a value that indicates the number of times this flag has * - * been trigged since the last time it was enabled or disabled. * - * Calling the SCIEnableConditionalInterrupt / SCIDisableConditionalInterrupt * - * functions will reset the counter value. * - * * - * Default semantics: * - * * - * If successful, the current trig count is returned in the * - * interruptTrigCounter parameter. * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OVERFLOW - The number of trig operations have exceeded the range * - * that can be counted. * - *********************************************************************************/ -#define SCIGetConditionalInterruptTrigCounter _SISCI_EXPANDE_FUNCTION_NAME(SCIGetConditionalInterruptTrigCounter) -DLL void SCIGetConditionalInterruptTrigCounter( - sci_local_interrupt_t interrupt, - unsigned int *interruptTrigCounter, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlock _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlock) -DLL void SCITransferBlock(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K A S Y N C * - * * - * Flags * - * * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_USE_CALLBACK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger than * - * the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlockAsync _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlockAsync) -DLL void SCITransferBlockAsync(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - sci_block_transfer_t *block, - sci_cb_block_transfer_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForBlockTransfer) -DLL void SCIWaitForBlockTransfer(sci_block_transfer_t block, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortBlockTransfer) -DLL void SCIAbortBlockTransfer(sci_block_transfer_t block, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M E M C P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - -#define SCIMemCpy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCpy) -DLL void SCIMemCpy(sci_sequence_t sequence, - void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I M E M C O P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - - -#define SCIMemCopy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCopy) -DLL void SCIMemCopy(void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E G I S T E R S E G M E N T M E M O R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_ILLEGAL_ADDRESS - Illegal address. * - * SCI_ERR_OUT_OF_RANGE - Size is larger than the maximum size for the * - * local segment. * - * * - *********************************************************************************/ -#define SCIRegisterSegmentMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterSegmentMemory) -DLL void SCIRegisterSegmentMemory(void *address, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S C I S P A C E * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * * - *********************************************************************************/ -#define SCIConnectSCISpace _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSCISpace) -DLL void SCIConnectSCISpace(sci_desc_t sd, - unsigned int localAdapterNo, - sci_remote_segment_t *segment, - sci_address_t address, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/* - * ===================================================================================== - * - * S C I A T T A C H L O C A L S E G M E N T - * Description: - * - * SCIAttachLocalSegment() permits an application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events - * on this segment. - * - * - * Specific error codes for this function: - * - * SCI_ERR_ACCESS - No such shared segment - * SCI_ERR_NO_SUCH_SEGMENT - No such segment - * Note: Current implenentation will return SCI_ERR_ACCESS for both cases. This will - * change from next release. Application should handle both cases. - * - * ===================================================================================== - */ -#define SCIAttachLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachLocalSegment) - -DLL void -SCIAttachLocalSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int *size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); -/* - * ===================================================================================== - * - * S C I S H A R E S E G M E N T - * - * Description: - * - * SCIShareSegment() permits other application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * none - * - * Specific error codes for this function: - * - * - * - * ===================================================================================== - */ -#define SCIShareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIShareSegment) - -DLL void -SCIShareSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I F L U S H * - * * - * This function will flush the CPU buffers and the PSB buffers. * - * * - * Flags * - * SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY : * - * Only flush CPU buffers ( Write combining * - * etc buffers). * - * * - *********************************************************************************/ - -#define SCIFlush _SISCI_EXPANDE_FUNCTION_NAME(SCIFlush) -DLL void SCIFlush(sci_sequence_t sequence, - unsigned int flags); - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - -#endif - - - - - - - - - - - diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_error.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_error.h deleted file mode 100644 index aab7c136d3a..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_error.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $Id: sisci_error.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - - - -#ifndef _SISCI_ERROR_H_ -#define _SISCI_ERROR_H_ - - -/* SCI Error return values always have 30 bit set */ -#define SCI_ERR_MASK 0x40000000 -#define SCI_ERR_REMOTE_MASK 0x01 /* Remote errors should have bit 0 set */ - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) - -/* Error codes */ -typedef enum { - SCI_ERR_OK = 0x000, - - - SCI_ERR_BUSY = (0x900 | SCI_ERR_MASK), - SCI_ERR_FLAG_NOT_IMPLEMENTED = (0x901 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_FLAG = (0x902 | SCI_ERR_MASK), - SCI_ERR_NOSPC = (0x904 | SCI_ERR_MASK), - SCI_ERR_API_NOSPC = (0x905 | SCI_ERR_MASK), - SCI_ERR_HW_NOSPC = (0x906 | SCI_ERR_MASK), - SCI_ERR_NOT_IMPLEMENTED = (0x907 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADAPTERNO = (0x908 | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_ADAPTERNO = (0x909 | SCI_ERR_MASK), - SCI_ERR_TIMEOUT = (0x90A | SCI_ERR_MASK), - SCI_ERR_OUT_OF_RANGE = (0x90B | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_SEGMENT = (0x90C | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_NODEID = (0x90D | SCI_ERR_MASK), - SCI_ERR_CONNECTION_REFUSED = (0x90E | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_CONNECTED = (0x90F | SCI_ERR_MASK), - SCI_ERR_SIZE_ALIGNMENT = (0x910 | SCI_ERR_MASK), - SCI_ERR_OFFSET_ALIGNMENT = (0x911 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_PARAMETER = (0x912 | SCI_ERR_MASK), - SCI_ERR_MAX_ENTRIES = (0x913 | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_PREPARED = (0x914 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADDRESS = (0x915 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_OPERATION = (0x916 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_QUERY = (0x917 | SCI_ERR_MASK), - SCI_ERR_SEGMENTID_USED = (0x918 | SCI_ERR_MASK), - SCI_ERR_SYSTEM = (0x919 | SCI_ERR_MASK), - SCI_ERR_CANCELLED = (0x91A | SCI_ERR_MASK), - SCI_ERR_NOT_CONNECTED = (0x91B | SCI_ERR_MASK), - SCI_ERR_NOT_AVAILABLE = (0x91C | SCI_ERR_MASK), - SCI_ERR_INCONSISTENT_VERSIONS = (0x91D | SCI_ERR_MASK), - SCI_ERR_COND_INT_RACE_PROBLEM = (0x91E | SCI_ERR_MASK), - SCI_ERR_OVERFLOW = (0x91F | SCI_ERR_MASK), - SCI_ERR_NOT_INITIALIZED = (0x920 | SCI_ERR_MASK), - - SCI_ERR_ACCESS = (0x921 | SCI_ERR_MASK), - - SCI_ERR_NO_SUCH_NODEID = (0xA00 | SCI_ERR_MASK), - SCI_ERR_NODE_NOT_RESPONDING = (0xA02 | SCI_ERR_MASK), - SCI_ERR_NO_REMOTE_LINK_ACCESS = (0xA04 | SCI_ERR_MASK), - SCI_ERR_NO_LINK_ACCESS = (0xA05 | SCI_ERR_MASK), - SCI_ERR_TRANSFER_FAILED = (0xA06 | SCI_ERR_MASK) -} sci_error_t; - - -#endif /* _SCI_ERROR_H_ */ - - - diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_types.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_types.h deleted file mode 100644 index 77989ffca59..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_types.h +++ /dev/null @@ -1,133 +0,0 @@ -/* $Id: sisci_types.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - -#ifndef _SISCI_TYPES_H -#define _SISCI_TYPES_H - -#include "sisci_error.h" - -#ifndef IN -#define IN -#endif - -#ifndef OUT -#define OUT -#endif - -#ifndef IN_OUT -#define IN_OUT -#endif - -/* Opaque data types for descriptors/handles */ -typedef struct sci_desc *sci_desc_t; -typedef struct sci_local_segment *sci_local_segment_t; -typedef struct sci_remote_segment *sci_remote_segment_t; - -typedef struct sci_map *sci_map_t; -typedef struct sci_sequence *sci_sequence_t; -#ifndef KERNEL -typedef struct sci_dma_queue *sci_dma_queue_t; -#endif -typedef struct sci_remote_interrupt *sci_remote_interrupt_t; -typedef struct sci_local_interrupt *sci_local_interrupt_t; -typedef struct sci_block_transfer *sci_block_transfer_t; - -/* - * Constants defining reasons for segment callbacks: - */ - -typedef enum { - SCI_CB_CONNECT = 1, - SCI_CB_DISCONNECT, - SCI_CB_NOT_OPERATIONAL, - SCI_CB_OPERATIONAL, - SCI_CB_LOST -} sci_segment_cb_reason_t; - -#define MAX_CB_REASON SCI_CB_LOST - -/* dma_queue_states is identical to the dma_queue_state_t in genif.h, they must be consistent.*/ -typedef enum { - SCI_DMAQUEUE_IDLE, - SCI_DMAQUEUE_GATHER, - SCI_DMAQUEUE_POSTED, - SCI_DMAQUEUE_DONE, - SCI_DMAQUEUE_ABORTED, - SCI_DMAQUEUE_ERROR -} sci_dma_queue_state_t; - - -typedef enum { - SCI_SEQ_OK, - SCI_SEQ_RETRIABLE, - SCI_SEQ_NOT_RETRIABLE, - SCI_SEQ_PENDING -} sci_sequence_status_t; - - -typedef struct { - unsigned short nodeId; /* SCI Address bit 63 - 48 */ - unsigned short offsHi; /* SCI Address bit 47 - 32 */ - unsigned int offsLo; /* SCI Address bit 31 - 0 */ -} sci_address_t; - - -typedef unsigned int sci_ioaddr_t; - -typedef enum { - SCI_CALLBACK_CANCEL = 1, - SCI_CALLBACK_CONTINUE -} sci_callback_action_t; - -#ifndef KERNEL -typedef sci_callback_action_t (*sci_cb_local_segment_t)(void *arg, - sci_local_segment_t segment, - sci_segment_cb_reason_t reason, - unsigned int nodeId, - unsigned int localAdapterNo, - sci_error_t error); - -typedef sci_callback_action_t (*sci_cb_remote_segment_t)(void *arg, - sci_remote_segment_t segment, - sci_segment_cb_reason_t reason, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_dma_t)(void IN *arg, - sci_dma_queue_t queue, - sci_error_t status); - - -typedef int (*sci_cb_block_transfer_t)(void *arg, - sci_block_transfer_t block, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_interrupt_t)(void *arg, - sci_local_interrupt_t interrupt, - sci_error_t status); - -#endif /* KERNEL */ -#endif diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_version.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_version.h deleted file mode 100644 index c2fccb9ec33..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_version.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: sisci_version.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *******************************************************************************/ - - -#ifndef SISCI_VERSION_H -#define SISCI_VERSION_H - - -#define SISCI_API_VER_MAJOR 1 -#define SISCI_API_VER_MAJORC "1" - -#define SISCI_API_VER_MINOR 10 -#define SISCI_API_VER_MINORC "10" -#define SISCI_API_VER_MICRO 4 -#define SISCI_API_VER_MICROC "4" - -#define SISCI_SIGN_VERSION_MASK 0xfffff000 /* used to mask off API_VER_MICRO */ - -#define SISCI_API_VERSION (SISCI_API_VER_MAJOR << 24 | SISCI_API_VER_MINOR << 12 | SISCI_API_VER_MICRO) - -/* the rules are: - * - * Changes in API_VER_MICRO should be binary compatible, New flags, functions added. No changes to user code - * required if new features is not needed. - * - * Changes in API_VER_MINOR requires recompilation of user code. - * - * Changes in the API_VER_MAJOR will most likely require changes to user code. This should not happen very - * often... - * - */ - -#ifndef BUILD_DATE -#define BUILD_DATE __DATE__ -#endif - -#ifndef BUILD_NAME -#define BUILD_NAME "" -#endif - -#define API_VERSION "SISCI API version " SISCI_API_VER_MAJORC "." SISCI_API_VER_MINORC "."SISCI_API_VER_MICROC " ( "BUILD_NAME" "BUILD_DATE" )" - -#endif - - -/* Version info: */ -/* */ -/* 1.5.2 First SISCI version */ -/* 1.5.3 Some bug fixes */ -/* 1.5.4 Some bug fixes */ -/* 1.5.5 No release */ -/* 1.5.6 Lock flag implemented in function SCIConnectSegment */ -/* 1.5.7 Expanded query functionality */ -/* 1.5.8 Updated error checking (sequence) functionality for D320 */ -/* 1.6.0 Updated error checking (sequence) D320 and IRM 1.9 support */ -/* 1.9.0 Ported to Solaris_sparc, Solaris_x86 and Linux. IRM 1.9. */ -/* 1.9.1 Some bug fixes */ -/* 1.9.2 Added more adapter queries */ -/* 1.9.3 Bug fix in SCIMapLocalSegment and SCIMapRemoteSegment */ -/* 1.9.4 NT Release Developers Kit 2.40 */ -/* 1.9.5 Added flush after data transfer in SCIMemCopy() */ -/* 1.9.5 NT Release Developers Kit 2.44 */ -/* 1.10.0: - * New SCIInitialize(), SCITerminate() functions. - * Support for D330 - * - * - */ - - diff --git a/ndb/src/external/WIN32.x86/sci/include/rmlib.h b/ndb/src/external/WIN32.x86/sci/include/rmlib.h deleted file mode 100644 index 87ba20db99f..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/rmlib.h +++ /dev/null @@ -1,212 +0,0 @@ -/* $Id: rmlib.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/********************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *********************************************************************************/ - -/********************************************************************************/ -/* This header file contains the declarations of the SCI Reflective Memory */ -/* library rmlib. The implementation of the library functions is in rmlib.c. */ -/* The library contains all the functions that operate on the reflective */ -/* memory. */ -/* */ -/* NB! */ -/* */ -/* DOLPHIN'S SCI REFLECTIVE MEMORY FILES ARE UNDER DEVELOPMENT AND MAY CHANGE. */ -/* PLEASE CONTACT DOLPHIN FOR FURTHER INFORMATION. */ -/* */ -/* */ -/********************************************************************************/ - -#include "sisci_error.h" -#include "sisci_api.h" -#include "sisci_demolib.h" -#include "sisci_types.h" - -unsigned int seqerr, syncseqerr; - -#ifndef _RMLIB_H -#define _RMLIB_H - - -#if defined(_REENTRANT) - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_MT_ ## name - -#else - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_ST_ ## name - -#endif - -#ifdef __sparc -#define CACHE_SIZE 2097152 -#else -#define CACHE_SIZE 8192 -#endif - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define REFLECT_ERRCHECK 0x2 - -struct ReflectiveMemorySpace { - unsigned int localAdapterNo; - unsigned int localNodeId; - unsigned int remoteNodeId; - sci_desc_t sd; - sci_desc_t syncsd; - sci_map_t localMap; - sci_map_t remoteMap; - unsigned int localSegmentId; - unsigned int remoteSegmentId; - unsigned int syncSegmentId; - unsigned int sync_rSegmentId; - unsigned int segmentSize; - unsigned int *localMapAddr; - volatile unsigned int *remoteMapAddr; - sci_local_segment_t localSegment; - sci_remote_segment_t remoteSegment; - sci_local_segment_t syncSegment; - sci_remote_segment_t sync_rSegment; - sci_map_t syncMap; - sci_map_t sync_rMap; - sci_sequence_t syncsequence; - sci_sequence_t sequence; - unsigned int protection; - unsigned int retry_value; - sci_sequence_status_t sequenceStatus, syncsequenceStatus; - volatile unsigned int *syncMapAddr; - volatile unsigned int *sync_rMapAddr; -}; - -/*********************************************************************************/ -/* P R I N T R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectPrintParameters _RMLIB_EXPAND_NAME(ReflectPrintParameters) -void ReflectPrintParameters(FILE *stream, struct ReflectiveMemorySpace RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A S E T U P */ -/* */ -/*********************************************************************************/ -#define ReflectDmaSetup _RMLIB_EXPAND_NAME(ReflectDmaSetup) -sci_error_t ReflectDmaSetup(struct ReflectiveMemorySpace RM_space, sci_dma_queue_t *dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R E M O V E */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRemove _RMLIB_EXPAND_NAME(ReflectDmaRemove) -sci_error_t ReflectDmaRemove(sci_dma_queue_t dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R U N */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRun _RMLIB_EXPAND_NAME(ReflectDmaRun) -sci_error_t ReflectDmaRun(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - sci_dma_queue_t dmaQueue); -/*********************************************************************************/ -/* C L O S E R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectClose _RMLIB_EXPAND_NAME(ReflectClose) -sci_error_t ReflectClose(struct ReflectiveMemorySpace RM_space, unsigned int segment_no); - -/*********************************************************************************/ -/* O P E N R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectOpen _RMLIB_EXPAND_NAME(ReflectOpen) -sci_error_t ReflectOpen(struct ReflectiveMemorySpace *RM_space, - unsigned int size, - unsigned int segment_no, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int protection, - unsigned int retry_value); - -/*********************************************************************************/ -/* R E F L E C T G E T A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectGetAccess _RMLIB_EXPAND_NAME(ReflectGetAccess) -sci_error_t ReflectGetAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T R E L E A S E A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectReleaseAccess _RMLIB_EXPAND_NAME(ReflectReleaseAccess) -sci_error_t ReflectReleaseAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A */ -/* */ -/*********************************************************************************/ -#define ReflectDma _RMLIB_EXPAND_NAME(ReflectDma) -sci_error_t ReflectDma(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset); - -/*********************************************************************************/ -/* R E F L E C T M E M C O P Y */ -/* */ -/*********************************************************************************/ -#define ReflectMemCopy _RMLIB_EXPAND_NAME(ReflectMemCopy) -sci_error_t ReflectMemCopy(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - unsigned int flags); - -/*********************************************************************************/ -/* R E F L E C T S E T */ -/* */ -/*********************************************************************************/ -#define ReflectSet _RMLIB_EXPAND_NAME(ReflectSet) -sci_error_t ReflectSet(struct ReflectiveMemorySpace RM_space, - unsigned int value, - unsigned int size, - unsigned int offset, - unsigned int flags - ); - -/*********************************************************************************/ -/* R E F L E C T P R I N T */ -/* */ -/*********************************************************************************/ -#define ReflectPrint _RMLIB_EXPAND_NAME(ReflectPrint) -sci_error_t ReflectPrint(FILE *stream, - struct ReflectiveMemorySpace RM_space, - unsigned int size, - unsigned int offset - ); - - -#endif diff --git a/ndb/src/external/WIN32.x86/sci/include/scilib.h b/ndb/src/external/WIN32.x86/sci/include/scilib.h deleted file mode 100644 index d1501082bab..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/scilib.h +++ /dev/null @@ -1,330 +0,0 @@ -/* $Id: scilib.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 2002 * - * Dolphin Interconnect Solutions AS * - * * - *******************************************************************************/ - - -#if defined(_REENTRANT) -#define _SCIL_EXPANDE_FUNCTION_NAME(name) _SCIL_PUBLIC_FUNC_MT_ ## name -#define _SCIL_EXPANDE_VARIABLE_NAME(name) _SCIL_PUBLIC_VAR_MT_ ## name -#else -#define _SCIL_EXPANDE_FUNCTION_NAME(name) _SCIL_PUBLIC_FUNC_ST_ ## name -#define _SCIL_EXPANDE_VARIABLE_NAME(name) _SCIL_PUBLIC_VAR_ST_ ## name -#endif -#define _SCIL_EXPANDE_CONSTANT_NAME(name) _SCIL_PUBLIC_CONST_ ## name - -#include "sisci_api.h" - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/* - * SISCI segment id pollution: - * =========================== - * The SISCI library uses regular SISCI segmens internally. - * The MSG_QUEUE_LIB_IDENTIFIER_MASK is a mask which is used by the SISCI - * library to identify internal SISCI segments ids, from segments used directly - * by the user. - * - * Future versions of the library may have its own namespace. - * - */ - -#define MSG_QUEUE_LIB_IDENTIFIER_MASK 0x10000000 - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCIL_FLAG_ERROR_CHECK_DATA _SCIL_EXPANDE_CONSTANT_NAME(SCIL_FLAG_ERROR_CHECK_DATA) -extern const unsigned int SCIL_FLAG_ERROR_CHECK_DATA; - -#define SCIL_FLAG_ERROR_CHECK_PROT _SCIL_EXPANDE_CONSTANT_NAME(SCIL_FLAG_ERROR_CHECK_PROT) -extern const unsigned int SCIL_FLAG_ERROR_CHECK_PROT; - -#define SCIL_FLAG_FULL_ERROR_CHECK _SCIL_EXPANDE_CONSTANT_NAME(SCIL_FLAG_FULL_ERROR_CHECK) -extern const unsigned int SCIL_FLAG_FULL_ERROR_CHECK; - - - - - -typedef struct sci_msq_queue *sci_msq_queue_t; - - -/********************************************************************************* - * * - * S C I L C r e a t e M s g Q u e u e * - * * - * Parameters: * - * * - * Creates a message queue. The message queue identifier object will be allocated* - * if the sci_msq_queue_t * msg pointer is NULL. The function will create a * - * remote connection. If this connection times out, the function shoud be * - * repeated until connection is established. SCILRemoveMsgQueue() must be called * - * to remove the connection and deallocate the message queue identifier. * - * * - * sci_msq_queue_t *msq : Message queue identifier * - * The function must be called with a null pointer * - * the first time. * - * unsigned int localAdapterNo: Local Adapter Number * - * unsigned int remoteNodeId : Remote nodeId * - * unsigned int msqId : Message queue number * - * unsigned int maxMsgCount : The maximum count of messages in queue * - * unsigned int maxMsgSize, : The maximum size of each messages in queue * - * unsigned int timeout : Time to wait for successful connection * - * unsigned int flags : Flags. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None. Normal SISIC error codes. * - * * - *********************************************************************************/ -#define SCILCreateMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILCreateMsgQueue) -DLL sci_error_t SCILCreateMsgQueue(sci_msq_queue_t *msq, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int msqId, - unsigned int maxMsgCount, - unsigned int maxMsgSize, - unsigned int timeout, - unsigned int flags); - - -/********************************************************************************* - * * - * S C I L R e c e i v e M s g * - * * - * * - * Receives a message from the queue. * - * * - * Paremeters * - * * - * sci_msq_queue_t msq : message queue identifier * - * void *msg : Location to store received data * - * unsigned int size : Size of message to read * - * unsigned int *sizeLeft: Bytes left in buffer, after current receive. This is * - * just a hint. There may be more. * - * * - * Flags * - * * - * SCIL_FLAG_ERROR_CHECK_PROT: The internal buffer management is done using full* - * error checking. - * * - * Specific error codes for this function: * - * * - * SCI_ERR_EWOULD_BLOCK : There is not enough data in the message buffer * - * to read the specified number of bytes. * - * . * - * SCI_ERR_NOT_CONNECTED : The connection is not established. * - * * - *********************************************************************************/ -#define SCILReceiveMsg _SCIL_EXPANDE_FUNCTION_NAME(SCILReceiveMsg) -DLL sci_error_t SCILReceiveMsg( - sci_msq_queue_t msq, - void *msg, - unsigned int size, - unsigned int *sizeLeft, - unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L S e n d M s g * - * * - * * - * Sends a message to the queue. * - * * - * Paremeters * - * * - * sci_msq_queue_t msq : Message queue identifier * - * void *msg : Send data * - * unsigned int size : Size of message to send * - * unsigned int *sizeFree: Bytes free in buffer, after current send. This is * - * just a hint. There may be more. * - * * - * Flags * - * * - * SCIL_FLAG_ERROR_CHECK_DATA: The data is transmitted using full error checking* - * SCIL_FLAG_ERROR_CHECK_PROT: The internal buffer management is done using full* - * error checking. * - * SCIL_FLSG_FULL_ERROR_CHECK: This flag is an combination of both above. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_EWOULD_BLOCK : There is not enough data in the message buffer * - * to send the specified number of bytes. * - * . * - * SCI_ERR_NOT_CONNECTED : The connection is not established. * - * * - *********************************************************************************/ -#define SCILSendMsg _SCIL_EXPANDE_FUNCTION_NAME(SCILSendMsg) -DLL sci_error_t SCILSendMsg( - sci_msq_queue_t msq, - void *msg, - unsigned int size, - unsigned int *sizeFree, - unsigned int flags); - - -/********************************************************************************* - * * - * S C I L R e m o v e M s g Q u e ue * - * * - * * - * Removes a message queue. * - * * - * sci_msq_queue_t msq : Message queue identifier * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCILRemoveMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILRemoveMsgQueue) -DLL sci_error_t SCILRemoveMsgQueue( - sci_msq_queue_t *msq, - unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L I n i t * - * * - * * - * Initializes the SCI library. This function must be called before any other * - * function in the library. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * . * - *********************************************************************************/ -#define SCILInit _SCIL_EXPANDE_FUNCTION_NAME(SCILInit) -DLL sci_error_t SCILInit(unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L D e s t r o y * - * * - * * - * Removes internal resources allocated by the SCI Library. No other library * - * function should be called after this function. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCILDestroy _SCIL_EXPANDE_FUNCTION_NAME(SCILDestroy) -DLL sci_error_t SCILDestroy(unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L C o n n e c t M s g Q u e u e * - * * - * * - * Makes a connection to a remote message queue. This must be done before * - * SCILSendMsg() is called. * - * * - * Parameters: * - * * - * sci_msq_queue_t *msq : Message queue identifier * - * unsigned int localAdapterNo: Local Adapter Number * - * unsigned int remoteNodeId : Remote nodeId * - * unsigned int msqId : Message queue number * - * unsigned int maxMsgCount : The maximum count of messages in queue * - * unsigned int maxMsgSize, : The maximum size of each messages in queue * - * unsigned int timeout : Time to wait for successful connection * - * unsigned int flags : Flags. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None. Normal SISIC error codes. * - * * - *********************************************************************************/ -#define SCILConnectMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILConnectMsgQueue) -DLL sci_error_t SCILConnectMsgQueue(sci_msq_queue_t *msq, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int rmsgId, - unsigned int maxMsgCount, - unsigned int maxMsgSize, - unsigned int timeout, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I L D i s c o n n e c t M s g Q u e u e * - * * - * * - * Disconnects from a remote message queue. * - * * - * Parameters: * - * * - * sci_msq_queue_t *msq : Message queue identifier * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCILDisconnectMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILDisconnectMsgQueue) -DLL sci_error_t SCILDisconnectMsgQueue(sci_msq_queue_t *msq, - unsigned int flags); - - - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - - - - - - - - - diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_api.h b/ndb/src/external/WIN32.x86/sci/include/sisci_api.h deleted file mode 100644 index 9f4a1ddffb3..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_api.h +++ /dev/null @@ -1,2217 +0,0 @@ -/* $Id: sisci_api.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ -/******************************************************************************* - * * - * Copyright (C) 1993 - 2001 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *******************************************************************************/ - -#ifndef _SISCI_API_H -#define _SISCI_API_H - -#include "sisci_types.h" -#include "sisci_error.h" - - -#ifdef WIN32 -#ifdef API_DLL -#define DLL __declspec(dllexport) -#elif CLIENT_DLL -#define DLL __declspec(dllimport) -#endif -#endif /* WIN32 */ - - -#ifndef DLL -#define DLL -#endif - -#if defined(_REENTRANT) -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_MT_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_MT_ ## name -#else -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_ST_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_ST_ ## name -#endif -#define _SISCI_EXPANDE_CONSTANT_NAME(name) _SISCI_PUBLIC_CONST_ ## name - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCI_FLAG_FIXED_INTNO _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_INTNO) -extern const unsigned int SCI_FLAG_FIXED_INTNO; - -#define SCI_FLAG_SHARED_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_INT) -extern const unsigned int SCI_FLAG_SHARED_INT; - -#define SCI_FLAG_COUNTING_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_COUNTING_INT) -extern const unsigned int SCI_FLAG_COUNTING_INT; - -#define SCI_FLAG_FIXED_MAP_ADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_MAP_ADDR) -extern const unsigned int SCI_FLAG_FIXED_MAP_ADDR; - -#define SCI_FLAG_READONLY_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READONLY_MAP) -extern const unsigned int SCI_FLAG_READONLY_MAP; - -#define SCI_FLAG_USE_CALLBACK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_USE_CALLBACK) -extern const unsigned int SCI_FLAG_USE_CALLBACK; - -#define SCI_FLAG_BLOCK_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_BLOCK_READ) -extern const unsigned int SCI_FLAG_BLOCK_READ; - -#define SCI_FLAG_THREAD_SAFE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_THREAD_SAFE) -extern const unsigned int SCI_FLAG_THREAD_SAFE; - -#define SCI_FLAG_ASYNCHRONOUS_CONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ASYNCHRONOUS_CONNECT) -extern const unsigned int SCI_FLAG_ASYNCHRONOUS_CONNECT; - -#define SCI_FLAG_EMPTY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_EMPTY) -extern const unsigned int SCI_FLAG_EMPTY; - -#define SCI_FLAG_PRIVATE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_PRIVATE) -extern const unsigned int SCI_FLAG_PRIVATE; - -#define SCI_FLAG_FORCE_DISCONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FORCE_DISCONNECT) -extern const unsigned int SCI_FLAG_FORCE_DISCONNECT; - -#define SCI_FLAG_NOTIFY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NOTIFY) -extern const unsigned int SCI_FLAG_NOTIFY; - -#define SCI_FLAG_DMA_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_READ) -extern const unsigned int SCI_FLAG_DMA_READ; - -#define SCI_FLAG_DMA_POST _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_POST) -extern const unsigned int SCI_FLAG_DMA_POST; - -#define SCI_FLAG_DMA_WAIT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_WAIT) -extern const unsigned int SCI_FLAG_DMA_WAIT; - -#define SCI_FLAG_DMA_RESET _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_RESET) -extern const unsigned int SCI_FLAG_DMA_RESET; - -#define SCI_FLAG_NO_FLUSH _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_FLUSH) -extern const unsigned int SCI_FLAG_NO_FLUSH; - -#define SCI_FLAG_NO_STORE_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_STORE_BARRIER) -extern const unsigned int SCI_FLAG_NO_STORE_BARRIER; - -#define SCI_FLAG_FAST_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FAST_BARRIER) -extern const unsigned int SCI_FLAG_FAST_BARRIER; - -#define SCI_FLAG_ERROR_CHECK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ERROR_CHECK) -extern const unsigned int SCI_FLAG_ERROR_CHECK; - -#define SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) -extern const unsigned int SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY; - -/* the FLUSH_CPU_BUFFERS_ONLY flag is for backwards compabillity only and should never be used */ -#define FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) - -#define SCI_FLAG_LOCK_OPERATION _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_LOCK_OPERATION) -extern const unsigned int SCI_FLAG_LOCK_OPERATION; - -#define SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP; - -#define SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP; - -#define SCI_FLAG_IO_MAP_IOSPACE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_IO_MAP_IOSPACE) -extern const unsigned int SCI_FLAG_IO_MAP_IOSPACE; - -#define SCI_FLAG_DMOVE_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMOVE_MAP) -extern const unsigned int SCI_FLAG_DMOVE_MAP; - -#define SCI_FLAG_WRITES_DISABLE_GATHER_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_WRITES_DISABLE_GATHER_MAP) -extern const unsigned int SCI_FLAG_WRITES_DISABLE_GATHER_MAP; - -#define SCI_FLAG_DISABLE_128_BYTES_PACKETS _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DISABLE_128_BYTES_PACKETS) -extern const unsigned int SCI_FLAG_DISABLE_128_BYTES_PACKETS; - -#define SCI_FLAG_SHARED_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_MAP) -extern const unsigned int SCI_FLAG_SHARED_MAP; - -#define SCI_FLAG_DMA_SOURCE_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_SOURCE_ONLY) -extern const unsigned int SCI_FLAG_DMA_SOURCE_ONLY; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT_MAP; - -#define SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP; - -#define SCI_FLAG_NO_MEMORY_LOOPBACK_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_MEMORY_LOOPBACK_MAP) -extern const unsigned int SCI_FLAG_NO_MEMORY_LOOPBACK_MAP; - -#if defined(OS_IS_LYNXOS) || defined(OS_IS_VXWORKS) -#define SCI_FLAG_WRITE_BACK_CACHE_MAP _SISCI_EXPANDE_CONSTANT_NAME(WRITE_BACK_CACHE_MAP) -extern const unsigned int SCI_FLAG_WRITE_BACK_CACHE_MAP; -#endif - -#define SCI_FLAG_DMA_PHDMA _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_PHDMA) -extern const unsigned int SCI_FLAG_DMA_PHDMA; - -/*********************************************************************************/ -/* GENERAL VALUES */ -/*********************************************************************************/ -#define SCI_LOCAL_HOST _SISCI_EXPANDE_CONSTANT_NAME(SCI_LOCAL_HOST) -extern const unsigned int SCI_LOCAL_HOST; - -#define SCI_INFINITE_TIMEOUT _SISCI_EXPANDE_CONSTANT_NAME(SCI_INFINITE_TIMEOUT) -extern const unsigned int SCI_INFINITE_TIMEOUT; - -/*********************************************************************************/ -/* GENERAL ERROR CODES */ -/* */ -/* SCI_ERR_ILLEGAL_FLAG - Illegal flag value. */ -/* SCI_ERR_FLAG_NOT_IMPLEMENTED - Flag legal but flag feature not implemented. */ -/* SCI_ERR_NOT_IMPLEMENTED - Function not implemented. */ -/* SCI_ERR_SYSTEM - A system error. Check errno. */ -/* SCI_ERR_NOSPC - Unable to allocate OS resources. */ -/* SCI_ERR_API_NOSPC - Unable to allocate API resources. */ -/* SCI_ERR_HW_NOSPC - Unable to allocate HW resources (Hardware) */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "ADAPTER" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_ADAPTERNO - Adapter number is legal but does not exist. */ -/* SCI_ERR_ILLEGAL_ADAPTERNO - Illegal local adapter number (i.e. outside */ -/* legal range). */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "NODEID" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_NODEID - The remote adapter identified by nodeId does */ -/* not respond, but the intermediate link(s) */ -/* seem(s) to be operational. */ -/* SCI_ERR_ILLEGAL_NODEID - Illegal NodeId. */ -/* */ -/*********************************************************************************/ - - - -/********************************************************************************* - * * - * S C I I N I T I A L I Z E * - * * - * This function initializes the SISCI library. * - * The function must be called before SCIOpen(). * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCIInitialize _SISCI_EXPANDE_FUNCTION_NAME(SCIInitialize) -DLL void SCIInitialize(unsigned int flags, - sci_error_t *error); -#if 0 -unsigned int __Internal_SISCI_version_var; -#endif - -/********************************************************************************* - * * - * S C I T E R M I N A T E * - * * - * This function terminates the SISCI library. * - * The function must be called after SCIClose(). * - * * - * * - *********************************************************************************/ -#define SCITerminate _SISCI_EXPANDE_FUNCTION_NAME(SCITerminate) -DLL void SCITerminate(void); - -/********************************************************************************* - * * - * S C I O P E N * - * * - * * - * Opens a SCI virtual device. * - * Caller must supply a pointer to a variable of type sci_desc_t to be * - * initialized. * - * * - * Flags * - * SCI_FLAG_THREAD_SAFE - Operations on resources associated with this * - * descriptor will be performed in a multithread-safe * - * manner. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INCONSISTENT_VERSIONS - Inconsistency between the SISCI library * - * and the SISCI driver versions. * - * * - * * - *********************************************************************************/ -#define SCIOpen _SISCI_EXPANDE_FUNCTION_NAME(SCIOpen) -DLL void SCIOpen(sci_desc_t *sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C L O S E * - * * - * This function closes an open SCI virtual device. * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - All resources are not deallocated. * - * * - *********************************************************************************/ -#define SCIClose _SISCI_EXPANDE_FUNCTION_NAME(SCIClose) -DLL void SCIClose(sci_desc_t sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S E G M E N T * - * * - * Connects to a remote shared memory segment located at with the * - * identifier . * - * The user may then call SCIMapRemoteSegment() to map shared memory * - * into user space. * - * * - * Flags * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_ASYNCHRONOUS_CONNECT * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_SEGMENT - Could not find the remote segment with the * - * given segmentId. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIConnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSegment) -DLL void SCIConnectSegment(sci_desc_t sd, - sci_remote_segment_t *segment, - unsigned int nodeId, - unsigned int segmentId, - unsigned int localAdapterNo, - sci_cb_remote_segment_t callback, - void *callbackArg, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T S E G M E N T * - * * - * Disconnects from the give mapped shared memory segment * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The segment is currently mapped or in use. * - * * - *********************************************************************************/ -#define SCIDisconnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectSegment) -DLL void SCIDisconnectSegment(sci_remote_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T R E M O T E S E G M E N T S I Z E * - * * - *********************************************************************************/ -#define SCIGetRemoteSegmentSize _SISCI_EXPANDE_FUNCTION_NAME(SCIGetRemoteSegmentSize) -DLL unsigned int SCIGetRemoteSegmentSize(sci_remote_segment_t segment); - - - -/********************************************************************************* - * * - * S C I W A I T F O R R E M O T E S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du * - * to a SCIDisconnectSegment() on the same * - * handle. The handle is invalid when this * - * error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForRemoteSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForRemoteSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForRemoteSegmentEvent( - sci_remote_segment_t segment, - sci_error_t *status, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P R E M O T E S E G M E N T * - * * - * This function is used to include a shared memory segment in the virtual * - * address space of the application. * - * * - * Flags: * - * * - * SCI_FLAG_SHARED_MAP - The low level physical map may be shared by * - * other applications. * - * * - * SCI_FLAG_FIXED_MAP_ADDR - Map at the suggested virtual address * - * SCI_FLAG_READONLY_MAP - The segment is mapped in read-only mode * - * SCI_FLAG_LOCK_OPERATION - Enable Lock operations (fetch and add) * - * SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP * - * - Enable aggressive prefetch with speculative * - * hold. * - * * - * SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP * - * - The PSB66 will prefetch 64 bytes. As soon * - * as the PCI read retry has been accepted, * - * the stream will change state to FREE, even * - * if less than 64 bytes were actually read. * - * * - * SCI_FLAG_IO_MAP_IOSPACE - Enable No Prefetch, no speculative hold. * - * * - * SCI_FLAG_DMOVE_MAP - Enable DMOVE packet type. The stream will be * - * set into FREE state immediately. * - * * - * SCI_FLAG_WRITES_DISABLE_GATHER_MAP * - * - Disable use of gather. * - * * - * SCI_FLAG_DISABLE_128_BYTES_PACKETS * - * - Disable use of 128-Byte packets * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an atomic "fetch-and-add-one" operation on * - * remote memory, but in addition an interrupt * - * will be generated if the target memory * - * location contained a "null value" before the * - * add operation was carried out. * - * The conditional interrupt flag must also be * - * specified in the SCIRegisterInterruptFlag() * - * function. * - * * - * SCI_FLAG_UNCONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an interrupt for the remote adapter * - * "in addition to" updating the corresponding * - * remote memory location with the data being * - * written. * - * The unconditional interrupt flag must also * - * be specified in the * - * SCIRegisterInterruptFlag() function. * - * * - * SCI_FLAG_WRITE_BACK_CACHE_MAP * - * - Enable cacheing of the mapped region. * - * Writes through this map will be written to a * - * write back cache, hence no remote SCI updates* - * until the cache line is flushed. The * - * application is responsible for the cache * - * flush operation. * - * The SCImemCopy() function will handle this * - * correctly by doing cache flushes internally. * - * This feature is architechture dependent and * - * not be available on all plattforms. * - * * - * SCI_FLAG_NO_MEMORY_LOOPBACK_MAP * - * - Forces a map to a remote segment located * - * in the local machine to be mapped using * - * SCI loopback. This is useful i.e. if you * - * want to use a regular map access to be * - * serialized with lock operations. * - * The default behaviour is to access a remte * - * segment located in the local machine as a * - * local MMU operation. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapRemoteSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapRemoteSegment) -DLL volatile void *SCIMapRemoteSegment( - sci_remote_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P L O C A L S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_FIXED_MAP_ADDR * - * SCI_FLAG_READONLY_MAP * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapLocalSegment) -DLL void *SCIMapLocalSegment(sci_local_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I U N M A P S E G M E N T * - * * - * This function unmaps pages of shared memory from the callers virtual * - * address space. * - * * - * Flags * - * None. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The map is currently in use. * - * * - *********************************************************************************/ -#define SCIUnmapSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIUnmapSegment) -DLL void SCIUnmapSegment(sci_map_t map, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E S E G M E N T * - * * - * Make the specified segment available for connections via the specified * - * adapter. If successful, the segment can be accessed from remote nodes * - * via the specified adapter. * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events * - * on this segment. * - * SCI_FLAG_EMPTY - No memory will be allocated for the segment. * - * SCI_FLAG_PRIVATE - The segment will be private meaning it will never * - * be any connections to it. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SEGMENTID_USED - The segment with this segmentId is already used * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * * - *********************************************************************************/ -#define SCICreateSegment _SISCI_EXPANDE_FUNCTION_NAME(SCICreateSegment) -DLL void SCICreateSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I W A I T F O R L O C A L S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du to a * - * SCIRemoveSegment() on the same handle. * - * The handle is invalid when this error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForLocalSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForLocalSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForLocalSegmentEvent( - sci_local_segment_t segment, - unsigned int *sourcenodeId, - unsigned int *localAdapterNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P R E P A R E S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_DMA_SOURCE_ONLY - The segment will be used as a source segment * - * for DMA operations. On some system types this * - * will enable the SISCI driver to use performance * - * improving features. * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIPrepareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIPrepareSegment) -DLL void SCIPrepareSegment(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E G M E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - Unable to remove the segment. The segment is currently * - * in use. * - * * - *********************************************************************************/ -#define SCIRemoveSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSegment) -DLL void SCIRemoveSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T A V A I L A B L E * - * * - * Flags * - * None. * - * * - * * - * SCI_ERR_SEGMENT_NOT_PREPARED - The segment has not been prepared for access * - * from this adapter. * - * SCI_ERR_ILLEGAL_OPERATION - The segment is created with the * - * SCI_FLAG_PRIVATE flag specified and * - * therefore has no segmentId. * - * * - *********************************************************************************/ -#define SCISetSegmentAvailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentAvailable) -DLL void SCISetSegmentAvailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T U N A V A I L A B L E * - * * - * Flags * - * * - * SCI_FLAG_FORCE_DISCONNECT * - * SCI_FLAG_NOTIFY * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * * - *********************************************************************************/ -#define SCISetSegmentUnavailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentUnavailable) -DLL void SCISetSegmentUnavailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E M A P S E Q U E N C E * - * * - * Flags: * - * * - * SCI_FLAG_FAST_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateMapSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICreateMapSequence) -DLL void SCICreateMapSequence(sci_map_t map, - sci_sequence_t *sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E Q U E N C E * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSequence) -DLL void SCIRemoveSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T A R T S E Q U E N C E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIStartSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIStartSequence) -DLL sci_sequence_status_t SCIStartSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I C H E C K S E Q U E N CE * - * * - * Flags * - * * - * SCI_FLAG_NO_FLUSH * - * SCI_FLAG_NO_STORE_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICheckSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICheckSequence) -DLL sci_sequence_status_t SCICheckSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T O R E B A R R I E R * - * * - * Flags * - * None. * - * * - * * - * * - *********************************************************************************/ -#define SCIStoreBarrier _SISCI_EXPANDE_FUNCTION_NAME(SCIStoreBarrier) -DLL void SCIStoreBarrier(sci_sequence_t sequence, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I F L U S H R E A D B U F F E R S * - * * - *********************************************************************************/ -#define SCIFlushReadBuffers _SISCI_EXPANDE_FUNCTION_NAME(SCIFlushReadBuffers) -DLL void SCIFlushReadBuffers(sci_sequence_t sequence); - - - - -/********************************************************************************* - * * - * S C I P R O B E N O D E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIProbeNode _SISCI_EXPANDE_FUNCTION_NAME(SCIProbeNode) -DLL int SCIProbeNode(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int nodeId, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIGetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCIGetCSRRegister) -DLL unsigned int SCIGetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCISetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCISetCSRRegister) -DLL void SCISetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I G E T L O C A L C S R * - * * - * SISCI Priveleged function * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIGetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCIGetLocalCSR) -DLL unsigned int SCIGetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T L O C A L C S R * - * * - * SISCI Priveleged function - * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCISetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCISetLocalCSR) -DLL void SCISetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A T T A C H P H Y S I C A L M E M O R Y * - * * - * SISCI Priveleged function * - * * - * Description: * - * * - * This function enables usage of physical devices and memory regions where the * - * Physical PCI bus address ( and mapped CPU address ) are already known. * - * The function will register the physical memory as a SISCI segment which can * - * be connected and mapped as a regular SISCI segment. * - * * - * Requirements: * - * * - * SCICreateSegment() with flag SCI_FLAG_EMPTY must have been called in advance * - * * - * Parameter description: * - * sci_ioaddr_t ioaddress : This is the address on the PCI bus that a PCI bus * - * master has to use to write to the specified memory * - * void * address : This is the (mapped) virtual address that the * - * application has to use to access the device. * - * This means that the device has to be mapped in * - * advance bye the devices own driver. * - * If the device is not to be accessed by the local * - * CPU, the address pointer shold be set to NULL * - * Flags * - * * - * None * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIAttachPhysicalMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachPhysicalMemory) -DLL void SCIAttachPhysicalMemory(sci_ioaddr_t ioaddress, - void *address, - unsigned int busNo, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I Q U E R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_QUERY - Unrecognized command. * - * * - *********************************************************************************/ -#define SCIQuery _SISCI_EXPANDE_FUNCTION_NAME(SCIQuery) -DLL void SCIQuery(unsigned int command, - void *data, - unsigned int flags, - sci_error_t *error); - - -/* MAJOR QUERY COMMANDS */ - -/* This command requires a pointer to a structure of type */ -/* "sci_query_string". The string will be filled in by the query. */ -#define SCI_Q_VENDORID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_VENDORID) -extern const unsigned int SCI_Q_VENDORID; - - -/* Same as for SCI_VENDOR_ID */ -#define SCI_Q_API _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_API) -extern const unsigned int SCI_Q_API; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_adapter" struct. */ -#define SCI_Q_ADAPTER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER) -extern const unsigned int SCI_Q_ADAPTER; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_system" struct. */ -#define SCI_Q_SYSTEM _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM) -extern const unsigned int SCI_Q_SYSTEM; - -#define SCI_Q_LOCAL_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT) -extern const unsigned int SCI_Q_LOCAL_SEGMENT; - -#define SCI_Q_REMOTE_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT) -extern const unsigned int SCI_Q_REMOTE_SEGMENT; - -#define SCI_Q_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP) -extern const unsigned int SCI_Q_MAP; - -typedef char* sci_semaphoreId_t; - -#ifdef WIN32 -struct _semaphoreid { - char *semaphoreName; -}; -#endif /*WIN32*/ - -typedef struct { - char *str; /* Pointer to a string of minimum "length" characters */ - unsigned int length; -} sci_query_string_t; - - -typedef struct { - unsigned int localAdapterNo; /* The adapter no. that the query concern. */ - unsigned int portNo; /* The SCI Link port number that the query concern. */ - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_adapter_t; - - -typedef struct { - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_system_t; - -typedef struct { - sci_local_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_local_segment_t; - -typedef struct { - sci_remote_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_remote_segment_t; - -typedef struct { - sci_map_t map; - unsigned int subcommand; - unsigned int data; -} sci_query_map_t; - -/* Minor query commands (sub-commands) for adapter specific information SCI_ADAPTER */ -#define SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_MTU _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_MTU) -extern const unsigned int SCI_Q_ADAPTER_DMA_MTU; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE; - -#define SCI_Q_ADAPTER_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NODEID) -extern const unsigned int SCI_Q_ADAPTER_NODEID; - -#define SCI_Q_ADAPTER_SERIAL_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SERIAL_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_SERIAL_NUMBER; - -#define SCI_Q_ADAPTER_CARD_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CARD_TYPE) -extern const unsigned int SCI_Q_ADAPTER_CARD_TYPE; - -#define SCI_Q_ADAPTER_NUMBER_OF_STREAMS _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER_OF_STREAMS) -extern const unsigned int SCI_Q_ADAPTER_NUMBER_OF_STREAMS; - -#define SCI_Q_ADAPTER_STREAM_BUFFER_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_STREAM_BUFFER_SIZE) -extern const unsigned int SCI_Q_ADAPTER_STREAM_BUFFER_SIZE; - -#define SCI_Q_ADAPTER_CONFIGURED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONFIGURED) -extern const unsigned int SCI_Q_ADAPTER_CONFIGURED; - -#define SCI_Q_ADAPTER_LINK_OPERATIONAL _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LINK_OPERATIONAL) -extern const unsigned int SCI_Q_ADAPTER_LINK_OPERATIONAL; - -#define SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK) -extern const unsigned int SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK; - -#define SCI_Q_ADAPTER_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_NUMBER; - -#define SCI_Q_ADAPTER_INSTANCE_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_INSTANCE_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_INSTANCE_NUMBER; - -#define SCI_Q_ADAPTER_FIRMWARE_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_FIRMWARE_OK) -extern const unsigned int SCI_Q_ADAPTER_FIRMWARE_OK; - -#define SCI_Q_ADAPTER_CONNECTED_TO_SWITCH _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_SWITCH) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_SWITCH; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER; - -#define SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT; - -#define SCI_Q_ADAPTER_ATT_PAGE_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_PAGE_SIZE) -extern const unsigned int SCI_Q_ADAPTER_ATT_PAGE_SIZE; - -#define SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES; - -#define SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES; - -#define SCI_Q_ADAPTER_PHYS_MEM_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MEM_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MEM_NODEID; - -#define SCI_Q_ADAPTER_PHYS_MBX_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MBX_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MBX_NODEID; - -#define SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID; - -#define SCI_Q_ADAPTER_SCI_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SCI_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_SCI_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_B_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_B_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_B_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_IO_BUS_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_IO_BUS_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_IO_BUS_FREQUENCY; - -/* Minor query commands (sub-commands) for adapter specific information SCI_SYSTEM */ -#define SCI_Q_SYSTEM_HOSTBRIDGE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_HOSTBRIDGE) -extern const unsigned int SCI_Q_SYSTEM_HOSTBRIDGE; - -#define SCI_Q_SYSTEM_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_POSTING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_POSTING_ENABLED; - -#define SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED; - -#define SCI_Q_LOCAL_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_LOCAL_SEGMENT_IOADDR; - -#define SCI_Q_REMOTE_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_REMOTE_SEGMENT_IOADDR; - -#define SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET; - -#define SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET; - -#define HOSTBRIDGE_NOT_AVAILABLE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_NOT_AVAILABLE) -extern const unsigned int HOSTBRIDGE_NOT_AVAILABLE; - -#define HOSTBRIDGE_UNKNOWN _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_UNKNOWN) -extern const unsigned int HOSTBRIDGE_UNKNOWN; - -#define HOSTBRIDGE_440FX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440FX) -extern const unsigned int HOSTBRIDGE_440FX; - -#define HOSTBRIDGE_440LX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440LX) -extern const unsigned int HOSTBRIDGE_440LX; - -#define HOSTBRIDGE_440BX_A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_A) -extern const unsigned int HOSTBRIDGE_440BX_A; - -#define HOSTBRIDGE_440BX_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_B) -extern const unsigned int HOSTBRIDGE_440BX_B; - -#define HOSTBRIDGE_440GX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440GX) -extern const unsigned int HOSTBRIDGE_440GX; - -#define HOSTBRIDGE_450KX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450KX) -extern const unsigned int HOSTBRIDGE_450KX; - -#define HOSTBRIDGE_430NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_430NX) -extern const unsigned int HOSTBRIDGE_430NX; - -#define HOSTBRIDGE_450NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX) -extern const unsigned int HOSTBRIDGE_450NX; - -#define HOSTBRIDGE_450NX_MICO _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_MICO) -extern const unsigned int HOSTBRIDGE_450NX_MICO; - -#define HOSTBRIDGE_450NX_PXB _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_PXB) -extern const unsigned int HOSTBRIDGE_450NX_PXB; - -#define HOSTBRIDGE_I810 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810) -extern const unsigned int HOSTBRIDGE_I810; - -#define HOSTBRIDGE_I810_DC100 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810_DC100) -extern const unsigned int HOSTBRIDGE_I810_DC100; - -#define HOSTBRIDGE_I810E _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810E) -extern const unsigned int HOSTBRIDGE_I810E; - -#define HOSTBRIDGE_I815 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I815) -extern const unsigned int HOSTBRIDGE_I815; - -#define HOSTBRIDGE_I840 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I840) -extern const unsigned int HOSTBRIDGE_I840; - -#define HOSTBRIDGE_I850 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I850) -extern const unsigned int HOSTBRIDGE_I850; - -#define HOSTBRIDGE_I860 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I860) -extern const unsigned int HOSTBRIDGE_I860; - -#define HOSTBRIDGE_INTEL_E7500 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_INTEL_E7500) -extern const unsigned int HOSTBRIDGE_INTEL_E7500; - -#define HOSTBRIDGE_VIA_KT133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KT133) -extern const unsigned int HOSTBRIDGE_VIA_KT133; - -#define HOSTBRIDGE_VIA_KX133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KX133) -extern const unsigned int HOSTBRIDGE_VIA_KX133; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_133A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_133A) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_133A; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_266 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_266) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_266; - -#define HOSTBRIDGE_AMD_760_MP _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_760_MP) -extern const unsigned int HOSTBRIDGE_AMD_760_MP; - -#define HOSTBRIDGE_AMD_HAMMER _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_HAMMER) -extern const unsigned int HOSTBRIDGE_AMD_HAMMER; - -#define HOSTBRIDGE_SERVERWORKS_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE; - -#define HOSTBRIDGE_SERVERWORKS_HE_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE_B) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE_B; - -#define HOSTBRIDGE_SERVERWORKS_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_HE; - -#define HOSTBRIDGE_SERVERWORKS_GC_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_WS _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_WS) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_WS; - -#define HOSTBRIDGE_SERVERWORKS_GC_SL _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_SL) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_SL; - - -#define HOSTBRIDGE_WRITE_POSTING_DISABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_DISABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_DISABLED; - -#define HOSTBRIDGE_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_ENABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_ENABLED; - - - - -/********************************************************************************* - * * - * S C I C R E A T E D M A Q U E U E * - * * - * Flags * - * * - * SCI_FLAG_DMA_PHDMA : Create physical DMA queue. Please note that this is an * - * priveleged operation. * - * * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCICreateDMAQueue) -DLL void SCICreateDMAQueue(sci_desc_t sd, - sci_dma_queue_t *dq, - unsigned int localAdapterNo, - unsigned int maxEntries, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Not allowed in this queue state. * - * * - *********************************************************************************/ -#define SCIRemoveDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveDMAQueue) -DLL void SCIRemoveDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I E N Q U E U E D M A T R A N S F E R * - * * - * Flags: * - * * - * SCI_FLAG_DMA_READ - The DMA will be remote --> local * - * (default is local --> remote) * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is larger * - * than the segment size or larger than max * - * DMA size. * - * SCI_ERR_MAX_ENTRIES - The DMA queue is full * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_SEGMENT_NOT_PREPARED - The local segment has not been prepared for * - * access from the adapter associated with the * - * queue. * - * SCI_ERR_SEGMENT_NOT_CONNECTED - The remote segment is not connected through * - * the adapter associated with the queue. * - *********************************************************************************/ -#define SCIEnqueueDMATransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIEnqueueDMATransfer) -DLL sci_dma_queue_state_t SCIEnqueueDMATransfer(sci_dma_queue_t dq, - sci_local_segment_t localSegment, - sci_remote_segment_t remoteSegment, - unsigned int localOffset, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P O S T D M A Q U E U E * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The end of the transfer will cause the callback * - * function to be invoked. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIPostDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIPostDMAQueue) -DLL void SCIPostDMAQueue(sci_dma_queue_t dq, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortDMAQueue) -DLL void SCIAbortDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I R E S E T D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIResetDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIResetDMAQueue) -DLL void SCIResetDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I D M A Q U E U E S T A T E * - * * - *********************************************************************************/ -#define SCIDMAQueueState _SISCI_EXPANDE_FUNCTION_NAME(SCIDMAQueueState) -DLL sci_dma_queue_state_t SCIDMAQueueState(sci_dma_queue_t dq); - - - -/********************************************************************************* - * * - * S C I W A I T F O R D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForDMAQueue) -DLL sci_dma_queue_state_t SCIWaitForDMAQueue(sci_dma_queue_t dq, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I P H D M A E N Q U E U E * - * * - * SISCI Priveleged function * - * * - * Flags * - * * - * SCI_FLAG_DMA_READ * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaEnqueue _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaEnqueue) -DLL void SCIphDmaEnqueue(sci_dma_queue_t dmaqueue, - unsigned int size, - sci_ioaddr_t localBusAddr, - unsigned int remote_nodeid, - unsigned int remote_highaddr, - unsigned int remote_lowaddr, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I P H D M A S T A R T * - * * - * Flags * - * * - * SCI_FLAG_DMA_WAIT * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_DMA_RESET * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaStart _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaStart) -DLL sci_dma_queue_state_t SCIphDmaStart(sci_dma_queue_t dmaqueue, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - -#ifdef WIN32 -/********************************************************************************* - * * - * S C I C R E A T E N A M E D I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateNamedInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateNamedInterrupt) -DLL void SCICreateNamedInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_semaphoreId_t semId, - sci_error_t *error); -#endif /*WIN32*/ - -/********************************************************************************* - * * - * S C I C R E A T E I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * SCI_FLAG_COUNTING_INT: This flag will enable counting interrupts. This means * - * that the number of trigged interrupts is equal to the * - * number of received interrupts. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateInterrupt) -DLL void SCICreateInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveInterrupt) -DLL void SCIRemoveInterrupt(sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I W A I T F O R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait was interrupted by a call to * - * SCIRemoveInterrupt. * - * The handle is invalid when this error code is returned.* - * * - *********************************************************************************/ -#define SCIWaitForInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForInterrupt) -DLL void SCIWaitForInterrupt(sci_local_interrupt_t interrupt, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_COUNTING_INT: This flag will enable counting interrupts. This means * - * that the number of trigged interrupts is equal to the * - * number of received interrupts. * - * if SCI_FLAG_COUNTING_INT is not used, the interface * - * guarentees that there always will be an remote * - * interrupt generated after the first and after the last* - * trigger. If interupts is triggered faster than the * - * remote interrupt handler can handle, interrupts may be* - * lost. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_INTNO - No such interrupt number. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIConnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectInterrupt) -DLL void SCIConnectInterrupt(sci_desc_t sd, - sci_remote_interrupt_t *interrupt, - unsigned int nodeId, - unsigned int localAdapterNo, - unsigned int interruptNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisconnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectInterrupt) -DLL void SCIDisconnectInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I T R I G G E R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCITriggerInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCITriggerInterrupt) -DLL void SCITriggerInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I R E G I S T E R I N T E R R U P T F L A G * - * * - * * - * This function register an "interrupt flag" that is identified as an unique * - * location within a local segment. If successful, the resulting interrupt * - * handle will have been associated with the specified local segment. * - * * - * It is up to the (remote) client(s) to set up an "interrupt mapping" for the * - * corresponding segment offset using either the * - * * - * - SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * * - * or the * - * * - * - SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP * - * * - * option to "SCIMapRemoteSegment()". - I.e. after having established a * - * connection to the corresponding segment. A trigger operation can then * - * be implemented using a store operation via the relevant "interrupt map". * - * * - * * - * * - * * - * * - * Flags: * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT - Triggering is to take place using * - * "conditional interrupts". * - * * - * * - * * - * Specific error codes for this function: * - * None. * - * * - *********************************************************************************/ -#define SCIRegisterInterruptFlag _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterInterruptFlag) -DLL void SCIRegisterInterruptFlag( - unsigned int localAdapterNo, - sci_local_interrupt_t *interrupt, - sci_local_segment_t segment, - unsigned int offset, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I E N A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * This function make sure that another HW interrupt will take place the next * - * time the corresponding interrupt flag is triggered by a * - * "conditional interrupt" operation. * - * * - * Default semantics: * - * * - * When successful, the client can rely on that the first subsequent trigger * - * operation will cause a HW interrupt and subsequently cause the client * - * handler function to be invoked. * - * * - * If an interrupt was triggered in parallell with the enable operation, then * - * the operation will fail (SCI_ERR_COND_INT_RACE_PROBLEM), and the client can * - * not rely on another trigger operation will lead to handler invocation. * - * Hence, any state checking normally associated with handling the * - * corresponding interrupt should take place before attempting to enable * - * again. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_COND_INT_RACE_PROBLEM - The enable operation failed because an * - * incomming trigger operation happened * - * concurrently. * - * * - *********************************************************************************/ -#define SCIEnableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIEnableConditionalInterrupt) -DLL void SCIEnableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I D I S A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * Prevent subsequent "conditional interrupt"trigger operations for * - * the specified interupt flag from causing HW interrupt and handler * - * invocations. * - * * - * * - * Default semantics: * - * * - * If successful, no subsequent HW interrupts will take place, but handler * - * invocations that have already been scheduled may still take place. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisableConditionalInterrupt) -DLL void SCIDisableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C O N D I T I O N A L I N T E R R U P T C O U N T E R * - * * - * * - * Returns a value that indicates the number of times this flag has * - * been trigged since the last time it was enabled or disabled. * - * Calling the SCIEnableConditionalInterrupt / SCIDisableConditionalInterrupt * - * functions will reset the counter value. * - * * - * Default semantics: * - * * - * If successful, the current trig count is returned in the * - * interruptTrigCounter parameter. * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OVERFLOW - The number of trig operations have exceeded the range * - * that can be counted. * - *********************************************************************************/ -#define SCIGetConditionalInterruptTrigCounter _SISCI_EXPANDE_FUNCTION_NAME(SCIGetConditionalInterruptTrigCounter) -DLL void SCIGetConditionalInterruptTrigCounter( - sci_local_interrupt_t interrupt, - unsigned int *interruptTrigCounter, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlock _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlock) -DLL void SCITransferBlock(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K A S Y N C * - * * - * Flags * - * * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_USE_CALLBACK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger than * - * the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlockAsync _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlockAsync) -DLL void SCITransferBlockAsync(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - sci_block_transfer_t *block, - sci_cb_block_transfer_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForBlockTransfer) -DLL void SCIWaitForBlockTransfer(sci_block_transfer_t block, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortBlockTransfer) -DLL void SCIAbortBlockTransfer(sci_block_transfer_t block, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M E M C P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - -#define SCIMemCpy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCpy) -DLL void SCIMemCpy(sci_sequence_t sequence, - void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I M E M C O P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - - -#define SCIMemCopy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCopy) -DLL void SCIMemCopy(void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E G I S T E R S E G M E N T M E M O R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_ILLEGAL_ADDRESS - Illegal address. * - * SCI_ERR_OUT_OF_RANGE - Size is larger than the maximum size for the * - * local segment. * - * * - *********************************************************************************/ -#define SCIRegisterSegmentMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterSegmentMemory) -DLL void SCIRegisterSegmentMemory(void *address, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S C I S P A C E * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * * - *********************************************************************************/ -#define SCIConnectSCISpace _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSCISpace) -DLL void SCIConnectSCISpace(sci_desc_t sd, - unsigned int localAdapterNo, - sci_remote_segment_t *segment, - sci_address_t address, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/* - * ===================================================================================== - * - * S C I A T T A C H L O C A L S E G M E N T - * Description: - * - * SCIAttachLocalSegment() permits an application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events - * on this segment. - * - * - * Specific error codes for this function: - * - * SCI_ERR_ACCESS - No such shared segment - * SCI_ERR_NO_SUCH_SEGMENT - No such segment - * Note: Current implenentation will return SCI_ERR_ACCESS for both cases. This will - * change from next release. Application should handle both cases. - * - * ===================================================================================== - */ -#define SCIAttachLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachLocalSegment) - -DLL void -SCIAttachLocalSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int *size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); -/* - * ===================================================================================== - * - * S C I S H A R E S E G M E N T - * - * Description: - * - * SCIShareSegment() permits other application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * none - * - * Specific error codes for this function: - * - * - * - * ===================================================================================== - */ -#define SCIShareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIShareSegment) - -DLL void -SCIShareSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I F L U S H * - * * - * This function will flush the CPU buffers and the PSB buffers. * - * * - * Flags * - * SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY : * - * Only flush CPU buffers ( Write combining * - * etc buffers). * - * * - *********************************************************************************/ - -#define SCIFlush _SISCI_EXPANDE_FUNCTION_NAME(SCIFlush) -DLL void SCIFlush(sci_sequence_t sequence, - unsigned int flags); - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - -#endif - - - - - - - - - - - diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_demolib.h b/ndb/src/external/WIN32.x86/sci/include/sisci_demolib.h deleted file mode 100644 index ce5bb2aec8e..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_demolib.h +++ /dev/null @@ -1,226 +0,0 @@ -/* $Id: sisci_demolib.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - -#ifndef _SISCI_DEMOLIB_H -#define _SISCI_DEMOLIB_H - - -#if defined(_REENTRANT) - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_MT_ ## name - -#else - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_ST_ ## name - -#endif - -/*********************************************************************************/ -/* Q U E R Y A D A P T E R */ -/* */ -/*********************************************************************************/ - -#define QueryAdapter _SISCI_DEMOLIB_EXPAND_NAME(QueryAdapter) - -sci_error_t QueryAdapter( - unsigned int subcommand, - unsigned int localAdapterNo, - unsigned int portNo, - unsigned int *data); - - -/*********************************************************************************/ -/* Q U E R Y S Y S T E M */ -/* */ -/*********************************************************************************/ - -#define QuerySystem _SISCI_DEMOLIB_EXPAND_NAME(QuerySystem) - -sci_error_t QuerySystem( - unsigned int subcommand, - unsigned int *data); - - -/*********************************************************************************/ -/* D E T E C T F I R S T A D A P T E R C A R D */ -/* */ -/*********************************************************************************/ - -#define DetectFirstAdapterCard _SISCI_DEMOLIB_EXPAND_NAME(DetectFirstAdapterCard) - -sci_error_t DetectFirstAdapterCard( - unsigned int *localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetAdapterType _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterType) - -sci_error_t GetAdapterType(unsigned int localAdapterNo, - unsigned int *adapterType); - - -/*********************************************************************************/ -/* G E T L O C A L N O D E I D */ -/* */ -/*********************************************************************************/ - -#define GetLocalNodeId _SISCI_DEMOLIB_EXPAND_NAME(GetLocalNodeId) - -sci_error_t GetLocalNodeId( - unsigned int localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R S E R I A L N U M B E R */ -/* */ -/*********************************************************************************/ - -#define GetAdapterSerialNumber _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterSerialNumber) - -sci_error_t GetAdapterSerialNumber( - unsigned int localAdapterNo, - unsigned int *serialNo); - - - -/*********************************************************************************/ -/* G E T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(GetHostbridgeType) - -sci_error_t GetHostbridgeType(unsigned int *hostbridgeType); - - - -/*********************************************************************************/ -/* P R I N T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define PrintHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(PrintHostbridgeType) - -void PrintHostbridgeType(unsigned int hostbridge); - - - -/*********************************************************************************/ -/* G E T A P I V E R S I O N S T R I N G */ -/* */ -/*********************************************************************************/ - -#define GetAPIVersionString _SISCI_DEMOLIB_EXPAND_NAME(GetAPIVersionString) - -sci_error_t GetAPIVersionString(char str[], unsigned int strLength); - - - -/*********************************************************************************/ -/* G E T A D A P T E R I O B U S F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterIoBusFrequency(unsigned int localAdapterNo, - unsigned int *ioBusFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R S C I L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterSciLinkFrequency(unsigned int localAdapterNo, - unsigned int *sciLinkFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R B L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterBlinkFrequency(unsigned int localAdapterNo, - unsigned int *bLinkFrequency); - - -/*********************************************************************************/ -/* S E N D I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define SendInterrupt _SISCI_DEMOLIB_EXPAND_NAME(SendInterrupt) - -sci_error_t SendInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int remoteNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* R E C E I V E I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define ReceiveInterrupt _SISCI_DEMOLIB_EXPAND_NAME(ReceiveInterrupt) - -sci_error_t ReceiveInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* E N D I A N S W A P */ -/* */ -/*********************************************************************************/ - -#define EndianSwap _SISCI_DEMOLIB_EXPAND_NAME(EndianSwap) - -unsigned int EndianSwap (unsigned int value); - - -/*********************************************************************************/ -/* S L E E P M I L L I S E C O N D S */ -/* */ -/*********************************************************************************/ - -#define SleepMilliseconds _SISCI_DEMOLIB_EXPAND_NAME(SleepMilliseconds) - -void SleepMilliseconds(int milliseconds); - - - - -#endif diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_error.h b/ndb/src/external/WIN32.x86/sci/include/sisci_error.h deleted file mode 100644 index 56fa0d18b3a..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_error.h +++ /dev/null @@ -1,94 +0,0 @@ -/* $Id: sisci_error.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - - - -#ifndef _SISCI_ERROR_H_ -#define _SISCI_ERROR_H_ - - -/* SCI Error return values always have 30 bit set */ -#define SCI_ERR_MASK 0x40000000 -#define SCI_ERR_REMOTE_MASK 0x01 /* Remote errors should have bit 0 set */ - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) - -/* Error codes */ -typedef enum { - SCI_ERR_OK = 0x000, - - - SCI_ERR_BUSY = (0x900 | SCI_ERR_MASK), - SCI_ERR_FLAG_NOT_IMPLEMENTED = (0x901 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_FLAG = (0x902 | SCI_ERR_MASK), - SCI_ERR_NOSPC = (0x904 | SCI_ERR_MASK), - SCI_ERR_API_NOSPC = (0x905 | SCI_ERR_MASK), - SCI_ERR_HW_NOSPC = (0x906 | SCI_ERR_MASK), - SCI_ERR_NOT_IMPLEMENTED = (0x907 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADAPTERNO = (0x908 | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_ADAPTERNO = (0x909 | SCI_ERR_MASK), - SCI_ERR_TIMEOUT = (0x90A | SCI_ERR_MASK), - SCI_ERR_OUT_OF_RANGE = (0x90B | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_SEGMENT = (0x90C | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_NODEID = (0x90D | SCI_ERR_MASK), - SCI_ERR_CONNECTION_REFUSED = (0x90E | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_CONNECTED = (0x90F | SCI_ERR_MASK), - SCI_ERR_SIZE_ALIGNMENT = (0x910 | SCI_ERR_MASK), - SCI_ERR_OFFSET_ALIGNMENT = (0x911 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_PARAMETER = (0x912 | SCI_ERR_MASK), - SCI_ERR_MAX_ENTRIES = (0x913 | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_PREPARED = (0x914 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADDRESS = (0x915 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_OPERATION = (0x916 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_QUERY = (0x917 | SCI_ERR_MASK), - SCI_ERR_SEGMENTID_USED = (0x918 | SCI_ERR_MASK), - SCI_ERR_SYSTEM = (0x919 | SCI_ERR_MASK), - SCI_ERR_CANCELLED = (0x91A | SCI_ERR_MASK), - SCI_ERR_NOT_CONNECTED = (0x91B | SCI_ERR_MASK), - SCI_ERR_NOT_AVAILABLE = (0x91C | SCI_ERR_MASK), - SCI_ERR_INCONSISTENT_VERSIONS = (0x91D | SCI_ERR_MASK), - SCI_ERR_COND_INT_RACE_PROBLEM = (0x91E | SCI_ERR_MASK), - SCI_ERR_OVERFLOW = (0x91F | SCI_ERR_MASK), - SCI_ERR_NOT_INITIALIZED = (0x920 | SCI_ERR_MASK), - - SCI_ERR_ACCESS = (0x921 | SCI_ERR_MASK), - - SCI_ERR_NO_SUCH_NODEID = (0xA00 | SCI_ERR_MASK), - SCI_ERR_NODE_NOT_RESPONDING = (0xA02 | SCI_ERR_MASK), - SCI_ERR_NO_REMOTE_LINK_ACCESS = (0xA04 | SCI_ERR_MASK), - SCI_ERR_NO_LINK_ACCESS = (0xA05 | SCI_ERR_MASK), - SCI_ERR_TRANSFER_FAILED = (0xA06 | SCI_ERR_MASK), - - SCI_ERR_EWOULD_BLOCK = ( 0xB00 | SCI_ERR_MASK), - SCI_ERR_SEMAPHORE_COUNT_EXCEEDED = ( 0xB01 | SCI_ERR_MASK), - SCI_ERR_IRQL_ILLEGAL = ( 0xB02 | SCI_ERR_MASK) - -} sci_error_t; - - -#endif /* _SCI_ERROR_H_ */ - - - diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_types.h b/ndb/src/external/WIN32.x86/sci/include/sisci_types.h deleted file mode 100644 index 03e7957c3f2..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_types.h +++ /dev/null @@ -1,133 +0,0 @@ -/* $Id: sisci_types.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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. * - * * - * * - *******************************************************************************/ - - -#ifndef _SISCI_TYPES_H -#define _SISCI_TYPES_H - -#include "sisci_error.h" - -#ifndef IN -#define IN -#endif - -#ifndef OUT -#define OUT -#endif - -#ifndef IN_OUT -#define IN_OUT -#endif - -/* Opaque data types for descriptors/handles */ -typedef struct sci_desc *sci_desc_t; -typedef struct sci_local_segment *sci_local_segment_t; -typedef struct sci_remote_segment *sci_remote_segment_t; - -typedef struct sci_map *sci_map_t; -typedef struct sci_sequence *sci_sequence_t; -#ifndef KERNEL -typedef struct sci_dma_queue *sci_dma_queue_t; -#endif -typedef struct sci_remote_interrupt *sci_remote_interrupt_t; -typedef struct sci_local_interrupt *sci_local_interrupt_t; -typedef struct sci_block_transfer *sci_block_transfer_t; - -/* - * Constants defining reasons for segment callbacks: - */ - -typedef enum { - SCI_CB_CONNECT = 1, - SCI_CB_DISCONNECT, - SCI_CB_NOT_OPERATIONAL, - SCI_CB_OPERATIONAL, - SCI_CB_LOST -} sci_segment_cb_reason_t; - -#define MAX_CB_REASON SCI_CB_LOST - -/* dma_queue_states is identical to the dma_queue_state_t in genif.h, they must be consistent.*/ -typedef enum { - SCI_DMAQUEUE_IDLE, - SCI_DMAQUEUE_GATHER, - SCI_DMAQUEUE_POSTED, - SCI_DMAQUEUE_DONE, - SCI_DMAQUEUE_ABORTED, - SCI_DMAQUEUE_ERROR -} sci_dma_queue_state_t; - - -typedef enum { - SCI_SEQ_OK, - SCI_SEQ_RETRIABLE, - SCI_SEQ_NOT_RETRIABLE, - SCI_SEQ_PENDING -} sci_sequence_status_t; - - -typedef struct { - unsigned short nodeId; /* SCI Address bit 63 - 48 */ - unsigned short offsHi; /* SCI Address bit 47 - 32 */ - unsigned int offsLo; /* SCI Address bit 31 - 0 */ -} sci_address_t; - - -typedef unsigned int sci_ioaddr_t; - -typedef enum { - SCI_CALLBACK_CANCEL = 1, - SCI_CALLBACK_CONTINUE -} sci_callback_action_t; - -#ifndef KERNEL -typedef sci_callback_action_t (*sci_cb_local_segment_t)(void *arg, - sci_local_segment_t segment, - sci_segment_cb_reason_t reason, - unsigned int nodeId, - unsigned int localAdapterNo, - sci_error_t error); - -typedef sci_callback_action_t (*sci_cb_remote_segment_t)(void *arg, - sci_remote_segment_t segment, - sci_segment_cb_reason_t reason, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_dma_t)(void IN *arg, - sci_dma_queue_t queue, - sci_error_t status); - - -typedef int (*sci_cb_block_transfer_t)(void *arg, - sci_block_transfer_t block, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_interrupt_t)(void *arg, - sci_local_interrupt_t interrupt, - sci_error_t status); - -#endif /* KERNEL */ -#endif diff --git a/ndb/test/odbc/tpcb/Makefile b/ndb/test/odbc/tpcb/Makefile deleted file mode 100644 index 8ab429c8ea1..00000000000 --- a/ndb/test/odbc/tpcb/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -include .defs.mk - -TYPE = * - -BIN_TARGET = tpcb - -SOURCES = ttTime.c tpcb.cpp - -CCFLAGS_LOC += \ - -I$(NDB_TOP)/include \ - -I$(NDB_TOP)/include/ndbapi \ - -I$(NDB_TOP)/include/portlib \ - -I$(NDB_TOP)/include/util \ - -I$(NDB_TOP)/test/include \ - -I/usr/local/include - -CCFLAGS_WARNINGS += -Wno-unused -Wno-sign-compare -Wformat - -CCFLAGS_TOP += -DndbODBC - -BIN_TARGET_LIBS = NDB_API_pic NDB_ODBC_pic NDBT - -ifeq ($(NDB_OS),SOLARIS) -BIN_TARGET_LIBS += dmallocthcxx -CCFLAGS_TOP += -DDMALLOC -endif - -include $(NDB_TOP)/Epilogue.mk - -$(BIN_DIR)$(BIN_TARGET): Makefile diff --git a/ndb/test/odbc/tpcb/Makefile_mysql b/ndb/test/odbc/tpcb/Makefile_mysql deleted file mode 100644 index 4e1b9a25fe2..00000000000 --- a/ndb/test/odbc/tpcb/Makefile_mysql +++ /dev/null @@ -1,33 +0,0 @@ -include $(NDB_TOP)/Defs.mk - -TYPE = odbcclient - -BIN_TARGET = tpcb - -SOURCES = ttTime.c tpcb.cpp - -CCFLAGS_LOC += -I/usr/local/include \ - -I$(NDB_TOP)/test/include \ - -I$(NDB_TOP)/include \ - -I$(NDB_TOP)/include/util \ - -I$(NDB_TOP)/src/client/odbc/common - - - - -#CCFLAGS_WARNINGS += -Wno-unused - -LIBS_LOC += -L/usr/local/lib -BIN_TARGET_LIBS_DIRS += /usr/local/lib -BIN_TARGET_LIBS += odbc odbcinst - -#LIBS_SPEC += -pg -# -lNDBT \ -# -lodbc \ -# -lodbcinst \ -# -lportlib - - - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/test/odbc/tpcb/Makefile_ndb b/ndb/test/odbc/tpcb/Makefile_ndb deleted file mode 100644 index 85960413ef0..00000000000 --- a/ndb/test/odbc/tpcb/Makefile_ndb +++ /dev/null @@ -1,30 +0,0 @@ -include $(NDB_TOP)/Defs.mk - -TYPE = * - -BIN_TARGET = tpcb - -SOURCES = ttTime.c tpcb.cpp - -CCFLAGS_LOC += \ - -I$(NDB_TOP)/include \ - -I$(NDB_TOP)/include/ndbapi \ - -I$(NDB_TOP)/include/portlib \ - -I$(NDB_TOP)/include/util \ - -I$(NDB_TOP)/test/include \ - -I/usr/local/include - -CCFLAGS_WARNINGS += -Wno-unused -Wno-sign-compare -Wformat - -CCFLAGS_TOP += -DndbODBC - -BIN_TARGET_LIBS = NDB_API_pic NDB_ODBC_pic NDBT - -ifeq ($(NDB_OS),SOLARIS) -BIN_TARGET_LIBS += dmallocthcxx -CCFLAGS_TOP += -DDMALLOC -endif - -include $(NDB_TOP)/Epilogue.mk - -$(BIN_DIR)$(BIN_TARGET): Makefile diff --git a/ndb/test/odbc/tpcb/readme.txt b/ndb/test/odbc/tpcb/readme.txt deleted file mode 100644 index 008cafb9d2f..00000000000 --- a/ndb/test/odbc/tpcb/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ -'tpcb' requires an .odbc.ini file in -/etc/ -or in -/home/user/ - -The .odbc.ini file must contain a DSN entry called ndb: - -#--------- .odbc.ini example -------------------- - -[ndb] -Driver = /path_to_installation/lib/libNDB_ODBC.so - -#--------- End of example ----------------------- - - diff --git a/ndb/test/odbc/tpcb/timesten.h b/ndb/test/odbc/tpcb/timesten.h deleted file mode 100644 index 45579f9d277..00000000000 --- a/ndb/test/odbc/tpcb/timesten.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2003 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 */ - -/* - * $Revision: 1.1 $ - * (c) Copyright 1997-2003, TimesTen, Inc. - * All rights reserved. - */ - -#ifndef TIMESTEN_H_INCLUDED -#define TIMESTEN_H_INCLUDED - -#ifdef _WIN32 -#include -#endif - -#include -#include -#include -/* - * TimesTen extension to application data types; only usable - * when application directly linked to the TimesTen driver. - */ -#define SQL_C_ADDR 100 - -#ifndef SQL_C_SBIGINT -#if (ODBCVER < 0x0300) -#define SQL_C_SBIGINT (SQL_BIGINT+SQL_SIGNED_OFFSET) -#define SQL_C_UBIGINT (SQL_BIGINT+SQL_UNSIGNED_OFFSET) -#endif -#endif - -#define SQL_C_BIGINT SQL_C_SBIGINT - -#if (ODBCVER < 0x0300) -#ifdef _WIN32 -typedef __int64 SQLBIGINT; -/* On Unix platforms SQLBIGINT is defined in odbcinclude directory*/ -#endif -#endif - -#define BIGINT SQLBIGINT - -#ifdef _WIN32 -#define UBIGINT unsigned __int64 -#else -#define UBIGINT unsigned long long -#endif - - -#define SQL_WCHAR (-8) -#define SQL_WVARCHAR (-9) -#define SQL_WLONGVARCHAR (-10) -#define SQL_C_WCHAR SQL_WCHAR - -/* SQLGetInfo() InfoTypes */ -#define SQL_CONVERT_WCHAR 122 -#define SQL_CONVERT_WLONGVARCHAR 125 -#define SQL_CONVERT_WVARCHAR 126 - -/* TimesTen specific SQLGetInfo types */ -#define TT_REPLICATION_INVALID (SQL_INFO_DRIVER_START + 2000) - -/* SQLGetInfo() return value bitmasks */ -#ifndef SQL_CVT_WCHAR -/* -** These definitions differ from Microsoft in that they are not -** specified as long (e.g. 0x00200000L), hence they are protected -** by the ifndef above. -*/ -#define SQL_CVT_WCHAR 0x00200000 -#define SQL_CVT_WLONGVARCHAR 0x00400000 -#define SQL_CVT_WVARCHAR 0x00800000 -#endif - -/* -** The Microsoft Driver Manager SQLBindParameter() will not pass SQL_WCHAR -** through. Use this hack to get around it. -*/ -#define SQL_WCHAR_DM_SQLBINDPARAMETER_BYPASS -888 - -/* This is an extension to ODBC's isolation levels. It reflects an - * earlier implementation of read-committed that released locks on - * next fetch, rather than releasing locks before returning value to - * application. */ -#define SQL_TXN_CURSOR_STABILITY 0x00001000 -#define SQL_TXN_NOBLOCK_DELETE 0x00002000 - -/* TimesTen-specific connection option */ -#define TT_PREFETCH_CLOSE 10001 -#define TT_PREFETCH_CLOSE_OFF 0 -#define TT_PREFETCH_CLOSE_ON 1 - -/* Adding a new sql connection option */ -#define TT_PREFETCH_COUNT 10003 -#define TT_PREFETCH_COUNT_MAX 128 - -/* - * Platform specific data types for integers that scale - * with pointer size - */ - -#ifdef _IA64_ -typedef signed __int64 tt_ptrint; -typedef unsigned __int64 tt_uptrint; -#else -#ifdef _WIN32 -typedef signed long tt_ptrint; -typedef unsigned long tt_uptrint; -#else -typedef signed long tt_ptrint; -typedef unsigned long tt_uptrint; -#endif -#endif - -#ifdef _WIN32 -typedef signed __int64 tt_int8; -typedef unsigned __int64 tt_uint8; -#else -typedef signed long long tt_int8; -typedef unsigned long long tt_uint8; -#endif - -/* printf formats for pointer-sized integers */ -#ifdef _IA64_ /* 64-bit NT */ -#define PTRINT_FMT "I64d" -#define UPTRINT_FMT "I64u" -#define xPTRINT_FMT "I64x" -#define XPTRINT_FMT "I64X" -#else -#ifdef _WIN32 /* 32-bit NT */ -#define PTRINT_FMT "ld" -#define UPTRINT_FMT "lu" -#define xPTRINT_FMT "lx" -#define XPTRINT_FMT "lX" -#else /* 32 and 64-bit UNIX */ -#define PTRINT_FMT "ld" -#define UPTRINT_FMT "lu" -#define xPTRINT_FMT "lx" -#define XPTRINT_FMT "lX" -#endif -#endif - -/* printf formats for 8-byte integers */ -#ifndef INT8_FMT_DEFINED -#ifdef _WIN32 /* 32 and 64-bit NT */ -#define INT8_FMT "I64d" -#define UINT8_FMT "I64u" -#define xINT8_FMT "I64x" -#define XINT8_FMT "I64X" -#else /* 32 and 64-bit UNIX */ -#define INT8_FMT "lld" -#define UINT8_FMT "llu" -#define xINT8_FMT "llx" -#define XINT8_FMT "llX" -#endif -#define INT8_FMT_DEFINED 1 -#endif - -/* The following types are defined in the newer odbc include files - from Microsoft -*/ -#if defined (_WIN32) && !defined (_IA64_) -#ifndef SQLROWSETSIZE -#define SQLROWSETSIZE SQLUINTEGER -#define SQLLEN SQLINTEGER -#define SQLROWOFFSET SQLINTEGER -#define SQLROWCOUNT SQLUINTEGER -#define SQLULEN SQLUINTEGER -#define SQLSETPOSIROW SQLUSMALLINT -#endif -#endif - - -#endif diff --git a/ndb/test/odbc/tpcb/tpcb.cpp b/ndb/test/odbc/tpcb/tpcb.cpp deleted file mode 100644 index 60d746e7844..00000000000 --- a/ndb/test/odbc/tpcb/tpcb.cpp +++ /dev/null @@ -1,1415 +0,0 @@ -/* Copyright (C) 2003 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 */ - -static const volatile char cvsid[] = "$Id: tpcb.cpp,v 1.4 2003/09/26 09:04:34 johan Exp $"; -/* - * $Revision: 1.4 $ - * (c) Copyright 1996-2003, TimesTen, Inc. - * All rights reserved. - */ - -/* This source is best displayed with a tabstop of 4 */ - -#define NDB - -//#define MYSQL - -#ifdef WIN32 -#include -#include "ttRand.h" -#else -#if !defined NDB && !defined MYSQL -#include -#endif -#include -#include -#include -#ifdef SB_P_OS_CHORUS -#include "ttRand.h" -#endif -#endif - -#include -#include -#include -#include -#include -#include - -#if !defined NDB && !defined MYSQL -#include "ttTime.h" -#include "utils.h" -#include "tt_version.h" -#include "timesten.h" -#endif - -#if defined NDB || defined MYSQL -#include -#include - -#include -#include -extern "C" { -#include "ttTime.h" -#include "timesten.h" - void ttGetWallClockTime(ttWallClockTime* timeP); - void ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP); - void ttGetThreadTimes(ttThreadTimes * endRes); - void ttCalcElapsedThreadTimes(ttThreadTimes* startRes, - ttThreadTimes * endRes, - double * kernel, - double * user); -} - -#define app_exit exit -#define status_msg0 ndbout_c -#define status_msg1 ndbout_c -#define status_msg2 ndbout_c -#define err_msg0 ndbout_c -#define err_msg1 ndbout_c -#define err_msg3 ndbout_c -#define out_msg0 ndbout_c -#define out_msg1 ndbout_c -#define out_msg3 ndbout_c -#define CONN_STR_LEN 255 -#define DBMS_TIMESTEN 1 -#define DBMS_MSSQL 2 -#define DBMS_UNKNOWN 3 -#define ABORT_DISCONNECT_EXIT 1 -#define NO_EXIT 0 -#define ERROR_EXIT 1 -#define DISCONNECT_EXIT 2 -#endif - -#define VERBOSE_NOMSGS 0 -/* this value is used for results (and err msgs) only */ -#define VERBOSE_RESULTS 1 -/* this value is the default for the cmdline demo */ -#define VERBOSE_DFLT 2 -#define VERBOSE_ALL 3 - -#ifdef MYSQL -#define DSNNAME "DSN=myodbc3" -#elif defined NDB -#define DSNNAME "DSN=ndb" -#else -#define DSNNAME "DSN=" -#endif - -/* number of branches, tellers, and accounts */ - -#define NumBranches 1 -#define TellersPerBranch 10 -#define AccountsPerBranch 10000 - -/* number of transactions to execute */ - -#define NumXacts 25000 - -/* starting seed value for the random number generator */ - -#define SeedVal 84773 - -/* for MS SQL, the drop, create and use database statements */ - -#define DatabaseDropStmt "drop database tpcbDB;" -#ifdef MYSQL -#define DatabaseCreateStmt "create database tpcbDB;" -#else -#define DatabaseCreateStmt "create database tpcbDB ON DEFAULT = %d;" -#endif -#define DatabaseUseStmt "use tpcbDB;" - -/* - * Specifications of table columns. - * Fillers of 80, 80, 84, and 24 bytes, respectively, are used - * to ensure that rows are the width required by the benchmark. - * - * Note: The TimesTen and MS SQL CREATE TABLE statements for the - * accounts, tellers and branches tables are different. - * - */ - -#define TuplesPerPage 256 - - -#ifdef MYSQL - -#define AccountCrTblStmt "create table accounts \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80));" - -#define TellerCrTblStmt "create table tellers \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80));" - -#define BranchCrTblStmt "create table branches \ -(number integer not null primary key, \ -balance float not null, \ -filler char(84));" - -#endif - - -#ifdef NDB -#define AccountCrTblStmt "create table accounts \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80)) nologging" - -#define TellerCrTblStmt "create table tellers \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80)) nologging" - -#define BranchCrTblStmt "create table branches \ -(number integer not null primary key, \ -balance float not null, \ -filler char(84)) nologging" -#endif - -#ifdef NDB - -#define HistoryCrTblStmt "create table History \ -(tellernum integer not null, \ -branchnum integer not null, \ -accountnum integer not null, \ -delta float not null, \ -createtime integer not null, \ -filler char(24), \ -primary key (tellernum, branchnum, accountnum, delta, createtime)) nologging" - -#else - -#ifdef MYSQL - -#define HistoryCrTblStmt "create table History \ -(tellernum integer not null, \ -branchnum integer not null, \ -accountnum integer not null, \ -delta float(53) not null, \ -createtime integer not null, \ -filler char(24))" -#endif - -#define HistoryCrTblStmt "create table History \ -(tellernum integer not null, \ -branchnum integer not null, \ -accountnum integer not null, \ -delta float(53) not null, \ -createtime integer not null, \ -filler char(24));" -#endif - -#define TTAccountCrTblStmt "create table accounts \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float(53) not null, \ -filler char(80)) unique hash on (number) pages = %" PTRINT_FMT ";" - -#define TTTellerCrTblStmt "create table tellers \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float(53) not null, \ -filler char(80)) unique hash on (number) pages = %" PTRINT_FMT ";" - -#define TTBranchCrTblStmt "create table branches \ -(number integer not null primary key, \ -balance float(53) not null, \ -filler char(84)) unique hash on (number) pages = %" PTRINT_FMT ";" - - -/* Insertion statements used to populate the tables */ - -#define NumInsStmts 3 -char* insStmt[NumInsStmts] = { - "insert into branches values (?, 0.0, NULL)", - "insert into tellers values (?, ?, 0.0, NULL)", - "insert into accounts values (?, ?, 0.0, NULL)" -}; - -/* Transaction statements used to update the tables */ - -#define NumXactStmts 5 - -#ifdef NDB -char* tpcbXactStmt[NumXactStmts] = { - "update accounts \ -set balance = balance + ? \ -where number = ?", - - "select balance \ -from accounts \ -where number = ?", - - "update tellers \ -set balance = balance + ? \ -where number = ?", - - "update branches \ -set balance = balance + ? \ -where number = ?", - - "insert into History(tellernum, branchnum, \ -accountnum, delta, createtime, filler) \ -values (?, ?, ?, ?, ?, NULL)" -}; - -#else -char* tpcbXactStmt[NumXactStmts] = { - "update accounts \ -set balance = balance + ? \ -where number = ?;", - - "select balance \ -from accounts \ -where number = ?;", - - "update tellers \ -set balance = balance + ? \ -where number = ?;", - - "update branches \ -set balance = balance + ? \ -where number = ?;", - - "insert into History \ -values (?, ?, ?, ?, ?, NULL);" -}; - - -#endif - -/* Global parameters and flags (typically set by parse_args()) */ - -int tabFlag = 0; /* Default is NOT tab output mode */ -char szConnStrIn[CONN_STR_LEN]; /* ODBC Connection String */ -int printXactTimes = 0; /* Transaction statistics - * gathering flag */ -char statFile[FILENAME_MAX]; /* Transaction statistics filename */ -int scaleFactor = 2; /* Default TPS scale factor */ -int numBranchTups; /* Number of branches */ -int numTellerTups; /* Number of tellers */ -int numAccountTups; /* Number of accounts */ -int numNonLocalAccountTups; /* Number of local accounts */ -int numXacts = NumXacts; /* Default number of transactions */ -int verbose = VERBOSE_DFLT; /* Verbose level */ -FILE *statusfp; /* File for status messages */ - - - -int DBMSType; /* DBMS type (DBMS_TIMESTEN, DBMS_MSSQL...) */ - - -SQLHENV henv; /* Environment handle */ - - - - - - - -void handle_errors( SQLHDBC hdbc, SQLHSTMT hstmt, int errcode, int action, char * msg, - char * file, int line) { - - if (errcode == SQL_SUCCESS) - return; - - if(errcode == SQL_ERROR) { - int ret; - long diagCount=0; - short length=0; - SQLCHAR state[10] = ""; - SQLCHAR message[200] = ""; - long native = 0; - if(hstmt != 0) { - ret = SQLGetDiagField(SQL_HANDLE_STMT, hstmt, 0, SQL_DIAG_NUMBER, &diagCount, SQL_IS_INTEGER, 0); - - for(long i = 0; i < diagCount; i++) { - ret = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, (SQLCHAR*)state, &native, (SQLCHAR*)message, 200, &length); - ndbout_c("GetDiagRec: Message : %s ", message); - } - } - } - - if(errcode != SQL_SUCCESS) { - ndbout_c("Message: %s", msg); - switch(errcode) { - case SQL_SUCCESS_WITH_INFO: - ndbout_c("SQL_SUCCESS_WITH_INFO"); - break; - case SQL_STILL_EXECUTING: - ndbout_c("SQL_STILL_EXECUTING"); - break; - case SQL_ERROR: - ndbout_c("SQL_ERROR"); - break; - case SQL_INVALID_HANDLE: - ndbout_c("SQL_INVALID_HANDLE"); - break; - default: - ndbout_c("Some other error"); - } - exit(1); - } - - -} - - - - - -/********************************************************************* - * FUNCTION: usage - * - * DESCRIPTION: This function prints a usage message describing - * the command line options of the program. - * - * PARAMETERS: char* prog full program path name - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -static void usage(char *prog) -{ - char *progname; - - /* Get the name of the program (sans path). */ - -#ifdef WIN32 - progname = strrchr(prog, '\\'); -#else - progname = strrchr(prog, '/'); -#endif - if (progname == 0) - progname = prog; - else - ++progname; - - /* Print the usage message */ - - fprintf(stderr, - "Usage:\t%s [-h] [-help] [-V] [-connStr ] [-v ]\n" - "\t\t[-xact ] [-scale ] [-tabs] [-s ]\n\n" - " -h Prints this message and exits.\n" - " -help Same as -h.\n" - " -V Prints version number and exits.\n" - " -connStr Specifies an ODBC connection string to replace the\n" - " default DSN for the program. The default is\n" - " \"DSN=TpcbData;OverWrite=1\".\n" - " -v Verbose level\n" - " 0 = errors only\n" - " 1 = results only\n" - " 2 = results and some status messages (default)\n" - " 3 = all messages\n" - " -xact Specifies the number of transactions to be run\n" - " The default is 25000 transactions.\n" - " -scale Specifies a scale factor which determines the\n" - " number of branches (scale), tellers (scale x 10),\n" - " accounts (scale x 10000) and non-local accounts\n" - " ((scale-1) x 10000. The default scale factor is 2.\n" - " -tabs Specifies that the output be a tab-separated\n" - " format suitable for import into a spreadsheet.\n" - " Results only go to stdout; status and other\n" - " messages go to stderr.\n" - " -s Prints individual transaction times to .\n", - progname); -} - -/********************************************************************* - * - * FUNCTION: parse_args - * - * DESCRIPTION: This function parses the command line arguments - * passed to main(), setting the appropriate global - * variables and issuing a usage message for - * invalid arguments. - * - * PARAMETERS: int argc # of arguments from main() - * char *argv[] arguments from main() - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -parse_args(int argc, char *argv[]) -{ - int i = 1; - - *szConnStrIn = 0; - - while (i < argc) { - - if ( !strcmp(argv[i], "-h") || !strcmp(argv[i], "-help") ) { - usage(argv[0]); - app_exit(0); - } - /* - if (!strcmp(argv[i], "-V")) { - printf("%s\n", TTVERSION_STRING); - app_exit(0); - } - */ - if (strcmp(argv[i], "-s") == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - if (sscanf(argv[i+1], "%s", statFile) == 0) { - usage(argv[0]); - app_exit(1); - } - printXactTimes = 1; - i += 2; - } - else if (!strcmp(argv[i], "-connStr")) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - strcpy(szConnStrIn, argv[i+1]); - i += 2; - continue; - } - else if (strcmp("-v", argv[i]) == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - if (sscanf(argv[i+1], "%d", &verbose) == -1 || - verbose < 0 || verbose > 3) { - fprintf(stderr, "-v flag requires an integer parameter (0-3)\n"); - usage(argv[0]); - app_exit(1); - } - i += 2; - } - else if (strcmp("-xact",argv[i]) == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - - if (sscanf(argv[i+1], "%" PTRINT_FMT, &numXacts) == -1 || numXacts < 0) { - fprintf(stderr, "-xact flag requires a non-negative integer argument\n"); - usage(argv[0]); - app_exit(1); - } - - i += 2; - } - else if (strcmp("-scale",argv[i]) == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - if (sscanf(argv[i+1], "%d", &scaleFactor) == -1 || scaleFactor < 1) { - fprintf(stderr, "-scale flag requires an integer argument >= 1\n"); - usage(argv[0]); - app_exit(1); - } - /* Calculate tuple sizes */ - numBranchTups = NumBranches * scaleFactor; - numTellerTups = TellersPerBranch * scaleFactor; - numAccountTups = AccountsPerBranch * scaleFactor; - numNonLocalAccountTups = AccountsPerBranch * (scaleFactor-1); - i += 2; - } - else if (strcmp("-tabs",argv[i]) == 0) { - tabFlag = 1; - statusfp = stderr; - i += 1; - } - else { - usage(argv[0]); - app_exit(1); - } - } -} - -/********************************************************************* - * - * FUNCTION: doImmed - * - * DESCRIPTION: This function executes and frees the specified - * statement. It is used as a direct means to - * create the tables used by this benchmark, - * - * PARAMETERS: SQLHDBC hdbc SQL Connection handle - * SQLHSTMT hs SQL Statement handle - * char* cmd SQL Statement text - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -doImmed(SQLHDBC hdbc, SQLHSTMT hs, char* cmd) -{ - SQLRETURN rc; - - /* Execute the command */ - - rc = SQLExecDirect(hs, (SQLCHAR *) cmd, SQL_NTS); - handle_errors(hdbc, hs, rc, ABORT_DISCONNECT_EXIT, - "Error executing statement", __FILE__, __LINE__); - - /* Close associated cursor and drop pending results */ - - rc = SQLFreeStmt(hs, SQL_CLOSE); - handle_errors(hdbc, hs, rc, ABORT_DISCONNECT_EXIT, - "closing statement handle", - __FILE__, __LINE__); - -} - - -/********************************************************************* - * - * FUNCTION: main - * - * DESCRIPTION: This is the main function of the tpcb benchmark. - * It connects to an ODBC data source, creates and - * populates tables, updates the tables in a user- - * specified number of transactions and reports on - * on the transaction times. - * - * PARAMETERS: int argc # of command line arguments - * char *argv[] command line arguments - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -int -main(int argc, char *argv[]) -{ - - /* variables used for setting up the tables */ - - char cmdStr[1024]; - char errstr[4096]; - - /* variables used during transactions */ - - int accountNum; - int tellerNum; - int branchNum; - int timeStamp; - double delta; - unsigned int lrand; - unsigned short *srands, localLimit; - int lp64; - - /* variables used for timing and statistics */ - - int warmup; - double kernel, user, real; - ttThreadTimes startRes, endRes; - ttWallClockTime startT, endT; - ttWallClockTime** rtStart; - ttWallClockTime** rtEnd; - double** resTime; - double maxTime, totTime; - int i; - int j; - int numLocalXacts=0, numRemoteXacts=0; - - /* variables for ODBC */ - - SQLHDBC hdbc; - SQLHSTMT hstmt; - SQLHSTMT txstmt[NumXactStmts]; - SQLRETURN rc; - char DBMSName[32]; - char DBMSVersion[32]; - int databaseSize; - - int fThreadTime = 1; - -#ifdef WIN32 - OSVERSIONINFO sysInfo; - - sysInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx (&sysInfo); - - /* GetThreadTimes is not supported on 95/98. Hence, - we do not support Resource/User/System times */ - if (sysInfo.dwPlatformId != VER_PLATFORM_WIN32_NT) - fThreadTime = 0; -#endif -#if defined(TTCLIENTSERVER) && defined(__hpux) && !defined(__LP64__) - /* HP requires this for C main programs that call aC++ shared libs */ - _main(); -#endif /* hpux32 */ - - /* Set up default signal handlers */ - -#ifndef NDB - /* StopRequestClear(); - if (HandleSignals() != 0) { - err_msg0("Unable to set signal handlers\n"); - return 1; - } - */ -#endif - /* set IO mode for demo */ - /* set_io_mode(); */ - - /* initialize the file for status messages */ - statusfp = stdout; - - /* set variable for 8-byte longs */ - lp64 = (sizeof(lrand) == 8); - - /* set the default tuple sizes */ - - numBranchTups = NumBranches * scaleFactor; - numTellerTups = TellersPerBranch * scaleFactor; - numAccountTups = AccountsPerBranch * scaleFactor; - numNonLocalAccountTups = AccountsPerBranch * (scaleFactor-1); - - /* parse the command arguments */ - parse_args(argc, argv); - - /* allocate the transaction-based variables */ - - rtStart = (ttWallClockTime**) malloc(numXacts * sizeof(ttWallClockTime*)); - if (!rtStart) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - for (i = 0; i < numXacts; i++) { - rtStart[i] = (ttWallClockTime*) malloc(sizeof(ttWallClockTime)); - if (!rtStart[i]) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - } - - rtEnd = (ttWallClockTime**) malloc(numXacts * sizeof(ttWallClockTime*)); - if (!rtEnd) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - for (i = 0; i < numXacts; i++) { - rtEnd[i] = (ttWallClockTime*) malloc(sizeof(ttWallClockTime)); - if (!rtEnd[i]) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - } - - resTime = (double**) malloc(numXacts * sizeof(double*)); - if (!resTime) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - for (i = 0; i < numXacts; i++) { - resTime[i] = (double*) malloc(sizeof(double)); - if (!resTime[i]) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - } - - /* ODBC initialization */ - - rc = SQLAllocEnv(&henv); - if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - /* error occurred -- don't bother calling handle_errors, since handle - * is not valid so SQLError won't work */ - err_msg3("ERROR in %s, line %d: %s\n", - __FILE__, __LINE__, "allocating an environment handle"); - app_exit(1); - } - SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER); - - /* call this in case of warning */ - handle_errors(NULL, NULL, rc, NO_EXIT, - "allocating execution environment", - __FILE__, __LINE__); - - rc = SQLAllocConnect(henv, &hdbc); - handle_errors(NULL, NULL, rc, ERROR_EXIT, - "allocating connection handle", - __FILE__, __LINE__); - - /* Connect to data store */ - - status_msg0("Connecting to the data source...\n"); - - /* Set up the connection options if not specified on the command line - * (default to TimesTen settings). - */ - - if ( !*szConnStrIn ) { - /* Running the benchmark with a scale factor creates (scale) branches, - * (scale x 10) tellers, (scale x 10000) accounts and ((scale-1) x 10000) - * non-local accounts. The size of the table rows are branches (141) - * tellers (141) and accounts (141). Therefore the data size requirements - * of this benchmark is: - * size ~= 141 * ((scale * 20011) - 10000) (bytes) - * - * Multiply data size by 20% to account for additional DB overhead (e.g. - * indexes), and round up the nearest 10Mb for safety. - */ - - int est_size = (int) (3.6 * scaleFactor + 10.0); - est_size = est_size - (est_size % 10); - - sprintf(szConnStrIn,"OverWrite=1;PermSize=%d;%s", - est_size, DSNNAME); - status_msg0("Connecting to the data source... %s \n", szConnStrIn); - } - - rc = SQLDriverConnect(hdbc, NULL, (SQLCHAR *) szConnStrIn, SQL_NTS, - NULL, 0, NULL, - SQL_DRIVER_NOPROMPT); - - status_msg0("Connected to the data source...\n"); - sprintf(errstr, "connecting to driver (connect string %s)\n", - szConnStrIn); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - errstr, __FILE__, __LINE__); - - /* Turn auto-commit off */ - - rc = SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF); - handle_errors(hdbc, NULL, rc, DISCONNECT_EXIT, - "switching off the AUTO_COMMIT option", - __FILE__, __LINE__); - - /* Allocate a statement handle */ - - rc = SQLAllocStmt(hdbc, &hstmt); - handle_errors(hdbc, NULL, rc, DISCONNECT_EXIT, - "allocating a statement handle", - __FILE__, __LINE__); - - /* (Implicit) Transaction begin */ - - /* Determine the DBMS Type*/ - - DBMSName[0] = '\0'; - rc = SQLGetInfo(hdbc, SQL_DBMS_NAME, (PTR) &DBMSName, - sizeof(DBMSName), NULL); - rc = SQLGetInfo(hdbc, SQL_DRIVER_VER, (PTR) &DBMSVersion, - sizeof(DBMSVersion), NULL); - - if (strcmp(DBMSName, "TimesTen") == 0) - DBMSType = DBMS_TIMESTEN; - else if (strcmp(DBMSName, "Microsoft SQL Server") == 0) - DBMSType = DBMS_MSSQL; - else DBMSType = DBMS_UNKNOWN; - - /* if not TimesTen: delete (if it exists), create & use the new database */ - - if (DBMSType != DBMS_TIMESTEN) { - status_msg0("Deleting the database...\n"); - rc = SQLExecDirect(hstmt, (SQLCHAR *) DatabaseDropStmt, SQL_NTS); - - /* estimate database size, size = data space + log space - * data space = (#tuples)/(tuples per page) * 2K bytes/page - * tuples per page = useable page size / row size (no index) = 2016/(96+2) - * log space = #transactions * average log size for the program transaction mix - * database size is in MB - */ - - databaseSize = (int) ceil((((numBranchTups + numTellerTups + numAccountTups)/ - (2016/98)) * 2048 + (numXacts * 600)) / 1000000.0); - - status_msg1("Creating the database (%dMB)...\n", databaseSize); -#ifndef NDB - sprintf(cmdStr, DatabaseCreateStmt, databaseSize); - doImmed(hdbc, hstmt, cmdStr); - strcpy(cmdStr, DatabaseUseStmt); - doImmed(hdbc, hstmt, cmdStr); -#endif - } - - status_msg2("Connected to '%s' version '%s'...\n", DBMSName, DBMSVersion); - - /* create branches table */ - status_msg0("Creating tasddbles...\n"); -#ifndef NDB - if (DBMSType == DBMS_TIMESTEN) - sprintf(cmdStr, TTBranchCrTblStmt, numBranchTups/TuplesPerPage + 1); - else -#endif - sprintf(cmdStr, BranchCrTblStmt); - doImmed(hdbc, hstmt, cmdStr); - - /* create tellers table */ -#ifndef NDB - if (DBMSType == DBMS_TIMESTEN) - sprintf(cmdStr, TTTellerCrTblStmt, numTellerTups/TuplesPerPage + 1); - - else -#endif - sprintf(cmdStr, TellerCrTblStmt); - doImmed(hdbc, hstmt, cmdStr); - - /* create accounts table */ -#ifndef NDB - if (DBMSType == DBMS_TIMESTEN) - sprintf(cmdStr, TTAccountCrTblStmt, numAccountTups/TuplesPerPage + 1); - else -#endif - sprintf(cmdStr, AccountCrTblStmt); - doImmed(hdbc, hstmt, cmdStr); - - /* create History table */ - - doImmed(hdbc, hstmt, HistoryCrTblStmt); - - /* lock the database during population */ -#ifndef NDB - if ( DBMSType == DBMS_TIMESTEN ) { - rc = SQLExecDirect(hstmt, (SQLCHAR *)"call ttlocklevel('DS')", SQL_NTS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "specifying dbs lock usage", - __FILE__, __LINE__); - /* make sure dbs lock take effect in next transaction */ - rc = SQLTransact(henv,hdbc,SQL_COMMIT); - if ( rc != SQL_SUCCESS) { - handle_errors(hdbc, SQL_NULL_HSTMT, rc, ERROR_EXIT, - "committing transaction", - __FILE__, __LINE__); - } - } -#endif - /* populate branches table */ - - - rc = SQLPrepare(hstmt, (SQLCHAR *) insStmt[0], SQL_NTS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "preparing statement", - __FILE__, __LINE__); - - rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 10, 0, &branchNum, sizeof branchNum, NULL); - - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - - status_msg1("Populating branches table (%" PTRINT_FMT " rows)...\n", - numBranchTups); - - - for (i=0; i= 0; warmup--) { - - int max_i = (warmup ? numXacts/10 : numXacts); - - /* Execute tpcb transaction max_i times.*/ - - if (warmup) { - status_msg1("\nWarming up with %d tpcb transactions...\n", max_i); - } - else { - status_msg1("Executing and timing %d tpcb transactions...\n", max_i); - } - - ttGetWallClockTime(&startT); - ttGetThreadTimes(&startRes); - - for (i = 0; i < max_i; i++) { - - lrand = lrand48(); - srands = (unsigned short *)(&lrand); - if (lp64) srands += 2; /* skip high half -- all zero */ - - /* randomly choose a teller */ - - tellerNum = srands[0] % numTellerTups; - - /* compute branch */ - - branchNum = (tellerNum / TellersPerBranch); - - /* randomly choose an account */ - - if (srands[1] < localLimit || numBranchTups == 1) { - - /* choose account local to selected branch */ - - accountNum = branchNum * AccountsPerBranch + - (lrand48() % AccountsPerBranch); - - ++numLocalXacts; - - } - else { - /* choose account not local to selected branch */ - - /* first select account in range [0,numNonLocalAccountTups) */ - - accountNum = lrand48() % numNonLocalAccountTups; - - /* if branch number of selected account is at least as big - * as local branch number, then increment account number - * by AccountsPerBranch to skip over local accounts - */ - - if ((accountNum/AccountsPerBranch) >= branchNum) - accountNum += AccountsPerBranch; - - ++numRemoteXacts; - } - - /* select delta amount, -999,999 to +999,999 */ - - delta = ((lrand48() % 1999999) - 999999); - - - /* begin timing the "residence time" */ - - ttGetWallClockTime(rtStart[i]); - - for ( j = 0; j < NumXactStmts - 2; j++) { - rc = SQLExecute(txstmt[j]); - handle_errors(hdbc, txstmt[j], rc, ABORT_DISCONNECT_EXIT, - "Error executing statement1", - __FILE__, __LINE__); - - /* Close the handle after the SELECT statement - * (txstmt[1]) for non TimesTen DBMS' */ - - if ((DBMSType != DBMS_TIMESTEN) && (j == 1)) { - SQLFreeStmt(txstmt[1], SQL_CLOSE); - } - - - } - - /* note that time must be taken within the */ - timeStamp = time(NULL); - - rc = SQLExecute(txstmt[NumXactStmts - 1]); - handle_errors(hdbc, txstmt[NumXactStmts - 1], rc, - ABORT_DISCONNECT_EXIT, "Error executing statement2", - __FILE__, __LINE__); - - rc = SQLTransact(henv, hdbc, SQL_COMMIT); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "Error committing transaction", - __FILE__, __LINE__); - - ttGetWallClockTime(rtEnd[i]); - - } /* end fortransaction loop */ - - - - - ttGetThreadTimes(&endRes); - ttGetWallClockTime(&endT); - ttCalcElapsedThreadTimes(&startRes, &endRes, &kernel, &user); - ttCalcElapsedWallClockTime(&startT, &endT, &real); - - if (warmup) { - if (!tabFlag) { - if (verbose) { - if (fThreadTime) { - out_msg0(" time user system\n"); - - out_msg3("Warmup time (sec): %12.3f %12.3f %12.3f\n\n", - real/1000.0, user, kernel); - } else { - out_msg1("Warmup time (sec): %12.3f\n\n", real/1000.0); - } - } - } else { - if (verbose) { - if (fThreadTime) { - out_msg0("\ttime\tuser\tsystem\n"); - - out_msg3("Warmup time (sec):\t%12.3f\t%12.3f\t%12.3f\n", - real/1000.0, user, kernel); - } else { - out_msg1("Warmup time (sec):\t%12.3f\n", real/1000.0); - } - } - } - } - } - - status_msg0("\nExecution completed...\n"); - - /* Compute and report timing statistics */ - - maxTime = 0.0; - totTime = 0.0; - - for (i = 0; i < numXacts; i++) { - ttCalcElapsedWallClockTime(rtStart[i], rtEnd[i], resTime[i]); - totTime += *(resTime[i]); - - if (*(resTime[i]) > maxTime) maxTime = *(resTime[i]); - } - - if (!tabFlag) { - if (verbose) { - if (fThreadTime) { - out_msg0(" time user system\n"); - out_msg3("Total time (sec): %12.3f %12.3f %12.3f\n", - real/1000.0, user, kernel); - } else { - out_msg1("Total time (sec): %12.3f\n", real/1000.0); - } - } - - if (verbose) - out_msg1("\nAverage transaction time (msec):%12.3f\n", - totTime/numXacts); - if (verbose) - out_msg1("Maximum transaction time (msec):%12.3f\n", maxTime); - if (verbose) - out_msg1("\nLocal transactions: %7" PTRINT_FMT "\n", numLocalXacts); - if (verbose) - out_msg1("Remote transactions: %7" PTRINT_FMT "\n", numRemoteXacts); - - } else { - if (verbose) { - if (fThreadTime) { - out_msg0("\ttime\tuser\tsystem\n"); - out_msg3("Total time (sec):\t%12.3f\t%12.3f\t%12.3f\n", - real/1000.0, user, kernel); - } else { - out_msg1("Total time (sec):\t%12.3f\n", real/1000.0); - } - } - - if (verbose) - out_msg1("\nAverage transaction time (msec):\t%12.3f\n", - totTime/numXacts); - if (verbose) - out_msg1("Maximum transaction time (msec):\t%12.3f\n", maxTime); - if (verbose) - out_msg1("Local transactions:\t%7" PTRINT_FMT "\n", numLocalXacts); - - if (verbose) - out_msg1("Remote transactions:\t%7" PTRINT_FMT "\n", numRemoteXacts); - - - - } - - /* If the statfile option is selected, print each transaction's time */ - - if (printXactTimes) { - FILE * fp; - if ( (fp = fopen (statFile, "w")) == NULL ) { - err_msg1("Unable to open stat file %s for writing\n\n", statFile); - } else { - for (int i = 0; i < numXacts; i++) - fprintf(fp,"%6d: %12.3f\n", i, *(resTime[i])); - fclose(fp); - } - } - - /* Disconnect and return */ - - rc = SQLFreeStmt(hstmt, SQL_DROP); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "dropping the statement handle", - __FILE__, __LINE__); - - for (int i=0; i= VERBOSE_DFLT) - status_msg0("Disconnecting from the data source...\n"); - - rc = SQLDisconnect(hdbc); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "disconnecting", - __FILE__, __LINE__); - - rc = SQLFreeConnect(hdbc); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "freeing connection handle", - __FILE__, __LINE__); - - rc = SQLFreeEnv(henv); - handle_errors(NULL, NULL, rc, ERROR_EXIT, - "freeing environment handle", - __FILE__, __LINE__); - - app_exit(0); - return 0; -} - - - - - -/* Emacs variable settings */ -/* Local Variables: */ -/* tab-width:8 */ -/* indent-tabs-mode:nil */ -/* c-basic-offset:2 */ -/* End: */ - - - diff --git a/ndb/test/odbc/tpcb/ttTime.c b/ndb/test/odbc/tpcb/ttTime.c deleted file mode 100644 index 8f10b0c6b91..00000000000 --- a/ndb/test/odbc/tpcb/ttTime.c +++ /dev/null @@ -1,366 +0,0 @@ -/* Copyright (C) 2003 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 */ - -static const volatile char cvsid[] = "$Id: ttTime.c,v 1.1 2003/09/23 12:43:46 johan Exp $"; -/* - * $Revision: 1.1 $ - * (c) Copyright 1996-2003, TimesTen, Inc. - * All rights reserved. - * - */ - - -/* Contains functions for performing elapsed-time calculations - in a portable manner */ - -#include "ttTime.h" - -#ifdef WIN32 - -#include -#include - -/*------------*/ -/* NT VERSION */ -/*------------*/ - -/********************************************************************* - * - * FUNCTION: ttGetThreadTimes - * - * DESCRIPTION: This function sets the supplied parameter's - * user and kernel time for the current thread. - * - * PARAMETERS: ttThreadTimes* timesP thread time structure - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttGetThreadTimes(ttThreadTimes* timesP) -{ - BOOL rc; - HANDLE curThread; - FILETIME creationTime; - FILETIME exitTime; - FILETIME kTime; - FILETIME uTime; - - memset (&kTime, 0, sizeof (FILETIME)); - memset (&uTime, 0, sizeof (FILETIME)); - - curThread = GetCurrentThread(); - rc = GetThreadTimes(curThread, - &creationTime, - &exitTime, - &kTime, - &uTime); - - timesP->kernelTime = kTime; - timesP->userTime = uTime; - -} - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedThreadTimes - * - * DESCRIPTION: This function calculates the user and kernel - * time deltas. - * - * PARAMETERS: ttThreadTimes* beforeP beginning timestamp (IN) - * ttThreadTimes* afterP ending timestamp (IN) - * double* kernelDeltaP kernel time delta (OUT) - * double* userDeltaP user time delta (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, - ttThreadTimes* afterP, - double* kernelDeltaP, - double* userDeltaP) -{ - static const double secPerHi = (double) 4.294967296; /* 2**32 * 10**-9 */ - FILETIME *before, *after; - - before = &beforeP->kernelTime; - after = &afterP->kernelTime; - *kernelDeltaP = (double) ((after->dwHighDateTime - before->dwHighDateTime) * secPerHi - + (after->dwLowDateTime - before->dwLowDateTime) * 100e-9); - before = &beforeP->userTime; - after = &afterP->userTime; - *userDeltaP = (double) ((after->dwHighDateTime - before->dwHighDateTime) * secPerHi - + (after->dwLowDateTime - before->dwLowDateTime) * 100e-9); -} - -/********************************************************************* - * - * FUNCTION: ttGetWallClockTime - * - * DESCRIPTION: This function gets the current wall-clock time. - * - * PARAMETERS: ttWallClockTime* timeP tms time structure (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttGetWallClockTime(ttWallClockTime* timeP) -{ - LARGE_INTEGER frequency; - if ( QueryPerformanceFrequency(&frequency) ) { - QueryPerformanceCounter(&(timeP->time64)); - } - else { - _ftime(&(timeP->notSoLargeTime)); - } -} - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedWallClockTime - * - * DESCRIPTION: This function calculates the elapsed wall-clock - * time in msec. - * - * PARAMETERS: ttWallClockTime* beforeP starting timestamp - * ttWallClockTime* afterP ending timestamp - * double* nmillisecondsP elapsed time (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP) -{ - LARGE_INTEGER frequency; - - if ( QueryPerformanceFrequency(&frequency) ) { - *nmillisecondsP = 1000 * ((double) (afterP->time64.QuadPart - - beforeP->time64.QuadPart)) - / frequency.QuadPart; - - } - else { - double start; - double end; - - start = (double) beforeP->notSoLargeTime.time * 1000. + - (double) beforeP->notSoLargeTime.millitm; - end = (double) afterP->notSoLargeTime.time * 1000. + - (double) afterP->notSoLargeTime.millitm; - - *nmillisecondsP = (double) (end - start); - } -} - -#elif defined (RTSYS_VXWORKS) - -/*-----------------*/ -/* VxWorks VERSION */ -/*-----------------*/ - -/* - * The TimeBase registers have a period of 60ns, i.e. - * 0.00000006 or (6e-8) seconds. - */ -#define TIMER_MSEC_PER_CYC (6e-5) - -void -ttGetWallClockTime(ttWallClockTime* timeP) -{ - vxTimeBaseGet(&timeP->sep.upper32, &timeP->sep.lower32); -} - - -void -ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP) -{ - *nmillisecondsP = (double)(afterP->val - beforeP->val) * TIMER_MSEC_PER_CYC; -} - - -#else - -/*--------------*/ -/* UNIX VERSION */ -/*--------------*/ - -#include - -/********************************************************************* - * - * FUNCTION: ttGetThreadTimes - * - * DESCRIPTION: This function sets the supplied parameter's - * tms structure. - * - * PARAMETERS: ttThreadTimes* timesP tms time structure - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -#ifdef SB_P_OS_CHORUS -void ttGetThreadTimes(ttThreadTimes* timesP) -{ - KnCap actorCap; - - if (acap (agetId(), &actorCap) == -1) { - timesP->ins.tmSec = 0; - timesP->ins.tmNSec = 0; - timesP->ext.tmSec = 0; - timesP->ext.tmNSec = 0; - } - else { - (void) threadTimes (&actorCap, K_ALLACTORTHREADS, - ×P->ins, ×P->ext); - } -} -#else -void ttGetThreadTimes(ttThreadTimes* timesP) -{ - (void) times(timesP); -} -#endif - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedThreadTimes - * - * DESCRIPTION: This function calculates the user and kernel - * time deltas. - * - * PARAMETERS: ttThreadTimes* beforeP beginning timestamp (IN) - * ttThreadTimes* afterP ending timestamp (IN) - * double* kernelDeltaP kernel time delta (OUT) - * double* userDeltaP user time delta (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -#ifdef SB_P_OS_CHORUS -void -ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, - ttThreadTimes* afterP, - double* kernelDeltaP, - double* userDeltaP) -{ - double kernelBefore; - double kernelAfter; - double userBefore; - double userAfter; - - kernelBefore = (beforeP->ext.tmSec) + (beforeP->ext.tmNSec / 1e9); - kernelAfter = (afterP->ext.tmSec) + (afterP->ext.tmNSec / 1e9); - *kernelDeltaP = kernelAfter - kernelBefore; - - userBefore = (beforeP->ins.tmSec) + (beforeP->ins.tmNSec / 1e9); - userAfter = (afterP->ins.tmSec) + (afterP->ins.tmNSec / 1e9); - *userDeltaP = userAfter - userBefore; - -} -#else -void -ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, - ttThreadTimes* afterP, - double* kernelDeltaP, - double* userDeltaP) -{ - double ticks = (double)sysconf(_SC_CLK_TCK); - - *kernelDeltaP = (afterP->tms_stime - beforeP->tms_stime) / ticks; - *userDeltaP = (afterP->tms_utime - beforeP->tms_utime) / ticks; -} -#endif - -/********************************************************************* - * - * FUNCTION: ttGetWallClockTime - * - * DESCRIPTION: This function gets the current wall-clock time. - * - * PARAMETERS: ttWallClockTime* timeP tms time structure (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttGetWallClockTime(ttWallClockTime* timeP) -{ - gettimeofday(timeP, NULL); -} - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedWallClockTime - * - * DESCRIPTION: This function calculates the elapsed wall-clock - * time is msec. - * - * PARAMETERS: ttWallClockTime* beforeP starting timestamp - * ttWallClockTime* afterP ending timestamp - * double* nmillisecondsP elapsed time (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisP) -{ - *nmillisP = (afterP->tv_sec - beforeP->tv_sec)*1000.0 + - (afterP->tv_usec - beforeP->tv_usec)/1000.0; -} - -#endif - -/* Emacs variable settings */ -/* Local Variables: */ -/* tab-width:8 */ -/* indent-tabs-mode:nil */ -/* c-basic-offset:2 */ -/* End: */ diff --git a/ndb/test/odbc/tpcb/ttTime.h b/ndb/test/odbc/tpcb/ttTime.h deleted file mode 100644 index f78b71667fe..00000000000 --- a/ndb/test/odbc/tpcb/ttTime.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 2003 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 */ - -/* - * $Revision: 1.1 $ - * (c) Copyright 1996-2003, TimesTen, Inc. - * All rights reserved. - * - */ - -#ifndef __TT_TIME -#define __TT_TIME - - -#ifdef WIN32 - -#include -#include -#include - -typedef struct { - FILETIME kernelTime; - FILETIME userTime; -} ttThreadTimes; - - -typedef union { - LARGE_INTEGER time64; - struct _timeb notSoLargeTime; -} ttWallClockTime; - -#elif defined(RTSYS_VXWORKS) - -#define srand48(x) sb_srand48((x)) -#define drand48() sb_drand48() - -#ifdef SB_P_OS_VXPPC -/* For little-endian switch the lower, upper fields */ -typedef union { - struct { - unsigned int upper32; - unsigned int lower32; - } sep; - long long val; -} ttWallClockTime; - -/* - * This is a VxWorks private function to read the PPC's 64 bit Time Base - * Register. This is the assembler dump of this function. - 001126e4 7cad42e6 mftb r5, TBU - 001126e8 7ccc42e6 mftb r6, TBL - 001126ec 7ced42e6 mftb r7, TBU - 001126f0 7c053800 cmp crf0, 0, r5, r7 - 001126f4 4082fff0 bc 0x4, 0x2, vxTimeBaseGet - 001126f8 90a30000 stw r5, 0x0(r3) - 001126fc 90c40000 stw r6, 0x0(r4) - 00112700 4e800020 blr - * This is a fine grained timer with a period of 60ns. - */ -void vxTimeBaseGet(unsigned int* pUpper32, unsigned int* pLower32); -#endif /* SB_P_OS_VXPPC */ - -#elif defined(SB_P_OS_CHORUS) -#include -#include -#include - -#include - -struct chrTimes { - KnTimeVal ins; - KnTimeVal ext; -}; -typedef struct chrTimes ttThreadTimes; - -typedef struct timeval ttWallClockTime; - -#else -/* UNIX version */ - -#include -#include - -typedef struct tms ttThreadTimes; - -typedef struct timeval ttWallClockTime; - -#endif /* NT, VxWorks, Chorus, Unix */ - - -#ifndef RTSYS_VXWORKS -void ttGetThreadTimes(ttThreadTimes* timesP); -void ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, ttThreadTimes* afterP, - double* kernelDeltaP, double* userDeltaP); -#endif /* ! VXWORKS */ -void ttGetWallClockTime(ttWallClockTime* timeP); -void ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP); - - - - - -#endif /* __TT_TIME */ - -/* Emacs variable settings */ -/* Local Variables: */ -/* tab-width:8 */ -/* indent-tabs-mode:nil */ -/* c-basic-offset:2 */ -/* End: */ From ca355c8a46ca015ab87ed273c81141f8d1c14fa9 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Fri, 5 Nov 2004 22:15:24 -0800 Subject: [PATCH 087/101] join_outer.result, join_outer.test: Added cases for bugs #6307 and #6460. sql_select.cc: Fixed the problem of bug reports #6307 and #6460. The reported wrong result sets were due to the fact that the added call of the fix_fields method for the built AND condition that joined WHERE and ON conditions broke ON expression, as it removed extra AND levels in the built condition. It looks like that no attributes of the built condition are needed, so we don't have to call fix_fields here. --- mysql-test/r/join_outer.result | 65 +++++++++++++++++++++++++++++ mysql-test/t/join_outer.test | 76 ++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 11 ++++- 3 files changed, 151 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 75bf96cb401..c045aa0d00a 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -751,3 +751,68 @@ player_id match_1_h * match_id home UUX 7 4 * 1 2 2 3 3 * 1 2 1 drop table t1, t2; +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); +select t1.a, t1.b, t2.c from t1 left join t2 +on t1.a=t2.a and t1.b=t2.b and t2.c=3 +where t1.a=1 and t2.c is null; +a b c +1 11 NULL +drop table t1, t2; +CREATE TABLE t1 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +CREATE TABLE t2 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES +(111056548820001, 0, 'flag1', NULL), +(111056548820001, 0, 'flag2', NULL), +(2, 0, 'other_flag', NULL); +INSERT INTO t2 VALUES +(111056548820001, 3, 'flag1', 'sss'); +SELECT t1.flag_name,t2.flag_value +FROM t1 LEFT JOIN t2 +ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND +t2.inst_id = 3) +WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND +t2.flag_value IS NULL; +flag_name flag_value +flag2 NULL +DROP TABLE t1,t2; +CREATE TABLE invoice ( +id int(11) unsigned NOT NULL auto_increment, +text_id int(10) unsigned default NULL, +PRIMARY KEY (id) +); +INSERT INTO invoice VALUES("1", "0"); +INSERT INTO invoice VALUES("2", "10"); +CREATE TABLE text_table ( +text_id char(3) NOT NULL default '', +language_id char(3) NOT NULL default '', +text_data text, +PRIMARY KEY (text_id,language_id) +); +INSERT INTO text_table VALUES("0", "EN", "0-EN"); +INSERT INTO text_table VALUES("0", "SV", "0-SV"); +INSERT INTO text_table VALUES("10", "EN", "10-EN"); +INSERT INTO text_table VALUES("10", "SV", "10-SV"); +SELECT invoice.id, invoice.text_id, text_table.text_data +FROM invoice LEFT JOIN text_table +ON invoice.text_id = text_table.text_id +AND text_table.language_id = 'SV' + WHERE (invoice.id LIKE '%' OR text_table.text_data LIKE '%'); +id text_id text_data +1 0 0-SV +2 10 10-SV +DROP TABLE invoice, text_table; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index bc96318ae2e..d177a68e685 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -506,3 +506,79 @@ select s.*, '*', m.*, (s.match_1_h - m.home) UUX from order by UUX desc; drop table t1, t2; + +# Tests for bugs #6307 and 6460 + +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); + +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); + +select t1.a, t1.b, t2.c from t1 left join t2 + on t1.a=t2.a and t1.b=t2.b and t2.c=3 + where t1.a=1 and t2.c is null; + +drop table t1, t2; + +CREATE TABLE t1 ( + ts_id bigint(20) default NULL, + inst_id tinyint(4) default NULL, + flag_name varchar(64) default NULL, + flag_value text, + UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +CREATE TABLE t2 ( + ts_id bigint(20) default NULL, + inst_id tinyint(4) default NULL, + flag_name varchar(64) default NULL, + flag_value text, + UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES + (111056548820001, 0, 'flag1', NULL), + (111056548820001, 0, 'flag2', NULL), + (2, 0, 'other_flag', NULL); + +INSERT INTO t2 VALUES + (111056548820001, 3, 'flag1', 'sss'); + +SELECT t1.flag_name,t2.flag_value + FROM t1 LEFT JOIN t2 + ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND + t2.inst_id = 3) + WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND + t2.flag_value IS NULL; + +DROP TABLE t1,t2; + +CREATE TABLE invoice ( + id int(11) unsigned NOT NULL auto_increment, + text_id int(10) unsigned default NULL, + PRIMARY KEY (id) +); + +INSERT INTO invoice VALUES("1", "0"); +INSERT INTO invoice VALUES("2", "10"); + +CREATE TABLE text_table ( + text_id char(3) NOT NULL default '', + language_id char(3) NOT NULL default '', + text_data text, + PRIMARY KEY (text_id,language_id) +); + +INSERT INTO text_table VALUES("0", "EN", "0-EN"); +INSERT INTO text_table VALUES("0", "SV", "0-SV"); +INSERT INTO text_table VALUES("10", "EN", "10-EN"); +INSERT INTO text_table VALUES("10", "SV", "10-SV"); + +SELECT invoice.id, invoice.text_id, text_table.text_data + FROM invoice LEFT JOIN text_table + ON invoice.text_id = text_table.text_id + AND text_table.language_id = 'SV' + WHERE (invoice.id LIKE '%' OR text_table.text_data LIKE '%'); + +DROP TABLE invoice, text_table; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index df74a946b5c..0a921ddb235 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3507,8 +3507,17 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) /* Join with outer join condition */ COND *orig_cond=sel->cond; sel->cond= and_conds(sel->cond, tab->on_expr); + + /* + We can't call sel->cond->fix_fields, + as it will break tab->on_expr if it's AND condition + (fix_fields currently removes extra AND/OR levels). + Yet attributes of the just built condition are not needed. + Thus we call sel->cond->quick_fix_field for safety. + */ if (sel->cond && !sel->cond->fixed) - sel->cond->fix_fields(join->thd, 0, &sel->cond); + sel->cond->quick_fix_field(); + if (sel->test_quick_select(join->thd, tab->keys, used_tables & ~ current_map, (join->select_options & From f9715d06dc660cc3de701cb4bb7abd222e89313b Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Sat, 6 Nov 2004 14:01:27 +0100 Subject: [PATCH 088/101] mysql_test_run_new.c: Included header fnmatch.h on Unix Changed C++ comments to C comments Corrected indentation of code written on Windows Split up lines to fit into 80 columns Initiated some variables to avoid warnings Added __attribute__((unused)) to unused function parameters Replace tab characters with space Put space after 'for', 'while' etc Added value to 'return' from non void function removef() On Unix strlwr() was incorrectly declared and a no op, replaced it with a macro that does nothing Split several statements on the same line Other minor changes to conform to coding standard --- mysql-test/my_manage.c | 527 +++++++++--------- mysql-test/my_manage.h | 26 +- mysql-test/mysql_test_run_new.c | 913 +++++++++++++++++--------------- 3 files changed, 750 insertions(+), 716 deletions(-) diff --git a/mysql-test/my_manage.c b/mysql-test/my_manage.c index e23d4f2227e..ba5c674d105 100644 --- a/mysql-test/my_manage.c +++ b/mysql-test/my_manage.c @@ -30,6 +30,7 @@ #ifndef __WIN__ #include #include +#include #else #include #include @@ -52,36 +53,37 @@ extern char **environ; /****************************************************************************** - macros - + macros + ******************************************************************************/ /****************************************************************************** - global variables - + global variables + ******************************************************************************/ /****************************************************************************** - functions - + functions + ******************************************************************************/ /****************************************************************************** - init_args() - - Init an argument list. + init_args() + + Init an argument list. ******************************************************************************/ + void init_args(arg_list_t *al) { ASSERT(al != NULL); - - al->argc = 0; - al->size = ARG_BUF; - al->argv = malloc(al->size * sizeof(char *)); + + al->argc= 0; + al->size= ARG_BUF; + al->argv= malloc(al->size * sizeof(char *)); ASSERT(al->argv != NULL); return; @@ -89,11 +91,12 @@ void init_args(arg_list_t *al) /****************************************************************************** - add_arg() - - Add an argument to a list. + add_arg() + + Add an argument to a list. ******************************************************************************/ + void add_arg(arg_list_t *al, const char *format, ...) { va_list ap; @@ -101,11 +104,11 @@ void add_arg(arg_list_t *al, const char *format, ...) ASSERT(al != NULL); - // increase size + /* increase size */ if (al->argc >= (int)al->size) { - al->size += ARG_BUF; - al->argv = realloc(al->argv, al->size * sizeof(char *)); + al->size+= ARG_BUF; + al->argv= realloc(al->argv, al->size * sizeof(char *)); ASSERT(al->argv != NULL); } @@ -115,7 +118,7 @@ void add_arg(arg_list_t *al, const char *format, ...) vsprintf(temp, format, ap); va_end(ap); - al->argv[al->argc] = malloc(strlen(temp)+1); + al->argv[al->argc]= malloc(strlen(temp)+1); ASSERT(al->argv[al->argc] != NULL); strcpy(al->argv[al->argc], temp); @@ -123,7 +126,7 @@ void add_arg(arg_list_t *al, const char *format, ...) } else { - al->argv[al->argc] = NULL; + al->argv[al->argc]= NULL; } return; @@ -131,102 +134,108 @@ void add_arg(arg_list_t *al, const char *format, ...) /****************************************************************************** - free_args() - - Free an argument list. + free_args() + + Free an argument list. ******************************************************************************/ + void free_args(arg_list_t *al) { int i; ASSERT(al != NULL); - for(i = 0; i < al->argc; i++) + for (i= 0; i < al->argc; i++) { ASSERT(al->argv[i] != NULL); free(al->argv[i]); - al->argv[i] = NULL; + al->argv[i]= NULL; } free(al->argv); - al->argc = 0; - al->argv = NULL; + al->argc= 0; + al->argv= NULL; return; } /****************************************************************************** - sleep_until_file_deleted() - - Sleep until the given file is no longer found. + sleep_until_file_deleted() + + Sleep until the given file is no longer found. ******************************************************************************/ + #ifndef __WIN__ int sleep_until_file_deleted(char *pid_file) #else int sleep_until_file_deleted(HANDLE pid_file) #endif { - int err; + int err= 0; /* Initiate to supress warning */ #ifndef __WIN__ - struct stat buf; - int i; - - for(i = 0; (i < TRY_MAX) && (err = !stat(pid_file, &buf)); i++) sleep(1); - - if (err != 0) err = errno; + struct stat buf; + int i; + + for (i= 0; (i < TRY_MAX) && (err= !stat(pid_file, &buf)); i++) sleep(1); + + if (err != 0) err= errno; #else err= (WaitForSingleObject(pid_file, TRY_MAX*1000) == WAIT_TIMEOUT); #endif - return err; + return err; } /****************************************************************************** - sleep_until_file_exists() + sleep_until_file_exists() - Sleep until the given file exists. + Sleep until the given file exists. ******************************************************************************/ + #ifndef __WIN__ int sleep_until_file_exists(char *pid_file) #else int sleep_until_file_exists(HANDLE pid_file) #endif { - int err; + int err= 0; /* Initiate to supress warning */ #ifndef __WIN__ - struct stat buf; - int i; - - for(i = 0; (i < TRY_MAX) && (err = stat(pid_file, &buf)); i++) sleep(1); - - if (err != 0) err = errno; + struct stat buf; + int i; + + for (i= 0; (i < TRY_MAX) && (err= stat(pid_file, &buf)); i++) sleep(1); + + if (err != 0) err= errno; #else err= (WaitForSingleObject(pid_file, TRY_MAX*1000) == WAIT_TIMEOUT); #endif - return err; + return err; } /****************************************************************************** - wait_for_server_start() - - Wait for the server on the given port to start. + wait_for_server_start() + + Wait for the server on the given port to start. ******************************************************************************/ -int wait_for_server_start(char *bin_dir, char *mysqladmin_file, char *user, char *password, int port,char *tmp_dir) + +int wait_for_server_start(char *bin_dir __attribute__((unused)), + char *mysqladmin_file, + char *user, char *password, int port,char *tmp_dir) { arg_list_t al; - int err, i; + int err= 0, i; char trash[PATH_MAX]; - - // mysqladmin file + + /* mysqladmin file */ snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); - - // args + + /* args */ init_args(&al); add_arg(&al, "%s", mysqladmin_file); add_arg(&al, "--no-defaults"); @@ -235,7 +244,7 @@ int wait_for_server_start(char *bin_dir, char *mysqladmin_file, char *user, char add_arg(&al, "--password=%s", password); add_arg(&al, "--silent"); -//#ifdef NOT_USED +/* #ifdef NOT_USED */ #ifndef __NETWARE__ add_arg(&al, "-O"); add_arg(&al, "connect_timeout=10"); @@ -245,20 +254,22 @@ int wait_for_server_start(char *bin_dir, char *mysqladmin_file, char *user, char add_arg(&al, "--host=localhost"); #ifndef __NETWARE__ add_arg(&al, "--protocol=tcp"); -#endif +#endif add_arg(&al, "ping"); - // NetWare does not support the connect timeout in the TCP/IP stack - // -- we will try the ping multiple times + /* + NetWare does not support the connect timeout in the TCP/IP stack + -- we will try the ping multiple times + */ #ifndef __WIN__ - for(i = 0; (i < TRY_MAX) - && (err = spawn(mysqladmin_file, &al, TRUE, NULL, - trash, NULL, NULL)); i++) sleep(1); + for (i= 0; (i < TRY_MAX) + && (err= spawn(mysqladmin_file, &al, TRUE, NULL, + trash, NULL, NULL)); i++) sleep(1); #else - err = spawn(mysqladmin_file, &al, TRUE, NULL,trash, NULL, NULL); + err= spawn(mysqladmin_file, &al, TRUE, NULL,trash, NULL, NULL); #endif - // free args + /* free args */ free_args(&al); return err; @@ -266,38 +277,39 @@ int wait_for_server_start(char *bin_dir, char *mysqladmin_file, char *user, char /****************************************************************************** - spawn() - - Spawn the given path with the given arguments. + spawn() + + Spawn the given path with the given arguments. ******************************************************************************/ + #ifdef __NETWARE__ int spawn(char *path, arg_list_t *al, int join, char *input, char *output, char *error, char *pid_file) { - pid_t pid; - int result = 0; - wiring_t wiring = { FD_UNUSED, FD_UNUSED, FD_UNUSED }; - unsigned long flags = PROC_CURRENT_SPACE | PROC_INHERIT_CWD; + pid_t pid; + int result= 0; + wiring_t wiring= { FD_UNUSED, FD_UNUSED, FD_UNUSED }; + unsigned long flags= PROC_CURRENT_SPACE | PROC_INHERIT_CWD; - // open wiring + /* open wiring */ if (input) - wiring.infd = open(input, O_RDONLY); + wiring.infd= open(input, O_RDONLY); if (output) - wiring.outfd = open(output, O_WRONLY | O_CREAT | O_TRUNC); + wiring.outfd= open(output, O_WRONLY | O_CREAT | O_TRUNC); if (error) - wiring.errfd = open(error, O_WRONLY | O_CREAT | O_TRUNC); + wiring.errfd= open(error, O_WRONLY | O_CREAT | O_TRUNC); - // procve requires a NULL + /* procve requires a NULL */ add_arg(al, NULL); - // go - pid = procve(path, flags, NULL, &wiring, NULL, NULL, 0, - NULL, (const char **)al->argv); + /* go */ + pid= procve(path, flags, NULL, &wiring, NULL, NULL, 0, + NULL, (const char **)al->argv); - // close wiring + /* close wiring */ if (wiring.infd != -1) close(wiring.infd); @@ -307,7 +319,7 @@ int spawn(char *path, arg_list_t *al, int join, char *input, if (wiring.errfd != -1) close(wiring.errfd); - return result; + return result; } #elif __WIN__ @@ -322,18 +334,16 @@ int spawn(char *path, arg_list_t *al, int join, char *input, char win_args[1024]= ""; char command_line[1024]= ""; - /* - Skip the first parameter - */ - for(i = 1; i < al->argc; i++) + /* Skip the first parameter */ + for (i= 1; i < al->argc; i++) { ASSERT(al->argv[i] != NULL); strcat(win_args,al->argv[i]); strcat(win_args," "); - } + } memset(&startup_info,0,sizeof(STARTUPINFO)); - startup_info.cb = sizeof(STARTUPINFO); + startup_info.cb= sizeof(STARTUPINFO); if (input) freopen(input, "rb", stdin); @@ -361,7 +371,8 @@ int spawn(char *path, arg_list_t *al, int join, char *input, { if (join) { - if (WaitForSingleObject(process_information.hProcess, mysqld_timeout) == WAIT_TIMEOUT) + if (WaitForSingleObject(process_information.hProcess, mysqld_timeout) + == WAIT_TIMEOUT) { exit_code= -1; } @@ -393,76 +404,60 @@ int spawn(char *path, arg_list_t *al, int join, char *input, } #else int spawn(char *path, arg_list_t *al, int join, char *input, - char *output, char *error, char *pid_file) + char *output, char *error, char *pid_file __attribute__((unused))) { pid_t pid; - int res_exec = 0; - int result = 0; - - pid = fork(); - + int res_exec= 0; + int result= 0; + + pid= fork(); + if (pid == -1) { fprintf(stderr, "fork was't created\n"); - /* - We can't create the fork...exit with error - */ - return EXIT_FAILURE; + /* We can't create the fork...exit with error */ + return EXIT_FAILURE; } - + if (pid > 0) { - /* - The parent process is waiting for child process if join is not zero - */ + /* The parent process is waiting for child process if join is not zero */ if (join) { - waitpid(pid, &result, 0); - if (WIFEXITED(result) != 0) - { - result = WEXITSTATUS(result); - } - else - { - result = EXIT_FAILURE; - } - } + waitpid(pid, &result, 0); + if (WIFEXITED(result) != 0) + { + result= WEXITSTATUS(result); + } + else + { + result= EXIT_FAILURE; + } + } } else { - - /* - Child process - */ - add_arg(al, NULL); + /* Child process */ + add_arg(al, NULL); - - /* - Reassign streams - */ + /* Reassign streams */ if (input) - freopen(input, "r", stdin); - + freopen(input, "r", stdin); if (output) freopen(output, "w", stdout); - if (error) freopen(error, "w", stderr); /* Spawn the process */ - if ((res_exec = execve(path, al->argv, environ)) < 0) - { + if ((res_exec= execve(path, al->argv, environ)) < 0) exit(EXIT_FAILURE); - } - /* - Restore streams - */ + /* Restore streams */ if (input) - freopen("/dev/tty", "r", stdin); + freopen("/dev/tty", "r", stdin); if (output) freopen("/dev/tty", "w", stdout); @@ -472,32 +467,34 @@ int spawn(char *path, arg_list_t *al, int join, char *input, exit(0); } - + return result; } #endif /****************************************************************************** - stop_server() - - Stop the server with the given port and pid file. + stop_server() + + Stop the server with the given port and pid file. ******************************************************************************/ + +int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file, + char *user, char *password, int port, #ifndef __WIN__ -int stop_server(char *bin_dir, char *mysqladmin_file, char *user, char *password, int port, - char *pid_file,char *tmp_dir) + char *pid_file, #else -int stop_server(char *bin_dir, char *mysqladmin_file, char *user, char *password, int port, - HANDLE pid_file,char *tmp_dir) + HANDLE pid_file, #endif + char *tmp_dir) { arg_list_t al; - int err = 0; + int err= 0; char trash[PATH_MAX]; - + snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); - - // args + + /* args */ init_args(&al); add_arg(&al, "%s", mysqladmin_file); add_arg(&al, "--no-defaults"); @@ -508,33 +505,33 @@ int stop_server(char *bin_dir, char *mysqladmin_file, char *user, char *password add_arg(&al, "shutdown_timeout=20"); #ifndef __NETWARE__ add_arg(&al, "--protocol=tcp"); -#endif +#endif add_arg(&al, "shutdown"); - // spawn - if ((err = spawn(mysqladmin_file, &al, TRUE, NULL, - trash, NULL, NULL)) == 0) + /* spawn */ + if ((err= spawn(mysqladmin_file, &al, TRUE, NULL, + trash, NULL, NULL)) == 0) { sleep_until_file_deleted(pid_file); } else { #ifndef __WIN__ - pid_t pid = get_server_pid(pid_file); - - // shutdown failed - kill server + pid_t pid= get_server_pid(pid_file); + + /* shutdown failed - kill server */ kill_server(pid); - + sleep(TRY_MAX); - - // remove pid file if possible - err = remove(pid_file); + + /* remove pid file if possible */ + err= remove(pid_file); #else TerminateProcess(pid_file,err); #endif } - - // free args + + /* free args */ free_args(&al); return err; @@ -542,57 +539,59 @@ int stop_server(char *bin_dir, char *mysqladmin_file, char *user, char *password /****************************************************************************** - get_server_pid() - - Get the VM id with the given pid file. + get_server_pid() + + Get the VM id with the given pid file. ******************************************************************************/ + #ifndef __WIN__ pid_t get_server_pid(char *pid_file) { char buf[PATH_MAX]; int fd, err; char *p; - pid_t id = 0; - - // discover id - fd = open(pid_file, O_RDONLY); - - err = read(fd, buf, PATH_MAX); - - close(fd); - - if (err > 0) - { - // terminate string - if ((p = strchr(buf, '\n')) != NULL) - { - *p = '\0'; - - // check for a '\r' - if ((p = strchr(buf, '\r')) != NULL) - { - *p = '\0'; - } - } - else - { - buf[err] = '\0'; - } - - id = strtol(buf, NULL, 0); - } - + pid_t id= 0; + + /* discover id */ + fd= open(pid_file, O_RDONLY); + + err= read(fd, buf, PATH_MAX); + + close(fd); + + if (err > 0) + { + /* terminate string */ + if ((p= strchr(buf, '\n')) != NULL) + { + *p= '\0'; + + /* check for a '\r' */ + if ((p= strchr(buf, '\r')) != NULL) + { + *p= '\0'; + } + } + else + { + buf[err]= '\0'; + } + + id= strtol(buf, NULL, 0); + } + return id; } /****************************************************************************** - kill_server() - - Force a kill of the server with the given pid. + kill_server() + + Force a kill of the server with the given pid. ******************************************************************************/ + void kill_server(pid_t pid) { if (pid > 0) @@ -603,51 +602,52 @@ void kill_server(pid_t pid) #else /* __NETWARE__ */ /* destroy vm */ NXVmDestroy(pid); -#endif +#endif } } #endif /****************************************************************************** - del_tree() - - Delete the directory and subdirectories. + del_tree() + + Delete the directory and subdirectories. ******************************************************************************/ + void del_tree(char *dir) { #ifndef __WIN__ - DIR *parent = opendir(dir); + DIR *parent= opendir(dir); struct dirent *entry; char temp[PATH_MAX]; - + if (parent == NULL) { return; } - while((entry = readdir(parent)) != NULL) + while ((entry= readdir(parent)) != NULL) { - // create long name + /* create long name */ snprintf(temp, PATH_MAX, "%s/%s", dir, entry->d_name); if (entry->d_name[0] == '.') { - // Skip + /* Skip */ } - else + else if (S_ISDIR(entry->d_type)) { - // delete subdirectory + /* delete subdirectory */ del_tree(temp); } else { - // remove file + /* remove file */ remove(temp); } } - // remove directory + /* remove directory */ rmdir(dir); #else struct _finddata_t parent; @@ -664,50 +664,51 @@ void del_tree(char *dir) do { - // create long name - snprintf(temp, PATH_MAX, "%s/%s", dir, parent.name); + /* create long name */ + snprintf(temp, PATH_MAX, "%s/%s", dir, parent.name); if (parent.name[0] == '.') { - // Skip + /* Skip */ } - else + else if (parent.attrib & _A_SUBDIR) { - // delete subdirectory + /* delete subdirectory */ del_tree(temp); } else { - // remove file + /* remove file */ remove(temp); } } while (_findnext(handle,&parent) == 0); _findclose(handle); - // remove directory + /* remove directory */ _rmdir(dir); #endif } /****************************************************************************** - removef() - + removef() + ******************************************************************************/ + int removef(const char *format, ...) { -#ifdef __NETWARE__ +#ifdef __NETWARE__ va_list ap; char path[PATH_MAX]; - + va_start(ap, format); vsnprintf(path, PATH_MAX, format, ap); - + va_end(ap); return remove(path); - + #eldef __WIN__ { va_list ap; @@ -716,25 +717,23 @@ int removef(const char *format, ...) intptr_t handle; char temp[PATH_MAX]; char *p; - + va_start(ap, format); vsnprintf(path, PATH_MAX, format, ap); - + va_end(ap); - - p = path + strlen(path); + + p= path + strlen(path); while (*p != '\\' && *p != '/' && p > path) p--; if ((handle=_findfirst(path,&parent)) == -1L) { - /* - if there is not files....it's ok. - */ + /* if there is not files....it's ok */ return 0; } - *p = '\0'; + *p= '\0'; do { @@ -754,89 +753,80 @@ int removef(const char *format, ...) va_list ap; char path[PATH_MAX]; char *p; - /* - Get path with mask - */ + /* Get path with mask */ va_start(ap, format); vsnprintf(path, PATH_MAX, format, ap); - + va_end(ap); - - p = path + strlen(path); + + p= path + strlen(path); while (*p != '\\' && *p != '/' && p > path) p--; - *p = '\0'; + *p= '\0'; p++; - - parent = opendir(path); + + parent= opendir(path); if (parent == NULL) { - return; + return 1; /* Error, directory missing */ } - - while((entry = readdir(parent)) != NULL) + + while ((entry= readdir(parent)) != NULL) { - /* - entry is not directory and entry matches with mask - */ + /* entry is not directory and entry matches with mask */ if (!S_ISDIR(entry->d_type) && !fnmatch(p, entry->d_name,0)) { - // create long name + /* create long name */ snprintf(temp, PATH_MAX, "%s/%s", path, entry->d_name); - // Delete only files + /* Delete only files */ remove(temp); } } #endif - return 0; + return 0; } /****************************************************************************** - get_basedir() - + get_basedir() + ******************************************************************************/ + void get_basedir(char *argv0, char *basedir) { char temp[PATH_MAX]; char *p; int position; - + ASSERT(argv0 != NULL); ASSERT(basedir != NULL); strcpy(temp, strlwr(argv0)); - while((p = strchr(temp, '\\')) != NULL) *p = '/'; - - if ((position = strinstr(temp, "/bin/")) != 0) + while ((p= strchr(temp, '\\')) != NULL) *p= '/'; + + if ((position= strinstr(temp, "/bin/")) != 0) { - p = temp + position; - *p = '\0'; + p= temp + position; + *p= '\0'; strcpy(basedir, temp); } } -#if !defined(__NETWARE__) && !defined(__WIN__) -char *strlwr(const char *s) -{ - return s; -} -#endif - uint strinstr(reg1 const char *str,reg4 const char *search) { reg2 my_string i,j; - my_string start = (my_string) str; + my_string start= (my_string) str; skipp: while (*str != '\0') { if (*str++ == *search) { - i=(my_string) str; j= (my_string) search+1; + i=(my_string) str; + j= (my_string) search+1; while (*j) - if (*i++ != *j++) goto skipp; + if (*i++ != *j++) goto skipp; return ((uint) (str - start)); } } @@ -845,13 +835,14 @@ uint strinstr(reg1 const char *str,reg4 const char *search) /****************************************************************************** - remove_empty_file() - + remove_empty_file() + ******************************************************************************/ + void remove_empty_file(const char *file_name) { struct stat file; - + if (!stat(file_name,&file)) { if (!file.st_size) diff --git a/mysql-test/my_manage.h b/mysql-test/my_manage.h index 56ba7ce0496..a61c693c22c 100644 --- a/mysql-test/my_manage.h +++ b/mysql-test/my_manage.h @@ -21,8 +21,8 @@ /****************************************************************************** - includes - + includes + ******************************************************************************/ #include @@ -36,7 +36,7 @@ #ifndef __WIN__ #define strnicmp strncasecmp -char *strlwr(const char *s); +#define strlwr(STRARG) (STRARG) #else int my_vsnprintf_(char *to, size_t n, const char* value, ...); #endif @@ -44,12 +44,12 @@ int my_vsnprintf_(char *to, size_t n, const char* value, ...); /****************************************************************************** - macros - + macros + ******************************************************************************/ -#define ARG_BUF 10 -#define TRY_MAX 5 +#define ARG_BUF 10 +#define TRY_MAX 5 #ifdef __WIN__ #define PATH_MAX _MAX_PATH @@ -71,8 +71,8 @@ bool skip_first_param; /****************************************************************************** - structures - + structures + ******************************************************************************/ typedef struct @@ -90,14 +90,14 @@ typedef int pid_t; #endif /****************************************************************************** - global variables - + global variables + ******************************************************************************/ /****************************************************************************** - prototypes - + prototypes + ******************************************************************************/ void init_args(arg_list_t *); diff --git a/mysql-test/mysql_test_run_new.c b/mysql-test/mysql_test_run_new.c index 6f388fc4a45..1e8a1dded51 100644 --- a/mysql-test/mysql_test_run_new.c +++ b/mysql-test/mysql_test_run_new.c @@ -21,7 +21,7 @@ #include #ifndef __WIN__ #include -#endif +#endif #include #ifdef __NETWARE__ #include @@ -46,51 +46,52 @@ /****************************************************************************** macros - + ******************************************************************************/ #define HEADER "TEST RESULT \n" #define DASH "-------------------------------------------------------\n" -#define NW_TEST_SUFFIX ".nw-test" -#define NW_RESULT_SUFFIX ".nw-result" -#define TEST_SUFFIX ".test" -#define RESULT_SUFFIX ".result" -#define REJECT_SUFFIX ".reject" -#define OUT_SUFFIX ".out" -#define ERR_SUFFIX ".err" +#define NW_TEST_SUFFIX ".nw-test" +#define NW_RESULT_SUFFIX ".nw-result" +#define TEST_SUFFIX ".test" +#define RESULT_SUFFIX ".result" +#define REJECT_SUFFIX ".reject" +#define OUT_SUFFIX ".out" +#define ERR_SUFFIX ".err" -const char *TEST_PASS = "[ pass ]"; -const char *TEST_SKIP = "[ skip ]"; -const char *TEST_FAIL = "[ fail ]"; -const char *TEST_BAD = "[ bad ]"; -const char *TEST_IGNORE = "[ignore]"; +const char *TEST_PASS= "[ pass ]"; +const char *TEST_SKIP= "[ skip ]"; +const char *TEST_FAIL= "[ fail ]"; +const char *TEST_BAD= "[ bad ]"; +const char *TEST_IGNORE= "[ignore]"; /****************************************************************************** global variables - -******************************************************************************/ -#ifdef __NETWARE__ -static char base_dir[PATH_MAX] = "sys:/mysql"; -#else -static char base_dir[PATH_MAX] = ".."; -#endif -static char db[PATH_MAX] = "test"; -static char user[PATH_MAX] = "root"; -static char password[PATH_MAX] = ""; -int master_port = 9306; -int slave_port = 9307; +******************************************************************************/ + +#ifdef __NETWARE__ +static char base_dir[PATH_MAX]= "sys:/mysql"; +#else +static char base_dir[PATH_MAX]= ".."; +#endif +static char db[PATH_MAX]= "test"; +static char user[PATH_MAX]= "root"; +static char password[PATH_MAX]= ""; + +int master_port= 9306; +int slave_port= 9307; #if !defined(__NETWARE__) && !defined(__WIN__) -static char master_socket[PATH_MAX] = "./var/tmp/master.sock"; -static char slave_socket[PATH_MAX] = "./var/tmp/slave.sock"; +static char master_socket[PATH_MAX]= "./var/tmp/master.sock"; +static char slave_socket[PATH_MAX]= "./var/tmp/slave.sock"; #endif -// comma delimited list of tests to skip or empty string +/* comma delimited list of tests to skip or empty string */ #ifndef __WIN__ -static char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix "; +static char skip_test[PATH_MAX]= " lowercase_table3 , system_mysql_db_fix "; #else /* The most ignore testes contain the calls of system command @@ -109,9 +110,20 @@ static char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix "; mysqldump contains a command system rpl000001 makes non-exit loop...temporary skiped */ -static char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix , sp , rpl_EE_error , rpl_loaddatalocal , ndb_autodiscover , rpl_rotate_logs , repair , rpl_trunc_binlog , mysqldump , rpl000001 "; +static char skip_test[PATH_MAX]= +" lowercase_table3 ," +" system_mysql_db_fix ," +" sp ," +" rpl_EE_error ," +" rpl_loaddatalocal ," +" ndb_autodiscover ," +" rpl_rotate_logs ," +" repair ," +" rpl_trunc_binlog ," +" mysqldump ," +" rpl000001 "; #endif -static char ignore_test[PATH_MAX] = ""; +static char ignore_test[PATH_MAX]= ""; static char bin_dir[PATH_MAX]; static char mysql_test_dir[PATH_MAX]; @@ -129,54 +141,54 @@ static char mysqltest_file[PATH_MAX]; #ifndef __WIN__ static char master_pid[PATH_MAX]; static char slave_pid[PATH_MAX]; -static char sh_file[PATH_MAX] = "/bin/sh"; +static char sh_file[PATH_MAX]= "/bin/sh"; #else static HANDLE master_pid; static HANDLE slave_pid; #endif -static char master_opt[PATH_MAX] = ""; -static char slave_opt[PATH_MAX] = ""; +static char master_opt[PATH_MAX]= ""; +static char slave_opt[PATH_MAX]= ""; -static char slave_master_info[PATH_MAX] = ""; +static char slave_master_info[PATH_MAX]= ""; -static char master_init_script[PATH_MAX] = ""; -static char slave_init_script[PATH_MAX] = ""; +static char master_init_script[PATH_MAX]= ""; +static char slave_init_script[PATH_MAX]= ""; -// OpenSSL +/* OpenSSL */ static char ca_cert[PATH_MAX]; static char server_cert[PATH_MAX]; static char server_key[PATH_MAX]; static char client_cert[PATH_MAX]; static char client_key[PATH_MAX]; -int total_skip = 0; -int total_pass = 0; -int total_fail = 0; -int total_test = 0; +int total_skip= 0; +int total_pass= 0; +int total_fail= 0; +int total_test= 0; -int total_ignore = 0; +int total_ignore= 0; -int use_openssl = FALSE; -int master_running = FALSE; -int slave_running = FALSE; -int skip_slave = TRUE; -int single_test = TRUE; +int use_openssl= FALSE; +int master_running= FALSE; +int slave_running= FALSE; +int skip_slave= TRUE; +int single_test= TRUE; -int restarts = 0; +int restarts= 0; -FILE *log_fd = NULL; +FILE *log_fd= NULL; /****************************************************************************** functions - + ******************************************************************************/ /****************************************************************************** prototypes - + ******************************************************************************/ void report_stats(); @@ -205,10 +217,11 @@ void run_init_script(const char *script_name); /****************************************************************************** report_stats() - + Report the gathered statistics. ******************************************************************************/ + void report_stats() { if (total_fail == 0) @@ -217,24 +230,26 @@ void report_stats() } else { - double percent = ((double)total_pass / total_test) * 100; - + double percent= ((double)total_pass / total_test) * 100; + mlog("\nFailed %u/%u test(s), %.02f%% successful.\n", - total_fail, total_test, percent); - mlog("\nThe .out and .err files in %s may give you some\n", result_dir); - mlog("hint of what when wrong.\n"); - mlog("\nIf you want to report this error, please first read the documentation\n"); - mlog("at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html\n"); + total_fail, total_test, percent); + mlog("\nThe .out and .err files in %s may give you some\n", result_dir); + mlog("hint of what when wrong.\n"); + mlog("\nIf you want to report this error, please first read " + "the documentation\n"); + mlog("at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html\n"); } } /****************************************************************************** install_db() - + Install the a database. ******************************************************************************/ + void install_db(char *datadir) { arg_list_t al; @@ -243,16 +258,16 @@ void install_db(char *datadir) char output[PATH_MAX]; char error[PATH_MAX]; - // input file -#ifdef __NETWARE__ + /* input file */ +#ifdef __NETWARE__ snprintf(input, PATH_MAX, "%s/bin/init_db.sql", base_dir); #else snprintf(input, PATH_MAX, "%s/mysql-test/init_db.sql", base_dir); -#endif +#endif snprintf(output, PATH_MAX, "%s/install.out", datadir); snprintf(error, PATH_MAX, "%s/install.err", datadir); - - // args + + /* args */ init_args(&al); add_arg(&al, mysqld_file); add_arg(&al, "--no-defaults"); @@ -265,39 +280,40 @@ void install_db(char *datadir) #ifndef __NETWARE__ add_arg(&al, "--character-sets-dir=%s", char_dir); add_arg(&al, "--language=%s", lang_dir); -#endif +#endif - // spawn - if ((err = spawn(mysqld_file, &al, TRUE, input, output, error, NULL)) != 0) + /* spawn */ + if ((err= spawn(mysqld_file, &al, TRUE, input, output, error, NULL)) != 0) { die("Unable to create database."); } - - // free args + + /* free args */ free_args(&al); } /****************************************************************************** mysql_install_db() - + Install the test databases. ******************************************************************************/ + void mysql_install_db() { char temp[PATH_MAX]; - - // var directory + + /* var directory */ snprintf(temp, PATH_MAX, "%s/var", mysql_test_dir); - - // clean up old direcotry + + /* clean up old direcotry */ del_tree(temp); - - // create var directory + + /* create var directory */ #ifndef __WIN__ mkdir(temp, S_IRWXU); - // create subdirectories + /* create subdirectories */ mlog("Creating test-suite folders...\n"); snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); mkdir(temp, S_IRWXU); @@ -317,7 +333,7 @@ void mysql_install_db() mkdir(temp, S_IRWXU); #else mkdir(temp); - // create subdirectories + /* create subdirectories */ mlog("Creating test-suite folders...\n"); snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); mkdir(temp); @@ -337,7 +353,7 @@ void mysql_install_db() mkdir(temp); #endif - // install databases + /* install databases */ mlog("Creating test databases for master... \n"); install_db(master_dir); mlog("Creating test databases for slave... \n"); @@ -347,49 +363,50 @@ void mysql_install_db() /****************************************************************************** start_master() - + Start the master server. ******************************************************************************/ + void start_master() { arg_list_t al; int err; char master_out[PATH_MAX]; char master_err[PATH_MAX]; -// char temp[PATH_MAX]; +/* char temp[PATH_MAX]; */ char temp2[PATH_MAX]; - // remove old berkeley db log files that can confuse the server + /* remove old berkeley db log files that can confuse the server */ removef("%s/log.*", master_dir); - // remove stale binary logs + /* remove stale binary logs */ removef("%s/var/log/*-bin.*", mysql_test_dir); - // remove stale binary logs + /* remove stale binary logs */ removef("%s/var/log/*.index", mysql_test_dir); - // remove master.info file + /* remove master.info file */ removef("%s/master.info", master_dir); - // remove relay files + /* remove relay files */ removef("%s/var/log/*relay*", mysql_test_dir); - // remove relay-log.info file + /* remove relay-log.info file */ removef("%s/relay-log.info", master_dir); - // init script + /* init script */ if (master_init_script[0] != 0) { #ifdef __NETWARE__ - // TODO: use the scripts + /* TODO: use the scripts */ if (strinstr(master_init_script, "repair_part2-master.sh") != 0) { FILE *fp; - // create an empty index file + /* create an empty index file */ snprintf(temp, PATH_MAX, "%s/test/t1.MYI", master_dir); - fp = fopen(temp, "wb+"); + fp= fopen(temp, "wb+"); fputs("1", fp); @@ -397,10 +414,10 @@ void start_master() } #elif !defined(__WIN__) run_init_script(master_init_script); -#endif +#endif } - // redirection files + /* redirection files */ snprintf(master_out, PATH_MAX, "%s/var/run/master%u.out", mysql_test_dir, restarts); snprintf(master_err, PATH_MAX, "%s/var/run/master%u.err", @@ -416,7 +433,7 @@ void start_master() snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); mkdir(temp2); #endif - // args + /* args */ init_args(&al); add_arg(&al, "%s", mysqld_file); add_arg(&al, "--no-defaults"); @@ -426,7 +443,7 @@ void start_master() add_arg(&al, "--port=%u", master_port); #if !defined(__NETWARE__) && !defined(__WIN__) add_arg(&al, "--socket=%s",master_socket); -#endif +#endif add_arg(&al, "--local-infile"); add_arg(&al, "--core"); add_arg(&al, "--datadir=%s", master_dir); @@ -436,7 +453,7 @@ void start_master() add_arg(&al, "--character-sets-dir=%s", char_dir); add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); add_arg(&al, "--language=%s", lang_dir); -#ifdef DEBUG //only for debug builds +#ifdef DEBUG /* only for debug builds */ add_arg(&al, "--debug"); #endif @@ -447,11 +464,11 @@ void start_master() add_arg(&al, "--ssl-key=%s", server_key); } - // $MASTER_40_ARGS + /* $MASTER_40_ARGS */ add_arg(&al, "--rpl-recovery-rank=1"); add_arg(&al, "--init-rpl-role=master"); - // $SMALL_SERVER + /* $SMALL_SERVER */ add_arg(&al, "-O"); add_arg(&al, "key_buffer_size=1M"); add_arg(&al, "-O"); @@ -459,44 +476,46 @@ void start_master() add_arg(&al, "-O"); add_arg(&al, "max_heap_table_size=1M"); - // $EXTRA_MASTER_OPT + /* $EXTRA_MASTER_OPT */ if (master_opt[0] != 0) { char *p; - p = (char *)str_tok(master_opt, " \t"); + p= (char *)str_tok(master_opt, " \t"); if (!strstr(master_opt, "timezone")) { while (p) { add_arg(&al, "%s", p); - p = (char *)str_tok(NULL, " \t"); + p= (char *)str_tok(NULL, " \t"); } } } - // remove the pid file if it exists + /* remove the pid file if it exists */ #ifndef __WIN__ remove(master_pid); #endif - // spawn + /* spawn */ #ifdef __WIN__ - if ((err= spawn(mysqld_file, &al, FALSE, NULL, master_out, master_err, &master_pid)) == 0) + if ((err= spawn(mysqld_file, &al, FALSE, NULL, + master_out, master_err, &master_pid)) == 0) #else - if ((err= spawn(mysqld_file, &al, FALSE, NULL, master_out, master_err, master_pid)) == 0) -#endif + if ((err= spawn(mysqld_file, &al, FALSE, NULL, + master_out, master_err, master_pid)) == 0) +#endif { sleep_until_file_exists(master_pid); - if ((err = wait_for_server_start(bin_dir, mysqladmin_file, user, password, master_port, - mysql_tmp_dir)) == 0) + if ((err= wait_for_server_start(bin_dir, mysqladmin_file, user, password, + master_port, mysql_tmp_dir)) == 0) { - master_running = TRUE; + master_running= TRUE; } else { - log_error("The master server went down early."); + log_error("The master server went down early."); } } else @@ -504,17 +523,18 @@ void start_master() log_error("Unable to start master server."); } - // free_args + /* free_args */ free_args(&al); } /****************************************************************************** start_slave() - + Start the slave server. ******************************************************************************/ + void start_slave() { arg_list_t al; @@ -522,43 +542,43 @@ void start_slave() char slave_out[PATH_MAX]; char slave_err[PATH_MAX]; - // skip? + /* skip? */ if (skip_slave) return; - // remove stale binary logs + /* remove stale binary logs */ removef("%s/*-bin.*", slave_dir); - // remove stale binary logs + /* remove stale binary logs */ removef("%s/*.index", slave_dir); - // remove master.info file + /* remove master.info file */ removef("%s/master.info", slave_dir); - // remove relay files + /* remove relay files */ removef("%s/var/log/*relay*", mysql_test_dir); - // remove relay-log.info file + /* remove relay-log.info file */ removef("%s/relay-log.info", slave_dir); - // init script + /* init script */ if (slave_init_script[0] != 0) { #ifdef __NETWARE__ - // TODO: use the scripts + /* TODO: use the scripts */ if (strinstr(slave_init_script, "rpl000016-slave.sh") != 0) { - // create empty master.info file + /* create empty master.info file */ snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); } else if (strinstr(slave_init_script, "rpl000017-slave.sh") != 0) { FILE *fp; - - // create a master.info file + + /* create a master.info file */ snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); - fp = fopen(temp, "wb+"); - + fp= fopen(temp, "wb+"); + fputs("master-bin.000001\n", fp); fputs("4\n", fp); fputs("127.0.0.1\n", fp); @@ -572,22 +592,22 @@ void start_slave() } else if (strinstr(slave_init_script, "rpl_rotate_logs-slave.sh") != 0) { - // create empty master.info file + /* create empty master.info file */ snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); } -#elif !defined(__WIN__) +#elif !defined(__WIN__) run_init_script(slave_init_script); -#endif +#endif } - // redirection files + /* redirection files */ snprintf(slave_out, PATH_MAX, "%s/var/run/slave%u.out", mysql_test_dir, restarts); snprintf(slave_err, PATH_MAX, "%s/var/run/slave%u.err", mysql_test_dir, restarts); - - // args + + /* args */ init_args(&al); add_arg(&al, "%s", mysqld_file); add_arg(&al, "--no-defaults"); @@ -597,7 +617,7 @@ void start_slave() add_arg(&al, "--port=%u", slave_port); #if !defined(__NETWARE__) && !defined(__WIN__) add_arg(&al, "--socket=%s",slave_socket); -#endif +#endif add_arg(&al, "--datadir=%s", slave_dir); #ifndef __WIN__ add_arg(&al, "--pid-file=%s", slave_pid); @@ -613,7 +633,7 @@ void start_slave() add_arg(&al, "--skip-innodb"); add_arg(&al, "--skip-slave-start"); add_arg(&al, "--slave-load-tmpdir=../../var/tmp"); - + add_arg(&al, "--report-user=%s", user); add_arg(&al, "--report-host=127.0.0.1"); add_arg(&al, "--report-port=%u", slave_port); @@ -621,7 +641,7 @@ void start_slave() add_arg(&al, "--master-retry-count=10"); add_arg(&al, "-O"); add_arg(&al, "slave_net_timeout=10"); -#ifdef DEBUG //only for debug builds +#ifdef DEBUG /* only for debug builds */ add_arg(&al, "--debug"); #endif @@ -632,18 +652,17 @@ void start_slave() add_arg(&al, "--ssl-key=%s", server_key); } - // slave master info + /* slave master info */ if (slave_master_info[0] != 0) { char *p; - p = (char *)str_tok(slave_master_info, " \t"); + p= (char *)str_tok(slave_master_info, " \t"); - while(p) + while (p) { add_arg(&al, "%s", p); - - p = (char *)str_tok(NULL, " \t"); + p= (char *)str_tok(NULL, " \t"); } } else @@ -656,8 +675,8 @@ void start_slave() add_arg(&al, "--server-id=2"); add_arg(&al, "--rpl-recovery-rank=2"); } - - // small server + + /* small server */ add_arg(&al, "-O"); add_arg(&al, "key_buffer_size=1M"); add_arg(&al, "-O"); @@ -666,38 +685,39 @@ void start_slave() add_arg(&al, "max_heap_table_size=1M"); - // opt args + /* opt args */ if (slave_opt[0] != 0) { char *p; - p = (char *)str_tok(slave_opt, " \t"); + p= (char *)str_tok(slave_opt, " \t"); - while(p) + while (p) { add_arg(&al, "%s", p); - - p = (char *)str_tok(NULL, " \t"); + p= (char *)str_tok(NULL, " \t"); } } - - // remove the pid file if it exists + + /* remove the pid file if it exists */ #ifndef __WIN__ remove(slave_pid); #endif - // spawn -#ifdef __WIN__ - if ((err = spawn(mysqld_file, &al, FALSE, NULL, slave_out, slave_err, &slave_pid)) == 0) + /* spawn */ +#ifdef __WIN__ + if ((err= spawn(mysqld_file, &al, FALSE, NULL, + slave_out, slave_err, &slave_pid)) == 0) #else - if ((err = spawn(mysqld_file, &al, FALSE, NULL, slave_out, slave_err, slave_pid)) == 0) -#endif + if ((err= spawn(mysqld_file, &al, FALSE, NULL, + slave_out, slave_err, slave_pid)) == 0) +#endif { sleep_until_file_exists(slave_pid); - - if ((err = wait_for_server_start(bin_dir, mysqladmin_file, user, password, slave_port, - mysql_tmp_dir)) == 0) + + if ((err= wait_for_server_start(bin_dir, mysqladmin_file, user, password, + slave_port, mysql_tmp_dir)) == 0) { - slave_running = TRUE; + slave_running= TRUE; } else { @@ -708,29 +728,30 @@ void start_slave() { log_error("Unable to start slave server."); } - - // free args + + /* free args */ free_args(&al); } /****************************************************************************** mysql_start() - + Start the mysql servers. ******************************************************************************/ + void mysql_start() { -// log_info("Starting the MySQL server(s): %u", ++restarts); +/* log_info("Starting the MySQL server(s): %u", ++restarts); */ start_master(); start_slave(); - // activate the test screen -#ifdef __NETWARE__ + /* activate the test screen */ +#ifdef __NETWARE__ ActivateScreen(getscreenhandle()); -#endif +#endif } /****************************************************************************** @@ -740,18 +761,19 @@ void mysql_start() Stop the slave server. ******************************************************************************/ + void stop_slave() { int err; - // running? + /* running? */ if (!slave_running) return; - // stop - if ((err = stop_server(bin_dir, mysqladmin_file, user, password, slave_port, slave_pid, - mysql_tmp_dir)) == 0) + /* stop */ + if ((err= stop_server(bin_dir, mysqladmin_file, user, password, + slave_port, slave_pid, mysql_tmp_dir)) == 0) { - slave_running = FALSE; + slave_running= FALSE; } else { @@ -766,17 +788,18 @@ void stop_slave() Stop the master server. ******************************************************************************/ + void stop_master() { int err; - // running? + /* running? */ if (!master_running) return; - if ((err = stop_server(bin_dir, mysqladmin_file, user, password, master_port, master_pid, - mysql_tmp_dir)) == 0) + if ((err= stop_server(bin_dir, mysqladmin_file, user, password, + master_port, master_pid, mysql_tmp_dir)) == 0) { - master_running = FALSE; + master_running= FALSE; } else { @@ -791,6 +814,7 @@ void stop_master() Stop the mysql servers. ******************************************************************************/ + void mysql_stop() { @@ -798,10 +822,10 @@ void mysql_stop() stop_slave(); - // activate the test screen -#ifdef __NETWARE__ + /* activate the test screen */ +#ifdef __NETWARE__ ActivateScreen(getscreenhandle()); -#endif +#endif } /****************************************************************************** @@ -811,9 +835,10 @@ void mysql_stop() Restart the mysql servers. ******************************************************************************/ + void mysql_restart() { -// log_info("Restarting the MySQL server(s): %u", ++restarts); +/* log_info("Restarting the MySQL server(s): %u", ++restarts); */ mysql_stop(); @@ -829,55 +854,52 @@ void mysql_restart() Read the option file. ******************************************************************************/ + int read_option(char *opt_file, char *opt) { int fd, err; char *p; char buf[PATH_MAX]; - // copy current option + /* copy current option */ strncpy(buf, opt, PATH_MAX); - // open options file - fd = open(opt_file, O_RDONLY); - - err = read(fd, opt, PATH_MAX); - + /* open options file */ + fd= open(opt_file, O_RDONLY); + err= read(fd, opt, PATH_MAX); close(fd); - + if (err > 0) { - // terminate string - if ((p = strchr(opt, '\n')) != NULL) + /* terminate string */ + if ((p= strchr(opt, '\n')) != NULL) { - *p = 0; - - // check for a '\r' - if ((p = strchr(opt, '\r')) != NULL) + *p= 0; + + /* check for a '\r' */ + if ((p= strchr(opt, '\r')) != NULL) { - *p = 0; + *p= 0; } } else { - opt[err] = 0; + opt[err]= 0; } - // check for $MYSQL_TEST_DIR - if ((p = strstr(opt, "$MYSQL_TEST_DIR")) != NULL) + /* check for $MYSQL_TEST_DIR */ + if ((p= strstr(opt, "$MYSQL_TEST_DIR")) != NULL) { char temp[PATH_MAX]; - - *p = 0; - + + *p= 0; + strcpy(temp, p + strlen("$MYSQL_TEST_DIR")); - strcat(opt, mysql_test_dir); - strcat(opt, temp); } - // Check for double backslash and replace it with single bakslash - if ((p = strstr(opt, "\\\\")) != NULL) + /* Check for double backslash and replace it with single bakslash */ + if ((p= strstr(opt, "\\\\")) != NULL) { /* bmove is guranteed to work byte by byte */ bmove(p, p+1, strlen(p+1)); @@ -885,54 +907,55 @@ int read_option(char *opt_file, char *opt) } else { - // clear option - *opt = 0; + /* clear option */ + *opt= 0; } - - // compare current option with previous + + /* compare current option with previous */ return strcmp(opt, buf); } /****************************************************************************** run_test() - + Run the given test case. ******************************************************************************/ + void run_test(char *test) { char temp[PATH_MAX]; const char *rstr; - int skip = FALSE, ignore=FALSE; - int restart = FALSE; - int flag = FALSE; + int skip= FALSE, ignore=FALSE; + int restart= FALSE; + int flag= FALSE; struct stat info; - - // skip tests in the skip list + + /* skip tests in the skip list */ snprintf(temp, PATH_MAX, " %s ", test); - skip = (strinstr(skip_test, temp) != 0); + skip= (strinstr(skip_test, temp) != 0); if (skip == FALSE) - ignore = (strinstr(ignore_test, temp) != 0); + ignore= (strinstr(ignore_test, temp) != 0); snprintf(master_init_script, PATH_MAX, "%s/%s-master.sh", test_dir, test); snprintf(slave_init_script, PATH_MAX, "%s/%s-slave.sh", test_dir, test); -#ifdef __WIN__ +#ifdef __WIN__ if (! stat(master_init_script, &info)) - skip = TRUE; + skip= TRUE; if (!stat(slave_init_script, &info)) - skip = TRUE; + skip= TRUE; #endif if (ignore) { - // show test + /* show test */ mlog("%-46s ", test); - - // ignore - rstr = TEST_IGNORE; + + /* ignore */ + rstr= TEST_IGNORE; ++total_ignore; - } - else if (!skip) // skip test? + } + else if (!skip) /* skip test? */ { char test_file[PATH_MAX]; char master_opt_file[PATH_MAX]; @@ -945,29 +968,29 @@ void run_test(char *test) int err; arg_list_t al; #ifdef __WIN__ - /* - Clean test database - */ + /* Clean test database */ removef("%s/test/*.*", master_dir); removef("%s/test/*.*", slave_dir); removef("%s/mysqltest/*.*", master_dir); removef("%s/mysqltest/*.*", slave_dir); #endif - // skip slave? - flag = skip_slave; - skip_slave = (strncmp(test, "rpl", 3) != 0); - if (flag != skip_slave) restart = TRUE; - - // create files + /* skip slave? */ + flag= skip_slave; + skip_slave= (strncmp(test, "rpl", 3) != 0); + if (flag != skip_slave) restart= TRUE; + + /* create files */ snprintf(master_opt_file, PATH_MAX, "%s/%s-master.opt", test_dir, test); snprintf(slave_opt_file, PATH_MAX, "%s/%s-slave.opt", test_dir, test); - snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", test_dir, test); - snprintf(reject_file, PATH_MAX, "%s/%s%s", result_dir, test, REJECT_SUFFIX); + snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", + test_dir, test); + snprintf(reject_file, PATH_MAX, "%s/%s%s", + result_dir, test, REJECT_SUFFIX); snprintf(out_file, PATH_MAX, "%s/%s%s", result_dir, test, OUT_SUFFIX); snprintf(err_file, PATH_MAX, "%s/%s%s", result_dir, test, ERR_SUFFIX); - - // netware specific files + + /* netware specific files */ snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, NW_TEST_SUFFIX); if (stat(test_file, &info)) { @@ -979,45 +1002,46 @@ void run_test(char *test) } } - snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, NW_RESULT_SUFFIX); + snprintf(result_file, PATH_MAX, "%s/%s%s", + result_dir, test, NW_RESULT_SUFFIX); if (stat(result_file, &info)) { - snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, RESULT_SUFFIX); + snprintf(result_file, PATH_MAX, "%s/%s%s", + result_dir, test, RESULT_SUFFIX); } - // init scripts + /* init scripts */ if (stat(master_init_script, &info)) - master_init_script[0] = 0; + master_init_script[0]= 0; else - restart = TRUE; - - if (stat(slave_init_script, &info)) - slave_init_script[0] = 0; - else - restart = TRUE; + restart= TRUE; - // read options - if (read_option(master_opt_file, master_opt)) restart = TRUE; - if (read_option(slave_opt_file, slave_opt)) restart = TRUE; - if (read_option(slave_master_info_file, slave_master_info)) restart = TRUE; - - // cleanup previous run + if (stat(slave_init_script, &info)) + slave_init_script[0]= 0; + else + restart= TRUE; + + /* read options */ + if (read_option(master_opt_file, master_opt)) restart= TRUE; + if (read_option(slave_opt_file, slave_opt)) restart= TRUE; + if (read_option(slave_master_info_file, slave_master_info)) restart= TRUE; + + /* cleanup previous run */ remove(reject_file); remove(out_file); remove(err_file); - - // start or restart? + + /* start or restart? */ if (!master_running) mysql_start(); else if (restart) mysql_restart(); - - // let the system stabalize + + /* let the system stabalize */ sleep(1); - // show test + /* show test */ mlog("%-46s ", test); - - - // args + + /* args */ init_args(&al); add_arg(&al, "%s", mysqltest_file); add_arg(&al, "--no-defaults"); @@ -1025,7 +1049,7 @@ void run_test(char *test) #if !defined(__NETWARE__) && !defined(__WIN__) add_arg(&al, "--socket=%s", master_socket); add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); -#endif +#endif add_arg(&al, "--database=%s", db); add_arg(&al, "--user=%s", user); add_arg(&al, "--password=%s", password); @@ -1043,70 +1067,71 @@ void run_test(char *test) add_arg(&al, "--ssl-key=%s", client_key); } - // spawn - err = spawn(mysqltest_file, &al, TRUE, test_file, out_file, err_file, NULL); - - // free args + /* spawn */ + err= spawn(mysqltest_file, &al, TRUE, test_file, out_file, err_file, NULL); + + /* free args */ free_args(&al); - remove_empty_file(out_file); - remove_empty_file(err_file); - + remove_empty_file(out_file); + remove_empty_file(err_file); + if (err == 0) { - // pass - rstr = TEST_PASS; + /* pass */ + rstr= TEST_PASS; ++total_pass; - - // increment total + + /* increment total */ ++total_test; } else if (err == 2) { - // skip - rstr = TEST_SKIP; + /* skip */ + rstr= TEST_SKIP; ++total_skip; } else if (err == 1) { - // fail - rstr = TEST_FAIL; + /* fail */ + rstr= TEST_FAIL; ++total_fail; - // increment total + /* increment total */ ++total_test; } else { - rstr = TEST_BAD; + rstr= TEST_BAD; } } - else // early skips + else /* early skips */ { - // show test + /* show test */ mlog("%-46s ", test); - - // skip - rstr = TEST_SKIP; + + /* skip */ + rstr= TEST_SKIP; ++total_skip; } - // result + /* result */ mlog("%-14s\n", rstr); } /****************************************************************************** vlog() - + Log the message. ******************************************************************************/ + void vlog(const char *format, va_list ap) { vfprintf(stdout, format, ap); fflush(stdout); - + if (log_fd) { vfprintf(log_fd, format, ap); @@ -1117,10 +1142,11 @@ void vlog(const char *format, va_list ap) /****************************************************************************** log() - + Log the message. ******************************************************************************/ + void mlog(const char *format, ...) { va_list ap; @@ -1128,21 +1154,22 @@ void mlog(const char *format, ...) va_start(ap, format); vlog(format, ap); - + va_end(ap); } /****************************************************************************** log_info() - + Log the given information. ******************************************************************************/ + void log_info(const char *format, ...) { va_list ap; - + va_start(ap, format); mlog("-- INFO : "); @@ -1155,14 +1182,15 @@ void log_info(const char *format, ...) /****************************************************************************** log_error() - + Log the given error. ******************************************************************************/ + void log_error(const char *format, ...) { va_list ap; - + va_start(ap, format); mlog("-- ERROR: "); @@ -1175,14 +1203,15 @@ void log_error(const char *format, ...) /****************************************************************************** log_errno() - + Log the given error and errno. ******************************************************************************/ + void log_errno(const char *format, ...) { va_list ap; - + va_start(ap, format); mlog("-- ERROR: (%003u) ", errno); @@ -1195,10 +1224,11 @@ void log_errno(const char *format, ...) /****************************************************************************** die() - + Exit the application. ******************************************************************************/ + void die(const char *msg) { log_error(msg); @@ -1211,48 +1241,49 @@ void die(const char *msg) /****************************************************************************** setup() - + Setup the mysql test enviornment. ******************************************************************************/ -void setup(char *file) + +void setup(char *file __attribute__((unused))) { char temp[PATH_MAX]; char file_path[PATH_MAX*2]; char *p; int position; - // set the timezone for the timestamp test + /* set the timezone for the timestamp test */ #ifdef __WIN__ _putenv( "TZ=GMT-3" ); #else setenv("TZ", "GMT-3", TRUE); #endif - // find base dir -#ifdef __NETWARE__ + /* find base dir */ +#ifdef __NETWARE__ strcpy(temp, strlwr(file)); - while((p = strchr(temp, '\\')) != NULL) *p = '/'; -#else + while ((p= strchr(temp, '\\')) != NULL) *p= '/'; +#else getcwd(temp, PATH_MAX); - position = strlen(temp); - temp[position] = '/'; - temp[position+1] = 0; + position= strlen(temp); + temp[position]= '/'; + temp[position+1]= 0; #ifdef __WIN__ - while((p = strchr(temp, '\\')) != NULL) *p = '/'; + while ((p= strchr(temp, '\\')) != NULL) *p= '/'; +#endif #endif -#endif - if ((position = strinstr(temp, "/mysql-test/")) != 0) + if ((position= strinstr(temp, "/mysql-test/")) != 0) { - p = temp + position - 1; - *p = 0; + p= temp + position - 1; + *p= 0; strcpy(base_dir, temp); - } + } log_info("Currect directory: %s",base_dir); #ifdef __NETWARE__ - // setup paths + /* setup paths */ snprintf(bin_dir, PATH_MAX, "%s/bin", base_dir); snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); @@ -1264,24 +1295,24 @@ void setup(char *file) snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); #ifdef HAVE_OPENSSL - use_openssl = TRUE; -#endif // HAVE_OPENSSL + use_openssl= TRUE; +#endif /* HAVE_OPENSSL */ - // OpenSSL paths + /* OpenSSL paths */ snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); - // setup files + /* setup files */ snprintf(mysqld_file, PATH_MAX, "%s/mysqld", bin_dir); snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); #elif __WIN__ - // setup paths + /* setup paths */ #ifdef _DEBUG snprintf(bin_dir, PATH_MAX, "%s/client_debug", base_dir); #else @@ -1297,22 +1328,22 @@ void setup(char *file) snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); #ifdef HAVE_OPENSSL - use_openssl = TRUE; -#endif // HAVE_OPENSSL + use_openssl= TRUE; +#endif /* HAVE_OPENSSL */ - // OpenSSL paths + /* OpenSSL paths */ snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); - // setup files + /* setup files */ snprintf(mysqld_file, PATH_MAX, "%s/mysqld.exe", bin_dir); snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest.exe", bin_dir); snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin.exe", bin_dir); -#else - // setup paths +#else + /* setup paths */ snprintf(bin_dir, PATH_MAX, "%s/client", base_dir); snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); @@ -1324,60 +1355,72 @@ void setup(char *file) snprintf(char_dir, PATH_MAX, "%s/sql/share/charsets", base_dir); #ifdef HAVE_OPENSSL - use_openssl = TRUE; -#endif // HAVE_OPENSSL + use_openssl= TRUE; +#endif /* HAVE_OPENSSL */ - // OpenSSL paths + /* OpenSSL paths */ snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); - // setup files + /* setup files */ snprintf(mysqld_file, PATH_MAX, "%s/sql/mysqld", base_dir); snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); - + snprintf(master_socket,PATH_MAX, "%s/var/tmp/master.sock", mysql_test_dir); snprintf(slave_socket,PATH_MAX, "%s/var/tmp/slave.sock", mysql_test_dir); #endif - // create log file + /* create log file */ snprintf(temp, PATH_MAX, "%s/mysql-test-run.log", mysql_test_dir); - if ((log_fd = fopen(temp, "w+")) == NULL) + if ((log_fd= fopen(temp, "w+")) == NULL) { log_errno("Unable to create log file."); } - // prepare skip test list - while((p = strchr(skip_test, ',')) != NULL) *p = ' '; + /* prepare skip test list */ + while ((p= strchr(skip_test, ',')) != NULL) *p= ' '; strcpy(temp, strlwr(skip_test)); snprintf(skip_test, PATH_MAX, " %s ", temp); - // environment -#ifdef __NETWARE__ + /* environment */ +#ifdef __NETWARE__ setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); - snprintf(file_path, PATH_MAX*2, "%s/client/mysqldump --no-defaults -u root --port=%u", bin_dir, master_port); + snprintf(file_path, PATH_MAX*2, + "%s/client/mysqldump --no-defaults -u root --port=%u", + bin_dir, master_port); setenv("MYSQL_DUMP", file_path, 1); - snprintf(file_path, PATH_MAX*2, "%s/client/mysqlbinlog --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + snprintf(file_path, PATH_MAX*2, + "%s/client/mysqlbinlog --no-defaults --local-load=%s", + bin_dir, mysql_tmp_dir); setenv("MYSQL_BINLOG", file_path, 1); #elif __WIN__ snprintf(file_path,MAX_PATH,"MYSQL_TEST_DIR=%s",mysql_test_dir); _putenv(file_path); - snprintf(file_path, PATH_MAX*2, "MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u", bin_dir, master_port); + snprintf(file_path, PATH_MAX*2, + "MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u", + bin_dir, master_port); _putenv(file_path); - snprintf(file_path, PATH_MAX*2, "MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + snprintf(file_path, PATH_MAX*2, + "MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s", + bin_dir, mysql_tmp_dir); _putenv(file_path); #else setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); - snprintf(file_path, PATH_MAX*2, "%s/mysqldump --no-defaults -u root --port=%u --socket=%s", bin_dir, master_port, master_socket); + snprintf(file_path, PATH_MAX*2, + "%s/mysqldump --no-defaults -u root --port=%u --socket=%s", + bin_dir, master_port, master_socket); setenv("MYSQL_DUMP", file_path, 1); - snprintf(file_path, PATH_MAX*2, "%s/mysqlbinlog --no-defaults --local-load=%s", bin_dir, mysql_tmp_dir); + snprintf(file_path, PATH_MAX*2, + "%s/mysqlbinlog --no-defaults --local-load=%s", + bin_dir, mysql_tmp_dir); setenv("MYSQL_BINLOG", file_path, 1); -#endif +#endif #ifndef __WIN__ setenv("MASTER_MYPORT", "9306", 1); @@ -1394,21 +1437,23 @@ void setup(char *file) /****************************************************************************** main() - + ******************************************************************************/ + int main(int argc, char **argv) { - int is_ignore_list = 0; - // setup + int is_ignore_list= 0; + /* setup */ setup(argv[0]); - - /* The --ignore option is comma saperated list of test cases to skip and - should be very first command line option to the test suite. - The usage is now: - mysql_test_run --ignore=test1,test2 test3 test4 - where test1 and test2 are test cases to ignore - and test3 and test4 are test cases to run. + /* + The --ignore option is comma saperated list of test cases to skip and + should be very first command line option to the test suite. + + The usage is now: + mysql_test_run --ignore=test1,test2 test3 test4 + where test1 and test2 are test cases to ignore + and test3 and test4 are test cases to run. */ if (argc >= 2 && !strnicmp(argv[1], "--ignore=", sizeof("--ignore=")-1)) { @@ -1425,22 +1470,22 @@ int main(int argc, char **argv) } } free(temp); - is_ignore_list = 1; + is_ignore_list= 1; } - // header + /* header */ #ifndef __WIN__ mlog("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); #else mlog("MySQL Server ---, for %s (%s)\n\n", SYSTEM_TYPE, MACHINE_TYPE); #endif - + mlog("Initializing Tests...\n"); - - // install test databases + + /* install test databases */ mysql_install_db(); - + mlog("Starting Tests...\n"); - + mlog("\n"); mlog(HEADER); mlog(DASH); @@ -1449,46 +1494,46 @@ int main(int argc, char **argv) { int i; - // single test - single_test = TRUE; + /* single test */ + single_test= TRUE; - for (i = 1 + is_ignore_list; i < argc; i++) + for (i= 1 + is_ignore_list; i < argc; i++) { - // run given test + /* run given test */ run_test(argv[i]); } } else { - // run all tests + /* run all tests */ #ifndef __WIN__ struct dirent **namelist; int i,n; char test[NAME_MAX]; char *p; int position; - - n = scandir(test_dir, &namelist, 0, alphasort); + + n= scandir(test_dir, &namelist, 0, alphasort); if (n < 0) die("Unable to open tests directory."); - else + else { - for (i = 0; i < n; i++) + for (i= 0; i < n; i++) { - strcpy(test, strlwr(namelist[i]->d_name)); - // find the test suffix - if ((position = strinstr(test, TEST_SUFFIX)) != 0) + strcpy(test, strlwr(namelist[i]->d_name)); + /* find the test suffix */ + if ((position= strinstr(test, TEST_SUFFIX)) != 0) { - p = test + position - 1; - // null terminate at the suffix - *p = 0; - // run test + p= test + position - 1; + /* null terminate at the suffix */ + *p= 0; + /* run test */ run_test(test); } free(namelist[n]); - } + } free(namelist); - } + } #else struct _finddata_t dir; intptr_t handle; @@ -1496,52 +1541,52 @@ int main(int argc, char **argv) char mask[PATH_MAX]; char *p; int position; - char **names = 0; - char **testes = 0; + char **names= 0; + char **testes= 0; int name_index; int index; - - // single test - single_test = FALSE; + + /* single test */ + single_test= FALSE; snprintf(mask,MAX_PATH,"%s/*.test",test_dir); - + if ((handle=_findfirst(mask,&dir)) == -1L) { die("Unable to open tests directory."); } - names = malloc(MAX_COUNT_TESTES*4); - testes = names; - name_index = 0; + names= malloc(MAX_COUNT_TESTES*4); + testes= names; + name_index= 0; do { - if (!(dir.attrib & _A_SUBDIR)) + if (!(dir.attrib & _A_SUBDIR)) { strcpy(test, strlwr(dir.name)); - - // find the test suffix - if ((position = strinstr(test, TEST_SUFFIX)) != 0) - { - p = test + position - 1; - // null terminate at the suffix - *p = 0; - // insert test - *names = malloc(PATH_MAX); + /* find the test suffix */ + if ((position= strinstr(test, TEST_SUFFIX)) != 0) + { + p= test + position - 1; + /* null terminate at the suffix */ + *p= 0; + + /* insert test */ + *names= malloc(PATH_MAX); strcpy(*names,test); names++; name_index++; } - } + } }while (_findnext(handle,&dir) == 0); _findclose(handle); qsort( (void *)testes, name_index, sizeof( char * ), compare ); - for (index = 0; index <= name_index; index++) + for (index= 0; index <= name_index; index++) { run_test(testes[index]); free(testes[index]); @@ -1551,7 +1596,7 @@ int main(int argc, char **argv) #endif } - // stop server + /* stop server */ mysql_stop(); mlog(DASH); @@ -1559,14 +1604,14 @@ int main(int argc, char **argv) mlog("Ending Tests...\n"); - // report stats + /* report stats */ report_stats(); - // close log + /* close log */ if (log_fd) fclose(log_fd); - // keep results up -#ifdef __NETWARE__ + /* keep results up */ +#ifdef __NETWARE__ pressanykey(); #endif return 0; @@ -1577,12 +1622,12 @@ int main(int argc, char **argv) Synopsis: This function breaks the string into a sequence of tokens. The difference between this function and strtok is that it respects the quoted string i.e. - it skips any delimiter character within the quoted part of the string. + it skips any delimiter character within the quoted part of the string. It return tokens by eliminating quote character. It modifies the input string passed. It will work with whitespace delimeter but may not work properly with other delimeter. If the delimeter will contain any quote character, then function will not tokenize and will return null string. - e.g. if input string is + e.g. if input string is --init-slave="set global max_connections=500" --skip-external-locking then the output will two string i.e. --init-slave=set global max_connections=500 @@ -1595,7 +1640,6 @@ Output: return the null terminated token of NULL. */ - char *str_tok(char *string, const char *delim) { char *token; /* current token received from strtok */ @@ -1607,40 +1651,38 @@ char *str_tok(char *string, const char *delim) char *ptr_token=NULL; /* pointer to the quote character in the token from strtok */ char *ptr_quote=NULL; - + /* See if the delimeter contains any quote character */ if (strchr(delim,'\'') || strchr(delim,'\"')) return NULL; /* repeate till we are getting some token from strtok */ - while ((token = (char*)strtok(string, delim) ) != NULL) + while ((token= (char*)strtok(string, delim) ) != NULL) { /* make the input string NULL so that next time onward strtok can be called with NULL input string. */ - string = NULL; - /* - We don't need to remove any quote character for Windows version - */ + string= NULL; + /* We don't need to remove any quote character for Windows version */ #ifndef __WIN__ /* check if the current token contain double quote character*/ - if ((ptr_quote = (char*)strchr(token,'\"')) != NULL) + if ((ptr_quote= (char*)strchr(token,'\"')) != NULL) { /* get the matching the matching double quote in the remaining input string */ - qt_token = (char*)strtok(NULL,"\""); + qt_token= (char*)strtok(NULL,"\""); } /* check if the current token contain single quote character*/ - else if ((ptr_quote = (char*)strchr(token,'\'')) != NULL) + else if ((ptr_quote= (char*)strchr(token,'\'')) != NULL) { /* get the matching the matching single quote in the remaining input string */ - qt_token = (char*)strtok(NULL,"\'"); + qt_token= (char*)strtok(NULL,"\'"); } #endif /* @@ -1663,7 +1705,7 @@ char *str_tok(char *string, const char *delim) and hence quote will be removed */ *ptr_quote= 0; - + /* check if ptr_token has been initialized or not */ if (ptr_token == NULL) { @@ -1678,18 +1720,18 @@ char *str_tok(char *string, const char *delim) copy the current token and entire string between matching pair of quote */ - if (qt_token == NULL) - { - sprintf(ptr_token+strlen(ptr_token),"%s%s", token, ptr_quote+1); - } - else - { - sprintf(ptr_token+strlen(ptr_token),"%s%s %s", token, ptr_quote+1, - qt_token ); - } + if (qt_token == NULL) + { + sprintf(ptr_token+strlen(ptr_token),"%s%s", token, ptr_quote+1); + } + else + { + sprintf(ptr_token+strlen(ptr_token),"%s%s %s", token, ptr_quote+1, + qt_token ); + } } } - + /* return the concatenated token */ return ptr_token; } @@ -1706,23 +1748,24 @@ Arguments: Output: nothing */ + void run_init_script(const char *script_name) { arg_list_t al; int err; - - // args + + /* args */ init_args(&al); add_arg(&al, sh_file); add_arg(&al, script_name); - - // spawn - if ((err = spawn(sh_file, &al, TRUE, NULL, NULL, NULL, NULL)) != 0) + + /* spawn */ + if ((err= spawn(sh_file, &al, TRUE, NULL, NULL, NULL, NULL)) != 0) { die("Unable to run script."); } - - // free args + + /* free args */ free_args(&al); } #endif From 11d7ba905cad3fd8f939575412c167a44dc16664 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Sun, 7 Nov 2004 09:42:27 +0000 Subject: [PATCH 089/101] wrong copyright --- ndb/src/common/editline/complete.c | 16 ---------------- ndb/src/common/editline/editline.c | 16 ---------------- ndb/src/common/editline/editline_internal.h | 16 ---------------- ndb/src/common/editline/sysunix.c | 16 ---------------- ndb/src/common/editline/unix.h | 16 ---------------- 5 files changed, 80 deletions(-) diff --git a/ndb/src/common/editline/complete.c b/ndb/src/common/editline/complete.c index d1f8b1d3ff4..c524a88c678 100644 --- a/ndb/src/common/editline/complete.c +++ b/ndb/src/common/editline/complete.c @@ -1,19 +1,3 @@ -/* Copyright (C) 2003 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 */ - /* -*- c-basic-offset: 4; -*- ** $Revision: 1.8 $ ** diff --git a/ndb/src/common/editline/editline.c b/ndb/src/common/editline/editline.c index 1e4c1ecba76..886dac2793b 100644 --- a/ndb/src/common/editline/editline.c +++ b/ndb/src/common/editline/editline.c @@ -1,19 +1,3 @@ -/* Copyright (C) 2003 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 */ - /* -*- c-basic-offset: 4; -*- ** $Revision: 1.6 $ ** diff --git a/ndb/src/common/editline/editline_internal.h b/ndb/src/common/editline/editline_internal.h index 5ed2b32a873..d82fa91c44b 100644 --- a/ndb/src/common/editline/editline_internal.h +++ b/ndb/src/common/editline/editline_internal.h @@ -1,19 +1,3 @@ -/* Copyright (C) 2003 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 */ - /* $Revision: 1.2 $ ** ** Internal header file for editline library. diff --git a/ndb/src/common/editline/sysunix.c b/ndb/src/common/editline/sysunix.c index d7437f6a9c7..b0242fb99ce 100644 --- a/ndb/src/common/editline/sysunix.c +++ b/ndb/src/common/editline/sysunix.c @@ -1,19 +1,3 @@ -/* Copyright (C) 2003 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 */ - /* $Revision: 1.4 $ ** ** Unix system-dependant routines for editline library. diff --git a/ndb/src/common/editline/unix.h b/ndb/src/common/editline/unix.h index 37f461b471d..c2fde7547b3 100644 --- a/ndb/src/common/editline/unix.h +++ b/ndb/src/common/editline/unix.h @@ -1,19 +1,3 @@ -/* Copyright (C) 2003 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 */ - /* $Revision: 1.3 $ ** ** Editline system header file for Unix. From b903a129e26e217cf3c891a604ec1733df8fa9ff Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 8 Nov 2004 01:13:54 +0200 Subject: [PATCH 090/101] Simpler arena swapping code Now thd->mem_root is a pointer to thd->main_mem_root and THR_MALLOC is a pointer to thd->mem_root. This gives us the following benefits: - Allow us to easily detect if arena has already been swapped before (this fixes a bug in setup_conds() where arena was swaped twice in some cases) - Faster swaps of arenas (as we don't have to copy the whole MEM_ROOT) - We don't anymore have to call my_pthread_setspecific_ptr(THR_MALLOC,...) to change where memory is alloced. Now it's enough to set thd->mem_root --- client/mysqltest.c | 8 -- include/config-win.h | 2 + mysql-test/t/rpl_failed_optimize-master.opt | 2 +- sql/ha_berkeley.cc | 10 ++- sql/item_cmpfunc.cc | 8 +- sql/item_func.cc | 7 +- sql/item_subselect.cc | 44 +++++------ sql/item_sum.cc | 30 +++---- sql/item_timefunc.cc | 6 +- sql/log_event.cc | 8 +- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 2 +- sql/opt_range.cc | 15 ++-- sql/repl_failsafe.cc | 2 +- sql/set_var.cc | 2 +- sql/sql_acl.cc | 10 ++- sql/sql_base.cc | 49 ++++++------ sql/sql_class.cc | 22 +++--- sql/sql_class.h | 32 ++++++-- sql/sql_db.cc | 2 +- sql/sql_error.cc | 6 +- sql/sql_help.cc | 14 ++-- sql/sql_insert.cc | 4 +- sql/sql_parse.cc | 24 +++--- sql/sql_prepare.cc | 6 +- sql/sql_select.cc | 8 +- sql/sql_select.h | 2 +- sql/sql_union.cc | 14 ++-- sql/sql_yacc.yy | 16 ++-- sql/table.cc | 14 ++-- sql/thr_malloc.cc | 2 +- tests/client_test.c | 86 ++++++++++++--------- 32 files changed, 243 insertions(+), 216 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index df80fc7bb66..a207da21af5 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -949,11 +949,7 @@ static void do_exec(struct st_query* q) while (fgets(buf, sizeof(buf), res_file)) replace_dynstr_append_mem(ds, buf, strlen(buf)); } -#ifndef __WIN__ error= pclose(res_file); -#else - error= _pclose(res_file); -#endif if (error != 0) die("command \"%s\" failed", cmd); @@ -4610,11 +4606,7 @@ FILE *my_popen(const char *cmd, const char *mode __attribute__((unused))) FILE *res_file; subst_cmd= subst_env_var(cmd); -#ifndef __WIN__ res_file= popen(subst_cmd, "r0"); -#else - res_file= _popen(subst_cmd, "r0"); -#endif my_free(subst_cmd, MYF(0)); return res_file; } diff --git a/include/config-win.h b/include/config-win.h index d28bb25cd09..946a91d7d42 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -175,6 +175,8 @@ typedef uint rf_SetTimer; #define sigset(A,B) signal((A),(B)) #define finite(A) _finite(A) #define sleep(A) Sleep((A)*1000) +#define popen(A) popen(A,B) _popen((A),(B)) +#define pclose(A) _pclose(A) #ifndef __BORLANDC__ #define access(A,B) _access(A,B) diff --git a/mysql-test/t/rpl_failed_optimize-master.opt b/mysql-test/t/rpl_failed_optimize-master.opt index a6ef074a120..3f82baff598 100644 --- a/mysql-test/t/rpl_failed_optimize-master.opt +++ b/mysql-test/t/rpl_failed_optimize-master.opt @@ -1 +1 @@ ---innodb-lock-wait-timeout=1 +--loose-innodb-lock-wait-timeout=1 diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 09b3e340d1f..2c7cce4bcd0 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -234,13 +234,13 @@ int berkeley_show_logs(Protocol *protocol) { char **all_logs, **free_logs, **a, **f; int error=1; - MEM_ROOT show_logs_root; - MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); + MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC); + MEM_ROOT show_logs_root, *old_mem_root= *root_ptr; DBUG_ENTER("berkeley_show_logs"); init_sql_alloc(&show_logs_root, BDB_LOG_ALLOC_BLOCK_SIZE, BDB_LOG_ALLOC_BLOCK_SIZE); - my_pthread_setspecific_ptr(THR_MALLOC,&show_logs_root); + *root_ptr= &show_logs_root; if ((error= db_env->log_archive(db_env, &all_logs, DB_ARCH_ABS | DB_ARCH_LOG)) || @@ -277,15 +277,17 @@ int berkeley_show_logs(Protocol *protocol) } err: free_root(&show_logs_root,MYF(0)); - my_pthread_setspecific_ptr(THR_MALLOC,old_root); + *root_ptr= old_mem_root; DBUG_RETURN(error); } + static void berkeley_print_error(const char *db_errpfx, char *buffer) { sql_print_error("%s: %s",db_errpfx,buffer); /* purecov: tested */ } + static void berkeley_noticecall(DB_ENV *db_env, db_notices notice) { switch (notice) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a28f0f5d4a9..c36f2d191c7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1744,9 +1744,9 @@ void Item_func_in::fix_length_and_dec() Conversion is possible: All IN arguments are constants. */ - Item_arena *arena= thd->current_arena, backup; - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); + Item_arena *arena, backup; + arena= thd->change_arena_if_needed(&backup); + for (arg= args+1, arg_end= args+arg_count; arg < arg_end; arg++) { if (!arg[0]->null_value && @@ -1764,7 +1764,7 @@ void Item_func_in::fix_length_and_dec() arg[0]= conv; } } - if (arena->is_stmt_prepare()) + if (arena) thd->restore_backup_item_arena(arena, &backup); } } diff --git a/sql/item_func.cc b/sql/item_func.cc index b382dbf7bf9..bf85e5b378a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -160,14 +160,13 @@ bool Item_func::agg_arg_charsets(DTCollation &coll, } THD *thd= current_thd; - Item_arena *arena= thd->current_arena, backup; + Item_arena *arena, backup; bool res= FALSE; /* In case we're in statement prepare, create conversion item in its memory: it will be reused on each execute. */ - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); + arena= thd->change_arena_if_needed(&backup); for (arg= args, last= args + nargs; arg < last; arg++) { @@ -193,7 +192,7 @@ bool Item_func::agg_arg_charsets(DTCollation &coll, conv->fix_fields(thd, 0, &conv); *arg= conv; } - if (arena->is_stmt_prepare()) + if (arena) thd->restore_backup_item_arena(arena, &backup); return res; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 401d4dee20f..62cd016b0df 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -190,15 +190,16 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) bool Item_subselect::exec() { int res; - MEM_ROOT *old_root= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC); - if (&thd->mem_root != old_root) - { - my_pthread_setspecific_ptr(THR_MALLOC, &thd->mem_root); - res= engine->exec(); - my_pthread_setspecific_ptr(THR_MALLOC, old_root); - } - else - res= engine->exec(); + MEM_ROOT *old_root= thd->mem_root; + + /* + As this is execution, all objects should be allocated through the main + mem root + */ + thd->mem_root= &thd->main_mem_root; + res= engine->exec(); + thd->mem_root= old_root; + if (engine_changed) { engine_changed= 0; @@ -312,7 +313,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join) /* Juggle with current arena only if we're in prepared statement prepare */ Item_arena *arena= join->thd->current_arena; - Item_arena backup; if (!select_lex->master_unit()->first_select()->next_select() && !select_lex->table_list.elements && @@ -655,11 +655,9 @@ Item_in_subselect::single_value_transformer(JOIN *join, } SELECT_LEX *select_lex= join->select_lex; - Item_arena *arena= join->thd->current_arena, backup; - + Item_arena *arena, backup; + arena= thd->change_arena_if_needed(&backup); thd->where= "scalar IN/ALL/ANY subquery"; - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); /* Check that the right part of the subselect contains no more than one @@ -892,7 +890,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SELECT_REDUCED, warn_buff); } - if (arena->is_stmt_prepare()) + if (arena) thd->restore_backup_item_arena(arena, &backup); DBUG_RETURN(RES_REDUCE); } @@ -900,13 +898,13 @@ Item_in_subselect::single_value_transformer(JOIN *join, } ok: - if (arena->is_stmt_prepare()) + if (arena) thd->restore_backup_item_arena(arena, &backup); thd->where= save_where; DBUG_RETURN(RES_OK); err: - if (arena->is_stmt_prepare()) + if (arena) thd->restore_backup_item_arena(arena, &backup); DBUG_RETURN(RES_ERROR); } @@ -922,14 +920,12 @@ Item_in_subselect::row_value_transformer(JOIN *join) { DBUG_RETURN(RES_OK); } - Item_arena *arena= join->thd->current_arena, backup; + Item_arena *arena, backup; Item *item= 0; + SELECT_LEX *select_lex= join->select_lex; thd->where= "row IN/ALL/ANY subquery"; - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); - - SELECT_LEX *select_lex= join->select_lex; + arena= thd->change_arena_if_needed(&backup); if (select_lex->item_list.elements != left_expr->cols()) { @@ -1006,13 +1002,13 @@ Item_in_subselect::row_value_transformer(JOIN *join) if (join->conds->fix_fields(thd, join->tables_list, 0)) goto err; } - if (arena->is_stmt_prepare()) + if (arena) thd->restore_backup_item_arena(arena, &backup); thd->where= save_where; DBUG_RETURN(RES_OK); err: - if (arena->is_stmt_prepare()) + if (arena) thd->restore_backup_item_arena(arena, &backup); DBUG_RETURN(RES_ERROR); } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index e6c96dd6a9a..3b3a6083725 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -254,7 +254,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) Item *Item_sum_sum::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_sum(thd, this); + return new (thd->mem_root) Item_sum_sum(thd, this); } @@ -282,7 +282,7 @@ double Item_sum_sum::val() Item *Item_sum_count::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_count(thd, this); + return new (thd->mem_root) Item_sum_count(thd, this); } @@ -327,7 +327,7 @@ void Item_sum_count::cleanup() Item *Item_sum_avg::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_avg(thd, this); + return new (thd->mem_root) Item_sum_avg(thd, this); } @@ -374,7 +374,7 @@ double Item_sum_std::val() Item *Item_sum_std::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_std(thd, this); + return new (thd->mem_root) Item_sum_std(thd, this); } @@ -384,7 +384,7 @@ Item *Item_sum_std::copy_or_same(THD* thd) Item *Item_sum_variance::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_variance(thd, this); + return new (thd->mem_root) Item_sum_variance(thd, this); } @@ -546,7 +546,7 @@ void Item_sum_hybrid::cleanup() Item *Item_sum_min::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_min(thd, this); + return new (thd->mem_root) Item_sum_min(thd, this); } @@ -599,7 +599,7 @@ bool Item_sum_min::add() Item *Item_sum_max::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_max(thd, this); + return new (thd->mem_root) Item_sum_max(thd, this); } @@ -666,7 +666,7 @@ void Item_sum_bit::clear() Item *Item_sum_or::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_or(thd, this); + return new (thd->mem_root) Item_sum_or(thd, this); } @@ -680,7 +680,7 @@ bool Item_sum_or::add() Item *Item_sum_xor::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_xor(thd, this); + return new (thd->mem_root) Item_sum_xor(thd, this); } @@ -694,7 +694,7 @@ bool Item_sum_xor::add() Item *Item_sum_and::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_and(thd, this); + return new (thd->mem_root) Item_sum_and(thd, this); } @@ -1337,7 +1337,7 @@ int Item_sum_count_distinct::tree_to_myisam() Item *Item_sum_count_distinct::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_count_distinct(thd, this); + return new (thd->mem_root) Item_sum_count_distinct(thd, this); } @@ -1438,7 +1438,7 @@ bool Item_udf_sum::add() Item *Item_sum_udf_float::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_udf_float(thd, this); + return new (thd->mem_root) Item_sum_udf_float(thd, this); } double Item_sum_udf_float::val() @@ -1463,7 +1463,7 @@ String *Item_sum_udf_float::val_str(String *str) Item *Item_sum_udf_int::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_udf_int(thd, this); + return new (thd->mem_root) Item_sum_udf_int(thd, this); } @@ -1501,7 +1501,7 @@ void Item_sum_udf_str::fix_length_and_dec() Item *Item_sum_udf_str::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_udf_str(thd, this); + return new (thd->mem_root) Item_sum_udf_str(thd, this); } @@ -1815,7 +1815,7 @@ Item_func_group_concat::~Item_func_group_concat() Item *Item_func_group_concat::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_func_group_concat(thd, this); + return new (thd->mem_root) Item_func_group_concat(thd, this); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f621953a5bc..41418c0094d 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -164,10 +164,10 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, CHARSET_INFO *cs= &my_charset_bin; int error= 0; bool usa_time= 0; - bool sunday_first_n_first_week_non_iso; + bool sunday_first_n_first_week_non_iso= -2; bool strict_week_number; int strict_week_number_year= -1; - bool strict_week_number_year_type; + bool strict_week_number_year_type= -1; int frac_part; const char *val_begin= val; const char *val_end= val + length; @@ -175,9 +175,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, const char *end= ptr + format->format.length; DBUG_ENTER("extract_date_time"); - LINT_INIT(sunday_first_n_first_week_non_iso); LINT_INIT(strict_week_number); - LINT_INIT(strict_week_number_year_type); if (!sub_pattern_end) bzero((char*) l_time, sizeof(*l_time)); diff --git a/sql/log_event.cc b/sql/log_event.cc index 326f2fc5c59..8e7f8062014 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1090,7 +1090,7 @@ end: thd->query_length= thd->db_length =0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); close_thread_tables(thd); - free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); + free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); /* If there was an error we stop. Otherwise we increment positions. Note that we will not increment group* positions if we are just after a SET @@ -1888,10 +1888,10 @@ Slave: load data infile on table '%s' at log position %s in log \ slave_print_error(rli,sql_errno,"\ Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'", err, (char*)table_name, print_slave_db_safe(db)); - free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); + free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); return 1; } - free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); + free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); if (thd->is_fatal_error) { @@ -2505,7 +2505,7 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli) */ e.fix_fields(thd, 0, 0); e.update_hash(val, val_len, type, charset, DERIVATION_NONE); - free_root(&thd->mem_root,0); + free_root(thd->mem_root,0); rli->inc_event_relay_log_pos(get_event_len()); return 0; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 770b7057661..3f55a88b262 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -910,7 +910,7 @@ extern char *default_tz_name; extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern FILE *bootstrap_file; -extern pthread_key(MEM_ROOT*,THR_MALLOC); +extern pthread_key(MEM_ROOT**,THR_MALLOC); extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status, LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index af6f25c1400..078ee19fe6a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -374,7 +374,7 @@ SHOW_COMP_OPTION have_crypt, have_compress; /* Thread specific variables */ -pthread_key(MEM_ROOT*,THR_MALLOC); +pthread_key(MEM_ROOT**,THR_MALLOC); pthread_key(THD*, THR_THD); pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, LOCK_mapped_file, LOCK_status, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c9528af7d98..d25901e56b1 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -400,7 +400,7 @@ QUICK_SELECT::QUICK_SELECT(THD *thd, TABLE *table, uint key_nr, bool no_alloc) { // Allocates everything through the internal memroot init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0); - my_pthread_setspecific_ptr(THR_MALLOC,&alloc); + thd->mem_root= &alloc; } else bzero((char*) &alloc,sizeof(alloc)); @@ -668,8 +668,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, DBUG_RETURN(0); // Can't use range } key_parts= param.key_parts; - old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); - my_pthread_setspecific_ptr(THR_MALLOC,&alloc); + old_root= thd->mem_root; + thd->mem_root= &alloc; key_info= head->key_info; for (idx=0 ; idx < head->keys ; idx++, key_info++) @@ -769,7 +769,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, } } free_root(&alloc,MYF(0)); // Return memory & allocator - my_pthread_setspecific_ptr(THR_MALLOC,old_root); + thd->mem_root= old_root; thd->no_errors=0; } DBUG_EXECUTE("info",print_quick(quick,&needed_reg);); @@ -2563,7 +2563,8 @@ static bool null_part_in_key(KEY_PART *key_part, const char *key, uint length) QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref) { - MEM_ROOT *old_root= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC); + MEM_ROOT *old_root= thd->mem_root; + /* The following call may change thd->mem_root */ QUICK_SELECT *quick= new QUICK_SELECT(thd, table, ref->key); KEY *key_info = &table->key_info[ref->key]; KEY_PART *key_part; @@ -2624,11 +2625,11 @@ QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref) } ok: - my_pthread_setspecific_ptr(THR_MALLOC, old_root); + thd->mem_root= old_root; return quick; err: - my_pthread_setspecific_ptr(THR_MALLOC, old_root); + thd->mem_root= old_root; delete quick; return 0; } diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 83fceca80ef..720e82f414e 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -92,7 +92,7 @@ static int init_failsafe_rpl_thread(THD* thd) VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); #endif - thd->mem_root.free=thd->mem_root.used=0; + thd->mem_root->free= thd->mem_root->used= 0; if (thd->variables.max_join_size == HA_POS_ERROR) thd->options|= OPTION_BIG_SELECTS; diff --git a/sql/set_var.cc b/sql/set_var.cc index 905bffac29a..a97506ad07c 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1165,7 +1165,7 @@ static void fix_max_connections(THD *thd, enum_var_type type) static void fix_thd_mem_root(THD *thd, enum_var_type type) { if (type != OPT_GLOBAL) - reset_root_defaults(&thd->mem_root, + reset_root_defaults(thd->mem_root, thd->variables.query_alloc_block_size, thd->variables.query_prealloc_size); } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index ff2dfedc30b..98dde1071c3 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2309,8 +2309,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, create_new_users= test_if_create_new_users(thd); int result=0; rw_wrlock(&LOCK_grant); - MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); - my_pthread_setspecific_ptr(THR_MALLOC,&memex); + MEM_ROOT *old_root= thd->mem_root; + thd->mem_root= &memex; while ((Str = str_list++)) { @@ -2415,7 +2415,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, } } grant_option=TRUE; - my_pthread_setspecific_ptr(THR_MALLOC,old_root); + thd->mem_root= old_root; rw_unlock(&LOCK_grant); if (!result) send_ok(thd); @@ -2549,6 +2549,7 @@ my_bool grant_init(THD *org_thd) THD *thd; TABLE_LIST tables[2]; MYSQL_LOCK *lock; + MEM_ROOT *memex_ptr; my_bool return_val= 1; TABLE *t_table, *c_table; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; @@ -2596,7 +2597,8 @@ my_bool grant_init(THD *org_thd) grant_option= TRUE; /* Will be restored by org_thd->store_globals() */ - my_pthread_setspecific_ptr(THR_MALLOC,&memex); + memex_ptr= &memex; + my_pthread_setspecific_ptr(THR_MALLOC, &memex_ptr); do { GRANT_TABLE *mem_check; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 839b92e7e7f..a5db02478ac 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -499,7 +499,7 @@ void close_temporary_tables(THD *thd) */ query_buf_size+= table->key_length+1; - if ((query = alloc_root(&thd->mem_root, query_buf_size))) + if ((query = alloc_root(thd->mem_root, query_buf_size))) // Better add "if exists", in case a RESET MASTER has been done end=strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS "); @@ -2311,18 +2311,16 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, if (!wild_num) DBUG_RETURN(0); - Item_arena *arena= thd->current_arena, backup; - + reg2 Item *item; + List_iterator it(fields); + Item_arena *arena, backup; /* If we are in preparing prepared statement phase then we have change temporary mem_root to statement mem root to save changes of SELECT list */ - if ((is_stmt_prepare= arena->is_stmt_prepare())) - thd->set_n_backup_item_arena(arena, &backup); + arena= thd->change_arena_if_needed(&backup); - reg2 Item *item; - List_iterator it(fields); - while ( wild_num && (item= it++)) + while (wild_num && (item= it++)) { if (item->type() == Item::FIELD_ITEM && ((Item_field*) item)->field_name && @@ -2344,7 +2342,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, else if (insert_fields(thd,tables,((Item_field*) item)->db_name, ((Item_field*) item)->table_name, &it)) { - if (is_stmt_prepare) + if (arena) thd->restore_backup_item_arena(arena, &backup); DBUG_RETURN(-1); } @@ -2360,7 +2358,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, wild_num--; } } - if (is_stmt_prepare) + if (arena) thd->restore_backup_item_arena(arena, &backup); DBUG_RETURN(0); } @@ -2589,11 +2587,10 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) { table_map not_null_tables= 0; - Item_arena *arena= thd->current_arena, backup; - bool is_stmt_prepare= arena->is_stmt_prepare(); + Item_arena *arena= 0, backup; DBUG_ENTER("setup_conds"); + thd->set_query_id=1; - thd->lex->current_select->cond_count= 0; if (*conds) { @@ -2628,12 +2625,14 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) !(specialflag & SPECIAL_NO_NEW_FUNC))) { table->outer_join= 0; - if (is_stmt_prepare) - thd->set_n_backup_item_arena(arena, &backup); + arena= thd->change_arena_if_needed(&backup); *conds= and_conds(*conds, table->on_expr); table->on_expr=0; - if (is_stmt_prepare) + if (arena) + { thd->restore_backup_item_arena(arena, &backup); + arena= 0; // Safety if goto err + } if ((*conds) && !(*conds)->fixed && (*conds)->fix_fields(thd, tables, conds)) DBUG_RETURN(1); @@ -2641,8 +2640,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) } if (table->natural_join) { - if (is_stmt_prepare) - thd->set_n_backup_item_arena(arena, &backup); + arena= thd->change_arena_if_needed(&backup); /* Make a join of all fields with have the same name */ TABLE *t1= table->table; TABLE *t2= table->natural_join->table; @@ -2683,7 +2681,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) { *conds= and_conds(*conds, cond_and); // fix_fields() should be made with temporary memory pool - if (is_stmt_prepare) + if (arena) thd->restore_backup_item_arena(arena, &backup); if (*conds && !(*conds)->fixed) { @@ -2695,7 +2693,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) { table->on_expr= and_conds(table->on_expr, cond_and); // fix_fields() should be made with temporary memory pool - if (is_stmt_prepare) + if (arena) thd->restore_backup_item_arena(arena, &backup); if (table->on_expr && !table->on_expr->fixed) { @@ -2704,12 +2702,15 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) } } } - else if (is_stmt_prepare) + else if (arena) + { thd->restore_backup_item_arena(arena, &backup); + arena= 0; // Safety if goto err + } } } - if (is_stmt_prepare) + if (thd->current_arena->is_stmt_prepare()) { /* We are in prepared statement preparation code => we should store @@ -2722,8 +2723,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) DBUG_RETURN(test(thd->net.report_error)); err: - if (is_stmt_prepare) - thd->restore_backup_item_arena(arena, &backup); + if (arena) + thd->restore_backup_item_arena(arena, &backup); DBUG_RETURN(1); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7ad20967de0..eda60b5cfdb 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -305,7 +305,7 @@ void THD::init_for_queries() { ha_enable_transaction(this,TRUE); - reset_root_defaults(&mem_root, variables.query_alloc_block_size, + reset_root_defaults(mem_root, variables.query_alloc_block_size, variables.query_prealloc_size); reset_root_defaults(&transaction.mem_root, variables.trans_alloc_block_size, @@ -411,7 +411,7 @@ THD::~THD() dbug_sentry = THD_SENTRY_GONE; #endif /* Reset stmt_backup.mem_root to not double-free memory from thd.mem_root */ - clear_alloc_root(&stmt_backup.mem_root); + clear_alloc_root(&stmt_backup.main_mem_root); DBUG_VOID_RETURN; } @@ -1394,10 +1394,10 @@ void select_dumpvar::cleanup() for memory root initialization. */ Item_arena::Item_arena(THD* thd) - :free_list(0), - state(INITIALIZED) + :free_list(0), mem_root(&main_mem_root), + state(INITIALIZED) { - init_sql_alloc(&mem_root, + init_sql_alloc(&main_mem_root, thd->variables.query_alloc_block_size, thd->variables.query_prealloc_size); } @@ -1420,11 +1420,11 @@ Item_arena::Item_arena(THD* thd) statements. */ Item_arena::Item_arena(bool init_mem_root) - :free_list(0), + :free_list(0), mem_root(&main_mem_root), state(CONVENTIONAL_EXECUTION) { if (init_mem_root) - init_sql_alloc(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0); + init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0); } @@ -1518,13 +1518,16 @@ void THD::end_statement() void Item_arena::set_n_backup_item_arena(Item_arena *set, Item_arena *backup) { + DBUG_ENTER("Item_arena::set_n_backup_item_arena"); backup->set_item_arena(this); set_item_arena(set); + DBUG_VOID_RETURN; } void Item_arena::restore_backup_item_arena(Item_arena *set, Item_arena *backup) { + DBUG_ENTER("Item_arena::restore_backup_item_arena"); set->set_item_arena(this); set_item_arena(backup); #ifdef NOT_NEEDED_NOW @@ -1537,18 +1540,19 @@ void Item_arena::restore_backup_item_arena(Item_arena *set, Item_arena *backup) */ clear_alloc_root(&backup->mem_root); #endif + DBUG_VOID_RETURN; } void Item_arena::set_item_arena(Item_arena *set) { - mem_root= set->mem_root; + mem_root= set->mem_root; free_list= set->free_list; state= set->state; } Statement::~Statement() { - free_root(&mem_root, MYF(0)); + free_root(&main_mem_root, MYF(0)); } C_MODE_START diff --git a/sql/sql_class.h b/sql/sql_class.h index e73b35966a9..df6be559df2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -429,7 +429,8 @@ public: itself to the list on creation (see Item::Item() for details)) */ Item *free_list; - MEM_ROOT mem_root; + MEM_ROOT main_mem_root; + MEM_ROOT *mem_root; // Pointer to current memroot enum enum_state { INITIALIZED= 0, PREPARED= 1, EXECUTED= 3, CONVENTIONAL_EXECUTION= 2, @@ -468,24 +469,24 @@ public: { return state == PREPARED || state == EXECUTED; } inline bool is_conventional_execution() const { return state == CONVENTIONAL_EXECUTION; } - inline gptr alloc(unsigned int size) { return alloc_root(&mem_root,size); } + inline gptr alloc(unsigned int size) { return alloc_root(mem_root,size); } inline gptr calloc(unsigned int size) { gptr ptr; - if ((ptr=alloc_root(&mem_root,size))) + if ((ptr=alloc_root(mem_root,size))) bzero((char*) ptr,size); return ptr; } inline char *strdup(const char *str) - { return strdup_root(&mem_root,str); } + { return strdup_root(mem_root,str); } inline char *strmake(const char *str, uint size) - { return strmake_root(&mem_root,str,size); } + { return strmake_root(mem_root,str,size); } inline char *memdup(const char *str, uint size) - { return memdup_root(&mem_root,str,size); } + { return memdup_root(mem_root,str,size); } inline char *memdup_w_gap(const char *str, uint size, uint gap) { gptr ptr; - if ((ptr=alloc_root(&mem_root,size+gap))) + if ((ptr=alloc_root(mem_root,size+gap))) memcpy(ptr,str,size); return ptr; } @@ -1052,11 +1053,26 @@ public: inline CHARSET_INFO *charset() { return variables.character_set_client; } void update_charset(); + inline Item_arena *change_arena_if_needed(Item_arena *backup) + { + /* + use new arena if we are in a prepared statements and we have not + already changed to use this arena. + */ + if (current_arena->is_stmt_prepare() && + mem_root != ¤t_arena->main_mem_root) + { + set_n_backup_item_arena(current_arena, backup); + return current_arena; + } + return 0; + } + void change_item_tree(Item **place, Item *new_value) { /* TODO: check for OOM condition here */ if (!current_arena->is_conventional_execution()) - nocheck_register_item_tree_change(place, *place, &mem_root); + nocheck_register_item_tree_change(place, *place, mem_root); *place= new_value; } void nocheck_register_item_tree_change(Item **place, Item *old_value, diff --git a/sql/sql_db.cc b/sql/sql_db.cc index eb851e79d2e..e50796f2a33 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -725,7 +725,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, if ((mysql_rm_known_files(thd, new_dirp, NullS, newpath,1)) < 0) goto err; if (!(copy_of_path= thd->memdup(newpath, length+1)) || - !(dir= new (&thd->mem_root) String(copy_of_path, length, + !(dir= new (thd->mem_root) String(copy_of_path, length, &my_charset_bin)) || raid_dirs.push_back(dir)) goto err; diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 87644300535..eab5ec890df 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -113,12 +113,12 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, The following code is here to change the allocation to not use the thd->mem_root, which is freed after each query */ - MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); - my_pthread_setspecific_ptr(THR_MALLOC, &thd->warn_root); + MEM_ROOT *old_root= thd->mem_root; + thd->mem_root= &thd->warn_root; err= new MYSQL_ERROR(thd, code, level, msg); if (err) thd->warn_list.push_back(err); - my_pthread_setspecific_ptr(THR_MALLOC, old_root); + thd->mem_root= old_root; } thd->warn_count[(uint) level]++; thd->total_warn_count++; diff --git a/sql/sql_help.cc b/sql/sql_help.cc index ffaaafc26e6..04ecbbd43b9 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -127,7 +127,7 @@ void memorize_variant_topic(THD *thd, TABLE *topics, int count, String *name, String *description, String *example) { DBUG_ENTER("memorize_variant_topic"); - MEM_ROOT *mem_root= &thd->mem_root; + MEM_ROOT *mem_root= thd->mem_root; if (count==0) { get_field(mem_root,find_fields[help_topic_name].field, name); @@ -138,7 +138,7 @@ void memorize_variant_topic(THD *thd, TABLE *topics, int count, { if (count == 1) names->push_back(name); - String *new_name= new (&thd->mem_root) String; + String *new_name= new (thd->mem_root) String; get_field(mem_root,find_fields[help_topic_name].field,new_name); names->push_back(new_name); } @@ -351,8 +351,8 @@ int search_categories(THD *thd, TABLE *categories, { if (select && !select->cond->val_int()) continue; - String *lname= new (&thd->mem_root) String; - get_field(&thd->mem_root,pfname,lname); + String *lname= new (thd->mem_root) String; + get_field(thd->mem_root,pfname,lname); if (++count == 1 && res_id) *res_id= (int16) pcat_id->val_int(); names->push_back(lname); @@ -385,8 +385,8 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname, { if (!select->cond->val_int()) continue; - String *name= new (&thd->mem_root) String(); - get_field(&thd->mem_root,pfname,name); + String *name= new (thd->mem_root) String(); + get_field(thd->mem_root,pfname,name); res->push_back(name); } end_read_record(&read_record_info); @@ -638,7 +638,7 @@ int mysqld_help(THD *thd, const char *mask) String name, description, example; int res, count_topics, count_categories, error; uint mlen= strlen(mask); - MEM_ROOT *mem_root= &thd->mem_root; + MEM_ROOT *mem_root= thd->mem_root; if (open_and_lock_tables(thd, tables)) { diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 648549ca3ac..822ce622b1b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -202,7 +202,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, { /* it should be allocated before Item::fix_fields() */ table->insert_values= - (byte *)alloc_root(&thd->mem_root, table->rec_buff_length); + (byte *)alloc_root(thd->mem_root, table->rec_buff_length); if (!table->insert_values) goto abort; } @@ -924,7 +924,7 @@ TABLE *delayed_insert::get_local_table(THD* client_thd) found_next_number_field=table->found_next_number_field; for (org_field=table->field ; *org_field ; org_field++,field++) { - if (!(*field= (*org_field)->new_field(&client_thd->mem_root,copy))) + if (!(*field= (*org_field)->new_field(client_thd->mem_root,copy))) return 0; (*field)->orig_table= copy; // Remove connection (*field)->move_field(adjust_ptrs); // Point at copy->record[0] diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f5b9bc0638f..2bf977804af 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1026,7 +1026,7 @@ pthread_handler_decl(handle_one_connection,arg) } if (thd->user_connect) decrease_user_connections(thd->user_connect); - free_root(&thd->mem_root,MYF(0)); + free_root(thd->mem_root,MYF(0)); if (net->error && net->vio != 0 && net->report_error) { if (!thd->killed && thd->variables.log_warnings > 1) @@ -1121,14 +1121,14 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) { thd->net.error = 0; close_thread_tables(thd); // Free tables - free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); + free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); break; } mysql_parse(thd,thd->query,length); close_thread_tables(thd); // Free tables if (thd->is_fatal_error) break; - free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); + free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); free_root(&thd->transaction.mem_root,MYF(MY_KEEP_PREALLOC)); } @@ -1681,7 +1681,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #endif close_connection(thd, 0, 1); close_thread_tables(thd); // Free before kill - free_root(&thd->mem_root,MYF(0)); + free_root(thd->mem_root,MYF(0)); free_root(&thd->transaction.mem_root,MYF(0)); kill_mysql(); error=TRUE; @@ -1808,7 +1808,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thread_running--; VOID(pthread_mutex_unlock(&LOCK_thread_count)); thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory - free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); + free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); DBUG_RETURN(error); } @@ -2062,7 +2062,7 @@ mysql_execute_command(THD *thd) query_len= need_conversion? (pstr->length() * to_cs->mbmaxlen) : pstr->length(); - if (!(query_str= alloc_root(&thd->mem_root, query_len+1))) + if (!(query_str= alloc_root(thd->mem_root, query_len+1))) { res= -1; break; // EOM (error should be reported by allocator) @@ -3937,8 +3937,8 @@ mysql_init_select(LEX *lex) bool mysql_new_select(LEX *lex, bool move_down) { - SELECT_LEX *select_lex = new(&lex->thd->mem_root) SELECT_LEX(); - if (!select_lex) + SELECT_LEX *select_lex; + if (!(select_lex= new(lex->thd->mem_root) SELECT_LEX())) return 1; select_lex->select_number= ++lex->thd->select_number; select_lex->init_query(); @@ -3946,9 +3946,10 @@ mysql_new_select(LEX *lex, bool move_down) if (move_down) { /* first select_lex of subselect or derived table */ - SELECT_LEX_UNIT *unit= new(&lex->thd->mem_root) SELECT_LEX_UNIT(); - if (!unit) + SELECT_LEX_UNIT *unit; + if (!(unit= new(lex->thd->mem_root) SELECT_LEX_UNIT())) return 1; + unit->init_query(); unit->init_select(); unit->thd= lex->thd; @@ -3970,7 +3971,8 @@ mysql_new_select(LEX *lex, bool move_down) as far as we included SELECT_LEX for UNION unit should have fake SELECT_LEX for UNION processing */ - fake= unit->fake_select_lex= new(&lex->thd->mem_root) SELECT_LEX(); + if (!(fake= unit->fake_select_lex= new(lex->thd->mem_root) SELECT_LEX())) + return 1; fake->include_standalone(unit, (SELECT_LEX_NODE**)&unit->fake_select_lex); fake->select_number= INT_MAX; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 4ae69e40342..d81ed2cd014 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1065,7 +1065,7 @@ static int mysql_test_select(Prepared_statement *stmt, DBUG_RETURN(1); #endif - if (!lex->result && !(lex->result= new (&stmt->mem_root) select_send)) + if (!lex->result && !(lex->result= new (stmt->mem_root) select_send)) { send_error(thd); goto err; @@ -1503,7 +1503,7 @@ static bool init_param_array(Prepared_statement *stmt) List_iterator param_iterator(lex->param_list); /* Use thd->mem_root as it points at statement mem_root */ stmt->param_array= (Item_param **) - alloc_root(&stmt->thd->mem_root, + alloc_root(stmt->thd->mem_root, sizeof(Item_param*) * stmt->param_count); if (!stmt->param_array) { @@ -1569,7 +1569,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, if (name) { stmt->name.length= name->length; - if (!(stmt->name.str= memdup_root(&stmt->mem_root, (char*)name->str, + if (!(stmt->name.str= memdup_root(stmt->mem_root, (char*)name->str, name->length))) { delete stmt; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index df74a946b5c..089bb150bbd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4603,7 +4603,7 @@ static Field* create_tmp_field_from_field(THD *thd, Field* org_field, org_field->field_name, table, org_field->charset()); else - new_field= org_field->new_field(&thd->mem_root, table); + new_field= org_field->new_field(thd->mem_root, table); if (new_field) { if (modify_item) @@ -5206,7 +5206,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, if (!using_unique_constraint) { group->buff=(char*) group_buff; - if (!(group->field=field->new_field(&thd->mem_root,table))) + if (!(group->field=field->new_field(thd->mem_root,table))) goto err; /* purecov: inspected */ if (maybe_null) { @@ -8499,7 +8499,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, saved value */ Field *field= item->field; - item->result_field=field->new_field(&thd->mem_root,field->table); + item->result_field=field->new_field(thd->mem_root,field->table); char *tmp=(char*) sql_alloc(field->pack_length()+1); if (!tmp) goto err; @@ -8942,7 +8942,7 @@ bool JOIN::rollup_init() return 1; rollup.ref_pointer_arrays= (Item***) (rollup.fields + send_group_parts); ref_array= (Item**) (rollup.ref_pointer_arrays+send_group_parts); - rollup.item_null= new (&thd->mem_root) Item_null(); + rollup.item_null= new (thd->mem_root) Item_null(); /* Prepare space for field list for the different levels diff --git a/sql/sql_select.h b/sql/sql_select.h index 34eaa7e272d..bbd169d1850 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -354,7 +354,7 @@ class store_key :public Sql_alloc field_arg->table, field_arg->charset()); else { - to_field=field_arg->new_field(&thd->mem_root,field_arg->table); + to_field=field_arg->new_field(thd->mem_root,field_arg->table); if (to_field) to_field->move_field(ptr, (uchar*) null, 1); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 0be554f58a2..e0e8f8d42c5 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -313,24 +313,24 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, We're in statement prepare or in execution of a conventional statement. */ - Item_arena backup; - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); + Item_arena *tmp_arena,backup; + tmp_arena= thd->change_arena_if_needed(&backup); + Field **field; for (field= table->field; *field; field++) { Item_field *item= new Item_field(*field); if (!item || item_list.push_back(item)) { - if (arena->is_stmt_prepare()) - thd->restore_backup_item_arena(arena, &backup); + if (tmp_arena) + thd->restore_backup_item_arena(tmp_arena, &backup); DBUG_RETURN(-1); } } + if (tmp_arena) + thd->restore_backup_item_arena(tmp_arena, &backup); if (arena->is_stmt_prepare()) { - thd->restore_backup_item_arena(arena, &backup); - /* prepare fake select to initialize it correctly */ ulong options_tmp= init_prepare_fake_select_lex(thd); if (!(fake_select_lex->join= new JOIN(thd, item_list, thd->options, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 4538cb6e6ac..94c0fe3cf0c 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3297,7 +3297,7 @@ opt_distinct: |DISTINCT { $$ = 1; }; opt_gconcat_separator: - /* empty */ { $$ = new (&YYTHD->mem_root) String(",",1,default_charset_info); } + /* empty */ { $$ = new (YYTHD->mem_root) String(",",1,default_charset_info); } |SEPARATOR_SYM text_string { $$ = $2; }; @@ -3551,15 +3551,15 @@ key_list_or_empty: key_usage_list2: key_usage_list2 ',' ident { Select-> - interval_list.push_back(new (&YYTHD->mem_root) String((const char*) $3.str, $3.length, + interval_list.push_back(new (YYTHD->mem_root) String((const char*) $3.str, $3.length, system_charset_info)); } | ident { Select-> - interval_list.push_back(new (&YYTHD->mem_root) String((const char*) $1.str, $1.length, + interval_list.push_back(new (YYTHD->mem_root) String((const char*) $1.str, $1.length, system_charset_info)); } | PRIMARY_SYM { Select-> - interval_list.push_back(new (&YYTHD->mem_root) String("PRIMARY", 7, + interval_list.push_back(new (YYTHD->mem_root) String("PRIMARY", 7, system_charset_info)); }; using_list: @@ -4507,7 +4507,7 @@ opt_db: wild: /* empty */ | LIKE TEXT_STRING_sys - { Lex->wild= new (&YYTHD->mem_root) String($2.str, $2.length, + { Lex->wild= new (YYTHD->mem_root) String($2.str, $2.length, system_charset_info); }; opt_full: @@ -4561,7 +4561,7 @@ opt_describe_column: /* empty */ {} | text_string { Lex->wild= $1; } | ident - { Lex->wild= new (&YYTHD->mem_root) String((const char*) $1.str,$1.length,system_charset_info); }; + { Lex->wild= new (YYTHD->mem_root) String((const char*) $1.str,$1.length,system_charset_info); }; /* flush things */ @@ -4802,7 +4802,7 @@ text_literal: text_string: TEXT_STRING_literal - { $$= new (&YYTHD->mem_root) String($1.str,$1.length,YYTHD->variables.collation_connection); } + { $$= new (YYTHD->mem_root) String($1.str,$1.length,YYTHD->variables.collation_connection); } | HEX_NUM { Item *tmp = new Item_varbinary($1.str,$1.length); @@ -5821,7 +5821,7 @@ column_list: column_list_id: ident { - String *new_str = new (&YYTHD->mem_root) String((const char*) $1.str,$1.length,system_charset_info); + String *new_str = new (YYTHD->mem_root) String((const char*) $1.str,$1.length,system_charset_info); List_iterator iter(Lex->columns); class LEX_COLUMN *point; LEX *lex=Lex; diff --git a/sql/table.cc b/sql/table.cc index 3ae3d668407..20ac714020d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -81,6 +81,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, uchar *null_pos; uint null_bit, new_frm_ver, field_pack_length; SQL_CRYPT *crypted=0; + MEM_ROOT **root_ptr, *old_root; DBUG_ENTER("openfrm"); DBUG_PRINT("enter",("name: '%s' form: %lx",name,outparam)); @@ -91,8 +92,9 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, error=1; init_sql_alloc(&outparam->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0); - MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); - my_pthread_setspecific_ptr(THR_MALLOC,&outparam->mem_root); + root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**, THR_MALLOC); + old_root= *root_ptr; + *root_ptr= &outparam->mem_root; outparam->real_name=strdup_root(&outparam->mem_root, name+dirname_length(name)); @@ -251,9 +253,9 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, #ifdef HAVE_CRYPTED_FRM else if (*(head+26) == 2) { - my_pthread_setspecific_ptr(THR_MALLOC,old_root); + *root_ptr= old_root crypted=get_crypt_for_frm(); - my_pthread_setspecific_ptr(THR_MALLOC,&outparam->mem_root); + *root_ptr= &outparam->mem_root; outparam->crypted=1; } #endif @@ -736,7 +738,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, } outparam->db_low_byte_first=outparam->file->low_byte_first(); - my_pthread_setspecific_ptr(THR_MALLOC,old_root); + *root_ptr= old_root; opened_tables++; #ifndef DBUG_OFF if (use_hash) @@ -751,7 +753,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, err_end: /* Here when no file */ delete crypted; - my_pthread_setspecific_ptr(THR_MALLOC,old_root); + *root_ptr= old_root; frm_error(error,outparam,name,ME_ERROR+ME_WAITTANG); delete outparam->file; outparam->file=0; // For easyer errorchecking diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index 0df60858bcb..3a9ca397bba 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -38,7 +38,7 @@ void init_sql_alloc(MEM_ROOT *mem_root, uint block_size, uint pre_alloc) gptr sql_alloc(uint Size) { - MEM_ROOT *root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); + MEM_ROOT *root= *my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC); char *ptr= (char*) alloc_root(root,Size); return ptr; } diff --git a/tests/client_test.c b/tests/client_test.c index 004f076c6df..1578f8c7d95 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -97,11 +97,12 @@ void die(const char *file, int line, const char *expr) #define myerror(msg) print_error(msg) #define mysterror(stmt, msg) print_st_error(stmt, msg) -#define myquery(r) \ +#define myquery(RES) \ { \ -if (r) \ - myerror(NULL); \ - DIE_UNLESS(r == 0); \ + int r= (RES); \ + if (r) \ + myerror(NULL); \ + DIE_UNLESS(r == 0); \ } #define myquery_r(r) \ @@ -282,38 +283,40 @@ static void client_query() myheader("client_query"); - rc= mysql_query(mysql, "DROP TABLE IF EXISTS myclient_test"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - rc= mysql_query(mysql, "CREATE TABLE myclient_test(" + rc= mysql_query(mysql, "CREATE TABLE t1(" "id int primary key auto_increment, " "name varchar(20))"); myquery(rc); - rc= mysql_query(mysql, "CREATE TABLE myclient_test(id int, name varchar(20))"); + rc= mysql_query(mysql, "CREATE TABLE t1(id int, name varchar(20))"); myquery_r(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('mysql')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('mysql')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('monty')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('monty')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('venu')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('venu')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('deleted')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('deleted')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')"); myquery(rc); - rc= mysql_query(mysql, "UPDATE myclient_test SET name= 'updated' " + rc= mysql_query(mysql, "UPDATE t1 SET name= 'updated' " "WHERE name= 'deleted'"); myquery(rc); - rc= mysql_query(mysql, "UPDATE myclient_test SET id= 3 WHERE name= 'updated'"); + rc= mysql_query(mysql, "UPDATE t1 SET id= 3 WHERE name= 'updated'"); myquery_r(rc); + + myquery(mysql_query(mysql, "drop table t1")); } @@ -743,7 +746,7 @@ static void client_store_result() myheader("client_store_result"); - rc= mysql_query(mysql, "SELECT * FROM myclient_test"); + rc= mysql_query(mysql, "SELECT * FROM t1"); myquery(rc); /* get the result */ @@ -763,7 +766,7 @@ static void client_use_result() int rc; myheader("client_use_result"); - rc= mysql_query(mysql, "SELECT * FROM myclient_test"); + rc= mysql_query(mysql, "SELECT * FROM t1"); myquery(rc); /* get the result */ @@ -7537,17 +7540,17 @@ static void test_fetch_seek() char c2[11], c3[20]; myheader("test_fetch_seek"); + rc= mysql_query(mysql, "drop table if exists t1"); - rc= mysql_query(mysql, "drop table if exists test_seek"); myquery(rc); - rc= mysql_query(mysql, "create table test_seek(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))"); + rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))"); myquery(rc); - rc= mysql_query(mysql, "insert into test_seek(c2) values('venu'), ('mysql'), ('open'), ('source')"); + rc= mysql_query(mysql, "insert into t1(c2) values('venu'), ('mysql'), ('open'), ('source')"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "select * from test_seek"); + stmt= mysql_simple_prepare(mysql, "select * from t1"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7620,6 +7623,7 @@ static void test_fetch_seek() DIE_UNLESS(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); + myquery(mysql_query(mysql, "drop table t1")); } @@ -7637,16 +7641,16 @@ static void test_fetch_offset() myheader("test_fetch_offset"); - rc= mysql_query(mysql, "drop table if exists test_column"); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); - rc= mysql_query(mysql, "create table test_column(a char(10))"); + rc= mysql_query(mysql, "create table t1(a char(10))"); myquery(rc); - rc= mysql_query(mysql, "insert into test_column values('abcdefghij'), (null)"); + rc= mysql_query(mysql, "insert into t1 values('abcdefghij'), (null)"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "select * from test_column"); + stmt= mysql_simple_prepare(mysql, "select * from t1"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7706,6 +7710,8 @@ static void test_fetch_offset() check_execute_r(stmt, rc); mysql_stmt_close(stmt); + + myquery(mysql_query(mysql, "drop table t1")); } @@ -7721,16 +7727,16 @@ static void test_fetch_column() myheader("test_fetch_column"); - rc= mysql_query(mysql, "drop table if exists test_column"); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); - rc= mysql_query(mysql, "create table test_column(c1 int primary key auto_increment, c2 char(10))"); + rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10))"); myquery(rc); - rc= mysql_query(mysql, "insert into test_column(c2) values('venu'), ('mysql')"); + rc= mysql_query(mysql, "insert into t1(c2) values('venu'), ('mysql')"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "select * from test_column order by c2 desc"); + stmt= mysql_simple_prepare(mysql, "select * from t1 order by c2 desc"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7841,6 +7847,7 @@ static void test_fetch_column() check_execute_r(stmt, rc); mysql_stmt_close(stmt); + myquery(mysql_query(mysql, "drop table t1")); } @@ -7852,27 +7859,28 @@ static void test_list_fields() int rc; myheader("test_list_fields"); - rc= mysql_query(mysql, "drop table if exists test_list_fields"); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); - rc= mysql_query(mysql, "create table test_list_fields(c1 int primary key auto_increment, c2 char(10) default 'mysql')"); + rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10) default 'mysql')"); myquery(rc); - result= mysql_list_fields(mysql, "test_list_fields", NULL); + result= mysql_list_fields(mysql, "t1", NULL); mytest(result); rc= my_process_result_set(result); DIE_UNLESS(rc == 0); verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_LONG, - "test_list_fields", "test_list_fields", + "t1", "t1", current_db, 11, "0"); verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_STRING, - "test_list_fields", "test_list_fields", + "t1", "t1", current_db, 10, "mysql"); mysql_free_result(result); + myquery(mysql_query(mysql, "drop table t1")); } @@ -11140,11 +11148,13 @@ static void test_bug4172() res= mysql_store_result(mysql); row= mysql_fetch_row(res); - printf("Binary protocol: float=%s, double=%s, decimal(10,4)=%s\n", - f, d, e); - printf("Text protocol: float=%s, double=%s, decimal(10,4)=%s\n", - row[0], row[1], row[2]); - + if (!opt_silent) + { + printf("Binary protocol: float=%s, double=%s, decimal(10,4)=%s\n", + f, d, e); + printf("Text protocol: float=%s, double=%s, decimal(10,4)=%s\n", + row[0], row[1], row[2]); + } DIE_UNLESS(!strcmp(f, row[0]) && !strcmp(d, row[1]) && !strcmp(e, row[2])); mysql_free_result(res); From 07f9c634adc8dc73b514b763c1ea6acd830dce87 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 8 Nov 2004 01:51:10 +0200 Subject: [PATCH 091/101] After merge fixes --- sql/item.cc | 7 +++++++ sql/item.h | 1 + sql/item_func.cc | 2 ++ 3 files changed, 10 insertions(+) diff --git a/sql/item.cc b/sql/item.cc index 1f90b1842ac..14ba097cf6d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1733,6 +1733,13 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) return 0; } +Item *Item_field::safe_charset_converter(CHARSET_INFO *tocs) +{ + no_const_subst= 1; + return Item::safe_charset_converter(tocs); +} + + void Item_field::cleanup() { DBUG_ENTER("Item_field::cleanup"); diff --git a/sql/item.h b/sql/item.h index 11aeb22b6e5..37583143548 100644 --- a/sql/item.h +++ b/sql/item.h @@ -561,6 +561,7 @@ public: bool replace_equal_field_processor(byte *arg); inline uint32 max_disp_length() { return field->max_length(); } Item_field *filed_for_view_update() { return this; } + Item *safe_charset_converter(CHARSET_INFO *tocs); friend class Item_default_value; friend class Item_insert_value; friend class st_select_lex_unit; diff --git a/sql/item_func.cc b/sql/item_func.cc index 173b1b3fd82..583371aed32 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -193,6 +193,8 @@ bool Item_func::agg_arg_charsets(DTCollation &coll, res= TRUE; break; // we cannot return here, we need to restore "arena". } + if ((*arg)->type() == FIELD_ITEM) + ((Item_field *)(*arg))->no_const_subst= 1; conv->fix_fields(thd, 0, &conv); *arg= conv; } From 401ede54b71028c5b4cb85a0a7deb520f5ed989d Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 8 Nov 2004 16:36:25 +0200 Subject: [PATCH 092/101] Fixed typo --- sql/sql_select.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2e1429feb3e..53c66e9b192 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1497,6 +1497,7 @@ JOIN::exec() are fixed or do not need fix_fields, too */ curr_table->select->cond->quick_fix_field(); + cur_tabl } curr_table->select_cond= curr_table->select->cond; curr_table->select_cond->top_level_item(); @@ -5018,7 +5019,7 @@ add_found_match_trig_cond(JOIN_TAB *tab, COND *cond, JOIN_TAB *root_tab) { tmp= new Item_func_trig_cond(tmp, &tab->found); } - if (!tmp) + if (tmp) tmp->quick_fix_field(); return tmp; } From 2bba55b57fba78b018fe3ed64bafb7ea4b0c9d5c Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 9 Nov 2004 03:58:44 +0200 Subject: [PATCH 093/101] After merge fixes Added push_back(void *, MEM_ROOT *) to make some list-handling code easier that needs to be allocated in a different mem-root (Before one had to change thd->mem_root ; push_back(); restore mem_root. --- mysql-test/t/range.test | 1 + sql/item_func.cc | 2 +- sql/item_sum.cc | 2 +- sql/opt_range.cc | 4 ++-- sql/parse_file.cc | 26 ++++---------------------- sql/sp.cc | 22 +++++++++++----------- sql/sp_head.cc | 28 ++++++++++++++-------------- sql/sp_head.h | 2 +- sql/sql_base.cc | 9 +++++---- sql/sql_class.h | 2 +- sql/sql_list.h | 12 ++++++++++++ sql/sql_prepare.cc | 8 ++++++-- sql/sql_select.cc | 30 ++++++++++++++++-------------- sql/sql_table.cc | 6 ++++-- sql/sql_trigger.cc | 22 ++++------------------ sql/sql_union.cc | 1 + sql/sql_view.cc | 8 ++++---- sql/sql_yacc.yy | 2 +- sql/table.cc | 5 ++--- 19 files changed, 91 insertions(+), 101 deletions(-) diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index e0d2e07bef2..0b96f71d585 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -432,3 +432,4 @@ explain select * from t1 where a=binary 'aaa'; explain select * from t1 where a='aaa' collate latin1_bin; # this one cannot: explain select * from t1 where a='aaa' collate latin1_german1_ci; +drop table t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 82912f8a0fa..185d4f115ad 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3514,7 +3514,7 @@ Item_func_sp::func_name() const 1 + // . 1 + // end of string ALIGN_SIZE(1)); // to avoid String reallocation - String qname((char *)alloc_root(&thd->mem_root, len), len, + String qname((char *)alloc_root(thd->mem_root, len), len, system_charset_info); qname.length(0); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 28d77cdf8b5..72c85e2dd40 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -313,7 +313,7 @@ Item_sum_sum_distinct::~Item_sum_sum_distinct() Item * Item_sum_sum_distinct::copy_or_same(THD *thd) { - return new (&thd->mem_root) Item_sum_sum_distinct(thd, this); + return new (thd->mem_root) Item_sum_sum_distinct(thd, this); } C_MODE_START diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 997edbdf155..f036cbc799b 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1041,7 +1041,7 @@ QUICK_ROR_UNION_SELECT::QUICK_ROR_UNION_SELECT(THD *thd_param, rowid_length= table->file->ref_length; record= head->record[0]; init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0); - thd_param->malloc= &alloc; + thd_param->mem_root= &alloc; } @@ -7497,7 +7497,7 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg, if (!parent_alloc) { init_sql_alloc(&alloc, join->thd->variables.range_alloc_block_size, 0); - thd->mem_root= &alloc; + join->thd->mem_root= &alloc; } else bzero(&alloc, sizeof(MEM_ROOT)); // ensure that it's not used diff --git a/sql/parse_file.cc b/sql/parse_file.cc index f548c16d808..c3043ed2c73 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -608,15 +608,13 @@ parse_quoted_escaped_string(char *ptr, char *end, my_bool File_parser::parse(gptr base, MEM_ROOT *mem_root, - struct File_option *parameters, uint required) + struct File_option *parameters, uint required) { uint first_param= 0, found= 0; register char *ptr= start; char *eol; LEX_STRING *str; - MEM_ROOT *sql_mem; List *list; - bool change_mem; DBUG_ENTER("File_parser::parse"); while (ptr < end && found < required) @@ -720,18 +718,7 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, } case FILE_OPTIONS_STRLIST: { - /* - TODO: remove play with mem_root, when List will be able - to store MEM_ROOT* pointer for list elements allocation - FIXME: we can't handle empty lists - */ - sql_mem= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC); - list= (List*)(base + parameter->offset); - if ((change_mem= (sql_mem != mem_root))) - { - change_mem= 1; - my_pthread_setspecific_ptr(THR_MALLOC, mem_root); - } + list= (List*)(base + parameter->offset); list->empty(); // list parsing @@ -739,7 +726,7 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, { if (!(str= (LEX_STRING*)alloc_root(mem_root, sizeof(LEX_STRING))) || - list->push_back(str)) + list->push_back(str, mem_root)) goto list_err; if(!(ptr= parse_quoted_escaped_string(ptr, end, mem_root, str))) goto list_err_w_message; @@ -754,20 +741,15 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, goto list_err_w_message; } } - end_of_list: + end_of_list: if (*(ptr++) != '\n') goto list_err; - - if (change_mem) - my_pthread_setspecific_ptr(THR_MALLOC, sql_mem); break; list_err_w_message: my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), parameter->name.str, line); list_err: - if (change_mem) - my_pthread_setspecific_ptr(THR_MALLOC, sql_mem); DBUG_RETURN(TRUE); } default: diff --git a/sql/sp.cc b/sql/sp.cc index a1e52ee1ca7..96bb8a17a49 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -166,7 +166,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) } bzero((char *)&chistics, sizeof(chistics)); - if ((ptr= get_field(&thd->mem_root, + if ((ptr= get_field(thd->mem_root, table->field[MYSQL_PROC_FIELD_ACCESS])) == NULL) { ret= SP_GET_FIELD_FAILED; @@ -189,7 +189,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) chistics.daccess= SP_CONTAINS_SQL; } - if ((ptr= get_field(&thd->mem_root, + if ((ptr= get_field(thd->mem_root, table->field[MYSQL_PROC_FIELD_DETERMINISTIC])) == NULL) { ret= SP_GET_FIELD_FAILED; @@ -197,7 +197,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) } chistics.detistic= (ptr[0] == 'N' ? FALSE : TRUE); - if ((ptr= get_field(&thd->mem_root, + if ((ptr= get_field(thd->mem_root, table->field[MYSQL_PROC_FIELD_SECURITY_TYPE])) == NULL) { ret= SP_GET_FIELD_FAILED; @@ -205,7 +205,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) } chistics.suid= (ptr[0] == 'I' ? SP_IS_NOT_SUID : SP_IS_SUID); - if ((params= get_field(&thd->mem_root, + if ((params= get_field(thd->mem_root, table->field[MYSQL_PROC_FIELD_PARAM_LIST])) == NULL) { params= ""; @@ -213,14 +213,14 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) if (type == TYPE_ENUM_PROCEDURE) returns= ""; - else if ((returns= get_field(&thd->mem_root, + else if ((returns= get_field(thd->mem_root, table->field[MYSQL_PROC_FIELD_RETURNS])) == NULL) { ret= SP_GET_FIELD_FAILED; goto done; } - if ((body= get_field(&thd->mem_root, + if ((body= get_field(thd->mem_root, table->field[MYSQL_PROC_FIELD_BODY])) == NULL) { ret= SP_GET_FIELD_FAILED; @@ -228,7 +228,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) } // Get additional information - if ((definer= get_field(&thd->mem_root, + if ((definer= get_field(thd->mem_root, table->field[MYSQL_PROC_FIELD_DEFINER])) == NULL) { ret= SP_GET_FIELD_FAILED; @@ -511,10 +511,10 @@ print_field_values(THD *thd, TABLE *table, String name_string; struct st_used_field *used_field= used_fields; - if (get_field(&thd->mem_root, used_field->field, &db_string)) + if (get_field(thd->mem_root, used_field->field, &db_string)) db_string.set_ascii("", 0); used_field+= 1; - get_field(&thd->mem_root, used_field->field, &name_string); + get_field(thd->mem_root, used_field->field, &name_string); if (!wild || !wild[0] || !wild_compare(name_string.ptr(), wild, 0)) { @@ -539,7 +539,7 @@ print_field_values(THD *thd, TABLE *table, { String tmp_string; - get_field(&thd->mem_root, used_field->field, &tmp_string); + get_field(thd->mem_root, used_field->field, &tmp_string); protocol->store(&tmp_string); } break; @@ -982,7 +982,7 @@ sp_cache_functions(THD *thd, LEX *lex) newlex->proc_table= oldlex->proc_table; // hint if mysql.oper is opened name.m_name.str= strchr(name.m_qname.str, '.'); name.m_db.length= name.m_name.str - name.m_qname.str; - name.m_db.str= strmake_root(&thd->mem_root, + name.m_db.str= strmake_root(thd->mem_root, name.m_qname.str, name.m_db.length); name.m_name.str+= 1; name.m_name.length= name.m_qname.length - name.m_db.length - 1; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 8de1b6e906a..47e3952bcdd 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -190,7 +190,7 @@ void sp_name::init_qname(THD *thd) { m_qname.length= m_db.length+m_name.length+1; - m_qname.str= alloc_root(&thd->mem_root, m_qname.length+1); + m_qname.str= thd->alloc(m_qname.length+1); sprintf(m_qname.str, "%*s.%*s", m_db.length, (m_db.length ? m_db.str : ""), m_name.length, m_name.str); @@ -232,10 +232,9 @@ sp_head::operator new(size_t size) MEM_ROOT own_root; sp_head *sp; - bzero((char *)&own_root, sizeof(own_root)); init_alloc_root(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); - sp= (sp_head *)alloc_root(&own_root, size); - sp->mem_root= own_root; + sp= (sp_head *) alloc_root(&own_root, size); + sp->main_mem_root= own_root; DBUG_PRINT("info", ("mem_root 0x%lx", (ulong) &sp->mem_root)); DBUG_RETURN(sp); } @@ -245,9 +244,10 @@ sp_head::operator delete(void *ptr, size_t size) { DBUG_ENTER("sp_head::operator delete"); MEM_ROOT own_root; - sp_head *sp= (sp_head *)ptr; + sp_head *sp= (sp_head *) ptr; - memcpy(&own_root, (const void *)&sp->mem_root, sizeof(MEM_ROOT)); + /* Make a copy of main_mem_root as free_root will free the sp */ + own_root= sp->main_mem_root; DBUG_PRINT("info", ("mem_root 0x%lx moved to 0x%lx", (ulong) &sp->mem_root, (ulong) &own_root)); free_root(&own_root, MYF(0)); @@ -291,7 +291,7 @@ sp_head::init_strings(THD *thd, LEX *lex, sp_name *name) DBUG_ENTER("sp_head::init_strings"); uint n; /* Counter for nul trimming */ /* During parsing, we must use thd->mem_root */ - MEM_ROOT *root= &thd->mem_root; + MEM_ROOT *root= thd->mem_root; /* We have to copy strings to get them into the right memroot */ if (name) @@ -916,19 +916,19 @@ sp_head::set_info(char *definer, uint definerlen, if (! p) p= definer; // Weird... len= p-definer; - m_definer_user.str= strmake_root(&mem_root, definer, len); + m_definer_user.str= strmake_root(mem_root, definer, len); m_definer_user.length= len; len= definerlen-len-1; - m_definer_host.str= strmake_root(&mem_root, p+1, len); + m_definer_host.str= strmake_root(mem_root, p+1, len); m_definer_host.length= len; m_created= created; m_modified= modified; - m_chistics= (st_sp_chistics *)alloc_root(&mem_root, sizeof(st_sp_chistics)); - memcpy(m_chistics, chistics, sizeof(st_sp_chistics)); + m_chistics= (st_sp_chistics *) memdup_root(mem_root, (char*) chistics, + sizeof(*chistics)); if (m_chistics->comment.length == 0) m_chistics->comment.str= 0; else - m_chistics->comment.str= strmake_root(&mem_root, + m_chistics->comment.str= strmake_root(mem_root, m_chistics->comment.str, m_chistics->comment.length); m_sql_mode= sql_mode; @@ -939,14 +939,14 @@ sp_head::reset_thd_mem_root(THD *thd) { DBUG_ENTER("sp_head::reset_thd_mem_root"); m_thd_root= thd->mem_root; - thd->mem_root= mem_root; + thd->mem_root= &main_mem_root; DBUG_PRINT("info", ("mem_root 0x%lx moved to thd mem root 0x%lx", (ulong) &mem_root, (ulong) &thd->mem_root)); free_list= thd->free_list; // Keep the old list thd->free_list= NULL; // Start a new one /* Copy the db, since substatements will point to it */ m_thd_db= thd->db; - thd->db= strmake_root(&thd->mem_root, thd->db, thd->db_length); + thd->db= thd->strmake(thd->db, thd->db_length); m_thd= thd; DBUG_VOID_RETURN; } diff --git a/sql/sp_head.h b/sql/sp_head.h index 6aa05838291..4bfe1076f65 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -231,7 +231,7 @@ public: private: - MEM_ROOT m_thd_root; // Temp. store for thd's mem_root + MEM_ROOT *m_thd_root; // Temp. store for thd's mem_root THD *m_thd; // Set if we have reset mem_root char *m_thd_db; // Original thd->db pointer diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a1481bb2522..2cb3c9eb782 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -815,7 +815,7 @@ TABLE *reopen_name_locked_table(THD* thd, TABLE_LIST* table_list) pthread_mutex_lock(&LOCK_open); if (open_unireg_entry(thd, table, db, table_name, table_name, 0, - &thd->mem_root) || + thd->mem_root) || !(table->table_cache_key =memdup_root(&table->mem_root,(char*) key, key_length))) { @@ -1135,7 +1135,7 @@ bool reopen_table(TABLE *table,bool locked) safe_mutex_assert_owner(&LOCK_open); if (open_unireg_entry(table->in_use, &tmp, db, table_name, - table->table_name, 0, &table->in_use->mem_root)) + table->table_name, 0, table->in_use->mem_root)) goto end; free_io_cache(table); @@ -1774,7 +1774,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) thd->current_tablenr= 0; /* open_ltable can be used only for BASIC TABLEs */ table_list->required_type= FRMTYPE_TABLE; - while (!(table= open_table(thd, table_list, &thd->mem_root, &refresh)) && + while (!(table= open_table(thd, table_list, thd->mem_root, &refresh)) && refresh) ; @@ -2999,7 +2999,8 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name, during cleunup() this item will be put in list to replace expression from VIEW */ - thd->nocheck_register_item_tree_change(it->ref(), item, &thd->mem_root); + thd->nocheck_register_item_tree_change(it->ref(), item, + thd->mem_root); } } /* All fields are used */ diff --git a/sql/sql_class.h b/sql/sql_class.h index 987e557c37c..515c1c13b58 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1174,7 +1174,7 @@ public: use new arena if we are in a prepared statements and we have not already changed to use this arena. */ - if (current_arena->is_stmt_prepare() && + if (!current_arena->is_conventional() && mem_root != ¤t_arena->main_mem_root) { set_n_backup_item_arena(current_arena, backup); diff --git a/sql/sql_list.h b/sql/sql_list.h index d8d3719d39d..141742c3d4a 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -113,6 +113,16 @@ public: } return 1; } + inline bool push_back(void *info, MEM_ROOT *mem_root) + { + if (((*last)=new (mem_root) list_node(info, &end_of_list))) + { + last= &(*last)->next; + elements++; + return 0; + } + return 1; + } inline bool push_front(void *info) { list_node *node=new list_node(info,first); @@ -284,6 +294,8 @@ public: inline List() :base_list() {} inline List(const List &tmp) :base_list(tmp) {} inline bool push_back(T *a) { return base_list::push_back(a); } + inline bool push_back(T *a, MEM_ROOT *mem_root) + { return base_list::push_back(a, mem_root); } inline bool push_front(T *a) { return base_list::push_front(a); } inline T* head() {return (T*) base_list::head(); } inline T** head_ref() {return (T**) base_list::head_ref(); } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 4f94bfb6c05..9f25408acf8 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1828,7 +1828,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) { DBUG_PRINT("info",("Using READ_ONLY cursor")); if (!stmt->cursor && - !(stmt->cursor= new (&stmt->mem_root) Cursor())) + !(stmt->cursor= new (&stmt->main_mem_root) Cursor())) { send_error(thd, ER_OUT_OF_RESOURCES); DBUG_VOID_RETURN; @@ -2013,7 +2013,12 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, /* COM_FETCH handler: fetches requested amount of rows from cursor + SYNOPSIS + mysql_stmt_fetch() + thd Thread handler + packet Packet from client (with stmt_id & num_rows) + packet_length Length of packet */ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) @@ -2023,7 +2028,6 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) ulong num_rows= uint4korr(packet+=4); Statement *stmt; int error; - DBUG_ENTER("mysql_stmt_fetch"); if (!(stmt= thd->stmt_map.find(stmt_id)) || diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d154e3e93c1..f679c45ae3d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1497,7 +1497,6 @@ JOIN::exec() are fixed or do not need fix_fields, too */ curr_table->select->cond->quick_fix_field(); - cur_tabl } curr_table->select_cond= curr_table->select->cond; curr_table->select_cond->top_level_item(); @@ -1653,9 +1652,13 @@ Cursor::init_from_thd(THD *thd) /* We need to save and reset thd->mem_root, otherwise it'll be freed later in mysql_parse. + + We can't just change the thd->mem_root here as we want to keep the things + that is already allocated in thd->mem_root for Cursor::fetch() */ - mem_root= thd->mem_root; - init_sql_alloc(&thd->mem_root, + main_mem_root= *thd->mem_root; + /* Allocate new memory root for thd */ + init_sql_alloc(thd->mem_root, thd->variables.query_alloc_block_size, thd->variables.query_prealloc_size); @@ -1669,7 +1672,7 @@ Cursor::init_from_thd(THD *thd) open_tables= thd->open_tables; lock= thd->lock; query_id= thd->query_id; - free_list= thd->free_list; + free_list= thd->free_list; reset_thd(thd); /* XXX: thd->locked_tables is not changed. @@ -1684,8 +1687,11 @@ Cursor::init_from_thd(THD *thd) void Cursor::init_thd(THD *thd) { - thd->mem_root= mem_root; - + /* + Use the original mem_root, in which we store all memory allocated + during the lifetime of the cursor. + */ + thd->mem_root= &main_mem_root; DBUG_ASSERT(thd->derived_tables == 0); thd->derived_tables= derived_tables; @@ -1773,11 +1779,10 @@ int Cursor::fetch(ulong num_rows) { THD *thd= join->thd; - JOIN_TAB *join_tab= join->join_tab + join->const_tables;; + JOIN_TAB *join_tab= join->join_tab + join->const_tables; COND *on_expr= *join_tab->on_expr_ref; COND *select_cond= join_tab->select_cond; READ_RECORD *info= &join_tab->read_record; - int error= 0; join->fetch_limit+= num_rows; @@ -1853,7 +1858,6 @@ Cursor::fetch(ulong num_rows) ::send_eof(thd); thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS; /* save references to memory, allocated during fetch */ - mem_root= thd->mem_root; free_list= thd->free_list; break; /* Limit clause worked: this is the same as 'no more rows' */ @@ -1875,8 +1879,7 @@ Cursor::fetch(ulong num_rows) Must be last, as some memory might be allocated for free purposes, like in free_tmp_table() (TODO: fix this issue) */ - mem_root= thd->mem_root; - free_root(&mem_root, MYF(0)); + free_root(&main_mem_root, MYF(0)); break; default: close(); @@ -1888,8 +1891,7 @@ Cursor::fetch(ulong num_rows) Must be last, as some memory might be allocated for free purposes, like in free_tmp_table() (TODO: fix this issue) */ - mem_root= thd->mem_root; - free_root(&mem_root, MYF(0)); + free_root(&main_mem_root, MYF(0)); break; } return error; @@ -1940,7 +1942,7 @@ Cursor::~Cursor() Must be last, as some memory might be allocated for free purposes, like in free_tmp_table() (TODO: fix this issue) */ - free_root(&mem_root, MYF(0)); + free_root(&main_mem_root, MYF(0)); } /*********************************************************************/ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f4f9841ead3..e73bf81eb74 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1401,7 +1401,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, create_info, *extra_fields, *keys, 0, select_field_count)) { - if (!(table= open_table(thd, create_table, &thd->mem_root, (bool*) 0))) + if (!(table= open_table(thd, create_table, thd->mem_root, (bool*) 0))) quick_rm_table(create_info->db_type, create_table->db, table_case_name(create_info, create_table->real_name)); } @@ -3077,7 +3077,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, bzero((void*) &tbl, sizeof(tbl)); tbl.db= new_db; tbl.real_name= tbl.alias= tmp_name; - new_table= open_table(thd, &tbl, &thd->mem_root, 0); + new_table= open_table(thd, &tbl, thd->mem_root, 0); } else { @@ -3516,6 +3516,8 @@ int mysql_recreate_table(THD *thd, TABLE_LIST *table_list, create_info.db_type=DB_TYPE_DEFAULT; create_info.row_type=ROW_TYPE_DEFAULT; create_info.default_table_charset=default_charset_info; + /* Force alter table to recreate table */ + lex->alter_info.flags= ALTER_CHANGE_COLUMN; DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info, table_list, lex->create_list, lex->key_list, 0, (ORDER *) 0, diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 17f3bc48678..5d175be74e1 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -134,7 +134,6 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables) TABLE *table= tables->table; char dir_buff[FN_REFLEN], file_buff[FN_REFLEN]; LEX_STRING dir, file; - MEM_ROOT *old_global_root; LEX_STRING *trg_def, *name; List_iterator_fast it(names_list); @@ -168,9 +167,6 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables) triggers_file_ext, NullS) - file_buff; file.str= file_buff; - old_global_root= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC); - my_pthread_setspecific_ptr(THR_MALLOC, &table->mem_root); - /* Soon we will invalidate table object and thus Table_triggers_list object so don't care about place to which trg_def->ptr points and other @@ -181,17 +177,12 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables) */ if (!(trg_def= (LEX_STRING *)alloc_root(&table->mem_root, sizeof(LEX_STRING))) || - definitions_list.push_back(trg_def)) - { - my_pthread_setspecific_ptr(THR_MALLOC, old_global_root); + definitions_list.push_back(trg_def, &table->mem_root)) return 1; - } trg_def->str= thd->query; trg_def->length= thd->query_length; - my_pthread_setspecific_ptr(THR_MALLOC, old_global_root); - return sql_create_definition_file(&dir, &file, &triggers_file_type, (gptr)this, triggers_file_parameters, 3); } @@ -302,7 +293,6 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, char path_buff[FN_REFLEN]; LEX_STRING path; File_parser *parser; - MEM_ROOT *old_global_mem_root; DBUG_ENTER("Table_triggers_list::check_n_load"); @@ -406,14 +396,9 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, trg_name_str->str= trg_name_buff; trg_name_str->length= lex.name_and_length.length; - old_global_mem_root= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC); - my_pthread_setspecific_ptr(THR_MALLOC, &table->mem_root); - - if (triggers->names_list.push_back(trg_name_str)) + if (triggers->names_list.push_back(trg_name_str, &table->mem_root)) goto err_with_lex_cleanup; - my_pthread_setspecific_ptr(THR_MALLOC, old_global_mem_root); - lex_end(&lex); } thd->lex= old_lex; @@ -431,7 +416,8 @@ err_with_lex_cleanup: We don't care about this error message much because .TRG files will be merged into .FRM anyway. */ - my_error(ER_WRONG_OBJECT, MYF(0), table_name, triggers_file_ext, "TRIGGER"); + my_error(ER_WRONG_OBJECT, MYF(0), table_name, triggers_file_ext, + "TRIGGER"); DBUG_RETURN(1); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 20d762eba55..792e2cdf775 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -314,6 +314,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, thd_arg->lex->current_select= lex_select_save; if (!item_list.elements) { + Field **field; Item_arena *tmp_arena,backup; tmp_arena= thd->change_arena_if_needed(&backup); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index f8994148ffc..a03a7acdf72 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -434,7 +434,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, DBUG_RETURN(-1); } - if (!(parser= sql_parse_prepare(&path, &thd->mem_root, 0))) + if (!(parser= sql_parse_prepare(&path, thd->mem_root, 0))) DBUG_RETURN(1); if (!parser->ok() || @@ -451,7 +451,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, TODO: read dependence list, too, to process cascade/restrict TODO: special cascade/restrict procedure for alter? */ - if (parser->parse((gptr)view, &thd->mem_root, + if (parser->parse((gptr)view, thd->mem_root, view_parameters + revision_number_position, 1)) { DBUG_RETURN(thd->net.report_error? -1 : 0); @@ -565,7 +565,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) TODO: when VIEWs will be stored in cache, table mem_root should be used here */ - if (parser->parse((gptr)table, &thd->mem_root, view_parameters, + if (parser->parse((gptr)table, thd->mem_root, view_parameters, required_view_parameters)) goto err; @@ -586,7 +586,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) now Lex placed in statement memory */ - table->view= lex= thd->lex= (LEX*) new(&thd->mem_root) st_lex_local; + table->view= lex= thd->lex= (LEX*) new(thd->mem_root) st_lex_local; lex_start(thd, (uchar*)table->query.str, table->query.length); lex->select_lex.select_number= ++thd->select_number; old_lex->derived_tables|= DERIVED_VIEW; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 82646e1db36..309a9249d0e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1848,7 +1848,7 @@ sp_proc_stmt: i->m_query.length= lex->ptr - sp->m_tmp_query; else i->m_query.length= lex->tok_end - sp->m_tmp_query; - i->m_query.str= strmake_root(&YYTHD->mem_root, + i->m_query.str= strmake_root(YYTHD->mem_root, (char *)sp->m_tmp_query, i->m_query.length); i->set_lex(lex); diff --git a/sql/table.cc b/sql/table.cc index 71999b2c3d4..403d9db342c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -89,7 +89,8 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, error=1; disk_buff=NULL; - old_root= my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); + root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**, THR_MALLOC); + old_root= *root_ptr; if ((file=my_open(fn_format(index_file, name, "", reg_ext, MY_UNPACK_FILENAME), @@ -123,8 +124,6 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, outparam->blob_ptr_size=sizeof(char*); outparam->db_stat = db_stat; init_sql_alloc(&outparam->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0); - root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**, THR_MALLOC); - old_root= *root_ptr; *root_ptr= &outparam->mem_root; outparam->real_name=strdup_root(&outparam->mem_root, From d2d7533e4a8c99ab9d556548130a18607d1d7cf5 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 9 Nov 2004 13:56:54 +0200 Subject: [PATCH 094/101] After merge fixes --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 83c69ab7727..85feea3d51a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1876,7 +1876,7 @@ Cursor::fetch(ulong num_rows) /* free cursor memory */ free_items(free_list); free_list= 0; - free_root(&mem_root, MYF(0)); + free_root(&main_mem_root, MYF(0)); } return error; } From 46089cfd144be3430f69e2a8b48b0aeee154d6fa Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 9 Nov 2004 15:50:33 +0200 Subject: [PATCH 095/101] Simple optimization to avoid a malloc for each query --- sql/sql_lex.cc | 7 ++----- sql/sql_lex.h | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3cbfd96b6aa..86219abc632 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -178,11 +178,8 @@ void lex_start(THD *thd, uchar *buf,uint length) lex->trg_table= NULL; lex->proc_list.first= 0; - extern byte *sp_lex_spfuns_key(const byte *ptr, uint *plen, my_bool first); - hash_free(&lex->spfuns); - hash_init(&lex->spfuns, system_charset_info, 0, 0, 0, - sp_lex_spfuns_key, 0, 0); - + if (lex->spfuns.records) + hash_reset(&lex->spfuns); } void lex_end(LEX *lex) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 2bdc35f35cb..c8b4faa47c2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -758,7 +758,8 @@ typedef struct st_lex st_lex() :result(0) { - bzero((char *)&spfuns, sizeof(spfuns)); + extern byte *sp_lex_spfuns_key(const byte *ptr, uint *plen, my_bool first); + hash_init(&spfuns, system_charset_info, 0, 0, 0, sp_lex_spfuns_key, 0, 0); } ~st_lex() From 3e8e4d06b6e93ce936957f7704574222f24729c8 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Wed, 10 Nov 2004 14:36:21 +0400 Subject: [PATCH 096/101] A fix (bug #6475: Another server crash in 5.0.2 bug #6515: count(distinct...) crashes the server) --- mysql-test/r/count_distinct.result | 7 +++++ mysql-test/r/func_gconcat.result | 7 +++++ mysql-test/t/count_distinct.test | 8 ++++++ mysql-test/t/func_gconcat.test | 9 ++++++ sql/sql_select.cc | 44 ++++++++++++++++++++++-------- 5 files changed, 64 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/count_distinct.result b/mysql-test/r/count_distinct.result index 16460580d6c..1bc1ad6a31e 100644 --- a/mysql-test/r/count_distinct.result +++ b/mysql-test/r/count_distinct.result @@ -53,3 +53,10 @@ select count(distinct f) from t1; count(distinct f) 0 drop table t1; +create table t1 (a char(3), b char(20), primary key (a, b)); +insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); +select count(distinct a) from t1 group by b; +count(distinct a) +1 +1 +drop table t1; diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 22868aa03c4..dfaf5758699 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -457,3 +457,10 @@ group_concat(distinct b order by b) Warnings: Warning 1260 2 line(s) were cut by GROUP_CONCAT() drop table t1; +create table t1 (a char(3), b char(20), primary key (a, b)); +insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); +select group_concat(a) from t1 group by b; +group_concat(a) +ABW +ABW +drop table t1; diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test index 1f0404876cb..73c6951e78f 100644 --- a/mysql-test/t/count_distinct.test +++ b/mysql-test/t/count_distinct.test @@ -55,3 +55,11 @@ create table t1 (f int); select count(distinct f) from t1; drop table t1; +# +# Bug #6515 +# + +create table t1 (a char(3), b char(20), primary key (a, b)); +insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); +select count(distinct a) from t1 group by b; +drop table t1; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index e0737a42221..c5147dc381e 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -277,3 +277,12 @@ select group_concat(b order by b) from t1 group by a; select group_concat(distinct b order by b) from t1 group by a; drop table t1; + +# +# Bug #6475 +# + +create table t1 (a char(3), b char(20), primary key (a, b)); +insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); +select group_concat(a) from t1 group by b; +drop table t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 18ffb7079c8..b2da617ca1f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -192,6 +192,7 @@ static void init_tmptable_sum_functions(Item_sum **func); static void update_tmptable_sum_func(Item_sum **func,TABLE *tmp_table); static void copy_sum_funcs(Item_sum **func_ptr); static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab); +static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr); static bool init_sum_functions(Item_sum **func, Item_sum **end); static bool update_sum_func(Item_sum **func); static void select_describe(JOIN *join, bool need_tmp_table,bool need_order, @@ -990,13 +991,15 @@ JOIN::optimize() if (create_sort_index(thd, this, group_list, HA_POS_ERROR, HA_POS_ERROR) || alloc_group_fields(this, group_list) || - make_sum_func_list(all_fields, fields_list, 1)) + make_sum_func_list(all_fields, fields_list, 1) || + setup_sum_funcs(thd, sum_funcs)) DBUG_RETURN(1); group_list=0; } else { - if (make_sum_func_list(all_fields, fields_list, 0)) + if (make_sum_func_list(all_fields, fields_list, 0) || + setup_sum_funcs(thd, sum_funcs)) DBUG_RETURN(1); if (!group_list && ! exec_tmp_table1->distinct && order && simple_order) { @@ -1372,6 +1375,7 @@ JOIN::exec() } if (curr_join->make_sum_func_list(*curr_all_fields, *curr_fields_list, 1, TRUE) || + setup_sum_funcs(curr_join->thd, curr_join->sum_funcs) || (tmp_error= do_select(curr_join, (List *) 0, curr_tmp_table, 0))) { @@ -1459,7 +1463,9 @@ JOIN::exec() set_items_ref_array(items3); if (curr_join->make_sum_func_list(*curr_all_fields, *curr_fields_list, - 1, TRUE) || thd->is_fatal_error) + 1, TRUE) || + setup_sum_funcs(curr_join->thd, curr_join->sum_funcs) || + thd->is_fatal_error) DBUG_VOID_RETURN; } if (curr_join->group_list || curr_join->order) @@ -11794,9 +11800,6 @@ bool JOIN::alloc_func_list() before_group_by Set to 1 if this is called before GROUP BY handling recompute Set to TRUE if sum_funcs must be recomputed - NOTES - Calls ::setup() for all item_sum objects in field_list - RETURN 0 ok 1 error @@ -11817,12 +11820,7 @@ bool JOIN::make_sum_func_list(List &field_list, List &send_fields, while ((item=it++)) { if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item()) - { *func++= (Item_sum*) item; - /* let COUNT(DISTINCT) create the temporary table */ - if (((Item_sum*) item)->setup(thd)) - DBUG_RETURN(TRUE); - } } if (before_group_by && rollup.state == ROLLUP::STATE_INITED) { @@ -11967,6 +11965,30 @@ change_refs_to_tmp_fields(THD *thd, Item **ref_pointer_array, Code for calculating functions ******************************************************************************/ + +/* + Call ::setup for all sum functions + + SYNOPSIS + setup_sum_funcs() + thd thread handler + func_ptr sum function list + + RETURN + FALSE ok + TRUE error +*/ + +static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr) +{ + Item_sum *func; + while ((func= *(func_ptr++))) + if (func->setup(thd)) + return TRUE; + return FALSE; +} + + static void init_tmptable_sum_functions(Item_sum **func_ptr) { From 1e424ecbffacd0bf92453aff437400546c3e8e01 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Wed, 10 Nov 2004 14:55:55 +0200 Subject: [PATCH 097/101] Portability fix (Problems compiling on MacOSX with gcc) --- sql/item.cc | 1 + sql/item_cmpfunc.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index d78c6f5b8ba..9e28793493d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3391,5 +3391,6 @@ void Item_result_field::cleanup() template class List; template class List_iterator; template class List_iterator_fast; +template class List_iterator_fast; template class List; #endif diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 754ebe08b77..af2c385b296 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -20,9 +20,6 @@ #ifdef __GNUC__ #pragma interface /* gcc class implementation */ #endif -#ifdef __GNUC__ -template class List_iterator_fast; -#endif extern Item_result item_cmp_type(Item_result a,Item_result b); class Item_bool_func2; From 52da4cd91231929709ecb8a8fa542074f0144986 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Wed, 10 Nov 2004 16:49:44 +0300 Subject: [PATCH 098/101] Fix compile failure of client_test: Move DBUG_ENTER to work in standard C. --- tests/client_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/client_test.c b/tests/client_test.c index 6ce33789aba..e03be170a03 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -786,9 +786,9 @@ static void client_use_result() void fill_tables(const char **query_list, unsigned query_count) { - DBUG_ENTER("fill_tables"); int rc; const char **query; + DBUG_ENTER("fill_tables"); for (query= query_list; query < query_list + query_count; ++query) { @@ -11534,7 +11534,6 @@ static void test_bug6046() static void test_basic_cursors() { - DBUG_ENTER("test_basic_cursors"); const char *basic_tables[]= { "DROP TABLE IF EXISTS t1, t2", @@ -11567,6 +11566,7 @@ static void test_basic_cursors() "SELECT * FROM t2" }; + DBUG_ENTER("test_basic_cursors"); myheader("test_basic_cursors"); fill_tables(basic_tables, sizeof(basic_tables)/sizeof(*basic_tables)); From 4aa856c2a674ef2fa9827ddae795ed6595ef550c Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 10 Nov 2004 14:25:02 +0000 Subject: [PATCH 099/101] change option -c to refer to connectstring --- ndb/src/mgmsrv/main.cpp | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 15767e4766d..6e3a0b280d1 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -101,22 +101,7 @@ static char *opt_connect_str= 0; static struct my_option my_long_options[] = { -#ifndef DBUG_OFF - { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", - 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, -#endif - { "usage", '?', "Display this help and exit.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, - { "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 }, - { "connect-string", 1023, - "Set connect string for connecting to ndb_mgmd. " - "=\"host=[;nodeid=]\". " - "Overides specifying entries in NDB_CONNECTSTRING and config file", - (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, - GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + NDB_STD_OPTS("ndb_mgm"), { "config-file", 'f', "Specify cluster configuration file", (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, @@ -135,11 +120,6 @@ static struct my_option my_long_options[] = { "nodaemon", 258, "Don't run as daemon, but don't read from stdin", (gptr*) &glob.non_interactive, (gptr*) &glob.non_interactive, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, - { "config-file", 'c', - "-c provided for backwards compatability, will be removed in 5.0." - " Use -f instead", - (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0, - GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void short_usage_sub(void) @@ -168,9 +148,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'V': print_version(); exit(0); - case 'c': - printf("Warning: -c will be removed in 5.0, use -f instead\n"); - break; case '?': usage(); exit(0); From 597781c1b1d6824a09d42b3b012942f93864c489 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Wed, 10 Nov 2004 11:22:39 -0800 Subject: [PATCH 100/101] select.result, select.test: Added test cases for bug #6474. sql_select.cc: Fixed bug #6474. A wrong result was returned when a query contained the same equality of the form field=const on different AND levels. --- mysql-test/r/select.result | 33 +++++++++++++++++++++++++++++++++ mysql-test/t/select.test | 36 ++++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 12 +++++++----- 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index e0e839abdce..b49f7758c4a 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2333,3 +2333,36 @@ EXPLAIN SELECT i FROM t1 WHERE i=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index DROP TABLE t1; +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 3619cf116d1..7ee344c4b13 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1910,3 +1910,39 @@ EXPLAIN SELECT i FROM t1 WHERE i=1; EXPLAIN SELECT i FROM t1 WHERE i=1; DROP TABLE t1; + +# +# Test for bug #6474 +# + +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); + +SELECT K2C4, K4N4, F2I4 FROM t1 + WHERE K2C4 = 'WART' AND + (F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); + +SELECT K2C4, K4N4, F2I4 FROM t1 + WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); + +DROP TABLE t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 85feea3d51a..686316d80a6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6639,10 +6639,7 @@ static Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, List eq_list; Item_func_eq *eq_item= 0; if (((Item *) item_equal)->const_item() && !item_equal->val_int()) - { - cond= new Item_int((char*) "FALSE",0,1); - return cond; - } + return new Item_int((longlong) 0,1); Item *item_const= item_equal->get_const(); Item_equal_iterator it(*item_equal); Item *head; @@ -6685,9 +6682,14 @@ static Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, } if (!cond && !eq_list.head()) + { + if (!eq_item) + return new Item_int((longlong) 1,1); return eq_item; + } - eq_list.push_back(eq_item); + if (eq_item) + eq_list.push_back(eq_item); if (!cond) cond= new Item_cond_and(eq_list); else From d74b5499d25b09aadcf1ca0742b533c20c4a0420 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Thu, 11 Nov 2004 12:43:08 +0100 Subject: [PATCH 101/101] '5.4', -1, HALF_UP fixed --- strings/decimal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/strings/decimal.c b/strings/decimal.c index 09f6cb6bb51..b8e8fd3725f 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -867,7 +867,7 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode error=E_DEC_TRUNCATED; } - if (scale+from->intg <=0) + if (scale+from->intg <0) { decimal_make_zero(to); return E_DEC_OK; @@ -881,7 +881,7 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode buf0=from->buf; buf1=to->buf; to->sign=from->sign; - to->intg=min(from->intg, len*DIG_PER_DEC1); + to->intg=min(intg0, len)*DIG_PER_DEC1; } if (frac0 > frac1) @@ -921,8 +921,6 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode *buf1-=DIG_BASE; while (carry && --buf1 >= to->buf) ADD(*buf1, *buf1, 0, carry); - if (to->buf[0] > from->buf[0]) - to->intg++; if (unlikely(carry)) { /* shifting the number to create space for new digit */ @@ -937,6 +935,7 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode buf1[0]=buf1[-1]; } *buf1=1; + to->intg++; } } if (scale<0) scale=0; @@ -2058,6 +2057,7 @@ main() test_ro("15.17",1,HALF_UP); test_ro("15.4",-1,HALF_UP); test_ro("-15.4",-1,HALF_UP); + test_ro("5.4",-1,HALF_UP); test_ro("15.1",0,HALF_EVEN); test_ro("15.5",0,HALF_EVEN); test_ro("14.5",0,HALF_EVEN);