Commit 4eeadedc authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix json_bjson (s was erase by Json_Subset)

  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h

- Fix compile error (Force_Bson was not conditional by BSON_SUPPORT)
  modified:   storage/connect/ha_connect.cc

- Continue Bjson implementation
  modified:   storage/connect/block.h
  modified:   storage/connect/bson.cpp
  modified:   storage/connect/bson.h
  modified:   storage/connect/bsonudf.cpp
  modified:   storage/connect/bsonudf.h
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/tabbson.cpp
  modified:   storage/connect/tabjson.cpp

- Typo
  deleted:    storage/connect/Header.h
parent 871532c3
This diff is collapsed.
/*************** json CPP Declares Source Code File (.H) ***************/
/* Name: json.cpp Version 1.5 */
/*************** bson CPP Declares Source Code File (.H) ***************/
/* Name: bson.cpp Version 1.0 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2020 */
/* (C) Copyright to the author Olivier BERTRAND 2020 */
/* */
/* This file contains the JSON classes functions. */
/* This file contains the BJSON classes functions. */
/***********************************************************************/
/***********************************************************************/
......@@ -15,7 +15,7 @@
/* Include application header files: */
/* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing the DB application declarations. */
/* xjson.h is header containing the JSON classes declarations. */
/* bson.h is header containing the BSON classes declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
......@@ -112,6 +112,7 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng, int* ptyp, bool* comma)
{
int i, pretty = (ptyp) ? *ptyp : 3;
bool b = false;
PBVAL bvp = NULL;
s = js;
len = lng;
......@@ -128,26 +129,26 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng, int* ptyp, bool* comma)
pty[0] = false;
try {
Bvp = NewVal();
Bvp->Type = TYPE_UNKNOWN;
bvp = NewVal();
bvp->Type = TYPE_UNKNOWN;
for (i = 0; i < len; i++)
switch (s[i]) {
case '[':
if (Bvp->Type != TYPE_UNKNOWN)
Bvp->To_Val = ParseAsArray(i, pretty, ptyp);
if (bvp->Type != TYPE_UNKNOWN)
bvp->To_Val = ParseAsArray(i, pretty, ptyp);
else
Bvp->To_Val = ParseArray(++i);
bvp->To_Val = ParseArray(++i);
Bvp->Type = TYPE_JAR;
bvp->Type = TYPE_JAR;
break;
case '{':
if (Bvp->Type != TYPE_UNKNOWN) {
Bvp->To_Val = ParseAsArray(i, pretty, ptyp);
Bvp->Type = TYPE_JAR;
if (bvp->Type != TYPE_UNKNOWN) {
bvp->To_Val = ParseAsArray(i, pretty, ptyp);
bvp->Type = TYPE_JAR;
} else {
Bvp->To_Val = ParseObject(++i);
Bvp->Type = TYPE_JOB;
bvp->To_Val = ParseObject(++i);
bvp->Type = TYPE_JOB;
} // endif Type
break;
......@@ -157,7 +158,7 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng, int* ptyp, bool* comma)
case '\r':
break;
case ',':
if (Bvp->Type != TYPE_UNKNOWN && (pretty == 1 || pretty == 3)) {
if (bvp->Type != TYPE_UNKNOWN && (pretty == 1 || pretty == 3)) {
if (comma)
*comma = true;
......@@ -177,18 +178,18 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng, int* ptyp, bool* comma)
} // endif b
default:
if (Bvp->Type != TYPE_UNKNOWN) {
Bvp->To_Val = ParseAsArray(i, pretty, ptyp);
Bvp->Type = TYPE_JAR;
} else if ((Bvp->To_Val = MOF(ParseValue(i))))
Bvp->Type = TYPE_JVAL;
if (bvp->Type != TYPE_UNKNOWN) {
bvp->To_Val = ParseAsArray(i, pretty, ptyp);
bvp->Type = TYPE_JAR;
} else if ((bvp->To_Val = MOF(ParseValue(i))))
bvp->Type = TYPE_JVAL;
else
throw 4;
break;
}; // endswitch s[i]
if (Bvp->Type == TYPE_UNKNOWN)
if (bvp->Type == TYPE_UNKNOWN)
sprintf(g->Message, "Invalid Json string '%.*s'", MY_MIN((int)len, 50), s);
else if (ptyp && pretty == 3) {
*ptyp = 3; // Not recognized pretty
......@@ -205,13 +206,13 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng, int* ptyp, bool* comma)
if (trace(1))
htrc("Exception %d: %s\n", n, G->Message);
GetMsg(g);
Bvp = NULL;
bvp = NULL;
} catch (const char* msg) {
strcpy(g->Message, msg);
Bvp = NULL;
bvp = NULL;
} // end catch
return Bvp;
return bvp;
} // end of ParseJson
/***********************************************************************/
......@@ -391,13 +392,11 @@ PBVAL BDOC::ParseValue(int& i)
bvp->Type = TYPE_JOB;
break;
case '"':
// jvp->Val = AllocVal(g, TYPE_STRG);
bvp->To_Val = ParseString(++i);
bvp->Type = TYPE_STRG;
break;
case 't':
if (!strncmp(s + i, "true", 4)) {
// jvp->Val = AllocVal(g, TYPE_BOOL);
bvp->B = true;
bvp->Type = TYPE_BOOL;
i += 3;
......@@ -407,7 +406,6 @@ PBVAL BDOC::ParseValue(int& i)
break;
case 'f':
if (!strncmp(s + i, "false", 5)) {
// jvp->Val = AllocVal(g, TYPE_BOOL);
bvp->B = false;
bvp->Type = TYPE_BOOL;
i += 4;
......@@ -872,7 +870,7 @@ void BJSON::SubSet(bool b)
if (b)
G->Saved_Size = 0;
} /* end of JsonSubSet */
} // end of SubSet
/* ------------------------ Bobject functions ------------------------ */
......
#pragma once
/**************** bson H Declares Source Code File (.H) ****************/
/* Name: bson.h Version 1.0 */
/* */
......@@ -6,6 +5,7 @@
/* */
/* This file contains the BSON classe declares. */
/***********************************************************************/
#pragma once
#include <mysql_com.h>
#include "json.h"
#include "xobject.h"
......@@ -189,130 +189,3 @@ class BDOC : public BJSON {
// Default constructor not to be used
BDOC(void) {}
}; // end of class BDOC
#if 0
/***********************************************************************/
/* Class JOBJECT: contains a list of value pairs. */
/***********************************************************************/
class JOBJECT : public JSON {
friend class JDOC;
friend class JSNX;
friend class SWAP;
public:
JOBJECT(void) : JSON() { Type = TYPE_JOB; First = Last = NULL; }
JOBJECT(int i) : JSON(i) {}
// Methods
virtual void Clear(void) { First = Last = NULL; }
virtual PJPR GetFirst(void) { return First; }
virtual int GetSize(PBPR prp, bool b);
virtual PJOB GetObject(void) { return this; }
virtual PSZ GetText(PGLOBAL g, PSTRG text);
virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual bool IsNull(void);
// Specific
PJPR AddPair(PGLOBAL g, PCSZ key);
PJVAL GetKeyValue(const char* key);
PJAR GetKeyList(PGLOBAL g);
PJAR GetValList(PGLOBAL g);
void SetKeyValue(PGLOBAL g, PJVAL jvp, PCSZ key);
void DeleteKey(PCSZ k);
protected:
PJPR First;
PJPR Last;
}; // end of class JOBJECT
/***********************************************************************/
/* Class JARRAY. */
/***********************************************************************/
class JARRAY : public JSON {
friend class SWAP;
public:
JARRAY(void);
JARRAY(int i) : JSON(i) {}
// Methods
virtual void Clear(void) { First = Last = NULL; Size = 0; }
virtual int size(void) { return Size; }
virtual PJAR GetArray(void) { return this; }
virtual int GetSize(bool b);
virtual PJVAL GetArrayValue(int i);
virtual PSZ GetText(PGLOBAL g, PSTRG text);
virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual bool DeleteValue(int n);
virtual bool IsNull(void);
// Specific
PJVAL AddArrayValue(PGLOBAL g, PJVAL jvp = NULL, int* x = NULL);
bool SetArrayValue(PGLOBAL g, PJVAL jvp, int i);
void InitArray(PGLOBAL g);
protected:
// Members
int Size; // The number of items in the array
int Alloc; // The Mvals allocated size
PJVAL First; // Used when constructing
PJVAL Last; // Last constructed value
PJVAL* Mvals; // Allocated when finished
}; // end of class JARRAY
/***********************************************************************/
/* Class JVALUE. */
/***********************************************************************/
class JVALUE : public JSON {
friend class JARRAY;
friend class JSNX;
friend class JSONDISC;
friend class JSONCOL;
friend class JSON;
friend class JDOC;
friend class SWAP;
public:
JVALUE(void) : JSON() { Type = TYPE_JVAL; Clear(); }
JVALUE(PJSON jsp);
JVALUE(PGLOBAL g, PVAL valp);
JVALUE(PGLOBAL g, PCSZ strp);
JVALUE(int i) : JSON(i) {}
// Methods
virtual void Clear(void);
//virtual JTYP GetType(void) {return TYPE_JVAL;}
virtual JTYP GetValType(void);
virtual PJOB GetObject(void);
virtual PJAR GetArray(void);
virtual PJSON GetJsp(void) { return (DataType == TYPE_JSON ? Jsp : NULL); }
virtual PSZ GetText(PGLOBAL g, PSTRG text);
virtual bool IsNull(void);
// Specific
inline PJSON GetJson(void) { return (DataType == TYPE_JSON ? Jsp : this); }
PSZ GetString(PGLOBAL g, char* buff = NULL);
int GetInteger(void);
long long GetBigint(void);
double GetFloat(void);
PVAL GetValue(PGLOBAL g);
void SetValue(PJSON jsp);
void SetValue(PGLOBAL g, PVAL valp);
void SetString(PGLOBAL g, PSZ s, int ci = 0);
void SetInteger(PGLOBAL g, int n);
void SetBigint(PGLOBAL g, longlong ll);
void SetFloat(PGLOBAL g, double f);
void SetBool(PGLOBAL g, bool b);
protected:
union {
PJSON Jsp; // To the json value
char* Strp; // Ptr to a string
int N; // An integer value
long long LLn; // A big integer value
double F; // A (double) float value
bool B; // True or false
};
PJVAL Next; // Next value in array
JTYP DataType; // The data value type
int Nd; // Decimal number
bool Del; // True when deleted
}; // end of class JVALUE
#endif // 0
......@@ -1706,3 +1706,127 @@ void bson_locate_all_deinit(UDF_INIT* initid) {
JsonFreeMem((PGLOBAL)initid->ptr);
} // end of bson_locate_all_deinit
/*********************************************************************************/
/* Convert a pretty=0 Json file to binary BJSON. */
/*********************************************************************************/
my_bool bfile_bjson_init(UDF_INIT* initid, UDF_ARGS* args, char* message) {
unsigned long reslen, memlen;
if (args->arg_count != 2 && args->arg_count != 3) {
strcpy(message, "This function must have 2 or 3 arguments");
return true;
} else if (args->arg_count == 3 && args->arg_type[2] != INT_RESULT) {
strcpy(message, "Third Argument must be an integer (LRECL)");
return true;
} else for (int i = 0; i < 2; i++)
if (args->arg_type[i] != STRING_RESULT) {
sprintf(message, "Arguments %d must be a string (file name)", i + 1);
return true;
} // endif args
CalcLen(args, false, reslen, memlen);
memlen = memlen * M;
memlen += (args->arg_count == 3) ? (ulong)*(longlong*)args->args[2] : 1024;
return JsonInit(initid, args, message, false, reslen, memlen);
} // end of bfile_bjson_init
char *bfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char*, char *error) {
char *buf, *str = NULL, fn[_MAX_PATH], ofn[_MAX_PATH];
bool loop;
ssize_t len, newloc;
size_t lrecl, binszp;
PBVAL jsp;
PBJNX bnxp;
PGLOBAL g = (PGLOBAL)initid->ptr;
BDOC doc(g);
strcpy(fn, MakePSZ(g, args, 0));
strcpy(ofn, MakePSZ(g, args, 1));
if (args->arg_count == 3)
lrecl = (size_t)*(longlong*)args->args[2];
else
lrecl = 1024;
if (!g->Xchk) {
int msgid = MSGID_OPEN_MODE_STRERROR;
FILE *fout;
FILE *fin;
if (!(fin = global_fopen(g, msgid, fn, "rt")))
str = strcpy(result, g->Message);
else if (!(fout = global_fopen(g, msgid, ofn, "wb")))
str = strcpy(result, g->Message);
else if ((buf = (char*)malloc(lrecl))) {
try {
do {
loop = false;
PlugSubSet(g->Sarea, g->Sarea_Size);
if (!fgets(buf, lrecl, fin)) {
if (!feof(fin)) {
sprintf(g->Message, "Error %d reading %zd bytes from %s",
errno, lrecl, fn);
str = strcpy(result, g->Message);
} else
str = strcpy(result, ofn);
} else if ((len = strlen(buf))) {
if ((jsp = doc.ParseJson(g, buf, len))) {
newloc = (size_t)PlugSubAlloc(g, NULL, 0);
binszp = newloc - (size_t)jsp;
if (fwrite(&binszp, sizeof(binszp), 1, fout) != 1) {
sprintf(g->Message, "Error %d writing %zd bytes to %s",
errno, sizeof(binszp), ofn);
str = strcpy(result, g->Message);
} else if (fwrite(jsp, binszp, 1, fout) != 1) {
sprintf(g->Message, "Error %d writing %zd bytes to %s",
errno, binszp, ofn);
str = strcpy(result, g->Message);
} else
loop = true;
} else {
str = strcpy(result, g->Message);
} // endif jsp
} else
loop = true;
} while (loop);
} catch (int) {
str = strcpy(result, g->Message);
} catch (const char* msg) {
str = strcpy(result, msg);
} // end catch
free(buf);
} else
str = strcpy(result, "Buffer malloc failed");
if (fin) fclose(fin);
if (fout) fclose(fout);
g->Xchk = str;
} else
str = (char*)g->Xchk;
if (!str) {
if (g->Message)
str = strcpy(result, g->Message);
else
str = strcpy(result, "Unexpected error");
} // endif str
*res_length = strlen(str);
return str;
} // end of bfile_bjson
void bfile_bjson_deinit(UDF_INIT* initid) {
JsonFreeMem((PGLOBAL)initid->ptr);
} // end of bfile_bjson_deinit
......@@ -106,5 +106,8 @@ extern "C" {
DllExport my_bool bson_locate_all_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bson_locate_all(UDF_EXEC_ARGS);
DllExport void bson_locate_all_deinit(UDF_INIT*);
} // extern "C"
DllExport my_bool bfile_bjson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bfile_bjson(UDF_EXEC_ARGS);
DllExport void bfile_bjson_deinit(UDF_INIT*);
} // extern "C"
......@@ -170,7 +170,7 @@
#define JSONMAX 10 // JSON Default max grp size
extern "C" {
char version[]= "Version 1.07.0002 December 07, 2020";
char version[]= "Version 1.07.0002 December 12, 2020";
#if defined(__WIN__)
char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__;
char slash= '\\';
......@@ -516,7 +516,9 @@ char *GetJavaWrapper(void)
bool MongoEnabled(void) {return THDVAR(current_thd, enable_mongo);}
#endif // JAVA_SUPPORT || CMGO_SUPPORT
#if defined(BSON_SUPPORT)
bool Force_Bson(void) {return THDVAR(current_thd, force_bson);}
#endif // BSON_SUPPORT)
#if defined(XMSG) || defined(NEWMSG)
extern "C" const char *msglang(void)
......
......@@ -1174,13 +1174,16 @@ static uint GetJsonGroupSize(void)
/*********************************************************************************/
/* Program for SubSet re-initialization of the memory pool. */
/*********************************************************************************/
my_bool JsonSubSet(PGLOBAL g)
my_bool JsonSubSet(PGLOBAL g, my_bool b)
{
PPOOLHEADER pph = (PPOOLHEADER)g->Sarea;
pph->To_Free = (g->Saved_Size) ? g->Saved_Size : sizeof(POOLHEADER);
pph->FreeBlk = g->Sarea_Size - pph->To_Free;
if (b)
g->Saved_Size = 0;
return FALSE;
} /* end of JsonSubSet */
......@@ -1458,7 +1461,7 @@ int IsJson(UDF_ARGS *args, uint i, bool b)
char *sap;
PGLOBAL g = PlugInit(NULL, (size_t)args->lengths[i] * M + 1024);
JsonSubSet(g);
// JsonSubSet(g);
sap = MakePSZ(g, args, i);
if (ParseJson(g, sap, strlen(sap)))
......
......@@ -53,13 +53,13 @@ typedef struct _jnode {
typedef class JSNX *PJSNX;
/*********************************************************************************/
/* The JSON tree node. Can be an Object or an Array. */
/* The JSON utility functions. */
/*********************************************************************************/
bool IsNum(PSZ s);
char *NextChr(PSZ s, char sep);
char *GetJsonNull(void);
uint GetJsonGrpSize(void);
my_bool JsonSubSet(PGLOBAL g);
my_bool JsonSubSet(PGLOBAL g, my_bool b = false);
my_bool CalcLen(UDF_ARGS* args, my_bool obj, unsigned long& reslen,
unsigned long& memlen, my_bool mod = false);
my_bool JsonInit(UDF_INIT* initid, UDF_ARGS* args, char* message, my_bool mbn,
......
......@@ -96,7 +96,7 @@ char *msglang(void);
typedef struct {
ushort Segsize;
ushort Size;
} AREASIZE;
} AREASIZE;
ACTIVITY defActivity = { /* Describes activity and language */
NULL, /* Points to user work area(s) */
......@@ -204,7 +204,7 @@ PGLOBAL PlugExit(PGLOBAL g)
/* Note: this routine is not really implemented for Unix. */
/***********************************************************************/
LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
{
{
#if defined(__WIN__)
char drive[_MAX_DRIVE];
#else
......@@ -228,8 +228,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
htrc("buff='%s'\n", pBuff);
return pBuff;
} // end of PlugRemoveType
} // end of PlugRemoveType
BOOL PlugIsAbsolutePath(LPCSTR path)
{
......@@ -246,7 +245,7 @@ BOOL PlugIsAbsolutePath(LPCSTR path)
/* Note: this routine is not really implemented for Unix. */
/***********************************************************************/
LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
{
{
char newname[_MAX_PATH];
char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR];
char fname[_MAX_FNAME];
......@@ -347,14 +346,14 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
} else
return FileName; // Error, return unchanged name
} // end of PlugSetPath
} // end of PlugSetPath
#if defined(XMSG)
/***********************************************************************/
/* PlugGetMessage: get a message from the message file. */
/***********************************************************************/
char *PlugReadMessage(PGLOBAL g, int mid, char *m)
{
{
char msgfile[_MAX_PATH], msgid[32], buff[256];
char *msg;
FILE *mfile = NULL;
......@@ -405,14 +404,14 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m)
msg = stmsg;
return msg;
} // end of PlugReadMessage
} // end of PlugReadMessage
#elif defined(NEWMSG)
/***********************************************************************/
/* PlugGetMessage: get a message from the resource string table. */
/***********************************************************************/
char *PlugGetMessage(PGLOBAL g, int mid)
{
{
char *msg;
#if 0 // was !defined(UNIX) && !defined(UNIV_LINUX)
......@@ -440,7 +439,7 @@ char *PlugGetMessage(PGLOBAL g, int mid)
msg = stmsg;
return msg;
} // end of PlugGetMessage
} // end of PlugGetMessage
#endif // NEWMSG
#if defined(__WIN__)
......@@ -448,13 +447,13 @@ char *PlugGetMessage(PGLOBAL g, int mid)
/* Return the line length of the console screen buffer. */
/***********************************************************************/
short GetLineLength(PGLOBAL g)
{
{
CONSOLE_SCREEN_BUFFER_INFO coninfo;
HANDLE hcons = GetStdHandle(STD_OUTPUT_HANDLE);
BOOL b = GetConsoleScreenBufferInfo(hcons, &coninfo);
return (b) ? coninfo.dwSize.X : 0;
} // end of GetLineLength
} // end of GetLineLength
#endif // __WIN__
/***********************************************************************/
......@@ -527,13 +526,13 @@ void FreeSarea(PGLOBAL g)
/* the address and size not larger than memory size. */
/***********************************************************************/
BOOL PlugSubSet(void *memp, size_t size)
{
{
PPOOLHEADER pph = (PPOOLHEADER)memp;
pph->To_Free = (size_t)sizeof(POOLHEADER);
pph->FreeBlk = size - pph->To_Free;
return FALSE;
} /* end of PlugSubSet */
} /* end of PlugSubSet */
/***********************************************************************/
/* Use it to export a function that do throwing. */
......@@ -596,7 +595,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
/* 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);
......@@ -605,12 +604,13 @@ char *PlugDup(PGLOBAL g, const char *str)
} else
return NULL;
} // end of PlugDup
} // end of PlugDup
/*************************************************************************/
/* This routine makes a pointer from an offset to a memory pointer. */
/*************************************************************************/
void* MakePtr(void* memp, size_t offset) {
void* MakePtr(void* memp, size_t offset)
{
// return ((offset == 0) ? NULL : &((char*)memp)[offset]);
return (!offset) ? NULL : (char *)memp + offset;
} /* end of MakePtr */
......@@ -618,11 +618,14 @@ void* MakePtr(void* memp, size_t offset) {
/*************************************************************************/
/* This routine makes an offset from a pointer new format. */
/*************************************************************************/
size_t MakeOff(void* memp, void* ptr) {
size_t MakeOff(void* memp, void* ptr)
{
if (ptr) {
#if defined(_DEBUG) || defined(DEVELOPMENT)
if (ptr <= memp)
if (ptr <= memp) {
fprintf(stderr, "ptr %p <= memp %p", ptr, memp);
throw 999;
} // endif ptr
#endif // _DEBUG || DEVELOPMENT
return (size_t)((char*)ptr - (size_t)memp);
} else
......
......@@ -259,7 +259,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
} // endif Lrecl
// Allocate the parse work memory
tdp->G = PlugInit(NULL, (size_t)tdp->Lrecl * (tdp->Pretty >= 0 ? 6 : 2));
tdp->G = PlugInit(NULL, (size_t)tdp->Lrecl * (tdp->Pretty >= 0 ? 4 : 2));
tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF);
if (tdp->Zipped) {
......@@ -1167,7 +1167,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
if (Lrecl) {
// Allocate the parse work memory
G = PlugInit(NULL, (size_t)Lrecl * 6);
G = PlugInit(NULL, (size_t)Lrecl * 4);
} else {
strcpy(g->Message, "LRECL is not defined");
return NULL;
......@@ -1200,7 +1200,6 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
} // endif Driver
} else if (Zipped) {
// if (Zipped) {
#if defined(ZIP_SUPPORT)
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
txfp = new(g) UNZFAM(this);
......@@ -1226,9 +1225,9 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
#endif // !GZ_SUPPORT
} else if (map)
txfp = new(g) MAPFAM(this);
else if (Pretty < 0) // BJsonfile
else if (Pretty < 0) { // BJsonfile
txfp = new(g) BINFAM(this);
else
} else
txfp = new(g) DOSFAM(this);
// Txfp must be set for TDBBSN
......@@ -1436,7 +1435,6 @@ bool TDBBSN::OpenDB(PGLOBAL g)
} // endif Use
if (Pretty < 0) {
#if 0
/*******************************************************************/
/* Binary BJSON table. */
/*******************************************************************/
......@@ -1450,7 +1448,7 @@ bool TDBBSN::OpenDB(PGLOBAL g)
if (!To_Kindex) {
Txfp->Rewind(); // see comment in Work.log
} else // Table is to be accessed through a sorted index table
To_Kindex->Reset();
To_Kindex->Reset(); // TODO: NIY
return false;
} // endif use
......@@ -1469,14 +1467,12 @@ bool TDBBSN::OpenDB(PGLOBAL g)
/*********************************************************************/
size_t linelen = Lrecl;
//To_Line = (char*)PlugSubAlloc(g, NULL, linelen);
//memset(To_Line, 0, linelen);
// Buffer should be the first allocated thing in G->Sarea
Txfp->AllocateBuffer(Bp->G);
To_Line = Txfp->GetBuf();
memset(To_Line, 0, linelen);
Bp->MemSave();
xtrc(1, "OpenJSN: R%hd mode=%d To_Line=%p\n", Tdb_No, Mode, To_Line);
return false;
#endif // 0
strcpy(g->Message, "TDBBSN: Binary NIY");
return true;
} else if (TDBDOS::OpenDB(g))
return true;
......@@ -1548,23 +1544,14 @@ int TDBBSN::ReadDB(PGLOBAL g)
rc = RC_EF;
} else {
#if 0
// Here we get a movable Json binary tree
PJSON jsp;
SWAP* swp;
jsp = (PJSON)To_Line;
swp = new(g) SWAP(G, jsp);
swp->SwapJson(jsp, false); // Restore pointers from offsets
Row = jsp;
Row = FindRow(g);
Bp->SubSet(); // Perhaps Useful when updating
Row = (PBVAL)To_Line;
Row = Bp->FindRow(g);
SameRow = 0;
Fpos++;
M = 1;
rc = RC_OK;
#endif // 0
strcpy(g->Message, "TDBBSN: Binary NIY");
rc = RC_FX;
} // endif Pretty
} // endif ReadDB
......
......@@ -298,14 +298,6 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
tjnp->SetMode(MODE_READ);
// Allocate the parse work memory
#if 0
PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL));
memset(G, 0, sizeof(GLOBAL));
G->Sarea_Size = (size_t)tdp->Lrecl * (tdp->Pretty >= 0 ? 10 : 2);
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
PlugSubSet(G->Sarea, G->Sarea_Size);
G->jump_level = 0;
#endif // 0
G = PlugInit(NULL, (size_t)tdp->Lrecl * (tdp->Pretty >= 0 ? 10 : 2));
tjnp->SetG(G);
......
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