Commit f2c2279b authored by mskold@mysql.com's avatar mskold@mysql.com

Merge mskold@build.mysql.com:/home/bk/mysql-4.1

into mysql.com:/usr/local/home/marty/MySQL/test/mysql-4.1
parents f06d8027 8df96ce0
......@@ -24,6 +24,7 @@ bar@bar.udmsearch.izhnet.ru
bar@deer.(none)
bar@gw.udmsearch.izhnet.ru
bar@mysql.com
bar@noter.intranet.mysql.r18.ru
bell@laptop.sanja.is.com.ua
bell@sanja.is.com.ua
bk@admin.bk
......
......@@ -725,7 +725,8 @@ extern void my_free_lock(byte *ptr,myf flags);
#define my_free_lock(A,B) my_free((A),(B))
#endif
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define clear_alloc_root(A) bzero((void *) (A), sizeof(MEM_ROOT))
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; } while(0)
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
......
......@@ -505,7 +505,7 @@ double rtree_overlapping_area(HA_KEYSEG *keyseg, uchar* a, uchar* b,
amax = korr_func(a+len); \
bmax = korr_func(b+len); \
a_area *= (((double)amax) - ((double)amin)); \
*ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
}
#define RT_AREA_INC_GET(type, get_func, len)\
......@@ -516,7 +516,7 @@ double rtree_overlapping_area(HA_KEYSEG *keyseg, uchar* a, uchar* b,
get_func(amax, a+len); \
get_func(bmax, b+len); \
a_area *= (((double)amax) - ((double)amin)); \
*ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
}
/*
......@@ -526,6 +526,7 @@ double rtree_area_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
uint key_length, double *ab_area)
{
double a_area= 1.0;
double loc_ab_area= 1.0;
*ab_area= 1.0;
for (; (int)key_length > 0; keyseg += 2)
......@@ -575,7 +576,7 @@ double rtree_area_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
RT_AREA_INC_GET(double, mi_float8get, 8);
break;
case HA_KEYTYPE_END:
return *ab_area - a_area;
goto safe_end;
default:
return -1;
}
......@@ -584,7 +585,9 @@ double rtree_area_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
a+= keyseg_length;
b+= keyseg_length;
}
return *ab_area - a_area;
safe_end:
*ab_area= loc_ab_area;
return loc_ab_area - a_area;
}
#define RT_PERIM_INC_KORR(type, korr_func, len) \
......
......@@ -485,3 +485,99 @@ MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a);
AsText(a)
POINT(1 1)
drop table t1;
CREATE TABLE t1 (Coordinates POINT NOT NULL, SPATIAL INDEX(Coordinates));
INSERT INTO t1 VALUES(GeomFromText('POINT(383293632 1754448)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(564952612 157516260)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(903994614 180726515)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(98128178 141127631)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(862547902 799334546)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(341989013 850270906)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(803302376 93039099)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(857439153 817431356)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(319757546 343162742)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(826341972 717484432)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(305066789 201736238)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(626068992 616241497)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(55789424 755830108)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(802874458 312435220)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(153795660 551723671)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(242207428 537089292)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(553478119 807160039)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(694605552 457472733)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(987886554 792733729)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(598600363 850434457)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(592068275 940589376)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(700705362 395370650)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(33628474 558144514)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(212802006 353386020)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(901307256 39143977)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(70870451 206374045)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(240880214 696939443)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(822615542 296669638)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(452769551 625489999)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(609104858 606565210)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(177213669 851312285)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(143654501 730691787)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(658472325 838260052)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(188164520 646358878)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(630993781 786764883)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(496793334 223062055)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(727354258 197498696)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(618432704 760982731)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(755643210 831234710)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(114368751 656950466)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(870378686 185239202)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(863324511 111258900)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(882178645 685940052)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(407928538 334948195)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(311430051 17033395)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(941513405 488643719)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(868345680 85167906)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(219335507 526818004)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(923427958 407500026)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(173176882 554421738)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(194264908 669970217)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(777483793 921619165)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(867468912 395916497)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(682601897 623112122)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(227151206 796970647)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(280062588 97529892)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(982209849 143387099)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(208788792 864388493)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(829327151 616717329)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(199336688 140757201)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(633750724 140850093)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(629400920 502096404)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(226017998 848736426)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(28914408 149445955)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(256236452 202091290)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(703867693 450501360)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(872061506 481351486)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(372120524 739530418)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(877267982 54722420)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(362642540 104419188)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(851693067 642705127)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(201949080 833902916)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(786092225 410737872)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(698291409 615419376)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(27455201 897628096)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(756176576 661205925)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(38478189 385577496)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(163302328 264496186)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(234313922 192216735)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(413942141 490550373)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(394308025 117809834)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(941051732 266369530)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(599161319 313172256)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(5899948 476429301)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(367894677 368542487)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(580848489 219587743)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
drop table t1;
create table t1 select POINT(1,3);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`POINT(1,3)` longblob NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
......@@ -289,3 +289,11 @@ execute stmt using @var;
select * from t1;
deallocate prepare stmt;
drop table t1;
prepare stmt from "select 'abc' like convert('abc' using utf8)";
execute stmt;
'abc' like convert('abc' using utf8)
1
execute stmt;
'abc' like convert('abc' using utf8)
1
deallocate prepare stmt;
......@@ -198,4 +198,12 @@ CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3
select hex(c1), hex(c2) from t1;
hex(c1) hex(c2)
CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3
stop slave;
delete from t1;
change master to master_log_pos=5801;
start slave until master_log_file='master-bin.000001', master_log_pos=5937;
start slave;
select hex(c1), hex(c2) from t1;
hex(c1) hex(c2)
CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3
drop table t1;
......@@ -1661,3 +1661,19 @@ t1 CREATE TABLE `t1` (
`a` enum('','1','2') NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
set names latin1;
CREATE TABLE t1 (
a INT default 1,
b ENUM('value','_value','') character set latin1 NOT NULL
);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) default '1',
`b` enum('value','_value','') NOT NULL default 'value'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
a int(11) YES 1
b enum('value','_value','') value
drop table t1;
......@@ -190,3 +190,97 @@ select AsText(a) from t1 where
and
MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a);
drop table t1;
CREATE TABLE t1 (Coordinates POINT NOT NULL, SPATIAL INDEX(Coordinates));
INSERT INTO t1 VALUES(GeomFromText('POINT(383293632 1754448)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(564952612 157516260)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(903994614 180726515)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(98128178 141127631)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(862547902 799334546)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(341989013 850270906)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(803302376 93039099)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(857439153 817431356)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(319757546 343162742)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(826341972 717484432)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(305066789 201736238)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(626068992 616241497)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(55789424 755830108)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(802874458 312435220)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(153795660 551723671)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(242207428 537089292)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(553478119 807160039)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(694605552 457472733)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(987886554 792733729)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(598600363 850434457)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(592068275 940589376)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(700705362 395370650)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(33628474 558144514)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(212802006 353386020)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(901307256 39143977)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(70870451 206374045)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(240880214 696939443)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(822615542 296669638)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(452769551 625489999)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(609104858 606565210)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(177213669 851312285)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(143654501 730691787)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(658472325 838260052)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(188164520 646358878)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(630993781 786764883)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(496793334 223062055)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(727354258 197498696)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(618432704 760982731)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(755643210 831234710)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(114368751 656950466)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(870378686 185239202)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(863324511 111258900)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(882178645 685940052)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(407928538 334948195)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(311430051 17033395)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(941513405 488643719)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(868345680 85167906)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(219335507 526818004)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(923427958 407500026)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(173176882 554421738)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(194264908 669970217)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(777483793 921619165)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(867468912 395916497)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(682601897 623112122)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(227151206 796970647)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(280062588 97529892)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(982209849 143387099)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(208788792 864388493)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(829327151 616717329)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(199336688 140757201)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(633750724 140850093)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(629400920 502096404)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(226017998 848736426)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(28914408 149445955)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(256236452 202091290)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(703867693 450501360)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(872061506 481351486)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(372120524 739530418)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(877267982 54722420)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(362642540 104419188)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(851693067 642705127)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(201949080 833902916)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(786092225 410737872)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(698291409 615419376)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(27455201 897628096)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(756176576 661205925)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(38478189 385577496)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(163302328 264496186)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(234313922 192216735)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(413942141 490550373)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(394308025 117809834)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(941051732 266369530)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(599161319 313172256)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(5899948 476429301)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(367894677 368542487)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(580848489 219587743)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
drop table t1;
create table t1 select POINT(1,3);
show create table t1;
drop table t1;
......@@ -304,3 +304,13 @@ select * from t1;
deallocate prepare stmt;
drop table t1;
#
# BUG#5688 "Upgraded 4.1.5 Server seg faults" # (prepared statements)
# The test case speaks for itself.
# Just another place where we used wrong memory root for Items created
# during statement prepare.
#
prepare stmt from "select 'abc' like convert('abc' using utf8)";
execute stmt;
execute stmt;
deallocate prepare stmt;
......@@ -148,6 +148,24 @@ INSERT INTO t1 (c1, c2) VALUES ('
select hex(c1), hex(c2) from t1;
sync_slave_with_master;
select hex(c1), hex(c2) from t1;
# Now test for BUG##5705: SET CHARATER_SET_SERVERetc will be lost if
# STOP SLAVE before following query
stop slave;
delete from t1;
change master to master_log_pos=5801;
start slave until master_log_file='master-bin.000001', master_log_pos=5937;
# Slave is supposed to stop _after_ the INSERT, even though 5937 is
# the position of the beginning of the INSERT; after SET slave is not
# supposed to increment position.
wait_for_slave_to_stop;
# When you merge this into 5.0 you will have to adjust positions
# above; the first master_log_pos above should be the one of the SET,
# the second should be the one of the INSERT.
start slave;
sync_with_master;
select hex(c1), hex(c2) from t1;
connection master;
drop table t1;
sync_slave_with_master;
......@@ -45,3 +45,17 @@ create table t1 (a enum(0xE4, '1', '2') not null default 0xE4);
show columns from t1;
show create table t1;
drop table t1;
#
# Bug #5628 German characters in field-defs will be '?'
# with some table definitions
#
set names latin1;
CREATE TABLE t1 (
a INT default 1,
b ENUM('value','_value','') character set latin1 NOT NULL
);
show create table t1;
show columns from t1;
drop table t1;
......@@ -22,6 +22,27 @@
#undef EXTRA_DEBUG
#define EXTRA_DEBUG
/*
Initialize memory root
SYNOPSIS
init_alloc_root()
mem_root - memory root to initialize
block_size - size of chunks (blocks) used for memory allocation
(It is external size of chunk i.e. it should include
memory required for internal structures, thus it
should be no less than ALLOC_ROOT_MIN_BLOCK_SIZE)
pre_alloc_size - if non-0, then size of block that should be
pre-allocated during memory root initialization.
DESCRIPTION
This function prepares memory root for further use, sets initial size of
chunk for memory allocation and pre-allocates first block if specified.
Altough error can happen during execution of this function if pre_alloc_size
is non-0 it won't be reported. Instead it will be reported as error in first
alloc_root() on this memory root.
*/
void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size __attribute__((unused)))
{
......@@ -29,7 +50,7 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
DBUG_PRINT("enter",("root: 0x%lx", mem_root));
mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
mem_root->min_malloc= 32;
mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
mem_root->error_handler= 0;
mem_root->block_num= 4; /* We shift this with >>2 */
mem_root->first_block_usage= 0;
......@@ -54,9 +75,9 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
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)
block_size new value of block size. Must be greater or equal
than ALLOC_ROOT_MIN_BLOCK_SIZE (this value is about
68 bytes and 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'.
......@@ -70,7 +91,9 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size __attribute__((unused)))
{
mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
DBUG_ASSERT(alloc_root_inited(mem_root));
mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
{
......@@ -123,6 +146,8 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: 0x%lx", mem_root));
DBUG_ASSERT(alloc_root_inited(mem_root));
Size+=ALIGN_SIZE(sizeof(USED_MEM));
if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME))))
{
......@@ -140,6 +165,8 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
reg1 USED_MEM *next= 0;
reg2 USED_MEM **prev;
DBUG_ASSERT(alloc_root_inited(mem_root));
Size= ALIGN_SIZE(Size);
if ((*(prev= &mem_root->free)) != NULL)
{
......
......@@ -4281,8 +4281,9 @@ int Field_str::store(double nr)
uint length;
bool use_scientific_notation= TRUE;
use_scientific_notation= TRUE;
if (field_length < 32 && fabs(nr) < log_10[field_length]-1)
if (field_length < 32 && fabs(nr) < log_10[field_length]-1)
use_scientific_notation= FALSE;
length= (uint) my_sprintf(buff, (buff, "%-.*g",
(use_scientific_notation ?
max(0, (int)field_length-5) :
......
......@@ -188,17 +188,27 @@ void Item_bool_func2::fix_length_and_dec()
{
uint strong= 0;
uint weak= 0;
uint32 dummy_offset;
DTCollation coll;
if (args[0]->result_type() == STRING_RESULT &&
args[1]->result_type() == STRING_RESULT &&
!my_charset_same(args[0]->collation.collation,
args[1]->collation.collation) &&
String::needs_conversion(0, args[0]->collation.collation,
args[1]->collation.collation,
&dummy_offset) &&
!coll.set(args[0]->collation, args[1]->collation, TRUE))
{
Item* conv= 0;
THD *thd= current_thd;
Item_arena *arena= thd->current_arena, backup;
strong= coll.strong;
weak= strong ? 0 : 1;
/*
In case we're in statement prepare, create conversion item
in its memory: it will be reused on each execute.
*/
if (arena->is_stmt_prepare())
thd->set_n_backup_item_arena(arena, &backup);
if (args[weak]->type() == STRING_ITEM)
{
String tmp, cstr;
......@@ -211,21 +221,13 @@ void Item_bool_func2::fix_length_and_dec()
}
else
{
THD *thd= current_thd;
/*
In case we're in statement prepare, create conversion item
in its memory: it will be reused on each execute.
*/
Item_arena *arena= thd->current_arena, backup;
if (arena->is_stmt_prepare())
thd->set_n_backup_item_arena(arena, &backup);
conv= new Item_func_conv_charset(args[weak],
args[strong]->collation.collation);
if (arena->is_stmt_prepare())
thd->restore_backup_item_arena(arena, &backup);
conv->collation.set(args[weak]->collation.derivation);
conv->fix_fields(thd, 0, &conv);
}
if (arena->is_stmt_prepare())
thd->restore_backup_item_arena(arena, &backup);
args[weak]= conv ? conv : args[weak];
}
}
......
......@@ -27,6 +27,13 @@
#include "sql_acl.h"
#include <m_ctype.h>
void Item_geometry_func::fix_length_and_dec()
{
collation.set(&my_charset_bin);
decimals=0;
max_length=MAX_BLOB_WIDTH;
}
String *Item_func_geometry_from_text::val_str(String *str)
{
......@@ -44,6 +51,7 @@ String *Item_func_geometry_from_text::val_str(String *str)
if ((arg_count == 2) && !args[1]->null_value)
srid= (uint32)args[1]->val_int();
str->set_charset(&my_charset_bin);
if (str->reserve(SRID_SIZE, 512))
return 0;
str->length(0);
......@@ -54,12 +62,6 @@ String *Item_func_geometry_from_text::val_str(String *str)
}
void Item_func_geometry_from_text::fix_length_and_dec()
{
max_length=MAX_BLOB_WIDTH;
}
String *Item_func_geometry_from_wkb::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
......@@ -71,6 +73,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
if ((arg_count == 2) && !args[1]->null_value)
srid= (uint32)args[1]->val_int();
str->set_charset(&my_charset_bin);
if (str->reserve(SRID_SIZE, 512))
return 0;
str->length(0);
......@@ -84,12 +87,6 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
}
void Item_func_geometry_from_wkb::fix_length_and_dec()
{
max_length=MAX_BLOB_WIDTH;
}
String *Item_func_as_wkt::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
......@@ -138,12 +135,6 @@ String *Item_func_as_wkb::val_str(String *str)
}
void Item_func_as_wkb::fix_length_and_dec()
{
max_length= MAX_BLOB_WIDTH;
}
String *Item_func_geometry_type::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
......@@ -180,6 +171,7 @@ String *Item_func_envelope::val_str(String *str)
return 0;
srid= uint4korr(swkb->ptr());
str->set_charset(&my_charset_bin);
str->length(0);
if (str->reserve(SRID_SIZE, 512))
return 0;
......@@ -202,6 +194,7 @@ String *Item_func_centroid::val_str(String *str)
swkb->length() - SRID_SIZE))))
return 0;
str->set_charset(&my_charset_bin);
if (str->reserve(SRID_SIZE, 512))
return 0;
str->length(0);
......@@ -232,6 +225,7 @@ String *Item_func_spatial_decomp::val_str(String *str)
return 0;
srid= uint4korr(swkb->ptr());
str->set_charset(&my_charset_bin);
if (str->reserve(SRID_SIZE, 512))
goto err;
str->length(0);
......@@ -279,6 +273,7 @@ String *Item_func_spatial_decomp_n::val_str(String *str)
swkb->length() - SRID_SIZE)))))
return 0;
str->set_charset(&my_charset_bin);
if (str->reserve(SRID_SIZE, 512))
goto err;
srid= uint4korr(swkb->ptr());
......@@ -333,6 +328,7 @@ String *Item_func_point::val_str(String *str)
str->realloc(1 + 4 + SIZEOF_STORED_DOUBLE*2))))
return 0;
str->set_charset(&my_charset_bin);
str->length(0);
str->q_append((char)Geometry::wkb_ndr);
str->q_append((uint32)Geometry::wkb_point);
......@@ -358,6 +354,7 @@ String *Item_func_spatial_collection::val_str(String *str)
String arg_value;
uint i;
str->set_charset(&my_charset_bin);
str->length(0);
if (str->reserve(1 + 4 + 4, 512))
goto err;
......
......@@ -23,24 +23,33 @@
#pragma interface /* gcc class implementation */
#endif
class Item_func_geometry_from_text: public Item_str_func
class Item_geometry_func: public Item_str_func
{
public:
Item_func_geometry_from_text(Item *a) :Item_str_func(a) {}
Item_func_geometry_from_text(Item *a, Item *srid) :Item_str_func(a, srid) {}
Item_geometry_func() :Item_str_func() {}
Item_geometry_func(Item *a) :Item_str_func(a) {}
Item_geometry_func(Item *a,Item *b) :Item_str_func(a,b) {}
Item_geometry_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
Item_geometry_func(List<Item> &list) :Item_str_func(list) {}
void fix_length_and_dec();
};
class Item_func_geometry_from_text: public Item_geometry_func
{
public:
Item_func_geometry_from_text(Item *a) :Item_geometry_func(a) {}
Item_func_geometry_from_text(Item *a, Item *srid) :Item_geometry_func(a, srid) {}
const char *func_name() const { return "geometryfromtext"; }
String *val_str(String *);
void fix_length_and_dec();
};
class Item_func_geometry_from_wkb: public Item_str_func
class Item_func_geometry_from_wkb: public Item_geometry_func
{
public:
Item_func_geometry_from_wkb(Item *a): Item_str_func(a) {}
Item_func_geometry_from_wkb(Item *a, Item *srid): Item_str_func(a, srid) {}
Item_func_geometry_from_wkb(Item *a): Item_geometry_func(a) {}
Item_func_geometry_from_wkb(Item *a, Item *srid): Item_geometry_func(a, srid) {}
const char *func_name() const { return "geometryfromwkb"; }
String *val_str(String *);
void fix_length_and_dec();
};
class Item_func_as_wkt: public Item_str_func
......@@ -52,13 +61,12 @@ public:
void fix_length_and_dec();
};
class Item_func_as_wkb: public Item_str_func
class Item_func_as_wkb: public Item_geometry_func
{
public:
Item_func_as_wkb(Item *a): Item_str_func(a) {}
Item_func_as_wkb(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "aswkb"; }
String *val_str(String *);
void fix_length_and_dec();
};
class Item_func_geometry_type: public Item_str_func
......@@ -73,40 +81,37 @@ public:
};
};
class Item_func_centroid: public Item_str_func
class Item_func_centroid: public Item_geometry_func
{
public:
Item_func_centroid(Item *a): Item_str_func(a) {}
Item_func_centroid(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "centroid"; }
String *val_str(String *);
void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
class Item_func_envelope: public Item_str_func
class Item_func_envelope: public Item_geometry_func
{
public:
Item_func_envelope(Item *a): Item_str_func(a) {}
Item_func_envelope(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "envelope"; }
String *val_str(String *);
void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
class Item_func_point: public Item_str_func
class Item_func_point: public Item_geometry_func
{
public:
Item_func_point(Item *a, Item *b): Item_str_func(a, b) {}
Item_func_point(Item *a, Item *b, Item *srid): Item_str_func(a, b, srid) {}
Item_func_point(Item *a, Item *b): Item_geometry_func(a, b) {}
Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {}
const char *func_name() const { return "point"; }
String *val_str(String *);
void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
class Item_func_spatial_decomp: public Item_str_func
class Item_func_spatial_decomp: public Item_geometry_func
{
enum Functype decomp_func;
public:
Item_func_spatial_decomp(Item *a, Item_func::Functype ft) :
Item_str_func(a) { decomp_func = ft; }
Item_geometry_func(a) { decomp_func = ft; }
const char *func_name() const
{
switch (decomp_func)
......@@ -123,15 +128,14 @@ public:
}
}
String *val_str(String *);
void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
class Item_func_spatial_decomp_n: public Item_str_func
class Item_func_spatial_decomp_n: public Item_geometry_func
{
enum Functype decomp_func_n;
public:
Item_func_spatial_decomp_n(Item *a, Item *b, Item_func::Functype ft):
Item_str_func(a, b) { decomp_func_n = ft; }
Item_geometry_func(a, b) { decomp_func_n = ft; }
const char *func_name() const
{
switch (decomp_func_n)
......@@ -148,10 +152,9 @@ public:
}
}
String *val_str(String *);
void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
class Item_func_spatial_collection: public Item_str_func
class Item_func_spatial_collection: public Item_geometry_func
{
String tmp_value;
enum Geometry::wkbType coll_type;
......@@ -159,13 +162,12 @@ class Item_func_spatial_collection: public Item_str_func
public:
Item_func_spatial_collection(
List<Item> &list, enum Geometry::wkbType ct, enum Geometry::wkbType it):
Item_str_func(list)
Item_geometry_func(list)
{
coll_type=ct;
item_type=it;
}
String *val_str(String *);
void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
const char *func_name() const { return "multipoint"; }
};
......
......@@ -1091,7 +1091,15 @@ end:
VOID(pthread_mutex_unlock(&LOCK_thread_count));
close_thread_tables(thd);
free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC));
return (thd->query_error ? thd->query_error : Log_event::exec_event(rli));
/*
If there was an error we stop. Otherwise we increment positions. Note that
we will not increment group* positions if we are just after a SET
ONE_SHOT, because SET ONE_SHOT should not be separated from its following
updating query.
*/
return (thd->query_error ? thd->query_error :
(thd->one_shot_set ? (rli->inc_event_relay_log_pos(get_event_len()),0) :
Log_event::exec_event(rli)));
}
#endif
......
......@@ -2554,7 +2554,8 @@ static bool null_part_in_key(KEY_PART *key_part, const char *key, uint length)
QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref)
{
QUICK_SELECT *quick=new QUICK_SELECT(thd, table, ref->key, 1);
MEM_ROOT *old_root= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC);
QUICK_SELECT *quick= new QUICK_SELECT(thd, table, ref->key);
KEY *key_info = &table->key_info[ref->key];
KEY_PART *key_part;
QUICK_RANGE *range;
......@@ -2566,7 +2567,7 @@ QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref)
{
if (thd->is_fatal_error)
goto err; // out of memory
return quick; // empty range
goto ok; // empty range
}
if (!(range= new QUICK_RANGE()))
......@@ -2613,9 +2614,12 @@ QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref)
goto err;
}
ok:
my_pthread_setspecific_ptr(THR_MALLOC, old_root);
return quick;
err:
my_pthread_setspecific_ptr(THR_MALLOC, old_root);
delete quick;
return 0;
}
......
......@@ -221,7 +221,6 @@ THD::THD()
init();
/* Initialize sub structures */
clear_alloc_root(&transaction.mem_root);
init_alloc_root(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
user_connect=(USER_CONN *)0;
hash_init(&user_vars, &my_charset_bin, USER_VARS_HASH_SIZE, 0, 0,
......@@ -258,6 +257,7 @@ THD::THD()
transaction.trans_log.end_of_file= max_binlog_cache_size;
}
#endif
init_alloc_root(&transaction.mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
{
ulong tmp=sql_rnd_with_mutex();
randominit(&rand, tmp + (ulong) &rand, tmp + (ulong) ::query_id);
......@@ -303,12 +303,12 @@ void THD::init(void)
void THD::init_for_queries()
{
ha_enable_transaction(this,TRUE);
init_sql_alloc(&mem_root,
variables.query_alloc_block_size,
variables.query_prealloc_size);
init_sql_alloc(&transaction.mem_root,
variables.trans_alloc_block_size,
variables.trans_prealloc_size);
reset_root_defaults(&mem_root, variables.query_alloc_block_size,
variables.query_prealloc_size);
reset_root_defaults(&transaction.mem_root,
variables.trans_alloc_block_size,
variables.trans_prealloc_size);
}
......@@ -1332,6 +1332,17 @@ void select_dumpvar::cleanup()
}
/*
Create arena for already constructed THD.
SYNOPSYS
Item_arena()
thd - thread for which arena is created
DESCRIPTION
Create arena for already existing THD using its variables as parameters
for memory root initialization.
*/
Item_arena::Item_arena(THD* thd)
:free_list(0),
state(INITIALIZED)
......@@ -1342,24 +1353,31 @@ Item_arena::Item_arena(THD* thd)
}
/* This constructor is called when Item_arena is a subobject of THD */
/*
Create arena and optionally initialize memory root.
Item_arena::Item_arena()
:free_list(0),
state(CONVENTIONAL_EXECUTION)
{
clear_alloc_root(&mem_root);
}
SYNOPSYS
Item_arena()
init_mem_root - whenever we need to initialize memory root
DESCRIPTION
Create arena and optionally initialize memory root with minimal
possible parameters.
NOTE
We use this constructor when arena is part of THD, but reinitialize
its memory root in THD::init_for_queries() before execution of real
statements.
*/
Item_arena::Item_arena(bool init_mem_root)
:free_list(0),
state(INITIALIZED)
state(CONVENTIONAL_EXECUTION)
{
if (init_mem_root)
clear_alloc_root(&mem_root);
init_alloc_root(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
}
Item_arena::Type Item_arena::type() const
{
DBUG_ASSERT("Item_arena::type()" == "abstract");
......@@ -1367,10 +1385,6 @@ Item_arena::Type Item_arena::type() const
}
Item_arena::~Item_arena()
{}
/*
Statement functions
*/
......@@ -1394,7 +1408,8 @@ Statement::Statement(THD *thd)
*/
Statement::Statement()
:id(0),
:Item_arena((bool)TRUE),
id(0),
set_query_id(1),
allow_sum_func(0), /* initialized later */
lex(&main_lex),
......@@ -1462,8 +1477,16 @@ void Item_arena::restore_backup_item_arena(Item_arena *set, Item_arena *backup)
{
set->set_item_arena(this);
set_item_arena(backup);
// reset backup mem_root to avoid its freeing
init_alloc_root(&backup->mem_root, 0, 0);
#ifdef NOT_NEEDED_NOW
/*
Reset backup mem_root to avoid its freeing.
Since Item_arena's mem_root is freed only when it is part of Statement
we need this only if we use some Statement's arena as backup storage.
But we do this only with THD::stmt_backup and this Statement is specially
handled in this respect. So this code is not really needed now.
*/
clear_alloc_root(&backup->mem_root);
#endif
}
void Item_arena::set_item_arena(Item_arena *set)
......
......@@ -441,11 +441,23 @@ public:
STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE
};
/*
This constructor is used only when Item_arena is created as
backup storage for another instance of Item_arena.
*/
Item_arena() {};
/*
Create arena for already constructed THD using its variables as
parameters for memory root initialization.
*/
Item_arena(THD *thd);
Item_arena();
/*
Create arena and optionally init memory root with minimal values.
Particularly used if Item_arena is part of Statement.
*/
Item_arena(bool init_mem_root);
virtual Type type() const;
virtual ~Item_arena();
virtual ~Item_arena() {};
inline bool is_stmt_prepare() const { return (int)state < (int)PREPARED; }
inline bool is_first_stmt_execute() const { return state == PREPARED; }
......
......@@ -1265,6 +1265,8 @@ store_create_info(THD *thd, TABLE *table, String *packet)
// check for surprises from the previous call to Field::sql_type()
if (type.ptr() != tmp)
type.set(tmp, sizeof(tmp), system_charset_info);
else
type.set_charset(system_charset_info);
field->sql_type(type);
packet->append(type.ptr(), type.length(), system_charset_info);
......
......@@ -10251,7 +10251,7 @@ static void test_bug5194()
/* Number of columns per row */
const int COLUMN_COUNT= sizeof(float_array)/sizeof(*float_array);
/* Number of rows per bulk insert to start with */
const int MIN_ROWS_PER_INSERT= 260;
const int MIN_ROWS_PER_INSERT= 262;
/* Max number of rows per bulk insert to end with */
const int MAX_ROWS_PER_INSERT= 300;
const int MAX_PARAM_COUNT= COLUMN_COUNT*MAX_ROWS_PER_INSERT;
......
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