dbTalk Databases Forums  

Com_empty_query

mailing.database.mysql-internals mailing.database.mysql-internals


Discuss Com_empty_query in the mailing.database.mysql-internals forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Derek Downey
 
Posts: n/a

Default Com_empty_query - 10-06-2011 , 01:26 PM






Hi,
I was trying to find out what would trigger the counter on Com_empty_query and my two test cases do not trigger it:

mysql> SHOW STATUS LIKE 'Com_empty%';
+-----------------+-------+
Quote:
Variable_name | Value |
+-----------------+-------+
Com_empty_query | 0 |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> SELECT * FROM foo WHERE bar=2;
Empty set (0.03 sec)

mysql> ;
ERROR:
No query specified

mysql> SHOW STATUS LIKE 'Com_empty%';
+-----------------+-------+
Quote:
Variable_name | Value |
+-----------------+-------+
Com_empty_query | 0 |
+-----------------+-------+
1 row in set (0.00 sec)

Looking at the source, it seems to get triggered on an END_OF_INPUT in the query section of 'sql_yacc.yy' (assuming the query is syntactically correct). sql_lex.cc is the only instance that returns an END_OF_INPUT (after a lip->eof()), but I can't seem to trigger it.

Is this triggered on a breakdown from the client, or on a certain type of (reproducible) query?

Thanks,
Derek Downey
--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: http://lists.mysql.com/internals?uns...ie.nctu.edu.tw

Reply With Quote
  #2  
Old   
Eric Bergen
 
Posts: n/a

Default Re: Com_empty_query - 10-09-2011 , 01:20 PM






I think there are a few things going on. The first is that the command
line client is returning no query specified which means it didn't send
anything to the server. I wrote a small C app to send an empty query
to the server and it returns a "Query was empty" error then does a
show status on the same connection to check the counter. The counter
isn't incremented. I checked the source and the only increment I see
for empty_queries happens at the end of execute_sqlcom_select which
won't get called on an empty query. I think it needs to be incremented
in case SQLCOM_EMPTY_QUERY: in sql_parse.cc

Here is my small app for reference:

#include <stdio.h>
#include <string.h>
#include <mysql.h>

int main() {
MYSQL con;
MYSQL_RES *res;
MYSQL_ROW row;
char show_query[] = "show status like '%empty%'";
int num_fields, i;
mysql_init(&con);

if (!(mysql_real_connect(&con, "", "root", "", "test", 3306,
"/home/ebergen/store/mysql/standalone_mariadb/mysql.sock", 0)))
{
printf("Connection failed with %s\n", mysql_error(&con));
return 1;
}

if ((mysql_real_query(&con, "", 0)))
{
printf("Query failed with %s\n", mysql_error(&con));
// return 1;
}


if (mysql_real_query(&con, show_query, strlen(show_query)))
{
printf("Show query failed with %s\n", mysql_error(&con));
return 1;
}

res = mysql_store_result(&con);
num_fields = mysql_num_fields(res);

while ((row = mysql_fetch_row(res))) {
for (i = 0; i < num_fields; i++)
{
printf("%s\n", (char *)row[i]);
}
}

return 0;
}

On Thu, Oct 6, 2011 at 11:26 AM, Derek Downey <derek (AT) orange-pants (DOT) com> wrote:
Quote:
Hi,
*I was trying to find out what would trigger the counter on Com_empty_query and my two test cases do not trigger it:

mysql> SHOW STATUS LIKE 'Com_empty%';
+-----------------+-------+
| Variable_name * | Value |
+-----------------+-------+
| Com_empty_query | 0 * * |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> SELECT * FROM foo WHERE bar=2;
Empty set (0.03 sec)

mysql> ;
ERROR:
No query specified

mysql> SHOW STATUS LIKE 'Com_empty%';
+-----------------+-------+
| Variable_name * | Value |
+-----------------+-------+
| Com_empty_query | 0 * * |
+-----------------+-------+
1 row in set (0.00 sec)

Looking at the source, it seems to get triggered on an END_OF_INPUT in the query section of 'sql_yacc.yy' (assuming the query is syntactically correct). sql_lex.cc is the only instance that returns an END_OF_INPUT (after a lip->eof()), but I can't seem to trigger it.

Is this triggered on a breakdown from the client, or on a certain type of(reproducible) query?

Thanks,
*Derek Downey
--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: * *http://lists.mysql.com/internals?uns...mail (DOT) com




--
Eric Bergen
eric.bergen (AT) gmail (DOT) com
http://www.ebergen.net

--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: http://lists.mysql.com/internals?uns...ie.nctu.edu.tw

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.