1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Resolved merge from 4.1 -> 5.0 (mainly Guilhem's work with mysqldump)

BitKeeper/etc/ignore:
  auto-union
configure.in:
  Auto merged
include/my_global.h:
  Auto merged
include/my_sys.h:
  Auto merged
include/mysql.h:
  Auto merged
include/mysqld_error.h:
  Auto merged
mysql-test/mysql-test-run.sh:
  Auto merged
mysql-test/r/alter_table.result:
  Auto merged
mysql-test/r/ndb_autodiscover.result:
  Auto merged
mysql-test/r/null.result:
  Auto merged
mysql-test/r/ps_2myisam.result:
  Auto merged
mysql-test/r/ps_3innodb.result:
  Auto merged
mysql-test/r/ps_4heap.result:
  Auto merged
mysql-test/r/ps_5merge.result:
  Auto merged
mysql-test/r/ps_6bdb.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
mysql-test/t/null.test:
  Auto merged
ndb/src/mgmsrv/main.cpp:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/slave.h:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/share/czech/errmsg.txt:
  Auto merged
sql/share/danish/errmsg.txt:
  Auto merged
sql/share/dutch/errmsg.txt:
  Auto merged
sql/share/english/errmsg.txt:
  Auto merged
sql/share/estonian/errmsg.txt:
  Auto merged
sql/share/french/errmsg.txt:
  Auto merged
sql/share/german/errmsg.txt:
  Auto merged
sql/share/greek/errmsg.txt:
  Auto merged
sql/share/hungarian/errmsg.txt:
  Auto merged
sql/share/italian/errmsg.txt:
  Auto merged
sql/share/japanese/errmsg.txt:
  Auto merged
sql/share/korean/errmsg.txt:
  Auto merged
sql/share/norwegian-ny/errmsg.txt:
  Auto merged
sql/share/norwegian/errmsg.txt:
  Auto merged
sql/share/polish/errmsg.txt:
  Auto merged
sql/share/portuguese/errmsg.txt:
  Auto merged
sql/share/romanian/errmsg.txt:
  Auto merged
sql/share/russian/errmsg.txt:
  Auto merged
sql/share/serbian/errmsg.txt:
  Auto merged
sql/share/slovak/errmsg.txt:
  Auto merged
sql/share/spanish/errmsg.txt:
  Auto merged
sql/share/swedish/errmsg.txt:
  Auto merged
sql/share/ukrainian/errmsg.txt:
  Auto merged
This commit is contained in:
unknown
2004-11-11 18:58:57 -08:00
174 changed files with 3610 additions and 9563 deletions

View File

@ -742,6 +742,7 @@ ndb/tools/ndb_drop_table
ndb/tools/ndb_select_all ndb/tools/ndb_select_all
ndb/tools/ndb_select_count ndb/tools/ndb_select_count
ndb/tools/ndb_show_tables ndb/tools/ndb_show_tables
ndb/tools/ndb_test_platform
ndb/tools/ndb_waiter ndb/tools/ndb_waiter
pull.log pull.log
regex/re regex/re

View File

@ -1614,9 +1614,14 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [
--with-ndb-docs Include the NDB Cluster ndbapi and mgmapi documentation], --with-ndb-docs Include the NDB Cluster ndbapi and mgmapi documentation],
[ndb_docs="$withval"], [ndb_docs="$withval"],
[ndb_docs=no]) [ndb_docs=no])
AC_ARG_WITH([ndb-port],
[
--with-ndb-port Port for NDB Cluster management server],
[ndb_port="$withval"],
[ndb_port="default"])
AC_ARG_WITH([ndb-port-base], AC_ARG_WITH([ndb-port-base],
[ [
--with-ndb-port-base Base port for NDB Cluster], --with-ndb-port-base Base port for NDB Cluster transporters],
[ndb_port_base="$withval"], [ndb_port_base="$withval"],
[ndb_port_base="default"]) [ndb_port_base="default"])

View File

