Commit 66521277 authored by serg@serg.mysql.com's avatar serg@serg.mysql.com

Merge

parents 5f1599e4 71670dc9
...@@ -39,3 +39,5 @@ tonu@x3.internalnet ...@@ -39,3 +39,5 @@ tonu@x3.internalnet
jcole@sarvik.tfr.cafe.ee jcole@sarvik.tfr.cafe.ee
venu@work.mysql.com venu@work.mysql.com
bell@sanja.is.com.ua bell@sanja.is.com.ua
kaj@work.mysql.com
mwagner@cash.mwagner.org
This diff is collapsed.
...@@ -5393,6 +5393,10 @@ You will need the following: ...@@ -5393,6 +5393,10 @@ You will need the following:
A Windows 32 bits Operational System of the family Win9x, ME, A Windows 32 bits Operational System of the family Win9x, ME,
NT and Win 2000. The NT family permits running the MySQL server NT and Win 2000. The NT family permits running the MySQL server
as a service. @xref{NT start}. as a service. @xref{NT start}.
If you want to use tables bigger than 4G, you should install MySQL
on NTFS or newer file system. Don't forget to use @code{MAX_ROWS} and
@code{AVG_ROW_LENGTH} when you create the table. @xref{CREATE TABLE}.
@item @item
TCP/IP protocol support. TCP/IP protocol support.
@item @item
...@@ -32227,6 +32231,25 @@ returns immediately. The return value is the number of log events it had to ...@@ -32227,6 +32231,25 @@ returns immediately. The return value is the number of log events it had to
wait to get to the specified position, or NULL in case of error. Useful for wait to get to the specified position, or NULL in case of error. Useful for
control of master-slave synchronisation, but was originally written to control of master-slave synchronisation, but was originally written to
facilitate replication testing. facilitate replication testing.
@findex FOUND_ROWS()
@findex LIMIT
@item FOUND_ROWS()
Returns the number of rows that the last @code{SELECT CALC_FOUND_ROWS ...}
command would have returned, if wasn't restricted with @code{LIMIT}.
@example
SELECT CALC_FOUND_ROWS * FROM table_name WHERE id > 100 LIMIT 10;
SELECT FOUND_ROWS();
@end example
The second select will return how many rows the SELECT should have
returned if we would remove the @code{LIMIT} clause.
Note that if you are using @code{SELECT CALC_FOUND_ROWS ...} MySQL has
to calculate all rows in the result set. This is however faster than
if you would not use @code{LIMIT} as the result set doesn't have to be sent
to the client.
@end table @end table
...@@ -32413,7 +32436,7 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND(); ...@@ -32413,7 +32436,7 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
@c help SELECT @c help SELECT
@example @example
SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT] SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [HIGH_PRIORITY] [SQL_CACHE | SQL_NO_CACHE] [CALC_FOUND_ROWS] [HIGH_PRIORITY]
[DISTINCT | DISTINCTROW | ALL] [DISTINCT | DISTINCTROW | ALL]
select_expression,... select_expression,...
[INTO @{OUTFILE | DUMPFILE@} 'file_name' export_options] [INTO @{OUTFILE | DUMPFILE@} 'file_name' export_options]
...@@ -32570,6 +32593,12 @@ result set will be small. In this case, MySQL will use fast ...@@ -32570,6 +32593,12 @@ result set will be small. In this case, MySQL will use fast
temporary tables to store the resulting table instead of using sorting. In temporary tables to store the resulting table instead of using sorting. In
MySQL Version 3.23 this shouldn't normally be needed. MySQL Version 3.23 this shouldn't normally be needed.
@item
@code{CALC_FOUND_ROWS} tells MySQL to calculate how many rows there
would be in the result, disregarding any @code{LIMIT} clause. The number
of rows can be obtained with @code{SELECT
FOUND_ROWS()}. @xref{Miscellaneous functions}.
@item @item
@code{SQL_CACHE} tells MySQL to store the query result in the query cache @code{SQL_CACHE} tells MySQL to store the query result in the query cache
if you are using @code{SQL_QUERY_CACHE_TYPE=2} (@code{DEMAND}). if you are using @code{SQL_QUERY_CACHE_TYPE=2} (@code{DEMAND}).
...@@ -34502,12 +34531,14 @@ original tables, MySQL will not allow concurrent inserts during ...@@ -34502,12 +34531,14 @@ original tables, MySQL will not allow concurrent inserts during
@item @item
The @code{RAID_TYPE} option will help you to break the 2G/4G limit for The @code{RAID_TYPE} option will help you to break the 2G/4G limit for
the MyISAM data file (not the index file) on operating systems that the MyISAM data file (not the index file) on operating systems that
don't support big files. don't support big files. Note that this option is not recommended for
You can get more speed from the I/O bottleneck by putting file system that supports big files!
@code{RAID} directories on different physical disks. @code{RAID_TYPE}
will work on any OS, as long as you have configured MySQL with You can get more speed from the I/O bottleneck by putting @code{RAID}
@code{--with-raid}. For now the only allowed @code{RAID_TYPE} is directories on different physical disks. @code{RAID_TYPE} will work on
@code{STRIPED} (@code{1} and @code{RAID0} are aliases for this). any OS, as long as you have configured MySQL with @code{--with-raid}.
For now the only allowed @code{RAID_TYPE} is @code{STRIPED} (@code{1}
and @code{RAID0} are aliases for this).
If you specify @code{RAID_TYPE=STRIPED} for a @code{MyISAM} table, If you specify @code{RAID_TYPE=STRIPED} for a @code{MyISAM} table,
@code{MyISAM} will create @code{RAID_CHUNKS} subdirectories named 00, @code{MyISAM} will create @code{RAID_CHUNKS} subdirectories named 00,
...@@ -43283,7 +43314,8 @@ No UDF functions. ...@@ -43283,7 +43314,8 @@ No UDF functions.
@item @item
No stack trace on core dump. No stack trace on core dump.
@item @item
No internal RAID support. No internal RAID support. (This is not normally needed as most OS has
nowadays support for big files).
@item @item
You can set this up as a server or a master (no replication). You can set this up as a server or a master (no replication).
@item @item
...@@ -48007,7 +48039,12 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -48007,7 +48039,12 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@item @item
ODBC compatibility: added @code{BIT_LENGTH()} function. ODBC compatibility: added @code{BIT_LENGTH()} function.
@item @item
Added @code{CAST()} and @code{CONVERT()} functions. Fixed bug in @code{FLUSH QUERY CACHE}.
@item
Added @code{CAST()} and @code{CONVERT()} functions. The @code{CAST} and
@code{CONVERT} functions are nearly identical and mainly useful when you
want to create a column with a specific type in a @code{CREATE ... SELECT}.
For more information, read @ref{Cast Functions}.
@item @item
Changed order of how keys are created in tables. Changed order of how keys are created in tables.
@item @item
...@@ -48032,7 +48069,7 @@ Fixed shutdown problem on HPUX. ...@@ -48032,7 +48069,7 @@ Fixed shutdown problem on HPUX.
@item @item
Added functions @code{des_encrypt()} and @code{des_decrypt()}. Added functions @code{des_encrypt()} and @code{des_decrypt()}.
@item @item
Added statement FLUSH DES_KEY_FILE. Added statement @code{FLUSH DES_KEY_FILE}.
@item @item
Added mysqld option @code{--des-key-file}. Added mysqld option @code{--des-key-file}.
@item @item
...@@ -48085,7 +48122,7 @@ Added boolean fulltext search code. It should be considered early alpha. ...@@ -48085,7 +48122,7 @@ Added boolean fulltext search code. It should be considered early alpha.
Extended @code{MODIFY} and @code{CHANGE} in @code{ALTER TABLE} to accept Extended @code{MODIFY} and @code{CHANGE} in @code{ALTER TABLE} to accept
the @code{AFTER} keyword. the @code{AFTER} keyword.
@item @item
Index are now used with @code{ORDER} BY on a whole InnoDB table. Index are now used with @code{ORDER BY} on a whole @code{InnoDB} table.
@end itemize @end itemize
@node News-4.0.0, , News-4.0.1, News-4.0.x @node News-4.0.0, , News-4.0.1, News-4.0.x
...@@ -48100,7 +48137,7 @@ Added documentation for @code{libmysqld}, the embedded MySQL server ...@@ -48100,7 +48137,7 @@ Added documentation for @code{libmysqld}, the embedded MySQL server
library. Also added example programs (a @code{mysql} client and library. Also added example programs (a @code{mysql} client and
@code{mysqltest} test program) which use @code{libmysqld}. @code{mysqltest} test program) which use @code{libmysqld}.
@item @item
Removed all Gemini hooks from MySQL. Removed all Gemini hooks from MySQL server.
@item @item
Removed @code{my_thread_init()} and @code{my_thread_end()} Removed @code{my_thread_init()} and @code{my_thread_end()}
from mysql_com.h, and added @code{mysql_thread_init()} and from mysql_com.h, and added @code{mysql_thread_init()} and
...@@ -170,6 +170,11 @@ FTP (@uref{ftp://ftp.dn.ru/pub/MySQL/}) ...@@ -170,6 +170,11 @@ FTP (@uref{ftp://ftp.dn.ru/pub/MySQL/})
@image{Flags/russia} Russia [Scientific Center/Chernogolovka] @@ @image{Flags/russia} Russia [Scientific Center/Chernogolovka] @@
FTP (@uref{ftp://ftp.chg.ru/pub/databases/mysql/}) FTP (@uref{ftp://ftp.chg.ru/pub/databases/mysql/})
@item
@image{Flags/slovenia} Slovenia [ARNES] @@
WWW (@uref{http://ftp.arnes.si/mysql/})
FTP (@uref{ftp://ftp.arnes.si/packages/mysql/})
@item @item
@image{Flags/spain} Spain [GMC Control Systems] @@ @image{Flags/spain} Spain [GMC Control Systems] @@
WWW (@uref{http://mysql.neptuno2000.com/}) WWW (@uref{http://mysql.neptuno2000.com/})
...@@ -317,6 +322,7 @@ FTP (@uref{ftp://ftp.shellhung.org/pub/Mirror/mysql/}) ...@@ -317,6 +322,7 @@ FTP (@uref{ftp://ftp.shellhung.org/pub/Mirror/mysql/})
@item @item
@image{Flags/indonesia} Indonesia [incaf.net] @@ @image{Flags/indonesia} Indonesia [incaf.net] @@
WWW (@uref{http://mysql.incaf.net/}) WWW (@uref{http://mysql.incaf.net/})
FTP (@uref{ftp://mysql.incaf.net/})
@item @item
@image{Flags/indonesia} Indonesia [web.id] @@ @image{Flags/indonesia} Indonesia [web.id] @@
...@@ -341,7 +347,7 @@ WWW (@uref{http://mysql.hjc.edu.sg/}) ...@@ -341,7 +347,7 @@ WWW (@uref{http://mysql.hjc.edu.sg/})
FTP (@uref{ftp://ftp.hjc.edu.sg/mysql/}) FTP (@uref{ftp://ftp.hjc.edu.sg/mysql/})
@item @item
@image{Flags/south-korea} South Korea [PanworldNet] @@ @image{Flags/south-korea} South Korea [HolyNet] @@
WWW (@uref{http://mysql.holywar.net/}) WWW (@uref{http://mysql.holywar.net/})
@item @item
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
** and adapted to mysqldump 05/11/01 by Jani Tolonen ** and adapted to mysqldump 05/11/01 by Jani Tolonen
*/ */
#define DUMP_VERSION "8.20" #define DUMP_VERSION "8.21"
#include <my_global.h> #include <my_global.h>
#include <my_sys.h> #include <my_sys.h>
...@@ -309,7 +309,7 @@ static int get_options(int *argc,char ***argv) ...@@ -309,7 +309,7 @@ static int get_options(int *argc,char ***argv)
load_defaults("my",load_default_groups,argc,argv); load_defaults("my",load_default_groups,argc,argv);
set_all_changeable_vars(md_changeable_vars); set_all_changeable_vars(md_changeable_vars);
while ((c=getopt_long(*argc,*argv, while ((c=getopt_long(*argc,*argv,
"#::p::h:u:O:P:r:S:T:EBaAcCdefFKlnqtvVw:?IxX", "#::p::h:u:O:P:r:S:T:EBaAcCdefFKlnqQtvVw:?IxX",
long_options, &option_index)) != EOF) long_options, &option_index)) != EOF)
{ {
switch(c) { switch(c) {
......
...@@ -56,7 +56,19 @@ enum ha_rkey_function { ...@@ -56,7 +56,19 @@ enum ha_rkey_function {
HA_READ_AFTER_KEY, /* Find next rec. after key-record */ HA_READ_AFTER_KEY, /* Find next rec. after key-record */
HA_READ_BEFORE_KEY, /* Find next rec. before key-record */ HA_READ_BEFORE_KEY, /* Find next rec. before key-record */
HA_READ_PREFIX, /* Key which as same prefix */ HA_READ_PREFIX, /* Key which as same prefix */
HA_READ_PREFIX_LAST /* Last key with the same prefix */ HA_READ_PREFIX_LAST, /* Last key with the same prefix */
HA_READ_MBR_CONTAIN,
HA_READ_MBR_INTERSECT,
HA_READ_MBR_WITHIN,
HA_READ_MBR_DISJOINT,
HA_READ_MBR_EQUAL
};
/* Key algorithm types */
enum ha_key_alg {
HA_KEY_ALG_BTREE=0, /* B-tree, default one */
HA_KEY_ALG_RTREE=1 /* R-tree, for spatial searches */
}; };
/* The following is parameter to ha_extra() */ /* The following is parameter to ha_extra() */
...@@ -136,6 +148,8 @@ enum ha_base_keytype { ...@@ -136,6 +148,8 @@ enum ha_base_keytype {
#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */ #define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
#define HA_FULLTEXT 128 /* SerG: for full-text search */ #define HA_FULLTEXT 128 /* SerG: for full-text search */
#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */ #define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
#define HA_SPATIAL 1024 /* Alex Barkov: for spatial search */
/* Automatic bits in key-flag */ /* Automatic bits in key-flag */
...@@ -239,6 +253,12 @@ enum ha_base_keytype { ...@@ -239,6 +253,12 @@ enum ha_base_keytype {
#define SEARCH_UPDATE 64 #define SEARCH_UPDATE 64
#define SEARCH_PREFIX 128 #define SEARCH_PREFIX 128
#define SEARCH_LAST 256 #define SEARCH_LAST 256
#define MBR_CONTAIN 512
#define MBR_INTERSECT 1024
#define MBR_WITHIN 2048
#define MBR_DISJOINT 4096
#define MBR_EQUAL 8192
#define MBR_DATA 16384
/* bits in opt_flag */ /* bits in opt_flag */
#define QUICK_USED 1 #define QUICK_USED 1
......
...@@ -126,6 +126,7 @@ typedef struct st_mi_keydef /* Key definition with open & info */ ...@@ -126,6 +126,7 @@ typedef struct st_mi_keydef /* Key definition with open & info */
uint16 keysegs; /* Number of key-segment */ uint16 keysegs; /* Number of key-segment */
uint16 flag; /* NOSAME, PACK_USED */ uint16 flag; /* NOSAME, PACK_USED */
uint8 key_alg; /* BTREE, RTREE */
uint16 block_length; /* Length of keyblock (auto) */ uint16 block_length; /* Length of keyblock (auto) */
uint16 underflow_block_length; /* When to execute underflow */ uint16 underflow_block_length; /* When to execute underflow */
uint16 keylength; /* Tot length of keyparts (auto) */ uint16 keylength; /* Tot length of keyparts (auto) */
......
...@@ -150,7 +150,8 @@ enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY, ...@@ -150,7 +150,8 @@ enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
FIELD_TYPE_LONG_BLOB=251, FIELD_TYPE_LONG_BLOB=251,
FIELD_TYPE_BLOB=252, FIELD_TYPE_BLOB=252,
FIELD_TYPE_VAR_STRING=253, FIELD_TYPE_VAR_STRING=253,
FIELD_TYPE_STRING=254 FIELD_TYPE_STRING=254,
FIELD_TYPE_GEOMETRY=255
}; };
#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */ #define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */
......
...@@ -2,33 +2,95 @@ LIBRARY LIBMYSQL ...@@ -2,33 +2,95 @@ LIBRARY LIBMYSQL
DESCRIPTION 'MySQL 4.0 Client Library' DESCRIPTION 'MySQL 4.0 Client Library'
VERSION 4.0 VERSION 4.0
EXPORTS EXPORTS
mysql_affected_rows
mysql_num_rows mysql_close
mysql_num_fields mysql_connect
mysql_create_db
mysql_data_seek
mysql_debug
mysql_drop_db
mysql_dump_debug_info
mysql_eof mysql_eof
mysql_errno
mysql_error
mysql_escape_string
mysql_fetch_field
mysql_fetch_field_direct mysql_fetch_field_direct
mysql_fetch_fields mysql_fetch_fields
mysql_row_tell mysql_fetch_lengths
mysql_field_tell mysql_fetch_row
mysql_field_count mysql_field_count
mysql_affected_rows mysql_field_seek
mysql_insert_id mysql_field_tell
mysql_errno mysql_free_result
mysql_error mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_get_server_info
mysql_info mysql_info
mysql_thread_id
mysql_character_set_name
mysql_init mysql_init
mysql_ssl_set mysql_insert_id
mysql_ssl_clear mysql_kill
mysql_change_user mysql_list_dbs
mysql_list_fields
mysql_list_processes
mysql_list_tables
mysql_num_fields
mysql_num_rows
mysql_odbc_escape_string
mysql_options
mysql_ping
mysql_query
mysql_real_connect mysql_real_connect
mysql_close mysql_real_query
mysql_refresh
mysql_row_seek
mysql_row_tell
mysql_select_db mysql_select_db
mysql_query mysql_shutdown
mysql_stat
mysql_store_result
mysql_thread_id
mysql_use_result
bmove_upp
delete_dynamic
_dig_vec
init_dynamic_array
insert_dynamic
int2str
is_prefix
list_add
list_delete
max_allowed_packet
my_casecmp
my_init
my_end
my_strdup
my_malloc
my_memdup
my_no_flags_free
my_realloc
my_thread_end
my_thread_init
net_buffer_length
set_dynamic
strcend
strdup_root
strfill
strinstr
strmake
strmov
strxmov
myodbc_remove_escape
mysql_thread_safe
mysql_character_set_name
mysql_change_user
mysql_send_query mysql_send_query
mysql_read_query_result mysql_read_query_result
mysql_real_query mysql_real_escape_string
mysql_ssl_set
mysql_ssl_clear
mysql_real_connect
mysql_master_query mysql_master_query
mysql_master_send_query mysql_master_send_query
mysql_slave_query mysql_slave_query
...@@ -43,34 +105,18 @@ EXPORTS ...@@ -43,34 +105,18 @@ EXPORTS
mysql_rpl_probe mysql_rpl_probe
mysql_set_master mysql_set_master
mysql_add_slave mysql_add_slave
mysql_shutdown
mysql_dump_debug_info
mysql_refresh
mysql_kill
mysql_ping
mysql_stat
mysql_get_server_info
mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_list_dbs
mysql_list_tables
mysql_list_fields
mysql_list_processes
mysql_store_result
mysql_use_result
mysql_options
mysql_free_result
mysql_data_seek
mysql_row_seek
mysql_field_seek
mysql_fetch_row
mysql_fetch_lengths
mysql_fetch_field
mysql_escape_string
mysql_real_escape_string
mysql_debug
mysql_odbc_escape_string
myodbc_remove_escape
mysql_thread_safe
...@@ -36,4 +36,9 @@ mysql_load(THD * thd, sql_exchange * ex, TABLE_LIST * table_list, ...@@ -36,4 +36,9 @@ mysql_load(THD * thd, sql_exchange * ex, TABLE_LIST * table_list,
#define mysql_load mysql_load_internal #define mysql_load mysql_load_internal
#if defined (__WIN__)
#include "../sql/sql_load.cpp"
#else
#include "../sql/sql_load.cc" #include "../sql/sql_load.cc"
#endif
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#define main main1 #define main main1
#define mysql_unix_port mysql_inix_port1 #define mysql_unix_port mysql_inix_port1
#define mysql_port mysql_port1 #define mysql_port mysql_port1
#if !defined(__WIN__)
#define net_read_timeout net_read_timeout1 #define net_read_timeout net_read_timeout1
#define net_write_timeout net_write_timeout1 #define net_write_timeout net_write_timeout1
#endif
#define changeable_vars changeable_vars1 #define changeable_vars changeable_vars1
extern "C" extern "C"
...@@ -45,7 +47,11 @@ static bool check_user(THD *thd, enum_server_command command, ...@@ -45,7 +47,11 @@ static bool check_user(THD *thd, enum_server_command command,
void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);} void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);}
#define free_defaults free_defaults_internal #define free_defaults free_defaults_internal
#if defined (__WIN__)
#include "../sql/mysqld.cpp"
#else
#include "../sql/mysqld.cc" #include "../sql/mysqld.cc"
#endif
#define SCRAMBLE_LENGTH 8 #define SCRAMBLE_LENGTH 8
C_MODE_START C_MODE_START
......
LIBRARY LIBMYSQLD
DESCRIPTION 'MySQL 4.0 Embedded Server Library'
VERSION 4.0
EXPORTS
mysql_server_end
mysql_server_init
mysql_use_result
mysql_thread_safe
mysql_thread_id
mysql_store_result
mysql_stat
mysql_shutdown
mysql_select_db
mysql_row_tell
mysql_row_seek
mysql_real_query
mysql_real_connect
mysql_query
mysql_ping
mysql_options
mysql_num_rows
mysql_num_fields
mysql_list_tables
mysql_list_processes
mysql_list_fields
mysql_list_dbs
mysql_kill
mysql_insert_id
mysql_init
mysql_info
mysql_get_server_info
mysql_get_proto_info
mysql_get_host_info
mysql_get_client_info
mysql_free_result
mysql_field_tell
mysql_field_count
mysql_field_seek
mysql_fetch_row
mysql_fetch_lengths
mysql_fetch_fields
mysql_fetch_field_direct
mysql_fetch_field
mysql_escape_string
mysql_real_escape_string
mysql_error
mysql_errno
mysql_eof
mysql_dump_debug_info
mysql_drop_db
mysql_debug
mysql_data_seek
mysql_create_db
mysql_character_set_name
mysql_change_user
mysql_connect
mysql_close
mysql_affected_rows
mysql_thread_init
mysql_thread_end
mysql_send_query
mysql_read_query_result
mysql_refresh
mysql_odbc_escape_string
myodbc_remove_escape
...@@ -33,7 +33,7 @@ static uint lengths[256]; ...@@ -33,7 +33,7 @@ static uint lengths[256];
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
int error=0; int error=0;
uint keylen, keylen2, inx, doc_cnt=0; uint keylen, keylen2=0, inx, doc_cnt=0;
float weight; float weight;
double gws, min_gws=0, avg_gws=0; double gws, min_gws=0, avg_gws=0;
MI_INFO *info; MI_INFO *info;
...@@ -151,7 +151,7 @@ int main(int argc,char *argv[]) ...@@ -151,7 +151,7 @@ int main(int argc,char *argv[])
for (inx=0;inx<256;inx++) for (inx=0;inx<256;inx++)
{ {
count+=lengths[inx]; count+=lengths[inx];
if (count >= total/2) if ((ulong) count >= total/2)
break; break;
} }
printf("Total rows: %qu\nTotal words: %lu\n" printf("Total rows: %qu\nTotal words: %lu\n"
...@@ -170,7 +170,8 @@ int main(int argc,char *argv[]) ...@@ -170,7 +170,8 @@ int main(int argc,char *argv[])
count+=lengths[inx]; count+=lengths[inx];
if (count && lengths[inx]) if (count && lengths[inx])
printf("%3u: %10lu %5.2f%% %20lu %4.1f%%\n", inx, printf("%3u: %10lu %5.2f%% %20lu %4.1f%%\n", inx,
lengths[inx],100.0*lengths[inx]/total,count, 100.0*count/total); (ulong) lengths[inx],100.0*lengths[inx]/total,(ulong) count,
100.0*count/total);
} }
} }
} }
......
...@@ -179,8 +179,6 @@ create table t2 (a text not null); ...@@ -179,8 +179,6 @@ create table t2 (a text not null);
create table t21 (a text not null); create table t21 (a text not null);
create table t3 (a text not null); create table t3 (a text not null);
insert into t1 values("1111111111111111111111111111111111111111111111111111"); insert into t1 values("1111111111111111111111111111111111111111111111111111");
insert into t11 select * from t1;
insert into t21 select * from t1;
insert into t2 select * from t1; insert into t2 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
...@@ -196,6 +194,8 @@ insert into t1 select * from t2; ...@@ -196,6 +194,8 @@ insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
insert into t11 select * from t1;
insert into t21 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
......
...@@ -93,8 +93,6 @@ create table t2 (a text not null); ...@@ -93,8 +93,6 @@ create table t2 (a text not null);
create table t21 (a text not null); create table t21 (a text not null);
create table t3 (a text not null); create table t3 (a text not null);
insert into t1 values("1111111111111111111111111111111111111111111111111111"); insert into t1 values("1111111111111111111111111111111111111111111111111111");
insert into t11 select * from t1;
insert into t21 select * from t1;
insert into t2 select * from t1; insert into t2 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
...@@ -110,6 +108,9 @@ insert into t1 select * from t2; ...@@ -110,6 +108,9 @@ insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
# t11 and t21 must be over 4Kb (QUERY_CACHE_MIN_RESULT_DATA_SIZE)
insert into t11 select * from t1;
insert into t21 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
insert into t2 select * from t1; insert into t2 select * from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
......
...@@ -177,7 +177,7 @@ uint calc_hashnr_caseup(const byte *key, uint len) ...@@ -177,7 +177,7 @@ uint calc_hashnr_caseup(const byte *key, uint len)
#endif #endif
#ifndef _FORTREC_ #ifndef __SUNPRO_C /* SUNPRO can't handle this */
inline inline
#endif #endif
uint rec_hashnr(HASH *hash,const byte *record) uint rec_hashnr(HASH *hash,const byte *record)
......
...@@ -380,10 +380,12 @@ enum db_type default_table_type=DB_TYPE_MYISAM; ...@@ -380,10 +380,12 @@ enum db_type default_table_type=DB_TYPE_MYISAM;
#ifdef __WIN__ #ifdef __WIN__
#undef getpid #undef getpid
#include <process.h> #include <process.h>
#if !defined(EMBEDDED_LIBRARY)
HANDLE hEventShutdown; HANDLE hEventShutdown;
#include "nt_servc.h" #include "nt_servc.h"
static NTService Service; // Service object for WinNT static NTService Service; // Service object for WinNT
#endif #endif
#endif
#ifdef OS2 #ifdef OS2
pthread_cond_t eventShutdown; pthread_cond_t eventShutdown;
...@@ -609,6 +611,7 @@ void kill_mysql(void) ...@@ -609,6 +611,7 @@ void kill_mysql(void)
#endif #endif
#if defined(__WIN__) #if defined(__WIN__)
#if !defined(EMBEDDED_LIBRARY)
{ {
if (!SetEvent(hEventShutdown)) if (!SetEvent(hEventShutdown))
{ {
...@@ -621,6 +624,7 @@ void kill_mysql(void) ...@@ -621,6 +624,7 @@ void kill_mysql(void)
CloseHandle(hEvent); CloseHandle(hEvent);
*/ */
} }
#endif
#elif defined(OS2) #elif defined(OS2)
pthread_cond_signal( &eventShutdown); // post semaphore pthread_cond_signal( &eventShutdown); // post semaphore
#elif defined(HAVE_PTHREAD_KILL) #elif defined(HAVE_PTHREAD_KILL)
...@@ -1558,8 +1562,9 @@ pthread_handler_decl(handle_shutdown,arg) ...@@ -1558,8 +1562,9 @@ pthread_handler_decl(handle_shutdown,arg)
/* this call should create the message queue for this thread */ /* this call should create the message queue for this thread */
PeekMessage(&msg, NULL, 1, 65534,PM_NOREMOVE); PeekMessage(&msg, NULL, 1, 65534,PM_NOREMOVE);
#if !defined(EMBEDDED_LIBRARY)
if (WaitForSingleObject(hEventShutdown,INFINITE)==WAIT_OBJECT_0) if (WaitForSingleObject(hEventShutdown,INFINITE)==WAIT_OBJECT_0)
#endif
kill_server(MYSQL_KILL_SIGNAL); kill_server(MYSQL_KILL_SIGNAL);
return 0; return 0;
} }
...@@ -1976,7 +1981,7 @@ The server will not act as a slave."); ...@@ -1976,7 +1981,7 @@ The server will not act as a slave.");
} }
} }
(void) thr_setconcurrency(concurrency); // 10 by default (void) thr_setconcurrency(concurrency); // 10 by default
#ifdef __WIN__ //IRENA #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) //IRENA
{ {
hEventShutdown=CreateEvent(0, FALSE, FALSE, "MySqlShutdown"); hEventShutdown=CreateEvent(0, FALSE, FALSE, "MySqlShutdown");
pthread_t hThread; pthread_t hThread;
...@@ -2084,6 +2089,7 @@ The server will not act as a slave."); ...@@ -2084,6 +2089,7 @@ The server will not act as a slave.");
sql_print_error("After lock_thread_count"); sql_print_error("After lock_thread_count");
#endif #endif
#else #else
#if !defined(EMBEDDED_LIBRARY)
if (Service.IsNT()) if (Service.IsNT())
{ {
if(start_mode) if(start_mode)
...@@ -2103,6 +2109,7 @@ The server will not act as a slave."); ...@@ -2103,6 +2109,7 @@ The server will not act as a slave.");
if(hEventShutdown) CloseHandle(hEventShutdown); if(hEventShutdown) CloseHandle(hEventShutdown);
} }
#endif #endif
#endif
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
my_free((gptr)ssl_acceptor_fd,MYF(MY_ALLOW_ZERO_PTR)); my_free((gptr)ssl_acceptor_fd,MYF(MY_ALLOW_ZERO_PTR));
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
...@@ -2123,7 +2130,7 @@ The server will not act as a slave."); ...@@ -2123,7 +2130,7 @@ The server will not act as a slave.");
} }
#ifdef __WIN__ #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
main and thread entry function for Win32 main and thread entry function for Win32
(all this is needed only to run mysqld as a service on WinNT) (all this is needed only to run mysqld as a service on WinNT)
......
...@@ -54,32 +54,32 @@ ...@@ -54,32 +54,32 @@
ulong max_allowed_packet=65536; ulong max_allowed_packet=65536;
extern ulong net_read_timeout,net_write_timeout; extern ulong net_read_timeout,net_write_timeout;
extern uint test_flags; extern uint test_flags;
#define USE_QUERY_CACHE
extern void query_cache_insert(NET *net, const char *packet, ulong length);
#else #else
ulong max_allowed_packet=16*1024*1024L; ulong max_allowed_packet=16*1024*1024L;
ulong net_read_timeout= NET_READ_TIMEOUT; ulong net_read_timeout= NET_READ_TIMEOUT;
ulong net_write_timeout= NET_WRITE_TIMEOUT; ulong net_write_timeout= NET_WRITE_TIMEOUT;
#endif #endif
#ifdef __WIN__ #if defined(__WIN__) || !defined(MYSQL_SERVER)
/* The following is because alarms doesn't work on windows. */ /* The following is because alarms doesn't work on windows. */
#undef MYSQL_SERVER #define NO_ALARM
#endif #endif
#ifdef MYSQL_SERVER #ifndef NO_ALARM
#include "my_pthread.h" #include "my_pthread.h"
void sql_print_error(const char *format,...); void sql_print_error(const char *format,...);
#define RETRY_COUNT mysqld_net_retry_count #define RETRY_COUNT mysqld_net_retry_count
extern ulong mysqld_net_retry_count; extern ulong mysqld_net_retry_count;
extern ulong bytes_sent, bytes_received; extern ulong bytes_sent, bytes_received;
extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received; extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
extern void query_cache_insert(NET *net, const char *packet, ulong length);
#else #else
#undef statistic_add #undef statistic_add
#define statistic_add(A,B,C) #define statistic_add(A,B,C)
#define DONT_USE_THR_ALARM #define DONT_USE_THR_ALARM
#define RETRY_COUNT 1 #define RETRY_COUNT 1
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
#include "thr_alarm.h" #include "thr_alarm.h"
...@@ -322,7 +322,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -322,7 +322,7 @@ net_real_write(NET *net,const char *packet,ulong len)
long int length; long int length;
char *pos,*end; char *pos,*end;
thr_alarm_t alarmed; thr_alarm_t alarmed;
#if defined(MYSQL_SERVER) #ifndef NO_ALARM
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
uint retry_count=0; uint retry_count=0;
...@@ -371,13 +371,13 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -371,13 +371,13 @@ net_real_write(NET *net,const char *packet,ulong len)
#endif /* HAVE_COMPRESS */ #endif /* HAVE_COMPRESS */
/* DBUG_DUMP("net",packet,len); */ /* DBUG_DUMP("net",packet,len); */
#ifdef MYSQL_SERVER #ifndef NO_ALARM
thr_alarm_init(&alarmed); thr_alarm_init(&alarmed);
if (net_blocking) if (net_blocking)
thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff); thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff);
#else #else
alarmed=0; alarmed=0;
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
pos=(char*) packet; end=pos+len; pos=(char*) packet; end=pos+len;
while (pos != end) while (pos != end)
...@@ -459,8 +459,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -459,8 +459,7 @@ net_real_write(NET *net,const char *packet,ulong len)
** Read something from server/clinet ** Read something from server/clinet
*****************************************************************************/ *****************************************************************************/
#ifdef MYSQL_SERVER #ifndef NO_ALARM
/* /*
Help function to clear the commuication buffer when we get a too Help function to clear the commuication buffer when we get a too
big packet big packet
...@@ -493,7 +492,7 @@ static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed) ...@@ -493,7 +492,7 @@ static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed)
statistic_add(bytes_received,length,&LOCK_bytes_received); statistic_add(bytes_received,length,&LOCK_bytes_received);
} }
} }
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
/* /*
...@@ -510,7 +509,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -510,7 +509,7 @@ my_real_read(NET *net, ulong *complen)
uint i,retry_count=0; uint i,retry_count=0;
ulong len=packet_error; ulong len=packet_error;
thr_alarm_t alarmed; thr_alarm_t alarmed;
#if defined(MYSQL_SERVER) #ifndef NO_ALARM
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
my_bool net_blocking=vio_is_blocking(net->vio); my_bool net_blocking=vio_is_blocking(net->vio);
...@@ -520,10 +519,10 @@ my_real_read(NET *net, ulong *complen) ...@@ -520,10 +519,10 @@ my_real_read(NET *net, ulong *complen)
net->reading_or_writing=1; net->reading_or_writing=1;
thr_alarm_init(&alarmed); thr_alarm_init(&alarmed);
#ifdef MYSQL_SERVER #ifndef NO_ALARM
if (net_blocking) if (net_blocking)
thr_alarm(&alarmed,net->timeout,&alarm_buff); thr_alarm(&alarmed,net->timeout,&alarm_buff);
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
pos = net->buff + net->where_b; /* net->packet -4 */ pos = net->buff + net->where_b; /* net->packet -4 */
for (i=0 ; i < 2 ; i++) for (i=0 ; i < 2 ; i++)
...@@ -646,7 +645,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -646,7 +645,7 @@ my_real_read(NET *net, ulong *complen)
{ {
if (net_realloc(net,helping)) if (net_realloc(net,helping))
{ {
#ifdef MYSQL_SERVER #ifndef NO_ALARM
if (i == 1) if (i == 1)
my_net_skip_rest(net, (uint32) len, &alarmed); my_net_skip_rest(net, (uint32) len, &alarmed);
#endif #endif
......
This diff is collapsed.
...@@ -25,14 +25,22 @@ ...@@ -25,14 +25,22 @@
if QUERY_CACHE_MIN_ALLOCATION_UNIT == 0 then if QUERY_CACHE_MIN_ALLOCATION_UNIT == 0 then
QUERY_CACHE_MIN_ALLOCATION_UNIT choosed automaticaly QUERY_CACHE_MIN_ALLOCATION_UNIT choosed automaticaly
*/ */
#define QUERY_CACHE_MIN_ALLOCATION_UNIT 0 #define QUERY_CACHE_MIN_ALLOCATION_UNIT 512
/* inittial size of hashes */ /* inittial size of hashes */
#define QUERY_CACHE_DEF_QUERY_HASH_SIZE 1024 #define QUERY_CACHE_DEF_QUERY_HASH_SIZE 1024
#define QUERY_CACHE_DEF_TABLE_HASH_SIZE 1024 #define QUERY_CACHE_DEF_TABLE_HASH_SIZE 1024
/* minimal result data size when data allocated */ /* minimal result data size when data allocated */
#define QUERY_CACHE_MIN_RESULT_DATA_SIZE 1024 #define QUERY_CACHE_MIN_RESULT_DATA_SIZE 1024*4
/*
start estimation of first result block size only when number of queries
bigger then:
*/
#define QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER 3
/* memory bins size spacing (see at Query_cache::init_cache (sql_cache.cc)) */ /* memory bins size spacing (see at Query_cache::init_cache (sql_cache.cc)) */
#define QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2 4 #define QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2 4
...@@ -234,8 +242,7 @@ protected: ...@@ -234,8 +242,7 @@ protected:
query structure we locked an internal query block mutex. query structure we locked an internal query block mutex.
LOCK SEQUENCE (to prevent deadlocks): LOCK SEQUENCE (to prevent deadlocks):
1. structure_guard_mutex 1. structure_guard_mutex
2. query block / table block / free block 2. query block (for operation inside query (query block/results))
3. results blocks (only when must become free).
*/ */
pthread_mutex_t structure_guard_mutex; pthread_mutex_t structure_guard_mutex;
byte *cache; // cache memory byte *cache; // cache memory
...@@ -271,7 +278,8 @@ protected: ...@@ -271,7 +278,8 @@ protected:
void free_query(Query_cache_block *point); void free_query(Query_cache_block *point);
my_bool allocate_data_chain(Query_cache_block **result_block, my_bool allocate_data_chain(Query_cache_block **result_block,
ulong data_len, ulong data_len,
Query_cache_block *query_block); Query_cache_block *query_block,
my_bool first_block);
void invalidate_table(TABLE_LIST *table); void invalidate_table(TABLE_LIST *table);
void invalidate_table(TABLE *table); void invalidate_table(TABLE *table);
void invalidate_table(Query_cache_block *table_block); void invalidate_table(Query_cache_block *table_block);
...@@ -328,6 +336,8 @@ protected: ...@@ -328,6 +336,8 @@ protected:
Query_cache_block *parent, Query_cache_block *parent,
Query_cache_block::block_type Query_cache_block::block_type
type=Query_cache_block::RESULT); type=Query_cache_block::RESULT);
inline ulong get_min_first_result_data_size();
inline ulong get_min_append_result_data_size();
Query_cache_block *allocate_block(ulong len, my_bool not_less, Query_cache_block *allocate_block(ulong len, my_bool not_less,
ulong min, ulong min,
my_bool under_guard=0); my_bool under_guard=0);
...@@ -394,6 +404,9 @@ protected: ...@@ -394,6 +404,9 @@ protected:
my_bool check_integrity(bool not_locked); my_bool check_integrity(bool not_locked);
my_bool in_list(Query_cache_block * root, Query_cache_block * point, my_bool in_list(Query_cache_block * root, Query_cache_block * point,
const char *name); const char *name);
my_bool in_table_list(Query_cache_block_table * root,
Query_cache_block_table * point,
const char *name);
my_bool in_blocks(Query_cache_block * point); my_bool in_blocks(Query_cache_block * point);
}; };
......
...@@ -656,7 +656,7 @@ public: ...@@ -656,7 +656,7 @@ public:
uint num_of_tables; uint num_of_tables;
int error; int error;
thr_lock_type lock_option; thr_lock_type lock_option;
bool do_delete; bool do_delete, not_trans_safe;
public: public:
multi_delete(THD *thd, TABLE_LIST *dt, thr_lock_type lock_option_arg, multi_delete(THD *thd, TABLE_LIST *dt, thr_lock_type lock_option_arg,
uint num_of_tables); uint num_of_tables);
......
...@@ -216,6 +216,7 @@ multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, ...@@ -216,6 +216,7 @@ multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt,
do_delete(false) do_delete(false)
{ {
uint counter=0; uint counter=0;
not_trans_safe=false;
tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables-1)); tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables-1));
(void) dt->table->file->extra(HA_EXTRA_NO_READCHECK); (void) dt->table->file->extra(HA_EXTRA_NO_READCHECK);
...@@ -225,8 +226,9 @@ multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, ...@@ -225,8 +226,9 @@ multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt,
for (dt=dt->next ; dt ; dt=dt->next,counter++) for (dt=dt->next ; dt ; dt=dt->next,counter++)
{ {
TABLE *table=dt->table; TABLE *table=dt->table;
(void) dt->table->file->extra(HA_EXTRA_NO_READCHECK); (void) table->file->extra(HA_EXTRA_NO_READCHECK);
(void) dt->table->file->extra(HA_EXTRA_NO_KEYREAD); (void) table->file->extra(HA_EXTRA_NO_KEYREAD);
table->used_keys=0;
tempfiles[counter] = new Unique (refposcmp2, tempfiles[counter] = new Unique (refposcmp2,
(void *) &table->file->ref_length, (void *) &table->file->ref_length,
table->file->ref_length, table->file->ref_length,
...@@ -279,8 +281,11 @@ multi_delete::initialize_tables(JOIN *join) ...@@ -279,8 +281,11 @@ multi_delete::initialize_tables(JOIN *join)
walk=walk->next; walk=walk->next;
if (tab == join->join_tab) if (tab == join->join_tab)
tab->table->no_keyread=1; tab->table->no_keyread=1;
if (!not_trans_safe && !tab->table->file->has_transactions())
not_trans_safe=true;
} }
} }
init_ftfuncs(thd,1);
} }
...@@ -290,7 +295,11 @@ multi_delete::~multi_delete() ...@@ -290,7 +295,11 @@ multi_delete::~multi_delete()
for (table_being_deleted=delete_tables ; for (table_being_deleted=delete_tables ;
table_being_deleted ; table_being_deleted ;
table_being_deleted=table_being_deleted->next) table_being_deleted=table_being_deleted->next)
(void) table_being_deleted->table->file->extra(HA_EXTRA_READCHECK); {
TABLE *t=table_being_deleted->table;
(void) t->file->extra(HA_EXTRA_READCHECK);
t->no_keyread=0;
}
for (uint counter = 0; counter < num_of_tables-1; counter++) for (uint counter = 0; counter < num_of_tables-1; counter++)
{ {
...@@ -339,28 +348,13 @@ bool multi_delete::send_data(List<Item> &values) ...@@ -339,28 +348,13 @@ bool multi_delete::send_data(List<Item> &values)
return 0; return 0;
} }
/* Return true if some table is not transaction safe */
static bool some_table_is_not_transaction_safe (TABLE_LIST *tl)
{
for (; tl ; tl=tl->next)
{
if (!(tl->table->file->has_transactions()))
return true;
}
return false;
}
void multi_delete::send_error(uint errcode,const char *err) void multi_delete::send_error(uint errcode,const char *err)
{ {
/* First send error what ever it is ... */ /* First send error what ever it is ... */
::send_error(&thd->net,errcode,err); ::send_error(&thd->net,errcode,err);
/* reset used flags */ /* reset used flags */
delete_tables->table->no_keyread=0; // delete_tables->table->no_keyread=0;
/* If nothing deleted return */ /* If nothing deleted return */
if (!deleted) if (!deleted)
...@@ -376,8 +370,7 @@ void multi_delete::send_error(uint errcode,const char *err) ...@@ -376,8 +370,7 @@ void multi_delete::send_error(uint errcode,const char *err)
In all other cases do attempt deletes ... In all other cases do attempt deletes ...
*/ */
if ((table_being_deleted->table->file->has_transactions() && if ((table_being_deleted->table->file->has_transactions() &&
table_being_deleted == delete_tables) || table_being_deleted == delete_tables) || !not_trans_safe)
!some_table_is_not_transaction_safe(delete_tables->next))
ha_rollback_stmt(thd); ha_rollback_stmt(thd);
else if (do_delete) else if (do_delete)
VOID(do_deletes(true)); VOID(do_deletes(true));
...@@ -441,7 +434,6 @@ int multi_delete::do_deletes (bool from_send_error) ...@@ -441,7 +434,6 @@ int multi_delete::do_deletes (bool from_send_error)
READ_RECORD info; READ_RECORD info;
init_read_record(&info,thd,table,NULL,0,0); init_read_record(&info,thd,table,NULL,0,0);
bool not_trans_safe = some_table_is_not_transaction_safe(delete_tables);
while (!(error=info.read_record(&info)) && while (!(error=info.read_record(&info)) &&
(!thd->killed || from_send_error || not_trans_safe)) (!thd->killed || from_send_error || not_trans_safe))
{ {
...@@ -468,7 +460,7 @@ bool multi_delete::send_eof() ...@@ -468,7 +460,7 @@ bool multi_delete::send_eof()
int error = do_deletes(false); /* do_deletes returns 0 if success */ int error = do_deletes(false); /* do_deletes returns 0 if success */
/* reset used flags */ /* reset used flags */
delete_tables->table->no_keyread=0; // delete_tables->table->no_keyread=0; // Will stay in comment until Monty approves changes
thd->proc_info="end"; thd->proc_info="end";
if (error) if (error)
{ {
...@@ -481,20 +473,21 @@ bool multi_delete::send_eof() ...@@ -481,20 +473,21 @@ bool multi_delete::send_eof()
was a non-transaction-safe table involved, since was a non-transaction-safe table involved, since
modifications in it cannot be rolled back. */ modifications in it cannot be rolled back. */
if (deleted || some_table_is_not_transaction_safe(delete_tables)) if (deleted || not_trans_safe)
{ {
mysql_update_log.write(thd,thd->query,thd->query_length); mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query); Query_log_event qinfo(thd, thd->query);
if (mysql_bin_log.write(&qinfo) && if (mysql_bin_log.write(&qinfo) &&
!some_table_is_not_transaction_safe(delete_tables)) !not_trans_safe)
error=1; // Log write failed: roll back the SQL statement error=1; // Log write failed: roll back the SQL statement
} }
/* Commit or rollback the current SQL statement */ /* Commit or rollback the current SQL statement */
VOID(ha_autocommit_or_rollback(thd,error > 0)); VOID(ha_autocommit_or_rollback(thd,error > 0));
} }
if (deleted)
query_cache.invalidate(delete_tables);
::send_ok(&thd->net,deleted); ::send_ok(&thd->net,deleted);
return 0; return 0;
} }
......
...@@ -1328,7 +1328,7 @@ void select_insert::send_error(uint errcode,const char *err) ...@@ -1328,7 +1328,7 @@ void select_insert::send_error(uint errcode,const char *err)
::send_error(&thd->net,errcode,err); ::send_error(&thd->net,errcode,err);
table->file->extra(HA_EXTRA_NO_CACHE); table->file->extra(HA_EXTRA_NO_CACHE);
table->file->activate_all_index(thd); table->file->activate_all_index(thd);
ha_rollback(thd); ha_rollback_stmt(thd);
if (info.copied || info.deleted) if (info.copied || info.deleted)
query_cache.invalidate(table); query_cache.invalidate(table);
} }
......
...@@ -1216,7 +1216,6 @@ mysql_execute_command(void) ...@@ -1216,7 +1216,6 @@ mysql_execute_command(void)
#endif #endif
} }
thread_safe_increment(com_stat[lex->sql_command],&LOCK_thread_count);
/* /*
Skip if we are in the slave thread, some table rules have been given Skip if we are in the slave thread, some table rules have been given
and the table list says the query should not be replicated and the table list says the query should not be replicated
...@@ -1863,8 +1862,8 @@ mysql_execute_command(void) ...@@ -1863,8 +1862,8 @@ mysql_execute_command(void)
/* Fix tables-to-be-deleted-from list to point at opened tables */ /* Fix tables-to-be-deleted-from list to point at opened tables */
for (auxi=(TABLE_LIST*) aux_tables ; auxi ; auxi=auxi->next) for (auxi=(TABLE_LIST*) aux_tables ; auxi ; auxi=auxi->next)
auxi->table= ((TABLE_LIST*) auxi->table)->table; auxi->table= ((TABLE_LIST*) auxi->table)->table;
if ((result=new multi_delete(thd,aux_tables,lex->lock_option, if (!thd->fatal_error && (result=new multi_delete(thd,aux_tables,
table_count)) && ! thd->fatal_error) lex->lock_option,table_count)))
{ {
res=mysql_select(thd,tables,select_lex->item_list, res=mysql_select(thd,tables,select_lex->item_list,
select_lex->where, select_lex->where,
...@@ -1873,10 +1872,10 @@ mysql_execute_command(void) ...@@ -1873,10 +1872,10 @@ mysql_execute_command(void)
select_lex->options | thd->options | select_lex->options | thd->options |
SELECT_NO_JOIN_CACHE, SELECT_NO_JOIN_CACHE,
result); result);
delete result;
} }
else else
res= -1; // Error is not sent res= -1; // Error is not sent
delete result;
close_thread_tables(thd); close_thread_tables(thd);
break; break;
} }
......
...@@ -212,8 +212,6 @@ int quick_rm_table(enum db_type base,const char *db, ...@@ -212,8 +212,6 @@ int quick_rm_table(enum db_type base,const char *db,
static int sort_keys(KEY *a, KEY *b) static int sort_keys(KEY *a, KEY *b)
{ {
if (a == b) // Safety
return 0;
if (a->flags & HA_NOSAME) if (a->flags & HA_NOSAME)
{ {
if (!(b->flags & HA_NOSAME)) if (!(b->flags & HA_NOSAME))
...@@ -235,7 +233,13 @@ static int sort_keys(KEY *a, KEY *b) ...@@ -235,7 +233,13 @@ static int sort_keys(KEY *a, KEY *b)
{ {
return (a->flags & HA_FULLTEXT) ? 1 : -1; return (a->flags & HA_FULLTEXT) ? 1 : -1;
} }
return a < b ? -1 : 1; // Prefer original key order /*
Prefer original key order. usable_key_parts contains here
the original key position.
*/
return ((a->usable_key_parts < b->usable_key_parts) ? -1 :
(a->usable_key_parts > b->usable_key_parts) ? 1 :
0);
} }
...@@ -396,7 +400,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -396,7 +400,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
List<Key> keys_in_order; // Add new keys here List<Key> keys_in_order; // Add new keys here
bool primary_key=0,unique_key=0; bool primary_key=0,unique_key=0;
Key *key; Key *key;
uint tmp; uint tmp, key_number;
tmp=min(file->max_keys(), MAX_KEY); tmp=min(file->max_keys(), MAX_KEY);
if (key_count > tmp) if (key_count > tmp)
{ {
...@@ -428,7 +432,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -428,7 +432,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1); // Out of memory DBUG_RETURN(-1); // Out of memory
key_iterator.rewind(); key_iterator.rewind();
for (; (key=key_iterator++) ; key_info++) key_number=0;
for (; (key=key_iterator++) ; key_info++, key_number++)
{ {
uint key_length=0; uint key_length=0;
key_part_spec *column; key_part_spec *column;
...@@ -437,6 +442,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -437,6 +442,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
(key->type == Key::FULLTEXT) ? HA_FULLTEXT : HA_NOSAME; (key->type == Key::FULLTEXT) ? HA_FULLTEXT : HA_NOSAME;
key_info->key_parts=(uint8) key->columns.elements; key_info->key_parts=(uint8) key->columns.elements;
key_info->key_part=key_part_info; key_info->key_part=key_part_info;
key_info->usable_key_parts= key_number;
if (key->type == Key::FULLTEXT) if (key->type == Key::FULLTEXT)
{ {
......
...@@ -792,6 +792,8 @@ bool multi_update::send_eof() ...@@ -792,6 +792,8 @@ bool multi_update::send_eof()
char buff[80]; char buff[80];
sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated, sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated,
(long) thd->cuted_fields); (long) thd->cuted_fields);
if (updated)
query_cache.invalidate(update_tables);
::send_ok(&thd->net, ::send_ok(&thd->net,
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
thd->insert_id_used ? thd->insert_id() : 0L,buff); thd->insert_id_used ? thd->insert_id() : 0L,buff);
......
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