Merge lp:~ubuntu-43/undrop-for-innodb/pierre into lp:undrop-for-innodb
- pierre
- Merge into trunk
Proposed by
Aleksandr Kuzminsky
Status: | Merged |
---|---|
Merged at revision: | 33 |
Proposed branch: | lp:~ubuntu-43/undrop-for-innodb/pierre |
Merge into: | lp:undrop-for-innodb |
Diff against target: |
303 lines (+73/-36) (has conflicts) 3 files modified
Makefile (+10/-6) c_parser.c (+45/-25) print_data.c (+18/-5) Text conflict in c_parser.c Text conflict in print_data.c |
To merge this branch: | bzr merge lp:~ubuntu-43/undrop-for-innodb/pierre |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aleksandr Kuzminsky | Approve | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile' |
2 | --- Makefile 2014-09-03 23:24:55 +0000 |
3 | +++ Makefile 2014-10-19 02:20:41 +0000 |
4 | @@ -3,19 +3,23 @@ |
5 | SRCS = stream_parser.c include/mysql_def.h c_parser.c |
6 | INC_PATH = -I./include |
7 | LIBS = -pthread -lm |
8 | +BINDIR = ./bin |
9 | |
10 | CC ?= gcc |
11 | +INSTALL ?=install |
12 | YACC = bison |
13 | LEX = flex |
14 | |
15 | -CFLAGS += -g -O3 |
16 | +CFLAGS += -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe -fomit-frame-pointer -march=k8 |
17 | +#LDFLAGS=-static |
18 | +INSTALLFLAGS ?=-s |
19 | CentOS5 = $(findstring .el5,$(shell cat /proc/version)) |
20 | ifeq ($(CentOS5), .el5) |
21 | CFLAGS += -DCentOS5 |
22 | endif |
23 | |
24 | all: $(TARGETS) |
25 | - |
26 | + |
27 | debug: LEX_DEBUG = -d |
28 | debug: YACC_DEBUG = -r all |
29 | debug: CFLAGS += -DDEBUG -DSTREAM_PARSER_DEBUG |
30 | @@ -25,7 +29,7 @@ |
31 | $(CC) $(CFLAGS) $(INC_PATH) -c $< |
32 | |
33 | stream_parser: stream_parser.o |
34 | - $(CC) $(CFLAGS) $(INC_PATH) $(LIB_PATH) $(LIBS) $< -o $@ |
35 | + $(CC) $(CFLAGS) $(INC_PATH) $(LIB_PATH) $(LIBS) $(LDFLAGS) $< -o $@ |
36 | |
37 | sql_parser.o: sql_parser.c |
38 | $(CC) $(CFLAGS) $(INC_PATH) -c $< |
39 | @@ -49,17 +53,17 @@ |
40 | $(CC) $(CFLAGS) $(INC_PATH) -c $< |
41 | |
42 | c_parser: sql_parser.o c_parser.o tables_dict.o print_data.o check_data.o |
43 | - $(CC) $(CFLAGS) $(INC_PATH) $(LIB_PATH) $^ -o $@ $(LIBS) |
44 | + $(CC) $(CFLAGS) $(LDFLAGS) $(INC_PATH) $(LIB_PATH) $^ -o $@ $(LIBS) |
45 | |
46 | innochecksum_changer: innochecksum.c include/innochecksum.h |
47 | - $(CC) $(CFLAGS) $(INC_PATH) -o $@ $< |
48 | + $(CC) $(CFLAGS) $(LDFLAGS) $(INC_PATH) -o $@ $< |
49 | |
50 | sys_parser: sys_parser.c |
51 | @ which mysql_config || (echo "sys_parser needs mysql development package( either -devel or -dev)"; exit -1) |
52 | $(CC) `mysql_config --cflags` `mysql_config --libs` -o $@ $< |
53 | |
54 | install: $(TARGETS) |
55 | - $(INSTALL) $(INSTALLFLAGS) $(TARGETS) $(BINDIR)/$(TARGETS) |
56 | + $(INSTALL) $(INSTALLFLAGS) $(TARGETS) $(BINDIR) |
57 | |
58 | clean: |
59 | rm -f $(OBJECTS) $(TARGETS) lex.yy.c sql_parser.c sql_parser.output sys_parser |
60 | |
61 | === modified file 'c_parser.c' |
62 | --- c_parser.c 2014-10-07 22:51:39 +0000 |
63 | +++ c_parser.c 2014-10-19 02:20:41 +0000 |
64 | @@ -89,12 +89,13 @@ |
65 | int use_filter_id = 0; |
66 | |
67 | FILE* f_result; |
68 | +FILE* f_sql; |
69 | |
70 | extern int load_table(char*); |
71 | |
72 | inline void error(char *msg) { |
73 | - printf("Error: %s\n", msg); |
74 | - exit(1); |
75 | + fprintf(stderr, "Error: %s\n", msg); |
76 | + exit(1); |
77 | } |
78 | |
79 | |
80 | @@ -612,7 +613,7 @@ |
81 | } |
82 | fprintf(f_result, ", Records list: %s", is_page_valid? "Valid": "Invalid"); |
83 | expected_records_inheader = mach_read_from_2(page + PAGE_HEADER + PAGE_N_RECS); |
84 | - fprintf(f_result, ", Expected records: (%u %lu)", expected_records, expected_records_inheader); |
85 | + fprintf(f_result, ", Expected records: (%u %u)", expected_records, expected_records_inheader); |
86 | fprintf(f_result, "\n"); |
87 | if (debug) printf("Starting offset: %lu (%lX). Checking %d table definitions.\n", offset, offset, table_definitions_cnt); |
88 | |
89 | @@ -692,8 +693,8 @@ |
90 | while ((read_bytes = read(fn, page, UNIV_PAGE_SIZE)) == UNIV_PAGE_SIZE) { |
91 | pos = lseek(fn, 0, SEEK_CUR); |
92 | |
93 | - if (pos % (UNIV_PAGE_SIZE * 10) == 0) { |
94 | - fprintf(stderr, "-- %.2f%% done\n", 100.0 * pos / st.st_size); |
95 | + if (pos % (UNIV_PAGE_SIZE * 512) == 0) { |
96 | + fprintf(f_sql, "-- %.2f%% done\n", 100.0 * pos / st.st_size); |
97 | } |
98 | |
99 | if (deleted_pages_only) { |
100 | @@ -746,6 +747,7 @@ |
101 | " -f <InnoDB page(s)> -- InnoDB page or directory with pages(all pages should have same index_id)\n" |
102 | " -t <table.sql> -- CREATE statement of a table\n" |
103 | " -o <file> -- Save dump in this file. Otherwise print to stdout\n" |
104 | + " -l <file> -- Save SQL statements in this file. Otherwise print to stderr\n" |
105 | " -h -- Print this help\n" |
106 | " -d -- Process only those pages which potentially could have deleted records (default = NO)\n" |
107 | " -D -- Recover deleted rows only (default = NO)\n" |
108 | @@ -770,12 +772,19 @@ |
109 | struct stat st; |
110 | char src[256] = ""; |
111 | |
112 | - char buffer[16*1024]; |
113 | + char buffer[BUFSIZ]; |
114 | setvbuf(stdout, buffer, _IOFBF, sizeof(buffer)); |
115 | |
116 | f_result = stdout; |
117 | + f_sql = stderr; |
118 | char result_file[1024]; |
119 | +<<<<<<< TREE |
120 | while ((ch = getopt(argc, argv, "t:456hdDUVf:T:b:p:o:i:")) != -1) { |
121 | +======= |
122 | + char sql_file[1024]; |
123 | + |
124 | + while ((ch = getopt(argc, argv, "t:456hdDUVf:T:b:p:o:l:")) != -1) { |
125 | +>>>>>>> MERGE-SOURCE |
126 | switch (ch) { |
127 | case 'd': |
128 | deleted_pages_only = 1; |
129 | @@ -794,10 +803,21 @@ |
130 | exit(-1); |
131 | } |
132 | break; |
133 | +<<<<<<< TREE |
134 | case 'i': |
135 | strncpy(path_ibdata, optarg, sizeof(path_ibdata)); |
136 | external_in_ibdata = 1; |
137 | break; |
138 | +======= |
139 | + case 'l': |
140 | + strncpy(sql_file, optarg, sizeof(sql_file)); |
141 | + if(NULL == (f_sql = fopen(sql_file, "w"))){ |
142 | + fprintf(stderr, "Can't open file %s for writing\n", sql_file); |
143 | + exit(-1); |
144 | + } |
145 | + break; |
146 | + |
147 | +>>>>>>> MERGE-SOURCE |
148 | case 't': |
149 | if(load_table(optarg) != 0){ |
150 | fprintf(stderr, "Failed to parse table structure\n"); |
151 | @@ -882,63 +902,63 @@ |
152 | close(fn); |
153 | } |
154 | table_def_t *table = &(table_definitions[0]); |
155 | - fprintf(stderr, "SET FOREIGN_KEY_CHECKS=0;\n"); |
156 | - fprintf(stderr, "LOAD DATA LOCAL INFILE '"); |
157 | + fprintf(f_sql, "SET FOREIGN_KEY_CHECKS=0;\n"); |
158 | + fprintf(f_sql, "LOAD DATA LOCAL INFILE '"); |
159 | if(f_result == stdout){ |
160 | - fprintf(stderr, "%s/dumps/%s/%s", getenv("PWD"), dump_prefix, table->name); |
161 | + fprintf(f_sql, "%s/dumps/%s/%s", getenv("PWD"), dump_prefix, table->name); |
162 | } |
163 | else{ |
164 | - fprintf(stderr, "%s", result_file); |
165 | + fprintf(f_sql, "%s", result_file); |
166 | } |
167 | - fprintf(stderr, "' REPLACE INTO TABLE `%s` FIELDS TERMINATED BY '\\t' OPTIONALLY ENCLOSED BY '\"' LINES STARTING BY '%s\\t' ", table->name, table->name); |
168 | + fprintf(f_sql, "' REPLACE INTO TABLE `%s` FIELDS TERMINATED BY '\\t' OPTIONALLY ENCLOSED BY '\"' LINES STARTING BY '%s\\t' ", table->name, table->name); |
169 | int i = 0; |
170 | int comma = 0; |
171 | int has_set = 0; |
172 | - fprintf(stderr, "("); |
173 | + fprintf(f_sql, "("); |
174 | for(i = 0; i < table->fields_count; i++) { |
175 | if(table->fields[i].type == FT_INTERNAL) continue; |
176 | - if(comma) fprintf(stderr, ", "); |
177 | + if(comma) fprintf(f_sql, ", "); |
178 | switch(table->fields[i].type){ |
179 | case FT_BLOB: |
180 | case FT_BIN: |
181 | - fprintf(stderr, "@var_%s", table->fields[i].name); |
182 | + fprintf(f_sql, "@var_%s", table->fields[i].name); |
183 | has_set = 1; |
184 | break; |
185 | case FT_BIT: |
186 | - fprintf(stderr, "@var_%s", table->fields[i].name); |
187 | + fprintf(f_sql, "@var_%s", table->fields[i].name); |
188 | has_set = 1; |
189 | break; |
190 | default: |
191 | - fprintf(stderr, "`%s`", table->fields[i].name); |
192 | + fprintf(f_sql, "`%s`", table->fields[i].name); |
193 | } |
194 | comma = 1; |
195 | } |
196 | - fprintf(stderr, ")"); |
197 | + fprintf(f_sql, ")"); |
198 | comma = 0; |
199 | if(has_set){ |
200 | - fprintf(stderr, "\nSET\n"); |
201 | + fprintf(f_sql, "\nSET\n"); |
202 | for(i = 0; i < table->fields_count; i++) { |
203 | if(table->fields[i].type == FT_INTERNAL) continue; |
204 | switch(table->fields[i].type){ |
205 | case FT_BLOB: |
206 | case FT_BIN: |
207 | - if(comma) fprintf(stderr, ",\n"); |
208 | - fprintf(stderr, " %s = UNHEX(@var_%s)", table->fields[i].name, table->fields[i].name); |
209 | + if(comma) fprintf(f_sql, ",\n"); |
210 | + fprintf(f_sql, " %s = UNHEX(@var_%s)", table->fields[i].name, table->fields[i].name); |
211 | comma = 1; |
212 | break; |
213 | case FT_BIT: |
214 | - if(comma) fprintf(stderr, ",\n"); |
215 | - fprintf(stderr, " %s = CAST(@var_%s AS UNSIGNED)", table->fields[i].name, table->fields[i].name); |
216 | + if(comma) fprintf(f_sql, ",\n"); |
217 | + fprintf(f_sql, " %s = CAST(@var_%s AS UNSIGNED)", table->fields[i].name, table->fields[i].name); |
218 | comma = 1; |
219 | break; |
220 | default: break; |
221 | } |
222 | } |
223 | } |
224 | - fprintf(stderr, ";\n"); |
225 | + fprintf(f_sql, ";\n"); |
226 | if (!process_compact && !process_redundant) { |
227 | - printf("Error: Please, specify what format your datafile in. Use -4 for mysql 4.1 and below and -5 for 5.X+\n"); |
228 | - usage(); |
229 | + fprintf(stderr,"Error: Please, specify what format your datafile in. Use -4 for mysql 4.1 and below and -5 for 5.X+\n"); |
230 | + usage(); |
231 | } |
232 | |
233 | return 0; |
234 | |
235 | === modified file 'print_data.c' |
236 | --- print_data.c 2014-10-08 00:15:51 +0000 |
237 | +++ print_data.c 2014-10-19 02:20:41 +0000 |
238 | @@ -112,11 +112,19 @@ |
239 | void print_string_raw(char *value, ulint len) { |
240 | ulint i; |
241 | for(i = 0; i < len; i++) { |
242 | +<<<<<<< TREE |
243 | if (value[i] == '"') fprintf(f_result, "\\\""); |
244 | else if (value[i] == '\n') fprintf(f_result, "\\n"); |
245 | else if (value[i] == '\r') fprintf(f_result, "\\r"); |
246 | else fprintf(f_result, "%c", value[i]); |
247 | } |
248 | +======= |
249 | + if (value[i] == '"') fprintf(f_result,"\\\""); |
250 | + else if (value[i] == '\n') fprintf(f_result,"\\n"); |
251 | + else if (value[i] == '\r') fprintf(f_result,"\\r"); |
252 | + else fprintf(f_result, "%c", value[i]); |
253 | + } |
254 | +>>>>>>> MERGE-SOURCE |
255 | } |
256 | |
257 | void print_hex(char *value, ulint len) { |
258 | @@ -196,10 +204,8 @@ |
259 | |
260 | /*******************************************************************/ |
261 | inline void print_set(int value, field_def_t *field) { |
262 | - int i; |
263 | - int comma = 0; |
264 | - fprintf(f_result, "%d", value); |
265 | - /* |
266 | + /* int i; |
267 | + int comma = 0 |
268 | fprintf(f_result, "\""); |
269 | for(i=0; i<field->limits.set_values_count; i++){ |
270 | if(((value>>i) % 2) == 1){ |
271 | @@ -210,6 +216,7 @@ |
272 | } |
273 | fprintf(f_result, "\""); |
274 | */ |
275 | + fprintf(f_result, "%d", value); |
276 | } |
277 | |
278 | /*******************************************************************/ |
279 | @@ -336,7 +343,7 @@ |
280 | |
281 | /*******************************************************************/ |
282 | inline void print_field_value(byte *value, ulint len, field_def_t *field) { |
283 | - time_t t; |
284 | + /* time_t t;*/ |
285 | |
286 | switch (field->type) { |
287 | case FT_INTERNAL: |
288 | @@ -481,9 +488,15 @@ |
289 | if (len_sum >= extern_len) |
290 | break; |
291 | } else { |
292 | +<<<<<<< TREE |
293 | fprintf(stderr, "-- #####CannotOpen_%s;\n", tmp); |
294 | perror("-- print_field_value_with_external(): open()"); |
295 | break; |
296 | +======= |
297 | + fprintf(stderr, "-- #####CannotOpen_%s;\n", tmp); |
298 | + perror("External page:"); |
299 | + break; |
300 | +>>>>>>> MERGE-SOURCE |
301 | } |
302 | } |
303 | if (field->type == FT_TEXT) { |
conflicts fixed