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

Merge work:/home/bk/mysql into serg.mysql.com:/usr/home/serg/Abk/mysql

parents 37c41731 dfb1566f
heikki@donna.mysql.fi
jani@janikt.pp.saunalahti.fi
miguel@light.local
monty@hundin.mysql.fi
monty@tik.mysql.fi
monty@work.mysql.com
mwagner@evoq.mwagner.org
paul@central.snake.net
paul@teton.kitebird.com
sasha@mysql.sashanet.com
serg@serg.mysql.com
tim@threads.polyesthetic.msg
tim@white.box
jani@hynda.mysql.fi
jcole@tetra.spaceapes.com
davida@isil.mysql.com
tonu@x153.internalnet
tim@work.mysql.com
serg@serg.mysql.com
This diff is collapsed.
......@@ -2351,6 +2351,7 @@ btr_estimate_n_rows_in_range(
btr_path_t* slot1;
btr_path_t* slot2;
ibool diverged;
ulint divergence_level;
ulint n_rows;
ulint i;
mtr_t mtr;
......@@ -2393,6 +2394,7 @@ btr_estimate_n_rows_in_range(
n_rows = 1;
diverged = FALSE;
divergence_level = 1000000;
for (i = 0; ; i++) {
ut_ad(i < BTR_PATH_ARRAY_N_SLOTS);
......@@ -2403,6 +2405,13 @@ btr_estimate_n_rows_in_range(
if (slot1->nth_rec == ULINT_UNDEFINED
|| slot2->nth_rec == ULINT_UNDEFINED) {
if (i > divergence_level + 1) {
/* In trees whose height is > 1 our algorithm
tends to underestimate: multiply the estimate
by 2: */
n_rows = n_rows * 2;
}
return(n_rows);
}
......@@ -2417,6 +2426,8 @@ btr_estimate_n_rows_in_range(
return(10);
}
divergence_level = i;
diverged = TRUE;
} else if (diverged) {
n_rows = (n_rows * (slot1->n_recs + slot2->n_recs))
......
......@@ -21,6 +21,7 @@ Created 11/11/1995 Heikki Tuuri
#include "ibuf0ibuf.h"
#include "log0log.h"
#include "os0file.h"
#include "trx0sys.h"
/* When flushed, dirty blocks are searched in neigborhoods of this size, and
flushed along with the original page. */
......
......@@ -1698,8 +1698,7 @@ loop:
btr_pcur_open_at_rnd_pos(data->index, BTR_SEARCH_LEAF, &pcur, &mtr);
if (data->size == 1
&& 0 == page_get_n_recs(btr_pcur_get_page(&pcur))) {
if (0 == page_get_n_recs(btr_pcur_get_page(&pcur))) {
/* This tree is empty */
......
......@@ -789,8 +789,8 @@ row_upd_store_row(
node->row = row_build(ROW_COPY_DATA, clust_index, rec, node->heap);
node->ext_vec = mem_heap_alloc(node->heap, rec_get_n_fields(rec));
node->ext_vec = mem_heap_alloc(node->heap, sizeof(ulint)
* rec_get_n_fields(rec));
if (node->is_delete) {
update = NULL;
} else {
......
......@@ -678,6 +678,8 @@ trx_purge_choose_next_log(void)
rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
min_trx_no = ut_dulint_max;
min_rseg = NULL;
while (rseg) {
......
......@@ -1798,6 +1798,9 @@ compiler."
*-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
# these systems don't actually have a c library (as such)!
;;
*-*-freebsd*)
#FreeBSD needs to handle -lc and -lc_r itself
;;
*-*-rhapsody*)
# rhapsody is a little odd...
deplibs="$deplibs -framework System"
......
......@@ -822,11 +822,11 @@ ha_innobase::open(
if (NULL == (ib_table = dict_table_get(norm_name, NULL))) {
fprintf(stderr, "\
Cannot find table %s from the internal data dictionary\n\
of InnoDB though the .frm file for the table exists. Maybe you have deleted\n\
and created again an InnoDB database but forgotten to delete the\n\
corresponding .frm files of old InnoDB tables?\n",
fprintf(stderr,
"Cannot find table %s from the internal data dictionary\n"
"of InnoDB though the .frm file for the table exists. Maybe you have deleted\n"
"and created again an InnoDB database but forgotten to delete the\n"
"corresponding .frm files of old InnoDB tables?\n",
norm_name);
free_share(share);
......@@ -2659,6 +2659,37 @@ ha_innobase::records_in_range(
DBUG_RETURN((ha_rows) n_rows);
}
/*************************************************************************
Gives an UPPER BOUND to the number of rows in a table. This is used in
filesort.cc and the upper bound must hold. TODO: Since the number of
rows in a table may change after this function is called, we still may
get a 'Sort aborted' error in filesort.cc of MySQL. The ultimate fix is to
improve the algorithm of filesort.cc. */
ha_rows
ha_innobase::estimate_number_of_rows(void)
/*======================================*/
/* out: upper bound of rows, currently 32-bit int
or uint */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_table_t* ib_table;
DBUG_ENTER("info");
ib_table = prebuilt->table;
dict_update_statistics(ib_table);
data_file_length = ((ulonglong)
ib_table->stat_clustered_index_size)
* UNIV_PAGE_SIZE;
/* The minimum clustered index record size is 20 bytes */
return((ha_rows) (1000 + data_file_length / 20));
}
/*************************************************************************
How many seeks it will take to read through the table. This is to be
comparable to the number returned by records_in_range so that we can
......
......@@ -137,6 +137,7 @@ class ha_innobase: public handler
enum ha_rkey_function start_search_flag,
const byte *end_key,uint end_key_len,
enum ha_rkey_function end_search_flag);
ha_rows estimate_number_of_rows();
int create(const char *name, register TABLE *form,
HA_CREATE_INFO *create_info);
......
......@@ -35,7 +35,7 @@ ulong myisam_recover_options= HA_RECOVER_NONE;
/* bits in myisam_recover_options */
const char *myisam_recover_names[] =
{ "DEFAULT", "BACKUP", "FORCE", "QUICK"};
{ "DEFAULT", "BACKUP", "FORCE", "QUICK", NullS};
TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names),"",
myisam_recover_names};
......
......@@ -156,8 +156,7 @@ void kill_one_thread(THD *thd, ulong id);
#define OPTION_LOW_PRIORITY_UPDATES 8192
#define OPTION_WARNINGS 16384
#define OPTION_AUTO_IS_NULL 32768
#define OPTION_ANSI_MODE 65536L
#define OPTION_SAFE_UPDATES OPTION_ANSI_MODE*2
#define OPTION_SAFE_UPDATES 65536L*2
#define OPTION_BUFFER_RESULT OPTION_SAFE_UPDATES*2
#define OPTION_BIN_LOG OPTION_BUFFER_RESULT*2
#define OPTION_NOT_AUTO_COMMIT OPTION_BIN_LOG*2
......@@ -173,6 +172,14 @@ void kill_one_thread(THD *thd, ulong id);
#define QUERY_NO_INDEX_USED OPTION_STATUS_NO_TRANS_UPDATE*2
#define QUERY_NO_GOOD_INDEX_USED QUERY_NO_INDEX_USED*2
/* Bits for different SQL modes modes (including ANSI mode) */
#define MODE_REAL_AS_FLOAT 1
#define MODE_PIPES_AS_CONCAT 2
#define MODE_ANSI_QUOTES 4
#define MODE_IGNORE_SPACE 8
#define MODE_SERIALIZABLE 16
#define MODE_ONLY_FULL_GROUP_BY 32
#define RAID_BLOCK_SIZE 1024
/* BINLOG_DUMP options */
......@@ -530,7 +537,7 @@ extern ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size,
what_to_log,flush_time,
max_tmp_tables,max_heap_table_size,query_buff_size,
lower_case_table_names,thread_stack,thread_stack_min,
binlog_cache_size, max_binlog_cache_size;
binlog_cache_size, max_binlog_cache_size, opt_sql_mode;
extern ulong specialflag, current_pid;
extern bool low_priority_updates, using_update_log;
extern bool opt_sql_bin_update, opt_safe_show_db, opt_warnings;
......
......@@ -211,7 +211,7 @@ static char mysql_home[FN_REFLEN],pidfile_name[FN_REFLEN];
static pthread_t select_thread;
static bool opt_log,opt_update_log,opt_bin_log,opt_slow_log,opt_noacl,
opt_disable_networking=0, opt_bootstrap=0,opt_skip_show_db=0,
opt_ansi_mode=0,opt_myisam_log=0,
opt_myisam_log=0,
opt_large_files=sizeof(my_off_t) > 4;
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0, opt_safe_show_db=0;
FILE *bootstrap_file=0;
......@@ -307,6 +307,7 @@ char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION;
const char *first_keyword="first";
const char **errmesg; /* Error messages */
const char *myisam_recover_options_str="OFF";
const char *sql_mode_str="OFF";
const char *default_tx_isolation_name;
enum_tx_isolation default_tx_isolation=ISO_READ_COMMITTED;
......@@ -320,6 +321,12 @@ double log_10[32]; /* 10 potences */
I_List<THD> threads,thread_cache;
time_t start_time;
ulong opt_sql_mode = 0L;
const char *sql_mode_names[] =
{ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
"SERIALIZE","ONLY_FULL_GROUP_BY", NullS };
TYPELIB sql_mode_typelib= {array_elements(sql_mode_names),"",
sql_mode_names};
MY_BITMAP temp_pool;
bool use_temp_pool=0;
......@@ -2471,7 +2478,8 @@ enum options {
OPT_GEMINI_FLUSH_LOG, OPT_GEMINI_RECOVER,
OPT_GEMINI_UNBUFFERED_IO, OPT_SKIP_SAFEMALLOC,
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL
OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL,
OPT_SQL_MODE
};
static struct option long_options[] = {
......@@ -2604,6 +2612,7 @@ static struct option long_options[] = {
{"skip-symlink", no_argument, 0, (int) OPT_SKIP_SYMLINKS},
{"skip-thread-priority", no_argument, 0, (int) OPT_SKIP_PRIOR},
{"sql-bin-update-same", no_argument, 0, (int) OPT_SQL_BIN_UPDATE_SAME},
{"sql-mode", required_argument, 0, (int) OPT_SQL_MODE},
#include "sslopt-longopts.h"
#ifdef __WIN__
{"standalone", no_argument, 0, (int) OPT_STANDALONE},
......@@ -2764,7 +2773,6 @@ CHANGEABLE_VAR changeable_vars[] = {
struct show_var_st init_vars[]= {
{"ansi_mode", (char*) &opt_ansi_mode, SHOW_BOOL},
{"back_log", (char*) &back_log, SHOW_LONG},
{"basedir", mysql_home, SHOW_CHAR},
#ifdef HAVE_BERKELEY_DB
......@@ -2866,6 +2874,7 @@ struct show_var_st init_vars[]= {
{"slow_launch_time", (char*) &slow_launch_time, SHOW_LONG},
{"socket", (char*) &mysql_unix_port, SHOW_CHAR_PTR},
{"sort_buffer", (char*) &sortbuff_size, SHOW_LONG},
{"sql_mode", (char*) &sql_mode_str, SHOW_CHAR_PTR},
{"table_cache", (char*) &table_cache_size, SHOW_LONG},
{"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR},
{"thread_cache_size", (char*) &thread_cache_size, SHOW_LONG},
......@@ -3049,6 +3058,9 @@ static void usage(void)
Don't give threads different priorities.\n\
--socket=... Socket file to use for connection\n\
-t, --tmpdir=path Path for temporary files\n\
--sql-mode=option[,option[,option...]] where option can be one of:\n\
REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES,\n\
IGNORE_SPACE, SERIALIZE, ONLY_FULL_GROUP_BY.\n\
--transaction-isolation\n\
Default transaction isolation level\n\
--temp-pool Use a pool of temporary files\n\
......@@ -3202,8 +3214,9 @@ static void get_options(int argc,char **argv)
opt_warnings=1;
break;
case 'a':
opt_ansi_mode=1;
thd_startup_options|=OPTION_ANSI_MODE;
opt_sql_mode = (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT |
MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_SERIALIZABLE
| MODE_ONLY_FULL_GROUP_BY);
default_tx_isolation= ISO_SERIALIZABLE;
break;
case 'b':
......@@ -3726,6 +3739,19 @@ static void get_options(int argc,char **argv)
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
break;
}
case OPT_SQL_MODE:
{
sql_mode_str = optarg;
if ((opt_sql_mode =
find_bit_type(optarg, &sql_mode_typelib)) == ~(ulong) 0)
{
fprintf(stderr, "Unknown option to sql-mode: %s\n", optarg);
exit(1);
}
if (opt_sql_mode & MODE_SERIALIZABLE)
default_tx_isolation= ISO_SERIALIZABLE;
break;
}
case OPT_MASTER_HOST:
master_host=optarg;
break;
......
......@@ -120,6 +120,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
server_status=SERVER_STATUS_AUTOCOMMIT;
update_lock_default= low_priority_updates ? TL_WRITE_LOW_PRIORITY : TL_WRITE;
options=thd_startup_options;
sql_mode=(uint) opt_sql_mode;
inactive_timeout=net_wait_timeout;
open_options=ha_open_options;
tx_isolation=session_tx_isolation=default_tx_isolation;
......
......@@ -232,7 +232,7 @@ public:
char *query,*thread_stack;
char *host,*user,*priv_user,*db,*ip;
const char *proc_info;
uint client_capabilities,max_packet_length;
uint client_capabilities,sql_mode,max_packet_length;
uint master_access,db_access;
TABLE *open_tables,*temporary_tables;
MYSQL_LOCK *lock,*locked_tables;
......
......@@ -121,7 +121,7 @@ void lex_init(void)
state_map[(uchar)'*']= (uchar) STATE_END_LONG_COMMENT;
state_map[(uchar)'@']= (uchar) STATE_USER_END;
state_map[(uchar) '`']= (uchar) STATE_USER_VARIABLE_DELIMITER;
if (thd_startup_options & OPTION_ANSI_MODE)
if (opt_sql_mode & MODE_ANSI_QUOTES)
{
state_map[(uchar) '"'] = STATE_USER_VARIABLE_DELIMITER;
}
......@@ -149,7 +149,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
lex->ftfunc_list.empty();
lex->convert_set=(lex->thd=thd)->convert_set;
lex->yacc_yyss=lex->yacc_yyvs=0;
lex->ignore_space=test(thd->client_capabilities & CLIENT_IGNORE_SPACE);
lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE);
return lex;
}
......
......@@ -412,6 +412,8 @@ check_connections(THD *thd)
return(ER_OUT_OF_RESOURCES);
thd->client_capabilities=uint2korr(net->read_pos);
if (thd->client_capabilities & CLIENT_IGNORE_SPACE)
thd->sql_mode|= MODE_IGNORE_SPACE;
#ifdef HAVE_OPENSSL
DBUG_PRINT("info",
("pkt_len:%d, client capabilities: %d",
......@@ -538,8 +540,6 @@ pthread_handler_decl(handle_one_connection,arg)
thd->options |= OPTION_BIG_SELECTS;
if (thd->client_capabilities & CLIENT_COMPRESS)
net->compress=1; // Use compression
if (thd->options & OPTION_ANSI_MODE)
thd->client_capabilities|=CLIENT_IGNORE_SPACE;
thd->proc_info=0; // Remove 'login'
thd->command=COM_SLEEP;
......
......@@ -5425,6 +5425,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
{
if ((error=file->delete_row(record)))
goto err;
error=file->rnd_next(record);
continue;
}
if (copy_blobs(first_field))
......@@ -5936,7 +5937,7 @@ setup_group(THD *thd,TABLE_LIST *tables,List<Item> &fields,
if (!order)
return 0; /* Everything is ok */
if (thd->options & OPTION_ANSI_MODE)
if (thd->sql_mode & MODE_ONLY_FULL_GROUP_BY)
{
Item *item;
List_iterator<Item> li(fields);
......@@ -5958,7 +5959,7 @@ setup_group(THD *thd,TABLE_LIST *tables,List<Item> &fields,
return 1;
}
}
if (thd->options & OPTION_ANSI_MODE)
if (thd->sql_mode & MODE_ONLY_FULL_GROUP_BY)
{
/* Don't allow one to use fields that is not used in GROUP BY */
Item *item;
......
......@@ -34,7 +34,7 @@ int yylex(void *yylval);
inline Item *or_or_concat(Item* A, Item* B)
{
return (current_thd->options & OPTION_ANSI_MODE ?
return (current_thd->sql_mode & MODE_PIPES_AS_CONCAT ?
(Item*) new Item_func_concat(A,B) : (Item*) new Item_cond_or(A,B));
}
......@@ -915,7 +915,7 @@ int_type:
| BIGINT { $$=FIELD_TYPE_LONGLONG; }
real_type:
REAL { $$= current_thd->options & OPTION_ANSI_MODE ?
REAL { $$= current_thd->sql_mode & MODE_REAL_AS_FLOAT ?
FIELD_TYPE_FLOAT : FIELD_TYPE_DOUBLE; }
| DOUBLE_SYM { $$=FIELD_TYPE_DOUBLE; }
| DOUBLE_SYM PRECISION { $$=FIELD_TYPE_DOUBLE; }
......
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