Commit a418a35c authored by unknown's avatar unknown
Browse files

InnoDB: quote identifiers according to MySQL settings (Bug #5292)


innobase/btr/btr0btr.c:
  Add parameter to ut_print_name() and dict_index_name_print() calls
innobase/btr/btr0cur.c:
  Add parameter to dict_index_name_print() calls
innobase/buf/buf0buf.c:
  Add parameter to dict_index_name_print() calls
innobase/dict/dict0crea.c:
  Add parameter to ut_print_name() calls
innobase/dict/dict0dict.c:
  Add parameter to ut_print_name() calls
  Update documentation links to http://dev.mysql.com
innobase/dict/dict0load.c:
  Add parameter to ut_print_name() calls
innobase/fil/fil0fil.c:
  Use ut_print_filename()
  Update links to documentation to http://dev.mysql.com
innobase/ibuf/ibuf0ibuf.c:
  Replaced printf(...) with fprintf(stderr,...)
innobase/include/dict0dict.h:
  Added trx parameters
innobase/include/row0row.h:
  Added trx parameter
innobase/include/row0sel.h:
  Added trx parameter
innobase/include/row0upd.h:
  Added trx parameters
innobase/include/row0upd.ic:
  Added trx parameter for dict_index_name_print()
innobase/include/trx0rec.h:
  Added trx parameter
innobase/include/ut0ut.h:
  Added ut_print_filename()
  Added trx parameter to ut_print_name() and ut_print_namel()
innobase/lock/lock0lock.c:
  Added parameter to dict_index_name_print() and ut_print_name() calls
innobase/page/page0page.c:
  Added parameter to dict_index_name_print() calls
innobase/pars/pars0opt.c:
  Added parameter to dict_index_name_print() call
innobase/pars/pars0pars.c:
  Added parameter to upd_field_set_field_no() call
innobase/row/row0ins.c:
  Added trx parameters
innobase/row/row0mysql.c:
  Added trx parameters
innobase/row/row0purge.c:
  Added trx parameter
innobase/row/row0row.c:
  Added trx parameter
innobase/row/row0sel.c:
  Added trx parameters
innobase/row/row0umod.c:
  Added trx parameters
innobase/row/row0upd.c:
  Added trx parameters
innobase/trx/trx0rec.c:
  Added trx parameters
innobase/trx/trx0roll.c:
  Added parameter to ut_print_name() calls
innobase/ut/ut0ut.c:
  Added ut_print_filename()
  Added trx parameter to ut_print_namel() and ut_print_name() calls
sql/ha_innodb.cc:
  Added trx parameters
  Rewrote mysql_get_identifier_quote_char()
sql/mysql_priv.h:
  Added get_quote_char_for_identifier()
sql/sql_show.cc:
  Added get_quote_char_for_identifier()
  Removed append_quoted_simple_identifier()
  Make append_identifier() use get_quote_char_for_identifier()
parent 927179ec
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -595,10 +595,10 @@ btr_page_get_father_for_rec(
		buf_page_print(buf_frame_align(node_ptr));

		fputs("InnoDB: Corruption of an index tree: table ", stderr);
		ut_print_name(stderr,
		ut_print_name(stderr, NULL,
			UT_LIST_GET_FIRST(tree->tree_indexes)->table_name);
		fputs(", index ", stderr);
		ut_print_name(stderr,
		ut_print_name(stderr, NULL,
			UT_LIST_GET_FIRST(tree->tree_indexes)->name);
		fprintf(stderr, ",\n"
"InnoDB: father ptr page no %lu, child page no %lu\n",
@@ -2341,7 +2341,7 @@ btr_index_rec_validate_report(
	dict_index_t*	index)	/* in: index */
{
	fputs("InnoDB: Record in ", stderr);
	dict_index_name_print(stderr, index);
	dict_index_name_print(stderr, NULL, index);
	fprintf(stderr, ", page %lu, at offset %lu\n",
		buf_frame_get_page_no(page), (ulint)(rec - page));
}
@@ -2479,7 +2479,7 @@ btr_validate_report1(
{
	fprintf(stderr, "InnoDB: Error in page %lu of ",
		buf_frame_get_page_no(page));
	dict_index_name_print(stderr, index);
	dict_index_name_print(stderr, NULL, index);
	if (level) {
		fprintf(stderr, ", index tree level %lu", level);
	}
@@ -2500,7 +2500,7 @@ btr_validate_report2(
	fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ",
		buf_frame_get_page_no(page1),
		buf_frame_get_page_no(page2));
	dict_index_name_print(stderr, index);
	dict_index_name_print(stderr, NULL, index);
	if (level) {
		fprintf(stderr, ", index tree level %lu", level);
	}
+4 −4
Original line number Diff line number Diff line
@@ -839,7 +839,7 @@ static
void
btr_cur_trx_report(
/*===============*/
	const trx_t*		trx,	/* in: transaction */
	trx_t*			trx,	/* in: transaction */
	const dict_index_t*	index,	/* in: index */
	const char*		op)	/* in: operation */
{
@@ -847,7 +847,7 @@ btr_cur_trx_report(
		ut_dulint_get_high(trx->id),
		ut_dulint_get_low(trx->id));
	fputs(op, stderr);
	dict_index_name_print(stderr, index);
	dict_index_name_print(stderr, trx, index);
	putc('\n', stderr);
}

@@ -899,7 +899,7 @@ btr_cur_optimistic_insert(

	if (!dtuple_check_typed_no_assert(entry)) {
		fputs("InnoDB: Error in a tuple to insert into ", stderr);
		dict_index_name_print(stderr, index);
		dict_index_name_print(stderr, thr_get_trx(thr), index);
	}
	
	if (btr_cur_print_record_ops && thr) {
@@ -1001,7 +1001,7 @@ btr_cur_optimistic_insert(
			fputs("InnoDB: Error: cannot insert tuple ", stderr);
			dtuple_print(stderr, entry);
			fputs(" into ", stderr);
			dict_index_name_print(stderr, index);
			dict_index_name_print(stderr, thr_get_trx(thr), index);
			fprintf(stderr, "\nInnoDB: max insert size %lu\n",
				(ulong) max_size);
			ut_error;
+2 −2
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ buf_page_print(
					btr_page_get_index_id(read_buf));
		        if (index) {
				fputs("InnoDB: (", stderr);
				dict_index_name_print(stderr, index);
				dict_index_name_print(stderr, NULL, index);
				fputs(")\n", stderr);
			}
		}
@@ -2123,7 +2123,7 @@ buf_print(void)

		if (index) {
			putc(' ', stderr);
			dict_index_name_print(stderr, index);
			dict_index_name_print(stderr, NULL, index);
		}

		putc('\n', stderr);
+7 −4
Original line number Diff line number Diff line
@@ -501,11 +501,14 @@ dict_build_index_def_step(
	dict_table_t*	table;
	dict_index_t*	index;
	dtuple_t*	row;
	trx_t*		trx;

#ifdef UNIV_SYNC_DEBUG
	ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */

	trx = thr_get_trx(thr);

	index = node->index;

	table = dict_table_get_low(index->table_name);
@@ -514,7 +517,7 @@ dict_build_index_def_step(
		return(DB_TABLE_NOT_FOUND);
	}

	thr_get_trx(thr)->table_id = table->id;
	trx->table_id = table->id;

	node->table = table;

@@ -1264,9 +1267,9 @@ dict_create_add_foreigns_to_dictionary(
		ut_print_timestamp(ef);
		fputs(" Error in foreign key constraint creation for table ",
			ef);
		ut_print_name(ef, table->name);
		ut_print_name(ef, trx, table->name);
		fputs(".\nA foreign key constraint of name ", ef);
		ut_print_name(ef, foreign->id);
		ut_print_name(ef, trx, foreign->id);
		fputs("\nalready exists."
			"  (Note that internally InnoDB adds 'databasename/'\n"
			"in front of the user-defined constraint name).\n",
@@ -1286,7 +1289,7 @@ dict_create_add_foreigns_to_dictionary(
		ut_print_timestamp(ef);
		fputs(" Internal error in foreign key constraint creation"
			" for table ", ef);
		ut_print_name(ef, table->name);
		ut_print_name(ef, trx, table->name);
		fputs(".\n"
	"See the MySQL .err log in the datadir for more information.\n", ef);
		mutex_exit(&dict_foreign_err_mutex);
+47 −49
Original line number Diff line number Diff line
@@ -2085,14 +2085,14 @@ Report an error in a foreign key definition. */
static
void
dict_foreign_error_report_low(
/*==========================*/
	FILE*		file,	/* in: output stream */
	const char*	name)	/* in: table name */
{
	rewind(file);
	ut_print_timestamp(file);
	fputs(" Error in foreign key constraint of table ", file);
	ut_print_name(file, name);
	fputs(":\n", file);
	fprintf(file, " Error in foreign key constraint of table %s:\n",
		name);
}

/**************************************************************************
@@ -2100,6 +2100,7 @@ Report an error in a foreign key definition. */
static
void
dict_foreign_error_report(
/*======================*/
	FILE*		file,	/* in: output stream */
	dict_foreign_t*	fk,	/* in: foreign key constraint */
	const char*	msg)	/* in: the error message */
@@ -2108,10 +2109,10 @@ dict_foreign_error_report(
	dict_foreign_error_report_low(file, fk->foreign_table_name);
	fputs(msg, file);
	fputs(" Constraint:\n", file);
	dict_print_info_on_foreign_key_in_create_format(file, fk);
	dict_print_info_on_foreign_key_in_create_format(file, NULL, fk);
	if (fk->foreign_index) {
		fputs("\nThe index in the foreign key in table is ", file);
		ut_print_name(file, fk->foreign_index->name);
		ut_print_name(file, NULL, fk->foreign_index->name);
		fputs(
"See http://www.innodb.com/ibman.php for correct foreign key definition.\n",
		file);
@@ -2946,7 +2947,7 @@ dict_create_foreign_constraints_low(
		mutex_enter(&dict_foreign_err_mutex);
		dict_foreign_error_report_low(ef, name);
		fputs("There is no index in table ", ef);
		ut_print_name(ef, name);
		ut_print_name(ef, NULL, name);
		fprintf(ef, " where the columns appear\n"
"as the first columns. Constraint:\n%s\n"
"See http://www.innodb.com/ibman.php for correct foreign key definition.\n",
@@ -3389,12 +3390,12 @@ dict_foreign_parse_drop_constraints(
		ut_print_timestamp(ef);
		fputs(
	" Error in dropping of a foreign key constraint of table ", ef);
		ut_print_name(ef, table->name);
		ut_print_name(ef, NULL, table->name);
		fputs(",\n"
			"in SQL command\n", ef);
		fputs(str, ef);
		fputs("\nCannot find a constraint with the given id ", ef);
		ut_print_name(ef, id);
		ut_print_name(ef, NULL, id);
		fputs(".\n", ef);
		mutex_exit(&dict_foreign_err_mutex);

@@ -3411,7 +3412,7 @@ dict_foreign_parse_drop_constraints(
	ut_print_timestamp(ef);
	fputs(
	" Syntax error in dropping of a foreign key constraint of table ", ef);
	ut_print_name(ef, table->name);
	ut_print_name(ef, NULL, table->name);
	fprintf(ef, ",\n"
		"close to:\n%s\n in SQL command\n%s\n", ptr, str);
	mutex_exit(&dict_foreign_err_mutex);
@@ -3819,8 +3820,10 @@ dict_update_statistics_low(
		ut_print_timestamp(stderr);
		fprintf(stderr,
			"  InnoDB: cannot calculate statistics for table %s\n"
"InnoDB: because the .ibd file is missing. See section 15.1 of\n"
"InnoDB: http:/www.innodb.com/ibman.html for help\n", table->name);
"InnoDB: because the .ibd file is missing.  For help, please refer to\n"
"InnoDB: "
"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n",
			table->name);

		return;
	}
@@ -3906,25 +3909,19 @@ dict_foreign_print_low(
	ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */

	fputs("  FOREIGN KEY CONSTRAINT ", stderr);
	ut_print_name(stderr, foreign->id);
	fputs(": ", stderr);
	ut_print_name(stderr, foreign->foreign_table_name);
	fputs(" (", stderr);
	fprintf(stderr, "  FOREIGN KEY CONSTRAINT %s: %s (",
		foreign->id, foreign->foreign_table_name);

	for (i = 0; i < foreign->n_fields; i++) {
		putc(' ', stderr);
		ut_print_name(stderr, foreign->foreign_col_names[i]);
		fprintf(stderr, " %s", foreign->foreign_col_names[i]);
	}

	fputs(" )\n"
		"             REFERENCES ", stderr);
	ut_print_name(stderr, foreign->referenced_table_name);
	fputs(" (", stderr);
	fprintf(stderr, " )\n"
		"             REFERENCES %s (",
		foreign->referenced_table_name);
	
	for (i = 0; i < foreign->n_fields; i++) {
		putc(' ', stderr);
		ut_print_name(stderr, foreign->referenced_col_names[i]);
		fprintf(stderr, " %s", foreign->referenced_col_names[i]);
	}

	fputs(" )\n", stderr);
@@ -3981,12 +3978,11 @@ dict_table_print_low(

	dict_update_statistics_low(table, TRUE);
	
	fputs("--------------------------------------\n"
		"TABLE: name ", stderr);
	ut_print_name(stderr, table->name);
	fprintf(stderr,
		", id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n"
"--------------------------------------\n"
"TABLE: name %s, id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n"
"  COLUMNS: ",
			table->name,
			(ulong) ut_dulint_get_high(table->id),
			(ulong) ut_dulint_get_low(table->id),
			(ulong) table->n_cols,
@@ -4037,8 +4033,7 @@ dict_col_print_low(
#endif /* UNIV_SYNC_DEBUG */

	type = dict_col_get_type(col);
	ut_print_name(stderr, col->name);
	fputs(": ", stderr);
	fprintf(stderr, "%s: ", col->name);

	dtype_print(type);
}
@@ -4068,13 +4063,12 @@ dict_index_print_low(
		n_vals = index->stat_n_diff_key_vals[1];
	}

	fputs("  INDEX: ", stderr);
	dict_index_name_print(stderr, index);
	fprintf(stderr,
		", id %lu %lu, fields %lu/%lu, type %lu\n"
		"  INDEX: name %s, id %lu %lu, fields %lu/%lu, type %lu\n"
		"   root page %lu, appr.key vals %lu,"
		" leaf pages %lu, size pages %lu\n"
		"   FIELDS: ",
		index->name,
		(ulong) ut_dulint_get_high(tree->id),
		(ulong) ut_dulint_get_low(tree->id),
		(ulong) index->n_user_defined_cols,
@@ -4106,8 +4100,7 @@ dict_field_print_low(
#ifdef UNIV_SYNC_DEBUG
	ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
	putc(' ', stderr);
	ut_print_name(stderr, field->name);
	fprintf(stderr, " %s", field->name);

	if (field->prefix_len != 0) {
		fprintf(stderr, "(%lu)", (ulong) field->prefix_len);
@@ -4122,6 +4115,7 @@ void
dict_print_info_on_foreign_key_in_create_format(
/*============================================*/
	FILE*		file,	/* in: file where to print */
	trx_t*		trx,	/* in: transaction */
	dict_foreign_t*	foreign)/* in: foreign key constraint */
{
	const char*	stripped_id;
@@ -4136,11 +4130,11 @@ dict_print_info_on_foreign_key_in_create_format(
	}

	fputs(",\n  CONSTRAINT ", file);
	ut_print_name(file, stripped_id);
	ut_print_name(file, trx, stripped_id);
	fputs(" FOREIGN KEY (", file);

	for (i = 0;;) {
		ut_print_name(file, foreign->foreign_col_names[i]);
		ut_print_name(file, trx, foreign->foreign_col_names[i]);
		if (++i < foreign->n_fields) {
			fputs(", ", file);
	        } else {
@@ -4153,7 +4147,7 @@ dict_print_info_on_foreign_key_in_create_format(
	if (dict_tables_have_same_db(foreign->foreign_table_name,
					foreign->referenced_table_name)) {
		/* Do not print the database name of the referenced table */
		ut_print_name(file, dict_remove_db_name(
		ut_print_name(file, trx, dict_remove_db_name(
					foreign->referenced_table_name));
	} else {
		/* Look for the '/' in the table name */
@@ -4163,16 +4157,17 @@ dict_print_info_on_foreign_key_in_create_format(
			i++;
		}

		ut_print_namel(file, foreign->referenced_table_name, i);
		ut_print_namel(file, trx, foreign->referenced_table_name, i);
		putc('.', file);
		ut_print_name(file, foreign->referenced_table_name + i + 1);
		ut_print_name(file, trx,
				foreign->referenced_table_name + i + 1);
	}

	putc(' ', file);
	putc('(', file);

	for (i = 0;;) {
		ut_print_name(file, foreign->referenced_col_names[i]);
		ut_print_name(file, trx, foreign->referenced_col_names[i]);
		if (++i < foreign->n_fields) {
			fputs(", ", file);
		} else {
@@ -4218,6 +4213,7 @@ dict_print_info_on_foreign_keys(
				a CREATE TABLE, otherwise in the format
				of SHOW TABLE STATUS */
	FILE*		file,	/* in: file where to print */
	trx_t*		trx,	/* in: transaction */
	dict_table_t*	table)	/* in: table */
{
	dict_foreign_t*	foreign;
@@ -4235,7 +4231,7 @@ dict_print_info_on_foreign_keys(
	while (foreign != NULL) {
		if (create_table_format) {
			dict_print_info_on_foreign_key_in_create_format(
						file, foreign);
						file, trx, foreign);
		} else {
			ulint	i;
			fputs("; (", file);
@@ -4245,19 +4241,20 @@ dict_print_info_on_foreign_keys(
					putc(' ', file);
				}

				ut_print_name(file,
				ut_print_name(file, trx,
					foreign->foreign_col_names[i]);
			}

			fputs(") REFER ", file);
			ut_print_name(file, foreign->referenced_table_name);
			ut_print_name(file, trx,
					foreign->referenced_table_name);
			putc('(', file);

			for (i = 0; i < foreign->n_fields; i++) {
				if (i) {
					putc(' ', file);
				}
				ut_print_name(file,
				ut_print_name(file, trx,
					foreign->referenced_col_names[i]);
			}

@@ -4300,10 +4297,11 @@ void
dict_index_name_print(
/*==================*/
	FILE*			file,	/* in: output stream */
	trx_t*			trx,	/* in: transaction */
	const dict_index_t*	index)	/* in: index to print */
{
	fputs("index ", file);
	ut_print_name(file, index->name);
	ut_print_name(file, trx, index->name);
	fputs(" of table ", file);
	ut_print_name(file, index->table_name);
	ut_print_name(file, trx, index->table_name);
}
Loading