summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-06-21 10:24:40 +0300
committerunknown <monty@mysql.com>2004-06-21 10:24:40 +0300
commit028dfdb3f723aed827475fe4ddcc9377f7805567 (patch)
tree0e02d42f7a1f1f532c1d780d1c57097202d7369d /sql
parenta3c22ae7d2d719e6e4ba052056c1dba316390985 (diff)
parentb5dfd05662464d2c19da349942914cce897cdbaf (diff)
downloadmariadb-git-028dfdb3f723aed827475fe4ddcc9377f7805567.tar.gz
merge
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union Build-tools/Do-compile: Auto merged include/my_global.h: Auto merged innobase/row/row0ins.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/subselect.result: Auto merged scripts/mysql_install_db.sh: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/mysqld.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged innobase/fil/fil0fil.c: merge (Use heikki's code)
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc30
-rw-r--r--sql/field.h1
-rw-r--r--sql/item_cmpfunc.cc4
-rw-r--r--sql/mysqld.cc10
-rw-r--r--sql/net_serv.cc12
-rw-r--r--sql/opt_range.cc30
-rw-r--r--sql/sql_acl.cc4
-rw-r--r--sql/sql_class.cc3
-rw-r--r--sql/sql_parse.cc12
-rw-r--r--sql/sql_select.cc39
-rw-r--r--sql/sql_yacc.yy8
-rw-r--r--sql/table.cc2
12 files changed, 108 insertions, 47 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 21256b2bbcd..e8c6688545f 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -3369,6 +3369,36 @@ String *Field_time::val_str(String *val_buffer,
}
+/*
+ Normally we would not consider 'time' as a vaild date, but we allow
+ get_date() here to be able to do things like
+ DATE_FORMAT(time, "%l.%i %p")
+*/
+
+bool Field_time::get_date(TIME *ltime, uint fuzzydate)
+{
+ long tmp;
+ if (!fuzzydate)
+ {
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
+ return 1;
+ }
+ tmp=(long) sint3korr(ptr);
+ ltime->neg=0;
+ if (tmp < 0)
+ {
+ ltime->neg= 1;
+ tmp=-tmp;
+ }
+ ltime->hour=tmp/10000;
+ tmp-=ltime->hour*10000;
+ ltime->minute= tmp/100;
+ ltime->second= tmp % 100;
+ ltime->year= ltime->month= ltime->day= ltime->second_part= 0;
+ return 0;
+}
+
+
bool Field_time::get_time(TIME *ltime)
{
long tmp=(long) sint3korr(ptr);
diff --git a/sql/field.h b/sql/field.h
index f2a166d29c3..40d18693d2e 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -825,6 +825,7 @@ public:
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
+ bool get_date(TIME *ltime, uint fuzzydate);
bool send_binary(Protocol *protocol);
bool get_time(TIME *ltime);
int cmp(const char *,const char*);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 446d72ac143..be509c7ed11 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -922,8 +922,8 @@ Item_func_if::fix_length_and_dec()
decimals=max(args[1]->decimals,args[2]->decimals);
enum Item_result arg1_type=args[1]->result_type();
enum Item_result arg2_type=args[2]->result_type();
- bool null1=args[1]->null_value;
- bool null2=args[2]->null_value;
+ bool null1=args[1]->const_item() && args[1]->null_value;
+ bool null2=args[2]->const_item() && args[2]->null_value;
if (null1)
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 782f4021ea9..3c23ecd3c3d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -47,10 +47,6 @@
#define ONE_THREAD
#endif
-#define SHUTDOWN_THD
-#define MAIN_THD
-#define SIGNAL_THD
-
#ifdef HAVE_purify
#define IF_PURIFY(A,B) (A)
#else
@@ -828,7 +824,6 @@ static void __cdecl kill_server(int sig_ptr)
#if defined(USE_ONE_SIGNAL_HAND) || (defined(__NETWARE__) && defined(SIGNALS_DONT_BREAK_READ))
extern "C" pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
{
- SHUTDOWN_THD;
my_thread_init(); // Initialize new thread
kill_server(0);
my_thread_end(); // Normally never reached
@@ -1718,7 +1713,6 @@ static void init_signals(void)
signal(SIGALRM, SIG_IGN);
signal(SIGBREAK,SIG_IGN);
signal_thread = pthread_self();
- SIGNAL_THD;
}
static void start_signal_handler(void)
@@ -2118,7 +2112,6 @@ int uname(struct utsname *a)
extern "C" pthread_handler_decl(handle_shutdown,arg)
{
MSG msg;
- SHUTDOWN_THD;
my_thread_init();
/* this call should create the message queue for this thread */
@@ -2147,7 +2140,6 @@ int STDCALL handle_kill(ulong ctrl_type)
#ifdef OS2
extern "C" pthread_handler_decl(handle_shutdown,arg)
{
- SHUTDOWN_THD;
my_thread_init();
// wait semaphore
@@ -5481,7 +5473,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
mysql_data_home= mysql_real_data_home;
break;
case 'u':
- if (!mysqld_user)
+ if (!mysqld_user || !strcmp(mysqld_user, argument))
mysqld_user= argument;
else
fprintf(stderr, "Warning: Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user);
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index a0f7a779894..c2da47b480e 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -284,7 +284,9 @@ my_net_write(NET *net,const char *packet,ulong len)
buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
return 1;
+#ifndef DEBUG_DATA_PACKETS
DBUG_DUMP("packet_header",(char*) buff,NET_HEADER_SIZE);
+#endif
return test(net_write_buff(net,packet,len));
}
@@ -394,6 +396,9 @@ net_write_buff(NET *net,const char *packet,ulong len)
else
left_length= (ulong) (net->buff_end - net->write_pos);
+#ifdef DEBUG_DATA_PACKETS
+ DBUG_DUMP("data", packet, len);
+#endif
if (len > left_length)
{
if (net->write_pos != net->buff)
@@ -776,6 +781,8 @@ my_real_read(NET *net, ulong *complen)
if (i == 0)
{ /* First parts is packet length */
ulong helping;
+ DBUG_DUMP("packet_header",(char*) net->buff+net->where_b,
+ NET_HEADER_SIZE);
if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr)
{
if (net->buff[net->where_b] != (uchar) 255)
@@ -784,7 +791,6 @@ my_real_read(NET *net, ulong *complen)
("Packets out of order (Found: %d, expected %u)",
(int) net->buff[net->where_b + 3],
net->pkt_nr));
- DBUG_DUMP("packet_header",(char*) net->buff+net->where_b, 4);
#ifdef EXTRA_DEBUG
fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n",
(int) net->buff[net->where_b + 3],
@@ -841,6 +847,10 @@ end:
vio_blocking(net->vio, net_blocking, &old_mode);
}
net->reading_or_writing=0;
+#ifdef DEBUG_DATA_PACKETS
+ if (len != packet_error)
+ DBUG_DUMP("data",(char*) net->buff+net->where_b, len);
+#endif
return(len);
}
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index a5d2450e551..41ba09a3e70 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1561,7 +1561,7 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
{
swap_variables(SEL_ARG *,key1,key2);
}
- else if (!(key1=key1->clone_tree()))
+ if (key1->use_count > 0 || !(key1=key1->clone_tree()))
return 0; // OOM
}
@@ -1630,10 +1630,10 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
SEL_ARG *next=key2->next; // Keys are not overlapping
if (key2_shared)
{
- SEL_ARG *tmp= new SEL_ARG(*key2); // Must make copy
- if (!tmp)
+ SEL_ARG *cpy= new SEL_ARG(*key2); // Must make copy
+ if (!cpy)
return 0; // OOM
- key1=key1->insert(tmp);
+ key1=key1->insert(cpy);
key2->increment_use_count(key1->use_count+1);
}
else
@@ -1869,8 +1869,17 @@ SEL_ARG::find_range(SEL_ARG *key)
/*
-** Remove a element from the tree
-** This also frees all sub trees that is used by the element
+ Remove a element from the tree
+
+ SYNOPSIS
+ tree_delete()
+ key Key that is to be deleted from tree (this)
+
+ NOTE
+ This also frees all sub trees that is used by the element
+
+ RETURN
+ root of new tree (with key deleted)
*/
SEL_ARG *
@@ -1878,7 +1887,10 @@ SEL_ARG::tree_delete(SEL_ARG *key)
{
enum leaf_color remove_color;
SEL_ARG *root,*nod,**par,*fix_par;
- root=this; this->parent= 0;
+ DBUG_ENTER("tree_delete");
+
+ root=this;
+ this->parent= 0;
/* Unlink from list */
if (key->prev)
@@ -1925,7 +1937,7 @@ SEL_ARG::tree_delete(SEL_ARG *key)
}
if (root == &null_element)
- return 0; // Maybe root later
+ DBUG_RETURN(0); // Maybe root later
if (remove_color == BLACK)
root=rb_delete_fixup(root,nod,fix_par);
test_rb_tree(root,root->parent);
@@ -1933,7 +1945,7 @@ SEL_ARG::tree_delete(SEL_ARG *key)
root->use_count=this->use_count; // Fix root counters
root->elements=this->elements-1;
root->maybe_flag=this->maybe_flag;
- return root;
+ DBUG_RETURN(root);
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 9d1eb7bc54d..d552429af4b 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2830,7 +2830,7 @@ bool check_grant_all_columns(THD *thd, ulong want_access, TABLE *table)
if (table->grant.version != grant_version)
{
table->grant.grant_table=
- table_hash_search(thd->host,thd->ip,thd->db,
+ table_hash_search(thd->host, thd->ip, table->table_cache_key,
thd->priv_user,
table->real_name,0); /* purecov: inspected */
table->grant.version=grant_version; /* purecov: inspected */
@@ -2943,7 +2943,7 @@ ulong get_column_grant(THD *thd, TABLE_LIST *table, Field *field)
if (table->grant.version != grant_version)
{
table->grant.grant_table=
- table_hash_search(thd->host,thd->ip,thd->db,
+ table_hash_search(thd->host, thd->ip, table->db,
thd->priv_user,
table->real_name,0); /* purecov: inspected */
table->grant.version=grant_version; /* purecov: inspected */
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index a04823c6c43..7aa3bbbdd7b 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -162,7 +162,8 @@ THD::THD():user_time(0), current_statement(0), is_fatal_error(0),
{
host= user= priv_user= db= ip=0;
host_or_ip= "connecting host";
- locked=killed=some_tables_deleted=no_errors=password= 0;
+ locked=some_tables_deleted=no_errors=password= 0;
+ killed=0;
query_start_used= 0;
count_cuted_fields= CHECK_FIELD_IGNORE;
db_length= col_access= 0;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index cfa6d6bb079..77ce9be45fb 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1588,7 +1588,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
mysql_log.write(thd,command,db);
- mysql_rm_db(thd,alias,0,0);
+ mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : db), 0, 0);
break;
}
#ifndef EMBEDDED_LIBRARY
@@ -3135,7 +3135,8 @@ purposes internal to the MySQL server", MYF(0));
send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
goto error;
}
- res=mysql_rm_db(thd,alias,lex->drop_if_exists,0);
+ res=mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : lex->name),
+ lex->drop_if_exists, 0);
break;
}
case SQLCOM_ALTER_DB:
@@ -4207,7 +4208,12 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
break;
case FIELD_TYPE_DECIMAL:
if (!length)
- new_field->length= 10; // Default length for DECIMAL
+ {
+ if ((new_field->length= new_field->decimals))
+ new_field->length++;
+ else
+ new_field->length= 10; // Default length for DECIMAL
+ }
if (new_field->length < MAX_FIELD_WIDTH) // Skip wrong argument
{
new_field->length+=sign_len;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index b32cb228c72..196ed25e257 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5138,6 +5138,10 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
recinfo->length=null_pack_length;
recinfo++;
bfill(null_flags,null_pack_length,255); // Set null fields
+
+ table->null_flags= (uchar*) table->record[0];
+ table->null_fields= null_count+ hidden_null_count;
+ table->null_bytes= null_pack_length;
}
null_count= (blob_count == 0) ? 1 : 0;
hidden_field_count=param->hidden_field_count;
@@ -5201,7 +5205,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
param->copy_field_end=copy;
param->recinfo=recinfo;
- store_record(table,default_values); // Make empty default record
+ store_record(table,default_values); // Make empty default record
if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit
table->max_rows= ~(ha_rows) 0;
@@ -8327,10 +8331,11 @@ calc_group_buffer(JOIN *join,ORDER *group)
join->tmp_table_param.group_null_parts=null_parts;
}
+
/*
- alloc group fields or take prepared (chached)
+ allocate group fields or take prepared (cached)
- SYNOPSYS
+ SYNOPSIS
make_group_fields()
main_join - join of current select
curr_join - current join (join of current select or temporary copy of it)
@@ -8343,22 +8348,21 @@ calc_group_buffer(JOIN *join,ORDER *group)
static bool
make_group_fields(JOIN *main_join, JOIN *curr_join)
{
- if (main_join->group_fields_cache.elements)
- {
- curr_join->group_fields= main_join->group_fields_cache;
- curr_join->sort_and_group= 1;
- }
- else
- {
- if (alloc_group_fields(curr_join, curr_join->group_list))
- {
- return (1);
- }
- main_join->group_fields_cache= curr_join->group_fields;
- }
- return (0);
+ if (main_join->group_fields_cache.elements)
+ {
+ curr_join->group_fields= main_join->group_fields_cache;
+ curr_join->sort_and_group= 1;
+ }
+ else
+ {
+ if (alloc_group_fields(curr_join, curr_join->group_list))
+ return (1);
+ main_join->group_fields_cache= curr_join->group_fields;
+ }
+ return (0);
}
+
/*
Get a list of buffers for saveing last group
Groups are saved in reverse order for easyer check loop
@@ -8399,7 +8403,6 @@ test_if_group_changed(List<Item_buff> &list)
}
-
/*
Setup copy_fields to save fields at start of new group
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 89915852b9b..e1a4eb1c1a5 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -803,7 +803,7 @@ verb_clause:
;
deallocate:
- DEALLOCATE_SYM PREPARE_SYM ident
+ deallocate_or_drop PREPARE_SYM ident
{
THD *thd=YYTHD;
LEX *lex= thd->lex;
@@ -816,6 +816,12 @@ deallocate:
lex->prepared_stmt_name= $3;
};
+deallocate_or_drop:
+ DEALLOCATE_SYM |
+ DROP
+ ;
+
+
prepare:
PREPARE_SYM ident FROM prepare_src
{
diff --git a/sql/table.cc b/sql/table.cc
index 73f036aed87..e053eba7b6c 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1134,7 +1134,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo,
char fill[IO_SIZE];
#if SIZEOF_OFF_T > 4
- /* Fix this in MySQL 4.0; The current limit is 4G rows (QQ) */
+ /* Fix this when we have new .frm files; Current limit is 4G rows (QQ) */
if (create_info->max_rows > ~(ulong) 0)
create_info->max_rows= ~(ulong) 0;
if (create_info->min_rows > ~(ulong) 0)