mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
Fix gcc compiler warnings reported by Sergei
modified: storage/connect/array.cpp modified: storage/connect/array.h modified: storage/connect/blkfil.cpp modified: storage/connect/blkfil.h modified: storage/connect/block.h modified: storage/connect/colblk.cpp modified: storage/connect/colblk.h modified: storage/connect/csort.h modified: storage/connect/filamvct.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/global.h modified: storage/connect/json.h modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/tabcol.cpp modified: storage/connect/tabcol.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabjson.cpp modified: storage/connect/table.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabsys.h modified: storage/connect/tabxml.h modified: storage/connect/value.cpp modified: storage/connect/value.h modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h modified: storage/connect/xobject.cpp modified: storage/connect/xobject.h modified: storage/connect/xtable.h Set values as nullable when retrieving catalog info modified: storage/connect/jdbconn.cpp modified: storage/connect/mysql-test/connect/r/odbc_oracle.result modified: storage/connect/odbconn.cpp Change format of Jpath modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/mysql-test/connect/r/json.result modified: storage/connect/mysql-test/connect/r/json_udf.result modified: storage/connect/mysql-test/connect/r/json_udf_bin.result modified: storage/connect/mysql-test/connect/r/zip.result modified: storage/connect/mysql-test/connect/t/json.test modified: storage/connect/mysql-test/connect/t/json_udf.test modified: storage/connect/mysql-test/connect/t/json_udf_bin.test modified: storage/connect/mysql-test/connect/t/zip.test modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h modified: storage/connect/tabmgo.cpp Change null representation from ??? to <null> modified: storage/connect/json.cpp Change the name of UDF that are equal to a native JSON function name modified: storage/connect/jsonudf.cpp modified: storage/connect/jsonudf.h modified: storage/connect/mysql-test/connect/t/json_udf.inc modified: storage/connect/mysql-test/connect/t/json_udf2.inc Fix bug in making JSON project info modified: storage/connect/mongofam.cpp Fix COMPUTE when one argument is null modified: storage/connect/value.cpp Value is null only when nullable modified: storage/connect/value.h
This commit is contained in:
@@ -973,7 +973,7 @@ int ARRAY::BlockTest(PGLOBAL, int opc, int opm,
|
||||
PSZ ARRAY::MakeArrayList(PGLOBAL g)
|
||||
{
|
||||
char *p, *tp;
|
||||
int i;
|
||||
int i;
|
||||
size_t z, len = 2;
|
||||
|
||||
if (Type == TYPE_LIST)
|
||||
@@ -984,7 +984,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
|
||||
|
||||
for (i = 0; i < Nval; i++) {
|
||||
Value->SetValue_pvblk(Vblp, i);
|
||||
Value->Print(g, tp, z);
|
||||
Value->Prints(g, tp, z);
|
||||
len += strlen(tp);
|
||||
} // enfor i
|
||||
|
||||
@@ -996,7 +996,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
|
||||
|
||||
for (i = 0; i < Nval;) {
|
||||
Value->SetValue_pvblk(Vblp, i);
|
||||
Value->Print(g, tp, z);
|
||||
Value->Prints(g, tp, z);
|
||||
strcat(p, tp);
|
||||
strcat(p, (++i == Nval) ? ")" : ",");
|
||||
} // enfor i
|
||||
@@ -1010,7 +1010,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* Make file output of ARRAY contents. */
|
||||
/***********************************************************************/
|
||||
void ARRAY::Print(PGLOBAL g, FILE *f, uint n)
|
||||
void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
char m[64];
|
||||
int lim = MY_MIN(Nval,10);
|
||||
@@ -1027,25 +1027,25 @@ void ARRAY::Print(PGLOBAL g, FILE *f, uint n)
|
||||
if (Vblp)
|
||||
for (int i = 0; i < lim; i++) {
|
||||
Value->SetValue_pvblk(Vblp, i);
|
||||
Value->Print(g, f, n+4);
|
||||
Value->Printf(g, f, n+4);
|
||||
} // endfor i
|
||||
|
||||
} else
|
||||
fprintf(f, "%sVALLST: numval=%d\n", m, Nval);
|
||||
|
||||
} // end of Print
|
||||
} // end of Printf
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of ARRAY contents. */
|
||||
/***********************************************************************/
|
||||
void ARRAY::Print(PGLOBAL, char *ps, uint z)
|
||||
void ARRAY::Prints(PGLOBAL, char *ps, uint z)
|
||||
{
|
||||
if (z < 16)
|
||||
return;
|
||||
|
||||
sprintf(ps, "ARRAY: type=%d\n", Type);
|
||||
// More to be implemented later
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
/* -------------------------- Class MULAR ---------------------------- */
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
|
||||
virtual bool Compare(PXOB) {assert(false); return false;}
|
||||
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(false); return false;}
|
||||
//virtual int CheckSpcCol(PTDB, int) {return 0;}
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
// void Empty(void);
|
||||
void SetPrecision(PGLOBAL g, int p);
|
||||
bool AddValue(PGLOBAL g, PSZ sp);
|
||||
|
||||
@@ -56,7 +56,7 @@ BLOCKFILTER::BLOCKFILTER(PTDBDOS tdbp, int op)
|
||||
/***********************************************************************/
|
||||
/* Make file output of BLOCKFILTER contents. */
|
||||
/***********************************************************************/
|
||||
void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n)
|
||||
void BLOCKFILTER::Printf(PGLOBAL, FILE *f, uint n)
|
||||
{
|
||||
char m[64];
|
||||
|
||||
@@ -65,15 +65,15 @@ void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n)
|
||||
|
||||
fprintf(f, "%sBLOCKFILTER: at %p opc=%d opm=%d result=%d\n",
|
||||
m, this, Opc, Opm, Result);
|
||||
} // end of Print
|
||||
} // end of Printf
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of BLOCKFILTER contents. */
|
||||
/***********************************************************************/
|
||||
void BLOCKFILTER::Print(PGLOBAL, char *ps, uint z)
|
||||
void BLOCKFILTER::Prints(PGLOBAL, char *ps, uint z)
|
||||
{
|
||||
strncat(ps, "BlockFilter(s)", z);
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
|
||||
/* ---------------------- Class BLKFILLOG ---------------------------- */
|
||||
@@ -995,7 +995,7 @@ int BLOCKINDEX::BlockEval(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* Make file output of BLOCKINDEX contents. */
|
||||
/***********************************************************************/
|
||||
void BLOCKINDEX::Print(PGLOBAL g, FILE *f, UINT n)
|
||||
void BLOCKINDEX::Printf(PGLOBAL g, FILE *f, UINT n)
|
||||
{
|
||||
char m[64];
|
||||
|
||||
@@ -1006,17 +1006,17 @@ void BLOCKINDEX::Print(PGLOBAL g, FILE *f, UINT n)
|
||||
m, this, Next, (Colp) ? Colp->GetName() : "Rowid", Kxp, Result);
|
||||
|
||||
if (Next)
|
||||
Next->Print(g, f, n);
|
||||
Next->Printf(g, f, n);
|
||||
|
||||
} // end of Print
|
||||
} // end of Printf
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of BLOCKINDEX contents. */
|
||||
/***********************************************************************/
|
||||
void BLOCKINDEX::Print(PGLOBAL g, char *ps, UINT z)
|
||||
void BLOCKINDEX::Prints(PGLOBAL g, char *ps, UINT z)
|
||||
{
|
||||
strncat(ps, "BlockIndex(es)", z);
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ class DllExport BLOCKFILTER : public BLOCK { /* Block Filter */
|
||||
// Methods
|
||||
virtual void Reset(PGLOBAL) = 0;
|
||||
virtual int BlockEval(PGLOBAL) = 0;
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
|
||||
protected:
|
||||
BLOCKFILTER(void) {} // Standard constructor not to be used
|
||||
@@ -234,8 +234,8 @@ class DllExport BLOCKINDEX : public BLOCK { /* Indexing Test Block */
|
||||
// Methods
|
||||
void Reset(void);
|
||||
virtual int BlockEval(PGLOBAL);
|
||||
virtual void Print(PGLOBAL g, FILE *f, UINT n);
|
||||
virtual void Print(PGLOBAL g, char *ps, UINT z);
|
||||
virtual void Printf(PGLOBAL g, FILE *f, UINT n);
|
||||
virtual void Prints(PGLOBAL g, char *ps, UINT z);
|
||||
|
||||
protected:
|
||||
BLOCKINDEX(void) {} // Standard constructor not to be used
|
||||
|
||||
@@ -44,8 +44,8 @@ class DllExport BLOCK {
|
||||
return (PlugSubAlloc(g, p, size));
|
||||
} // end of new
|
||||
|
||||
virtual void Print(PGLOBAL, FILE *, uint) {} // Produce file desc
|
||||
virtual void Print(PGLOBAL, char *, uint) {} // Produce string desc
|
||||
virtual void Printf(PGLOBAL, FILE *, uint) {} // Produce file desc
|
||||
virtual void Prints(PGLOBAL, char *, uint) {} // Produce string desc
|
||||
|
||||
#if !defined(__BORLANDC__)
|
||||
// Avoid warning C4291 by defining a matching dummy delete operator
|
||||
|
||||
@@ -214,7 +214,7 @@ void COLBLK::WriteColumn(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* Make file output of a column descriptor block. */
|
||||
/***********************************************************************/
|
||||
void COLBLK::Print(PGLOBAL, FILE *f, uint n)
|
||||
void COLBLK::Printf(PGLOBAL, FILE *f, uint n)
|
||||
{
|
||||
char m[64];
|
||||
int i;
|
||||
@@ -232,15 +232,15 @@ void COLBLK::Print(PGLOBAL, FILE *f, uint n)
|
||||
fprintf(f,
|
||||
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
|
||||
ColUse, Status, Buf_Type, Value, Name);
|
||||
} // end of Print
|
||||
} // end of Printf
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of a column descriptor block. */
|
||||
/***********************************************************************/
|
||||
void COLBLK::Print(PGLOBAL, char *ps, uint)
|
||||
void COLBLK::Prints(PGLOBAL, char *ps, uint)
|
||||
{
|
||||
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -72,8 +72,8 @@ class DllExport COLBLK : public XOBJECT {
|
||||
virtual void SetTo_Val(PVAL) {}
|
||||
virtual void ReadColumn(PGLOBAL g);
|
||||
virtual void WriteColumn(PGLOBAL g);
|
||||
virtual void Print(PGLOBAL g, FILE *, uint);
|
||||
virtual void Print(PGLOBAL g, char *, uint);
|
||||
virtual void Printf(PGLOBAL g, FILE *, uint);
|
||||
virtual void Prints(PGLOBAL g, char *, uint);
|
||||
virtual bool VarSize(void) {return false;}
|
||||
bool InitValue(PGLOBAL g);
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ class DllExport CSORT {
|
||||
public:
|
||||
// Methods
|
||||
int Qsort(PGLOBAL g, int n); /* Sort calling routine */
|
||||
//virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
//virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
//virtual void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
//virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
#ifdef DEBTRACE
|
||||
int GetNcmp(void) {return num_comp;}
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
@@ -568,7 +568,6 @@ bool VCTFAM::InitInsert(PGLOBAL g)
|
||||
CurNum = 0;
|
||||
AddBlock = !MaxBlk;
|
||||
} else {
|
||||
int rc;
|
||||
PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
|
||||
|
||||
// The starting point must be at the end of file as for append.
|
||||
|
||||
@@ -1490,7 +1490,7 @@ bool FILTER::MakeSelector(PGLOBAL g, PSTRG s, bool m)
|
||||
if (GetArgType(1) == TYPE_COLBLK)
|
||||
return true;
|
||||
|
||||
Arg(1)->Print(g, buf, 500);
|
||||
Arg(1)->Prints(g, buf, 500);
|
||||
s->Append(buf);
|
||||
s->Append('}');
|
||||
} // endif Opc
|
||||
@@ -1503,7 +1503,7 @@ bool FILTER::MakeSelector(PGLOBAL g, PSTRG s, bool m)
|
||||
/*********************************************************************/
|
||||
/* Make file output of FILTER contents. */
|
||||
/*********************************************************************/
|
||||
void FILTER::Print(PGLOBAL g, FILE *f, uint n)
|
||||
void FILTER::Printf(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
char m[64];
|
||||
|
||||
@@ -1525,18 +1525,18 @@ void FILTER::Print(PGLOBAL g, FILE *f, uint n)
|
||||
if (lin && fp->GetArgType(i) == TYPE_FILTER)
|
||||
fprintf(f, "%s Filter at %p\n", m, fp->Arg(i));
|
||||
else
|
||||
fp->Arg(i)->Print(g, f, n + 2);
|
||||
fp->Arg(i)->Printf(g, f, n + 2);
|
||||
|
||||
} // endfor i
|
||||
|
||||
} // endfor fp
|
||||
|
||||
} // end of Print
|
||||
} // end of Printf
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of TABLE contents (z should be checked). */
|
||||
/***********************************************************************/
|
||||
void FILTER::Print(PGLOBAL g, char *ps, uint z)
|
||||
void FILTER::Prints(PGLOBAL g, char *ps, uint z)
|
||||
{
|
||||
#define FLEN 100
|
||||
|
||||
@@ -1564,7 +1564,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
|
||||
bcp = bxp;
|
||||
p = bcp->Cold;
|
||||
n = FLEN;
|
||||
fp->Arg(0)->Print(g, p, n);
|
||||
fp->Arg(0)->Prints(g, p, n);
|
||||
n = FLEN - strlen(p);
|
||||
|
||||
switch (fp->Opc) {
|
||||
@@ -1610,7 +1610,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
|
||||
|
||||
n = FLEN - strlen(p);
|
||||
p += strlen(p);
|
||||
fp->Arg(1)->Print(g, p, n);
|
||||
fp->Arg(1)->Prints(g, p, n);
|
||||
} else
|
||||
if (!bcp) {
|
||||
strncat(ps, "???", z);
|
||||
@@ -1673,7 +1673,7 @@ void FILTER::Print(PGLOBAL g, char *ps, uint z)
|
||||
bcp = bxp;
|
||||
} while (bcp); // enddo
|
||||
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
|
||||
/* -------------------- Derived Classes Functions -------------------- */
|
||||
@@ -1791,8 +1791,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
|
||||
|
||||
if (trace)
|
||||
htrc("PrepareFilter: fp=%p having=%d\n", fp, having);
|
||||
//if (fp)
|
||||
// fp->Print(g, debug, 0);
|
||||
|
||||
while (fp) {
|
||||
if (fp->Opc == OP_SEP)
|
||||
|
||||
@@ -64,8 +64,8 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
|
||||
#if defined(MONGO_SUPPORT)
|
||||
bool MakeSelector(PGLOBAL g, PSTRG s, bool m);
|
||||
#endif // MONGO_SUPPORT
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
// PFIL Linearize(bool nosep);
|
||||
// PFIL Link(PGLOBAL g, PFIL fil2);
|
||||
// PFIL RemoveLastSep(void);
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
#define TYPE_BIGINT 5
|
||||
#define TYPE_LIST 6
|
||||
#define TYPE_INT 7
|
||||
#define TYPE_DATE 8
|
||||
#define TYPE_DECIM 9
|
||||
#define TYPE_BIN 10
|
||||
#define TYPE_PCHAR 11
|
||||
|
||||
@@ -1045,8 +1045,8 @@ PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def)
|
||||
pv= strchr(pk, '=');
|
||||
|
||||
if (pv && (!pn || pv < pn)) {
|
||||
n= MY_MIN(pv - pk, sizeof(key) - 1);
|
||||
memcpy(key, pk, n);
|
||||
n = MY_MIN(static_cast<size_t>(pv - pk), sizeof(key) - 1);
|
||||
memcpy(key, pk, n);
|
||||
key[n]= 0;
|
||||
pv++;
|
||||
n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1);
|
||||
|
||||
@@ -1943,6 +1943,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
|
||||
} // endif len
|
||||
|
||||
pval[n] = AllocateValue(g, crp->Type, len);
|
||||
pval[n]->SetNullable(true);
|
||||
|
||||
if (crp->Type == TYPE_STRING) {
|
||||
pbuf[n] = (char*)PlugSubAlloc(g, NULL, len);
|
||||
|
||||
@@ -53,6 +53,36 @@ void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp)
|
||||
char *GetExceptionDesc(PGLOBAL g, unsigned int e);
|
||||
#endif // SE_CATCH
|
||||
|
||||
/***********************************************************************/
|
||||
/* IsNum: check whether this string is all digits. */
|
||||
/***********************************************************************/
|
||||
bool IsNum(PSZ s)
|
||||
{
|
||||
for (char *p = s; *p; p++)
|
||||
if (*p == ']')
|
||||
break;
|
||||
else if (!isdigit(*p) || *p == '-')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} // end of IsNum
|
||||
|
||||
/***********************************************************************/
|
||||
/* NextChr: return the first found '[' or Sep pointer. */
|
||||
/***********************************************************************/
|
||||
char *NextChr(PSZ s, char sep)
|
||||
{
|
||||
char *p1 = strchr(s, '[');
|
||||
char *p2 = strchr(s, sep);
|
||||
|
||||
if (!p2)
|
||||
return p1;
|
||||
else if (p1)
|
||||
return MY_MIN(p1, p2);
|
||||
|
||||
return p2;
|
||||
} // end of NextChr
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/* Parse a json string. */
|
||||
@@ -992,7 +1022,24 @@ PSZ JOBJECT::GetText(PGLOBAL g, PSZ text)
|
||||
|
||||
if (!First && n)
|
||||
return NULL;
|
||||
else for (PJPR jp = First; jp; jp = jp->Next)
|
||||
else if (n == 1 && Size == 1 && !strcmp(First->GetKey(), "$date")) {
|
||||
int i;
|
||||
|
||||
First->Val->GetText(g, text);
|
||||
i = (text[1] == '-' ? 2 : 1);
|
||||
|
||||
if (IsNum(text + i)) {
|
||||
// Date is in milliseconds
|
||||
int j = (int)strlen(text);
|
||||
|
||||
if (j >= 4 + i)
|
||||
text[j - 3] = 0; // Change it to seconds
|
||||
else
|
||||
strcpy(text, " 0");
|
||||
|
||||
} // endif text
|
||||
|
||||
} else for (PJPR jp = First; jp; jp = jp->Next)
|
||||
jp->Val->GetText(g, text);
|
||||
|
||||
if (n)
|
||||
@@ -1312,7 +1359,7 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
|
||||
if (s)
|
||||
strcat(strcat(text, " "), s);
|
||||
else
|
||||
strcat(text, " ???");
|
||||
strcat(text, " <null>");
|
||||
|
||||
return text;
|
||||
} // end of GetText
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************** json H Declares Source Code File (.H) ****************/
|
||||
/* Name: json.h Version 1.2 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
|
||||
/* */
|
||||
/* This file contains the JSON classes declares. */
|
||||
/***********************************************************************/
|
||||
@@ -13,11 +13,12 @@
|
||||
#define X
|
||||
#endif
|
||||
|
||||
enum JTYP {TYPE_STRG = 1,
|
||||
TYPE_DBL = 2,
|
||||
TYPE_BOOL = 4,
|
||||
TYPE_BINT = 5,
|
||||
TYPE_INTG = 7,
|
||||
enum JTYP {TYPE_STRG = TYPE_STRING,
|
||||
TYPE_DBL = TYPE_DOUBLE,
|
||||
TYPE_BOOL = TYPE_TINY,
|
||||
TYPE_BINT = TYPE_BIGINT,
|
||||
TYPE_DTM = TYPE_DATE,
|
||||
TYPE_INTG = TYPE_INT,
|
||||
TYPE_JSON = 12,
|
||||
TYPE_JAR,
|
||||
TYPE_JOB,
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
#endif
|
||||
#define M 7
|
||||
|
||||
uint GetJsonGrpSize(void);
|
||||
static int IsJson(UDF_ARGS *args, uint i);
|
||||
static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i);
|
||||
bool IsNum(PSZ s);
|
||||
char *NextChr(PSZ s, char sep);
|
||||
uint GetJsonGrpSize(void);
|
||||
static int IsJson(UDF_ARGS *args, uint i);
|
||||
static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i);
|
||||
static char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *is_null, char *error);
|
||||
static char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -111,10 +113,9 @@ my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
|
||||
PJNODE jnp = &Nodes[i];
|
||||
|
||||
if (*p) {
|
||||
if (p[--n] == ']') {
|
||||
p[n--] = 0;
|
||||
p++;
|
||||
} else {
|
||||
if (p[n - 1] == ']') {
|
||||
p[--n] = 0;
|
||||
} else if (!IsNum(p)) {
|
||||
// Wrong array specification
|
||||
sprintf(g->Message, "Invalid array specification %s", p);
|
||||
return true;
|
||||
@@ -124,8 +125,7 @@ my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
|
||||
b = true;
|
||||
|
||||
// To check whether a numeric Rank was specified
|
||||
for (int k = 0; dg && p[k]; k++)
|
||||
dg = isdigit(p[k]) > 0;
|
||||
dg = IsNum(p);
|
||||
|
||||
if (!n) {
|
||||
// Default specifications
|
||||
@@ -160,13 +160,12 @@ my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
|
||||
// Set the Op value;
|
||||
switch (*p) {
|
||||
case '+': jnp->Op = OP_ADD; break;
|
||||
case '*': jnp->Op = OP_MULT; break;
|
||||
case 'x': jnp->Op = OP_MULT; break;
|
||||
case '>': jnp->Op = OP_MAX; break;
|
||||
case '<': jnp->Op = OP_MIN; break;
|
||||
case '!': jnp->Op = OP_SEP; break; // Average
|
||||
case '#': jnp->Op = OP_NUM; break;
|
||||
case 'x':
|
||||
case 'X': // Expand this array
|
||||
case '*': // Expand this array
|
||||
strcpy(g->Message, "Expand not supported by this function");
|
||||
return true;
|
||||
default:
|
||||
@@ -232,9 +231,9 @@ my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
|
||||
/*********************************************************************************/
|
||||
my_bool JSNX::ParseJpath(PGLOBAL g)
|
||||
{
|
||||
char *p, *p2 = NULL, *pbuf = NULL;
|
||||
char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL;
|
||||
int i;
|
||||
my_bool mul = false;
|
||||
my_bool a, mul = false;
|
||||
|
||||
if (Parsed)
|
||||
return false; // Already done
|
||||
@@ -245,8 +244,12 @@ my_bool JSNX::ParseJpath(PGLOBAL g)
|
||||
if (!(pbuf = PlgDBDup(g, Jpath)))
|
||||
return true;
|
||||
|
||||
// The Jpath must be analyzed
|
||||
for (i = 0, p = pbuf; (p = strchr(p, ':')); i++, p++)
|
||||
if (*pbuf == '$') pbuf++;
|
||||
if (*pbuf == '.') pbuf++;
|
||||
if (*pbuf == '[') p1 = pbuf++;
|
||||
|
||||
// Estimate the required number of nodes
|
||||
for (i = 0, p = pbuf; (p = NextChr(p, '.')); i++, p++)
|
||||
Nod++; // One path node found
|
||||
|
||||
if (!(Nodes = (PJNODE)PlgDBSubAlloc(g, NULL, (++Nod) * sizeof(JNODE))))
|
||||
@@ -255,12 +258,28 @@ my_bool JSNX::ParseJpath(PGLOBAL g)
|
||||
memset(Nodes, 0, (Nod)* sizeof(JNODE));
|
||||
|
||||
// Analyze the Jpath for this column
|
||||
for (i = 0, p = pbuf; i < Nod; i++, p = (p2 ? p2 + 1 : p + strlen(p))) {
|
||||
if ((p2 = strchr(p, ':')))
|
||||
*p2 = 0;
|
||||
for (i = 0, p = pbuf; p && i < Nod; i++, p = (p2 ? p2 : NULL)) {
|
||||
a = (p1 != NULL);
|
||||
p1 = strchr(p, '[');
|
||||
p2 = strchr(p, '.');
|
||||
|
||||
if (!p2)
|
||||
p2 = p1;
|
||||
else if (p1) {
|
||||
if (p1 < p2)
|
||||
p2 = p1;
|
||||
else if (p1 == p2 + 1)
|
||||
*p2++ = 0; // Old syntax .[
|
||||
else
|
||||
p1 = NULL;
|
||||
|
||||
} // endif p1
|
||||
|
||||
if (p2)
|
||||
*p2++ = 0;
|
||||
|
||||
// Jpath must be explicit
|
||||
if (*p == 0 || *p == '[') {
|
||||
if (a || *p == 0 || *p == '[' || IsNum(p)) {
|
||||
// Analyse intermediate array processing
|
||||
if (SetArrayOptions(g, p, i, Nodes[i-1].Key))
|
||||
return true;
|
||||
@@ -279,6 +298,7 @@ my_bool JSNX::ParseJpath(PGLOBAL g)
|
||||
|
||||
} // endfor i, p
|
||||
|
||||
Nod = i;
|
||||
MulVal = AllocateValue(g, Value);
|
||||
Parsed = true;
|
||||
return false;
|
||||
@@ -711,6 +731,7 @@ PSZ JSNX::Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k)
|
||||
|
||||
// Write to the path string
|
||||
Jp = new(g) JOUTSTR(g);
|
||||
Jp->WriteChr('$');
|
||||
Jvalp = jvp;
|
||||
K = k;
|
||||
|
||||
@@ -769,7 +790,12 @@ my_bool JSNX::LocateArray(PJAR jarp)
|
||||
/*********************************************************************************/
|
||||
my_bool JSNX::LocateObject(PJOB jobp)
|
||||
{
|
||||
size_t m = Jp->N;
|
||||
size_t m;
|
||||
|
||||
if (Jp->WriteChr('.'))
|
||||
return true;
|
||||
|
||||
m = Jp->N;
|
||||
|
||||
for (PJPR pair = jobp->First; pair && !Found; pair = pair->Next) {
|
||||
Jp->N = m;
|
||||
@@ -790,19 +816,12 @@ my_bool JSNX::LocateObject(PJOB jobp)
|
||||
/*********************************************************************************/
|
||||
my_bool JSNX::LocateValue(PJVAL jvp)
|
||||
{
|
||||
if (CompareTree(Jvalp, jvp)) {
|
||||
if (CompareTree(Jvalp, jvp))
|
||||
Found = (--K == 0);
|
||||
} else if (jvp->GetArray()) {
|
||||
if (Jp->WriteChr(':'))
|
||||
return true;
|
||||
|
||||
else if (jvp->GetArray())
|
||||
return LocateArray(jvp->GetArray());
|
||||
} else if (jvp->GetObject()) {
|
||||
if (Jp->WriteChr(':'))
|
||||
return true;
|
||||
|
||||
else if (jvp->GetObject())
|
||||
return LocateObject(jvp->GetObject());
|
||||
} // endif's
|
||||
|
||||
return false;
|
||||
} // end of LocateValue
|
||||
@@ -848,6 +867,7 @@ PSZ JSNX::LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx)
|
||||
if (!g->Message[0])
|
||||
strcpy(g->Message, "Invalid json tree");
|
||||
|
||||
return NULL;
|
||||
} else {
|
||||
if (Jp->N > 1)
|
||||
Jp->N--;
|
||||
@@ -858,7 +878,6 @@ PSZ JSNX::LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx)
|
||||
return Jp->Strp;
|
||||
} // endif's
|
||||
|
||||
return NULL;
|
||||
} // end of LocateAll
|
||||
|
||||
/*********************************************************************************/
|
||||
@@ -964,26 +983,26 @@ my_bool JSNX::CompareTree(PJSON jp1, PJSON jp2)
|
||||
/*********************************************************************************/
|
||||
my_bool JSNX::AddPath(void)
|
||||
{
|
||||
char s[16];
|
||||
my_bool b = false;
|
||||
char s[16];
|
||||
|
||||
if (Jp->WriteChr('"'))
|
||||
if (Jp->WriteStr("\"$"))
|
||||
return true;
|
||||
|
||||
for (int i = 0; i <= I; i++) {
|
||||
if (b) {
|
||||
if (Jp->WriteChr(':')) return true;
|
||||
} else
|
||||
b = true;
|
||||
|
||||
if (Jpnp[i].Type == TYPE_JAR) {
|
||||
sprintf(s, "[%d]", Jpnp[i].N + B);
|
||||
|
||||
if (Jp->WriteStr(s))
|
||||
return true;
|
||||
|
||||
} else if (Jp->WriteStr(Jpnp[i].Key))
|
||||
return true;
|
||||
} else {
|
||||
if (Jp->WriteChr('.'))
|
||||
return true;
|
||||
|
||||
if (Jp->WriteStr(Jpnp[i].Key))
|
||||
return true;
|
||||
|
||||
} // endif's
|
||||
|
||||
} // endfor i
|
||||
|
||||
@@ -1757,16 +1776,16 @@ void jsonvalue_deinit(UDF_INIT* initid)
|
||||
/*********************************************************************************/
|
||||
/* Make a Json array containing all the parameters. */
|
||||
/*********************************************************************************/
|
||||
my_bool json_array_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
my_bool json_make_array_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen;
|
||||
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
return JsonInit(initid, args, message, false, reslen, memlen);
|
||||
} // end of json_array_init
|
||||
} // end of json_make_array_init
|
||||
|
||||
char *json_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *, char *)
|
||||
char *json_make_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *, char *)
|
||||
{
|
||||
char *str;
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
@@ -1793,12 +1812,12 @@ char *json_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
*res_length = strlen(str);
|
||||
return str;
|
||||
} // end of json_array
|
||||
} // end of json_make_array
|
||||
|
||||
void json_array_deinit(UDF_INIT* initid)
|
||||
{
|
||||
JsonFreeMem((PGLOBAL)initid->ptr);
|
||||
} // end of json_array_deinit
|
||||
} // end of json_make_array_deinit
|
||||
|
||||
/*********************************************************************************/
|
||||
/* Add one or several values to a Json array. */
|
||||
@@ -2081,16 +2100,16 @@ void json_array_delete_deinit(UDF_INIT* initid)
|
||||
/*********************************************************************************/
|
||||
/* Make a Json Object containing all the parameters. */
|
||||
/*********************************************************************************/
|
||||
my_bool json_object_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
my_bool json_make_object_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen;
|
||||
|
||||
CalcLen(args, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, false, reslen, memlen);
|
||||
} // end of json_object_init
|
||||
} // end of json_make_object_init
|
||||
|
||||
char *json_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *, char *)
|
||||
char *json_make_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *, char *)
|
||||
{
|
||||
char *str = NULL;
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
@@ -2115,12 +2134,12 @@ char *json_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
*res_length = strlen(str);
|
||||
return str;
|
||||
} // end of json_object
|
||||
} // end of json_make_object
|
||||
|
||||
void json_object_deinit(UDF_INIT* initid)
|
||||
void json_make_object_deinit(UDF_INIT* initid)
|
||||
{
|
||||
JsonFreeMem((PGLOBAL)initid->ptr);
|
||||
} // end of json_object_deinit
|
||||
} // end of json_make_object_deinit
|
||||
|
||||
/*********************************************************************************/
|
||||
/* Make a Json Object containing all not null parameters. */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/******************** tabjson H Declares Source Code File (.H) *******************/
|
||||
/* Name: jsonudf.h Version 1.2 */
|
||||
/* Name: jsonudf.h Version 1.3 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2015-2017 */
|
||||
/* */
|
||||
/* This file contains the JSON UDF function and class declares. */
|
||||
/*********************************************************************************/
|
||||
@@ -37,9 +37,9 @@ extern "C" {
|
||||
DllExport char *jsonvalue(UDF_EXEC_ARGS);
|
||||
DllExport void jsonvalue_deinit(UDF_INIT*);
|
||||
|
||||
DllExport my_bool json_array_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||
DllExport char *json_array(UDF_EXEC_ARGS);
|
||||
DllExport void json_array_deinit(UDF_INIT*);
|
||||
DllExport my_bool json_make_array_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||
DllExport char *json_make_array(UDF_EXEC_ARGS);
|
||||
DllExport void json_make_array_deinit(UDF_INIT*);
|
||||
|
||||
DllExport my_bool json_array_add_values_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||
DllExport char *json_array_add_values(UDF_EXEC_ARGS);
|
||||
@@ -53,9 +53,9 @@ extern "C" {
|
||||
DllExport char *json_array_delete(UDF_EXEC_ARGS);
|
||||
DllExport void json_array_delete_deinit(UDF_INIT*);
|
||||
|
||||
DllExport my_bool json_object_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||
DllExport char *json_object(UDF_EXEC_ARGS);
|
||||
DllExport void json_object_deinit(UDF_INIT*);
|
||||
DllExport my_bool json_make_object_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||
DllExport char *json_make_object(UDF_EXEC_ARGS);
|
||||
DllExport void json_make_object_deinit(UDF_INIT*);
|
||||
|
||||
DllExport my_bool json_object_nonull_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||
DllExport char *json_object_nonull(UDF_EXEC_ARGS);
|
||||
|
||||
@@ -297,10 +297,23 @@ bool MGOFAM::Init(PGLOBAL g)
|
||||
bool MGOFAM::MakeCursor(PGLOBAL g)
|
||||
{
|
||||
const char *p;
|
||||
bool b = false, id = (Mode != MODE_READ), all = false;
|
||||
uint len;
|
||||
PSZ jp;
|
||||
PCOL cp;
|
||||
PSTRG s = NULL;
|
||||
|
||||
if (Options && !stricmp(Options, "all")) {
|
||||
Options = NULL;
|
||||
all = true;
|
||||
} // endif Options
|
||||
|
||||
for (cp = Tdbp->GetColumns(); cp; cp = cp->GetNext())
|
||||
if (!strcmp(cp->GetName(), "_id"))
|
||||
id = true;
|
||||
else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*"))
|
||||
all = true;
|
||||
|
||||
if (Pipe) {
|
||||
if (trace)
|
||||
htrc("Pipeline: %s\n", Options);
|
||||
@@ -332,24 +345,37 @@ bool MGOFAM::MakeCursor(PGLOBAL g)
|
||||
|
||||
} // endif To_Filter
|
||||
|
||||
// Project list
|
||||
len = s->GetLength();
|
||||
s->Append(",{\"$project\":{\"_id\":0");
|
||||
if (!all) {
|
||||
// Project list
|
||||
len = s->GetLength();
|
||||
|
||||
for (PCOL cp = Tdbp->GetColumns(); cp; cp = cp->GetNext()) {
|
||||
s->Append(",\"");
|
||||
if (Tdbp->GetColumns()) {
|
||||
s->Append(",{\"$project\":{\"");
|
||||
|
||||
if ((jp = ((PJCOL)cp)->GetJpath(g, true)))
|
||||
s->Append(jp);
|
||||
else {
|
||||
s->Truncate(len);
|
||||
goto nop;
|
||||
} // endif Jpath
|
||||
if (!id)
|
||||
s->Append("_id\":0,\"");
|
||||
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
for (PCOL cp = Tdbp->GetColumns(); cp; cp = cp->GetNext()) {
|
||||
if (b)
|
||||
s->Append(",\"");
|
||||
else
|
||||
b = true;
|
||||
|
||||
s->Append("}}");
|
||||
if ((jp = ((PJCOL)cp)->GetJpath(g, true)))
|
||||
s->Append(jp);
|
||||
else {
|
||||
s->Truncate(len);
|
||||
goto nop;
|
||||
} // endif Jpath
|
||||
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
|
||||
} else
|
||||
s->Append(",{\"$project\":{\"_id\":1}}");
|
||||
|
||||
s->Append("}}");
|
||||
} // endif all
|
||||
|
||||
nop:
|
||||
s->Append("]}");
|
||||
@@ -383,7 +409,7 @@ bool MGOFAM::MakeCursor(PGLOBAL g)
|
||||
if (Tdbp->GetFilter()) {
|
||||
char buf[512];
|
||||
|
||||
Tdbp->GetFilter()->Print(g, buf, 511);
|
||||
Tdbp->GetFilter()->Prints(g, buf, 511);
|
||||
htrc("To_Filter: %s\n", buf);
|
||||
} // endif To_Filter
|
||||
|
||||
@@ -426,41 +452,55 @@ bool MGOFAM::MakeCursor(PGLOBAL g)
|
||||
} else
|
||||
Query = bson_new();
|
||||
|
||||
if (Options && *Options) {
|
||||
if (trace)
|
||||
htrc("options=%s\n", Options);
|
||||
if (!all) {
|
||||
if (Options && *Options) {
|
||||
if (trace)
|
||||
htrc("options=%s\n", Options);
|
||||
|
||||
Opts = bson_new_from_json((const uint8_t *)Options, -1, &Error);
|
||||
} else {
|
||||
// Projection list
|
||||
if (s)
|
||||
s->Set("{\"projection\":{\"_id\":0");
|
||||
else
|
||||
s = new(g) STRING(g, 511, "{\"projection\":{\"_id\":0");
|
||||
p = Options;
|
||||
} else if (Tdbp->GetColumns()) {
|
||||
// Projection list
|
||||
if (s)
|
||||
s->Set("{\"projection\":{\"");
|
||||
else
|
||||
s = new(g) STRING(g, 511, "{\"projection\":{\"");
|
||||
|
||||
for (PCOL cp = Tdbp->GetColumns(); cp; cp = cp->GetNext()) {
|
||||
s->Append(",\"");
|
||||
if (!id)
|
||||
s->Append("_id\":0,\"");
|
||||
|
||||
if ((jp = ((PJCOL)cp)->GetJpath(g, true)))
|
||||
s->Append(jp);
|
||||
else {
|
||||
s->Reset();
|
||||
s->Resize(0);
|
||||
goto nope;
|
||||
} // endif Jpath
|
||||
for (PCOL cp = Tdbp->GetColumns(); cp; cp = cp->GetNext()) {
|
||||
if (b)
|
||||
s->Append(",\"");
|
||||
else
|
||||
b = true;
|
||||
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
if ((jp = ((PJCOL)cp)->GetJpath(g, true)))
|
||||
s->Append(jp);
|
||||
else {
|
||||
s->Reset();
|
||||
s->Resize(0);
|
||||
goto nope;
|
||||
} // endif Jpath
|
||||
|
||||
s->Append("}}");
|
||||
s->Resize(s->GetLength() + 1);
|
||||
Opts = bson_new_from_json((const uint8_t *)s->GetStr(), -1, &Error);
|
||||
} // endif Options
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
|
||||
if (!Opts) {
|
||||
sprintf(g->Message, "Wrong options: %s", Error.message);
|
||||
return true;
|
||||
} // endif Opts
|
||||
s->Append("}}");
|
||||
s->Resize(s->GetLength() + 1);
|
||||
p = s->GetStr();
|
||||
} else {
|
||||
// count(*) ?
|
||||
p = "{\"projection\":{\"_id\":1}}";
|
||||
} // endif Options
|
||||
|
||||
Opts = bson_new_from_json((const uint8_t *)p, -1, &Error);
|
||||
|
||||
if (!Opts) {
|
||||
sprintf(g->Message, "Wrong options: %s", Error.message);
|
||||
return true;
|
||||
} // endif Opts
|
||||
|
||||
} // endif all
|
||||
|
||||
nope:
|
||||
Cursor = mongoc_collection_find_with_opts(Collection, Query, Opts, NULL);
|
||||
|
||||
@@ -24,15 +24,15 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15),
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
Authors INT(2) FIELD_FORMAT='AUTHOR:[#]',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB'
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
Authors INT(2) FIELD_FORMAT='$.AUTHOR[#]',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='$.TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB'
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
SELECT * FROM t1;
|
||||
@@ -46,16 +46,16 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15),
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='AUTHOR:[" and "]:FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='AUTHOR:[" and "]:LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB'
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='$.AUTHOR[" and "].FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='$.AUTHOR[" and "].LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='$.TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB'
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
SELECT * FROM t1;
|
||||
@@ -69,16 +69,16 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15),
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB'
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='$.TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB'
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
SELECT * FROM t1;
|
||||
@@ -97,7 +97,7 @@ ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher L
|
||||
CREATE TABLE t2 (
|
||||
FIRSTNAME CHAR(32),
|
||||
LASTNAME CHAR(32))
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR';
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=$[1].AUTHOR';
|
||||
SELECT * FROM t2;
|
||||
FIRSTNAME LASTNAME
|
||||
William J. Pardi
|
||||
@@ -176,17 +176,17 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15) NOT NULL,
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATED:PREFIX',
|
||||
TranslatorFN CHAR(80) FIELD_FORMAT='TRANSLATED:TRANSLATOR:FIRSTNAME',
|
||||
TranslatorLN CHAR(80) FIELD_FORMAT='TRANSLATED:TRANSLATOR:LASTNAME',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB',
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATED.PREFIX',
|
||||
TranslatorFN CHAR(80) FIELD_FORMAT='$.TRANSLATED.TRANSLATOR.FIRSTNAME',
|
||||
TranslatorLN CHAR(80) FIELD_FORMAT='$.TRANSLATED.TRANSLATOR.LASTNAME',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB',
|
||||
INDEX IX(ISBN)
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0';
|
||||
@@ -209,9 +209,9 @@ DROP TABLE t1;
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[X]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK::EXPENSE:["+"]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK::EXPENSE:[+]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[*].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[].EXPENSE["+"].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[].EXPENSE[+].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t1;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -230,9 +230,9 @@ DROP TABLE t1;
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[X]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[X]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[X]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[*].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[*].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[*].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t1;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -266,14 +266,14 @@ DROP TABLE t1;
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12) NOT NULL,
|
||||
WEEKS CHAR(12) NOT NULL FIELD_FORMAT='WEEK:[", "]:NUMBER',
|
||||
SUMS CHAR(64) NOT NULL FIELD_FORMAT='WEEK:["+"]:EXPENSE:[+]:AMOUNT',
|
||||
SUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[+]:EXPENSE:[+]:AMOUNT',
|
||||
AVGS CHAR(64) NOT NULL FIELD_FORMAT='WEEK:["+"]:EXPENSE:[!]:AMOUNT',
|
||||
SUMAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[+]:EXPENSE:[!]:AMOUNT',
|
||||
AVGSUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[+]:AMOUNT',
|
||||
AVGAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[!]:AMOUNT',
|
||||
AVERAGE DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[X]:AMOUNT')
|
||||
WEEKS CHAR(12) NOT NULL FIELD_FORMAT='$.WEEK[", "].NUMBER',
|
||||
SUMS CHAR(64) NOT NULL FIELD_FORMAT='$.WEEK["+"].EXPENSE[+].AMOUNT',
|
||||
SUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[+].EXPENSE[+].AMOUNT',
|
||||
AVGS CHAR(64) NOT NULL FIELD_FORMAT='$.WEEK["+"].EXPENSE[!].AMOUNT',
|
||||
SUMAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[+].EXPENSE[!].AMOUNT',
|
||||
AVGSUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[!].EXPENSE[+].AMOUNT',
|
||||
AVGAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[!].EXPENSE[!].AMOUNT',
|
||||
AVERAGE DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[!].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t1;
|
||||
WHO WEEKS SUMS SUM AVGS SUMAVG AVGSUM AVGAVG AVERAGE
|
||||
@@ -286,9 +286,9 @@ DROP TABLE t1;
|
||||
#
|
||||
CREATE TABLE t2 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[0].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[0].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[0].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t2;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -302,9 +302,9 @@ Janet 3 Food 18.00
|
||||
Janet 3 Beer 18.00
|
||||
CREATE TABLE t3 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[1].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[1].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[1].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t3;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -318,9 +318,9 @@ Beth 4 Beer 15.00
|
||||
Janet 4 Car 17.00
|
||||
CREATE TABLE t4 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[2].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[2].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[2].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t4;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -374,8 +374,8 @@ DROP TABLE t1, t2, t3, t4;
|
||||
CREATE TABLE t2 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp3.json';
|
||||
SELECT * FROM t2;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -390,8 +390,8 @@ Janet 3 Beer 18.00
|
||||
CREATE TABLE t3 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp4.json';
|
||||
SELECT * FROM t3;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -406,8 +406,8 @@ Janet 4 Car 17.00
|
||||
CREATE TABLE t4 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp5.json';
|
||||
SELECT * FROM t4;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -425,8 +425,8 @@ Janet 5 Food 12.00
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp*.json' MULTIPLE=1;
|
||||
SELECT * FROM t1 ORDER BY WHO, WEEK, WHAT, AMOUNT;
|
||||
WHO WEEK WHAT AMOUNT
|
||||
@@ -461,8 +461,8 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp%s.json';
|
||||
ALTER TABLE t1
|
||||
PARTITION BY LIST COLUMNS(WEEK) (
|
||||
|
||||
@@ -35,18 +35,18 @@ JsonValue('[11, 22, 33]' json_)
|
||||
[11,22,33]
|
||||
[11,22,33]
|
||||
[11,22,33]
|
||||
SELECT Json_Array();
|
||||
Json_Array()
|
||||
SELECT Json_Make_Array();
|
||||
Json_Make_Array()
|
||||
[]
|
||||
SELECT Json_Array(56, 3.1416, 'My name is "Foo"', NULL);
|
||||
Json_Array(56, 3.1416, 'My name is "Foo"', NULL)
|
||||
SELECT Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL);
|
||||
Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL)
|
||||
[56,3.141600,"My name is \"Foo\"",null]
|
||||
SELECT Json_Array(Json_Array(56, 3.1416, 'foo'), TRUE);
|
||||
Json_Array(Json_Array(56, 3.1416, 'foo'), TRUE)
|
||||
SELECT Json_Make_Array(Json_Make_Array(56, 3.1416, 'foo'), TRUE);
|
||||
Json_Make_Array(Json_Make_Array(56, 3.1416, 'foo'), TRUE)
|
||||
[[56,3.141600,"foo"],true]
|
||||
SELECT Json_Array_Add(Json_Array(56, 3.1416, 'foo', NULL)) Array;
|
||||
SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL)) Array;
|
||||
ERROR HY000: Can't initialize function 'json_array_add'; This function must have at least 2 arguments
|
||||
SELECT Json_Array_Add(Json_Array(56, 3.1416, 'foo', NULL), 'One more') Array;
|
||||
SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL), 'One more') Array;
|
||||
Array
|
||||
[56,3.141600,"foo",null,"One more"]
|
||||
SELECT Json_Array_Add(JsonValue('one value'), 'One more');
|
||||
@@ -70,33 +70,33 @@ Array
|
||||
SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 9);
|
||||
Json_Array_Add('[5,3,8,7,9]' json_, 4, 9)
|
||||
[5,3,8,7,9,4]
|
||||
SELECT Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), '[2]', 33, 1);
|
||||
Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), '[2]', 33, 1)
|
||||
SELECT Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), '[2]', 33, 1);
|
||||
Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), '[2]', 33, 1)
|
||||
[1,2,[11,22],"[2]"]
|
||||
SELECT Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), 33, '[2]', 1);
|
||||
Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), 33, '[2]', 1)
|
||||
SELECT Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), 33, '[2]', 1);
|
||||
Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), 33, '[2]', 1)
|
||||
[1,2,[11,33,22]]
|
||||
SELECT Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), 33, 1, '[2]');
|
||||
Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), 33, 1, '[2]')
|
||||
SELECT Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), 33, 1, '[2]');
|
||||
Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), 33, 1, '[2]')
|
||||
[1,2,[11,33,22]]
|
||||
SELECT Json_Array_Add_Values(Json_Array(56, 3.1416, 'machin', NULL), 'One more', 'Two more') Array;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(56, 3.1416, 'machin', NULL), 'One more', 'Two more') Array;
|
||||
Array
|
||||
[56,3.141600,"machin",null,"One more","Two more"]
|
||||
SELECT Json_Array_Add_Values(Json_Array(56, 3.1416, 'machin'), 'One more', 'Two more') Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(56, 3.1416, 'machin'), 'One more', 'Two more') Array FROM t1;
|
||||
Array
|
||||
[56,3.141600,"machin","One more","Two more"]
|
||||
[56,3.141600,"machin","One more","Two more"]
|
||||
[56,3.141600,"machin","One more","Two more"]
|
||||
[56,3.141600,"machin","One more","Two more"]
|
||||
[56,3.141600,"machin","One more","Two more"]
|
||||
SELECT Json_Array_Add_Values(Json_Array(56, 3.1416, 'machin'), n) Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(56, 3.1416, 'machin'), n) Array FROM t1;
|
||||
Array
|
||||
[56,3.141600,"machin",1]
|
||||
[56,3.141600,"machin",2]
|
||||
[56,3.141600,"machin",3]
|
||||
[56,3.141600,"machin",4]
|
||||
[56,3.141600,"machin",5]
|
||||
SELECT Json_Array_Add_Values(Json_Array(n, 3.1416, 'machin'), n) Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(n, 3.1416, 'machin'), n) Array FROM t1;
|
||||
Array
|
||||
[1,3.141600,"machin",1]
|
||||
[2,3.141600,"machin",2]
|
||||
@@ -106,49 +106,49 @@ Array
|
||||
SELECT Json_Array_Add_Values('[56]', 3.1416, 'machin') Array;
|
||||
Array
|
||||
[56,3.141600,"machin"]
|
||||
SELECT Json_Array_Delete(Json_Array(56, 3.1416, 'My name is "Foo"', NULL), 0);
|
||||
Json_Array_Delete(Json_Array(56, 3.1416, 'My name is "Foo"', NULL), 0)
|
||||
SELECT Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), 0);
|
||||
Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), 0)
|
||||
[3.141600,"My name is \"Foo\"",null]
|
||||
SELECT Json_Array_Delete(Json_Object(56, 3.1416, 'My name is Foo', NULL), 2);
|
||||
Json_Array_Delete(Json_Object(56, 3.1416, 'My name is Foo', NULL), 2)
|
||||
SELECT Json_Array_Delete(Json_Make_Object(56, 3.1416, 'My name is Foo', NULL), 2);
|
||||
Json_Array_Delete(Json_Make_Object(56, 3.1416, 'My name is Foo', NULL), 2)
|
||||
{"56":56,"3.1416":3.141600,"My name is Foo":"My name is Foo","NULL":null}
|
||||
Warnings:
|
||||
Warning 1105 First argument target is not an array
|
||||
SELECT Json_Array_Delete(Json_Array(56, 3.1416, 'My name is "Foo"', NULL), '2');
|
||||
Json_Array_Delete(Json_Array(56, 3.1416, 'My name is "Foo"', NULL), '2')
|
||||
SELECT Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), '2');
|
||||
Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), '2')
|
||||
[56,3.141600,"My name is \"Foo\"",null]
|
||||
Warnings:
|
||||
Warning 1105 Missing or null array index
|
||||
SELECT Json_Array_Delete(json_array(56, 3.1416, 'My name is "Foo"', NULL), '2', 2);
|
||||
Json_Array_Delete(json_array(56, 3.1416, 'My name is "Foo"', NULL), '2', 2)
|
||||
SELECT Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), '2', 2);
|
||||
Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), '2', 2)
|
||||
[56,3.141600,"My name is \"Foo\"",null]
|
||||
Warnings:
|
||||
Warning 1105 No sub-item at '2'
|
||||
SELECT Json_Object(56, 3.1416, 'foo', NULL);
|
||||
Json_Object(56, 3.1416, 'foo', NULL)
|
||||
Warning 1105 First argument target is not an array
|
||||
SELECT Json_Make_Object(56, 3.1416, 'foo', NULL);
|
||||
Json_Make_Object(56, 3.1416, 'foo', NULL)
|
||||
{"56":56,"3.1416":3.141600,"foo":"foo","NULL":null}
|
||||
SELECT Json_Object(56 qty, 3.1416 price, 'foo' truc, NULL garanty);
|
||||
Json_Object(56 qty, 3.1416 price, 'foo' truc, NULL garanty)
|
||||
SELECT Json_Make_Object(56 qty, 3.1416 price, 'foo' truc, NULL garanty);
|
||||
Json_Make_Object(56 qty, 3.1416 price, 'foo' truc, NULL garanty)
|
||||
{"qty":56,"price":3.141600,"truc":"foo","garanty":null}
|
||||
SELECT Json_Object();
|
||||
Json_Object()
|
||||
SELECT Json_Make_Object();
|
||||
Json_Make_Object()
|
||||
{}
|
||||
SELECT Json_Object(Json_Array(56, 3.1416, 'foo'), NULL);
|
||||
Json_Object(Json_Array(56, 3.1416, 'foo'), NULL)
|
||||
{"Array(56, 3.1416, 'foo')":[56,3.141600,"foo"],"NULL":null}
|
||||
SELECT Json_Array(Json_Object(56 "qty", 3.1416 "price", 'foo') ,NULL);
|
||||
Json_Array(Json_Object(56 "qty", 3.1416 "price", 'foo') ,NULL)
|
||||
SELECT Json_Make_Object(Json_Make_Array(56, 3.1416, 'foo'), NULL);
|
||||
Json_Make_Object(Json_Make_Array(56, 3.1416, 'foo'), NULL)
|
||||
{"Make_Array(56, 3.1416, 'foo')":[56,3.141600,"foo"],"NULL":null}
|
||||
SELECT Json_Make_Array(Json_Make_Object(56 "qty", 3.1416 "price", 'foo') ,NULL);
|
||||
Json_Make_Array(Json_Make_Object(56 "qty", 3.1416 "price", 'foo') ,NULL)
|
||||
[{"qty":56,"price":3.141600,"foo":"foo"},null]
|
||||
SELECT Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty', NULL);
|
||||
Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty', NULL)
|
||||
{"qty":56,"price":3.141600,"truc":"machin","garanty":null}
|
||||
SELECT Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty');
|
||||
ERROR HY000: Can't initialize function 'json_object_key'; This function must have an even number of arguments
|
||||
SELECT Json_Object_Add(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'blue' color);
|
||||
Json_Object_Add(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'blue' color)
|
||||
SELECT Json_Object_Add(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'blue' color);
|
||||
Json_Object_Add(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'blue' color)
|
||||
{"qty":56,"price":3.141600,"truc":"machin","garanty":null,"color":"blue"}
|
||||
SELECT Json_Object_Add(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 45.99 price);
|
||||
Json_Object_Add(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 45.99 price)
|
||||
SELECT Json_Object_Add(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 45.99 price);
|
||||
Json_Object_Add(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 45.99 price)
|
||||
{"qty":56,"price":45.990000,"truc":"machin","garanty":null}
|
||||
SELECT Json_Object_Add(Json_File('notexist.json'), 'cheese' item, '[1]', 1);
|
||||
Json_Object_Add(Json_File('notexist.json'), 'cheese' item, '[1]', 1)
|
||||
@@ -156,13 +156,13 @@ NULL
|
||||
Warnings:
|
||||
Warning 1105 Error 2 opening notexist.json
|
||||
Warning 1105 First argument target is not an object
|
||||
SELECT Json_Object_Delete(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'truc');
|
||||
Json_Object_Delete(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'truc')
|
||||
SELECT Json_Object_Delete(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'truc');
|
||||
Json_Object_Delete(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'truc')
|
||||
{"qty":56,"price":3.141600,"garanty":null}
|
||||
SELECT Json_Object_Delete(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'chose');
|
||||
Json_Object_Delete(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'chose')
|
||||
SELECT Json_Object_Delete(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'chose');
|
||||
Json_Object_Delete(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'chose')
|
||||
{"qty":56,"price":3.141600,"truc":"machin","garanty":null}
|
||||
SELECT Json_Object_List(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty)) "Key List";
|
||||
SELECT Json_Object_List(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty)) "Key List";
|
||||
Key List
|
||||
["qty","price","truc","garanty"]
|
||||
SELECT Json_Object_List('{"qty":56, "price":3.1416, "truc":"machin", "garanty":null}') "Key List";
|
||||
@@ -183,12 +183,12 @@ TRANSLATOR CHAR(80),
|
||||
PUBLISHER CHAR(32),
|
||||
DATEPUB int(4)
|
||||
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
SELECT Json_Array(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
Json_Array(AUTHOR, TITLE, DATEPUB)
|
||||
SELECT Json_Make_Array(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
Json_Make_Array(AUTHOR, TITLE, DATEPUB)
|
||||
["Jean-Christophe Bernadac","Construire une application XML",1999]
|
||||
["William J. Pardi","XML en Action",1999]
|
||||
SELECT Json_Object(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
Json_Object(AUTHOR, TITLE, DATEPUB)
|
||||
SELECT Json_Make_Object(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
Json_Make_Object(AUTHOR, TITLE, DATEPUB)
|
||||
{"AUTHOR":"Jean-Christophe Bernadac","TITLE":"Construire une application XML","DATEPUB":1999}
|
||||
{"AUTHOR":"William J. Pardi","TITLE":"XML en Action","DATEPUB":1999}
|
||||
SELECT Json_Array_Grp(TITLE, DATEPUB) FROM t2;
|
||||
@@ -206,8 +206,8 @@ DEPARTMENT CHAr(4) NOT NULL FLAG=41,
|
||||
SECRETARY CHAR(5) DEFAULT NULL FLAG=46,
|
||||
SALARY DOUBLE(8,2) NOT NULL FLAG=52
|
||||
) ENGINE=CONNECT TABLE_TYPE=FIX BLOCK_SIZE=8 FILE_NAME='employee.dat' ENDING=1;
|
||||
SELECT Json_Object(SERIALNO, NAME, TITLE, SALARY) FROM t3 WHERE NAME = 'MERCHANT';
|
||||
Json_Object(SERIALNO, NAME, TITLE, SALARY)
|
||||
SELECT Json_Make_Object(SERIALNO, NAME, TITLE, SALARY) FROM t3 WHERE NAME = 'MERCHANT';
|
||||
Json_Make_Object(SERIALNO, NAME, TITLE, SALARY)
|
||||
{"SERIALNO":"78943","NAME":"MERCHANT","TITLE":"SALESMAN","SALARY":8700.000000}
|
||||
SELECT DEPARTMENT, Json_Array_Grp(NAME) FROM t3 GROUP BY DEPARTMENT;
|
||||
DEPARTMENT Json_Array_Grp(NAME)
|
||||
@@ -220,8 +220,8 @@ Warning 1105 Result truncated to json_grp_size values
|
||||
SELECT JsonSet_Grp_Size(30);
|
||||
JsonSet_Grp_Size(30)
|
||||
30
|
||||
SELECT Json_Object(title, Json_Array_Grp(name) `json_names`) from t3 GROUP BY title;
|
||||
Json_Object(title, Json_Array_Grp(name) `json_names`)
|
||||
SELECT Json_Make_Object(title, Json_Array_Grp(name) `json_names`) from t3 GROUP BY title;
|
||||
Json_Make_Object(title, Json_Array_Grp(name) `json_names`)
|
||||
{"title":"ADMINISTRATOR","names":["GOOSEPEN","FUNNIGUY","SHRINKY"]}
|
||||
{"title":"DIRECTOR","names":["QUINN","WERTHER","STRONG"]}
|
||||
{"title":"ENGINEER","names":["BROWNY","ORELLY","MARTIN","TONGHO","WALTER","SMITH"]}
|
||||
@@ -230,26 +230,26 @@ Json_Object(title, Json_Array_Grp(name) `json_names`)
|
||||
{"title":"SCIENTIST","names":["BIGHEAD","BIGHORN"]}
|
||||
{"title":"SECRETARY","names":["MESSIFUL","HONEY","SHORTSIGHT","CHERRY","MONAPENNY"]}
|
||||
{"title":"TYPIST","names":["KITTY","PLUMHEAD"]}
|
||||
SELECT Json_Array(DEPARTMENT, Json_Array_Grp(NAME)) FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Array(DEPARTMENT, Json_Array_Grp(NAME))
|
||||
SELECT Json_Make_Array(DEPARTMENT, Json_Array_Grp(NAME)) FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Make_Array(DEPARTMENT, Json_Array_Grp(NAME))
|
||||
["0021",["STRONG","SHORTSIGHT"]]
|
||||
["0318",["BANCROFT","PLUMHEAD","HONEY","TONGHO","WALTER","SHRINKY","WERTHER","MERCHANT","WHEELFOR"]]
|
||||
["0319",["BULLOZER","QUINN","BROWNY","KITTY","MONAPENNY","MARTIN","FUNNIGUY","BUGHAPPY","FODDERMAN","MESSIFUL","GOOSEPEN"]]
|
||||
["2452",["BIGHEAD","ORELLY","BIGHORN","SMITH","CHERRY"]]
|
||||
SELECT Json_Object(DEPARTMENT, Json_Array_Grp(NAME) json_NAMES) FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Object(DEPARTMENT, Json_Array_Grp(NAME) json_NAMES)
|
||||
SELECT Json_Make_Object(DEPARTMENT, Json_Array_Grp(NAME) json_NAMES) FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Make_Object(DEPARTMENT, Json_Array_Grp(NAME) json_NAMES)
|
||||
{"DEPARTMENT":"0021","NAMES":["STRONG","SHORTSIGHT"]}
|
||||
{"DEPARTMENT":"0318","NAMES":["BANCROFT","PLUMHEAD","HONEY","TONGHO","WALTER","SHRINKY","WERTHER","MERCHANT","WHEELFOR"]}
|
||||
{"DEPARTMENT":"0319","NAMES":["BULLOZER","QUINN","BROWNY","KITTY","MONAPENNY","MARTIN","FUNNIGUY","BUGHAPPY","FODDERMAN","MESSIFUL","GOOSEPEN"]}
|
||||
{"DEPARTMENT":"2452","NAMES":["BIGHEAD","ORELLY","BIGHORN","SMITH","CHERRY"]}
|
||||
SELECT Json_Object(DEPARTMENT, Json_Array_Grp(Json_Object(SERIALNO, NAME, TITLE, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Object(DEPARTMENT, Json_Array_Grp(Json_Object(SERIALNO, NAME, TITLE, SALARY)) json_EMPLOYES)
|
||||
SELECT Json_Make_Object(DEPARTMENT, Json_Array_Grp(Json_Make_Object(SERIALNO, NAME, TITLE, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Make_Object(DEPARTMENT, Json_Array_Grp(Json_Make_Object(SERIALNO, NAME, TITLE, SALARY)) json_EMPLOYES)
|
||||
{"DEPARTMENT":"0021","EMPLOYES":[{"SERIALNO":"87777","NAME":"STRONG","TITLE":"DIRECTOR","SALARY":23000.000000},{"SERIALNO":"22222","NAME":"SHORTSIGHT","TITLE":"SECRETARY","SALARY":5500.000000}]}
|
||||
{"DEPARTMENT":"0318","EMPLOYES":[{"SERIALNO":"74200","NAME":"BANCROFT","TITLE":"SALESMAN","SALARY":9600.000000},{"SERIALNO":"24888","NAME":"PLUMHEAD","TITLE":"TYPIST","SALARY":2800.000000},{"SERIALNO":"27845","NAME":"HONEY","TITLE":"SECRETARY","SALARY":4900.000000},{"SERIALNO":"73452","NAME":"TONGHO","TITLE":"ENGINEER","SALARY":6800.000000},{"SERIALNO":"74234","NAME":"WALTER","TITLE":"ENGINEER","SALARY":7400.000000},{"SERIALNO":"77777","NAME":"SHRINKY","TITLE":"ADMINISTRATOR","SALARY":7500.000000},{"SERIALNO":"70012","NAME":"WERTHER","TITLE":"DIRECTOR","SALARY":14500.000000},{"SERIALNO":"78943","NAME":"MERCHANT","TITLE":"SALESMAN","SALARY":8700.000000},{"SERIALNO":"73111","NAME":"WHEELFOR","TITLE":"SALESMAN","SALARY":10030.000000}]}
|
||||
{"DEPARTMENT":"0319","EMPLOYES":[{"SERIALNO":"76543","NAME":"BULLOZER","TITLE":"SALESMAN","SALARY":14800.000000},{"SERIALNO":"40567","NAME":"QUINN","TITLE":"DIRECTOR","SALARY":14000.000000},{"SERIALNO":"00137","NAME":"BROWNY","TITLE":"ENGINEER","SALARY":10500.000000},{"SERIALNO":"12345","NAME":"KITTY","TITLE":"TYPIST","SALARY":3000.450000},{"SERIALNO":"33333","NAME":"MONAPENNY","TITLE":"SECRETARY","SALARY":3800.000000},{"SERIALNO":"00023","NAME":"MARTIN","TITLE":"ENGINEER","SALARY":10000.000000},{"SERIALNO":"07654","NAME":"FUNNIGUY","TITLE":"ADMINISTRATOR","SALARY":8500.000000},{"SERIALNO":"45678","NAME":"BUGHAPPY","TITLE":"PROGRAMMER","SALARY":8500.000000},{"SERIALNO":"56789","NAME":"FODDERMAN","TITLE":"SALESMAN","SALARY":7000.000000},{"SERIALNO":"55555","NAME":"MESSIFUL","TITLE":"SECRETARY","SALARY":5000.500000},{"SERIALNO":"98765","NAME":"GOOSEPEN","TITLE":"ADMINISTRATOR","SALARY":4700.000000}]}
|
||||
{"DEPARTMENT":"2452","EMPLOYES":[{"SERIALNO":"34567","NAME":"BIGHEAD","TITLE":"SCIENTIST","SALARY":8000.000000},{"SERIALNO":"31416","NAME":"ORELLY","TITLE":"ENGINEER","SALARY":13400.000000},{"SERIALNO":"36666","NAME":"BIGHORN","TITLE":"SCIENTIST","SALARY":11000.000000},{"SERIALNO":"02345","NAME":"SMITH","TITLE":"ENGINEER","SALARY":9000.000000},{"SERIALNO":"11111","NAME":"CHERRY","TITLE":"SECRETARY","SALARY":4500.000000}]}
|
||||
SELECT Json_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Object(SERIALNO, NAME, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT, TITLE;
|
||||
Json_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Object(SERIALNO, NAME, SALARY)) json_EMPLOYES)
|
||||
SELECT Json_Make_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Make_Object(SERIALNO, NAME, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT, TITLE;
|
||||
Json_Make_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Make_Object(SERIALNO, NAME, SALARY)) json_EMPLOYES)
|
||||
{"DEPARTMENT":"0021","TITLE":"DIRECTOR","EMPLOYES":[{"SERIALNO":"87777","NAME":"STRONG","SALARY":23000.000000}]}
|
||||
{"DEPARTMENT":"0021","TITLE":"SECRETARY","EMPLOYES":[{"SERIALNO":"22222","NAME":"SHORTSIGHT","SALARY":5500.000000}]}
|
||||
{"DEPARTMENT":"0318","TITLE":"ADMINISTRATOR","EMPLOYES":[{"SERIALNO":"77777","NAME":"SHRINKY","SALARY":7500.000000}]}
|
||||
@@ -273,8 +273,8 @@ ERROR HY000: Can't initialize function 'json_object_grp'; This function requires
|
||||
SELECT Json_Object_Grp(NAME, SALARY) FROM t3;
|
||||
Json_Object_Grp(NAME, SALARY)
|
||||
{"BANCROFT":9600.000000,"SMITH":9000.000000,"MERCHANT":8700.000000,"FUNNIGUY":8500.000000,"BUGHAPPY":8500.000000,"BIGHEAD":8000.000000,"SHRINKY":7500.000000,"WALTER":7400.000000,"FODDERMAN":7000.000000,"TONGHO":6800.000000,"SHORTSIGHT":5500.000000,"MESSIFUL":5000.500000,"HONEY":4900.000000,"GOOSEPEN":4700.000000,"CHERRY":4500.000000,"MONAPENNY":3800.000000,"KITTY":3000.450000,"PLUMHEAD":2800.000000,"STRONG":23000.000000,"BULLOZER":14800.000000,"WERTHER":14500.000000,"QUINN":14000.000000,"ORELLY":13400.000000,"BIGHORN":11000.000000,"BROWNY":10500.000000,"WHEELFOR":10030.000000,"MARTIN":10000.000000}
|
||||
SELECT Json_Object(DEPARTMENT, Json_Object_Grp(NAME, SALARY) "Json_SALARIES") FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Object(DEPARTMENT, Json_Object_Grp(NAME, SALARY) "Json_SALARIES")
|
||||
SELECT Json_Make_Object(DEPARTMENT, Json_Object_Grp(NAME, SALARY) "Json_SALARIES") FROM t3 GROUP BY DEPARTMENT;
|
||||
Json_Make_Object(DEPARTMENT, Json_Object_Grp(NAME, SALARY) "Json_SALARIES")
|
||||
{"DEPARTMENT":"0021","SALARIES":{"STRONG":23000.000000,"SHORTSIGHT":5500.000000}}
|
||||
{"DEPARTMENT":"0318","SALARIES":{"BANCROFT":9600.000000,"PLUMHEAD":2800.000000,"HONEY":4900.000000,"TONGHO":6800.000000,"WALTER":7400.000000,"SHRINKY":7500.000000,"WERTHER":14500.000000,"MERCHANT":8700.000000,"WHEELFOR":10030.000000}}
|
||||
{"DEPARTMENT":"0319","SALARIES":{"BULLOZER":14800.000000,"QUINN":14000.000000,"BROWNY":10500.000000,"KITTY":3000.450000,"MONAPENNY":3800.000000,"MARTIN":10000.000000,"FUNNIGUY":8500.000000,"BUGHAPPY":8500.000000,"FODDERMAN":7000.000000,"MESSIFUL":5000.500000,"GOOSEPEN":4700.000000}}
|
||||
@@ -309,26 +309,26 @@ SELECT JsonGet_String(Json_Array_Grp(name),'[>]') FROM t3;
|
||||
JsonGet_String(Json_Array_Grp(name),'[>]')
|
||||
WHEELFOR
|
||||
SET @j1 = '[45,28,36,45,89]';
|
||||
SELECT JsonGet_String(@j1,'[1]');
|
||||
JsonGet_String(@j1,'[1]')
|
||||
SELECT JsonGet_String(@j1,'1');
|
||||
JsonGet_String(@j1,'1')
|
||||
28
|
||||
SELECT JsonGet_String(@j1 json_,'[3]');
|
||||
JsonGet_String(@j1 json_,'[3]')
|
||||
SELECT JsonGet_String(@j1 json_,'3');
|
||||
JsonGet_String(@j1 json_,'3')
|
||||
45
|
||||
SELECT JsonGet_String(Json_Array(45,28,36,45,89),'[3]');
|
||||
JsonGet_String(Json_Array(45,28,36,45,89),'[3]')
|
||||
SELECT JsonGet_String(Json_Make_Array(45,28,36,45,89),'3');
|
||||
JsonGet_String(Json_Make_Array(45,28,36,45,89),'3')
|
||||
45
|
||||
SELECT JsonGet_String(Json_Array(45,28,36,45,89),'["+"]') "list",'=' as "egal",JsonGet_String(Json_Array(45,28,36,45,89),'[+]') "sum";
|
||||
SELECT JsonGet_String(Json_Make_Array(45,28,36,45,89),'["+"]') "list",'=' as "egal",JsonGet_String(Json_Make_Array(45,28,36,45,89),'[+]') "sum";
|
||||
list egal sum
|
||||
45+28+36+45+89 = 243.00
|
||||
SELECT JsonGet_String(Json_Array(json_array(45,28),json_array(36,45,89)),'[1]:[0]');
|
||||
JsonGet_String(Json_Array(json_array(45,28),json_array(36,45,89)),'[1]:[0]')
|
||||
SELECT JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)),'1.0');
|
||||
JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)),'1.0')
|
||||
36
|
||||
SELECT JsonGet_String(Json_Array(json_array(45,28),json_array(36,45,89)),'[1]:*');
|
||||
JsonGet_String(Json_Array(json_array(45,28),json_array(36,45,89)),'[1]:*')
|
||||
SELECT JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)),'1.*');
|
||||
JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)),'1.*')
|
||||
[36,45,89]
|
||||
SELECT JsonGet_String(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'truc');
|
||||
JsonGet_String(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'truc')
|
||||
SELECT JsonGet_String(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'truc');
|
||||
JsonGet_String(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'truc')
|
||||
machin
|
||||
SET @j2 = '{"qty":56,"price":3.141600,"truc":"machin","garanty":null}';
|
||||
SELECT JsonGet_String(@j2 json_,'truc');
|
||||
@@ -345,14 +345,14 @@ JsonGet_String(NULL json_, NULL)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1105
|
||||
SELECT department, JsonGet_String(Json_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries:[+]') Sumsal FROM t3 GROUP BY department;
|
||||
SELECT department, JsonGet_String(Json_Make_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries.[+]') Sumsal FROM t3 GROUP BY department;
|
||||
department Sumsal
|
||||
0021 28500.00
|
||||
0318 72230.00
|
||||
0319 89800.95
|
||||
2452 45900.00
|
||||
SELECT JsonGet_Int(@j1, '[4]');
|
||||
JsonGet_Int(@j1, '[4]')
|
||||
SELECT JsonGet_Int(@j1, '4');
|
||||
JsonGet_Int(@j1, '4')
|
||||
89
|
||||
SELECT JsonGet_Int(@j1, '[#]');
|
||||
JsonGet_Int(@j1, '[#]')
|
||||
@@ -360,26 +360,26 @@ JsonGet_Int(@j1, '[#]')
|
||||
SELECT JsonGet_Int(@j1, '[+]');
|
||||
JsonGet_Int(@j1, '[+]')
|
||||
243
|
||||
SELECT JsonGet_Int(@j1 json_, '[3]');
|
||||
JsonGet_Int(@j1 json_, '[3]')
|
||||
SELECT JsonGet_Int(@j1 json_, '3');
|
||||
JsonGet_Int(@j1 json_, '3')
|
||||
45
|
||||
SELECT JsonGet_Int(Json_Array(45,28,36,45,89), '[3]');
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[3]')
|
||||
SELECT JsonGet_Int(Json_Make_Array(45,28,36,45,89), '3');
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '3')
|
||||
45
|
||||
SELECT JsonGet_Int(Json_Array(45,28,36,45,89), '["+"]');
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '["+"]')
|
||||
SELECT JsonGet_Int(Json_Make_Array(45,28,36,45,89), '["+"]');
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '["+"]')
|
||||
45
|
||||
SELECT JsonGet_Int(Json_Array(45,28,36,45,89), '[+]');
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[+]')
|
||||
SELECT JsonGet_Int(Json_Make_Array(45,28,36,45,89), '[+]');
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '[+]')
|
||||
243
|
||||
SELECT JsonGet_Int(Json_Array(json_array(45,28), json_array(36,45,89)), '[1]:[0]');
|
||||
JsonGet_Int(Json_Array(json_array(45,28), json_array(36,45,89)), '[1]:[0]')
|
||||
SELECT JsonGet_Int(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '1.0');
|
||||
JsonGet_Int(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '1.0')
|
||||
36
|
||||
SELECT JsonGet_Int(Json_Array(json_array(45,28), json_array(36,45,89)), '[0]:[1]');
|
||||
JsonGet_Int(Json_Array(json_array(45,28), json_array(36,45,89)), '[0]:[1]')
|
||||
SELECT JsonGet_Int(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '0.1');
|
||||
JsonGet_Int(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '0.1')
|
||||
28
|
||||
SELECT JsonGet_Int(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'qty');
|
||||
JsonGet_Int(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'qty')
|
||||
SELECT JsonGet_Int(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'qty');
|
||||
JsonGet_Int(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'qty')
|
||||
56
|
||||
SELECT JsonGet_Int(@j2 json_, 'price');
|
||||
JsonGet_Int(@j2 json_, 'price')
|
||||
@@ -390,38 +390,38 @@ JsonGet_Int(@j2, 'qty')
|
||||
SELECT JsonGet_Int('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'chose');
|
||||
JsonGet_Int('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'chose')
|
||||
NULL
|
||||
SELECT JsonGet_Int(JsonGet_String(Json_Array(Json_Array(45,28),Json_Array(36,45,89)), '[1]:*'), '[+]') sum;
|
||||
SELECT JsonGet_Int(JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)), '1.*'), '[+]') sum;
|
||||
sum
|
||||
170
|
||||
SELECT department, JsonGet_Int(Json_Object(department, Json_Array_Grp(salary) "Json_salaries"), 'salaries:[+]') Sumsal FROM t3 GROUP BY department;
|
||||
SELECT department, JsonGet_Int(Json_Make_Object(department, Json_Array_Grp(salary) "Json_salaries"), 'salaries.[+]') Sumsal FROM t3 GROUP BY department;
|
||||
department Sumsal
|
||||
0021 28500
|
||||
0318 72230
|
||||
0319 89800
|
||||
2452 45900
|
||||
SELECT JsonGet_Real(@j1, '[2]');
|
||||
JsonGet_Real(@j1, '[2]')
|
||||
SELECT JsonGet_Real(@j1, '2');
|
||||
JsonGet_Real(@j1, '2')
|
||||
36.000000000000000
|
||||
SELECT JsonGet_Real(@j1 json_, '[3]', 2);
|
||||
JsonGet_Real(@j1 json_, '[3]', 2)
|
||||
SELECT JsonGet_Real(@j1 json_, '3', 2);
|
||||
JsonGet_Real(@j1 json_, '3', 2)
|
||||
45.00
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '[3]');
|
||||
JsonGet_Real(Json_Array(45,28,36,45,89), '[3]')
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '3');
|
||||
JsonGet_Real(Json_Make_Array(45,28,36,45,89), '3')
|
||||
45.000000000000000
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '["+"]');
|
||||
JsonGet_Real(Json_Array(45,28,36,45,89), '["+"]')
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '["+"]');
|
||||
JsonGet_Real(Json_Make_Array(45,28,36,45,89), '["+"]')
|
||||
45.000000000000000
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '[+]');
|
||||
JsonGet_Real(Json_Array(45,28,36,45,89), '[+]')
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[+]');
|
||||
JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[+]')
|
||||
243.000000000000000
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '[!]');
|
||||
JsonGet_Real(Json_Array(45,28,36,45,89), '[!]')
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[!]');
|
||||
JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[!]')
|
||||
48.600000000000000
|
||||
SELECT JsonGet_Real(Json_Array(json_array(45,28), json_array(36,45,89)), '[1]:[0]');
|
||||
JsonGet_Real(Json_Array(json_array(45,28), json_array(36,45,89)), '[1]:[0]')
|
||||
SELECT JsonGet_Real(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '1.0');
|
||||
JsonGet_Real(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '1.0')
|
||||
36.000000000000000
|
||||
SELECT JsonGet_Real(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'price');
|
||||
JsonGet_Real(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'price')
|
||||
SELECT JsonGet_Real(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'price');
|
||||
JsonGet_Real(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'price')
|
||||
3.141600000000000
|
||||
SELECT JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}' json_, 'qty');
|
||||
JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}' json_, 'qty')
|
||||
@@ -435,7 +435,7 @@ JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'pric
|
||||
SELECT JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'chose');
|
||||
JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'chose')
|
||||
NULL
|
||||
SELECT department, JsonGet_Real(Json_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries:[+]') Sumsal FROM t3 GROUP BY department;
|
||||
SELECT department, JsonGet_Real(Json_Make_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries.[+]') Sumsal FROM t3 GROUP BY department;
|
||||
department Sumsal
|
||||
0021 28500.000000000000000
|
||||
0318 72230.000000000000000
|
||||
@@ -445,11 +445,11 @@ department Sumsal
|
||||
# Documentation examples
|
||||
#
|
||||
SELECT
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[4]') "Rank",
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[#]') "Number",
|
||||
JsonGet_String(Json_Array(45,28,36,45,89), '[","]') "Concat",
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[+]') "Sum",
|
||||
JsonGet_Real(Json_Array(45,28,36,45,89), '[!]', 2) "Avg";
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '4') "Rank",
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '[#]') "Number",
|
||||
JsonGet_String(Json_Make_Array(45,28,36,45,89), '[","]') "Concat",
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '[+]') "Sum",
|
||||
JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[!]', 2) "Avg";
|
||||
Rank Number Concat Sum Avg
|
||||
89 5 45,28,36,45,89 243 48.60
|
||||
SELECT
|
||||
@@ -464,33 +464,33 @@ Real
|
||||
#
|
||||
# Testing Locate
|
||||
#
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'machin');
|
||||
JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'machin')
|
||||
truc
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),56);
|
||||
JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),56)
|
||||
qty
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),3.1416);
|
||||
JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),3.1416)
|
||||
price
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'chose');
|
||||
JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'chose')
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'machin');
|
||||
JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'machin')
|
||||
$.truc
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),56);
|
||||
JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),56)
|
||||
$.qty
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),3.1416);
|
||||
JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),3.1416)
|
||||
$.price
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'chose');
|
||||
JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'chose')
|
||||
NULL
|
||||
SELECT JsonLocate('{"AUTHORS":[{"FN":"Jules", "LN":"Verne"}, {"FN":"Jack", "LN":"London"}]}' json_, 'Jack') Path;
|
||||
Path
|
||||
AUTHORS:[1]:FN
|
||||
$.AUTHORS[1].FN
|
||||
SELECT JsonLocate('{"AUTHORS":[{"FN":"Jules", "LN":"Verne"}, {"FN":"Jack", "LN":"London"}]}' json_, 'jack' ci) Path;
|
||||
Path
|
||||
AUTHORS:[1]:FN
|
||||
$.AUTHORS[1].FN
|
||||
SELECT JsonLocate('{"AUTHORS":[{"FN":"Jules", "LN":"Verne"}, {"FN":"Jack", "LN":"London"}]}' json_, '{"FN":"Jack", "LN":"London"}' json_) Path;
|
||||
Path
|
||||
AUTHORS:[1]
|
||||
$.AUTHORS[1]
|
||||
SELECT JsonLocate('{"AUTHORS":[{"FN":"Jules", "LN":"Verne"}, {"FN":"Jack", "LN":"London"}]}' json_, '{"FN":"jack", "LN":"London"}' json_) Path;
|
||||
Path
|
||||
NULL
|
||||
SELECT JsonLocate('[45,28,36,45,89]',36);
|
||||
JsonLocate('[45,28,36,45,89]',36)
|
||||
[2]
|
||||
$[2]
|
||||
SELECT JsonLocate('[45,28,36,45,89]' json_,28.0);
|
||||
JsonLocate('[45,28,36,45,89]' json_,28.0)
|
||||
NULL
|
||||
@@ -499,71 +499,71 @@ Json_Locate_All('[45,28,36,45,89]',10)
|
||||
[]
|
||||
SELECT Json_Locate_All('[45,28,36,45,89]',45);
|
||||
Json_Locate_All('[45,28,36,45,89]',45)
|
||||
["[0]","[3]"]
|
||||
["$[0]","$[3]"]
|
||||
SELECT Json_Locate_All('[[45,28],36,45,89]',45);
|
||||
Json_Locate_All('[[45,28],36,45,89]',45)
|
||||
["[0]:[0]","[2]"]
|
||||
["$[0][0]","$[2]"]
|
||||
SELECT Json_Locate_All('[[45,28,45],36,45,89]',45);
|
||||
Json_Locate_All('[[45,28,45],36,45,89]',45)
|
||||
["[0]:[0]","[0]:[2]","[2]"]
|
||||
["$[0][0]","$[0][2]","$[2]"]
|
||||
SELECT Json_Locate_All('[[45,28,45],36,45,89]',JsonGet_Int('[3,45]','[1]'));
|
||||
Json_Locate_All('[[45,28,45],36,45,89]',JsonGet_Int('[3,45]','[1]'))
|
||||
["[0]:[0]","[0]:[2]","[2]"]
|
||||
["$[0][0]","$[0][2]","$[2]"]
|
||||
SELECT JsonLocate('[[45,28,45],36,45,89]',45,n) from t1;
|
||||
JsonLocate('[[45,28,45],36,45,89]',45,n)
|
||||
[0]:[0]
|
||||
[0]:[2]
|
||||
[2]
|
||||
$[0][0]
|
||||
$[0][2]
|
||||
$[2]
|
||||
NULL
|
||||
NULL
|
||||
SELECT JsonGet_String(Json_Locate_All('[[45,28,45],36,45,89]',45),concat('[',n-1,']')) FROM t1;
|
||||
JsonGet_String(Json_Locate_All('[[45,28,45],36,45,89]',45),concat('[',n-1,']'))
|
||||
[0]:[0]
|
||||
[0]:[2]
|
||||
[2]
|
||||
$[0][0]
|
||||
$[0][2]
|
||||
$[2]
|
||||
NULL
|
||||
NULL
|
||||
SELECT JsonGet_String(Json_Locate_All('[[45,28,45],36,45,89]',45),concat('[',n-1,']')) AS `Path` FROM t1 GROUP BY n HAVING `Path` IS NOT NULL;
|
||||
Path
|
||||
[0]:[0]
|
||||
[0]:[2]
|
||||
[2]
|
||||
$[0][0]
|
||||
$[0][2]
|
||||
$[2]
|
||||
SELECT Json_Locate_All('[45,28,[36,45,89]]',45);
|
||||
Json_Locate_All('[45,28,[36,45,89]]',45)
|
||||
["[0]","[2]:[1]"]
|
||||
["$[0]","$[2][1]"]
|
||||
SELECT Json_Locate_All('[[45,28],[36,45.0,89]]',JsonValue(45.0));
|
||||
Json_Locate_All('[[45,28],[36,45.0,89]]',JsonValue(45.0))
|
||||
[]
|
||||
SELECT Json_Locate_All('[[45,28],[36,45.0,89]]',45.0);
|
||||
Json_Locate_All('[[45,28],[36,45.0,89]]',45.0)
|
||||
["[1]:[1]"]
|
||||
["$[1][1]"]
|
||||
SELECT JsonLocate('[[45,28],[36,45,89]]','[36,45,89]' json_);
|
||||
JsonLocate('[[45,28],[36,45,89]]','[36,45,89]' json_)
|
||||
[1]
|
||||
$[1]
|
||||
SELECT JsonLocate('[[45,28],[36,45,89]]','[45,28]' json_);
|
||||
JsonLocate('[[45,28],[36,45,89]]','[45,28]' json_)
|
||||
[0]
|
||||
$[0]
|
||||
SELECT Json_Locate_All('[[45,28],[[36,45],89]]','45') "All paths";
|
||||
All paths
|
||||
[]
|
||||
SELECT Json_Locate_All('[[45,28],[[36,45],89]]','[36,45]' json_);
|
||||
Json_Locate_All('[[45,28],[[36,45],89]]','[36,45]' json_)
|
||||
["[1]:[0]"]
|
||||
["$[1][0]"]
|
||||
SELECT JsonGet_Int(Json_Locate_All('[[45,28],[[36,45],89]]',45), '[#]') "Nb of occurs";
|
||||
Nb of occurs
|
||||
2
|
||||
SELECT Json_Locate_All('[[45,28],[[36,45],89]]',45,2);
|
||||
Json_Locate_All('[[45,28],[[36,45],89]]',45,2)
|
||||
["[0]:[0]"]
|
||||
SELECT JsonGet_String(Json_Locate_All('[45,28,36,45,89]',45),'[0]');
|
||||
JsonGet_String(Json_Locate_All('[45,28,36,45,89]',45),'[0]')
|
||||
[0]
|
||||
["$[0][0]"]
|
||||
SELECT JsonGet_String(Json_Locate_All('[45,28,36,45,89]',45),'0');
|
||||
JsonGet_String(Json_Locate_All('[45,28,36,45,89]',45),'0')
|
||||
$[0]
|
||||
SELECT JsonLocate(Json_File('test/biblio.json'), 'Knab');
|
||||
JsonLocate(Json_File('test/biblio.json'), 'Knab')
|
||||
[0]:AUTHOR:[1]:LASTNAME
|
||||
$[0].AUTHOR[1].LASTNAME
|
||||
SELECT Json_Locate_All('test/biblio.json' jfile_, 'Knab');
|
||||
Json_Locate_All('test/biblio.json' jfile_, 'Knab')
|
||||
["[0]:AUTHOR:[1]:LASTNAME"]
|
||||
["$[0].AUTHOR[1].LASTNAME"]
|
||||
#
|
||||
# Testing json files
|
||||
#
|
||||
@@ -595,54 +595,54 @@ Warning 1105 File pretty format doesn't match the specified pretty value
|
||||
SELECT Json_File('test/fx.json', 0);
|
||||
Json_File('test/fx.json', 0)
|
||||
[{"_id":5,"type":"food","item":"beer","taste":"light","price":5.65,"ratings":[5,8,9]},{"_id":6,"type":"car","item":"roadster","mileage":56000,"ratings":[6,9]},{"_id":7,"type":"food","item":"meat","origin":"argentina","ratings":[2,4]},{"_id":8,"type":"furniture","item":"table","size":{"W":60,"L":80,"H":40},"ratings":[5,8,7]}]
|
||||
SELECT Json_File('test/fx.json', '[0]');
|
||||
Json_File('test/fx.json', '[0]')
|
||||
SELECT Json_File('test/fx.json', '0');
|
||||
Json_File('test/fx.json', '0')
|
||||
{"_id":5,"type":"food","item":"beer","taste":"light","price":5.65,"ratings":[5,8,9]}
|
||||
SELECT Json_File('test/fx.json', '[?]');
|
||||
Json_File('test/fx.json', '[?]')
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1105 Invalid function specification ?
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '[1]:*');
|
||||
JsonGet_String(Json_File('test/fx.json'), '[1]:*')
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '1.*');
|
||||
JsonGet_String(Json_File('test/fx.json'), '1.*')
|
||||
{"_id":6,"type":"car","item":"roadster","mileage":56000,"ratings":[6,9]}
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '[1]');
|
||||
JsonGet_String(Json_File('test/fx.json'), '[1]')
|
||||
6 car roadster 56000 ???
|
||||
SELECT JsonGet_Int(Json_File('test/fx.json'), '[1]:mileage') AS Mileage;
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '1');
|
||||
JsonGet_String(Json_File('test/fx.json'), '1')
|
||||
6 car roadster 56000 <null>
|
||||
SELECT JsonGet_Int(Json_File('test/fx.json'), '1.mileage') AS Mileage;
|
||||
Mileage
|
||||
56000
|
||||
SELECT JsonGet_Real(Json_File('test/fx.json'), '[0]:price', 2) AS Price;
|
||||
SELECT JsonGet_Real(Json_File('test/fx.json'), '0.price', 2) AS Price;
|
||||
Price
|
||||
5.65
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 'ratings');
|
||||
Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 'ratings')
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2'), 6, 'ratings');
|
||||
Json_Array_Add(Json_File('test/fx.json', '2'), 6, 'ratings')
|
||||
{"_id":7,"type":"food","item":"meat","origin":"argentina","ratings":[2,4,6]}
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 1, 'ratings');
|
||||
Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 1, 'ratings')
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2'), 6, 1, 'ratings');
|
||||
Json_Array_Add(Json_File('test/fx.json', '2'), 6, 1, 'ratings')
|
||||
{"_id":7,"type":"food","item":"meat","origin":"argentina","ratings":[2,6,4]}
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 'ratings', 1);
|
||||
Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 'ratings', 1)
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2'), 6, 'ratings', 1);
|
||||
Json_Array_Add(Json_File('test/fx.json', '2'), 6, 'ratings', 1)
|
||||
{"_id":7,"type":"food","item":"meat","origin":"argentina","ratings":[2,6,4]}
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]:ratings'), 6, 0);
|
||||
Json_Array_Add(Json_File('test/fx.json', '[2]:ratings'), 6, 0)
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2.ratings'), 6, 0);
|
||||
Json_Array_Add(Json_File('test/fx.json', '2.ratings'), 6, 0)
|
||||
[6,2,4]
|
||||
SELECT Json_Array_Delete(Json_File('test/fx.json', '[2]'), 'ratings', 1);
|
||||
Json_Array_Delete(Json_File('test/fx.json', '[2]'), 'ratings', 1)
|
||||
SELECT Json_Array_Delete(Json_File('test/fx.json', '2'), 'ratings', 1);
|
||||
Json_Array_Delete(Json_File('test/fx.json', '2'), 'ratings', 1)
|
||||
{"_id":7,"type":"food","item":"meat","origin":"argentina","ratings":[2]}
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '[2]'), 'france' origin);
|
||||
Json_Object_Add(Json_File('test/fx.json', '[2]'), 'france' origin)
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '2'), 'france' origin);
|
||||
Json_Object_Add(Json_File('test/fx.json', '2'), 'france' origin)
|
||||
{"_id":7,"type":"food","item":"meat","origin":"france","ratings":[2,4]}
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '[2]'), 70 H, 'size');
|
||||
Json_Object_Add(Json_File('test/fx.json', '[2]'), 70 H, 'size')
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '2'), 70 H, 'size');
|
||||
Json_Object_Add(Json_File('test/fx.json', '2'), 70 H, 'size')
|
||||
{"_id":7,"type":"food","item":"meat","origin":"argentina","ratings":[2,4]}
|
||||
Warnings:
|
||||
Warning 1105 No sub-item at 'size'
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '[3]'), 70 H, 'size');
|
||||
Json_Object_Add(Json_File('test/fx.json', '[3]'), 70 H, 'size')
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '3'), 70 H, 'size');
|
||||
Json_Object_Add(Json_File('test/fx.json', '3'), 70 H, 'size')
|
||||
{"_id":8,"type":"furniture","item":"table","size":{"W":60,"L":80,"H":70},"ratings":[5,8,7]}
|
||||
SELECT Json_Object_List(Json_File('test/fx.json', '[3]:size'));
|
||||
Json_Object_List(Json_File('test/fx.json', '[3]:size'))
|
||||
SELECT Json_Object_List(Json_File('test/fx.json', '3.size'));
|
||||
Json_Object_List(Json_File('test/fx.json', '3.size'))
|
||||
["W","L","H"]
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
@@ -29,8 +29,8 @@ Json_Array_Delete(Jbin_Array(56, Jbin_Array(3.1416, 'My name is "Foo"'), NULL),
|
||||
SELECT Json_Array_Delete(Jbin_Array(56, Jbin_Array(3.1416, 'My name is "Foo"'), TRUE), 1, '[1]');
|
||||
Json_Array_Delete(Jbin_Array(56, Jbin_Array(3.1416, 'My name is "Foo"'), TRUE), 1, '[1]')
|
||||
[56,[3.141600],true]
|
||||
SELECT Json_Array(1, TRUE, 0, FALSE);
|
||||
Json_Array(1, TRUE, 0, FALSE)
|
||||
SELECT Json_Make_Array(1, TRUE, 0, FALSE);
|
||||
Json_Make_Array(1, TRUE, 0, FALSE)
|
||||
[1,true,0,false]
|
||||
SELECT Json_Serialize(Jbin_Array(TRUE, FALSE));
|
||||
Json_Serialize(Jbin_Array(TRUE, FALSE))
|
||||
@@ -63,94 +63,94 @@ Json_Serialize(Jbin_File('gloss.json'))
|
||||
{"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}}}
|
||||
SELECT JsonLocate(Jbin_File('gloss.json'),'XML');
|
||||
JsonLocate(Jbin_File('gloss.json'),'XML')
|
||||
glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso:[1]
|
||||
$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso[1]
|
||||
SELECT Json_Object_Key('first', 'foo', 'second', Jbin_Array('a', 33));
|
||||
Json_Object_Key('first', 'foo', 'second', Jbin_Array('a', 33))
|
||||
{"first":"foo","second":["a",33]}
|
||||
SELECT Json_Get_Item(Json_Array('a','b','c'), '[1]');
|
||||
Json_Get_Item(Json_Array('a','b','c'), '[1]')
|
||||
SELECT Json_Get_Item(Json_Make_Array('a','b','c'), '$[1]');
|
||||
Json_Get_Item(Json_Make_Array('a','b','c'), '$[1]')
|
||||
NULL
|
||||
SELECT Json_Get_Item(Json_Object('foo' AS "first", Json_Array('a', 33) AS "json_second"), 'second') AS "item";
|
||||
SELECT Json_Get_Item(Json_Make_Object('foo' AS "first", Json_Make_Array('a', 33) AS "json_second"), '$.second') AS "item";
|
||||
item
|
||||
["a",33]
|
||||
SELECT Json_Get_Item(Jbin_Object('foo' first, Jbin_Array('a', 33) jbin_second), 'second:*') item;
|
||||
SELECT Json_Get_Item(Jbin_Object('foo' first, Jbin_Array('a', 33) jbin_second), '$.second') item;
|
||||
item
|
||||
["a",33]
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv');
|
||||
Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv')
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv');
|
||||
Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv')
|
||||
{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv'));
|
||||
Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv'))
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv'));
|
||||
Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv'))
|
||||
{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv:*');
|
||||
Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv:*')
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv');
|
||||
Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv')
|
||||
{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}
|
||||
SELECT JsonGet_String(Json_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso') lang;
|
||||
SELECT JsonGet_String(Json_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso') lang;
|
||||
lang
|
||||
GML
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso') "See also";
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso') "See also";
|
||||
See also
|
||||
["GML","XML"]
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso')) "See also";
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso')) "See also";
|
||||
See also
|
||||
["GML","XML"]
|
||||
SELECT JsonGet_String(Json_Get_Item(Json_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso'),'[0]') lang;
|
||||
SELECT JsonGet_String(Json_Get_Item(Json_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso'),'$[0]') lang;
|
||||
lang
|
||||
GML
|
||||
#
|
||||
# Test Item Get/Set/Insert/Update UDF's
|
||||
#
|
||||
SELECT Json_Get_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '[]');
|
||||
Json_Get_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '[]')
|
||||
SELECT Json_Get_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '$[]');
|
||||
Json_Get_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '$[]')
|
||||
[1,2,{"trois":3,"quatre":4}]
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '[1]');
|
||||
Json_Get_Item(Jbin_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '[1]')
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '$[1]');
|
||||
Json_Get_Item(Jbin_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '$[1]')
|
||||
NULL
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '[1]');
|
||||
Json_Get_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '[1]')
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '$[1]');
|
||||
Json_Get_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '$[1]')
|
||||
NULL
|
||||
SELECT Json_Set_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)));
|
||||
Json_Set_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)))
|
||||
SELECT Json_Set_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)));
|
||||
Json_Set_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)))
|
||||
[1,2,{"trois":3,"quatre":4}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 'foo');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '$.foo');
|
||||
ERROR HY000: Can't initialize function 'json_set_item'; This function must have an odd number of arguments
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq')
|
||||
[1,2,{"trois":3,"quatre":4,"cinq":5}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 7, '[1]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 7, '[1]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 7, '$[1]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 7, '$[1]')
|
||||
[1,7,{"trois":3,"quatre":4}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 7, '[1]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 7, '[1]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 7, '$[1]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 7, '$[1]')
|
||||
[1,7,{"trois":3,"quatre":4,"cinq":5}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Json_Array(7, 8, 9), '[1]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Json_Array(7, 8, 9), '[1]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Json_Make_Array(7, 8, 9), '$[1]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Json_Make_Array(7, 8, 9), '$[1]')
|
||||
[1,[7,8,9],{"trois":3,"quatre":4}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[2]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[2]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[2]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[2]')
|
||||
[1,2,[7,8,9]]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[2]:*');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[2]:*')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[2].*');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[2].*')
|
||||
[1,2,{"trois":3,"quatre":4}]
|
||||
Warnings:
|
||||
Warning 1105 Invalid specification * in a write path
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 3.1416, 'foo');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 3.1416, 'foo')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 3.1416, '$.foo');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 3.1416, '$.foo')
|
||||
[1,2,{"trois":3,"quatre":4}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 'toto', '[1]:[2]');
|
||||
Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 'toto', '[1]:[2]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 'toto', '$[1][2]');
|
||||
Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 'toto', '$[1][2]')
|
||||
[1,[7,8,"toto"],{"trois":3,"quatre":4}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 300, '[2]:nxt:total:[]');
|
||||
Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 300, '[2]:nxt:total:[]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 300, '$[2].nxt.total[]');
|
||||
Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 300, '$[2].nxt.total[]')
|
||||
[1,[7,8,9],{"trois":3,"quatre":4,"nxt":{"total":[300]}}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 300, '[2]:nxt:total:[]');
|
||||
Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 300, '[2]:nxt:total:[]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 300, '$[2].nxt.total[]');
|
||||
Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 300, '$[2].nxt.total[]')
|
||||
[1,[7,8,9,10],{"trois":3,"quatre":4,"cinq":5,"nxt":{"total":[300]}}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[1]', 5, '[2]:cinq', 10, '[1]:[]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[1]', 5, '[2]:cinq', 10, '[1]:[]')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[1]', 5, '$[2].cinq', 10, '$[1][]');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[1]', 5, '$[2].cinq', 10, '$[1][]')
|
||||
[1,[7,8,9,10],{"trois":3,"quatre":4,"cinq":5}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 44, '[2]:quatre');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 44, '[2]:quatre')
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 44, '$[2].quatre');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 44, '$[2].quatre')
|
||||
[1,2,{"trois":3,"quatre":44}]
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, 'truc');
|
||||
Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, 'truc')
|
||||
@@ -163,32 +163,32 @@ Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '*'
|
||||
[1,2,{"trois":3,"quatre":4}]
|
||||
Warnings:
|
||||
Warning 1105 Invalid specification * in a write path
|
||||
SELECT Json_Serialize(Jbin_Set_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq'));
|
||||
Json_Serialize(Jbin_Set_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq'))
|
||||
SELECT Json_Serialize(Jbin_Set_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq'));
|
||||
Json_Serialize(Jbin_Set_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq'))
|
||||
[1,2,{"trois":3,"quatre":4,"cinq":5}]
|
||||
SELECT Json_Insert_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq');
|
||||
Json_Insert_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq')
|
||||
SELECT Json_Insert_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq');
|
||||
Json_Insert_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq')
|
||||
[1,2,{"trois":3,"quatre":4,"cinq":5}]
|
||||
SELECT Json_Update_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq');
|
||||
Json_Update_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq')
|
||||
SELECT Json_Update_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq');
|
||||
Json_Update_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq')
|
||||
[1,2,{"trois":3,"quatre":4}]
|
||||
SELECT Json_Insert_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 44, '[2]:quatre');
|
||||
Json_Insert_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 44, '[2]:quatre')
|
||||
SELECT Json_Insert_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 44, '$[2].quatre');
|
||||
Json_Insert_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 44, '$[2].quatre')
|
||||
[1,[7,8,9,10],{"trois":3,"quatre":4,"cinq":5}]
|
||||
SELECT Json_Update_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 44, '[2]:quatre');
|
||||
Json_Update_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 44, '[2]:quatre')
|
||||
SELECT Json_Update_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 44, '$[2].quatre');
|
||||
Json_Update_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 44, '$[2].quatre')
|
||||
[1,[7,8,9],{"trois":3,"quatre":44}]
|
||||
SELECT Json_Insert_Item(Json_Array(1, Json_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[1]', 300, '[2]:nxt:total:[]');
|
||||
Json_Insert_Item(Json_Array(1, Json_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[1]', 300, '[2]:nxt:total:[]')
|
||||
SELECT Json_Insert_Item(Json_Make_Array(1, Json_Make_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][1]', 300, '$[2].nxt.total[]');
|
||||
Json_Insert_Item(Json_Make_Array(1, Json_Make_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][1]', 300, '$[2].nxt.total[]')
|
||||
[1,[7,8,9],{"trois":3,"quatre":4,"cinq":5,"nxt":{"total":[300]}}]
|
||||
SELECT Json_Update_Item(Json_Array(1, Json_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[1]', 300, '[2]:nxt:total:[]');
|
||||
Json_Update_Item(Json_Array(1, Json_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[1]', 300, '[2]:nxt:total:[]')
|
||||
SELECT Json_Update_Item(Json_Make_Array(1, Json_Make_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][1]', 300, '$[2].nxt.total[]');
|
||||
Json_Update_Item(Json_Make_Array(1, Json_Make_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][1]', 300, '$[2].nxt.total[]')
|
||||
[1,[7,10,9],{"trois":3,"quatre":4}]
|
||||
SELECT Json_Insert_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[]');
|
||||
Json_Insert_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[]')
|
||||
SELECT Json_Insert_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[]');
|
||||
Json_Insert_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[]')
|
||||
[1,2,{"trois":3,"quatre":4},5]
|
||||
SELECT Json_Update_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[]');
|
||||
Json_Update_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[]')
|
||||
SELECT Json_Update_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[]');
|
||||
Json_Update_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[]')
|
||||
[1,2,{"trois":3,"quatre":4}]
|
||||
#
|
||||
# Test merging items UDF's
|
||||
@@ -196,7 +196,7 @@ Json_Update_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5,
|
||||
SELECT Json_Item_Merge(Jbin_Array('a','b','c'), Jbin_Array('d','e','f'));
|
||||
Json_Item_Merge(Jbin_Array('a','b','c'), Jbin_Array('d','e','f'))
|
||||
["a","b","c","d","e","f"]
|
||||
SELECT Json_Item_Merge(Json_Array('a','b','c'), Json_Array('d','e','f')) AS "Result";
|
||||
SELECT Json_Item_Merge(Json_Make_Array('a','b','c'), Json_Make_Array('d','e','f')) AS "Result";
|
||||
Result
|
||||
["a","b","c","d","e","f"]
|
||||
SELECT Json_Array_Add(Jbin_Item_Merge(Jbin_Array('a','b','c'), Jbin_Array('d','e','f')), 'and', 3);
|
||||
@@ -216,7 +216,7 @@ Json_Object_Add(Jbin_Item_Merge(Jbin_Object(1 "a",2 "b",3 "c"), Jbin_Object(4 "d
|
||||
SELECT Json_Item_Merge(Jbin_Object(1 "a",2 "b",3 "c"), Jbin_Object(4 "a",5 "e",6 "f"));
|
||||
Json_Item_Merge(Jbin_Object(1 "a",2 "b",3 "c"), Jbin_Object(4 "a",5 "e",6 "f"))
|
||||
{"a":4,"b":2,"c":3,"e":5,"f":6}
|
||||
SELECT Json_Item_Merge('foo', Json_Array('d','e','f'));
|
||||
SELECT Json_Item_Merge('foo', Json_Make_Array('d','e','f'));
|
||||
ERROR HY000: Can't initialize function 'json_item_merge'; First argument must be a json item
|
||||
#
|
||||
# Test making file UDF's
|
||||
@@ -294,17 +294,17 @@ Json_File('bt1.json', 2)
|
||||
SELECT Jfile_Make(Jbin_Array('a','b','c'), 'bt1.json');
|
||||
Jfile_Make(Jbin_Array('a','b','c'), 'bt1.json')
|
||||
bt1.json
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_Array('a','b','c'), 'd') "Jbin_foo") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_Array('a','b','c'), 'd') "Jbin_foo") AS "Result";
|
||||
Result
|
||||
{"foo":["a","b","c","d"]}
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')) AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')) AS "Result";
|
||||
Result
|
||||
{"Array_Add(Jbin_File('bt1.json'), 'd')":["a","b","c","d"]}
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1") AS "Result";
|
||||
Result
|
||||
{"bt1":["a","b","c","d"]}
|
||||
# This does modify the file
|
||||
SELECT Json_Object(Json_Array_Add(Jbin_File('bt1.json'), 'd') "Jfile_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Array_Add(Jbin_File('bt1.json'), 'd') "Jfile_bt1") AS "Result";
|
||||
Result
|
||||
{"bt1":["a","b","c","d"]}
|
||||
SELECT Json_File('bt1.json');
|
||||
@@ -319,7 +319,7 @@ Json_File('bt1.json')
|
||||
SELECT Json_File(Json_Array_Delete(Jbin_File('bt1.json'), 3), 2);
|
||||
Json_File(Json_Array_Delete(Jbin_File('bt1.json'), 3), 2)
|
||||
["a","b","c"]
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
Result
|
||||
{"bt1":["a","b","c","d"],"t1":1}
|
||||
{"bt1":["a","b","c","d"],"t1":2}
|
||||
@@ -432,23 +432,23 @@ SELECT Jfile_Make(Jbin_Array('a','b','c'), 'bt1.json');
|
||||
Jfile_Make(Jbin_Array('a','b','c'), 'bt1.json')
|
||||
bt1.json
|
||||
# Test DELETE from file
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 1)) AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 1)) AS "Result";
|
||||
Result
|
||||
{"Array_Delete(Jbin_File('bt1.json'), 1)":["a","c"]}
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 2) "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 2) "Jbin_bt1") AS "Result";
|
||||
Result
|
||||
{"bt1":["a","b"]}
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 0) "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 0) "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
Result
|
||||
{"bt1":["b","c"],"t1":1}
|
||||
{"bt1":["b","c"],"t1":2}
|
||||
{"bt1":["b","c"],"t1":3}
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
Result
|
||||
{"bt1":["a","b"]}
|
||||
{"bt1":["a"]}
|
||||
{"bt1":[]}
|
||||
SELECT Json_Object(Json_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Json_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
Result
|
||||
{"bt1":["a","b"]}
|
||||
{"bt1":["a"]}
|
||||
@@ -475,17 +475,17 @@ SELECT Json_Serialize(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d"));
|
||||
Json_Serialize(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d"))
|
||||
{"a":1,"b":2,"c":3,"d":4}
|
||||
# First query (file not modified)
|
||||
SELECT Json_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jbin_new") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jbin_new") AS "Result";
|
||||
Result
|
||||
{"new":{"a":1,"b":2,"c":3,"d":4}}
|
||||
# First query (file modified)
|
||||
SELECT Json_Object(Json_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jfile_new") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jfile_new") AS "Result";
|
||||
Result
|
||||
{"new":{"a":1,"b":2,"c":3,"d":4}}
|
||||
SELECT Jfile_Make(Jbin_Object(1 "a", 2 "b", 3 "c"), 'bt2.json', 0);
|
||||
Jfile_Make(Jbin_Object(1 "a", 2 "b", 3 "c"), 'bt2.json', 0)
|
||||
bt2.json
|
||||
SELECT Json_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d") "Jbin_new", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d") "Jbin_new", n "t1") AS "Result" from t1;
|
||||
Result
|
||||
{"new":{"a":1,"b":2,"c":3,"d":4},"t1":1}
|
||||
{"new":{"a":1,"b":2,"c":3,"d":4},"t1":2}
|
||||
@@ -526,22 +526,22 @@ SELECT Json_File(Json_Item_Merge(Jbin_File('bt2.json'), Jbin_Object(4 "d",5 "e",
|
||||
Result
|
||||
{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6}
|
||||
|
||||
SELECT Json_Item_Merge(Json_Object(1 "a", 2 "b", 3 "c"), Json_Object(4 "d",5 "b",6 "f")) AS "Result";
|
||||
SELECT Json_Item_Merge(Json_Make_Object(1 "a", 2 "b", 3 "c"), Json_Make_Object(4 "d",5 "b",6 "f")) AS "Result";
|
||||
Result
|
||||
{"a":1,"b":5,"c":3,"d":4,"f":6}
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'b')) AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'b')) AS "Result";
|
||||
Result
|
||||
{"Object_Delete(Jbin_File('bt2.json'), 'b')":{"a":1,"c":3,"d":4,"e":5,"f":6}}
|
||||
SELECT Json_Object(Jbin_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
Result
|
||||
{"bt1":{"a":1,"d":4,"e":5,"f":6}}
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
Result
|
||||
{"bt1":{"a":1,"d":4,"e":5,"f":6}}
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jfile_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jfile_bt1") AS "Result";
|
||||
Result
|
||||
{"bt1":{"a":1,"d":4,"e":5,"f":6}}
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'a') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'a') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
Result
|
||||
{"bt1":{"d":4,"e":5,"f":6},"t1":1}
|
||||
{"bt1":{"d":4,"e":5,"f":6},"t1":2}
|
||||
@@ -552,14 +552,14 @@ Key list
|
||||
SELECT Jfile_Make('{"a":1, "b":[44, 55]}' json_, 'bt3.json', 0);
|
||||
Jfile_Make('{"a":1, "b":[44, 55]}' json_, 'bt3.json', 0)
|
||||
bt3.json
|
||||
SELECT Json_Array_Add(Json_File('bt3.json', 'b'), 66);
|
||||
Json_Array_Add(Json_File('bt3.json', 'b'), 66)
|
||||
SELECT Json_Array_Add(Json_File('bt3.json', '$.b'), 66);
|
||||
Json_Array_Add(Json_File('bt3.json', '$.b'), 66)
|
||||
[44,55,66]
|
||||
SELECT Json_Array_Add(Json_File('bt3.json'), 66, 'b');
|
||||
Json_Array_Add(Json_File('bt3.json'), 66, 'b')
|
||||
SELECT Json_Array_Add(Json_File('bt3.json'), 66, '$.b');
|
||||
Json_Array_Add(Json_File('bt3.json'), 66, '$.b')
|
||||
{"a":1,"b":[44,55,66]}
|
||||
SELECT Json_Array_Add(Jbin_File('bt3.json', 'b'), 66);
|
||||
Json_Array_Add(Jbin_File('bt3.json', 'b'), 66)
|
||||
SELECT Json_Array_Add(Jbin_File('bt3.json', '$.b'), 66);
|
||||
Json_Array_Add(Jbin_File('bt3.json', '$.b'), 66)
|
||||
bt3.json
|
||||
SELECT Json_File('bt3.json', 3);
|
||||
Json_File('bt3.json', 3)
|
||||
@@ -573,15 +573,15 @@ jfile_cols CHAR(12) NOT NULL)
|
||||
ENGINE= MYISAM;
|
||||
INSERT INTO t2 VALUES(1,'bt3.json');
|
||||
# In this table, the jfile_cols column just contains a file name
|
||||
UPDATE t2 SET jfile_cols = Json_Array_Add(Jbin_File('bt3.json', 'b'), 66) WHERE n = 1;
|
||||
UPDATE t2 SET jfile_cols = Json_Array_Add(Jbin_File('bt3.json', '$.b'), 66) WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, '*') FROM t2;
|
||||
JsonGet_String(jfile_cols, '*')
|
||||
{"a":1,"b":[44,55,66]}
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(jfile_cols, 77, 'b:[]') WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, 'b:*') FROM t2;
|
||||
JsonGet_String(jfile_cols, 'b:*')
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(jfile_cols, 77, '$.b[]') WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, '$.b.*') FROM t2;
|
||||
JsonGet_String(jfile_cols, '$.b.*')
|
||||
[44,55,66,77]
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(Jbin_Insert_Item(jfile_cols, 88, 'b:') , 99, 'b:') WHERE n = 1;
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(Jbin_Insert_Item(jfile_cols, 88, '$.b[]') , 99, '$.b[]') WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, '*') FROM t2;
|
||||
JsonGet_String(jfile_cols, '*')
|
||||
{"a":1,"b":[44,55,66,77,88,99]}
|
||||
|
||||
@@ -72,11 +72,11 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr'
|
||||
CATFUNC=Columns;
|
||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||
MTR T1 A 3 DECIMAL 38 40 0 10 1
|
||||
MTR T1 B 6 NUMBER 38 40 NULL NULL 1
|
||||
MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1
|
||||
MTR V1 A 3 DECIMAL 38 40 0 10 1
|
||||
MTR V1 B 6 NUMBER 38 40 NULL NULL 1
|
||||
NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL
|
||||
NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL
|
||||
NULL MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1 NULL
|
||||
NULL MTR V1 A 3 DECIMAL 38 40 0 10 1 NULL
|
||||
NULL MTR V1 B 6 NUMBER 38 40 NULL NULL 1 NULL
|
||||
DROP TABLE t1;
|
||||
# All columns in all schemas (limited with WHERE)
|
||||
CREATE TABLE t1 ENGINE=CONNECT
|
||||
@@ -84,18 +84,18 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr'
|
||||
CATFUNC=Columns TABNAME='%.%';
|
||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||
MTR T1 A 3 DECIMAL 38 40 0 10 1
|
||||
MTR T1 B 6 NUMBER 38 40 NULL NULL 1
|
||||
MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1
|
||||
MTR V1 A 3 DECIMAL 38 40 0 10 1
|
||||
MTR V1 B 6 NUMBER 38 40 NULL NULL 1
|
||||
NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL
|
||||
NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL
|
||||
NULL MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1 NULL
|
||||
NULL MTR V1 A 3 DECIMAL 38 40 0 10 1 NULL
|
||||
NULL MTR V1 B 6 NUMBER 38 40 NULL NULL 1 NULL
|
||||
DROP TABLE t1;
|
||||
# All tables "T1" in all schemas (limited with WHERE)
|
||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.T1';
|
||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||
MTR T1 A 3 DECIMAL 38 40 0 10 1
|
||||
MTR T1 B 6 NUMBER 38 40 NULL NULL 1
|
||||
NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL
|
||||
NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL
|
||||
DROP TABLE t1;
|
||||
# Table "T1" in the schema "MTR"
|
||||
CREATE TABLE t1 ENGINE=CONNECT
|
||||
@@ -103,8 +103,8 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr'
|
||||
CATFUNC=Columns TABNAME='MTR.T1';
|
||||
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||
MTR T1 A 3 DECIMAL 38 40 0 10 1
|
||||
MTR T1 B 6 NUMBER 38 40 NULL NULL 1
|
||||
NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL
|
||||
NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL
|
||||
DROP TABLE t1;
|
||||
# All tables "T1" in all schemas (filtered with WHERE)
|
||||
CREATE TABLE t1 ENGINE=CONNECT
|
||||
@@ -112,8 +112,8 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr'
|
||||
CATFUNC=Columns TABNAME='%.T1';
|
||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||
MTR T1 A 3 DECIMAL 38 40 0 10 1
|
||||
MTR T1 B 6 NUMBER 38 40 NULL NULL 1
|
||||
NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL
|
||||
NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Checking tables
|
||||
|
||||
@@ -171,16 +171,16 @@ DROP TABLE t1,t2,t3,t4;
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
_id INT(2) NOT NULL,
|
||||
name_first CHAR(9) NOT NULL FIELD_FORMAT='name:first',
|
||||
name_aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
|
||||
name_last CHAR(10) NOT NULL FIELD_FORMAT='name:last',
|
||||
name_first CHAR(9) NOT NULL FIELD_FORMAT='$.name.first',
|
||||
name_aka CHAR(4) DEFAULT NULL FIELD_FORMAT='$.name.aka',
|
||||
name_last CHAR(10) NOT NULL FIELD_FORMAT='$.name.last',
|
||||
title CHAR(12) DEFAULT NULL,
|
||||
birth CHAR(20) DEFAULT NULL,
|
||||
death CHAR(20) DEFAULT NULL,
|
||||
contribs CHAR(7) NOT NULL FIELD_FORMAT='contribs:',
|
||||
awards_award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards::award',
|
||||
awards_year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards::year',
|
||||
awards_by CHAR(38) DEFAULT NULL FIELD_FORMAT='awards::by'
|
||||
contribs CHAR(7) NOT NULL FIELD_FORMAT='$.contribs',
|
||||
awards_award CHAR(42) DEFAULT NULL FIELD_FORMAT='$.awards.award',
|
||||
awards_year CHAR(4) DEFAULT NULL FIELD_FORMAT='$.awards.year',
|
||||
awards_by CHAR(38) DEFAULT NULL FIELD_FORMAT='$.awards.by'
|
||||
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.zip' OPTION_LIST='ENTRY=bios.json,LOAD=bios.json' ZIPPED=YES;
|
||||
SELECT * FROM t1;
|
||||
_id name_first name_aka name_last title birth death contribs awards_award awards_year awards_by
|
||||
@@ -211,16 +211,16 @@ _id name_first name_aka name_last title birth death contribs awards_award awards
|
||||
10 Martin NULL Odersky NULL NULL NULL Scala NULL NULL NULL
|
||||
CREATE TABLE t3 (
|
||||
_id INT(2) NOT NULL,
|
||||
firstname CHAR(9) NOT NULL FIELD_FORMAT='name:first',
|
||||
aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
|
||||
lastname CHAR(10) NOT NULL FIELD_FORMAT='name:last',
|
||||
firstname CHAR(9) NOT NULL FIELD_FORMAT='$.name.first',
|
||||
aka CHAR(4) DEFAULT NULL FIELD_FORMAT='$.name.aka',
|
||||
lastname CHAR(10) NOT NULL FIELD_FORMAT='$.name.last',
|
||||
title CHAR(12) DEFAULT NULL,
|
||||
birth date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
|
||||
death date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
|
||||
contribs CHAR(64) NOT NULL FIELD_FORMAT='contribs:[", "]',
|
||||
award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards:[x]:award',
|
||||
year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards:[x]:year',
|
||||
`by` CHAR(38) DEFAULT NULL FIELD_FORMAT='awards:[x]:by'
|
||||
contribs CHAR(64) NOT NULL FIELD_FORMAT='$.contribs.[", "]',
|
||||
award CHAR(42) DEFAULT NULL FIELD_FORMAT='$.awards[*].award',
|
||||
year CHAR(4) DEFAULT NULL FIELD_FORMAT='$.awards[*].year',
|
||||
`by` CHAR(38) DEFAULT NULL FIELD_FORMAT='$.awards[*].by'
|
||||
) ENGINE=CONNECT TABLE_TYPE='json' FILE_NAME='bios.zip' ZIPPED=YES;
|
||||
SELECT * FROM t3 WHERE _id = 1;
|
||||
_id firstname aka lastname title birth death contribs award year by
|
||||
|
||||
@@ -35,15 +35,15 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15),
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
Authors INT(2) FIELD_FORMAT='AUTHOR:[#]',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB'
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
Authors INT(2) FIELD_FORMAT='$.AUTHOR[#]',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='$.TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB'
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
SELECT * FROM t1;
|
||||
@@ -55,16 +55,16 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15),
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='AUTHOR:[" and "]:FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='AUTHOR:[" and "]:LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB'
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='$.AUTHOR[" and "].FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='$.AUTHOR[" and "].LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='$.TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB'
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
SELECT * FROM t1;
|
||||
@@ -76,16 +76,16 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15),
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB'
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATION',
|
||||
Translator CHAR(80) FIELD_FORMAT='$.TRANSLATOR',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB'
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
SELECT * FROM t1;
|
||||
@@ -98,7 +98,7 @@ SELECT * FROM t1 WHERE ISBN = '9782212090819';
|
||||
CREATE TABLE t2 (
|
||||
FIRSTNAME CHAR(32),
|
||||
LASTNAME CHAR(32))
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR';
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=$[1].AUTHOR';
|
||||
SELECT * FROM t2;
|
||||
INSERT INTO t2 VALUES('Charles','Dickens');
|
||||
SELECT * FROM t1;
|
||||
@@ -122,17 +122,17 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
ISBN CHAR(15) NOT NULL,
|
||||
Language CHAR(2) FIELD_FORMAT='LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='AUTHOR:[X]:LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='TRANSLATED:PREFIX',
|
||||
TranslatorFN CHAR(80) FIELD_FORMAT='TRANSLATED:TRANSLATOR:FIRSTNAME',
|
||||
TranslatorLN CHAR(80) FIELD_FORMAT='TRANSLATED:TRANSLATOR:LASTNAME',
|
||||
Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
|
||||
Year int(4) FIELD_FORMAT='DATEPUB',
|
||||
Language CHAR(2) FIELD_FORMAT='$.LANG',
|
||||
Subject CHAR(32) FIELD_FORMAT='$.SUBJECT',
|
||||
AuthorFN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].FIRSTNAME',
|
||||
AuthorLN CHAR(128) FIELD_FORMAT='$.AUTHOR[*].LASTNAME',
|
||||
Title CHAR(32) FIELD_FORMAT='$.TITLE',
|
||||
Translation CHAR(32) FIELD_FORMAT='$.TRANSLATED.PREFIX',
|
||||
TranslatorFN CHAR(80) FIELD_FORMAT='$.TRANSLATED.TRANSLATOR.FIRSTNAME',
|
||||
TranslatorLN CHAR(80) FIELD_FORMAT='$.TRANSLATED.TRANSLATOR.LASTNAME',
|
||||
Publisher CHAR(20) FIELD_FORMAT='$.PUBLISHER.NAME',
|
||||
Location CHAR(16) FIELD_FORMAT='$.PUBLISHER.PLACE',
|
||||
Year int(4) FIELD_FORMAT='$.DATEPUB',
|
||||
INDEX IX(ISBN)
|
||||
)
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0';
|
||||
@@ -148,9 +148,9 @@ DROP TABLE t1;
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[X]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK::EXPENSE:["+"]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK::EXPENSE:[+]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[*].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[].EXPENSE["+"].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[].EXPENSE[+].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
@@ -160,9 +160,9 @@ DROP TABLE t1;
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[X]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[X]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[X]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[*].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[*].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[*].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
#--error ER_GET_ERRMSG
|
||||
SELECT * FROM t1;
|
||||
@@ -173,14 +173,14 @@ DROP TABLE t1;
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12) NOT NULL,
|
||||
WEEKS CHAR(12) NOT NULL FIELD_FORMAT='WEEK:[", "]:NUMBER',
|
||||
SUMS CHAR(64) NOT NULL FIELD_FORMAT='WEEK:["+"]:EXPENSE:[+]:AMOUNT',
|
||||
SUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[+]:EXPENSE:[+]:AMOUNT',
|
||||
AVGS CHAR(64) NOT NULL FIELD_FORMAT='WEEK:["+"]:EXPENSE:[!]:AMOUNT',
|
||||
SUMAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[+]:EXPENSE:[!]:AMOUNT',
|
||||
AVGSUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[+]:AMOUNT',
|
||||
AVGAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[!]:AMOUNT',
|
||||
AVERAGE DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[X]:AMOUNT')
|
||||
WEEKS CHAR(12) NOT NULL FIELD_FORMAT='$.WEEK[", "].NUMBER',
|
||||
SUMS CHAR(64) NOT NULL FIELD_FORMAT='$.WEEK["+"].EXPENSE[+].AMOUNT',
|
||||
SUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[+].EXPENSE[+].AMOUNT',
|
||||
AVGS CHAR(64) NOT NULL FIELD_FORMAT='$.WEEK["+"].EXPENSE[!].AMOUNT',
|
||||
SUMAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[+].EXPENSE[!].AMOUNT',
|
||||
AVGSUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[!].EXPENSE[+].AMOUNT',
|
||||
AVGAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[!].EXPENSE[!].AMOUNT',
|
||||
AVERAGE DOUBLE(8,2) NOT NULL FIELD_FORMAT='$.WEEK[!].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
@@ -190,25 +190,25 @@ DROP TABLE t1;
|
||||
--echo #
|
||||
CREATE TABLE t2 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[0].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[0].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[0].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t2;
|
||||
|
||||
CREATE TABLE t3 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[1].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[1].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[1].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t3;
|
||||
|
||||
CREATE TABLE t4 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT')
|
||||
WEEK INT(2) FIELD_FORMAT='$.WEEK[2].NUMBER',
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.WEEK[2].EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.WEEK[2].EXPENSE[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
|
||||
SELECT * FROM t4;
|
||||
|
||||
@@ -230,24 +230,24 @@ DROP TABLE t1, t2, t3, t4;
|
||||
CREATE TABLE t2 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp3.json';
|
||||
SELECT * FROM t2;
|
||||
|
||||
CREATE TABLE t3 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp4.json';
|
||||
SELECT * FROM t3;
|
||||
|
||||
CREATE TABLE t4 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp5.json';
|
||||
SELECT * FROM t4;
|
||||
|
||||
@@ -257,8 +257,8 @@ SELECT * FROM t4;
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp*.json' MULTIPLE=1;
|
||||
SELECT * FROM t1 ORDER BY WHO, WEEK, WHAT, AMOUNT;
|
||||
DROP TABLE t1;
|
||||
@@ -269,8 +269,8 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
WHO CHAR(12),
|
||||
WEEK INT(2),
|
||||
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
|
||||
WHAT CHAR(32) FIELD_FORMAT='$.EXPENSE[*].WHAT',
|
||||
AMOUNT DOUBLE(8,2) FIELD_FORMAT='$.EXPENSE.[*].AMOUNT')
|
||||
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp%s.json';
|
||||
ALTER TABLE t1
|
||||
PARTITION BY LIST COLUMNS(WEEK) (
|
||||
|
||||
@@ -9,11 +9,11 @@ if (!$HA_CONNECT_SO) {
|
||||
--skip Needs a dynamically built ha_connect.so
|
||||
}
|
||||
|
||||
--eval CREATE FUNCTION json_array RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_make_array RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_array_add RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_array_add_values RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_array_delete RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_object RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_make_object RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_object_nonull RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_object_key RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
--eval CREATE FUNCTION json_object_add RETURNS STRING SONAME '$HA_CONNECT_SO';
|
||||
|
||||
@@ -22,13 +22,13 @@ SELECT JsonValue(FALSE);
|
||||
SELECT JsonValue();
|
||||
SELECT JsonValue('[11, 22, 33]' json_) FROM t1;
|
||||
#
|
||||
SELECT Json_Array();
|
||||
SELECT Json_Array(56, 3.1416, 'My name is "Foo"', NULL);
|
||||
SELECT Json_Array(Json_Array(56, 3.1416, 'foo'), TRUE);
|
||||
SELECT Json_Make_Array();
|
||||
SELECT Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL);
|
||||
SELECT Json_Make_Array(Json_Make_Array(56, 3.1416, 'foo'), TRUE);
|
||||
#
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
SELECT Json_Array_Add(Json_Array(56, 3.1416, 'foo', NULL)) Array;
|
||||
SELECT Json_Array_Add(Json_Array(56, 3.1416, 'foo', NULL), 'One more') Array;
|
||||
SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL)) Array;
|
||||
SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL), 'One more') Array;
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
SELECT Json_Array_Add(JsonValue('one value'), 'One more');
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
@@ -39,38 +39,38 @@ SELECT Json_Array_Add(5 json_, 'One more');
|
||||
SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 0);
|
||||
SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 2) Array;
|
||||
SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 9);
|
||||
SELECT Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), '[2]', 33, 1);
|
||||
SELECT Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), 33, '[2]', 1);
|
||||
SELECT Json_Array_Add(Json_Array(1, 2, Json_Array(11, 22)), 33, 1, '[2]');
|
||||
SELECT Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), '[2]', 33, 1);
|
||||
SELECT Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), 33, '[2]', 1);
|
||||
SELECT Json_Array_Add(Json_Make_Array(1, 2, Json_Make_Array(11, 22)), 33, 1, '[2]');
|
||||
#
|
||||
SELECT Json_Array_Add_Values(Json_Array(56, 3.1416, 'machin', NULL), 'One more', 'Two more') Array;
|
||||
SELECT Json_Array_Add_Values(Json_Array(56, 3.1416, 'machin'), 'One more', 'Two more') Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Array(56, 3.1416, 'machin'), n) Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Array(n, 3.1416, 'machin'), n) Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(56, 3.1416, 'machin', NULL), 'One more', 'Two more') Array;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(56, 3.1416, 'machin'), 'One more', 'Two more') Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(56, 3.1416, 'machin'), n) Array FROM t1;
|
||||
SELECT Json_Array_Add_Values(Json_Make_Array(n, 3.1416, 'machin'), n) Array FROM t1;
|
||||
SELECT Json_Array_Add_Values('[56]', 3.1416, 'machin') Array;
|
||||
#
|
||||
SELECT Json_Array_Delete(Json_Array(56, 3.1416, 'My name is "Foo"', NULL), 0);
|
||||
SELECT Json_Array_Delete(Json_Object(56, 3.1416, 'My name is Foo', NULL), 2);
|
||||
SELECT Json_Array_Delete(Json_Array(56, 3.1416, 'My name is "Foo"', NULL), '2');
|
||||
SELECT Json_Array_Delete(json_array(56, 3.1416, 'My name is "Foo"', NULL), '2', 2);
|
||||
SELECT Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), 0);
|
||||
SELECT Json_Array_Delete(Json_Make_Object(56, 3.1416, 'My name is Foo', NULL), 2);
|
||||
SELECT Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), '2');
|
||||
SELECT Json_Array_Delete(Json_Make_Array(56, 3.1416, 'My name is "Foo"', NULL), '2', 2);
|
||||
#
|
||||
SELECT Json_Object(56, 3.1416, 'foo', NULL);
|
||||
SELECT Json_Object(56 qty, 3.1416 price, 'foo' truc, NULL garanty);
|
||||
SELECT Json_Object();
|
||||
SELECT Json_Object(Json_Array(56, 3.1416, 'foo'), NULL);
|
||||
SELECT Json_Array(Json_Object(56 "qty", 3.1416 "price", 'foo') ,NULL);
|
||||
SELECT Json_Make_Object(56, 3.1416, 'foo', NULL);
|
||||
SELECT Json_Make_Object(56 qty, 3.1416 price, 'foo' truc, NULL garanty);
|
||||
SELECT Json_Make_Object();
|
||||
SELECT Json_Make_Object(Json_Make_Array(56, 3.1416, 'foo'), NULL);
|
||||
SELECT Json_Make_Array(Json_Make_Object(56 "qty", 3.1416 "price", 'foo') ,NULL);
|
||||
SELECT Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty', NULL);
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
SELECT Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty');
|
||||
#
|
||||
SELECT Json_Object_Add(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'blue' color);
|
||||
SELECT Json_Object_Add(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 45.99 price);
|
||||
SELECT Json_Object_Add(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'blue' color);
|
||||
SELECT Json_Object_Add(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 45.99 price);
|
||||
SELECT Json_Object_Add(Json_File('notexist.json'), 'cheese' item, '[1]', 1);
|
||||
#
|
||||
SELECT Json_Object_Delete(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'truc');
|
||||
SELECT Json_Object_Delete(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'chose');
|
||||
SELECT Json_Object_Delete(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'truc');
|
||||
SELECT Json_Object_Delete(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'chose');
|
||||
#
|
||||
SELECT Json_Object_List(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty)) "Key List";
|
||||
SELECT Json_Object_List(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty)) "Key List";
|
||||
SELECT Json_Object_List('{"qty":56, "price":3.1416, "truc":"machin", "garanty":null}') "Key List";
|
||||
|
||||
--echo #
|
||||
@@ -89,8 +89,8 @@ CREATE TABLE t2
|
||||
DATEPUB int(4)
|
||||
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
|
||||
|
||||
SELECT Json_Array(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
SELECT Json_Object(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
SELECT Json_Make_Array(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
SELECT Json_Make_Object(AUTHOR, TITLE, DATEPUB) FROM t2;
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
SELECT Json_Array_Grp(TITLE, DATEPUB) FROM t2;
|
||||
SELECT Json_Array_Grp(TITLE) FROM t2;
|
||||
@@ -106,19 +106,19 @@ CREATE TABLE t3 (
|
||||
SALARY DOUBLE(8,2) NOT NULL FLAG=52
|
||||
) ENGINE=CONNECT TABLE_TYPE=FIX BLOCK_SIZE=8 FILE_NAME='employee.dat' ENDING=1;
|
||||
|
||||
SELECT Json_Object(SERIALNO, NAME, TITLE, SALARY) FROM t3 WHERE NAME = 'MERCHANT';
|
||||
SELECT Json_Make_Object(SERIALNO, NAME, TITLE, SALARY) FROM t3 WHERE NAME = 'MERCHANT';
|
||||
SELECT DEPARTMENT, Json_Array_Grp(NAME) FROM t3 GROUP BY DEPARTMENT;
|
||||
#SET connect_json_grp_size=30; Deprecated
|
||||
SELECT JsonSet_Grp_Size(30);
|
||||
SELECT Json_Object(title, Json_Array_Grp(name) `json_names`) from t3 GROUP BY title;
|
||||
SELECT Json_Array(DEPARTMENT, Json_Array_Grp(NAME)) FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Object(DEPARTMENT, Json_Array_Grp(NAME) json_NAMES) FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Object(DEPARTMENT, Json_Array_Grp(Json_Object(SERIALNO, NAME, TITLE, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Object(SERIALNO, NAME, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT, TITLE;
|
||||
SELECT Json_Make_Object(title, Json_Array_Grp(name) `json_names`) from t3 GROUP BY title;
|
||||
SELECT Json_Make_Array(DEPARTMENT, Json_Array_Grp(NAME)) FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Make_Object(DEPARTMENT, Json_Array_Grp(NAME) json_NAMES) FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Make_Object(DEPARTMENT, Json_Array_Grp(Json_Make_Object(SERIALNO, NAME, TITLE, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Make_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Make_Object(SERIALNO, NAME, SALARY)) json_EMPLOYES) FROM t3 GROUP BY DEPARTMENT, TITLE;
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
SELECT Json_Object_Grp(SALARY) FROM t3;
|
||||
SELECT Json_Object_Grp(NAME, SALARY) FROM t3;
|
||||
SELECT Json_Object(DEPARTMENT, Json_Object_Grp(NAME, SALARY) "Json_SALARIES") FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Make_Object(DEPARTMENT, Json_Object_Grp(NAME, SALARY) "Json_SALARIES") FROM t3 GROUP BY DEPARTMENT;
|
||||
SELECT Json_Array_Grp(NAME) FROM t3;
|
||||
#
|
||||
SELECT Json_Object_Key(name, title) FROM t3 WHERE DEPARTMENT = 318;
|
||||
@@ -131,59 +131,59 @@ SELECT JsonGet_String(Json_Array_Grp(name),'[#]') FROM t3;
|
||||
SELECT JsonGet_String(Json_Array_Grp(name),'[","]') FROM t3;
|
||||
SELECT JsonGet_String(Json_Array_Grp(name),'[>]') FROM t3;
|
||||
SET @j1 = '[45,28,36,45,89]';
|
||||
SELECT JsonGet_String(@j1,'[1]');
|
||||
SELECT JsonGet_String(@j1 json_,'[3]');
|
||||
SELECT JsonGet_String(Json_Array(45,28,36,45,89),'[3]');
|
||||
SELECT JsonGet_String(Json_Array(45,28,36,45,89),'["+"]') "list",'=' as "egal",JsonGet_String(Json_Array(45,28,36,45,89),'[+]') "sum";
|
||||
SELECT JsonGet_String(Json_Array(json_array(45,28),json_array(36,45,89)),'[1]:[0]');
|
||||
SELECT JsonGet_String(Json_Array(json_array(45,28),json_array(36,45,89)),'[1]:*');
|
||||
SELECT JsonGet_String(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'truc');
|
||||
SELECT JsonGet_String(@j1,'1');
|
||||
SELECT JsonGet_String(@j1 json_,'3');
|
||||
SELECT JsonGet_String(Json_Make_Array(45,28,36,45,89),'3');
|
||||
SELECT JsonGet_String(Json_Make_Array(45,28,36,45,89),'["+"]') "list",'=' as "egal",JsonGet_String(Json_Make_Array(45,28,36,45,89),'[+]') "sum";
|
||||
SELECT JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)),'1.0');
|
||||
SELECT JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)),'1.*');
|
||||
SELECT JsonGet_String(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'truc');
|
||||
SET @j2 = '{"qty":56,"price":3.141600,"truc":"machin","garanty":null}';
|
||||
SELECT JsonGet_String(@j2 json_,'truc');
|
||||
SELECT JsonGet_String(@j2,'truc');
|
||||
SELECT JsonGet_String(@j2,'chose');
|
||||
SELECT JsonGet_String(NULL json_, NULL);
|
||||
SELECT department, JsonGet_String(Json_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries:[+]') Sumsal FROM t3 GROUP BY department;
|
||||
SELECT department, JsonGet_String(Json_Make_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries.[+]') Sumsal FROM t3 GROUP BY department;
|
||||
#
|
||||
SELECT JsonGet_Int(@j1, '[4]');
|
||||
SELECT JsonGet_Int(@j1, '4');
|
||||
SELECT JsonGet_Int(@j1, '[#]');
|
||||
SELECT JsonGet_Int(@j1, '[+]');
|
||||
SELECT JsonGet_Int(@j1 json_, '[3]');
|
||||
SELECT JsonGet_Int(Json_Array(45,28,36,45,89), '[3]');
|
||||
SELECT JsonGet_Int(Json_Array(45,28,36,45,89), '["+"]');
|
||||
SELECT JsonGet_Int(Json_Array(45,28,36,45,89), '[+]');
|
||||
SELECT JsonGet_Int(Json_Array(json_array(45,28), json_array(36,45,89)), '[1]:[0]');
|
||||
SELECT JsonGet_Int(Json_Array(json_array(45,28), json_array(36,45,89)), '[0]:[1]');
|
||||
SELECT JsonGet_Int(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'qty');
|
||||
SELECT JsonGet_Int(@j1 json_, '3');
|
||||
SELECT JsonGet_Int(Json_Make_Array(45,28,36,45,89), '3');
|
||||
SELECT JsonGet_Int(Json_Make_Array(45,28,36,45,89), '["+"]');
|
||||
SELECT JsonGet_Int(Json_Make_Array(45,28,36,45,89), '[+]');
|
||||
SELECT JsonGet_Int(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '1.0');
|
||||
SELECT JsonGet_Int(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '0.1');
|
||||
SELECT JsonGet_Int(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'qty');
|
||||
SELECT JsonGet_Int(@j2 json_, 'price');
|
||||
SELECT JsonGet_Int(@j2, 'qty');
|
||||
SELECT JsonGet_Int('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'chose');
|
||||
SELECT JsonGet_Int(JsonGet_String(Json_Array(Json_Array(45,28),Json_Array(36,45,89)), '[1]:*'), '[+]') sum;
|
||||
SELECT department, JsonGet_Int(Json_Object(department, Json_Array_Grp(salary) "Json_salaries"), 'salaries:[+]') Sumsal FROM t3 GROUP BY department;
|
||||
SELECT JsonGet_Int(JsonGet_String(Json_Make_Array(Json_Make_Array(45,28),Json_Make_Array(36,45,89)), '1.*'), '[+]') sum;
|
||||
SELECT department, JsonGet_Int(Json_Make_Object(department, Json_Array_Grp(salary) "Json_salaries"), 'salaries.[+]') Sumsal FROM t3 GROUP BY department;
|
||||
#
|
||||
SELECT JsonGet_Real(@j1, '[2]');
|
||||
SELECT JsonGet_Real(@j1 json_, '[3]', 2);
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '[3]');
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '["+"]');
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '[+]');
|
||||
SELECT JsonGet_Real(Json_Array(45,28,36,45,89), '[!]');
|
||||
SELECT JsonGet_Real(Json_Array(json_array(45,28), json_array(36,45,89)), '[1]:[0]');
|
||||
SELECT JsonGet_Real(Json_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'price');
|
||||
SELECT JsonGet_Real(@j1, '2');
|
||||
SELECT JsonGet_Real(@j1 json_, '3', 2);
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '3');
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '["+"]');
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[+]');
|
||||
SELECT JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[!]');
|
||||
SELECT JsonGet_Real(Json_Make_Array(Json_Make_Array(45,28), Json_Make_Array(36,45,89)), '1.0');
|
||||
SELECT JsonGet_Real(Json_Make_Object(56 qty, 3.1416 price, 'machin' truc, NULL garanty), 'price');
|
||||
SELECT JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}' json_, 'qty');
|
||||
SELECT JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'price');
|
||||
SELECT JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'price', 4);
|
||||
SELECT JsonGet_Real('{"qty":56,"price":3.141600,"truc":"machin","garanty":null}', 'chose');
|
||||
SELECT department, JsonGet_Real(Json_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries:[+]') Sumsal FROM t3 GROUP BY department;
|
||||
SELECT department, JsonGet_Real(Json_Make_Object(department, Json_Array_Grp(salary) "Json_salaries"),'salaries.[+]') Sumsal FROM t3 GROUP BY department;
|
||||
|
||||
--echo #
|
||||
--echo # Documentation examples
|
||||
--echo #
|
||||
SELECT
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[4]') "Rank",
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[#]') "Number",
|
||||
JsonGet_String(Json_Array(45,28,36,45,89), '[","]') "Concat",
|
||||
JsonGet_Int(Json_Array(45,28,36,45,89), '[+]') "Sum",
|
||||
JsonGet_Real(Json_Array(45,28,36,45,89), '[!]', 2) "Avg";
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '4') "Rank",
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '[#]') "Number",
|
||||
JsonGet_String(Json_Make_Array(45,28,36,45,89), '[","]') "Concat",
|
||||
JsonGet_Int(Json_Make_Array(45,28,36,45,89), '[+]') "Sum",
|
||||
JsonGet_Real(Json_Make_Array(45,28,36,45,89), '[!]', 2) "Avg";
|
||||
SELECT
|
||||
JsonGet_String('{"qty":7,"price":29.50,"garanty":null}', 'price') "String",
|
||||
JsonGet_Int('{"qty":7,"price":29.50,"garanty":null}', 'price') "Int",
|
||||
@@ -193,10 +193,10 @@ SELECT JsonGet_Real('{"qty":7,"price":29.50,"garanty":null}', 'price', 3) "Real"
|
||||
--echo #
|
||||
--echo # Testing Locate
|
||||
--echo #
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'machin');
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),56);
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),3.1416);
|
||||
SELECT JsonLocate(Json_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'chose');
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'machin');
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),56);
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),3.1416);
|
||||
SELECT JsonLocate(Json_Make_Object(56 qty,3.1416 price,'machin' truc, NULL garanty),'chose');
|
||||
SELECT JsonLocate('{"AUTHORS":[{"FN":"Jules", "LN":"Verne"}, {"FN":"Jack", "LN":"London"}]}' json_, 'Jack') Path;
|
||||
SELECT JsonLocate('{"AUTHORS":[{"FN":"Jules", "LN":"Verne"}, {"FN":"Jack", "LN":"London"}]}' json_, 'jack' ci) Path;
|
||||
SELECT JsonLocate('{"AUTHORS":[{"FN":"Jules", "LN":"Verne"}, {"FN":"Jack", "LN":"London"}]}' json_, '{"FN":"Jack", "LN":"London"}' json_) Path;
|
||||
@@ -220,7 +220,7 @@ SELECT Json_Locate_All('[[45,28],[[36,45],89]]','45') "All paths";
|
||||
SELECT Json_Locate_All('[[45,28],[[36,45],89]]','[36,45]' json_);
|
||||
SELECT JsonGet_Int(Json_Locate_All('[[45,28],[[36,45],89]]',45), '[#]') "Nb of occurs";
|
||||
SELECT Json_Locate_All('[[45,28],[[36,45],89]]',45,2);
|
||||
SELECT JsonGet_String(Json_Locate_All('[45,28,36,45,89]',45),'[0]');
|
||||
SELECT JsonGet_String(Json_Locate_All('[45,28,36,45,89]',45),'0');
|
||||
SELECT JsonLocate(Json_File('test/biblio.json'), 'Knab');
|
||||
SELECT Json_Locate_All('test/biblio.json' jfile_, 'Knab');
|
||||
|
||||
@@ -237,21 +237,21 @@ SELECT Jfile_Make(Jbin_File('test/fx.json'), 0);
|
||||
SELECT Json_File('test/fx.json', 1);
|
||||
SELECT Json_File('test/fx.json', 2);
|
||||
SELECT Json_File('test/fx.json', 0);
|
||||
SELECT Json_File('test/fx.json', '[0]');
|
||||
SELECT Json_File('test/fx.json', '0');
|
||||
SELECT Json_File('test/fx.json', '[?]');
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '[1]:*');
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '[1]');
|
||||
SELECT JsonGet_Int(Json_File('test/fx.json'), '[1]:mileage') AS Mileage;
|
||||
SELECT JsonGet_Real(Json_File('test/fx.json'), '[0]:price', 2) AS Price;
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 'ratings');
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 1, 'ratings');
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]'), 6, 'ratings', 1);
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '[2]:ratings'), 6, 0);
|
||||
SELECT Json_Array_Delete(Json_File('test/fx.json', '[2]'), 'ratings', 1);
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '[2]'), 'france' origin);
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '[2]'), 70 H, 'size');
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '[3]'), 70 H, 'size');
|
||||
SELECT Json_Object_List(Json_File('test/fx.json', '[3]:size'));
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '1.*');
|
||||
SELECT JsonGet_String(Json_File('test/fx.json'), '1');
|
||||
SELECT JsonGet_Int(Json_File('test/fx.json'), '1.mileage') AS Mileage;
|
||||
SELECT JsonGet_Real(Json_File('test/fx.json'), '0.price', 2) AS Price;
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2'), 6, 'ratings');
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2'), 6, 1, 'ratings');
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2'), 6, 'ratings', 1);
|
||||
SELECT Json_Array_Add(Json_File('test/fx.json', '2.ratings'), 6, 0);
|
||||
SELECT Json_Array_Delete(Json_File('test/fx.json', '2'), 'ratings', 1);
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '2'), 'france' origin);
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '2'), 70 H, 'size');
|
||||
SELECT Json_Object_Add(Json_File('test/fx.json', '3'), 70 H, 'size');
|
||||
SELECT Json_Object_List(Json_File('test/fx.json', '3.size'));
|
||||
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
@@ -264,3 +264,5 @@ DROP TABLE t3;
|
||||
--remove_file $MYSQLD_DATADIR/test/biblio.json
|
||||
--remove_file $MYSQLD_DATADIR/test/employee.dat
|
||||
--remove_file $MYSQLD_DATADIR/test/fx.json
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
--disable_query_log
|
||||
|
||||
DROP FUNCTION json_array;
|
||||
DROP FUNCTION json_make_array;
|
||||
DROP FUNCTION json_array_add;
|
||||
DROP FUNCTION json_array_add_values;
|
||||
DROP FUNCTION json_array_delete;
|
||||
DROP FUNCTION json_object;
|
||||
DROP FUNCTION json_make_object;
|
||||
DROP FUNCTION json_object_nonull;
|
||||
DROP FUNCTION json_object_key;
|
||||
DROP FUNCTION json_object_add;
|
||||
|
||||
@@ -16,7 +16,7 @@ SELECT Json_Array_Add(Jbin_Array(56, 3.1416, 'My name is "Foo"', NULL), JsonGet_
|
||||
SELECT Json_Array_Delete(Jbin_Array_Add_Values(Jbin_Array(56, 3.1416, 'My name is "Foo"', NULL), "One more", 2), 4);
|
||||
SELECT Json_Array_Delete(Jbin_Array(56, Jbin_Array(3.1416, 'My name is "Foo"'), NULL), '[1]', 1);
|
||||
SELECT Json_Array_Delete(Jbin_Array(56, Jbin_Array(3.1416, 'My name is "Foo"'), TRUE), 1, '[1]');
|
||||
SELECT Json_Array(1, TRUE, 0, FALSE);
|
||||
SELECT Json_Make_Array(1, TRUE, 0, FALSE);
|
||||
SELECT Json_Serialize(Jbin_Array(TRUE, FALSE));
|
||||
#
|
||||
SELECT Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty', NULL);
|
||||
@@ -35,65 +35,65 @@ SELECT Json_Serialize(Jbin_File('gloss.json'));
|
||||
SELECT JsonLocate(Jbin_File('gloss.json'),'XML');
|
||||
#
|
||||
SELECT Json_Object_Key('first', 'foo', 'second', Jbin_Array('a', 33));
|
||||
SELECT Json_Get_Item(Json_Array('a','b','c'), '[1]');
|
||||
SELECT Json_Get_Item(Json_Object('foo' AS "first", Json_Array('a', 33) AS "json_second"), 'second') AS "item";
|
||||
SELECT Json_Get_Item(Jbin_Object('foo' first, Jbin_Array('a', 33) jbin_second), 'second:*') item;
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv');
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv'));
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv:*');
|
||||
SELECT JsonGet_String(Json_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso') lang;
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso') "See also";
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso')) "See also";
|
||||
SELECT JsonGet_String(Json_Get_Item(Json_File('gloss.json'),'glossary:GlossDiv:GlossList:GlossEntry:GlossDef:GlossSeeAlso'),'[0]') lang;
|
||||
SELECT Json_Get_Item(Json_Make_Array('a','b','c'), '$[1]');
|
||||
SELECT Json_Get_Item(Json_Make_Object('foo' AS "first", Json_Make_Array('a', 33) AS "json_second"), '$.second') AS "item";
|
||||
SELECT Json_Get_Item(Jbin_Object('foo' first, Jbin_Array('a', 33) jbin_second), '$.second') item;
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv');
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv'));
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv');
|
||||
SELECT JsonGet_String(Json_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso') lang;
|
||||
SELECT Json_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso') "See also";
|
||||
SELECT Json_Serialize(Jbin_Get_Item(Jbin_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso')) "See also";
|
||||
SELECT JsonGet_String(Json_Get_Item(Json_File('gloss.json'),'$.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso'),'$[0]') lang;
|
||||
|
||||
--echo #
|
||||
--echo # Test Item Get/Set/Insert/Update UDF's
|
||||
--echo #
|
||||
SELECT Json_Get_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '[]');
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '[1]');
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '[1]');
|
||||
SELECT Json_Get_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '$[]');
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), '$[1]');
|
||||
SELECT Json_Get_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '$[1]');
|
||||
#
|
||||
SELECT Json_Set_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)));
|
||||
SELECT Json_Set_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)));
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 'foo');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 7, '[1]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 7, '[1]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Json_Array(7, 8, 9), '[1]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[2]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[2]:*');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 3.1416, 'foo');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 'toto', '[1]:[2]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 300, '[2]:nxt:total:[]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 300, '[2]:nxt:total:[]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '[1]', 5, '[2]:cinq', 10, '[1]:[]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 44, '[2]:quatre');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), '$.foo');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 7, '$[1]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 7, '$[1]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Json_Make_Array(7, 8, 9), '$[1]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[2]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[2].*');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 3.1416, '$.foo');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 'toto', '$[1][2]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 300, '$[2].nxt.total[]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 300, '$[2].nxt.total[]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), Jbin_Array(7, 8, 9), '$[1]', 5, '$[2].cinq', 10, '$[1][]');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 44, '$[2].quatre');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, 'truc');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '');
|
||||
SELECT Json_Set_Item(Jbin_Array(1, 2, Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '*');
|
||||
SELECT Json_Serialize(Jbin_Set_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq'));
|
||||
SELECT Json_Serialize(Jbin_Set_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq'));
|
||||
#
|
||||
SELECT Json_Insert_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq');
|
||||
SELECT Json_Update_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq');
|
||||
SELECT Json_Insert_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 44, '[2]:quatre');
|
||||
SELECT Json_Update_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[]', 44, '[2]:quatre');
|
||||
SELECT Json_Insert_Item(Json_Array(1, Json_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[1]', 300, '[2]:nxt:total:[]');
|
||||
SELECT Json_Update_Item(Json_Array(1, Json_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[2]:cinq', 10, '[1]:[1]', 300, '[2]:nxt:total:[]');
|
||||
SELECT Json_Insert_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[]');
|
||||
SELECT Json_Update_Item(Json_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '[]');
|
||||
SELECT Json_Insert_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq');
|
||||
SELECT Json_Update_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq');
|
||||
SELECT Json_Insert_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 44, '$[2].quatre');
|
||||
SELECT Json_Update_Item(Jbin_Array(1, Jbin_Array(7, 8, 9), Jbin_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][]', 44, '$[2].quatre');
|
||||
SELECT Json_Insert_Item(Json_Make_Array(1, Json_Make_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][1]', 300, '$[2].nxt.total[]');
|
||||
SELECT Json_Update_Item(Json_Make_Array(1, Json_Make_Array(7, 8, 9), Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[2].cinq', 10, '$[1][1]', 300, '$[2].nxt.total[]');
|
||||
SELECT Json_Insert_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[]');
|
||||
SELECT Json_Update_Item(Json_Make_Array(1, 2, Json_Object_Key('trois', 3, 'quatre', 4)), 5, '$[]');
|
||||
|
||||
--echo #
|
||||
--echo # Test merging items UDF's
|
||||
--echo #
|
||||
SELECT Json_Item_Merge(Jbin_Array('a','b','c'), Jbin_Array('d','e','f'));
|
||||
SELECT Json_Item_Merge(Json_Array('a','b','c'), Json_Array('d','e','f')) AS "Result";
|
||||
SELECT Json_Item_Merge(Json_Make_Array('a','b','c'), Json_Make_Array('d','e','f')) AS "Result";
|
||||
SELECT Json_Array_Add(Jbin_Item_Merge(Jbin_Array('a','b','c'), Jbin_Array('d','e','f')), 'and', 3);
|
||||
SELECT Json_Item_Merge(Jbin_Object(1 "a",2 "b",3 "c"), Jbin_Object(4 "d",5 "e",6 "f"));
|
||||
SELECT Json_Item_Merge(Jbin_Object(1 "a",2 "b",2 "c"), Jbin_Array('d','e','f'));
|
||||
SELECT Json_Object_Add(Jbin_Item_Merge(Jbin_Object(1 "a",2 "b",3 "c"), Jbin_Object(4 "d",5 "e",6 "f")), 'x' AS "and");
|
||||
SELECT Json_Item_Merge(Jbin_Object(1 "a",2 "b",3 "c"), Jbin_Object(4 "a",5 "e",6 "f"));
|
||||
--error ER_CANT_INITIALIZE_UDF
|
||||
SELECT Json_Item_Merge('foo', Json_Array('d','e','f'));
|
||||
SELECT Json_Item_Merge('foo', Json_Make_Array('d','e','f'));
|
||||
|
||||
--echo #
|
||||
--echo # Test making file UDF's
|
||||
@@ -116,14 +116,14 @@ SELECT Json_Array_Add(Jbin_File('bt1.json'), 'd');
|
||||
SELECT Json_File('bt1.json', 2);
|
||||
--echo # Back to the original file
|
||||
SELECT Jfile_Make(Jbin_Array('a','b','c'), 'bt1.json');
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_Array('a','b','c'), 'd') "Jbin_foo") AS "Result";
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')) AS "Result";
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_Array('a','b','c'), 'd') "Jbin_foo") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')) AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1") AS "Result";
|
||||
--echo # This does modify the file
|
||||
SELECT Json_Object(Json_Array_Add(Jbin_File('bt1.json'), 'd') "Jfile_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Array_Add(Jbin_File('bt1.json'), 'd') "Jfile_bt1") AS "Result";
|
||||
SELECT Json_File('bt1.json');
|
||||
SELECT Json_File(Json_Array_Delete(Jbin_File('bt1.json'), 3), 2);
|
||||
SELECT Json_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Array_Add(Jbin_File('bt1.json'), 'd') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_File(Json_Array_Add(Jbin_Array_Add(Jbin_File('bt1.json'), 'd'), 'e')) AS "Result";
|
||||
SELECT Jfile_Make(Jbin_Array('a','b','c'), 'bt1.json');
|
||||
SELECT Json_File(Json_Array_Add(Jbin_Array_Add(Jbin_File('bt1.json'), 'd'), 'e')) AS "Result" from t1;
|
||||
@@ -140,11 +140,11 @@ SELECT Json_File(Jbin_Item_Merge(Jbin_File('bt1.json'), Jbin_Array('d','e','f'))
|
||||
SELECT Json_File(Json_Item_Merge(Jbin_File('bt1.json'), Jbin_Array('d','e','f')));
|
||||
SELECT Jfile_Make(Jbin_Array('a','b','c'), 'bt1.json');
|
||||
--echo # Test DELETE from file
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 1)) AS "Result";
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 2) "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 0) "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
SELECT Json_Object(Json_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 1)) AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 2) "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 0) "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Json_Array_Delete(Jbin_File('bt1.json'), 3 - n) "Jbin_bt1") AS "Result" from t1;
|
||||
--echo # Show modified file
|
||||
SELECT Json_File('bt1.json');
|
||||
--echo # Object file
|
||||
@@ -153,11 +153,11 @@ SELECT Json_File('bt2.json', 0);
|
||||
SELECT Json_File('bt2.json');
|
||||
SELECT Json_Serialize(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d"));
|
||||
--echo # First query (file not modified)
|
||||
SELECT Json_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jbin_new") AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jbin_new") AS "Result";
|
||||
--echo # First query (file modified)
|
||||
SELECT Json_Object(Json_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jfile_new") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Add(Jbin_File('bt2.json'), 4 AS "d") AS "Jfile_new") AS "Result";
|
||||
SELECT Jfile_Make(Jbin_Object(1 "a", 2 "b", 3 "c"), 'bt2.json', 0);
|
||||
SELECT Json_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d") "Jbin_new", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d") "Jbin_new", n "t1") AS "Result" from t1;
|
||||
SELECT Json_File(Json_Object_Add(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d"), 5 "e")) AS "Result";
|
||||
SELECT Json_Object_Add(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d"), 5 "e") AS "Result" from t1;
|
||||
SELECT Json_Object_Add(Jbin_Object_Add(Jbin_File('bt2.json'), 4 "d"), n "n") AS "Result" from t1;
|
||||
@@ -167,13 +167,13 @@ SELECT Json_File('bt2.json');
|
||||
SELECT Jfile_Make(Jbin_Object(1 "a", 2 "b", 3 "c"), 'bt2.json', 0);
|
||||
SELECT Json_Serialize(Jbin_Item_Merge(Jbin_File('bt2.json'), Jbin_Object(4 "d",5 "e",6 "f"))) AS "Result";
|
||||
SELECT Json_File(Json_Item_Merge(Jbin_File('bt2.json'), Jbin_Object(4 "d",5 "e",6 "f"))) AS "Result";
|
||||
SELECT Json_Item_Merge(Json_Object(1 "a", 2 "b", 3 "c"), Json_Object(4 "d",5 "b",6 "f")) AS "Result";
|
||||
SELECT Json_Item_Merge(Json_Make_Object(1 "a", 2 "b", 3 "c"), Json_Make_Object(4 "d",5 "b",6 "f")) AS "Result";
|
||||
#
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'b')) AS "Result";
|
||||
SELECT Json_Object(Jbin_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jfile_bt1") AS "Result";
|
||||
SELECT Json_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'a') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'b')) AS "Result";
|
||||
SELECT Json_Make_Object(Jbin_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jbin_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'c') "Jfile_bt1") AS "Result";
|
||||
SELECT Json_Make_Object(Json_Object_Delete(Jbin_File('bt2.json'), 'a') "Jbin_bt1", n "t1") AS "Result" from t1;
|
||||
#
|
||||
SELECT Json_Serialize(Jbin_Object_List(Jbin_File('bt2.json'))) "Key list";
|
||||
|
||||
@@ -181,9 +181,9 @@ SELECT Json_Serialize(Jbin_Object_List(Jbin_File('bt2.json'))) "Key list";
|
||||
# Test documentation examples
|
||||
#
|
||||
SELECT Jfile_Make('{"a":1, "b":[44, 55]}' json_, 'bt3.json', 0);
|
||||
SELECT Json_Array_Add(Json_File('bt3.json', 'b'), 66);
|
||||
SELECT Json_Array_Add(Json_File('bt3.json'), 66, 'b');
|
||||
SELECT Json_Array_Add(Jbin_File('bt3.json', 'b'), 66);
|
||||
SELECT Json_Array_Add(Json_File('bt3.json', '$.b'), 66);
|
||||
SELECT Json_Array_Add(Json_File('bt3.json'), 66, '$.b');
|
||||
SELECT Json_Array_Add(Jbin_File('bt3.json', '$.b'), 66);
|
||||
SELECT Json_File('bt3.json', 3);
|
||||
SELECT Jfile_Make('{"a":1, "b":[44, 55]}' json_, 'bt3.json', 0);
|
||||
#
|
||||
@@ -193,11 +193,11 @@ CREATE TABLE t2 (
|
||||
ENGINE= MYISAM;
|
||||
INSERT INTO t2 VALUES(1,'bt3.json');
|
||||
--echo # In this table, the jfile_cols column just contains a file name
|
||||
UPDATE t2 SET jfile_cols = Json_Array_Add(Jbin_File('bt3.json', 'b'), 66) WHERE n = 1;
|
||||
UPDATE t2 SET jfile_cols = Json_Array_Add(Jbin_File('bt3.json', '$.b'), 66) WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, '*') FROM t2;
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(jfile_cols, 77, 'b:[]') WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, 'b:*') FROM t2;
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(Jbin_Insert_Item(jfile_cols, 88, 'b:') , 99, 'b:') WHERE n = 1;
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(jfile_cols, 77, '$.b[]') WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, '$.b.*') FROM t2;
|
||||
UPDATE t2 SET jfile_cols = Json_Insert_Item(Jbin_Insert_Item(jfile_cols, 88, '$.b[]') , 99, '$.b[]') WHERE n = 1;
|
||||
SELECT JsonGet_String(jfile_cols, '*') FROM t2;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
@@ -210,3 +210,4 @@ DROP TABLE t1, t2;
|
||||
--remove_file $MYSQLD_DATADIR/bt1.json
|
||||
--remove_file $MYSQLD_DATADIR/bt2.json
|
||||
--remove_file $MYSQLD_DATADIR/bt3.json
|
||||
|
||||
|
||||
@@ -83,16 +83,16 @@ DROP TABLE t1,t2,t3,t4;
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
_id INT(2) NOT NULL,
|
||||
name_first CHAR(9) NOT NULL FIELD_FORMAT='name:first',
|
||||
name_aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
|
||||
name_last CHAR(10) NOT NULL FIELD_FORMAT='name:last',
|
||||
name_first CHAR(9) NOT NULL FIELD_FORMAT='$.name.first',
|
||||
name_aka CHAR(4) DEFAULT NULL FIELD_FORMAT='$.name.aka',
|
||||
name_last CHAR(10) NOT NULL FIELD_FORMAT='$.name.last',
|
||||
title CHAR(12) DEFAULT NULL,
|
||||
birth CHAR(20) DEFAULT NULL,
|
||||
death CHAR(20) DEFAULT NULL,
|
||||
contribs CHAR(7) NOT NULL FIELD_FORMAT='contribs:',
|
||||
awards_award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards::award',
|
||||
awards_year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards::year',
|
||||
awards_by CHAR(38) DEFAULT NULL FIELD_FORMAT='awards::by'
|
||||
contribs CHAR(7) NOT NULL FIELD_FORMAT='$.contribs',
|
||||
awards_award CHAR(42) DEFAULT NULL FIELD_FORMAT='$.awards.award',
|
||||
awards_year CHAR(4) DEFAULT NULL FIELD_FORMAT='$.awards.year',
|
||||
awards_by CHAR(38) DEFAULT NULL FIELD_FORMAT='$.awards.by'
|
||||
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.zip' OPTION_LIST='ENTRY=bios.json,LOAD=bios.json' ZIPPED=YES;
|
||||
SELECT * FROM t1;
|
||||
|
||||
@@ -104,16 +104,16 @@ SELECT * FROM t2;
|
||||
|
||||
CREATE TABLE t3 (
|
||||
_id INT(2) NOT NULL,
|
||||
firstname CHAR(9) NOT NULL FIELD_FORMAT='name:first',
|
||||
aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
|
||||
lastname CHAR(10) NOT NULL FIELD_FORMAT='name:last',
|
||||
firstname CHAR(9) NOT NULL FIELD_FORMAT='$.name.first',
|
||||
aka CHAR(4) DEFAULT NULL FIELD_FORMAT='$.name.aka',
|
||||
lastname CHAR(10) NOT NULL FIELD_FORMAT='$.name.last',
|
||||
title CHAR(12) DEFAULT NULL,
|
||||
birth date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
|
||||
death date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
|
||||
contribs CHAR(64) NOT NULL FIELD_FORMAT='contribs:[", "]',
|
||||
award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards:[x]:award',
|
||||
year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards:[x]:year',
|
||||
`by` CHAR(38) DEFAULT NULL FIELD_FORMAT='awards:[x]:by'
|
||||
contribs CHAR(64) NOT NULL FIELD_FORMAT='$.contribs.[", "]',
|
||||
award CHAR(42) DEFAULT NULL FIELD_FORMAT='$.awards[*].award',
|
||||
year CHAR(4) DEFAULT NULL FIELD_FORMAT='$.awards[*].year',
|
||||
`by` CHAR(38) DEFAULT NULL FIELD_FORMAT='$.awards[*].by'
|
||||
) ENGINE=CONNECT TABLE_TYPE='json' FILE_NAME='bios.zip' ZIPPED=YES;
|
||||
SELECT * FROM t3 WHERE _id = 1;
|
||||
|
||||
|
||||
@@ -2340,6 +2340,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
|
||||
} // endif len
|
||||
|
||||
pval[n] = AllocateValue(g, crp->Type, len);
|
||||
pval[n]->SetNullable(true);
|
||||
|
||||
if (crp->Type == TYPE_STRING) {
|
||||
pbuf[n] = (char*)PlugSubAlloc(g, NULL, len);
|
||||
|
||||
@@ -36,8 +36,6 @@ enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */
|
||||
TYPE_COLCRT = 71, /* Column creation block */
|
||||
TYPE_CONST = 72, /* Constant */
|
||||
|
||||
/*-------------------- type tokenized string --------------------------*/
|
||||
TYPE_DATE = 8, /* Timestamp */
|
||||
/*-------------------- additional values used by LNA ------------------*/
|
||||
TYPE_COLIST = 14, /* Column list */
|
||||
TYPE_COL = 41, /* Column */
|
||||
|
||||
@@ -1492,7 +1492,7 @@ void PlugPutOut(PGLOBAL g, FILE *f, short t, void *v, uint n)
|
||||
case TYPE_TABLE:
|
||||
case TYPE_TDB:
|
||||
case TYPE_XOBJECT:
|
||||
((PBLOCK)v)->Print(g, f, n-2);
|
||||
((PBLOCK)v)->Printf(g, f, n-2);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -73,7 +73,7 @@ PTABLE XTAB::Link(PTABLE tab2)
|
||||
/***********************************************************************/
|
||||
/* Make file output of XTAB contents. */
|
||||
/***********************************************************************/
|
||||
void XTAB::Print(PGLOBAL g, FILE *f, uint n)
|
||||
void XTAB::Printf(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
char m[64];
|
||||
|
||||
@@ -86,12 +86,12 @@ void XTAB::Print(PGLOBAL g, FILE *f, uint n)
|
||||
PlugPutOut(g, f, TYPE_TDB, tp->To_Tdb, n + 2);
|
||||
} /* endfor tp */
|
||||
|
||||
} /* end of Print */
|
||||
} /* end of Printf */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of XTAB contents. */
|
||||
/***********************************************************************/
|
||||
void XTAB::Print(PGLOBAL, char *ps, uint z)
|
||||
void XTAB::Prints(PGLOBAL, char *ps, uint z)
|
||||
{
|
||||
char buf[128];
|
||||
int i, n = (int)z - 1;
|
||||
@@ -105,7 +105,7 @@ void XTAB::Print(PGLOBAL, char *ps, uint z)
|
||||
n -= i;
|
||||
} // endif tp
|
||||
|
||||
} /* end of Print */
|
||||
} /* end of Prints */
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -134,7 +134,7 @@ bool COLUMN::SetFormat(PGLOBAL g, FORMAT&)
|
||||
/***********************************************************************/
|
||||
/* Make file output of COLUMN contents. */
|
||||
/***********************************************************************/
|
||||
void COLUMN::Print(PGLOBAL g, FILE *f, uint n)
|
||||
void COLUMN::Printf(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
char m[64];
|
||||
|
||||
@@ -149,12 +149,12 @@ void COLUMN::Print(PGLOBAL g, FILE *f, uint n)
|
||||
|
||||
PlugPutOut(g, f, TYPE_TABLE, To_Table, n + 2);
|
||||
PlugPutOut(g, f, TYPE_XOBJECT, To_Col, n + 2);
|
||||
} /* end of Print */
|
||||
} /* end of Printf */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of COLUMN contents. */
|
||||
/***********************************************************************/
|
||||
void COLUMN::Print(PGLOBAL, char *ps, uint z)
|
||||
void COLUMN::Prints(PGLOBAL, char *ps, uint z)
|
||||
{
|
||||
char buf[80];
|
||||
|
||||
@@ -166,4 +166,4 @@ void COLUMN::Print(PGLOBAL, char *ps, uint z)
|
||||
|
||||
strncpy(ps, buf, z);
|
||||
ps[z - 1] = '\0';
|
||||
} /* end of Print */
|
||||
} /* end of Prints */
|
||||
|
||||
@@ -38,8 +38,8 @@ class DllExport XTAB: public BLOCK { // Table Name-Schema-Srcdef block.
|
||||
|
||||
// Methods
|
||||
PTABLE Link(PTABLE);
|
||||
void Print(PGLOBAL g, FILE *f, uint n);
|
||||
void Print(PGLOBAL g, char *ps, uint z);
|
||||
void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
void Prints(PGLOBAL g, char *ps, uint z);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
@@ -78,8 +78,8 @@ class DllExport COLUMN: public XOBJECT { // Column Name/Qualifier block.
|
||||
void SetTo_Col(PCOL colp) {To_Col = colp;}
|
||||
|
||||
// Methods
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
// All methods below should never be used for COLUMN's
|
||||
virtual void Reset(void) {assert(false);}
|
||||
virtual bool Compare(PXOB) {assert(false); return false;}
|
||||
|
||||
@@ -2869,13 +2869,5 @@ bool DOSCOL::AddDistinctValue(PGLOBAL g)
|
||||
return false;
|
||||
} // end of AddDistinctValue
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make file output of a Dos column descriptor block. */
|
||||
/***********************************************************************/
|
||||
void DOSCOL::Print(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
COLBLK::Print(g, f, n);
|
||||
} // end of Print
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
|
||||
@@ -232,12 +232,10 @@ class DllExport DOSCOL : public COLBLK {
|
||||
virtual PVBLK GetDval(void) {return Dval;}
|
||||
|
||||
// Methods
|
||||
using COLBLK::Print;
|
||||
virtual bool VarSize(void);
|
||||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
||||
virtual void ReadColumn(PGLOBAL g);
|
||||
virtual void WriteColumn(PGLOBAL g);
|
||||
virtual void Print(PGLOBAL g, FILE *, uint);
|
||||
|
||||
protected:
|
||||
virtual bool SetMinMax(PGLOBAL g);
|
||||
|
||||
@@ -173,7 +173,6 @@ public:
|
||||
// Methods
|
||||
virtual void ReadColumn(PGLOBAL g);
|
||||
virtual void WriteColumn(PGLOBAL g);
|
||||
// void Print(PGLOBAL g, FILE *, uint);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
|
||||
@@ -47,9 +47,11 @@
|
||||
#define USE_G 1 /* Use recoverable memory if 1 */
|
||||
|
||||
/***********************************************************************/
|
||||
/* External function. */
|
||||
/* External functions. */
|
||||
/***********************************************************************/
|
||||
USETEMP UseTemp(void);
|
||||
bool IsNum(PSZ s);
|
||||
char *NextChr(PSZ s, char sep);
|
||||
|
||||
typedef struct _jncol {
|
||||
struct _jncol *Next;
|
||||
@@ -73,9 +75,10 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
|
||||
FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT};
|
||||
static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0};
|
||||
char colname[65], fmt[129];
|
||||
char *p, colname[65], fmt[129];
|
||||
int i, j, lvl, n = 0;
|
||||
int ncol = sizeof(buftyp) / sizeof(int);
|
||||
PCSZ sep;
|
||||
PVAL valp;
|
||||
JCOL jcol;
|
||||
PJCL jcp, fjcp = NULL, pjcp = NULL;
|
||||
@@ -107,6 +110,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
/*********************************************************************/
|
||||
lvl = GetIntegerTableOption(g, topt, "Level", 0);
|
||||
lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
|
||||
sep = GetStringTableOption(g, topt, "Separator", ".");
|
||||
|
||||
tdp = new(g) JSONDEF;
|
||||
#if defined(ZIP_SUPPORT)
|
||||
@@ -126,18 +130,22 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
|
||||
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
||||
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
|
||||
tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL);
|
||||
|
||||
if (trace)
|
||||
htrc("File %s objname=%s pretty=%d lvl=%d\n",
|
||||
tdp->Fn, tdp->Objname, tdp->Pretty, lvl);
|
||||
|
||||
if ((tdp->Uri = dsn) && *tdp->Uri) {
|
||||
if (dsn && *dsn)
|
||||
tdp->Uri = dsn;
|
||||
|
||||
if (tdp->Uri) {
|
||||
#if defined(MONGO_SUPPORT)
|
||||
tdp->Collname = GetStringTableOption(g, topt, "Name", NULL);
|
||||
tdp->Collname = GetStringTableOption(g, topt, "Tabname", tdp->Collname);
|
||||
tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test");
|
||||
tdp->Options = (char*)GetStringTableOption(g, topt, "Colist", NULL);
|
||||
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
|
||||
tdp->Options = PlugDup(g, "all");
|
||||
// tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
|
||||
tdp->Pretty = 0;
|
||||
#else // !MONGO_SUPPORT
|
||||
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO");
|
||||
@@ -223,6 +231,14 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
jcol.Found = true;
|
||||
colname[64] = 0;
|
||||
fmt[128] = 0;
|
||||
*fmt = '$';
|
||||
|
||||
if (!tdp->Uri) {
|
||||
fmt[1] = '.';
|
||||
p = fmt + 2;
|
||||
} else
|
||||
p = fmt + 1;
|
||||
|
||||
jrp = (PJPR*)PlugSubAlloc(g, NULL, sizeof(PJPR) * lvl);
|
||||
|
||||
/*********************************************************************/
|
||||
@@ -235,7 +251,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
|
||||
more:
|
||||
strncpy(colname, jpp->GetKey(), 64);
|
||||
*fmt = 0;
|
||||
*p = 0;
|
||||
j = 0;
|
||||
jvp = jpp->GetVal();
|
||||
|
||||
@@ -250,8 +266,8 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
jcol.Len = jcol.Scale = 0;
|
||||
jcol.Cbn = true;
|
||||
} else if (j < lvl) {
|
||||
if (!*fmt)
|
||||
strcpy(fmt, colname);
|
||||
if (!*p)
|
||||
strcat(fmt, colname);
|
||||
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
@@ -260,13 +276,24 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
if (!jrp[j])
|
||||
jrp[j] = jsp->GetFirst();
|
||||
|
||||
strncat(strncat(fmt, ":", 128), jrp[j]->GetKey(), 128);
|
||||
strncat(strncat(colname, "_", 64), jrp[j]->GetKey(), 64);
|
||||
jvp = jrp[j]->GetVal();
|
||||
j++;
|
||||
if (*jrp[j]->GetKey() != '$') {
|
||||
strncat(strncat(fmt, sep, 128), jrp[j]->GetKey(), 128);
|
||||
strncat(strncat(colname, "_", 64), jrp[j]->GetKey(), 64);
|
||||
} // endif Key
|
||||
|
||||
jvp = jrp[j]->GetVal();
|
||||
j++;
|
||||
break;
|
||||
case TYPE_JAR:
|
||||
strncat(fmt, ":", 128);
|
||||
if (!tdp->Xcol || stricmp(tdp->Xcol, colname)) {
|
||||
if (tdp->Uri)
|
||||
strncat(strncat(fmt, sep, 128), "0", 128);
|
||||
else
|
||||
strncat(fmt, "[0]", 128);
|
||||
|
||||
} else
|
||||
strncat(fmt, (tdp->Uri ? sep : "[]"), 128);
|
||||
|
||||
jvp = jsp->GetValue(0);
|
||||
break;
|
||||
default:
|
||||
@@ -296,10 +323,10 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
|
||||
} // endif Type
|
||||
|
||||
if (*fmt && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) {
|
||||
if (*p && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) {
|
||||
jcp->Fmt = PlugDup(g, fmt);
|
||||
length[7] = MY_MAX(length[7], strlen(fmt));
|
||||
} // endif *fmt
|
||||
} // endif fmt
|
||||
|
||||
jcp->Len = MY_MAX(jcp->Len, jcol.Len);
|
||||
jcp->Scale = MY_MAX(jcp->Scale, jcol.Scale);
|
||||
@@ -313,7 +340,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
|
||||
jcp->Name = PlugDup(g, colname);
|
||||
length[0] = MY_MAX(length[0], strlen(colname));
|
||||
|
||||
if (*fmt) {
|
||||
if (*p) {
|
||||
jcp->Fmt = PlugDup(g, fmt);
|
||||
length[7] = MY_MAX(length[7], strlen(fmt));
|
||||
} else
|
||||
@@ -435,9 +462,11 @@ JSONDEF::JSONDEF(void)
|
||||
Limit = 1;
|
||||
Base = 0;
|
||||
Strict = false;
|
||||
Sep = '.';
|
||||
#if defined(MONGO_SUPPORT)
|
||||
Uri = NULL;
|
||||
Collname = Schema = Options = NULL;
|
||||
Pipe = false;
|
||||
#endif // MONGO_SUPPORT
|
||||
} // end of JSONDEF constructor
|
||||
|
||||
@@ -452,6 +481,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
|
||||
Pretty = GetIntCatInfo("Pretty", 2);
|
||||
Limit = GetIntCatInfo("Limit", 10);
|
||||
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
||||
Sep = *GetStringCatInfo(g, "Separator", ".");
|
||||
|
||||
if (Uri = GetStringCatInfo(g, "Connect", NULL)) {
|
||||
#if defined(MONGO_SUPPORT)
|
||||
@@ -589,6 +619,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
|
||||
Limit = tdp->Limit;
|
||||
Pretty = tdp->Pretty;
|
||||
B = tdp->Base ? 1 : 0;
|
||||
Sep = tdp->Sep;
|
||||
Strict = tdp->Strict;
|
||||
} else {
|
||||
Jmode = MODE_OBJECT;
|
||||
@@ -597,6 +628,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
|
||||
Limit = 1;
|
||||
Pretty = 0;
|
||||
B = 0;
|
||||
Sep = '.';
|
||||
Strict = false;
|
||||
} // endif tdp
|
||||
|
||||
@@ -626,6 +658,7 @@ TDBJSN::TDBJSN(TDBJSN *tdbp) : TDBDOS(NULL, tdbp)
|
||||
SameRow = tdbp->SameRow;
|
||||
Xval = tdbp->Xval;
|
||||
B = tdbp->B;
|
||||
Sep = tdbp->Sep;
|
||||
Pretty = tdbp->Pretty;
|
||||
Strict = tdbp->Strict;
|
||||
Comma = tdbp->Comma;
|
||||
@@ -708,21 +741,27 @@ PJSON TDBJSN::FindRow(PGLOBAL g)
|
||||
PJSON jsp = Row;
|
||||
PJVAL val = NULL;
|
||||
|
||||
for (objpath = PlugDup(g, Objname); jsp && objpath; objpath = p) {
|
||||
if ((p = strchr(objpath, ':')))
|
||||
*p++ = 0;
|
||||
for (objpath = PlugDup(g, Objname); jsp && objpath; objpath = p) {
|
||||
if ((p = strchr(objpath, Sep)))
|
||||
*p++ = 0;
|
||||
|
||||
if (*objpath != '[') { // objpass is a key
|
||||
val = (jsp->GetType() == TYPE_JOB) ?
|
||||
jsp->GetObject()->GetValue(objpath) : NULL;
|
||||
} else if (objpath[strlen(objpath)-1] == ']') {
|
||||
val = (jsp->GetType() == TYPE_JAR) ?
|
||||
jsp->GetArray()->GetValue(atoi(objpath+1) - B) : NULL;
|
||||
} else
|
||||
val = NULL;
|
||||
if (*objpath != '[' && !IsNum(objpath)) { // objpass is a key
|
||||
val = (jsp->GetType() == TYPE_JOB) ?
|
||||
jsp->GetObject()->GetValue(objpath) : NULL;
|
||||
} else {
|
||||
if (*objpath == '[') {
|
||||
if (objpath[strlen(objpath) - 1] == ']')
|
||||
objpath++;
|
||||
else
|
||||
return NULL;
|
||||
} // endif [
|
||||
|
||||
jsp = (val) ? val->GetJson() : NULL;
|
||||
} // endfor objpath
|
||||
val = (jsp->GetType() == TYPE_JAR) ?
|
||||
jsp->GetArray()->GetValue(atoi(objpath) - B) : NULL;
|
||||
} // endif objpath
|
||||
|
||||
jsp = (val) ? val->GetJson() : NULL;
|
||||
} // endfor objpath
|
||||
|
||||
return jsp;
|
||||
} // end of FindRow
|
||||
@@ -841,63 +880,70 @@ int TDBJSN::ReadDB(PGLOBAL g)
|
||||
/* Make the top tree from the object path. */
|
||||
/***********************************************************************/
|
||||
int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
||||
{
|
||||
if (Objname) {
|
||||
if (!Val) {
|
||||
// Parse and allocate Objname item(s)
|
||||
char *p;
|
||||
char *objpath = PlugDup(g, Objname);
|
||||
int i;
|
||||
PJOB objp;
|
||||
PJAR arp;
|
||||
PJVAL val = NULL;
|
||||
|
||||
Top = NULL;
|
||||
|
||||
for (; objpath; objpath = p) {
|
||||
if ((p = strchr(objpath, ':')))
|
||||
*p++ = 0;
|
||||
|
||||
if (*objpath != '[') {
|
||||
objp = new(g) JOBJECT;
|
||||
|
||||
if (!Top)
|
||||
Top = objp;
|
||||
|
||||
if (val)
|
||||
val->SetValue(objp);
|
||||
|
||||
val = new(g) JVALUE;
|
||||
objp->SetValue(g, val, objpath);
|
||||
} else if (objpath[strlen(objpath)-1] == ']') {
|
||||
arp = new(g) JARRAY;
|
||||
{
|
||||
if (Objname) {
|
||||
if (!Val) {
|
||||
// Parse and allocate Objname item(s)
|
||||
char *p;
|
||||
char *objpath = PlugDup(g, Objname);
|
||||
int i;
|
||||
PJOB objp;
|
||||
PJAR arp;
|
||||
PJVAL val = NULL;
|
||||
|
||||
if (!Top)
|
||||
Top = arp;
|
||||
|
||||
if (val)
|
||||
val->SetValue(arp);
|
||||
|
||||
val = new(g) JVALUE;
|
||||
i = atoi(objpath+1) - B;
|
||||
arp->SetValue(g, val, i);
|
||||
arp->InitArray(g);
|
||||
} else {
|
||||
sprintf(g->Message, "Invalid Table path %s", Objname);
|
||||
return RC_FX;
|
||||
} // endif objpath
|
||||
|
||||
} // endfor p
|
||||
Top = NULL;
|
||||
|
||||
Val = val;
|
||||
} // endif Val
|
||||
for (; objpath; objpath = p) {
|
||||
if ((p = strchr(objpath, Sep)))
|
||||
*p++ = 0;
|
||||
|
||||
Val->SetValue(jsp);
|
||||
} else
|
||||
Top = jsp;
|
||||
if (*objpath != '[' && !IsNum(objpath)) {
|
||||
objp = new(g) JOBJECT;
|
||||
|
||||
return RC_OK;
|
||||
} // end of MakeTopTree
|
||||
if (!Top)
|
||||
Top = objp;
|
||||
|
||||
if (val)
|
||||
val->SetValue(objp);
|
||||
|
||||
val = new(g) JVALUE;
|
||||
objp->SetValue(g, val, objpath);
|
||||
} else {
|
||||
if (*objpath == '[') {
|
||||
// Old style
|
||||
if (objpath[strlen(objpath) - 1] != ']') {
|
||||
sprintf(g->Message, "Invalid Table path %s", Objname);
|
||||
return RC_FX;
|
||||
} else
|
||||
objpath++;
|
||||
|
||||
} // endif objpath
|
||||
|
||||
arp = new(g) JARRAY;
|
||||
|
||||
if (!Top)
|
||||
Top = arp;
|
||||
|
||||
if (val)
|
||||
val->SetValue(arp);
|
||||
|
||||
val = new(g) JVALUE;
|
||||
i = atoi(objpath) - B;
|
||||
arp->SetValue(g, val, i);
|
||||
arp->InitArray(g);
|
||||
} // endif objpath
|
||||
|
||||
} // endfor p
|
||||
|
||||
Val = val;
|
||||
} // endif Val
|
||||
|
||||
Val->SetValue(jsp);
|
||||
} else
|
||||
Top = jsp;
|
||||
|
||||
return RC_OK;
|
||||
} // end of MakeTopTree
|
||||
|
||||
/***********************************************************************/
|
||||
/* PrepareWriting: Prepare the line for WriteDB. */
|
||||
@@ -954,6 +1000,7 @@ JSONCOL::JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
|
||||
MulVal = NULL;
|
||||
Nodes = NULL;
|
||||
Nod = 0;
|
||||
Sep = Tjp->Sep;
|
||||
Xnod = -1;
|
||||
Xpd = false;
|
||||
Parsed = false;
|
||||
@@ -971,7 +1018,8 @@ JSONCOL::JSONCOL(JSONCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
|
||||
MulVal = col1->MulVal;
|
||||
Nodes = col1->Nodes;
|
||||
Nod = col1->Nod;
|
||||
Xnod = col1->Xnod;
|
||||
Sep = col1->Sep;
|
||||
Xnod = col1->Xnod;
|
||||
Xpd = col1->Xpd;
|
||||
Parsed = col1->Parsed;
|
||||
} // end of JSONCOL copy constructor
|
||||
@@ -1014,125 +1062,132 @@ bool JSONCOL::CheckExpand(PGLOBAL g, int i, PSZ nm, bool b)
|
||||
/* Analyse array processing options. */
|
||||
/***********************************************************************/
|
||||
bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
|
||||
{
|
||||
int n = (int)strlen(p);
|
||||
bool dg = true, b = false;
|
||||
PJNODE jnp = &Nodes[i];
|
||||
{
|
||||
int n;
|
||||
bool dg = true, b = false;
|
||||
PJNODE jnp = &Nodes[i];
|
||||
|
||||
if (*p) {
|
||||
if (p[--n] == ']') {
|
||||
p[n--] = 0;
|
||||
p++;
|
||||
} else {
|
||||
// Wrong array specification
|
||||
sprintf(g->Message,
|
||||
"Invalid array specification %s for %s", p, Name);
|
||||
return true;
|
||||
} // endif p
|
||||
//if (*p == '[') p++; // Old syntax .[ or :[
|
||||
n = (int)strlen(p);
|
||||
|
||||
} else
|
||||
b = true;
|
||||
if (*p) {
|
||||
if (p[n - 1] == ']') {
|
||||
p[--n] = 0;
|
||||
} else if (!IsNum(p)) {
|
||||
// Wrong array specification
|
||||
sprintf(g->Message, "Invalid array specification %s for %s", p, Name);
|
||||
return true;
|
||||
} // endif p
|
||||
|
||||
// To check whether a numeric Rank was specified
|
||||
for (int k = 0; dg && p[k]; k++)
|
||||
dg = isdigit(p[k]) > 0;
|
||||
} else
|
||||
b = true;
|
||||
|
||||
if (!n) {
|
||||
// Default specifications
|
||||
if (CheckExpand(g, i, nm, false))
|
||||
return true;
|
||||
else if (jnp->Op != OP_EXP) {
|
||||
if (b) {
|
||||
// Return 1st value (B is the index base)
|
||||
jnp->Rank = Tjp->B;
|
||||
jnp->Op = OP_EQ;
|
||||
} else if (!Value->IsTypeNum()) {
|
||||
jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING);
|
||||
jnp->Op = OP_CNC;
|
||||
} else
|
||||
jnp->Op = OP_ADD;
|
||||
// To check whether a numeric Rank was specified
|
||||
dg = IsNum(p);
|
||||
|
||||
} // endif OP
|
||||
if (!n) {
|
||||
// Default specifications
|
||||
if (CheckExpand(g, i, nm, false))
|
||||
return true;
|
||||
else if (jnp->Op != OP_EXP) {
|
||||
if (b) {
|
||||
// Return 1st value (B is the index base)
|
||||
jnp->Rank = Tjp->B;
|
||||
jnp->Op = OP_EQ;
|
||||
} else if (!Value->IsTypeNum()) {
|
||||
jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING);
|
||||
jnp->Op = OP_CNC;
|
||||
} else
|
||||
jnp->Op = OP_ADD;
|
||||
|
||||
} else if (dg) {
|
||||
// Return nth value
|
||||
jnp->Rank = atoi(p) - Tjp->B;
|
||||
jnp->Op = OP_EQ;
|
||||
} else if (n == 1) {
|
||||
// Set the Op value;
|
||||
switch (*p) {
|
||||
case '+': jnp->Op = OP_ADD; break;
|
||||
case '*': jnp->Op = OP_MULT; break;
|
||||
case '>': jnp->Op = OP_MAX; break;
|
||||
case '<': jnp->Op = OP_MIN; break;
|
||||
case '!': jnp->Op = OP_SEP; break; // Average
|
||||
case '#': jnp->Op = OP_NUM; break;
|
||||
case 'x':
|
||||
case 'X': // Expand this array
|
||||
if (!Tjp->Xcol && nm) {
|
||||
Xpd = true;
|
||||
jnp->Op = OP_EXP;
|
||||
Tjp->Xval = i;
|
||||
Tjp->Xcol = nm;
|
||||
} else if (CheckExpand(g, i, nm, true))
|
||||
return true;
|
||||
} // endif OP
|
||||
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message,
|
||||
"Invalid function specification %c for %s", *p, Name);
|
||||
return true;
|
||||
} // endswitch *p
|
||||
} else if (dg) {
|
||||
// Return nth value
|
||||
jnp->Rank = atoi(p) - Tjp->B;
|
||||
jnp->Op = OP_EQ;
|
||||
} else if (n == 1) {
|
||||
// Set the Op value;
|
||||
if (Sep == ':')
|
||||
switch (*p) {
|
||||
case '*': *p = 'x'; break;
|
||||
case 'x':
|
||||
case 'X': *p = '*'; break; // Expand this array
|
||||
default: break;
|
||||
} // endswitch p
|
||||
|
||||
} else if (*p == '"' && p[n - 1] == '"') {
|
||||
// This is a concat specification
|
||||
jnp->Op = OP_CNC;
|
||||
switch (*p) {
|
||||
case '+': jnp->Op = OP_ADD; break;
|
||||
case 'x': jnp->Op = OP_MULT; break;
|
||||
case '>': jnp->Op = OP_MAX; break;
|
||||
case '<': jnp->Op = OP_MIN; break;
|
||||
case '!': jnp->Op = OP_SEP; break; // Average
|
||||
case '#': jnp->Op = OP_NUM; break;
|
||||
case '*': // Expand this array
|
||||
if (!Tjp->Xcol && nm) {
|
||||
Xpd = true;
|
||||
jnp->Op = OP_EXP;
|
||||
Tjp->Xval = i;
|
||||
Tjp->Xcol = nm;
|
||||
} else if (CheckExpand(g, i, nm, true))
|
||||
return true;
|
||||
|
||||
if (n > 2) {
|
||||
// Set concat intermediate string
|
||||
p[n - 1] = 0;
|
||||
jnp->CncVal = AllocateValue(g, p + 1, TYPE_STRING);
|
||||
} // endif n
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message,
|
||||
"Invalid function specification %c for %s", *p, Name);
|
||||
return true;
|
||||
} // endswitch *p
|
||||
|
||||
} else {
|
||||
sprintf(g->Message, "Wrong array specification for %s", Name);
|
||||
return true;
|
||||
} // endif's
|
||||
} else if (*p == '"' && p[n - 1] == '"') {
|
||||
// This is a concat specification
|
||||
jnp->Op = OP_CNC;
|
||||
|
||||
// For calculated arrays, a local Value must be used
|
||||
switch (jnp->Op) {
|
||||
case OP_NUM:
|
||||
jnp->Valp = AllocateValue(g, TYPE_INT);
|
||||
break;
|
||||
case OP_ADD:
|
||||
case OP_MULT:
|
||||
case OP_SEP:
|
||||
if (!IsTypeChar(Buf_Type))
|
||||
jnp->Valp = AllocateValue(g, Buf_Type, 0, GetPrecision());
|
||||
else
|
||||
jnp->Valp = AllocateValue(g, TYPE_DOUBLE, 0, 2);
|
||||
if (n > 2) {
|
||||
// Set concat intermediate string
|
||||
p[n - 1] = 0;
|
||||
jnp->CncVal = AllocateValue(g, p + 1, TYPE_STRING);
|
||||
} // endif n
|
||||
|
||||
break;
|
||||
case OP_MIN:
|
||||
case OP_MAX:
|
||||
jnp->Valp = AllocateValue(g, Buf_Type, Long, GetPrecision());
|
||||
break;
|
||||
case OP_CNC:
|
||||
if (IsTypeChar(Buf_Type))
|
||||
jnp->Valp = AllocateValue(g, TYPE_STRING, Long, GetPrecision());
|
||||
else
|
||||
jnp->Valp = AllocateValue(g, TYPE_STRING, 512);
|
||||
} else {
|
||||
sprintf(g->Message, "Wrong array specification for %s", Name);
|
||||
return true;
|
||||
} // endif's
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // endswitch Op
|
||||
// For calculated arrays, a local Value must be used
|
||||
switch (jnp->Op) {
|
||||
case OP_NUM:
|
||||
jnp->Valp = AllocateValue(g, TYPE_INT);
|
||||
break;
|
||||
case OP_ADD:
|
||||
case OP_MULT:
|
||||
case OP_SEP:
|
||||
if (!IsTypeChar(Buf_Type))
|
||||
jnp->Valp = AllocateValue(g, Buf_Type, 0, GetPrecision());
|
||||
else
|
||||
jnp->Valp = AllocateValue(g, TYPE_DOUBLE, 0, 2);
|
||||
|
||||
if (jnp->Valp)
|
||||
MulVal = AllocateValue(g, jnp->Valp);
|
||||
break;
|
||||
case OP_MIN:
|
||||
case OP_MAX:
|
||||
jnp->Valp = AllocateValue(g, Buf_Type, Long, GetPrecision());
|
||||
break;
|
||||
case OP_CNC:
|
||||
if (IsTypeChar(Buf_Type))
|
||||
jnp->Valp = AllocateValue(g, TYPE_STRING, Long, GetPrecision());
|
||||
else
|
||||
jnp->Valp = AllocateValue(g, TYPE_STRING, 512);
|
||||
|
||||
return false;
|
||||
} // end of SetArrayOptions
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // endswitch Op
|
||||
|
||||
if (jnp->Valp)
|
||||
MulVal = AllocateValue(g, jnp->Valp);
|
||||
|
||||
return false;
|
||||
} // end of SetArrayOptions
|
||||
|
||||
/***********************************************************************/
|
||||
/* Parse the eventual passed Jpath information. */
|
||||
@@ -1141,68 +1196,89 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
|
||||
/* the node corresponding to that column. */
|
||||
/***********************************************************************/
|
||||
bool JSONCOL::ParseJpath(PGLOBAL g)
|
||||
{
|
||||
char *p, *p2 = NULL, *pbuf = NULL;
|
||||
int i;
|
||||
bool mul = false;
|
||||
{
|
||||
char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL;
|
||||
int i;
|
||||
bool a, mul = false;
|
||||
|
||||
if (Parsed)
|
||||
return false; // Already done
|
||||
else if (InitValue(g))
|
||||
return true;
|
||||
else if (!Jpath)
|
||||
Jpath = Name;
|
||||
if (Parsed)
|
||||
return false; // Already done
|
||||
else if (InitValue(g))
|
||||
return true;
|
||||
else if (!Jpath)
|
||||
Jpath = Name;
|
||||
|
||||
if (To_Tdb->GetOrig()) {
|
||||
// This is an updated column, get nodes from origin
|
||||
for (PJCOL colp = (PJCOL)Tjp->GetColumns(); colp;
|
||||
colp = (PJCOL)colp->GetNext())
|
||||
if (!stricmp(Name, colp->GetName())) {
|
||||
Nod = colp->Nod;
|
||||
Nodes = colp->Nodes;
|
||||
if (To_Tdb->GetOrig()) {
|
||||
// This is an updated column, get nodes from origin
|
||||
for (PJCOL colp = (PJCOL)Tjp->GetColumns(); colp;
|
||||
colp = (PJCOL)colp->GetNext())
|
||||
if (!stricmp(Name, colp->GetName())) {
|
||||
Nod = colp->Nod;
|
||||
Nodes = colp->Nodes;
|
||||
Xpd = colp->Xpd;
|
||||
goto fin;
|
||||
} // endif Name
|
||||
goto fin;
|
||||
} // endif Name
|
||||
|
||||
sprintf(g->Message, "Cannot parse updated column %s", Name);
|
||||
return true;
|
||||
} // endif To_Orig
|
||||
sprintf(g->Message, "Cannot parse updated column %s", Name);
|
||||
return true;
|
||||
} // endif To_Orig
|
||||
|
||||
pbuf = PlugDup(g, Jpath);
|
||||
pbuf = PlugDup(g, Jpath);
|
||||
if (*pbuf == '$') pbuf++;
|
||||
if (*pbuf == Sep) pbuf++;
|
||||
if (*pbuf == '[') p1 = pbuf++;
|
||||
|
||||
// The Jpath must be analyzed
|
||||
for (i = 0, p = pbuf; (p = strchr(p, ':')); i++, p++)
|
||||
Nod++; // One path node found
|
||||
// Estimate the required number of nodes
|
||||
for (i = 0, p = pbuf; (p = NextChr(p, Sep)); i++, p++)
|
||||
Nod++; // One path node found
|
||||
|
||||
Nodes = (PJNODE)PlugSubAlloc(g, NULL, (++Nod) * sizeof(JNODE));
|
||||
memset(Nodes, 0, (Nod) * sizeof(JNODE));
|
||||
Nodes = (PJNODE)PlugSubAlloc(g, NULL, (++Nod) * sizeof(JNODE));
|
||||
memset(Nodes, 0, (Nod) * sizeof(JNODE));
|
||||
|
||||
// Analyze the Jpath for this column
|
||||
for (i = 0, p = pbuf; i < Nod; i++, p = (p2 ? p2 + 1 : p + strlen(p))) {
|
||||
if ((p2 = strchr(p, ':')))
|
||||
*p2 = 0;
|
||||
// Analyze the Jpath for this column
|
||||
for (i = 0, p = pbuf; p && i < Nod; i++, p = (p2 ? p2 : NULL)) {
|
||||
a = (p1 != NULL);
|
||||
p1 = strchr(p, '[');
|
||||
p2 = strchr(p, Sep);
|
||||
|
||||
// Jpath must be explicit
|
||||
if (*p == 0 || *p == '[') {
|
||||
// Analyse intermediate array processing
|
||||
if (SetArrayOptions(g, p, i, Nodes[i-1].Key))
|
||||
return true;
|
||||
if (!p2)
|
||||
p2 = p1;
|
||||
else if (p1) {
|
||||
if (p1 < p2)
|
||||
p2 = p1;
|
||||
else if (p1 == p2 + 1)
|
||||
*p2++ = 0; // Old syntax .[ or :[
|
||||
else
|
||||
p1 = NULL;
|
||||
|
||||
} else if (*p == '*') {
|
||||
// Return JSON
|
||||
Nodes[i].Op = OP_XX;
|
||||
} else {
|
||||
Nodes[i].Key = p;
|
||||
Nodes[i].Op = OP_EXIST;
|
||||
} // endif's
|
||||
} // endif p1
|
||||
|
||||
} // endfor i, p
|
||||
if (p2)
|
||||
*p2++ = 0;
|
||||
|
||||
fin:
|
||||
MulVal = AllocateValue(g, Value);
|
||||
Parsed = true;
|
||||
return false;
|
||||
} // end of ParseJpath
|
||||
// Jpath must be explicit
|
||||
if (a || *p == 0 || *p == '[' || IsNum(p)) {
|
||||
// Analyse intermediate array processing
|
||||
if (SetArrayOptions(g, p, i, Nodes[i - 1].Key))
|
||||
return true;
|
||||
|
||||
} else if (*p == '*') {
|
||||
// Return JSON
|
||||
Nodes[i].Op = OP_XX;
|
||||
} else {
|
||||
Nodes[i].Key = p;
|
||||
Nodes[i].Op = OP_EXIST;
|
||||
} // endif's
|
||||
|
||||
} // endfor i, p
|
||||
|
||||
Nod = i;
|
||||
|
||||
fin:
|
||||
MulVal = AllocateValue(g, Value);
|
||||
Parsed = true;
|
||||
return false;
|
||||
} // end of ParseJpath
|
||||
|
||||
/***********************************************************************/
|
||||
/* Get Jpath converted to Mongo path. */
|
||||
@@ -1213,9 +1289,12 @@ char *JSONCOL::GetJpath(PGLOBAL g, bool proj)
|
||||
char *p1, *p2, *mgopath;
|
||||
int i = 0;
|
||||
|
||||
if (strcmp(Jpath, "*"))
|
||||
mgopath = PlugDup(g, Jpath);
|
||||
else
|
||||
if (strcmp(Jpath, "*")) {
|
||||
p1 = Jpath;
|
||||
if (*p1 == '$') p1++;
|
||||
if (*p1 == '.') p1++;
|
||||
mgopath = PlugDup(g, p1);
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
for (p1 = p2 = mgopath; *p1; p1++)
|
||||
@@ -1224,27 +1303,42 @@ char *JSONCOL::GetJpath(PGLOBAL g, bool proj)
|
||||
if (!proj)
|
||||
*p2++ = *p1;
|
||||
|
||||
i = 2;
|
||||
} else if (*p1 == ']' && i == 2) {
|
||||
if (proj && *(p1 + 1) == ':')
|
||||
} else if (*p1 == ']' && i == 1) {
|
||||
if (proj && p1[1] == '.')
|
||||
p1++;
|
||||
|
||||
i = 0;
|
||||
} else if (proj)
|
||||
i = 2;
|
||||
else
|
||||
} else if (*p1 == '.' && i == 2) {
|
||||
if (!proj)
|
||||
*p2++ = '.';
|
||||
|
||||
i = 0;
|
||||
} else if (!proj)
|
||||
return NULL;
|
||||
|
||||
} else switch (*p1) {
|
||||
case ':': *p2++ = '.'; break;
|
||||
case '[': i = 1; break;
|
||||
case ':':
|
||||
case '.':
|
||||
if (isdigit(p1[1]))
|
||||
i = 2;
|
||||
|
||||
*p2++ = '.';
|
||||
break;
|
||||
case '[':
|
||||
if (*p2 != '.')
|
||||
*p2++ = '.';
|
||||
|
||||
i = 1;
|
||||
break;
|
||||
case '*':
|
||||
if (*(p2 - 1) == '.' && !*(p1 + 1)) {
|
||||
p2--; // Suppress last :*
|
||||
break;
|
||||
} // endif p2
|
||||
|
||||
default: *p2++ = *p1; break;
|
||||
default:
|
||||
*p2++ = *p1;
|
||||
break;
|
||||
} // endswitch p1;
|
||||
|
||||
*p2 = 0;
|
||||
@@ -1279,7 +1373,7 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n)
|
||||
case TYPE_INTG:
|
||||
case TYPE_BINT:
|
||||
case TYPE_DBL:
|
||||
case TYPE_DATE:
|
||||
case TYPE_DTM:
|
||||
vp->SetValue_pval(val->GetValue());
|
||||
break;
|
||||
case TYPE_BOOL:
|
||||
@@ -1455,8 +1549,9 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
|
||||
} else
|
||||
SetJsonValue(g, MulVal, jvp, n);
|
||||
|
||||
if (!MulVal->IsZero()) {
|
||||
switch (op) {
|
||||
// if (!MulVal->IsZero()) {
|
||||
if (!MulVal->IsNull()) {
|
||||
switch (op) {
|
||||
case OP_CNC:
|
||||
if (Nodes[n].CncVal) {
|
||||
val[0] = Nodes[n].CncVal;
|
||||
@@ -1481,7 +1576,7 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
|
||||
if (err)
|
||||
vp->Reset();
|
||||
|
||||
} // endif Zero
|
||||
} // endif Null
|
||||
|
||||
} while (Tjp->NextSame > nextsame);
|
||||
|
||||
@@ -1768,54 +1863,66 @@ int TDBJSON::MakeDocument(PGLOBAL g)
|
||||
if (!jsp && g->Message[0])
|
||||
return RC_FX;
|
||||
|
||||
objpath = PlugDup(g, Objname);
|
||||
if ((objpath = PlugDup(g, Objname))) {
|
||||
if (*objpath == '$') objpath++;
|
||||
if (*objpath == '.') objpath++;
|
||||
|
||||
/*********************************************************************/
|
||||
/* Find the table in the tree structure. */
|
||||
/*********************************************************************/
|
||||
for (; jsp && objpath; objpath = p) {
|
||||
if ((p = strchr(objpath, ':')))
|
||||
*p++ = 0;
|
||||
/*********************************************************************/
|
||||
/* Find the table in the tree structure. */
|
||||
/*********************************************************************/
|
||||
for (; jsp && objpath; objpath = p) {
|
||||
if ((p = strchr(objpath, Sep)))
|
||||
*p++ = 0;
|
||||
|
||||
if (*objpath != '[') { // objpass is a key
|
||||
if (jsp->GetType() != TYPE_JOB) {
|
||||
strcpy(g->Message, "Table path does not match the json file");
|
||||
return RC_FX;
|
||||
} // endif Type
|
||||
if (*objpath != '[' && !IsNum(objpath)) {
|
||||
// objpass is a key
|
||||
if (jsp->GetType() != TYPE_JOB) {
|
||||
strcpy(g->Message, "Table path does not match the json file");
|
||||
return RC_FX;
|
||||
} // endif Type
|
||||
|
||||
key = objpath;
|
||||
objp = jsp->GetObject();
|
||||
arp = NULL;
|
||||
val = objp->GetValue(key);
|
||||
key = objpath;
|
||||
objp = jsp->GetObject();
|
||||
arp = NULL;
|
||||
val = objp->GetValue(key);
|
||||
|
||||
if (!val || !(jsp = val->GetJson())) {
|
||||
sprintf(g->Message, "Cannot find object key %s", key);
|
||||
return RC_FX;
|
||||
} // endif val
|
||||
if (!val || !(jsp = val->GetJson())) {
|
||||
sprintf(g->Message, "Cannot find object key %s", key);
|
||||
return RC_FX;
|
||||
} // endif val
|
||||
|
||||
} else if (objpath[strlen(objpath)-1] == ']') {
|
||||
if (jsp->GetType() != TYPE_JAR) {
|
||||
strcpy(g->Message, "Table path does not match the json file");
|
||||
return RC_FX;
|
||||
} // endif Type
|
||||
} else {
|
||||
if (*objpath == '[') {
|
||||
// Old style
|
||||
if (objpath[strlen(objpath) - 1] != ']') {
|
||||
sprintf(g->Message, "Invalid Table path %s", Objname);
|
||||
return RC_FX;
|
||||
} else
|
||||
objpath++;
|
||||
|
||||
arp = jsp->GetArray();
|
||||
objp = NULL;
|
||||
i = atoi(objpath+1) - B;
|
||||
val = arp->GetValue(i);
|
||||
} // endif objpath
|
||||
|
||||
if (!val) {
|
||||
sprintf(g->Message, "Cannot find array value %d", i);
|
||||
return RC_FX;
|
||||
} // endif val
|
||||
if (jsp->GetType() != TYPE_JAR) {
|
||||
strcpy(g->Message, "Table path does not match the json file");
|
||||
return RC_FX;
|
||||
} // endif Type
|
||||
|
||||
} else {
|
||||
sprintf(g->Message, "Invalid Table path %s", Objname);
|
||||
return RC_FX;
|
||||
} // endif objpath
|
||||
arp = jsp->GetArray();
|
||||
objp = NULL;
|
||||
i = atoi(objpath) - B;
|
||||
val = arp->GetValue(i);
|
||||
|
||||
jsp = val->GetJson();
|
||||
} // endfor objpath
|
||||
if (!val) {
|
||||
sprintf(g->Message, "Cannot find array value %d", i);
|
||||
return RC_FX;
|
||||
} // endif val
|
||||
|
||||
} // endif
|
||||
|
||||
jsp = val->GetJson();
|
||||
} // endfor objpath
|
||||
|
||||
} // endif objpath
|
||||
|
||||
if (jsp && jsp->GetType() == TYPE_JAR)
|
||||
Doc = jsp->GetArray();
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
int Level; /* Used for catalog table */
|
||||
int Base; /* The array index base */
|
||||
bool Strict; /* Strict syntax checking */
|
||||
char Sep; /* The Jpath separator */
|
||||
const char *Uri; /* MongoDB connection URI */
|
||||
#if defined(MONGO_SUPPORT)
|
||||
PCSZ Collname; /* External collection name */
|
||||
@@ -133,6 +134,7 @@ public:
|
||||
int SameRow; // Same row nb
|
||||
int Xval; // Index of expandable array
|
||||
int B; // Array index base
|
||||
char Sep; // The Jpath separator
|
||||
bool Strict; // Strict syntax checking
|
||||
bool Comma; // Row has final comma
|
||||
}; // end of class TDBJSN
|
||||
@@ -182,7 +184,8 @@ class DllExport JSONCOL : public DOSCOL {
|
||||
JNODE *Nodes; // The intermediate objects
|
||||
int Nod; // The number of intermediate objects
|
||||
int Xnod; // Index of multiple values
|
||||
bool Xpd; // True for expandable column
|
||||
char Sep; // The Jpath separator
|
||||
bool Xpd; // True for expandable column
|
||||
bool Parsed; // True when parsed
|
||||
}; // end of class JSONCOL
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ bool TDB::SetRecpos(PGLOBAL g, int)
|
||||
return true;
|
||||
} // end of SetRecpos
|
||||
|
||||
void TDB::Print(PGLOBAL g, FILE *f, uint n)
|
||||
void TDB::Printf(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
PCOL cp;
|
||||
char m[64];
|
||||
@@ -315,16 +315,16 @@ void TDB::Print(PGLOBAL g, FILE *f, uint n)
|
||||
fprintf(f, "%s Columns (deg=%d):\n", m, tp->Degree);
|
||||
|
||||
for (cp = tp->Columns; cp; cp = cp->GetNext())
|
||||
cp->Print(g, f, n);
|
||||
cp->Printf(g, f, n);
|
||||
|
||||
} /* endfor tp */
|
||||
|
||||
} // end of Print
|
||||
} // end of Printf
|
||||
|
||||
void TDB::Print(PGLOBAL, char *ps, uint)
|
||||
void TDB::Prints(PGLOBAL, char *ps, uint)
|
||||
{
|
||||
sprintf(ps, "R%d.%s", Tdb_No, Name);
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
/* -------------------------- class TDBASE --------------------------- */
|
||||
|
||||
|
||||
@@ -144,13 +144,20 @@ MGODISC::MGODISC(PGLOBAL g, int *lg) {
|
||||
/***********************************************************************/
|
||||
int MGODISC::GetColumns(PGLOBAL g, char *db, PTOS topt)
|
||||
{
|
||||
bson_iter_t iter;
|
||||
PCSZ level;
|
||||
bson_iter_t iter;
|
||||
const bson_t *doc;
|
||||
PMGODEF tdp;
|
||||
TDBMGO *tmgp = NULL;
|
||||
PMGODEF tdp;
|
||||
TDBMGO *tmgp = NULL;
|
||||
|
||||
level = GetStringTableOption(g, topt, "Level", NULL);
|
||||
|
||||
if (level) {
|
||||
lvl = atoi(level);
|
||||
lvl = (lvl > 16) ? 16 : lvl;
|
||||
} else
|
||||
lvl = 0;
|
||||
|
||||
lvl = GetIntegerTableOption(g, topt, "Level", 0);
|
||||
lvl = (lvl > 16) ? 16 : lvl;
|
||||
all = GetBooleanTableOption(g, topt, "Fullarray", false);
|
||||
|
||||
/*********************************************************************/
|
||||
@@ -162,7 +169,7 @@ int MGODISC::GetColumns(PGLOBAL g, char *db, PTOS topt)
|
||||
tdp->Tabname = GetStringTableOption(g, topt, "Tabname", tdp->Tabname);
|
||||
tdp->Tabschema = GetStringTableOption(g, topt, "Dbname", db);
|
||||
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
||||
tdp->Colist = GetStringTableOption(g, topt, "Colist", NULL);
|
||||
tdp->Colist = GetStringTableOption(g, topt, "Colist", "all");
|
||||
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
|
||||
|
||||
if (tdp->Colist) {
|
||||
@@ -726,9 +733,22 @@ void TDBMGO::SetFilter(PFIL fp)
|
||||
mongoc_cursor_t *TDBMGO::MakeCursor(PGLOBAL g)
|
||||
{
|
||||
const char *p;
|
||||
bool b = false, id = (Mode != MODE_READ), all = false;
|
||||
mongoc_cursor_t *cursor;
|
||||
PCOL cp;
|
||||
PSTRG s = NULL;
|
||||
|
||||
if (Options && !stricmp(Options, "all")) {
|
||||
Options = NULL;
|
||||
all = true;
|
||||
} // endif Options
|
||||
|
||||
for (cp = Columns; cp; cp = cp->GetNext())
|
||||
if (!strcmp(cp->GetName(), "_id"))
|
||||
id = true;
|
||||
else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*"))
|
||||
all = true;
|
||||
|
||||
if (Pipe) {
|
||||
if (trace)
|
||||
htrc("Pipeline: %s\n", Options);
|
||||
@@ -755,16 +775,31 @@ mongoc_cursor_t *TDBMGO::MakeCursor(PGLOBAL g)
|
||||
To_Filter = NULL; // Not needed anymore
|
||||
} // endif To_Filter
|
||||
|
||||
// Project list
|
||||
s->Append(",{\"$project\":{\"_id\":0");
|
||||
if (!all) {
|
||||
// Project list
|
||||
if (Columns) {
|
||||
s->Append(",{\"$project\":{\"");
|
||||
|
||||
for (PCOL cp = Columns; cp; cp = cp->GetNext()) {
|
||||
s->Append(",\"");
|
||||
s->Append(((PMGOCOL)cp)->GetProjPath(g));
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
if (!id)
|
||||
s->Append("_id\":0,\"");
|
||||
|
||||
s->Append("}}]}");
|
||||
for (cp = Columns; cp; cp = cp->GetNext()) {
|
||||
if (b)
|
||||
s->Append(",\"");
|
||||
else
|
||||
b = true;
|
||||
|
||||
s->Append(((PMGOCOL)cp)->GetProjPath(g));
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
|
||||
s->Append("}}");
|
||||
} else
|
||||
s->Append(",{\"$project\":{\"_id\":1}}");
|
||||
|
||||
} // endif all
|
||||
|
||||
s->Append("]}");
|
||||
s->Resize(s->GetLength() + 1);
|
||||
p = s->GetStr();
|
||||
|
||||
@@ -795,7 +830,7 @@ mongoc_cursor_t *TDBMGO::MakeCursor(PGLOBAL g)
|
||||
if (To_Filter) {
|
||||
char buf[512];
|
||||
|
||||
To_Filter->Print(g, buf, 511);
|
||||
To_Filter->Prints(g, buf, 511);
|
||||
htrc("To_Filter: %s\n", buf);
|
||||
} // endif To_Filter
|
||||
|
||||
@@ -829,33 +864,48 @@ mongoc_cursor_t *TDBMGO::MakeCursor(PGLOBAL g)
|
||||
} else
|
||||
Query = bson_new();
|
||||
|
||||
if (Options && *Options) {
|
||||
if (trace)
|
||||
htrc("options=%s\n", Options);
|
||||
if (!all) {
|
||||
if (Options && *Options) {
|
||||
if (trace)
|
||||
htrc("options=%s\n", Options);
|
||||
|
||||
Opts = bson_new_from_json((const uint8_t *)Options, -1, &Error);
|
||||
} else {
|
||||
// Projection list
|
||||
if (s)
|
||||
s->Set("{\"projection\":{\"_id\":0");
|
||||
else
|
||||
s = new(g) STRING(g, 511, "{\"projection\":{\"_id\":0");
|
||||
p = Options;
|
||||
} else if (Columns) {
|
||||
// Projection list
|
||||
if (s)
|
||||
s->Set("{\"projection\":{\"");
|
||||
else
|
||||
s = new(g) STRING(g, 511, "{\"projection\":{\"");
|
||||
|
||||
for (PCOL cp = Columns; cp; cp = cp->GetNext()) {
|
||||
s->Append(",\"");
|
||||
s->Append(((PMGOCOL)cp)->GetProjPath(g));
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
if (!id)
|
||||
s->Append("_id\":0,\"");
|
||||
|
||||
s->Append("}}");
|
||||
s->Resize(s->GetLength() + 1);
|
||||
Opts = bson_new_from_json((const uint8_t *)s->GetStr(), -1, &Error);
|
||||
} // endif Options
|
||||
for (cp = Columns; cp; cp = cp->GetNext()) {
|
||||
if (b)
|
||||
s->Append(",\"");
|
||||
else
|
||||
b = true;
|
||||
|
||||
if (!Opts) {
|
||||
sprintf(g->Message, "Wrong options: %s", Error.message);
|
||||
return NULL;
|
||||
} // endif Opts
|
||||
s->Append(((PMGOCOL)cp)->GetProjPath(g));
|
||||
s->Append("\":1");
|
||||
} // endfor cp
|
||||
|
||||
s->Append("}}");
|
||||
s->Resize(s->GetLength() + 1);
|
||||
p = s->GetStr();
|
||||
} else {
|
||||
// count(*) ?
|
||||
p = "{\"projection\":{\"_id\":1}}";
|
||||
} // endif Options
|
||||
|
||||
Opts = bson_new_from_json((const uint8_t *)p, -1, &Error);
|
||||
|
||||
if (!Opts) {
|
||||
sprintf(g->Message, "Wrong options: %s", Error.message);
|
||||
return NULL;
|
||||
} // endif Opts
|
||||
|
||||
} // endif all
|
||||
|
||||
cursor = mongoc_collection_find_with_opts(Collection, Query, Opts, NULL);
|
||||
} // endif Pipe
|
||||
@@ -893,6 +943,8 @@ bool TDBMGO::OpenDB(PGLOBAL g)
|
||||
|
||||
if (Mode == MODE_DELETE && !Next) {
|
||||
// Delete all documents
|
||||
Query = bson_new();
|
||||
|
||||
if (!mongoc_collection_remove(Collection, MONGOC_REMOVE_NONE,
|
||||
Query, NULL, &Error)) {
|
||||
sprintf(g->Message, "Mongo remove all: %s", Error.message);
|
||||
|
||||
@@ -273,7 +273,7 @@ PCSZ TDBODBC::GetFile(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* Set DBQ and get the new file name into the connect string. */
|
||||
/***********************************************************************/
|
||||
void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
|
||||
void TDBODBC::SetFile(PGLOBAL g, PCSZ fn)
|
||||
{
|
||||
if (MulConn) {
|
||||
int n = strlen(MulConn) + strlen(fn) - 1;
|
||||
@@ -289,7 +289,7 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
|
||||
sprintf(Connect, MulConn, fn);
|
||||
} // endif MultConn
|
||||
|
||||
DBQ = fn;
|
||||
DBQ = (PSZ)fn;
|
||||
} // end of SetFile
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -71,7 +71,7 @@ class TDBODBC : public TDBEXT {
|
||||
virtual PTDB Clone(PTABS t);
|
||||
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
||||
virtual PCSZ GetFile(PGLOBAL g);
|
||||
virtual void SetFile(PGLOBAL g, PSZ fn);
|
||||
virtual void SetFile(PGLOBAL g, PCSZ fn);
|
||||
virtual void ResetSize(void);
|
||||
virtual PCSZ GetServer(void) {return "ODBC";}
|
||||
virtual int Indexable(void) {return 2;}
|
||||
@@ -187,7 +187,6 @@ class XSRCCOL : public ODBCCOL {
|
||||
// Methods
|
||||
virtual void ReadColumn(PGLOBAL g);
|
||||
virtual void WriteColumn(PGLOBAL g);
|
||||
// void Print(PGLOBAL g, FILE *, uint);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
|
||||
@@ -62,7 +62,7 @@ class TDBINI : public TDBASE {
|
||||
virtual int GetProgCur(void) {return N;}
|
||||
//virtual int GetAffectedRows(void) {return 0;}
|
||||
virtual PCSZ GetFile(PGLOBAL g) {return Ifile;}
|
||||
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;}
|
||||
virtual void SetFile(PGLOBAL g, PCSZ fn) {Ifile = fn;}
|
||||
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;}
|
||||
virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;}
|
||||
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
|
||||
@@ -80,7 +80,7 @@ class TDBINI : public TDBASE {
|
||||
|
||||
protected:
|
||||
// Members
|
||||
char *Ifile; // The INI file
|
||||
PCSZ Ifile; // The INI file
|
||||
char *Seclist; // The section list
|
||||
char *Section; // The current section
|
||||
int Seclen; // Length of seclist buffer
|
||||
|
||||
@@ -75,7 +75,7 @@ class DllExport TDBXML : public TDBASE {
|
||||
virtual int GetRecpos(void);
|
||||
virtual int GetProgCur(void) {return N;}
|
||||
virtual PCSZ GetFile(PGLOBAL g) {return Xfile;}
|
||||
virtual void SetFile(PGLOBAL g, PSZ fn) {Xfile = fn;}
|
||||
virtual void SetFile(PGLOBAL g, PCSZ fn) {Xfile = fn;}
|
||||
virtual void ResetDB(void) {N = 0;}
|
||||
virtual void ResetSize(void) {MaxSize = -1;}
|
||||
virtual int RowNumber(PGLOBAL g, bool b = false);
|
||||
|
||||
@@ -561,7 +561,7 @@ bool VALUE::Compute(PGLOBAL g, PVAL *, int, OPVAL)
|
||||
/***********************************************************************/
|
||||
/* Make file output of an object value. */
|
||||
/***********************************************************************/
|
||||
void VALUE::Print(PGLOBAL g, FILE *f, uint n)
|
||||
void VALUE::Printf(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
char m[64], buf[64];
|
||||
|
||||
@@ -573,12 +573,12 @@ void VALUE::Print(PGLOBAL g, FILE *f, uint n)
|
||||
else
|
||||
fprintf(f, strcat(strcat(GetCharString(buf), "\n"), m));
|
||||
|
||||
} /* end of Print */
|
||||
} /* end of Printf */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of an object value. */
|
||||
/***********************************************************************/
|
||||
void VALUE::Print(PGLOBAL g, char *ps, uint z)
|
||||
void VALUE::Prints(PGLOBAL g, char *ps, uint z)
|
||||
{
|
||||
char *p, buf[64];
|
||||
|
||||
@@ -588,7 +588,7 @@ void VALUE::Print(PGLOBAL g, char *ps, uint z)
|
||||
p = GetCharString(buf);
|
||||
|
||||
strncpy(ps, p, z);
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
/* -------------------------- Class TYPVAL ---------------------------- */
|
||||
|
||||
@@ -1655,32 +1655,36 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < np; i++)
|
||||
p[i] = vp[i]->GetCharString(val[i]);
|
||||
p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]);
|
||||
|
||||
switch (op) {
|
||||
case OP_CNC:
|
||||
assert(np == 1 || np == 2);
|
||||
if (p[i]) {
|
||||
switch (op) {
|
||||
case OP_CNC:
|
||||
assert(np == 1 || np == 2);
|
||||
|
||||
if (np == 2)
|
||||
SetValue_psz(p[0]);
|
||||
if (np == 2)
|
||||
SetValue_psz(p[0]);
|
||||
|
||||
if ((i = Len - (signed)strlen(Strp)) > 0)
|
||||
strncat(Strp, p[np - 1], i);
|
||||
if ((i = Len - (signed)strlen(Strp)) > 0)
|
||||
strncat(Strp, p[np - 1], i);
|
||||
|
||||
break;
|
||||
case OP_MIN:
|
||||
assert(np == 2);
|
||||
SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
|
||||
break;
|
||||
case OP_MAX:
|
||||
assert(np == 2);
|
||||
SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
|
||||
break;
|
||||
default:
|
||||
// sprintf(g->Message, MSG(BAD_EXP_OPER), op);
|
||||
strcpy(g->Message, "Function not supported");
|
||||
return true;
|
||||
} // endswitch op
|
||||
break;
|
||||
case OP_MIN:
|
||||
assert(np == 2);
|
||||
SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
|
||||
break;
|
||||
case OP_MAX:
|
||||
assert(np == 2);
|
||||
SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
|
||||
break;
|
||||
default:
|
||||
// sprintf(g->Message, MSG(BAD_EXP_OPER), op);
|
||||
strcpy(g->Message, "Function not supported");
|
||||
return true;
|
||||
} // endswitch op
|
||||
|
||||
Null = false;
|
||||
} // endif p[i]
|
||||
|
||||
return false;
|
||||
} // end of Compute
|
||||
@@ -1712,14 +1716,14 @@ bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL, FORMAT& fmt)
|
||||
/***********************************************************************/
|
||||
/* Make string output of an object value. */
|
||||
/***********************************************************************/
|
||||
void TYPVAL<PSZ>::Print(PGLOBAL g, char *ps, uint z)
|
||||
void TYPVAL<PSZ>::Prints(PGLOBAL g, char *ps, uint z)
|
||||
{
|
||||
if (Null)
|
||||
strncpy(ps, "null", z);
|
||||
else
|
||||
strcat(strncat(strncpy(ps, "\"", z), Strp, z-2), "\"");
|
||||
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
/* -------------------------- Class DECIMAL -------------------------- */
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ class DllExport VALUE : public BLOCK {
|
||||
virtual double GetFloatValue(void) = 0;
|
||||
virtual void *GetTo_Val(void) = 0;
|
||||
virtual void SetPrec(int prec) {Prec = prec;}
|
||||
bool IsNull(void) {return Null;}
|
||||
void SetNull(bool b) {Null = b;}
|
||||
bool IsNull(void) {return (Nullable && Null);}
|
||||
void SetNull(bool b) {Null = (Nullable ? b : false);}
|
||||
bool GetNullable(void) {return Nullable;}
|
||||
void SetNullable(bool b) {Nullable = b;}
|
||||
int GetType(void) {return Type;}
|
||||
@@ -122,8 +122,8 @@ class DllExport VALUE : public BLOCK {
|
||||
virtual bool IsEqual(PVAL vp, bool chktype) = 0;
|
||||
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
|
||||
virtual bool FormatValue(PVAL vp, PCSZ fmt) = 0;
|
||||
virtual void Print(PGLOBAL g, FILE *, uint);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Printf(PGLOBAL g, FILE *, uint);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
|
||||
/**
|
||||
Set value from a non-aligned in-memory value in the machine byte order.
|
||||
@@ -308,7 +308,7 @@ class DllExport TYPVAL<PSZ>: public VALUE {
|
||||
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
|
||||
virtual bool FormatValue(PVAL vp, PCSZ fmt);
|
||||
virtual bool SetConstFormat(PGLOBAL, FORMAT&);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
|
||||
@@ -181,23 +181,23 @@ XXBASE::XXBASE(PTDBDOS tbxp, bool b) : CSORT(b),
|
||||
/***********************************************************************/
|
||||
/* Make file output of XINDEX contents. */
|
||||
/***********************************************************************/
|
||||
void XXBASE::Print(PGLOBAL, FILE *f, uint n)
|
||||
void XXBASE::Printf(PGLOBAL, FILE *f, uint n)
|
||||
{
|
||||
char m[64];
|
||||
|
||||
memset(m, ' ', n); // Make margin string
|
||||
m[n] = '\0';
|
||||
fprintf(f, "%sXINDEX: Tbxp=%p Num=%d\n", m, Tbxp, Num_K);
|
||||
} // end of Print
|
||||
} // end of Printf
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of XINDEX contents. */
|
||||
/***********************************************************************/
|
||||
void XXBASE::Print(PGLOBAL, char *ps, uint z)
|
||||
void XXBASE::Prints(PGLOBAL, char *ps, uint z)
|
||||
{
|
||||
*ps = '\0';
|
||||
strncat(ps, "Xindex", z);
|
||||
} // end of Print
|
||||
} // end of Prints
|
||||
|
||||
/* -------------------------- XINDEX Class --------------------------- */
|
||||
|
||||
|
||||
@@ -200,8 +200,8 @@ class DllExport XXBASE : public CSORT, public BLOCK {
|
||||
void FreeIndex(void) {PlgDBfree(Index);}
|
||||
|
||||
// Methods
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
virtual bool Init(PGLOBAL g) = 0;
|
||||
virtual bool Make(PGLOBAL g, PIXDEF sxp) = 0;
|
||||
#if defined(XMAP)
|
||||
|
||||
@@ -173,18 +173,18 @@ bool CONSTANT::Rephrase(PGLOBAL g, PSZ work)
|
||||
/***********************************************************************/
|
||||
/* Make file output of a constant object. */
|
||||
/***********************************************************************/
|
||||
void CONSTANT::Print(PGLOBAL g, FILE *f, uint n)
|
||||
void CONSTANT::Printf(PGLOBAL g, FILE *f, uint n)
|
||||
{
|
||||
Value->Print(g, f, n);
|
||||
} /* end of Print */
|
||||
Value->Printf(g, f, n);
|
||||
} /* end of Printf */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make string output of a constant object. */
|
||||
/***********************************************************************/
|
||||
void CONSTANT::Print(PGLOBAL g, char *ps, uint z)
|
||||
void CONSTANT::Prints(PGLOBAL g, char *ps, uint z)
|
||||
{
|
||||
Value->Print(g, ps, z);
|
||||
} /* end of Print */
|
||||
Value->Prints(g, ps, z);
|
||||
} /* end of Prints */
|
||||
|
||||
/* -------------------------- Class STRING --------------------------- */
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ class DllExport CONSTANT : public XOBJECT {
|
||||
{return Value->SetConstFormat(g, fmt);}
|
||||
void Convert(PGLOBAL g, int newtype);
|
||||
void SetValue(PVAL vp) {Value = vp;}
|
||||
virtual void Print(PGLOBAL g, FILE *, uint);
|
||||
virtual void Print(PGLOBAL g, char *, uint);
|
||||
virtual void Printf(PGLOBAL g, FILE *, uint);
|
||||
virtual void Prints(PGLOBAL g, char *, uint);
|
||||
}; // end of class CONSTANT
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -109,8 +109,8 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
|
||||
virtual PTDB Copy(PTABS t);
|
||||
virtual void PrintAM(FILE *f, char *m)
|
||||
{fprintf(f, "%s AM(%d)\n", m, GetAmType());}
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
virtual void Printf(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
||||
virtual PCSZ GetServer(void) = 0;
|
||||
virtual int GetBadLines(void) {return 0;}
|
||||
virtual CHARSET_INFO *data_charset(void);
|
||||
|
||||
Reference in New Issue
Block a user