@ -14,28 +14,11 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
TODO: print the catalog (some USE catalog.db ????).
Standalone program to read a MySQL binary log (or relay log);
can read files produced by 3.23, 4.x, 5.0 servers.
Can read binlogs from 3.23/4.x/5.0 and relay logs from 4.x/5.0.
Should be able to read any file of these categories, even with
--start-position.
An important fact: the Format_desc event of the log is at most the 3rd event
of the log; if it is the 3rd then there is this combination:
Format_desc_of_slave, Rotate_of_master, Format_desc_of_master.
*/
#define MYSQL_CLIENT #define MYSQL_CLIENT
#undef MYSQL_SERVER #undef MYSQL_SERVER
#include "client_priv.h" #include "client_priv.h"
#include <my_time.h> #include <my_time.h>
#include "log_event.h" #include "log_event.h"
/* That one is necessary for defines of OPTION_NO_FOREIGN_KEY_CHECKS etc */
#include "mysql_priv.h"
#define BIN_LOG_HEADER_SIZE 4 #define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4) #define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
@ -83,14 +66,6 @@ static MYSQL* mysql = NULL;
static const char* dirname_for_local_load= 0; static const char* dirname_for_local_load= 0;
static bool stop_passed= 0; static bool stop_passed= 0;
/*
check_header() will set the pointer below.
Why do we need here a pointer on an event instead of an event ?
This is because the event will be created (alloced) in read_log_event()
(which returns a pointer) in check_header().
*/
Format_description_log_event* description_event;
static int dump_local_log_entries(const char* logname); static int dump_local_log_entries(const char* logname);
static int dump_remote_log_entries(const char* logname); static int dump_remote_log_entries(const char* logname);
static int dump_log_entries(const char* logname); static int dump_log_entries(const char* logname);
@ -229,7 +204,7 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname,
for (;;) for (;;)
{ {
uint packet_len = my_net_read(net); ulong packet_len = my_net_read(net);
if (packet_len == 0) if (packet_len == 0)
{ {
if (my_net_write(net, "", 0) || net_flush(net)) if (my_net_write(net, "", 0) || net_flush(net))
@ -251,7 +226,13 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname,
return -1; return -1;
} }
if (my_write(file, (byte*) net->read_pos, packet_len,MYF(MY_WME|MY_NABP))) if (packet_len > UINT_MAX)
{
sql_print_error("Illegal length of packet read from net");
return -1;
}
if (my_write(file, (byte*) net->read_pos,
(uint) packet_len, MYF(MY_WME|MY_NABP)))
return -1; return -1;
} }
@ -324,8 +305,8 @@ int Load_log_processor::process(Append_block_log_event *ae)
/* /*
There is no Create_file event (a bad binlog or a big There is no Create_file event (a bad binlog or a big
--start-position). Assuming it's a big --start-position, we just do --position). Assuming it's a big --position, we just do nothing and
nothing and print a warning. print a warning.
*/ */
fprintf(stderr,"Warning: ignoring Append_block as there is no \ fprintf(stderr,"Warning: ignoring Append_block as there is no \
Create_file event for file_id: %u\n",ae->file_id); Create_file event for file_id: %u\n",ae->file_id);
@ -335,49 +316,30 @@ Create_file event for file_id: %u\n",ae->file_id);
Load_log_processor load_processor; Load_log_processor load_processor;
/* /*
Process an event
SYNOPSIS
process_event()
RETURN RETURN
0 ok and continue 0 ok and continue
1 error and terminate 1 error and terminate
-1 ok and terminate -1 ok and terminate
TODO TODO
This function returns 0 even in some error cases. This should be changed. This function returns 0 even in some error cases. This should be changed.
*/ */
int process_event(char *last_db, Log_event *ev, my_off_t pos, int old_format)
int process_event(LAST_EVENT_INFO *last_event_info, Log_event *ev,
my_off_t pos)
{ {
char ll_buff[21]; char ll_buff[21];
Log_event_type ev_type= ev->get_type_code();
DBUG_ENTER("process_event"); DBUG_ENTER("process_event");
/*
Format events are not concerned by --offset and such, we always need to
read them to be able to process the wanted events.
*/
if ((rec_count >= offset) && if ((rec_count >= offset) &&
((my_time_t)(ev->when) >= start_datetime) || ((my_time_t)(ev->when) >= start_datetime))
(ev_type == FORMAT_DESCRIPTION_EVENT))
{ {
if (ev_type != FORMAT_DESCRIPTION_EVENT) /*
{ We have found an event after start_datetime, from now on print
/* everything (in case the binlog has timestamps increasing and decreasing,
We have found an event after start_datetime, from now on print we do this to avoid cutting the middle).
everything (in case the binlog has timestamps increasing and */
decreasing, we do this to avoid cutting the middle). start_datetime= 0;
*/ offset= 0; // print everything and protect against cycling rec_count
start_datetime= 0;
offset= 0; // print everything and protect against cycling rec_count
}
if (((my_time_t)(ev->when) >= stop_datetime) if (((my_time_t)(ev->when) >= stop_datetime)
|| (pos >= stop_position_mot)) || (pos >= stop_position_mot))
{ {
@ -387,7 +349,7 @@ int process_event(LAST_EVENT_INFO *last_event_info, Log_event *ev,
if (!short_form) if (!short_form)
fprintf(result_file, "# at %s\n",llstr(pos,ll_buff)); fprintf(result_file, "# at %s\n",llstr(pos,ll_buff));
switch (ev_type) { switch (ev->get_type_code()) {
case QUERY_EVENT: case QUERY_EVENT:
if (one_database) if (one_database)
{ {
@ -395,7 +357,7 @@ int process_event(LAST_EVENT_INFO *last_event_info, Log_event *ev,
if ((log_dbname != NULL) && (strcmp(log_dbname, database))) if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
goto end; goto end;
} }
ev->print(result_file, short_form, last_event_info); ev->print(result_file, short_form, last_db);
break; break;
case CREATE_FILE_EVENT: case CREATE_FILE_EVENT:
{ {
@ -419,9 +381,8 @@ int process_event(LAST_EVENT_INFO *last_event_info, Log_event *ev,
filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT'
below. below.
*/ */
ce->print(result_file, short_form, last_event_info, TRUE); ce->print(result_file, short_form, last_db, TRUE);
// If this binlog is not 3.23 ; why this test?? if (!old_format)
if (description_event->binlog_version >= 3)
{ {
if (load_processor.process(ce)) if (load_processor.process(ce))
break; // Error break; // Error
@ -430,23 +391,23 @@ int process_event(LAST_EVENT_INFO *last_event_info, Log_event *ev,
break; break;
} }
case APPEND_BLOCK_EVENT: case APPEND_BLOCK_EVENT:
ev->print(result_file, short_form, last_event_info); ev->print(result_file, short_form, last_db);
if (load_processor.process((Append_block_log_event*) ev)) if (load_processor.process((Append_block_log_event*) ev))
break; // Error break; // Error
break; break;
case EXEC_LOAD_EVENT: case EXEC_LOAD_EVENT:
{ {
ev->print(result_file, short_form, last_event_info); ev->print(result_file, short_form, last_db);
Execute_load_log_event *exv= (Execute_load_log_event*)ev; Execute_load_log_event *exv= (Execute_load_log_event*)ev;
Create_file_log_event *ce= load_processor.grab_event(exv->file_id); Create_file_log_event *ce= load_processor.grab_event(exv->file_id);
/* /*
if ce is 0, it probably means that we have not seen the Create_file if ce is 0, it probably means that we have not seen the Create_file
event (a bad binlog, or most probably --start-position is after the event (a bad binlog, or most probably --position is after the
Create_file event). Print a warning comment. Create_file event). Print a warning comment.
*/ */
if (ce) if (ce)
{ {
ce->print(result_file, short_form, last_event_info, TRUE); ce->print(result_file, short_form, last_db, TRUE);
my_free((char*)ce->fname,MYF(MY_WME)); my_free((char*)ce->fname,MYF(MY_WME));
delete ce; delete ce;
} }
@ -455,20 +416,8 @@ int process_event(LAST_EVENT_INFO *last_event_info, Log_event *ev,
Create_file event for file_id: %u\n",exv->file_id); Create_file event for file_id: %u\n",exv->file_id);
break; break;
} }
case FORMAT_DESCRIPTION_EVENT:
delete description_event;
description_event= (Format_description_log_event*) ev;
ev->print(result_file, short_form, last_event_info);
/*
We don't want this event to be deleted now, so let's hide it (I
(Guilhem) should later see if this triggers a non-serious Valgrind
error). Not serious error, because we will free description_event
later.
*/
ev= 0;
break;
default: default:
ev->print(result_file, short_form, last_event_info); ev->print(result_file, short_form, last_db);
} }
} }
@ -609,7 +558,7 @@ static void die(const char* fmt, ...)
static void print_version() static void print_version()
{ {
printf("%s Ver 3.1 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); printf("%s Ver 3.0 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
NETWARE_SET_SCREEN_MODE(1); NETWARE_SET_SCREEN_MODE(1);
} }
@ -752,17 +701,12 @@ static int dump_log_entries(const char* logname)
} }
/* static int check_master_version(MYSQL* mysql)
This is not as smart as check_header() (used for local log); it will not work
for a binlog which mixes format. TODO: fix this.
*/
static int check_master_version(MYSQL* mysql,
Format_description_log_event
**description_event)
{ {
MYSQL_RES* res = 0; MYSQL_RES* res = 0;
MYSQL_ROW row; MYSQL_ROW row;
const char* version; const char* version;
int old_format = 0;
if (mysql_query(mysql, "SELECT VERSION()") || if (mysql_query(mysql, "SELECT VERSION()") ||
!(res = mysql_store_result(mysql))) !(res = mysql_store_result(mysql)))
@ -787,18 +731,11 @@ static int check_master_version(MYSQL* mysql,
switch (*version) { switch (*version) {
case '3': case '3':
*description_event= new Format_description_log_event(1); old_format = 1;
break; break;
case '4': case '4':
*description_event= new Format_description_log_event(3);
case '5': case '5':
/* old_format = 0;
The server is soon going to send us its Format_description log
event, unless it is a 5.0 server with 3.23 or 4.0 binlogs.
So we first assume that this is 4.0 (which is enough to read the
Format_desc event if one comes).
*/
*description_event= new Format_description_log_event(3);
break; break;
default: default:
sql_print_error("Master reported unrecognized MySQL version '%s'", sql_print_error("Master reported unrecognized MySQL version '%s'",
@ -808,17 +745,18 @@ static int check_master_version(MYSQL* mysql,
return 1; return 1;
} }
mysql_free_result(res); mysql_free_result(res);
return 0; return old_format;
} }
static int dump_remote_log_entries(const char* logname) static int dump_remote_log_entries(const char* logname)
{ {
char buf[128]; char buf[128];
LAST_EVENT_INFO last_event_info; char last_db[FN_REFLEN+1] = "";
uint len, logname_len; ulong len;
uint logname_len;
NET* net; NET* net;
int old_format;
int error= 0; int error= 0;
my_off_t old_off= start_position_mot; my_off_t old_off= start_position_mot;
char fname[FN_REFLEN+1]; char fname[FN_REFLEN+1];
@ -831,18 +769,7 @@ static int dump_remote_log_entries(const char* logname)
*/ */
mysql= safe_connect(); mysql= safe_connect();
net= &mysql->net; net= &mysql->net;
old_format = check_master_version(mysql);
if (check_master_version(mysql, &description_event))
{
fprintf(stderr, "Could not find server version");
DBUG_RETURN(1);
}
if (!description_event || !description_event->is_valid())
{
fprintf(stderr, "Invalid Format_description log event; \
could be out of memory");
DBUG_RETURN(1);
}
/* /*
COM_BINLOG_DUMP accepts only 4 bytes for the position, so we are forced to COM_BINLOG_DUMP accepts only 4 bytes for the position, so we are forced to
@ -850,7 +777,15 @@ could be out of memory");
*/ */
int4store(buf, (uint32)start_position); int4store(buf, (uint32)start_position);
int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags); int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags);
logname_len = (uint) strlen(logname);
size_s tlen = strlen(logname);
if (tlen > UINT_MAX)
{
fprintf(stderr,"Log name too long\n");
error= 1;
goto err;
}
logname_len = (uint) tlen;
int4store(buf + 6, 0); int4store(buf + 6, 0);
memcpy(buf + 10, logname, logname_len); memcpy(buf + 10, logname, logname_len);
if (simple_command(mysql, COM_BINLOG_DUMP, buf, logname_len + 10, 1)) if (simple_command(mysql, COM_BINLOG_DUMP, buf, logname_len + 10, 1))
@ -863,8 +798,6 @@ could be out of memory");
for (;;) for (;;)
{ {
const char *error_msg; const char *error_msg;
Log_event *ev;
len = net_safe_read(mysql); len = net_safe_read(mysql);
if (len == packet_error) if (len == packet_error)
{ {
@ -877,9 +810,9 @@ could be out of memory");
break; // end of data break; // end of data
DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n", DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n",
len, net->read_pos[5])); len, net->read_pos[5]));
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 , Log_event *ev = Log_event::read_log_event((const char*) net->read_pos + 1 ,
len - 1, &error_msg, len - 1, &error_msg, old_format);
description_event))) if (!ev)
{ {
fprintf(stderr, "Could not construct log event object\n"); fprintf(stderr, "Could not construct log event object\n");
error= 1; error= 1;
@ -887,27 +820,25 @@ could be out of memory");
} }
Log_event_type type= ev->get_type_code(); Log_event_type type= ev->get_type_code();
if (description_event->binlog_version >= 3 || if (!old_format || ( type != LOAD_EVENT && type != CREATE_FILE_EVENT))
(type != LOAD_EVENT && type != CREATE_FILE_EVENT))
{ {
/* if (ev->get_type_code() == ROTATE_EVENT)
If this is a Rotate event, maybe it's the end of the requested binlog;
in this case we are done (stop transfer).
This is suitable for binlogs, not relay logs (but for now we don't read
relay logs remotely because the server is not able to do that). If one
day we read relay logs remotely, then we will have a problem with the
detection below: relay logs contain Rotate events which are about the
binlogs, so which would trigger the end-detection below.
*/
if (type == ROTATE_EVENT)
{ {
Rotate_log_event *rev= (Rotate_log_event *)ev; Rotate_log_event *rev= (Rotate_log_event *)ev;
/* /*
mysqld is sending us all its binlogs after the requested one, but we
don't want them.
If this is a fake Rotate event, and not about our log, we can stop If this is a fake Rotate event, and not about our log, we can stop
transfer. If this a real Rotate event (so it's not about our log, transfer. If this a real Rotate event (so it's not about our log,
it's in our log describing the next log), we print it (because it's it's in our log describing the next log), we print it (because it's
part of our log) and then we will stop when we receive the fake one part of our log) and then we will stop when we receive the fake one
soon. soon.
This is suitable for binlogs, not relay logs (but for now we don't
read relay logs remotely because the server is not able to do
that). If one day we read relay logs remotely, then we will have a
problem with the detection below: relay logs contain Rotate events
which are about the binlogs, so which would trigger the end-detection
below.
*/ */
if (rev->when == 0) if (rev->when == 0)
{ {
@ -930,7 +861,7 @@ could be out of memory");
len= 1; // fake Rotate, so don't increment old_off len= 1; // fake Rotate, so don't increment old_off
} }
} }
if ((error= process_event(&last_event_info,ev,old_off))) if ((error= process_event(last_db,ev,old_off,old_format)))
{ {
error= ((error < 0) ? 0 : 1); error= ((error < 0) ? 0 : 1);
goto err; goto err;
@ -942,135 +873,64 @@ could be out of memory");
const char *old_fname= le->fname; const char *old_fname= le->fname;
uint old_len= le->fname_len; uint old_len= le->fname_len;
File file; File file;
if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0) if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0)
{ {
error= 1; error= 1;
goto err; goto err;
} }
if ((error= process_event(&last_event_info,ev,old_off))) if ((error= process_event(last_db,ev,old_off,old_format)))
{ {
my_close(file,MYF(MY_WME)); my_close(file,MYF(MY_WME));
error= ((error < 0) ? 0 : 1); error= ((error < 0) ? 0 : 1);
goto err; goto err;
} }
error= load_processor.load_old_format_file(net,old_fname,old_len,file); if (load_processor.load_old_format_file(net,old_fname,old_len,file))
my_close(file,MYF(MY_WME));
if (error)
{ {
my_close(file,MYF(MY_WME));
error= 1; error= 1;
goto err; goto err;
} }
my_close(file,MYF(MY_WME));
} }
/* /*
Let's adjust offset for remote log as for local log to produce Let's adjust offset for remote log as for local log to produce
similar text. similar text.
*/ */
old_off+= len-1; old_off+= len-1;
} }
err: err:
mysql_close(mysql); mysql_close(mysql);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
static void check_header(IO_CACHE* file, static int check_header(IO_CACHE* file)
Format_description_log_event **description_event)
{ {
byte header[BIN_LOG_HEADER_SIZE]; byte header[BIN_LOG_HEADER_SIZE];
byte buf[PROBE_HEADER_LEN]; byte buf[PROBE_HEADER_LEN];
my_off_t tmp_pos, pos; int old_format=0;
DBUG_ENTER("check_header");
*description_event= new Format_description_log_event(3); my_off_t pos = my_b_tell(file);
pos= my_b_tell(file);
my_b_seek(file, (my_off_t)0); my_b_seek(file, (my_off_t)0);
if (my_b_read(file, header, sizeof(header))) if (my_b_read(file, header, sizeof(header)))
die("Failed reading header; Probably an empty file"); die("Failed reading header; Probably an empty file");
if (memcmp(header, BINLOG_MAGIC, sizeof(header))) if (memcmp(header, BINLOG_MAGIC, sizeof(header)))
die("File is not a binary log file"); die("File is not a binary log file");
if (!my_b_read(file, buf, sizeof(buf)))
/*
Imagine we are running with --start-position=1000. We still need
to know the binlog format's. So we still need to find, if there is
one, the Format_desc event, or to know if this is a 3.23
binlog. So we need to first read the first events of the log,
those around offset 4. Even if we are reading a 3.23 binlog from
the start (no --start-position): we need to know the header length
(which is 13 in 3.23, 19 in 4.x) to be able to successfully print
the first event (Start_log_event_v3). So even in this case, we
need to "probe" the first bytes of the log *before* we do a real
read_log_event(). Because read_log_event() needs to know the
header's length to work fine.
*/
for(;;)
{ {
tmp_pos= my_b_tell(file); /* should be 4 the first time */ if (buf[4] == START_EVENT)
if (my_b_read(file, buf, sizeof(buf)))
{ {
if (file->error) uint event_len;
die("\ event_len = uint4korr(buf + EVENT_LEN_OFFSET);
Could not read entry at offset %lu : Error in log format or read error", old_format = (event_len < (LOG_EVENT_HEADER_LEN + START_HEADER_LEN));
tmp_pos);
/*
Otherwise this is just EOF : this log currently contains 0-2
events. Maybe it's going to be filled in the next
milliseconds; then we are going to have a problem if this a
3.23 log (imagine we are locally reading a 3.23 binlog which
is being written presently): we won't know it in
read_log_event() and will fail(). Similar problems could
happen with hot relay logs if --start-position is used (but a
--start-position which is posterior to the current size of the log).
These are rare problems anyway (reading a hot log + when we
read the first events there are not all there yet + when we
read a bit later there are more events + using a strange
--start-position).
*/
break;
}
else
{
DBUG_PRINT("info",("buf[4]=%d", buf[4]));
/* always test for a Start_v3, even if no --start-position */
if (buf[4] == START_EVENT_V3) /* This is 3.23 or 4.x */
{
if (uint4korr(buf + EVENT_LEN_OFFSET) <
(LOG_EVENT_MINIMAL_HEADER_LEN + START_V3_HEADER_LEN))
{
/* This is 3.23 (format 1) */
delete *description_event;
*description_event= new Format_description_log_event(1);
}
break;
}
else if (tmp_pos >= start_position)
break;
else if (buf[4] == FORMAT_DESCRIPTION_EVENT) /* This is 5.0 */
{
my_b_seek(file, tmp_pos); /* seek back to event's start */
if (!(*description_event= (Format_description_log_event*)
Log_event::read_log_event(file, *description_event)))
/* EOF can't be hit here normally, so it's a real error */
die("Could not read a Format_description_log_event event \
at offset %lu ; this could be a log format error or read error",
tmp_pos);
DBUG_PRINT("info",("Setting description_event"));
}
else if (buf[4] == ROTATE_EVENT)
{
my_b_seek(file, tmp_pos); /* seek back to event's start */
if (!Log_event::read_log_event(file, *description_event))
/* EOF can't be hit here normally, so it's a real error */
die("Could not read a Rotate_log_event event \
at offset %lu ; this could be a log format error or read error",
tmp_pos);
}
else
break;
} }
} }
my_b_seek(file, pos); my_b_seek(file, pos);
DBUG_RETURN(old_format);
} }
@ -1078,10 +938,13 @@ static int dump_local_log_entries(const char* logname)
{ {
File fd = -1; File fd = -1;
IO_CACHE cache,*file= &cache; IO_CACHE cache,*file= &cache;
LAST_EVENT_INFO last_event_info; char last_db[FN_REFLEN+1];
byte tmp_buff[BIN_LOG_HEADER_SIZE]; byte tmp_buff[BIN_LOG_HEADER_SIZE];
bool old_format = 0;
int error= 0; int error= 0;
last_db[0]= 0;
if (logname && logname[0] != '-') if (logname && logname[0] != '-')
{ {
if ((fd = my_open(logname, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) if ((fd = my_open(logname, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0)
@ -1090,16 +953,16 @@ static int dump_local_log_entries(const char* logname)
MYF(MY_WME | MY_NABP))) MYF(MY_WME | MY_NABP)))
{ {
my_close(fd, MYF(MY_WME)); my_close(fd, MYF(MY_WME));
return 1; exit(1);
} }
check_header(file, &description_event); old_format = check_header(file);
} }
else // reading from stdin; TODO: check that it works else
{ {
if (init_io_cache(file, fileno(result_file), 0, READ_CACHE, (my_off_t) 0, if (init_io_cache(file, fileno(result_file), 0, READ_CACHE, (my_off_t) 0,
0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE))) 0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE)))
return 1; return 1;
check_header(file, &description_event); old_format = check_header(file);
if (start_position) if (start_position)
{ {
/* skip 'start_position' characters from stdout */ /* skip 'start_position' characters from stdout */
@ -1109,44 +972,46 @@ static int dump_local_log_entries(const char* logname)
{ {
tmp=min(length,sizeof(buff)); tmp=min(length,sizeof(buff));
if (my_b_read(file, buff, (uint) tmp)) if (my_b_read(file, buff, (uint) tmp))
{ {
error= 1; error= 1;
goto end; goto end;
} }
} }
} }
file->pos_in_file= start_position_mot; file->pos_in_file= start_position_mot;
file->seek_not_done=0; file->seek_not_done=0;
} }
if (!description_event || !description_event->is_valid()) if (!start_position)
die("Invalid Format_description log event; could be out of memory");
if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE))
{ {
error= 1; // Skip header
goto end; if (my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE))
{
error= 1;
goto end;
}
} }
for (;;) for (;;)
{ {
char llbuff[21]; char llbuff[21];
my_off_t old_off = my_b_tell(file); my_off_t old_off = my_b_tell(file);
Log_event* ev = Log_event::read_log_event(file, description_event); Log_event* ev = Log_event::read_log_event(file, old_format);
if (!ev) if (!ev)
{ {
if (file->error) if (file->error)
{ {
fprintf(stderr, fprintf(stderr,
"Could not read entry at offset %s:" "Could not read entry at offset %s:"
"Error in log format or read error\n", "Error in log format or read error\n",
llstr(old_off,llbuff)); llstr(old_off,llbuff));
error= 1; error= 1;
} }
// file->error == 0 means EOF, that's OK, we break in this case // file->error == 0 means EOF, that's OK, we break in this case
break; break;
} }
if ((error= process_event(&last_event_info,ev,old_off))) if ((error= process_event(last_db,ev,old_off,false)))
{ {
if (error < 0) if (error < 0)
error= 0; error= 0;
@ -1158,7 +1023,6 @@ end:
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(MY_WME)); my_close(fd, MYF(MY_WME));
end_io_cache(file); end_io_cache(file);
delete description_event;
return error; return error;
} }

View File

@ -37,7 +37,7 @@
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov ** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
*/ */
#define DUMP_VERSION "10.8" #define DUMP_VERSION "10.9"
#include <my_global.h> #include <my_global.h>
#include <my_sys.h> #include <my_sys.h>
@ -78,8 +78,8 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick= 1, extended_insert= 1,
lock_tables=1,ignore_errors=0,flush_logs=0,replace=0, lock_tables=1,ignore_errors=0,flush_logs=0,replace=0,
ignore=0,opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0, ignore=0,opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0,
opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0, opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0,
opt_alldbs=0,opt_create_db=0,opt_first_slave=0,opt_set_charset, opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0,opt_set_charset,
opt_autocommit=0,opt_master_data,opt_disable_keys=1,opt_xml=0, opt_autocommit=0,opt_disable_keys=1,opt_xml=0,
opt_delete_master_logs=0, tty_password=0, opt_delete_master_logs=0, tty_password=0,
opt_single_transaction=0, opt_comments= 0, opt_compact= 0, opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
opt_hex_blob=0; opt_hex_blob=0;
@ -93,7 +93,9 @@ static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*err_ptr= 0; *err_ptr= 0;
static char compatible_mode_normal_str[255]; static char compatible_mode_normal_str[255];
static ulong opt_compatible_mode= 0; static ulong opt_compatible_mode= 0;
static uint opt_mysql_port= 0, err_len= 0; #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
static uint opt_mysql_port= 0, err_len= 0, opt_master_data;
static my_string opt_mysql_unix_port=0; static my_string opt_mysql_unix_port=0;
static int first_error=0; static int first_error=0;
static DYNAMIC_STRING extended_row; static DYNAMIC_STRING extended_row;
@ -106,8 +108,6 @@ static uint opt_protocol= 0;
static char *default_charset= (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET; static char *default_charset= (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET;
static CHARSET_INFO *charset_info= &my_charset_latin1; static CHARSET_INFO *charset_info= &my_charset_latin1;
const char *default_dbug_option="d:t:o,/tmp/mysqldump.trace"; const char *default_dbug_option="d:t:o,/tmp/mysqldump.trace";
/* do we met VIEWs during tables scaning */
my_bool was_views= 0;
const char *compatible_mode_names[]= const char *compatible_mode_names[]=
{ {
@ -185,8 +185,9 @@ static struct my_option my_long_options[] =
(gptr*) &opt_delayed, (gptr*) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (gptr*) &opt_delayed, (gptr*) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"delete-master-logs", OPT_DELETE_MASTER_LOGS, {"delete-master-logs", OPT_DELETE_MASTER_LOGS,
"Delete logs on master after backup. This automatically enables --first-slave.", "Delete logs on master after backup. This automatically enables --master-data.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &opt_delete_master_logs, (gptr*) &opt_delete_master_logs, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"disable-keys", 'K', {"disable-keys", 'K',
"'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (gptr*) &opt_disable_keys, "'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (gptr*) &opt_disable_keys,
(gptr*) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, (gptr*) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
@ -205,13 +206,18 @@ static struct my_option my_long_options[] =
(gptr*) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, (gptr*) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0},
{"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...", {"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...",
(gptr*) &escaped, (gptr*) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &escaped, (gptr*) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"first-slave", 'x', "Locks all tables across all databases.", {"first-slave", 'x', "Deprecated, renamed to --lock-all-tables.",
(gptr*) &opt_first_slave, (gptr*) &opt_first_slave, 0, GET_BOOL, NO_ARG, (gptr*) &opt_lock_all_tables, (gptr*) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"flush-logs", 'F', "Flush logs file in server before starting dump. " {"flush-logs", 'F', "Flush logs file in server before starting dump. "
"Note that if you dump many databases at once (using the option " "Note that if you dump many databases at once (using the option "
"--databases= or --all-databases), the logs will be flushed for " "--databases= or --all-databases), the logs will be flushed for "
"each database dumped.", "each database dumped. The exception is when using --lock-all-tables "
"or --master-data: "
"in this case the logs will be flushed only once, corresponding "
"to the moment all tables are locked. So if you want your dump and "
"the log flush to happen at the same exact moment you should use "
"--lock-all-tables or --master-data with --flush-logs",
(gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"force", 'f', "Continue even if we get an sql-error.", {"force", 'f', "Continue even if we get an sql-error.",
@ -224,17 +230,40 @@ static struct my_option my_long_options[] =
{"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...",
(gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lock-all-tables", 'x', "Locks all tables across all databases. This "
"is achieved by taking a global read lock for the duration of the whole "
"dump. Automatically turns --single-transaction and --lock-tables off.",
(gptr*) &opt_lock_all_tables, (gptr*) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables, {"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables,
(gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"master-data", OPT_MASTER_DATA, {"master-data", OPT_MASTER_DATA,
"This causes the master position and filename to be appended to your output. This automatically enables --first-slave.", "This causes the binary log position and filename to be appended to the "
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, "output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
" to 2, that command will be prefixed with a comment symbol. "
"This option will turn --lock-all-tables on, unless "
"--single-transaction is specified too (in which case a "
"global read lock is only taken a short time at the beginning of the dump "
"- don't forget to read about --single-transaction below). In all cases "
"any action on logs will happen at the exact moment of the dump."
"Option automatically turns --lock-tables off.",
(gptr*) &opt_master_data, (gptr*) &opt_master_data, 0,
GET_UINT, REQUIRED_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0},
{"no-autocommit", OPT_AUTOCOMMIT, {"no-autocommit", OPT_AUTOCOMMIT,
"Wrap tables with autocommit/commit statements.", "Wrap tables with autocommit/commit statements.",
(gptr*) &opt_autocommit, (gptr*) &opt_autocommit, 0, GET_BOOL, NO_ARG, (gptr*) &opt_autocommit, (gptr*) &opt_autocommit, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
/*
Note that the combination --single-transaction --master-data
will give bullet-proof binlog position only if server >=4.1.3. That's the
old "FLUSH TABLES WITH READ LOCK does not block commit" fixed bug.
*/
{"single-transaction", OPT_TRANSACTION, {"single-transaction", OPT_TRANSACTION,
"Dump all tables in single transaction to get consistent snapshot. Mutually exclusive with --lock-tables.", "Creates a consistent snapshot by dumping all tables in a single "
"transaction. Works ONLY for tables stored in storage engines which "
"support multiversioning (currently only InnoDB does); the dump is NOT "
"guaranteed to be consistent for other storage engines. Option "
"automatically turns off --lock-tables.",
(gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0, (gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"no-create-db", 'n', {"no-create-db", 'n',
@ -338,8 +367,6 @@ static int dump_databases(char **);
static int dump_all_databases(); static int dump_all_databases();
static char *quote_name(const char *name, char *buff, my_bool force); static char *quote_name(const char *name, char *buff, my_bool force);
static const char *check_if_ignore_table(const char *table_name); static const char *check_if_ignore_table(const char *table_name);
static my_bool getViewStructure(char *table, char* db);
static my_bool dump_all_views_in_db(char *database);
#include <help_start.h> #include <help_start.h>
@ -476,14 +503,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { switch (optid) {
case OPT_MASTER_DATA:
opt_master_data=1;
opt_first_slave=1;
break;
case OPT_DELETE_MASTER_LOGS:
opt_delete_master_logs=1;
opt_first_slave=1;
break;
case 'p': case 'p':
if (argument) if (argument)
{ {
@ -531,7 +550,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_OPTIMIZE: case (int) OPT_OPTIMIZE:
extended_insert= opt_drop= opt_lock= quick= create_options= extended_insert= opt_drop= opt_lock= quick= create_options=
opt_disable_keys= lock_tables= opt_set_charset= 1; opt_disable_keys= lock_tables= opt_set_charset= 1;
if (opt_single_transaction) lock_tables=0;
break; break;
case (int) OPT_SKIP_OPTIMIZATION: case (int) OPT_SKIP_OPTIMIZATION:
extended_insert= opt_drop= opt_lock= quick= create_options= extended_insert= opt_drop= opt_lock= quick= create_options=
@ -627,7 +645,19 @@ static int get_options(int *argc, char ***argv)
"%s: You must use option --tab with --fields-...\n", my_progname); "%s: You must use option --tab with --fields-...\n", my_progname);
return(1); return(1);
} }
if (opt_single_transaction)
/* Ensure consistency of the set of binlog & locking options */
if (opt_delete_master_logs && !opt_master_data)
opt_master_data= MYSQL_OPT_MASTER_DATA_COMMENTED_SQL;
if (opt_single_transaction && opt_lock_all_tables)
{
fprintf(stderr, "%s: You can't use --single-transaction and "
"--lock-all-tables at the same time.\n", my_progname);
return(1);
}
if (opt_master_data)
opt_lock_all_tables= !opt_single_transaction;
if (opt_single_transaction || opt_lock_all_tables)
lock_tables= 0; lock_tables= 0;
if (enclosed && opt_enclosed) if (enclosed && opt_enclosed)
{ {
@ -674,6 +704,36 @@ static void DBerror(MYSQL *mysql, const char *when)
} /* DBerror */ } /* DBerror */
/*
Sends a query to server, optionally reads result, prints error message if
some.
SYNOPSIS
mysql_query_with_error_report()
mysql_con connection to use
res if non zero, result will be put there with mysql_store_result
query query to send to server
RETURN VALUES
0 query sending and (if res!=0) result reading went ok
1 error
*/
static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
const char *query)
{
if (mysql_query(mysql_con, query) ||
(res && !((*res)= mysql_store_result(mysql_con))))
{
my_printf_error(0, "%s: Couldn't execute '%s': %s (%d)",
MYF(0), my_progname, query,
mysql_error(mysql_con), mysql_errno(mysql_con));
return 1;
}
return 0;
}
static void safe_exit(int error) static void safe_exit(int error)
{ {
if (!first_error) if (!first_error)
@ -721,12 +781,15 @@ static int dbConnect(char *host, char *user,char *passwd)
DBerror(&mysql_connection, "when trying to connect"); DBerror(&mysql_connection, "when trying to connect");
return 1; return 1;
} }
/*
As we're going to set SQL_MODE, it would be lost on reconnect, so we
cannot reconnect.
*/
sock->reconnect= 0;
sprintf(buff, "/*!40100 SET @@SQL_MODE=\"%s\" */", sprintf(buff, "/*!40100 SET @@SQL_MODE=\"%s\" */",
compatible_mode_normal_str); compatible_mode_normal_str);
if (mysql_query(sock, buff)) if (mysql_query_with_error_report(sock, 0, buff))
{ {
fprintf(stderr, "%s: Can't set the compatible mode %s (error %s)\n",
my_progname, compatible_mode_normal_str, mysql_error(sock));
mysql_close(sock); mysql_close(sock);
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
return 1; return 1;
@ -965,20 +1028,17 @@ static uint getTableStructure(char *table, char* db)
result_table= quote_name(table, table_buff, 1); result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0); opt_quoted_table= quote_name(table, table_buff2, 0);
if (!opt_xml && !mysql_query(sock,insert_pat)) if (!opt_xml && !mysql_query_with_error_report(sock, 0, insert_pat))
{ {
/* using SHOW CREATE statement */ /* using SHOW CREATE statement */
if (!tFlag) if (!tFlag)
{ {
/* Make an sql-file, if path was given iow. option -T was given */ /* Make an sql-file, if path was given iow. option -T was given */
char buff[20+FN_REFLEN]; char buff[20+FN_REFLEN];
MYSQL_FIELD *field;
sprintf(buff,"show create table %s", result_table); sprintf(buff,"show create table %s", result_table);
if (mysql_query(sock, buff)) if (mysql_query_with_error_report(sock, 0, buff))
{ {
fprintf(stderr, "%s: Can't get CREATE TABLE for table %s (%s)\n",
my_progname, result_table, mysql_error(sock));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -1008,25 +1068,15 @@ static uint getTableStructure(char *table, char* db)
check_io(sql_file); check_io(sql_file);
} }
tableRes= mysql_store_result(sock); tableRes=mysql_store_result(sock);
field= mysql_fetch_field_direct(tableRes, 0); row=mysql_fetch_row(tableRes);
if (strcmp(field->name, "View") == 0)
{
if (verbose)
fprintf(stderr, "-- It's a view, skipped\n");
was_views= 1;
DBUG_RETURN(0);
}
row= mysql_fetch_row(tableRes);
fprintf(sql_file, "%s;\n", row[1]); fprintf(sql_file, "%s;\n", row[1]);
check_io(sql_file); check_io(sql_file);
mysql_free_result(tableRes); mysql_free_result(tableRes);
} }
sprintf(insert_pat,"show fields from %s", result_table); sprintf(insert_pat,"show fields from %s", result_table);
if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) if (mysql_query_with_error_report(sock, &tableRes, insert_pat))
{ {
fprintf(stderr, "%s: Can't get info about table: %s\nerror: %s\n",
my_progname, result_table, mysql_error(sock));
if (path) if (path)
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
@ -1066,10 +1116,8 @@ static uint getTableStructure(char *table, char* db)
my_progname, mysql_error(sock)); my_progname, mysql_error(sock));
sprintf(insert_pat,"show fields from %s", result_table); sprintf(insert_pat,"show fields from %s", result_table);
if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock))) if (mysql_query_with_error_report(sock, &tableRes, insert_pat))
{ {
fprintf(stderr, "%s: Can't get info about table: %s\nerror: %s\n",
my_progname, result_table, mysql_error(sock));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -1163,23 +1211,14 @@ static uint getTableStructure(char *table, char* db)
char buff[20+FN_REFLEN]; char buff[20+FN_REFLEN];
uint keynr,primary_key; uint keynr,primary_key;
sprintf(buff,"show keys from %s", result_table); sprintf(buff,"show keys from %s", result_table);
if (mysql_query(sock, buff)) if (mysql_query_with_error_report(sock, &tableRes, buff))
{ {
if (mysql_errno(sock) == ER_WRONG_OBJECT)
{
/* it is VIEW */
fputs("\t\t<options Comment=\"view\" />\n", sql_file);
goto continue_xml;
}
fprintf(stderr, "%s: Can't get keys for table %s (%s)\n",
my_progname, result_table, mysql_error(sock));
if (path) if (path)
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
tableRes=mysql_store_result(sock);
/* Find first which key is primary key */ /* Find first which key is primary key */
keynr=0; keynr=0;
primary_key=INT_MAX; primary_key=INT_MAX;
@ -1243,7 +1282,7 @@ static uint getTableStructure(char *table, char* db)
char show_name_buff[FN_REFLEN]; char show_name_buff[FN_REFLEN];
sprintf(buff,"show table status like %s", sprintf(buff,"show table status like %s",
quote_for_like(table, show_name_buff)); quote_for_like(table, show_name_buff));
if (mysql_query(sock, buff)) if (mysql_query_with_error_report(sock, &tableRes, buff))
{ {
if (mysql_errno(sock) != ER_PARSE_ERROR) if (mysql_errno(sock) != ER_PARSE_ERROR)
{ /* If old MySQL version */ { /* If old MySQL version */
@ -1253,8 +1292,7 @@ static uint getTableStructure(char *table, char* db)
result_table,mysql_error(sock)); result_table,mysql_error(sock));
} }
} }
else if (!(tableRes=mysql_store_result(sock)) || else if (!(row=mysql_fetch_row(tableRes)))
!(row=mysql_fetch_row(tableRes)))
{ {
fprintf(stderr, fprintf(stderr,
"Error: Couldn't read status information for table %s (%s)\n", "Error: Couldn't read status information for table %s (%s)\n",
@ -1278,7 +1316,6 @@ static uint getTableStructure(char *table, char* db)
} }
mysql_free_result(tableRes); /* Is always safe to free */ mysql_free_result(tableRes); /* Is always safe to free */
} }
continue_xml:
if (!opt_xml) if (!opt_xml)
fputs(";\n", sql_file); fputs(";\n", sql_file);
else else
@ -1459,22 +1496,14 @@ static void dumpTable(uint numFields, char *table)
fputs("\n", md_result_file); fputs("\n", md_result_file);
check_io(md_result_file); check_io(md_result_file);
} }
if (mysql_query(sock, query)) if (mysql_query_with_error_report(sock, 0, query))
{
DBerror(sock, "when retrieving data from server"); DBerror(sock, "when retrieving data from server");
error= EX_CONSCHECK;
goto err;
}
if (quick) if (quick)
res=mysql_use_result(sock); res=mysql_use_result(sock);
else else
res=mysql_store_result(sock); res=mysql_store_result(sock);
if (!res) if (!res)
{
DBerror(sock, "when retrieving data from server"); DBerror(sock, "when retrieving data from server");
error= EX_CONSCHECK;
goto err;
}
if (verbose) if (verbose)
fprintf(stderr, "-- Retrieving rows...\n"); fprintf(stderr, "-- Retrieving rows...\n");
if (mysql_num_fields(res) != numFields) if (mysql_num_fields(res) != numFields)
@ -1809,33 +1838,13 @@ static int dump_all_databases()
MYSQL_RES *tableres; MYSQL_RES *tableres;
int result=0; int result=0;
if (mysql_query(sock, "SHOW DATABASES") || if (mysql_query_with_error_report(sock, &tableres, "SHOW DATABASES"))
!(tableres = mysql_store_result(sock)))
{
my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s",
MYF(0), mysql_error(sock));
return 1; return 1;
}
while ((row = mysql_fetch_row(tableres))) while ((row = mysql_fetch_row(tableres)))
{ {
if (dump_all_tables_in_db(row[0])) if (dump_all_tables_in_db(row[0]))
result=1; result=1;
} }
if (was_views)
{
if (mysql_query(sock, "SHOW DATABASES") ||
!(tableres = mysql_store_result(sock)))
{
my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s",
MYF(0), mysql_error(sock));
return 1;
}
while ((row = mysql_fetch_row(tableres)))
{
if (dump_all_views_in_db(row[0]))
result=1;
}
}
return result; return result;
} }
/* dump_all_databases */ /* dump_all_databases */
@ -1844,20 +1853,11 @@ static int dump_all_databases()
static int dump_databases(char **db_names) static int dump_databases(char **db_names)
{ {
int result=0; int result=0;
char **db; for ( ; *db_names ; db_names++)
for (db= db_names ; *db ; db++)
{ {
if (dump_all_tables_in_db(*db)) if (dump_all_tables_in_db(*db_names))
result=1; result=1;
} }
if (!result && was_views)
{
for (db= db_names ; *db ; db++)
{
if (dump_all_views_in_db(*db))
result=1;
}
}
return result; return result;
} /* dump_databases */ } /* dump_databases */
@ -1892,7 +1892,7 @@ static int init_dumping(char *database)
sprintf(qbuf,"SHOW CREATE DATABASE WITH IF NOT EXISTS %s", sprintf(qbuf,"SHOW CREATE DATABASE WITH IF NOT EXISTS %s",
qdatabase); qdatabase);
if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock))) if (mysql_query_with_error_report(sock, &dbinfo, qbuf))
{ {
/* Old server version, dump generic CREATE DATABASE */ /* Old server version, dump generic CREATE DATABASE */
fprintf(md_result_file, fprintf(md_result_file,
@ -1961,68 +1961,15 @@ static int dump_all_tables_in_db(char *database)
check_io(md_result_file); check_io(md_result_file);
} }
if (lock_tables) if (lock_tables)
mysql_query(sock,"UNLOCK TABLES"); mysql_query_with_error_report(sock, 0, "UNLOCK TABLES");
return 0; return 0;
} /* dump_all_tables_in_db */ } /* dump_all_tables_in_db */
/*
dump structure of views of database
SYNOPSIS
dump_all_views_in_db()
database database name
RETURN
0 OK
1 ERROR
*/
static my_bool dump_all_views_in_db(char *database)
{
char *table;
uint numrows;
char table_buff[NAME_LEN*2+3];
if (init_dumping(database))
return 1;
if (opt_xml)
print_xml_tag1(md_result_file, "", "database name=", database, "\n");
if (lock_tables)
{
DYNAMIC_STRING query;
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (numrows= 0 ; (table= getTableName(1)); numrows++)
{
dynstr_append(&query, quote_name(table, table_buff, 1));
dynstr_append(&query, " READ /*!32311 LOCAL */,");
}
if (numrows && mysql_real_query(sock, query.str, query.length-1))
DBerror(sock, "when using LOCK TABLES");
/* We shall continue here, if --force was given */
dynstr_free(&query);
}
if (flush_logs)
{
if (mysql_refresh(sock, REFRESH_LOG))
DBerror(sock, "when doing refresh");
/* We shall continue here, if --force was given */
}
while ((table= getTableName(0)))
getViewStructure(table, database);
if (opt_xml)
{
fputs("</database>\n", md_result_file);
check_io(md_result_file);
}
if (lock_tables)
mysql_query(sock,"UNLOCK TABLES");
return 0;
} /* dump_all_tables_in_db */
static int dump_selected_tables(char *db, char **table_names, int tables) static int dump_selected_tables(char *db, char **table_names, int tables)
{ {
uint numrows; uint numrows;
int i;
char table_buff[NAME_LEN*+3]; char table_buff[NAME_LEN*+3];
if (init_dumping(db)) if (init_dumping(db))
@ -2030,6 +1977,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
if (lock_tables) if (lock_tables)
{ {
DYNAMIC_STRING query; DYNAMIC_STRING query;
int i;
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (i=0 ; i < tables ; i++) for (i=0 ; i < tables ; i++)
@ -2050,16 +1998,11 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
} }
if (opt_xml) if (opt_xml)
print_xml_tag1(md_result_file, "", "database name=", db, "\n"); print_xml_tag1(md_result_file, "", "database name=", db, "\n");
for (i=0 ; i < tables ; i++) for (; tables > 0 ; tables-- , table_names++)
{ {
numrows = getTableStructure(table_names[i], db); numrows = getTableStructure(*table_names, db);
if (!dFlag && numrows > 0) if (!dFlag && numrows > 0)
dumpTable(numrows, table_names[i]); dumpTable(numrows, *table_names);
}
if (was_views)
{
for (i=0 ; i < tables ; i++)
getViewStructure(table_names[i], db);
} }
if (opt_xml) if (opt_xml)
{ {
@ -2067,11 +2010,76 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
check_io(md_result_file); check_io(md_result_file);
} }
if (lock_tables) if (lock_tables)
mysql_query(sock,"UNLOCK TABLES"); mysql_query_with_error_report(sock, 0, "UNLOCK TABLES");
return 0; return 0;
} /* dump_selected_tables */ } /* dump_selected_tables */
static int do_show_master_status(MYSQL *mysql_con)
{
MYSQL_ROW row;
MYSQL_RES *master;
const char *comment_prefix=
(opt_master_data == MYSQL_OPT_MASTER_DATA_COMMENTED_SQL) ? "-- " : "";
if (mysql_query_with_error_report(mysql_con, &master, "SHOW MASTER STATUS"))
{
my_printf_error(0, "Error: Couldn't execute 'SHOW MASTER STATUS': %s",
MYF(0), mysql_error(mysql_con));
return 1;
}
else
{
row = mysql_fetch_row(master);
if (row && row[0] && row[1])
{
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- Position to start replication or point-in-time "
"recovery from\n--\n\n");
fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
comment_prefix, row[0], row[1]);
check_io(md_result_file);
}
mysql_free_result(master);
}
return 0;
}
static int do_flush_tables_read_lock(MYSQL *mysql_con)
{
return
mysql_query_with_error_report(mysql_con, 0, "FLUSH TABLES WITH READ LOCK");
}
static int do_unlock_tables(MYSQL *mysql_con)
{
return mysql_query_with_error_report(mysql_con, 0, "UNLOCK TABLES");
}
static int do_reset_master(MYSQL *mysql_con)
{
return mysql_query_with_error_report(mysql_con, 0, "RESET MASTER");
}
static int start_transaction(MYSQL *mysql_con, my_bool consistent_read_now)
{
/*
We use BEGIN for old servers. --single-transaction --master-data will fail
on old servers, but that's ok as it was already silently broken (it didn't
do a consistent read, so better tell people frankly, with the error).
*/
return (mysql_query_with_error_report(mysql_con, 0,
consistent_read_now ?
"START TRANSACTION "
"WITH CONSISTENT SNAPSHOT" :
"BEGIN"));
}
static ulong find_set(TYPELIB *lib, const char *x, uint length, static ulong find_set(TYPELIB *lib, const char *x, uint length,
char **err_pos, uint *err_len) char **err_pos, uint *err_len)
@ -2169,7 +2177,7 @@ static const char *check_if_ignore_table(const char *table_name)
sprintf(buff,"show table status like %s", sprintf(buff,"show table status like %s",
quote_for_like(table_name, show_name_buff)); quote_for_like(table_name, show_name_buff));
if (mysql_query(sock, buff)) if (mysql_query_with_error_report(sock, &res, buff))
{ {
if (mysql_errno(sock) != ER_PARSE_ERROR) if (mysql_errno(sock) != ER_PARSE_ERROR)
{ /* If old MySQL version */ { /* If old MySQL version */
@ -2180,8 +2188,7 @@ static const char *check_if_ignore_table(const char *table_name)
return 0; /* assume table is ok */ return 0; /* assume table is ok */
} }
} }
if (!(res= mysql_store_result(sock)) || if (!(row= mysql_fetch_row(res)))
!(row= mysql_fetch_row(res)))
{ {
fprintf(stderr, fprintf(stderr,
"Error: Couldn't read status information for table %s (%s)\n", "Error: Couldn't read status information for table %s (%s)\n",
@ -2190,117 +2197,16 @@ static const char *check_if_ignore_table(const char *table_name)
mysql_free_result(res); mysql_free_result(res);
return 0; /* assume table is ok */ return 0; /* assume table is ok */
} }
if (!(row[1])) if (strcmp(row[1], (result= "MRG_MyISAM")) &&
result= "VIEW"; strcmp(row[1], (result= "MRG_ISAM")))
else result= 0;
{
if (strcmp(row[1], (result= "MRG_MyISAM")) &&
strcmp(row[1], (result= "MRG_ISAM")))
result= 0;
}
mysql_free_result(res); mysql_free_result(res);
return result; return result;
} }
/*
Getting VIEW structure
SYNOPSIS
getViewStructure()
table view name
db db name
RETURN
0 OK
1 ERROR
*/
static my_bool getViewStructure(char *table, char* db)
{
MYSQL_RES *tableRes;
MYSQL_ROW row;
MYSQL_FIELD *field;
char *result_table, *opt_quoted_table;
char table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3];
char buff[20+FN_REFLEN];
FILE *sql_file = md_result_file;
DBUG_ENTER("getViewStructure");
if (tFlag)
DBUG_RETURN(0);
if (verbose)
fprintf(stderr, "-- Retrieving view structure for table %s...\n", table);
sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d",
(opt_quoted || opt_keywords));
result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
sprintf(buff,"show create table %s", result_table);
if (mysql_query(sock, buff))
{
fprintf(stderr, "%s: Can't get CREATE TABLE for view %s (%s)\n",
my_progname, result_table, mysql_error(sock));
safe_exit(EX_MYSQLERR);
DBUG_RETURN(0);
}
if (path)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path,path,NullS);
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME));
if (!sql_file) /* If file couldn't be opened */
{
safe_exit(EX_MYSQLERR);
DBUG_RETURN(1);
}
write_header(sql_file, db);
}
tableRes= mysql_store_result(sock);
field= mysql_fetch_field_direct(tableRes, 0);
if (strcmp(field->name, "View") != 0)
{
if (verbose)
fprintf(stderr, "-- It's base table, skipped\n");
DBUG_RETURN(0);
}
if (!opt_xml && opt_comments)
{
fprintf(sql_file, "\n--\n-- View structure for view %s\n--\n\n",
result_table);
check_io(sql_file);
}
if (opt_drop)
{
fprintf(sql_file, "DROP VIEW IF EXISTS %s;\n", opt_quoted_table);
check_io(sql_file);
}
row= mysql_fetch_row(tableRes);
fprintf(sql_file, "%s;\n", row[1]);
check_io(sql_file);
mysql_free_result(tableRes);
if (sql_file != md_result_file)
{
fputs("\n", sql_file);
write_footer(sql_file);
my_fclose(sql_file, MYF(MY_WME));
}
DBUG_RETURN(0);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
MYSQL_ROW row;
MYSQL_RES *master;
compatible_mode_normal_str[0]= 0; compatible_mode_normal_str[0]= 0;
MY_INIT(argv[0]); MY_INIT(argv[0]);
@ -2314,28 +2220,24 @@ int main(int argc, char **argv)
if (!path) if (!path)
write_header(md_result_file, *argv); write_header(md_result_file, *argv);
if (opt_first_slave) if ((opt_lock_all_tables || opt_master_data) &&
do_flush_tables_read_lock(sock))
goto err;
if (opt_single_transaction && start_transaction(sock, test(opt_master_data)))
goto err;
if (opt_delete_master_logs && do_reset_master(sock))
goto err;
if (opt_lock_all_tables || opt_master_data)
{ {
lock_tables=0; /* No other locks needed */ if (flush_logs && mysql_refresh(sock, REFRESH_LOG))
if (mysql_query(sock, "FLUSH TABLES WITH READ LOCK")) goto err;
{ flush_logs= 0; /* not anymore; that would not be sensible */
my_printf_error(0, "Error: Couldn't execute 'FLUSH TABLES WITH READ LOCK': %s",
MYF(0), mysql_error(sock));
my_end(0);
return(first_error);
}
}
else if (opt_single_transaction)
{
/* There is no sense to start transaction if all tables are locked */
if (mysql_query(sock, "BEGIN"))
{
my_printf_error(0, "Error: Couldn't execute 'BEGIN': %s",
MYF(0), mysql_error(sock));
my_end(0);
return(first_error);
}
} }
if (opt_master_data && do_show_master_status(sock))
goto err;
if (opt_single_transaction && do_unlock_tables(sock)) // unlock but no commit!
goto err;
if (opt_alldbs) if (opt_alldbs)
dump_all_databases(); dump_all_databases();
else if (argc > 1 && !opt_databases) else if (argc > 1 && !opt_databases)
@ -2348,57 +2250,16 @@ int main(int argc, char **argv)
/* One or more databases, all tables */ /* One or more databases, all tables */
dump_databases(argv); dump_databases(argv);
} }
if (opt_first_slave)
{
if (opt_delete_master_logs && mysql_query(sock, "FLUSH MASTER"))
{
my_printf_error(0, "Error: Couldn't execute 'FLUSH MASTER': %s",
MYF(0), mysql_error(sock));
}
if (opt_master_data)
{
if (mysql_query(sock, "SHOW MASTER STATUS") ||
!(master = mysql_store_result(sock)))
my_printf_error(0, "Error: Couldn't execute 'SHOW MASTER STATUS': %s",
MYF(0), mysql_error(sock));
else
{
row = mysql_fetch_row(master);
if (row && row[0] && row[1])
{
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- Position to start replication from\n--\n\n");
fprintf(md_result_file,
"CHANGE MASTER TO MASTER_LOG_FILE='%s', \
MASTER_LOG_POS=%s ;\n",row[0],row[1]);
check_io(md_result_file);
}
mysql_free_result(master);
}
}
if (mysql_query(sock, "UNLOCK TABLES"))
my_printf_error(0, "Error: Couldn't execute 'UNLOCK TABLES': %s",
MYF(0), mysql_error(sock));
}
else if (opt_single_transaction) /* Just to make it beautiful enough */
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif #endif
{ /*
/* No reason to explicitely COMMIT the transaction, neither to explicitely
In case we were locking all tables, we did not start transaction UNLOCK TABLES: these will be automatically be done by the server when we
so there is no need to commit it. disconnect now. Saves some code here, some network trips, adds nothing to
*/ server.
*/
/* This should just free locks as we did not change anything */ err:
if (mysql_query(sock, "COMMIT"))
{
my_printf_error(0, "Error: Couldn't execute 'COMMIT': %s",
MYF(0), mysql_error(sock));
}
}
dbDisconnect(current_host); dbDisconnect(current_host);
if (!path) if (!path)
write_footer(md_result_file); write_footer(md_result_file);

View File

@ -3065,9 +3065,15 @@ AC_SUBST([NDB_DEFS])
AC_SUBST([ndb_cxxflags_fix]) AC_SUBST([ndb_cxxflags_fix])
if test X"$ndb_port" = Xdefault
then
ndb_port="1186"
fi
AC_SUBST([ndb_port])
if test X"$ndb_port_base" = Xdefault if test X"$ndb_port_base" = Xdefault
then then
ndb_port_base="2200" ndb_port_base="2202"
fi fi
AC_SUBST([ndb_port_base]) AC_SUBST([ndb_port_base])
@ -3106,7 +3112,6 @@ AC_CONFIG_FILES(ndb/Makefile ndb/include/Makefile dnl
ndb/src/common/logger/Makefile dnl ndb/src/common/logger/Makefile dnl
ndb/src/common/transporter/Makefile dnl ndb/src/common/transporter/Makefile dnl
ndb/src/common/mgmcommon/Makefile dnl ndb/src/common/mgmcommon/Makefile dnl
ndb/src/common/editline/Makefile dnl
ndb/src/kernel/Makefile dnl ndb/src/kernel/Makefile dnl
ndb/src/kernel/error/Makefile dnl ndb/src/kernel/error/Makefile dnl
ndb/src/kernel/blocks/Makefile dnl ndb/src/kernel/blocks/Makefile dnl

View File

@ -227,14 +227,15 @@ static my_bool init_done = FALSE; /* Set to TRUE when initialization done */
static struct state *stack=0; static struct state *stack=0;
typedef struct st_code_state { typedef struct st_code_state {
int lineno; /* Current debugger output line number */
int level; /* Current function nesting level */
const char *func; /* Name of current user function */ const char *func; /* Name of current user function */
const char *file; /* Name of current user file */ const char *file; /* Name of current user file */
char **framep; /* Pointer to current frame */ char **framep; /* Pointer to current frame */
int jmplevel; /* Remember nesting level at setjmp () */
const char *jmpfunc; /* Remember current function for setjmp */ const char *jmpfunc; /* Remember current function for setjmp */
const char *jmpfile; /* Remember current file for setjmp */ const char *jmpfile; /* Remember current file for setjmp */
int lineno; /* Current debugger output line number */
int level; /* Current function nesting level */
int disable_output; /* Set to it if output is disabled */
int jmplevel; /* Remember nesting level at setjmp () */
/* /*
* The following variables are used to hold the state information * The following variables are used to hold the state information
@ -247,8 +248,8 @@ typedef struct st_code_state {
*/ */
uint u_line; /* User source code line number */ uint u_line; /* User source code line number */
const char *u_keyword; /* Keyword for current macro */
int locked; /* If locked with _db_lock_file */ int locked; /* If locked with _db_lock_file */
const char *u_keyword; /* Keyword for current macro */
} CODE_STATE; } CODE_STATE;
/* Parse a debug command string */ /* Parse a debug command string */
@ -370,8 +371,10 @@ static CODE_STATE *code_state(void)
#define code_state() (&static_code_state) #define code_state() (&static_code_state)
#define pthread_mutex_lock(A) {} #define pthread_mutex_lock(A) {}
#define pthread_mutex_unlock(A) {} #define pthread_mutex_unlock(A) {}
static CODE_STATE static_code_state = { 0,0,"?func","?file",NULL,0,NULL, static CODE_STATE static_code_state=
NULL,0,"?",0}; {
"?func", "?file", NULL, NullS, NullS, 0,0,0,0,0,0, NullS
};
#endif #endif
@ -728,9 +731,12 @@ char ***_sframep_ __attribute__((unused)))
if (DoProfile ()) if (DoProfile ())
{ {
long stackused; long stackused;
if (*state->framep == NULL) { if (*state->framep == NULL)
{
stackused = 0; stackused = 0;
} else { }
else
{
stackused = ((long)(*state->framep)) - ((long)(state->framep)); stackused = ((long)(*state->framep)) - ((long)(state->framep));
stackused = stackused > 0 ? stackused : -stackused; stackused = stackused > 0 ? stackused : -stackused;
} }
@ -744,7 +750,7 @@ char ***_sframep_ __attribute__((unused)))
(void) fflush (_db_pfp_); (void) fflush (_db_pfp_);
} }
#endif #endif
if (DoTrace (state)) if (DoTrace(state))
{ {
if (!state->locked) if (!state->locked)
pthread_mutex_lock(&THR_LOCK_dbug); pthread_mutex_lock(&THR_LOCK_dbug);
@ -754,7 +760,7 @@ char ***_sframep_ __attribute__((unused)))
dbug_flush (state); /* This does a unlock */ dbug_flush (state); /* This does a unlock */
} }
#ifdef SAFEMALLOC #ifdef SAFEMALLOC
if (stack -> flags & SANITY_CHECK_ON) if (stack->flags & SANITY_CHECK_ON && !state->disable_output)
if (_sanity(_file_,_line_)) /* Check of safemalloc */ if (_sanity(_file_,_line_)) /* Check of safemalloc */
stack -> flags &= ~SANITY_CHECK_ON; stack -> flags &= ~SANITY_CHECK_ON;
#endif #endif
@ -809,9 +815,11 @@ uint *_slevel_)
else else
{ {
#ifdef SAFEMALLOC #ifdef SAFEMALLOC
if (stack -> flags & SANITY_CHECK_ON) if (stack->flags & SANITY_CHECK_ON && !state->disable_output)
{
if (_sanity(*_sfile_,_line_)) if (_sanity(*_sfile_,_line_))
stack->flags &= ~SANITY_CHECK_ON; stack->flags &= ~SANITY_CHECK_ON;
}
#endif #endif
#ifndef THREAD #ifndef THREAD
if (DoProfile ()) if (DoProfile ())
@ -954,7 +962,6 @@ uint length)
int pos; int pos;
char dbuff[90]; char dbuff[90];
CODE_STATE *state; CODE_STATE *state;
/* Sasha: pre-my_thread_init() safety */
if (!(state=code_state())) if (!(state=code_state()))
return; return;
@ -994,6 +1001,25 @@ uint length)
} }
} }
/*
Enable/Disable output for this thread
SYNOPSIS
_db_output_()
flag 1 = enable output, 0 = disable_output
*/
void _db_output_(uint flag)
{
CODE_STATE *state;
if (!(state=code_state()))
return;
state->disable_output= !flag;
}
/* /*
* FUNCTION * FUNCTION
* *
@ -1159,7 +1185,7 @@ static BOOLEAN DoTrace (CODE_STATE *state)
{ {
reg2 BOOLEAN trace=FALSE; reg2 BOOLEAN trace=FALSE;
if (TRACING && if (TRACING && !state->disable_output &&
state->level <= stack -> maxdepth && state->level <= stack -> maxdepth &&
InList (stack -> functions, state->func) && InList (stack -> functions, state->func) &&
InList (stack -> processes, _db_process_)) InList (stack -> processes, _db_process_))
@ -1195,7 +1221,7 @@ static BOOLEAN DoProfile ()
state=code_state(); state=code_state();
profile = FALSE; profile = FALSE;
if (PROFILING && if (PROFILING && !state->disable_output &&
state->level <= stack -> maxdepth && state->level <= stack -> maxdepth &&
InList (stack -> p_functions, state->func) && InList (stack -> p_functions, state->func) &&
InList (stack -> processes, _db_process_)) InList (stack -> processes, _db_process_))
@ -1242,7 +1268,7 @@ const char *keyword)
if (!(state=code_state())) if (!(state=code_state()))
return FALSE; return FALSE;
result = FALSE; result = FALSE;
if (DEBUGGING && if (DEBUGGING && !state->disable_output &&
state->level <= stack -> maxdepth && state->level <= stack -> maxdepth &&
InList (stack -> functions, state->func) && InList (stack -> functions, state->func) &&
InList (stack -> keywords, keyword) && InList (stack -> keywords, keyword) &&

View File

@ -38,6 +38,7 @@ extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...)); extern void _db_doprnt_ _VARARGS((const char *format,...));
extern void _db_dump_(uint _line_,const char *keyword,const char *memory, extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
uint length); uint length);
extern void _db_output_();
extern void _db_lock_file(); extern void _db_lock_file();
extern void _db_unlock_file(); extern void _db_unlock_file();
@ -66,6 +67,7 @@ extern void _db_unlock_file();
#define DEBUGGER_ON _no_db_=0 #define DEBUGGER_ON _no_db_=0
#define DBUG_LOCK_FILE { _db_lock_file(); } #define DBUG_LOCK_FILE { _db_lock_file(); }
#define DBUG_UNLOCK_FILE { _db_unlock_file(); } #define DBUG_UNLOCK_FILE { _db_unlock_file(); }
#define DBUG_OUTPUT(A) { _db_output_(A); }
#define DBUG_ASSERT(A) assert(A) #define DBUG_ASSERT(A) assert(A)
#else /* No debugger */ #else /* No debugger */
@ -86,6 +88,7 @@ extern void _db_unlock_file();
#define DEBUGGER_ON #define DEBUGGER_ON
#define DBUG_LOCK_FILE #define DBUG_LOCK_FILE
#define DBUG_UNLOCK_FILE #define DBUG_UNLOCK_FILE
#define DBUG_OUTPUT(A)
#define DBUG_ASSERT(A) {} #define DBUG_ASSERT(A) {}
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -370,6 +370,12 @@ int __void__;
#define LINT_INIT(var) #define LINT_INIT(var)
#endif #endif
#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)
#define PURIFY_OR_LINT_INIT(var) var=0
#else
#define PURIFY_OR_LINT_INIT(var)
#endif
/* Define some useful general macros */ /* Define some useful general macros */
#if defined(__cplusplus) && defined(__GNUC__) #if defined(__cplusplus) && defined(__GNUC__)
#define max(a, b) ((a) >? (b)) #define max(a, b) ((a) >? (b))

View File

@ -221,6 +221,7 @@ extern ulong my_cache_w_requests, my_cache_write, my_cache_r_requests,
my_cache_read; my_cache_read;
extern ulong my_blocks_used, my_blocks_changed; extern ulong my_blocks_used, my_blocks_changed;
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
extern uint mysys_usage_id;
extern my_bool my_init_done; extern my_bool my_init_done;
/* Point to current my_message() */ /* Point to current my_message() */

View File

@ -490,6 +490,8 @@ MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
const char *wild); const char *wild);
unsigned long STDCALL mysql_escape_string(char *to,const char *from, unsigned long STDCALL mysql_escape_string(char *to,const char *from,
unsigned long from_length); unsigned long from_length);
unsigned long STDCALL mysql_hex_string(char *to,const char *from,
unsigned long from_length);
unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
char *to,const char *from, char *to,const char *from,
unsigned long length); unsigned long length);

View File

@ -342,13 +342,16 @@ dict_index_rec_get_sys_col(
ut_ad(len == 7); ut_ad(len == 7);
return(trx_read_roll_ptr(field)); return(trx_read_roll_ptr(field));
} else if ((type == DATA_ROW_ID) || (type == DATA_MIX_ID)) { } else if (type == DATA_TRX_ID) {
return(trx_read_trx_id(field));
} else if (type == DATA_MIX_ID) {
return(mach_dulint_read_compressed(field)); return(mach_dulint_read_compressed(field));
} else { } else {
ut_ad(type == DATA_TRX_ID); ut_a(type == DATA_ROW_ID);
return(trx_read_trx_id(field)); return(mach_read_from_6(field));
} }
} }

View File

@ -37,7 +37,7 @@ test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem
CLEANFILES = $(test_SCRIPTS) $(test_DATA) CLEANFILES = $(test_SCRIPTS) $(test_DATA)
INCLUDES = -I$(srcdir)/../include -I../include -I.. INCLUDES = -I$(srcdir)/../include -I../include -I..
bin_PROGRAMS = mysql_test_run_new EXTRA_PROGRAMS = mysql_test_run_new
noinst_HEADERS = my_manage.h noinst_HEADERS = my_manage.h
mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,8 @@
#ifndef __WIN__ #ifndef __WIN__
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <fnmatch.h> #include <signal.h>
#include <fnmatch.h> /* FIXME HAVE_FNMATCH_H or something */
#else #else
#include <direct.h> #include <direct.h>
#include <stdlib.h> #include <stdlib.h>
@ -100,7 +101,7 @@ void init_args(arg_list_t *al)
void add_arg(arg_list_t *al, const char *format, ...) void add_arg(arg_list_t *al, const char *format, ...)
{ {
va_list ap; va_list ap;
char temp[PATH_MAX]; char temp[FN_REFLEN];
ASSERT(al != NULL); ASSERT(al != NULL);
@ -230,10 +231,10 @@ int wait_for_server_start(char *bin_dir __attribute__((unused)),
{ {
arg_list_t al; arg_list_t al;
int err= 0, i; int err= 0, i;
char trash[PATH_MAX]; char trash[FN_REFLEN];
/* mysqladmin file */ /* mysqladmin file */
snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); snprintf(trash, FN_REFLEN, "%s/trash.out",tmp_dir);
/* args */ /* args */
init_args(&al); init_args(&al);
@ -490,9 +491,9 @@ int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file,
{ {
arg_list_t al; arg_list_t al;
int err= 0; int err= 0;
char trash[PATH_MAX]; char trash[FN_REFLEN];
snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); snprintf(trash, FN_REFLEN, "%s/trash.out",tmp_dir);
/* args */ /* args */
init_args(&al); init_args(&al);
@ -548,7 +549,7 @@ int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file,
#ifndef __WIN__ #ifndef __WIN__
pid_t get_server_pid(char *pid_file) pid_t get_server_pid(char *pid_file)
{ {
char buf[PATH_MAX]; char buf[FN_REFLEN];
int fd, err; int fd, err;
char *p; char *p;
pid_t id= 0; pid_t id= 0;
@ -556,7 +557,7 @@ pid_t get_server_pid(char *pid_file)
/* discover id */ /* discover id */
fd= open(pid_file, O_RDONLY); fd= open(pid_file, O_RDONLY);
err= read(fd, buf, PATH_MAX); err= read(fd, buf, FN_REFLEN);
close(fd); close(fd);
@ -619,7 +620,7 @@ void del_tree(char *dir)
#ifndef __WIN__ #ifndef __WIN__
DIR *parent= opendir(dir); DIR *parent= opendir(dir);
struct dirent *entry; struct dirent *entry;
char temp[PATH_MAX]; char temp[FN_REFLEN];
if (parent == NULL) if (parent == NULL)
{ {
@ -629,22 +630,36 @@ void del_tree(char *dir)
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); snprintf(temp, FN_REFLEN, "%s/%s", dir, entry->d_name);
if (entry->d_name[0] == '.') if (entry->d_name[0] == '.')
{ {
/* Skip */ /* Skip */
} }
else else
if (S_ISDIR(entry->d_type))
{ {
/* delete subdirectory */ /* FIXME missing test in acinclude.m4 */
del_tree(temp); #ifndef STRUCT_DIRENT_HAS_D_TYPE
} struct stat st;
else
{ if (lstat(entry->d_name, &st) == -1)
/* remove file */ {
remove(temp); /* FIXME error */
return;
}
if (S_ISDIR(st.st_mode))
#else
if (S_ISDIR(entry->d_type))
#endif
{
/* delete subdirectory */
del_tree(temp);
}
else
{
/* remove file */
remove(temp);
}
} }
} }
/* remove directory */ /* remove directory */
@ -652,10 +667,10 @@ void del_tree(char *dir)
#else #else
struct _finddata_t parent; struct _finddata_t parent;
intptr_t handle; intptr_t handle;
char temp[PATH_MAX]; char temp[FN_REFLEN];
char mask[PATH_MAX]; char mask[FN_REFLEN];
snprintf(mask,MAX_PATH,"%s/*.*",dir); snprintf(mask,FN_REFLEN,"%s/*.*",dir);
if ((handle=_findfirst(mask,&parent)) == -1L) if ((handle=_findfirst(mask,&parent)) == -1L)
{ {
@ -665,7 +680,7 @@ void del_tree(char *dir)
do do
{ {
/* create long name */ /* create long name */
snprintf(temp, PATH_MAX, "%s/%s", dir, parent.name); snprintf(temp, FN_REFLEN, "%s/%s", dir, parent.name);
if (parent.name[0] == '.') if (parent.name[0] == '.')
{ {
/* Skip */ /* Skip */
@ -700,11 +715,11 @@ int removef(const char *format, ...)
{ {
#ifdef __NETWARE__ #ifdef __NETWARE__
va_list ap; va_list ap;
char path[PATH_MAX]; char path[FN_REFLEN];
va_start(ap, format); va_start(ap, format);
vsnprintf(path, PATH_MAX, format, ap); vsnprintf(path, FN_REFLEN, format, ap);
va_end(ap); va_end(ap);
return remove(path); return remove(path);
@ -712,15 +727,15 @@ int removef(const char *format, ...)
#eldef __WIN__ #eldef __WIN__
{ {
va_list ap; va_list ap;
char path[PATH_MAX]; char path[FN_REFLEN];
struct _finddata_t parent; struct _finddata_t parent;
intptr_t handle; intptr_t handle;
char temp[PATH_MAX]; char temp[FN_REFLEN];
char *p; char *p;
va_start(ap, format); va_start(ap, format);
vsnprintf(path, PATH_MAX, format, ap); vsnprintf(path, FN_REFLEN, format, ap);
va_end(ap); va_end(ap);
@ -739,7 +754,7 @@ int removef(const char *format, ...)
{ {
if (! (parent.attrib & _A_SUBDIR)) if (! (parent.attrib & _A_SUBDIR))
{ {
snprintf(temp, PATH_MAX, "%s/%s", path, parent.name); snprintf(temp, FN_REFLEN, "%s/%s", path, parent.name);
remove(temp); remove(temp);
} }
}while (_findnext(handle,&parent) == 0); }while (_findnext(handle,&parent) == 0);
@ -749,14 +764,14 @@ int removef(const char *format, ...)
#else #else
DIR *parent; DIR *parent;
struct dirent *entry; struct dirent *entry;
char temp[PATH_MAX]; char temp[FN_REFLEN];
va_list ap; va_list ap;
char path[PATH_MAX]; char path[FN_REFLEN];
char *p; char *p;
/* Get path with mask */ /* Get path with mask */
va_start(ap, format); va_start(ap, format);
vsnprintf(path, PATH_MAX, format, ap); vsnprintf(path, FN_REFLEN, format, ap);
va_end(ap); va_end(ap);
@ -775,10 +790,21 @@ int removef(const char *format, ...)
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 */
#ifndef STRUCT_DIRENT_HAS_D_TYPE
struct stat st;
if (lstat(entry->d_name, &st) == -1)
{
return 1;
}
if (!S_ISDIR(st.st_mode) && !fnmatch(p, entry->d_name,0))
#else
if (!S_ISDIR(entry->d_type) && !fnmatch(p, entry->d_name,0)) if (!S_ISDIR(entry->d_type) && !fnmatch(p, entry->d_name,0))
#endif
{ {
/* create long name */ /* create long name */
snprintf(temp, PATH_MAX, "%s/%s", path, entry->d_name); snprintf(temp, FN_REFLEN, "%s/%s", path, entry->d_name);
/* Delete only files */ /* Delete only files */
remove(temp); remove(temp);
} }
@ -795,7 +821,7 @@ int removef(const char *format, ...)
void get_basedir(char *argv0, char *basedir) void get_basedir(char *argv0, char *basedir)
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
char *p; char *p;
int position; int position;

View File

@ -52,8 +52,6 @@ int my_vsnprintf_(char *to, size_t n, const char* value, ...);
#define TRY_MAX 5 #define TRY_MAX 5
#ifdef __WIN__ #ifdef __WIN__
#define PATH_MAX _MAX_PATH
#define NAME_MAX _MAX_FNAME
#define kill(A,B) TerminateProcess((HANDLE)A,0) #define kill(A,B) TerminateProcess((HANDLE)A,0)
#define NOT_NEED_PID 0 #define NOT_NEED_PID 0
#define MASTER_PID 1 #define MASTER_PID 1

View File

@ -227,7 +227,7 @@ DO_CLIENT_GDB=""
SLEEP_TIME_AFTER_RESTART=1 SLEEP_TIME_AFTER_RESTART=1
SLEEP_TIME_FOR_DELETE=10 SLEEP_TIME_FOR_DELETE=10
SLEEP_TIME_FOR_FIRST_MASTER=400 # Enough time to create innodb tables SLEEP_TIME_FOR_FIRST_MASTER=400 # Enough time to create innodb tables
SLEEP_TIME_FOR_SECOND_MASTER=30 SLEEP_TIME_FOR_SECOND_MASTER=400
SLEEP_TIME_FOR_FIRST_SLAVE=400 SLEEP_TIME_FOR_FIRST_SLAVE=400
SLEEP_TIME_FOR_SECOND_SLAVE=30 SLEEP_TIME_FOR_SECOND_SLAVE=30
CHARACTER_SET=latin1 CHARACTER_SET=latin1
@ -457,6 +457,9 @@ SMALL_SERVER="--key_buffer_size=1M --sort_buffer=256K --max_heap_table_size=1M"
export MASTER_MYPORT MASTER_MYPORT1 SLAVE_MYPORT MYSQL_TCP_PORT MASTER_MYSOCK MASTER_MYSOCK1 export MASTER_MYPORT MASTER_MYPORT1 SLAVE_MYPORT MYSQL_TCP_PORT MASTER_MYSOCK MASTER_MYSOCK1
NDBCLUSTER_BASE_PORT=`expr $NDBCLUSTER_PORT + 2`
NDBCLUSTER_OPTS="--port=$NDBCLUSTER_PORT --port-base=$NDBCLUSTER_BASE_PORT --data-dir=$MYSQL_TEST_DIR/var"
if [ x$SOURCE_DIST = x1 ] ; then if [ x$SOURCE_DIST = x1 ] ; then
MY_BASEDIR=$MYSQL_TEST_DIR MY_BASEDIR=$MYSQL_TEST_DIR
else else
@ -941,11 +944,11 @@ start_ndbcluster()
echo "Starting ndbcluster" echo "Starting ndbcluster"
if [ "$DO_BENCH" = 1 ] if [ "$DO_BENCH" = 1 ]
then then
NDBCLUSTER_OPTS="" NDBCLUSTER_EXTRA_OPTS=""
else else
NDBCLUSTER_OPTS="--small" NDBCLUSTER_EXTRA_OPTS="--small"
fi fi
./ndb/ndbcluster --port-base=$NDBCLUSTER_PORT $NDBCLUSTER_OPTS --diskless --initial --data-dir=$MYSQL_TEST_DIR/var || exit 1 ./ndb/ndbcluster $NDBCLUSTER_OPTS $NDBCLUSTER_EXTRA_OPTS --diskless --initial || exit 1
NDB_CONNECTSTRING="host=localhost:$NDBCLUSTER_PORT" NDB_CONNECTSTRING="host=localhost:$NDBCLUSTER_PORT"
else else
NDB_CONNECTSTRING="$USE_RUNNING_NDBCLUSTER" NDB_CONNECTSTRING="$USE_RUNNING_NDBCLUSTER"
@ -963,7 +966,7 @@ stop_ndbcluster()
if [ -z "$USE_RUNNING_NDBCLUSTER" ] if [ -z "$USE_RUNNING_NDBCLUSTER" ]
then then
# Kill any running ndbcluster stuff # Kill any running ndbcluster stuff
./ndb/ndbcluster --data-dir=$MYSQL_TEST_DIR/var --port-base=$NDBCLUSTER_PORT --stop ./ndb/ndbcluster $NDBCLUSTER_OPTS --stop
fi fi
fi fi
} }

View File

@ -73,25 +73,25 @@ const char *TEST_IGNORE= "[ignore]";
******************************************************************************/ ******************************************************************************/
#ifdef __NETWARE__ #ifdef __NETWARE__
static char base_dir[PATH_MAX]= "sys:/mysql"; static char base_dir[FN_REFLEN]= "sys:/mysql";
#else #else
static char base_dir[PATH_MAX]= ".."; static char base_dir[FN_REFLEN]= "..";
#endif #endif
static char db[PATH_MAX]= "test"; static char db[FN_LEN]= "test";
static char user[PATH_MAX]= "root"; static char user[FN_LEN]= "root";
static char password[PATH_MAX]= ""; static char password[FN_LEN]= "";
int master_port= 9306; int master_port= 9306;
int slave_port= 9307; int slave_port= 9307;
#if !defined(__NETWARE__) && !defined(__WIN__) #if !defined(__NETWARE__) && !defined(__WIN__)
static char master_socket[PATH_MAX]= "./var/tmp/master.sock"; static char master_socket[FN_REFLEN]= "./var/tmp/master.sock";
static char slave_socket[PATH_MAX]= "./var/tmp/slave.sock"; static char slave_socket[FN_REFLEN]= "./var/tmp/slave.sock";
#endif #endif
/* comma delimited list of tests to skip or empty string */ /* comma delimited list of tests to skip or empty string */
#ifndef __WIN__ #ifndef __WIN__
static char skip_test[PATH_MAX]= " lowercase_table3 , system_mysql_db_fix "; static char skip_test[FN_REFLEN]= " lowercase_table3 , system_mysql_db_fix ";
#else #else
/* /*
The most ignore testes contain the calls of system command The most ignore testes contain the calls of system command
@ -110,7 +110,7 @@ static char skip_test[PATH_MAX]= " lowercase_table3 , system_mysql_db_fix ";
mysqldump contains a command system mysqldump contains a command system
rpl000001 makes non-exit loop...temporary skiped rpl000001 makes non-exit loop...temporary skiped
*/ */
static char skip_test[PATH_MAX]= static char skip_test[FN_REFLEN]=
" lowercase_table3 ," " lowercase_table3 ,"
" system_mysql_db_fix ," " system_mysql_db_fix ,"
" sp ," " sp ,"
@ -123,44 +123,44 @@ static char skip_test[PATH_MAX]=
" mysqldump ," " mysqldump ,"
" rpl000001 "; " rpl000001 ";
#endif #endif
static char ignore_test[PATH_MAX]= ""; static char ignore_test[FN_REFLEN]= "";
static char bin_dir[PATH_MAX]; static char bin_dir[FN_REFLEN];
static char mysql_test_dir[PATH_MAX]; static char mysql_test_dir[FN_REFLEN];
static char test_dir[PATH_MAX]; static char test_dir[FN_REFLEN];
static char mysql_tmp_dir[PATH_MAX]; static char mysql_tmp_dir[FN_REFLEN];
static char result_dir[PATH_MAX]; static char result_dir[FN_REFLEN];
static char master_dir[PATH_MAX]; static char master_dir[FN_REFLEN];
static char slave_dir[PATH_MAX]; static char slave_dir[FN_REFLEN];
static char lang_dir[PATH_MAX]; static char lang_dir[FN_REFLEN];
static char char_dir[PATH_MAX]; static char char_dir[FN_REFLEN];
static char mysqladmin_file[PATH_MAX]; static char mysqladmin_file[FN_REFLEN];
static char mysqld_file[PATH_MAX]; static char mysqld_file[FN_REFLEN];
static char mysqltest_file[PATH_MAX]; static char mysqltest_file[FN_REFLEN];
#ifndef __WIN__ #ifndef __WIN__
static char master_pid[PATH_MAX]; static char master_pid[FN_REFLEN];
static char slave_pid[PATH_MAX]; static char slave_pid[FN_REFLEN];
static char sh_file[PATH_MAX]= "/bin/sh"; static char sh_file[FN_REFLEN]= "/bin/sh";
#else #else
static HANDLE master_pid; static HANDLE master_pid;
static HANDLE slave_pid; static HANDLE slave_pid;
#endif #endif
static char master_opt[PATH_MAX]= ""; static char master_opt[FN_REFLEN]= "";
static char slave_opt[PATH_MAX]= ""; static char slave_opt[FN_REFLEN]= "";
static char slave_master_info[PATH_MAX]= ""; static char slave_master_info[FN_REFLEN]= "";
static char master_init_script[PATH_MAX]= ""; static char master_init_script[FN_REFLEN]= "";
static char slave_init_script[PATH_MAX]= ""; static char slave_init_script[FN_REFLEN]= "";
/* OpenSSL */ /* OpenSSL */
static char ca_cert[PATH_MAX]; static char ca_cert[FN_REFLEN];
static char server_cert[PATH_MAX]; static char server_cert[FN_REFLEN];
static char server_key[PATH_MAX]; static char server_key[FN_REFLEN];
static char client_cert[PATH_MAX]; static char client_cert[FN_REFLEN];
static char client_key[PATH_MAX]; static char client_key[FN_REFLEN];
int total_skip= 0; int total_skip= 0;
int total_pass= 0; int total_pass= 0;
@ -254,18 +254,18 @@ void install_db(char *datadir)
{ {
arg_list_t al; arg_list_t al;
int err; int err;
char input[PATH_MAX]; char input[FN_REFLEN];
char output[PATH_MAX]; char output[FN_REFLEN];
char error[PATH_MAX]; char error[FN_REFLEN];
/* input file */ /* input file */
#ifdef __NETWARE__ #ifdef __NETWARE__
snprintf(input, PATH_MAX, "%s/bin/init_db.sql", base_dir); snprintf(input, FN_REFLEN, "%s/bin/init_db.sql", base_dir);
#else #else
snprintf(input, PATH_MAX, "%s/mysql-test/init_db.sql", base_dir); snprintf(input, FN_REFLEN, "%s/mysql-test/init_db.sql", base_dir);
#endif #endif
snprintf(output, PATH_MAX, "%s/install.out", datadir); snprintf(output, FN_REFLEN, "%s/install.out", datadir);
snprintf(error, PATH_MAX, "%s/install.err", datadir); snprintf(error, FN_REFLEN, "%s/install.err", datadir);
/* args */ /* args */
init_args(&al); init_args(&al);
@ -302,10 +302,10 @@ void install_db(char *datadir)
void mysql_install_db() void mysql_install_db()
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
/* var directory */ /* var directory */
snprintf(temp, PATH_MAX, "%s/var", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var", mysql_test_dir);
/* clean up old direcotry */ /* clean up old direcotry */
del_tree(temp); del_tree(temp);
@ -315,41 +315,41 @@ void mysql_install_db()
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
/* create subdirectories */ /* create subdirectories */
mlog("Creating test-suite folders...\n"); mlog("Creating test-suite folders...\n");
snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/run", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/mysql", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/test", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/mysql", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/test", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
#else #else
mkdir(temp); mkdir(temp);
/* create subdirectories */ /* create subdirectories */
mlog("Creating test-suite folders...\n"); mlog("Creating test-suite folders...\n");
snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/run", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/mysql", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/test", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/mysql", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/test", mysql_test_dir);
mkdir(temp); mkdir(temp);
#endif #endif
@ -372,10 +372,10 @@ void start_master()
{ {
arg_list_t al; arg_list_t al;
int err; int err;
char master_out[PATH_MAX]; char master_out[FN_REFLEN];
char master_err[PATH_MAX]; char master_err[FN_REFLEN];
/* char temp[PATH_MAX]; */ /* char temp[FN_REFLEN]; */
char temp2[PATH_MAX]; char temp2[FN_REFLEN];
/* 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); removef("%s/log.*", master_dir);
@ -405,7 +405,7 @@ void start_master()
FILE *fp; FILE *fp;
/* create an empty index file */ /* create an empty index file */
snprintf(temp, PATH_MAX, "%s/test/t1.MYI", master_dir); snprintf(temp, FN_REFLEN, "%s/test/t1.MYI", master_dir);
fp= fopen(temp, "wb+"); fp= fopen(temp, "wb+");
fputs("1", fp); fputs("1", fp);
@ -418,19 +418,19 @@ void start_master()
} }
/* redirection files */ /* redirection files */
snprintf(master_out, PATH_MAX, "%s/var/run/master%u.out", snprintf(master_out, FN_REFLEN, "%s/var/run/master%u.out",
mysql_test_dir, restarts); mysql_test_dir, restarts);
snprintf(master_err, PATH_MAX, "%s/var/run/master%u.err", snprintf(master_err, FN_REFLEN, "%s/var/run/master%u.err",
mysql_test_dir, restarts); mysql_test_dir, restarts);
#ifndef __WIN__ #ifndef __WIN__
snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var",mysql_test_dir);
mkdir(temp2,S_IRWXU); mkdir(temp2,S_IRWXU);
snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var/log",mysql_test_dir);
mkdir(temp2,S_IRWXU); mkdir(temp2,S_IRWXU);
#else #else
snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var",mysql_test_dir);
mkdir(temp2); mkdir(temp2);
snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var/log",mysql_test_dir);
mkdir(temp2); mkdir(temp2);
#endif #endif
/* args */ /* args */
@ -539,8 +539,8 @@ void start_slave()
{ {
arg_list_t al; arg_list_t al;
int err; int err;
char slave_out[PATH_MAX]; char slave_out[FN_REFLEN];
char slave_err[PATH_MAX]; char slave_err[FN_REFLEN];
/* skip? */ /* skip? */
if (skip_slave) return; if (skip_slave) return;
@ -568,7 +568,7 @@ void start_slave()
if (strinstr(slave_init_script, "rpl000016-slave.sh") != 0) 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); snprintf(temp, FN_REFLEN, "%s/master.info", slave_dir);
close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO));
} }
else if (strinstr(slave_init_script, "rpl000017-slave.sh") != 0) else if (strinstr(slave_init_script, "rpl000017-slave.sh") != 0)
@ -576,7 +576,7 @@ void start_slave()
FILE *fp; FILE *fp;
/* create a master.info file */ /* create a master.info file */
snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); snprintf(temp, FN_REFLEN, "%s/master.info", slave_dir);
fp= fopen(temp, "wb+"); fp= fopen(temp, "wb+");
fputs("master-bin.000001\n", fp); fputs("master-bin.000001\n", fp);
@ -593,7 +593,7 @@ void start_slave()
else if (strinstr(slave_init_script, "rpl_rotate_logs-slave.sh") != 0) 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); snprintf(temp, FN_REFLEN, "%s/master.info", slave_dir);
close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO));
} }
#elif !defined(__WIN__) #elif !defined(__WIN__)
@ -602,9 +602,9 @@ void start_slave()
} }
/* redirection files */ /* redirection files */
snprintf(slave_out, PATH_MAX, "%s/var/run/slave%u.out", snprintf(slave_out, FN_REFLEN, "%s/var/run/slave%u.out",
mysql_test_dir, restarts); mysql_test_dir, restarts);
snprintf(slave_err, PATH_MAX, "%s/var/run/slave%u.err", snprintf(slave_err, FN_REFLEN, "%s/var/run/slave%u.err",
mysql_test_dir, restarts); mysql_test_dir, restarts);
/* args */ /* args */
@ -859,14 +859,14 @@ int read_option(char *opt_file, char *opt)
{ {
int fd, err; int fd, err;
char *p; char *p;
char buf[PATH_MAX]; char buf[FN_REFLEN];
/* copy current option */ /* copy current option */
strncpy(buf, opt, PATH_MAX); strncpy(buf, opt, FN_REFLEN);
/* open options file */ /* open options file */
fd= open(opt_file, O_RDONLY); fd= open(opt_file, O_RDONLY);
err= read(fd, opt, PATH_MAX); err= read(fd, opt, FN_REFLEN);
close(fd); close(fd);
if (err > 0) if (err > 0)
@ -890,7 +890,7 @@ int read_option(char *opt_file, char *opt)
/* check for $MYSQL_TEST_DIR */ /* check for $MYSQL_TEST_DIR */
if ((p= strstr(opt, "$MYSQL_TEST_DIR")) != NULL) if ((p= strstr(opt, "$MYSQL_TEST_DIR")) != NULL)
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
*p= 0; *p= 0;
@ -925,7 +925,7 @@ int read_option(char *opt_file, char *opt)
void run_test(char *test) void run_test(char *test)
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
const char *rstr; const char *rstr;
int skip= FALSE, ignore=FALSE; int skip= FALSE, ignore=FALSE;
int restart= FALSE; int restart= FALSE;
@ -933,13 +933,13 @@ void run_test(char *test)
struct stat info; struct stat info;
/* skip tests in the skip list */ /* skip tests in the skip list */
snprintf(temp, PATH_MAX, " %s ", test); snprintf(temp, FN_REFLEN, " %s ", test);
skip= (strinstr(skip_test, temp) != 0); skip= (strinstr(skip_test, temp) != 0);
if (skip == FALSE) 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(master_init_script, FN_REFLEN, "%s/%s-master.sh", test_dir, test);
snprintf(slave_init_script, PATH_MAX, "%s/%s-slave.sh", test_dir, test); snprintf(slave_init_script, FN_REFLEN, "%s/%s-slave.sh", test_dir, test);
#ifdef __WIN__ #ifdef __WIN__
if (! stat(master_init_script, &info)) if (! stat(master_init_script, &info))
skip= TRUE; skip= TRUE;
@ -957,14 +957,14 @@ void run_test(char *test)
} }
else if (!skip) /* skip test? */ else if (!skip) /* skip test? */
{ {
char test_file[PATH_MAX]; char test_file[FN_REFLEN];
char master_opt_file[PATH_MAX]; char master_opt_file[FN_REFLEN];
char slave_opt_file[PATH_MAX]; char slave_opt_file[FN_REFLEN];
char slave_master_info_file[PATH_MAX]; char slave_master_info_file[FN_REFLEN];
char result_file[PATH_MAX]; char result_file[FN_REFLEN];
char reject_file[PATH_MAX]; char reject_file[FN_REFLEN];
char out_file[PATH_MAX]; char out_file[FN_REFLEN];
char err_file[PATH_MAX]; char err_file[FN_REFLEN];
int err; int err;
arg_list_t al; arg_list_t al;
#ifdef __WIN__ #ifdef __WIN__
@ -981,20 +981,20 @@ void run_test(char *test)
if (flag != skip_slave) restart= TRUE; if (flag != skip_slave) restart= TRUE;
/* create files */ /* create files */
snprintf(master_opt_file, PATH_MAX, "%s/%s-master.opt", test_dir, test); snprintf(master_opt_file, FN_REFLEN, "%s/%s-master.opt", test_dir, test);
snprintf(slave_opt_file, PATH_MAX, "%s/%s-slave.opt", test_dir, test); snprintf(slave_opt_file, FN_REFLEN, "%s/%s-slave.opt", test_dir, test);
snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", snprintf(slave_master_info_file, FN_REFLEN, "%s/%s.slave-mi",
test_dir, test); test_dir, test);
snprintf(reject_file, PATH_MAX, "%s/%s%s", snprintf(reject_file, FN_REFLEN, "%s/%s%s",
result_dir, test, REJECT_SUFFIX); result_dir, test, REJECT_SUFFIX);
snprintf(out_file, PATH_MAX, "%s/%s%s", result_dir, test, OUT_SUFFIX); snprintf(out_file, FN_REFLEN, "%s/%s%s", result_dir, test, OUT_SUFFIX);
snprintf(err_file, PATH_MAX, "%s/%s%s", result_dir, test, ERR_SUFFIX); snprintf(err_file, FN_REFLEN, "%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); snprintf(test_file, FN_REFLEN, "%s/%s%s", test_dir, test, NW_TEST_SUFFIX);
if (stat(test_file, &info)) if (stat(test_file, &info))
{ {
snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, TEST_SUFFIX); snprintf(test_file, FN_REFLEN, "%s/%s%s", test_dir, test, TEST_SUFFIX);
if (access(test_file,0)) if (access(test_file,0))
{ {
printf("Invalid test name %s, %s file not found\n",test,test_file); printf("Invalid test name %s, %s file not found\n",test,test_file);
@ -1002,11 +1002,11 @@ void run_test(char *test)
} }
} }
snprintf(result_file, PATH_MAX, "%s/%s%s", snprintf(result_file, FN_REFLEN, "%s/%s%s",
result_dir, test, NW_RESULT_SUFFIX); result_dir, test, NW_RESULT_SUFFIX);
if (stat(result_file, &info)) if (stat(result_file, &info))
{ {
snprintf(result_file, PATH_MAX, "%s/%s%s", snprintf(result_file, FN_REFLEN, "%s/%s%s",
result_dir, test, RESULT_SUFFIX); result_dir, test, RESULT_SUFFIX);
} }
@ -1248,8 +1248,8 @@ void die(const char *msg)
void setup(char *file __attribute__((unused))) void setup(char *file __attribute__((unused)))
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
char file_path[PATH_MAX*2]; char file_path[FN_REFLEN*2];
char *p; char *p;
int position; int position;
@ -1257,14 +1257,14 @@ void setup(char *file __attribute__((unused)))
#ifdef __WIN__ #ifdef __WIN__
_putenv( "TZ=GMT-3" ); _putenv( "TZ=GMT-3" );
#else #else
setenv("TZ", "GMT-3", TRUE); putenv((char *)"TZ=GMT-3");
#endif #endif
/* find base dir */ /* find base dir */
#ifdef __NETWARE__ #ifdef __NETWARE__
strcpy(temp, strlwr(file)); strcpy(temp, strlwr(file));
while ((p= strchr(temp, '\\')) != NULL) *p= '/'; while ((p= strchr(temp, '\\')) != NULL) *p= '/';
#else #else
getcwd(temp, PATH_MAX); getcwd(temp, FN_REFLEN);
position= strlen(temp); position= strlen(temp);
temp[position]= '/'; temp[position]= '/';
temp[position+1]= 0; temp[position+1]= 0;
@ -1284,100 +1284,100 @@ void setup(char *file __attribute__((unused)))
#ifdef __NETWARE__ #ifdef __NETWARE__
/* setup paths */ /* setup paths */
snprintf(bin_dir, PATH_MAX, "%s/bin", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/bin", base_dir);
snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(mysql_test_dir, FN_REFLEN, "%s/mysql-test", base_dir);
snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); snprintf(test_dir, FN_REFLEN, "%s/t", mysql_test_dir);
snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(mysql_tmp_dir, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); snprintf(result_dir, FN_REFLEN, "%s/r", mysql_test_dir);
snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(master_dir, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(slave_dir, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); snprintf(lang_dir, FN_REFLEN, "%s/share/english", base_dir);
snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); snprintf(char_dir, FN_REFLEN, "%s/share/charsets", base_dir);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
use_openssl= TRUE; use_openssl= TRUE;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* OpenSSL paths */ /* OpenSSL paths */
snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(ca_cert, FN_REFLEN, "%s/SSL/cacert.pem", base_dir);
snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_cert, FN_REFLEN, "%s/SSL/server-cert.pem", base_dir);
snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(server_key, FN_REFLEN, "%s/SSL/server-key.pem", base_dir);
snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_cert, FN_REFLEN, "%s/SSL/client-cert.pem", base_dir);
snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); snprintf(client_key, FN_REFLEN, "%s/SSL/client-key.pem", base_dir);
/* setup files */ /* setup files */
snprintf(mysqld_file, PATH_MAX, "%s/mysqld", bin_dir); snprintf(mysqld_file, FN_REFLEN, "%s/mysqld", bin_dir);
snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); snprintf(mysqltest_file, FN_REFLEN, "%s/mysqltest", bin_dir);
snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); snprintf(mysqladmin_file, FN_REFLEN, "%s/mysqladmin", bin_dir);
snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); snprintf(master_pid, FN_REFLEN, "%s/var/run/master.pid", mysql_test_dir);
snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); snprintf(slave_pid, FN_REFLEN, "%s/var/run/slave.pid", mysql_test_dir);
#elif __WIN__ #elif __WIN__
/* setup paths */ /* setup paths */
#ifdef _DEBUG #ifdef _DEBUG
snprintf(bin_dir, PATH_MAX, "%s/client_debug", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/client_debug", base_dir);
#else #else
snprintf(bin_dir, PATH_MAX, "%s/client_release", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/client_release", base_dir);
#endif #endif
snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(mysql_test_dir, FN_REFLEN, "%s/mysql-test", base_dir);
snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); snprintf(test_dir, FN_REFLEN, "%s/t", mysql_test_dir);
snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(mysql_tmp_dir, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); snprintf(result_dir, FN_REFLEN, "%s/r", mysql_test_dir);
snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(master_dir, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(slave_dir, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); snprintf(lang_dir, FN_REFLEN, "%s/share/english", base_dir);
snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); snprintf(char_dir, FN_REFLEN, "%s/share/charsets", base_dir);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
use_openssl= TRUE; use_openssl= TRUE;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* OpenSSL paths */ /* OpenSSL paths */
snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(ca_cert, FN_REFLEN, "%s/SSL/cacert.pem", base_dir);
snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_cert, FN_REFLEN, "%s/SSL/server-cert.pem", base_dir);
snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(server_key, FN_REFLEN, "%s/SSL/server-key.pem", base_dir);
snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_cert, FN_REFLEN, "%s/SSL/client-cert.pem", base_dir);
snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); snprintf(client_key, FN_REFLEN, "%s/SSL/client-key.pem", base_dir);
/* setup files */ /* setup files */
snprintf(mysqld_file, PATH_MAX, "%s/mysqld.exe", bin_dir); snprintf(mysqld_file, FN_REFLEN, "%s/mysqld.exe", bin_dir);
snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest.exe", bin_dir); snprintf(mysqltest_file, FN_REFLEN, "%s/mysqltest.exe", bin_dir);
snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin.exe", bin_dir); snprintf(mysqladmin_file, FN_REFLEN, "%s/mysqladmin.exe", bin_dir);
#else #else
/* setup paths */ /* setup paths */
snprintf(bin_dir, PATH_MAX, "%s/client", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/client", base_dir);
snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(mysql_test_dir, FN_REFLEN, "%s/mysql-test", base_dir);
snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); snprintf(test_dir, FN_REFLEN, "%s/t", mysql_test_dir);
snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(mysql_tmp_dir, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); snprintf(result_dir, FN_REFLEN, "%s/r", mysql_test_dir);
snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(master_dir, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(slave_dir, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
snprintf(lang_dir, PATH_MAX, "%s/sql/share/english", base_dir); snprintf(lang_dir, FN_REFLEN, "%s/sql/share/english", base_dir);
snprintf(char_dir, PATH_MAX, "%s/sql/share/charsets", base_dir); snprintf(char_dir, FN_REFLEN, "%s/sql/share/charsets", base_dir);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
use_openssl= TRUE; use_openssl= TRUE;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* OpenSSL paths */ /* OpenSSL paths */
snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(ca_cert, FN_REFLEN, "%s/SSL/cacert.pem", base_dir);
snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_cert, FN_REFLEN, "%s/SSL/server-cert.pem", base_dir);
snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(server_key, FN_REFLEN, "%s/SSL/server-key.pem", base_dir);
snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_cert, FN_REFLEN, "%s/SSL/client-cert.pem", base_dir);
snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); snprintf(client_key, FN_REFLEN, "%s/SSL/client-key.pem", base_dir);
/* setup files */ /* setup files */
snprintf(mysqld_file, PATH_MAX, "%s/sql/mysqld", base_dir); snprintf(mysqld_file, FN_REFLEN, "%s/sql/mysqld", base_dir);
snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); snprintf(mysqltest_file, FN_REFLEN, "%s/mysqltest", bin_dir);
snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); snprintf(mysqladmin_file, FN_REFLEN, "%s/mysqladmin", bin_dir);
snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); snprintf(master_pid, FN_REFLEN, "%s/var/run/master.pid", mysql_test_dir);
snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); snprintf(slave_pid, FN_REFLEN, "%s/var/run/slave.pid", mysql_test_dir);
snprintf(master_socket,PATH_MAX, "%s/var/tmp/master.sock", mysql_test_dir); snprintf(master_socket,FN_REFLEN, "%s/var/tmp/master.sock", mysql_test_dir);
snprintf(slave_socket,PATH_MAX, "%s/var/tmp/slave.sock", mysql_test_dir); snprintf(slave_socket,FN_REFLEN, "%s/var/tmp/slave.sock", mysql_test_dir);
#endif #endif
/* create log file */ /* create log file */
snprintf(temp, PATH_MAX, "%s/mysql-test-run.log", mysql_test_dir); snprintf(temp, FN_REFLEN, "%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."); log_errno("Unable to create log file.");
@ -1386,46 +1386,47 @@ void setup(char *file __attribute__((unused)))
/* prepare skip test list */ /* prepare skip test list */
while ((p= strchr(skip_test, ',')) != NULL) *p= ' '; while ((p= strchr(skip_test, ',')) != NULL) *p= ' ';
strcpy(temp, strlwr(skip_test)); strcpy(temp, strlwr(skip_test));
snprintf(skip_test, PATH_MAX, " %s ", temp); snprintf(skip_test, FN_REFLEN, " %s ", temp);
/* environment */ /* environment */
#ifdef __NETWARE__ #ifdef __NETWARE__
setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); setenv("MYSQL_TEST_DIR", mysql_test_dir, 1);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"%s/client/mysqldump --no-defaults -u root --port=%u", "%s/client/mysqldump --no-defaults -u root --port=%u",
bin_dir, master_port); bin_dir, master_port);
setenv("MYSQL_DUMP", file_path, 1); setenv("MYSQL_DUMP", file_path, 1);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"%s/client/mysqlbinlog --no-defaults --local-load=%s", "%s/client/mysqlbinlog --no-defaults --local-load=%s",
bin_dir, mysql_tmp_dir); bin_dir, mysql_tmp_dir);
setenv("MYSQL_BINLOG", file_path, 1); setenv("MYSQL_BINLOG", file_path, 1);
#elif __WIN__ #elif __WIN__
snprintf(file_path,MAX_PATH,"MYSQL_TEST_DIR=%s",mysql_test_dir); snprintf(file_path,FN_REFLEN,"MYSQL_TEST_DIR=%s",mysql_test_dir);
_putenv(file_path); _putenv(file_path);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u", "MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u",
bin_dir, master_port); bin_dir, master_port);
_putenv(file_path); _putenv(file_path);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s", "MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s",
bin_dir, mysql_tmp_dir); bin_dir, mysql_tmp_dir);
_putenv(file_path); _putenv(file_path);
#else #else
setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); snprintf(file_path,FN_REFLEN,"MYSQL_TEST_DIR=%s",mysql_test_dir);
snprintf(file_path, PATH_MAX*2, putenv(file_path);
"%s/mysqldump --no-defaults -u root --port=%u --socket=%s", snprintf(file_path, FN_REFLEN*2,
"MYSQL_DUMP=%s/mysqldump --no-defaults -u root --port=%u --socket=%s",
bin_dir, master_port, master_socket); bin_dir, master_port, master_socket);
setenv("MYSQL_DUMP", file_path, 1); putenv(file_path);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"%s/mysqlbinlog --no-defaults --local-load=%s", "MYSQL_BINLOG=%s/mysqlbinlog --no-defaults --local-load=%s",
bin_dir, mysql_tmp_dir); bin_dir, mysql_tmp_dir);
setenv("MYSQL_BINLOG", file_path, 1); putenv(file_path);
#endif #endif
#ifndef __WIN__ #ifndef __WIN__
setenv("MASTER_MYPORT", "9306", 1); putenv((char *)"MASTER_MYPORT=9306");
setenv("SLAVE_MYPORT", "9307", 1); putenv((char *)"SLAVE_MYPORT=9307");
setenv("MYSQL_TCP_PORT", "3306", 1); putenv((char *)"MYSQL_TCP_PORT=3306");
#else #else
_putenv("MASTER_MYPORT=9306"); _putenv("MASTER_MYPORT=9306");
_putenv("SLAVE_MYPORT=9307"); _putenv("SLAVE_MYPORT=9307");
@ -1461,7 +1462,7 @@ int main(int argc, char **argv)
temp= strdup(strchr(argv[1],'=') + 1); temp= strdup(strchr(argv[1],'=') + 1);
for (token=str_tok(temp, ","); token != NULL; token=str_tok(NULL, ",")) for (token=str_tok(temp, ","); token != NULL; token=str_tok(NULL, ","))
{ {
if (strlen(ignore_test) + strlen(token) + 2 <= PATH_MAX-1) if (strlen(ignore_test) + strlen(token) + 2 <= FN_REFLEN-1)
sprintf(ignore_test+strlen(ignore_test), " %s ", token); sprintf(ignore_test+strlen(ignore_test), " %s ", token);
else else
{ {
@ -1507,38 +1508,35 @@ int main(int argc, char **argv)
{ {
/* run all tests */ /* run all tests */
#ifndef __WIN__ #ifndef __WIN__
struct dirent **namelist; struct dirent *entry;
int i,n; DIR *parent;
char test[NAME_MAX]; char test[FN_LEN];
char *p;
int position; int position;
n= scandir(test_dir, &namelist, 0, alphasort); /* FIXME are we sure the list is sorted if using readdir()? */
if (n < 0) if ((parent= opendir(test_dir)) == NULL) /* Not thread safe */
die("Unable to open tests directory."); die("Unable to open tests directory.");
else else
{ {
for (i= 0; i < n; i++) while ((entry= readdir(parent)) != NULL) /* Not thread safe */
{ {
strcpy(test, strlwr(namelist[i]->d_name)); strcpy(test, strlwr(entry->d_name));
/* find the test suffix */ /* find the test suffix */
if ((position= strinstr(test, TEST_SUFFIX)) != 0) if ((position= strinstr(test, TEST_SUFFIX)) != 0)
{ {
p= test + position - 1;
/* null terminate at the suffix */ /* null terminate at the suffix */
*p= 0; *(test + position - 1)= '\0';
/* run test */ /* run test */
run_test(test); run_test(test);
} }
free(namelist[n]);
} }
free(namelist); closedir(parent);
} }
#else #else
struct _finddata_t dir; struct _finddata_t dir;
intptr_t handle; intptr_t handle;
char test[NAME_MAX]; char test[FN_LEN];
char mask[PATH_MAX]; char mask[FN_REFLEN];
char *p; char *p;
int position; int position;
char **names= 0; char **names= 0;
@ -1549,7 +1547,7 @@ int main(int argc, char **argv)
/* single test */ /* single test */
single_test= FALSE; single_test= FALSE;
snprintf(mask,MAX_PATH,"%s/*.test",test_dir); snprintf(mask,FN_REFLEN,"%s/*.test",test_dir);
if ((handle=_findfirst(mask,&dir)) == -1L) if ((handle=_findfirst(mask,&dir)) == -1L)
{ {
@ -1574,7 +1572,7 @@ int main(int argc, char **argv)
*p= 0; *p= 0;
/* insert test */ /* insert test */
*names= malloc(PATH_MAX); *names= malloc(FN_REFLEN);
strcpy(*names,test); strcpy(*names,test);
names++; names++;
name_index++; name_index++;

View File

@ -13,6 +13,8 @@ SUFFIXES = .sh
.sh: .sh:
@RM@ -f $@ $@-t @RM@ -f $@ $@-t
@SED@ \ @SED@ \
-e 's!@''ndb_port''@!$(ndb_port)!g' \
-e 's!@''ndb_port_base''@!$(ndb_port_base)!g' \
-e 's!@''ndbbindir''@!$(ndbbindir)!g' \ -e 's!@''ndbbindir''@!$(ndbbindir)!g' \
-e 's!@''ndbtoolsdir''@!$(ndbtoolsdir)!g' \ -e 's!@''ndbtoolsdir''@!$(ndbtoolsdir)!g' \
$< > $@-t $< > $@-t

View File

@ -5,7 +5,8 @@
# This scripts starts the table handler ndbcluster # This scripts starts the table handler ndbcluster
# configurable parameters, make sure to change in mysqlcluterd as well # configurable parameters, make sure to change in mysqlcluterd as well
port_base="2200" port=@ndb_port@
port_base=@ndb_port_base@
fsdir=`pwd` fsdir=`pwd`
# end configurable parameters # end configurable parameters
@ -22,6 +23,7 @@ if [ -d ../sql ] ; then
exec_ndb=$ndbtop/src/kernel/ndbd exec_ndb=$ndbtop/src/kernel/ndbd
exec_mgmtsrvr=$ndbtop/src/mgmsrv/ndb_mgmd exec_mgmtsrvr=$ndbtop/src/mgmsrv/ndb_mgmd
exec_waiter=$ndbtop/tools/ndb_waiter exec_waiter=$ndbtop/tools/ndb_waiter
exec_test=$ndbtop/tools/ndb_test_platform
exec_mgmtclient=$ndbtop/src/mgmclient/ndb_mgm exec_mgmtclient=$ndbtop/src/mgmclient/ndb_mgm
else else
BINARY_DIST=1 BINARY_DIST=1
@ -34,9 +36,15 @@ else
exec_mgmtsrvr=$BASEDIR/bin/ndb_mgmd exec_mgmtsrvr=$BASEDIR/bin/ndb_mgmd
fi fi
exec_waiter=$BASEDIR/bin/ndb_waiter exec_waiter=$BASEDIR/bin/ndb_waiter
exec_test=$BASEDIR/bin/ndb_test_platform
exec_mgmtclient=$BASEDIR/bin/ndb_mgm exec_mgmtclient=$BASEDIR/bin/ndb_mgm
fi fi
if $exec_test ; then :; else
echo "ndb not correctly compiled to support this platform"
exit 1
fi
pidfile=ndbcluster.pid pidfile=ndbcluster.pid
cfgfile=Ndb.cfg cfgfile=Ndb.cfg
stop_ndb= stop_ndb=
@ -77,6 +85,9 @@ while test $# -gt 0; do
--data-dir=*) --data-dir=*)
fsdir=`echo "$1" | sed -e "s;--data-dir=;;"` fsdir=`echo "$1" | sed -e "s;--data-dir=;;"`
;; ;;
--port=*)
port=`echo "$1" | sed -e "s;--port=;;"`
;;
--port-base=*) --port-base=*)
port_base=`echo "$1" | sed -e "s;--port-base=;;"` port_base=`echo "$1" | sed -e "s;--port-base=;;"`
;; ;;
@ -87,7 +98,7 @@ while test $# -gt 0; do
shift shift
done done
fs_ndb="$fsdir/ndbcluster-$port_base" fs_ndb="$fsdir/ndbcluster-$port"
NDB_HOME= NDB_HOME=
if [ ! -x "$fsdir" ]; then if [ ! -x "$fsdir" ]; then
@ -113,7 +124,7 @@ exec_ndb="$exec_ndb --no-defaults"
exec_waiter="$exec_waiter --no-defaults" exec_waiter="$exec_waiter --no-defaults"
ndb_host="localhost" ndb_host="localhost"
ndb_mgmd_port=$port_base ndb_mgmd_port=$port
NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port" NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port"
export NDB_CONNECTSTRING export NDB_CONNECTSTRING
@ -151,10 +162,6 @@ if [ -d "$fs_ndb" ]; then :; else
exit 1 exit 1
fi fi
# set som help variables
port_transporter=`expr $ndb_mgmd_port + 2`
# Start management server as deamon # Start management server as deamon
# Edit file system path and ports in config file # Edit file system path and ports in config file
@ -169,7 +176,7 @@ sed \
-e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \ -e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \
-e s,"CHOOSE_FILESYSTEM","$fs_ndb",g \ -e s,"CHOOSE_FILESYSTEM","$fs_ndb",g \
-e s,"CHOOSE_PORT_MGM","$ndb_mgmd_port",g \ -e s,"CHOOSE_PORT_MGM","$ndb_mgmd_port",g \
-e s,"CHOOSE_PORT_TRANSPORTER","$port_transporter",g \ -e s,"CHOOSE_PORT_TRANSPORTER","$port_base",g \
< ndb/ndb_config_2_node.ini \ < ndb/ndb_config_2_node.ini \
> "$fs_ndb/config.ini" > "$fs_ndb/config.ini"
fi fi

View File

@ -483,3 +483,13 @@ ERROR 42000: Incorrect table name 't1\\'
rename table t1 to `t1\\`; rename table t1 to `t1\\`;
ERROR 42000: Incorrect table name 't1\\' ERROR 42000: Incorrect table name 't1\\'
drop table t1; drop table t1;
create table t1 (a text) character set koi8r;
insert into t1 values (_koi8r'<27><><EFBFBD><EFBFBD>');
select hex(a) from t1;
hex(a)
D4C5D3D4
alter table t1 convert to character set cp1251;
select hex(a) from t1;
hex(a)
F2E5F1F2
drop table t1;

View File

@ -0,0 +1,15 @@
drop table if exists t1;
create table t1 (a int) engine=innodb;
start transaction with consistent snapshot;
insert into t1 values(1);
select * from t1;
a
commit;
delete from t1;
start transaction;
insert into t1 values(1);
select * from t1;
a
1
commit;
drop table t1;

View File

@ -126,3 +126,43 @@ Field Type Null Key Default Extra
a char(1) a char(1)
b enum('<27><>','<27><>') YES NULL b enum('<27><>','<27><>') YES NULL
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
a b
0 aaabbbcccddd
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
a b
1 eeefffggghhh
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
a b
2 iiijjjkkkl
DROP TABLE t1;
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
a b
0 aaabbbcccddd
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
a b
1 eeefffggghhh
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
a b
2 iiijjjkkkl
DROP TABLE t1;

View File

@ -5,7 +5,7 @@ def 1 8 1 1 N 32769 0 8
def 1.0 5 3 3 N 32769 1 8 def 1.0 5 3 3 N 32769 1 8
def -1 8 1 2 N 32769 0 8 def -1 8 1 2 N 32769 0 8
def hello 254 5 5 N 1 31 8 def hello 254 5 5 N 1 31 8
def NULL 6 0 0 Y 32768 0 8 def NULL 6 0 0 Y 32896 0 63
1 1.0 -1 hello NULL 1 1.0 -1 hello NULL
1 1.0 -1 hello NULL 1 1.0 -1 hello NULL
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp, l datetime, m enum('a','b'), n set('a','b'), o char(10)); create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp, l datetime, m enum('a','b'), n set('a','b'), o char(10));

View File

@ -1,4 +1,4 @@
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
flush status; flush status;
create table t1( create table t1(
id int not null primary key, id int not null primary key,
@ -363,3 +363,8 @@ a int NOT NULL PRIMARY KEY,
b int b int
) engine=ndb; ) engine=ndb;
insert t9 values(1, 2), (2,3), (3, 4), (4, 5); insert t9 values(1, 2), (2,3), (3, 4), (4, 5);
create table t10 (
a int not null primary key,
b blob
) engine=ndb;
insert into t10 values (1, 'kalle');

View File

@ -8,3 +8,6 @@ show status like 'handler_discover%';
Variable_name Value Variable_name Value
Handler_discover 1 Handler_discover 1
drop table t9; drop table t9;
select * from t10;
ERROR HY000: Got error 4263 'Invalid blob attributes or invalid blob parts table' from ndbcluster
drop table t10;

View File

@ -400,6 +400,13 @@ b attr1
9413 9412 9413 9412
drop table test.t1, t2; drop table test.t1, t2;
drop database mysqltest; drop database mysqltest;
drop database if exists ndbtest1;
create database ndbtest1;
use ndbtest1;
create table t1(id int) engine=ndbcluster;
drop database ndbtest1;
drop database ndbtest1;
ERROR HY000: Can't drop database 'ndbtest1'; database doesn't exist
use test; use test;
create table t1 (a int primary key, b char(0)); create table t1 (a int primary key, b char(0));
insert into t1 values (1,""); insert into t1 values (1,"");

View File

@ -1,4 +1,4 @@
drop table if exists t1; drop table if exists t1, test1, test2;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int unsigned NOT NULL PRIMARY KEY, a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null, b int unsigned not null,
@ -275,3 +275,38 @@ a b c
1 1 1 1 1 1
4 4 NULL 4 4 NULL
drop table t1; drop table t1;
CREATE TABLE test1 (
SubscrID int(11) NOT NULL auto_increment,
UsrID int(11) NOT NULL default '0',
PRIMARY KEY (SubscrID),
KEY idx_usrid (UsrID)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO test1 VALUES (2,224),(3,224),(1,224);
CREATE TABLE test2 (
SbclID int(11) NOT NULL auto_increment,
SbcrID int(11) NOT NULL default '0',
PRIMARY KEY (SbclID),
KEY idx_sbcrid (SbcrID)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO test2 VALUES (3,2),(1,1),(2,1),(4,2);
select * from test1 order by 1;
SubscrID UsrID
1 224
2 224
3 224
select * from test2 order by 1;
SbclID SbcrID
1 1
2 1
3 2
4 2
SELECT s.SubscrID,l.SbclID FROM test1 s left JOIN test2 l ON
l.SbcrID=s.SubscrID WHERE s.UsrID=224 order by 1, 2;
SubscrID SbclID
1 1
1 2
2 3
2 4
3 NULL
drop table test1;
drop table test2;

View File

@ -184,3 +184,97 @@ select count(*) from t1 where i=2 or i is null;
count(*) count(*)
9 9
drop table t1; drop table t1;
set names latin2;
create table t1 select
null as c00,
if(1, null, 'string') as c01,
if(0, null, 'string') as c02,
ifnull(null, 'string') as c03,
ifnull('string', null) as c04,
case when 0 then null else 'string' end as c05,
case when 1 then null else 'string' end as c06,
coalesce(null, 'string') as c07,
coalesce('string', null) as c08,
least('string',null) as c09,
least(null, 'string') as c10,
greatest('string',null) as c11,
greatest(null, 'string') as c12,
nullif('string', null) as c13,
nullif(null, 'string') as c14,
trim('string' from null) as c15,
trim(null from 'string') as c16,
substring_index('string', null, 1) as c17,
substring_index(null, 'string', 1) as c18,
elt(1, null, 'string') as c19,
elt(1, 'string', null) as c20,
concat('string', null) as c21,
concat(null, 'string') as c22,
concat_ws('sep', 'string', null) as c23,
concat_ws('sep', null, 'string') as c24,
concat_ws(null, 'string', 'string') as c25,
make_set(3, 'string', null) as c26,
make_set(3, null, 'string') as c27,
export_set(3, null, 'off', 'sep') as c29,
export_set(3, 'on', null, 'sep') as c30,
export_set(3, 'on', 'off', null) as c31,
replace(null, 'from', 'to') as c32,
replace('str', null, 'to') as c33,
replace('str', 'from', null) as c34,
insert('str', 1, 2, null) as c35,
insert(null, 1, 2, 'str') as c36,
lpad('str', 10, null) as c37,
rpad(null, 10, 'str') as c38;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c00` binary(0) default NULL,
`c01` varchar(6) character set latin2 default NULL,
`c02` varchar(6) character set latin2 default NULL,
`c03` varchar(6) character set latin2 NOT NULL default '',
`c04` varchar(6) character set latin2 default NULL,
`c05` varchar(6) character set latin2 default NULL,
`c06` varchar(6) character set latin2 default NULL,
`c07` varchar(6) character set latin2 default NULL,
`c08` varchar(6) character set latin2 default NULL,
`c09` varchar(6) character set latin2 NOT NULL default '',
`c10` varchar(6) character set latin2 NOT NULL default '',
`c11` varchar(6) character set latin2 NOT NULL default '',
`c12` varchar(6) character set latin2 NOT NULL default '',
`c13` varchar(6) character set latin2 default NULL,
`c14` char(0) character set latin2 default NULL,
`c15` char(0) character set latin2 default NULL,
`c16` varchar(6) character set latin2 default NULL,
`c17` varchar(6) character set latin2 default NULL,
`c18` char(0) character set latin2 default NULL,
`c19` varchar(6) character set latin2 default NULL,
`c20` varchar(6) character set latin2 default NULL,
`c21` varchar(6) character set latin2 default NULL,
`c22` varchar(6) character set latin2 default NULL,
`c23` varchar(9) character set latin2 default NULL,
`c24` varchar(9) character set latin2 default NULL,
`c25` varchar(12) character set latin2 default NULL,
`c26` varchar(7) character set latin2 default NULL,
`c27` varchar(7) character set latin2 default NULL,
`c29` longtext character set latin2,
`c30` longtext character set latin2,
`c31` varchar(192) character set latin2 default NULL,
`c32` char(0) character set latin2 default NULL,
`c33` char(3) character set latin2 default NULL,
`c34` char(3) character set latin2 default NULL,
`c35` char(3) character set latin2 default NULL,
`c36` char(3) character set latin2 default NULL,
`c37` varchar(10) character set latin2 default NULL,
`c38` varchar(10) character set latin2 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
case 'str' when null then 'null' when 'STR' then 'str' end as c02,
field(null, 'str1', 'str2') as c03,
field('str1','STR1', null) as c04,
field('str1', null, 'STR1') as c05,
'string' in ('STRING', null) as c08,
'string' in (null, 'STRING') as c09;
c01 c02 c03 c04 c05 c08 c09
str str 0 1 2 1 1
set names latin1;

View File

@ -1789,7 +1789,7 @@ t5 CREATE TABLE `t5` (
`param10` bigint(20) default NULL, `param10` bigint(20) default NULL,
`const11` int(4) default NULL, `const11` int(4) default NULL,
`param11` bigint(20) default NULL, `param11` bigint(20) default NULL,
`const12` char(0) default NULL, `const12` binary(0) default NULL,
`param12` bigint(20) default NULL, `param12` bigint(20) default NULL,
`param13` double default NULL, `param13` double default NULL,
`param14` longtext, `param14` longtext,
@ -1819,7 +1819,7 @@ def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 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 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 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 param13 param13 5 20 0 Y 32768 31 63
def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8

View File

@ -1772,7 +1772,7 @@ t5 CREATE TABLE `t5` (
`param10` bigint(20) default NULL, `param10` bigint(20) default NULL,
`const11` int(4) default NULL, `const11` int(4) default NULL,
`param11` bigint(20) default NULL, `param11` bigint(20) default NULL,
`const12` char(0) default NULL, `const12` binary(0) default NULL,
`param12` bigint(20) default NULL, `param12` bigint(20) default NULL,
`param13` double default NULL, `param13` double default NULL,
`param14` longtext, `param14` longtext,
@ -1802,7 +1802,7 @@ def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 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 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 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 param13 param13 5 20 0 Y 32768 31 63
def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8

View File

@ -1773,7 +1773,7 @@ t5 CREATE TABLE `t5` (
`param10` bigint(20) default NULL, `param10` bigint(20) default NULL,
`const11` int(4) default NULL, `const11` int(4) default NULL,
`param11` bigint(20) default NULL, `param11` bigint(20) default NULL,
`const12` char(0) default NULL, `const12` binary(0) default NULL,
`param12` bigint(20) default NULL, `param12` bigint(20) default NULL,
`param13` double default NULL, `param13` double default NULL,
`param14` longtext, `param14` longtext,
@ -1803,7 +1803,7 @@ def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 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 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 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 param13 param13 5 20 0 Y 32768 31 63
def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8

View File

@ -1712,7 +1712,7 @@ t5 CREATE TABLE `t5` (
`param10` bigint(20) default NULL, `param10` bigint(20) default NULL,
`const11` int(4) default NULL, `const11` int(4) default NULL,
`param11` bigint(20) default NULL, `param11` bigint(20) default NULL,
`const12` char(0) default NULL, `const12` binary(0) default NULL,
`param12` bigint(20) default NULL, `param12` bigint(20) default NULL,
`param13` double default NULL, `param13` double default NULL,
`param14` longtext, `param14` longtext,
@ -1742,7 +1742,7 @@ def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 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 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 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 param13 param13 5 20 0 Y 32768 31 63
def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
@ -4721,7 +4721,7 @@ t5 CREATE TABLE `t5` (
`param10` bigint(20) default NULL, `param10` bigint(20) default NULL,
`const11` int(4) default NULL, `const11` int(4) default NULL,
`param11` bigint(20) default NULL, `param11` bigint(20) default NULL,
`const12` char(0) default NULL, `const12` binary(0) default NULL,
`param12` bigint(20) default NULL, `param12` bigint(20) default NULL,
`param13` double default NULL, `param13` double default NULL,
`param14` longtext, `param14` longtext,
@ -4751,7 +4751,7 @@ def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 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 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 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 param13 param13 5 20 0 Y 32768 31 63
def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8

View File

@ -1772,7 +1772,7 @@ t5 CREATE TABLE `t5` (
`param10` bigint(20) default NULL, `param10` bigint(20) default NULL,
`const11` int(4) default NULL, `const11` int(4) default NULL,
`param11` bigint(20) default NULL, `param11` bigint(20) default NULL,
`const12` char(0) default NULL, `const12` binary(0) default NULL,
`param12` bigint(20) default NULL, `param12` bigint(20) default NULL,
`param13` double default NULL, `param13` double default NULL,
`param14` longtext, `param14` longtext,
@ -1802,7 +1802,7 @@ def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 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 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 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 param13 param13 5 20 0 Y 32768 31 63
def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8

View File

@ -1749,7 +1749,7 @@ t5 CREATE TABLE `t5` (
`param10` bigint(20) default NULL, `param10` bigint(20) default NULL,
`const11` int(4) default NULL, `const11` int(4) default NULL,
`param11` bigint(20) default NULL, `param11` bigint(20) default NULL,
`const12` char(0) default NULL, `const12` binary(0) default NULL,
`param12` bigint(20) default NULL, `param12` bigint(20) default NULL,
`param13` double default NULL, `param13` double default NULL,
`param14` longtext, `param14` longtext,
@ -1779,7 +1779,7 @@ def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 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 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 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 param13 param13 5 20 0 Y 32768 31 63
def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8 def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8

View File

@ -0,0 +1,22 @@
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;
drop database if exists mysqltest1;
create database mysqltest1;
use mysqltest1;
create table t1 (a int);
insert into t1 values(9);
select * from mysqltest1.t1;
a
9
show databases like 'mysqltest1';
Database (mysqltest1)
mysqltest1
select * from test.t1;
a
9
drop table t1;
drop database mysqltest1;

View File

@ -324,3 +324,15 @@ alter table t1 rename to `t1\\`;
rename table t1 to `t1\\`; rename table t1 to `t1\\`;
drop table t1; drop table t1;
#
# Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
#
# The column's character set was changed but the actual data was not
# modified. In other words, the values were reinterpreted
# as UTF8 instead of being converted.
create table t1 (a text) character set koi8r;
insert into t1 values (_koi8r'<27><><EFBFBD><EFBFBD>');
select hex(a) from t1;
alter table t1 convert to character set cp1251;
select hex(a) from t1;
drop table t1;

View File

@ -0,0 +1,41 @@
-- source include/have_innodb.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
### Test 1:
### - While a consistent snapshot transaction is executed,
### no external inserts should be visible to the transaction.
connection con1;
create table t1 (a int) engine=innodb;
start transaction with consistent snapshot;
connection con2;
insert into t1 values(1);
connection con1;
select * from t1; # if consistent snapshot was set as expected, we
# should see nothing.
commit;
### Test 2:
### - For any non-consistent snapshot transaction, external
### committed inserts should be visible to the transaction.
delete from t1;
start transaction; # Now we omit WITH CONSISTENT SNAPSHOT
connection con2;
insert into t1 values(1);
connection con1;
select * from t1; # if consistent snapshot was not set, as expected, we
# should see 1.
commit;
drop table t1;

View File

@ -83,3 +83,39 @@ CREATE TABLE t1 (
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SHOW COLUMNS FROM t1; SHOW COLUMNS FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #6345 Unexpected behaviour with partial indices
#
--disable_warnings
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
--enable_warnings
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
DROP TABLE t1;
--disable_warnings
CREATE TABLE t1
(
a INTEGER NOT NULL,
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
--enable_warnings
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl');
SELECT t1.* FROM t1 WHERE b='aaabbbcccddd' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='eeefffggghhh' ORDER BY a;
SELECT t1.* FROM t1 WHERE b='iiijjjkkkl' ORDER BY a;
DROP TABLE t1;

View File

@ -1,7 +1,7 @@
-- source include/have_ndb.inc -- source include/have_ndb.inc
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
--enable_warnings --enable_warnings
################################################ ################################################
@ -472,5 +472,11 @@ system rm var/master-data/test/t9.frm ;
# MySQL Server will have been restarted because it has a # MySQL Server will have been restarted because it has a
# ndb_autodiscover2-master.opt file. # ndb_autodiscover2-master.opt file.
create table t10 (
a int not null primary key,
b blob
) engine=ndb;
insert into t10 values (1, 'kalle');
--exec $NDB_TOOLS_DIR/ndb_drop_table -d test `$NDB_TOOLS_DIR/ndb_show_tables | grep BLOB` > /dev/null 2>&1 || true

View File

@ -13,4 +13,7 @@ show status like 'handler_discover%';
drop table t9; drop table t9;
--error 1296
select * from t10;
drop table t10;

View File

@ -360,6 +360,21 @@ select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a;
drop table test.t1, t2; drop table test.t1, t2;
drop database mysqltest; drop database mysqltest;
#
# BUG#6031 - DROP DATABASE doesn't drop database on first try
#
--disable_warnings
drop database if exists ndbtest1;
--enable_warnings
create database ndbtest1;
use ndbtest1;
create table t1(id int) engine=ndbcluster;
drop database ndbtest1;
--error 1008
drop database ndbtest1;
# #
# test support of char(0) # test support of char(0)
# #

View File

@ -1,7 +1,7 @@
-- source include/have_ndb.inc -- source include/have_ndb.inc
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1, test1, test2;
--enable_warnings --enable_warnings
# #
@ -146,3 +146,29 @@ select * from t1 use index (bc) where b IS NULL and c = 2 order by a;
select * from t1 use index (bc) where b < 4 order by a; select * from t1 use index (bc) where b < 4 order by a;
select * from t1 use index (bc) where b IS NOT NULL order by a; select * from t1 use index (bc) where b IS NOT NULL order by a;
drop table t1; drop table t1;
#
# Bug #6435
CREATE TABLE test1 (
SubscrID int(11) NOT NULL auto_increment,
UsrID int(11) NOT NULL default '0',
PRIMARY KEY (SubscrID),
KEY idx_usrid (UsrID)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO test1 VALUES (2,224),(3,224),(1,224);
CREATE TABLE test2 (
SbclID int(11) NOT NULL auto_increment,
SbcrID int(11) NOT NULL default '0',
PRIMARY KEY (SbclID),
KEY idx_sbcrid (SbcrID)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO test2 VALUES (3,2),(1,1),(2,1),(4,2);
select * from test1 order by 1;
select * from test2 order by 1;
SELECT s.SubscrID,l.SbclID FROM test1 s left JOIN test2 l ON
l.SbcrID=s.SubscrID WHERE s.UsrID=224 order by 1, 2;
drop table test1;
drop table test2;

View File

@ -122,3 +122,70 @@ explain select * from t1 where i=2 or i is null;
select count(*) from t1 where i=2 or i is null; select count(*) from t1 where i=2 or i is null;
drop table t1; drop table t1;
#
# NULL has its own type BINARY(0) by default.
# But NULL should be weaker than a constant
# when mixing charsets/collations
#
set names latin2;
# Check that result type is taken from a non-null string
create table t1 select
null as c00,
if(1, null, 'string') as c01,
if(0, null, 'string') as c02,
ifnull(null, 'string') as c03,
ifnull('string', null) as c04,
case when 0 then null else 'string' end as c05,
case when 1 then null else 'string' end as c06,
coalesce(null, 'string') as c07,
coalesce('string', null) as c08,
least('string',null) as c09,
least(null, 'string') as c10,
greatest('string',null) as c11,
greatest(null, 'string') as c12,
nullif('string', null) as c13,
nullif(null, 'string') as c14,
trim('string' from null) as c15,
trim(null from 'string') as c16,
substring_index('string', null, 1) as c17,
substring_index(null, 'string', 1) as c18,
elt(1, null, 'string') as c19,
elt(1, 'string', null) as c20,
concat('string', null) as c21,
concat(null, 'string') as c22,
concat_ws('sep', 'string', null) as c23,
concat_ws('sep', null, 'string') as c24,
concat_ws(null, 'string', 'string') as c25,
make_set(3, 'string', null) as c26,
make_set(3, null, 'string') as c27,
export_set(3, null, 'off', 'sep') as c29,
export_set(3, 'on', null, 'sep') as c30,
export_set(3, 'on', 'off', null) as c31,
replace(null, 'from', 'to') as c32,
replace('str', null, 'to') as c33,
replace('str', 'from', null) as c34,
insert('str', 1, 2, null) as c35,
insert(null, 1, 2, 'str') as c36,
lpad('str', 10, null) as c37,
rpad(null, 10, 'str') as c38;
show create table t1;
drop table t1;
#
# Check that comparison is done according to
# non-null string collation, i.e. case insensitively,
# rather than according to NULL's collation, i.e. case sensitively
#
-- in field
select
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
case 'str' when null then 'null' when 'STR' then 'str' end as c02,
field(null, 'str1', 'str2') as c03,
field('str1','STR1', null) as c04,
field('str1', null, 'STR1') as c05,
'string' in ('STRING', null) as c08,
'string' in (null, 'STRING') as c09;
# Restore charset to the default value.
set names latin1;

View File

@ -0,0 +1 @@
"--replicate-rewrite-db=mysqltest1->test"

View File

@ -0,0 +1,19 @@
source include/master-slave.inc;
--disable_warnings
drop database if exists mysqltest1;
--enable_warnings
create database mysqltest1;
use mysqltest1;
create table t1 (a int);
insert into t1 values(9);
select * from mysqltest1.t1;
sync_slave_with_master;
show databases like 'mysqltest1'; # should be empty
select * from test.t1;
# cleanup
connection master;
drop table t1;
drop database mysqltest1;
sync_slave_with_master;

View File

@ -42,8 +42,8 @@ static void netware_init();
#define netware_init() #define netware_init()
#endif #endif
my_bool my_init_done= 0;
my_bool my_init_done=0; uint mysys_usage_id= 0; /* Incremented for each my_init() */
static ulong atoi_octal(const char *str) static ulong atoi_octal(const char *str)
{ {
@ -51,7 +51,7 @@ static ulong atoi_octal(const char *str)
while (*str && my_isspace(&my_charset_latin1, *str)) while (*str && my_isspace(&my_charset_latin1, *str))
str++; str++;
str2int(str, str2int(str,
(*str == '0' ? 8 : 10), /* Octalt or decimalt */ (*str == '0' ? 8 : 10), /* Octalt or decimalt */
0, INT_MAX, &tmp); 0, INT_MAX, &tmp);
return (ulong) tmp; return (ulong) tmp;
} }
@ -74,6 +74,7 @@ my_bool my_init(void)
if (my_init_done) if (my_init_done)
return 0; return 0;
my_init_done=1; my_init_done=1;
mysys_usage_id++;
#if defined(THREAD) && defined(SAFE_MUTEX) #if defined(THREAD) && defined(SAFE_MUTEX)
safe_mutex_global_init(); /* Must be called early */ safe_mutex_global_init(); /* Must be called early */
#endif #endif

View File

@ -733,6 +733,7 @@ extern "C" {
int param, unsigned long long * value); int param, unsigned long long * value);
int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*, int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*,
int param, const char ** value); int param, const char ** value);
int ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -21,11 +21,11 @@
#ifndef NDB_TYPES_H #ifndef NDB_TYPES_H
#define NDB_TYPES_H #define NDB_TYPES_H
typedef char Int8; typedef signed char Int8;
typedef unsigned char Uint8; typedef unsigned char Uint8;
typedef short Int16; typedef signed short Int16;
typedef unsigned short Uint16; typedef unsigned short Uint16;
typedef int Int32; typedef signed int Int32;
typedef unsigned int Uint32; typedef unsigned int Uint32;
typedef unsigned int UintR; typedef unsigned int UintR;
@ -45,10 +45,10 @@ typedef uintptr_t UintPtr;
#if defined(WIN32) || defined(NDB_WIN32) #if defined(WIN32) || defined(NDB_WIN32)
typedef unsigned __int64 Uint64; typedef unsigned __int64 Uint64;
typedef __int64 Int64; typedef signed __int64 Int64;
#else #else
typedef unsigned long long Uint64; typedef unsigned long long Uint64;
typedef long long Int64; typedef signed long long Int64;
#endif #endif
#endif #endif

View File

@ -369,7 +369,7 @@ public:
*/ */
bool getDistributionKey() const; bool getDistributionKey() const;
/** @} *******************************************************************/ /** @} *******************************************************************/
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
void setTupleKey(bool); void setTupleKey(bool);
bool getTupleKey() const; bool getTupleKey() const;
@ -486,6 +486,18 @@ public:
*/ */
const Column* getColumn(const char * name) const; const Column* getColumn(const char * name) const;
/**
* Get column definition via index in table.
* @return null if none existing name
*/
Column* getColumn(const int attributeId);
/**
* Get column definition via name.
* @return null if none existing name
*/
Column* getColumn(const char * name);
/** /**
* Get column definition via index in table. * Get column definition via index in table.
* @return null if none existing name * @return null if none existing name

View File

@ -104,6 +104,11 @@ public:
*/ */
static void bitXOR(unsigned size, Uint32 data[], const Uint32 data2[]); static void bitXOR(unsigned size, Uint32 data[], const Uint32 data2[]);
/**
* bitXORC - Bitwise (x ^ ~y) into first operand.
*/
static void bitXORC(unsigned size, Uint32 data[], const Uint32 data2[]);
/** /**
* contains - Check if all bits set in data2 are set in data * contains - Check if all bits set in data2 are set in data
*/ */
@ -261,6 +266,14 @@ BitmaskImpl::bitXOR(unsigned size, Uint32 data[], const Uint32 data2[])
} }
} }
inline void
BitmaskImpl::bitXORC(unsigned size, Uint32 data[], const Uint32 data2[])
{
for (unsigned i = 0; i < size; i++) {
data[i] ^= ~data2[i];
}
}
inline bool inline bool
BitmaskImpl::contains(unsigned size, Uint32 data[], const Uint32 data2[]) BitmaskImpl::contains(unsigned size, Uint32 data[], const Uint32 data2[])
{ {
@ -451,6 +464,12 @@ public:
static void bitXOR(Uint32 data[], const Uint32 data2[]); static void bitXOR(Uint32 data[], const Uint32 data2[]);
BitmaskPOD<size>& bitXOR(const BitmaskPOD<size>& mask2); BitmaskPOD<size>& bitXOR(const BitmaskPOD<size>& mask2);
/**
* bitXORC - Bitwise (x ^ ~y) into first operand.
*/
static void bitXORC(Uint32 data[], const Uint32 data2[]);
BitmaskPOD<size>& bitXORC(const BitmaskPOD<size>& mask2);
/** /**
* contains - Check if all bits set in data2 (that) are also set in data (this) * contains - Check if all bits set in data2 (that) are also set in data (this)
*/ */
@ -712,6 +731,21 @@ BitmaskPOD<size>::bitXOR(const BitmaskPOD<size>& mask2)
return *this; return *this;
} }
template <unsigned size>
inline void
BitmaskPOD<size>::bitXORC(Uint32 data[], const Uint32 data2[])
{
BitmaskImpl::bitXORC(size,data, data2);
}
template <unsigned size>
inline BitmaskPOD<size>&
BitmaskPOD<size>::bitXORC(const BitmaskPOD<size>& mask2)
{
BitmaskPOD<size>::bitXORC(rep.data, mask2.rep.data);
return *this;
}
template <unsigned size> template <unsigned size>
char * char *
BitmaskPOD<size>::getText(const Uint32 data[], char* buf) BitmaskPOD<size>::getText(const Uint32 data[], char* buf)

View File

@ -37,7 +37,7 @@ public:
public: public:
virtual ~Session() {} virtual ~Session() {}
virtual void runSession(){} virtual void runSession(){}
virtual void stopSession(){} virtual void stopSession(){ m_stop = true; }
protected: protected:
friend class SocketServer; friend class SocketServer;
friend void* sessionThread_C(void*); friend void* sessionThread_C(void*);
@ -98,6 +98,8 @@ public:
*/ */
void stopSessions(bool wait = false); void stopSessions(bool wait = false);
void foreachSession(void (*f)(SocketServer::Session*, void*), void *data);
private: private:
struct SessionInstance { struct SessionInstance {
Service * m_service; Service * m_service;

View File

@ -1,4 +1,4 @@
SUBDIRS = portlib debugger util logger transporter mgmcommon editline SUBDIRS = portlib debugger util logger transporter mgmcommon
noinst_LTLIBRARIES = libcommon.la noinst_LTLIBRARIES = libcommon.la

View File

@ -1,15 +0,0 @@
include .defs.mk
LIB_DIRS := \
portlib \
debugger \
util \
logger
ifneq ($(USE_EDITLINE), N)
LIB_DIRS += editline
endif
DIRS := transporter mgmcommon
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,11 +0,0 @@
include .defs.mk
TYPE := kernel
DIRS := signaldata
PIC_ARCHIVE := Y
ARCHIVE_TARGET := trace
SOURCES = SignalLoggerManager.cpp DebuggerNames.cpp BlockNames.cpp LogLevel.cpp EventLogger.cpp GrepError.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,33 +0,0 @@
include .defs.mk
TYPE := ndbapi
PIC_ARCHIVE := Y
ARCHIVE_TARGET := signaldataprint
SOURCES = TcKeyReq.cpp TcKeyConf.cpp TcKeyRef.cpp \
TcRollbackRep.cpp \
TupKey.cpp TupCommit.cpp LqhKey.cpp \
FsOpenReq.cpp FsCloseReq.cpp FsRef.cpp FsConf.cpp FsReadWriteReq.cpp\
SignalDataPrint.cpp SignalNames.cpp \
ContinueB.cpp DihContinueB.cpp NdbfsContinueB.cpp \
CloseComReqConf.cpp PackedSignal.cpp PrepFailReqRef.cpp \
GCPSave.cpp DictTabInfo.cpp \
AlterTable.cpp AlterTab.cpp \
CreateTrig.cpp AlterTrig.cpp DropTrig.cpp \
FireTrigOrd.cpp TrigAttrInfo.cpp \
CreateIndx.cpp AlterIndx.cpp DropIndx.cpp TcIndx.cpp \
IndxKeyInfo.cpp IndxAttrInfo.cpp \
FsAppendReq.cpp ScanTab.cpp \
BackupImpl.cpp BackupSignalData.cpp \
UtilSequence.cpp UtilPrepare.cpp UtilDelete.cpp UtilExecute.cpp \
LqhFrag.cpp DropTab.cpp PrepDropTab.cpp LCP.cpp MasterLCP.cpp \
CopyGCI.cpp SystemError.cpp StartRec.cpp NFCompleteRep.cpp \
FailRep.cpp DisconnectRep.cpp SignalDroppedRep.cpp \
SumaImpl.cpp NdbSttor.cpp CreateFragmentation.cpp \
CntrStart.cpp ReadNodesConf.cpp \
UtilLock.cpp TuxMaint.cpp TupAccess.cpp AccLock.cpp \
LqhTrans.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -16,65 +16,9 @@
#include "GlobalSignalNumbers.h" #include <GlobalSignalNumbers.h>
#include "signaldata/SignalDataPrint.hpp" #include <signaldata/SignalData.hpp>
#include "signaldata/TcKeyReq.hpp" #include <signaldata/SignalDataPrint.hpp>
#include "signaldata/TcKeyConf.hpp"
#include "signaldata/TcKeyRef.hpp"
#include "signaldata/LqhKey.hpp"
#include "signaldata/TupKey.hpp"
#include "signaldata/TupCommit.hpp"
#include "signaldata/FsOpenReq.hpp"
#include "signaldata/FsCloseReq.hpp"
#include "signaldata/FsReadWriteReq.hpp"
#include "signaldata/FsRef.hpp"
#include "signaldata/FsConf.hpp"
#include "signaldata/CloseComReqConf.hpp"
#include "signaldata/PackedSignal.hpp"
#include "signaldata/PrepFailReqRef.hpp"
#include "signaldata/DictTabInfo.hpp"
#include "signaldata/AlterTable.hpp"
#include "signaldata/AlterTab.hpp"
#include "signaldata/CreateTrig.hpp"
#include "signaldata/AlterTrig.hpp"
#include "signaldata/DropTrig.hpp"
#include "signaldata/FireTrigOrd.hpp"
#include "signaldata/TrigAttrInfo.hpp"
#include "signaldata/CreateIndx.hpp"
#include "signaldata/AlterIndx.hpp"
#include "signaldata/DropIndx.hpp"
#include "signaldata/TcIndx.hpp"
#include "signaldata/IndxKeyInfo.hpp"
#include "signaldata/IndxAttrInfo.hpp"
#include <signaldata/FsAppendReq.hpp>
#include <signaldata/BackupSignalData.hpp>
#include <signaldata/BackupImpl.hpp>
#include <signaldata/UtilSequence.hpp>
#include <signaldata/UtilPrepare.hpp>
#include <signaldata/UtilExecute.hpp>
#include <signaldata/ScanTab.hpp>
#include <signaldata/ScanFrag.hpp>
#include <signaldata/LqhFrag.hpp>
#include <signaldata/LqhTransConf.hpp>
#include <signaldata/DropTab.hpp>
#include <signaldata/PrepDropTab.hpp>
#include <signaldata/LCP.hpp>
#include <signaldata/MasterLCP.hpp>
#include <signaldata/CopyGCIReq.hpp>
#include <signaldata/SystemError.hpp>
#include <signaldata/StartRec.hpp>
#include <signaldata/NFCompleteRep.hpp>
#include <signaldata/SignalDroppedRep.hpp>
#include <signaldata/FailRep.hpp>
#include <signaldata/DisconnectRep.hpp>
#include <signaldata/SumaImpl.hpp>
#include <signaldata/NdbSttor.hpp>
#include <signaldata/CreateFragmentation.hpp>
#include <signaldata/UtilLock.hpp>
#include <signaldata/CntrStart.hpp>
#include <signaldata/ReadNodesConf.hpp>
#include <signaldata/TuxMaint.hpp>
#include <signaldata/AccLock.hpp>
/** /**
* This is the register * This is the register
@ -254,9 +198,11 @@ SignalDataPrintFunctions[] = {
,{ 0, 0 } ,{ 0, 0 }
}; };
template class Bitmask<1>; #include <Bitmask.hpp>
template class Bitmask<2>;
template class Bitmask<4>;
template struct BitmaskPOD<1>; template struct BitmaskPOD<1>;
template struct BitmaskPOD<2>; template struct BitmaskPOD<2>;
template struct BitmaskPOD<4>; template struct BitmaskPOD<4>;
template class Bitmask<1>;
template class Bitmask<2>;
template class Bitmask<4>;

View File

@ -1,15 +0,0 @@
File Name Description
--------------------------------------------------------
README Release notes and copyright
MANIFEST This shipping list
Make.os9 OS-9 makefile
Makefile Unix makefile
complete.c Filename completion routines
editline.3 Manual page for editline library
editline.c Line-editing routines
editline_internal.h Internal library header file
os9.h OS-9-specific declarations
sysos9.c OS-9-specific routines
sysunix.c Unix-specific routines
testit.c Test driver
unix.h Unix-specific declarations

View File

@ -1,10 +0,0 @@
noinst_LIBRARIES = libeditline.a
libeditline_a_SOURCES = complete.c editline.c sysunix.c
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/ndb/include
DEFS = -DANSI_ARROWS -DHAVE_TCGETATTR -DSYS_UNIX
# Don't update the files from bitkeeper
%::SCCS/s.%

View File

@ -1,18 +0,0 @@
include .defs.mk
TYPE :=
ARCHIVE_TARGET := editline
CFLAGS += -DANSI_ARROWS -DHAVE_TCGETATTR -DSYS_UNIX
ifeq ($(NDB_OS), WIN32)
SOURCES = editline_win32.c
else
SOURCES = complete.c editline.c sysunix.c
endif
DIRS := test
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,53 +0,0 @@
--
NOTE: This version has been modified by Ericsson/Alzato. Please
see the cvs changelog for more details.
--
$Revision: 1.2 $
This is a line-editing library. It can be linked into almost any
program to provide command-line editing and recall.
It is call-compatible with the FSF readline library, but it is a
fraction of the size (and offers fewer features). It does not use
standard I/O. It is distributed under a "C News-like" copyright.
Configuration is done in the Makefile. Type "make testit" to get
a small slow shell for testing.
This contains some changes since the posting to comp.sources.misc:
- Bugfix for completion on absolute pathnames.
- Better handling of M-n versus showing raw 8bit chars.
- Better signal handling.
- Now supports termios/termio/sgttyb ioctl's.
- Add M-m command to toggle how 8bit data is displayed.
The following changes, made since the last public release, come from
J.G. Vons <vons@cesar.crbca1.sinet.slb.com>:
- History-searching no longer redraws the line wrong
- Added ESC-ESC as synonym for ESC-?
- SIGQUIT (normally ^\) now sends a signal, not indicating EOF.
- Fixed some typo's and unclear wording in the manpage.
- Fixed completion when all entries shared a common prefix.
- Fixed some meta-char line-redrawing bugs.
Enjoy,
Rich $alz
<rsalz@osf.org>
Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
This software is not subject to any license of the American Telephone
and Telegraph Company or of the Regents of the University of California.
Permission is granted to anyone to use this software for any purpose on
any computer system, and to alter it and redistribute it freely, subject
to the following restrictions:
1. The authors are not responsible for the consequences of use of this
software, no matter how awful, even if they arise from flaws in it.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. Since few users ever read sources,
credits must appear in the documentation.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software. Since few users
ever read sources, credits must appear in the documentation.
4. This notice may not be removed or altered.

View File

@ -1,195 +0,0 @@
/* -*- c-basic-offset: 4; -*-
** $Revision: 1.8 $
**
** History and file completion functions for editline library.
*/
#include "editline_internal.h"
/*
** strcmp-like sorting predicate for qsort.
*/
static int
compare(const void *p1, const void *p2)
{
const char **v1;
const char **v2;
v1 = (const char **)p1;
v2 = (const char **)p2;
return strcmp(*v1, *v2);
}
/*
** Fill in *avp with an array of names that match file, up to its length.
** Ignore . and .. .
*/
static int
FindMatches(char *dir, char *file, char ***avp)
{
char **av;
char **new;
char *p;
DIR *dp;
struct dirent *ep;
size_t ac;
size_t len;
if ((dp = opendir(dir)) == NULL)
return 0;
av = NULL;
ac = 0;
len = strlen(file);
while ((ep = readdir(dp)) != NULL) {
p = ep->d_name;
if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')))
continue;
if (len && strncmp(p, file, len) != 0)
continue;
if ((ac % MEM_INC) == 0) {
if ((new = malloc(sizeof(char*) * (ac + MEM_INC))) == NULL)
break;
if (ac) {
memcpy(new, av, ac * sizeof (char **));
free(av);
}
*avp = av = new;
}
if ((av[ac] = strdup(p)) == NULL) {
if (ac == 0)
free(av);
break;
}
ac++;
}
/* Clean up and return. */
(void)closedir(dp);
if (ac)
qsort(av, ac, sizeof (char **), compare);
return ac;
}
/*
** Split a pathname into allocated directory and trailing filename parts.
*/
static int
SplitPath(char *path, char **dirpart, char ** filepart)
{
static char DOT[] = ".";
char *dpart;
char *fpart;
if ((fpart = strrchr(path, '/')) == NULL) {
if ((dpart = strdup(DOT)) == NULL)
return -1;
if ((fpart = strdup(path)) == NULL) {
free(dpart);
return -1;
}
}
else {
if ((dpart = strdup(path)) == NULL)
return -1;
dpart[fpart - path + 1] = '\0';
if ((fpart = strdup(++fpart)) == NULL) {
free(dpart);
return -1;
}
}
*dirpart = dpart;
*filepart = fpart;
return 0;
}
/*
** Attempt to complete the pathname, returning an allocated copy.
** Fill in *unique if we completed it, or set it to 0 if ambiguous.
*/
char *
rl_complete(char *pathname,int *unique)
{
char **av;
char *dir;
char *file;
char *new;
char *p;
size_t ac;
size_t end;
size_t i;
size_t j;
size_t len;
size_t new_len;
size_t p_len;
if (SplitPath(pathname, &dir, &file) < 0)
return NULL;
if ((ac = FindMatches(dir, file, &av)) == 0) {
free(dir);
free(file);
return NULL;
}
p = NULL;
len = strlen(file);
if (ac == 1) {
/* Exactly one match -- finish it off. */
*unique = 1;
j = strlen(av[0]) - len + 2;
p_len = sizeof(char) * (j + 1);
if ((p = malloc(p_len)) != NULL) {
memcpy(p, av[0] + len, j);
new_len = sizeof(char) * (strlen(dir) + strlen(av[0]) + 2);
new = malloc(new_len);
if(new != NULL) {
snprintf(new, new_len, "%s/%s", dir, av[0]);
rl_add_slash(new, p, p_len);
free(new);
}
}
}
else {
/* Find largest matching substring. */
for (*unique = 0, i = len, end = strlen(av[0]); i < end; i++)
for (j = 1; j < ac; j++)
if (av[0][i] != av[j][i])
goto breakout;
breakout:
if (i > len) {
j = i - len + 1;
if ((p = malloc(sizeof(char) * j)) != NULL) {
memcpy(p, av[0] + len, j);
p[j - 1] = '\0';
}
}
}
/* Clean up and return. */
free(dir);
free(file);
for (i = 0; i < ac; i++)
free(av[i]);
free(av);
return p;
}
/*
** Return all possible completions.
*/
int
rl_list_possib(char *pathname, char ***avp)
{
char *dir;
char *file;
int ac;
if (SplitPath(pathname, &dir, &file) < 0)
return 0;
ac = FindMatches(dir, file, avp);
free(dir);
free(file);
return ac;
}

View File

@ -1,178 +0,0 @@
.\" $Revision: 1.1 $
.TH EDITLINE 3
.SH NAME
editline \- command-line editing library with history
.SH SYNOPSIS
.nf
.B "char *"
.B "readline(prompt)"
.B " char *prompt;"
.B "void"
.B "add_history(line)"
.B " char *line;"
.fi
.SH DESCRIPTION
.I Editline
is a library that provides an line-editing interface with text recall.
It is intended to be compatible with the
.I readline
library provided by the Free Software Foundation, but much smaller.
The bulk of this manual page describes the user interface.
.PP
The
.I readline
routine returns a line of text with the trailing newline removed.
The data is returned in a buffer allocated with
.IR malloc (3),
so the space should be released with
.IR free (3)
when the calling program is done with it.
Before accepting input from the user, the specified
.I prompt
is displayed on the terminal.
.PP
The
.I add_history
routine makes a copy of the specified
.I line
and adds it to the internal history list.
.SS "User Interface"
A program that uses this library provides a simple emacs-like editing
interface to its users.
A line may be edited before it is sent to the calling program by typing either
control characters or escape sequences.
A control character, shown as a caret followed by a letter, is typed by
holding down the ``control'' key while the letter is typed.
For example, ``^A'' is a control-A.
An escape sequence is entered by typing the ``escape'' key followed by one or
more characters.
The escape key is abbreviated as ``ESC''.
Note that unlike control keys, case matters in escape sequences; ``ESC\ F''
is not the same as ``ESC\ f''.
.PP
An editing command may be typed anywhere on the line, not just at the
beginning.
In addition, a return may also be typed anywhere on the line, not just at
the end.
.PP
Most editing commands may be given a repeat count,
.IR n ,
where
.I n
is a number.
To enter a repeat count, type the escape key, the number, and then
the command to execute.
For example, ``ESC\ 4\ ^f'' moves forward four characters.
If a command may be given a repeat count then the text ``[n]'' is given at the
end of its description.
.PP
The following control characters are accepted:
.RS
.nf
.ta \w'ESC DEL 'u
^A Move to the beginning of the line
^B Move left (backwards) [n]
^D Delete character [n]
^E Move to end of line
^F Move right (forwards) [n]
^G Ring the bell
^H Delete character before cursor (backspace key) [n]
^I Complete filename (tab key); see below
^J Done with line (return key)
^K Kill to end of line (or column [n])
^L Redisplay line
^M Done with line (alternate return key)
^N Get next line from history [n]
^P Get previous line from history [n]
^R Search backward (forward if [n]) through history for text;
\& prefixing the string with a caret (^) forces it to
\& match only at the beginning of a history line
^T Transpose characters
^V Insert next character, even if it is an edit command
^W Wipe to the mark
^X^X Exchange current location and mark
^Y Yank back last killed text
^[ Start an escape sequence (escape key)
^]c Move forward to next character ``c''
^? Delete character before cursor (delete key) [n]
.fi
.RE
.PP
The following escape sequences are provided.
.RS
.nf
.ta \w'ESC DEL 'u
ESC\ ^H Delete previous word (backspace key) [n]
ESC\ DEL Delete previous word (delete key) [n]
ESC\ ESC Show possible completions; see below
ESC\ SP Set the mark (space key); see ^X^X and ^Y above
ESC\ . Get the last (or [n]'th) word from previous line
ESC\ ? Show possible completions; see below
ESC\ < Move to start of history
ESC\ > Move to end of history
ESC\ b Move backward a word [n]
ESC\ d Delete word under cursor [n]
ESC\ f Move forward a word [n]
ESC\ l Make word lowercase [n]
ESC\ m Toggle if 8bit chars display as themselves or with
\& an ``M\-'' prefix
ESC\ u Make word uppercase [n]
ESC\ y Yank back last killed text
ESC\ w Make area up to mark yankable
ESC\ nn Set repeat count to the number nn
ESC\ C Read from environment variable ``_C_'', where C is
\& an uppercase letter
.fi
.RE
.PP
The
.I editline
library has a small macro facility.
If you type the escape key followed by an uppercase letter,
.IR C ,
then the contents of the environment variable
.I _C_
are read in as if you had typed them at the keyboard.
For example, if the variable
.I _L_
contains the following:
.RS
^A^Kecho '^V^[[H^V^[[2J'^M
.RE
Then typing ``ESC L'' will move to the beginning of the line, kill the
entire line, enter the echo command needed to clear the terminal (if your
terminal is like a VT-100), and send the line back to the shell.
.PP
The
.I editline
library also does filename completion.
Suppose the root directory has the following files in it:
.RS
.nf
.ta \w'core 'u
bin vmunix
core vmunix.old
.fi
.RE
If you type ``rm\ /v'' and then the tab key.
.I Editline
will then finish off as much of the name as possible by adding ``munix''.
Because the name is not unique, it will then beep.
If you type the escape key followed by either a question mark or another
escape, it will display the two choices.
If you then type a period and a tab, the library will finish off the filename
for you:
.RS
.nf
.RI "rm /v[TAB]" munix ".[TAB]" old
.fi
.RE
The tab key is shown by ``[TAB]'' and the automatically-entered text
is shown in italics.
.SH "BUGS AND LIMITATIONS"
Cannot handle lines more than 80 columns.
.SH AUTHORS
Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy>
and Rich $alz <rsalz@osf.org>.
Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>.

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +0,0 @@
/* $Revision: 1.2 $
**
** Internal header file for editline library.
*/
#include <ndb_global.h>
#if defined(SYS_UNIX)
#include "unix.h"
#endif /* defined(SYS_UNIX) */
#define MEM_INC 64
#define SCREEN_INC 256
/*
** Variables and routines internal to this package.
*/
extern int rl_eof;
extern int rl_erase;
extern int rl_intr;
extern int rl_kill;
extern int rl_quit;
#if defined(DO_SIGTSTP)
extern int rl_susp;
#endif /* defined(DO_SIGTSTP) */
extern char *rl_complete();
extern int rl_list_possib();
extern void rl_ttyset();
extern void rl_add_slash();

View File

@ -1,132 +0,0 @@
/* $Revision: 1.4 $
**
** Unix system-dependant routines for editline library.
*/
#include "editline_internal.h"
#if defined(HAVE_TCGETATTR)
#include <termios.h>
void
rl_ttyset(int Reset)
{
static struct termios old;
struct termios new;
if (Reset == 0) {
if (tcgetattr(0, &old) < 0) perror("tcgetattr");
rl_erase = old.c_cc[VERASE];
rl_kill = old.c_cc[VKILL];
rl_eof = old.c_cc[VEOF];
rl_intr = old.c_cc[VINTR];
rl_quit = old.c_cc[VQUIT];
#if defined(DO_SIGTSTP)
rl_susp = old.c_cc[VSUSP];
#endif /* defined(DO_SIGTSTP) */
new = old;
new.c_lflag &= ~(ECHO | ICANON | ISIG);
new.c_iflag &= ~(ISTRIP | INPCK);
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
if (tcsetattr(0, TCSADRAIN, &new) < 0) perror("tcsetattr");
}
else
(void)tcsetattr(0, TCSADRAIN, &old);
}
#else
#if defined(HAVE_TERMIO)
#include <termio.h>
void
rl_ttyset(int Reset)
{
static struct termio old;
struct termio new;
if (Reset == 0) {
(void)ioctl(0, TCGETA, &old);
rl_erase = old.c_cc[VERASE];
rl_kill = old.c_cc[VKILL];
rl_eof = old.c_cc[VEOF];
rl_intr = old.c_cc[VINTR];
rl_quit = old.c_cc[VQUIT];
#if defined(DO_SIGTSTP)
rl_susp = old.c_cc[VSUSP];
#endif /* defined(DO_SIGTSTP) */
new = old;
new.c_lflag &= ~(ECHO | ICANON | ISIG);
new.c_iflag &= ~(ISTRIP | INPCK);
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
(void)ioctl(0, TCSETAW, &new);
}
else
(void)ioctl(0, TCSETAW, &old);
}
#else
#include <sgtty.h>
void
rl_ttyset(int Reset)
{
static struct sgttyb old_sgttyb;
static struct tchars old_tchars;
struct sgttyb new_sgttyb;
struct tchars new_tchars;
#if defined(DO_SIGTSTP)
struct ltchars old_ltchars;
#endif /* defined(DO_SIGTSTP) */
if (Reset == 0) {
(void)ioctl(0, TIOCGETP, &old_sgttyb);
rl_erase = old_sgttyb.sg_erase;
rl_kill = old_sgttyb.sg_kill;
(void)ioctl(0, TIOCGETC, &old_tchars);
rl_eof = old_tchars.t_eofc;
rl_intr = old_tchars.t_intrc;
rl_quit = old_tchars.t_quitc;
#if defined(DO_SIGTSTP)
(void)ioctl(0, TIOCGLTC, &old_ltchars);
rl_susp = old_ltchars.t_suspc;
#endif /* defined(DO_SIGTSTP) */
new_sgttyb = old_sgttyb;
new_sgttyb.sg_flags &= ~ECHO;
new_sgttyb.sg_flags |= RAW;
#if defined(PASS8)
new_sgttyb.sg_flags |= PASS8;
#endif /* defined(PASS8) */
(void)ioctl(0, TIOCSETP, &new_sgttyb);
new_tchars = old_tchars;
new_tchars.t_intrc = -1;
new_tchars.t_quitc = -1;
(void)ioctl(0, TIOCSETC, &new_tchars);
}
else {
(void)ioctl(0, TIOCSETP, &old_sgttyb);
(void)ioctl(0, TIOCSETC, &old_tchars);
}
}
#endif /* defined(HAVE_TERMIO) */
#endif /* defined(HAVE_TCGETATTR) */
void
rl_add_slash(char *path, char *p, size_t p_len)
{
struct stat Sb;
if (stat(path, &Sb) >= 0) {
size_t len= strlen(p);
if (len+1 < p_len) {
p[len]= S_ISDIR(Sb.st_mode) ? '/' : ' ';
p[len+1]= 0;
}
}
}

View File

@ -1,10 +0,0 @@
include .defs.mk
TYPE := util
BIN_TARGET := editline_test
BIN_TARGET_ARCHIVES := editline
SOURCES = testit.c
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,9 +0,0 @@
/* $Revision: 1.3 $
**
** Editline system header file for Unix.
*/
#define CRLF "\r\n"
#include <ndb_global.h>
#include <dirent.h>

View File

@ -1,27 +0,0 @@
include .defs.mk
TYPE := ndbapi
PIC_ARCHIVE := Y
ARCHIVE_TARGET := logger
DIRS := loggertest
SOURCES := Logger.cpp LogHandlerList.cpp LogHandler.cpp \
ConsoleLogHandler.cpp FileLogHandler.cpp
ifeq ($(NDB_OS), OSE)
NO_SYSLOG := Y
endif
ifeq ($(NDB_OS), WIN32)
NO_SYSLOG := Y
endif
ifneq ($(NO_SYSLOG), Y)
SOURCES += SysLogHandler.cpp
endif
include $(NDB_TOP)/Epilogue.mk

View File

@ -90,7 +90,7 @@ LocalConfig::init(const char *connectString,
//7. Check //7. Check
{ {
char buf[256]; char buf[256];
BaseString::snprintf(buf, sizeof(buf), "host=localhost:%s", NDB_BASE_PORT); BaseString::snprintf(buf, sizeof(buf), "host=localhost:%s", NDB_PORT);
if(readConnectString(buf, "default connect string")) if(readConnectString(buf, "default connect string"))
return true; return true;
} }
@ -124,12 +124,12 @@ void LocalConfig::printUsage() const {
ndbout << "1. Put a Ndb.cfg file in the directory where you start"<<endl ndbout << "1. Put a Ndb.cfg file in the directory where you start"<<endl
<< " the node. "<< endl << " the node. "<< endl
<< " Ex: Ndb.cfg" << endl << " Ex: Ndb.cfg" << endl
<< " | host=localhost:"<<NDB_BASE_PORT<<endl; << " | host=localhost:"<<NDB_PORT<<endl;
ndbout << "2. Use the environment variable NDB_CONNECTSTRING to "<<endl ndbout << "2. Use the environment variable NDB_CONNECTSTRING to "<<endl
<< " provide this information." <<endl << " provide this information." <<endl
<< " Ex: " << endl << " Ex: " << endl
<< " >export NDB_CONNECTSTRING=\"host=localhost:"<<NDB_BASE_PORT<<"\"" << " >export NDB_CONNECTSTRING=\"host=localhost:"<<NDB_PORT<<"\""
<<endl<<endl; <<endl<<endl;
} }

View File

@ -7,7 +7,7 @@ libmgmsrvcommon_la_SOURCES = \
INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv
DEFS_LOC = -DNDB_BASE_PORT="\"@ndb_port_base@\"" DEFS_LOC = -DNDB_PORT="\"@ndb_port@\""
include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_ndbapi.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am

View File

@ -1,29 +0,0 @@
include .defs.mk
TYPE := ndbapi mgmapiclient
PIC_ARCHIVE := Y
ARCHIVE_TARGET := mgmsrvcommon
# Removed temporary
DIRS := printConfig
SOURCES = \
LocalConfig.cpp \
Config.cpp \
ConfigInfo.cpp \
ConfigRetriever.cpp \
InitConfigFileParser.cpp \
IPCConfig.cpp
SOURCES.c = NdbConfig.c
CFLAGS_IPCConfig.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi)
include $(NDB_TOP)/Epilogue.mk

View File

@ -74,7 +74,7 @@ NdbConfig_NdbCfgName(int with_ndb_home){
static static
char *get_prefix_buf(int len, int node_id) char *get_prefix_buf(int len, int node_id)
{ {
char tmp_buf[sizeof("ndb_pid#########")+1]; char tmp_buf[sizeof("ndb_pid#############")+1];
char *buf; char *buf;
if (node_id > 0) if (node_id > 0)
snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id); snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id);

View File

@ -1,21 +0,0 @@
include .defs.mk
DIRS :=
ifeq ($(NDB_OS), SOFTOSE)
DIRS += ose
else
ifeq ($(NDB_OS), OSE)
DIRS += ose
else
ifeq ($(NDB_OS), WIN32)
DIRS += win32
else
DIRS += unix
endif
endif
endif
include $(NDB_TOP)/Epilogue.mk

View File

@ -55,18 +55,21 @@ NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags)
"%s: lseek failed: %s", lockfile, strerror(errno)); "%s: lseek failed: %s", lockfile, strerror(errno));
return -1; return -1;
} }
#ifdef F_TLOCK
/* Test for lock before becoming daemon */ /* Test for lock before becoming daemon */
if (lockf(lockfd, F_TEST, 0) == -1) { if (lockf(lockfd, F_TLOCK, 0) == -1)
if (errno == EACCES || errno == EAGAIN) { /* results may vary */ {
if (errno == EACCES || errno == EAGAIN) { /* results may vary */
snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize, snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
"%s: already locked by pid=%ld", lockfile, NdbDaemon_DaemonPid); "%s: already locked by pid=%ld", lockfile, NdbDaemon_DaemonPid);
return -1; return -1;
} }
NdbDaemon_ErrorCode = errno; NdbDaemon_ErrorCode = errno;
snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize, snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
"%s: lock test failed: %s", lockfile, strerror(errno)); "%s: lock test failed: %s", lockfile, strerror(errno));
return -1; return -1;
} }
#endif
/* Test open log file before becoming daemon */ /* Test open log file before becoming daemon */
if (logfile != NULL) { if (logfile != NULL) {
logfd = open(logfile, O_CREAT|O_WRONLY|O_APPEND, 0644); logfd = open(logfile, O_CREAT|O_WRONLY|O_APPEND, 0644);
@ -77,6 +80,15 @@ NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags)
return -1; return -1;
} }
} }
#ifdef F_TLOCK
if (lockf(lockfd, F_ULOCK, 0) == -1)
{
snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
"%s: fail to unlock", lockfile);
return -1;
}
#endif
/* Fork */ /* Fork */
n = fork(); n = fork();
if (n == -1) { if (n == -1) {

View File

@ -1,27 +0,0 @@
include .defs.mk
TYPE := util
PIC_ARCHIVE := Y
ARCHIVE_TARGET := portlib
SOURCES.c = NdbCondition.c \
NdbMutex.c \
NdbSleep.c \
NdbTick.c \
NdbEnv.c \
NdbThread.c \
NdbHost.c \
NdbTCP.c \
NdbDaemon.c
ifeq ($(NDB_OS), SOFTOSE)
SOURCES += NdbMem_SoftOse.cpp
else
SOURCES.c += NdbMem.c
endif
include $(NDB_TOP)/Epilogue.mk
testNdbDaemon: NdbDaemon.c
$(CC) -o $@ NdbDaemon.c $(CCFLAGS) -DNDB_DAEMON_TEST -L$(NDB_TOP)/lib

View File

@ -1,43 +0,0 @@
include .defs.mk
TYPE := util
PIC_ARCHIVE := Y
ARCHIVE_TARGET := transporter
DIRS := basictest perftest
# Source files of non-templated classes (.cpp files)
SOURCES = \
Transporter.cpp \
SendBuffer.cpp \
TCP_Transporter.cpp \
TransporterRegistry.cpp \
Packer.cpp
DIRS := basictest perftest
CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/kernel) \
-I$(call fixpath,$(NDB_TOP)/include/transporter)
ifeq ($(NDB_SHM), Y)
SOURCES += SHM_Transporter.cpp
ifeq ($(NDB_OS), WIN32)
SOURCES += SHM_Transporter.win32.cpp
else
SOURCES += SHM_Transporter.unix.cpp
endif
endif
ifeq ($(NDB_SCI), Y)
SOURCES += SCI_Transporter.cpp
endif
ifneq ($(findstring OSE, $(NDB_OS)),)
SOURCES += OSE_Transporter.cpp
SOURCES += OSE_Receiver.cpp
endif
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,28 +0,0 @@
include .defs.mk
TYPE := util
PIC_ARCHIVE := Y
ARCHIVE_TARGET := general
SOURCES = File.cpp md5_hash.cpp Properties.cpp socket_io.cpp \
SimpleProperties.cpp Parser.cpp InputStream.cpp SocketServer.cpp \
OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \
NdbSqlUtil.cpp ConfigValues.cpp new.cpp
SOURCES.c = uucode.c random.c getarg.c version.c
ifeq ($(NDB_OS), OSE)
SOURCES += NdbErrHnd.cpp
endif
ifeq ($(NDB_OS), OSE)
SOURCES += NdbErrHnd.cpp
endif
SOURCES.c += strdup.c strlcat.c strlcpy.c
DIRS := testSimpleProperties testProperties testConfigValues
include $(NDB_TOP)/Epilogue.mk
testNdbSqlUtil: NdbSqlUtil.cpp
$(CC) -o $@ NdbSqlUtil.cpp $(CCFLAGS) -DNDB_SQL_UTIL_TEST -L$(NDB_TOP)/lib -lportlib -lgeneral

View File

@ -258,6 +258,15 @@ transfer(NDB_SOCKET_TYPE sock){
return true; return true;
} }
void
SocketServer::foreachSession(void (*func)(SocketServer::Session*, void *), void *data)
{
for(int i = m_sessions.size() - 1; i >= 0; i--){
(*func)(m_sessions[i].m_session, data);
}
checkSessions();
}
void void
SocketServer::checkSessions(){ SocketServer::checkSessions(){
for(int i = m_sessions.size() - 1; i >= 0; i--){ for(int i = m_sessions.size() - 1; i >= 0; i--){
@ -278,8 +287,10 @@ void
SocketServer::stopSessions(bool wait){ SocketServer::stopSessions(bool wait){
int i; int i;
for(i = m_sessions.size() - 1; i>=0; i--) for(i = m_sessions.size() - 1; i>=0; i--)
m_sessions[i].m_session->m_stop = true; {
m_sessions[i].m_session->stopSession();
m_sessions[i].m_session->m_stop = true; // to make sure
}
for(i = m_services.size() - 1; i>=0; i--) for(i = m_services.size() - 1; i>=0; i--)
m_services[i].m_service->stopSessions(); m_services[i].m_service->stopSessions();

View File

@ -20,6 +20,10 @@
#include <basestring_vsnprintf.h> #include <basestring_vsnprintf.h>
#include <my_config.h> #include <my_config.h>
/*
#define SNPRINTF_RETURN_TRUNC
*/
int int
basestring_snprintf(char *str, size_t size, const char *format, ...) basestring_snprintf(char *str, size_t size, const char *format, ...)
{ {
@ -40,7 +44,6 @@ basestring_snprintf(char *str, size_t size, const char *format, ...)
* Let's hope vsnprintf works anyways * Let's hope vsnprintf works anyways
*/ */
#define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) #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 #endif
#ifdef SNPRINTF_RETURN_TRUNC #ifdef SNPRINTF_RETURN_TRUNC
static char basestring_vsnprintf_buf[16*1024]; static char basestring_vsnprintf_buf[16*1024];
@ -48,13 +51,27 @@ static char basestring_vsnprintf_buf[16*1024];
int int
basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap) basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap)
{ {
int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap); if (size == 0)
{
#ifdef SNPRINTF_RETURN_TRUNC #ifdef SNPRINTF_RETURN_TRUNC
if (ret == size-1 || ret == -1) { return BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf,
ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf, sizeof(basestring_vsnprintf_buf),
sizeof(basestring_vsnprintf_buf), format, ap);
format, ap); #else
} char buf[1];
return BASESTRING_VSNPRINTF_FUNC(buf, 1, format, ap);
#endif #endif
return ret; }
{
int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap);
#ifdef SNPRINTF_RETURN_TRUNC
if (ret == size-1 || ret == -1)
{
ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf,
sizeof(basestring_vsnprintf_buf),
format, ap);
}
#endif
return ret;
}
} }

View File

@ -1,6 +0,0 @@
include .defs.mk
DIRS := cpcd
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,11 +0,0 @@
include .defs.mk
TYPE := util
BIN_TARGET := ndb_cpcd
# Source files of non-templated classes (.cpp files)
SOURCES = main.cpp CPCD.cpp Process.cpp APIService.cpp Monitor.cpp common.cpp
BIN_TARGET_LIBS += logger
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,5 +0,0 @@
include .defs.mk
DIRS := error vm ndb-main blocks
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,28 +0,0 @@
#--------------------------------------------------------------------------
#
# Name Makefile
#
#
#
# List subdirectories to be travered
include .defs.mk
DIRS := \
cmvmi \
dbacc \
dbdict \
dbdih \
dblqh \
dbtc \
dbtup \
ndbfs \
ndbcntr \
qmgr \
trix \
backup \
dbutil \
suma \
grep \
dbtux
include ${NDB_TOP}/Epilogue.mk

View File

@ -1,18 +0,0 @@
include .defs.mk
TYPE := kernel
#ifneq ($(MYSQLCLUSTER_TOP),)
DIRS := restore
#endif
ARCHIVE_TARGET := backup
SOURCES = Backup.cpp BackupInit.cpp
include $(NDB_TOP)/Epilogue.mk
$(NDB_TOP)/bin/readBackupFile: read.o
$(C++) -o $@ read.o \
$(NDB_TOP)/lib/libportlib.a $(NDB_TOP)/lib/libgeneral.a

View File

@ -1,9 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := cmvmi
SOURCES = Cmvmi.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,11 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := dbacc
SOURCES = \
DbaccInit.cpp \
DbaccMain.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,12 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := dbdict
SOURCES = \
Dbdict.cpp
DIRS := printSchemafile
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,13 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := dbdih
DIRS := printSysfile
SOURCES = \
DbdihInit.cpp \
DbdihMain.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,12 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := dblqh
DIRS := redoLogReader
SOURCES = \
DblqhInit.cpp \
DblqhMain.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,11 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := dbtc
SOURCES = \
DbtcInit.cpp \
DbtcMain.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,26 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := dbtup
SOURCES = \
DbtupExecQuery.cpp \
DbtupBuffer.cpp \
DbtupRoutines.cpp \
DbtupCommit.cpp \
DbtupFixAlloc.cpp \
DbtupTrigger.cpp \
DbtupAbort.cpp \
DbtupLCP.cpp \
DbtupUndoLog.cpp \
DbtupPageMap.cpp \
DbtupPagMan.cpp \
DbtupStoredProcDef.cpp \
DbtupMeta.cpp \
DbtupTabDesMan.cpp \
DbtupGen.cpp \
DbtupSystemRestart.cpp \
DbtupIndex.cpp \
DbtupDebug.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,17 +0,0 @@
include .defs.mk
TYPE = kernel
ARCHIVE_TARGET = dbtux
SOURCES = \
DbtuxGen.cpp \
DbtuxMeta.cpp \
DbtuxMaint.cpp \
DbtuxNode.cpp \
DbtuxTree.cpp \
DbtuxScan.cpp \
DbtuxCmp.cpp \
DbtuxDebug.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,8 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := dbutil
SOURCES = DbUtil.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,9 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := grep
SOURCES = Grep.cpp GrepInit.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,12 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := ndbcntr
SOURCES = \
NdbcntrInit.cpp \
NdbcntrSysTable.cpp \
NdbcntrMain.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,14 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := ndbfs
SOURCES = \
AsyncFile.cpp \
Ndbfs.cpp VoidFs.cpp \
Filename.cpp \
CircularIndex.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,11 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := qmgr
SOURCES = \
QmgrInit.cpp \
QmgrMain.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,10 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := suma
SOURCES = Suma.cpp SumaInit.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,8 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := trix
SOURCES = Trix.cpp
include $(NDB_TOP)/Epilogue.mk

View File

@ -1,12 +0,0 @@
include .defs.mk
TYPE := kernel
ARCHIVE_TARGET := error
SOURCES = \
TimeModule.cpp \
ErrorReporter.cpp \
ErrorMessages.cpp
include $(NDB_TOP)/Epilogue.mk

Some files were not shown because too many files have changed in this diff Show More