Commit 5614033d authored by unknown's avatar unknown

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

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


sql/mysqld.cc:
  Auto merged
parents af6141b2 93d36845
......@@ -43,6 +43,7 @@ jani@janikt.pp.saunalahti.fi
jani@rhols221.adsl.netsonic.fi
jani@rhols221.arenanet.fi
jani@ua126d19.elisa.omakaista.fi
jani@ua141d10.elisa.omakaista.fi
jcole@abel.spaceapes.com
jcole@main.burghcom.com
jcole@mugatu.spaceapes.com
......
......@@ -740,6 +740,8 @@ extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
uint prealloc_size);
extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
......
DROP TABLE IF EXISTS t620;
CREATE TABLE t620 (
recid int(11) NOT NULL auto_increment,
dyninfo text,
PRIMARY KEY (recid)
) TYPE=MyISAM;
INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n');
INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n');
SELECT DISTINCT
(IF( LOCATE( 'year=\"', dyninfo ) = 1,
SUBSTRING( dyninfo, 6+1, LOCATE('\"\r',dyninfo) - 6 -1),
IF( LOCATE( '\nyear=\"', dyninfo ),
SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7,
LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year
FROM t620
HAVING year != '' ORDER BY year;
year
--default-character-set=tis620
DROP TABLE IF EXISTS t620;
CREATE TABLE t620 (
recid int(11) NOT NULL auto_increment,
dyninfo text,
PRIMARY KEY (recid)
) TYPE=MyISAM;
INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n');
INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n');
SELECT DISTINCT
(IF( LOCATE( 'year=\"', dyninfo ) = 1,
SUBSTRING( dyninfo, 6+1, LOCATE('\"\r',dyninfo) - 6 -1),
IF( LOCATE( '\nyear=\"', dyninfo ),
SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7,
LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year
FROM t620
HAVING year != '' ORDER BY year;
......@@ -47,6 +47,72 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
#endif
}
/*
SYNOPSIS
reset_root_defaults()
mem_root memory root to change defaults of
block_size new value of block size. Must be
greater than ~68 bytes (the exact value depends on
platform and compilation flags)
pre_alloc_size new size of preallocated block. If not zero,
must be equal to or greater than block size,
otherwise means 'no prealloc'.
DESCRIPTION
Function aligns and assigns new value to block size; then it tries to
reuse one of existing blocks as prealloc block, or malloc new one of
requested size. If no blocks can be reused, all unused blocks are freed
before allocation.
*/
void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size)
{
mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
{
uint size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM));
if (!mem_root->pre_alloc || mem_root->pre_alloc->size != size)
{
USED_MEM *mem, **prev= &mem_root->free;
/*
Free unused blocks, so that consequent calls
to reset_root_defaults won't eat away memory.
*/
while (*prev)
{
mem= *prev;
if (mem->size == size)
{
/* We found a suitable block, no need to do anything else */
mem_root->pre_alloc= mem;
return;
}
if (mem->left + ALIGN_SIZE(sizeof(USED_MEM)) == mem->size)
{
/* remove block from the list and free it */
*prev= mem->next;
my_free((gptr) mem, MYF(0));
}
else
prev= &mem->next;
}
/* Allocate new prealloc block and add it to the end of free list */
if ((mem= (USED_MEM *) my_malloc(size, MYF(0))))
{
mem->size= size;
mem->left= pre_alloc_size;
mem->next= *prev;
*prev= mem_root->pre_alloc= mem;
}
}
}
else
#endif
mem_root->pre_alloc= 0;
}
gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
{
#if defined(HAVE_purify) && defined(EXTRA_DEBUG)
......
......@@ -298,9 +298,11 @@ int handle_options(int *argc, char ***argv,
--enable-'option-name'.
*optend was set to '0' if one used --disable-option
*/
*((my_bool*) optp->value)= (my_bool) (!optend || *optend == '1');
(*argc)--;
get_one_option(optp->id, optp, argument);
my_bool tmp= (my_bool) (!optend || *optend == '1');
*((my_bool*) optp->value)= tmp;
(*argc)--;
get_one_option(optp->id, optp,
tmp ? (char*) "1" : disabled_my_option);
continue;
}
argument= optend;
......
......@@ -711,7 +711,7 @@ extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
extern my_bool opt_safe_show_db, opt_local_infile;
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
extern my_bool opt_readonly;
extern my_bool opt_enable_named_pipe;
extern my_bool opt_enable_named_pipe, opt_sync_frm;
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
extern FILE *bootstrap_file;
......
......@@ -308,7 +308,7 @@ static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0;
my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
my_bool opt_log_slave_updates= 0, opt_console= 0;
my_bool opt_readonly = 0;
my_bool opt_readonly = 0, opt_sync_bdb_logs, opt_sync_frm;
volatile bool mqh_used = 0;
FILE *bootstrap_file=0;
......@@ -3158,7 +3158,7 @@ enum options_mysqld {
OPT_DELAY_KEY_WRITE_ALL, OPT_SLOW_QUERY_LOG,
OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR,
OPT_BDB_HOME, OPT_BDB_LOG,
OPT_BDB_TMP, OPT_BDB_NOSYNC,
OPT_BDB_TMP, OPT_BDB_SYNC,
OPT_BDB_LOCK, OPT_BDB_SKIP,
OPT_BDB_NO_RECOVER, OPT_BDB_SHARED,
OPT_MASTER_HOST, OPT_MASTER_USER,
......@@ -3251,7 +3251,8 @@ enum options_mysqld {
OPT_DEFAULT_WEEK_FORMAT,
OPT_RANGE_ALLOC_BLOCK_SIZE,
OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE,
OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE
OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE,
OPT_SYNC_FRM, OPT_BDB_NOSYNC
};
......@@ -3277,8 +3278,14 @@ struct my_option my_long_options[] =
{"bdb-no-recover", OPT_BDB_NO_RECOVER,
"Don't try to recover Berkeley DB tables on start", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"bdb-no-sync", OPT_BDB_NOSYNC, "Don't synchronously flush logs", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"bdb-no-sync", OPT_BDB_NOSYNC,
"Disable synchronously flushing logs. This option is deprecated, use --skip-sync-bdb-logs or sync-bdb-logs=0 instead",
// (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL,
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"sync-bdb-logs", OPT_BDB_SYNC,
"Synchronously flush logs. Enabled by default",
(gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL,
NO_ARG, 1, 0, 0, 0, 0, 0},
{"bdb-shared-data", OPT_BDB_SHARED,
"Start Berkeley DB in multi-process mode", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
......@@ -3286,6 +3293,9 @@ struct my_option my_long_options[] =
(gptr*) &berkeley_tmpdir, (gptr*) &berkeley_tmpdir, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif /* HAVE_BERKELEY_DB */
{"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default",
(gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
0, 0, 0, 0},
{"skip-bdb", OPT_BDB_SKIP, "Don't use berkeley db (will save memory)",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"big-tables", OPT_BIG_TABLES,
......@@ -4728,7 +4738,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
}
#ifdef HAVE_BERKELEY_DB
case OPT_BDB_NOSYNC:
berkeley_env_flags|=DB_TXN_NOSYNC;
/* Deprecated option */
opt_sync_bdb_logs= 0;
/* Fall through */
case OPT_BDB_SYNC:
if (!opt_sync_bdb_logs)
berkeley_env_flags|= DB_TXN_NOSYNC;
else
berkeley_env_flags&= ~DB_TXN_NOSYNC;
printf("berkeley_env_flags: %d, arg '%s'\n", berkeley_env_flags, argument);
break;
case OPT_BDB_NO_RECOVER:
berkeley_init_flags&= ~(DB_RECOVER);
......
......@@ -88,6 +88,8 @@ static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
static void fix_max_binlog_size(THD *thd, enum_var_type type);
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
static void fix_max_connections(THD *thd, enum_var_type type);
static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type);
/*
Variable definition list
......@@ -209,13 +211,17 @@ sys_var_long_ptr sys_query_cache_size("query_cache_size",
sys_var_thd_ulong sys_range_alloc_block_size("range_alloc_block_size",
&SV::range_alloc_block_size);
sys_var_thd_ulong sys_query_alloc_block_size("query_alloc_block_size",
&SV::query_alloc_block_size);
&SV::query_alloc_block_size,
fix_thd_mem_root);
sys_var_thd_ulong sys_query_prealloc_size("query_prealloc_size",
&SV::query_prealloc_size);
&SV::query_prealloc_size,
fix_thd_mem_root);
sys_var_thd_ulong sys_trans_alloc_block_size("transaction_alloc_block_size",
&SV::trans_alloc_block_size);
&SV::trans_alloc_block_size,
fix_trans_mem_root);
sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
&SV::trans_prealloc_size);
&SV::trans_prealloc_size,
fix_trans_mem_root);
#ifdef HAVE_QUERY_CACHE
sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
......@@ -763,6 +769,24 @@ static void fix_max_connections(THD *thd, enum_var_type type)
}
static void fix_thd_mem_root(THD *thd, enum_var_type type)
{
if (type != OPT_GLOBAL)
reset_root_defaults(&thd->mem_root,
thd->variables.query_alloc_block_size,
thd->variables.query_prealloc_size);
}
static void fix_trans_mem_root(THD *thd, enum_var_type type)
{
if (type != OPT_GLOBAL)
reset_root_defaults(&thd->transaction.mem_root,
thd->variables.trans_alloc_block_size,
thd->variables.trans_prealloc_size);
}
bool sys_var_long_ptr::update(THD *thd, set_var *var)
{
ulonglong tmp= var->value->val_int();
......
......@@ -150,7 +150,7 @@ int rea_create_table(my_string file_name,
my_free((gptr) screen_buff,MYF(0));
my_afree((gptr) keybuff);
if (my_sync(file, MYF(MY_WME)))
if (opt_sync_frm && my_sync(file, MYF(MY_WME)))
goto err2;
if (my_close(file,MYF(MY_WME)) ||
ha_create_table(file_name,create_info,0))
......
......@@ -15,6 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Copyright (C) 2003 by Sathit Jittanupat <jsat66@hotmail.com,jsat66@yahoo.com>
* solving bug crash with long text field string
* sorting with different number of space or sign char. within string
Copyright (C) 2001 by Korakot Chaovavanich <korakot@iname.com> and
Apisilp Trunganont <apisilp@pantip.inet.co.th>
Copyright (C) 1998, 1999 by Pruet Boonma <pruet@eng.cmu.ac.th>
......@@ -49,10 +53,6 @@
#include "m_ctype.h"
#include "t_ctype.h"
static uchar* thai2sortable(const uchar *tstr,int len);
#define BUFFER_MULTIPLY 4
#define buffsize(s) (BUFFER_MULTIPLY * (strlen(s) + 1))
#define M L_MIDDLE
#define U L_UPPER
#define L L_LOWER
......@@ -453,13 +453,77 @@ uchar NEAR sort_order_tis620[]=
Arg: const source string and length of converted string
Ret: Sortable string
*/
static void _thai2sortable(uchar *tstr)
{
uchar *p ;
int len,tlen ;
uchar c,l2bias ;
tlen= len = strlen (tstr) ;
l2bias = 256 - 8 ;
for (p=tstr; tlen > 0; p++,tlen--)
{
c = *p ;
if (isthai(c))
{
int *t_ctype0 = t_ctype[c] ;
if (isconsnt(c))
l2bias -= 8 ;
if (isldvowel(c) && isconsnt(p[1]))
{
/*
simply swap between leading-vowel and consonant
*/
*p = p[1];
p[1]= c ;
tlen-- ;
p++;
continue ;
}
// if found level 2 char (L2_GARAN,L2_TONE*,L2_TYKHU) move to last
if (t_ctype0[1]>= L2_GARAN)
{
// l2bias use to control position weight of l2char
// example (*=l2char) XX*X must come before X*XX
strcpy (p,p+1) ;
tstr[len-1] = l2bias + t_ctype0[1]- L2_GARAN +1 ;
p-- ;
continue ;
}
}
else
{
l2bias -= 8 ;
*p = to_lower_tis620[c];
}
/*
this routine skip non-printable char
but not necessary, leave it like raw ascii 8 bits
*/
/*
t_ctype0 = t_ctype[p[0]];
if ((t_ctype0[0]|t_ctype0[1]|t_ctype0[2])==IGNORE)
{
strcpy(p,p+1);
p-- ;
}
*/
}
}
/*
NOTE: isn't it faster to alloc buffer in calling function?
*/
*/
/*
Sathit's NOTE: we don't use this function anymore
static uchar* thai2sortable(const uchar * tstr,int len)
{
*/
/* We use only 3 levels (neglect capitalization). */
/*
const uchar* p= tstr;
uchar *outBuf;
uchar *pRight1, *pRight2, *pRight3;
......@@ -526,6 +590,7 @@ static uchar* thai2sortable(const uchar * tstr,int len)
memcpy(pRight1, pLeft3, pRight3 - pLeft3);
return outBuf;
}
*/
/* strncoll() replacement, compare 2 string, both are conveted to sortable string
Arg: 2 Strings and it compare length
......@@ -533,16 +598,27 @@ static uchar* thai2sortable(const uchar * tstr,int len)
*/
int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
{
uchar *tc1, *tc2;
int i;
tc1= thai2sortable(s1, len1);
tc2= thai2sortable(s2, len2);
i= strcmp((char*)tc1, (char*)tc2);
if (tc1 != s1)
free(tc1);
if (tc2 != s2)
free(tc2);
return i;
uchar buf[80] ;
uchar *tc1, *tc2;
int i;
len1= (int) strnlen((char*) s1,len1);
len2= (int) strnlen((char*) s2,len2);
if ((len1 + len2 +2) > (int) sizeof(buf))
tc1 = (uchar *)malloc(len1+len2) ;
else
tc1 = buf ;
tc2 = tc1 + len1+1 ;
strncpy((char *)tc1,(char *)s1,len1) ;
tc1[len1] = 0; // if s1's length > len1, need to put 'end of string'
strncpy((char *)tc2,(char *)s2,len2) ;
tc2[len2] = 0; // put end of string
_thai2sortable(tc1);
_thai2sortable(tc2);
i= strcmp((char*)tc1, (char*)tc2);
if (tc1 != buf )
free(tc1);
return i;
}
/* strnxfrm replacment, convert Thai string to sortable string
......@@ -551,15 +627,12 @@ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
*/
int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen)
{
uint bufSize;
uchar *tmp;
bufSize= (uint) buffsize((char*)src);
tmp= thai2sortable(src,srclen);
set_if_smaller(bufSize,(uint) len);
memcpy((uchar *)dest, tmp, bufSize);
if (tmp != src)
free(tmp);
return (int)bufSize;
if (len > srclen)
len = srclen ;
strncpy (dest,src,len) ;
dest[len] = 0; // if src's length > len, need to put 'end of string'
_thai2sortable(dest);
return strlen(dest);
}
/* strcoll replacment, compare 2 strings
......@@ -568,16 +641,7 @@ int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen)
*/
int my_strcoll_tis620(const uchar * s1, const uchar * s2)
{
uchar *tc1, *tc2;
int i;
tc1= thai2sortable(s1, (int) strlen((char*)s1));
tc2= thai2sortable(s2, (int) strlen((char*)s2));
i= strcmp((char*)tc1, (char*)tc2);
if (tc1 != s1)
free(tc1);
if (tc2 != s2)
free(tc2);
return i;
return my_strnncoll_tis620(s1, strlen((char *)s1),s2,strlen((char *)s2));
}
/* strxfrm replacment, convert Thai string to sortable string
......@@ -586,15 +650,7 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2)
*/
int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
{
uint bufSize;
uchar *tmp;
bufSize= (uint)buffsize((char*) src);
tmp= thai2sortable(src, len);
memcpy((uchar *)dest, tmp, bufSize);
if (tmp != src)
free(tmp);
return bufSize;
return my_strnxfrm_tis620(dest,src,len,strlen((char *)src));
}
/* Convert SQL like string to C string
......@@ -658,20 +714,31 @@ void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length)
{
const uchar* fr= from;
uchar* p= ptr;
uint i;
if (length > field_length)
length= field_length;
while (length--)
if ((istone(*fr) || isdiacrt1(*fr)) &&
(islwrvowel(fr[1]) || isuprvowel(fr[1])))
{
*p= fr[1];
p[1]= *fr;
fr+= 2;
p+= 2;
length--;
for (i=0;i<length;i++,p++,fr++)
{
*p = *fr ;
/* Sathit's NOTE: it's better idea not to do any normalize
*/
if (istone(*fr) || isdiacrt1(*fr))
{
if (i > 0 && (islwrvowel(fr[-1]) || isuprvowel(fr[-1])))
continue ;
if(islwrvowel(fr[1]) || isuprvowel(fr[1]))
{
*p= fr[1];
p[1]= *fr;
fr++;
p++;
i++ ;
}
}
else
*p++ = *fr++;
}
}
......@@ -59,6 +59,12 @@ export PATH
mode=$1 # start or stop
case `echo "testing\c"`,`echo -n testing` in
*c*,-n*) echo_n= echo_c=' ';;
*c*,*) echo_n=-n echo_c= ;;
*) echo_n= echo_c='\c';;
esac
parse_arguments() {
for arg do
case "$arg" in
......@@ -169,7 +175,7 @@ case "$mode" in
sleep 1
while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
do
[ -z "$flags" ] && echo "Wait for mysqld to exit\c" || echo ".\c"
[ -z "$flags" ] && echo $echo_n "Wait for mysqld to exit$echo_c" || echo $echo_n ".$echo_c"
flags=a$flags
sleep 1
done
......
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