List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:September 12 2011 10:43am
Subject:Re: check_access() returns FALSE for internal access granted
View as plain text  
Hi, Salil Arun!

On Sep 10, Bhagurkar, Salil Arun wrote:
> if ((db != NULL) && (db != any_db))
>   {
>     const ACL_internal_schema_access *access;
>     access= get_cached_schema_access(grant_internal_info, db);
>     if (access)
>     {
>       switch (access->check(want_access, save_priv))
>       {
>       case ACL_INTERNAL_ACCESS_GRANTED:
>         /*
>           All the privileges requested have been granted internally.
>           [out] *save_privileges= Internal privileges.
>         */
>         DBUG_RETURN(FALSE);
>       case ACL_INTERNAL_ACCESS_DENIED:
>         if (! no_errors)
>         {
>           my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
>                    sctx->priv_user, sctx->priv_host, db);
>         }
>         DBUG_RETURN(TRUE);
> 
> In the above code snippet from check_access() in sql_parse.cc, the
> code returns FALSE when ACL_INTERNAL_ACCESS_GRANTED is returned by
> access->check(). Does this mean that the access is really granted, or
> is some logical inversion implied here that I'm missing out?

In MySQL sources many functions by convention return 0 on success and 1
(or error code) on failure. It supports the typical usage pattern:

  if (do_this() || do_that() || do_something_else())
    goto err;

technically, FALSE and TRUE mean the same as 0 and 1, but I agree that
they look quite confusing.

Regards,
Sergei

Thread
check_access() returns FALSE for internal access grantedSalil Arun Bhagurkar10 Sep
  • Re: check_access() returns FALSE for internal access grantedSergei Golubchik12 Sep