Commit 8b833274 authored by Michael Widenius's avatar Michael Widenius

Merge with 1.0.11-7 Pre-GA - 2010-09-09

Updated results for failing test cases (In all cases the estimated number of rows was different)
parent 6b1c78e7
...@@ -388,7 +388,7 @@ Table Op Msg_type Msg_text ...@@ -388,7 +388,7 @@ Table Op Msg_type Msg_text
test.t1 analyze status OK test.t1 analyze status OK
explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a)); explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a));
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 21 100.00 Using where; Using index 1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or `test`.`t1`.`a`) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` having `test`.`t1`.`a` Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or `test`.`t1`.`a`) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` having `test`.`t1`.`a`
drop table t1; drop table t1;
...@@ -1384,52 +1384,52 @@ Table Op Msg_type Msg_text ...@@ -1384,52 +1384,52 @@ Table Op Msg_type Msg_text
test.t2 analyze status OK test.t2 analyze status OK
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where 1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
companynr companynr companynr companynr
37 36 37 36
...@@ -1437,7 +1437,7 @@ companynr companynr ...@@ -1437,7 +1437,7 @@ companynr companynr
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Using join buffer 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
fld1 companynr fld3 period fld1 companynr fld3 period
038008 37 reporters 1008 038008 37 reporters 1008
...@@ -1511,7 +1511,7 @@ count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) ...@@ -1511,7 +1511,7 @@ count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069
explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
Warnings: Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
...@@ -1955,7 +1955,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -1955,7 +1955,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
explain select fld3 from t2 where fld1=fld1; explain select fld3 from t2 where fld1=fld1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502;
companynr fld1 companynr fld1
34 250501 34 250501
...@@ -2007,7 +2007,7 @@ count(*) ...@@ -2007,7 +2007,7 @@ count(*)
4181 4181
explain select min(fld1),max(fld1),count(*) from t2; explain select min(fld1),max(fld1),count(*) from t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL fld1 4 NULL 1200 Using index 1 SIMPLE t2 index NULL fld1 4 NULL 1199 Using index
select min(fld1),max(fld1),count(*) from t2; select min(fld1),max(fld1),count(*) from t2;
min(fld1) max(fld1) count(*) min(fld1) max(fld1) count(*)
0 1232609 1199 0 1232609 1199
...@@ -2093,9 +2093,9 @@ show full columns from t2 from test like 's%'; ...@@ -2093,9 +2093,9 @@ show full columns from t2 from test like 's%';
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
show keys from t2; show keys from t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t2 0 PRIMARY 1 auto A 1200 NULL NULL BTREE t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
t2 0 fld1 1 fld1 A 1200 NULL NULL BTREE t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
t2 1 fld3 1 fld3 A 1200 NULL NULL BTREE t2 1 fld3 1 fld3 A 1199 NULL NULL BTREE
drop table t4, t3, t2, t1; drop table t4, t3, t2, t1;
DO 1; DO 1;
DO benchmark(100,1+1),1,1; DO benchmark(100,1+1),1,1;
......
PBXT Release Notes PBXT Release Notes
================== ==================
+------- 1.0.11 Pre-GA - 2010-05-11 ------- 1.0.11-7 Pre-GA - 2010-09-09
RN336: Compiled and tested with MySQL 5.1.50.
RN335: Fixed bug #523994: Deleting all records does not update table statistics.
RN334: Made a change to reduce the time that only temporary tables exist during the ALTER TABLE and REPAIR TABLE statements. This increases the chance of recovery if a crash occurs during these operations.
RN333: Log name of table when PBXT recovers an index on startup. If an error occurs during index recovery, the index is set to "repair pending".
RN332: Fixed an inifinite loop when a record in a row is corrupt. Added logging and set the table to "repair pending" in this case.
RN331: Fixed bug #626890: Crash on truncate table operation.
RN330: Added additional checks for corruption of the index free list.
------- 1.0.11-6 Pre-GA - 2010-07-08
RN329: Fixed bug #601245: make fails. PBXT did not compile if the partition engine was disabled in the MySQL build.
------- 1.0.11-5 Pre-GA - 2010-06-18
RN328: Fixed bug #595478: Compile fails (1.0.11-4).
------- 1.0.11-4 Pre-GA - 2010-06-15
RN327: Fixed a bug that caused a crash during delete on the index. The crash occurred due to memory overwrite when a long key is promoted after a shorter key is deleted, and the difference causes a node size overflow.
------- 1.0.11-3 Pre-GA - 2010-06-11
RN326: Fixed bug #587740: pbxt-1.0.11-pre2-ga first time create partition table error. This was not a new bug. The problem was the PBXT system table's .frm files are corrupted when the first PBXT table created is a partition table.
RN325: Fixed the "to-sweep" column output in xtstat.
------- 1.0.11-2 Pre-GA - 2010-05-26
RN324: Fixed bug #584070:pbxt-1.0.11-pre-ga does not work with mysql 5.1.47. This bug fix removes a hack which was done to avoid running into the LOCK_plugin lock.
------- 1.0.11-1 Pre-GA - 2010-05-19
RN323: Detect corruption of a key length in an index page. This bug fix avoids a possible crash due to index page corruption.
------- 1.0.11 Pre-GA - 2010-05-11
RN322: Creating a table the references a non-existing table can now only be done if you set: foreign_key_checks = 0. Also fixed a failure when creating tables with recursive foreign key declarations. RN322: Creating a table the references a non-existing table can now only be done if you set: foreign_key_checks = 0. Also fixed a failure when creating tables with recursive foreign key declarations.
......
...@@ -40,8 +40,8 @@ libpbxt_la_LDFLAGS = -module ...@@ -40,8 +40,8 @@ libpbxt_la_LDFLAGS = -module
# These are the warning Drizzle uses: # These are the warning Drizzle uses:
# DRIZZLE_WARNINGS = -W -Wall -Wextra -pedantic -Wundef -Wredundant-decls -Wno-strict-aliasing -Wno-long-long -Wno-unused-parameter # DRIZZLE_WARNINGS = -W -Wall -Wextra -pedantic -Wundef -Wredundant-decls -Wno-strict-aliasing -Wno-long-long -Wno-unused-parameter
libpbxt_la_CXXFLAGS = -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN libpbxt_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
libpbxt_la_CFLAGS = -shared $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -std=c99 libpbxt_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -std=c99
EXTRA_LIBRARIES = libpbxt.a EXTRA_LIBRARIES = libpbxt.a
noinst_LIBRARIES = libpbxt.a noinst_LIBRARIES = libpbxt.a
......
...@@ -667,6 +667,9 @@ xtPublic void xt_ind_init(XTThreadPtr self, size_t cache_size) ...@@ -667,6 +667,9 @@ xtPublic void xt_ind_init(XTThreadPtr self, size_t cache_size)
#ifdef XT_USE_DIRECT_IO_ON_INDEX #ifdef XT_USE_DIRECT_IO_ON_INDEX
block->cb_data = buffer; block->cb_data = buffer;
buffer += XT_INDEX_PAGE_SIZE; buffer += XT_INDEX_PAGE_SIZE;
#endif
#ifdef CHECK_BLOCK_TRAILERS
XT_SET_DISK_4(block->cp_check, 0xDEADBEEF);
#endif #endif
ind_cac_globals.cg_free_list = block; ind_cac_globals.cg_free_list = block;
block++; block++;
...@@ -684,6 +687,19 @@ xtPublic void xt_ind_init(XTThreadPtr self, size_t cache_size) ...@@ -684,6 +687,19 @@ xtPublic void xt_ind_init(XTThreadPtr self, size_t cache_size)
cont_(a); cont_(a);
} }
#ifdef CHECK_BLOCK_TRAILERS
xtPublic void check_block_trailers()
{
XTIndBlockPtr block;
block = ind_cac_globals.cg_blocks;
for (u_int i=0; i<ind_cac_globals.cg_block_count; i++) {
ASSERT_NS(XT_GET_DISK_4(block->cp_check) == 0xDEADBEEF);
block++;
}
}
#endif
xtPublic void xt_ind_exit(XTThreadPtr self) xtPublic void xt_ind_exit(XTThreadPtr self)
{ {
#ifdef XT_USE_MYSYS #ifdef XT_USE_MYSYS
...@@ -1283,7 +1299,7 @@ static XTIndBlockPtr ind_cac_fetch(XTOpenTablePtr ot, XTIndexPtr ind, xtIndexNod ...@@ -1283,7 +1299,7 @@ static XTIndBlockPtr ind_cac_fetch(XTOpenTablePtr ot, XTIndexPtr ind, xtIndexNod
* Conditionally count the number of deleted entries in the index: * Conditionally count the number of deleted entries in the index:
* We do this before other threads can read the block. * We do this before other threads can read the block.
*/ */
if (ind->mi_lazy_delete && read_data) if (ind && ind->mi_lazy_delete && read_data)
xt_ind_count_deleted_items(ot->ot_table, ind, block); xt_ind_count_deleted_items(ot->ot_table, ind, block);
/* Add to the hash table: */ /* Add to the hash table: */
...@@ -1357,6 +1373,9 @@ xtPublic xtBool xt_ind_write(XTOpenTablePtr ot, XTIndexPtr ind, xtIndexNodeID ad ...@@ -1357,6 +1373,9 @@ xtPublic xtBool xt_ind_write(XTOpenTablePtr ot, XTIndexPtr ind, xtIndexNodeID ad
IDX_CAC_UNLOCK(seg, ot->ot_thread); IDX_CAC_UNLOCK(seg, ot->ot_thread);
#ifdef XT_TRACK_INDEX_UPDATES #ifdef XT_TRACK_INDEX_UPDATES
ot->ot_ind_changed++; ot->ot_ind_changed++;
#endif
#ifdef CHECK_BLOCK_TRAILERS
check_block_trailers();
#endif #endif
return OK; return OK;
} }
......
...@@ -33,6 +33,7 @@ struct XTIdxReadBuffer; ...@@ -33,6 +33,7 @@ struct XTIdxReadBuffer;
#ifdef DEBUG #ifdef DEBUG
//#define XT_USE_CACHE_DEBUG_SIZES //#define XT_USE_CACHE_DEBUG_SIZES
//#define CHECK_BLOCK_TRAILERS
#endif #endif
#ifdef XT_USE_CACHE_DEBUG_SIZES #ifdef XT_USE_CACHE_DEBUG_SIZES
...@@ -116,6 +117,9 @@ typedef struct XTIndBlock { ...@@ -116,6 +117,9 @@ typedef struct XTIndBlock {
#else #else
xtWord1 cb_data[XT_INDEX_PAGE_SIZE]; xtWord1 cb_data[XT_INDEX_PAGE_SIZE];
#endif #endif
#ifdef CHECK_BLOCK_TRAILERS
xtWord1 cp_check[4];
#endif
} XTIndBlockRec, *XTIndBlockPtr; } XTIndBlockRec, *XTIndBlockPtr;
typedef struct XTIndReference { typedef struct XTIndReference {
...@@ -177,6 +181,10 @@ xtBool xt_ind_copy_on_write(XTIndReferencePtr iref); ...@@ -177,6 +181,10 @@ xtBool xt_ind_copy_on_write(XTIndReferencePtr iref);
XTIndHandlePtr xt_ind_get_handle(struct XTOpenTable *ot, XTIndexPtr ind, XTIndReferencePtr iref); XTIndHandlePtr xt_ind_get_handle(struct XTOpenTable *ot, XTIndexPtr ind, XTIndReferencePtr iref);
void xt_ind_release_handle(XTIndHandlePtr handle, xtBool have_lock, XTThreadPtr thread); void xt_ind_release_handle(XTIndHandlePtr handle, xtBool have_lock, XTThreadPtr thread);
#ifdef CHECK_BLOCK_TRAILERS
extern void check_block_trailers();
#endif
#ifdef DEBUG #ifdef DEBUG
//#define DEBUG_CHECK_IND_CACHE //#define DEBUG_CHECK_IND_CACHE
#endif #endif
......
...@@ -117,6 +117,7 @@ typedef struct XTDatabase : public XTHeap { ...@@ -117,6 +117,7 @@ typedef struct XTDatabase : public XTHeap {
XTSortedListPtr db_table_by_id; XTSortedListPtr db_table_by_id;
XTSortedListPtr db_table_paths; /* A list of table paths used by this database. */ XTSortedListPtr db_table_paths; /* A list of table paths used by this database. */
xtBool db_multi_path; xtBool db_multi_path;
XTSortedListPtr db_error_list; /* A list of errors already reported. */
/* The open table pool: */ /* The open table pool: */
XTAllTablePoolsRec db_ot_pool; XTAllTablePoolsRec db_ot_pool;
......
...@@ -396,7 +396,7 @@ void XTToken::expectNumber(XTThreadPtr self) ...@@ -396,7 +396,7 @@ void XTToken::expectNumber(XTThreadPtr self)
struct charset_info_st; struct charset_info_st;
class XTTokenizer { class XTTokenizer {
struct charset_info_st *tkn_charset; MX_CONST_CHARSET_INFO *tkn_charset;
char *tkn_cstring; char *tkn_cstring;
char *tkn_curr_pos; char *tkn_curr_pos;
XTToken *tkn_current; XTToken *tkn_current;
...@@ -1324,7 +1324,7 @@ void XTParseTable::parseDropIndex(XTThreadPtr self) ...@@ -1324,7 +1324,7 @@ void XTParseTable::parseDropIndex(XTThreadPtr self)
class XTCreateTable : public XTParseTable { class XTCreateTable : public XTParseTable {
public: public:
bool ct_convert; bool ct_convert;
struct charset_info_st *ct_charset; MX_CONST_CHARSET_INFO *ct_charset;
XTPathStrPtr ct_tab_path; XTPathStrPtr ct_tab_path;
u_int ct_contraint_no; u_int ct_contraint_no;
XTDDTable *ct_curr_table; XTDDTable *ct_curr_table;
...@@ -2039,11 +2039,6 @@ void XTDDTableRef::deleteAllRows(XTThreadPtr self) ...@@ -2039,11 +2039,6 @@ void XTDDTableRef::deleteAllRows(XTThreadPtr self)
if (!(ot = xt_db_open_table_using_tab(tr_fkey->co_table->dt_table, self))) if (!(ot = xt_db_open_table_using_tab(tr_fkey->co_table->dt_table, self)))
xt_throw(self); xt_throw(self);
/* {FREE-ROWS-BAD} */
/*
row_count = ((xtInt8) ot->ot_table->tab_row_eof_id) - 1;
row_count -= (xtInt8) ot->ot_table->tab_row_fnum;
*/
/* Check if there are any rows in the referencing table: */ /* Check if there are any rows in the referencing table: */
if (!xt_tab_seq_init(ot)) if (!xt_tab_seq_init(ot))
goto failed; goto failed;
......
...@@ -1249,7 +1249,7 @@ xtBool XTDataLogBuffer::dlb_write_thru_log(xtLogID XT_NDEBUG_UNUSED(log_id), xtL ...@@ -1249,7 +1249,7 @@ xtBool XTDataLogBuffer::dlb_write_thru_log(xtLogID XT_NDEBUG_UNUSED(log_id), xtL
*/ */
dlb_data_log->dlf_log_eof += size; dlb_data_log->dlf_log_eof += size;
#ifdef DEBUG #ifdef DEBUG
if ((ulonglong) (log_offset + size) > (ulonglong) dlb_max_write_offset) if (log_offset + (xtLogOffset) size > (xtLogOffset) dlb_max_write_offset)
dlb_max_write_offset = log_offset + size; dlb_max_write_offset = log_offset + size;
#endif #endif
dlb_flush_required = TRUE; dlb_flush_required = TRUE;
...@@ -1291,7 +1291,7 @@ xtBool XTDataLogBuffer::dlb_append_log(xtLogID XT_NDEBUG_UNUSED(log_id), xtLogOf ...@@ -1291,7 +1291,7 @@ xtBool XTDataLogBuffer::dlb_append_log(xtLogID XT_NDEBUG_UNUSED(log_id), xtLogOf
if (!xt_pwrite_file(dlb_data_log->dlf_log_file, log_offset, size, data, &thread->st_statistics.st_data, thread)) if (!xt_pwrite_file(dlb_data_log->dlf_log_file, log_offset, size, data, &thread->st_statistics.st_data, thread))
return FAILED; return FAILED;
#ifdef DEBUG #ifdef DEBUG
if ((ulonglong) (log_offset + size) > (ulonglong) dlb_max_write_offset) if (log_offset + (xtLogOffset) size > (xtLogOffset) dlb_max_write_offset)
dlb_max_write_offset = log_offset + size; dlb_max_write_offset = log_offset + size;
#endif #endif
dlb_flush_required = TRUE; dlb_flush_required = TRUE;
...@@ -1734,8 +1734,8 @@ static xtBool dl_collect_garbage(XTThreadPtr self, XTDatabaseHPtr db, XTDataLogF ...@@ -1734,8 +1734,8 @@ static xtBool dl_collect_garbage(XTThreadPtr self, XTDatabaseHPtr db, XTDataLogF
xtLogOffset src_log_offset; xtLogOffset src_log_offset;
xtLogID curr_log_id; xtLogID curr_log_id;
xtLogOffset curr_log_offset; xtLogOffset curr_log_offset;
xtLogID dest_log_id= 0; xtLogID dest_log_id = 0;
xtLogOffset dest_log_offset= 0; xtLogOffset dest_log_offset = 0;
off_t garbage_count = 0; off_t garbage_count = 0;
memset(&cs, 0, sizeof(XTCompactorStateRec)); memset(&cs, 0, sizeof(XTCompactorStateRec));
......
...@@ -1622,7 +1622,11 @@ int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char * ...@@ -1622,7 +1622,11 @@ int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *
COLUMN_FORMAT_TYPE_FIXED, COLUMN_FORMAT_TYPE_FIXED,
#endif #endif
NULL /*default_value*/, NULL /*on_update_value*/, &comment, NULL /*change*/, NULL /*default_value*/, NULL /*on_update_value*/, &comment, NULL /*change*/,
NULL /*interval_list*/, info->field_charset, 0 /*uint_geom_type*/)) NULL /*interval_list*/, info->field_charset, 0 /*uint_geom_type*/
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID > 50200
, NULL /*vcol_info*/, NULL /* create options */
#endif
))
#endif #endif
goto error; goto error;
...@@ -1654,8 +1658,17 @@ int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char * ...@@ -1654,8 +1658,17 @@ int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *
if (mysql_create_table_no_lock(thd, db, name, &create_info, &table_proto, &stmt->alter_info, 1, 0)) if (mysql_create_table_no_lock(thd, db, name, &create_info, &table_proto, &stmt->alter_info, 1, 0))
goto error; goto error;
#else #else
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info;
part_info = thd->work_part_info;
thd->work_part_info = NULL;
#endif
if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &mylex.alter_info, 1, 0)) if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &mylex.alter_info, 1, 0))
goto error; goto error;
#ifdef WITH_PARTITION_STORAGE_ENGINE
thd->work_part_info = part_info;
#endif
#endif #endif
noerror: noerror:
......
...@@ -1232,6 +1232,11 @@ static int pbxt_init(void *p) ...@@ -1232,6 +1232,11 @@ static int pbxt_init(void *p)
THD *thd = NULL; THD *thd = NULL;
#ifndef DRIZZLED #ifndef DRIZZLED
#if MYSQL_VERSION_ID < 50147
/* A hack which is no longer required after 5.1.46 */
extern myxt_mutex_t LOCK_plugin;
#endif
/* {MYSQL QUIRK} /* {MYSQL QUIRK}
* I have to release this lock for PBXT recovery to * I have to release this lock for PBXT recovery to
* work, because it needs to open .frm files. * work, because it needs to open .frm files.
...@@ -1248,8 +1253,7 @@ static int pbxt_init(void *p) ...@@ -1248,8 +1253,7 @@ static int pbxt_init(void *p)
* Only real problem, 2 threads try to load the same * Only real problem, 2 threads try to load the same
* plugin at the same time. * plugin at the same time.
*/ */
#if MYSQL_VERSION_ID <= 50146 #if MYSQL_VERSION_ID < 50147
extern myxt_mutex_t LOCK_plugin;
myxt_mutex_unlock(&LOCK_plugin); myxt_mutex_unlock(&LOCK_plugin);
#endif #endif
#endif #endif
...@@ -1285,8 +1289,10 @@ static int pbxt_init(void *p) ...@@ -1285,8 +1289,10 @@ static int pbxt_init(void *p)
if (thd) if (thd)
myxt_destroy_thread(thd, FALSE); myxt_destroy_thread(thd, FALSE);
#if MYSQL_VERSION_ID <= 50146 && !defined(DRIZZLED) #ifndef DRIZZLED
#if MYSQL_VERSION_ID < 50147
myxt_mutex_lock(&LOCK_plugin); myxt_mutex_lock(&LOCK_plugin);
#endif
#endif #endif
} }
#endif #endif
...@@ -1948,8 +1954,13 @@ xtPublic int ha_pbxt::reopen() ...@@ -1948,8 +1954,13 @@ xtPublic int ha_pbxt::reopen()
* selectity of the indices, as soon as the number of rows * selectity of the indices, as soon as the number of rows
* exceeds 200 (see [**]) * exceeds 200 (see [**])
*/ */
#ifdef XT_ROW_COUNT_CORRECTED
/* {CORRECTED-ROW-COUNT} */
pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 - pb_share->sh_table->tab_row_fnum) < 150;
#else
/* {FREE-ROWS-BAD} */ /* {FREE-ROWS-BAD} */
pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) < 150; pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) < 150;
#endif
} }
/* I am not doing this anymore because it was only required /* I am not doing this anymore because it was only required
...@@ -2006,7 +2017,7 @@ static int pbxt_statistics_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2006,7 +2017,7 @@ static int pbxt_statistics_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL); xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL);
} }
err = myxt_statistics_fill_table(self, thd, tables, cond, system_charset_info); err = myxt_statistics_fill_table(self, thd, tables, cond, (void*) system_charset_info);
} }
catch_(a) { catch_(a) {
err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE);
...@@ -2296,6 +2307,36 @@ void ha_pbxt::internal_close(THD *thd, struct XTThread *self) ...@@ -2296,6 +2307,36 @@ void ha_pbxt::internal_close(THD *thd, struct XTThread *self)
*/ */
if (!thd || thd_sql_command(thd) == SQLCOM_FLUSH) // FLUSH TABLES if (!thd || thd_sql_command(thd) == SQLCOM_FLUSH) // FLUSH TABLES
xt_sync_flush_table(self, ot); xt_sync_flush_table(self, ot);
else {
/* This change is a result of a problem mentioned by Arjen.
* REPAIR and ALTER lead to the following sequence:
* 1. tab -- copy --> tmp1
* 2. tab -- rename --> tmp2
* 3. tmp1 -- rename --> tab
* 4. delete tmp2
*
* PBXT flushes a table before rename.
* In the sequence above results in a table flush in step 3 which can
* take a very long time.
*
* The problem is, during this time frame we have only temp tables.
* A crash in this state leaves the database in a bad state.
*
* To reduce the time in this state, the flush needs to be done
* elsewhere. The code below causes the flish to occur after
* step 1:
*/
switch (thd_sql_command(thd)) {
case SQLCOM_REPAIR:
case SQLCOM_RENAME_TABLE:
case SQLCOM_OPTIMIZE:
case SQLCOM_ANALYZE:
case SQLCOM_ALTER_TABLE:
case SQLCOM_CREATE_INDEX:
xt_sync_flush_table(self, ot);
break;
}
}
} }
freer_(); // xt_db_return_table_to_pool(ot); freer_(); // xt_db_return_table_to_pool(ot);
} }
...@@ -2356,9 +2397,15 @@ int ha_pbxt::open(const char *table_path, int XT_UNUSED(mode), uint XT_UNUSED(te ...@@ -2356,9 +2397,15 @@ int ha_pbxt::open(const char *table_path, int XT_UNUSED(mode), uint XT_UNUSED(te
#else #else
xt_tab_load_row_pointers(self, pb_open_tab); xt_tab_load_row_pointers(self, pb_open_tab);
#endif #endif
xt_ind_set_index_selectivity(pb_open_tab, self); xt_ind_set_index_selectivity(pb_open_tab, self);
#ifdef XT_ROW_COUNT_CORRECTED
/* {CORRECTED-ROW-COUNT} */
pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 - pb_share->sh_table->tab_row_fnum) < 150;
#else
/* {FREE-ROWS-BAD} */ /* {FREE-ROWS-BAD} */
pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) < 150; pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) < 150;
#endif
} }
init_auto_increment(0); init_auto_increment(0);
...@@ -3929,6 +3976,8 @@ int ha_pbxt::info(uint flag) ...@@ -3929,6 +3976,8 @@ int ha_pbxt::info(uint flag)
if ((ot = pb_open_tab)) { if ((ot = pb_open_tab)) {
if (flag & HA_STATUS_VARIABLE) { if (flag & HA_STATUS_VARIABLE) {
register XTTableHPtr tab = ot->ot_table;
/* {FREE-ROWS-BAD} /* {FREE-ROWS-BAD}
* Free row count is not reliable, so ignore it. * Free row count is not reliable, so ignore it.
* The problem is if tab_row_fnum > tab_row_eof_id - 1 then * The problem is if tab_row_fnum > tab_row_eof_id - 1 then
...@@ -3955,11 +4004,26 @@ int ha_pbxt::info(uint flag) ...@@ -3955,11 +4004,26 @@ int ha_pbxt::info(uint flag)
* the actual number of vectors. But it must assume that it has at * the actual number of vectors. But it must assume that it has at
* least EXTRA_RECORDS vectors. * least EXTRA_RECORDS vectors.
*/ */
stats.deleted = /* ot->ot_table->tab_row_fnum */ 0; #ifdef XT_ROW_COUNT_CORRECTED
stats.records = (ha_rows) (ot->ot_table->tab_row_eof_id - 1 /* - stats.deleted */); if (tab->tab_row_eof_id <= tab->tab_row_fnum ||
stats.data_file_length = xt_rec_id_to_rec_offset(ot->ot_table, ot->ot_table->tab_rec_eof_id); (!tab->tab_row_free_id && tab->tab_row_fnum))
stats.index_file_length = xt_ind_node_to_offset(ot->ot_table, ot->ot_table->tab_ind_eof); xt_tab_check_free_lists(NULL, ot, false, true);
stats.delete_length = ot->ot_table->tab_rec_fnum * ot->ot_rec_size; stats.records = (ha_rows) tab->tab_row_eof_id - 1;
if (stats.records >= tab->tab_row_fnum) {
stats.deleted = tab->tab_row_fnum;
stats.records -= stats.deleted;
}
else {
stats.deleted = 0;
stats.records = 2;
}
#else
stats.deleted = /* tab->tab_row_fnum */ 0;
stats.records = (ha_rows) (tab->tab_row_eof_id - 1 /* - stats.deleted */);
#endif
stats.data_file_length = xt_rec_id_to_rec_offset(tab, tab->tab_rec_eof_id);
stats.index_file_length = xt_ind_node_to_offset(tab, tab->tab_ind_eof);
stats.delete_length = tab->tab_rec_fnum * ot->ot_rec_size;
//check_time = info.check_time; //check_time = info.check_time;
stats.mean_rec_length = (ulong) ot->ot_rec_size; stats.mean_rec_length = (ulong) ot->ot_rec_size;
} }
...@@ -4584,13 +4648,24 @@ xtPublic int ha_pbxt::external_lock(THD *thd, int lock_type) ...@@ -4584,13 +4648,24 @@ xtPublic int ha_pbxt::external_lock(THD *thd, int lock_type)
} }
if (pb_share->sh_recalc_selectivity) { if (pb_share->sh_recalc_selectivity) {
#ifdef XT_ROW_COUNT_CORRECTED
/* {CORRECTED-ROW-COUNT} */
if ((pb_share->sh_table->tab_row_eof_id - 1 - pb_share->sh_table->tab_row_fnum) >= 200)
#else
/* {FREE-ROWS-BAD} */ /* {FREE-ROWS-BAD} */
if ((pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) >= 200) { if ((pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) >= 200)
#endif
{
/* [**] */ /* [**] */
pb_share->sh_recalc_selectivity = FALSE; pb_share->sh_recalc_selectivity = FALSE;
xt_ind_set_index_selectivity(pb_open_tab, self); xt_ind_set_index_selectivity(pb_open_tab, self);
#ifdef XT_ROW_COUNT_CORRECTED
/* {CORRECTED-ROW-COUNT} */
pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 - pb_share->sh_table->tab_row_fnum) < 150;
#else
/* {FREE-ROWS-BAD} */ /* {FREE-ROWS-BAD} */
pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) < 150; pb_share->sh_recalc_selectivity = (pb_share->sh_table->tab_row_eof_id - 1 /* - pb_share->sh_table->tab_row_fnum */) < 150;
#endif
} }
} }
} }
...@@ -4638,6 +4713,17 @@ xtPublic int ha_pbxt::external_lock(THD *thd, int lock_type) ...@@ -4638,6 +4713,17 @@ xtPublic int ha_pbxt::external_lock(THD *thd, int lock_type)
goto complete; goto complete;
} }
cont_(a); cont_(a);
/* Occurs if you do:
* truncate table t1;
* truncate table t1;
*/
if (!pb_open_tab) {
if ((err = reopen())) {
pb_ex_in_use = 0;
goto complete;
}
}
} }
else { else {
pb_ex_in_use = 1; pb_ex_in_use = 1;
...@@ -6076,6 +6162,40 @@ mysql_declare_plugin(pbxt) ...@@ -6076,6 +6162,40 @@ mysql_declare_plugin(pbxt)
drizzle_declare_plugin_end; drizzle_declare_plugin_end;
#else #else
mysql_declare_plugin_end; mysql_declare_plugin_end;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID > 50200
maria_declare_plugin(pbxt)
{ /* PBXT */
MYSQL_STORAGE_ENGINE_PLUGIN,
&pbxt_storage_engine,
"PBXT",
"Paul McCullagh, PrimeBase Technologies GmbH",
"High performance, multi-versioning transactional engine",
PLUGIN_LICENSE_GPL,
pbxt_init, /* Plugin Init */
pbxt_end, /* Plugin Deinit */
0x0001 /* 0.1 */,
NULL, /* status variables */
pbxt_system_variables, /* system variables */
"1.0.11-7 Pre-GA", /* string version */
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
},
{ /* PBXT_STATISTICS */
MYSQL_INFORMATION_SCHEMA_PLUGIN,
&pbxt_statitics,
"PBXT_STATISTICS",
"Paul McCullagh, PrimeBase Technologies GmbH",
"PBXT internal system statitics",
PLUGIN_LICENSE_GPL,
pbxt_init_statistics, /* plugin init */
pbxt_exit_statistics, /* plugin deinit */
0x0005,
NULL, /* status variables */
NULL, /* system variables */
"1.0.11-7 Pre-GA", /* string version */
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
}
maria_declare_plugin_end;
#endif
#endif #endif
#if defined(XT_WIN) && defined(XT_COREDUMP) #if defined(XT_WIN) && defined(XT_COREDUMP)
......
This diff is collapsed.
...@@ -312,7 +312,7 @@ typedef struct XTIndex { ...@@ -312,7 +312,7 @@ typedef struct XTIndex {
u_int mi_flags; u_int mi_flags;
u_int mi_key_size; u_int mi_key_size;
u_int mi_max_items; /* The maximum number of items that can fit in a leaf node. */ u_int mi_max_items; /* The maximum number of items that can fit in a leaf node. */
xtBool mi_low_byte_first; xtBool mi_key_corrupted; /* Set to TRUE if a currupted index key is detected. */
xtBool mi_fix_key; xtBool mi_fix_key;
xtBool mi_lazy_delete; /* TRUE if index entries are "lazy deleted". */ xtBool mi_lazy_delete; /* TRUE if index entries are "lazy deleted". */
u_int mi_single_type; /* Used when the index contains a single field. */ u_int mi_single_type; /* Used when the index contains a single field. */
......
...@@ -1088,7 +1088,10 @@ xtPublic u_int myxt_get_key_length(XTIndexPtr ind, xtWord1 *key_buf) ...@@ -1088,7 +1088,10 @@ xtPublic u_int myxt_get_key_length(XTIndexPtr ind, xtWord1 *key_buf)
} }
end: end:
return (xtWord1 *) key_data - key_buf; u_int ilen = (xtWord1 *) key_data - key_buf;
if (ilen > XT_INDEX_MAX_KEY_SIZE)
ind->mi_key_corrupted = TRUE;
return ilen;
} }
/* Derived from ha_key_cmp */ /* Derived from ha_key_cmp */
...@@ -2183,7 +2186,8 @@ static XTIndexPtr my_create_index(XTThreadPtr self, TABLE *table_arg, u_int idx, ...@@ -2183,7 +2186,8 @@ static XTIndexPtr my_create_index(XTThreadPtr self, TABLE *table_arg, u_int idx,
xt_spinlock_init_with_autoname(self, &ind->mi_dirty_lock); xt_spinlock_init_with_autoname(self, &ind->mi_dirty_lock);
ind->mi_index_no = idx; ind->mi_index_no = idx;
ind->mi_flags = (index->flags & (HA_NOSAME | HA_NULL_ARE_EQUAL | HA_UNIQUE_CHECK)); ind->mi_flags = (index->flags & (HA_NOSAME | HA_NULL_ARE_EQUAL | HA_UNIQUE_CHECK));
ind->mi_low_byte_first = TS(table_arg)->db_low_byte_first; //ind->mi_low_byte_first = TS(table_arg)->db_low_byte_first;
ind->mi_key_corrupted = FALSE;
ind->mi_fix_key = TRUE; ind->mi_fix_key = TRUE;
ind->mi_select_total = 0; ind->mi_select_total = 0;
ind->mi_subset_of = 0; ind->mi_subset_of = 0;
......
...@@ -69,17 +69,17 @@ void myxt_free_dictionary(XTThreadPtr self, XTDictionary *dic); ...@@ -69,17 +69,17 @@ void myxt_free_dictionary(XTThreadPtr self, XTDictionary *dic);
void myxt_move_dictionary(XTDictionaryPtr dic, XTDictionaryPtr source_dic); void myxt_move_dictionary(XTDictionaryPtr dic, XTDictionaryPtr source_dic);
XTDDTable *myxt_create_table_from_table(XTThreadPtr self, STRUCT_TABLE *my_tab); XTDDTable *myxt_create_table_from_table(XTThreadPtr self, STRUCT_TABLE *my_tab);
void myxt_static_convert_identifier(XTThreadPtr self, struct charset_info_st *cs, char *from, char *to, size_t to_len); void myxt_static_convert_identifier(XTThreadPtr self, MX_CONST_CHARSET_INFO *cs, char *from, char *to, size_t to_len);
char *myxt_convert_identifier(XTThreadPtr self, struct charset_info_st *cs, char *from); char *myxt_convert_identifier(XTThreadPtr self, MX_CONST_CHARSET_INFO *cs, char *from);
void myxt_static_convert_table_name(XTThreadPtr self, char *from, char *to, size_t to_len); void myxt_static_convert_table_name(XTThreadPtr self, char *from, char *to, size_t to_len);
void myxt_static_convert_file_name(char *from, char *to, size_t to_len); void myxt_static_convert_file_name(char *from, char *to, size_t to_len);
char *myxt_convert_table_name(XTThreadPtr self, char *from); char *myxt_convert_table_name(XTThreadPtr self, char *from);
int myxt_strcasecmp(char * a, char *b); int myxt_strcasecmp(char * a, char *b);
int myxt_isspace(struct charset_info_st *cs, char a); int myxt_isspace(MX_CONST_CHARSET_INFO *cs, char a);
int myxt_ispunct(struct charset_info_st *cs, char a); int myxt_ispunct(MX_CONST_CHARSET_INFO *cs, char a);
int myxt_isdigit(struct charset_info_st *cs, char a); int myxt_isdigit(MX_CONST_CHARSET_INFO *cs, char a);
struct charset_info_st *myxt_getcharset(bool convert); MX_CONST_CHARSET_INFO *myxt_getcharset(bool convert);
void *myxt_create_thread(); void *myxt_create_thread();
void myxt_destroy_thread(void *thread, xtBool end_threads); void myxt_destroy_thread(void *thread, xtBool end_threads);
......
...@@ -1359,6 +1359,57 @@ static xtBool xres_sync_operations(XTThreadPtr self, XTDatabaseHPtr db, XTWriter ...@@ -1359,6 +1359,57 @@ static xtBool xres_sync_operations(XTThreadPtr self, XTDatabaseHPtr db, XTWriter
return op_synced; return op_synced;
} }
#ifdef XT_CORRECT_TABLE_FREE_COUNT
#define CORRECT_COUNT TRUE
#else
#define CORRECT_COUNT FALSE
#endif
#ifdef XT_CHECK_RECORD_FREE_COUNT
#define CHECK_RECS TRUE
#else
#define CHECK_RECS FALSE
#endif
#if defined(XT_CHECK_RECORD_FREE_COUNT) || defined(XT_CHECK_ROW_FREE_COUNT)
#define RECOVER_FREE_COUNTS
#endif
#ifdef RECOVER_FREE_COUNTS
/* {CORRECTED-ROW-COUNT}
* This error can be repeated by crashing the server during
* high activitity, after flush table writes the table header
*
* On recovery, the free count "from the future" is used as
* the starting point for subsequent allocation and frees.
* The count is wrong after that point.
*
* The recovery of the count only works correctly if a
* checkpoint is complete successfully after that table
* header is flushed. Basically the writing of the table
* header should be synchronsized with the writing of the
* end of the checkpoint.
*
* Another solution would be to log the count, along with
* the allocate and free commannds.
*
* The 3rd solution is the one used here. The count is corrected
* after recovery.
*/
static void xres_recover_table_free_counts(XTThreadPtr self, XTDatabaseHPtr db, XTWriterStatePtr ws)
{
u_int edx;
XTTableEntryPtr te_ptr;
XTTableHPtr tab;
xt_enum_tables_init(&edx);
while ((te_ptr = xt_enum_tables_next(self, db, &edx))) {
if ((tab = te_ptr->te_table)) {
if (xres_open_table(self, ws, te_ptr->te_tab_id))
xt_tab_check_free_lists(self, ws->ws_ot, CHECK_RECS, CORRECT_COUNT);
}
}
}
#endif
/* /*
* Operations from the log are applied in sequence order. * Operations from the log are applied in sequence order.
* If the operations are out of sequence, they are buffered * If the operations are out of sequence, they are buffered
...@@ -2175,6 +2226,13 @@ xtBool XTXactRestart::xres_restart(XTThreadPtr self, xtLogID *log_id, xtLogOffse ...@@ -2175,6 +2226,13 @@ xtBool XTXactRestart::xres_restart(XTThreadPtr self, xtLogID *log_id, xtLogOffse
/* This is true because if no transaction was placed in RAM then /* This is true because if no transaction was placed in RAM then
* the next transaction in RAM will have the next ID: */ * the next transaction in RAM will have the next ID: */
db->db_xn_min_ram_id = db->db_xn_curr_id + 1; db->db_xn_min_ram_id = db->db_xn_curr_id + 1;
#ifdef RECOVER_FREE_COUNTS
if (xres_cp_log_id != *log_id || xres_cp_log_offset != *log_offset) {
/* Recovery took place, correct the row count! */
xres_recover_table_free_counts(self, db, &ws);
}
#endif
} }
failed: failed:
......
...@@ -380,7 +380,7 @@ xtPublic void xt_int8_to_byte_size(xtInt8 value, char *string) ...@@ -380,7 +380,7 @@ xtPublic void xt_int8_to_byte_size(xtInt8 value, char *string)
/* Version number must also be set in configure.in! */ /* Version number must also be set in configure.in! */
xtPublic c_char *xt_get_version(void) xtPublic c_char *xt_get_version(void)
{ {
return "1.0.11 Pre-GA"; return "1.0.11-7 Pre-GA";
} }
/* Copy and URL decode! */ /* Copy and URL decode! */
......
This diff is collapsed.
...@@ -507,6 +507,7 @@ int xt_tab_compare_names(const char *n1, const char *n2); ...@@ -507,6 +507,7 @@ int xt_tab_compare_names(const char *n1, const char *n2);
int xt_tab_compare_paths(char *n1, char *n2); int xt_tab_compare_paths(char *n1, char *n2);
void xt_tab_init_db(struct XTThread *self, struct XTDatabase *db); void xt_tab_init_db(struct XTThread *self, struct XTDatabase *db);
void xt_tab_exit_db(struct XTThread *self, struct XTDatabase *db); void xt_tab_exit_db(struct XTThread *self, struct XTDatabase *db);
void xt_tab_check_free_lists(struct XTThread *self, XTOpenTablePtr ot, bool check_recs, bool correct_count);
void xt_check_tables(struct XTThread *self); void xt_check_tables(struct XTThread *self);
char *xt_tab_file_to_name(size_t size, char *tab_name, char *file_name); char *xt_tab_file_to_name(size_t size, char *tab_name, char *file_name);
...@@ -572,6 +573,7 @@ xtBool xt_tab_get_rec_data(register XTOpenTablePtr ot, xtRecordID rec_id, siz ...@@ -572,6 +573,7 @@ xtBool xt_tab_get_rec_data(register XTOpenTablePtr ot, xtRecordID rec_id, siz
void xt_tab_disable_index(XTTableHPtr tab, u_int ind_error); void xt_tab_disable_index(XTTableHPtr tab, u_int ind_error);
void xt_tab_set_index_error(XTTableHPtr tab); void xt_tab_set_index_error(XTTableHPtr tab);
void xt_tab_make_table_name(XTTableHPtr tab, char *table_name, size_t size);
xtBool xt_tab_is_table_repair_pending(XTTableHPtr tab); xtBool xt_tab_is_table_repair_pending(XTTableHPtr tab);
void xt_tab_table_repaired(XTTableHPtr tab); void xt_tab_table_repaired(XTTableHPtr tab);
void xt_tab_set_table_repair_pending(XTTableHPtr tab); void xt_tab_set_table_repair_pending(XTTableHPtr tab);
......
...@@ -224,12 +224,17 @@ static void thr_log_va(XTThreadPtr self, c_char *func, c_char *file, u_int line, ...@@ -224,12 +224,17 @@ static void thr_log_va(XTThreadPtr self, c_char *func, c_char *file, u_int line,
#else #else
/* Use the buffer, unless it is too small */ /* Use the buffer, unless it is too small */
va_list ap2; va_list ap2;
int bufsize;
va_copy(ap2, ap); va_copy(ap2, ap);
if (vsnprintf(buffer, DEFAULT_LOG_BUFFER_SIZE, fmt, ap) >= DEFAULT_LOG_BUFFER_SIZE) { bufsize = vsnprintf(buffer, DEFAULT_LOG_BUFFER_SIZE, fmt, ap);
if (vasprintf(&log_string, fmt, ap2) == -1) if (bufsize >= DEFAULT_LOG_BUFFER_SIZE) {
log_string = (char *) malloc(bufsize + 1);
if (vsnprintf(log_string, bufsize + 1, fmt, ap2) > bufsize) {
free(log_string);
log_string = NULL; log_string = NULL;
} }
}
else else
log_string = buffer; log_string = buffer;
#endif #endif
......
...@@ -1558,6 +1558,8 @@ xtPublic int xt_xn_status(XTOpenTablePtr ot, xtXactID xn_id, xtRecordID XT_UNUSE ...@@ -1558,6 +1558,8 @@ xtPublic int xt_xn_status(XTOpenTablePtr ot, xtXactID xn_id, xtRecordID XT_UNUSE
* Because we are only here because the record was valid but not * Because we are only here because the record was valid but not
* clean (you can confirm this by looking at the code that * clean (you can confirm this by looking at the code that
* calls this function). * calls this function).
*
* See {RETRY-READ}
*/ */
return XT_XN_REREAD; return XT_XN_REREAD;
} }
...@@ -1743,7 +1745,7 @@ xtPublic xtWord8 xt_xn_bytes_to_sweep(XTDatabaseHPtr db, XTThreadPtr thread) ...@@ -1743,7 +1745,7 @@ xtPublic xtWord8 xt_xn_bytes_to_sweep(XTDatabaseHPtr db, XTThreadPtr thread)
} }
else { else {
xn_log_id = x_log_id; xn_log_id = x_log_id;
x_log_offset = x_log_offset; xn_log_offset = x_log_offset;
} }
} }
xn_id++; xn_id++;
......
...@@ -397,6 +397,24 @@ typedef struct XTPathStr { ...@@ -397,6 +397,24 @@ typedef struct XTPathStr {
*/ */
#define XT_XLOG_FLUSH_FREQ 1000 #define XT_XLOG_FLUSH_FREQ 1000
/*
* Define here if you want to check (and correct) the table free list
* counts. The free list counts are not durable, because they are not
* written to the log.
*
* The row free count is most critical because it can be used to
* estimate the the of rows in the record.
*/
#define XT_CHECK_ROW_FREE_COUNT
#ifdef DEBUG
#define XT_CHECK_RECORD_FREE_COUNT
#endif
#define XT_CORRECT_TABLE_FREE_COUNT
#if defined(XT_CHECK_ROW_FREE_COUNT) && defined(XT_CORRECT_TABLE_FREE_COUNT)
#define XT_ROW_COUNT_CORRECTED
#endif
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
* GLOBAL CONSTANTS * GLOBAL CONSTANTS
*/ */
...@@ -873,7 +891,11 @@ extern "C" void session_mark_transaction_to_rollback(Session *session, bool all) ...@@ -873,7 +891,11 @@ extern "C" void session_mark_transaction_to_rollback(Session *session, bool all)
#define MX_ULONGLONG_T ulonglong #define MX_ULONGLONG_T ulonglong
#define MX_LONGLONG_T longlong #define MX_LONGLONG_T longlong
#define MX_CHARSET_INFO CHARSET_INFO #define MX_CHARSET_INFO CHARSET_INFO
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID > 50200
#define MX_CONST_CHARSET_INFO const struct charset_info_st
#else
#define MX_CONST_CHARSET_INFO struct charset_info_st #define MX_CONST_CHARSET_INFO struct charset_info_st
#endif
#define MX_CONST #define MX_CONST
#define MX_BITMAP MY_BITMAP #define MX_BITMAP MY_BITMAP
#define MX_BIT_SIZE() n_bits #define MX_BIT_SIZE() n_bits
......
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