171
171
#define JSONMAX 10 // JSON Default max grp size
172
172
173
173
extern " C" {
174
- char version[]= " Version 1.03.0006 February 06 , 2015" ;
174
+ char version[]= " Version 1.03.0006 March 16 , 2015" ;
175
175
176
176
#if defined(WIN32)
177
177
char compver[]= " Version 1.03.0006 " __DATE__ " " __TIME__;
@@ -211,6 +211,8 @@ extern "C" {
211
211
/* **********************************************************************/
212
212
PQRYRES OEMColumns (PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
213
213
PQRYRES VirColumns (PGLOBAL g, char *tab, char *db, bool info);
214
+ PQRYRES JSONColumns (PGLOBAL g, char *dp, const char *fn, char *objn,
215
+ int pretty, int lvl, int mxr, bool info);
214
216
void PushWarning (PGLOBAL g, THD *thd, int level);
215
217
bool CheckSelf (PGLOBAL g, TABLE_SHARE *s, const char *host,
216
218
const char *db, char *tab, const char *src, int port);
@@ -1020,8 +1022,7 @@ char *GetListOption(PGLOBAL g, const char *opname,
1020
1022
} // endif pv
1021
1023
1022
1024
if (!stricmp (opname, key)) {
1023
- opval= (char *)PlugSubAlloc (g, NULL , strlen (val) + 1 );
1024
- strcpy (opval, val);
1025
+ opval= PlugDup (g, val);
1025
1026
break ;
1026
1027
} else if (!pn)
1027
1028
break ;
@@ -1506,8 +1507,7 @@ PIXDEF ha_connect::GetIndexInfo(TABLE_SHARE *s)
1506
1507
1507
1508
// Now get index information
1508
1509
pn= (char *)s->keynames .type_names [n];
1509
- name= (char *)PlugSubAlloc (g, NULL , strlen (pn) + 1 );
1510
- strcpy (name, pn); // This is probably unuseful
1510
+ name= PlugDup (g, pn);
1511
1511
unique= (kp.flags & 1 ) != 0 ;
1512
1512
pkp= NULL ;
1513
1513
@@ -1517,8 +1517,7 @@ PIXDEF ha_connect::GetIndexInfo(TABLE_SHARE *s)
1517
1517
// Get the the key parts info
1518
1518
for (int k= 0 ; (unsigned )k < kp.user_defined_key_parts ; k++) {
1519
1519
pn= (char *)kp.key_part [k].field ->field_name ;
1520
- name= (char *)PlugSubAlloc (g, NULL , strlen (pn) + 1 );
1521
- strcpy (name, pn); // This is probably unuseful
1520
+ name= PlugDup (g, pn);
1522
1521
1523
1522
// Allocate the key part description block
1524
1523
kpp= new (g) KPARTDEF (name, k + 1 );
@@ -4738,9 +4737,9 @@ static char *encode(PGLOBAL g, const char *cnm)
4738
4737
@return
4739
4738
Return 0 if ok
4740
4739
*/
4741
- static bool add_field (String *sql, const char *field_name, int typ,
4742
- int len, int dec, char *key, uint tm, const char *rem,
4743
- char *dft , char *xtra , int flag, bool dbf, char v)
4740
+ static bool add_field (String *sql, const char *field_name, int typ, int len,
4741
+ int dec, char *key, uint tm, const char *rem, char *dft ,
4742
+ char *xtra , char *fmt , int flag, bool dbf, char v)
4744
4743
{
4745
4744
char var = (len > 255 ) ? ' V' : v;
4746
4745
bool q, error= false ;
@@ -4809,6 +4808,12 @@ static bool add_field(String *sql, const char *field_name, int typ,
4809
4808
error|= sql->append (" '" );
4810
4809
} // endif rem
4811
4810
4811
+ if (fmt && *fmt) {
4812
+ error|= sql->append (" FIELD_FORMAT='" );
4813
+ error|= sql->append_for_single_quote (fmt, strlen (fmt));
4814
+ error|= sql->append (" '" );
4815
+ } // endif flag
4816
+
4812
4817
if (flag) {
4813
4818
error|= sql->append (" FLAG=" );
4814
4819
error|= sql->append_ulonglong (flag);
@@ -4952,12 +4957,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
4952
4957
const char *fncn= " ?" ;
4953
4958
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src;
4954
4959
const char *col, *ocl, *rnk, *pic, *fcl, *skc;
4955
- char *tab, *dsn, *shm, *dpath;
4960
+ char *tab, *dsn, *shm, *dpath, *objn ;
4956
4961
#if defined(WIN32)
4957
4962
char *nsp= NULL , *cls= NULL ;
4958
4963
#endif // WIN32
4959
4964
int port= 0 , hdr= 0 , mxr __attribute__ ((unused))= 0 , mxe= 0 , rc= 0 ;
4960
- int cop __attribute__ ((unused)) = 0 ;
4965
+ int cop __attribute__ ((unused))= 0 , pty= 2 , lrecl= 0 , lvl = 0 ;
4961
4966
#if defined(ODBC_SUPPORT)
4962
4967
POPARM sop = NULL ;
4963
4968
char *ucnc = NULL ;
@@ -4987,7 +4992,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
4987
4992
if (!g)
4988
4993
return HA_ERR_INTERNAL_ERROR;
4989
4994
4990
- user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= NULL ;
4995
+ user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= objn= NULL ;
4991
4996
4992
4997
// Get the useful create options
4993
4998
ttp= GetTypeID (topt->type );
@@ -5003,6 +5008,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5003
5008
hdr= (int )topt->header ;
5004
5009
tbl= topt->tablist ;
5005
5010
col= topt->colist ;
5011
+ lrecl= (int )topt->lrecl ;
5006
5012
5007
5013
if (topt->oplist ) {
5008
5014
host= GetListOption (g, " host" , topt->oplist , " localhost" );
@@ -5017,6 +5023,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5017
5023
skc= GetListOption (g, " skipcol" , topt->oplist , NULL );
5018
5024
rnk= GetListOption (g, " rankcol" , topt->oplist , NULL );
5019
5025
pwd= GetListOption (g, " password" , topt->oplist );
5026
+ objn= GetListOption (g, " Object" , topt->oplist , NULL );
5020
5027
#if defined(WIN32)
5021
5028
nsp= GetListOption (g, " namespace" , topt->oplist );
5022
5029
cls= GetListOption (g, " class" , topt->oplist );
@@ -5034,6 +5041,8 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5034
5041
#if defined(PROMPT_OK)
5035
5042
cop= atoi (GetListOption (g, " checkdsn" , topt->oplist , " 0" ));
5036
5043
#endif // PROMPT_OK
5044
+ pty= atoi (GetListOption (g," Pretty" , topt->oplist , " 2" ));
5045
+ lvl= atoi (GetListOption (g," Level" , topt->oplist , " 0" ));
5037
5046
} else {
5038
5047
host= " localhost" ;
5039
5048
user= (ttp == TAB_ODBC ? NULL : " root" );
@@ -5077,8 +5086,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5077
5086
goto err;
5078
5087
} // endif tbl
5079
5088
5080
- tab= (char *)PlugSubAlloc (g, NULL , strlen (tbl) + 1 );
5081
- strcpy (tab, tbl);
5089
+ tab= PlugDup (g, tbl);
5082
5090
5083
5091
if ((p= strchr (tab, ' ,' )))
5084
5092
*p= 0 ;
@@ -5204,6 +5212,13 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5204
5212
else
5205
5213
strcpy (g->Message , " Missing OEM module or subtype" );
5206
5214
5215
+ break ;
5216
+ case TAB_JSON:
5217
+ if (!fn)
5218
+ sprintf (g->Message , " Missing %s file name" , topt->type );
5219
+ else
5220
+ ok= true ;
5221
+
5207
5222
break ;
5208
5223
case TAB_VIR:
5209
5224
ok= true ;
@@ -5226,7 +5241,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5226
5241
} // endif src
5227
5242
5228
5243
if (ok) {
5229
- char *cnm, *rem, *dft, *xtra, *key;
5244
+ char *cnm, *rem, *dft, *xtra, *key, *fmt ;
5230
5245
int i, len, prec, dec, typ, flg;
5231
5246
5232
5247
// if (cat)
@@ -5315,6 +5330,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5315
5330
case TAB_VIR:
5316
5331
qrp= VirColumns (g, tab, (char *)db, fnc == FNC_COL);
5317
5332
break ;
5333
+ case TAB_JSON:
5334
+ qrp= JSONColumns (g, (char *)db, fn, objn, pty, lrecl, lvl, fnc == FNC_COL);
5335
+ break ;
5318
5336
case TAB_OEM:
5319
5337
qrp= OEMColumns (g, topt, tab, (char *)db, fnc == FNC_COL);
5320
5338
break ;
@@ -5331,7 +5349,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5331
5349
if (fnc != FNC_NO || src || ttp == TAB_PIVOT) {
5332
5350
// Catalog like table
5333
5351
for (crp= qrp->Colresp ; !rc && crp; crp= crp->Next ) {
5334
- cnm= encode (g, crp->Name );
5352
+ cnm= (ttp == TAB_PIVOT) ? crp-> Name : encode (g, crp->Name );
5335
5353
typ= crp->Type ;
5336
5354
len= crp->Length ;
5337
5355
dec= crp->Prec ;
@@ -5347,7 +5365,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5347
5365
NOT_NULL_FLAG, " " , flg, dbf, v);
5348
5366
#else // !NEW_WAY
5349
5367
if (add_field (&sql, cnm, typ, len, dec, NULL , NOT_NULL_FLAG,
5350
- NULL , NULL , NULL , flg, dbf, v))
5368
+ NULL , NULL , NULL , NULL , flg, dbf, v))
5351
5369
rc= HA_ERR_OUT_OF_MEM;
5352
5370
#endif // !NEW_WAY
5353
5371
} // endfor crp
@@ -5368,7 +5386,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5368
5386
typ= len= prec= dec= 0 ;
5369
5387
tm= NOT_NULL_FLAG;
5370
5388
cnm= (char *)" noname" ;
5371
- dft= xtra= key= NULL ;
5389
+ dft= xtra= key= fmt= NULL ;
5372
5390
v= ' ' ;
5373
5391
#if defined(NEW_WAY)
5374
5392
rem= " " ;
@@ -5407,6 +5425,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5407
5425
if (crp->Kdata ->GetIntValue (i))
5408
5426
tm= 0 ; // Nullable
5409
5427
5428
+ break ;
5429
+ case FLD_FORMAT:
5430
+ fmt= (crp->Kdata ) ? crp->Kdata ->GetCharValue (i) : NULL ;
5410
5431
break ;
5411
5432
case FLD_REM:
5412
5433
rem= crp->Kdata ->GetCharValue (i);
@@ -5485,7 +5506,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
5485
5506
tm, rem, 0 , dbf, v);
5486
5507
#else // !NEW_WAY
5487
5508
if (add_field (&sql, cnm, typ, prec, dec, key, tm, rem, dft, xtra,
5488
- 0 , dbf, v))
5509
+ fmt, 0 , dbf, v))
5489
5510
rc= HA_ERR_OUT_OF_MEM;
5490
5511
#endif // !NEW_WAY
5491
5512
} // endfor i
@@ -6545,7 +6566,7 @@ maria_declare_plugin(connect)
6545
6566
0x0103 , /* version number (1.03) */
6546
6567
NULL , /* status variables */
6547
6568
connect_system_variables, /* system variables */
6548
- " 1.03.0005 " , /* string version */
6569
+ " 1.03.0006 " , /* string version */
6549
6570
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
6550
6571
}
6551
6572
maria_declare_plugin_end;
0 commit comments