Commit fcf743ef authored by unknown's avatar unknown

Fixes for bugs in the usage of IO_CACHE


Docs/manual.texi:
  Fixed the TRUNCATE syntax + Changelog
include/my_sys.h:
  Added my_b_vprintf
mysys/mf_iocache2.c:
  Added my_b_vprintf
mysys/my_vsnprintf.c:
  Fixed fatal (new) bug
mysys/thr_lock.c:
  Cleanup
readline/bind.c:
  cleanup
scripts/Makefile.am:
  Added mysqldumpslow
sql-bench/crash-me.sh:
  Fixed TRUNCATE
sql/log.cc:
  bug fix
sql/log_event.cc:
  Removed compiler warnings
sql/log_event.h:
  Fixed non portable header in binary dump
sql/mf_iocache.cc:
  cleanup
sql/mysqld.cc:
  Fixed loop problem on NT
sql/slave.cc:
  cleanup
sql/sql_class.cc:
  Fixed typos
sql/sql_parse.cc:
  cleanup
sql/sql_select.cc:
  bugfix
sql/sql_table.cc:
  cleanup
sql/sql_yacc.yy:
  Changed ALTER TABLE ... ORDER BY to get fewer warnings
sql/unireg.cc:
  cleanup
sql/unireg.h:
  Added missing define
