diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-06-21 13:20:22 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-06-21 13:20:22 -0600 |
commit | 63bd9b50530145b5f2d5ae5b8a0c9d019eb9771a (patch) | |
tree | 15ba19aff50fcf336938dccd836f07ca4cefed06 /sql | |
parent | 5eefda7a8504d01c0dba8304a0ff3f0fd2910c2c (diff) | |
parent | 8f33f8d4d36080b161fac72971239afd4bf3137f (diff) | |
download | mariadb-git-63bd9b50530145b5f2d5ae5b8a0c9d019eb9771a.tar.gz |
Merge work:/home/bk/mysql-4.0
into mysql.sashanet.com:/home/sasha/src/bk/mysql-4.0
sql/sql_parse.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/item_sum.cc | 31 | ||||
-rw-r--r-- | sql/item_sum.h | 15 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/mysqlbinlog.cc | 4 | ||||
-rw-r--r-- | sql/mysqld.cc | 23 | ||||
-rw-r--r-- | sql/sql_base.cc | 43 | ||||
-rw-r--r-- | sql/sql_parse.cc | 1 | ||||
-rw-r--r-- | sql/sql_select.cc | 20 | ||||
-rw-r--r-- | sql/sql_show.cc | 10 | ||||
-rw-r--r-- | sql/time.cc | 4 |
11 files changed, 101 insertions, 54 deletions
diff --git a/sql/field.cc b/sql/field.cc index 629ae899494..78f57c5ceb5 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1593,7 +1593,7 @@ double Field_longlong::val_real(void) else #endif longlongget(j,ptr); - return unsigned_flag ? ulonglong2double(j) : (double) j; + return unsigned_flag ? ulonglong2double((ulonglong) j) : (double) j; } longlong Field_longlong::val_int(void) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index fb20d31ee90..2cf23d48bc6 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -875,8 +875,19 @@ bool Item_sum_count_distinct::setup(THD *thd) List<Item> list; /* Create a table with an unique key over all parameters */ for (uint i=0; i < arg_count ; i++) - if (list.push_back(args[i])) - return 1; + { + Item *item=args[i]; + if (list.push_back(item)) + return 1; // End of memory + if (item->const_item()) + { + (void) item->val_int(); + if (item->null_value) + always_null=1; + } + } + if (always_null) + return 0; count_field_types(tmp_table_param,list,0); if (table) { @@ -978,20 +989,22 @@ int Item_sum_count_distinct::tree_to_myisam() void Item_sum_count_distinct::reset() { - if(use_tree) + if (use_tree) reset_tree(&tree); - else - { - table->file->extra(HA_EXTRA_NO_CACHE); - table->file->delete_all_rows(); - table->file->extra(HA_EXTRA_WRITE_CACHE); - } + else if (table) + { + table->file->extra(HA_EXTRA_NO_CACHE); + table->file->delete_all_rows(); + table->file->extra(HA_EXTRA_WRITE_CACHE); + } (void) add(); } bool Item_sum_count_distinct::add() { int error; + if (always_null) + return 0; copy_fields(tmp_table_param); copy_funcs(tmp_table_param->funcs); diff --git a/sql/item_sum.h b/sql/item_sum.h index 6a62614aff8..aea4d054c62 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -148,20 +148,21 @@ class Item_sum_count_distinct :public Item_sum_int bool fix_fields(THD *thd,TABLE_LIST *tables); TMP_TABLE_PARAM *tmp_table_param; TREE tree; - + // calculated based on max_heap_table_size. If reached, // walk the tree and dump it into MyISAM table uint max_elements_in_tree; + + // the first few bytes of record ( at least one) + // are just markers for deleted and NULLs. We want to skip them since + // they will just bloat the tree without providing any valuable info + int rec_offset; // If there are no blobs, we can use a tree, which // is faster than heap table. In that case, we still use the table // to help get things set up, but we insert nothing in it bool use_tree; - - // the first few bytes of record ( at least one) - // are just markers for deleted and NULLs. We want to skip them since - // they will just bloat the tree without providing any valuable info - int rec_offset; + bool always_null; // Set to 1 if the result is always NULL int tree_to_myisam(); @@ -172,7 +173,7 @@ class Item_sum_count_distinct :public Item_sum_int public: Item_sum_count_distinct(List<Item> &list) :Item_sum_int(list),table(0),used_table_cache(~(table_map) 0), - tmp_table_param(0),use_tree(0) + tmp_table_param(0),always_null(0),use_tree(0) { quick_group=0; } ~Item_sum_count_distinct(); table_map used_tables() const { return used_table_cache; } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index fd0ab984dda..07c73aa37a9 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -550,7 +550,7 @@ extern ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size, binlog_cache_size, max_binlog_cache_size; extern ulong specialflag, current_pid; extern bool low_priority_updates, using_update_log; -extern bool opt_sql_bin_update, opt_safe_show_db; +extern bool opt_sql_bin_update, opt_safe_show_db, opt_warnings; extern char language[LIBLEN],reg_ext[FN_EXTLEN],blob_newline; extern const char **errmesg; /* Error messages */ extern const char *default_tx_isolation_name; diff --git a/sql/mysqlbinlog.cc b/sql/mysqlbinlog.cc index c234e2421bf..5edfe6e0591 100644 --- a/sql/mysqlbinlog.cc +++ b/sql/mysqlbinlog.cc @@ -108,7 +108,7 @@ static void die(const char* fmt, ...) static void print_version() { - printf("%s Ver 1.3 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); } @@ -132,7 +132,7 @@ the mysql command line client\n\n"); -s, --short-form Just show the queries, no extra info\n\ -o, --offset=N Skip the first N entries\n\ -h, --host=server Get the binlog from server\n\ --P, --port=port Use port to connect to the remove server\n\ +-P, --port=port Use port to connect to the remote server\n\ -u, --user=username Connect to the remove server as username\n\ -p, --password=password Password to connect to remote server\n\ -r, --result-file=file Direct output to a given file\n\ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2b2db714c72..c86ed19092c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -220,7 +220,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_ansi_mode=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, opt_show_slave_auth_info = 0; @@ -289,7 +289,7 @@ ulong max_tmp_tables,max_heap_table_size; ulong bytes_sent = 0L, bytes_received = 0L; bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory; -bool opt_using_transactions, using_update_log; +bool opt_using_transactions, using_update_log, opt_warnings=0; bool volatile abort_loop,select_thread_in_use,grant_option; bool volatile ready_to_exit,shutdown_in_progress; ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */ @@ -1205,7 +1205,7 @@ Some pointers may be invalid and cause the dump to abort...\n"); fprintf(stderr, "\n Successfully dumped variables, if you ran with --log, take a look at the\n\ details of what thread %ld did to cause the crash. In some cases of really\n\ -bad corruption, the above values may be invalid\n\n", +bad corruption, the values shown above may be invalid\n\n", thd->thread_id); } fprintf(stderr, "\ @@ -2479,7 +2479,7 @@ enum options { OPT_INNODB_LOG_ARCH_DIR, OPT_INNODB_LOG_ARCHIVE, OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, - OPT_INNODB_UNIX_FILE_FLUSH_METHOD, + OPT_innodb_flush_method, OPT_SAFE_SHOW_DB, OPT_GEMINI_SKIP, OPT_INNODB_SKIP, OPT_TEMP_POOL, OPT_DO_PSTACK, OPT_TX_ISOLATION, @@ -2544,7 +2544,7 @@ static struct option long_options[] = { OPT_INNODB_LOG_ARCHIVE}, {"innodb_flush_log_at_trx_commit", optional_argument, 0, OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT}, - {"innodb_unix_file_flush_method", required_argument, 0, + {"innodb_flush_method", required_argument, 0, OPT_INNODB_UNIX_FILE_FLUSH_METHOD}, #endif {"help", no_argument, 0, '?'}, @@ -2636,6 +2636,7 @@ static struct option long_options[] = { {"use-locking", no_argument, 0, (int) OPT_USE_LOCKING}, {"user", required_argument, 0, 'u'}, {"version", no_argument, 0, 'V'}, + {"warnings", no_argument, 0, 'W'}, {0, 0, 0, 0} }; @@ -3050,6 +3051,8 @@ static void usage(void) -O, --set-variable var=option\n\ Give a variable an value. --help lists variables\n\ --safe-mode Skip some optimize stages (for testing)\n\ + --safe-show-database Don't show databases for which the user has no\n\ + privileges\n\ --skip-concurrent-insert\n\ Don't use concurrent insert with MyISAM\n\ --skip-delay-key-write\n\ @@ -3076,7 +3079,8 @@ static void usage(void) Default transaction isolation level\n\ --temp-pool Use a pool of temporary files\n\ -u, --user=user_name Run mysqld daemon as user\n\ - -V, --version output version information and exit"); + -V, --version output version information and exit\n\ + -W, --warnings Log some not critical warnings to the log file\n"); #ifdef __WIN__ puts("NT and Win32 specific options:\n\ --console Don't remove the console window\n\ @@ -3113,7 +3117,7 @@ static void usage(void) puts("\ --innodb_data_home_dir=dir The common part for Innodb table spaces\n\ --innodb_data_file_path=dir Path to individual files and their sizes\n\ - --innodb_flush_method=# Which method to flush data\n\ + --innodb_flush_method=# With which method to flush data\n\ --innodb_flush_log_at_trx_commit[=#]\n\ Set to 0 if you don't want to flush logs\n\ --innodb_log_arch_dir=dir Where full logs should be archived\n\ @@ -3209,7 +3213,7 @@ static void get_options(int argc,char **argv) myisam_delay_key_write=1; // Allow use of this my_use_symdir=1; // Use internal symbolic links - while ((c=getopt_long(argc,argv,"ab:C:h:#::T::?l::L:O:P:sS::t:u:noVvI?", + while ((c=getopt_long(argc,argv,"ab:C:h:#::T::?l::L:O:P:sS::t:u:noVvWI?", long_options, &option_index)) != EOF) { switch(c) { @@ -3219,6 +3223,9 @@ static void get_options(int argc,char **argv) #endif opt_endinfo=1; /* unireg: memory allocation */ break; + case 'W': + opt_warnings=1; + break; case 'a': opt_ansi_mode=1; thd_startup_options|=OPTION_ANSI_MODE; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index fabbf8948ac..ea3d77c5158 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -504,11 +504,12 @@ void close_temporary(TABLE *table,bool delete_table) void close_temporary_tables(THD *thd) { TABLE *table,*next; - uint init_query_buf_size = 11, query_buf_size; // "drop table " - char* query, *p; + char *query, *end; + const uint init_query_buf_size = 11; // "drop table " + uint query_buf_size; bool found_user_tables = 0; - LINT_INIT(p); + LINT_INIT(end); query_buf_size = init_query_buf_size; for (table=thd->temporary_tables ; table ; table=table->next) @@ -516,37 +517,37 @@ void close_temporary_tables(THD *thd) query_buf_size += table->key_length; } - if(query_buf_size == init_query_buf_size) + if (query_buf_size == init_query_buf_size) return; // no tables to close - if((query = alloc_root(&thd->mem_root, query_buf_size))) - { - memcpy(query, "drop table ", init_query_buf_size); - p = query + init_query_buf_size; - } + if ((query = alloc_root(&thd->mem_root, query_buf_size))) + { + memcpy(query, "drop table ", init_query_buf_size); + end = query + init_query_buf_size; + } for (table=thd->temporary_tables ; table ; table=next) { - if(query) // we might be out of memory, but this is not fatal + if (query) // we might be out of memory, but this is not fatal + { + // skip temporary tables not created directly by the user + if (table->table_name[0] != '#') { - // skip temporary tables not created directly by the user - if(table->table_name[0] != '#') - { - p = strxmov(p,table->table_cache_key,".", - table->table_name,",", NullS); - // here we assume table_cache_key always starts - // with \0 terminated db name - found_user_tables = 1; - } + end = strxmov(end,table->table_cache_key,".", + table->table_name,",", NullS); + // here we assume table_cache_key always starts + // with \0 terminated db name + found_user_tables = 1; } + } next=table->next; close_temporary(table); } if (query && found_user_tables && mysql_bin_log.is_open()) { uint save_query_len = thd->query_length; - *--p = 0; - thd->query_length = (uint)(p-query); + *--end = 0; // Remove last ',' + thd->query_length = (uint)(end-query); Query_log_event qinfo(thd, query); mysql_bin_log.write(&qinfo); thd->query_length = save_query_len; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0e3a1e4d91f..928a62a397e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -556,6 +556,7 @@ pthread_handler_decl(handle_one_connection,arg) free_root(&thd->mem_root,MYF(0)); if (net->error && net->vio != 0) { + if (!thd->killed && ! opt_warnings) sql_print_error(ER(ER_NEW_ABORTING_CONNECTION), thd->thread_id,(thd->db ? thd->db : "unconnected"), thd->user ? thd->user : "unauthenticated", diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b7e9db46507..4a033f3e6ad 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -403,7 +403,22 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, goto err; /* purecov: inspected */ } if (join.const_tables && !thd->locked_tables) + { + TABLE **table, **end; + for (table=join.table, end=table + join.const_tables ; + table != end; + table++) + { + /* BDB tables require that we call index_end() before doing an unlock */ + if ((*table)->key_read) + { + (*table)->key_read=0; + (*table)->file->extra(HA_EXTRA_NO_KEYREAD); + } + (*table)->file->index_end(); + } mysql_unlock_some_tables(thd, join.table,join.const_tables); + } if (!conds && join.outer_join) { /* Handle the case where we have an OUTER JOIN without a WHERE */ @@ -2810,7 +2825,12 @@ return_zero_rows(select_result *result,TABLE_LIST *tables,List<Item> &fields, if (send_row) result->send_data(fields); if (tables) // Not from do_select() + { + /* Close open cursors */ + for (TABLE_LIST *table=tables; table ; table=table->next) + table->table->file->index_end(); result->send_eof(); // Should be safe + } } DBUG_RETURN(0); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ac89b7a2782..199d6a764e0 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -844,18 +844,22 @@ store_create_info(THD *thd, TABLE *table, String *packet) for (uint i=0 ; i < table->keys ; i++,key_info++) { + KEY_PART_INFO *key_part= key_info->key_part; + bool found_primary=0; packet->append(",\n ", 4); - KEY_PART_INFO *key_part= key_info->key_part; - if (i == primary_key) + if (i == primary_key && !strcmp(key_info->name,"PRIMARY")) + { + found_primary=1; packet->append("PRIMARY ", 8); + } else if (key_info->flags & HA_NOSAME) packet->append("UNIQUE ", 7); else if (key_info->flags & HA_FULLTEXT) packet->append("FULLTEXT ", 9); packet->append("KEY ", 4); - if (i != primary_key) + if (!found_primary) append_identifier(thd,packet,key_info->name); packet->append(" (", 2); diff --git a/sql/time.cc b/sql/time.cc index 086977af72f..e0b74fc9d25 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -455,8 +455,8 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) if ((date[i]=tmp_value)) date_used=1; // Found something if (i == 2 && str != end && *str == 'T') - str++; // ISO8601: CCYYMMDDThhmmss - else + str++; // ISO8601: CCYYMMDDThhmmss + else if ( i != 5 ) // Skip inter-field delimiters { while (str != end && (ispunct(*str) || isspace(*str))) { |