1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 46_CVE-2007-1420_subselect_dos.dpatch by <seanius@debian.org>
4
## All lines beginning with `## DP:' are a description of the patch.
8
diff -urNad mysql-dfsg-5.0-5.0.32~/sql/mysql_priv.h mysql-dfsg-5.0-5.0.32/sql/mysql_priv.h
9
--- mysql-dfsg-5.0-5.0.32~/sql/mysql_priv.h 2006-12-20 12:14:48.000000000 +0100
10
+++ mysql-dfsg-5.0-5.0.32/sql/mysql_priv.h 2007-03-14 20:13:29.000000000 +0100
12
int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
13
int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
14
int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
15
-bool get_schema_tables_result(JOIN *join);
16
+bool get_schema_tables_result(JOIN *join,
17
+ enum enum_schema_table_state executed_place);
18
#define is_schema_db(X) \
19
!my_strcasecmp(system_charset_info, information_schema_name.str, (X))
21
diff -urNad mysql-dfsg-5.0-5.0.32~/sql/sql_select.cc mysql-dfsg-5.0-5.0.32/sql/sql_select.cc
22
--- mysql-dfsg-5.0-5.0.32~/sql/sql_select.cc 2006-12-20 12:14:03.000000000 +0100
23
+++ mysql-dfsg-5.0-5.0.32/sql/sql_select.cc 2007-03-14 20:13:29.000000000 +0100
26
if ((curr_join->select_lex->options & OPTION_SCHEMA_TABLE) &&
27
!thd->lex->describe &&
28
- get_schema_tables_result(curr_join))
29
+ get_schema_tables_result(curr_join, PROCESSED_BY_JOIN_EXEC))
33
@@ -12278,7 +12278,7 @@
34
/* Fill schema tables with data before filesort if it's necessary */
35
if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
36
!thd->lex->describe &&
37
- get_schema_tables_result(join))
38
+ get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX))
41
if (table->s->tmp_table)
42
diff -urNad mysql-dfsg-5.0-5.0.32~/sql/sql_show.cc mysql-dfsg-5.0-5.0.32/sql/sql_show.cc
43
--- mysql-dfsg-5.0-5.0.32~/sql/sql_show.cc 2006-12-20 12:14:31.000000000 +0100
44
+++ mysql-dfsg-5.0-5.0.32/sql/sql_show.cc 2007-03-14 20:13:29.000000000 +0100
45
@@ -3939,13 +3939,15 @@
47
get_schema_tables_result()
48
join join which use schema tables
49
+ executed_place place where I_S table processed
56
-bool get_schema_tables_result(JOIN *join)
57
+bool get_schema_tables_result(JOIN *join,
58
+ enum enum_schema_table_state executed_place)
60
JOIN_TAB *tmp_join_tab= join->join_tab+join->tables;
62
@@ -3965,14 +3967,24 @@
63
bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&
64
lex->current_select->master_unit()->item);
66
- The schema table is already processed and
67
- the statement is not a subselect.
68
- So we don't need to handle this table again.
69
+ If schema table is already processed and
70
+ the statement is not a subselect then
71
+ we don't need to fill this table again.
72
+ If schema table is already processed and
73
+ schema_table_state != executed_place then
74
+ table is already processed and
75
+ we should skip second data processing.
77
- if (table_list->is_schema_table_processed && !is_subselect)
78
+ if (table_list->schema_table_state &&
79
+ (!is_subselect || table_list->schema_table_state != executed_place))
82
- if (is_subselect) // is subselect
84
+ if table is used in a subselect and
85
+ table has been processed earlier with the same
86
+ 'executed_place' value then we should refresh the table.
88
+ if (table_list->schema_table_state && is_subselect)
90
table_list->table->file->extra(HA_EXTRA_RESET_STATE);
91
table_list->table->file->delete_all_rows();
92
@@ -3988,10 +4000,10 @@
96
- table_list->is_schema_table_processed= TRUE;
97
+ table_list->schema_table_state= executed_place;
100
- table_list->is_schema_table_processed= TRUE;
101
+ table_list->schema_table_state= executed_place;
104
thd->no_warnings_for_error= 0;
105
diff -urNad mysql-dfsg-5.0-5.0.32~/sql/table.cc mysql-dfsg-5.0-5.0.32/sql/table.cc
106
--- mysql-dfsg-5.0-5.0.32~/sql/table.cc 2006-12-20 12:14:17.000000000 +0100
107
+++ mysql-dfsg-5.0-5.0.32/sql/table.cc 2007-03-14 20:13:29.000000000 +0100
108
@@ -3029,7 +3029,7 @@
111
/* Reset is_schema_table_processed value(needed for I_S tables */
112
- is_schema_table_processed= FALSE;
113
+ schema_table_state= NOT_PROCESSED;
115
TABLE_LIST *embedded; /* The table at the current level of nesting. */
116
TABLE_LIST *embedding= this; /* The parent nested table reference. */
117
diff -urNad mysql-dfsg-5.0-5.0.32~/sql/table.h mysql-dfsg-5.0-5.0.32/sql/table.h
118
--- mysql-dfsg-5.0-5.0.32~/sql/table.h 2006-12-20 12:14:27.000000000 +0100
119
+++ mysql-dfsg-5.0-5.0.32/sql/table.h 2007-03-14 20:13:29.000000000 +0100
121
void reset_item_list(List<Item> *item_list) const;
124
+enum enum_schema_table_state
127
+ PROCESSED_BY_CREATE_SORT_INDEX,
128
+ PROCESSED_BY_JOIN_EXEC
131
typedef struct st_foreign_key_info
134
st_select_lex_unit *derived; /* SELECT_LEX_UNIT of derived table */
135
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
136
st_select_lex *schema_select_lex;
137
- bool is_schema_table_processed;
139
True when the view field translation table is used to convert
140
schema table fields for backwards compatibility with SHOW command.
143
bool prelocking_placeholder;
145
+ enum enum_schema_table_state schema_table_state;
146
void calc_md5(char *buffer);
147
void set_underlying_merge();
148
int view_check_option(THD *thd, bool ignore_failure);