parent 17ad3822
......@@ -374,7 +374,7 @@ MySQL Language Reference
* ANALYZE TABLE:: @code{ANALYZE TABLE} syntax
* REPAIR TABLE:: @code{REPAIR TABLE} syntax
* DELETE:: @code{DELETE} syntax
* TRUNCATE::
* TRUNCATE:: @code{TRUNCATE} syntax
* SELECT:: @code{SELECT} syntax
* JOIN:: @code{JOIN} syntax
* INSERT:: @code{INSERT} syntax
......@@ -1011,8 +1011,7 @@ The following list describes some useful sections of the manual:
For a discussion of @strong{MySQL}'s capabilities, see @ref{Features}.
@item
For installation instructions, see @ref{Installing}. For tips on porting
@strong{MySQL} to new architectures or operating systems, see @ref{Porting}.
For installation instructions, see @ref{Installing}.
@item
For tips on porting @strong{MySQL} to new architectures or operating
......@@ -3581,7 +3580,9 @@ We will provide hints on optimizing your system and your queries.
@item
You are allowed to call a @strong{MySQL} developer (in moderation) and
discuss your @strong{MySQL}-related problems.
discuss your @strong{MySQL}-related problems. This option is however
only to be used as a last result during an emergency after we have
failed to grasp the total problem with email.
@end itemize
@node Extended login support, , Login support, Support
......@@ -12590,7 +12591,7 @@ to restart @code{mysqld} with @code{--skip-grant-tables} to run
* ANALYZE TABLE:: @code{ANALYZE TABLE} syntax
* REPAIR TABLE:: @code{REPAIR TABLE} syntax
* DELETE:: @code{DELETE} syntax
* TRUNCATE::
* TRUNCATE:: @code{TRUNCATE} syntax
* SELECT:: @code{SELECT} syntax
* JOIN:: @code{JOIN} syntax
* INSERT:: @code{INSERT} syntax
......@@ -18264,7 +18265,7 @@ the @code{LIMIT} value.
@section @code{TRUNCATE} syntax
@example
TRUNCATE TABLE table_name
TRUNCATE table_name
@end example
Is in 3.23 and the same thing as @code{DELETE FROM table_name}. @xref{DELETE}.
......@@ -19528,7 +19529,7 @@ the @code{mysql} database.
@item @code{TABLES} @tab Closes all open tables and force all tables in use to be closed.
@item @code{TABLES table_name [,table_name...]} @tab Flush only the given tables
@item @code{[TABLE | TABLES] table_name [,table_name...]} @tab Flush only the given tables
@item @code{TABLES WITH READ LOCK} @tab Closes all open tables and locks all tables for all databases with a read until one executes @code{UNLOCK TABLES}. This is very convinient way to get backups if you have a file system, like Veritas,that can take snapshots in time.
......@@ -21551,13 +21552,19 @@ while other threads are reading from the table.
Support for big files (63-bit) on filesystems/operating systems that
support big files.
@item
All data is stored with the low byte first. This makes the data machine and
OS independent. The only requirement is that the machine uses two's-complement
signed integers (as every machine for the last 20 years has)
and IEEE floating-point format (also totally dominant among mainstream
machines). The only area of machines that may not support binary
compatibility are embedded systems (because they sometimes have peculiar
processors).
All data is stored with the low byte first. This makes the data machine
and OS independent. The only requirement is that the machine uses
two's-complement signed integers (as every machine for the last 20 years
has) and IEEE floating-point format (also totally dominant among
mainstream machines). The only area of machines that may not support
binary compatibility are embedded systems (because they sometimes have
peculiar processors).
There is no big speed penalty in storing data low byte first; The bytes
in a table row is normally unaligned and it doesn't take that much more
power to read an unaligned byte in order than in reverse order. The
actual fetch-column-value code is also not time critical compared to
other code.
@item
All number keys are stored with high byte first to give better index
compression.
......@@ -22094,7 +22101,7 @@ You need enough extra memory for all HEAP tables that you want to use at
the same time.
@item
To free memory, you should execute @code{DELETE FROM heap_table},
@code{TRUNCATE TABLE heap_table} or @code{DROP TABLE heap_table}.
@code{TRUNCATE heap_table} or @code{DROP TABLE heap_table}.
@item
@strong{MySQL} cannot find out how approximately many rows there
are between two values (this is used by the range optimizer to decide which
......@@ -26255,7 +26262,7 @@ This can be done with the following code:
@example
mysql> LOCK TABLES real_table WRITE, insert_table WRITE;
mysql> insert into real_table select * from insert_table;
mysql> TRUNCATE TABLE insert_table;
mysql> TRUNCATE insert_table;
mysql> UNLOCK TABLES;
@end example
......@@ -27110,7 +27117,7 @@ it is very important to @code{OPTIMIZE TABLE} sometimes.
@subsection Speed of @code{DELETE} queries
If you want to delete all rows in the table, you should use
@code{TRUNCATE TABLE table_name}. @xref{TRUNCATE}.
@code{TRUNCATE table_name}. @xref{TRUNCATE}.
The time to delete a record is exactly proportional to the number of
indexes. To delete records more quickly, you can increase the size of
......@@ -29825,7 +29832,7 @@ Use the table description file to create new (empty) data and index files:
@example
shell> mysql db_name
mysql> SET AUTOCOMMIT=1;
mysql> TRUNCATE TABLE table_name;
mysql> TRUNCATE table_name;
mysql> quit
@end example
......@@ -38485,6 +38492,13 @@ though, so Version 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.28
@itemize @bullet
@item
Fixed the @code{--skip-networking} works properly on NT.
@item
Fixed bug in @code{MyISAM} when running multiple updating processes on
the same table.
@item
Allow one to use @code{FLUSH TABLE tablename}.
@item
Changed all log files to use our own IO_CACHE mechanism instead of
FILE:s to avoid OS problems when there is many files open.
@item
......@@ -38500,7 +38514,7 @@ Added status variables @code{large_file_support},@code{net_read_timeout},
Fixed bug where we didn't allow an index name after the
@code{FOREIGN KEY} definition.
@item
Added @code{TRUNCATE TABLE table_name} as a synonym for
Added @code{TRUNCATE table_name} as a synonym for
@code{DELETE FROM table_name}.
@item
Fixed bug in a BDB key compare function when comparing part keys.
......@@ -511,6 +511,7 @@ extern uint my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
const char *prefix, uint cache_size,
myf cache_myflags);
......
......@@ -128,30 +128,38 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
uint my_b_printf(IO_CACHE *info, const char* fmt, ...)
{
int result;
va_list args;
va_start(args,fmt);
result=my_b_vprintf(info, fmt, args);
va_end(args);
return result;
}
uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
{
reg1 char *to= info->rc_pos;
char *end=info->rc_end;
uint out_length=0;
va_start(args,fmt);
for (; *fmt ; fmt++)
{
if (fmt[0] != '%')
if (*fmt++ != '%')
{
/* Copy everything until '%' or end of string */
const char *start=fmt;
const char *start=fmt-1;
uint length;
for (fmt++ ; *fmt && *fmt != '%' ; fmt++ ) ;
for (; *fmt && *fmt != '%' ; fmt++ ) ;
length= (uint) (fmt - start);
out_length+=length;
if (my_b_write(info, start, length))
goto err;
if (!*fmt) /* End of format */
{
va_end(args);
return out_length;
}
fmt++;
/* Found one '%' */
}
/* Skipp if max size is used (to be compatible with printf) */
......@@ -203,10 +211,8 @@ uint my_b_printf(IO_CACHE *info, const char* fmt, ...)
out_length++;
}
}
va_end(args);
return out_length;
err:
return (uint) -1;
va_end(args);
}
......@@ -35,6 +35,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
continue;
}
/* Skipp if max size is used (to be compatible with printf) */
fmt++;
while (isdigit(*fmt) || *fmt == '.' || *fmt == '-')
fmt++;
if (*fmt == 's') /* String parameter */
......
......@@ -422,8 +422,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
/* Request for READ lock */
if (lock->write.data)
{
/* We can get allow a read lock even if there is already a write lock
one the table in one the following cases:
/* We can allow a read lock even if there is already a write lock
on the table in one the following cases:
- This thread alread have a write lock on the table
- The write lock is TL_WRITE_ALLOW_READ or TL_WRITE_DELAYED
and the read lock is TL_READ_HIGH_PRIORITY or TL_READ
......
......@@ -1210,7 +1210,7 @@ rl_parse_and_bind (string)
if (fl && funname[fl - 1] == *funname)
funname[fl - 1] = '\0';
rl_macro_bind (useq, &funname[1], _rl_keymap);
rl_macro_bind ((char*) useq, &funname[1], _rl_keymap);
}
#if defined (PREFIX_META_HACK)
/* Ugly, but working hack to keep prefix-meta around. */
......
......@@ -26,7 +26,8 @@ bin_SCRIPTS = @server_scripts@ \
mysqlbug \
mysql_convert_table_format \
mysql_find_rows \
mysqlhotcopy
mysqlhotcopy \
mysqldumpslow
EXTRA_SCRIPTS = make_binary_distribution.sh \
msql2mysql.sh \
......@@ -40,6 +41,7 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \
mysql_convert_table_format.sh \
mysql_find_rows.sh \
mysqlhotcopy.sh \
mysqldumpslow.sh \
safe_mysqld.sh
EXTRA_DIST = $(EXTRA_SCRIPTS) \
......@@ -60,7 +62,8 @@ CLEANFILES = @server_scripts@ \
mysqlaccess \
mysql_convert_table_format \
mysql_find_rows \
mysqlhotcopy
mysqlhotcopy \
mysqldumpslow
SUPERCLEANFILES = mysqlbug
......
......@@ -289,9 +289,9 @@ report("rename table","rename_table",
$dbh->do("drop table crash_q1");
$dbh->do("drop table crash_q");
report("truncate table","truncate_table",
report("truncate","truncate_table",
"create table crash_q (a integer, b integer,c CHAR(10))",
"truncate table crash_q",
"truncate crash_q",
"drop table crash_q1");
if ($dbh->do("create table crash_q (a integer, b integer,c CHAR(10))") &&
......
......@@ -582,7 +582,7 @@ void MYSQL_LOG::write(THD *thd,enum enum_server_command command,
if (format)
{
if (my_b_write(&log_file," ",1) ||
my_b_printf(&log_file,format,args) == (uint) -1)
my_b_vprintf(&log_file,format,args) == (uint) -1)
error=errno;
}
if (my_b_write(&log_file,"\n",1) ||
......
......@@ -246,11 +246,10 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len)
case START_EVENT: return new Start_log_event(buf);
case STOP_EVENT: return new Stop_log_event(buf);
case INTVAR_EVENT: return new Intvar_log_event(buf);
default: return NULL;
default:
break;
}
//impossible
return NULL;
return NULL; // default value
}
void Log_event::print_header(FILE* file)
......@@ -351,6 +350,15 @@ Start_log_event::Start_log_event(const char* buf) :Log_event(buf)
created = uint4korr(buf + 2 + sizeof(server_version));
}
int Start_log_event::write_data(IO_CACHE* file)
{
char buff[sizeof(server_version)+2+4];
int2store(buff,binlog_version);
memcpy(buff+2,server_version,sizeof(server_version));
int4store(buff+2+sizeof(server_version),created);
return (my_b_write(file, (byte*) buff, sizeof(buff)) ? -1 : 0);
}
Rotate_log_event::Rotate_log_event(const char* buf, int event_len):
Log_event(buf),new_log_ident(NULL),alloced(0)
{
......
......@@ -183,7 +183,7 @@ class Load_log_event: public Log_event
{
protected:
char* data_buf;
void Load_log_event::copy_log_event(const char *buf, ulong data_len);
void copy_log_event(const char *buf, ulong data_len);
public:
int thread_id;
......@@ -304,9 +304,9 @@ extern char server_version[50];
class Start_log_event: public Log_event
{
public:
uint32 created;
uint16 binlog_version;
char server_version[50];
uint32 created;
Start_log_event() :Log_event(time(NULL)),binlog_version(BINLOG_VERSION)
{
......@@ -316,8 +316,7 @@ class Start_log_event: public Log_event
Start_log_event(IO_CACHE* file, time_t when_arg, uint32 server_id) :
Log_event(when_arg, 0, 0, server_id)
{
char buf[sizeof(server_version) + sizeof(binlog_version) +
sizeof(created)+4];
char buf[sizeof(server_version) + 2 + 4 + 4];
if (my_b_read(file, (byte*) buf, sizeof(buf)))
return;
binlog_version = uint2korr(buf+4);
......@@ -328,18 +327,11 @@ class Start_log_event: public Log_event
~Start_log_event() {}
Log_event_type get_type_code() { return START_EVENT;}
int write_data(IO_CACHE* file)
{
if (my_b_write(file, (byte*) &binlog_version, sizeof(binlog_version)) ||
my_b_write(file, (byte*) server_version, sizeof(server_version)) ||
my_b_write(file, (byte*) &created, sizeof(created)))
return -1;
return 0;
}
int write_data(IO_CACHE* file);
int get_data_size()
{
return sizeof(binlog_version) + sizeof(server_version) +
sizeof(created);
// sizeof(binlog_version) + sizeof(server_version) sizeof(created)
return 2 + sizeof(server_version) + 4;
}
void print(FILE* file, bool short_form = 0);
};
......
......@@ -320,7 +320,7 @@ int _my_b_net_read(register IO_CACHE *info, byte *Buffer,
read_length=my_net_read(net);
if (read_length == (int) packet_error)
{
info->error=(uint) -1;
info->error= -1;
return 1;
}
if (read_length == 0)
......
......@@ -1653,7 +1653,7 @@ int main(int argc, char **argv)
handler_count--;
}
}
if (have_tcpip)
if (have_tcpip && !opt_disable_networking)
{
handler_count++;
if (pthread_create(&hThread,&connection_attrib,
......
......@@ -171,9 +171,6 @@ int db_ok(const char* db, I_List<i_string> &do_list,
return 1;
}
// impossible
return 0;
}
static void init_strvar_from_file(char* var, int max_size, FILE* f,
......
......@@ -116,8 +116,8 @@ THD::THD()
system_thread=0;
bzero((char*) &mem_root,sizeof(mem_root));
#if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || defined(HAVE_GEMENI_DB)
if (open_cached_file(&transactions.trans_log,
mysql_tempdir,LOG_PREFIX,0,MYF(MY_WME)))
if (open_cached_file(&transaction.trans_log,
mysql_tmpdir,LOG_PREFIX,0,MYF(MY_WME)))
killed=1;
transaction.bdb_lock_count=0;
#endif
......@@ -145,7 +145,7 @@ THD::~THD()
}
close_temporary_tables(this);
#if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || defined(HAVE_GEMENI_DB)
close_cached_file(transactions.trans_log);
close_cached_file(&transaction.trans_log);
#endif
if (global_read_lock)
{
......
......@@ -78,7 +78,7 @@ static inline bool end_active_trans(THD *thd)
{
if (ha_commit(thd))
return 1;
thd->options&= ~OPTION_BEGIN;
thd->options&= ~(ulong) (OPTION_BEGIN);
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
}
return 0;
......@@ -1562,7 +1562,7 @@ mysql_execute_command(void)
if (!org_options & OPTION_AUTO_COMMIT)
{
/* We changed to auto_commit mode */
thd->options&= ~OPTION_BEGIN;
thd->options&= ~(ulong) (OPTION_BEGIN);
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
if (ha_commit(thd))
{
......@@ -1747,7 +1747,7 @@ mysql_execute_command(void)
even if there is a problem with the OPTION_AUTO_COMMIT flag
(Which of course should never happen...)
*/
thd->options&= ~OPTION_BEGIN;
thd->options&= ~(ulong) (OPTION_BEGIN);
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
if (!ha_commit(thd))
send_ok(&thd->net);
......@@ -1755,7 +1755,7 @@ mysql_execute_command(void)
res= -1;
break;
case SQLCOM_ROLLBACK:
thd->options&= ~OPTION_BEGIN;
thd->options&= ~(ulong) (OPTION_BEGIN);
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
if (!ha_rollback(thd))
send_ok(&thd->net);
......
......@@ -3718,7 +3718,8 @@ static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
}
MI_CREATE_INFO create_info;
bzero((char*) &create_info,sizeof(create_info));
if (options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT) == OPTION_BIG_TABLES)
if ((options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) ==
OPTION_BIG_TABLES)
create_info.data_file_length= ~(ulonglong) 0;
if ((error=mi_create(table->real_name,table->keys,&keydef,
......
......@@ -1446,7 +1446,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
mysql_bin_log.write(&qinfo);
}
goto end_temporary;
DBUG_RETURN(0);
}
intern_close_table(new_table); /* close temporary table */
......
......@@ -138,7 +138,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token BOTH
%token BY
%token CASCADE
%token CHANGED_FILES
%token CHECKSUM_SYM
%token CHECK_SYM
%token COLUMNS
......@@ -332,8 +331,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token DATE_SUB_INTERVAL
%token DAY_HOUR_SYM
%token DAY_MINUTE_SYM
%token DAY_OF_WEEK
%token DAY_OF_YEAR
%token DAY_SECOND_SYM
%token DAY_SYM
%token DECODE_SYM
......@@ -372,7 +369,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token RIGHT
%token ROUND
%token SECOND_SYM
%token SEC_TO_TIME
%token SUBSTRING
%token SUBSTRING_INDEX
%token TRIM
......@@ -385,8 +381,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token UNIQUE_USERS
%token UNIX_TIMESTAMP
%token USER
%token VERSION_SYM
%token WEEKDAY
%token WEEK_SYM
%token WHEN_SYM
%token WORK_SYM
......@@ -1040,10 +1034,9 @@ alter:
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT;
}
alter_list order_clause opt_create_table_options
alter_list
alter_list:
/* empty */
| alter_list_item
| alter_list ',' alter_list_item
......@@ -1082,7 +1075,8 @@ alter_list_item:
{ Lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0)); }
| RENAME opt_to table_alias table_ident
{ Lex->db=$4->db.str ; Lex->name= $4->table.str; }
| opt_create_table_options
| create_table_options
| order_clause
opt_column:
/* empty */ {}
......@@ -1227,7 +1221,7 @@ select_into:
| select_from opt_into
select_from:
FROM join_table_list where_clause group_clause having_clause order_clause limit_clause procedure_clause
FROM join_table_list where_clause group_clause having_clause opt_order_clause limit_clause procedure_clause
select_options:
......@@ -1850,9 +1844,12 @@ group_list:
** Order by statement in select
*/
order_clause:
opt_order_clause:
/* empty */
| ORDER_SYM BY { Lex->sort_default=1; } order_list
| order_clause
order_clause:
ORDER_SYM BY { Lex->sort_default=1; } order_list
order_list:
order_list ',' order_ident order_dir
......@@ -2136,7 +2133,7 @@ opt_delete_option:
| LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; }
truncate:
TRUNCATE_SYM TABLE_SYM table
TRUNCATE_SYM table
{ Lex->sql_command= SQLCOM_TRUNCATE; Lex->options=0;
Lex->lock_option= current_thd->update_lock_default; }
......@@ -2241,7 +2238,7 @@ flush_options:
| flush_option
flush_option:
TABLES { Lex->type|= REFRESH_TABLES; } opt_table_list
table_or_tables { Lex->type|= REFRESH_TABLES; } opt_table_list
| TABLES WITH READ_SYM LOCK_SYM { Lex->type|= REFRESH_TABLES | REFRESH_READ_LOCK; }
| HOSTS_SYM { Lex->type|= REFRESH_HOSTS; }
| PRIVILEGES { Lex->type|= REFRESH_GRANT; }
......
......@@ -280,11 +280,11 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo)
}
/* Save keynames */
keyname_pos=pos;
*pos++=NAMES_SEP_CHAR;
*pos++=(uchar) NAMES_SEP_CHAR;
for (key=keyinfo ; key != end ; key++)
{
uchar *tmp=(uchar*) strmov((char*) pos,key->name);
*tmp++=NAMES_SEP_CHAR;
*tmp++= (uchar) NAMES_SEP_CHAR;
*tmp=0;
pos=tmp;
}
......@@ -458,7 +458,7 @@ static bool pack_fields(File file,List<create_field> &create_fields)
}
/* Write fieldnames */
buff[0]=NAMES_SEP_CHAR;
buff[0]=(uchar) NAMES_SEP_CHAR;
if (my_write(file,(byte*) buff,1,MYF_RW))
DBUG_RETURN(1);
i=0;
......
......@@ -28,6 +28,7 @@
#define LANGUAGE "english/"
#define ERRMSG_FILE "errmsg.sys"
#define TEMP_PREFIX "MY"
#define LOG_PREFIX "ML"
#define PROGDIR "bin/"
#ifndef DATADIR
#define DATADIR "data/"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment