Skip to content

Commit 0fb92dd

Browse files
committed
- 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
1 parent 5d6daa6 commit 0fb92dd

File tree

13 files changed

+231
-203
lines changed

13 files changed

+231
-203
lines changed

storage/connect/global.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir);
219219
DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
220220
DllExport bool AllocSarea(PGLOBAL, uint);
221221
DllExport void FreeSarea(PGLOBAL);
222-
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
222+
DllExport BOOL PlugSubSet(void *, uint);
223+
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
223224
DllExport char *PlugDup(PGLOBAL g, const char *str);
224225
DllExport void *MakePtr(void *, OFFSET);
225226
DllExport void htrc(char const *fmt, ...);
226-
//DllExport int GetTraceValue(void);
227227
DllExport uint GetTraceValue(void);
228228

229229
#if defined(__cplusplus)
@@ -233,6 +233,6 @@ DllExport uint GetTraceValue(void);
233233
/***********************************************************************/
234234
/* Non exported routine declarations. */
235235
/***********************************************************************/
236-
void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
236+
//void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
237237

238238
/*-------------------------- End of Global.H --------------------------*/

storage/connect/ha_connect.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4191,7 +4191,7 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
41914191
rc= rnd_next(buf);
41924192
} else {
41934193
PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp);
4194-
strcpy(g->Message, "Not supported by this table type");
4194+
// strcpy(g->Message, "Not supported by this table type");
41954195
my_message(ER_ILLEGAL_HA, g->Message, MYF(0));
41964196
rc= HA_ERR_INTERNAL_ERROR;
41974197
} // endif SetRecpos

storage/connect/jsonudf.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
30553055

30563056
PGLOBAL g = (PGLOBAL)initid->ptr;
30573057

3058-
PlugSubSet(g, g->Sarea, g->Sarea_Size);
3058+
PlugSubSet(g->Sarea, g->Sarea_Size);
30593059
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR);
30603060
g->N = (int)n;
30613061
return false;
@@ -3098,7 +3098,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*)
30983098
{
30993099
PGLOBAL g = (PGLOBAL)initid->ptr;
31003100

3101-
PlugSubSet(g, g->Sarea, g->Sarea_Size);
3101+
PlugSubSet(g->Sarea, g->Sarea_Size);
31023102
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR);
31033103
g->N = GetJsonGroupSize();
31043104
} // end of json_array_grp_clear
@@ -3132,7 +3132,7 @@ my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
31323132

31333133
PGLOBAL g = (PGLOBAL)initid->ptr;
31343134

3135-
PlugSubSet(g, g->Sarea, g->Sarea_Size);
3135+
PlugSubSet(g->Sarea, g->Sarea_Size);
31363136
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB);
31373137
g->N = (int)n;
31383138
return false;
@@ -3169,7 +3169,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*)
31693169
{
31703170
PGLOBAL g = (PGLOBAL)initid->ptr;
31713171

3172-
PlugSubSet(g, g->Sarea, g->Sarea_Size);
3172+
PlugSubSet(g->Sarea, g->Sarea_Size);
31733173
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB);
31743174
g->N = GetJsonGroupSize();
31753175
} // end of json_object_grp_clear
@@ -4418,7 +4418,7 @@ char *json_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
44184418
} else if (initid->const_item)
44194419
g->N = 1;
44204420

4421-
PlugSubSet(g, g->Sarea, g->Sarea_Size);
4421+
PlugSubSet(g->Sarea, g->Sarea_Size);
44224422
fn = MakePSZ(g, args, 0);
44234423

44244424
if (args->arg_count > 1) {
@@ -5662,7 +5662,7 @@ char *jbin_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
56625662
if (bsp && !bsp->Changed)
56635663
goto fin;
56645664

5665-
PlugSubSet(g, g->Sarea, g->Sarea_Size);
5665+
PlugSubSet(g->Sarea, g->Sarea_Size);
56665666
g->Xchk = NULL;
56675667
fn = MakePSZ(g, args, 0);
56685668
pretty = (args->arg_count > 2 && args->args[2]) ? (int)*(longlong*)args->args[2] : 3;

storage/connect/mysql-test/connect/r/jdbc_oracle.result

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ SELECT * FROM t2 WHERE command = 'drop table employee';
88
command number message
99
drop table employee 0 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
1010

11+
Warnings:
12+
Warning 1105 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
13+
1114
SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary number(8,2))';
1215
command number message
1316
create table employee (id int not null, name varchar(32), title char(16), salary number(8,2)) 0 Affected rows
17+
Warnings:
18+
Warning 1105 Affected rows
1419
SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)";
1520
command number message
1621
insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows
22+
Warnings:
23+
Warning 1105 Affected rows
1724
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
1825
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
1926
OPTION_LIST='User=system,Password=manager';
@@ -27,8 +34,8 @@ OPTION_LIST='User=system,Password=manager';
2734
SELECT * FROM t1;
2835
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
2936
NULL SYSTEM EMPLOYEE ID 3 NUMBER 38 0 0 10 0 NULL
30-
NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 0 10 1 NULL
31-
NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 0 10 1 NULL
37+
NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 NULL 10 1 NULL
38+
NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 NULL 10 1 NULL
3239
NULL SYSTEM EMPLOYEE SALARY 3 NUMBER 8 0 2 10 1 NULL
3340
DROP TABLE t1;
3441
CREATE SERVER 'oracle' FOREIGN DATA WRAPPER 'oracle.jdbc.driver.OracleDriver' OPTIONS (
@@ -52,7 +59,7 @@ Note 1105 EMPLOYEE: 1 affected rows
5259
SELECT * FROM t1;
5360
ID NAME TITLE SALARY
5461
4567 Trump Engineer 12560.50
55-
6214 Clinton Retired 0.00
62+
6214 Clinton Retired NULL
5663
DELETE FROM t1 WHERE id = 6214;
5764
Warnings:
5865
Note 1105 EMPLOYEE: 1 affected rows
@@ -63,8 +70,7 @@ DROP TABLE t1;
6370
SELECT * FROM t2 WHERE command = 'drop table employee';
6471
command number message
6572
drop table employee 0 Affected rows
73+
Warnings:
74+
Warning 1105 Affected rows
6675
DROP TABLE t2;
6776
DROP SERVER 'oracle';
68-
SET GLOBAL connect_jvm_path=NULL;
69-
SET GLOBAL connect_class_path=NULL;
70-
SET GLOBAL time_zone = SYSTEM;

storage/connect/plugutil.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -514,27 +514,31 @@ void FreeSarea(PGLOBAL g)
514514
/* Here there should be some verification done such as validity of */
515515
/* the address and size not larger than memory size. */
516516
/***********************************************************************/
517-
BOOL PlugSubSet(PGLOBAL g __attribute__((unused)), void *memp, uint size)
517+
BOOL PlugSubSet(void *memp, uint size)
518518
{
519519
PPOOLHEADER pph = (PPOOLHEADER)memp;
520520

521521
pph->To_Free = (OFFSET)sizeof(POOLHEADER);
522522
pph->FreeBlk = size - pph->To_Free;
523-
524523
return FALSE;
525524
} /* end of PlugSubSet */
526525

526+
/***********************************************************************/
527+
/* Use it to export a function that do throwing. */
528+
/***********************************************************************/
529+
void *DoThrow(int n)
530+
{
531+
throw n;
532+
} /* end of DoThrow */
533+
527534
/***********************************************************************/
528535
/* Program for sub-allocating one item in a storage area. */
529-
/* Note: SubAlloc routines of OS/2 are no more used to increase the */
530-
/* code portability and avoid problems when a grammar compiled under */
531-
/* one version of OS/2 is used under another version. */
532-
/* The simple way things are done here is also based on the fact */
533-
/* that no freeing of suballocated blocks is permitted in Plug. */
536+
/* The simple way things are done here is based on the fact */
537+
/* that no freeing of suballocated blocks is permitted in CONNECT. */
534538
/***********************************************************************/
535539
void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
536-
{
537-
PPOOLHEADER pph; /* Points on area header. */
540+
{
541+
PPOOLHEADER pph; /* Points on area header. */
538542

539543
if (!memp)
540544
/*******************************************************************/
@@ -559,8 +563,8 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
559563
if (trace(1))
560564
htrc("PlugSubAlloc: %s\n", g->Message);
561565

562-
throw 1234;
563-
} /* endif size OS32 code */
566+
DoThrow(1234);
567+
} /* endif size OS32 code */
564568

565569
/*********************************************************************/
566570
/* Do the suballocation the simplest way. */
@@ -574,7 +578,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
574578
memp, pph->To_Free, pph->FreeBlk);
575579

