@@ -4054,7 +4054,7 @@ int ha_connect::delete_all_rows()
4054
4054
} // end of delete_all_rows
4055
4055
4056
4056
4057
- bool ha_connect::check_privileges (THD *thd, PTOS options, char *dbn)
4057
+ bool ha_connect::check_privileges (THD *thd, PTOS options, char *dbn, bool quick )
4058
4058
{
4059
4059
const char *db= (dbn && *dbn) ? dbn : NULL ;
4060
4060
TABTYPE type=GetRealType (options);
@@ -4081,6 +4081,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn)
4081
4081
case TAB_VEC:
4082
4082
case TAB_JSON:
4083
4083
if (options->filename && *options->filename ) {
4084
+ if (!quick) {
4084
4085
char *s, path[FN_REFLEN], dbpath[FN_REFLEN];
4085
4086
#if defined(__WIN__)
4086
4087
s= " \\ " ;
@@ -4099,7 +4100,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn)
4099
4100
my_error (ER_OPTION_PREVENTS_STATEMENT, MYF (0 ), " --secure-file-priv" );
4100
4101
return true ;
4101
4102
} // endif path
4102
-
4103
+ }
4103
4104
} else
4104
4105
return false ;
4105
4106
@@ -4121,10 +4122,13 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn)
4121
4122
Otherwise it's a DML, the table was normally opened, locked,
4122
4123
privilege were already checked, and table->grant.privilege is set.
4123
4124
With SQL SECURITY DEFINER, table->grant.privilege has definer's privileges.
4125
+
4126
+ Unless we're in prelocking mode, in this case table->grant.privilege
4127
+ is only checked in start_stmt(), not in external_lock().
4124
4128
*/
4125
4129
if (!table || !table->mdl_ticket || table->mdl_ticket ->get_type () == MDL_EXCLUSIVE)
4126
4130
return check_access (thd, FILE_ACL, db, NULL , NULL , 0 , 0 );
4127
- if (table->grant .privilege & FILE_ACL)
4131
+ if ((!quick && thd-> lex -> requires_prelocking ()) || table->grant .privilege & FILE_ACL)
4128
4132
return false ;
4129
4133
status_var_increment (thd->status_var .access_denied_errors );
4130
4134
my_error (access_denied_error_code (thd->password ), MYF (0 ),
@@ -4308,6 +4312,9 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
4308
4312
PGLOBAL g= GetPlug (thd, xp);
4309
4313
DBUG_ENTER (" ha_connect::start_stmt" );
4310
4314
4315
+ if (check_privileges (thd, GetTableOptionStruct (), table->s ->db .str , true ))
4316
+ DBUG_RETURN (HA_ERR_INTERNAL_ERROR);
4317
+
4311
4318
// Action will depend on lock_type
4312
4319
switch (lock_type) {
4313
4320
case TL_WRITE_ALLOW_WRITE:
0 commit comments