Salil Bhagurkar | 5 Sep 09:43 2011

Using fprintf or DBUG_PRINT to print messages in mysqld

Hello All,

I am trying to understand the code flow of mysql-5.5.15 mysqld server.

1. I am able to use fprintf(stdout, ..) to print out messages to the console 
in the main startup code of mysqld.

2. I cannot use fprintf in any of the thread context to print messages to 
the console. Why is this?

3. If I compile the source code with the debug option and use DBUG_PRINT, 
then it does not work in some cases, specifically in the function 
do_handle_one_connection() in sql/sql_connect.cc.

4. DBUG_PRINT works and is used in the function do_command which is called 
by the do_handle_one_connection() method. From what I observed, is 
DBUG_ENTER always required to be able to DBUG_PRINT?

Thanks,
Salil Bhagurkar 

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals?unsub=gcdmd-internals <at> m.gmane.org

AugustQ | 5 Sep 18:14 2011
Picon
Picon

RE: Using fprintf or DBUG_PRINT to print messages in mysqld

Hi Salil,

I've used 

    fprintf(stderr, .....)

and this worked, at least the message appeared in the log-file.

And I've also used Eclipse (with CDT) to set breakpoints, inspect
variables etc. And I could see my messages in the console.

Here is an example:
I looked ath this statement:
    select PZN, EVP, HAP from ABDAcol where PZN IN (1, 2, 3, 456);

and this is what I found in the console:
FUNC-ITEM=[ IN ] args: 5  res=2 type=[IN_FUNC]
FIELD-ITEM[ABDAcol] [PZN] [] 0 	name=<PZN>
INT-ITEM	val = 1 res=2	name=<1>
INT-ITEM	val = 2 res=2	name=<2>
INT-ITEM	val = 3 res=2	name=<3>
INT-ITEM	val = 456 res=2	name=<456>

This text was written by my own fprintf()-statements.

hope that helps.
August

--

-- 
MySQL Internals Mailing List
(Continue reading)

Thomas Jones-Low | 5 Sep 19:12 2011

Re: Using fprintf or DBUG_PRINT to print messages in mysqld

On 9/5/2011 3:43 AM, Salil Bhagurkar wrote:
> Hello All,
>
> I am trying to understand the code flow of mysql-5.5.15 mysqld server.
>
> 1. I am able to use fprintf(stdout, ..) to print out messages to the
> console in the main startup code of mysqld.
>
> 2. I cannot use fprintf in any of the thread context to print messages
> to the console. Why is this?
>
	The MySQL logging system redirects both stdout and stderr to the MySQL 
log file. use tail -f /var/log/mysql.log to see your messages.

> 3. If I compile the source code with the debug option and use
> DBUG_PRINT, then it does not work in some cases, specifically in the
> function do_handle_one_connection() in sql/sql_connect.cc.
>
> 4. DBUG_PRINT works and is used in the function do_command which is
> called by the do_handle_one_connection() method. From what I observed,
> is DBUG_ENTER always required to be able to DBUG_PRINT?
>
	Yes, and DEBUG_RETURN() or DBUG_VOID_RETURN; These are macros, each of 
which sets (or clears) some global state. They must be used together.

--

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals?unsub=gcdmd-internals <at> m.gmane.org

(Continue reading)

Bhagurkar, Salil Arun | 10 Sep 20:24 2011

check_access() returns FALSE for internal access granted

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?

Cheers,
Salil Bhagurkar

--

-- 
(Continue reading)

Sergei Golubchik | 12 Sep 12:43 2011

Re: check_access() returns FALSE for internal access granted

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?

(Continue reading)


Gmane