576580
return (memp);
577-
} /* end of PlugSubAlloc */
581+
} /* end of PlugSubAlloc */
578582

579583
/***********************************************************************/
580584
/* Program for sub-allocating and copying a string in a storage area. */

storage/connect/reldef.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,15 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
522522

523523
// Get the function returning an instance of the external DEF class
524524
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
525-
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
526-
FreeLibrary((HMODULE)Hdll);
525+
char buf[256];
526+
DWORD rc = GetLastError();
527+
528+
sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname);
529+
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
530+
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
531+
(LPTSTR)buf, sizeof(buf), NULL);
532+
strcat(strcat(g->Message, ": "), buf);
533+
FreeLibrary((HMODULE)Hdll);
527534
return NULL;
528535
} // endif getdef
529536
#else // !__WIN__

storage/connect/tabfmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef class TDBFMT *PTDBFMT;
1313
/***********************************************************************/
1414
/* Functions used externally. */
1515
/***********************************************************************/
16-
PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
16+
DllExport PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
1717

1818
/***********************************************************************/
1919
/* CSV table. */

storage/connect/tabjson.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
299299
memset(G, 0, sizeof(GLOBAL));
300300
G->Sarea_Size = tdp->Lrecl * 10;
301301
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
302-
PlugSubSet(G, G->Sarea, G->Sarea_Size);
302+
PlugSubSet(G->Sarea, G->Sarea_Size);
303303
G->jump_level = 0;
304304
tjnp->SetG(G);
305305

@@ -670,7 +670,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
670670
memset(G, 0, sizeof(GLOBAL));
671671
G->Sarea_Size = Lrecl * 10;
672672
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
673-
PlugSubSet(G, G->Sarea, G->Sarea_Size);
673+
PlugSubSet(G->Sarea, G->Sarea_Size);
674674
G->jump_level = 0;
675675
((TDBJSN*)tdbp)->G = G;
676676
} else {
@@ -963,7 +963,7 @@ int TDBJSN::ReadDB(PGLOBAL g)
963963
return rc;
964964

965965
// Recover the memory used for parsing
966-
PlugSubSet(G, G->Sarea, G->Sarea_Size);
966+
PlugSubSet(G->Sarea, G->Sarea_Size);
967967

968968
if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) {
969969
Row = FindRow(g);
@@ -1079,13 +1079,13 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
10791079
} // end of PrepareWriting
10801080

10811081
/***********************************************************************/
1082-
/* WriteDB: Data Base write routine for DOS access method. */
1082+
/* WriteDB: Data Base write routine for JSON access method. */
10831083
/***********************************************************************/
10841084
int TDBJSN::WriteDB(PGLOBAL g)
10851085
{
10861086
int rc = TDBDOS::WriteDB(g);
10871087

1088-
PlugSubSet(G, G->Sarea, G->Sarea_Size);
1088+
PlugSubSet(G->Sarea, G->Sarea_Size);
10891089
Row->Clear();
10901090
return rc;
10911091
} // end of WriteDB

storage/connect/tabjson.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*************** tabjson H Declares Source Code File (.H) **************/
22
/* Name: tabjson.h Version 1.3 */
33
/* */
4-
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
4+
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2018 */
55
/* */
66
/* This file contains the JSON classes declares. */
77
/***********************************************************************/
8-
#include "osutil.h"
8+
//#include "osutil.h" // Unuseful and bad for OEM
99
#include "block.h"
1010
#include "colblk.h"
1111
#include "json.h"
@@ -16,7 +16,7 @@ typedef class JSONDEF *PJDEF;
1616
typedef class TDBJSON *PJTDB;
1717
typedef class JSONCOL *PJCOL;
1818
class TDBJSN;
19-
PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info);
19+
DllExport PQRYRES JSONColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool);
2020

2121
/***********************************************************************/
2222
/* The JSON tree node. Can be an Object or an Array. */

0 commit comments

Comments
 (0)