summaryrefslogtreecommitdiff
blob: 7f1d4318560f60f428474950fea917ed39173b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
diff -r c3e57b0c22c4 patch_info/show_patches.info
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patch_info/show_patches.info	Mon Dec 22 00:25:06 2008 -0800
@@ -0,0 +1,6 @@
+File=show_patches.patch
+Name=SHOW PATCHES
+Version=1.0
+Author=Jeremy Cole
+License=N/A
+Comment
diff -r c3e57b0c22c4 sql/Makefile.am
--- a/sql/Makefile.am	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/Makefile.am	Mon Dec 22 00:25:06 2008 -0800
@@ -118,7 +118,7 @@
 			-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
 			@DEFS@
 
-BUILT_SOURCES =		sql_yacc.cc sql_yacc.h lex_hash.h
+BUILT_SOURCES =		sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
 EXTRA_DIST =		$(BUILT_SOURCES) nt_servc.cc nt_servc.h \
 			message.mc message.h message.rc MSG00001.bin \
 			examples/CMakeLists.txt CMakeLists.txt \
@@ -175,6 +175,8 @@
 udf_example_la_SOURCES= udf_example.c
 udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
 
+patch_info.h: patch_info.h.pl
+	$(PERL) $< > $@
 
 # Don't update the files from bitkeeper
 %::SCCS/s.%
diff -r c3e57b0c22c4 sql/Makefile.in
--- a/sql/Makefile.in	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/Makefile.in	Mon Dec 22 00:25:06 2008 -0800
@@ -561,7 +561,7 @@
 gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
 mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
 mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
-BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
 EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
 			message.mc message.h message.rc MSG00001.bin \
 			examples/CMakeLists.txt CMakeLists.txt \
@@ -1237,6 +1237,9 @@
 		./gen_lex_hash$(EXEEXT) > $@-t
 		$(MV) $@-t $@
 
+patch_info.h: patch_info.h.pl
+	$(PERL) $< > $@
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff -r c3e57b0c22c4 sql/lex.h
--- a/sql/lex.h	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/lex.h	Mon Dec 22 00:25:06 2008 -0800
@@ -367,6 +367,7 @@
   { "PACK_KEYS",	SYM(PACK_KEYS_SYM)},
   { "PARTIAL",		SYM(PARTIAL)},
   { "PASSWORD",		SYM(PASSWORD)},
+  { "PATCHES",		SYM(PATCHES)},
   { "PHASE",            SYM(PHASE_SYM)},
   { "POINT",		SYM(POINT_SYM)},
   { "POLYGON",		SYM(POLYGON)},
diff -r c3e57b0c22c4 sql/mysql_priv.h
--- a/sql/mysql_priv.h	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/mysql_priv.h	Mon Dec 22 00:25:06 2008 -0800
@@ -968,6 +968,7 @@
 int mysqld_show_status(THD *thd);
 int mysqld_show_variables(THD *thd,const char *wild);
 bool mysqld_show_storage_engines(THD *thd);
+bool mysqld_show_patches(THD *thd);
 bool mysqld_show_privileges(THD *thd);
 bool mysqld_show_column_types(THD *thd);
 bool mysqld_help (THD *thd, const char *text);
diff -r c3e57b0c22c4 sql/patch_info.h.pl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sql/patch_info.h.pl	Mon Dec 22 00:25:06 2008 -0800
@@ -0,0 +1,65 @@
+use strict;
+
+my $patch_info_path = '../patch_info';
+my $file = '';
+my $output = '';
+
+
+if (opendir(PATCH_DIR, $patch_info_path))
+{
+	while ((my $file = readdir(PATCH_DIR)))
+	{
+		open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
+		my %fields;
+	
+		if ($file =~ /^\./)
+		{
+			next;
+		}	
+	
+		while (<PATCH_FILE>)
+		{
+			chomp;
+	
+			my ($key, $value) = split(/\s*=\s*/);
+			$fields{lc($key)} = $value;
+		}
+	
+		$output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
+	}
+}	
+
+print <<HEADER;
+
+/* Copyright (C) 2002-2006 MySQL AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifdef USE_PRAGMA_INTERFACE
+#pragma interface			/* gcc class implementation */
+#endif
+
+struct patch {
+	const char *file;
+	const char *name;
+	const char *version;
+	const char *author;
+	const char *license;
+	const char *comment;
+}patches[] = {
+$output
+{NULL, NULL, NULL, NULL}
+};	
+
+HEADER
diff -r c3e57b0c22c4 sql/sp_head.cc
--- a/sql/sp_head.cc	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/sp_head.cc	Mon Dec 22 00:25:06 2008 -0800
@@ -191,6 +191,7 @@
   case SQLCOM_SHOW_MUTEX_STATUS:
   case SQLCOM_SHOW_NEW_MASTER:
   case SQLCOM_SHOW_OPEN_TABLES:
+  case SQLCOM_SHOW_PATCHES:
   case SQLCOM_SHOW_PRIVILEGES:
   case SQLCOM_SHOW_PROCESSLIST:
   case SQLCOM_SHOW_SLAVE_HOSTS:
