@@ -195,9 +195,8 @@ extern "C" {
195
195
/* **********************************************************************/
196
196
PQRYRES OEMColumns (PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
197
197
PQRYRES VirColumns (PGLOBAL g, bool info);
198
- PQRYRES JSONColumns (PGLOBAL g, char *dp, const char *fn, char *objn,
199
- int pretty, int lvl, int mxr, bool info);
200
- PQRYRES XMLColumns (PGLOBAL g, char *dp, char *tab, PTOS topt, bool info);
198
+ PQRYRES JSONColumns (PGLOBAL g, char *db, PTOS topt, bool info);
199
+ PQRYRES XMLColumns (PGLOBAL g, char *db, char *tab, PTOS topt, bool info);
201
200
void PushWarning (PGLOBAL g, THD *thd, int level);
202
201
bool CheckSelf (PGLOBAL g, TABLE_SHARE *s, const char *host,
203
202
const char *db, char *tab, const char *src, int port);
@@ -1017,6 +1016,117 @@ char *GetListOption(PGLOBAL g, const char *opname,
1017
1016
return opval;
1018
1017
} // end of GetListOption
1019
1018
1019
+ /* ***************************************************************************/
1020
+ /* Return the value of a string option or NULL if not specified. */
1021
+ /* ***************************************************************************/
1022
+ char *GetStringTableOption (PGLOBAL g, PTOS options, char *opname, char *sdef)
1023
+ {
1024
+ const char *opval= NULL ;
1025
+
1026
+ if (!options)
1027
+ return sdef;
1028
+ else if (!stricmp (opname, " Type" ))
1029
+ opval= options->type ;
1030
+ else if (!stricmp (opname, " Filename" ))
1031
+ opval= options->filename ;
1032
+ else if (!stricmp (opname, " Optname" ))
1033
+ opval= options->optname ;
1034
+ else if (!stricmp (opname, " Tabname" ))
1035
+ opval= options->tabname ;
1036
+ else if (!stricmp (opname, " Tablist" ))
1037
+ opval= options->tablist ;
1038
+ else if (!stricmp (opname, " Database" ) ||
1039
+ !stricmp (opname, " DBname" ))
1040
+ opval= options->dbname ;
1041
+ else if (!stricmp (opname, " Separator" ))
1042
+ opval= options->separator ;
1043
+ else if (!stricmp (opname, " Qchar" ))
1044
+ opval= options->qchar ;
1045
+ else if (!stricmp (opname, " Module" ))
1046
+ opval= options->module ;
1047
+ else if (!stricmp (opname, " Subtype" ))
1048
+ opval= options->subtype ;
1049
+ else if (!stricmp (opname, " Catfunc" ))
1050
+ opval= options->catfunc ;
1051
+ else if (!stricmp (opname, " Srcdef" ))
1052
+ opval= options->srcdef ;
1053
+ else if (!stricmp (opname, " Colist" ))
1054
+ opval= options->colist ;
1055
+ else if (!stricmp (opname, " Data_charset" ))
1056
+ opval= options->data_charset ;
1057
+
1058
+ if (!opval && options && options->oplist )
1059
+ opval= GetListOption (g, opname, options->oplist );
1060
+
1061
+ return opval ? (char *)opval : sdef;
1062
+ } // end of GetStringTableOption
1063
+
1064
+ /* ***************************************************************************/
1065
+ /* Return the value of a Boolean option or bdef if not specified. */
1066
+ /* ***************************************************************************/
1067
+ bool GetBooleanTableOption (PGLOBAL g, PTOS options, char *opname, bool bdef)
1068
+ {
1069
+ bool opval= bdef;
1070
+ char *pv;
1071
+
1072
+ if (!options)
1073
+ return bdef;
1074
+ else if (!stricmp (opname, " Mapped" ))
1075
+ opval= options->mapped ;
1076
+ else if (!stricmp (opname, " Huge" ))
1077
+ opval= options->huge ;
1078
+ else if (!stricmp (opname, " Split" ))
1079
+ opval= options->split ;
1080
+ else if (!stricmp (opname, " Readonly" ))
1081
+ opval= options->readonly ;
1082
+ else if (!stricmp (opname, " SepIndex" ))
1083
+ opval= options->sepindex ;
1084
+ else if (!stricmp (opname, " Header" ))
1085
+ opval= (options->header != 0 ); // Is Boolean for some table types
1086
+ else if (options->oplist )
1087
+ if ((pv= GetListOption (g, opname, options->oplist )))
1088
+ opval= (!*pv || *pv == ' y' || *pv == ' Y' || atoi (pv) != 0 );
1089
+
1090
+ return opval;
1091
+ } // end of GetBooleanTableOption
1092
+
1093
+ /* ***************************************************************************/
1094
+ /* Return the value of an integer option or NO_IVAL if not specified. */
1095
+ /* ***************************************************************************/
1096
+ int GetIntegerTableOption (PGLOBAL g, PTOS options, char *opname, int idef)
1097
+ {
1098
+ ulonglong opval= NO_IVAL;
1099
+
1100
+ if (!options)
1101
+ return idef;
1102
+ else if (!stricmp (opname, " Lrecl" ))
1103
+ opval= options->lrecl ;
1104
+ else if (!stricmp (opname, " Elements" ))
1105
+ opval= options->elements ;
1106
+ else if (!stricmp (opname, " Multiple" ))
1107
+ opval= options->multiple ;
1108
+ else if (!stricmp (opname, " Header" ))
1109
+ opval= options->header ;
1110
+ else if (!stricmp (opname, " Quoted" ))
1111
+ opval= options->quoted ;
1112
+ else if (!stricmp (opname, " Ending" ))
1113
+ opval= options->ending ;
1114
+ else if (!stricmp (opname, " Compressed" ))
1115
+ opval= (options->compressed );
1116
+
1117
+ if (opval == NO_IVAL) {
1118
+ char *pv;
1119
+
1120
+ if ((pv= GetListOption (g, opname, options->oplist )))
1121
+ opval= CharToNumber (pv, strlen (pv), ULONGLONG_MAX, true );
1122
+ else
1123
+ return idef;
1124
+
1125
+ } // endif opval
1126
+
1127
+ return (int )opval;
1128
+ } // end of GetIntegerTableOption
1129
+
1020
1130
/* ***************************************************************************/
1021
1131
/* Return the table option structure. */
1022
1132
/* ***************************************************************************/
@@ -1035,9 +1145,6 @@ char *ha_connect::GetRealString(const char *s)
1035
1145
char *sv;
1036
1146
1037
1147
if (IsPartitioned () && s) {
1038
- // sv= (char*)PlugSubAlloc(xp->g, NULL, strlen(s) + strlen(partname));
1039
- // With wrong string pattern, the size of the constructed string
1040
- // can be more than strlen(s) + strlen(partname)
1041
1148
sv= (char *)PlugSubAlloc (xp->g , NULL , 0 );
1042
1149
sprintf (sv, s, partname);
1043
1150
PlugSubAlloc (xp->g , NULL , strlen (sv) + 1 );
@@ -1048,7 +1155,7 @@ char *ha_connect::GetRealString(const char *s)
1048
1155
} // end of GetRealString
1049
1156
1050
1157
/* ***************************************************************************/
1051
- /* Return the value of a string option or NULL if not specified. */
1158
+ /* Return the value of a string option or sdef if not specified. */
1052
1159
/* ***************************************************************************/
1053
1160
char *ha_connect::GetStringOption (char *opname, char *sdef)
1054
1161
{
@@ -1066,55 +1173,20 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
1066
1173
opval= thd_query_string (table->in_use )->str ;
1067
1174
else if (!stricmp (opname, " Partname" ))
1068
1175
opval= partname;
1069
- else if (!options)
1070
- ;
1071
- else if (!stricmp (opname, " Type" ))
1072
- opval= (char *)options->type ;
1073
- else if (!stricmp (opname, " Filename" ))
1074
- opval= GetRealString (options->filename );
1075
- else if (!stricmp (opname, " Optname" ))
1076
- opval= (char *)options->optname ;
1077
- else if (!stricmp (opname, " Tabname" ))
1078
- opval= GetRealString (options->tabname );
1079
- else if (!stricmp (opname, " Tablist" ))
1080
- opval= (char *)options->tablist ;
1081
- else if (!stricmp (opname, " Database" ) ||
1082
- !stricmp (opname, " DBname" ))
1083
- opval= (char *)options->dbname ;
1084
- else if (!stricmp (opname, " Separator" ))
1085
- opval= (char *)options->separator ;
1086
- else if (!stricmp (opname, " Qchar" ))
1087
- opval= (char *)options->qchar ;
1088
- else if (!stricmp (opname, " Module" ))
1089
- opval= (char *)options->module ;
1090
- else if (!stricmp (opname, " Subtype" ))
1091
- opval= (char *)options->subtype ;
1092
- else if (!stricmp (opname, " Catfunc" ))
1093
- opval= (char *)options->catfunc ;
1094
- else if (!stricmp (opname, " Srcdef" ))
1095
- opval= (char *)options->srcdef ;
1096
- else if (!stricmp (opname, " Colist" ))
1097
- opval= (char *)options->colist ;
1098
- else if (!stricmp (opname, " Data_charset" ))
1099
- opval= (char *)options->data_charset ;
1100
1176
else if (!stricmp (opname, " Table_charset" )) {
1101
1177
const CHARSET_INFO *chif= (tshp) ? tshp->table_charset
1102
1178
: table->s ->table_charset ;
1103
1179
1104
1180
if (chif)
1105
1181
opval= (char *)chif->csname ;
1106
1182
1107
- } // endif Table_charset
1108
-
1109
- if (!opval && options && options->oplist ) {
1110
- opval= GetListOption (xp->g , opname, options->oplist );
1111
-
1112
- if (opval && (!stricmp (opname, " connect" )
1113
- || !stricmp (opname, " tabname" )
1114
- || !stricmp (opname, " filename" )))
1115
- opval = GetRealString (opval);
1183
+ } else
1184
+ opval= GetStringTableOption (xp->g , options, opname, NULL );
1116
1185
1117
- } // endif opval
1186
+ if (opval && (!stricmp (opname, " connect" )
1187
+ || !stricmp (opname, " tabname" )
1188
+ || !stricmp (opname, " filename" )))
1189
+ opval = GetRealString (opval);
1118
1190
1119
1191
if (!opval) {
1120
1192
if (sdef && !strcmp (sdef, " *" )) {
@@ -1145,31 +1217,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
1145
1217
/* ***************************************************************************/
1146
1218
bool ha_connect::GetBooleanOption (char *opname, bool bdef)
1147
1219
{
1148
- bool opval= bdef;
1149
- char *pv;
1220
+ bool opval;
1150
1221
PTOS options= GetTableOptionStruct ();
1151
1222
1152
1223
if (!stricmp (opname, " View" ))
1153
1224
opval= (tshp) ? tshp->is_view : table_share->is_view ;
1154
- else if (!options)
1155
- ;
1156
- else if (!stricmp (opname, " Mapped" ))
1157
- opval= options->mapped ;
1158
- else if (!stricmp (opname, " Huge" ))
1159
- opval= options->huge ;
1160
- // else if (!stricmp(opname, "Compressed"))
1161
- // opval= options->compressed;
1162
- else if (!stricmp (opname, " Split" ))
1163
- opval= options->split ;
1164
- else if (!stricmp (opname, " Readonly" ))
1165
- opval= options->readonly ;
1166
- else if (!stricmp (opname, " SepIndex" ))
1167
- opval= options->sepindex ;
1168
- else if (!stricmp (opname, " Header" ))
1169
- opval= (options->header != 0 ); // Is Boolean for some table types
1170
- else if (options->oplist )
1171
- if ((pv= GetListOption (xp->g , opname, options->oplist )))
1172
- opval= (!*pv || *pv == ' y' || *pv == ' Y' || atoi (pv) != 0 );
1225
+ else
1226
+ opval= GetBooleanTableOption (xp->g , options, opname, bdef);
1173
1227
1174
1228
return opval;
1175
1229
} // end of GetBooleanOption
@@ -1198,37 +1252,18 @@ bool ha_connect::SetBooleanOption(char *opname, bool b)
1198
1252
/* ***************************************************************************/
1199
1253
int ha_connect::GetIntegerOption (char *opname)
1200
1254
{
1201
- ulonglong opval= NO_IVAL;
1202
- char *pv;
1255
+ int opval;
1203
1256
PTOS options= GetTableOptionStruct ();
1204
1257
TABLE_SHARE *tsp= (tshp) ? tshp : table_share;
1205
1258
1206
1259
if (!stricmp (opname, " Avglen" ))
1207
- opval= (ulonglong )tsp->avg_row_length ;
1260
+ opval= (int )tsp->avg_row_length ;
1208
1261
else if (!stricmp (opname, " Estimate" ))
1209
- opval= (ulonglong)tsp->max_rows ;
1210
- else if (!options)
1211
- ;
1212
- else if (!stricmp (opname, " Lrecl" ))
1213
- opval= options->lrecl ;
1214
- else if (!stricmp (opname, " Elements" ))
1215
- opval= options->elements ;
1216
- else if (!stricmp (opname, " Multiple" ))
1217
- opval= options->multiple ;
1218
- else if (!stricmp (opname, " Header" ))
1219
- opval= options->header ;
1220
- else if (!stricmp (opname, " Quoted" ))
1221
- opval= options->quoted ;
1222
- else if (!stricmp (opname, " Ending" ))
1223
- opval= options->ending ;
1224
- else if (!stricmp (opname, " Compressed" ))
1225
- opval= (options->compressed );
1226
-
1227
- if (opval == (ulonglong)NO_IVAL && options && options->oplist )
1228
- if ((pv= GetListOption (xp->g , opname, options->oplist )))
1229
- opval= CharToNumber (pv, strlen (pv), ULONGLONG_MAX, true );
1262
+ opval= (int )tsp->max_rows ;
1263
+ else
1264
+ opval= GetIntegerTableOption (xp->g , options, opname, NO_IVAL);
1230
1265
1231
- return ( int ) opval;
1266
+ return opval;
1232
1267
} // end of GetIntegerOption
1233
1268
1234
1269
/* ***************************************************************************/
@@ -4965,12 +5000,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
4965
5000
const char *fncn= " ?" ;
4966
5001
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src;
4967
5002
const char *col, *ocl, *rnk, *pic, *fcl, *skc;
4968
- char *tab, *dsn, *shm, *dpath, *objn ;
5003
+ char *tab, *dsn, *shm, *dpath;
4969
5004
#if defined(WIN32)
4970
5005
char *nsp= NULL , *cls= NULL ;
4971
5006
#endif // WIN32
4972
- int port= 0 , hdr= 0 , mxr= 0 , mxe= 0 , rc= 0 , lvl= 0 ;
4973
- int cop __attribute__ ((unused))= 0 , pty= 2 , lrecl= 0 ;
5007
+ int port= 0 , hdr= 0 , mxr= 0 , mxe= 0 , rc= 0 ;
5008
+ int cop __attribute__ ((unused))= 0 , lrecl= 0 ;
4974
5009
#if defined(ODBC_SUPPORT)
4975
5010
POPARM sop = NULL ;
4976
5011
char *ucnc = NULL ;
@@ -5000,7 +5035,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
5000
5035
if (!g)
5001
5036
return HA_ERR_INTERNAL_ERROR;
5002
5037
5003
- user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= objn= NULL ;
5038
+ user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= NULL ;
5004
5039
5005
5040
// Get the useful create options
5006
5041
ttp= GetTypeID (topt->type );
@@ -5031,7 +5066,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
5031
5066
skc= GetListOption (g, " skipcol" , topt->oplist , NULL );
5032
5067
rnk= GetListOption (g, " rankcol" , topt->oplist , NULL );
5033
5068
pwd= GetListOption (g, " password" , topt->oplist );
5034
- objn= GetListOption (g, " Object" , topt->oplist , NULL );
5035
5069
#if defined(WIN32)
5036
5070
nsp= GetListOption (g, " namespace" , topt->oplist );
5037
5071
cls= GetListOption (g, " class" , topt->oplist );
@@ -5049,8 +5083,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
5049
5083
#if defined(PROMPT_OK)
5050
5084
cop= atoi (GetListOption (g, " checkdsn" , topt->oplist , " 0" ));
5051
5085
#endif // PROMPT_OK
5052
- pty= atoi (GetListOption (g," Pretty" , topt->oplist , " 2" ));
5053
- lvl= atoi (GetListOption (g," Level" , topt->oplist , " 0" ));
5054
5086
} else {
5055
5087
host= " localhost" ;
5056
5088
user= (ttp == TAB_ODBC ? NULL : " root" );
@@ -5342,7 +5374,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
5342
5374
qrp= VirColumns (g, fnc == FNC_COL);
5343
5375
break ;
5344
5376
case TAB_JSON:
5345
- qrp= JSONColumns (g, (char *)db, fn, objn, pty, lrecl, lvl , fnc == FNC_COL);
5377
+ qrp= JSONColumns (g, (char *)db, topt , fnc == FNC_COL);
5346
5378
break ;
5347
5379
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
5348
5380
case TAB_XML:
@@ -6608,7 +6640,7 @@ maria_declare_plugin(connect)
6608
6640
0x0103 , /* version number (1.03) */
6609
6641
NULL , /* status variables */
6610
6642
connect_system_variables, /* system variables */
6611
- " 1.03.0006 " , /* string version */
6643
+ " 1.03.0007 " , /* string version */
6612
6644
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
6613
6645
}
6614
6646
maria_declare_plugin_end;
0 commit comments