~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to debian/patches/46_CVE-2007-1420_subselect_dos.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-02 16:10:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070402161053-zkil9hjq9k5p1uzv
Tags: 5.0.37-0ubuntu1
* New upstream bugfix release.
  - Fixes replication failure with auto-increment and on duplicate key
    update, a regression introduced into 5.0.24. (LP: #95821)
* debian/control: Set Ubuntu maintainer.
* debian/rules: Change comments from 'Debian etch' to 'Ubuntu 7.04'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## 46_CVE-2007-1420_subselect_dos.dpatch by  <seanius@debian.org>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: No description.
6
 
 
7
 
@DPATCH@
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
11
 
@@ -928,7 +928,8 @@
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))
20
 
 
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
24
 
@@ -1472,7 +1472,7 @@
25
 
 
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))
30
 
   {
31
 
     DBUG_VOID_RETURN;
32
 
   }
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))
39
 
     goto err;
40
 
 
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 @@
46
 
   SYNOPSIS
47
 
     get_schema_tables_result()
48
 
     join  join which use schema tables
49
 
+    executed_place place where I_S table processed
50
 
 
51
 
   RETURN
52
 
     FALSE success
53
 
     TRUE  error
54
 
 */
55
 
 
56
 
-bool get_schema_tables_result(JOIN *join)
57
 
+bool get_schema_tables_result(JOIN *join,
58
 
+                              enum enum_schema_table_state executed_place)
59
 
 {
60
 
   JOIN_TAB *tmp_join_tab= join->join_tab+join->tables;
61
 
   THD *thd= join->thd;
62
 
@@ -3965,14 +3967,24 @@
63
 
       bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&
64
 
                           lex->current_select->master_unit()->item);
65
 
       /*
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.
76
 
       */
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))
80
 
         continue;
81
 
 
82
 
-      if (is_subselect) // is subselect
83
 
+      /*
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.
87
 
+      */
88
 
+      if (table_list->schema_table_state && is_subselect)
89
 
       {
90
 
         table_list->table->file->extra(HA_EXTRA_RESET_STATE);
91
 
         table_list->table->file->delete_all_rows();
92
 
@@ -3988,10 +4000,10 @@
93
 
       {
94
 
         result= 1;
95
 
         join->error= 1;
96
 
-        table_list->is_schema_table_processed= TRUE;
97
 
+        table_list->schema_table_state= executed_place;
98
 
         break;
99
 
       }
100
 
-      table_list->is_schema_table_processed= TRUE;
101
 
+      table_list->schema_table_state= executed_place;
102
 
     }
103
 
   }
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 @@
109
 
   */
110
 
   table= 0;
111
 
   /* Reset is_schema_table_processed value(needed for I_S tables */
112
 
-  is_schema_table_processed= FALSE;
113
 
+  schema_table_state= NOT_PROCESSED;
114
 
 
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
120
 
@@ -288,6 +288,12 @@
121
 
   void reset_item_list(List<Item> *item_list) const;
122
 
 };
123
 
 
124
 
+enum enum_schema_table_state
125
 
+{ 
126
 
+  NOT_PROCESSED= 0,
127
 
+  PROCESSED_BY_CREATE_SORT_INDEX,
128
 
+  PROCESSED_BY_JOIN_EXEC
129
 
+};
130
 
 
131
 
 typedef struct st_foreign_key_info
132
 
 {
133
 
@@ -530,7 +536,6 @@
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;
138
 
   /*
139
 
     True when the view field translation table is used to convert
140
 
     schema table fields for backwards compatibility with SHOW command.
141
 
@@ -639,6 +644,7 @@
142
 
   */
143
 
   bool          prelocking_placeholder;
144
 
 
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);