Commit f0e23df6 authored by unknown's avatar unknown

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

into serg.mylan:/usr/home/serg/Abk/mysql-4.1

parents b9c0f6b7 736963b5
......@@ -2834,25 +2834,13 @@ com_status(String *buffer __attribute__((unused)),
const char *status;
char buff[22];
ulonglong id;
MYSQL_RES *result;
LINT_INIT(result);
tee_puts("--------------", stdout);
usage(1); /* Print version */
if (connected)
{
MYSQL_RES *result;
LINT_INIT(result);
tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") &&
(result=mysql_use_result(&mysql)))
{
MYSQL_ROW cur=mysql_fetch_row(result);
if (cur)
{
tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
}
mysql_free_result(result);
}
#ifdef HAVE_OPENSSL
if (mysql.net.vio && mysql.net.vio->ssl_arg &&
SSL_get_cipher((SSL*) mysql.net.vio->ssl_arg))
......@@ -2886,9 +2874,20 @@ com_status(String *buffer __attribute__((unused)),
if ((id= mysql_insert_id(&mysql)))
tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff));
tee_fprintf(stdout, "Client characterset:\t%s\n",
charset_info->name);
tee_fprintf(stdout, "Server characterset:\t%s\n", mysql.charset->name);
if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database") &&
(result=mysql_use_result(&mysql)))
{
MYSQL_ROW cur=mysql_fetch_row(result);
if (cur)
{
tee_fprintf(stdout, "Server characterset:\t%s\n", cur[0] ? cur[0] : "");
tee_fprintf(stdout, "Db characterset:\t%s\n", cur[3] ? cur[3] : "");
tee_fprintf(stdout, "Client characterset:\t%s\n", cur[2] ? cur[2] : "");
tee_fprintf(stdout, "Conn. characterset:\t%s\n", cur[1] ? cur[1] : "");
}
mysql_free_result(result);
}
#ifndef EMBEDDED_LIBRARY
if (strstr(mysql_get_host_info(&mysql),"TCP/IP") || ! mysql.unix_socket)
tee_fprintf(stdout, "TCP port:\t\t%d\n", mysql.port);
......
......@@ -2715,7 +2715,7 @@ case $default_charset in
define(UCSC2, ucs2_czech_ci ucs2_danish_ci)
define(UCSC3, ucs2_estonian_ci ucs2_icelandic_ci)
define(UCSC4, ucs2_latvian_ci ucs2_lithuanian_ci)
define(UCSC5, ucs2_polish_ci ucs2_romanian_ci)
define(UCSC5, ucs2_persian_ci ucs2_polish_ci ucs2_romanian_ci)
define(UCSC6, ucs2_slovak_ci ucs2_slovenian_ci)
define(UCSC7, ucs2_spanish2_ci ucs2_spanish_ci)
define(UCSC8, ucs2_swedish_ci ucs2_turkish_ci)
......@@ -2733,7 +2733,7 @@ case $default_charset in
define(UTFC2, utf8_czech_ci utf8_danish_ci)
define(UTFC3, utf8_estonian_ci utf8_icelandic_ci)
define(UTFC4, utf8_latvian_ci utf8_lithuanian_ci)
define(UTFC5, utf8_polish_ci utf8_romanian_ci)
define(UTFC5, utf8_persian_ci utf8_polish_ci utf8_romanian_ci)
define(UTFC6, utf8_slovak_ci utf8_slovenian_ci)
define(UTFC7, utf8_spanish2_ci utf8_spanish_ci)
define(UTFC8, utf8_swedish_ci utf8_turkish_ci)
......
......@@ -1860,14 +1860,14 @@ MYSQL_STMT * STDCALL mysql_prepare(MYSQL *mysql, const char *query,
a server-side prepared statement. Memory for this structure (~700
bytes) is allocated using 'malloc'. Once created, the handle can be
reused many times. Created statement handle is bound to connection
handle provided to this call: it's lifetime is limited by lifetime
handle provided to this call: its lifetime is limited by lifetime
of connection.
'mysql_stmt_init()' is a pure local call, server side structure is
created only in mysql_stmt_prepare.
Next steps you may want to make:
- set a statement attribute (mysql_stmt_attr_set()),
- prepare statement handle with a query (mysql_stmt_prepare()),
- close statement handle and free it's memory (mysql_stmt_close()),
- close statement handle and free its memory (mysql_stmt_close()),
- reset statement with mysql_stmt_reset() (a no-op which will
just return).
Behaviour of the rest of API calls on this statement is not defined yet
......@@ -2592,7 +2592,7 @@ stmt_read_row_no_data(MYSQL_STMT *stmt __attribute__((unused)),
mysql_stmt_attr_get()
mysql_stmt_attr_set()
attr_type statemenet attribute
attr_type statement attribute
value casted to const void * pointer to value.
RETURN VALUE
......@@ -2688,7 +2688,7 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
mysql_stmt_free_result(stmt);
/*
No need to check for stmt->state: if the statement wasn't
prepared we'll get 'unknown statemenet handler' error from server.
prepared we'll get 'unknown statement handler' error from server.
*/
if (mysql->methods->stmt_execute(stmt))
DBUG_RETURN(1);
......@@ -2813,7 +2813,7 @@ static my_bool int_is_null_false= 0;
By properly initializing bind array you can bind virtually any
C language type to statement's placeholders:
First, it's strongly recommended to always zero-initialize entire
bind structure before setting it's members. This will both shorten
bind structure before setting its members. This will both shorten
your application code and make it robust to future extensions of
MYSQL_BIND structure.
Then you need to assign typecode of your application buffer to
......
This diff is collapsed.
......@@ -64,3 +64,6 @@ find_in_set('a',binary 'A,B,C')
select find_in_set(binary 'a', 'A,B,C');
find_in_set(binary 'a', 'A,B,C')
0
select find_in_set('1','3,1,');
find_in_set('1','3,1,')
2
......@@ -723,3 +723,16 @@ col2 col col
2 2 2
1 3 3
drop table t1, t2;
create table t1 (a char(25));
insert into t1 set a = repeat('x', 20);
insert into t1 set a = concat(repeat('x', 19), 'z');
insert into t1 set a = concat(repeat('x', 19), 'ab');
insert into t1 set a = concat(repeat('x', 19), 'aa');
set max_sort_length=20;
select a from t1 order by a;
a
xxxxxxxxxxxxxxxxxxxab
xxxxxxxxxxxxxxxxxxxaa
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxz
drop table t1;
This diff is collapsed.
......@@ -47,3 +47,8 @@ select find_in_set(binary 'a',binary 'A,B,C');
select find_in_set('a',binary 'A,B,C');
select find_in_set(binary 'a', 'A,B,C');
#
# Bug5513:FIND_IN_SET fails if set ends with a comma
#
select find_in_set('1','3,1,');
......@@ -486,3 +486,16 @@ select t2.col2 as col, t2.col from t2 order by t2.col;
select t2.col2, t2.col, t2.col from t2 order by t2.col;
drop table t1, t2;
#
# Bug #5428: a problem with small max_sort_length value
#
create table t1 (a char(25));
insert into t1 set a = repeat('x', 20);
insert into t1 set a = concat(repeat('x', 19), 'z');
insert into t1 set a = concat(repeat('x', 19), 'ab');
insert into t1 set a = concat(repeat('x', 19), 'aa');
set max_sort_length=20;
select a from t1 order by a;
drop table t1;
......@@ -39,6 +39,7 @@ extern CHARSET_INFO my_charset_ucs2_lithuanian_uca_ci;
extern CHARSET_INFO my_charset_ucs2_slovak_uca_ci;
extern CHARSET_INFO my_charset_ucs2_spanish2_uca_ci;
extern CHARSET_INFO my_charset_ucs2_roman_uca_ci;
extern CHARSET_INFO my_charset_ucs2_persian_uca_ci;
#endif
#ifdef HAVE_CHARSET_utf8
......@@ -58,6 +59,7 @@ extern CHARSET_INFO my_charset_utf8_lithuanian_uca_ci;
extern CHARSET_INFO my_charset_utf8_slovak_uca_ci;
extern CHARSET_INFO my_charset_utf8_spanish2_uca_ci;
extern CHARSET_INFO my_charset_utf8_roman_uca_ci;
extern CHARSET_INFO my_charset_utf8_persian_uca_ci;
#endif
my_bool init_compiled_charsets(myf flags __attribute__((unused)))
......@@ -127,6 +129,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_ucs2_slovak_uca_ci);
add_compiled_collation(&my_charset_ucs2_spanish2_uca_ci);
add_compiled_collation(&my_charset_ucs2_roman_uca_ci);
add_compiled_collation(&my_charset_ucs2_persian_uca_ci);
#endif
#ifdef HAVE_CHARSET_ujis
......@@ -153,6 +156,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_utf8_slovak_uca_ci);
add_compiled_collation(&my_charset_utf8_spanish2_uca_ci);
add_compiled_collation(&my_charset_utf8_roman_uca_ci);
add_compiled_collation(&my_charset_utf8_persian_uca_ci);
#endif
/* Copy compiled charsets */
......
......@@ -90,6 +90,12 @@ class ha_tina: public handler
/* The next method will never be called */
virtual double read_time(ha_rows rows) { DBUG_ASSERT(0); return((double) rows / 20.0+1); }
virtual bool fast_key_read() { return 1;}
/*
TODO: return actual upper bound of number of records in the table.
(e.g. save number of records seen on full table scan and/or use file size
as upper bound)
*/
ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; }
int open(const char *name, int mode, uint test_if_locked);
int close(void);
......
......@@ -169,7 +169,13 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
else
#endif
{
records=table->file->estimate_number_of_rows();
records= table->file->estimate_rows_upper_bound();
/*
If number of records is not known, use as much of sort buffer
as possible.
*/
if (records == HA_POS_ERROR)
records--; // we use 'records+1' below.
selected_records_file= 0;
}
......@@ -315,7 +321,7 @@ static char **make_char_array(register uint fields, uint length, myf my_flag)
} /* make_char_array */
/* Read all buffer pointers into memory */
/* Read 'count' number of buffer pointers into memory */
static BUFFPEK *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count)
{
......@@ -336,8 +342,40 @@ static BUFFPEK *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count)
}
/* Search after sort_keys and place them in a temp. file */
/*
Search after sort_keys and write them into tempfile.
SYNOPSIS
find_all_keys()
param Sorting parameter
select Use this to get source data
sort_keys Array of pointers to sort key + addon buffers.
buffpek_pointers File to write BUFFPEKs describing sorted segments
in tempfile.
tempfile File to write sorted sequences of sortkeys to.
indexfile If !NULL, use it for source data (contains rowids)
NOTE
Basic idea:
while (get_next_sortkey())
{
if (no free space in sort_keys buffers)
{
sort sort_keys buffer;
dump sorted sequence to 'tempfile';
dump BUFFPEK describing sequence location into 'buffpek_pointers';
}
put sort key into 'sort_keys';
}
if (sort_keys has some elements && dumped at least once)
sort-dump-dump as above;
else
don't sort, leave sort_keys array to be sorted by caller.
All produced sequences are guaranteed to be non-empty.
RETURN
Number of records written on success.
HA_POS_ERROR on error.
*/
static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
uchar **sort_keys,
......@@ -452,7 +490,25 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
} /* find_all_keys */
/* Skriver en buffert med nycklar till filen */
/*
Sort the buffer and write:
1) the sorted sequence to tempfile
2) a BUFFPEK describing the sorted sequence position to buffpek_pointers
(was: Skriver en buffert med nycklar till filen)
SYNOPSIS
write_keys()
param Sort parameters
sort_keys Array of pointers to keys to sort
count Number of elements in sort_keys array
buffpek_pointers One 'BUFFPEK' struct will be written into this file.
The BUFFPEK::{file_pos, count} will indicate where
the sorted data was stored.
tempfile The sorted sequence will be written into this file.
RETURN
0 OK
1 Error
*/
static int
write_keys(SORTPARAM *param, register uchar **sort_keys, uint count,
......@@ -784,7 +840,21 @@ uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
/*
Merge buffers to one buffer
Merge buffers to one buffer
SYNOPSIS
merge_buffers()
param Sort parameter
from_file File with source data (BUFFPEKs point to this file)
to_file File to write the sorted result data.
sort_buffer Buffer for data to store up to MERGEBUFF2 sort keys.
lastbuff OUT Store here BUFFPEK describing data written to to_file
Fb First element in source BUFFPEKs array
Tb Last element in source BUFFPEKs array
flag
RETURN
0 - OK
other - error
*/
int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
......@@ -822,6 +892,9 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
strpos= (uchar*) sort_buffer;
org_max_rows=max_rows= param->max_rows;
/* The following will fire if there is not enough space in sort_buffer */
DBUG_ASSERT(maxcount!=0);
if (init_queue(&queue, (uint) (Tb-Fb)+1, offsetof(BUFFPEK,key), 0,
(queue_compare) (cmp= get_ptr_compare(sort_length)),
(void*) &sort_length))
......
......@@ -25,7 +25,7 @@
We will need an updated Berkeley DB version for this.
- Killing threads that has got a 'deadlock'
- SHOW TABLE STATUS should give more information about the table.
- Get a more accurate count of the number of rows (estimate_number_of_rows()).
- Get a more accurate count of the number of rows (estimate_rows_upper_bound()).
We could store the found number of rows when the table is scanned and
then increment the counter for each attempted write.
- We will need to extend the manager thread to makes checkpoints at
......@@ -63,7 +63,7 @@
#define HA_BERKELEY_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_BERKELEY_RANGE_COUNT 100
#define HA_BERKELEY_MAX_ROWS 10000000 /* Max rows in table */
/* extra rows for estimate_number_of_rows() */
/* extra rows for estimate_rows_upper_bound() */
#define HA_BERKELEY_EXTRA_ROWS 100
/* Bits for share->status */
......@@ -2556,7 +2556,7 @@ end:
Used when sorting to allocate buffers and by the optimizer.
*/
ha_rows ha_berkeley::estimate_number_of_rows()
ha_rows ha_berkeley::estimate_rows_upper_bound()
{
return share->rows + HA_BERKELEY_EXTRA_ROWS;
}
......
......@@ -100,7 +100,7 @@ class ha_berkeley: public handler
ulong table_flags(void) const { return int_table_flags; }
uint max_supported_keys() const { return MAX_KEY-1; }
uint extra_rec_buf_length() { return BDB_HIDDEN_PRIMARY_KEY_LENGTH; }
ha_rows estimate_number_of_rows();
ha_rows estimate_rows_upper_bound();
const key_map *keys_to_use_for_scanning() { return &key_map_full; }
bool has_transactions() { return 1;}
......
......@@ -4115,7 +4115,7 @@ Gives an UPPER BOUND to the number of rows in a table. This is used in
filesort.cc. */
ha_rows
ha_innobase::estimate_number_of_rows(void)
ha_innobase::estimate_rows_upper_bound(void)
/*======================================*/
/* out: upper bound of rows */
{
......@@ -4124,7 +4124,7 @@ ha_innobase::estimate_number_of_rows(void)
ulonglong estimate;
ulonglong local_data_file_length;
DBUG_ENTER("estimate_number_of_rows");
DBUG_ENTER("estimate_rows_upper_bound");
/* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table
......@@ -4204,7 +4204,7 @@ ha_innobase::read_time(
time_for_scan = scan_time();
if ((total_rows = estimate_number_of_rows()) < rows)
if ((total_rows = estimate_rows_upper_bound()) < rows)
return time_for_scan;
return (ranges + (double) rows / (double) total_rows * time_for_scan);
......
......@@ -150,7 +150,7 @@ class ha_innobase: public handler
void position(byte *record);
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
ha_rows estimate_number_of_rows();
ha_rows estimate_rows_upper_bound();
int create(const char *name, register TABLE *form,
HA_CREATE_INFO *create_info);
......
......@@ -300,7 +300,15 @@ public:
virtual const key_map *keys_to_use_for_scanning() { return &key_map_empty; }
virtual bool has_transactions(){ return 0;}
virtual uint extra_rec_buf_length() { return 0; }
virtual ha_rows estimate_number_of_rows() { return records+EXTRA_RECORDS; }
/*
Return upper bound of current number of records in the table
(max. of how many records one will retrieve when doing a full table scan)
If upper bound is not known, HA_POS_ERROR should be returned as a max
possible upper bound.
*/
virtual ha_rows estimate_rows_upper_bound()
{ return records+EXTRA_RECORDS; }
virtual const char *index_type(uint key_number) { DBUG_ASSERT(0); return "";}
......
......@@ -1455,10 +1455,11 @@ longlong Item_func_find_in_set::val_int()
{
const char *substr_end= str_end + symbol_len;
bool is_last_item= (substr_end == real_end);
if (wc == (my_wc_t) separator || is_last_item)
bool is_separator= (wc == (my_wc_t) separator);
if (is_separator || is_last_item)
{
position++;
if (is_last_item)
if (is_last_item && !is_separator)
str_end= substr_end;
if (!my_strnncoll(cs, (const uchar *) str_begin,
str_end - str_begin,
......
......@@ -6657,6 +6657,42 @@ static const char roman[]= /* i.e. Classical Latin */
"& I << j <<< J "
"& V << u <<< U ";
/*
Persian collation support was provided by
Jody McIntyre <mysql@modernduck.com>
To: internals@lists.mysql.com
Subject: Persian UTF8 collation support
Date: 17.08.2004
Contraction is not implemented. Some implementations do perform
contraction but others do not, and it is able to sort all my test
strings correctly.
Jody.
*/
static const char persian[]=
"& \\u066D < \\u064E < \\uFE76 < \\uFE77 < \\u0650 < \\uFE7A < \\uFE7B"
" < \\u064F < \\uFE78 < \\uFE79 < \\u064B < \\uFE70 < \\uFE71"
" < \\u064D < \\uFE74 < \\u064C < \\uFE72"
"& \\uFE7F < \\u0653 < \\u0654 < \\u0655 < \\u0670"
"& \\u0669 < \\u0622 < \\u0627 < \\u0671 < \\u0621 < \\u0623 < \\u0625"
" < \\u0624 < \\u0626"
"& \\u0642 < \\u06A9 < \\u0643"
"& \\u0648 < \\u0647 < \\u0629 < \\u06C0 < \\u06CC < \\u0649 < \\u064A"
"& \\uFE80 < \\uFE81 < \\uFE82 < \\uFE8D < \\uFE8E < \\uFB50 < \\uFB51"
" < \\uFE80 < \\uFE83 < \\uFE84 < \\uFE87 < \\uFE88 < \\uFE85"
" < \\uFE86 < \\u0689 < \\u068A"
"& \\uFEAE < \\uFDFC"
"& \\uFED8 < \\uFB8E < \\uFB8F < \\uFB90 < \\uFB91 < \\uFED9 < \\uFEDA"
" < \\uFEDB < \\uFEDC"
"& \\uFEEE < \\uFEE9 < \\uFEEA < \\uFEEB < \\uFEEC < \\uFE93 < \\uFE94"
" < \\uFBA4 < \\uFBA5 < \\uFBFC < \\uFBFD < \\uFBFE < \\uFBFF"
" < \\uFEEF < \\uFEF0 < \\uFEF1 < \\uFEF2 < \\uFEF3 < \\uFEF4"
" < \\uFEF5 < \\uFEF6 < \\uFEF7 < \\uFEF8 < \\uFEF9 < \\uFEFA"
" < \\uFEFB < \\uFEFC";
/*
Unicode Collation Algorithm:
Collation element (weight) scanner,
......@@ -7671,7 +7707,7 @@ static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems,
return (size_t) nitems;
}
#define MY_MAX_COLL_RULE 64
#define MY_MAX_COLL_RULE 128
/*
This function copies an UCS2 collation from
......@@ -8360,6 +8396,35 @@ CHARSET_INFO my_charset_ucs2_roman_uca_ci=
&my_collation_ucs2_uca_handler
};
CHARSET_INFO my_charset_ucs2_persian_uca_ci=
{
144,0,0, /* number */
MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE,
"ucs2", /* cs name */
"ucs2_persian_ci", /* name */
"", /* comment */
persian, /* tailoring */
NULL, /* ctype */
NULL, /* to_lower */
NULL, /* to_upper */
NULL, /* sort_order */
NULL, /* contractions */
NULL, /* sort_order_big*/
NULL, /* tab_to_uni */
NULL, /* tab_from_uni */
NULL, /* state_map */
NULL, /* ident_map */
8, /* strxfrm_multiply */
2, /* mbminlen */
2, /* mbmaxlen */
9, /* min_sort_char */
0xFFFF, /* max_sort_char */
&my_charset_ucs2_handler,
&my_collation_ucs2_uca_handler
};
#endif
......@@ -8838,4 +8903,32 @@ CHARSET_INFO my_charset_utf8_roman_uca_ci=
&my_charset_utf8_handler,
&my_collation_any_uca_handler
};
CHARSET_INFO my_charset_utf8_persian_uca_ci=
{
208,0,0, /* number */
MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE,
"utf8", /* cs name */
"utf8_persian_ci", /* name */
"", /* comment */
persian, /* tailoring */
ctype_utf8, /* ctype */
NULL, /* to_lower */
NULL, /* to_upper */
NULL, /* sort_order */
NULL, /* contractions */
NULL, /* sort_order_big*/
NULL, /* tab_to_uni */
NULL, /* tab_from_uni */
NULL, /* state_map */
NULL, /* ident_map */
8, /* strxfrm_multiply */
1, /* mbminlen */
2, /* mbmaxlen */
9, /* min_sort_char */
0xFFFF, /* max_sort_char */
&my_charset_utf8_handler,
&my_collation_any_uca_handler
};
#endif
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