mirror of
https://github.com/MariaDB/server.git
synced 2025-11-30 05:23:50 +03:00
commit 02d8c21380f Author: Olivier Bertrand <bertrandop@gmail.com> Date: Sat Oct 6 16:27:13 2018 +0200 - Fix truncating error messages on first unrecognized latin1 character modified: storage/connect/ha_connect.cc - Fix MDEV-17343 Reject multi-table UPDATE/DELETE commands that crash on some systems modified: storage/connect/ha_connect.cc modified: storage/connect/tabext.cpp - Try to fix failing tests (MariaDB version 10.0 only) modified: storage/connect/mysql-test/connect/disabled.def - Typo modified: storage/connect/global.h commit f83caed8569 Author: Olivier Bertrand <bertrandop@gmail.com> Date: Tue Sep 25 15:49:26 2018 +0200 - Try to fix failing tests (MariaDB version 10.0 only) modified: storage/connect/mysql-test/connect/disabled.def modified: storage/connect/mysql-test/connect/r/grant2.result modified: storage/connect/mysql-test/connect/r/infoschema2-9739.result modified: storage/connect/mysql-test/connect/r/mysql_exec.result commit 9fd6f178846 Author: Olivier Bertrand <bertrandop@gmail.com> Date: Sun Sep 23 19:45:59 2018 +0200 - Implement the CHECK TABLE statement and accept REPAIR and ANALYZE modified: storage/connect/connect.cc modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabmysql.cpp modified: storage/connect/tabodbc.cpp - MDEV-17212: Test if NumResultCols is implemented by the data source modified: storage/connect/odbconn.cpp - Change error type in Optimize modified: storage/connect/ha_connect.cc - Update version date modified: storage/connect/ha_connect.cc - Record new result from odbc_postgresql.test modified: storage/connect/mysql-test/connect/r/odbc_postgresql.result commit d8cf51319e1 Author: Olivier Bertrand <bertrandop@gmail.com> Date: Wed Aug 8 12:18:52 2018 +0200 - Comment out failing Cyrillic test in xml2.test modified: storage/connect/mysql-test/connect/r/xml2.result modified: storage/connect/mysql-test/connect/t/xml2.test commit 9df49e21f9e Author: Olivier Bertrand <bertrandop@gmail.com> Date: Tue Aug 7 15:01:06 2018 +0200 - Fix MDEV-16672 Connect: Warnings with 10.0 filamtxt.cpp: DOSFAM::RenameTempFile: Change sprintf to snprintf. filamvct.cpp: VECFAM::RenameTempFile: Change sprintf to snprintf. javaconn.cpp: Add JAVAConn::GetUTFString function. Use it instead of env->GetStringUTFChars. Fix wrong identation. javaconn.h: Add GetUTFString declaration. jdbconn.cpp: Use GetUTFString function instead of env->GetStringUTFChars. jmgoconn.cpp: Use GetUTFString function instead of env->GetStringUTFChars. Fix wrong identation. jsonudf.cpp: change 139 to BMX line 4631. tabjmg.cpp: Add ReleaseStringUTF. Fix wrong identation. tabpivot.cpp: Fix wrong identation. tabutil.cpp: TDBPRX::GetSubTable: Change sprintf to snprintf. modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/javaconn.cpp modified: storage/connect/javaconn.h modified: storage/connect/jdbconn.cpp modified: storage/connect/jmgoconn.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjmg.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabutil.cpp - Fix MDEV-16895 CONNECT engine's get_error_message can cause buffer overflow and server crash with long queries ha_connect_cc: Update version. get_error_message: Remove charset conversion. modified: storage/connect/ha_connect.cc - Fix a server crash on inserting bigint to a JDBC table JDBConn::SetUUID: Suppress check on ctyp that causes a server crash because ctyp can be negative and this triggers an DEBUG_ASSERT on return. modified: storage/connect/jdbconn.cpp - Delete an assert(qrp) from JCATPARM *AllocCatInfo that is called with qrp=NULL from JDBConn::SetUUID. Also delete a clone of this function that was duplicated in javaconn.cpp. modified: storage/connect/javaconn.cpp modified: storage/connect/jdbconn.cpp - Update some disabled tests and results to avoid failure modified: storage/connect/mysql-test/connect/r/jdbc.result modified: storage/connect/mysql-test/connect/r/json_java_2.result modified: storage/connect/mysql-test/connect/r/json_java_3.result modified: storage/connect/mysql-test/connect/r/mongo_java_2.result modified: storage/connect/mysql-test/connect/r/mongo_java_3.result modified: storage/connect/mysql-test/connect/t/json_java_2.test modified: storage/connect/mysql-test/connect/t/json_java_3.test modified: storage/connect/mysql-test/connect/t/mongo_java_2.test modified: storage/connect/mysql-test/connect/t/mongo_java_3.test commit 415273eb193 Author: Olivier Bertrand <bertrandop@gmail.com> Date: Thu Jun 28 19:37:49 2018 +0200 - Fix MDEV-16167 Cannot insert unsigned values into a VEC table modified: storage/connect/filamvct.cpp modified: storage/connect/tabvct.cpp commit 9ffcb68a9f2 Author: Olivier Bertrand <bertrandop@gmail.com> Date: Mon May 7 22:43:43 2018 +0200 - Fix MDEV-15735 CONNECT [filamtxt.cpp:429]: Suspicious condition modified: storage/connect/filamtxt.cpp - Fix compiler warnings modified: storage/connect/domdoc.cpp modified: storage/connect/ha_connect.cc modified: storage/connect/json.h modified: storage/connect/jsonudf.cpp modified: storage/connect/tabext.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h - Miscelleanous from 10.3 modified: storage/connect/ha_connect.cc modified: storage/connect/mycat.cc modified: storage/connect/user_connect.cc
313 lines
11 KiB
C++
313 lines
11 KiB
C++
/*************** tabjson H Declares Source Code File (.H) **************/
|
|
/* Name: tabjson.h Version 1.3 */
|
|
/* */
|
|
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
|
|
/* */
|
|
/* This file contains the JSON classes declares. */
|
|
/***********************************************************************/
|
|
#include "osutil.h"
|
|
#include "block.h"
|
|
#include "colblk.h"
|
|
#include "json.h"
|
|
|
|
enum JMODE {MODE_OBJECT, MODE_ARRAY, MODE_VALUE};
|
|
|
|
typedef class JSONDEF *PJDEF;
|
|
typedef class TDBJSON *PJTDB;
|
|
typedef class JSONCOL *PJCOL;
|
|
class TDBJSN;
|
|
PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info);
|
|
|
|
/***********************************************************************/
|
|
/* The JSON tree node. Can be an Object or an Array. */
|
|
/***********************************************************************/
|
|
typedef struct _jnode {
|
|
PSZ Key; // The key used for object
|
|
OPVAL Op; // Operator used for this node
|
|
PVAL CncVal; // To cont value used for OP_CNC
|
|
PVAL Valp; // The internal array VALUE
|
|
int Rank; // The rank in array
|
|
int Rx; // Read row number
|
|
int Nx; // Next to read row number
|
|
} JNODE, *PJNODE;
|
|
|
|
typedef struct _jncol {
|
|
struct _jncol *Next;
|
|
char *Name;
|
|
char *Fmt;
|
|
int Type;
|
|
int Len;
|
|
int Scale;
|
|
bool Cbn;
|
|
bool Found;
|
|
} JCOL, *PJCL;
|
|
|
|
/***********************************************************************/
|
|
/* Class used to get the columns of a mongo collection. */
|
|
/***********************************************************************/
|
|
class JSONDISC : public BLOCK {
|
|
public:
|
|
// Constructor
|
|
JSONDISC(PGLOBAL g, uint *lg);
|
|
|
|
// Functions
|
|
int GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt);
|
|
bool Find(PGLOBAL g, PJVAL jvp, int j);
|
|
void AddColumn(PGLOBAL g);
|
|
|
|
// Members
|
|
JCOL jcol;
|
|
PJCL jcp, fjcp, pjcp;
|
|
PVAL valp;
|
|
PJDEF tdp;
|
|
TDBJSN *tjnp;
|
|
PJTDB tjsp;
|
|
PJPR jpp;
|
|
PJSON jsp;
|
|
PJOB row;
|
|
PCSZ sep;
|
|
char colname[65], fmt[129], buf[16];
|
|
uint *length;
|
|
int i, n, bf, ncol, lvl;
|
|
bool all;
|
|
}; // end of JSONDISC
|
|
|
|
/***********************************************************************/
|
|
/* JSON table. */
|
|
/***********************************************************************/
|
|
class DllExport JSONDEF : public DOSDEF { /* Table description */
|
|
friend class TDBJSON;
|
|
friend class TDBJSN;
|
|
friend class TDBJCL;
|
|
friend class JSONDISC;
|
|
#if defined(CMGO_SUPPORT)
|
|
friend class CMGFAM;
|
|
#endif // CMGO_SUPPORT
|
|
#if defined(JAVA_SUPPORT)
|
|
friend class JMGFAM;
|
|
#endif // JAVA_SUPPORT
|
|
public:
|
|
// Constructor
|
|
JSONDEF(void);
|
|
|
|
// Implementation
|
|
virtual const char *GetType(void) {return "JSON";}
|
|
|
|
// Methods
|
|
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
|
virtual PTDB GetTable(PGLOBAL g, MODE m);
|
|
|
|
protected:
|
|
// Members
|
|
JMODE Jmode; /* MODE_OBJECT by default */
|
|
PCSZ Objname; /* Name of first level object */
|
|
PCSZ Xcol; /* Name of expandable column */
|
|
int Limit; /* Limit of multiple values */
|
|
int Pretty; /* Depends on file structure */
|
|
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 */
|
|
PCSZ Collname; /* External collection name */
|
|
PSZ Options; /* Colist ; Pipe */
|
|
PSZ Filter; /* Filter */
|
|
PSZ Driver; /* MongoDB Driver (C or JAVA) */
|
|
bool Pipe; /* True if Colist is a pipeline */
|
|
int Version; /* Driver version */
|
|
PSZ Wrapname; /* MongoDB java wrapper name */
|
|
}; // end of JSONDEF
|
|
|
|
/* -------------------------- TDBJSN class --------------------------- */
|
|
|
|
/***********************************************************************/
|
|
/* This is the JSN Access Method class declaration. */
|
|
/* The table is a DOS file, each record being a JSON object. */
|
|
/***********************************************************************/
|
|
class DllExport TDBJSN : public TDBDOS {
|
|
friend class JSONCOL;
|
|
friend class JSONDEF;
|
|
#if defined(CMGO_SUPPORT)
|
|
friend class CMGFAM;
|
|
#endif // CMGO_SUPPORT
|
|
#if defined(JAVA_SUPPORT)
|
|
friend class JMGFAM;
|
|
#endif // JAVA_SUPPORT
|
|
public:
|
|
// Constructor
|
|
TDBJSN(PJDEF tdp, PTXF txfp);
|
|
TDBJSN(TDBJSN *tdbp);
|
|
|
|
// Implementation
|
|
virtual AMT GetAmType(void) {return TYPE_AM_JSN;}
|
|
virtual bool SkipHeader(PGLOBAL g);
|
|
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);}
|
|
PJSON GetRow(void) {return Row;}
|
|
void SetG(PGLOBAL g) {G = g;}
|
|
|
|
// Methods
|
|
virtual PTDB Clone(PTABS t);
|
|
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
|
virtual PCOL InsertSpecialColumn(PCOL colp);
|
|
virtual int RowNumber(PGLOBAL g, bool b = FALSE)
|
|
{return (b) ? M : N;}
|
|
virtual bool CanBeFiltered(void)
|
|
{return Txfp->GetAmType() == TYPE_AM_MGO || !Xcol;}
|
|
|
|
// Database routines
|
|
virtual int Cardinality(PGLOBAL g);
|
|
virtual int GetMaxSize(PGLOBAL g);
|
|
virtual bool OpenDB(PGLOBAL g);
|
|
virtual int ReadDB(PGLOBAL g);
|
|
virtual bool PrepareWriting(PGLOBAL g);
|
|
virtual int WriteDB(PGLOBAL g);
|
|
|
|
protected:
|
|
PJSON FindRow(PGLOBAL g);
|
|
int MakeTopTree(PGLOBAL g, PJSON jsp);
|
|
|
|
// Members
|
|
PGLOBAL G; // Support of parse memory
|
|
PJSON Top; // The top JSON tree
|
|
PJSON Row; // The current row
|
|
PJSON Val; // The value of the current row
|
|
PJCOL Colp; // The multiple column
|
|
JMODE Jmode; // MODE_OBJECT by default
|
|
PCSZ Objname; // The table object name
|
|
PCSZ Xcol; // Name of expandable column
|
|
int Fpos; // The current row index
|
|
int N; // The current Rownum
|
|
int M; // Index of multiple value
|
|
int Limit; // Limit of multiple values
|
|
int Pretty; // Depends on file structure
|
|
int NextSame; // Same next row
|
|
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
|
|
|
|
/* -------------------------- JSONCOL class -------------------------- */
|
|
|
|
/***********************************************************************/
|
|
/* Class JSONCOL: JSON access method column descriptor. */
|
|
/***********************************************************************/
|
|
class DllExport JSONCOL : public DOSCOL {
|
|
friend class TDBJSN;
|
|
friend class TDBJSON;
|
|
#if defined(CMGO_SUPPORT)
|
|
friend class CMGFAM;
|
|
#endif // CMGO_SUPPORT
|
|
#if defined(JAVA_SUPPORT)
|
|
friend class JMGFAM;
|
|
#endif // JAVA_SUPPORT
|
|
public:
|
|
// Constructors
|
|
JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
|
|
JSONCOL(JSONCOL *colp, PTDB tdbp); // Constructor used in copy process
|
|
|
|
// Implementation
|
|
virtual int GetAmType(void) {return Tjp->GetAmType();}
|
|
|
|
// Methods
|
|
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
|
bool ParseJpath(PGLOBAL g);
|
|
virtual PSZ GetJpath(PGLOBAL g, bool proj);
|
|
virtual void ReadColumn(PGLOBAL g);
|
|
virtual void WriteColumn(PGLOBAL g);
|
|
|
|
protected:
|
|
bool CheckExpand(PGLOBAL g, int i, PSZ nm, bool b);
|
|
bool SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm);
|
|
PVAL GetColumnValue(PGLOBAL g, PJSON row, int i);
|
|
PVAL ExpandArray(PGLOBAL g, PJAR arp, int n);
|
|
PVAL CalculateArray(PGLOBAL g, PJAR arp, int n);
|
|
PVAL MakeJson(PGLOBAL g, PJSON jsp);
|
|
void SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n);
|
|
PJSON GetRow(PGLOBAL g);
|
|
|
|
// Default constructor not to be used
|
|
JSONCOL(void) {}
|
|
|
|
// Members
|
|
PGLOBAL G; // Support of parse memory
|
|
TDBJSN *Tjp; // To the JSN table block
|
|
PVAL MulVal; // To value used by multiple column
|
|
char *Jpath; // The json path
|
|
JNODE *Nodes; // The intermediate objects
|
|
int Nod; // The number of intermediate objects
|
|
int Xnod; // Index of multiple values
|
|
char Sep; // The Jpath separator
|
|
bool Xpd; // True for expandable column
|
|
bool Parsed; // True when parsed
|
|
}; // end of class JSONCOL
|
|
|
|
/* -------------------------- TDBJSON class -------------------------- */
|
|
|
|
/***********************************************************************/
|
|
/* This is the JSON Access Method class declaration. */
|
|
/***********************************************************************/
|
|
class DllExport TDBJSON : public TDBJSN {
|
|
friend class JSONDEF;
|
|
friend class JSONCOL;
|
|
public:
|
|
// Constructor
|
|
TDBJSON(PJDEF tdp, PTXF txfp);
|
|
TDBJSON(PJTDB tdbp);
|
|
|
|
// Implementation
|
|
virtual AMT GetAmType(void) {return TYPE_AM_JSON;}
|
|
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSON(this);}
|
|
PJAR GetDoc(void) {return Doc;}
|
|
|
|
// Methods
|
|
virtual PTDB Clone(PTABS t);
|
|
|
|
// Database routines
|
|
virtual int Cardinality(PGLOBAL g);
|
|
virtual int GetMaxSize(PGLOBAL g);
|
|
virtual void ResetSize(void);
|
|
virtual int GetProgCur(void) {return N;}
|
|
virtual int GetRecpos(void);
|
|
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
|
virtual bool OpenDB(PGLOBAL g);
|
|
virtual int ReadDB(PGLOBAL g);
|
|
virtual bool PrepareWriting(PGLOBAL g) {return false;}
|
|
virtual int WriteDB(PGLOBAL g);
|
|
virtual int DeleteDB(PGLOBAL g, int irc);
|
|
virtual void CloseDB(PGLOBAL g);
|
|
int MakeDocument(PGLOBAL g);
|
|
|
|
// Optimization routines
|
|
virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
|
|
|
|
protected:
|
|
int MakeNewDoc(PGLOBAL g);
|
|
|
|
// Members
|
|
PJAR Doc; // The document array
|
|
int Multiple; // 0: No 1: DIR 2: Section 3: filelist
|
|
bool Done; // True when document parsing is done
|
|
bool Changed; // After Update, Insert or Delete
|
|
}; // end of class TDBJSON
|
|
|
|
/***********************************************************************/
|
|
/* This is the class declaration for the JSON catalog table. */
|
|
/***********************************************************************/
|
|
class DllExport TDBJCL : public TDBCAT {
|
|
public:
|
|
// Constructor
|
|
TDBJCL(PJDEF tdp);
|
|
|
|
protected:
|
|
// Specific routines
|
|
virtual PQRYRES GetResult(PGLOBAL g);
|
|
|
|
// Members
|
|
PTOS Topt;
|
|
PCSZ Db;
|
|
PCSZ Dsn;
|
|
}; // end of class TDBJCL
|