~tsarev/percona-server/5.5_percona_server_variables_fix_bug_785566

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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# name       : innodb_files_extend.patch
# introduced : 11 or before
# maintainer : Yasufumi
#
#!!! notice !!!
# Any small change to this file in the main branch
# should be done or reviewed by the maintainer!
diff -ruN a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c
--- a/storage/innobase/fil/fil0fil.c	2010-12-04 15:55:21.358513751 +0900
+++ b/storage/innobase/fil/fil0fil.c	2010-12-04 15:55:58.243481131 +0900
@@ -731,7 +731,7 @@
 		ut_a(space->purpose != FIL_LOG);
 		ut_a(!trx_sys_sys_space(space->id));
 
-		if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
+		if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
 			fprintf(stderr,
 				"InnoDB: Error: the size of single-table"
 				" tablespace file %s\n"
@@ -4151,7 +4151,7 @@
 
 	size = (((ib_int64_t)size_high) << 32) + (ib_int64_t)size_low;
 #ifndef UNIV_HOTBACKUP
-	if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
+	if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
 		fprintf(stderr,
 			"InnoDB: Error: the size of single-table tablespace"
 			" file %s\n"
@@ -4171,7 +4171,7 @@
 	/* Align the memory for file i/o if we might have O_DIRECT set */
 	page = ut_align(buf2, UNIV_PAGE_SIZE);
 
-	if (size >= FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
+	if (size >= FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
 		success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
 
 		/* We have to read the tablespace id from the file */
@@ -5149,9 +5149,9 @@
 	ut_ad(ut_is_2pow(zip_size));
 	ut_ad(buf);
 	ut_ad(len > 0);
-#if (1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE
-# error "(1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE"
-#endif
+//#if (1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE
+//# error "(1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE"
+//#endif
 	ut_ad(fil_validate_skip());
 #ifndef UNIV_HOTBACKUP
 # ifndef UNIV_LOG_DEBUG
diff -ruN a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c
--- a/storage/innobase/fsp/fsp0fsp.c	2010-12-04 15:52:23.411513754 +0900
+++ b/storage/innobase/fsp/fsp0fsp.c	2010-12-04 15:55:58.244514273 +0900
@@ -656,16 +656,18 @@
 				0 for uncompressed pages */
 	ulint	offset)		/*!< in: page offset */
 {
-#ifndef DOXYGEN /* Doxygen gets confused of these */
-# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET \
-		+ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
-#  error
-# endif
-# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET \
-		+ (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
-#  error
-# endif
-#endif /* !DOXYGEN */
+//#ifndef DOXYGEN /* Doxygen gets confused of these */
+//# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET
+//		+ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
+//#  error
+//# endif
+//# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET
+//		+ (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
+//#  error
+//# endif
+//#endif /* !DOXYGEN */
+	ut_a(UNIV_PAGE_SIZE > XDES_ARR_OFFSET + (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE);
+	ut_a(PAGE_ZIP_MIN_SIZE > XDES_ARR_OFFSET + (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE);
 	ut_ad(ut_is_2pow(zip_size));
 
 	if (!zip_size) {
@@ -1464,12 +1466,12 @@
 							   mtr);
 		xdes_init(descr, mtr);
 
-#if UNIV_PAGE_SIZE % FSP_EXTENT_SIZE
-# error "UNIV_PAGE_SIZE % FSP_EXTENT_SIZE != 0"
-#endif
-#if PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE
-# error "PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE != 0"
-#endif
+//#if UNIV_PAGE_SIZE % FSP_EXTENT_SIZE
+//# error "UNIV_PAGE_SIZE % FSP_EXTENT_SIZE != 0"
+//#endif
+//#if PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE
+//# error "PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE != 0"
+//#endif
 
 		if (UNIV_UNLIKELY(init_xdes)) {
 
diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
--- a/storage/innobase/handler/ha_innodb.cc	2010-12-04 15:55:21.367482924 +0900
+++ b/storage/innobase/handler/ha_innodb.cc	2010-12-04 15:55:58.248549631 +0900
@@ -148,6 +148,9 @@
 static ulong innobase_write_io_threads;
 static long innobase_buffer_pool_instances = 1;
 
+static ulong innobase_page_size;
+static ulong innobase_log_block_size;
+
 static my_bool innobase_thread_concurrency_timer_based;
 static long long innobase_buffer_pool_size, innobase_log_file_size;
 
@@ -2316,6 +2319,65 @@
 	}
 #endif /* DBUG_OFF */
 
+	srv_page_size = 0;
+	srv_page_size_shift = 0;
+
+	if (innobase_page_size != (1 << 14)) {
+		uint n_shift;
+
+		fprintf(stderr,
+			"InnoDB: Warning: innodb_page_size has been changed from default value 16384. (###EXPERIMENTAL### operation)\n");
+		for (n_shift = 12; n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX; n_shift++) {
+			if (innobase_page_size == ((ulong)1 << n_shift)) {
+				srv_page_size_shift = n_shift;
+				srv_page_size = (1 << srv_page_size_shift);
+				fprintf(stderr,
+					"InnoDB: The universal page size of the database is set to %lu.\n",
+					srv_page_size);
+				break;
+			}
+		}
+	} else {
+		srv_page_size_shift = 14;
+		srv_page_size = (1 << srv_page_size_shift);
+	}
+
+	if (!srv_page_size_shift) {
+		fprintf(stderr,
+			"InnoDB: Error: %lu is not a valid value for innodb_page_size.\n"
+			"InnoDB: Error: Valid values are 4096, 8192, and 16384 (default=16384).\n",
+			innobase_page_size);
+		goto error;
+	}
+
+	srv_log_block_size = 0;
+	if (innobase_log_block_size != (1 << 9)) { /*!=512*/
+		uint	n_shift;
+
+		fprintf(stderr,
+			"InnoDB: Warning: innodb_log_block_size has been changed from default value 512. (###EXPERIMENTAL### operation)\n");
+		for (n_shift = 9; n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX; n_shift++) {
+			if (innobase_log_block_size == ((ulong)1 << n_shift)) {
+				srv_log_block_size = (1 << n_shift);
+				fprintf(stderr,
+					"InnoDB: The log block size is set to %lu.\n",
+					srv_log_block_size);
+				break;
+			}
+		}
+	} else {
+		srv_log_block_size = 512;
+	}
+
+	if (!srv_log_block_size) {
+		fprintf(stderr,
+			"InnoDB: Error: %lu is not a valid value for innodb_log_block_size.\n"
+			"InnoDB: Error: A valid value for innodb_log_block_size is\n"
+			"InnoDB: Error: a power of 2 from 512 to 16384.\n",
+			innobase_log_block_size);
+		goto error;
+	}
+
 #ifndef MYSQL_SERVER
 	innodb_overwrite_relay_log_info = FALSE;
 #endif
@@ -7241,9 +7303,9 @@
 				| DICT_TF_COMPACT
 				| DICT_TF_FORMAT_ZIP
 				<< DICT_TF_FORMAT_SHIFT;
-#if DICT_TF_ZSSIZE_MAX < 1
-# error "DICT_TF_ZSSIZE_MAX < 1"
-#endif
+//#if DICT_TF_ZSSIZE_MAX < 1
+//# error "DICT_TF_ZSSIZE_MAX < 1"
+//#endif
 		}
 	}
 
@@ -11432,6 +11494,16 @@
   "#### Attention: The checksum is not compatible for normal or disabled version! ####",
   NULL, NULL, FALSE);
 
+static MYSQL_SYSVAR_ULONG(page_size, innobase_page_size,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "###EXPERIMENTAL###: The universal page size of the database. Changing for created database is not supported. Use on your own risk!",
+  NULL, NULL, (1 << 14), (1 << 12), (1 << UNIV_PAGE_SIZE_SHIFT_MAX), 0);
+
+static MYSQL_SYSVAR_ULONG(log_block_size, innobase_log_block_size,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "###EXPERIMENTAL###: The log block size of the transaction log file. Changing for created log file is not supported. Use on your own risk!",
+  NULL, NULL, (1 << 9)/*512*/, (1 << 9)/*512*/, (1 << UNIV_PAGE_SIZE_SHIFT_MAX), 0);
+
 static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
   PLUGIN_VAR_READONLY,
   "The common part for InnoDB table spaces.",
@@ -11936,6 +12008,8 @@
   NULL, NULL, 0, &corrupt_table_action_typelib);
 
 static struct st_mysql_sys_var* innobase_system_variables[]= {
+  MYSQL_SYSVAR(page_size),
+  MYSQL_SYSVAR(log_block_size),
   MYSQL_SYSVAR(additional_mem_pool_size),
   MYSQL_SYSVAR(autoextend_increment),
   MYSQL_SYSVAR(buffer_pool_size),
diff -ruN a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
--- a/storage/innobase/include/buf0buf.h	2010-12-04 15:55:21.375482937 +0900
+++ b/storage/innobase/include/buf0buf.h	2010-12-04 15:55:58.258469088 +0900
@@ -1683,7 +1683,7 @@
 	time_t		last_printout_time;
 					/*!< when buf_print_io was last time
 					called */
-	buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES + 1];
+	buf_buddy_stat_t buddy_stat[BUF_BUDDY_SIZES_MAX + 1];
 					/*!< Statistics of buddy system,
 					indexed by block size */
 	buf_pool_stat_t	stat;		/*!< current statistics */
@@ -1779,7 +1779,7 @@
 	/* @{ */
 	UT_LIST_BASE_NODE_T(buf_page_t)	zip_clean;
 					/*!< unmodified compressed pages */
-	UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES];
+	UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES_MAX];
 					/*!< buddy free lists */
 
 	buf_page_t			watch[BUF_POOL_WATCH_SIZE];
@@ -1787,9 +1787,9 @@
 					pool watches. Protected by
 				       	buf_pool->mutex. */
 
-#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
-# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
-#endif
+//#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
+//# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
+//#endif
 #if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
 # error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
 #endif
diff -ruN a/storage/innobase/include/buf0types.h b/storage/innobase/include/buf0types.h
--- a/storage/innobase/include/buf0types.h	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/include/buf0types.h	2010-12-04 15:55:58.259482590 +0900
@@ -72,12 +72,13 @@
 					buddy system; must be at least
 					sizeof(buf_page_t) */
 #define BUF_BUDDY_SIZES		(UNIV_PAGE_SIZE_SHIFT - BUF_BUDDY_LOW_SHIFT)
+#define BUF_BUDDY_SIZES_MAX	(UNIV_PAGE_SIZE_SHIFT_MAX - BUF_BUDDY_LOW_SHIFT)
 					/*!< number of buddy sizes */
 
 /** twice the maximum block size of the buddy system;
 the underlying memory is aligned by this amount:
 this must be equal to UNIV_PAGE_SIZE */
-#define BUF_BUDDY_HIGH	(BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
+#define BUF_BUDDY_HIGH	((ulint)BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
 /* @} */
 
 #endif
diff -ruN a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h
--- a/storage/innobase/include/fsp0types.h	2010-12-04 02:58:26.000000000 +0900
+++ b/storage/innobase/include/fsp0types.h	2011-02-03 15:14:21.000000000 +0900
@@ -42,7 +42,7 @@
 /* @} */
 
 /** File space extent size (one megabyte) in pages */
-#define	FSP_EXTENT_SIZE		(1 << (20 - UNIV_PAGE_SIZE_SHIFT))
+#define	FSP_EXTENT_SIZE		((ulint)1 << (20 - UNIV_PAGE_SIZE_SHIFT))
 
 /** On a page of any file segment, data may be put starting from this
 offset */
diff -ruN a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h
--- a/storage/innobase/include/log0log.h	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/include/log0log.h	2010-12-09 18:16:47.737728305 +0900
@@ -672,6 +672,9 @@
 					when mysqld is first time started
 					on the restored database, it can
 					print helpful info for the user */
+#define LOG_FILE_OS_FILE_LOG_BLOCK_SIZE 64
+					/* extend to record log_block_size
+					of XtraDB. 0 means default 512 */
 #define	LOG_FILE_ARCH_COMPLETED	OS_FILE_LOG_BLOCK_SIZE
 					/* this 4-byte field is TRUE when
 					the writing of an archived log file
diff -ruN a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic
--- a/storage/innobase/include/mtr0log.ic	2010-12-04 15:37:50.590551517 +0900
+++ b/storage/innobase/include/mtr0log.ic	2010-12-04 15:55:58.260482404 +0900
@@ -203,7 +203,7 @@
 	system tablespace */
 	if ((space == TRX_SYS_SPACE
 	     || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE))
-	    && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) {
+	    && offset >= (ulint)FSP_EXTENT_SIZE && offset < 3 * (ulint)FSP_EXTENT_SIZE) {
 		if (trx_doublewrite_buf_is_being_created) {
 			/* Do nothing: we only come to this branch in an
 			InnoDB database creation. We do not redo log
diff -ruN a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
--- a/storage/innobase/include/os0file.h	2010-12-09 18:16:02.323727427 +0900
+++ b/storage/innobase/include/os0file.h	2010-12-09 18:16:47.738694194 +0900
@@ -101,7 +101,7 @@
 if this fails for a log block, then it is equivalent to a media failure in the
 log. */
 
-#define OS_FILE_LOG_BLOCK_SIZE		512
+#define OS_FILE_LOG_BLOCK_SIZE		srv_log_block_size
 
 /** Options for file_create @{ */
 #define	OS_FILE_OPEN			51
@@ -190,6 +190,8 @@
 extern ulint	os_n_file_writes;
 extern ulint	os_n_fsyncs;
 
+extern ulint	srv_log_block_size;
+
 #ifdef UNIV_PFS_IO
 /* Keys to register InnoDB I/O with performance schema */
 extern mysql_pfs_key_t	innodb_file_data_key;
diff -ruN a/storage/innobase/include/page0types.h b/storage/innobase/include/page0types.h
--- a/storage/innobase/include/page0types.h	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/include/page0types.h	2010-12-04 15:55:58.261483930 +0900
@@ -56,8 +56,9 @@
 
 /** Number of supported compressed page sizes */
 #define PAGE_ZIP_NUM_SSIZE (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 2)
-#if PAGE_ZIP_NUM_SSIZE > (1 << PAGE_ZIP_SSIZE_BITS)
-# error "PAGE_ZIP_NUM_SSIZE > (1 << PAGE_ZIP_SSIZE_BITS)"
+#define PAGE_ZIP_NUM_SSIZE_MAX (UNIV_PAGE_SIZE_SHIFT_MAX - PAGE_ZIP_MIN_SIZE_SHIFT + 2)
+#if PAGE_ZIP_NUM_SSIZE_MAX > (1 << PAGE_ZIP_SSIZE_BITS)
+# error "PAGE_ZIP_NUM_SSIZE_MAX > (1 << PAGE_ZIP_SSIZE_BITS)"
 #endif
 
 /** Compressed page descriptor */
@@ -98,7 +99,7 @@
 typedef struct page_zip_stat_struct page_zip_stat_t;
 
 /** Statistics on compression, indexed by page_zip_des_struct::ssize - 1 */
-extern page_zip_stat_t page_zip_stat[PAGE_ZIP_NUM_SSIZE - 1];
+extern page_zip_stat_t page_zip_stat[PAGE_ZIP_NUM_SSIZE_MAX - 1];
 
 /**********************************************************************//**
 Write the "deleted" flag of a record on a compressed page.  The flag must
diff -ruN a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h
--- a/storage/innobase/include/trx0sys.h	2010-12-04 15:37:50.593480594 +0900
+++ b/storage/innobase/include/trx0sys.h	2010-12-04 15:55:58.262549554 +0900
@@ -515,9 +515,9 @@
 /** Contents of TRX_SYS_MYSQL_LOG_MAGIC_N_FLD */
 #define TRX_SYS_MYSQL_LOG_MAGIC_N	873422344
 
-#if UNIV_PAGE_SIZE < 4096
-# error "UNIV_PAGE_SIZE < 4096"
-#endif
+//#if UNIV_PAGE_SIZE < 4096
+//# error "UNIV_PAGE_SIZE < 4096"
+//#endif
 /** The offset of the MySQL replication info in the trx system header;
 this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */
 #define TRX_SYS_MYSQL_MASTER_LOG_INFO	(UNIV_PAGE_SIZE - 2000)
diff -ruN a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
--- a/storage/innobase/include/univ.i	2010-11-03 07:01:13.000000000 +0900
+++ b/storage/innobase/include/univ.i	2010-12-04 15:55:58.263549721 +0900
@@ -311,9 +311,13 @@
 */
 
 /* The 2-logarithm of UNIV_PAGE_SIZE: */
-#define UNIV_PAGE_SIZE_SHIFT	14
+/* #define UNIV_PAGE_SIZE_SHIFT	14 */
+#define UNIV_PAGE_SIZE_SHIFT_MAX	14
+#define UNIV_PAGE_SIZE_SHIFT	srv_page_size_shift
 /* The universal page size of the database */
-#define UNIV_PAGE_SIZE		(1 << UNIV_PAGE_SIZE_SHIFT)
+/* #define UNIV_PAGE_SIZE		(1 << UNIV_PAGE_SIZE_SHIFT) */
+#define UNIV_PAGE_SIZE		srv_page_size
+#define UNIV_PAGE_SIZE_MAX	(1 << UNIV_PAGE_SIZE_SHIFT_MAX)
 
 /* Maximum number of parallel threads in a parallelized operation */
 #define UNIV_MAX_PARALLELISM	32
@@ -432,7 +436,7 @@
 stored part of the field in the tablespace. The length field then
 contains the sum of the following flag and the locally stored len. */
 
-#define UNIV_EXTERN_STORAGE_FIELD (UNIV_SQL_NULL - UNIV_PAGE_SIZE)
+#define UNIV_EXTERN_STORAGE_FIELD (UNIV_SQL_NULL - UNIV_PAGE_SIZE_MAX)
 
 /* Some macros to improve branch prediction and reduce cache misses */
 #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER)
@@ -535,4 +539,6 @@
 	UNIV_MEM_ALLOC(addr, size);			\
 } while (0)
 
+extern ulint	srv_page_size_shift;
+extern ulint	srv_page_size;
 #endif
diff -ruN a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c
--- a/storage/innobase/log/log0log.c	2010-12-03 15:18:48.899986203 +0900
+++ b/storage/innobase/log/log0log.c	2010-12-04 15:55:58.266551567 +0900
@@ -604,7 +604,9 @@
 
 	offset = (gr_lsn_size_offset + difference) % group_size;
 
+	if (sizeof(ulint) == 4) {
 	ut_a(offset < (((ib_int64_t) 1) << 32)); /* offset must be < 4 GB */
+	}
 
 	/* fprintf(stderr,
 	"Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
@@ -1201,6 +1203,9 @@
 	/* Wipe over possible label of ibbackup --restore */
 	memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, "    ", 4);
 
+	mach_write_to_4(buf + LOG_FILE_OS_FILE_LOG_BLOCK_SIZE,
+			srv_log_block_size);
+
 	dest_offset = nth_file * group->file_size;
 
 #ifdef UNIV_DEBUG
@@ -1794,9 +1799,7 @@
 	ulint		i;
 
 	ut_ad(mutex_own(&(log_sys->mutex)));
-#if LOG_CHECKPOINT_SIZE > OS_FILE_LOG_BLOCK_SIZE
-# error "LOG_CHECKPOINT_SIZE > OS_FILE_LOG_BLOCK_SIZE"
-#endif
+	ut_a(LOG_CHECKPOINT_SIZE <= OS_FILE_LOG_BLOCK_SIZE);
 
 	buf = group->checkpoint_buf;
 
@@ -1810,6 +1813,7 @@
 	mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, log_sys->buf_size);
 
 #ifdef UNIV_LOG_ARCHIVE
+#error "UNIV_LOG_ARCHIVE could not be enabled"
 	if (log_sys->archiving_state == LOG_ARCH_OFF) {
 		archived_lsn = IB_ULONGLONG_MAX;
 	} else {
@@ -1823,7 +1827,9 @@
 
 	mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
 #else /* UNIV_LOG_ARCHIVE */
-	mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
+	mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN,
+			(ib_uint64_t)log_group_calc_lsn_offset(
+				log_sys->next_checkpoint_lsn, group));
 #endif /* UNIV_LOG_ARCHIVE */
 
 	for (i = 0; i < LOG_MAX_N_GROUPS; i++) {
diff -ruN a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c
--- a/storage/innobase/log/log0recv.c	2010-12-03 17:32:15.638986405 +0900
+++ b/storage/innobase/log/log0recv.c	2010-12-04 15:55:58.269550689 +0900
@@ -712,8 +712,22 @@
 
 			group->lsn = mach_read_from_8(
 				buf + LOG_CHECKPOINT_LSN);
+
+#ifdef UNIV_LOG_ARCHIVE
+#error "UNIV_LOG_ARCHIVE could not be enabled"
+#endif
+			{
+			ib_uint64_t tmp_lsn_offset = mach_read_from_8(
+					buf + LOG_CHECKPOINT_ARCHIVED_LSN);
+				if (sizeof(ulint) != 4
+				    && tmp_lsn_offset != IB_ULONGLONG_MAX) {
+					group->lsn_offset = (ulint) tmp_lsn_offset;
+				} else {
 			group->lsn_offset = mach_read_from_4(
 				buf + LOG_CHECKPOINT_OFFSET);
+				}
+			}
+
 			checkpoint_no = mach_read_from_8(
 				buf + LOG_CHECKPOINT_NO);
 
@@ -2955,6 +2969,7 @@
 	log_group_t*	max_cp_group;
 	log_group_t*	up_to_date_group;
 	ulint		max_cp_field;
+	ulint		log_hdr_log_block_size;
 	ib_uint64_t	checkpoint_lsn;
 	ib_uint64_t	checkpoint_no;
 	ib_uint64_t	old_scanned_lsn;
@@ -3056,6 +3071,21 @@
 		       log_hdr_buf, max_cp_group);
 	}
 
+	log_hdr_log_block_size
+		= mach_read_from_4(log_hdr_buf + LOG_FILE_OS_FILE_LOG_BLOCK_SIZE);
+	if (log_hdr_log_block_size == 0) {
+		/* 0 means default value */
+		log_hdr_log_block_size = 512;
+	}
+	if (log_hdr_log_block_size != srv_log_block_size) {
+		fprintf(stderr,
+			"InnoDB: Error: The block size of ib_logfile (%lu) "
+			"is not equal to innodb_log_block_size.\n"
+			"InnoDB: Error: Suggestion - Recreate log files.\n",
+			log_hdr_log_block_size);
+		return(DB_ERROR);
+	}
+
 #ifdef UNIV_LOG_ARCHIVE
 	group = UT_LIST_GET_FIRST(log_sys->log_groups);
 
diff -ruN a/storage/innobase/page/page0zip.c b/storage/innobase/page/page0zip.c
--- a/storage/innobase/page/page0zip.c	2010-12-04 15:52:23.484482786 +0900
+++ b/storage/innobase/page/page0zip.c	2010-12-04 15:55:58.274551431 +0900
@@ -49,7 +49,7 @@
 
 #ifndef UNIV_HOTBACKUP
 /** Statistics on compression, indexed by page_zip_des_t::ssize - 1 */
-UNIV_INTERN page_zip_stat_t page_zip_stat[PAGE_ZIP_NUM_SSIZE - 1];
+UNIV_INTERN page_zip_stat_t page_zip_stat[PAGE_ZIP_NUM_SSIZE_MAX - 1];
 #endif /* !UNIV_HOTBACKUP */
 
 /* Please refer to ../include/page0zip.ic for a description of the
diff -ruN a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c
--- a/storage/innobase/row/row0merge.c	2010-12-04 15:52:23.490513562 +0900
+++ b/storage/innobase/row/row0merge.c	2010-12-04 15:55:58.277550562 +0900
@@ -97,7 +97,7 @@
 row_merge_block_t.  Thus, it must be able to hold one merge record,
 whose maximum size is the same as the minimum size of
 row_merge_block_t. */
-typedef byte	mrec_buf_t[UNIV_PAGE_SIZE];
+typedef byte	mrec_buf_t[UNIV_PAGE_SIZE_MAX];
 
 /** @brief Merge record in row_merge_block_t.
 
diff -ruN a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
--- a/storage/innobase/srv/srv0srv.c	2010-12-04 15:55:21.384486344 +0900
+++ b/storage/innobase/srv/srv0srv.c	2010-12-04 15:55:58.282550845 +0900
@@ -234,6 +234,13 @@
 UNIV_INTERN ulint	srv_n_read_io_threads	= ULINT_MAX;
 UNIV_INTERN ulint	srv_n_write_io_threads	= ULINT_MAX;
 
+/* The universal page size of the database */
+UNIV_INTERN ulint	srv_page_size_shift	= 0;
+UNIV_INTERN ulint	srv_page_size		= 0;
+
+/* The log block size */
+UNIV_INTERN ulint	srv_log_block_size	= 0;
+
 /* User settable value of the number of pages that must be present
 in the buffer cache and accessed sequentially for InnoDB to trigger a
 readahead request. */
diff -ruN a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c
--- a/storage/innobase/srv/srv0start.c	2010-12-04 15:52:23.502513556 +0900
+++ b/storage/innobase/srv/srv0start.c	2010-12-04 15:55:58.285550583 +0900
@@ -1561,11 +1561,13 @@
 	}
 #endif /* UNIV_LOG_ARCHIVE */
 
-	if (srv_n_log_files * srv_log_file_size >= 262144) {
+	if (sizeof(ulint) == 4
+	    && srv_n_log_files * srv_log_file_size
+	       >= ((ulint)1 << (32 - UNIV_PAGE_SIZE_SHIFT))) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
 			" InnoDB: Error: combined size of log files"
-			" must be < 4 GB\n");
+			" must be < 4 GB on 32-bit systems\n");
 
 		return(DB_ERROR);
 	}
@@ -1574,7 +1576,7 @@
 
 	for (i = 0; i < srv_n_data_files; i++) {
 #ifndef __WIN__
-		if (sizeof(off_t) < 5 && srv_data_file_sizes[i] >= 262144) {
+		if (sizeof(off_t) < 5 && srv_data_file_sizes[i] >= ((ulint)1 << (32 - UNIV_PAGE_SIZE_SHIFT))) {
 			ut_print_timestamp(stderr);
 			fprintf(stderr,
 				" InnoDB: Error: file size must be < 4 GB"