mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
- Make PlugSubAlloc to be exportable
Suppress unused parameter from PlugSubSet modified: storage/connect/global.h modified: storage/connect/plugutil.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/user_connect.cc - Fix a bug making column catalog XML tables fail modified: storage/connect/tabxml.cpp - Comment out wrong message modified: storage/connect/ha_connect.cc - Update error message when sorting an ODBC table fails modified: storage/connect/tabodbc.cpp - Add error message when gettting an address from an OEM fails. modified: storage/connect/reldef.cpp - Make some modifications useful for OEM module writting Export discovery functions for CSV, JDBC and XML Remove unuseful include from tabjson.h Move TDBXML::data_charset function from header file to source modified: storage/connect/tabfmt.h modified: storage/connect/tabjson.h modified: storage/connect/tabxml.cpp modified: storage/connect/tabxml.h - Update test result modified: storage/connect/mysql-test/connect/r/jdbc_oracle.result
This commit is contained in:
parent
5d6daa6f15
commit
0fb92dddf9
13 changed files with 225 additions and 197 deletions
|
@ -219,11 +219,11 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir);
|
|||
DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
|
||||
DllExport bool AllocSarea(PGLOBAL, uint);
|
||||
DllExport void FreeSarea(PGLOBAL);
|
||||
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
|
||||
DllExport BOOL PlugSubSet(void *, uint);
|
||||
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
|
||||
DllExport char *PlugDup(PGLOBAL g, const char *str);
|
||||
DllExport void *MakePtr(void *, OFFSET);
|
||||
DllExport void htrc(char const *fmt, ...);
|
||||
//DllExport int GetTraceValue(void);
|
||||
DllExport uint GetTraceValue(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -233,6 +233,6 @@ DllExport uint GetTraceValue(void);
|
|||
/***********************************************************************/
|
||||
/* Non exported routine declarations. */
|
||||
/***********************************************************************/
|
||||
void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
|
||||
//void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
|
||||
|
||||
/*-------------------------- End of Global.H --------------------------*/
|
||||
|
|
|
@ -4191,7 +4191,7 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
|
|||
rc= rnd_next(buf);
|
||||
} else {
|
||||
PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp);
|
||||
strcpy(g->Message, "Not supported by this table type");
|
||||
// strcpy(g->Message, "Not supported by this table type");
|
||||
my_message(ER_ILLEGAL_HA, g->Message, MYF(0));
|
||||
rc= HA_ERR_INTERNAL_ERROR;
|
||||
} // endif SetRecpos
|
||||
|
|
|
@ -3055,7 +3055,7 @@ my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
|
||||
PlugSubSet(g, g->Sarea, g->Sarea_Size);
|
||||
PlugSubSet(g->Sarea, g->Sarea_Size);
|
||||
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR);
|
||||
g->N = (int)n;
|
||||
return false;
|
||||
|
@ -3098,7 +3098,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*)
|
|||
{
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
|
||||
PlugSubSet(g, g->Sarea, g->Sarea_Size);
|
||||
PlugSubSet(g->Sarea, g->Sarea_Size);
|
||||
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR);
|
||||
g->N = GetJsonGroupSize();
|
||||
} // end of json_array_grp_clear
|
||||
|
@ -3132,7 +3132,7 @@ my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
|
||||
PlugSubSet(g, g->Sarea, g->Sarea_Size);
|
||||
PlugSubSet(g->Sarea, g->Sarea_Size);
|
||||
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB);
|
||||
g->N = (int)n;
|
||||
return false;
|
||||
|
@ -3169,7 +3169,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*)
|
|||
{
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
|
||||
PlugSubSet(g, g->Sarea, g->Sarea_Size);
|
||||
PlugSubSet(g->Sarea, g->Sarea_Size);
|
||||
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB);
|
||||
g->N = GetJsonGroupSize();
|
||||
} // end of json_object_grp_clear
|
||||
|
@ -4418,7 +4418,7 @@ char *json_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
PlugSubSet(g, g->Sarea, g->Sarea_Size);
|
||||
PlugSubSet(g->Sarea, g->Sarea_Size);
|
||||
fn = MakePSZ(g, args, 0);
|
||||
|
||||
if (args->arg_count > 1) {
|
||||
|
@ -5662,7 +5662,7 @@ char *jbin_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
if (bsp && !bsp->Changed)
|
||||
goto fin;
|
||||
|
||||
PlugSubSet(g, g->Sarea, g->Sarea_Size);
|
||||
PlugSubSet(g->Sarea, g->Sarea_Size);
|
||||
g->Xchk = NULL;
|
||||
fn = MakePSZ(g, args, 0);
|
||||
pretty = (args->arg_count > 2 && args->args[2]) ? (int)*(longlong*)args->args[2] : 3;
|
||||
|
|
|
@ -8,12 +8,19 @@ SELECT * FROM t2 WHERE command = 'drop table employee';
|
|||
command number message
|
||||
drop table employee 0 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
|
||||
|
||||
Warnings:
|
||||
Warning 1105 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
|
||||
|
||||
SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary number(8,2))';
|
||||
command number message
|
||||
create table employee (id int not null, name varchar(32), title char(16), salary number(8,2)) 0 Affected rows
|
||||
Warnings:
|
||||
Warning 1105 Affected rows
|
||||
SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)";
|
||||
command number message
|
||||
insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows
|
||||
Warnings:
|
||||
Warning 1105 Affected rows
|
||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
|
||||
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
||||
OPTION_LIST='User=system,Password=manager';
|
||||
|
@ -27,8 +34,8 @@ OPTION_LIST='User=system,Password=manager';
|
|||
SELECT * FROM t1;
|
||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||
NULL SYSTEM EMPLOYEE ID 3 NUMBER 38 0 0 10 0 NULL
|
||||
NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 0 10 1 NULL
|
||||
NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 0 10 1 NULL
|
||||
NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 NULL 10 1 NULL
|
||||
NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 NULL 10 1 NULL
|
||||
NULL SYSTEM EMPLOYEE SALARY 3 NUMBER 8 0 2 10 1 NULL
|
||||
DROP TABLE t1;
|
||||
CREATE SERVER 'oracle' FOREIGN DATA WRAPPER 'oracle.jdbc.driver.OracleDriver' OPTIONS (
|
||||
|
@ -52,7 +59,7 @@ Note 1105 EMPLOYEE: 1 affected rows
|
|||
SELECT * FROM t1;
|
||||
ID NAME TITLE SALARY
|
||||
4567 Trump Engineer 12560.50
|
||||
6214 Clinton Retired 0.00
|
||||
6214 Clinton Retired NULL
|
||||
DELETE FROM t1 WHERE id = 6214;
|
||||
Warnings:
|
||||
Note 1105 EMPLOYEE: 1 affected rows
|
||||
|
@ -63,8 +70,7 @@ DROP TABLE t1;
|
|||
SELECT * FROM t2 WHERE command = 'drop table employee';
|
||||
command number message
|
||||
drop table employee 0 Affected rows
|
||||
Warnings:
|
||||
Warning 1105 Affected rows
|
||||
DROP TABLE t2;
|
||||
DROP SERVER 'oracle';
|
||||
SET GLOBAL connect_jvm_path=NULL;
|
||||
SET GLOBAL connect_class_path=NULL;
|
||||
SET GLOBAL time_zone = SYSTEM;
|
||||
|
|
|
@ -514,23 +514,27 @@ void FreeSarea(PGLOBAL g)
|
|||
/* Here there should be some verification done such as validity of */
|
||||
/* the address and size not larger than memory size. */
|
||||
/***********************************************************************/
|
||||
BOOL PlugSubSet(PGLOBAL g __attribute__((unused)), void *memp, uint size)
|
||||
BOOL PlugSubSet(void *memp, uint size)
|
||||
{
|
||||
PPOOLHEADER pph = (PPOOLHEADER)memp;
|
||||
|
||||
pph->To_Free = (OFFSET)sizeof(POOLHEADER);
|
||||
pph->FreeBlk = size - pph->To_Free;
|
||||
|
||||
return FALSE;
|
||||
} /* end of PlugSubSet */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Use it to export a function that do throwing. */
|
||||
/***********************************************************************/
|
||||
void *DoThrow(int n)
|
||||
{
|
||||
throw n;
|
||||
} /* end of DoThrow */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Program for sub-allocating one item in a storage area. */
|
||||
/* Note: SubAlloc routines of OS/2 are no more used to increase the */
|
||||
/* code portability and avoid problems when a grammar compiled under */
|
||||
/* one version of OS/2 is used under another version. */
|
||||
/* The simple way things are done here is also based on the fact */
|
||||
/* that no freeing of suballocated blocks is permitted in Plug. */
|
||||
/* The simple way things are done here is based on the fact */
|
||||
/* that no freeing of suballocated blocks is permitted in CONNECT. */
|
||||
/***********************************************************************/
|
||||
void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
||||
{
|
||||
|
@ -559,7 +563,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||
if (trace(1))
|
||||
htrc("PlugSubAlloc: %s\n", g->Message);
|
||||
|
||||
throw 1234;
|
||||
DoThrow(1234);
|
||||
} /* endif size OS32 code */
|
||||
|
||||
/*********************************************************************/
|
||||
|
|
|
@ -522,7 +522,14 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
|
|||
|
||||
// Get the function returning an instance of the external DEF class
|
||||
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
|
||||
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
|
||||
char buf[256];
|
||||
DWORD rc = GetLastError();
|
||||
|
||||
sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname);
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
|
||||
(LPTSTR)buf, sizeof(buf), NULL);
|
||||
strcat(strcat(g->Message, ": "), buf);
|
||||
FreeLibrary((HMODULE)Hdll);
|
||||
return NULL;
|
||||
} // endif getdef
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef class TDBFMT *PTDBFMT;
|
|||
/***********************************************************************/
|
||||
/* Functions used externally. */
|
||||
/***********************************************************************/
|
||||
PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
|
||||
DllExport PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
|
||||
|
||||
/***********************************************************************/
|
||||
/* CSV table. */
|
||||
|
|
|
@ -299,7 +299,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||
memset(G, 0, sizeof(GLOBAL));
|
||||
G->Sarea_Size = tdp->Lrecl * 10;
|
||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
PlugSubSet(G->Sarea, G->Sarea_Size);
|
||||
G->jump_level = 0;
|
||||
tjnp->SetG(G);
|
||||
|
||||
|
@ -670,7 +670,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||
memset(G, 0, sizeof(GLOBAL));
|
||||
G->Sarea_Size = Lrecl * 10;
|
||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
PlugSubSet(G->Sarea, G->Sarea_Size);
|
||||
G->jump_level = 0;
|
||||
((TDBJSN*)tdbp)->G = G;
|
||||
} else {
|
||||
|
@ -963,7 +963,7 @@ int TDBJSN::ReadDB(PGLOBAL g)
|
|||
return rc;
|
||||
|
||||
// Recover the memory used for parsing
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
PlugSubSet(G->Sarea, G->Sarea_Size);
|
||||
|
||||
if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) {
|
||||
Row = FindRow(g);
|
||||
|
@ -1079,13 +1079,13 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
|||
} // end of PrepareWriting
|
||||
|
||||
/***********************************************************************/
|
||||
/* WriteDB: Data Base write routine for DOS access method. */
|
||||
/* WriteDB: Data Base write routine for JSON access method. */
|
||||
/***********************************************************************/
|
||||
int TDBJSN::WriteDB(PGLOBAL g)
|
||||
{
|
||||
int rc = TDBDOS::WriteDB(g);
|
||||
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
PlugSubSet(G->Sarea, G->Sarea_Size);
|
||||
Row->Clear();
|
||||
return rc;
|
||||
} // end of WriteDB
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*************** tabjson H Declares Source Code File (.H) **************/
|
||||
/* Name: tabjson.h Version 1.3 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2018 */
|
||||
/* */
|
||||
/* This file contains the JSON classes declares. */
|
||||
/***********************************************************************/
|
||||
#include "osutil.h"
|
||||
//#include "osutil.h" // Unuseful and bad for OEM
|
||||
#include "block.h"
|
||||
#include "colblk.h"
|
||||
#include "json.h"
|
||||
|
@ -16,7 +16,7 @@ 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);
|
||||
DllExport PQRYRES JSONColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool);
|
||||
|
||||
/***********************************************************************/
|
||||
/* The JSON tree node. Can be an Object or an Array. */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2000-2017 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2000-2018 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
|
@ -593,7 +593,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
|
|||
Use = USE_OPEN; // Do it now in case we are recursively called
|
||||
|
||||
/*********************************************************************/
|
||||
/* Make the command and allocate whatever is used for getting results. */
|
||||
/* Make the command and allocate whatever is used for getting results*/
|
||||
/*********************************************************************/
|
||||
if (Mode == MODE_READ || Mode == MODE_READX) {
|
||||
if (Memory > 1 && !Srcdef) {
|
||||
|
@ -696,7 +696,8 @@ bool TDBODBC::SetRecpos(PGLOBAL g, int recpos)
|
|||
} // endif recpos
|
||||
|
||||
} else {
|
||||
strcpy(g->Message, "This action requires a scrollable cursor");
|
||||
strcpy(g->Message,
|
||||
"This action requires Memory setting or a scrollable cursor");
|
||||
return true;
|
||||
} // endif's
|
||||
|
||||
|
@ -1283,7 +1284,7 @@ int TDBXDBC::ReadDB(PGLOBAL g)
|
|||
} // end of ReadDB
|
||||
|
||||
/***********************************************************************/
|
||||
/* Data Base delete line routine for ODBC access method. */
|
||||
/* Data Base write line routine for XDBC access method. */
|
||||
/***********************************************************************/
|
||||
int TDBXDBC::WriteDB(PGLOBAL g)
|
||||
{
|
||||
|
@ -1292,7 +1293,7 @@ int TDBXDBC::WriteDB(PGLOBAL g)
|
|||
} // end of DeleteDB
|
||||
|
||||
/***********************************************************************/
|
||||
/* Data Base delete line routine for ODBC access method. */
|
||||
/* Data Base delete line routine for XDBC access method. */
|
||||
/***********************************************************************/
|
||||
int TDBXDBC::DeleteDB(PGLOBAL g, int irc)
|
||||
{
|
||||
|
|
|
@ -681,6 +681,14 @@ PTDB TDBXML::Clone(PTABS t)
|
|||
return tp;
|
||||
} // end of Clone
|
||||
|
||||
/***********************************************************************/
|
||||
/* Must not be in tabxml.h because of OEM tables */
|
||||
/***********************************************************************/
|
||||
const CHARSET_INFO *TDBXML::data_charset()
|
||||
{
|
||||
return &my_charset_utf8_general_ci;
|
||||
} // end of data_charset
|
||||
|
||||
/***********************************************************************/
|
||||
/* Allocate XML column description block. */
|
||||
/***********************************************************************/
|
||||
|
@ -2209,7 +2217,8 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
|
|||
TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp)
|
||||
{
|
||||
Topt = tdp->GetTopt();
|
||||
Db = (char*)tdp->GetDB();
|
||||
//Db = (char*)tdp->GetDB();
|
||||
Db = (char*)tdp->Schema;
|
||||
Tabn = tdp->Tabname;
|
||||
} // end of TDBXCT constructor
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ typedef class XMLDEF *PXMLDEF;
|
|||
typedef class TDBXML *PTDBXML;
|
||||
typedef class XMLCOL *PXMLCOL;
|
||||
|
||||
DllExport PQRYRES XMLColumns(PGLOBAL, char *, char *, PTOS, bool);
|
||||
|
||||
/* --------------------------- XML classes --------------------------- */
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -100,8 +102,7 @@ class DllExport TDBXML : public TDBASE {
|
|||
virtual int DeleteDB(PGLOBAL g, int irc);
|
||||
virtual void CloseDB(PGLOBAL g);
|
||||
virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;}
|
||||
virtual const CHARSET_INFO *data_charset()
|
||||
{return &my_charset_utf8_general_ci;}
|
||||
virtual const CHARSET_INFO *data_charset();
|
||||
|
||||
protected:
|
||||
// Members
|
||||
|
|
|
@ -107,7 +107,7 @@ bool user_connect::user_init()
|
|||
g= PlugInit(NULL, worksize);
|
||||
|
||||
// Check whether the initialization is complete
|
||||
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
|
||||
if (!g || !g->Sarea || PlugSubSet(g->Sarea, g->Sarea_Size)
|
||||
|| !(dup= PlgMakeUser(g))) {
|
||||
if (g)
|
||||
printf("%s\n", g->Message);
|
||||
|
@ -172,7 +172,7 @@ bool user_connect::CheckCleanup(bool force)
|
|||
|
||||
} // endif worksize
|
||||
|
||||
PlugSubSet(g, g->Sarea, g->Sarea_Size);
|
||||
PlugSubSet(g->Sarea, g->Sarea_Size);
|
||||
g->Xchk = NULL;
|
||||
g->Createas = 0;
|
||||
g->Alchecked = 0;
|
||||
|
|
Loading…
Reference in a new issue