3543 Magne Mahre 2011-11-01
Added support for Bison 'locations'
modified:
sql/sql_lex.cc
sql/sql_lex.h
sql/sql_yacc.yy
3542 Jon Olav Hauglid 2011-11-01
Bug#13326965 THD->CURRENT_UTIME() CALLED WHEN NOT NEEDED IN
LOG_SLOW_STATEMENT()
The problem was that thd->current_utime() was called before
writing to the slow log even if no log entries ended up being
written. This is unneccessary and potentially a performance
problem (thd->current_utime() -> my_micro_time() ->
__gettimeofday()).
This patch fixes the problem by not calling thd->current_utime()
before it is known that a log entry will in fact be written.
The patch doesn't contain a test case since it is hard to test
for performance improvements in our test framework.
modified:
sql/log.cc
sql/log.h
sql/sql_parse.cc
=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc 2011-10-18 13:45:29 +0000
+++ b/sql/sql_lex.cc 2011-11-01 09:21:48 +0000
@@ -861,11 +861,12 @@ bool consume_comment(Lex_input_stream *l
(which can't be followed by a signed number)
*/
-int MYSQLlex(void *arg, void *yythd)
+int MYSQLlex(void *arg, void *arg2, void *yythd)
{
THD *thd= (THD *)yythd;
Lex_input_stream *lip= & thd->m_parser_state->m_lip;
YYSTYPE *yylval=(YYSTYPE*) arg;
+ YYLTYPE *yylloc=(YYLTYPE*) arg2;
int token;
if (lip->lookahead_token >= 0)
@@ -877,11 +878,14 @@ int MYSQLlex(void *arg, void *yythd)
token= lip->lookahead_token;
lip->lookahead_token= -1;
*yylval= *(lip->lookahead_yylval);
+ yylloc->start= (char*) lip->get_cpp_tok_start();
+ yylloc->end= (char*) lip->get_cpp_ptr();
lip->lookahead_yylval= NULL;
return token;
}
token= lex_one_token(arg, yythd);
+ yylloc->start= (char*) lip->get_cpp_tok_start();
switch(token) {
case WITH:
@@ -895,8 +899,10 @@ int MYSQLlex(void *arg, void *yythd)
token= lex_one_token(arg, yythd);
switch(token) {
case CUBE_SYM:
+ yylloc->end= (char*) lip->get_cpp_ptr();
return WITH_CUBE_SYM;
case ROLLUP_SYM:
+ yylloc->end= (char*) lip->get_cpp_ptr();
return WITH_ROLLUP_SYM;
default:
/*
@@ -905,17 +911,18 @@ int MYSQLlex(void *arg, void *yythd)
lip->lookahead_yylval= lip->yylval;
lip->yylval= NULL;
lip->lookahead_token= token;
+ yylloc->end= (char*) lip->get_cpp_ptr();
return WITH;
}
break;
default:
break;
}
-
+ yylloc->end= (char*) lip->get_cpp_ptr();
return token;
}
-int lex_one_token(void *arg, void *yythd)
+static int lex_one_token(void *arg, void *yythd)
{
reg1 uchar c= 0;
bool comment_closed;
=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h 2011-10-13 12:33:08 +0000
+++ b/sql/sql_lex.h 2011-11-01 09:21:48 +0000
@@ -105,6 +105,43 @@ struct sys_var_with_base
LEX_STRING base_name;
};
+typedef struct YYLTYPE
+{
+ int first_line;
+ int first_column;
+ int last_line;
+ int last_column;
+
+ char *start;
+ char *end;
+} YYLTYPE;
+
+#define YYLTYPE_IS_DECLARED 1 /* signal bison that we have our own definition */
+#define YYLTYPE_IS_TRIVIAL 1
+
+#define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ (Current).start = YYRHSLOC (Rhs, 1).start; \
+ (Current).end = YYRHSLOC (Rhs, N).end; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ (Current).start = YYRHSLOC (Rhs, 0).start; \
+ (Current).end = YYRHSLOC (Rhs, 0).end; \
+ } \
+ while (YYID (0))
+
+
#ifdef MYSQL_SERVER
/*
The following hack is needed because mysql_yacc.cc does not define
@@ -2658,7 +2695,7 @@ extern void lex_init(void);
extern void lex_free(void);
extern void lex_start(THD *thd);
extern void lex_end(LEX *lex);
-extern int MYSQLlex(void *arg, void *yythd);
+extern int MYSQLlex(void *arg, void *arg2, void *yythd);
extern void trim_whitespace(const CHARSET_INFO *cs, LEX_STRING *str);
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2011-10-14 15:38:24 +0000
+++ b/sql/sql_yacc.yy 2011-11-01 09:21:48 +0000
@@ -73,9 +73,9 @@
int yylex(void *yylval, void *yythd);
-#define yyoverflow(A,B,C,D,E,F) \
+#define yyoverflow(A,B,C,D,E,F,G,H) \
{ \
- ulong val= *(F); \
+ ulong val= *(H); \
if (my_yyoverflow((B), (D), &val)) \
{ \
yyerror((char*) (A)); \
@@ -83,7 +83,7 @@ int yylex(void *yylval, void *yythd);
} \
else \
{ \
- *(F)= (YYSIZE_T)val; \
+ *(H)= (YYSIZE_T)val; \
} \
}
@@ -7780,34 +7780,34 @@ select_item_list:
;
select_item:
- remember_name table_wild remember_end
+ table_wild
{
THD *thd= YYTHD;
- if (add_item_to_list(thd, $2))
+ if (add_item_to_list(thd, $1))
MYSQL_YYABORT;
}
- | remember_name expr remember_end select_alias
+ | expr select_alias
{
THD *thd= YYTHD;
- DBUG_ASSERT($1 < $3);
+ DBUG_ASSERT(@1.start < @1.end);
- if (add_item_to_list(thd, $2))
+ if (add_item_to_list(thd, $1))
MYSQL_YYABORT;
- if ($4.str)
+ if ($2.str)
{
if (Lex->sql_command == SQLCOM_CREATE_VIEW &&
- check_column_name($4.str))
+ check_column_name($2.str))
{
- my_error(ER_WRONG_COLUMN_NAME, MYF(0), $4.str);
+ my_error(ER_WRONG_COLUMN_NAME, MYF(0), $2.str);
MYSQL_YYABORT;
}
- $2->is_autogenerated_name= FALSE;
- $2->set_name($4.str, $4.length, system_charset_info);
+ $1->is_autogenerated_name= FALSE;
+ $1->set_name($2.str, $2.length, system_charset_info);
}
- else if (!$2->name)
+ else if (!$1->name)
{
- $2->set_name($1, (uint) ($3 - $1), thd->charset());
+ $1->set_name(@1.start, (uint) (@1.end - @1.start), thd->charset());
}
}
;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (magne.mahre:3542 to 3543) | Magne Mahre | 1 Nov |