Commit 5dcb111c authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'Buggynours:10.0' into 10.0

parents bbcc8e69 eae8318b
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.cc text
*.cpp text
*.h text
*.test text
# Declare files that will always have LF line endings on checkout.
*.result text eol=lf
storage/connect/mysql-test/connect/std_data/*.txt text eol=lf
storage/connect/mysql-test/connect/std_data/*.dat text eol=lf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.c diff=cpp *.c diff=cpp
*.h diff=cpp *.h diff=cpp
*.cc diff=cpp *.cc diff=cpp
......
# Edited by Olivier Bertrand
*-t *-t
*.a *.a
*.ctest *.ctest
...@@ -7,6 +8,8 @@ ...@@ -7,6 +8,8 @@
*.so.* *.so.*
*.spec *.spec
*~ *~
*.bak
*.log
.*.swp .*.swp
*.ninja *.ninja
.ninja_* .ninja_*
...@@ -15,6 +18,9 @@ errmsg.sys ...@@ -15,6 +18,9 @@ errmsg.sys
typescript typescript
CMakeCache.txt CMakeCache.txt
CMakeFiles/ CMakeFiles/
MakeFile
cmake_install.cmake
install_manifest.txt
CPackConfig.cmake CPackConfig.cmake
CPackSourceConfig.cmake CPackSourceConfig.cmake
CTestTestfile.cmake CTestTestfile.cmake
...@@ -230,3 +236,230 @@ storage/mroonga/vendor/groonga/src/grnslap ...@@ -230,3 +236,230 @@ storage/mroonga/vendor/groonga/src/grnslap
storage/mroonga/vendor/groonga/src/groonga storage/mroonga/vendor/groonga/src/groonga
storage/mroonga/vendor/groonga/src/groonga-benchmark storage/mroonga/vendor/groonga/src/groonga-benchmark
storage/mroonga/vendor/groonga/src/suggest/groonga-suggest-create-dataset storage/mroonga/vendor/groonga/src/suggest/groonga-suggest-create-dataset
# C and C++
# Compiled Object files
*.slo
*.lo
*.o
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Compiled Static libraries
*.lib
*.a
*.la
*.lai
*.lo
# Compiled Dynamic libraries
*.so
*.so.*
*.dylib
*.dll
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
*.ncb
*.sln
*.vcproj
*.vcproj.*
*.vcproj.*.*
*.vcproj.*.*.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Roslyn cache directories
*.ide/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
#NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# If using the old MSBuild-Integrated Package Restore, uncomment this:
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
# sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
...@@ -21,18 +21,18 @@ ha_connect.cc connect.cc user_connect.cc mycat.cc ...@@ -21,18 +21,18 @@ ha_connect.cc connect.cc user_connect.cc mycat.cc
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
array.cpp blkfil.cpp colblk.cpp csort.cpp array.cpp blkfil.cpp colblk.cpp csort.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp filamzip.cpp filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp filamzip.cpp
filter.cpp json.cpp jsonudf.cpp maputil.cpp myutil.cpp plgdbutl.cpp reldef.cpp filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp tabmul.cpp reldef.cpp tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp
taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp tabvct.cpp tabvir.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp
tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp tabvct.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h
engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h
filter.h global.h ha_connect.h inihandl.h json.h maputil.h msgid.h mycat.h filter.h global.h ha_connect.h inihandl.h json.h maputil.h msgid.h mycat.h
myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h resource.h myconn.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h
tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h taboccur.h tabpivot.h resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h tabmysql.h
tabsys.h tabtbl.h tabutil.h tabvct.h tabvir.h tabxcl.h user_connect.h taboccur.h tabpivot.h tabsys.h tabtbl.h tabutil.h tabvct.h tabvir.h tabxcl.h
valblk.h value.h xindex.h xobject.h xtable.h) user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
# #
# Definitions that are shared for all OSes # Definitions that are shared for all OSes
...@@ -166,24 +166,15 @@ IF(LIBXML2_FOUND OR MSXML_FOUND) ...@@ -166,24 +166,15 @@ IF(LIBXML2_FOUND OR MSXML_FOUND)
ENDIF() ENDIF()
# #
# MySQL # MySQL is now included unconditionnally
# #
OPTION(CONNECT_WITH_MYSQL IF(NOT UNIX)
"Compile CONNECT storage engine with remote MySQL connection support"
ON)
IF(CONNECT_WITH_MYSQL)
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
myconn.cpp myconn.h tabmysql.cpp tabmysql.h)
add_definitions(-DMYSQL_SUPPORT)
IF(NOT UNIX)
# #
# TODO: remove this # TODO: remove this
# change to use "#include "../../include/mysql.h" in the sources. # change to use "#include "../../include/mysql.h" in the sources.
INCLUDE_DIRECTORIES("../../include/mysql") INCLUDE_DIRECTORIES("../../include/mysql")
ENDIF(NOT UNIX) ENDIF(NOT UNIX)
ENDIF(CONNECT_WITH_MYSQL)
# #
...@@ -232,6 +223,8 @@ IF(CONNECT_WITH_ODBC) ...@@ -232,6 +223,8 @@ IF(CONNECT_WITH_ODBC)
DOC "Specify the ODBC driver manager library here." DOC "Specify the ODBC driver manager library here."
) )
mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR)
IF(ODBC_INCLUDE_DIR AND ODBC_LIBRARY) IF(ODBC_INCLUDE_DIR AND ODBC_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${ODBC_LIBRARY}) set(CMAKE_REQUIRED_LIBRARIES ${ODBC_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES ${ODBC_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${ODBC_INCLUDE_DIR})
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "tabcol.h" #include "tabcol.h"
#include "catalog.h" #include "catalog.h"
#include "ha_connect.h" #include "ha_connect.h"
#include "mycat.h"
#define my_strupr(p) my_caseup_str(default_charset_info, (p)); #define my_strupr(p) my_caseup_str(default_charset_info, (p));
#define my_strlwr(p) my_casedn_str(default_charset_info, (p)); #define my_strlwr(p) my_casedn_str(default_charset_info, (p));
......
...@@ -275,7 +275,7 @@ PXNODE DOMNODE::GetNext(PGLOBAL g) ...@@ -275,7 +275,7 @@ PXNODE DOMNODE::GetNext(PGLOBAL g)
{ {
if (Nodep->nextSibling == NULL) if (Nodep->nextSibling == NULL)
Next = NULL; Next = NULL;
else if (!Next) else // if (!Next)
Next = new(g) DOMNODE(Doc, Nodep->nextSibling); Next = new(g) DOMNODE(Doc, Nodep->nextSibling);
return Next; return Next;
...@@ -288,7 +288,7 @@ PXNODE DOMNODE::GetChild(PGLOBAL g) ...@@ -288,7 +288,7 @@ PXNODE DOMNODE::GetChild(PGLOBAL g)
{ {
if (Nodep->firstChild == NULL) if (Nodep->firstChild == NULL)
Children = NULL; Children = NULL;
else if (!Children) else // if (!Children)
Children = new(g) DOMNODE(Doc, Nodep->firstChild); Children = new(g) DOMNODE(Doc, Nodep->firstChild);
return Children; return Children;
...@@ -441,15 +441,27 @@ PXNODE DOMNODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np) ...@@ -441,15 +441,27 @@ PXNODE DOMNODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np)
/******************************************************************/ /******************************************************************/
PXATTR DOMNODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap) PXATTR DOMNODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap)
{ {
MSXML2::IXMLDOMElementPtr ep = Nodep; MSXML2::IXMLDOMElementPtr ep;
MSXML2::IXMLDOMAttributePtr atp = ep->getAttributeNode(name); MSXML2::IXMLDOMNamedNodeMapPtr nmp;
MSXML2::IXMLDOMAttributePtr atp;
if (name) {
ep = Nodep;
atp = ep->getAttributeNode(name);
nmp = NULL;
} else {
nmp = Nodep->Getattributes();
atp = nmp->Getitem(0);
} // endif name
if (atp) { if (atp) {
if (ap) { if (ap) {
((PDOMATTR)ap)->Atrp = atp; ((PDOMATTR)ap)->Atrp = atp;
((PDOMATTR)ap)->Nmp = nmp;
((PDOMATTR)ap)->K = 0;
return ap; return ap;
} else } else
return new(g) DOMATTR(Doc, atp); return new(g) DOMATTR(Doc, atp, nmp);
} else } else
return NULL; return NULL;
...@@ -617,14 +629,85 @@ bool DOMNODELIST::DropItem(PGLOBAL g, int n) ...@@ -617,14 +629,85 @@ bool DOMNODELIST::DropItem(PGLOBAL g, int n)
/******************************************************************/ /******************************************************************/
/* DOMATTR constructor. */ /* DOMATTR constructor. */
/******************************************************************/ /******************************************************************/
DOMATTR::DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap) DOMATTR::DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap,
MSXML2::IXMLDOMNamedNodeMapPtr nmp)
: XMLATTRIBUTE(dp) : XMLATTRIBUTE(dp)
{ {
Atrp = ap; Atrp = ap;
Nmp = nmp;
Ws = NULL; Ws = NULL;
Len = 0; Len = 0;
K = 0;
} // end of DOMATTR constructor } // end of DOMATTR constructor
/******************************************************************/
/* Return the attribute name. */
/******************************************************************/
char *DOMATTR::GetName(PGLOBAL g)
{
if (!WideCharToMultiByte(CP_ACP, 0, Atrp->nodeName, -1,
Name, sizeof(Name), NULL, NULL)) {
strcpy(g->Message, MSG(NAME_CONV_ERR));
return NULL;
} // endif
return Name;
} // end of GetName
/******************************************************************/
/* Return the next attribute node. */
/* This funtion is implemented as needed by XMLColumns. */
/******************************************************************/
PXATTR DOMATTR::GetNext(PGLOBAL g)
{
if (!Nmp)
return NULL;
if (++K >= Nmp->Getlength()) {
Nmp->reset();
Nmp = NULL;
K = 0;
return NULL;
} // endif K
Atrp = Nmp->Getitem(K);
return this;
} // end of GetNext
/******************************************************************/
/* Return the content of a node and subnodes. */
/******************************************************************/
RCODE DOMATTR::GetText(PGLOBAL g, char *buf, int len)
{
RCODE rc = RC_OK;
if (!WideCharToMultiByte(CP_UTF8, 0, Atrp->text, -1,
buf, len, NULL, NULL)) {
DWORD lsr = GetLastError();
switch (lsr) {
case 0:
case ERROR_INSUFFICIENT_BUFFER: // 122L
sprintf(g->Message, "Truncated %s content", GetName(g));
rc = RC_INFO;
break;
case ERROR_NO_UNICODE_TRANSLATION: // 1113L
sprintf(g->Message, "Invalid character(s) in %s content",
GetName(g));
rc = RC_INFO;
break;
default:
sprintf(g->Message, "System error getting %s content",
GetName(g));
rc = RC_FX;
break;
} // endswitch
} // endif
return rc;
} // end of GetText
/******************************************************************/ /******************************************************************/
/* Set the text content of an attribute. */ /* Set the text content of an attribute. */
/******************************************************************/ /******************************************************************/
......
...@@ -122,15 +122,24 @@ class DOMATTR : public XMLATTRIBUTE { ...@@ -122,15 +122,24 @@ class DOMATTR : public XMLATTRIBUTE {
friend class DOMDOC; friend class DOMDOC;
friend class DOMNODE; friend class DOMNODE;
public: public:
// Properties
virtual char *GetName(PGLOBAL g);
virtual PXATTR GetNext(PGLOBAL);
// Methods // Methods
virtual RCODE GetText(PGLOBAL g, char *bufp, int len);
virtual bool SetText(PGLOBAL g, char *txtp, int len); virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected: protected:
// Constructor // Constructor
DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap); DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap,
MSXML2::IXMLDOMNamedNodeMapPtr nmp = NULL);
// Members // Members
MSXML2::IXMLDOMAttributePtr Atrp; MSXML2::IXMLDOMAttributePtr Atrp;
MSXML2::IXMLDOMNamedNodeMapPtr Nmp;
char Name[64];
WCHAR *Ws; WCHAR *Ws;
int Len; int Len;
long K;
}; // end of class DOMATTR }; // end of class DOMATTR
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -207,8 +207,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -207,8 +207,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_MAP; fp->Type = TYPE_FB_MAP;
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); fp->Fname = PlugDup(g, filename);
strcpy((char*)fp->Fname, filename);
fp->Next = dbuserp->Openlist; fp->Next = dbuserp->Openlist;
dbuserp->Openlist = fp; dbuserp->Openlist = fp;
fp->Count = 1; fp->Count = 1;
......
...@@ -17,6 +17,7 @@ typedef class MAPFAM *PMAPFAM; ...@@ -17,6 +17,7 @@ typedef class MAPFAM *PMAPFAM;
/* This is the variable file access method using file mapping. */ /* This is the variable file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MAPFAM : public TXTFAM { class DllExport MAPFAM : public TXTFAM {
friend class TDBJSON;
public: public:
// Constructor // Constructor
MAPFAM(PDOSDEF tdp); MAPFAM(PDOSDEF tdp);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -289,8 +289,7 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top) ...@@ -289,8 +289,7 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top)
pp->Intval = *(int*)val; pp->Intval = *(int*)val;
break; break;
// case TYPE_STRING: // case TYPE_STRING:
// pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1); // pp->Value = PlugDup(g, (char*)val);
// strcpy((char*)pp->Value, (char*)val);
// break; // break;
case TYPE_PCHAR: case TYPE_PCHAR:
pp->Value = val; pp->Value = val;
...@@ -325,8 +324,7 @@ int TXTFAM::StoreValues(PGLOBAL g, bool upd) ...@@ -325,8 +324,7 @@ int TXTFAM::StoreValues(PGLOBAL g, bool upd)
if (Tdbp->PrepareWriting(g)) if (Tdbp->PrepareWriting(g))
return RC_FX; return RC_FX;
buf = (char*)PlugSubAlloc(g, NULL, strlen(Tdbp->GetLine()) + 1); buf = PlugDup(g, Tdbp->GetLine());
strcpy(buf, Tdbp->GetLine());
rc = AddListValue(g, TYPE_PCHAR, buf, &To_Upd); rc = AddListValue(g, TYPE_PCHAR, buf, &To_Upd);
} // endif upd } // endif upd
......
...@@ -42,6 +42,7 @@ class DllExport TXTFAM : public BLOCK { ...@@ -42,6 +42,7 @@ class DllExport TXTFAM : public BLOCK {
virtual PTXF Duplicate(PGLOBAL g) = 0; virtual PTXF Duplicate(PGLOBAL g) = 0;
virtual bool GetUseTemp(void) {return false;} virtual bool GetUseTemp(void) {return false;}
virtual int GetDelRows(void) {return DelRows;} virtual int GetDelRows(void) {return DelRows;}
PFBLOCK GetTo_Fb(void) {return To_Fb;}
int GetCurBlk(void) {return CurBlk;} int GetCurBlk(void) {return CurBlk;}
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;} void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;}
int GetBlock(void) {return Block;} int GetBlock(void) {return Block;}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -1451,8 +1451,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) ...@@ -1451,8 +1451,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_MAP; fp->Type = TYPE_FB_MAP;
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); fp->Fname = PlugDup(g, filename);
strcpy((char*)fp->Fname, filename);
fp->Next = dbuserp->Openlist; fp->Next = dbuserp->Openlist;
dbuserp->Openlist = fp; dbuserp->Openlist = fp;
fp->Count = 1; fp->Count = 1;
...@@ -2844,8 +2843,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i) ...@@ -2844,8 +2843,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
/*******************************************************************/ /*******************************************************************/
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_MAP; fp->Type = TYPE_FB_MAP;
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); fp->Fname = PlugDup(g, filename);
strcpy((char*)fp->Fname, filename);
fp->Next = dup->Openlist; fp->Next = dup->Openlist;
dup->Openlist = fp; dup->Openlist = fp;
fp->Count = 1; fp->Count = 1;
......
This diff is collapsed.
/* Copyright (C) Olivier Bertrand 2004 - 2014 /* Copyright (C) Olivier Bertrand 2004 - 2015
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
/****************************************************************************/
/* mycat.h contains the TOS, PTOS, ha_table_option_struct declarations. */
/****************************************************************************/
#include "mycat.h"
static char *strz(PGLOBAL g, LEX_STRING &ls); static char *strz(PGLOBAL g, LEX_STRING &ls);
/****************************************************************************/ /****************************************************************************/
...@@ -56,11 +61,7 @@ public: ...@@ -56,11 +61,7 @@ public:
oldopn= newopn= NULL; oldopn= newopn= NULL;
oldpix= newpix= NULL;} oldpix= newpix= NULL;}
inline char *SetName(PGLOBAL g, char *name) { inline char *SetName(PGLOBAL g, char *name) {return PlugDup(g, name);}
char *nm= NULL;
if (name) {nm= (char*)PlugSubAlloc(g, NULL, strlen(name) + 1);
strcpy(nm, name);}
return nm;}
bool oldsep; // Sepindex before create/alter bool oldsep; // Sepindex before create/alter
bool newsep; // Sepindex after create/alter bool newsep; // Sepindex after create/alter
...@@ -72,7 +73,6 @@ public: ...@@ -72,7 +73,6 @@ public:
typedef class XCHK *PCHK; typedef class XCHK *PCHK;
typedef class user_connect *PCONNECT; typedef class user_connect *PCONNECT;
typedef struct ha_table_option_struct TOS, *PTOS;
typedef struct ha_field_option_struct FOS, *PFOS; typedef struct ha_field_option_struct FOS, *PFOS;
typedef struct ha_index_option_struct XOS, *PXOS; typedef struct ha_index_option_struct XOS, *PXOS;
...@@ -84,6 +84,9 @@ extern handlerton *connect_hton; ...@@ -84,6 +84,9 @@ extern handlerton *connect_hton;
These can be specified in the CREATE TABLE: These can be specified in the CREATE TABLE:
CREATE TABLE ( ... ) {...here...} CREATE TABLE ( ... ) {...here...}
*/ */
#if 0 // moved to mycat.h
typedef struct ha_table_option_struct TOS, *PTOS;
struct ha_table_option_struct { struct ha_table_option_struct {
const char *type; const char *type;
const char *filename; const char *filename;
...@@ -115,6 +118,7 @@ struct ha_table_option_struct { ...@@ -115,6 +118,7 @@ struct ha_table_option_struct {
bool readonly; bool readonly;
bool sepindex; bool sepindex;
}; };
#endif // 0
/** /**
structure for CREATE TABLE options (field options) structure for CREATE TABLE options (field options)
...@@ -239,7 +243,7 @@ public: ...@@ -239,7 +243,7 @@ public:
int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf); int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf);
int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL, int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL,
uint key_len= 0); uint key_len= 0);
bool MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q, bool MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL op, char q,
const void *key, int klen); const void *key, int klen);
inline char *Strz(LEX_STRING &ls); inline char *Strz(LEX_STRING &ls);
......
/*************** json CPP Declares Source Code File (.H) ***************/ /*************** json CPP Declares Source Code File (.H) ***************/
/* Name: json.cpp Version 1.0 */ /* Name: json.cpp Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
/* */ /* */
...@@ -1157,6 +1157,6 @@ void JVALUE::SetString(PGLOBAL g, PSZ s) ...@@ -1157,6 +1157,6 @@ void JVALUE::SetString(PGLOBAL g, PSZ s)
/***********************************************************************/ /***********************************************************************/
bool JVALUE::IsNull(void) bool JVALUE::IsNull(void)
{ {
return (Jsp) ? Jsp->IsNull() : (Value) ? Value->IsNull() : true; return (Jsp) ? Jsp->IsNull() : (Value) ? Value->IsZero() : true;
} // end of IsNull } // end of IsNull
/**************** json H Declares Source Code File (.H) ****************/ /**************** json H Declares Source Code File (.H) ****************/
/* Name: json.h Version 1.0 */ /* Name: json.h Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
/* */ /* */
...@@ -123,6 +123,10 @@ class JPAIR : public BLOCK { ...@@ -123,6 +123,10 @@ class JPAIR : public BLOCK {
public: public:
JPAIR(PSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;} JPAIR(PSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;}
inline PSZ GetKey(void) {return Key;}
inline PJVAL GetVal(void) {return Val;}
inline PJPR GetNext(void) {return Next;}
protected: protected:
PSZ Key; // This pair key name PSZ Key; // This pair key name
PJVAL Val; // To the value of the pair PJVAL Val; // To the value of the pair
...@@ -144,11 +148,12 @@ class JSON : public BLOCK { ...@@ -144,11 +148,12 @@ class JSON : public BLOCK {
virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL) {X return NULL;} virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL) {X return NULL;}
virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;} virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;}
virtual PJVAL GetValue(const char *key) {X return NULL;} virtual PJVAL GetValue(const char *key) {X return NULL;}
virtual PJOB GetObject(void) {X return NULL;} virtual PJOB GetObject(void) {return NULL;}
virtual PJAR GetArray(void) {X return NULL;} virtual PJAR GetArray(void) {return NULL;}
virtual PJVAL GetValue(int i) {X return NULL;} virtual PJVAL GetValue(int i) {X return NULL;}
virtual PVAL GetValue(void) {X return NULL;} virtual PVAL GetValue(void) {X return NULL;}
virtual PJSON GetJson(void) {X return NULL;} virtual PJSON GetJson(void) {X return NULL;}
virtual PJPR GetFirst(void) {X return NULL;}
virtual int GetInteger(void) {X return 0;} virtual int GetInteger(void) {X return 0;}
virtual double GetFloat() {X return 0.0;} virtual double GetFloat() {X return 0.0;}
virtual PSZ GetString() {X return NULL;} virtual PSZ GetString() {X return NULL;}
...@@ -180,6 +185,7 @@ class JOBJECT : public JSON { ...@@ -180,6 +185,7 @@ class JOBJECT : public JSON {
using JSON::SetValue; using JSON::SetValue;
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JOB;} virtual JTYP GetType(void) {return TYPE_JOB;}
virtual PJPR GetFirst(void) {return First;}
virtual PJPR AddPair(PGLOBAL g, PSZ key); virtual PJPR AddPair(PGLOBAL g, PSZ key);
virtual PJOB GetObject(void) {return this;} virtual PJOB GetObject(void) {return this;}
virtual PJVAL GetValue(const char* key); virtual PJVAL GetValue(const char* key);
......
/******************************************************************/ /******************************************************************/
/* Implementation of XML document processing using libxml2 */ /* Implementation of XML document processing using libxml2 */
/* Author: Olivier Bertrand 2007-2013 */ /* Author: Olivier Bertrand 2007-2015 */
/******************************************************************/ /******************************************************************/
#include "my_global.h" #include "my_global.h"
#include <string.h> #include <string.h>
...@@ -162,9 +162,11 @@ class XML2ATTR : public XMLATTRIBUTE { ...@@ -162,9 +162,11 @@ class XML2ATTR : public XMLATTRIBUTE {
friend class XML2NODE; friend class XML2NODE;
public: public:
// Properties // Properties
//virtual char *GetText(void); virtual char *GetName(PGLOBAL g) {return (char*)Atrp->name;}
virtual PXATTR GetNext(PGLOBAL g);
// Methods // Methods
virtual RCODE GetText(PGLOBAL g, char *bufp, int len);
virtual bool SetText(PGLOBAL g, char *txtp, int len); virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected: protected:
...@@ -408,8 +410,7 @@ PFBLOCK LIBXMLDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn) ...@@ -408,8 +410,7 @@ PFBLOCK LIBXMLDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
xp->Next = (PX2BLOCK)dup->Openlist; xp->Next = (PX2BLOCK)dup->Openlist;
dup->Openlist = (PFBLOCK)xp; dup->Openlist = (PFBLOCK)xp;
xp->Type = TYPE_FB_XML2; xp->Type = TYPE_FB_XML2;
xp->Fname = (LPCSTR)PlugSubAlloc(g, NULL, strlen(fn) + 1); xp->Fname = (LPCSTR)PlugDup(g, fn);
strcpy((char*)xp->Fname, fn);
xp->Count = 1; xp->Count = 1;
xp->Length = (m == MODE_READ) ? 1 : 0; xp->Length = (m == MODE_READ) ? 1 : 0;
xp->Retcode = rc; xp->Retcode = rc;
...@@ -813,7 +814,7 @@ PXNODE XML2NODE::GetNext(PGLOBAL g) ...@@ -813,7 +814,7 @@ PXNODE XML2NODE::GetNext(PGLOBAL g)
if (!Nodep->next) if (!Nodep->next)
Next = NULL; Next = NULL;
else if (!Next) else // if (!Next)
Next = new(g) XML2NODE(Doc, Nodep->next); Next = new(g) XML2NODE(Doc, Nodep->next);
return Next; return Next;
...@@ -829,7 +830,7 @@ PXNODE XML2NODE::GetChild(PGLOBAL g) ...@@ -829,7 +830,7 @@ PXNODE XML2NODE::GetChild(PGLOBAL g)
if (!Nodep->children) if (!Nodep->children)
Children = NULL; Children = NULL;
else if (!Children) else // if (!Children)
Children = new(g) XML2NODE(Doc, Nodep->children); Children = new(g) XML2NODE(Doc, Nodep->children);
return Children; return Children;
...@@ -979,10 +980,16 @@ PXNODE XML2NODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np) ...@@ -979,10 +980,16 @@ PXNODE XML2NODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np)
/******************************************************************/ /******************************************************************/
PXATTR XML2NODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap) PXATTR XML2NODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap)
{ {
xmlAttrPtr atp;
if (trace) if (trace)
htrc("GetAttribute: %s\n", name); htrc("GetAttribute: %s\n", SVP(name));
if (name)
atp = xmlHasProp(Nodep, BAD_CAST name);
else
atp = Nodep->properties;
xmlAttrPtr atp = xmlHasProp(Nodep, BAD_CAST name);
if (atp) { if (atp) {
if (ap) { if (ap) {
...@@ -1210,6 +1217,52 @@ XML2ATTR::XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np) ...@@ -1210,6 +1217,52 @@ XML2ATTR::XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np)
Parent = np; Parent = np;
} // end of XML2ATTR constructor } // end of XML2ATTR constructor
/******************************************************************/
/* Return the next sibling of the attribute. */
/******************************************************************/
PXATTR XML2ATTR::GetNext(PGLOBAL g)
{
if (trace)
htrc("Attr GetNext\n");
if (!Atrp->next)
return NULL;
else
return new(g) XML2ATTR(Doc, Atrp->next, Atrp->parent);
} // end of GetNext
/******************************************************************/
/* Return the text of an attribute. */
/******************************************************************/
RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len)
{
RCODE rc = RC_OK;
xmlChar *txt;
if (trace)
htrc("GetText\n");
if ((txt = xmlGetProp(Atrp->parent, Atrp->name))) {
// Copy the text to the buffer
if (strlen((char*)txt) >= (unsigned)len) {
memcpy(buf, txt, len - 1);
buf[len - 1] = 0;
sprintf(g->Message, "Truncated %s content", Atrp->name);
rc = RC_INFO;
} else
strcpy(buf, (const char*)txt);
xmlFree(txt);
} else
*buf = '\0';
if (trace)
htrc("GetText: %s\n", buf);
return rc;
} // end of GetText
/******************************************************************/ /******************************************************************/
/* Set the content of an attribute. */ /* Set the content of an attribute. */
/******************************************************************/ /******************************************************************/
......
...@@ -74,13 +74,8 @@ ...@@ -74,13 +74,8 @@
#include "tabxcl.h" #include "tabxcl.h"
#include "tabtbl.h" #include "tabtbl.h"
#include "taboccur.h" #include "taboccur.h"
#if defined(XML_SUPPORT)
#include "tabxml.h"
#endif // XML_SUPPORT
#include "tabmul.h" #include "tabmul.h"
#if defined(MYSQL_SUPPORT)
#include "tabmysql.h" #include "tabmysql.h"
#endif // MYSQL_SUPPORT
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
#define NODBC #define NODBC
#include "tabodbc.h" #include "tabodbc.h"
...@@ -91,7 +86,9 @@ ...@@ -91,7 +86,9 @@
#include "tabvir.h" #include "tabvir.h"
#include "tabjson.h" #include "tabjson.h"
#include "ha_connect.h" #include "ha_connect.h"
#include "mycat.h" #if defined(XML_SUPPORT)
#include "tabxml.h"
#endif // XML_SUPPORT
/***********************************************************************/ /***********************************************************************/
/* Extern static variables. */ /* Extern static variables. */
...@@ -122,10 +119,8 @@ TABTYPE GetTypeID(const char *type) ...@@ -122,10 +119,8 @@ TABTYPE GetTypeID(const char *type)
#ifdef ODBC_SUPPORT #ifdef ODBC_SUPPORT
: (!stricmp(type, "ODBC")) ? TAB_ODBC : (!stricmp(type, "ODBC")) ? TAB_ODBC
#endif #endif
#ifdef MYSQL_SUPPORT
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYSQL")) ? TAB_MYSQL
: (!stricmp(type, "MYPRX")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL
#endif
: (!stricmp(type, "DIR")) ? TAB_DIR : (!stricmp(type, "DIR")) ? TAB_DIR
#ifdef WIN32 #ifdef WIN32
: (!stricmp(type, "MAC")) ? TAB_MAC : (!stricmp(type, "MAC")) ? TAB_MAC
...@@ -537,9 +532,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) ...@@ -537,9 +532,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
case TAB_XCL: tdp= new(g) XCLDEF; break; case TAB_XCL: tdp= new(g) XCLDEF; break;
case TAB_PRX: tdp= new(g) PRXDEF; break; case TAB_PRX: tdp= new(g) PRXDEF; break;
case TAB_OCCUR: tdp= new(g) OCCURDEF; break; case TAB_OCCUR: tdp= new(g) OCCURDEF; break;
#if defined(MYSQL_SUPPORT)
case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; case TAB_MYSQL: tdp= new(g) MYSQLDEF; break;
#endif // MYSQL_SUPPORT
#if defined(PIVOT_SUPPORT) #if defined(PIVOT_SUPPORT)
case TAB_PIVOT: tdp= new(g) PIVOTDEF; break; case TAB_PIVOT: tdp= new(g) PIVOTDEF; break;
#endif // PIVOT_SUPPORT #endif // PIVOT_SUPPORT
......
...@@ -24,6 +24,46 @@ ...@@ -24,6 +24,46 @@
#include "block.h" #include "block.h"
#include "catalog.h" #include "catalog.h"
typedef struct ha_table_option_struct TOS, *PTOS;
/**
structure for CREATE TABLE options (table options)
These can be specified in the CREATE TABLE:
CREATE TABLE ( ... ) {...here...}
*/
struct ha_table_option_struct {
const char *type;
const char *filename;
const char *optname;
const char *tabname;
const char *tablist;
const char *dbname;
const char *separator;
//const char *connect;
const char *qchar;
const char *module;
const char *subtype;
const char *catfunc;
const char *srcdef;
const char *colist;
const char *oplist;
const char *data_charset;
ulonglong lrecl;
ulonglong elements;
//ulonglong estimate;
ulonglong multiple;
ulonglong header;
ulonglong quoted;
ulonglong ending;
ulonglong compressed;
bool mapped;
bool huge;
bool split;
bool readonly;
bool sepindex;
};
// Possible value for catalog functions // Possible value for catalog functions
#define FNC_NO (1 << 0) // Not a catalog table #define FNC_NO (1 << 0) // Not a catalog table
#define FNC_COL (1 << 1) // Column catalog function #define FNC_COL (1 << 1) // Column catalog function
......
...@@ -15,7 +15,7 @@ DATEPUB int(4) ...@@ -15,7 +15,7 @@ DATEPUB int(4)
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json'; ) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
SELECT * FROM t1; SELECT * FROM t1;
ISBN LANG SUBJECT AUTHOR TITLE TRANSLATION TRANSLATOR PUBLISHER DATEPUB ISBN LANG SUBJECT AUTHOR TITLE TRANSLATION TRANSLATOR PUBLISHER DATEPUB
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999 9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999
DROP TABLE t1; DROP TABLE t1;
# #
...@@ -37,7 +37,7 @@ Year int(4) FIELD_FORMAT='DATEPUB' ...@@ -37,7 +37,7 @@ Year int(4) FIELD_FORMAT='DATEPUB'
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json'; ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
SELECT * FROM t1; SELECT * FROM t1;
ISBN Language Subject Authors Title Translation Translator Publisher Location Year ISBN Language Subject Authors Title Translation Translator Publisher Location Year
9782212090819 fr applications 2 Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications 2 Construire une application XML NULL NULL Eyrolles Paris 1999
9782840825685 fr applications 1 XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999 9782840825685 fr applications 1 XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999
DROP TABLE t1; DROP TABLE t1;
# #
...@@ -60,7 +60,7 @@ Year int(4) FIELD_FORMAT='DATEPUB' ...@@ -60,7 +60,7 @@ Year int(4) FIELD_FORMAT='DATEPUB'
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json'; ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
SELECT * FROM t1; SELECT * FROM t1;
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
9782212090819 fr applications Jean-Christophe and Franois Bernadac and Knab Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Jean-Christophe and Franois Bernadac and Knab Construire une application XML NULL NULL Eyrolles Paris 1999
9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999 9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999
DROP TABLE t1; DROP TABLE t1;
# #
...@@ -83,14 +83,14 @@ Year int(4) FIELD_FORMAT='DATEPUB' ...@@ -83,14 +83,14 @@ Year int(4) FIELD_FORMAT='DATEPUB'
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json'; ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
SELECT * FROM t1; SELECT * FROM t1;
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Franois Knab Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Franois Knab Construire une application XML NULL NULL Eyrolles Paris 1999
9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999 9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999
UPDATE t1 SET AuthorFN = 'Philippe' WHERE AuthorLN = 'Knab'; UPDATE t1 SET AuthorFN = 'Philippe' WHERE AuthorLN = 'Knab';
SELECT * FROM t1 WHERE ISBN = '9782212090819'; SELECT * FROM t1 WHERE ISBN = '9782212090819';
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
9782212090819 fr applications Philippe Bernadac Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Philippe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Franois Knab Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Franois Knab Construire une application XML NULL NULL Eyrolles Paris 1999
# #
# To add an author a new table must be created # To add an author a new table must be created
# #
...@@ -104,8 +104,8 @@ William J. Pardi ...@@ -104,8 +104,8 @@ William J. Pardi
INSERT INTO t2 VALUES('Charles','Dickens'); INSERT INTO t2 VALUES('Charles','Dickens');
SELECT * FROM t1; SELECT * FROM t1;
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
9782212090819 fr applications Philippe Bernadac Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Philippe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Franois Knab Construire une application XML Eyrolles Paris 1999 9782212090819 fr applications Franois Knab Construire une application XML NULL NULL Eyrolles Paris 1999
9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999 9782840825685 fr applications William J. Pardi XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999
9782840825685 fr applications Charles Dickens XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999 9782840825685 fr applications Charles Dickens XML en Action adapt de l'anglais par James Guerin Microsoft Press Paris 1999
DROP TABLE t1; DROP TABLE t1;
......
/************ Odbconn C++ Functions Source Code File (.CPP) ************/ /************ Odbconn C++ Functions Source Code File (.CPP) ************/
/* Name: ODBCONN.CPP Version 2.1 */ /* Name: ODBCONN.CPP Version 2.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */ /* */
...@@ -867,8 +867,7 @@ bool DBX::BuildErrorMessage(ODBConn* pdb, HSTMT hstmt) ...@@ -867,8 +867,7 @@ bool DBX::BuildErrorMessage(ODBConn* pdb, HSTMT hstmt)
for (int i = 0; i < MAX_NUM_OF_MSG for (int i = 0; i < MAX_NUM_OF_MSG
&& (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) && (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
&& strcmp((char*)state, "00000"); i++) { && strcmp((char*)state, "00000"); i++) {
m_ErrMsg[i] = (PSZ)PlugSubAlloc(g, NULL, strlen((char*)msg) + 1); m_ErrMsg[i] = (PSZ)PlugDup(g, (char*)msg);
strcpy(m_ErrMsg[i], (char*)msg);
if (trace) if (trace)
htrc("%s: %s, Native=%d\n", state, msg, native); htrc("%s: %s, Native=%d\n", state, msg, native);
...@@ -882,8 +881,7 @@ bool DBX::BuildErrorMessage(ODBConn* pdb, HSTMT hstmt) ...@@ -882,8 +881,7 @@ bool DBX::BuildErrorMessage(ODBConn* pdb, HSTMT hstmt)
} else { } else {
snprintf((char*)msg, SQL_MAX_MESSAGE_LENGTH + 1, "%s: %s", m_Msg, snprintf((char*)msg, SQL_MAX_MESSAGE_LENGTH + 1, "%s: %s", m_Msg,
MSG(BAD_HANDLE_VAL)); MSG(BAD_HANDLE_VAL));
m_ErrMsg[0] = (PSZ)PlugSubAlloc(g, NULL, strlen((char*)msg) + 1); m_ErrMsg[0] = (PSZ)PlugDup(g, (char*)msg);
strcpy(m_ErrMsg[0], (char*)msg);
if (trace) if (trace)
htrc("%s: rc=%hd\n", SVP(m_ErrMsg[0]), m_RC); htrc("%s: rc=%hd\n", SVP(m_ErrMsg[0]), m_RC);
...@@ -1012,8 +1010,7 @@ PSZ ODBConn::GetStringInfo(ushort infotype) ...@@ -1012,8 +1010,7 @@ PSZ ODBConn::GetStringInfo(ushort infotype)
// *buffer = '\0'; // *buffer = '\0';
} // endif rc } // endif rc
p = (char *)PlugSubAlloc(m_G, NULL, strlen(buffer) + 1); p = PlugDup(m_G, buffer);
strcpy(p, buffer);
return p; return p;
} // end of GetStringInfo } // end of GetStringInfo
......
/************** PlgDBSem H Declares Source Code File (.H) **************/ /************** PlgDBSem H Declares Source Code File (.H) **************/
/* Name: PLGDBSEM.H Version 3.6 */ /* Name: PLGDBSEM.H Version 3.6 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */ /* */
/* This file contains the PlugDB++ application type definitions. */ /* This file contains the PlugDB++ application type definitions. */
/***********************************************************************/ /***********************************************************************/
...@@ -504,9 +504,10 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */ ...@@ -504,9 +504,10 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */
FLD_EXTRA = 13, /* Field extra info */ FLD_EXTRA = 13, /* Field extra info */
FLD_PRIV = 14, /* Field priviledges */ FLD_PRIV = 14, /* Field priviledges */
FLD_DATEFMT = 15, /* Field date format */ FLD_DATEFMT = 15, /* Field date format */
FLD_CAT = 16, /* Table catalog */ FLD_FORMAT = 16, /* Field format */
FLD_SCHEM = 17, /* Table schema */ FLD_CAT = 17, /* Table catalog */
FLD_TABNAME = 18}; /* Column Table name */ FLD_SCHEM = 18, /* Table schema */
FLD_TABNAME = 19}; /* Column Table name */
/***********************************************************************/ /***********************************************************************/
/* Result of last SQL noconv query. */ /* Result of last SQL noconv query. */
...@@ -584,6 +585,7 @@ DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true); ...@@ -584,6 +585,7 @@ DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true);
DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int); DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int);
DllExport void PlgDBfree(MBLOCK&); DllExport void PlgDBfree(MBLOCK&);
DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size); DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size);
DllExport char *PlgDBDup(PGLOBAL g, const char *str);
DllExport void *PlgDBalloc(PGLOBAL, void *, MBLOCK&); DllExport void *PlgDBalloc(PGLOBAL, void *, MBLOCK&);
DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t); DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t);
DllExport void NewPointer(PTABS, void *, void *); DllExport void NewPointer(PTABS, void *, void *);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -294,8 +294,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, ...@@ -294,8 +294,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
#else // !XMSG #else // !XMSG
GetRcString(ids + crp->Ncol, cname, sizeof(cname)); GetRcString(ids + crp->Ncol, cname, sizeof(cname));
#endif // !XMSG #endif // !XMSG
crp->Name = (PSZ)PlugSubAlloc(g, NULL, strlen(cname) + 1); crp->Name = (PSZ)PlugDup(g, cname);
strcpy(crp->Name, cname);
} else } else
crp->Name = NULL; // Will be set by caller crp->Name = NULL; // Will be set by caller
...@@ -853,8 +852,7 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype) ...@@ -853,8 +852,7 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype)
htrc(" fp=%p\n", fp); htrc(" fp=%p\n", fp);
// fname may be in volatile memory such as stack // fname may be in volatile memory such as stack
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(fname) + 1); fp->Fname = PlugDup(g, fname);
strcpy((char*)fp->Fname, fname);
fp->Count = 1; fp->Count = 1;
fp->Type = TYPE_FB_FILE; fp->Type = TYPE_FB_FILE;
fp->File = fop; fp->File = fop;
...@@ -1400,6 +1398,23 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) ...@@ -1400,6 +1398,23 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
return (memp); return (memp);
} // end of PlgDBSubAlloc } // end of PlgDBSubAlloc
/***********************************************************************/
/* Program for sub-allocating and copying a string in a storage area. */
/***********************************************************************/
char *PlgDBDup(PGLOBAL g, const char *str)
{
if (str) {
char *sm = (char*)PlgDBSubAlloc(g, NULL, strlen(str) + 1);
if (sm)
strcpy(sm, str);
return sm;
} else
return NULL;
} // end of PlgDBDup
/***********************************************************************/ /***********************************************************************/
/* PUTOUT: Plug DB object typing routine. */ /* PUTOUT: Plug DB object typing routine. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -109,6 +109,7 @@ class XMLNODE : public BLOCK { ...@@ -109,6 +109,7 @@ class XMLNODE : public BLOCK {
virtual int GetType(void) = 0; virtual int GetType(void) = 0;
virtual PXNODE GetNext(PGLOBAL) = 0; virtual PXNODE GetNext(PGLOBAL) = 0;
virtual PXNODE GetChild(PGLOBAL) = 0; virtual PXNODE GetChild(PGLOBAL) = 0;
virtual int GetLen(void) {return Len;}
// Methods // Methods
virtual RCODE GetContent(PGLOBAL, char *, int) = 0; virtual RCODE GetContent(PGLOBAL, char *, int) = 0;
...@@ -163,9 +164,11 @@ class XMLNODELIST : public BLOCK { ...@@ -163,9 +164,11 @@ class XMLNODELIST : public BLOCK {
class XMLATTRIBUTE : public BLOCK { class XMLATTRIBUTE : public BLOCK {
public: public:
// Properties // Properties
//virtual char *GetText(void) = 0; virtual char *GetName(PGLOBAL) = 0;
virtual PXATTR GetNext(PGLOBAL) = 0;
// Methods // Methods
virtual RCODE GetText(PGLOBAL, char *, int) = 0;
virtual bool SetText(PGLOBAL, char *, int) = 0; virtual bool SetText(PGLOBAL, char *, int) = 0;
protected: protected:
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1993-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1993-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -228,7 +228,6 @@ BOOL PlugIsAbsolutePath(LPCSTR path) ...@@ -228,7 +228,6 @@ BOOL PlugIsAbsolutePath(LPCSTR path)
#endif #endif
} }
/***********************************************************************/ /***********************************************************************/
/* Set the full path of a file relatively to a given path. */ /* Set the full path of a file relatively to a given path. */
/* Note: this routine is not really implemented for Unix. */ /* Note: this routine is not really implemented for Unix. */
...@@ -385,8 +384,7 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m) ...@@ -385,8 +384,7 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m)
err: err:
if (g) { if (g) {
// Called by STEP // Called by STEP
msg = (char *)PlugSubAlloc(g, NULL, strlen(stmsg) + 1); msg = PlugDup(g, stmsg);
strcpy(msg, stmsg);
} else // Called by MSG or PlgGetErrorMsg } else // Called by MSG or PlgGetErrorMsg
msg = stmsg; msg = stmsg;
...@@ -421,8 +419,7 @@ char *PlugGetMessage(PGLOBAL g, int mid) ...@@ -421,8 +419,7 @@ char *PlugGetMessage(PGLOBAL g, int mid)
if (g) { if (g) {
// Called by STEP // Called by STEP
msg = (char *)PlugSubAlloc(g, NULL, strlen(stmsg) + 1); msg = PlugDup(g, stmsg);
strcpy(msg, stmsg);
} else // Called by MSG or PlgGetErrorMsg } else // Called by MSG or PlgGetErrorMsg
msg = stmsg; msg = stmsg;
...@@ -536,6 +533,22 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) ...@@ -536,6 +533,22 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
return (memp); return (memp);
} /* end of PlugSubAlloc */ } /* end of PlugSubAlloc */
/***********************************************************************/
/* Program for sub-allocating and copying a string in a storage area. */
/***********************************************************************/
char *PlugDup(PGLOBAL g, const char *str)
{
if (str) {
char *sm = (char*)PlugSubAlloc(g, NULL, strlen(str) + 1);
strcpy(sm, str);
return sm;
} else
return NULL;
} // end of PlugDup
#if 0
/***********************************************************************/ /***********************************************************************/
/* This routine suballocate a copy of the passed string. */ /* This routine suballocate a copy of the passed string. */
/***********************************************************************/ /***********************************************************************/
...@@ -552,6 +565,7 @@ char *PlugDup(PGLOBAL g, const char *str) ...@@ -552,6 +565,7 @@ char *PlugDup(PGLOBAL g, const char *str)
return(buf); return(buf);
} /* end of PlugDup */ } /* end of PlugDup */
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* This routine makes a pointer from an offset to a memory pointer. */ /* This routine makes a pointer from an offset to a memory pointer. */
......
/************* RelDef CPP Program Source Code File (.CPP) **************/ /************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: REFDEF */ /* PROGRAM NAME: RELDEF */
/* ------------- */ /* ------------- */
/* Version 1.4 */ /* Version 1.4 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
/***********************************************************************/ /***********************************************************************/
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "mycat.h"
#include "reldef.h" #include "reldef.h"
#include "colblk.h" #include "colblk.h"
#include "filamap.h" #include "filamap.h"
...@@ -73,6 +72,14 @@ RELDEF::RELDEF(void) ...@@ -73,6 +72,14 @@ RELDEF::RELDEF(void)
Hc = NULL; Hc = NULL;
} // end of RELDEF constructor } // end of RELDEF constructor
/***********************************************************************/
/* This function return a pointer to the Table Option Struct. */
/***********************************************************************/
PTOS RELDEF::GetTopt(void)
{
return Hc->GetTableOptionStruct();
} // end of GetTopt
/***********************************************************************/ /***********************************************************************/
/* This function sets an integer table information. */ /* This function sets an integer table information. */
/***********************************************************************/ /***********************************************************************/
...@@ -153,10 +160,9 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) ...@@ -153,10 +160,9 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
if (s) { if (s) {
if (!Hc->IsPartitioned() || if (!Hc->IsPartitioned() ||
(stricmp(what, "filename") && stricmp(what, "tabname") (stricmp(what, "filename") && stricmp(what, "tabname")
&& stricmp(what, "connect"))) { && stricmp(what, "connect")))
sval= (char*)PlugSubAlloc(g, NULL, strlen(s) + 1); sval= PlugDup(g, s);
strcpy(sval, s); else
} else
sval= s; sval= s;
} else if (!stricmp(what, "filename")) { } else if (!stricmp(what, "filename")) {
...@@ -213,8 +219,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) ...@@ -213,8 +219,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
{ {
int poff = 0; int poff = 0;
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); Name = (PSZ)PlugDup(g, name);
strcpy(Name, name);
Cat = cat; Cat = cat;
Hc = ((MYCAT*)cat)->GetHandler(); Hc = ((MYCAT*)cat)->GetHandler();
Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL)); Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL));
...@@ -712,8 +717,7 @@ COLDEF::COLDEF(void) : COLCRT() ...@@ -712,8 +717,7 @@ COLDEF::COLDEF(void) : COLCRT()
/***********************************************************************/ /***********************************************************************/
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
{ {
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1); Name = (PSZ)PlugDup(g, cfp->Name);
strcpy(Name, cfp->Name);
if (!(cfp->Flags & U_SPECIAL)) { if (!(cfp->Flags & U_SPECIAL)) {
Poff = poff; Poff = poff;
...@@ -735,22 +739,16 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) ...@@ -735,22 +739,16 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
Key = cfp->Key; Key = cfp->Key;
Freq = cfp->Freq; Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) { if (cfp->Remark && *cfp->Remark)
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1); Desc = (PSZ)PlugDup(g, cfp->Remark);
strcpy(Desc, cfp->Remark);
} // endif Remark
if (cfp->Datefmt) { if (cfp->Datefmt)
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1); Decode = (PSZ)PlugDup(g, cfp->Datefmt);
strcpy(Decode, cfp->Datefmt);
} // endif Datefmt
} // endif special } // endif special
if (cfp->Fieldfmt) { if (cfp->Fieldfmt)
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1); Fmt = (PSZ)PlugDup(g, cfp->Fieldfmt);
strcpy(Fmt, cfp->Fieldfmt);
} // endif Fieldfmt
Flags = cfp->Flags; Flags = cfp->Flags;
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long; return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "block.h" #include "block.h"
#include "catalog.h" #include "catalog.h"
#include "my_sys.h" #include "my_sys.h"
#include "mycat.h"
typedef class INDEXDEF *PIXDEF; typedef class INDEXDEF *PIXDEF;
typedef class ha_connect *PHC; typedef class ha_connect *PHC;
...@@ -40,6 +41,7 @@ class DllExport RELDEF : public BLOCK { // Relation definition block ...@@ -40,6 +41,7 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
void SetCat(PCATLG cat) { Cat=cat; } void SetCat(PCATLG cat) { Cat=cat; }
// Methods // Methods
PTOS GetTopt(void);
bool GetBoolCatInfo(PSZ what, bool bdef); bool GetBoolCatInfo(PSZ what, bool bdef);
bool SetIntCatInfo(PSZ what, int ival); bool SetIntCatInfo(PSZ what, int ival);
bool Partitioned(void); bool Partitioned(void);
......
This diff is collapsed.
/*************** tabjson H Declares Source Code File (.H) **************/ /*************** tabjson H Declares Source Code File (.H) **************/
/* Name: tabjson.h Version 1.0 */ /* Name: tabjson.h Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
/* */ /* */
...@@ -34,6 +34,9 @@ typedef struct _jnode { ...@@ -34,6 +34,9 @@ typedef struct _jnode {
class JSONDEF : public DOSDEF { /* Table description */ class JSONDEF : public DOSDEF { /* Table description */
friend class TDBJSON; friend class TDBJSON;
friend class TDBJSN; friend class TDBJSN;
friend class TDBJCL;
friend PQRYRES JSONColumns(PGLOBAL, char *, const char *, char *,
int, int, int, bool);
public: public:
// Constructor // Constructor
JSONDEF(void); JSONDEF(void);
...@@ -52,6 +55,7 @@ class JSONDEF : public DOSDEF { /* Table description */ ...@@ -52,6 +55,7 @@ class JSONDEF : public DOSDEF { /* Table description */
char *Xcol; /* Name of expandable column */ char *Xcol; /* Name of expandable column */
int Limit; /* Limit of multiple values */ int Limit; /* Limit of multiple values */
int Pretty; /* Depends on file structure */ int Pretty; /* Depends on file structure */
int Level; /* Used for catalog table */
bool Strict; /* Strict syntax checking */ bool Strict; /* Strict syntax checking */
}; // end of JSONDEF }; // end of JSONDEF
...@@ -72,6 +76,7 @@ class TDBJSN : public TDBDOS { ...@@ -72,6 +76,7 @@ class TDBJSN : public TDBDOS {
virtual AMT GetAmType(void) {return TYPE_AM_JSN;} virtual AMT GetAmType(void) {return TYPE_AM_JSN;}
virtual bool SkipHeader(PGLOBAL g); virtual bool SkipHeader(PGLOBAL g);
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);}
PJSON GetRow(void) {return Row;}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
...@@ -88,10 +93,16 @@ class TDBJSN : public TDBDOS { ...@@ -88,10 +93,16 @@ class TDBJSN : public TDBDOS {
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
protected: protected:
PJSON FindRow(PGLOBAL g);
int MakeTopTree(PGLOBAL g, PJSON jsp);
// Members // Members
PJSON Top; // The top JSON tree
PJSON Row; // The current row PJSON Row; // The current row
PJSON Val; // The value of the current row
PJCOL Colp; // The multiple column PJCOL Colp; // The multiple column
JMODE Jmode; // MODE_OBJECT by default JMODE Jmode; // MODE_OBJECT by default
char *Objname; // The table object name
char *Xcol; // Name of expandable column char *Xcol; // Name of expandable column
int Fpos; // The current row index int Fpos; // The current row index
//int Spos; // DELETE start index //int Spos; // DELETE start index
...@@ -166,6 +177,7 @@ class TDBJSON : public TDBJSN { ...@@ -166,6 +177,7 @@ class TDBJSON : public TDBJSN {
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_JSON;} virtual AMT GetAmType(void) {return TYPE_AM_JSON;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSON(this);} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSON(this);}
PJAR GetDoc(void) {return Doc;}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
...@@ -183,19 +195,39 @@ class TDBJSON : public TDBJSN { ...@@ -183,19 +195,39 @@ class TDBJSON : public TDBJSN {
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
int MakeDocument(PGLOBAL g);
// Optimization routines // Optimization routines
virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
protected: protected:
int MakeNewDoc(PGLOBAL g); int MakeNewDoc(PGLOBAL g);
int MakeDocument(PGLOBAL g);
// Members // Members
PJSON Top; // The file JSON tree
PJAR Doc; // The document array PJAR Doc; // The document array
char *Objname; // The table object name
int Multiple; // 0: No 1: DIR 2: Section 3: filelist int Multiple; // 0: No 1: DIR 2: Section 3: filelist
bool Done; // True when document parsing is done bool Done; // True when document parsing is done
bool Changed; // After Update, Insert or Delete bool Changed; // After Update, Insert or Delete
}; // end of class TDBJSON }; // end of class TDBJSON
/***********************************************************************/
/* This is the class declaration for the JSON catalog table. */
/***********************************************************************/
class TDBJCL : public TDBCAT {
public:
// Constructor
TDBJCL(PJDEF tdp);
protected:
// Specific routines
virtual PQRYRES GetResult(PGLOBAL g);
// Members
//char *Dp;
const char *Fn;
char *Objn;
int Pretty;
int Lrecl;
int lvl;
}; // end of class TDBJCL
...@@ -587,6 +587,10 @@ CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n) ...@@ -587,6 +587,10 @@ CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n)
void CATCOL::ReadColumn(PGLOBAL g) void CATCOL::ReadColumn(PGLOBAL g)
{ {
// Get the value of the Name or Description property // Get the value of the Name or Description property
if (Crp->Kdata)
Value->SetValue_pvblk(Crp->Kdata, Tdbp->N); Value->SetValue_pvblk(Crp->Kdata, Tdbp->N);
else
Value->Reset();
} // end of ReadColumn } // end of ReadColumn
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to PlugDB Software Development 2003 - 2012 */ /* (C) Copyright to PlugDB Software Development 2003 - 2015 */
/* Author: Olivier BERTRAND */ /* Author: Olivier BERTRAND */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
...@@ -172,8 +172,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) ...@@ -172,8 +172,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
while (n < PFNZ) { while (n < PFNZ) {
strcat(strcat(strcpy(filename, drive), direc), FileData.cFileName); strcat(strcat(strcpy(filename, drive), direc), FileData.cFileName);
pfn[n] = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); pfn[n++] = PlugDup(g, filename);
strcpy(pfn[n++], filename);
if (!FindNextFile(hSearch, &FileData)) { if (!FindNextFile(hSearch, &FileData)) {
rc = GetLastError(); rc = GetLastError();
...@@ -239,8 +238,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) ...@@ -239,8 +238,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
continue; // Not a match continue; // Not a match
strcat(strcpy(filename, direc), entry->d_name); strcat(strcpy(filename, direc), entry->d_name);
pfn[n] = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); pfn[n++] = PlugDup(g, filename);
strcpy(pfn[n++], filename);
if (trace) if (trace)
htrc("Adding pfn[%d] %s\n", n, filename); htrc("Adding pfn[%d] %s\n", n, filename);
...@@ -292,8 +290,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) ...@@ -292,8 +290,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
*(++p) = '\0'; *(++p) = '\0';
// Suballocate the file name // Suballocate the file name
pfn[n] = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); pfn[n++] = PlugDup(g, filename);
strcpy(pfn[n++], filename);
} // endfor n } // endfor n
} // endif Mul } // endif Mul
......
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
#include "xtable.h" #include "xtable.h"
#include "tabcol.h" #include "tabcol.h"
#include "colblk.h" #include "colblk.h"
#include "mycat.h"
#include "reldef.h" #include "reldef.h"
#include "tabmysql.h" #include "tabmysql.h"
#include "valblk.h" #include "valblk.h"
...@@ -1078,8 +1077,7 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const void *key, int len) ...@@ -1078,8 +1077,7 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const void *key, int len)
if (Myc.m_Res) if (Myc.m_Res)
Myc.FreeResult(); Myc.FreeResult();
To_Def->GetHandler()->MakeKeyWhere(g, Query->GetStr(), To_Def->GetHandler()->MakeKeyWhere(g, Query, op, '`', key, len);
op, "`", key, len);
if (To_CondFil) { if (To_CondFil) {
oom = Query->Append(" AND ("); oom = Query->Append(" AND (");
......
/************ TabOccur CPP Declares Source Code File (.CPP) ************/ /************ TabOccur CPP Declares Source Code File (.CPP) ************/
/* Name: TABOCCUR.CPP Version 1.1 */ /* Name: TABOCCUR.CPP Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2013 */ /* (C) Copyright to the author Olivier BERTRAND 2013 - 2015 */
/* */ /* */
/* OCCUR: Table that provides a view of a source table where the */ /* OCCUR: Table that provides a view of a source table where the */
/* contain of several columns of the source table is placed in only */ /* contain of several columns of the source table is placed in only */
...@@ -45,11 +45,8 @@ ...@@ -45,11 +45,8 @@
#include "tabcol.h" #include "tabcol.h"
#include "taboccur.h" #include "taboccur.h"
#include "xtable.h" #include "xtable.h"
#if defined(MYSQL_SUPPORT)
#include "tabmysql.h" #include "tabmysql.h"
#endif // MYSQL_SUPPORT
#include "ha_connect.h" #include "ha_connect.h"
#include "mycat.h"
/***********************************************************************/ /***********************************************************************/
/* Prepare and count columns in the column list. */ /* Prepare and count columns in the column list. */
...@@ -93,8 +90,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col, ...@@ -93,8 +90,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
} // endif col } // endif col
// Prepare the column list // Prepare the column list
colist = (char*)PlugSubAlloc(g, NULL, strlen(col) + 1); colist = PlugDup(g, col);
strcpy(colist, col);
m = PrepareColist(colist); m = PrepareColist(colist);
if ((rk = (rank && *rank))) { if ((rk = (rank && *rank))) {
...@@ -191,8 +187,7 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col, ...@@ -191,8 +187,7 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
} // endif col } // endif col
// Prepare the column list // Prepare the column list
colist = (char*)PlugSubAlloc(g, NULL, strlen(col) + 1); colist = PlugDup(g, col);
strcpy(colist, col);
m = PrepareColist(colist); m = PrepareColist(colist);
if ((rk = (rank && *rank))) if ((rk = (rank && *rank)))
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#include "tabpivot.h" #include "tabpivot.h"
#include "valblk.h" #include "valblk.h"
#include "ha_connect.h" #include "ha_connect.h"
#include "mycat.h" // For GetHandler
/***********************************************************************/ /***********************************************************************/
/* Make the Pivot table column list. */ /* Make the Pivot table column list. */
...@@ -150,11 +149,18 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -150,11 +149,18 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
query = Tabsrc; query = Tabsrc;
// Open a MySQL connection for this table // Open a MySQL connection for this table
if (Myc.Open(g, Host, Database, User, Pwd, Port)) if (!Myc.Open(g, Host, Database, User, Pwd, Port)) {
return NULL;
else
b = true; b = true;
// Returned values must be in their original character set
if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
goto err;
else
Myc.FreeResult();
} else
return NULL;
// Send the source command to MySQL // Send the source command to MySQL
if (Myc.ExecSQL(g, query, &w) == RC_FX) if (Myc.ExecSQL(g, query, &w) == RC_FX)
goto err; goto err;
...@@ -241,6 +247,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -241,6 +247,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} else { } else {
// The query was limited, we must get pivot column values // The query was limited, we must get pivot column values
// Returned values must be in their original character set
// if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
// goto err;
query = (char*)PlugSubAlloc(g, NULL, 0); query = (char*)PlugSubAlloc(g, NULL, 0);
sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname); sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname);
PlugSubAlloc(g, NULL, strlen(query) + 1); PlugSubAlloc(g, NULL, strlen(query) + 1);
...@@ -284,8 +294,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -284,8 +294,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
valp->SetValue_pvblk(Rblkp, i); valp->SetValue_pvblk(Rblkp, i);
colname = valp->GetCharString(buf); colname = valp->GetCharString(buf);
crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1); crp->Name = PlugDup(g, colname);
strcpy(crp->Name, colname);
crp->Flag = 1; crp->Flag = 1;
// Add this column // Add this column
......
...@@ -70,11 +70,8 @@ ...@@ -70,11 +70,8 @@
#include "tabcol.h" #include "tabcol.h"
#include "tabdos.h" // TDBDOS and DOSCOL class dcls #include "tabdos.h" // TDBDOS and DOSCOL class dcls
#include "tabtbl.h" #include "tabtbl.h"
#if defined(MYSQL_SUPPORT)
#include "tabmysql.h" #include "tabmysql.h"
#endif // MYSQL_SUPPORT
#include "ha_connect.h" #include "ha_connect.h"
#include "mycat.h" // For GetHandler
#if defined(WIN32) #if defined(WIN32)
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
......
...@@ -43,14 +43,11 @@ ...@@ -43,14 +43,11 @@
#include "plgdbsem.h" #include "plgdbsem.h"
#include "plgcnx.h" // For DB types #include "plgcnx.h" // For DB types
#include "myutil.h" #include "myutil.h"
#include "mycat.h"
#include "valblk.h" #include "valblk.h"
#include "resource.h" #include "resource.h"
#include "reldef.h" #include "reldef.h"
#include "xtable.h" #include "xtable.h"
#if defined(MYSQL_SUPPORT)
#include "tabmysql.h" #include "tabmysql.h"
#endif // MYSQL_SUPPORT
#include "tabcol.h" #include "tabcol.h"
#include "tabutil.h" #include "tabutil.h"
#include "ha_connect.h" #include "ha_connect.h"
...@@ -94,19 +91,13 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, ...@@ -94,19 +91,13 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
if (!open_table_def(thd, s, GTS_TABLE | GTS_VIEW)) { if (!open_table_def(thd, s, GTS_TABLE | GTS_VIEW)) {
if (!s->is_view) { if (!s->is_view) {
if (stricmp(plugin_name(s->db_plugin)->str, "connect")) { if (stricmp(plugin_name(s->db_plugin)->str, "connect"))
#if defined(MYSQL_SUPPORT)
mysql = true; mysql = true;
#else // !MYSQL_SUPPORT else
sprintf(g->Message, "%s.%s is not a CONNECT table", db, name);
return NULL;
#endif // MYSQL_SUPPORT
} else
mysql = false; mysql = false;
} else { } else
mysql = true; mysql = true;
} // endif is_view
} else { } else {
if (thd->is_error()) if (thd->is_error())
...@@ -428,7 +419,6 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) ...@@ -428,7 +419,6 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
} // endif srcdef } // endif srcdef
if (mysql) { if (mysql) {
#if defined(MYSQL_SUPPORT)
// Access sub-table via MySQL API // Access sub-table via MySQL API
if (!(tdbp= cat->GetTable(g, tabp, Mode, "MYPRX"))) { if (!(tdbp= cat->GetTable(g, tabp, Mode, "MYPRX"))) {
char buf[MAX_STR]; char buf[MAX_STR];
...@@ -445,11 +435,6 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) ...@@ -445,11 +435,6 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
if (Mode == MODE_UPDATE || Mode == MODE_DELETE) if (Mode == MODE_UPDATE || Mode == MODE_DELETE)
tdbp->SetName(Name); // For Make_Command tdbp->SetName(Name); // For Make_Command
#else // !MYSQL_SUPPORT
sprintf(g->Message, "%s.%s is not a CONNECT table",
db, tblp->Name);
goto err;
#endif // MYSQL_SUPPORT
} else { } else {
// Sub-table is a CONNECT table // Sub-table is a CONNECT table
tabp->Next = To_Table; // For loop checking tabp->Next = To_Table; // For loop checking
......
...@@ -51,11 +51,8 @@ ...@@ -51,11 +51,8 @@
#include "tabcol.h" #include "tabcol.h"
#include "tabxcl.h" #include "tabxcl.h"
#include "xtable.h" #include "xtable.h"
#if defined(MYSQL_SUPPORT)
#include "tabmysql.h" #include "tabmysql.h"
#endif // MYSQL_SUPPORT
#include "ha_connect.h" #include "ha_connect.h"
#include "mycat.h"
/* -------------- Implementation of the XCOL classes ---------------- */ /* -------------- Implementation of the XCOL classes ---------------- */
......
This diff is collapsed.
...@@ -16,6 +16,8 @@ typedef class XMLCOL *PXMLCOL; ...@@ -16,6 +16,8 @@ typedef class XMLCOL *PXMLCOL;
/***********************************************************************/ /***********************************************************************/
class DllExport XMLDEF : public TABDEF { /* Logical table description */ class DllExport XMLDEF : public TABDEF { /* Logical table description */
friend class TDBXML; friend class TDBXML;
friend class TDBXCT;
friend PQRYRES XMLColumns(PGLOBAL, char*, char*, PTOS, bool);
public: public:
// Constructor // Constructor
XMLDEF(void); XMLDEF(void);
...@@ -55,6 +57,7 @@ class DllExport TDBXML : public TDBASE { ...@@ -55,6 +57,7 @@ class DllExport TDBXML : public TDBASE {
friend class XMLCOL; friend class XMLCOL;
friend class XMULCOL; friend class XMULCOL;
friend class XPOSCOL; friend class XPOSCOL;
friend PQRYRES XMLColumns(PGLOBAL, char*, char*, PTOS, bool);
public: public:
// Constructor // Constructor
TDBXML(PXMLDEF tdp); TDBXML(PXMLDEF tdp);
...@@ -237,4 +240,24 @@ class XPOSCOL : public XMLCOLX { ...@@ -237,4 +240,24 @@ class XPOSCOL : public XMLCOLX {
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
}; // end of class XPOSCOL }; // end of class XPOSCOL
/***********************************************************************/
/* This is the class declaration for the XML catalog table. */
/***********************************************************************/
class TDBXCT : public TDBCAT {
public:
// Constructor
TDBXCT(PXMLDEF tdp);
protected:
// Specific routines
virtual PQRYRES GetResult(PGLOBAL g);
// Members
PTOS Topt;
char *Dp;
//const char *Fn;
char *Tabn;
}; // end of class TDBXCT
#endif // INCLUDE_TDBXML #endif // INCLUDE_TDBXML
/************ Valblk C++ Functions Source Code File (.CPP) *************/ /************ Valblk C++ Functions Source Code File (.CPP) *************/
/* Name: VALBLK.CPP Version 2.1 */ /* Name: VALBLK.CPP Version 2.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* This file contains the VALBLK and derived classes functions. */ /* This file contains the VALBLK and derived classes functions. */
/* Second family is VALBLK, representing simple suballocated arrays */ /* Second family is VALBLK, representing simple suballocated arrays */
...@@ -1155,10 +1155,9 @@ void STRBLK::SetValue(PVAL valp, int n) ...@@ -1155,10 +1155,9 @@ void STRBLK::SetValue(PVAL valp, int n)
void STRBLK::SetValue(PSZ p, int n) void STRBLK::SetValue(PSZ p, int n)
{ {
if (p) { if (p) {
if (!Sorted || !n || !Strp[n-1] || strcmp(p, Strp[n-1])) { if (!Sorted || !n || !Strp[n-1] || strcmp(p, Strp[n-1]))
Strp[n] = (PSZ)PlugSubAlloc(Global, NULL, strlen(p) + 1); Strp[n] = (PSZ)PlugDup(Global, p);
strcpy(Strp[n], p); else
} else
Strp[n] = Strp[n-1]; Strp[n] = Strp[n-1];
} else } else
......
...@@ -627,6 +627,7 @@ int TYPVAL<double>::GetValLen(void) ...@@ -627,6 +627,7 @@ int TYPVAL<double>::GetValLen(void)
template <class TYPE> template <class TYPE>
bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype) bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype)
{ {
if (valp != this) {
if (chktype && Type != valp->GetType()) if (chktype && Type != valp->GetType())
return true; return true;
...@@ -635,6 +636,8 @@ bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype) ...@@ -635,6 +636,8 @@ bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype)
else else
Reset(); Reset();
} // endif valp
return false; return false;
} // end of SetValue } // end of SetValue
...@@ -1319,6 +1322,7 @@ ulonglong TYPVAL<PSZ>::GetUBigintValue(void) ...@@ -1319,6 +1322,7 @@ ulonglong TYPVAL<PSZ>::GetUBigintValue(void)
/***********************************************************************/ /***********************************************************************/
bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype) bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
{ {
if (valp != this) {
if (chktype && (valp->GetType() != Type || valp->GetSize() > Len)) if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
return true; return true;
...@@ -1329,6 +1333,8 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype) ...@@ -1329,6 +1333,8 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
else else
Reset(); Reset();
} // endif valp
return false; return false;
} // end of SetValue_pval } // end of SetValue_pval
...@@ -2063,11 +2069,12 @@ double BINVAL::GetFloatValue(void) ...@@ -2063,11 +2069,12 @@ double BINVAL::GetFloatValue(void)
/***********************************************************************/ /***********************************************************************/
bool BINVAL::SetValue_pval(PVAL valp, bool chktype) bool BINVAL::SetValue_pval(PVAL valp, bool chktype)
{ {
bool rc = false;
if (valp != this) {
if (chktype && (valp->GetType() != Type || valp->GetSize() > Clen)) if (chktype && (valp->GetType() != Type || valp->GetSize() > Clen))
return true; return true;
bool rc = false;
if (!(Null = valp->IsNull() && Nullable)) { if (!(Null = valp->IsNull() && Nullable)) {
if ((rc = (Len = valp->GetSize()) > Clen)) if ((rc = (Len = valp->GetSize()) > Clen))
Len = Clen; Len = Clen;
...@@ -2076,6 +2083,8 @@ bool BINVAL::SetValue_pval(PVAL valp, bool chktype) ...@@ -2076,6 +2083,8 @@ bool BINVAL::SetValue_pval(PVAL valp, bool chktype)
} else } else
Reset(); Reset();
} // endif valp
return rc; return rc;
} // end of SetValue_pval } // end of SetValue_pval
...@@ -2629,6 +2638,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) ...@@ -2629,6 +2638,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval)
/***********************************************************************/ /***********************************************************************/
bool DTVAL::SetValue_pval(PVAL valp, bool chktype) bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
{ {
if (valp != this) {
if (chktype && Type != valp->GetType()) if (chktype && Type != valp->GetType())
return true; return true;
...@@ -2645,6 +2655,8 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype) ...@@ -2645,6 +2655,8 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
} else } else
Reset(); Reset();
} // endif valp
return false; return false;
} // end of SetValue } // end of SetValue
......
...@@ -289,6 +289,34 @@ bool STRING::Set(char *s, uint n) ...@@ -289,6 +289,34 @@ bool STRING::Set(char *s, uint n)
return false; return false;
} // end of Set } // end of Set
/***********************************************************************/
/* Append a char* to a STRING. */
/***********************************************************************/
bool STRING::Append(const char *s, uint ln)
{
if (!s)
return false;
uint len = Length + ln + 1;
if (len > Size) {
char *p = Realloc(len);
if (!p)
return true;
else if (p != Strp) {
strcpy(p, Strp);
Strp = p;
} // endif p
} // endif n
strncpy(Strp + Length, s, ln);
Length = len - 1;
Strp[Length] = 0;
return false;
} // end of Append
/***********************************************************************/ /***********************************************************************/
/* Append a PSZ to a STRING. */ /* Append a PSZ to a STRING. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -134,6 +134,7 @@ class DllExport STRING : public BLOCK { ...@@ -134,6 +134,7 @@ class DllExport STRING : public BLOCK {
inline void Reset(void) {*Strp = 0;} inline void Reset(void) {*Strp = 0;}
bool Set(PSZ s); bool Set(PSZ s);
bool Set(char *s, uint n); bool Set(char *s, uint n);
bool Append(const char *s, uint ln);
bool Append(PSZ s); bool Append(PSZ s);
bool Append(STRING &str); bool Append(STRING &str);
bool Append(char c); bool Append(char c);
......
/**************** Table H Declares Source Code File (.H) ***************/ /**************** Table H Declares Source Code File (.H) ***************/
/* Name: TABLE.H Version 2.3 */ /* Name: TABLE.H Version 2.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
/* */ /* */
/* This file contains the TBX, OPJOIN and TDB class definitions. */ /* This file contains the TBX, OPJOIN and TDB class definitions. */
/***********************************************************************/ /***********************************************************************/
...@@ -24,9 +24,7 @@ typedef class CMD *PCMD; ...@@ -24,9 +24,7 @@ typedef class CMD *PCMD;
class CMD : public BLOCK { class CMD : public BLOCK {
public: public:
// Constructor // Constructor
CMD(PGLOBAL g, char *cmd) { CMD(PGLOBAL g, char *cmd) {Cmd = PlugDup(g, cmd); Next = NULL;}
Cmd = (char*)PlugSubAlloc(g, NULL, strlen(cmd) + 1);
strcpy(Cmd, cmd); Next = NULL; }
// Members // Members
PCMD Next; PCMD Next;
......
...@@ -770,7 +770,7 @@ dict_foreign_set_validate( ...@@ -770,7 +770,7 @@ dict_foreign_set_validate(
{ {
dict_foreign_not_exists not_exists(fk_set); dict_foreign_not_exists not_exists(fk_set);
dict_foreign_set::iterator it = std::find_if( dict_foreign_set::const_iterator it = std::find_if(
fk_set.begin(), fk_set.end(), not_exists); fk_set.begin(), fk_set.end(), not_exists);
if (it == fk_set.end()) { if (it == fk_set.end()) {
......
...@@ -50,6 +50,7 @@ Created 1/8/1996 Heikki Tuuri ...@@ -50,6 +50,7 @@ Created 1/8/1996 Heikki Tuuri
#include <set> #include <set>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <ostream>
/* Forward declaration. */ /* Forward declaration. */
struct ib_rbt_t; struct ib_rbt_t;
......
...@@ -788,7 +788,7 @@ dict_foreign_set_validate( ...@@ -788,7 +788,7 @@ dict_foreign_set_validate(
{ {
dict_foreign_not_exists not_exists(fk_set); dict_foreign_not_exists not_exists(fk_set);
dict_foreign_set::iterator it = std::find_if( dict_foreign_set::const_iterator it = std::find_if(
fk_set.begin(), fk_set.end(), not_exists); fk_set.begin(), fk_set.end(), not_exists);
if (it == fk_set.end()) { if (it == fk_set.end()) {
......
...@@ -53,6 +53,7 @@ Created 1/8/1996 Heikki Tuuri ...@@ -53,6 +53,7 @@ Created 1/8/1996 Heikki Tuuri
#include <set> #include <set>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <ostream>
/* Forward declaration. */ /* Forward declaration. */
struct ib_rbt_t; struct ib_rbt_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment