Commit db32cb17 authored by unknown's avatar unknown
Browse files

InnoDB: Keep the "compact format" flag in SYS_TABLES.N_COLS

instead of SYS_TABLES.MIX_LEN, because the latter was not
initialized to zero in old MySQL 3.23 releases. This will break
existing MySQL/InnoDB 5.0.3-bk databases for which
SHOW TABLE STATUS displays Row_format=Compact.


innobase/dict/dict0crea.c:
  Write the "compact format" flag to N_COLS instead of MIX_LEN.
  Remove corruption analysis for MIX_LEN, as it has been tracked down
  to MySQL 3.23.4x not initializing MIX_LEN.
innobase/dict/dict0load.c:
  Read the "compact format" flag from N_COLS instead of MIX_LEN.
parent 380c64b1
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -63,8 +63,8 @@ dict_create_sys_tables_tuple(
	dfield = dtuple_get_nth_field(entry, 2);

	ptr = mem_heap_alloc(heap, 4);
	mach_write_to_4(ptr, table->n_def);

	mach_write_to_4(ptr, table->n_def
			| ((ulint) table->comp << 31));
	dfield_set_data(dfield, ptr, 4);
	/* 5: TYPE -----------------------------*/
	dfield = dtuple_get_nth_field(entry, 3);
@@ -82,21 +82,10 @@ dict_create_sys_tables_tuple(
	dfield_set_data(dfield, ptr, 8);
	/* 7: MIX_LEN --------------------------*/

	/* Track corruption reported on mailing list Jan 14, 2005 */
	if (table->mix_len != 0 && table->mix_len != 0x80000000) {
		fprintf(stderr,
"InnoDB: Error: mix_len is %lu in table %s\n", (ulong)table->mix_len,
							table->name);
		mem_analyze_corruption((byte*)&(table->mix_len));
	
		ut_error;
	}

	dfield = dtuple_get_nth_field(entry, 5);

	ptr = mem_heap_alloc(heap, 4);
	mach_write_to_4(ptr, (table->mix_len & 0x7fffffff) |
			((ulint) table->comp << 31));
	mach_write_to_4(ptr, table->mix_len);

	dfield_set_data(dfield, ptr, 4);
	/* 8: CLUSTER_NAME ---------------------*/
+7 −7
Original line number Diff line number Diff line
@@ -818,8 +818,10 @@ dict_load_table(
	field = rec_get_nth_field_old(rec, 4, &len);
	n_cols = mach_read_from_4(field);

	/* table->comp will be initialized later, in this function */
	table = dict_mem_table_create(name, space, n_cols, FALSE);
	/* The high-order bit of N_COLS is the "compact format" flag. */
	table = dict_mem_table_create(name, space,
					n_cols & ~0x80000000UL,
					!!(n_cols & 0x80000000UL));

	table->ibd_file_missing = ibd_file_missing;

@@ -844,14 +846,12 @@ dict_load_table(
#endif
	}

	/* The high-order bit of MIX_LEN is the "compact format" flag */
	field = rec_get_nth_field_old(rec, 7, &len);
	table->comp = !!(mach_read_from_1(field) & 0x80);

	if ((table->type == DICT_TABLE_CLUSTER)
	    || (table->type == DICT_TABLE_CLUSTER_MEMBER)) {

		table->mix_len = mach_read_from_4(field) & 0x7fffffff;
		field = rec_get_nth_field_old(rec, 7, &len);
		ut_a(len == 4);
		table->mix_len = mach_read_from_4(field);
	}

	btr_pcur_close(&pcur);