diff -r c3e57b0c22c4 sql/sql_lex.h
--- a/sql/sql_lex.h	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/sql_lex.h	Mon Dec 22 00:25:06 2008 -0800
@@ -95,6 +95,7 @@
   SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
   SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
   SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
+  SQLCOM_SHOW_PATCHES,
 
   /*
     When a command is added here, be sure it's also added in mysqld.cc
diff -r c3e57b0c22c4 sql/sql_parse.cc
--- a/sql/sql_parse.cc	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/sql_parse.cc	Mon Dec 22 00:25:06 2008 -0800
@@ -3947,6 +3947,9 @@
     break;
   case SQLCOM_SHOW_STORAGE_ENGINES:
     res= mysqld_show_storage_engines(thd);
+    break;
+  case SQLCOM_SHOW_PATCHES:
+    res= mysqld_show_patches(thd);
     break;
   case SQLCOM_SHOW_PRIVILEGES:
     res= mysqld_show_privileges(thd);
diff -r c3e57b0c22c4 sql/sql_prepare.cc
--- a/sql/sql_prepare.cc	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/sql_prepare.cc	Mon Dec 22 00:25:06 2008 -0800
@@ -1790,6 +1790,7 @@
   case SQLCOM_SHOW_DATABASES:
   case SQLCOM_SHOW_PROCESSLIST:
   case SQLCOM_SHOW_STORAGE_ENGINES:
+  case SQLCOM_SHOW_PATCHES:
   case SQLCOM_SHOW_PRIVILEGES:
   case SQLCOM_SHOW_COLUMN_TYPES:
   case SQLCOM_SHOW_STATUS:
diff -r c3e57b0c22c4 sql/sql_show.cc
--- a/sql/sql_show.cc	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/sql_show.cc	Mon Dec 22 00:25:06 2008 -0800
@@ -22,6 +22,7 @@
 #include "sp.h"
 #include "sp_head.h"
 #include "sql_trigger.h"
+#include "patch_info.h"
 #include <my_dir.h>
 
 #ifdef HAVE_BERKELEY_DB
@@ -45,6 +46,47 @@
 static int
 view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
 bool schema_table_store_record(THD *thd, TABLE *table);
+
+/***************************************************************************
+** List patches built into this release
+***************************************************************************/
+
+bool mysqld_show_patches(THD *thd)
+{
+  List<Item> field_list;
+	int i = 0;
+  Protocol *protocol= thd->protocol;
+  DBUG_ENTER("mysqld_show_patches");
+
+  field_list.push_back(new Item_empty_string("File", 255));
+  field_list.push_back(new Item_empty_string("Name", 50));
+  field_list.push_back(new Item_empty_string("Version", 10));
+  field_list.push_back(new Item_empty_string("Author", 50));
+  field_list.push_back(new Item_empty_string("License", 50));
+  field_list.push_back(new Item_empty_string("Comment", 32));
+
+  if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
+    DBUG_RETURN(TRUE);
+
+	for (i = 0; patches[i].file; i++)
+	{
+	  protocol->prepare_for_resend();
+  	protocol->store(patches[i].file, system_charset_info);
+  	protocol->store(patches[i].name, system_charset_info);
+  	protocol->store(patches[i].version, system_charset_info);
+  	protocol->store(patches[i].author, system_charset_info);
+  	protocol->store(patches[i].license, system_charset_info);
+  	protocol->store(patches[i].comment, system_charset_info);
+
+  	if (protocol->write())
+    	DBUG_RETURN(TRUE);
+	}	
+
+   
+  send_eof(thd);
+  DBUG_RETURN(FALSE);
+
+}
 
 
 /***************************************************************************
diff -r c3e57b0c22c4 sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	Mon Dec 22 00:20:06 2008 -0800
+++ b/sql/sql_yacc.yy	Mon Dec 22 00:25:06 2008 -0800
@@ -824,6 +824,7 @@
 %token  PAGE_SYM
 %token  PARTIAL
 %token  PASSWORD
+%token  PATCHES
 %token  PARAM_MARKER
 %token  PHASE_SYM
 %token  POINTFROMTEXT
@@ -8019,7 +8020,7 @@
 	;
 
 show_param:
-         DATABASES wild_and_where
+        DATABASES wild_and_where
          {
            LEX *lex= Lex;
            lex->sql_command= SQLCOM_SELECT;
@@ -8119,6 +8120,10 @@
 	    LEX *lex=Lex;
 	    lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
 	    WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
+	  }
+	| PATCHES
+	  {
+	    Lex->sql_command= SQLCOM_SHOW_PATCHES;
 	  }
 	| opt_storage ENGINES_SYM
 	  {
@@ -9554,6 +9559,7 @@
 	| PAGE_SYM              {}
 	| PARTIAL		{}
 	| PASSWORD		{}
+	| PATCHES {}
         | PHASE_SYM             {}
 	| POINT_SYM		{}
 	| POLYGON		{}