@@ -1204,16 +1204,16 @@ class User_table_json: public User_table
1204
1204
1205
1205
int get_auth (THD *thd, MEM_ROOT *root, const char **plugin, const char **authstr) const
1206
1206
{
1207
- *plugin= get_str_value (root, STRING_WITH_LEN ( " plugin" ) );
1207
+ *plugin= get_str_value (root, " plugin" );
1208
1208
if (!**plugin)
1209
1209
*plugin= native_password_plugin_name.str ;
1210
- *authstr= get_str_value (root, STRING_WITH_LEN ( " authentication_string" ) );
1210
+ *authstr= get_str_value (root, " authentication_string" );
1211
1211
return *plugin == NULL || *authstr == NULL ;
1212
1212
}
1213
1213
void set_auth (const char *p, size_t pl, const char *as, size_t asl) const
1214
1214
{
1215
- set_str_value (STRING_WITH_LEN ( " plugin" ) , p, pl);
1216
- set_str_value (STRING_WITH_LEN ( " authentication_string" ) , as, asl);
1215
+ set_str_value (" plugin" , p, pl);
1216
+ set_str_value (" authentication_string" , as, asl);
1217
1217
}
1218
1218
ulong get_access () const
1219
1219
{
@@ -1222,7 +1222,7 @@ class User_table_json: public User_table
1222
1222
(or, for example, my_count_bits(GLOBAL_ACLS))
1223
1223
in the json too, and it'll allow us to do privilege upgrades
1224
1224
*/
1225
- return get_int_value (STRING_WITH_LEN ( " access" ) ) & GLOBAL_ACLS;
1225
+ return get_int_value (" access" ) & GLOBAL_ACLS;
1226
1226
}
1227
1227
void set_access (ulong rights, bool revoke) const
1228
1228
{
@@ -1231,53 +1231,53 @@ class User_table_json: public User_table
1231
1231
access&= ~rights;
1232
1232
else
1233
1233
access|= rights;
1234
- set_int_value (STRING_WITH_LEN ( " access" ) , access & GLOBAL_ACLS);
1234
+ set_int_value (" access" , access & GLOBAL_ACLS);
1235
1235
}
1236
1236
1237
1237
SSL_type get_ssl_type () const
1238
- { return (SSL_type)get_int_value (STRING_WITH_LEN ( " ssl_type" ) ); }
1238
+ { return (SSL_type)get_int_value (" ssl_type" ); }
1239
1239
int set_ssl_type (SSL_type x) const
1240
- { return set_int_value (STRING_WITH_LEN ( " ssl_type" ) , x); }
1240
+ { return set_int_value (" ssl_type" , x); }
1241
1241
const char * get_ssl_cipher (MEM_ROOT *root) const
1242
- { return get_str_value (root, STRING_WITH_LEN ( " ssl_cipher" ) ); }
1242
+ { return get_str_value (root, " ssl_cipher" ); }
1243
1243
int set_ssl_cipher (const char *s, size_t l) const
1244
- { return set_str_value (STRING_WITH_LEN ( " ssl_cipher" ) , s, l); }
1244
+ { return set_str_value (" ssl_cipher" , s, l); }
1245
1245
const char * get_x509_issuer (MEM_ROOT *root) const
1246
- { return get_str_value (root, STRING_WITH_LEN ( " x509_issuer" ) ); }
1246
+ { return get_str_value (root, " x509_issuer" ); }
1247
1247
int set_x509_issuer (const char *s, size_t l) const
1248
- { return set_str_value (STRING_WITH_LEN ( " x509_issuer" ) , s, l); }
1248
+ { return set_str_value (" x509_issuer" , s, l); }
1249
1249
const char * get_x509_subject (MEM_ROOT *root) const
1250
- { return get_str_value (root, STRING_WITH_LEN ( " x509_subject" ) ); }
1250
+ { return get_str_value (root, " x509_subject" ); }
1251
1251
int set_x509_subject (const char *s, size_t l) const
1252
- { return set_str_value (STRING_WITH_LEN ( " x509_subject" ) , s, l); }
1252
+ { return set_str_value (" x509_subject" , s, l); }
1253
1253
longlong get_max_questions () const
1254
- { return get_int_value (STRING_WITH_LEN ( " max_questions" ) ); }
1254
+ { return get_int_value (" max_questions" ); }
1255
1255
int set_max_questions (longlong x) const
1256
- { return set_int_value (STRING_WITH_LEN ( " max_questions" ) , x); }
1256
+ { return set_int_value (" max_questions" , x); }
1257
1257
longlong get_max_updates () const
1258
- { return get_int_value (STRING_WITH_LEN ( " max_updates" ) ); }
1258
+ { return get_int_value (" max_updates" ); }
1259
1259
int set_max_updates (longlong x) const
1260
- { return set_int_value (STRING_WITH_LEN ( " max_updates" ) , x); }
1260
+ { return set_int_value (" max_updates" , x); }
1261
1261
longlong get_max_connections () const
1262
- { return get_int_value (STRING_WITH_LEN ( " max_connections" ) ); }
1262
+ { return get_int_value (" max_connections" ); }
1263
1263
int set_max_connections (longlong x) const
1264
- { return set_int_value (STRING_WITH_LEN ( " max_connections" ) , x); }
1264
+ { return set_int_value (" max_connections" , x); }
1265
1265
longlong get_max_user_connections () const
1266
- { return get_int_value (STRING_WITH_LEN ( " max_user_connections" ) ); }
1266
+ { return get_int_value (" max_user_connections" ); }
1267
1267
int set_max_user_connections (longlong x) const
1268
- { return set_int_value (STRING_WITH_LEN ( " max_user_connections" ) , x); }
1268
+ { return set_int_value (" max_user_connections" , x); }
1269
1269
double get_max_statement_time () const
1270
- { return get_double_value (STRING_WITH_LEN ( " max_statement_time" ) ); }
1270
+ { return get_double_value (" max_statement_time" ); }
1271
1271
int set_max_statement_time (double x) const
1272
- { return set_double_value (STRING_WITH_LEN ( " max_statement_time" ) , x); }
1272
+ { return set_double_value (" max_statement_time" , x); }
1273
1273
bool get_is_role () const
1274
- { return get_bool_value (STRING_WITH_LEN ( " is_role" ) ); }
1274
+ { return get_bool_value (" is_role" ); }
1275
1275
int set_is_role (bool x) const
1276
- { return set_bool_value (STRING_WITH_LEN ( " is_role" ) , x); }
1276
+ { return set_bool_value (" is_role" , x); }
1277
1277
const char * get_default_role (MEM_ROOT *root) const
1278
- { return get_str_value (root, STRING_WITH_LEN ( " default_role" ) ); }
1278
+ { return get_str_value (root, " default_role" ); }
1279
1279
int set_default_role (const char *s, size_t l) const
1280
- { return set_str_value (STRING_WITH_LEN ( " default_role" ) , s, l); }
1280
+ { return set_str_value (" default_role" , s, l); }
1281
1281
1282
1282
~User_table_json () {}
1283
1283
private:
@@ -1290,24 +1290,24 @@ class User_table_json: public User_table
1290
1290
USERNAME_CHAR_LENGTH);
1291
1291
return 0 ;
1292
1292
}
1293
- bool get_value (const char *key, size_t klen,
1293
+ bool get_value (const char *key,
1294
1294
enum json_types vt, const char **v, size_t *vl) const
1295
1295
{
1296
1296
enum json_types value_type;
1297
1297
int int_vl;
1298
1298
String str, *res= m_table->field [2 ]->val_str (&str);
1299
1299
if (!res ||
1300
- (value_type= json_get_object_key (res->ptr (), res->end (),
1301
- key, key+klen, v, &int_vl)) == JSV_BAD_JSON)
1300
+ (value_type= json_get_object_key (res->ptr (), res->end (), key,
1301
+ v, &int_vl)) == JSV_BAD_JSON)
1302
1302
return 1 ; // invalid
1303
1303
*vl= int_vl;
1304
1304
return value_type != vt;
1305
1305
}
1306
- const char *get_str_value (MEM_ROOT *root, const char *key, size_t klen ) const
1306
+ const char *get_str_value (MEM_ROOT *root, const char *key) const
1307
1307
{
1308
1308
size_t value_len;
1309
1309
const char *value_start;
1310
- if (get_value (key, klen, JSV_STRING, &value_start, &value_len))
1310
+ if (get_value (key, JSV_STRING, &value_start, &value_len))
1311
1311
return " " ;
1312
1312
char *ptr= (char *)alloca (value_len);
1313
1313
int len= json_unescape (m_table->field [2 ]->charset (),
@@ -1319,35 +1319,35 @@ class User_table_json: public User_table
1319
1319
return NULL ;
1320
1320
return strmake_root (root, ptr, len);
1321
1321
}
1322
- longlong get_int_value (const char *key, size_t klen ) const
1322
+ longlong get_int_value (const char *key) const
1323
1323
{
1324
1324
int err;
1325
1325
size_t value_len;
1326
1326
const char *value_start;
1327
- if (get_value (key, klen, JSV_NUMBER, &value_start, &value_len))
1327
+ if (get_value (key, JSV_NUMBER, &value_start, &value_len))
1328
1328
return 0 ;
1329
1329
const char *value_end= value_start + value_len;
1330
1330
return my_strtoll10 (value_start, (char **)&value_end, &err);
1331
1331
}
1332
- double get_double_value (const char *key, size_t klen ) const
1332
+ double get_double_value (const char *key) const
1333
1333
{
1334
1334
int err;
1335
1335
size_t value_len;
1336
1336
const char *value_start;
1337
- if (get_value (key, klen, JSV_NUMBER, &value_start, &value_len))
1337
+ if (get_value (key, JSV_NUMBER, &value_start, &value_len))
1338
1338
return 0 ;
1339
1339
const char *value_end= value_start + value_len;
1340
1340
return my_strtod (value_start, (char **)&value_end, &err);
1341
1341
}
1342
- bool get_bool_value (const char *key, size_t klen ) const
1342
+ bool get_bool_value (const char *key) const
1343
1343
{
1344
1344
size_t value_len;
1345
1345
const char *value_start;
1346
- if (get_value (key, klen, JSV_TRUE, &value_start, &value_len))
1346
+ if (get_value (key, JSV_TRUE, &value_start, &value_len))
1347
1347
return false ;
1348
1348
return true ;
1349
1349
}
1350
- bool set_value (const char *key, size_t klen,
1350
+ bool set_value (const char *key,
1351
1351
const char *val, size_t vlen, bool string) const
1352
1352
{
1353
1353
int value_len;
@@ -1356,7 +1356,7 @@ class User_table_json: public User_table
1356
1356
String str, *res= m_table->field [2 ]->val_str (&str);
1357
1357
if (!res || !res->length ())
1358
1358
(res= &str)->set (STRING_WITH_LEN (" {}" ), m_table->field [2 ]->charset ());
1359
- value_type= json_get_object_key (res->ptr (), res->end (), key, key+klen,
1359
+ value_type= json_get_object_key (res->ptr (), res->end (), key,
1360
1360
&value_start, &value_len);
1361
1361
if (value_type == JSV_BAD_JSON)
1362
1362
return 1 ; // invalid
@@ -1367,7 +1367,7 @@ class User_table_json: public User_table
1367
1367
if (value_len)
1368
1368
json.append (' ,' );
1369
1369
json.append (' "' );
1370
- json.append (key, klen );
1370
+ json.append (STRING_WITH_LEN ( key) );
1371
1371
json.append (STRING_WITH_LEN (" \" :" ));
1372
1372
if (string)
1373
1373
json.append (' "' );
@@ -1382,7 +1382,7 @@ class User_table_json: public User_table
1382
1382
m_table->field [2 ]->store (json.ptr (), json.length (), json.charset ());
1383
1383
return 0 ;
1384
1384
}
1385
- bool set_str_value (const char *key, size_t klen, const char *val, size_t vlen) const
1385
+ bool set_str_value (const char *key, const char *val, size_t vlen) const
1386
1386
{
1387
1387
char buf[JSON_SIZE];
1388
1388
int blen= json_escape (system_charset_info,
@@ -1391,22 +1391,22 @@ class User_table_json: public User_table
1391
1391
(uchar*)buf, (uchar*)buf+sizeof (buf));
1392
1392
if (blen < 0 )
1393
1393
return 1 ;
1394
- return set_value (key, klen, buf, blen, true );
1394
+ return set_value (key, buf, blen, true );
1395
1395
}
1396
- bool set_int_value (const char *key, size_t klen, longlong val) const
1396
+ bool set_int_value (const char *key, longlong val) const
1397
1397
{
1398
1398
char v[MY_INT64_NUM_DECIMAL_DIGITS+1 ];
1399
1399
size_t vlen= longlong10_to_str (val, v, -10 ) - v;
1400
- return set_value (key, klen, v, vlen, false );
1400
+ return set_value (key, v, vlen, false );
1401
1401
}
1402
- bool set_double_value (const char *key, size_t klen, double val) const
1402
+ bool set_double_value (const char *key, double val) const
1403
1403
{
1404
1404
char v[FLOATING_POINT_BUFFER+1 ];
1405
1405
size_t vlen= my_fcvt (val, TIME_SECOND_PART_DIGITS, v, NULL );
1406
- return set_value (key, klen, v, vlen, false );
1406
+ return set_value (key, v, vlen, false );
1407
1407
}
1408
- bool set_bool_value (const char *key, size_t klen, bool val) const
1409
- { return set_value (key, klen, val ? " true" : " false" , val ? 4 : 5 , false ); }
1408
+ bool set_bool_value (const char *key, bool val) const
1409
+ { return set_value (key, val ? " true" : " false" , val ? 4 : 5 , false ); }
1410
1410
};
1411
1411
1412
1412
class Db_table : public Grant_table_base
0 commit comments