@@ -9172,7 +9172,6 @@ longlong Item_func_can_access_database::val_int()
9172
9172
DBUG_ENTER (" Item_func_can_access_database::val_int" );
9173
9173
bool have_access= true ;
9174
9174
9175
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
9176
9175
// Read schema_name
9177
9176
String schema_name;
9178
9177
String *schema_name_ptr;
@@ -9181,15 +9180,16 @@ longlong Item_func_can_access_database::val_int()
9181
9180
// Make sure we have safe string to access.
9182
9181
schema_name_ptr->c_ptr_safe ();
9183
9182
9184
- // Skip INFORMATION_SCHEMA database
9185
- if (is_infoschema_db (schema_name_ptr->ptr ()))
9186
- DBUG_RETURN (true );
9187
-
9188
9183
// Check if schema is hidden.
9189
9184
THD *thd= current_thd;
9190
9185
if (is_hidden_by_ndb (thd, schema_name_ptr, nullptr ))
9191
9186
DBUG_RETURN (false );
9192
9187
9188
+ #ifndef NO_EMBEDDED_ACCESS_CHECKS
9189
+ // Skip INFORMATION_SCHEMA database
9190
+ if (is_infoschema_db (schema_name_ptr->ptr ()))
9191
+ DBUG_RETURN (true );
9192
+
9193
9193
// Check access
9194
9194
Security_context *sctx= thd->security_context ();
9195
9195
if (!(sctx->master_access () & (DB_ACLS | SHOW_DB_ACL) ||
@@ -9200,8 +9200,8 @@ longlong Item_func_can_access_database::val_int()
9200
9200
{
9201
9201
have_access= false ;
9202
9202
}
9203
- }
9204
9203
#endif
9204
+ }
9205
9205
9206
9206
DBUG_RETURN (have_access);
9207
9207
}
@@ -9224,7 +9224,6 @@ longlong Item_func_can_access_table::val_int()
9224
9224
DBUG_ENTER (" Item_func_can_access_table::val_int" );
9225
9225
bool have_access= true ;
9226
9226
9227
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
9228
9227
// Read schema_name, table_name
9229
9228
String schema_name;
9230
9229
String *schema_name_ptr;
@@ -9237,15 +9236,16 @@ longlong Item_func_can_access_table::val_int()
9237
9236
schema_name_ptr->c_ptr_safe ();
9238
9237
table_name_ptr->c_ptr_safe ();
9239
9238
9240
- // Skip INFORMATION_SCHEMA database
9241
- if (is_infoschema_db (schema_name_ptr->ptr ()))
9242
- DBUG_RETURN (true );
9243
-
9244
9239
// Check if table is hidden.
9245
9240
THD *thd= current_thd;
9246
9241
if (is_hidden_by_ndb (thd, schema_name_ptr, table_name_ptr))
9247
9242
DBUG_RETURN (false );
9248
9243
9244
+ #ifndef NO_EMBEDDED_ACCESS_CHECKS
9245
+ // Skip INFORMATION_SCHEMA database
9246
+ if (is_infoschema_db (schema_name_ptr->ptr ()))
9247
+ DBUG_RETURN (true );
9248
+
9249
9249
// Check access
9250
9250
ulong db_access= 0 ;
9251
9251
check_access (thd, SELECT_ACL, schema_name_ptr->ptr (),
@@ -9267,8 +9267,8 @@ longlong Item_func_can_access_table::val_int()
9267
9267
have_access= false ;
9268
9268
}
9269
9269
}
9270
- }
9271
9270
#endif
9271
+ }
9272
9272
9273
9273
DBUG_RETURN (have_access);
9274
9274
}
@@ -9293,32 +9293,36 @@ longlong Item_func_can_access_column::val_int()
9293
9293
DBUG_ENTER (" Item_func_can_access_column::val_int" );
9294
9294
bool have_access= true ;
9295
9295
9296
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
9297
9296
// Read schema_name, table_name
9298
9297
String schema_name;
9299
9298
String *schema_name_ptr;
9300
9299
String table_name;
9301
9300
String *table_name_ptr;
9302
- String column_name;
9303
- String *column_name_ptr;
9304
9301
if ((schema_name_ptr=args[0 ]->val_str (&schema_name)) != nullptr &&
9305
- (table_name_ptr=args[1 ]->val_str (&table_name)) != nullptr &&
9306
- (column_name_ptr=args[2 ]->val_str (&column_name)) != nullptr )
9302
+ (table_name_ptr=args[1 ]->val_str (&table_name)) != nullptr )
9307
9303
{
9308
9304
// Make sure we have safe string to access.
9309
9305
schema_name_ptr->c_ptr_safe ();
9310
9306
table_name_ptr->c_ptr_safe ();
9311
- column_name_ptr->c_ptr_safe ();
9312
-
9313
- // Skip INFORMATION_SCHEMA database
9314
- if (is_infoschema_db (schema_name_ptr->ptr ()))
9315
- DBUG_RETURN (true );
9316
9307
9317
9308
// Check if table is hidden.
9318
9309
THD *thd= current_thd;
9319
9310
if (is_hidden_by_ndb (thd, schema_name_ptr, table_name_ptr))
9320
9311
DBUG_RETURN (false );
9321
9312
9313
+ #ifndef NO_EMBEDDED_ACCESS_CHECKS
9314
+ // Read column_name.
9315
+ String column_name;
9316
+ String *column_name_ptr;
9317
+ if ((column_name_ptr=args[2 ]->val_str (&column_name)) == nullptr )
9318
+ DBUG_RETURN (true );
9319
+ // Make sure we have safe string to access.
9320
+ column_name_ptr->c_ptr_safe ();
9321
+
9322
+ // Skip INFORMATION_SCHEMA database
9323
+ if (is_infoschema_db (schema_name_ptr->ptr ()))
9324
+ DBUG_RETURN (true );
9325
+
9322
9326
// Check access
9323
9327
GRANT_INFO grant_info;
9324
9328
memset (&grant_info, 0 , sizeof (grant_info));
@@ -9334,8 +9338,8 @@ longlong Item_func_can_access_column::val_int()
9334
9338
{
9335
9339
have_access= false ;
9336
9340
}
9337
- }
9338
9341
#endif
9342
+ }
9339
9343
9340
9344
DBUG_RETURN (have_access);
9341
9345
}
0 commit comments