You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4292 lines
140 KiB

This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
This is a major update that fixes most of the issues and bugs that have been created by the last addition of new CONNECT features. The version previous to this one is a preliminary test version and should not be distributed. - Handle indexed UPDATE/DELETE. Previously this was just tested and an error message send when it could not be done. Now CONNECT can do it in all the cases. It is done by a MRR like tchnique by making a list of all update or delete to do, sort them, then execute them. modified: storage/connect/array.cpp storage/connect/array.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h - Differenciate Cardinality that returns a true or estimated table size and GetMaxSize that return a value equal or greater than the table row number. This fixes the errors of non matching opt files. modified: storage/connect/connect.cc storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/table.cpp storage/connect/tabmac.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabwmi.h storage/connect/xtable.h - Fix some errors and issues when making index and opt files. Erase opt and index files for void tables. Fix wrong calculation of Block and Last in MakeBlockValues. Invalidate indexes before making opt file. Fully handle blocked variable tables. Make opt file for blocked variable tables even when they have no optimised colums. modified: storage/connect/tabdos.cpp storage/connect/xindex.h - Fix some errors making index Return an error when the allocation is too small (should not really occur now that GetMaxSize is sure) Don't use XXROW index for DBF tables because of soft deleted lines. modified: storage/connect/xindex.cpp - Typo modified: storage/connect/macutil.cpp storage/connect/tabdos.h storage/connect/tabsys.cpp storage/connect/tabsys.h
11 years ago
  1. /*********** File AM Vct C++ Program Source Code File (.CPP) ***********/
  2. /* PROGRAM NAME: FILAMVCT */
  3. /* ------------- */
  4. /* Version 2.6 */
  5. /* */
  6. /* COPYRIGHT: */
  7. /* ---------- */
  8. /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
  9. /* */
  10. /* WHAT THIS PROGRAM DOES: */
  11. /* ----------------------- */
  12. /* This program are the VCT file access method classes. */
  13. /* Added in version 2: */
  14. /* - Split Vec format. */
  15. /* - Partial delete. */
  16. /* - Use of tempfile for update. */
  17. /* */
  18. /***********************************************************************/
  19. /***********************************************************************/
  20. /* Include relevant MariaDB header file. */
  21. /***********************************************************************/
  22. #include "my_global.h"
  23. #if defined(WIN32)
  24. #include <io.h>
  25. #include <fcntl.h>
  26. #if defined(__BORLANDC__)
  27. #define __MFC_COMPAT__ // To define min/max as macro
  28. #endif // __BORLAND__
  29. //#include <windows.h>
  30. #include <sys/stat.h>
  31. #else // !WIN32
  32. #if defined(UNIX)
  33. #include <sys/types.h>
  34. #include <sys/stat.h>
  35. #include <unistd.h>
  36. #include <errno.h>
  37. #define NO_ERROR 0
  38. #else // !UNIX
  39. #include <io.h>
  40. #endif // !UNIX
  41. #include <fcntl.h>
  42. #endif // !WIN32
  43. /***********************************************************************/
  44. /* Include application header files: */
  45. /* global.h is header containing all global declarations. */
  46. /* plgdbsem.h is header containing the DB application declarations. */
  47. /* tabdos.h is header containing the TABDOS class declarations. */
  48. /***********************************************************************/
  49. #include "global.h"
  50. #include "osutil.h" // Unuseful for WIN32
  51. #include "plgdbsem.h"
  52. #include "valblk.h"
  53. #include "filamfix.h"
  54. #include "tabdos.h"
  55. #include "tabvct.h"
  56. #include "maputil.h"
  57. #include "filamvct.h"
  58. #ifndef INVALID_SET_FILE_POINTER
  59. #define INVALID_SET_FILE_POINTER ((DWORD)-1)
  60. #endif
  61. extern int num_read, num_there; // Statistics
  62. static int num_write;
  63. extern "C" int trace;
  64. #if defined(UNIX)
  65. // Add dummy strerror (NGC)
  66. char *strerror(int num);
  67. #endif // UNIX
  68. /***********************************************************************/
  69. /* Header containing block info for not split VEC tables. */
  70. /* Block and last values can be calculated from NumRec and Nrec. */
  71. /* This is better than directly storing Block and Last because it */
  72. /* make possible to use the same file with tables having a different */
  73. /* block size value (Element -> Nrec) */
  74. /* Note: can be in a separate file if header=1 or a true header (2) */
  75. /***********************************************************************/
  76. typedef struct _vecheader {
  77. //int Block; /* The number of used blocks */
  78. //int Last; /* The number of used records in last block */
  79. int MaxRec; /* Max number of records (True vector format)*/
  80. int NumRec; /* Number of valid records in the table */
  81. } VECHEADER;
  82. /***********************************************************************/
  83. /* Char VCT column blocks are right filled with blanks (blank = true) */
  84. /* Conversion of block values allowed conditionally for insert only. */
  85. /***********************************************************************/
  86. PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int,
  87. bool check = true, bool blank = true, bool un = false);
  88. /* -------------------------- Class VCTFAM --------------------------- */
  89. /***********************************************************************/
  90. /* Implementation of the VCTFAM class. */
  91. /***********************************************************************/
  92. VCTFAM::VCTFAM(PVCTDEF tdp) : FIXFAM((PDOSDEF)tdp)
  93. {
  94. Last = tdp->GetLast();
  95. MaxBlk = (tdp->GetEstimate() > 0) ?
  96. ((tdp->GetEstimate() - 1) / Nrec + 1) : 0;
  97. NewBlock = NULL;
  98. AddBlock = false;
  99. Split = false;
  100. if ((Header = (MaxBlk) ? tdp->Header : 0))
  101. Block = Last = -1;
  102. Bsize = Nrec;
  103. CurNum = Nrec - 1;
  104. Colfn = NULL;
  105. Tempat = NULL;
  106. Clens = NULL;
  107. Deplac = NULL;
  108. Isnum = NULL;
  109. Ncol = 0;
  110. } // end of VCTFAM standard constructor
  111. VCTFAM::VCTFAM(PVCTFAM txfp) : FIXFAM(txfp)
  112. {
  113. MaxBlk = txfp->MaxBlk;
  114. NewBlock = NULL;
  115. AddBlock = false;
  116. Split = txfp->Split;
  117. Header = txfp->Header;
  118. Bsize = txfp->Bsize;
  119. Colfn = txfp->Colfn;
  120. Tempat = txfp->Tempat;
  121. Clens = txfp->Clens;
  122. Deplac = txfp->Deplac;
  123. Isnum = txfp->Isnum;
  124. Ncol = txfp->Ncol;
  125. } // end of VCTFAM copy constructor
  126. /***********************************************************************/
  127. /* VCT GetFileLength: returns file size in number of bytes. */
  128. /* This function is here to be accessible by VECFAM and VMPFAM. */
  129. /***********************************************************************/
  130. int VCTFAM::GetFileLength(PGLOBAL g)
  131. {
  132. if (Split) {
  133. // Get the total file length
  134. char filename[_MAX_PATH];
  135. char *savfile = To_File;
  136. int i, len = 0;
  137. // Initialize the array of file structures
  138. if (!Colfn) {
  139. // Prepare the column file name pattern and set Ncol
  140. Colfn = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
  141. Ncol = ((PVCTDEF)Tdbp->GetDef())->MakeFnPattern(Colfn);
  142. } // endif Colfn
  143. To_File = filename;
  144. for (i = 0; i < Ncol; i++) {
  145. sprintf(filename, Colfn, i+1);
  146. len += TXTFAM::GetFileLength(g);
  147. } // endfor i
  148. To_File = savfile;
  149. return len;
  150. } else
  151. return TXTFAM::GetFileLength(g);
  152. } // end of GetFileLength
  153. /***********************************************************************/
  154. /* Reset read/write position values. */
  155. /***********************************************************************/
  156. void VCTFAM::Reset(void)
  157. {
  158. FIXFAM::Reset();
  159. NewBlock = NULL;
  160. AddBlock = false;
  161. CurNum = Nrec - 1;
  162. } // end of Reset
  163. /***********************************************************************/
  164. /* Get the Headlen, Block and Last info from the file header. */
  165. /***********************************************************************/
  166. int VCTFAM::GetBlockInfo(PGLOBAL g)
  167. {
  168. char filename[_MAX_PATH];
  169. int h, k, n;
  170. VECHEADER vh;
  171. if (Header < 1 || Header > 3 || !MaxBlk) {
  172. sprintf(g->Message, "Invalid header value %d", Header);
  173. return -1;
  174. } else
  175. n = (Header == 1) ? (int)sizeof(VECHEADER) : 0;
  176. PlugSetPath(filename, To_File, Tdbp->GetPath());
  177. if (Header == 2)
  178. strcat(PlugRemoveType(filename, filename), ".blk");
  179. if ((h = global_open(g, MSGID_CANNOT_OPEN, filename, O_RDONLY)) == -1
  180. || !_filelength(h)) {
  181. // Consider this is a void table
  182. Last = Nrec;
  183. Block = 0;
  184. if (h != -1)
  185. close(h);
  186. return n;
  187. } else if (Header == 3)
  188. k = lseek(h, -(int)sizeof(VECHEADER), SEEK_END);
  189. if ((k = read(h, &vh, sizeof(vh))) != sizeof(vh)) {
  190. sprintf(g->Message, "Error reading header file %s", filename);
  191. n = -1;
  192. } else if (MaxBlk * Nrec != vh.MaxRec) {
  193. sprintf(g->Message, "MaxRec=%d doesn't match MaxBlk=%d Nrec=%d",
  194. vh.MaxRec, MaxBlk, Nrec);
  195. n = -1;
  196. } else {
  197. Block = (vh.NumRec > 0) ? (vh.NumRec + Nrec - 1) / Nrec : 0;
  198. Last = (vh.NumRec + Nrec - 1) % Nrec + 1;
  199. } // endif s
  200. close(h);
  201. return n;
  202. } // end of GetBlockInfo
  203. /***********************************************************************/
  204. /* Get the Headlen, Block and Last info from the file header. */
  205. /***********************************************************************/
  206. bool VCTFAM::SetBlockInfo(PGLOBAL g)
  207. {
  208. char filename[_MAX_PATH];
  209. bool rc = false;
  210. size_t n;
  211. VECHEADER vh;
  212. FILE *s;
  213. PlugSetPath(filename, To_File, Tdbp->GetPath());
  214. if (Header != 2) {
  215. if (Stream) {
  216. s = Stream;
  217. if (Header == 1)
  218. /*k =*/ fseek(s, 0, SEEK_SET);
  219. } else
  220. s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "r+b");
  221. } else { // Header == 2
  222. strcat(PlugRemoveType(filename, filename), ".blk");
  223. s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "wb");
  224. } // endif Header
  225. if (!s) {
  226. sprintf(g->Message, "Error opening header file %s", filename);
  227. return true;
  228. } else if (Header == 3)
  229. /*k =*/ fseek(s, -(int)sizeof(VECHEADER), SEEK_END);
  230. vh.MaxRec = MaxBlk * Bsize;
  231. vh.NumRec = (Block - 1) * Nrec + Last;
  232. if ((n = fwrite(&vh, sizeof(vh), 1, s)) != 1) {
  233. sprintf(g->Message, "Error writing header file %s", filename);
  234. rc = true;
  235. } // endif fread
  236. if (Header == 2 || !Stream)
  237. fclose(s);
  238. return rc;
  239. } // end of SetBlockInfo
  240. /***********************************************************************/
  241. /* Use BlockTest to reduce the table estimated size. */
  242. /***********************************************************************/
  243. int VCTFAM::MaxBlkSize(PGLOBAL g, int s)
  244. {
  245. int rc = RC_OK, savcur = CurBlk;
  246. int size;
  247. // Roughly estimate the table size as the sum of blocks
  248. // that can contain good rows
  249. for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
  250. if ((rc = Tdbp->TestBlock(g)) == RC_OK)
  251. size += (CurBlk == Block - 1) ? Last : Nrec;
  252. else if (rc == RC_EF)
  253. break;
  254. CurBlk = savcur;
  255. return size;
  256. } // end of MaxBlkSize
  257. /***********************************************************************/
  258. /* VCT Cardinality: returns table cardinality in number of rows. */
  259. /* This function can be called with a null argument to test the */
  260. /* availability of Cardinality implementation (1 yes, 0 no). */
  261. /***********************************************************************/
  262. int VCTFAM::Cardinality(PGLOBAL g)
  263. {
  264. if (!g)
  265. return 1;
  266. if (Block < 0)
  267. if (Split) {
  268. // Separate column files and no pre setting of Block and Last
  269. // This allows to see a table modified externally, but Block
  270. // and Last must be set from the file cardinality.
  271. // Only happens when called by sub classes.
  272. char filename[_MAX_PATH];
  273. PSZ savfn = To_File;
  274. int len, clen, card = -1;
  275. PCOLDEF cdp = Tdbp->GetDef()->GetCols();
  276. if (!Colfn) {
  277. // Prepare the column file name pattern
  278. Colfn = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
  279. Ncol = ((VCTDEF*)Tdbp->GetDef())->MakeFnPattern(Colfn);
  280. } // endif Colfn
  281. // Use the first column file to calculate the cardinality
  282. clen = cdp->GetClen();
  283. sprintf(filename, Colfn, 1);
  284. To_File = filename;
  285. len = TXTFAM::GetFileLength(g);
  286. To_File = savfn;
  287. if (len >= 0) {
  288. if (!(len % clen))
  289. card = len / clen; // Fixed length file
  290. else
  291. sprintf(g->Message, MSG(NOT_FIXED_LEN), To_File, len, clen);
  292. if (trace)
  293. htrc(" Computed max_K=%d Filen=%d Clen=%d\n", card, len, clen);
  294. } else
  295. card = 0;
  296. // Set number of blocks for later use
  297. Block = (card > 0) ? (card + Nrec - 1) / Nrec : 0;
  298. Last = (card + Nrec - 1) % Nrec + 1;
  299. return card;
  300. } else {
  301. // Vector table having Block and Last info in a Header (file)
  302. if ((Headlen = GetBlockInfo(g)) < 0)
  303. return -1; // Error
  304. } // endif split
  305. return (Block) ? ((Block - 1) * Nrec + Last) : 0;
  306. } // end of Cardinality
  307. /***********************************************************************/
  308. /* GetRowID: return the RowID of last read record. */
  309. /***********************************************************************/
  310. int VCTFAM::GetRowID(void)
  311. {
  312. return 1 + ((CurBlk < Block) ? CurNum + Nrec * CurBlk
  313. : (Block - 1) * Nrec + Last);
  314. } // end of GetRowID
  315. /***********************************************************************/
  316. /* VCT Create an empty file for Vector formatted tables. */
  317. /***********************************************************************/
  318. bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn)
  319. {
  320. // Vector formatted file: this will create an empty file of the
  321. // required length if it does not exists yet.
  322. char filename[_MAX_PATH], c = 0;
  323. int h, n;
  324. PlugSetPath(filename, fn, Tdbp->GetPath());
  325. #if defined(WIN32)
  326. h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE);
  327. #else // !WIN32
  328. h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
  329. #endif // !WIN32
  330. if (h == -1)
  331. return true;
  332. n = (Header == 1 || Header == 3) ? sizeof(VECHEADER) : 0;
  333. if (lseek(h, n + MaxBlk * Nrec * Lrecl - 1, SEEK_SET) == -1) {
  334. sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
  335. close(h);
  336. return true;
  337. } // endif h
  338. write(h, &c, 1); // This actually fills the empty file
  339. close(h);
  340. return false;
  341. } // end of MakeEmptyFile
  342. /***********************************************************************/
  343. /* VCT Access Method opening routine. */
  344. /* New method now that this routine is called recursively (last table */
  345. /* first in reverse order): index blocks are immediately linked to */
  346. /* join block of next table if it exists or else are discarted. */
  347. /***********************************************************************/
  348. bool VCTFAM::OpenTableFile(PGLOBAL g)
  349. {
  350. char opmode[4], filename[_MAX_PATH];
  351. MODE mode = Tdbp->GetMode();
  352. PDBUSER dbuserp = PlgGetUser(g);
  353. /*********************************************************************/
  354. /* Update block info if necessary. */
  355. /*********************************************************************/
  356. if (Block < 0)
  357. if ((Headlen = GetBlockInfo(g)) < 0)
  358. return true;
  359. /*********************************************************************/
  360. /* Open according to input/output mode required. */
  361. /*********************************************************************/
  362. switch (mode) {
  363. case MODE_READ:
  364. strcpy(opmode, "rb");
  365. break;
  366. case MODE_DELETE:
  367. if (!Tdbp->GetNext()) {
  368. // Store the number of deleted lines
  369. DelRows = Cardinality(g);
  370. // This will delete the whole file
  371. strcpy(opmode, "wb");
  372. break;
  373. } // endif
  374. // Selective delete, pass thru
  375. case MODE_UPDATE:
  376. UseTemp = Tdbp->IsUsingTemp(g);
  377. strcpy(opmode, (UseTemp) ? "rb" : "r+b");
  378. break;
  379. case MODE_INSERT:
  380. if (MaxBlk) {
  381. if (!Block)
  382. if (MakeEmptyFile(g, To_File))
  383. return true;
  384. strcpy(opmode, "r+b"); // Required to update empty blocks
  385. } else if (!Block || Last == Nrec)
  386. strcpy(opmode, "ab");
  387. else
  388. strcpy(opmode, "r+b"); // Required to update the last block
  389. break;
  390. default:
  391. sprintf(g->Message, MSG(BAD_OPEN_MODE), mode);
  392. return true;
  393. } // endswitch Mode
  394. /*********************************************************************/
  395. /* Use conventionnal input/output functions. */
  396. /*********************************************************************/
  397. PlugSetPath(filename, To_File, Tdbp->GetPath());
  398. if (!(Stream = PlugOpenFile(g, filename, opmode))) {
  399. if (trace)
  400. htrc("%s\n", g->Message);
  401. return (mode == MODE_READ && errno == ENOENT)
  402. ? PushWarning(g, Tdbp) : true;
  403. } // endif Stream
  404. if (trace)
  405. htrc("File %s is open in mode %s\n", filename, opmode);
  406. To_Fb = dbuserp->Openlist; // Keep track of File block
  407. if (!strcmp(opmode, "wb"))
  408. // This will stop the process by
  409. // causing GetProgMax to return 0.
  410. return ResetTableSize(g, 0, Nrec);
  411. num_read = num_there = num_write = 0;
  412. // Allocate the table and column block buffer
  413. return AllocateBuffer(g);
  414. } // end of OpenTableFile
  415. /***********************************************************************/
  416. /* Allocate the block buffers for columns used in the query. */
  417. /***********************************************************************/
  418. bool VCTFAM::AllocateBuffer(PGLOBAL g)
  419. {
  420. MODE mode = Tdbp->GetMode();
  421. PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
  422. PCOLDEF cdp;
  423. PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
  424. if (mode == MODE_INSERT) {
  425. bool chk = PlgGetUser(g)->Check & CHK_TYPE;
  426. NewBlock = (char*)PlugSubAlloc(g, NULL, Blksize);
  427. for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext())
  428. memset(NewBlock + Nrec * cdp->GetPoff(),
  429. (IsTypeNum(cdp->GetType()) ? 0 : ' '),
  430. Nrec * cdp->GetClen());
  431. for (; cp; cp = (PVCTCOL)cp->Next)
  432. cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac,
  433. cp->Buf_Type, Nrec, cp->Format.Length,
  434. cp->Format.Prec, chk);
  435. return InitInsert(g); // Initialize inserting
  436. } else {
  437. if (UseTemp || mode == MODE_DELETE) {
  438. // Allocate all that is needed to move lines
  439. int i = 0, n = (MaxBlk) ? MaxBlk : 1;
  440. if (!Ncol)
  441. for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext())
  442. Ncol++;
  443. Clens = (int*)PlugSubAlloc(g, NULL, Ncol * sizeof(int));
  444. Deplac = (int*)PlugSubAlloc(g, NULL, Ncol * sizeof(int));
  445. Isnum = (bool*)PlugSubAlloc(g, NULL, Ncol * sizeof(bool));
  446. for (cdp = defp->GetCols(); cdp; i++, cdp = cdp->GetNext()) {
  447. Clens[i] = cdp->GetClen();
  448. Deplac[i] = Headlen + cdp->GetPoff() * n * Nrec;
  449. Isnum[i] = IsTypeNum(cdp->GetType());
  450. Buflen = MY_MAX(Buflen, cdp->GetClen());
  451. } // endfor cdp
  452. if (!UseTemp || MaxBlk) {
  453. Buflen *= Nrec;
  454. To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
  455. } else
  456. NewBlock = (char*)PlugSubAlloc(g, NULL, Blksize);
  457. } // endif mode
  458. for (; cp; cp = (PVCTCOL)cp->Next)
  459. if (!cp->IsSpecial()) // Not a pseudo column
  460. cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec,
  461. cp->Format.Length, cp->Format.Prec);
  462. } //endif mode
  463. return false;
  464. } // end of AllocateBuffer
  465. /***********************************************************************/
  466. /* Do initial action when inserting. */
  467. /***********************************************************************/
  468. bool VCTFAM::InitInsert(PGLOBAL g)
  469. {
  470. // We come here in MODE_INSERT only
  471. if (Last == Nrec) {
  472. CurBlk = Block;
  473. CurNum = 0;
  474. AddBlock = !MaxBlk;
  475. } else {
  476. int rc;
  477. PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
  478. // The starting point must be at the end of file as for append.
  479. CurBlk = Block - 1;
  480. CurNum = Last;
  481. // Prepare error return
  482. if (g->jump_level == MAX_JUMP) {
  483. strcpy(g->Message, MSG(TOO_MANY_JUMPS));
  484. return true;
  485. } // endif
  486. if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
  487. g->jump_level--;
  488. return true;
  489. } // endif
  490. // Last block must be updated by new values
  491. for (; cp; cp = (PVCTCOL)cp->Next)
  492. cp->ReadBlock(g);
  493. g->jump_level--;
  494. } // endif Last
  495. // We are not currently using a temporary file for Insert
  496. T_Stream = Stream;
  497. return false;
  498. } // end of InitInsert
  499. /***********************************************************************/
  500. /* ReadBuffer: Read one line for a VCT file. */
  501. /***********************************************************************/
  502. int VCTFAM::ReadBuffer(PGLOBAL g)
  503. {
  504. int rc = RC_OK;
  505. MODE mode = Tdbp->GetMode();
  506. if (Placed)
  507. Placed = false;
  508. else if ((++CurNum) >= ((CurBlk < Block - 1) ? Nrec : Last)) {
  509. /*******************************************************************/
  510. /* New block. */
  511. /*******************************************************************/
  512. CurNum = 0;
  513. next:
  514. if (++CurBlk == Block)
  515. return RC_EF; // End of file
  516. /*******************************************************************/
  517. /* Before reading a new block, check whether block optimizing */
  518. /* can be done, as well as for join as for local filtering. */
  519. /*******************************************************************/
  520. switch (Tdbp->TestBlock(g)) {
  521. case RC_EF:
  522. return RC_EF;
  523. case RC_NF:
  524. goto next;
  525. } // endswitch rc
  526. num_there++;
  527. } // endif CurNum
  528. if (OldBlk != CurBlk) {
  529. if (mode == MODE_UPDATE) {
  530. /*****************************************************************/
  531. /* Flush the eventually modified column buffers in old blocks */
  532. /* and read the blocks to modify attached to Set columns. */
  533. /*****************************************************************/
  534. if (MoveLines(g)) // For VECFAM
  535. return RC_FX;
  536. for (PVCTCOL colp = (PVCTCOL)Tdbp->GetSetCols();
  537. colp; colp = (PVCTCOL)colp->Next) {
  538. colp->WriteBlock(g);
  539. colp->ReadBlock(g);
  540. } // endfor colp
  541. } // endif mode
  542. OldBlk = CurBlk; // Last block actually read
  543. } // endif oldblk
  544. if (trace)
  545. htrc(" Read: CurNum=%d CurBlk=%d rc=%d\n", CurNum, CurBlk, RC_OK);
  546. return rc;
  547. } // end of ReadBuffer
  548. /***********************************************************************/
  549. /* Data Base write routine for VCT access method. */
  550. /***********************************************************************/
  551. int VCTFAM::WriteBuffer(PGLOBAL g)
  552. {
  553. if (trace)
  554. htrc("VCT WriteBuffer: R%d Mode=%d CurNum=%d CurBlk=%d\n",
  555. Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk);
  556. if (Tdbp->GetMode() == MODE_UPDATE) {
  557. // Mode Update is done in ReadDB, we just initialize it here
  558. if (!T_Stream) {
  559. if (UseTemp) {
  560. if (OpenTempFile(g))
  561. return RC_FX;
  562. // Most of the time, not all table columns are updated.
  563. // This why we must completely pre-fill the temporary file.
  564. Fpos = (MaxBlk) ? (Block - 1) * Nrec + Last
  565. : Block * Nrec; // To write last lock
  566. if (MoveIntermediateLines(g))
  567. return RC_FX;
  568. } else
  569. T_Stream = Stream;
  570. } // endif T_Stream
  571. } else {
  572. // Mode Insert
  573. if (MaxBlk && CurBlk == MaxBlk) {
  574. strcpy(g->Message, MSG(TRUNC_BY_ESTIM));
  575. return RC_EF; // Too many lines for vector formatted table
  576. } // endif MaxBlk
  577. if (Closing || ++CurNum == Nrec) {
  578. PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
  579. if (!AddBlock) {
  580. // Write back the updated last block values
  581. for (; cp; cp = (PVCTCOL)cp->Next)
  582. cp->WriteBlock(g);
  583. if (!Closing && !MaxBlk) {
  584. // For VCT tables, future blocks must be added
  585. char filename[_MAX_PATH];
  586. // Close the file and reopen it in mode Insert
  587. fclose(Stream);
  588. PlugSetPath(filename, To_File, Tdbp->GetPath());
  589. if (!(Stream= global_fopen(g, MSGID_OPEN_MODE_STRERROR, filename, "ab"))) {
  590. Closing = true; // Tell CloseDB of error
  591. return RC_FX;
  592. } // endif Stream
  593. AddBlock = true;
  594. } // endif Closing
  595. } else {
  596. // Here we must add a new block to the file
  597. if (Closing)
  598. // Reset the overwritten columns for last block extra records
  599. for (; cp; cp = (PVCTCOL)cp->Next)
  600. memset(NewBlock + Nrec * cp->Deplac + Last * cp->Clen,
  601. (cp->Buf_Type == TYPE_STRING) ? ' ' : '\0',
  602. (Nrec - Last) * cp->Clen);
  603. if ((size_t)Nrec !=
  604. fwrite(NewBlock, (size_t)Lrecl, (size_t)Nrec, Stream)) {
  605. sprintf(g->Message, MSG(WRITE_STRERROR), To_File, strerror(errno));
  606. return RC_FX;
  607. } // endif
  608. } // endif AddBlock
  609. if (!Closing) {
  610. CurBlk++;
  611. CurNum = 0;
  612. } // endif Closing
  613. } // endif Closing || CurNum
  614. } // endif Mode
  615. return RC_OK;
  616. } // end of WriteBuffer
  617. /***********************************************************************/
  618. /* Data Base delete line routine for VCT access method. */
  619. /* Note: lines are moved directly in the files (ooops...) */
  620. /* Using temp file depends on the Check setting, false by default. */
  621. /***********************************************************************/
  622. int VCTFAM::DeleteRecords(PGLOBAL g, int irc)
  623. {
  624. bool eof = false;
  625. if (trace)
  626. htrc("VCT DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
  627. irc, UseTemp, Fpos, Tpos, Spos);
  628. if (irc != RC_OK) {
  629. /*******************************************************************/
  630. /* EOF: position Fpos at the end-of-file position. */
  631. /*******************************************************************/
  632. Fpos = (Block - 1) * Nrec + Last;
  633. if (trace)
  634. htrc("Fpos placed at file end=%d\n", Fpos);
  635. eof = UseTemp && !MaxBlk;
  636. } else // Fpos is the Deleted line position
  637. Fpos = CurBlk * Nrec + CurNum;
  638. if (Tpos == Spos) {
  639. if (UseTemp) {
  640. /*****************************************************************/
  641. /* Open the temporary file, Spos is at the beginning of file. */
  642. /*****************************************************************/
  643. if (OpenTempFile(g))
  644. return RC_FX;
  645. } else {
  646. /*****************************************************************/
  647. /* First line to delete. Move of eventual preceding lines is */
  648. /* not required here, just the setting of future Spos and Tpos. */
  649. /*****************************************************************/
  650. T_Stream = Stream;
  651. Spos = Tpos = Fpos;
  652. } // endif UseTemp
  653. } // endif Tpos == Spos
  654. /*********************************************************************/
  655. /* Move any intermediate lines. */
  656. /*********************************************************************/
  657. if (MoveIntermediateLines(g, &eof))
  658. return RC_FX;
  659. if (irc == RC_OK) {
  660. /*******************************************************************/
  661. /* Reposition the file pointer and set Spos. */
  662. /*******************************************************************/
  663. #ifdef _DEBUG
  664. assert(Spos == Fpos);
  665. #endif
  666. Spos++; // New start position is on next line
  667. if (trace)
  668. htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
  669. } else {
  670. /*******************************************************************/
  671. /* Last call after EOF has been reached. */
  672. /* Update the Block and Last values. */
  673. /*******************************************************************/
  674. Block = (Tpos > 0) ? (Tpos + Nrec - 1) / Nrec : 0;
  675. Last = (Tpos + Nrec - 1) % Nrec + 1;
  676. if (!UseTemp) { // The UseTemp case is treated in CloseTableFile
  677. if (!MaxBlk) {
  678. /***************************************************************/
  679. /* Because the chsize functionality is only accessible with a */
  680. /* system call we must close the file and reopen it with the */
  681. /* open function (_fopen for MS ??) this is still to be */
  682. /* checked for compatibility with Text files and other OS's. */
  683. /***************************************************************/
  684. char filename[_MAX_PATH];
  685. int h;
  686. /*rc =*/ CleanUnusedSpace(g); // Clean last block
  687. /*rc =*/ PlugCloseFile(g, To_Fb);
  688. Stream = NULL; // For SetBlockInfo
  689. PlugSetPath(filename, To_File, Tdbp->GetPath());
  690. if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0)
  691. return RC_FX;
  692. /***************************************************************/
  693. /* Remove extra blocks. */
  694. /***************************************************************/
  695. #if defined(UNIX)
  696. if (ftruncate(h, (off_t)(Headlen + Block * Blksize))) {
  697. sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
  698. close(h);
  699. return RC_FX;
  700. } // endif
  701. #else
  702. if (chsize(h, Headlen + Block * Blksize)) {
  703. sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
  704. close(h);
  705. return RC_FX;
  706. } // endif
  707. #endif
  708. close(h);
  709. if (trace)
  710. htrc("done, h=%d irc=%d\n", h, irc);
  711. } else
  712. // Clean the unused space in the file, this is required when
  713. // inserting again with a partial column list.
  714. if (CleanUnusedSpace(g))
  715. return RC_FX;
  716. if (ResetTableSize(g, Block, Last))
  717. return RC_FX;
  718. } // endif UseTemp
  719. } // endif irc
  720. return RC_OK; // All is correct
  721. } // end of DeleteRecords
  722. /***********************************************************************/
  723. /* Open a temporary file used while updating or deleting. */
  724. /***********************************************************************/
  725. bool VCTFAM::OpenTempFile(PGLOBAL g)
  726. {
  727. char *opmode, tempname[_MAX_PATH];
  728. bool rc = false;
  729. /*********************************************************************/
  730. /* Open the temporary file, Spos is at the beginning of file. */
  731. /*********************************************************************/
  732. PlugSetPath(tempname, To_File, Tdbp->GetPath());
  733. strcat(PlugRemoveType(tempname, tempname), ".t");
  734. if (MaxBlk) {
  735. if (MakeEmptyFile(g, tempname))
  736. return true;
  737. opmode = "r+b";
  738. } else
  739. opmode = "wb";
  740. if (!(T_Stream = PlugOpenFile(g, tempname, opmode))) {
  741. if (trace)
  742. htrc("%s\n", g->Message);
  743. rc = true;
  744. } else
  745. To_Fbt = PlgGetUser(g)->Openlist;
  746. return rc;
  747. } // end of OpenTempFile
  748. /***********************************************************************/
  749. /* Move intermediate deleted or updated lines. */
  750. /***********************************************************************/
  751. bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
  752. {
  753. int i, dep, off;
  754. int n;
  755. bool eof = (b) ? *b : false;
  756. size_t req, len;
  757. for (n = Fpos - Spos; n > 0 || eof; n -= req) {
  758. /*******************************************************************/
  759. /* Non consecutive line to delete. Move intermediate lines. */
  760. /*******************************************************************/
  761. if (!MaxBlk)
  762. req = (size_t)MY_MIN(n, Nrec - MY_MAX(Spos % Nrec, Tpos % Nrec));
  763. else
  764. req = (size_t)MY_MIN(n, Nrec);
  765. if (req) for (i = 0; i < Ncol; i++) {
  766. if (MaxBlk) {
  767. dep = Deplac[i];
  768. off = Spos * Clens[i];
  769. } else {
  770. if (UseTemp)
  771. To_Buf = NewBlock + Deplac[i] + (Tpos % Nrec) * Clens[i];
  772. dep = Deplac[i] + (Spos / Nrec) * Blksize;
  773. off = (Spos % Nrec) * Clens[i];
  774. } // endif MaxBlk
  775. if (fseek(Stream, dep + off, SEEK_SET)) {
  776. sprintf(g->Message, MSG(READ_SEEK_ERROR), strerror(errno));
  777. return true;
  778. } // endif
  779. len = fread(To_Buf, Clens[i], req, Stream);
  780. if (trace)
  781. htrc("after read req=%d len=%d\n", req, len);
  782. if (len != req) {
  783. sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
  784. return true;
  785. } // endif len
  786. if (!UseTemp || MaxBlk) {
  787. if (MaxBlk) {
  788. dep = Deplac[i];
  789. off = Tpos * Clens[i];
  790. } else {
  791. dep = Deplac[i] + (Tpos / Nrec) * Blksize;
  792. off = (Tpos % Nrec) * Clens[i];
  793. } // endif MaxBlk
  794. if (fseek(T_Stream, dep + off, SEEK_SET)) {
  795. sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno));
  796. return true;
  797. } // endif
  798. if ((len = fwrite(To_Buf, Clens[i], req, T_Stream)) != req) {
  799. sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno));
  800. return true;
  801. } // endif
  802. } // endif UseTemp
  803. if (trace)
  804. htrc("after write pos=%d\n", ftell(Stream));
  805. } // endfor i
  806. Tpos += (int)req;
  807. Spos += (int)req;
  808. if (UseTemp && !MaxBlk && (Tpos % Nrec == 0 || (eof && Spos == Fpos))) {
  809. // Write the full or last block to the temporary file
  810. if ((dep = Nrec - (Tpos % Nrec)) < Nrec)
  811. // Clean the last block in case of future insert,
  812. // must be done here because T_Stream was open in write only.
  813. for (i = 0; i < Ncol; i++) {
  814. To_Buf = NewBlock + Deplac[i] + (Tpos % Nrec) * Clens[i];
  815. memset(To_Buf, (Isnum[i]) ? 0 : ' ', dep * Clens[i]);
  816. } // endfor i
  817. // Write a new block in the temporary file
  818. len = (size_t)Blksize;
  819. if (fwrite(NewBlock, 1, len, T_Stream) != len) {
  820. sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno));
  821. return true;
  822. } // endif
  823. if (Spos == Fpos)
  824. eof = false;
  825. } // endif UseTemp
  826. if (trace)
  827. htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
  828. } // endfor n
  829. return false;
  830. } // end of MoveIntermediateLines
  831. /***********************************************************************/
  832. /* Clean deleted space in a VCT or Vec table file. */
  833. /***********************************************************************/
  834. bool VCTFAM::CleanUnusedSpace(PGLOBAL g)
  835. {
  836. int i, dep;
  837. int n;
  838. size_t req, len;
  839. if (!MaxBlk) {
  840. /*******************************************************************/
  841. /* Clean last block of the VCT table file. */
  842. /*******************************************************************/
  843. assert(!UseTemp);
  844. if (!(n = Nrec - Last))
  845. return false;
  846. dep = (Block - 1) * Blksize;
  847. req = (size_t)n;
  848. for (i = 0; i < Ncol; i++) {
  849. memset(To_Buf, (Isnum[i]) ? 0 : ' ', n * Clens[i]);
  850. if (fseek(Stream, dep + Deplac[i] + Last * Clens[i], SEEK_SET)) {
  851. sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno));
  852. return true;
  853. } // endif
  854. if ((len = fwrite(To_Buf, Clens[i], req, Stream)) != req) {
  855. sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno));
  856. return true;
  857. } // endif
  858. } // endfor i
  859. } else for (n = Fpos - Tpos; n > 0; n -= req) {
  860. /*******************************************************************/
  861. /* Fill VEC file remaining lines with 0's. */
  862. /* Note: this seems to work even column blocks have been made */
  863. /* with Blanks = true. Perhaps should it be set to false for VEC. */
  864. /*******************************************************************/
  865. req = (size_t)MY_MIN(n, Nrec);
  866. memset(To_Buf, 0, Buflen);
  867. for (i = 0; i < Ncol; i++) {
  868. if (fseek(T_Stream, Deplac[i] + Tpos * Clens[i], SEEK_SET)) {
  869. sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno));
  870. return true;
  871. } // endif
  872. if ((len = fwrite(To_Buf, Clens[i], req, T_Stream)) != req) {
  873. sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno));
  874. return true;
  875. } // endif
  876. } // endfor i
  877. Tpos += (int)req;
  878. } // endfor n
  879. return false;
  880. } // end of CleanUnusedSpace
  881. /***********************************************************************/
  882. /* Data Base close routine for VCT access method. */
  883. /***********************************************************************/
  884. void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
  885. {
  886. int rc = 0, wrc = RC_OK;
  887. MODE mode = Tdbp->GetMode();
  888. Abort = abort;
  889. if (mode == MODE_INSERT) {
  890. if (Closing)
  891. wrc = RC_FX; // Last write was in error
  892. else
  893. if (CurNum) {
  894. // Some more inserted lines remain to be written
  895. Last = CurNum;
  896. Block = CurBlk + 1;
  897. Closing = true;
  898. wrc = WriteBuffer(g);
  899. } else {
  900. Last = Nrec;
  901. Block = CurBlk;
  902. wrc = RC_OK;
  903. } // endif CurNum
  904. if (wrc != RC_FX) {
  905. rc = ResetTableSize(g, Block, Last);
  906. } else if (AddBlock) {
  907. // Last block was not written
  908. rc = ResetTableSize(g, CurBlk, Nrec);
  909. longjmp(g->jumper[g->jump_level], 44);
  910. } // endif
  911. } else if (mode == MODE_UPDATE) {
  912. // Write back to file any pending modifications
  913. for (PVCTCOL colp = (PVCTCOL)((PTDBVCT)Tdbp)->To_SetCols;
  914. colp; colp = (PVCTCOL)colp->Next)
  915. colp->WriteBlock(g);
  916. if (UseTemp && T_Stream) {
  917. rc = RenameTempFile(g);
  918. if (Header) {
  919. // Header must be set because it was not set in temp file
  920. Stream = T_Stream = NULL; // For SetBlockInfo
  921. rc = SetBlockInfo(g);
  922. } // endif Header
  923. } // endif UseTemp
  924. } else if (mode == MODE_DELETE && UseTemp && T_Stream) {
  925. if (MaxBlk)
  926. rc = CleanUnusedSpace(g);
  927. if ((rc = RenameTempFile(g)) != RC_FX) {
  928. Stream = T_Stream = NULL; // For SetBlockInfo
  929. rc = ResetTableSize(g, Block, Last);
  930. } // endif rc
  931. } // endif's mode
  932. if (!(UseTemp && T_Stream))
  933. rc = PlugCloseFile(g, To_Fb);
  934. if (trace)
  935. htrc("VCT CloseTableFile: closing %s wrc=%d rc=%d\n",
  936. To_File, wrc, rc);
  937. Stream = NULL;
  938. } // end of CloseTableFile
  939. /***********************************************************************/
  940. /* Data Base close routine for VCT access method. */
  941. /***********************************************************************/
  942. bool VCTFAM::ResetTableSize(PGLOBAL g, int block, int last)
  943. {
  944. bool rc = false;
  945. // Set Block and Last values for TDBVCT::MakeBlockValues
  946. Block = block;
  947. Last = last;
  948. if (!Split) {
  949. if (!Header) {
  950. // Update catalog values for Block and Last
  951. PVCTDEF defp = (PVCTDEF)Tdbp->GetDef();
  952. LPCSTR name = Tdbp->GetName();
  953. defp->SetBlock(Block);
  954. defp->SetLast(Last);
  955. if (!defp->SetIntCatInfo("Blocks", Block) ||
  956. !defp->SetIntCatInfo("Last", Last)) {
  957. sprintf(g->Message, MSG(UPDATE_ERROR), "Header");
  958. rc = true;
  959. } // endif
  960. } else
  961. rc = SetBlockInfo(g);
  962. } // endif Split
  963. Tdbp->ResetSize();
  964. return rc;
  965. } // end of ResetTableSize
  966. /***********************************************************************/
  967. /* Rewind routine for VCT access method. */
  968. /***********************************************************************/
  969. void VCTFAM::Rewind(void)
  970. {
  971. // In mode update we need to read Set Column blocks
  972. if (Tdbp->GetMode() == MODE_UPDATE)
  973. OldBlk = -1;
  974. // Initialize so block optimization is called for 1st block
  975. CurBlk = -1;
  976. CurNum = Nrec - 1;
  977. //rewind(Stream); will be placed by fseek
  978. } // end of Rewind
  979. /***********************************************************************/
  980. /* ReadBlock: Read column values from current block. */
  981. /***********************************************************************/
  982. bool VCTFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
  983. {
  984. int len;
  985. size_t n;
  986. /*********************************************************************/
  987. /* Calculate the offset and size of the block to read. */
  988. /*********************************************************************/
  989. if (MaxBlk) // True vector format
  990. len = Headlen + Nrec * (colp->Deplac * MaxBlk + colp->Clen * CurBlk);
  991. else // Blocked vector format
  992. len = Nrec * (colp->Deplac + Lrecl * CurBlk);
  993. if (trace)
  994. htrc("len=%d Nrec=%d Deplac=%d Lrecl=%d CurBlk=%d maxblk=%d\n",
  995. len, Nrec, colp->Deplac, Lrecl, CurBlk, MaxBlk);
  996. if (fseek(Stream, len, SEEK_SET)) {
  997. sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno));
  998. return true;
  999. } // endif
  1000. n = fread(colp->Blk->GetValPointer(), (size_t)colp->Clen,
  1001. (size_t)Nrec, Stream);
  1002. if (n != (size_t)Nrec) {
  1003. if (errno == NO_ERROR)
  1004. sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, To_File);
  1005. else
  1006. sprintf(g->Message, MSG(READ_ERROR),
  1007. To_File, strerror(errno));
  1008. if (trace)
  1009. htrc(" Read error: %s\n", g->Message);
  1010. return true;
  1011. } // endif
  1012. if (trace)
  1013. num_read++;
  1014. return false;
  1015. } // end of ReadBlock
  1016. /***********************************************************************/
  1017. /* WriteBlock: Write back current column values for one block. */
  1018. /* Note: the test of Status is meant to prevent physical writing of */
  1019. /* the block during the checking loop in mode Update. It is set to */
  1020. /* BUF_EMPTY when reopening the table between the two loops. */
  1021. /***********************************************************************/
  1022. bool VCTFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
  1023. {
  1024. int len;
  1025. size_t n;
  1026. /*********************************************************************/
  1027. /* Calculate the offset and size of the block to write. */
  1028. /*********************************************************************/
  1029. if (MaxBlk) // File has Vector format
  1030. len = Headlen
  1031. + Nrec * (colp->Deplac * MaxBlk + colp->Clen * colp->ColBlk);
  1032. else // Old VCT format
  1033. len = Nrec * (colp->Deplac + Lrecl * colp->ColBlk);
  1034. if (trace)
  1035. htrc("modif=%d len=%d Nrec=%d Deplac=%d Lrecl=%d colblk=%d\n",
  1036. Modif, len, Nrec, colp->Deplac, Lrecl, colp->ColBlk);
  1037. if (fseek(T_Stream, len, SEEK_SET)) {
  1038. sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno));
  1039. return true;
  1040. } // endif
  1041. // Here Nrec was changed to CurNum in mode Insert,
  1042. // this is the true number of records to write,
  1043. // this also avoid writing garbage in the file for true vector tables.
  1044. n = (Tdbp->GetMode() == MODE_INSERT) ? CurNum : Nrec;
  1045. if (n != fwrite(colp->Blk->GetValPointer(),
  1046. (size_t)colp->Clen, n, T_Stream)) {
  1047. sprintf(g->Message, MSG(WRITE_STRERROR),
  1048. (UseTemp) ? To_Fbt->Fname : To_File, strerror(errno));
  1049. if (trace)
  1050. htrc("Write error: %s\n", strerror(errno));
  1051. return true;
  1052. } // endif
  1053. #if defined(UNIX)
  1054. fflush(T_Stream); //NGC
  1055. #endif
  1056. #ifdef _DEBUG
  1057. num_write++;
  1058. #endif
  1059. return false;
  1060. } // end of WriteBlock
  1061. /* -------------------------- Class VCMFAM --------------------------- */
  1062. /***********************************************************************/
  1063. /* Implementation of the VCMFAM class. */
  1064. /***********************************************************************/
  1065. VCMFAM::VCMFAM(PVCTDEF tdp) : VCTFAM((PVCTDEF)tdp)
  1066. {
  1067. Memory = NULL;
  1068. Memcol = NULL;
  1069. } // end of VCMFAM standard constructor
  1070. VCMFAM::VCMFAM(PVCMFAM txfp) : VCTFAM(txfp)
  1071. {
  1072. Memory = txfp->Memory;
  1073. Memcol = txfp->Memcol;
  1074. } // end of VCMFAM copy constructor
  1075. /***********************************************************************/
  1076. /* Mapped VCT Access Method opening routine. */
  1077. /* New method now that this routine is called recursively (last table */
  1078. /* first in reverse order): index blocks are immediately linked to */
  1079. /* join block of next table if it exists or else are discarted. */
  1080. /***********************************************************************/
  1081. bool VCMFAM::OpenTableFile(PGLOBAL g)
  1082. {
  1083. char filename[_MAX_PATH];
  1084. int len;
  1085. MODE mode = Tdbp->GetMode();
  1086. PFBLOCK fp = NULL;
  1087. PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr;
  1088. /*********************************************************************/
  1089. /* Update block info if necessary. */
  1090. /*********************************************************************/
  1091. if (Block < 0)
  1092. if ((Headlen = GetBlockInfo(g)) < 0)
  1093. return true;
  1094. /*********************************************************************/
  1095. /* We used the file name relative to recorded datapath. */
  1096. /*********************************************************************/
  1097. PlugSetPath(filename, To_File, Tdbp->GetPath());
  1098. /*********************************************************************/
  1099. /* The whole file will be mapped so we can use it as if it were */
  1100. /* entirely read into virtual memory. */
  1101. /* Firstly we check whether this file have been already mapped. */
  1102. /*********************************************************************/
  1103. if (mode == MODE_READ) {
  1104. for (fp = dbuserp->Openlist; fp; fp = fp->Next)
  1105. if (fp->Type == TYPE_FB_MAP && !stricmp(fp->Fname, filename)
  1106. && fp->Count && fp->Mode == mode)
  1107. break;
  1108. if (trace)
  1109. htrc("Mapping VCM file, fp=%p cnt=%d\n", fp, fp->Count);
  1110. } else
  1111. fp = NULL;
  1112. if (fp) {
  1113. /*******************************************************************/
  1114. /* File already mapped. Just increment use count and get pointer. */
  1115. /*******************************************************************/
  1116. fp->Count++;
  1117. Memory = fp->Memory;
  1118. len = fp->Length;
  1119. } else {
  1120. /*******************************************************************/
  1121. /* If required, delete the whole file if no filtering is implied. */
  1122. /*******************************************************************/
  1123. bool del;
  1124. HANDLE hFile;
  1125. MEMMAP mm;
  1126. MODE mapmode = mode;
  1127. if (mode == MODE_INSERT) {
  1128. if (MaxBlk) {
  1129. if (!Block)
  1130. if (MakeEmptyFile(g, To_File))
  1131. return true;
  1132. // Inserting will be like updating the file
  1133. mapmode = MODE_UPDATE;
  1134. } else {
  1135. strcpy(g->Message, "MAP Insert is for VEC Estimate tables only");
  1136. return true;
  1137. } // endif MaxBlk
  1138. } // endif mode
  1139. del = mode == MODE_DELETE && !Tdbp->GetNext();
  1140. if (del) {
  1141. DelRows = Cardinality(g);
  1142. // This will stop the process by causing GetProgMax to return 0.
  1143. // ResetTableSize(g, 0, Nrec); must be done later
  1144. } // endif del
  1145. /*******************************************************************/
  1146. /* Create the mapping file object. */
  1147. /*******************************************************************/
  1148. hFile = CreateFileMap(g, filename, &mm, mapmode, del);
  1149. if (hFile == INVALID_HANDLE_VALUE) {
  1150. DWORD rc = GetLastError();
  1151. if (!(*g->Message))
  1152. sprintf(g->Message, MSG(OPEN_MODE_ERROR),
  1153. "map", (int) rc, filename);
  1154. if (trace)
  1155. htrc("%s\n", g->Message);
  1156. return (mode == MODE_READ && rc == ENOENT)
  1157. ? PushWarning(g, Tdbp) : true;
  1158. } // endif hFile
  1159. /*******************************************************************/
  1160. /* Get the file size (assuming file is smaller than 4 GB) */
  1161. /*******************************************************************/
  1162. len = mm.lenL;
  1163. Memory = (char *)mm.memory;
  1164. if (!len) { // Empty or deleted file
  1165. CloseFileHandle(hFile);
  1166. bool rc = ResetTableSize(g, 0, Nrec);
  1167. return (mapmode == MODE_UPDATE) ? true : rc;
  1168. } // endif len
  1169. if (!Memory) {
  1170. CloseFileHandle(hFile);
  1171. sprintf(g->Message, MSG(MAP_VIEW_ERROR),
  1172. filename, GetLastError());
  1173. return true;
  1174. } // endif Memory
  1175. if (mode != MODE_DELETE) {
  1176. CloseFileHandle(hFile); // Not used anymore
  1177. hFile = INVALID_HANDLE_VALUE; // For Fblock
  1178. } // endif Mode
  1179. /*******************************************************************/
  1180. /* Link a Fblock. This make possible to reuse already opened maps */
  1181. /* and also to automatically unmap them in case of error g->jump. */
  1182. /* Note: block can already exist for previously closed file. */
  1183. /*******************************************************************/
  1184. fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
  1185. fp->Type = TYPE_FB_MAP;
  1186. fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1);
  1187. strcpy((char*)fp->Fname, filename);
  1188. fp->Next = dbuserp->Openlist;
  1189. dbuserp->Openlist = fp;
  1190. fp->Count = 1;
  1191. fp->Length = len;
  1192. fp->Memory = Memory;
  1193. fp->Mode = mode;
  1194. fp->File = NULL;
  1195. fp->Handle = hFile; // Used for Delete
  1196. } // endif fp
  1197. To_Fb = fp; // Useful when closing
  1198. if (trace)
  1199. htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
  1200. fp, fp->Count, Memory, len);
  1201. return AllocateBuffer(g);
  1202. } // end of OpenTableFile
  1203. /***********************************************************************/
  1204. /* Allocate the block buffers for columns used in the query. */
  1205. /* Give a dummy value (1) to prevent allocating the value block. */
  1206. /* It will be set pointing into the memory map of the file. */
  1207. /* Note: Memcol must be set for all columns because it can be used */
  1208. /* for set columns in Update. Clens values are used only in Delete. */
  1209. /***********************************************************************/
  1210. bool VCMFAM::AllocateBuffer(PGLOBAL g)
  1211. {
  1212. int m, i = 0;
  1213. bool b = Tdbp->GetMode() == MODE_DELETE;
  1214. PVCTCOL cp;
  1215. PCOLDEF cdp;
  1216. PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
  1217. // Calculate the number of columns
  1218. if (!Ncol)
  1219. for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext())
  1220. Ncol++;
  1221. // To store the start position of each column
  1222. Memcol = (char**)PlugSubAlloc(g, NULL, Ncol * sizeof(char*));
  1223. m = (MaxBlk) ? MaxBlk : 1;
  1224. // We will need all column sizes and type for Delete
  1225. if (b) {
  1226. Clens = (int*)PlugSubAlloc(g, NULL, Ncol * sizeof(int));
  1227. Isnum = (bool*)PlugSubAlloc(g, NULL, Ncol * sizeof(bool));
  1228. } // endif b
  1229. for (cdp = defp->GetCols(); i < Ncol; i++, cdp = cdp->GetNext()) {
  1230. if (b) {
  1231. Clens[i] = cdp->GetClen();
  1232. Isnum[i] = IsTypeNum(cdp->GetType());
  1233. } // endif b
  1234. Memcol[i] = Memory + Headlen + cdp->GetPoff() * m * Nrec;
  1235. } // endfor cdp
  1236. for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
  1237. if (!cp->IsSpecial()) { // Not a pseudo column
  1238. cp->Blk = AllocValBlock(g, (void*)1, cp->Buf_Type, Nrec,
  1239. cp->Format.Length, cp->Format.Prec);
  1240. cp->AddStatus(BUF_MAPPED);
  1241. } // endif IsSpecial
  1242. if (Tdbp->GetMode() == MODE_INSERT)
  1243. return InitInsert(g);
  1244. return false;
  1245. } // end of AllocateBuffer
  1246. /***********************************************************************/
  1247. /* Do initial action when inserting. */
  1248. /***********************************************************************/
  1249. bool VCMFAM::InitInsert(PGLOBAL g)
  1250. {
  1251. int rc;
  1252. volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
  1253. // We come here in MODE_INSERT only
  1254. if (Last == Nrec) {
  1255. CurBlk = Block;
  1256. CurNum = 0;
  1257. AddBlock = !MaxBlk;
  1258. } else {
  1259. // The starting point must be at the end of file as for append.
  1260. CurBlk = Block - 1;
  1261. CurNum = Last;
  1262. } // endif Last
  1263. // Prepare error return
  1264. if (g->jump_level == MAX_JUMP) {
  1265. strcpy(g->Message, MSG(TOO_MANY_JUMPS));
  1266. return true;
  1267. } // endif
  1268. if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
  1269. g->jump_level--;
  1270. return true;
  1271. } // endif
  1272. // Initialize the column block pointer
  1273. for (; cp; cp = (PVCTCOL)cp->Next)
  1274. cp->ReadBlock(g);
  1275. g->jump_level--;
  1276. return false;
  1277. } // end of InitInsert
  1278. /***********************************************************************/
  1279. /* Data Base write routine for VMP access method. */
  1280. /***********************************************************************/
  1281. int VCMFAM::WriteBuffer(PGLOBAL g)
  1282. {
  1283. if (trace)
  1284. htrc("VCM WriteBuffer: R%d Mode=%d CurNum=%d CurBlk=%d\n",
  1285. Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk);
  1286. // Mode Update being done in ReadDB we process here Insert mode only.
  1287. if (Tdbp->GetMode() == MODE_INSERT) {
  1288. if (CurBlk == MaxBlk) {
  1289. strcpy(g->Message, MSG(TRUNC_BY_ESTIM));
  1290. return RC_EF; // Too many lines for vector formatted table
  1291. } // endif MaxBlk
  1292. if (Closing || ++CurNum == Nrec) {
  1293. PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
  1294. // Write back the updated last block values
  1295. for (; cp; cp = (PVCTCOL)cp->Next)
  1296. cp->WriteBlock(g);
  1297. if (!Closing) {
  1298. CurBlk++;
  1299. CurNum = 0;
  1300. // Re-initialize the column block pointer
  1301. for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
  1302. cp->ReadBlock(g);
  1303. } // endif Closing
  1304. } // endif Closing || CurNum
  1305. } // endif Mode
  1306. return RC_OK;
  1307. } // end of WriteBuffer
  1308. /***********************************************************************/
  1309. /* Data Base delete line routine for VMP access method. */
  1310. /* Lines between deleted lines are moved in the mapfile view. */
  1311. /***********************************************************************/
  1312. int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
  1313. {
  1314. if (trace)
  1315. htrc("VCM DeleteDB: irc=%d tobuf=%p Tpos=%p Spos=%p\n",
  1316. irc, To_Buf, Tpos, Spos);
  1317. if (irc != RC_OK) {
  1318. /*******************************************************************/
  1319. /* EOF: position Fpos at the top of map position. */
  1320. /*******************************************************************/
  1321. Fpos = (Block - 1) * Nrec + Last;
  1322. if (trace)
  1323. htrc("Fpos placed at file top=%p\n", Fpos);
  1324. } else // Fpos is the Deleted line position
  1325. Fpos = CurBlk * Nrec + CurNum;
  1326. if (Tpos == Spos) {
  1327. /*******************************************************************/
  1328. /* First line to delete. Move of eventual preceding lines is */
  1329. /* not required here, just setting of future Spos and Tpos. */
  1330. /*******************************************************************/
  1331. Tpos = Spos = Fpos;
  1332. } else
  1333. (void)MoveIntermediateLines(g);
  1334. if (irc == RC_OK) {
  1335. Spos = Fpos + 1; // New start position
  1336. if (trace)
  1337. htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
  1338. } else {
  1339. /*******************************************************************/
  1340. /* Last call after EOF has been reached. */
  1341. /*******************************************************************/
  1342. int i, m, n;
  1343. /*******************************************************************/
  1344. /* Reset the Block and Last values for TDBVCT::MakeBlockValues. */
  1345. /*******************************************************************/
  1346. Block = (Tpos > 0) ? (Tpos + Nrec - 1) / Nrec : 0;
  1347. Last = (Tpos + Nrec - 1) % Nrec + 1;
  1348. if (!MaxBlk) {
  1349. PFBLOCK fp = To_Fb;
  1350. // Clean the unused part of the last block
  1351. m = (Block - 1) * Blksize;
  1352. n = Nrec - Last;
  1353. for (i = 0; i < Ncol; i++)
  1354. memset(Memcol[i] + m + Last * Clens[i],
  1355. (Isnum[i]) ? 0 : ' ', n * Clens[i]);
  1356. // We must Unmap the view and use the saved file handle
  1357. // to put an EOF at the end of the last block of the file.
  1358. CloseMemMap(fp->Memory, (size_t)fp->Length);
  1359. fp->Count = 0; // Avoid doing it twice
  1360. // Remove extra blocks
  1361. n = Block * Blksize;
  1362. #if defined(WIN32)
  1363. DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
  1364. if (drc == 0xFFFFFFFF) {
  1365. sprintf(g->Message, MSG(FUNCTION_ERROR),
  1366. "SetFilePointer", GetLastError());
  1367. CloseHandle(fp->Handle);
  1368. return RC_FX;
  1369. } // endif
  1370. if (trace)
  1371. htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
  1372. if (!SetEndOfFile(fp->Handle)) {
  1373. sprintf(g->Message, MSG(FUNCTION_ERROR),
  1374. "SetEndOfFile", GetLastError());
  1375. CloseHandle(fp->Handle);
  1376. return RC_FX;
  1377. } // endif
  1378. CloseHandle(fp->Handle);
  1379. #else // UNIX
  1380. if (ftruncate(fp->Handle, (off_t)n)) {
  1381. sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
  1382. close(fp->Handle);
  1383. return RC_FX;
  1384. } // endif
  1385. close(fp->Handle);
  1386. #endif // UNIX
  1387. } else
  1388. // True vector table, Table file size does not change.
  1389. // Just clean the unused part of the file.
  1390. for (n = Fpos - Tpos, i = 0; i < Ncol; i++)
  1391. memset(Memcol[i] + Tpos * Clens[i], 0, n * Clens[i]);
  1392. // Reset Last and Block values in the catalog
  1393. PlugCloseFile(g, To_Fb); // in case of Header
  1394. ResetTableSize(g, Block, Last);
  1395. } // endif irc
  1396. return RC_OK; // All is correct
  1397. } // end of DeleteRecords
  1398. /***********************************************************************/
  1399. /* Move intermediate deleted or updated lines. */
  1400. /***********************************************************************/
  1401. bool VCMFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
  1402. {
  1403. int i, m, n;
  1404. if ((n = Fpos - Spos) > 0) {
  1405. /*******************************************************************/
  1406. /* Non consecutive line to delete. Move intermediate lines. */
  1407. /*******************************************************************/
  1408. if (!MaxBlk) {
  1409. // Old VCT format, moving must respect block limits
  1410. char *ps, *pt;
  1411. int req, soff, toff;
  1412. for (; n > 0; n -= req) {
  1413. soff = Spos % Nrec;
  1414. toff = Tpos % Nrec;
  1415. req = (size_t)MY_MIN(n, Nrec - MY_MAX(soff, toff));
  1416. for (i = 0; i < Ncol; i++) {
  1417. ps = Memcol[i] + (Spos / Nrec) * Blksize + soff * Clens[i];
  1418. pt = Memcol[i] + (Tpos / Nrec) * Blksize + toff * Clens[i];
  1419. memmove(pt, ps, req * Clens[i]);
  1420. } // endfor i
  1421. Tpos += req;
  1422. Spos += req;
  1423. } // endfor n
  1424. } else {
  1425. // True vector format, all is simple...
  1426. for (i = 0; i < Ncol; i++) {
  1427. m = Clens[i];
  1428. memmove(Memcol[i] + Tpos * m, Memcol[i] + Spos * m, n * m);
  1429. } // endfor i
  1430. Tpos += n;
  1431. } // endif MaxBlk
  1432. if (trace)
  1433. htrc("move %d bytes\n", n);
  1434. } // endif n
  1435. return false;
  1436. } // end of MoveIntermediate Lines
  1437. /***********************************************************************/
  1438. /* Data Base close routine for VMP access method. */
  1439. /***********************************************************************/
  1440. void VCMFAM::CloseTableFile(PGLOBAL g, bool abort)
  1441. {
  1442. int wrc = RC_OK;
  1443. MODE mode = Tdbp->GetMode();
  1444. if (mode == MODE_INSERT) {
  1445. if (!Closing) {
  1446. if (CurNum) {
  1447. // Some more inserted lines remain to be written
  1448. Last = CurNum;
  1449. Block = CurBlk + 1;
  1450. Closing = true;
  1451. wrc = WriteBuffer(g);
  1452. } else {
  1453. Last = Nrec;
  1454. Block = CurBlk;
  1455. wrc = RC_OK;
  1456. } // endif CurNum
  1457. } else
  1458. wrc = RC_FX; // Last write was in error
  1459. PlugCloseFile(g, To_Fb);
  1460. if (wrc != RC_FX)
  1461. /*rc =*/ ResetTableSize(g, Block, Last);
  1462. } else if (mode != MODE_DELETE || Abort)
  1463. PlugCloseFile(g, To_Fb);
  1464. } // end of CloseTableFile
  1465. /***********************************************************************/
  1466. /* ReadBlock: Read column values from current block. */
  1467. /***********************************************************************/
  1468. bool VCMFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
  1469. {
  1470. char *mempos;
  1471. int i = colp->Index - 1;
  1472. int n = Nrec * ((MaxBlk || Split) ? colp->Clen : Lrecl);
  1473. /*********************************************************************/
  1474. /* Calculate the start position of the column block to read. */
  1475. /*********************************************************************/
  1476. mempos = Memcol[i] + n * CurBlk;
  1477. if (trace)
  1478. htrc("mempos=%p i=%d Nrec=%d Clen=%d CurBlk=%d\n",
  1479. mempos, i, Nrec, colp->Clen, CurBlk);
  1480. if (colp->GetStatus(BUF_MAPPED))
  1481. colp->Blk->SetValPointer(mempos);
  1482. if (trace)
  1483. num_read++;
  1484. return false;
  1485. } // end of ReadBlock
  1486. /***********************************************************************/
  1487. /* WriteBlock: Write back current column values for one block. */
  1488. /* Note: there is nothing to do because we are working directly into */
  1489. /* the mapped file, except when checking for Update but in this case */
  1490. /* we do not want to write back the modifications either. */
  1491. /***********************************************************************/
  1492. bool VCMFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
  1493. {
  1494. #if defined(_DEBUG)
  1495. char *mempos;
  1496. int i = colp->Index - 1;
  1497. int n = Nrec * colp->Clen;
  1498. /*********************************************************************/
  1499. /* Calculate the offset and size of the block to write. */
  1500. /*********************************************************************/
  1501. mempos = Memcol[i] + n * CurBlk;
  1502. if (trace)
  1503. htrc("modif=%d mempos=%p i=%d Nrec=%d Clen=%d colblk=%d\n",
  1504. Modif, mempos, i, Nrec, colp->Clen, colp->ColBlk);
  1505. #endif // _DEBUG
  1506. return false;
  1507. } // end of WriteBlock
  1508. /* -------------------------- Class VECFAM --------------------------- */
  1509. /***********************************************************************/
  1510. /* Implementation of the VECFAM class. */
  1511. /***********************************************************************/
  1512. VECFAM::VECFAM(PVCTDEF tdp) : VCTFAM((PVCTDEF)tdp)
  1513. {
  1514. Streams = NULL;
  1515. To_Fbs = NULL;
  1516. To_Bufs = NULL;
  1517. Split = true;
  1518. Block = Last = -1;
  1519. InitUpdate = false;
  1520. } // end of VECFAM standard constructor
  1521. VECFAM::VECFAM(PVECFAM txfp) : VCTFAM(txfp)
  1522. {
  1523. Streams = txfp->Streams;
  1524. To_Fbs = txfp->To_Fbs;
  1525. Clens = txfp->Clens;
  1526. To_Bufs = txfp->To_Bufs;
  1527. InitUpdate = txfp->InitUpdate;
  1528. } // end of VECFAM copy constructor
  1529. /***********************************************************************/
  1530. /* VEC Access Method opening routine. */
  1531. /* New method now that this routine is called recursively (last table */
  1532. /* first in reverse order): index blocks are immediately linked to */
  1533. /* join block of next table if it exists or else are discarted. */
  1534. /***********************************************************************/
  1535. bool VECFAM::OpenTableFile(PGLOBAL g)
  1536. {
  1537. char opmode[4];
  1538. int i;
  1539. bool b= false;
  1540. PCOLDEF cdp;
  1541. PVCTCOL cp;
  1542. MODE mode = Tdbp->GetMode();
  1543. PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
  1544. /*********************************************************************/
  1545. /* Call Cardinality to set Block and Last values in case it was not */
  1546. /* already called (this happens indeed in test xmode) */
  1547. /*********************************************************************/
  1548. Cardinality(g);
  1549. /*********************************************************************/
  1550. /* Open according to input/output mode required. */
  1551. /*********************************************************************/
  1552. switch (mode) {
  1553. case MODE_READ:
  1554. strcpy(opmode, "rb");
  1555. break;
  1556. case MODE_DELETE:
  1557. if (!Tdbp->GetNext()) {
  1558. // Store the number of deleted lines
  1559. DelRows = Cardinality(g);
  1560. // This will delete the whole file
  1561. strcpy(opmode, "wb");
  1562. // This will stop the process by causing GetProgMax to return 0.
  1563. ResetTableSize(g, 0, Nrec);
  1564. break;
  1565. } // endif filter
  1566. // Selective delete, pass thru
  1567. case MODE_UPDATE:
  1568. UseTemp = Tdbp->IsUsingTemp(g);
  1569. strcpy(opmode, (UseTemp) ? "rb": "r+b");
  1570. break;
  1571. case MODE_INSERT:
  1572. strcpy(opmode, "ab");
  1573. break;
  1574. default:
  1575. sprintf(g->Message, MSG(BAD_OPEN_MODE), mode);
  1576. return true;
  1577. } // endswitch Mode
  1578. /*********************************************************************/
  1579. /* Initialize the array of file structures. */
  1580. /*********************************************************************/
  1581. if (!Colfn) {
  1582. // Prepare the column file name pattern and set Ncol
  1583. Colfn = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
  1584. Ncol = ((VCTDEF*)Tdbp->GetDef())->MakeFnPattern(Colfn);
  1585. } // endif Colfn
  1586. Streams = (FILE* *)PlugSubAlloc(g, NULL, Ncol * sizeof(FILE*));
  1587. To_Fbs = (PFBLOCK *)PlugSubAlloc(g, NULL, Ncol * sizeof(PFBLOCK));
  1588. for (i = 0; i < Ncol; i++) {
  1589. Streams[i] = NULL;
  1590. To_Fbs[i] = NULL;
  1591. } // endif i
  1592. /*********************************************************************/
  1593. /* Open the files corresponding to columns used in the query. */
  1594. /*********************************************************************/
  1595. if (mode == MODE_INSERT || mode == MODE_DELETE) {
  1596. // All columns must be written or deleted
  1597. for (i = 0, cdp = defp->GetCols(); cdp; i++, cdp = cdp->GetNext())
  1598. if (OpenColumnFile(g, opmode, i))
  1599. return true;
  1600. // Check for void table or missing columns
  1601. for (b = !Streams[0], i = 1; i < Ncol; i++)
  1602. if (b != !Streams[i])
  1603. return true;
  1604. } else {
  1605. /*******************************************************************/
  1606. /* Open the files corresponding to updated columns of the query. */
  1607. /*******************************************************************/
  1608. for (cp = (PVCTCOL)((PTDBVCT)Tdbp)->To_SetCols; cp;
  1609. cp = (PVCTCOL)cp->Next)
  1610. if (OpenColumnFile(g, opmode, cp->Index - 1))
  1611. return true;
  1612. // Open in read only mode the used columns not already open
  1613. for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
  1614. if (!cp->IsSpecial() && !Streams[cp->Index - 1])
  1615. if (OpenColumnFile(g, "rb", cp->Index - 1))
  1616. return true;
  1617. // Check for void table or missing columns
  1618. for (i = 0, cp = (PVCTCOL)Tdbp->GetColumns(); cp;
  1619. cp = (PVCTCOL)cp->Next)
  1620. if (!cp->IsSpecial()) {
  1621. if (!i++)
  1622. b = !Streams[cp->Index - 1];
  1623. else if (b != !Streams[cp->Index - 1])
  1624. return true;
  1625. } // endif Special
  1626. } // endif mode
  1627. /*********************************************************************/
  1628. /* Allocate the table and column block buffer. */
  1629. /*********************************************************************/
  1630. return (b) ? false : AllocateBuffer(g);
  1631. } // end of OpenTableFile
  1632. /***********************************************************************/
  1633. /* Open the file corresponding to one column. */
  1634. /***********************************************************************/
  1635. bool VECFAM::OpenColumnFile(PGLOBAL g, char *opmode, int i)
  1636. {
  1637. char filename[_MAX_PATH];
  1638. PDBUSER dup = PlgGetUser(g);
  1639. sprintf(filename, Colfn, i+1);
  1640. if (!(Streams[i] = PlugOpenFile(g, filename, opmode))) {
  1641. if (trace)
  1642. htrc("%s\n", g->Message);
  1643. return (Tdbp->GetMode() == MODE_READ && errno == ENOENT)
  1644. ? PushWarning(g, Tdbp) : true;
  1645. } // endif Streams
  1646. if (trace)
  1647. htrc("File %s is open in mode %s\n", filename, opmode);
  1648. To_Fbs[i] = dup->Openlist; // Keep track of File blocks
  1649. return false;
  1650. } // end of OpenColumnFile
  1651. /***********************************************************************/
  1652. /* Allocate the block buffers for columns used in the query. */
  1653. /***********************************************************************/
  1654. bool VECFAM::AllocateBuffer(PGLOBAL g)
  1655. {
  1656. int i;
  1657. PVCTCOL cp;
  1658. PCOLDEF cdp;
  1659. PTDBVCT tdbp = (PTDBVCT)Tdbp;
  1660. MODE mode = tdbp->GetMode();
  1661. PDOSDEF defp = (PDOSDEF)tdbp->GetDef();
  1662. if (mode != MODE_READ) {
  1663. // Allocate what is needed by all modes except Read
  1664. T_Streams = (FILE* *)PlugSubAlloc(g, NULL, Ncol * sizeof(FILE*));
  1665. Clens = (int*)PlugSubAlloc(g, NULL, Ncol * sizeof(int));
  1666. // Give default values
  1667. for (i = 0; i < Ncol; i++) {
  1668. T_Streams[i] = Streams[i];
  1669. Clens[i] = 0;
  1670. } // endfor i
  1671. } // endif mode
  1672. if (mode == MODE_INSERT) {
  1673. bool chk = PlgGetUser(g)->Check & CHK_TYPE;
  1674. To_Bufs = (void**)PlugSubAlloc(g, NULL, Ncol * sizeof(void*));
  1675. cdp = defp->GetCols();
  1676. for (i = 0; cdp && i < Ncol; i++, cdp = cdp->GetNext()) {
  1677. Clens[i] = cdp->GetClen();
  1678. To_Bufs[i] = PlugSubAlloc(g, NULL, Nrec * Clens[i]);
  1679. if (cdp->GetType() == TYPE_STRING)
  1680. memset(To_Bufs[i], ' ', Nrec * Clens[i]);
  1681. else
  1682. memset(To_Bufs[i], 0, Nrec * Clens[i]);
  1683. } // endfor cdp
  1684. for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next)
  1685. cp->Blk = AllocValBlock(g, To_Bufs[cp->Index - 1],
  1686. cp->Buf_Type, Nrec, cp->Format.Length,
  1687. cp->Format.Prec, chk);
  1688. return InitInsert(g);
  1689. } else {
  1690. if (UseTemp || mode == MODE_DELETE) {
  1691. // Allocate all that is needed to move lines and make Temp
  1692. if (UseTemp) {
  1693. Tempat = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
  1694. strcpy(Tempat, Colfn);
  1695. PlugSetPath(Tempat, Tempat, Tdbp->GetPath());
  1696. strcat(PlugRemoveType(Tempat, Tempat), ".t");
  1697. T_Fbs = (PFBLOCK *)PlugSubAlloc(g, NULL, Ncol * sizeof(PFBLOCK));
  1698. } // endif UseTemp
  1699. if (UseTemp)
  1700. for (i = 0; i < Ncol; i++) {
  1701. T_Streams[i] = (mode == MODE_UPDATE) ? (FILE*)1 : NULL;
  1702. T_Fbs[i] = NULL;
  1703. } // endfor i
  1704. if (mode == MODE_DELETE) { // All columns are moved
  1705. cdp = defp->GetCols();
  1706. for (i = 0; cdp && i < Ncol; i++, cdp = cdp->GetNext()) {
  1707. Clens[i] = cdp->GetClen();
  1708. Buflen = MY_MAX(Buflen, cdp->GetClen());
  1709. } // endfor cdp
  1710. } else { // Mode Update, only some columns are updated
  1711. for (cp = (PVCTCOL)tdbp->To_SetCols; cp; cp = (PVCTCOL)cp->Next) {
  1712. i = cp->Index -1;
  1713. if (UseTemp)
  1714. T_Streams[i] = NULL; // Mark the streams to open
  1715. Clens[i] = cp->Clen;
  1716. Buflen = MY_MAX(Buflen, cp->Clen);
  1717. } // endfor cp
  1718. InitUpdate = true; // To be initialized
  1719. } // endif mode
  1720. To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen * Nrec);
  1721. } // endif mode
  1722. // Finally allocate column buffers for all modes
  1723. for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next)
  1724. if (!cp->IsSpecial()) // Not a pseudo column
  1725. cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec,
  1726. cp->Format.Length, cp->Format.Prec);
  1727. } // endif mode
  1728. return false;
  1729. } // end of AllocateBuffer
  1730. /***********************************************************************/
  1731. /* Do initial action when inserting. */
  1732. /***********************************************************************/
  1733. bool VECFAM::InitInsert(PGLOBAL g)
  1734. {
  1735. // We come here in MODE_INSERT only
  1736. CurBlk = 0;
  1737. CurNum = 0;
  1738. AddBlock = true;
  1739. return false;
  1740. } // end of InitInsert
  1741. /***********************************************************************/
  1742. /* Reset buffer access according to indexing and to mode. */
  1743. /* >>>>>>>>>>>>>> TO BE RE-VISITED AND CHECKED <<<<<<<<<<<<<<<<<<<<<< */
  1744. /***********************************************************************/
  1745. void VECFAM::ResetBuffer(PGLOBAL g)
  1746. {
  1747. /*********************************************************************/
  1748. /* If access is random, performances can be much better when the */
  1749. /* reads are done on only one row, except for small tables that can */
  1750. /* be entirely read in one block. If the index is just used as a */
  1751. /* bitmap filter, as for Update or Delete, reading will be */
  1752. /* sequential and we better keep block reading. */
  1753. /*********************************************************************/
  1754. if (Tdbp->GetKindex() && Block > 1 && Tdbp->GetMode() == MODE_READ) {
  1755. Nrec = 1; // Better for random access
  1756. Rbuf = 0;
  1757. OldBlk = -2; // Has no meaning anymore
  1758. Block = Tdbp->Cardinality(g); // Blocks are one line now
  1759. Last = 1; // Probably unuseful
  1760. } // endif Mode
  1761. } // end of ResetBuffer
  1762. /***********************************************************************/
  1763. /* Data Base write routine for VCT access method. */
  1764. /***********************************************************************/
  1765. int VECFAM::WriteBuffer(PGLOBAL g)
  1766. {
  1767. if (trace)
  1768. htrc("VCT WriteBuffer: R%d Mode=%d CurNum=%d CurBlk=%d\n",
  1769. Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk);
  1770. if (Tdbp->GetMode() == MODE_INSERT) {
  1771. if (Closing || ++CurNum == Nrec) {
  1772. // Here we must add a new blocks to the files
  1773. int i;
  1774. size_t n = (size_t)CurNum;
  1775. for (i = 0; i < Ncol; i++)
  1776. if (n != fwrite(To_Bufs[i], (size_t)Clens[i], n, Streams[i])) {
  1777. sprintf(g->Message, MSG(WRITE_STRERROR), To_File, strerror(errno));
  1778. return RC_FX;
  1779. } // endif
  1780. if (!Closing) {
  1781. CurBlk++;
  1782. CurNum = 0;
  1783. } // endif Closing
  1784. } // endif Closing || CurNum
  1785. } else // Mode Update
  1786. // Writing updates being done in ReadDB we do initialization only.
  1787. if (InitUpdate) {
  1788. if (OpenTempFile(g))
  1789. return RC_FX;
  1790. InitUpdate = false; // Done
  1791. } // endif InitUpdate
  1792. return RC_OK;
  1793. } // end of WriteBuffer
  1794. /***********************************************************************/
  1795. /* Data Base delete line routine for split vertical access methods. */
  1796. /* Note: lines are moved directly in the files (ooops...) */
  1797. /* Using temp file depends on the Check setting, false by default. */
  1798. /***********************************************************************/
  1799. int VECFAM::DeleteRecords(PGLOBAL g, int irc)
  1800. {
  1801. if (trace)
  1802. htrc("VEC DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
  1803. irc, UseTemp, Fpos, Tpos, Spos);
  1804. if (irc != RC_OK) {
  1805. /*******************************************************************/
  1806. /* EOF: position Fpos at the end-of-file position. */
  1807. /*******************************************************************/
  1808. Fpos = Cardinality(g);
  1809. if (trace)
  1810. htrc("Fpos placed at file end=%d\n", Fpos);
  1811. } else // Fpos is the Deleted line position
  1812. Fpos = CurBlk * Nrec + CurNum;
  1813. if (Tpos == Spos) {
  1814. // First line to delete
  1815. if (UseTemp) {
  1816. /*****************************************************************/
  1817. /* Open the temporary files, Spos is at the beginning of file. */
  1818. /*****************************************************************/
  1819. if (OpenTempFile(g))
  1820. return RC_FX;
  1821. } else
  1822. /*****************************************************************/
  1823. /* Move of eventual preceding lines is not required here. */
  1824. /* Set the future Tpos, and give Spos a value to block copying. */
  1825. /*****************************************************************/
  1826. Spos = Tpos = Fpos;
  1827. } // endif Tpos == Spos
  1828. /*********************************************************************/
  1829. /* Move any intermediate lines. */
  1830. /*********************************************************************/
  1831. if (MoveIntermediateLines(g))
  1832. return RC_FX;
  1833. if (irc == RC_OK) {
  1834. #ifdef _DEBUG
  1835. assert(Spos == Fpos);
  1836. #endif
  1837. Spos++; // New start position is on next line
  1838. if (trace)
  1839. htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
  1840. } else {
  1841. /*******************************************************************/
  1842. /* Last call after EOF has been reached. */
  1843. /*******************************************************************/
  1844. if (!UseTemp) {
  1845. /*****************************************************************/
  1846. /* Because the chsize functionality is only accessible with a */
  1847. /* system call we must close the files and reopen them with the */
  1848. /* open function (_fopen for MS??) this is still to be checked */
  1849. /* for compatibility with other OS's. */
  1850. /*****************************************************************/
  1851. char filename[_MAX_PATH];
  1852. int h; // File handle, return code
  1853. for (int i = 0; i < Ncol; i++) {
  1854. sprintf(filename, Colfn, i + 1);
  1855. /*rc =*/ PlugCloseFile(g, To_Fbs[i]);
  1856. if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0)
  1857. return RC_FX;
  1858. /***************************************************************/
  1859. /* Remove extra records. */
  1860. /***************************************************************/
  1861. #if defined(UNIX)
  1862. if (ftruncate(h, (off_t)(Tpos * Clens[i]))) {
  1863. sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
  1864. close(h);
  1865. return RC_FX;
  1866. } // endif
  1867. #else
  1868. if (chsize(h, Tpos * Clens[i])) {
  1869. sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
  1870. close(h);
  1871. return RC_FX;
  1872. } // endif
  1873. #endif
  1874. close(h);
  1875. if (trace)
  1876. htrc("done, h=%d irc=%d\n", h, irc);
  1877. } // endfor i
  1878. } else // UseTemp
  1879. // Ok, now delete old files and rename new temp files
  1880. if (RenameTempFile(g) == RC_FX)
  1881. return RC_FX;
  1882. // Reset these values for TDBVCT::MakeBlockValues
  1883. Block = (Tpos > 0) ? (Tpos + Nrec - 1) / Nrec : 0;
  1884. Last = (Tpos + Nrec - 1) % Nrec + 1;
  1885. if (ResetTableSize(g, Block, Last))
  1886. return RC_FX;
  1887. } // endif irc
  1888. return RC_OK; // All is correct
  1889. } // end of DeleteRecords
  1890. /***********************************************************************/
  1891. /* Open temporary files used while updating or deleting. */
  1892. /* Note: the files not updated have been given a T_Stream value of 1. */
  1893. /***********************************************************************/
  1894. bool VECFAM::OpenTempFile(PGLOBAL g)
  1895. {
  1896. char tempname[_MAX_PATH];
  1897. for (int i = 0; i < Ncol; i++)
  1898. if (!T_Streams[i]) {
  1899. /*****************************************************************/
  1900. /* Open the temporary file, Spos is at the beginning of file. */
  1901. /*****************************************************************/
  1902. sprintf(tempname, Tempat, i+1);
  1903. if (!(T_Streams[i] = PlugOpenFile(g, tempname, "wb"))) {
  1904. if (trace)
  1905. htrc("%s\n", g->Message);
  1906. return true;
  1907. } else
  1908. T_Fbs[i] = PlgGetUser(g)->Openlist;
  1909. } else // This is a column that is not updated
  1910. T_Streams[i] = NULL; // For RenameTempFile
  1911. return false;
  1912. } // end of OpenTempFile
  1913. /***********************************************************************/
  1914. /* Move intermediate updated lines before writing blocks. */
  1915. /***********************************************************************/
  1916. bool VECFAM::MoveLines(PGLOBAL g)
  1917. {
  1918. if (UseTemp && !InitUpdate) { // Don't do it in check pass
  1919. Fpos = OldBlk * Nrec;
  1920. if (MoveIntermediateLines(g)) {
  1921. Closing = true; // ???
  1922. return true;
  1923. } // endif UseTemp
  1924. // Spos = Fpos + Nrec;
  1925. } // endif UseTemp
  1926. return false;
  1927. } // end of MoveLines
  1928. /***********************************************************************/
  1929. /* Move intermediate deleted or updated lines. */
  1930. /***********************************************************************/
  1931. bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *bn)
  1932. {
  1933. int i, n;
  1934. bool b = false;
  1935. size_t req, len;
  1936. for (n = Fpos - Spos; n > 0; n -= Nrec) {
  1937. /*******************************************************************/
  1938. /* Non consecutive line to delete. Move intermediate lines. */
  1939. /*******************************************************************/
  1940. req = (size_t)MY_MIN(n, Nrec);
  1941. for (i = 0; i < Ncol; i++) {
  1942. if (!T_Streams[i])
  1943. continue; // Non updated column
  1944. if (!UseTemp || !b)
  1945. if (fseek(Streams[i], Spos * Clens[i], SEEK_SET)) {
  1946. sprintf(g->Message, MSG(READ_SEEK_ERROR), strerror(errno));
  1947. return true;
  1948. } // endif
  1949. len = fread(To_Buf, Clens[i], req, Streams[i]);
  1950. if (trace)
  1951. htrc("after read req=%d len=%d\n", req, len);
  1952. if (len != req) {
  1953. sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
  1954. return true;
  1955. } // endif len
  1956. if (!UseTemp)
  1957. if (fseek(T_Streams[i], Tpos * Clens[i], SEEK_SET)) {
  1958. sprintf(g->Message, MSG(WRITE_SEEK_ERR), strerror(errno));
  1959. return true;
  1960. } // endif
  1961. if ((len = fwrite(To_Buf, Clens[i], req, T_Streams[i])) != req) {
  1962. sprintf(g->Message, MSG(DEL_WRITE_ERROR), strerror(errno));
  1963. return true;
  1964. } // endif
  1965. if (trace)
  1966. htrc("after write pos=%d\n", ftell(Streams[i]));
  1967. } // endfor i
  1968. Tpos += (int)req;
  1969. Spos += (int)req;
  1970. if (trace)
  1971. htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
  1972. b = true;
  1973. } // endfor n
  1974. return false;
  1975. } // end of MoveIntermediate Lines
  1976. /***********************************************************************/
  1977. /* Delete the old files and rename the new temporary files. */
  1978. /***********************************************************************/
  1979. int VECFAM::RenameTempFile(PGLOBAL g)
  1980. {
  1981. char *tempname, filetemp[_MAX_PATH], filename[_MAX_PATH];
  1982. int rc = RC_OK;
  1983. // Close all files.
  1984. // This loop is necessary because, in case of join,
  1985. // the table files can have been open several times.
  1986. for (PFBLOCK fb = PlgGetUser(g)->Openlist; fb; fb = fb->Next)
  1987. rc = PlugCloseFile(g, fb);
  1988. for (int i = 0; i < Ncol && rc == RC_OK; i++) {
  1989. if (!T_Fbs[i])
  1990. continue;
  1991. tempname = (char*)T_Fbs[i]->Fname;
  1992. if (!Abort) {
  1993. sprintf(filename, Colfn, i+1);
  1994. PlugSetPath(filename, filename, Tdbp->GetPath());
  1995. strcat(PlugRemoveType(filetemp, filename), ".ttt");
  1996. remove(filetemp); // May still be there from previous error
  1997. if (rename(filename, filetemp)) { // Save file for security
  1998. sprintf(g->Message, MSG(RENAME_ERROR),
  1999. filename, filetemp, strerror(errno));
  2000. rc = RC_FX;
  2001. } else if (rename(tempname, filename)) {
  2002. sprintf(g->Message, MSG(RENAME_ERROR),
  2003. tempname, filename, strerror(errno));
  2004. rc = rename(filetemp, filename); // Restore saved file
  2005. rc = RC_FX;
  2006. } else if (remove(filetemp)) {
  2007. sprintf(g->Message, MSG(REMOVE_ERROR),
  2008. filetemp, strerror(errno));
  2009. rc = RC_INFO; // Acceptable
  2010. } // endif's
  2011. } else
  2012. remove(tempname);
  2013. } // endfor i
  2014. return rc;
  2015. } // end of RenameTempFile
  2016. /***********************************************************************/
  2017. /* Data Base close routine for VEC access method. */
  2018. /***********************************************************************/
  2019. void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
  2020. {
  2021. int rc = 0, wrc = RC_OK;
  2022. MODE mode = Tdbp->GetMode();
  2023. Abort = abort;
  2024. if (mode == MODE_INSERT) {
  2025. if (Closing)
  2026. wrc = RC_FX; // Last write was in error
  2027. else
  2028. if (CurNum) {
  2029. // Some more inserted lines remain to be written
  2030. Last += (CurBlk * Nrec + CurNum -1);
  2031. Block += (Last / Nrec);
  2032. Last = Last % Nrec + 1;
  2033. Closing = true;
  2034. wrc = WriteBuffer(g);
  2035. } else {
  2036. Block += CurBlk;
  2037. wrc = RC_OK;
  2038. } // endif CurNum
  2039. if (wrc != RC_FX)
  2040. rc = ResetTableSize(g, Block, Last);
  2041. else
  2042. longjmp(g->jumper[g->jump_level], 44);
  2043. } else if (mode == MODE_UPDATE) {
  2044. if (UseTemp && !InitUpdate && !Abort) {
  2045. // Write any intermediate lines to temp file
  2046. Fpos = OldBlk * Nrec;
  2047. Abort = MoveIntermediateLines(g) != RC_OK;
  2048. // Spos = Fpos + Nrec;
  2049. } // endif UseTemp
  2050. // Write back to file any pending modifications
  2051. if (wrc == RC_OK)
  2052. for (PVCTCOL colp = (PVCTCOL)((PTDBVCT)Tdbp)->To_SetCols;
  2053. colp; colp = (PVCTCOL)colp->Next)
  2054. colp->WriteBlock(g);
  2055. if (wrc == RC_OK && UseTemp && !InitUpdate && !Abort) {
  2056. // Write any intermediate lines to temp file
  2057. Fpos = (Block - 1) * Nrec + Last;
  2058. Abort = MoveIntermediateLines(g) != RC_OK;
  2059. } // endif UseTemp
  2060. } // endif's mode
  2061. if (UseTemp && !InitUpdate) {
  2062. // If they are errors, leave files unchanged
  2063. rc = RenameTempFile(g);
  2064. } else if (Streams)
  2065. for (int i = 0; i < Ncol; i++)
  2066. if (Streams[i]) {
  2067. rc = PlugCloseFile(g, To_Fbs[i]);
  2068. Streams[i] = NULL;
  2069. To_Fbs[i] = NULL;
  2070. } // endif Streams
  2071. if (trace)
  2072. htrc("VCT CloseTableFile: closing %s wrc=%d rc=%d\n", To_File, wrc, rc);
  2073. } // end of CloseTableFile
  2074. /***********************************************************************/
  2075. /* ReadBlock: Read column values from current block. */
  2076. /***********************************************************************/
  2077. bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
  2078. {
  2079. int i, len;
  2080. size_t n;
  2081. /*********************************************************************/
  2082. /* Calculate the offset and size of the block to read. */
  2083. /*********************************************************************/
  2084. len = Nrec * colp->Clen * CurBlk;
  2085. i = colp->Index - 1;
  2086. if (trace)
  2087. htrc("len=%d i=%d Nrec=%d Deplac=%d Lrecl=%d CurBlk=%d\n",
  2088. len, i, Nrec, colp->Deplac, Lrecl, CurBlk);
  2089. if (fseek(Streams[i], len, SEEK_SET)) {
  2090. sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno));
  2091. return true;
  2092. } // endif
  2093. n = fread(colp->Blk->GetValPointer(), (size_t)colp->Clen,
  2094. (size_t)Nrec, Streams[i]);
  2095. if (n != (size_t)Nrec && (CurBlk+1 != Block || n != (size_t)Last)) {
  2096. char fn[_MAX_PATH];
  2097. sprintf(fn, Colfn, colp->Index);
  2098. #if defined(WIN32)
  2099. if (feof(Streams[i]))
  2100. #else // !WIN32
  2101. if (errno == NO_ERROR)
  2102. #endif // !WIN32
  2103. sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn);
  2104. else
  2105. sprintf(g->Message, MSG(READ_ERROR),
  2106. fn, strerror(errno));
  2107. if (trace)
  2108. htrc(" Read error: %s\n", g->Message);
  2109. return true;
  2110. } // endif
  2111. if (trace)
  2112. num_read++;
  2113. return false;
  2114. } // end of ReadBlock
  2115. /***********************************************************************/
  2116. /* WriteBlock: Write back current column values for one block. */
  2117. /* Note: the test of Status is meant to prevent physical writing of */
  2118. /* the block during the checking loop in mode Update. It is set to */
  2119. /* BUF_EMPTY when reopening the table between the two loops. */
  2120. /***********************************************************************/
  2121. bool VECFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
  2122. {
  2123. int i, len;
  2124. size_t n;
  2125. /*********************************************************************/
  2126. /* Calculate the offset and size of the block to write. */
  2127. /*********************************************************************/
  2128. len = Nrec * colp->Clen * colp->ColBlk;
  2129. i = colp->Index - 1;
  2130. if (trace)
  2131. htrc("modif=%d len=%d i=%d Nrec=%d Deplac=%d Lrecl=%d colblk=%d\n",
  2132. Modif, len, i, Nrec, colp->Deplac, Lrecl, colp->ColBlk);
  2133. if (Tdbp->GetMode() == MODE_UPDATE && !UseTemp)
  2134. if (fseek(T_Streams[i], len, SEEK_SET)) {
  2135. sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno));
  2136. return true;
  2137. } // endif
  2138. // Here Nrec was changed to CurNum in mode Insert,
  2139. // this is the true number of records to write,
  2140. // this also avoid writing garbage in the file for true vector tables.
  2141. n = (Tdbp->GetMode() == MODE_INSERT) ? CurNum
  2142. : (colp->ColBlk == Block - 1) ? Last : Nrec;
  2143. if (n != fwrite(colp->Blk->GetValPointer(),
  2144. (size_t)colp->Clen, n, T_Streams[i])) {
  2145. char fn[_MAX_PATH];
  2146. sprintf(fn, (UseTemp) ? Tempat : Colfn, colp->Index);
  2147. sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno));
  2148. if (trace)
  2149. htrc("Write error: %s\n", strerror(errno));
  2150. return true;
  2151. } else
  2152. Spos = Fpos + n;
  2153. #if defined(UNIX)
  2154. fflush(Streams[i]); //NGC
  2155. #endif
  2156. return false;
  2157. } // end of WriteBlock
  2158. /* -------------------------- Class VMPFAM --------------------------- */
  2159. /***********************************************************************/
  2160. /* Implementation of the VMPFAM class. */
  2161. /***********************************************************************/
  2162. VMPFAM::VMPFAM(PVCTDEF tdp) : VCMFAM((PVCTDEF)tdp)
  2163. {
  2164. To_Fbs = NULL;
  2165. Split = true;
  2166. Block = Last = -1;
  2167. } // end of VMPFAM standard constructor
  2168. VMPFAM::VMPFAM(PVMPFAM txfp) : VCMFAM(txfp)
  2169. {
  2170. To_Fbs = txfp->To_Fbs;
  2171. } // end of VMPFAM copy constructor
  2172. /***********************************************************************/
  2173. /* VCT Access Method opening routine. */
  2174. /* New method now that this routine is called recursively (last table */
  2175. /* first in reverse order): index blocks are immediately linked to */
  2176. /* join block of next table if it exists or else are discarted. */
  2177. /***********************************************************************/
  2178. bool VMPFAM::OpenTableFile(PGLOBAL g)
  2179. {
  2180. int i;
  2181. bool b = false;
  2182. MODE mode = Tdbp->GetMode();
  2183. PCOLDEF cdp;
  2184. PVCTCOL cp;
  2185. PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
  2186. if (mode == MODE_DELETE && !Tdbp->GetNext()) {
  2187. DelRows = Cardinality(g);
  2188. // This will stop the process by causing GetProgMax to return 0.
  2189. ResetTableSize(g, 0, Nrec);
  2190. } else
  2191. Cardinality(g); // See comment in VECFAM::OpenTbleFile
  2192. /*********************************************************************/
  2193. /* Prepare the filename pattern for column files and set Ncol. */
  2194. /*********************************************************************/
  2195. if (!Colfn) {
  2196. // Prepare the column file name pattern
  2197. Colfn = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
  2198. Ncol = ((VCTDEF*)Tdbp->GetDef())->MakeFnPattern(Colfn);
  2199. } // endif Colfn
  2200. /*********************************************************************/
  2201. /* Initialize the array of file structures. */
  2202. /*********************************************************************/
  2203. Memcol = (char* *)PlugSubAlloc(g, NULL, Ncol * sizeof(char *));
  2204. To_Fbs = (PFBLOCK *)PlugSubAlloc(g, NULL, Ncol * sizeof(PFBLOCK));
  2205. for (i = 0; i < Ncol; i++) {
  2206. Memcol[i] = NULL;
  2207. To_Fbs[i] = NULL;
  2208. } // endif i
  2209. /*********************************************************************/
  2210. /* Open the files corresponding to columns used in the query. */
  2211. /*********************************************************************/
  2212. if (mode == MODE_DELETE) {
  2213. // All columns are used in Delete mode
  2214. for (i = 0, cdp = defp->GetCols(); cdp; i++, cdp = cdp->GetNext())
  2215. if (MapColumnFile(g, mode, i))
  2216. return true;
  2217. } else {
  2218. /*******************************************************************/
  2219. /* Open the files corresponding to updated columns of the query. */
  2220. /*******************************************************************/
  2221. for (cp = (PVCTCOL)((PTDBVCT)Tdbp)->To_SetCols; cp;
  2222. cp = (PVCTCOL)cp->Next)
  2223. if (MapColumnFile(g, MODE_UPDATE, cp->Index - 1))
  2224. return true;
  2225. /*******************************************************************/
  2226. /* Open other non already open used columns (except pseudos) */
  2227. /*******************************************************************/
  2228. for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
  2229. if (!cp->IsSpecial() && !Memcol[cp->Index - 1])
  2230. if (MapColumnFile(g, MODE_READ, cp->Index - 1))
  2231. return true;
  2232. // Check for void table or missing columns
  2233. for (i = 0, cp = (PVCTCOL)Tdbp->GetColumns(); cp;
  2234. cp = (PVCTCOL)cp->Next)
  2235. if (!cp->IsSpecial()) {
  2236. if (!i++)
  2237. b = !Memcol[cp->Index - 1];
  2238. else if (b != !Memcol[cp->Index - 1])
  2239. return true;
  2240. } // endif Special
  2241. } // endif mode
  2242. /*********************************************************************/
  2243. /* Allocate the table and column block buffer. */
  2244. /*********************************************************************/
  2245. return (b) ? false : AllocateBuffer(g);
  2246. } // end of OpenTableFile
  2247. /***********************************************************************/
  2248. /* Open the file corresponding to one column. */
  2249. /***********************************************************************/
  2250. bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
  2251. {
  2252. char filename[_MAX_PATH];
  2253. int len;
  2254. HANDLE hFile;
  2255. MEMMAP mm;
  2256. PFBLOCK fp;
  2257. PDBUSER dup = PlgGetUser(g);
  2258. sprintf(filename, Colfn, i+1);
  2259. /*********************************************************************/
  2260. /* The whole file will be mapped so we can use it as */
  2261. /* if it were entirely read into virtual memory. */
  2262. /* Firstly we check whether this file have been already mapped. */
  2263. /*********************************************************************/
  2264. if (mode == MODE_READ) {
  2265. for (fp = dup->Openlist; fp; fp = fp->Next)
  2266. if (fp->Type == TYPE_FB_MAP && !stricmp(fp->Fname, filename)
  2267. && fp->Count && fp->Mode == mode)
  2268. break;
  2269. if (trace)
  2270. htrc("Mapping file, fp=%p\n", fp);
  2271. } else
  2272. fp = NULL;
  2273. if (fp) {
  2274. /*******************************************************************/
  2275. /* File already mapped. Just increment use count and get pointer. */
  2276. /*******************************************************************/
  2277. fp->Count++;
  2278. Memcol[i] = fp->Memory;
  2279. len = fp->Length;
  2280. } else {
  2281. /*******************************************************************/
  2282. /* Create the mapping file object. */
  2283. /*******************************************************************/
  2284. hFile = CreateFileMap(g, filename, &mm, mode, DelRows);
  2285. if (hFile == INVALID_HANDLE_VALUE) {
  2286. DWORD rc = GetLastError();
  2287. if (!(*g->Message))
  2288. sprintf(g->Message, MSG(OPEN_MODE_ERROR),
  2289. "map", (int) rc, filename);
  2290. if (trace)
  2291. htrc("%s\n", g->Message);
  2292. return (mode == MODE_READ && rc == ENOENT)
  2293. ? PushWarning(g, Tdbp) : true;
  2294. } // endif hFile
  2295. /*****************************************************************/
  2296. /* Get the file size (assuming file is smaller than 4 GB) */
  2297. /*****************************************************************/
  2298. len = mm.lenL;
  2299. Memcol[i] = (char *)mm.memory;
  2300. if (!len) { // Empty or deleted file
  2301. CloseFileHandle(hFile);
  2302. ResetTableSize(g, 0, Nrec);
  2303. return false;
  2304. } // endif len
  2305. if (!Memcol[i]) {
  2306. CloseFileHandle(hFile);
  2307. sprintf(g->Message, MSG(MAP_VIEW_ERROR),
  2308. filename, GetLastError());
  2309. return true;
  2310. } // endif Memory
  2311. if (mode != MODE_DELETE) {
  2312. CloseFileHandle(hFile); // Not used anymore
  2313. hFile = INVALID_HANDLE_VALUE; // For Fblock
  2314. } // endif Mode
  2315. /*******************************************************************/
  2316. /* Link a Fblock. This make possible to reuse already opened maps */
  2317. /* and also to automatically unmap them in case of error g->jump. */
  2318. /* Note: block can already exist for previously closed file. */
  2319. /*******************************************************************/
  2320. fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
  2321. fp->Type = TYPE_FB_MAP;
  2322. fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1);
  2323. strcpy((char*)fp->Fname, filename);
  2324. fp->Next = dup->Openlist;
  2325. dup->Openlist = fp;
  2326. fp->Count = 1;
  2327. fp->Length = len;
  2328. fp->Memory = Memcol[i];
  2329. fp->Mode = mode;
  2330. fp->File = NULL;
  2331. fp->Handle = hFile; // Used for Delete
  2332. } // endif fp
  2333. To_Fbs[i] = fp; // Useful when closing
  2334. if (trace)
  2335. htrc("fp=%p count=%d MapView=%p len=%d\n",
  2336. fp, fp->Count, Memcol[i], len);
  2337. return false;
  2338. } // end of MapColumnFile
  2339. /***********************************************************************/
  2340. /* Allocate the block buffers for columns used in the query. */
  2341. /* Give a dummy value (1) to prevent allocating the value block. */
  2342. /* It will be set pointing into the memory map of the file. */
  2343. /***********************************************************************/
  2344. bool VMPFAM::AllocateBuffer(PGLOBAL g)
  2345. {
  2346. PVCTCOL cp;
  2347. if (Tdbp->GetMode() == MODE_DELETE) {
  2348. PCOLDEF cdp = Tdbp->GetDef()->GetCols();
  2349. Clens = (int*)PlugSubAlloc(g, NULL, Ncol * sizeof(int));
  2350. for (int i = 0; cdp && i < Ncol; i++, cdp = cdp->GetNext())
  2351. Clens[i] = cdp->GetClen();
  2352. } // endif mode
  2353. for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
  2354. if (!cp->IsSpecial()) { // Not a pseudo column
  2355. cp->Blk = AllocValBlock(g, (void*)1, cp->Buf_Type, Nrec,
  2356. cp->Format.Length, cp->Format.Prec);
  2357. cp->AddStatus(BUF_MAPPED);
  2358. } // endif IsSpecial
  2359. return false;
  2360. } // end of AllocateBuffer
  2361. /***********************************************************************/
  2362. /* Data Base delete line routine for VMP access method. */
  2363. /* Lines between deleted lines are moved in the mapfile view. */
  2364. /***********************************************************************/
  2365. int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
  2366. {
  2367. int i;
  2368. int m, n;
  2369. if (trace)
  2370. htrc("VMP DeleteDB: irc=%d tobuf=%p Tpos=%p Spos=%p\n",
  2371. irc, To_Buf, Tpos, Spos);
  2372. if (irc != RC_OK) {
  2373. /*******************************************************************/
  2374. /* EOF: position Fpos at the top of map position. */
  2375. /*******************************************************************/
  2376. Fpos = (Block - 1) * Nrec + Last;
  2377. if (trace)
  2378. htrc("Fpos placed at file top=%p\n", Fpos);
  2379. } else // Fpos is the Deleted line position
  2380. Fpos = CurBlk * Nrec + CurNum;
  2381. if (Tpos == Spos) {
  2382. /*******************************************************************/
  2383. /* First line to delete. Move of eventual preceding lines is */
  2384. /* not required here, just setting of future Spos and Tpos. */
  2385. /*******************************************************************/
  2386. Tpos = Fpos; // Spos is set below
  2387. } else if ((n = Fpos - Spos) > 0) {
  2388. /*******************************************************************/
  2389. /* Non consecutive line to delete. Move intermediate lines. */
  2390. /*******************************************************************/
  2391. for (i = 0; i < Ncol; i++) {
  2392. m = Clens[i];
  2393. memmove(Memcol[i] + Tpos * m, Memcol[i] + Spos * m, m * n);
  2394. } // endif i
  2395. Tpos += n;
  2396. if (trace)
  2397. htrc("move %d bytes\n", n);
  2398. } // endif n
  2399. if (irc == RC_OK) {
  2400. Spos = Fpos + 1; // New start position
  2401. if (trace)
  2402. htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
  2403. } else {
  2404. /*******************************************************************/
  2405. /* Last call after EOF has been reached. */
  2406. /* We must firstly Unmap the view and use the saved file handle */
  2407. /* to put an EOF at the end of the copied part of the file. */
  2408. /*******************************************************************/
  2409. PFBLOCK fp;
  2410. /*******************************************************************/
  2411. /* Reset the Block and Last values for TDBVCT::MakeBlockValues. */
  2412. /*******************************************************************/
  2413. // Block = (Tpos > 0) ? (Tpos + Nrec - 1) / Nrec : 0;
  2414. // Last = (Tpos + Nrec - 1) % Nrec + 1;
  2415. for (i = 0; i < Ncol; i++) {
  2416. fp = To_Fbs[i];
  2417. CloseMemMap(fp->Memory, (size_t)fp->Length);
  2418. fp->Count = 0; // Avoid doing it twice
  2419. /*****************************************************************/
  2420. /* Remove extra records. */
  2421. /*****************************************************************/
  2422. n = Tpos * Clens[i];
  2423. #if defined(WIN32)
  2424. DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
  2425. if (drc == 0xFFFFFFFF) {
  2426. sprintf(g->Message, MSG(FUNCTION_ERROR),
  2427. "SetFilePointer", GetLastError());
  2428. CloseHandle(fp->Handle);
  2429. return RC_FX;
  2430. } // endif
  2431. if (trace)
  2432. htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
  2433. if (!SetEndOfFile(fp->Handle)) {
  2434. sprintf(g->Message, MSG(FUNCTION_ERROR),
  2435. "SetEndOfFile", GetLastError());
  2436. CloseHandle(fp->Handle);
  2437. return RC_FX;
  2438. } // endif
  2439. CloseHandle(fp->Handle);
  2440. #else // UNIX
  2441. if (ftruncate(fp->Handle, (off_t)n)) {
  2442. sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
  2443. close(fp->Handle);
  2444. return RC_FX;
  2445. } // endif
  2446. close(fp->Handle);
  2447. #endif // UNIX
  2448. } // endfor i
  2449. } // endif irc
  2450. return RC_OK; // All is correct
  2451. } // end of DeleteRecords
  2452. /***********************************************************************/
  2453. /* Data Base close routine for VMP access method. */
  2454. /***********************************************************************/
  2455. void VMPFAM::CloseTableFile(PGLOBAL g, bool abort)
  2456. {
  2457. if (Tdbp->GetMode() == MODE_DELETE) {
  2458. // Set Block and Nrec values for TDBVCT::MakeBlockValues
  2459. Block = (Tpos > 0) ? (Tpos + Nrec - 1) / Nrec : 0;
  2460. Last = (Tpos + Nrec - 1) % Nrec + 1;
  2461. ResetTableSize(g, Block, Last);
  2462. } else if (Tdbp->GetMode() == MODE_INSERT)
  2463. assert(false);
  2464. for (int i = 0; i < Ncol; i++)
  2465. PlugCloseFile(g, To_Fbs[i]);
  2466. } // end of CloseTableFile
  2467. /* -------------------------- Class BGVFAM --------------------------- */
  2468. /***********************************************************************/
  2469. /* Implementation of the BGVFAM class. */
  2470. /***********************************************************************/
  2471. // Constructors
  2472. BGVFAM::BGVFAM(PVCTDEF tdp) : VCTFAM(tdp)
  2473. {
  2474. Hfile = INVALID_HANDLE_VALUE;
  2475. Tfile = INVALID_HANDLE_VALUE;
  2476. BigDep = NULL;
  2477. } // end of BGVFAM constructor
  2478. BGVFAM::BGVFAM(PBGVFAM txfp) : VCTFAM(txfp)
  2479. {
  2480. Hfile = txfp->Hfile;
  2481. Tfile = txfp->Tfile;
  2482. BigDep= txfp->BigDep;
  2483. } // end of BGVFAM copy constructor
  2484. /***********************************************************************/
  2485. /* Set current position in a big file. */
  2486. /***********************************************************************/
  2487. bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
  2488. {
  2489. #if defined(WIN32)
  2490. char buf[256];
  2491. DWORD drc, m = (b) ? FILE_END : FILE_BEGIN;
  2492. LARGE_INTEGER of;
  2493. of.QuadPart = pos;
  2494. of.LowPart = SetFilePointer(h, of.LowPart, &of.HighPart, m);
  2495. if (of.LowPart == INVALID_SET_FILE_POINTER &&
  2496. (drc = GetLastError()) != NO_ERROR) {
  2497. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  2498. FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
  2499. (LPTSTR)buf, sizeof(buf), NULL);
  2500. sprintf(g->Message, MSG(SFP_ERROR), buf);
  2501. return true;
  2502. } // endif
  2503. #else // !WIN32
  2504. if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) {
  2505. sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
  2506. return true;
  2507. } // endif
  2508. #endif // !WIN32
  2509. return false;
  2510. } // end of BigSeek
  2511. /***********************************************************************/
  2512. /* Read from a big file. */
  2513. /***********************************************************************/
  2514. bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
  2515. {
  2516. bool rc = false;
  2517. #if defined(WIN32)
  2518. DWORD nbr, drc, len = (DWORD)req;
  2519. bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
  2520. if (trace)
  2521. htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr);
  2522. if (!brc || nbr != len) {
  2523. char buf[256]; // , *fn = (h == Hfile) ? To_File : "Tempfile";
  2524. if (brc)
  2525. strcpy(buf, MSG(BAD_BYTE_READ));
  2526. else {
  2527. drc = GetLastError();
  2528. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  2529. FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
  2530. (LPTSTR)buf, sizeof(buf), NULL);
  2531. } // endelse brc
  2532. sprintf(g->Message, MSG(READ_ERROR), To_File, buf);
  2533. if (trace)
  2534. htrc("BIGREAD: %s\n", g->Message);
  2535. rc = true;
  2536. } // endif brc || nbr
  2537. #else // !WIN32
  2538. size_t len = (size_t)req;
  2539. ssize_t nbr = read(h, inbuf, len);
  2540. if (nbr != (ssize_t)len) {
  2541. const char *fn = (h == Hfile) ? To_File : "Tempfile";
  2542. sprintf(g->Message, MSG(READ_ERROR), fn, strerror(errno));
  2543. if (trace)
  2544. htrc("BIGREAD: nbr=%d len=%d errno=%d %s\n",
  2545. nbr, len, errno, g->Message);
  2546. rc = true;
  2547. } // endif nbr
  2548. #endif // !WIN32
  2549. return rc;
  2550. } // end of BigRead
  2551. /***********************************************************************/
  2552. /* Write into a big file. */
  2553. /***********************************************************************/
  2554. bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
  2555. {
  2556. bool rc = false;
  2557. #if defined(WIN32)
  2558. DWORD nbw, drc, len = (DWORD)req;
  2559. bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
  2560. if (trace)
  2561. htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
  2562. if (!brc || nbw != len) {
  2563. char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile";
  2564. if (brc)
  2565. strcpy(buf, MSG(BAD_BYTE_NUM));
  2566. else {
  2567. drc = GetLastError();
  2568. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  2569. FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
  2570. (LPTSTR)buf, sizeof(buf), NULL);
  2571. } // endelse brc
  2572. sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf);
  2573. if (trace)
  2574. htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
  2575. nbw, len, drc, g->Message);
  2576. rc = true;
  2577. } // endif brc || nbw
  2578. #else // !WIN32
  2579. size_t len = (size_t)req;
  2580. ssize_t nbw = write(h, inbuf, len);
  2581. if (nbw != (ssize_t)len) {
  2582. const char *fn = (h == Hfile) ? To_File : "Tempfile";
  2583. sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno));
  2584. if (trace)
  2585. htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
  2586. nbw, len, errno, g->Message);
  2587. rc = true;
  2588. } // endif nbr
  2589. #endif // !WIN32
  2590. return rc;
  2591. } // end of BigWrite
  2592. /***********************************************************************/
  2593. /* Get the Headlen, Block and Last info from the file header. */
  2594. /***********************************************************************/
  2595. int BGVFAM::GetBlockInfo(PGLOBAL g)
  2596. {
  2597. char filename[_MAX_PATH];
  2598. int n;
  2599. VECHEADER vh;
  2600. HANDLE h;
  2601. if (Header < 1 || Header > 3 || !MaxBlk) {
  2602. sprintf(g->Message, "Invalid header value %d", Header);
  2603. return -1;
  2604. } else
  2605. n = (Header == 1) ? (int)sizeof(VECHEADER) : 0;
  2606. PlugSetPath(filename, To_File, Tdbp->GetPath());
  2607. if (Header == 2)
  2608. strcat(PlugRemoveType(filename, filename), ".blk");
  2609. #if defined(WIN32)
  2610. LARGE_INTEGER len;
  2611. h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
  2612. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  2613. if (h != INVALID_HANDLE_VALUE) {
  2614. // Get the size of the file (can be greater than 4 GB)
  2615. len.LowPart = GetFileSize(h, (LPDWORD)&len.HighPart);
  2616. } // endif h
  2617. if (h == INVALID_HANDLE_VALUE || !len.QuadPart) {
  2618. #else // !WIN32
  2619. h = open64(filename, O_RDONLY, 0);
  2620. if (h == INVALID_HANDLE_VALUE || !_filelength(h)) {
  2621. #endif // !WIN32
  2622. // Consider this is a void table
  2623. if (trace)
  2624. htrc("Void table h=%d\n", h);
  2625. Last = Nrec;
  2626. Block = 0;
  2627. if (h != INVALID_HANDLE_VALUE)
  2628. CloseFileHandle(h);
  2629. return n;
  2630. } else if (Header == 3)
  2631. /*b = */ BigSeek(g, h, -(BIGINT)sizeof(vh), true);
  2632. if (BigRead(g, h, &vh, sizeof(vh))) {
  2633. sprintf(g->Message, "Error reading header file %s", filename);
  2634. n = -1;
  2635. } else if (MaxBlk * Nrec != vh.MaxRec) {
  2636. sprintf(g->Message, "MaxRec=%d doesn't match MaxBlk=%d Nrec=%d",
  2637. vh.MaxRec, MaxBlk, Nrec);
  2638. n = -1;
  2639. } else {
  2640. Block = (vh.NumRec > 0) ? (vh.NumRec + Nrec - 1) / Nrec : 0;
  2641. Last = (vh.NumRec + Nrec - 1) % Nrec + 1;
  2642. if (trace)
  2643. htrc("Block=%d Last=%d\n", Block, Last);
  2644. } // endif's
  2645. CloseFileHandle(h);
  2646. return n;
  2647. } // end of GetBlockInfo
  2648. /***********************************************************************/
  2649. /* Set the MaxRec and NumRec info in the file header. */
  2650. /***********************************************************************/
  2651. bool BGVFAM::SetBlockInfo(PGLOBAL g)
  2652. {
  2653. char filename[_MAX_PATH];
  2654. bool b = false, rc = false;
  2655. VECHEADER vh;
  2656. HANDLE h = INVALID_HANDLE_VALUE;
  2657. PlugSetPath(filename, To_File, Tdbp->GetPath());
  2658. if (Header != 2) {
  2659. if (Hfile != INVALID_HANDLE_VALUE) {
  2660. h = Hfile;
  2661. if (Header == 1)
  2662. /*bk =*/ BigSeek(g, h, (BIGINT)0);
  2663. } else
  2664. b = true;
  2665. } else // Header == 2
  2666. strcat(PlugRemoveType(filename, filename), ".blk");
  2667. if (h == INVALID_HANDLE_VALUE) {
  2668. #if defined(WIN32)
  2669. DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING;
  2670. h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0,
  2671. NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
  2672. #else // !WIN32
  2673. int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC;
  2674. h = open64(filename, oflag, 0);
  2675. #endif // !WIN32
  2676. if (h == INVALID_HANDLE_VALUE) {
  2677. sprintf(g->Message, "Error opening header file %s", filename);
  2678. return true;
  2679. } // endif h
  2680. } // endif h
  2681. if (Header == 3)
  2682. /*bk =*/ BigSeek(g, h, -(BIGINT)sizeof(vh), true);
  2683. vh.MaxRec = MaxBlk * Bsize;
  2684. vh.NumRec = (Block - 1) * Nrec + Last;
  2685. if (BigWrite(g, h, &vh, sizeof(vh))) {
  2686. sprintf(g->Message, "Error writing header file %s", filename);
  2687. rc = true;
  2688. } // endif fread
  2689. if (Header == 2 || Hfile == INVALID_HANDLE_VALUE)
  2690. CloseFileHandle(h);
  2691. return rc;
  2692. } // end of SetBlockInfo
  2693. /***********************************************************************/
  2694. /* VEC Create an empty file for new Vector formatted tables. */
  2695. /***********************************************************************/
  2696. bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
  2697. {
  2698. // Vector formatted file this will create an empty file of the
  2699. // required length if it does not exists yet.
  2700. char filename[_MAX_PATH], c = 0;
  2701. int n = (Header == 1 || Header == 3) ? sizeof(VECHEADER) : 0;
  2702. PlugSetPath(filename, fn, Tdbp->GetPath());
  2703. #if defined(WIN32)
  2704. char *p;
  2705. DWORD rc;
  2706. bool brc;
  2707. LARGE_INTEGER of;
  2708. HANDLE h;
  2709. h = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
  2710. FILE_ATTRIBUTE_NORMAL, NULL);
  2711. if (h == INVALID_HANDLE_VALUE) {
  2712. p = MSG(OPENING);
  2713. goto err;
  2714. } // endif h
  2715. of.QuadPart = (BIGINT)n + (BIGINT)MaxBlk * (BIGINT)Blksize - (BIGINT)1;
  2716. if (trace)
  2717. htrc("MEF: of=%lld n=%d maxblk=%d blksize=%d\n",
  2718. of.QuadPart, n, MaxBlk, Blksize);
  2719. of.LowPart = SetFilePointer(h, of.LowPart,
  2720. &of.HighPart, FILE_BEGIN);
  2721. if (of.LowPart == INVALID_SET_FILE_POINTER &&
  2722. GetLastError() != NO_ERROR) {
  2723. p = MSG(MAKING);
  2724. goto err;
  2725. } // endif
  2726. brc = WriteFile(h, &c, 1, &rc, NULL);
  2727. if (!brc || rc != 1) {
  2728. p = MSG(WRITING);
  2729. goto err;
  2730. } // endif
  2731. CloseHandle(h);
  2732. return false;
  2733. err:
  2734. rc = GetLastError();
  2735. sprintf(g->Message, MSG(EMPTY_FILE), p, filename);
  2736. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  2737. FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
  2738. (LPTSTR)filename, sizeof(filename), NULL);
  2739. strcat(g->Message, filename);
  2740. if (h != INVALID_HANDLE_VALUE)
  2741. CloseHandle(h);
  2742. return true;
  2743. #else // !WIN32
  2744. int h;
  2745. BIGINT pos;
  2746. h= open64(filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
  2747. if (h == -1)
  2748. return true;
  2749. pos = (BIGINT)n + (BIGINT)MaxBlk * (BIGINT)Blksize - (BIGINT)1;
  2750. if (trace)
  2751. htrc("MEF: pos=%lld n=%d maxblk=%d blksize=%d\n",
  2752. pos, n, MaxBlk, Blksize);
  2753. if (lseek64(h, pos, SEEK_SET) < 0) {
  2754. sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
  2755. close(h);
  2756. return true;
  2757. } // endif h
  2758. write(h, &c, 1); // This actually fills the empty file
  2759. close(h);
  2760. return false;
  2761. #endif // !WIN32
  2762. } // end of MakeEmptyFile
  2763. /***********************************************************************/
  2764. /* Vopen function: opens a file using Windows or Unix API's. */
  2765. /***********************************************************************/
  2766. bool BGVFAM::OpenTableFile(PGLOBAL g)
  2767. {
  2768. char filename[_MAX_PATH];
  2769. bool del = false;
  2770. MODE mode = Tdbp->GetMode();
  2771. PDBUSER dbuserp = PlgGetUser(g);
  2772. if ((To_Fb && To_Fb->Count) || Hfile != INVALID_HANDLE_VALUE) {
  2773. sprintf(g->Message, MSG(FILE_OPEN_YET), To_File);
  2774. return true;
  2775. } // endif
  2776. /*********************************************************************/
  2777. /* Update block info if necessary. */
  2778. /*********************************************************************/
  2779. if (Block < 0)
  2780. if ((Headlen = GetBlockInfo(g)) < 0)
  2781. return true;
  2782. PlugSetPath(filename, To_File, Tdbp->GetPath());
  2783. if (trace)
  2784. htrc("OpenTableFile: filename=%s mode=%d Last=%d\n",
  2785. filename, mode, Last);
  2786. #if defined(WIN32)
  2787. DWORD access, creation, share = 0, rc = 0;
  2788. /*********************************************************************/
  2789. /* Create the file object according to access mode */
  2790. /*********************************************************************/
  2791. switch (mode) {
  2792. case MODE_READ:
  2793. access = GENERIC_READ;
  2794. share = FILE_SHARE_READ;
  2795. creation = OPEN_EXISTING;
  2796. break;
  2797. case MODE_INSERT:
  2798. if (MaxBlk) {
  2799. if (!Block)
  2800. if (MakeEmptyFile(g, To_File))
  2801. return true;
  2802. // Required to update empty blocks
  2803. access = GENERIC_READ | GENERIC_WRITE;
  2804. } else if (Last == Nrec)
  2805. access = GENERIC_WRITE;
  2806. else
  2807. // Required to update the last block
  2808. access = GENERIC_READ | GENERIC_WRITE;
  2809. creation = OPEN_ALWAYS;
  2810. break;
  2811. case MODE_DELETE:
  2812. if (!Tdbp->GetNext()) {
  2813. // Store the number of deleted lines
  2814. DelRows = Cardinality(g);
  2815. // This will stop the process by
  2816. // causing GetProgMax to return 0.
  2817. // ResetTableSize(g, 0, Nrec); must be done later
  2818. del = true;
  2819. // This will delete the whole file
  2820. access = GENERIC_READ | GENERIC_WRITE;
  2821. creation = TRUNCATE_EXISTING;
  2822. break;
  2823. } // endif
  2824. // Selective delete, pass thru
  2825. case MODE_UPDATE:
  2826. if ((UseTemp = Tdbp->IsUsingTemp(g)))
  2827. access = GENERIC_READ;
  2828. else
  2829. access = GENERIC_READ | GENERIC_WRITE;
  2830. creation = OPEN_EXISTING;
  2831. break;
  2832. default:
  2833. sprintf(g->Message, MSG(BAD_OPEN_MODE), mode);
  2834. return true;
  2835. } // endswitch
  2836. /*********************************************************************/
  2837. /* Use specific Windows API functions. */
  2838. /*********************************************************************/
  2839. Hfile = CreateFile(filename, access, share, NULL, creation,
  2840. FILE_ATTRIBUTE_NORMAL, NULL);
  2841. if (Hfile == INVALID_HANDLE_VALUE) {
  2842. rc = GetLastError();
  2843. sprintf(g->Message, MSG(OPEN_ERROR), rc, mode, filename);
  2844. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  2845. FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
  2846. (LPTSTR)filename, sizeof(filename), NULL);
  2847. strcat(g->Message, filename);
  2848. } // endif Hfile
  2849. if (trace)
  2850. htrc(" rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n",
  2851. rc, access, share, creation, Hfile, filename);
  2852. if (mode == MODE_INSERT) {
  2853. /*******************************************************************/
  2854. /* In Insert mode we must position the cursor at end of file. */
  2855. /*******************************************************************/
  2856. LARGE_INTEGER of;
  2857. of.QuadPart = (BIGINT)0;
  2858. of.LowPart = SetFilePointer(Hfile, of.LowPart,
  2859. &of.HighPart, FILE_END);
  2860. if (of.LowPart == INVALID_SET_FILE_POINTER &&
  2861. (rc = GetLastError()) != NO_ERROR) {
  2862. sprintf(g->Message, MSG(ERROR_IN_SFP), rc);
  2863. CloseHandle(Hfile);
  2864. Hfile = INVALID_HANDLE_VALUE;
  2865. } // endif
  2866. } // endif Mode
  2867. #else // UNIX
  2868. /*********************************************************************/
  2869. /* The open() function has a transitional interface for 64-bit */
  2870. /* file offsets. Note that using open64() is equivalent to using */
  2871. /* open() with O_LARGEFILE set in oflag (see Xopen in tabfix.cpp). */
  2872. /*********************************************************************/
  2873. int rc = 0;
  2874. int oflag;
  2875. mode_t pmd = 0;
  2876. /*********************************************************************/
  2877. /* Create the file object according to access mode */
  2878. /*********************************************************************/
  2879. switch (mode) {
  2880. case MODE_READ:
  2881. oflag = O_RDONLY;
  2882. break;
  2883. case MODE_INSERT:
  2884. if (MaxBlk) {
  2885. if (!Block)
  2886. if (MakeEmptyFile(g, To_File))
  2887. return true;
  2888. // Required to update empty blocks
  2889. oflag = O_RDWR;
  2890. } else if (Last == Nrec)
  2891. oflag = O_WRONLY | O_CREAT | O_APPEND;
  2892. else
  2893. // Required to update the last block
  2894. oflag = O_RDWR | O_CREAT | O_APPEND;
  2895. pmd = S_IREAD | S_IWRITE;
  2896. break;
  2897. case MODE_DELETE:
  2898. // This is temporary until a partial delete is implemented
  2899. if (!Tdbp->GetNext()) {
  2900. // Store the number of deleted lines
  2901. DelRows = Cardinality(g);
  2902. del = true;
  2903. // This will delete the whole file and provoque ReadDB to
  2904. // return immediately.
  2905. oflag = O_RDWR | O_TRUNC;
  2906. strcpy(g->Message, MSG(NO_VCT_DELETE));
  2907. break;
  2908. } // endif
  2909. // Selective delete, pass thru
  2910. case MODE_UPDATE:
  2911. UseTemp = Tdbp->IsUsingTemp(g);
  2912. oflag = (UseTemp) ? O_RDONLY : O_RDWR;
  2913. break;
  2914. default:
  2915. sprintf(g->Message, MSG(BAD_OPEN_MODE), mode);
  2916. return true;
  2917. } // endswitch
  2918. Hfile = open64(filename, oflag, pmd); // Enable file size > 2G
  2919. if (Hfile == INVALID_HANDLE_VALUE) {
  2920. rc = errno;
  2921. sprintf(g->Message, MSG(OPEN_ERROR), rc, mode, filename);
  2922. strcat(g->Message, strerror(errno));
  2923. } // endif Hfile
  2924. if (trace)
  2925. htrc(" rc=%d oflag=%p mode=%p handle=%d fn=%s\n",
  2926. rc, oflag, mode, Hfile, filename);
  2927. #endif // UNIX
  2928. if (!rc) {
  2929. if (!To_Fb) {
  2930. To_Fb = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
  2931. To_Fb->Fname = To_File;
  2932. To_Fb->Type = TYPE_FB_HANDLE;
  2933. To_Fb->Memory = NULL;
  2934. To_Fb->Length = 0;
  2935. To_Fb->File = NULL;
  2936. To_Fb->Next = dbuserp->Openlist;
  2937. dbuserp->Openlist = To_Fb;
  2938. } // endif To_Fb
  2939. To_Fb->Count = 1;
  2940. To_Fb->Mode = mode;
  2941. To_Fb->Handle = Hfile;
  2942. if (trace)
  2943. htrc("File %s is open in mode %d\n", filename, mode);
  2944. if (del)
  2945. // This will stop the process by
  2946. // causing GetProgMax to return 0.
  2947. return ResetTableSize(g, 0, Nrec);
  2948. /*********************************************************************/
  2949. /* Allocate the table and column block buffers. */
  2950. /*********************************************************************/
  2951. return AllocateBuffer(g);
  2952. } else
  2953. return (mode == MODE_READ && rc == ENOENT)
  2954. ? PushWarning(g, Tdbp) : true;
  2955. } // end of OpenTableFile
  2956. /***********************************************************************/
  2957. /* Allocate the block buffers for columns used in the query. */
  2958. /***********************************************************************/
  2959. bool BGVFAM::AllocateBuffer(PGLOBAL g)
  2960. {
  2961. MODE mode = Tdbp->GetMode();
  2962. PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
  2963. PCOLDEF cdp;
  2964. PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
  2965. if (mode == MODE_INSERT) {
  2966. if (!NewBlock) {
  2967. // Not reopening after inserting the last block
  2968. bool chk = PlgGetUser(g)->Check & CHK_TYPE;
  2969. NewBlock = (char*)PlugSubAlloc(g, NULL, Blksize);
  2970. for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext())
  2971. memset(NewBlock + Nrec * cdp->GetPoff(),
  2972. (IsTypeNum(cdp->GetType()) ? 0 : ' '),
  2973. Nrec * cdp->GetClen());
  2974. for (; cp; cp = (PVCTCOL)cp->Next)
  2975. cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac,
  2976. cp->Buf_Type, Nrec, cp->Format.Length,
  2977. cp->Format.Prec, chk);
  2978. InitInsert(g); // Initialize inserting
  2979. // Currently we don't use a temporary file for inserting
  2980. Tfile = Hfile;
  2981. } // endif NewBlock
  2982. } else {
  2983. if (UseTemp || mode == MODE_DELETE) {
  2984. // Allocate all that is needed to move lines
  2985. int i = 0;
  2986. if (!Ncol)
  2987. for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext())
  2988. Ncol++;
  2989. if (MaxBlk)
  2990. BigDep = (BIGINT*)PlugSubAlloc(g, NULL, Ncol * sizeof(BIGINT));
  2991. else
  2992. Deplac = (int*)PlugSubAlloc(g, NULL, Ncol * sizeof(int));
  2993. Clens = (int*)PlugSubAlloc(g, NULL, Ncol * sizeof(int));
  2994. Isnum = (bool*)PlugSubAlloc(g, NULL, Ncol * sizeof(bool));
  2995. for (cdp = defp->GetCols(); cdp; i++, cdp = cdp->GetNext()) {
  2996. if (MaxBlk)
  2997. BigDep[i] = (BIGINT)Headlen
  2998. + (BIGINT)(cdp->GetPoff() * Nrec) * (BIGINT)MaxBlk;
  2999. else
  3000. Deplac[i] = cdp->GetPoff() * Nrec;
  3001. Clens[i] = cdp->GetClen();
  3002. Isnum[i] = IsTypeNum(cdp->GetType());
  3003. Buflen = MY_MAX(Buflen, cdp->GetClen());
  3004. } // endfor cdp
  3005. if (!UseTemp || MaxBlk) {
  3006. Buflen *= Nrec;
  3007. To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
  3008. } else
  3009. NewBlock = (char*)PlugSubAlloc(g, NULL, Blksize);
  3010. } // endif mode
  3011. for (; cp; cp = (PVCTCOL)cp->Next)
  3012. if (!cp->IsSpecial()) // Not a pseudo column
  3013. cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec,
  3014. cp->Format.Length, cp->Format.Prec);
  3015. } //endif mode
  3016. return false;
  3017. } // end of AllocateBuffer
  3018. /***********************************************************************/
  3019. /* Data Base write routine for huge VCT access method. */
  3020. /***********************************************************************/
  3021. int BGVFAM::WriteBuffer(PGLOBAL g)
  3022. {
  3023. if (trace)
  3024. htrc("BGV WriteDB: R%d Mode=%d CurNum=%d CurBlk=%d\n",
  3025. Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk);
  3026. if (Tdbp->GetMode() == MODE_UPDATE) {
  3027. // Mode Update is done in ReadDB, we just initialize it here
  3028. if (Tfile == INVALID_HANDLE_VALUE) {
  3029. if (UseTemp) {
  3030. if (OpenTempFile(g))
  3031. return RC_FX;
  3032. // Most of the time, not all table columns are updated.
  3033. // This why we must completely pre-fill the temporary file.
  3034. Fpos = (MaxBlk) ? (Block - 1) * Nrec + Last
  3035. : Block * Nrec; // To write last lock
  3036. if (MoveIntermediateLines(g))
  3037. return RC_FX;
  3038. } else
  3039. Tfile = Hfile;
  3040. } // endif Tfile
  3041. } else {
  3042. // Mode Insert
  3043. if (MaxBlk && CurBlk == MaxBlk) {
  3044. strcpy(g->Message, MSG(TRUNC_BY_ESTIM));
  3045. return RC_EF; // Too many lines for a Vector formatted table
  3046. } // endif MaxBlk
  3047. if (Closing || ++CurNum == Nrec) {
  3048. PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
  3049. if (!AddBlock) {
  3050. // Write back the updated last block values
  3051. for (; cp; cp = (PVCTCOL)cp->Next)
  3052. cp->WriteBlock(g);
  3053. if (!Closing && !MaxBlk) {
  3054. // Close the VCT file and reopen it in mode Insert
  3055. //#if defined(WIN32) //OB
  3056. // CloseHandle(Hfile);
  3057. //#else // UNIX
  3058. // close(Hfile);
  3059. //#endif // UNIX
  3060. CloseFileHandle(Hfile);
  3061. Hfile = INVALID_HANDLE_VALUE;
  3062. To_Fb->Count = 0;
  3063. Last = Nrec; // Tested in OpenTableFile
  3064. if (OpenTableFile(g)) {
  3065. Closing = true; // Tell CloseDB of error
  3066. return RC_FX;
  3067. } // endif Vopen
  3068. AddBlock = true;
  3069. } // endif Closing
  3070. } else {
  3071. // Here we must add a new block to the VCT file
  3072. if (Closing)
  3073. // Reset the overwritten columns for last block extra records
  3074. for (; cp; cp = (PVCTCOL)cp->Next)
  3075. memset(NewBlock + Nrec * cp->Deplac + Last * cp->Clen,
  3076. (cp->Buf_Type == TYPE_STRING) ? ' ' : '\0',
  3077. (Nrec - Last) * cp->Clen);
  3078. if (BigWrite(g, Hfile, NewBlock, Blksize))
  3079. return RC_FX;
  3080. } // endif AddBlock
  3081. if (!Closing) {
  3082. CurBlk++;
  3083. CurNum = 0;
  3084. } // endif Closing
  3085. } // endif
  3086. } // endif Mode
  3087. return RC_OK;
  3088. } // end of WriteBuffer
  3089. /***********************************************************************/
  3090. /* Data Base delete line routine for BGVFAM access method. */
  3091. /***********************************************************************/
  3092. int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
  3093. {
  3094. bool eof = false;
  3095. /*********************************************************************/
  3096. /* There is an alternative here depending on UseTemp: */
  3097. /* 1 - use a temporary file in which are copied all not deleted */
  3098. /* lines, at the end the original file will be deleted and */
  3099. /* the temporary file renamed to the original file name. */
  3100. /* 2 - directly move the not deleted lines inside the original */
  3101. /* file, and at the end erase all trailing records. */
  3102. /*********************************************************************/
  3103. if (trace)
  3104. htrc("BGV DeleteDB: irc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
  3105. irc, UseTemp, Fpos, Tpos, Spos);
  3106. if (irc != RC_OK) {
  3107. /*******************************************************************/
  3108. /* EOF: position Fpos at the end-of-file position. */
  3109. /*******************************************************************/
  3110. Fpos = (Block - 1) * Nrec + Last;
  3111. if (trace)
  3112. htrc("Fpos placed at file end=%d\n", Fpos);
  3113. eof = UseTemp && !MaxBlk;
  3114. } else // Fpos is the deleted line position
  3115. Fpos = CurBlk * Nrec + CurNum;
  3116. if (Tpos == Spos) {
  3117. if (UseTemp) {
  3118. /*****************************************************************/
  3119. /* Open the temporary file, Spos is at the beginning of file. */
  3120. /*****************************************************************/
  3121. if (OpenTempFile(g))
  3122. return RC_FX;
  3123. } else {
  3124. /*****************************************************************/
  3125. /* Move of eventual preceding lines is not required here. */
  3126. /* Set the target file as being the source file itself. */
  3127. /* Set the future Tpos, and give Spos a value to block copying. */
  3128. /*****************************************************************/
  3129. Tfile = Hfile;
  3130. Spos = Tpos = Fpos;
  3131. } // endif UseTemp
  3132. } // endif Tpos == Spos
  3133. /*********************************************************************/
  3134. /* Move any intermediate lines. */
  3135. /*********************************************************************/
  3136. if (MoveIntermediateLines(g, &eof))
  3137. return RC_FX;
  3138. if (irc == RC_OK) {
  3139. #ifdef _DEBUG
  3140. assert(Spos == Fpos);
  3141. #endif
  3142. Spos++; // New start position is on next line
  3143. if (trace)
  3144. htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
  3145. } else {
  3146. /*******************************************************************/
  3147. /* Last call after EOF has been reached. */
  3148. /*******************************************************************/
  3149. Block = (Tpos > 0) ? (Tpos + Nrec - 1) / Nrec : 0;
  3150. Last = (Tpos + Nrec - 1) % Nrec + 1;
  3151. if (!UseTemp) { // The UseTemp case is treated in CloseTableFile
  3152. if (!MaxBlk) {
  3153. if (Last < Nrec) // Clean last block
  3154. if (CleanUnusedSpace(g))
  3155. return RC_FX;
  3156. /***************************************************************/
  3157. /* Remove extra records. */
  3158. /***************************************************************/
  3159. #if defined(WIN32)
  3160. BIGINT pos = (BIGINT)Block * (BIGINT)Blksize;
  3161. if (BigSeek(g, Hfile, pos))
  3162. return RC_FX;
  3163. if (!SetEndOfFile(Hfile)) {
  3164. DWORD drc = GetLastError();
  3165. sprintf(g->Message, MSG(SETEOF_ERROR), drc);
  3166. return RC_FX;
  3167. } // endif error
  3168. #else // !WIN32
  3169. if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
  3170. sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
  3171. return RC_FX;
  3172. } // endif
  3173. #endif // !WIN32
  3174. } else // MaxBlk
  3175. // Clean the unused space in the file, this is required when
  3176. // inserting again with a partial column list.
  3177. if (CleanUnusedSpace(g))
  3178. return RC_FX;
  3179. if (ResetTableSize(g, Block, Last))
  3180. return RC_FX;
  3181. } // endif UseTemp
  3182. } // endif irc
  3183. return RC_OK; // All is correct
  3184. } // end of DeleteRecords
  3185. /***********************************************************************/
  3186. /* Open a temporary file used while updating or deleting. */
  3187. /***********************************************************************/
  3188. bool BGVFAM::OpenTempFile(PGLOBAL g)
  3189. {
  3190. char *tempname;
  3191. PDBUSER dup = PlgGetUser(g);
  3192. /*********************************************************************/
  3193. /* Open the temporary file, Spos is at the beginning of file. */
  3194. /*********************************************************************/
  3195. tempname = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
  3196. PlugSetPath(tempname, To_File, Tdbp->GetPath());
  3197. strcat(PlugRemoveType(tempname, tempname), ".t");
  3198. if (!MaxBlk)
  3199. remove(tempname); // Be sure it does not exist yet
  3200. else if (MakeEmptyFile(g, tempname))
  3201. return true;
  3202. #if defined(WIN32)
  3203. DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW;
  3204. Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
  3205. access, FILE_ATTRIBUTE_NORMAL, NULL);
  3206. if (Tfile == INVALID_HANDLE_VALUE) {
  3207. DWORD rc = GetLastError();
  3208. sprintf(g->Message, MSG(OPEN_ERROR), rc, MODE_DELETE, tempname);
  3209. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  3210. FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
  3211. (LPTSTR)tempname, _MAX_PATH, NULL);
  3212. strcat(g->Message, tempname);
  3213. return true;
  3214. } // endif Tfile
  3215. #else // UNIX
  3216. int oflag = (MaxBlk) ? O_WRONLY : O_WRONLY | O_TRUNC;
  3217. Tfile = open64(tempname, oflag, S_IWRITE);
  3218. if (Tfile == INVALID_HANDLE_VALUE) {
  3219. int rc = errno;
  3220. sprintf(g->Message, MSG(OPEN_ERROR), rc, MODE_INSERT, tempname);
  3221. strcat(g->Message, strerror(errno));
  3222. return true;
  3223. } //endif Tfile
  3224. #endif // UNIX
  3225. To_Fbt = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
  3226. To_Fbt->Fname = tempname;
  3227. To_Fbt->Type = TYPE_FB_HANDLE;
  3228. To_Fbt->Memory = NULL;
  3229. To_Fbt->Length = 0;
  3230. To_Fbt->File = NULL;
  3231. To_Fbt->Next = dup->Openlist;
  3232. To_Fbt->Count = 1;
  3233. To_Fbt->Mode = MODE_INSERT;
  3234. To_Fbt->Handle = Tfile;
  3235. dup->Openlist = To_Fbt;
  3236. return false;
  3237. } // end of OpenTempFile
  3238. /***********************************************************************/
  3239. /* Move intermediate deleted or updated lines. */
  3240. /***********************************************************************/
  3241. bool BGVFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
  3242. {
  3243. int i, n, req, dep;
  3244. bool eof = (b) ? *b : false;
  3245. BIGINT pos;
  3246. for (n = Fpos - Spos; n > 0 || eof; n -= req) {
  3247. /*******************************************************************/
  3248. /* Non consecutive line to delete. Move intermediate lines. */
  3249. /*******************************************************************/
  3250. if (!MaxBlk)
  3251. req = (DWORD)MY_MIN(n, Nrec - MY_MAX(Spos % Nrec, Tpos % Nrec));
  3252. else
  3253. req = (DWORD)MY_MIN(n, Nrec);
  3254. if (req) for (i = 0; i < Ncol; i++) {
  3255. if (!MaxBlk) {
  3256. if (UseTemp)
  3257. To_Buf = NewBlock + Deplac[i] + (Tpos % Nrec) * Clens[i];
  3258. pos = (BIGINT)Deplac[i] + (BIGINT)((Spos % Nrec) * Clens[i])
  3259. + (BIGINT)(Spos / Nrec) * (BIGINT)Blksize;
  3260. } else
  3261. pos = BigDep[i] + (BIGINT)Spos * (BIGINT)Clens[i];
  3262. if (BigSeek(g, Hfile, pos))
  3263. return true;
  3264. if (BigRead(g, Hfile, To_Buf, req * Clens[i]))
  3265. return true;
  3266. if (!UseTemp || MaxBlk) {
  3267. if (!MaxBlk)
  3268. pos = (BIGINT)Deplac[i] + (BIGINT)((Tpos % Nrec) * Clens[i])
  3269. + (BIGINT)(Tpos / Nrec) * (BIGINT)Blksize;
  3270. else
  3271. pos = BigDep[i] + (BIGINT)Tpos * (BIGINT)Clens[i];
  3272. if (BigSeek(g, Tfile, pos))
  3273. return true;
  3274. if (BigWrite(g, Tfile, To_Buf, req * Clens[i]))
  3275. return true;
  3276. } // endif UseTemp
  3277. } // endfor i
  3278. Tpos += (int)req;
  3279. Spos += (int)req;
  3280. if (UseTemp && !MaxBlk && (!(Tpos % Nrec) || (eof && Spos == Fpos))) {
  3281. // Write the full or last block to the temporary file
  3282. if ((dep = Nrec - (Tpos % Nrec)) < Nrec)
  3283. // Clean the last block in case of future insert, must be
  3284. // done here because Tfile was open in write only.
  3285. for (i = 0; i < Ncol; i++) {
  3286. To_Buf = NewBlock + Deplac[i] + (Tpos % Nrec) * Clens[i];
  3287. memset(To_Buf, (Isnum[i]) ? 0 : ' ', dep * Clens[i]);
  3288. } // endfor i
  3289. if (BigWrite(g, Tfile, NewBlock, Blksize))
  3290. return true;
  3291. if (Spos == Fpos)
  3292. eof = false;
  3293. } // endif Usetemp...
  3294. if (trace)
  3295. htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
  3296. } // endfor n
  3297. return false;
  3298. } // end of MoveIntermediateLines
  3299. /***********************************************************************/
  3300. /* Clean deleted space in a huge VCT or Vec table file. */
  3301. /***********************************************************************/
  3302. bool BGVFAM::CleanUnusedSpace(PGLOBAL g)
  3303. {
  3304. int i;
  3305. int n;
  3306. BIGINT pos, dep;
  3307. if (!MaxBlk) {
  3308. /*******************************************************************/
  3309. /* Clean last block of the VCT table file. */
  3310. /*******************************************************************/
  3311. assert(!UseTemp); // This case is handled in MoveIntermediateLines
  3312. if (!(n = Nrec - Last))
  3313. return false;
  3314. dep = (BIGINT)((Block - 1) * Blksize);
  3315. for (i = 0; i < Ncol; i++) {
  3316. memset(To_Buf, (Isnum[i]) ? 0 : ' ', n * Clens[i]);
  3317. pos = dep + (BIGINT)(Deplac[i] + Last * Clens[i]);
  3318. if (BigSeek(g, Hfile, pos))
  3319. return true;
  3320. if (BigWrite(g, Hfile, To_Buf, n * Clens[i]))
  3321. return true;
  3322. } // endfor i
  3323. } else {
  3324. int req;
  3325. memset(To_Buf, 0, Buflen);
  3326. for (n = Fpos - Tpos; n > 0; n -= req) {
  3327. /*****************************************************************/
  3328. /* Fill VEC file remaining lines with 0's. */
  3329. /* This seems to work even column blocks have been made with */
  3330. /* Blanks = true. Perhaps should it be set to false for VEC. */
  3331. /*****************************************************************/
  3332. req = MY_MIN(n, Nrec);
  3333. for (i = 0; i < Ncol; i++) {
  3334. pos = BigDep[i] + (BIGINT)Tpos * (BIGINT)Clens[i];
  3335. if (BigSeek(g, Tfile, pos))
  3336. return true;
  3337. if (BigWrite(g, Tfile, To_Buf, req * Clens[i]))
  3338. return true;
  3339. } // endfor i
  3340. Tpos += req;
  3341. } // endfor n
  3342. } // endif MaxBlk
  3343. return false;
  3344. } // end of CleanUnusedSpace
  3345. /***********************************************************************/
  3346. /* Data Base close routine for huge VEC access method. */
  3347. /***********************************************************************/
  3348. void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
  3349. {
  3350. int rc = 0, wrc = RC_OK;
  3351. MODE mode = Tdbp->GetMode();
  3352. Abort = abort;
  3353. if (mode == MODE_INSERT) {
  3354. if (Closing)
  3355. wrc = RC_FX; // Last write was in error
  3356. else
  3357. if (CurNum) {
  3358. // Some more inserted lines remain to be written
  3359. Last = CurNum;
  3360. Block = CurBlk + 1;
  3361. Closing = true;
  3362. wrc = WriteBuffer(g);
  3363. } else {
  3364. Last = Nrec;
  3365. Block = CurBlk;
  3366. wrc = RC_OK;
  3367. } // endif CurNum
  3368. if (wrc != RC_FX) {
  3369. rc = ResetTableSize(g, Block, Last);
  3370. } else if (AddBlock) {
  3371. // Last block was not written
  3372. rc = ResetTableSize(g, CurBlk, Nrec);
  3373. longjmp(g->jumper[g->jump_level], 44);
  3374. } // endif
  3375. } else if (mode == MODE_UPDATE) {
  3376. // Write back to file any pending modifications
  3377. for (PVCTCOL colp = (PVCTCOL)((PTDBVCT)Tdbp)->GetSetCols();
  3378. colp; colp = (PVCTCOL)colp->Next)
  3379. colp->WriteBlock(g);
  3380. if (UseTemp && Tfile) {
  3381. rc = RenameTempFile(g);
  3382. Hfile = Tfile = INVALID_HANDLE_VALUE;
  3383. if (Header)
  3384. // Header must be set because it was not set in temp file
  3385. rc = SetBlockInfo(g);
  3386. } // endif UseTemp
  3387. } else if (mode == MODE_DELETE && UseTemp && Tfile) {
  3388. if (MaxBlk)
  3389. rc = CleanUnusedSpace(g);
  3390. if ((rc = RenameTempFile(g)) != RC_FX) {
  3391. Hfile = Tfile = INVALID_HANDLE_VALUE; // For SetBlockInfo
  3392. rc = ResetTableSize(g, Block, Last);
  3393. } // endif rc
  3394. } // endif's mode
  3395. if (Hfile != INVALID_HANDLE_VALUE)
  3396. rc = PlugCloseFile(g, To_Fb);
  3397. if (trace)
  3398. htrc("BGV CloseTableFile: closing %s wrc=%d rc=%d\n",
  3399. To_File, wrc, rc);
  3400. Hfile = INVALID_HANDLE_VALUE;
  3401. } // end of CloseDB
  3402. /***********************************************************************/
  3403. /* Rewind routine for huge VCT access method. */
  3404. /***********************************************************************/
  3405. void BGVFAM::Rewind(void)
  3406. {
  3407. // In mode update we need to read Set Column blocks
  3408. if (Tdbp->GetMode() == MODE_UPDATE)
  3409. OldBlk = -1;
  3410. // Initialize so block optimization is called for 1st block
  3411. CurBlk = -1;
  3412. CurNum = Nrec - 1;
  3413. #if 0 // This is probably unuseful as the file is directly accessed
  3414. #if defined(WIN32) //OB
  3415. SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
  3416. #else // UNIX
  3417. lseek64(Hfile, 0, SEEK_SET);
  3418. #endif // UNIX
  3419. #endif // 0
  3420. } // end of Rewind
  3421. /***********************************************************************/
  3422. /* ReadBlock: Read column values from current block. */
  3423. /***********************************************************************/
  3424. bool BGVFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
  3425. {
  3426. BIGINT pos;
  3427. /*********************************************************************/
  3428. /* Calculate the offset and size of the block to read. */
  3429. /*********************************************************************/
  3430. if (MaxBlk) // File has Vector format
  3431. pos = (BIGINT)Nrec * ((BIGINT)colp->Deplac * (BIGINT)MaxBlk
  3432. + (BIGINT)colp->Clen * (BIGINT)CurBlk) + (BIGINT)Headlen;
  3433. else // Old VCT format
  3434. pos = (BIGINT)Nrec * ((BIGINT)colp->Deplac
  3435. + (BIGINT)Lrecl * (BIGINT)CurBlk);
  3436. if (trace)
  3437. htrc("RB: offset=%lld Nrec=%d Deplac=%d Lrecl=%d CurBlk=%d MaxBlk=%d\n",
  3438. pos, Nrec, colp->Deplac, Lrecl, CurBlk, MaxBlk);
  3439. if (BigSeek(g, Hfile, pos))
  3440. return true;
  3441. if (BigRead(g, Hfile, colp->Blk->GetValPointer(), colp->Clen * Nrec))
  3442. return true;
  3443. if (trace)
  3444. num_read++;
  3445. return false;
  3446. } // end of ReadBlock
  3447. /***********************************************************************/
  3448. /* WriteBlock: Write back current column values for one block. */
  3449. /* Note: the test of Status is meant to prevent physical writing of */
  3450. /* the block during the checking loop in mode Update. It is set to */
  3451. /* BUF_EMPTY when reopening the table between the two loops. */
  3452. /***********************************************************************/
  3453. bool BGVFAM::WriteBlock(PGLOBAL g, PVCTCOL colp)
  3454. {
  3455. int len;
  3456. BIGINT pos;
  3457. /*********************************************************************/
  3458. /* Calculate the offset and size of the block to write. */
  3459. /*********************************************************************/
  3460. if (MaxBlk) // File has Vector format
  3461. pos = (BIGINT)Nrec * ((BIGINT)colp->Deplac * (BIGINT)MaxBlk
  3462. + (BIGINT)colp->Clen * (BIGINT)colp->ColBlk) + (BIGINT)Headlen;
  3463. else // Old VCT format
  3464. pos = (BIGINT)Nrec * ((BIGINT)colp->Deplac
  3465. + (BIGINT)Lrecl * (BIGINT)colp->ColBlk);
  3466. if (trace)
  3467. htrc("WB: offset=%lld Nrec=%d Deplac=%d Lrecl=%d ColBlk=%d\n",
  3468. pos, Nrec, colp->Deplac, Lrecl, colp->ColBlk);
  3469. if (BigSeek(g, Tfile, pos))
  3470. return true;
  3471. //len = colp->Clen * Nrec; see comment in VCTFAM
  3472. len = colp->Clen * ((Tdbp->GetMode() == MODE_INSERT) ? CurNum : Nrec);
  3473. if (BigWrite(g, Tfile, colp->Blk->GetValPointer(), len))
  3474. return true;
  3475. return false;
  3476. } // end of WriteBlock
  3477. /* ----------------------- End of FilAMVct --------------------------- */