2013-02-07 10:34:27 +01:00
|
|
|
/************* RelDef CPP Program Source Code File (.CPP) **************/
|
|
|
|
/* PROGRAM NAME: REFDEF */
|
|
|
|
/* ------------- */
|
2014-03-22 08:57:32 +01:00
|
|
|
/* Version 1.4 */
|
2013-02-07 10:34:27 +01:00
|
|
|
/* */
|
|
|
|
/* COPYRIGHT: */
|
|
|
|
/* ---------- */
|
2014-03-22 08:57:32 +01:00
|
|
|
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
|
2013-02-07 10:34:27 +01:00
|
|
|
/* */
|
|
|
|
/* WHAT THIS PROGRAM DOES: */
|
|
|
|
/* ----------------------- */
|
|
|
|
/* This program are the DB definition related routines. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Include relevant MariaDB header file. */
|
|
|
|
/***********************************************************************/
|
|
|
|
#include "my_global.h"
|
|
|
|
#if defined(WIN32)
|
|
|
|
#include <sqlext.h>
|
|
|
|
#else
|
|
|
|
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
|
|
|
|
#include "osutil.h"
|
|
|
|
//#include "sqlext.h"
|
|
|
|
#endif
|
2014-04-14 14:26:48 +02:00
|
|
|
#include "handler.h"
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Include application header files */
|
|
|
|
/* */
|
|
|
|
/* global.h is header containing all global declarations. */
|
|
|
|
/* plgdbsem.h is header containing DB application declarations. */
|
|
|
|
/* catalog.h is header containing DB description declarations. */
|
|
|
|
/***********************************************************************/
|
|
|
|
#include "global.h"
|
|
|
|
#include "plgdbsem.h"
|
2013-02-12 12:34:14 +01:00
|
|
|
#include "mycat.h"
|
2013-02-07 10:34:27 +01:00
|
|
|
#include "reldef.h"
|
|
|
|
#include "colblk.h"
|
|
|
|
#include "filamap.h"
|
|
|
|
#include "filamfix.h"
|
|
|
|
#include "filamvct.h"
|
|
|
|
#if defined(ZIP_SUPPORT)
|
|
|
|
#include "filamzip.h"
|
|
|
|
#endif // ZIP_SUPPORT
|
|
|
|
#include "tabdos.h"
|
|
|
|
#include "valblk.h"
|
|
|
|
#include "tabmul.h"
|
2014-04-14 14:26:48 +02:00
|
|
|
#include "ha_connect.h"
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-10-14 16:42:22 +02:00
|
|
|
#if !defined(WIN32)
|
|
|
|
extern handlerton *connect_hton;
|
|
|
|
#endif // !WIN32
|
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* External function. */
|
|
|
|
/***********************************************************************/
|
|
|
|
USETEMP UseTemp(void);
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/* --------------------------- Class RELDEF -------------------------- */
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* RELDEF Constructor. */
|
|
|
|
/***********************************************************************/
|
|
|
|
RELDEF::RELDEF(void)
|
|
|
|
{
|
|
|
|
Next = NULL;
|
|
|
|
To_Cols = NULL;
|
|
|
|
Name = NULL;
|
|
|
|
Database = NULL;
|
|
|
|
Cat = NULL;
|
2014-04-14 14:26:48 +02:00
|
|
|
Hc = NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of RELDEF constructor
|
|
|
|
|
2014-04-14 14:26:48 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* This function sets an integer table information. */
|
|
|
|
/***********************************************************************/
|
|
|
|
bool RELDEF::SetIntCatInfo(PSZ what, int n)
|
|
|
|
{
|
|
|
|
return Hc->SetIntegerOption(what, n);
|
|
|
|
} // end of SetIntCatInfo
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* This function returns integer table information. */
|
|
|
|
/***********************************************************************/
|
|
|
|
int RELDEF::GetIntCatInfo(PSZ what, int idef)
|
|
|
|
{
|
|
|
|
int n= Hc->GetIntegerOption(what);
|
|
|
|
|
|
|
|
return (n == NO_IVAL) ? idef : n;
|
|
|
|
} // end of GetIntCatInfo
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* This function returns Boolean table information. */
|
|
|
|
/***********************************************************************/
|
|
|
|
bool RELDEF::GetBoolCatInfo(PSZ what, bool bdef)
|
|
|
|
{
|
|
|
|
bool b= Hc->GetBooleanOption(what, bdef);
|
|
|
|
|
|
|
|
return b;
|
|
|
|
} // end of GetBoolCatInfo
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* This function returns size catalog information. */
|
|
|
|
/***********************************************************************/
|
|
|
|
int RELDEF::GetSizeCatInfo(PSZ what, PSZ sdef)
|
|
|
|
{
|
|
|
|
char * s, c;
|
|
|
|
int i, n= 0;
|
|
|
|
|
|
|
|
if (!(s= Hc->GetStringOption(what)))
|
|
|
|
s= sdef;
|
|
|
|
|
|
|
|
if ((i= sscanf(s, " %d %c ", &n, &c)) == 2)
|
|
|
|
switch (toupper(c)) {
|
|
|
|
case 'M':
|
|
|
|
n *= 1024;
|
|
|
|
case 'K':
|
|
|
|
n *= 1024;
|
|
|
|
} // endswitch c
|
|
|
|
|
|
|
|
return n;
|
|
|
|
} // end of GetSizeCatInfo
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* This function sets char table information in buf. */
|
|
|
|
/***********************************************************************/
|
|
|
|
int RELDEF::GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size)
|
|
|
|
{
|
|
|
|
char *s= Hc->GetStringOption(what);
|
|
|
|
|
|
|
|
strncpy(buf, ((s) ? s : sdef), size);
|
|
|
|
return size;
|
|
|
|
} // end of GetCharCatInfo
|
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* To be used by any TDB's. */
|
|
|
|
/***********************************************************************/
|
|
|
|
bool RELDEF::Partitioned(void)
|
|
|
|
{
|
|
|
|
return Hc->IsPartitioned();
|
|
|
|
} // end of Partitioned
|
|
|
|
|
2014-04-14 14:26:48 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* This function returns string table information. */
|
|
|
|
/* Default parameter is "*" to get the handler default. */
|
|
|
|
/***********************************************************************/
|
|
|
|
char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
|
|
|
|
{
|
2014-05-31 12:31:26 +02:00
|
|
|
char *name, *sval= NULL, *s= Hc->GetStringOption(what, sdef);
|
2014-04-14 14:26:48 +02:00
|
|
|
|
|
|
|
if (s) {
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
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
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
if (!Hc->IsPartitioned() ||
|
|
|
|
(stricmp(what, "filename") && stricmp(what, "tabname")
|
|
|
|
&& stricmp(what, "connect"))) {
|
2014-05-31 12:31:26 +02:00
|
|
|
sval= (char*)PlugSubAlloc(g, NULL, strlen(s) + 1);
|
|
|
|
strcpy(sval, s);
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
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
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
} else
|
|
|
|
sval= s;
|
2014-05-31 12:31:26 +02:00
|
|
|
|
2014-04-14 14:26:48 +02:00
|
|
|
} else if (!stricmp(what, "filename")) {
|
|
|
|
// Return default file name
|
|
|
|
char *ftype= Hc->GetStringOption("Type", "*");
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
if (IsFileType(GetTypeID(ftype))) {
|
2014-05-31 12:31:26 +02:00
|
|
|
name= Hc->GetPartName();
|
|
|
|
sval= (char*)PlugSubAlloc(g, NULL, strlen(name) + 12);
|
|
|
|
strcat(strcpy(sval, name), ".");
|
2014-04-14 14:26:48 +02:00
|
|
|
n= strlen(sval);
|
|
|
|
|
|
|
|
// Fold ftype to lower case
|
|
|
|
for (i= 0; i < 12; i++)
|
|
|
|
if (!ftype[i]) {
|
|
|
|
sval[n+i]= 0;
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
sval[n+i]= tolower(ftype[i]);
|
|
|
|
|
|
|
|
} // endif FileType
|
|
|
|
|
|
|
|
} // endif s
|
|
|
|
|
|
|
|
return sval;
|
|
|
|
} // end of GetStringCatInfo
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/* --------------------------- Class TABDEF -------------------------- */
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* TABDEF Constructor. */
|
|
|
|
/***********************************************************************/
|
|
|
|
TABDEF::TABDEF(void)
|
|
|
|
{
|
2013-12-28 15:46:49 +01:00
|
|
|
Schema = NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
Desc = NULL;
|
2013-02-12 12:34:14 +01:00
|
|
|
Catfunc = FNC_NO;
|
2013-02-07 10:34:27 +01:00
|
|
|
Card = 0;
|
|
|
|
Elemt = 0;
|
|
|
|
Sort = 0;
|
|
|
|
Multiple = 0;
|
|
|
|
Degree = 0;
|
|
|
|
Pseudo = 0;
|
|
|
|
Read_Only = false;
|
2015-01-06 10:18:04 +01:00
|
|
|
m_data_charset = NULL;
|
|
|
|
csname = NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of TABDEF constructor
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Define: initialize the table definition block from XDB file. */
|
|
|
|
/***********************************************************************/
|
|
|
|
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
|
|
|
|
{
|
|
|
|
int poff = 0;
|
|
|
|
|
2013-05-13 12:20:08 +02:00
|
|
|
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1);
|
2013-02-07 10:34:27 +01:00
|
|
|
strcpy(Name, name);
|
|
|
|
Cat = cat;
|
2014-04-14 14:26:48 +02:00
|
|
|
Hc = ((MYCAT*)cat)->GetHandler();
|
|
|
|
Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL));
|
|
|
|
Elemt = GetIntCatInfo("Elements", 0);
|
|
|
|
Multiple = GetIntCatInfo("Multiple", 0);
|
|
|
|
Degree = GetIntCatInfo("Degree", 0);
|
|
|
|
Read_Only = GetBoolCatInfo("ReadOnly", false);
|
|
|
|
const char *data_charset_name= GetStringCatInfo(g, "Data_charset", NULL);
|
2013-02-18 16:21:52 +01:00
|
|
|
m_data_charset= data_charset_name ?
|
|
|
|
get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0):
|
|
|
|
NULL;
|
2015-01-06 10:18:04 +01:00
|
|
|
csname = GetStringCatInfo(g, "Table_charset", NULL);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Get The column definitions
|
2014-04-14 14:26:48 +02:00
|
|
|
if ((poff = GetColCatInfo(g)) < 0)
|
2013-02-07 10:34:27 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// Do the definition of AM specific fields
|
|
|
|
return DefineAM(g, am, poff);
|
|
|
|
} // end of Define
|
|
|
|
|
2014-08-23 19:17:15 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* This function returns the database data path. */
|
|
|
|
/***********************************************************************/
|
|
|
|
PSZ TABDEF::GetPath(void)
|
|
|
|
{
|
|
|
|
return (Database) ? (PSZ)Database : Hc->GetDataPath();
|
|
|
|
} // end of GetPath
|
|
|
|
|
2014-04-14 14:26:48 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* This function returns column table information. */
|
|
|
|
/***********************************************************************/
|
|
|
|
int TABDEF::GetColCatInfo(PGLOBAL g)
|
|
|
|
{
|
|
|
|
char *type= GetStringCatInfo(g, "Type", "*");
|
|
|
|
int i, loff, poff, nof, nlg;
|
|
|
|
void *field= NULL;
|
|
|
|
TABTYPE tc;
|
|
|
|
PCOLDEF cdp, lcdp= NULL, tocols= NULL;
|
|
|
|
PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO));
|
|
|
|
|
|
|
|
memset(pcf, 0, sizeof(COLINFO));
|
|
|
|
|
|
|
|
// Get a unique char identifier for type
|
|
|
|
tc= (Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX;
|
|
|
|
|
|
|
|
// Take care of the column definitions
|
|
|
|
i= poff= nof= nlg= 0;
|
|
|
|
|
|
|
|
// Offsets of HTML and DIR tables start from 0, DBF at 1
|
|
|
|
loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
// Default Offset depends on table type
|
|
|
|
switch (tc) {
|
|
|
|
case TAB_DOS:
|
|
|
|
case TAB_FIX:
|
|
|
|
case TAB_BIN:
|
|
|
|
case TAB_VEC:
|
|
|
|
case TAB_DBF:
|
|
|
|
poff= loff + nof; // Default next offset
|
2014-04-21 12:57:10 +02:00
|
|
|
nlg= MY_MAX(nlg, poff); // Default lrecl
|
2014-04-14 14:26:48 +02:00
|
|
|
break;
|
|
|
|
case TAB_CSV:
|
|
|
|
case TAB_FMT:
|
|
|
|
nlg+= nof;
|
|
|
|
case TAB_DIR:
|
|
|
|
case TAB_XML:
|
|
|
|
poff= loff + 1;
|
|
|
|
break;
|
|
|
|
case TAB_INI:
|
|
|
|
case TAB_MAC:
|
|
|
|
case TAB_TBL:
|
|
|
|
case TAB_XCL:
|
|
|
|
case TAB_OCCUR:
|
|
|
|
case TAB_PRX:
|
|
|
|
case TAB_OEM:
|
|
|
|
poff = 0; // Offset represents an independant flag
|
|
|
|
break;
|
|
|
|
default: // VCT PLG ODBC MYSQL WMI...
|
|
|
|
poff = 0; // NA
|
|
|
|
break;
|
|
|
|
} // endswitch tc
|
|
|
|
|
|
|
|
// do {
|
|
|
|
field= Hc->GetColumnOption(g, field, pcf);
|
|
|
|
// } while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/));
|
|
|
|
|
|
|
|
if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) {
|
|
|
|
// DBF date format defaults to 'YYYMMDD'
|
|
|
|
pcf->Datefmt= "YYYYMMDD";
|
|
|
|
pcf->Length= 8;
|
|
|
|
} // endif tc
|
|
|
|
|
|
|
|
if (!field)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Allocate the column description block
|
|
|
|
cdp= new(g) COLDEF;
|
|
|
|
|
|
|
|
if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0)
|
|
|
|
return -1; // Error, probably unhandled type
|
|
|
|
else if (nof)
|
|
|
|
loff= cdp->GetOffset();
|
|
|
|
|
|
|
|
switch (tc) {
|
|
|
|
case TAB_VEC:
|
|
|
|
cdp->SetOffset(0); // Not to have shift
|
|
|
|
case TAB_BIN:
|
|
|
|
// BIN/VEC are packed by default
|
|
|
|
if (nof)
|
|
|
|
// Field width is the internal representation width
|
|
|
|
// that can also depend on the column format
|
|
|
|
switch (cdp->Fmt ? *cdp->Fmt : 'X') {
|
|
|
|
case 'C': break;
|
|
|
|
case 'R':
|
|
|
|
case 'F':
|
|
|
|
case 'L':
|
|
|
|
case 'I': nof= 4; break;
|
|
|
|
case 'D': nof= 8; break;
|
|
|
|
case 'S': nof= 2; break;
|
|
|
|
case 'T': nof= 1; break;
|
|
|
|
default: nof= cdp->Clen;
|
|
|
|
} // endswitch Fmt
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} // endswitch tc
|
|
|
|
|
|
|
|
if (lcdp)
|
|
|
|
lcdp->SetNext(cdp);
|
|
|
|
else
|
|
|
|
tocols= cdp;
|
|
|
|
|
|
|
|
lcdp= cdp;
|
|
|
|
i++;
|
|
|
|
} // endwhile
|
|
|
|
|
|
|
|
// Degree is the the number of defined columns (informational)
|
|
|
|
if (i != GetDegree())
|
|
|
|
SetDegree(i);
|
|
|
|
|
|
|
|
if (GetDefType() == TYPE_AM_DOS) {
|
|
|
|
int ending, recln= 0;
|
|
|
|
|
|
|
|
// Was commented because sometimes ending is 0 even when
|
|
|
|
// not specified (for instance if quoted is specified)
|
|
|
|
// if ((ending= Hc->GetIntegerOption("Ending")) < 0) {
|
|
|
|
if ((ending= Hc->GetIntegerOption("Ending")) <= 0) {
|
|
|
|
#if defined(WIN32)
|
|
|
|
ending= 2;
|
|
|
|
#else
|
|
|
|
ending= 1;
|
|
|
|
#endif
|
|
|
|
Hc->SetIntegerOption("Ending", ending);
|
|
|
|
} // endif ending
|
|
|
|
|
|
|
|
// Calculate the default record size
|
|
|
|
switch (tc) {
|
|
|
|
case TAB_FIX:
|
|
|
|
recln= nlg + ending; // + length of line ending
|
|
|
|
break;
|
|
|
|
case TAB_BIN:
|
|
|
|
case TAB_VEC:
|
|
|
|
recln= nlg;
|
|
|
|
|
|
|
|
// if ((k= (pak < 0) ? 8 : pak) > 1)
|
|
|
|
// See above for detailed comment
|
|
|
|
// Round up lrecl to multiple of 8 or pak
|
|
|
|
// recln= ((recln + k - 1) / k) * k;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case TAB_DOS:
|
|
|
|
case TAB_DBF:
|
|
|
|
recln= nlg;
|
|
|
|
break;
|
|
|
|
case TAB_CSV:
|
|
|
|
case TAB_FMT:
|
|
|
|
// The number of separators (assuming an extra one can exist)
|
|
|
|
// recln= poff * ((qotd) ? 3 : 1); to be investigated
|
|
|
|
recln= nlg + poff * 3; // To be safe
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} // endswitch tc
|
|
|
|
|
|
|
|
// lrecl must be at least recln to avoid buffer overflow
|
2014-04-21 12:57:10 +02:00
|
|
|
recln= MY_MAX(recln, Hc->GetIntegerOption("Lrecl"));
|
2014-04-14 14:26:48 +02:00
|
|
|
Hc->SetIntegerOption("Lrecl", recln);
|
|
|
|
((PDOSDEF)this)->SetLrecl(recln);
|
|
|
|
} // endif Lrecl
|
|
|
|
|
|
|
|
// Attach the column definition to the tabdef
|
|
|
|
SetCols(tocols);
|
|
|
|
return poff;
|
|
|
|
} // end of GetColCatInfo
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* SetIndexInfo: retrieve index description from the table structure. */
|
|
|
|
/***********************************************************************/
|
|
|
|
void TABDEF::SetIndexInfo(void)
|
|
|
|
{
|
|
|
|
// Attach new index(es)
|
|
|
|
SetIndx(Hc->GetIndexInfo());
|
|
|
|
} // end of SetIndexInfo
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/* --------------------------- Class OEMDEF -------------------------- */
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* GetXdef: get the external TABDEF from OEM module. */
|
|
|
|
/***********************************************************************/
|
|
|
|
PTABDEF OEMDEF::GetXdef(PGLOBAL g)
|
|
|
|
{
|
|
|
|
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *);
|
|
|
|
char c, getname[40] = "Get";
|
|
|
|
PTABDEF xdefp;
|
|
|
|
XGETDEF getdef = NULL;
|
|
|
|
PCATLG cat = Cat;
|
|
|
|
|
|
|
|
#if defined(WIN32)
|
|
|
|
// Is the DLL already loaded?
|
|
|
|
if (!Hdll && !(Hdll = GetModuleHandle(Module)))
|
|
|
|
// No, load the Dll implementing the function
|
|
|
|
if (!(Hdll = LoadLibrary(Module))) {
|
|
|
|
char buf[256];
|
|
|
|
DWORD rc = GetLastError();
|
|
|
|
|
|
|
|
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module);
|
|
|
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
|
|
|
|
(LPTSTR)buf, sizeof(buf), NULL);
|
|
|
|
strcat(strcat(g->Message, ": "), buf);
|
|
|
|
return NULL;
|
|
|
|
} // endif hDll
|
|
|
|
|
|
|
|
// The exported name is always in uppercase
|
|
|
|
for (int i = 0; ; i++) {
|
|
|
|
c = Subtype[i];
|
|
|
|
getname[i + 3] = toupper(c);
|
|
|
|
if (!c) break;
|
|
|
|
} // endfor i
|
|
|
|
|
|
|
|
// Get the function returning an instance of the external DEF class
|
|
|
|
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
|
|
|
|
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
|
|
|
|
FreeLibrary((HMODULE)Hdll);
|
|
|
|
return NULL;
|
|
|
|
} // endif getdef
|
|
|
|
#else // !WIN32
|
|
|
|
const char *error = NULL;
|
2014-10-14 16:42:22 +02:00
|
|
|
Dl_info dl_info;
|
|
|
|
|
|
|
|
// The OEM lib must retrieve exported CONNECT variables
|
|
|
|
if (dladdr(&connect_hton, &dl_info)) {
|
|
|
|
if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) {
|
|
|
|
error = dlerror();
|
|
|
|
sprintf(g->Message, "dlopen failed: %s, OEM not supported", SVP(error));
|
|
|
|
return NULL;
|
|
|
|
} // endif dlopen
|
|
|
|
|
|
|
|
} else {
|
|
|
|
error = dlerror();
|
|
|
|
sprintf(g->Message, "dladdr failed: %s, OEM not supported", SVP(error));
|
|
|
|
return NULL;
|
|
|
|
} // endif dladdr
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// Is the library already loaded?
|
|
|
|
// if (!Hdll && !(Hdll = ???))
|
|
|
|
// Load the desired shared library
|
|
|
|
if (!(Hdll = dlopen(Module, RTLD_LAZY))) {
|
|
|
|
error = dlerror();
|
|
|
|
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error));
|
|
|
|
return NULL;
|
|
|
|
} // endif Hdll
|
|
|
|
|
|
|
|
// The exported name is always in uppercase
|
|
|
|
for (int i = 0; ; i++) {
|
|
|
|
c = Subtype[i];
|
|
|
|
getname[i + 3] = toupper(c);
|
|
|
|
if (!c) break;
|
|
|
|
} // endfor i
|
|
|
|
|
|
|
|
// Get the function returning an instance of the external DEF class
|
|
|
|
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) {
|
|
|
|
error = dlerror();
|
|
|
|
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error));
|
|
|
|
dlclose(Hdll);
|
|
|
|
return NULL;
|
|
|
|
} // endif getdef
|
|
|
|
#endif // !WIN32
|
|
|
|
|
|
|
|
// Just in case the external Get function does not set error messages
|
|
|
|
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
|
|
|
|
|
|
|
|
// Get the table definition block
|
2013-05-13 12:20:08 +02:00
|
|
|
if (!(xdefp = getdef(g, NULL)))
|
2013-02-07 10:34:27 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Have the external class do its complete definition
|
|
|
|
if (!cat->Cbuf) {
|
|
|
|
// Suballocate a temporary buffer for the entire column section
|
2014-04-14 14:26:48 +02:00
|
|
|
cat->Cblen = GetSizeCatInfo("Colsize", "8K");
|
2013-02-07 10:34:27 +01:00
|
|
|
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen);
|
|
|
|
} // endif Cbuf
|
|
|
|
|
|
|
|
// Here "OEM" should be replace by a more useful value
|
|
|
|
if (xdefp->Define(g, cat, Name, "OEM"))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Ok, return external block
|
|
|
|
return xdefp;
|
|
|
|
} // end of GetXdef
|
|
|
|
|
2014-03-10 18:29:04 +01:00
|
|
|
#if 0
|
2013-02-07 10:34:27 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* DeleteTableFile: Delete an OEM table file if applicable. */
|
|
|
|
/***********************************************************************/
|
|
|
|
bool OEMDEF::DeleteTableFile(PGLOBAL g)
|
|
|
|
{
|
|
|
|
if (!Pxdef)
|
|
|
|
Pxdef = GetXdef(g);
|
|
|
|
|
|
|
|
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
|
|
|
|
} // end of DeleteTableFile
|
2014-03-10 18:29:04 +01:00
|
|
|
#endif // 0
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Define: initialize the table definition block from XDB file. */
|
|
|
|
/***********************************************************************/
|
|
|
|
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|
|
|
{
|
2014-04-14 14:26:48 +02:00
|
|
|
Module = GetStringCatInfo(g, "Module", "");
|
|
|
|
Subtype = GetStringCatInfo(g, "Subtype", Module);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (!*Module)
|
|
|
|
Module = Subtype;
|
|
|
|
|
2013-05-13 12:20:08 +02:00
|
|
|
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
|
2013-02-07 10:34:27 +01:00
|
|
|
+ strlen(Subtype) + 3);
|
|
|
|
sprintf(Desc, "%s(%s)", Module, Subtype);
|
|
|
|
return false;
|
|
|
|
} // end of DefineAM
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* GetTable: makes a new Table Description Block. */
|
|
|
|
/***********************************************************************/
|
|
|
|
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
|
|
|
|
{
|
|
|
|
RECFM rfm;
|
|
|
|
PTDBASE tdbp = NULL;
|
|
|
|
|
|
|
|
// If define block not here yet, get it now
|
|
|
|
if (!Pxdef && !(Pxdef = GetXdef(g)))
|
|
|
|
return NULL; // Error
|
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
/* Allocate a TDB of the proper type. */
|
|
|
|
/* Column blocks will be allocated only when needed. */
|
|
|
|
/*********************************************************************/
|
|
|
|
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode)))
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
rfm = tdbp->GetFtype();
|
|
|
|
|
|
|
|
if (rfm == RECFM_NAF)
|
|
|
|
return tdbp;
|
|
|
|
else if (rfm == RECFM_OEM) {
|
|
|
|
if (Multiple)
|
|
|
|
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
|
|
|
|
|
|
|
|
return tdbp;
|
|
|
|
} // endif OEM
|
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
/* The OEM table is based on a file type (currently DOS+ only) */
|
|
|
|
/*********************************************************************/
|
|
|
|
assert (rfm == RECFM_VAR || rfm == RECFM_FIX ||
|
|
|
|
rfm == RECFM_BIN || rfm == RECFM_VCT);
|
|
|
|
|
|
|
|
PTXF txfp = NULL;
|
|
|
|
PDOSDEF defp = (PDOSDEF)Pxdef;
|
|
|
|
bool map = defp->Mapped && mode != MODE_INSERT &&
|
2014-10-21 17:29:51 +02:00
|
|
|
!(UseTemp() == TMP_FORCE &&
|
2013-02-07 10:34:27 +01:00
|
|
|
(mode == MODE_UPDATE || mode == MODE_DELETE));
|
|
|
|
int cmpr = defp->Compressed;
|
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
/* Allocate table and file processing class of the proper type. */
|
|
|
|
/* Column blocks will be allocated only when needed. */
|
|
|
|
/*********************************************************************/
|
|
|
|
if (!((PTDBDOS)tdbp)->GetTxfp()) {
|
|
|
|
if (cmpr) {
|
|
|
|
#if defined(ZIP_SUPPORT)
|
|
|
|
if (cmpr == 1)
|
|
|
|
txfp = new(g) ZIPFAM(defp);
|
2014-03-22 08:57:32 +01:00
|
|
|
else
|
|
|
|
txfp = new(g) ZLBFAM(defp);
|
2013-02-07 10:34:27 +01:00
|
|
|
#else // !ZIP_SUPPORT
|
|
|
|
strcpy(g->Message, "Compress not supported");
|
|
|
|
return NULL;
|
|
|
|
#endif // !ZIP_SUPPORT
|
|
|
|
} else if (rfm == RECFM_VAR) {
|
|
|
|
if (map)
|
|
|
|
txfp = new(g) MAPFAM(defp);
|
|
|
|
else
|
|
|
|
txfp = new(g) DOSFAM(defp);
|
|
|
|
|
2013-04-29 17:47:23 +02:00
|
|
|
} else if (rfm == RECFM_FIX || rfm == RECFM_BIN) {
|
2013-02-07 10:34:27 +01:00
|
|
|
if (map)
|
|
|
|
txfp = new(g) MPXFAM(defp);
|
|
|
|
else
|
|
|
|
txfp = new(g) FIXFAM(defp);
|
|
|
|
|
|
|
|
} else if (rfm == RECFM_VCT) {
|
|
|
|
assert (Pxdef->GetDefType() == TYPE_AM_VCT);
|
|
|
|
|
|
|
|
if (map)
|
|
|
|
txfp = new(g) VCMFAM((PVCTDEF)defp);
|
|
|
|
else
|
|
|
|
txfp = new(g) VCTFAM((PVCTDEF)defp);
|
|
|
|
|
|
|
|
} // endif's
|
|
|
|
|
|
|
|
((PTDBDOS)tdbp)->SetTxfp(txfp);
|
|
|
|
} // endif Txfp
|
|
|
|
|
|
|
|
if (Multiple)
|
|
|
|
tdbp = new(g) TDBMUL(tdbp);
|
|
|
|
|
|
|
|
return tdbp;
|
|
|
|
} // end of GetTable
|
|
|
|
|
|
|
|
/* --------------------------- Class COLCRT -------------------------- */
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* COLCRT Constructors. */
|
|
|
|
/***********************************************************************/
|
|
|
|
COLCRT::COLCRT(PSZ name)
|
|
|
|
{
|
|
|
|
Next = NULL;
|
|
|
|
Name = name;
|
|
|
|
Desc = NULL;
|
|
|
|
Decode = NULL;
|
|
|
|
Fmt = NULL;
|
|
|
|
Offset = -1;
|
|
|
|
Long = -1;
|
2013-12-28 15:46:49 +01:00
|
|
|
Precision = -1;
|
2014-03-22 08:57:32 +01:00
|
|
|
Freq = -1;
|
2013-02-07 10:34:27 +01:00
|
|
|
Key = -1;
|
2013-12-28 15:46:49 +01:00
|
|
|
Scale = -1;
|
2014-03-22 08:57:32 +01:00
|
|
|
Opt = -1;
|
2013-02-07 10:34:27 +01:00
|
|
|
DataType = '*';
|
|
|
|
} // end of COLCRT constructor for table creation
|
|
|
|
|
|
|
|
COLCRT::COLCRT(void)
|
|
|
|
{
|
|
|
|
Next = NULL;
|
|
|
|
Name = NULL;
|
|
|
|
Desc = NULL;
|
|
|
|
Decode = NULL;
|
|
|
|
Fmt = NULL;
|
|
|
|
Offset = 0;
|
|
|
|
Long = 0;
|
2013-12-28 15:46:49 +01:00
|
|
|
Precision = 0;
|
2014-03-22 08:57:32 +01:00
|
|
|
Freq = 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
Key = 0;
|
2013-12-28 15:46:49 +01:00
|
|
|
Scale = 0;
|
2014-03-22 08:57:32 +01:00
|
|
|
Opt = 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
DataType = '*';
|
|
|
|
} // end of COLCRT constructor for table & view definition
|
|
|
|
|
|
|
|
/* --------------------------- Class COLDEF -------------------------- */
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* COLDEF Constructor. */
|
|
|
|
/***********************************************************************/
|
|
|
|
COLDEF::COLDEF(void) : COLCRT()
|
|
|
|
{
|
2014-03-22 08:57:32 +01:00
|
|
|
To_Min = NULL;
|
|
|
|
To_Max = NULL;
|
|
|
|
To_Pos = NULL;
|
|
|
|
Xdb2 = FALSE;
|
|
|
|
To_Bmap = NULL;
|
|
|
|
To_Dval = NULL;
|
|
|
|
Ndv = 0;
|
|
|
|
Nbm = 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
Buf_Type = TYPE_ERROR;
|
|
|
|
Clen = 0;
|
|
|
|
Poff = 0;
|
|
|
|
memset(&F, 0, sizeof(FORMAT));
|
|
|
|
Flags = 0;
|
|
|
|
} // end of COLDEF constructor
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Define: initialize a column definition from a COLINFO structure. */
|
|
|
|
/***********************************************************************/
|
|
|
|
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
|
|
|
|
{
|
|
|
|
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1);
|
|
|
|
strcpy(Name, cfp->Name);
|
|
|
|
|
2013-08-09 18:02:47 +02:00
|
|
|
if (!(cfp->Flags & U_SPECIAL)) {
|
|
|
|
Poff = poff;
|
|
|
|
Buf_Type = cfp->Type;
|
|
|
|
|
|
|
|
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) {
|
|
|
|
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name);
|
|
|
|
return -1;
|
|
|
|
} // endswitch
|
|
|
|
|
|
|
|
strcpy(F.Type, GetFormatType(Buf_Type));
|
|
|
|
F.Length = cfp->Length;
|
2013-12-28 15:46:49 +01:00
|
|
|
F.Prec = cfp->Scale;
|
2013-08-09 18:02:47 +02:00
|
|
|
Offset = (cfp->Offset < 0) ? poff : cfp->Offset;
|
2013-12-28 15:46:49 +01:00
|
|
|
Precision = cfp->Precision;
|
|
|
|
Scale = cfp->Scale;
|
2013-08-09 18:02:47 +02:00
|
|
|
Long = cfp->Length;
|
2014-03-22 08:57:32 +01:00
|
|
|
Opt = cfp->Opt;
|
2013-08-09 18:02:47 +02:00
|
|
|
Key = cfp->Key;
|
2014-03-22 08:57:32 +01:00
|
|
|
Freq = cfp->Freq;
|
2013-08-09 18:02:47 +02:00
|
|
|
|
|
|
|
if (cfp->Remark && *cfp->Remark) {
|
|
|
|
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
|
|
|
|
strcpy(Desc, cfp->Remark);
|
|
|
|
} // endif Remark
|
|
|
|
|
|
|
|
if (cfp->Datefmt) {
|
|
|
|
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1);
|
|
|
|
strcpy(Decode, cfp->Datefmt);
|
|
|
|
} // endif Datefmt
|
|
|
|
|
|
|
|
} // endif special
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (cfp->Fieldfmt) {
|
|
|
|
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1);
|
|
|
|
strcpy(Fmt, cfp->Fieldfmt);
|
|
|
|
} // endif Fieldfmt
|
|
|
|
|
|
|
|
Flags = cfp->Flags;
|
2013-08-09 18:02:47 +02:00
|
|
|
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of Define
|
|
|
|
|
|
|
|
/* ------------------------- End of RelDef --------------------------- */
|