diff --git a/configure.in b/configure.in index b49dffcb59f..00a13253166 100644 --- a/configure.in +++ b/configure.in @@ -1667,6 +1667,7 @@ else CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS" CXXFLAGS="$OPTIMIZE_CXXFLAGS -DDBUG_OFF $CXXFLAGS" fi +AM_CONDITIONAL(MYSQL_CONF_DEBUG, test "x$with_debug" != "xno") # Force static compilation to avoid linking problems/get more speed AC_ARG_WITH(mysqld-ldflags, diff --git a/sql/Makefile.am b/sql/Makefile.am index 8428d6401b5..251fbaa1c9a 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -117,9 +117,14 @@ DEFS = -DMYSQL_SERVER \ BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h EXTRA_DIST = $(BUILT_SOURCES) -DISTCLEANFILES = lex_hash.h +DISTCLEANFILES = lex_hash.h sql_yacc.output + AM_YFLAGS = -d +if MYSQL_CONF_DEBUG +AM_YFLAGS += --debug --verbose +endif + mysql_tzinfo_to_sql.cc: rm -f mysql_tzinfo_to_sql.cc @LN_CP_F@ $(srcdir)/tztime.cc mysql_tzinfo_to_sql.cc diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 72098fb83e4..ceda7507d23 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5776,6 +5776,26 @@ void mysql_init_multi_delete(LEX *lex) lex->query_tables_last= &lex->query_tables; } +#ifndef DBUG_OFF +static void turn_parser_debug_on() +{ + /* + MYSQLdebug is in sql/sql_yacc.cc, in bison generated code. + Turning this option on is **VERY** verbose, and should be + used when investigating a syntax error problem only. + + The syntax to run with bison traces is as follows : + - Starting a server manually : + mysqld --debug="d,parser_debug" ... + - Running a test : + mysql-test-run.pl --mysqld="--debug=d,parser_debug" ... + + The result will be in the process stderr (var/log/master.err) + */ + extern int MYSQLdebug; + MYSQLdebug= 1; +} +#endif /* When you modify mysql_parse(), you may need to mofify @@ -5785,6 +5805,9 @@ void mysql_init_multi_delete(LEX *lex) void mysql_parse(THD *thd, char *inBuf, uint length) { DBUG_ENTER("mysql_parse"); + + DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on();); + mysql_init_query(thd, (uchar*) inBuf, length); if (query_cache_send_result_to_client(thd, inBuf, length) <= 0) {