Below is the list of changes that have just been committed into a local
5.1 repository of cps. When cps does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1950 05/11/09 15:15:01 petr@stripped +15 -0
Merge mysql.com:/home/cps/mysql/trees/mysql-5.0-virgin
into mysql.com:/home/cps/mysql/trees/mysql-5.1-virgin
sql/examples/ha_tina.cc
1.22 05/11/09 15:14:56 petr@stripped +0 -0
SCCS merged
support-files/mysql.spec.sh
1.116 05/11/09 15:12:06 petr@stripped +0 -0
Auto merged
sql/table.h
1.116 05/11/09 15:12:06 petr@stripped +0 -0
Auto merged
sql/sql_table.cc
1.277 05/11/09 15:12:06 petr@stripped +0 -0
Auto merged
sql/sql_select.h
1.100 05/11/09 15:12:06 petr@stripped +0 -0
Auto merged
sql/share/errmsg.txt
1.53 05/11/09 15:12:06 petr@stripped +0 -0
Auto merged
sql/sql_select.cc
1.368 05/11/09 15:12:05 petr@stripped +0 -0
Auto merged
sql/sql_prepare.cc
1.154 05/11/09 15:12:05 petr@stripped +0 -0
Auto merged
sql/sql_parse.cc
1.481 05/11/09 15:12:05 petr@stripped +0 -0
Auto merged
sql/sql_lex.cc
1.165 05/11/09 15:12:05 petr@stripped +0 -0
Auto merged
sql/mysql_priv.h
1.342 05/11/09 15:12:05 petr@stripped +0 -0
Auto merged
sql/handler.h
1.166 05/11/09 15:12:05 petr@stripped +0 -0
Auto merged
sql/field.cc
1.288 05/11/09 15:12:04 petr@stripped +0 -0
Auto merged
mysql-test/t/view.test
1.121 05/11/09 15:12:04 petr@stripped +0 -0
Auto merged
configure.in
1.309 05/11/09 15:12:04 petr@stripped +0 -0
Auto merged
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: petr
# Host: owlet.
# Root: /home/cps/mysql/trees/mysql-5.1-virgin/RESYNC
--- 1.308/configure.in 2005-11-08 09:36:52 +03:00
+++ 1.309/configure.in 2005-11-09 15:12:04 +03:00
@@ -311,6 +311,10 @@
# Use the built-in alloca()
CFLAGS="$CFLAGS -Kalloca"
CXXFLAGS="$CFLAGS -Kalloca"
+ # Use no_implicit for templates
+ CXXFLAGS="$CXXFLAGS -Tno_implicit"
+ AC_DEFINE([HAVE_EXPLICIT_TEMPLATE_INSTANTIATION],
+ [1], [Defined by configure. Use explicit template instantiation.])
fi
;;
esac
--- 1.287/sql/field.cc 2005-11-04 23:09:54 +03:00
+++ 1.288/sql/field.cc 2005-11-09 15:12:04 +03:00
@@ -7986,7 +7986,7 @@
{
int delta;
- for (; !*from && length; from++, length--); // skip left 0's
+ for (; length && !*from; from++, length--); // skip left 0's
delta= field_length - length;
if (delta < -1 ||
@@ -8235,7 +8235,7 @@
int delta;
uchar bits= create_length & 7;
- for (; !*from && length; from++, length--); // skip left 0's
+ for (; length && !*from; from++, length--); // skip left 0's
delta= field_length - length;
if (delta < 0 ||
--- 1.165/sql/handler.h 2005-11-07 18:24:40 +03:00
+++ 1.166/sql/handler.h 2005-11-09 15:12:05 +03:00
@@ -42,6 +42,7 @@
#define HA_ADMIN_REJECT -6
#define HA_ADMIN_TRY_ALTER -7
#define HA_ADMIN_WRONG_CHECKSUM -8
+#define HA_ADMIN_NOT_BASE_TABLE -9
/* Bits in table_flags() to show what database can do */
--- 1.341/sql/mysql_priv.h 2005-11-07 18:24:41 +03:00
+++ 1.342/sql/mysql_priv.h 2005-11-09 15:12:05 +03:00
@@ -44,6 +44,12 @@
typedef ulonglong table_map; /* Used for table bits in join */
typedef Bitmap<64> key_map; /* Used for finding keys */
typedef ulong key_part_map; /* Used for finding key parts */
+/*
+ Used to identify NESTED_JOIN structures within a join (applicable only to
+ structures that have not been simplified away and embed more the one
+ element)
+*/
+typedef ulonglong nested_join_map;
/* query_id */
typedef ulonglong query_id_t;
--- 1.164/sql/sql_lex.cc 2005-11-06 03:36:18 +03:00
+++ 1.165/sql/sql_lex.cc 2005-11-09 15:12:05 +03:00
@@ -2040,6 +2040,35 @@
/*
+ Do end-of-prepare fixup for list of tables and their merge-VIEWed tables
+
+ SYNOPSIS
+ fix_prepare_info_in_table_list()
+ thd Thread handle
+ tbl List of tables to process
+
+ DESCRIPTION
+ Perform end-end-of prepare fixup for list of tables, if any of the tables
+ is a merge-algorithm VIEW, recursively fix up its underlying tables as
+ well.
+
+*/
+
+static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
+{
+ for (; tbl; tbl= tbl->next_local)
+ {
+ if (tbl->on_expr)
+ {
+ tbl->prep_on_expr= tbl->on_expr;
+ tbl->on_expr= tbl->on_expr->copy_andor_structure(thd);
+ }
+ fix_prepare_info_in_table_list(thd, tbl->merge_underlying_list);
+ }
+}
+
+
+/*
fix some structures at the end of preparation
SYNOPSIS
@@ -2058,16 +2087,7 @@
prep_where= *conds;
*conds= where= prep_where->copy_andor_structure(thd);
}
- for (TABLE_LIST *tbl= (TABLE_LIST *)table_list.first;
- tbl;
- tbl= tbl->next_local)
- {
- if (tbl->on_expr)
- {
- tbl->prep_on_expr= tbl->on_expr;
- tbl->on_expr= tbl->on_expr->copy_andor_structure(thd);
- }
- }
+ fix_prepare_info_in_table_list(thd, (TABLE_LIST *)table_list.first);
}
}
--- 1.480/sql/sql_parse.cc 2005-11-07 18:24:43 +03:00
+++ 1.481/sql/sql_parse.cc 2005-11-09 15:12:05 +03:00
@@ -188,6 +188,18 @@
#endif
+static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables)
+{
+ for (TABLE_LIST *table= tables; table; table= table->next_global)
+ {
+ DBUG_ASSERT(table->db && table->table_name);
+ if (table->updating &&
+ !find_temporary_table(thd, table->db, table->table_name))
+ return 1;
+ }
+ return 0;
+}
+
static HASH hash_user_connections;
static int get_or_create_user_conn(THD *thd, const char *user,
@@ -2360,7 +2372,7 @@
mysql_reset_errors(thd, 0);
#ifdef HAVE_REPLICATION
- if (thd->slave_thread)
+ if (unlikely(thd->slave_thread))
{
/*
Check if statment should be skipped because of slave filtering
@@ -2399,16 +2411,20 @@
}
#endif
}
+ else
#endif /* HAVE_REPLICATION */
/*
- When option readonly is set deny operations which change tables.
- Except for the replication thread and the 'super' users.
+ When option readonly is set deny operations which change non-temporary
+ tables. Except for the replication thread and the 'super' users.
*/
if (opt_readonly &&
- !(thd->slave_thread ||
- (thd->security_ctx->master_access & SUPER_ACL)) &&
- uc_update_queries[lex->sql_command])
+ !(thd->security_ctx->master_access & SUPER_ACL) &&
+ uc_update_queries[lex->sql_command] &&
+ !((lex->sql_command == SQLCOM_CREATE_TABLE) &&
+ (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) &&
+ ((lex->sql_command != SQLCOM_UPDATE_MULTI) &&
+ some_non_temp_table_to_be_updated(thd, all_tables)))
{
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
DBUG_RETURN(-1);
@@ -3198,13 +3214,24 @@
#ifdef HAVE_REPLICATION
/* Check slave filtering rules */
- if (thd->slave_thread && all_tables_not_ok(thd, all_tables))
+ if (unlikely(thd->slave_thread))
{
- /* we warn the slave SQL thread */
- my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
- break;
+ if (all_tables_not_ok(thd, all_tables))
+ {
+ /* we warn the slave SQL thread */
+ my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ break;
+ }
}
+ else
#endif /* HAVE_REPLICATION */
+ if (opt_readonly &&
+ !(thd->security_ctx->master_access & SUPER_ACL) &&
+ some_non_temp_table_to_be_updated(thd, all_tables))
+ {
+ my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
+ break;
+ }
res= mysql_multi_update(thd, all_tables,
&select_lex->item_list,
--- 1.367/sql/sql_select.cc 2005-11-06 10:28:50 +03:00
+++ 1.368/sql/sql_select.cc 2005-11-09 15:12:05 +03:00
@@ -98,6 +98,12 @@
void *table_join_idx);
static COND *simplify_joins(JOIN *join, List<TABLE_LIST> *join_list,
COND *conds, bool top);
+static bool check_interleaving_with_nj(JOIN_TAB *last, JOIN_TAB *next);
+static void restore_prev_nj_state(JOIN_TAB *last);
+static void reset_nj_counters(List<TABLE_LIST> *join_list);
+static uint build_bitmap_for_nested_joins(List<TABLE_LIST> *join_list,
+ uint first_unused);
+
static COND *optimize_cond(JOIN *join, COND *conds,
List<TABLE_LIST> *join_list,
Item::cond_result *cond_value);
@@ -520,12 +526,14 @@
return 0;
}
+
/*
global select optimisation.
return 0 - success
1 - error
error code saved in field 'error'
*/
+
int
JOIN::optimize()
{
@@ -588,6 +596,7 @@
/* Convert all outer joins to inner joins if possible */
conds= simplify_joins(this, join_list, conds, TRUE);
+ build_bitmap_for_nested_joins(join_list, 0);
sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0;
@@ -700,7 +709,8 @@
DBUG_PRINT("error",("Error: make_select() failed"));
DBUG_RETURN(1);
}
-
+
+ reset_nj_counters(join_list);
make_outerjoin_info(this);
/*
@@ -1980,14 +1990,19 @@
continue;
}
outer_join|= table->map;
+ s->embedding_map= 0;
+ for (;embedding; embedding= embedding->embedding)
+ s->embedding_map|= embedding->nested_join->nj_map;
continue;
}
if (embedding)
{
/* s belongs to a nested join, maybe to several embedded joins */
+ s->embedding_map= 0;
do
{
NESTED_JOIN *nested_join= embedding->nested_join;
+ s->embedding_map|=nested_join->nj_map;
s->dependent|= embedding->dep_tables;
embedding= embedding->embedding;
outer_join|= nested_join->used_tables;
@@ -3561,6 +3576,8 @@
bool straight_join= join->select_options & SELECT_STRAIGHT_JOIN;
DBUG_ENTER("choose_plan");
+ join->cur_embedding_map= 0;
+ reset_nj_counters(join->join_list);
/*
if (SELECT_STRAIGHT_JOIN option is set)
reorder tables so dependent tables come after tables they depend
@@ -4041,7 +4058,9 @@
for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++)
{
table_map real_table_bit= s->table->map;
- if ((remaining_tables & real_table_bit) && !(remaining_tables & s->dependent))
+ if ((remaining_tables & real_table_bit) &&
+ !(remaining_tables & s->dependent) &&
+ (!idx || !check_interleaving_with_nj(join->positions[idx-1].table, s)))
{
double current_record_count, current_read_time;
@@ -4057,6 +4076,7 @@
{
DBUG_EXECUTE("opt", print_plan(join, read_time, record_count, idx,
"prune_by_cost"););
+ restore_prev_nj_state(s);
continue;
}
@@ -4085,6 +4105,7 @@
{
DBUG_EXECUTE("opt", print_plan(join, read_time, record_count, idx,
"pruned_by_heuristic"););
+ restore_prev_nj_state(s);
continue;
}
}
@@ -4119,9 +4140,11 @@
sizeof(POSITION) * (idx + 1));
join->best_read= current_read_time - 0.001;
}
- DBUG_EXECUTE("opt",
- print_plan(join, current_read_time, current_record_count, idx, "full_plan"););
+ DBUG_EXECUTE("opt", print_plan(join, current_read_time,
+ current_record_count, idx,
+ "full_plan"););
}
+ restore_prev_nj_state(s);
}
}
DBUG_VOID_RETURN;
@@ -4166,7 +4189,8 @@
for (JOIN_TAB **pos=join->best_ref+idx ; (s=*pos) ; pos++)
{
table_map real_table_bit=s->table->map;
- if ((rest_tables & real_table_bit) && !(rest_tables & s->dependent))
+ if ((rest_tables & real_table_bit) && !(rest_tables & s->dependent) &&
+ (!idx|| !check_interleaving_with_nj(join->positions[idx-1].table, s)))
{
double best,best_time,records;
best=best_time=records=DBL_MAX;
@@ -4504,10 +4528,10 @@
join->unit->select_limit_cnt >= records)
join->sort_by_table= (TABLE*) 1; // Must use temporary table
- /*
+ /*
Go to the next level only if there hasn't been a better key on
this level! This will cut down the search for a lot simple cases!
- */
+ */
double current_record_count=record_count*records;
double current_read_time=read_time+best;
if (best_record_count > current_record_count ||
@@ -4528,6 +4552,7 @@
return;
swap_variables(JOIN_TAB*, join->best_ref[idx], *pos);
}
+ restore_prev_nj_state(s);
if (join->select_options & SELECT_STRAIGHT_JOIN)
break; // Don't test all combinations
}
@@ -5113,7 +5138,7 @@
This function can be called only after the execution plan
has been chosen.
*/
-
+
static void
make_outerjoin_info(JOIN *join)
{
@@ -7277,11 +7302,11 @@
ascent all attributes are calculated, all outer joins that can be
converted are replaced and then all unnecessary braces are removed.
As join list contains join tables in the reverse order sequential
- elimination of outer joins does not requite extra recursive calls.
+ elimination of outer joins does not require extra recursive calls.
EXAMPLES
Here is an example of a join query with invalid cross references:
- SELECT * FROM t1 LEFT JOIN t2 ON t2.a=t3.a LEFT JOIN ON t3.b=t1.b
+ SELECT * FROM t1 LEFT JOIN t2 ON t2.a=t3.a LEFT JOIN t3 ON t3.b=t1.b
RETURN VALUE
The new condition, if success
@@ -7438,7 +7463,257 @@
}
DBUG_RETURN(conds);
}
-
+
+
+/*
+ Assign each nested join structure a bit in nested_join_map
+
+ SYNOPSIS
+ build_bitmap_for_nested_joins()
+ join Join being processed
+ join_list List of tables
+ first_unused Number of first unused bit in nested_join_map before the
+ call
+
+ DESCRIPTION
+ Assign each nested join structure (except "confluent" ones - those that
+ embed only one element) a bit in nested_join_map.
+
+ NOTE
+ This function is called after simplify_joins(), when there are no
+ redundant nested joins, #non_confluent_nested_joins <= #tables_in_join so
+ we will not run out of bits in nested_join_map.
+
+ RETURN
+ First unused bit in nested_join_map after the call.
+*/
+
+static uint build_bitmap_for_nested_joins(List<TABLE_LIST> *join_list,
+ uint first_unused)
+{
+ List_iterator<TABLE_LIST> li(*join_list);
+ TABLE_LIST *table;
+ DBUG_ENTER("build_bitmap_for_nested_joins");
+ while ((table= li++))
+ {
+ NESTED_JOIN *nested_join;
+ if ((nested_join= table->nested_join))
+ {
+ /*
+ It is guaranteed by simplify_joins() function that a nested join
+ that has only one child represents a single table VIEW (and the child
+ is an underlying table). We don't assign bits to such nested join
+ structures because
+ 1. it is redundant (a "sequence" of one table cannot be interleaved
+ with anything)
+ 2. we could run out bits in nested_join_map otherwise.
+ */
+ if (nested_join->join_list.elements != 1)
+ {
+ nested_join->nj_map= 1 << first_unused++;
+ first_unused= build_bitmap_for_nested_joins(&nested_join->join_list,
+ first_unused);
+ }
+ }
+ }
+ DBUG_RETURN(first_unused);
+}
+
+
+/*
+ Set NESTED_JOIN::counter=0 in all nested joins in passed list
+
+ SYNOPSIS
+ reset_nj_counters()
+ join_list List of nested joins to process. It may also contain base
+ tables which will be ignored.
+
+ DESCRIPTION
+ Recursively set NESTED_JOIN::counter=0 for all nested joins contained in
+ the passed join_list.
+*/
+
+static void reset_nj_counters(List<TABLE_LIST> *join_list)
+{
+ List_iterator<TABLE_LIST> li(*join_list);
+ TABLE_LIST *table;
+ DBUG_ENTER("reset_nj_counters");
+ while ((table= li++))
+ {
+ NESTED_JOIN *nested_join;
+ if ((nested_join= table->nested_join))
+ {
+ nested_join->counter= 0;
+ reset_nj_counters(&nested_join->join_list);
+ }
+ }
+ DBUG_VOID_RETURN;
+}
+
+
+/*
+ Check interleaving with an inner tables of an outer join for extension table
+
+ SYNOPSIS
+ check_interleaving_with_nj()
+ join Join being processed
+ last_tab Last table in current partial join order (this function is
+ not called for empty partial join orders)
+ next_tab Table we're going to extend the current partial join with
+
+ DESCRIPTION
+ Check if table next_tab can be added to current partial join order, and
+ if yes, record that it has been added.
+
+ The function assumes that both current partial join order and its
+ extension with next_tab are valid wrt table dependencies.
+
+ IMPLEMENTATION
+ LIMITATIONS ON JOIN ORDER
+ The nested [outer] joins executioner algorithm imposes these limitations
+ on join order:
+ 1. "Outer tables first" - any "outer" table must be before any
+ corresponding "inner" table.
+ 2. "No interleaving" - tables inside a nested join must form a continuous
+ sequence in join order (i.e. the sequence must not be interrupted by
+ tables that are outside of this nested join).
+
+ #1 is checked elsewhere, this function checks #2 provided that #1 has
+ been already checked.
+
+ WHY NEED NON-INTERLEAVING
+ Consider an example:
+
+ select * from t0 join t1 left join (t2 join t3) on cond1
+
+ The join order "t1 t2 t0 t3" is invalid:
+
+ table t0 is outside of the nested join, so WHERE condition for t0 is
+ attached directly to t0 (without triggers, and it may be used to access
+ t0). Applying WHERE(t0) to (t2,t0,t3) record is invalid as we may miss
+ combinations of (t1, t2, t3) that satisfy condition cond1, and produce a
+ null-complemented (t1, t2.NULLs, t3.NULLs) row, which should not have
+ been produced.
+
+ If table t0 is not between t2 and t3, the problem doesn't exist:
+ * If t0 is located after (t2,t3), WHERE(t0) is applied after nested join
+ processing has finished.
+ * If t0 is located before (t2,t3), predicates like WHERE_cond(t0, t2) are
+ wrapped into condition triggers, which takes care of correct nested
+ join processing.
+
+ HOW IT IS IMPLEMENTED
+ The limitations on join order can be rephrased as follows: for valid
+ join order one must be able to:
+ 1. write down the used tables in the join order on one line.
+ 2. for each nested join, put one '(' and one ')' on the said line
+ 3. write "LEFT JOIN" and "ON (...)" where appropriate
+ 4. get a query equivalent to the query we're trying to execute.
+
+ Calls to check_interleaving_with_nj() are equivalent to writing the
+ above described line from left to right.
+ A single check_interleaving_with_nj(A,B) call is equivalent to writing
+ table B and appropriate brackets on condition that table A and
+ appropriate brackets is the last what was written. Graphically the
+ transition is as follows:
+
+ +---- current position
+ |
+ ... last_tab ))) | ( next_tab ) )..) | ...
+ X Y Z |
+ +- need to move to this
+ position.
+
+ Notes about the position:
+ The caller guarantees that there is no more then one X-bracket by
+ checking "!(remaining_tables & s->dependent)" before calling this
+ function. X-bracket may have a pair in Y-bracket.
+
+ When "writing" we store/update this auxilary info about the current
+ position:
+ 1. join->cur_embedding_map - bitmap of pairs of brackets (aka nested
+ joins) we've opened but didn't close.
+ 2. {each NESTED_JOIN structure not simplified away}->counter - number
+ of this nested join's children that have already been added to to
+ the partial join order.
+
+ RETURN
+ FALSE Join order extended, nested joins info about current join order
+ (see NOTE section) updated.
+ TRUE Requested join order extension not allowed.
+*/
+
+static bool check_interleaving_with_nj(JOIN_TAB *last_tab, JOIN_TAB *next_tab)
+{
+ TABLE_LIST *next_emb= next_tab->table->pos_in_table_list->embedding;
+ JOIN *join= last_tab->join;
+
+ if (join->cur_embedding_map & ~next_tab->embedding_map)
+ {
+ /*
+ next_tab is outside of the "pair of brackets" we're currently in.
+ Cannot add it.
+ */
+ return TRUE;
+ }
+
+ /*
+ Do update counters for "pairs of brackets" that we've left (marked as
+ X,Y,Z in the above picture)
+ */
+ for (;next_emb; next_emb= next_emb->embedding)
+ {
+ next_emb->nested_join->counter++;
+ if (next_emb->nested_join->counter == 1)
+ {
+ /*
+ next_emb is the first table inside a nested join we've "entered". In
+ the picture above, we're looking at the 'X' bracket. Don't exit yet as
+ X bracket might have Y pair bracket.
+ */
+ join->cur_embedding_map |= next_emb->nested_join->nj_map;
+ }
+
+ if (next_emb->nested_join->join_list.elements !=
+ next_emb->nested_join->counter)
+ break;
+
+ /*
+ We're currently at Y or Z-bracket as depicted in the above picture.
+ Mark that we've left it and continue walking up the brackets hierarchy.
+ */
+ join->cur_embedding_map &= ~next_emb->nested_join->nj_map;
+ }
+ return FALSE;
+}
+
+
+/*
+ Nested joins perspective: Remove the last table from the join order
+
+ SYNOPSIS
+ restore_prev_nj_state()
+ last join table to remove, it is assumed to be the last in current
+ partial join order.
+
+ DESCRIPTION
+ Remove the last table from the partial join order and update the nested
+ joins counters and join->cur_embedding_map. It is ok to call this
+ function for the first table in join order (for which
+ check_interleaving_with_nj has not been called)
+*/
+
+static void restore_prev_nj_state(JOIN_TAB *last)
+{
+ TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding;
+ JOIN *join= last->join;
+ while (last_emb && !(--last_emb->nested_join->counter))
+ {
+ join->cur_embedding_map &= last_emb->nested_join->nj_map;
+ last_emb= last_emb->embedding;
+ }
+}
+
static COND *
optimize_cond(JOIN *join, COND *conds, List<TABLE_LIST> *join_list,
--- 1.99/sql/sql_select.h 2005-11-04 23:09:57 +03:00
+++ 1.100/sql/sql_select.h 2005-11-09 15:12:06 +03:00
@@ -137,7 +137,9 @@
TABLE_REF ref;
JOIN_CACHE cache;
JOIN *join;
-
+ /* Bitmap of nested joins this table is part of */
+ nested_join_map embedding_map;
+
void cleanup();
} JOIN_TAB;
@@ -194,6 +196,13 @@
*/
ha_rows fetch_limit;
POSITION positions[MAX_TABLES+1],best_positions[MAX_TABLES+1];
+
+ /*
+ Bitmap of nested joins embedding the position at the end of the current
+ partial join (valid only during join optimizer run).
+ */
+ nested_join_map cur_embedding_map;
+
double best_read;
List<Item> *fields;
List<Cached_item> group_fields, group_fields_cache;
--- 1.276/sql/sql_table.cc 2005-11-07 18:24:44 +03:00
+++ 1.277/sql/sql_table.cc 2005-11-09 15:12:06 +03:00
@@ -2338,7 +2338,7 @@
/* if view are unsupported */
if (table->view && view_operator_func == NULL)
{
- result_code= HA_ADMIN_NOT_IMPLEMENTED;
+ result_code= HA_ADMIN_NOT_BASE_TABLE;
goto send_result;
}
thd->open_options&= ~extra_open_options;
@@ -2473,6 +2473,16 @@
}
break;
+ case HA_ADMIN_NOT_BASE_TABLE:
+ {
+ char buf[ERRMSGSIZE+20];
+ uint length= my_snprintf(buf, ERRMSGSIZE,
+ ER(ER_BAD_TABLE_ERROR), table_name);
+ protocol->store("note", 4, system_charset_info);
+ protocol->store(buf, length, system_charset_info);
+ }
+ break;
+
case HA_ADMIN_OK:
protocol->store("status", 6, system_charset_info);
protocol->store("OK",2, system_charset_info);
@@ -2573,16 +2583,19 @@
break;
}
}
- if (fatal_error)
- table->table->s->version=0; // Force close of table
- else if (open_for_modify)
+ if (table->table)
{
- pthread_mutex_lock(&LOCK_open);
- remove_table_from_cache(thd, table->table->s->db,
- table->table->s->table_name, RTFC_NO_FLAG);
- pthread_mutex_unlock(&LOCK_open);
- /* May be something modified consequently we have to invalidate cache */
- query_cache_invalidate3(thd, table->table, 0);
+ if (fatal_error)
+ table->table->s->version=0; // Force close of table
+ else if (open_for_modify)
+ {
+ pthread_mutex_lock(&LOCK_open);
+ remove_table_from_cache(thd, table->table->s->db,
+ table->table->s->table_name, RTFC_NO_FLAG);
+ pthread_mutex_unlock(&LOCK_open);
+ /* Something may be modified, that's why we have to invalidate cache */
+ query_cache_invalidate3(thd, table->table, 0);
+ }
}
close_thread_tables(thd);
table->table=0; // For query cache
--- 1.115/sql/table.h 2005-11-07 18:24:45 +03:00
+++ 1.116/sql/table.h 2005-11-09 15:12:06 +03:00
@@ -802,7 +802,15 @@
table_map used_tables; /* bitmap of tables in the nested join */
table_map not_null_tables; /* tables that rejects nulls */
struct st_join_table *first_nested;/* the first nested table in the plan */
- uint counter; /* to count tables in the nested join */
+ /*
+ Used to count tables in the nested join in 2 isolated places:
+ 1. In make_outerjoin_info().
+ 2. check_interleaving_with_nj/restore_prev_nj_state (these are called
+ by the join optimizer.
+ Before each use the counters are zeroed by reset_nj_counters.
+ */
+ uint counter;
+ nested_join_map nj_map; /* Bit used to identify this nested join*/
} NESTED_JOIN;
--- 1.115/support-files/mysql.spec.sh 2005-11-04 23:10:00 +03:00
+++ 1.116/support-files/mysql.spec.sh 2005-11-09 15:12:06 +03:00
@@ -259,6 +259,7 @@
--includedir=%{_includedir} \
--mandir=%{_mandir} \
--enable-thread-safe-client \
+ --with-zlib-dir=bundled \
--with-readline ; \
# Add this for more debugging support
# --with-debug
--- 1.120/mysql-test/t/view.test 2005-11-06 09:45:49 +03:00
+++ 1.121/mysql-test/t/view.test 2005-11-09 15:12:04 +03:00
@@ -1804,7 +1804,9 @@
# underlying tables (BUG#6443)
#
set sql_mode='strict_all_tables';
+--disable_warnings
CREATE TABLE t1 (col1 INT NOT NULL, col2 INT NOT NULL) ENGINE = INNODB;
+--enable_warnings
CREATE VIEW v1 (vcol1) AS SELECT col1 FROM t1;
CREATE VIEW v2 (vcol1) AS SELECT col1 FROM t1 WHERE col2 > 2;
-- error 1364
@@ -1860,7 +1862,9 @@
#
# Test for bug #11771: wrong query_id in SELECT * FROM <view>
#
+--disable_warnings
CREATE TABLE t1 (f1 char) ENGINE = innodb;
+--enable_warnings
INSERT INTO t1 VALUES ('A');
CREATE VIEW v1 AS SELECT * FROM t1;
--- 1.21/sql/examples/ha_tina.cc 2005-11-07 18:24:36 +03:00
+++ 1.22/sql/examples/ha_tina.cc 2005-11-09 15:14:56 +03:00
@@ -95,11 +95,15 @@
*****************************************************************************/
/*
- Used for sorting chains.
+ Used for sorting chains with qsort().
*/
int sort_set (tina_set *a, tina_set *b)
{
- return ( a->begin > b->begin ? 1 : ( a->begin < b->begin ? -1 : 0 ) );
+ /*
+ We assume that intervals do not intersect. So, it is enought to compare
+ any two points. Here we take start of intervals for comparison.
+ */
+ return ( a->begin > b->begin ? -1 : ( a->begin < b->begin ? 1 : 0 ) );
}
static byte* tina_get_key(TINA_SHARE *share,uint *length,
@@ -200,7 +204,8 @@
thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
- if ((share->data_file= my_open(data_file_name, O_RDWR, MYF(0))) == -1)
+ if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND,
+ MYF(0))) == -1)
goto error2;
/*
@@ -836,14 +841,8 @@
(qsort_cmp)sort_set);
for (ptr= chain; ptr < chain_ptr; ptr++)
{
- /* We peek a head to see if this is the last chain */
- if (ptr+1 == chain_ptr)
- memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end,
- length - (size_t)ptr->end);
- else
- memmove((caddr_t)share->mapped_file + ptr->begin,
- (caddr_t)share->mapped_file + ptr->end,
- (size_t)((ptr++)->begin - ptr->end));
+ memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end,
+ length - (size_t)ptr->end);
length= length - (size_t)(ptr->end - ptr->begin);
}
--- 1.153/sql/sql_prepare.cc 2005-11-07 18:24:44 +03:00
+++ 1.154/sql/sql_prepare.cc 2005-11-09 15:12:05 +03:00
@@ -2111,8 +2111,6 @@
were closed in the end of previous prepare or execute call.
*/
tables->table= 0;
- if (tables->nested_join)
- tables->nested_join->counter= 0;
if (tables->prep_on_expr)
{
| Thread |
|---|
| • bk commit into 5.1 tree (petr:1.1950) | Petr Chardin | 9 Nov |