Commit 5f164e2f authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Merge bk-internal.mysql.com:/home/bk/mysql-4.0

into narttu.mysql.fi:/my/mysql-4.0
parents f05a1c83 ef8cd361
......@@ -40,7 +40,7 @@
#include <signal.h>
#include <violite.h>
const char *VER= "12.21";
const char *VER= "12.22";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
......@@ -801,7 +801,9 @@ static int read_lines(bool execute_commands)
char *prompt= (char*) (glob_buffer.is_empty() ? construct_prompt() :
!in_string ? " -> " :
in_string == '\'' ?
" '> " : " \"> ");
" '> " : (in_string == '`' ?
" `> " :
" \"> "));
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);
......
......@@ -21,6 +21,7 @@
#include <assert.h>
#include "log_event.h"
#include "include/my_sys.h"
#include "unistd.h"
#define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
......@@ -81,9 +82,9 @@ class Load_log_processor
bname--;
uint blen= ce->fname_len - (bname-ce->fname);
uint full_len= target_dir_name_len + blen;
uint full_len= target_dir_name_len + blen + 9 + 9 + 1;
char *tmp;
if (!(tmp= my_malloc(full_len + 9 + 1,MYF(MY_WME))) ||
if (!(tmp= my_malloc(full_len,MYF(MY_WME))) ||
set_dynamic(&file_names,(gptr)&ce,ce->file_id))
{
die("Could not construct local filename %s%s",target_dir_name,bname);
......@@ -96,6 +97,21 @@ class Load_log_processor
memcpy(ptr,bname,blen);
ptr+= blen;
sprintf(ptr,"-%08x",ce->file_id);
ptr+= 9;
uint version= 0;
for (;;)
{
sprintf(ptr,"-%08x",version);
if (access(tmp,F_OK))
break;
version++;
if (version>UINT_MAX)
{
die("Could not construct local filename %s%s",target_dir_name,bname);
return 0;
}
}
ce->set_fname_outside_temp_buf(tmp,full_len);
......@@ -169,6 +185,8 @@ class Load_log_processor
}
Create_file_log_event *grab_event(uint file_id)
{
if (file_id >= file_names.elements)
return 0;
Create_file_log_event **ptr=
(Create_file_log_event**)file_names.buffer + file_id;
Create_file_log_event *res= *ptr;
......@@ -182,8 +200,12 @@ class Load_log_processor
}
void process(Append_block_log_event *ae)
{
if (ae->file_id >= file_names.elements)
{
Create_file_log_event* ce= (ae->file_id < file_names.elements) ?
*((Create_file_log_event**)file_names.buffer + ae->file_id) : 0;
if (ce)
append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY,ae->block,ae->block_len);
else
/*
There is no Create_file event (a bad binlog or a big
--position). Assuming it's a big --position, we just do nothing and
......@@ -191,11 +213,6 @@ class Load_log_processor
*/
fprintf(stderr,"Warning: ignoring Append_block as there is no \
Create_file event for file_id: %u\n",ae->file_id);
return;
}
Create_file_log_event* ce=
*((Create_file_log_event**)file_names.buffer + ae->file_id);
append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY,ae->block,ae->block_len);
}
};
......
......@@ -109,7 +109,7 @@ int main(int argc,char *argv[])
if (to)
fclose(to);
if (error)
fprintf(stderr,"Can't uppdate messagefile %s, errno: %d\n",*argv,errno);
fprintf(stderr,"Can't update messagefile %s, errno: %d\n",*argv,errno);
exit(error);
return(0);
......
......@@ -237,12 +237,12 @@ int main(int argc, char *argv[])
{
if (my_errno != HA_ERR_FOUND_DUPP_KEY || key3[n3] == 0)
{
printf("error: %d; can't uppdate:\nFrom: \"%s\"\nTo: \"%s\"\n",
printf("error: %d; can't update:\nFrom: \"%s\"\nTo: \"%s\"\n",
my_errno,record,record2);
goto err;
}
if (verbose)
printf("Double key when tryed to uppdate:\nFrom: \"%s\"\nTo: \"%s\"\n",record,record2);
printf("Double key when tried to update:\nFrom: \"%s\"\nTo: \"%s\"\n",record,record2);
}
else
{
......
......@@ -1105,4 +1105,14 @@ typedef union {
#define statistic_add(V,C,L) (V)+=(C)
#endif
#ifdef HAVE_OPENSSL
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER < 0x0090700f
#define DES_cblock des_cblock
#define DES_key_schedule des_key_schedule
#define DES_set_key_unchecked(k,ks) des_set_key_unchecked((k),*(ks))
#define DES_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e) des_ede3_cbc_encrypt((i),(o),(l),*(k1),*(k2),*(k3),(iv),(e))
#endif
#endif
#endif /* my_global_h */
......@@ -265,12 +265,12 @@ int main(int argc, char *argv[])
{
if (my_errno != HA_ERR_FOUND_DUPP_KEY || key3[n3] == 0)
{
printf("error: %d; can't uppdate:\nFrom: \"%s\"\nTo: \"%s\"\n",
printf("error: %d; can't update:\nFrom: \"%s\"\nTo: \"%s\"\n",
my_errno,read_record,record2);
goto err;
}
if (verbose)
printf("Double key when tryed to uppdate:\nFrom: \"%s\"\nTo: \"%s\"\n",record,record2);
printf("Double key when tried to update:\nFrom: \"%s\"\nTo: \"%s\"\n",record,record2);
}
else
{
......
......@@ -329,12 +329,12 @@ int main(int argc, char *argv[])
{
if (my_errno != HA_ERR_FOUND_DUPP_KEY || key3[n3] == 0)
{
printf("error: %d; can't uppdate:\nFrom: \"%s\"\nTo: \"%s\"\n",
printf("error: %d; can't update:\nFrom: \"%s\"\nTo: \"%s\"\n",
my_errno,read_record,record2);
goto err;
}
if (verbose)
printf("Double key when tryed to uppdate:\nFrom: \"%s\"\nTo: \"%s\"\n",record,record2);
printf("Double key when tried to update:\nFrom: \"%s\"\nTo: \"%s\"\n",record,record2);
}
else
{
......
......@@ -173,9 +173,9 @@ INSERT INTO t2 values (1),(2),(3);
INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
t2 index a a 4 NULL 5 Using index; Using temporary
t1 eq_ref PRIMARY PRIMARY 4 t2.a 1
t3 index a a 5 NULL 5 Using where; Using index
t3 index a a 5 NULL 6 Using index; Using temporary
t2 index a a 4 NULL 5 Using index; Distinct
t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 Using where; Distinct
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
a
1
......@@ -303,9 +303,9 @@ t1 index id id 4 NULL 2 Using index; Using temporary
t2 index id id 8 NULL 1 Using index; Distinct
t3 index id id 8 NULL 1 Using index; Distinct
j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct
t2_lj index id id 8 NULL 1 Using where; Using index; Distinct
t2_lj ref id id 4 j_lj_t2.id 1 Using where; Using index; Distinct
j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct
t3_lj index id id 8 NULL 1 Using where; Using index; Distinct
t3_lj ref id id 4 j_lj_t3.id 1 Using where; Using index; Distinct
SELECT DISTINCT
t1.id
from
......
......@@ -307,17 +307,17 @@ table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 8 Using where; Using index
explain select * from t1 where a = 2 and b >0 order by a desc,b desc;
table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 4 Using where; Using index
t1 range a a 9 NULL 5 Using where; Using index
explain select * from t1 where a = 2 and b is null order by a desc,b desc;
table type possible_keys key key_len ref rows Extra
t1 ref a a 9 const,const 1 Using where; Using index; Using filesort
explain select * from t1 where a = 2 and (b is null or b > 0) order by a
desc,b desc;
table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 5 Using where; Using index
t1 range a a 9 NULL 6 Using where; Using index
explain select * from t1 where a = 2 and b > 0 order by a desc,b desc;
table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 4 Using where; Using index
t1 range a a 9 NULL 5 Using where; Using index
explain select * from t1 where a = 2 and b < 2 order by a desc,b desc;
table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 2 Using where; Using index
......@@ -466,8 +466,8 @@ t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index
t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where
t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
t1 eq_ref PRIMARY PRIMARY 4 t3.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
......@@ -475,8 +475,8 @@ t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where
t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
t1 eq_ref PRIMARY PRIMARY 4 t3.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
......
......@@ -111,22 +111,10 @@ n s
2 two bar
3 three bar
4 four bar
insert into bar.t1 values(10, 'should be there');
flush tables;
load data from master;
Error on delete of './bar/t1.MYI' (Errcode: 13)
select * from bar.t1;
n s
1 one bar
2 two bar
3 three bar
4 four bar
10 should be there
load table bar.t1 from master;
Table 't1' already exists
drop table bar.t1;
load table bar.t1 from master;
start slave;
drop database bar;
drop database foo;
drop database foo;
......
......@@ -110,13 +110,14 @@ select * from bar.t1;
# Check that LOAD DATA FROM MASTER reports the error if it can't drop a
# table to be overwritten.
insert into bar.t1 values(10, 'should be there');
flush tables;
system chmod 500 var/slave-data/bar/;
--error 6
load data from master; # should fail (errno 13)
system chmod 700 var/slave-data/bar/;
select * from bar.t1; # should contain the row (10, ...)
# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX
# insert into bar.t1 values(10, 'should be there');
# flush tables;
# system chmod 500 var/slave-data/bar/;
# --error 6
# load data from master; # should fail (errno 13)
# system chmod 700 var/slave-data/bar/;
# select * from bar.t1; # should contain the row (10, ...)
# Check that LOAD TABLE FROM MASTER fails if the table exists on slave
......@@ -126,7 +127,8 @@ drop table bar.t1;
load table bar.t1 from master;
# as LOAD DATA FROM MASTER failed it did not restart slave threads
start slave;
# DISABLED FOR NOW
# start slave;
# Now time for cleanup
connection master;
......
......@@ -387,6 +387,8 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
*ptr++= '=';
for ( ; value != value_end; value++)
{
if (*value == '\"' || *value == '\'')
continue;
if (*value == '\\' && value != value_end-1)
{
switch(*++value) {
......@@ -405,6 +407,12 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
case 's':
*ptr++= ' '; /* space */
break;
case '\"':
*ptr++= '\"';
break;
case '\'':
*ptr++= '\'';
break;
case '\\':
*ptr++= '\\';
break;
......
......@@ -76,16 +76,16 @@ load_des_key_file(const char *file_name)
if (start != end)
{
des_cblock ivec;
DES_cblock ivec;
bzero((char*) &ivec,sizeof(ivec));
// We make good 24-byte (168 bit) key from given plaintext key with MD5
EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL,
(uchar *) start, (int) (end-start),1,
(uchar *) &keyblock,
ivec);
des_set_key_unchecked(&keyblock.key1,des_keyschedule[(int)offset].ks1);
des_set_key_unchecked(&keyblock.key2,des_keyschedule[(int)offset].ks2);
des_set_key_unchecked(&keyblock.key3,des_keyschedule[(int)offset].ks3);
DES_set_key_unchecked(&keyblock.key1,&(des_keyschedule[(int)offset].ks1));
DES_set_key_unchecked(&keyblock.key2,&(des_keyschedule[(int)offset].ks2));
DES_set_key_unchecked(&keyblock.key3,&(des_keyschedule[(int)offset].ks3));
if (des_default_key == 15)
des_default_key= (uint) offset; // use first as def.
}
......
......@@ -330,7 +330,7 @@ void Item_func_concat::fix_length_and_dec()
String *Item_func_des_encrypt::val_str(String *str)
{
#ifdef HAVE_OPENSSL
des_cblock ivec;
DES_cblock ivec;
struct st_des_keyblock keyblock;
struct st_des_keyschedule keyschedule;
const char *append_str="********";
......@@ -370,9 +370,9 @@ String *Item_func_des_encrypt::val_str(String *str)
EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL,
(uchar*) keystr->ptr(), (int) keystr->length(),
1, (uchar*) &keyblock,ivec);
des_set_key_unchecked(&keyblock.key1,keyschedule.ks1);
des_set_key_unchecked(&keyblock.key2,keyschedule.ks2);
des_set_key_unchecked(&keyblock.key3,keyschedule.ks3);
DES_set_key_unchecked(&keyblock.key1,&keyschedule.ks1);
DES_set_key_unchecked(&keyblock.key2,&keyschedule.ks2);
DES_set_key_unchecked(&keyblock.key3,&keyschedule.ks3);
}
/*
......@@ -393,12 +393,12 @@ String *Item_func_des_encrypt::val_str(String *str)
tmp_value[0]=(char) (128 | key_number);
// Real encryption
bzero((char*) &ivec,sizeof(ivec));
des_ede3_cbc_encrypt((const uchar*) (res->ptr()),
DES_ede3_cbc_encrypt((const uchar*) (res->ptr()),
(uchar*) (tmp_value.ptr()+1),
res_length,
keyschedule.ks1,
keyschedule.ks2,
keyschedule.ks3,
&keyschedule.ks1,
&keyschedule.ks2,
&keyschedule.ks3,
&ivec, TRUE);
return &tmp_value;
......@@ -412,8 +412,8 @@ String *Item_func_des_encrypt::val_str(String *str)
String *Item_func_des_decrypt::val_str(String *str)
{
#ifdef HAVE_OPENSSL
des_key_schedule ks1, ks2, ks3;
des_cblock ivec;
DES_key_schedule ks1, ks2, ks3;
DES_cblock ivec;
struct st_des_keyblock keyblock;
struct st_des_keyschedule keyschedule;
String *res= args[0]->val_str(str);
......@@ -447,20 +447,20 @@ String *Item_func_des_decrypt::val_str(String *str)
(uchar*) keystr->ptr(),(int) keystr->length(),
1,(uchar*) &keyblock,ivec);
// Here we set all 64-bit keys (56 effective) one by one
des_set_key_unchecked(&keyblock.key1,keyschedule.ks1);
des_set_key_unchecked(&keyblock.key2,keyschedule.ks2);
des_set_key_unchecked(&keyblock.key3,keyschedule.ks3);
DES_set_key_unchecked(&keyblock.key1,&keyschedule.ks1);
DES_set_key_unchecked(&keyblock.key2,&keyschedule.ks2);
DES_set_key_unchecked(&keyblock.key3,&keyschedule.ks3);
}
if (tmp_value.alloc(length-1))
goto error;
bzero((char*) &ivec,sizeof(ivec));
des_ede3_cbc_encrypt((const uchar*) res->ptr()+1,
DES_ede3_cbc_encrypt((const uchar*) res->ptr()+1,
(uchar*) (tmp_value.ptr()),
length-1,
keyschedule.ks1,
keyschedule.ks2,
keyschedule.ks3,
&keyschedule.ks1,
&keyschedule.ks2,
&keyschedule.ks3,
&ivec, FALSE);
/* Restore old length of key */
if ((tail=(uint) (uchar) tmp_value[length-2]) > 8)
......
......@@ -474,11 +474,11 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
#include <openssl/des.h>
struct st_des_keyblock
{
des_cblock key1, key2, key3;
DES_cblock key1, key2, key3;
};
struct st_des_keyschedule
{
des_key_schedule ks1, ks2, ks3;
DES_key_schedule ks1, ks2, ks3;
};
extern char *des_key_file;
extern struct st_des_keyschedule des_keyschedule[10];
......
......@@ -1898,7 +1898,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
best=best_time=records=DBL_MAX;
KEYUSE *best_key=0;
uint best_max_key_part=0;
my_bool found_constrain= 0;
my_bool found_constraint= 0;
if (s->keyuse)
{ /* Use key if possible */
......@@ -1979,7 +1979,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
}
else
{
found_constrain= 1;
found_constraint= 1;
/*
Check if we found full key
*/
......@@ -2133,12 +2133,28 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
s->table->used_keys && best_key) &&
!(s->table->force_index && best_key))
{ // Check full join
ha_rows rnd_records= s->found_records;
/* Estimate cost of reading table. */
tmp= (double) s->read_time;
tmp= s->table->file->scan_time();
/*
If there is a restriction on the table, assume that 25% of the
rows can be skipped on next part.
This is to force tables that this table depends on before this
table
*/
if (found_constraint)
rnd_records-= rnd_records/4;
if (s->on_expr) // Can't use join cache
{
tmp= record_count *
/* We have to read the whole table for each record */
tmp*= record_count;
(tmp +
/*
And we have to skip rows which does not satisfy join
condition for each record.
*/
(s->records - rnd_records)/(double) TIME_FOR_COMPARE);
}
else
{
......@@ -2146,30 +2162,25 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
tmp*= (1.0 + floor((double) cache_record_length(join,idx) *
record_count /
(double) thd->variables.join_buff_size));
/*
We don't make full cartesian product between rows in the scanned
table and existing records because we skip all rows from the
scanned table, which does not satisfy join condition when
we read the table (see flush_cached_records for details). Here we
take into account cost to read and skip these records.
*/
tmp+= (s->records - rnd_records)/(double) TIME_FOR_COMPARE;
}
/*
We estimate the cost of making full cortesian product between
rows in the scanned table and generated records as
record_count*s->records/TIME_FOR_COMPARE. Taking into account
cost of evaluating WHERE clause for s->found_records is not
necessary because it costs much less than the cost mentioned
above.
We estimate the cost of evaluating WHERE clause for found records
as record_count * rnd_records + TIME_FOR_COMPARE. This cost plus
tmp give us total cost of using TABLE SCAN
*/
if (best == DBL_MAX ||
(tmp + record_count/(double) TIME_FOR_COMPARE*s->records <
(tmp + record_count/(double) TIME_FOR_COMPARE*rnd_records <
best + record_count/(double) TIME_FOR_COMPARE*records))
{
/*
If there is a restriction on the table, assume that 25% of the
rows can be skipped on next part.
This is to force tables that this table depends on before this
table
*/
ha_rows rnd_records= s->found_records;
if (found_constrain)
rnd_records-= rnd_records/4;
/*
If the table has a range (s->quick is set) make_join_select()
will ensure that this will be used
......
......@@ -178,7 +178,7 @@ case "$mode" in
# delete lock for RedHat / SuSE
if test -f /var/lock/subsys/mysql
then
rm /var/lock/subsys/mysql
rm -f /var/lock/subsys/mysql
fi
else
echo "No mysqld pid file found. Looked for $pid_file."
......
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