Commit aece56e3 authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-5.0

into serg.mylan:/usr/home/serg/Abk/mysql-5.0


sql/sql_select.cc:
  Auto merged
parents 8f8f6974 79180b19
......@@ -164,10 +164,17 @@ static char TMPDIR[FN_REFLEN];
static char delimiter[MAX_DELIMITER]= DEFAULT_DELIMITER;
static uint delimiter_length= 1;
static int *cur_block, *block_stack_end;
static int block_stack[BLOCK_STACK_DEPTH];
/* Block stack */
enum block_cmd { cmd_none, cmd_if, cmd_while };
typedef struct
{
int line; /* Start line of block */
my_bool ok; /* Should block be executed */
enum block_cmd cmd; /* Command owning the block */
} BLOCK;
static BLOCK block_stack[BLOCK_STACK_DEPTH];
static BLOCK *cur_block, *block_stack_end;
static int block_ok_stack[BLOCK_STACK_DEPTH];
static CHARSET_INFO *charset_info= &my_charset_latin1; /* Default charset */
static const char *charset_name= "latin1"; /* Default character set name */
......@@ -221,8 +228,6 @@ MYSQL_RES *last_result=0;
PARSER parser;
MASTER_POS master_pos;
int *block_ok; /* set to 0 if the current block should not be executed */
int false_block_depth = 0;
/* if set, all results are concated and compared against this file */
const char *result_file = 0;
......@@ -296,6 +301,7 @@ Q_START_TIMER, Q_END_TIMER,
Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL,
Q_EXIT,
Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT,
Q_IF,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
......@@ -386,6 +392,7 @@ const char *command_names[]=
"exit",
"disable_reconnect",
"enable_reconnect",
"if",
0
};
......@@ -1924,36 +1931,54 @@ int do_connect(struct st_query* q)
int do_done(struct st_query* q)
{
/* Dummy statement to eliminate compiler warning */
q->type = Q_END_BLOCK;
/* Check if empty block stack */
if (cur_block == block_stack)
die("Stray '}' - end of block before beginning");
if (*block_ok--)
/* Test if inner block has been executed */
if (cur_block->ok && cur_block->cmd == cmd_while)
{
parser.current_line = *--cur_block;
/* Pop block from stack, re-execute outer block */
cur_block--;
parser.current_line = cur_block->line;
}
else
{
++parser.current_line;
--cur_block;
/* Pop block from stack, goto next line */
cur_block--;
parser.current_line++;
}
return 0;
}
int do_while(struct st_query* q)
int do_block(enum block_cmd cmd, struct st_query* q)
{
char* p=q->first_argument;
const char* expr_start, *expr_end;
VAR v;
/* Check stack overflow */
if (cur_block == block_stack_end)
die("Nesting too deeply");
if (!*block_ok)
/* Set way to find outer block again, increase line counter */
cur_block->line= parser.current_line++;
/* If this block is ignored */
if (!cur_block->ok)
{
++false_block_depth;
*++block_ok = 0;
*cur_block++ = parser.current_line++;
/* Inner block should be ignored too */
cur_block++;
cur_block->cmd= cmd;
cur_block->ok= FALSE;
return 0;
}
/* Parse and evaluate test expression */
expr_start = strchr(p, '(');
if (!expr_start)
die("missing '(' in while");
......@@ -1962,14 +1987,12 @@ int do_while(struct st_query* q)
die("missing ')' in while");
var_init(&v,0,0,0,0);
eval_expr(&v, ++expr_start, &expr_end);
*cur_block++ = parser.current_line++;
if (!v.int_val)
{
*++block_ok = 0;
false_block_depth++;
}
else
*++block_ok = 1;
/* Define inner block */
cur_block++;
cur_block->cmd= cmd;
cur_block->ok= (v.int_val ? TRUE : FALSE);
var_free(&v);
return 0;
}
......@@ -3653,12 +3676,13 @@ int main(int argc, char **argv)
lineno = lineno_stack;
my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES,
INIT_Q_LINES);
memset(block_stack, 0, sizeof(block_stack));
block_stack_end = block_stack + BLOCK_STACK_DEPTH;
memset(block_ok_stack, 0, sizeof(block_stack));
cur_block = block_stack;
block_ok = block_ok_stack;
*block_ok = 1;
block_stack_end= block_stack + BLOCK_STACK_DEPTH;
cur_block= block_stack;
cur_block->ok= TRUE; /* Outer block should always be executed */
cur_block->cmd= cmd_none;
init_dynamic_string(&ds_res, "", 0, 65536);
parse_args(argc, argv);
......@@ -3712,7 +3736,7 @@ int main(int argc, char **argv)
int current_line_inc = 1, processed = 0;
if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
get_query_type(q);
if (*block_ok)
if (cur_block->ok)
{
processed = 1;
switch (q->type) {
......@@ -3915,7 +3939,8 @@ int main(int argc, char **argv)
{
current_line_inc = 0;
switch (q->type) {
case Q_WHILE: do_while(q); break;
case Q_WHILE: do_block(cmd_while, q); break;
case Q_IF: do_block(cmd_if, q); break;
case Q_END_BLOCK: do_done(q); break;
default: current_line_inc = 1; break;
}
......
......@@ -616,6 +616,9 @@ How to make the InnoDB parser and lexer C files:
7. Add '#include "univ.i"' before #include <stdio.h> in lexyy.c
(Needed for AIX)
8. Add a type cast to int to the assignment below the comment
'need more input.' (Removes a warning on Win64)
These instructions seem to work at least with bison-1.28 and flex-2.5.4 on
Linux.
*******************************************************/
......@@ -2114,7 +2117,7 @@ static int input()
else
{ /* need more input */
int offset = yy_c_buf_p - yytext_ptr;
int offset = (int) (yy_c_buf_p - yytext_ptr);
++yy_c_buf_p;
switch ( yy_get_next_buffer() )
......
......@@ -31,6 +31,9 @@ How to make the InnoDB parser and lexer C files:
7. Add '#include "univ.i"' before #include <stdio.h> in lexyy.c
(Needed for AIX)
8. Add a type cast to int to the assignment below the comment
'need more input.' (Removes a warning on Win64)
These instructions seem to work at least with bison-1.28 and flex-2.5.4 on
Linux.
*******************************************************/
......
......@@ -7,7 +7,7 @@
###############################################################
# Debug options : To debug this test script
###############################################################
let $showbinlog= 0;
let $show_binlog= 0;
let $manipulate= 1;
######## The typical test sequence
......
This diff is collapsed.
......@@ -28,6 +28,8 @@
#include <hash.h>
#include <ft_global.h>
typedef uint32 cache_rec_length_type;
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext",
"ref_or_null","unique_subquery","index_subquery",
......@@ -11604,7 +11606,7 @@ used_blob_length(CACHE_FIELD **ptr)
static bool
store_record_in_cache(JOIN_CACHE *cache)
{
ulong length;
cache_rec_length_type length;
uchar *pos;
CACHE_FIELD *copy,*end_field;
bool last_record;
......@@ -11685,7 +11687,7 @@ static void
read_cached_record(JOIN_TAB *tab)
{
uchar *pos;
uint length;
cache_rec_length_type length;
bool last_record;
CACHE_FIELD *copy,*end_field;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment