summaryrefslogtreecommitdiff
path: root/innobase/dict
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/dict')
-rw-r--r--innobase/dict/dict0boot.c59
-rw-r--r--innobase/dict/dict0crea.c6
-rw-r--r--innobase/dict/dict0dict.c62
3 files changed, 124 insertions, 3 deletions
diff --git a/innobase/dict/dict0boot.c b/innobase/dict/dict0boot.c
index 35fdfce16a6..206fbe32940 100644
--- a/innobase/dict/dict0boot.c
+++ b/innobase/dict/dict0boot.c
@@ -24,6 +24,65 @@ Created 4/18/1996 Heikki Tuuri
#include "os0file.h"
/**************************************************************************
+Gets a pointer to the dictionary header and x-latches its page. */
+
+dict_hdr_t*
+dict_hdr_get(
+/*=========*/
+ /* out: pointer to the dictionary header,
+ page x-latched */
+ mtr_t* mtr) /* in: mtr */
+{
+ dict_hdr_t* header;
+
+ ut_ad(mtr);
+
+ header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO,
+ RW_X_LATCH, mtr);
+ buf_page_dbg_add_level(header, SYNC_DICT_HEADER);
+
+ return(header);
+}
+
+/**************************************************************************
+Returns a new table, index, or tree id. */
+
+dulint
+dict_hdr_get_new_id(
+/*================*/
+ /* out: the new id */
+ ulint type) /* in: DICT_HDR_ROW_ID, ... */
+{
+ dict_hdr_t* dict_hdr;
+ dulint id;
+ mtr_t mtr;
+
+ ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID)
+ || (type == DICT_HDR_MIX_ID));
+
+ mtr_start(&mtr);
+
+ dict_hdr = dict_hdr_get(&mtr);
+
+ id = mtr_read_dulint(dict_hdr + type, MLOG_8BYTES, &mtr);
+
+ /* Add some dummy code here because otherwise pgcc seems to
+ compile wrong */
+
+ if (0 == ut_dulint_cmp(id, ut_dulint_max)) {
+ printf("Max id\n");
+ }
+
+ id = ut_dulint_add(id, 1);
+
+ mlog_write_dulint(dict_hdr + type, id, MLOG_8BYTES, &mtr);
+
+ mtr_commit(&mtr);
+
+ return(id);
+}
+
+/**************************************************************************
Writes the current value of the row id counter to the dictionary header file
page. */
diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c
index 9d79983c9e5..b3bf9157e18 100644
--- a/innobase/dict/dict0crea.c
+++ b/innobase/dict/dict0crea.c
@@ -1076,7 +1076,7 @@ dict_create_or_check_foreign_constraint_tables(void)
}
fprintf(stderr,
- "InnoDB: creating foreign key constraint system tables\n");
+ "InnoDB: Creating foreign key constraint system tables\n");
/* NOTE: in dict_load_foreigns we use the fact that
there are 2 secondary indexes on SYS_FOREIGN, and they
@@ -1112,6 +1112,8 @@ dict_create_or_check_foreign_constraint_tables(void)
error = trx->error_state;
if (error != DB_SUCCESS) {
+ fprintf(stderr, "InnoDB: error %lu in creation\n", error);
+
ut_a(error == DB_OUT_OF_FILE_SPACE);
fprintf(stderr, "InnoDB: creation failed\n");
@@ -1133,7 +1135,7 @@ dict_create_or_check_foreign_constraint_tables(void)
if (error == DB_SUCCESS) {
fprintf(stderr,
- "InnoDB: foreign key constraint system tables created\n");
+ "InnoDB: Foreign key constraint system tables created\n");
}
mutex_exit(&(dict_sys->mutex));
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
index e0a7fd327a5..07a9b472d66 100644
--- a/innobase/dict/dict0dict.c
+++ b/innobase/dict/dict0dict.c
@@ -246,7 +246,7 @@ dict_table_get_index_noninline(
}
/************************************************************************
-Initializes the autoinc counter. It is not an error to initialize already
+Initializes the autoinc counter. It is not an error to initialize an already
initialized counter. */
void
@@ -2811,3 +2811,63 @@ dict_field_print_low(
printf(" %s", field->name);
}
+
+/**************************************************************************
+Sprintfs to a string info on foreign keys of a table. */
+
+void
+dict_print_info_on_foreign_keys(
+/*============================*/
+ char* str, /* in/out: pointer to a string */
+ ulint len, /* in: space in str available for info */
+ dict_table_t* table) /* in: table */
+{
+ dict_foreign_t* foreign;
+ ulint i;
+ char* buf2;
+ char buf[10000];
+
+ buf2 = buf;
+
+ mutex_enter(&(dict_sys->mutex));
+
+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
+
+ if (foreign == NULL) {
+ mutex_exit(&(dict_sys->mutex));
+
+ return;
+ }
+
+ while (foreign != NULL) {
+ buf2 += sprintf(buf2, "; (");
+
+ for (i = 0; i < foreign->n_fields; i++) {
+ buf2 += sprintf(buf2, "%s",
+ foreign->foreign_col_names[i]);
+ if (i + 1 < foreign->n_fields) {
+ buf2 += sprintf(buf2, " ");
+ }
+ }
+
+ buf2 += sprintf(buf2, ") REFER %s(",
+ foreign->referenced_table_name);
+
+ for (i = 0; i < foreign->n_fields; i++) {
+ buf2 += sprintf(buf2, "%s",
+ foreign->referenced_col_names[i]);
+ if (i + 1 < foreign->n_fields) {
+ buf2 += sprintf(buf2, " ");
+ }
+ }
+
+ buf2 += sprintf(buf2, ")");
+
+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
+ }
+
+ mutex_exit(&(dict_sys->mutex));
+
+ buf[len - 1] = '\0';
+ ut_memcpy(str, buf, len);
+}