Re: check_access() returns FALSE for internal access granted

Sergei Golubchik <[email protected]>
Newsgroups gmane.comp.db.mysql.devel
Message-ID <[email protected]>
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


-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.