summaryrefslogtreecommitdiff
path: root/innobase/dict/dict0crea.c
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2004-02-20 16:34:09 +0200
committerunknown <marko@hundin.mysql.fi>2004-02-20 16:34:09 +0200
commit0eacf58fd5ebc665ce799a673739c97d6157b13b (patch)
tree96c04a7ccc804314e3737d02fc081513e1e827db /innobase/dict/dict0crea.c
parentf443541a36769eaacf9228ad517ed224c827c565 (diff)
downloadmariadb-git-0eacf58fd5ebc665ce799a673739c97d6157b13b.tar.gz
Many files:
Removed unused code .del-os0trash.c~8cae5c1695501117: Delete: innobase/os/os0trash.c dict0crea.c: Protect all sprintf(%s) with assertions BitKeeper/deleted/.del-os0trash.c~8cae5c1695501117: Delete: innobase/os/os0trash.c innobase/btr/btr0sea.c: Removed unused code innobase/buf/buf0buf.c: Removed unused code innobase/com/com0shm.c: Removed unused code innobase/data/data0data.c: Removed unused code innobase/dict/dict0crea.c: Removed unused code innobase/fsp/fsp0fsp.c: Removed unused code innobase/ha/ha0ha.c: Removed unused code innobase/include/btr0cur.h: Removed unused code innobase/include/btr0sea.h: Removed unused code innobase/include/buf0buf.ic: Removed unused code innobase/include/data0data.h: Removed unused code innobase/include/dict0crea.h: Removed unused code innobase/include/dict0dict.h: Removed unused code innobase/include/ibuf0ibuf.h: Removed unused code innobase/include/lock0lock.h: Removed unused code innobase/include/mem0dbg.h: Removed unused code innobase/include/mem0mem.ic: Removed unused code innobase/include/mtr0log.h: Removed unused code innobase/include/mtr0mtr.h: Removed unused code innobase/include/os0proc.h: Removed unused code innobase/include/os0thread.h: Removed unused code innobase/include/rem0cmp.ic: Removed unused code innobase/include/row0row.h: Removed unused code innobase/include/srv0srv.h: Removed unused code innobase/include/sync0sync.h: Removed unused code innobase/lock/lock0lock.c: Removed unused code innobase/log/log0recv.c: Removed unused code innobase/mem/mem0dbg.c: Removed unused code innobase/mtr/mtr0mtr.c: Removed unused code innobase/os/os0proc.c: Removed unused code innobase/page/page0page.c: Removed unused code innobase/que/que0que.c: Removed unused code innobase/rem/rem0cmp.c: Removed unused code innobase/row/row0ins.c: Removed unused code innobase/row/row0mysql.c: Removed unused code innobase/row/row0row.c: Removed unused code innobase/srv/srv0srv.c: Removed unused code innobase/srv/srv0start.c: Removed unused code innobase/sync/sync0sync.c: Removed unused code innobase/trx/trx0rec.c: Removed unused code innobase/trx/trx0trx.c: Removed unused code innobase/ut/ut0dbg.c: Removed unused code innobase/ut/ut0mem.c: Removed unused code innobase/ut/ut0ut.c: Removed unused code
Diffstat (limited to 'innobase/dict/dict0crea.c')
-rw-r--r--innobase/dict/dict0crea.c85
1 files changed, 27 insertions, 58 deletions
diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c
index 0445c339fe9..76e72ddd9c2 100644
--- a/innobase/dict/dict0crea.c
+++ b/innobase/dict/dict0crea.c
@@ -25,6 +25,11 @@ Created 1/8/1996 Heikki Tuuri
#include "trx0roll.h"
#include "usr0sess.h"
+/* Maximum lengths of identifiers in MySQL, in bytes */
+#define MAX_TABLE_NAME_LEN 64
+#define MAX_COLUMN_NAME_LEN 64
+#define MAX_IDENTIFIER_LEN 255
+
/*********************************************************************
Based on a table object, this function builds the entry to be inserted
in the SYS_TABLES system table. */
@@ -316,34 +321,6 @@ dict_build_col_def_step(
return(DB_SUCCESS);
}
-#ifdef notdefined
-
-/*************************************************************************
-Creates the single index for a cluster: it contains all the columns of
-the cluster definition in the order they were defined. */
-static
-void
-dict_create_index_for_cluster_step(
-/*===============================*/
- tab_node_t* node) /* in: table create node */
-{
- dict_index_t* index;
- ulint i;
- dict_col_t* col;
-
- index = dict_mem_index_create(table->name, "IND_DEFAULT_CLUSTERED",
- table->space, DICT_CLUSTERED,
- table->n_cols);
-
- for (i = 0; i < table->n_cols; i++) {
- col = dict_table_get_nth_col(table, i);
- dict_mem_index_add_field(index, col->name, 0, 0);
- }
-
- (node->cluster)->index = index;
-}
-#endif
-
/*********************************************************************
Based on an index object, this function builds the entry to be inserted
in the SYS_INDEXES system table. */
@@ -727,27 +704,6 @@ dict_drop_index_tree(
page_rec_write_index_page_no(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
FIL_NULL, mtr);
}
-
-#ifdef notdefined
-/*************************************************************************
-Creates the default clustered index for a table: the records are ordered
-by row id. */
-
-void
-dict_create_default_index(
-/*======================*/
- dict_table_t* table, /* in: table */
- trx_t* trx) /* in: transaction handle */
-{
- dict_index_t* index;
-
- index = dict_mem_index_create(table->name, "IND_DEFAULT_CLUSTERED",
- table->space, DICT_CLUSTERED, 0);
-
- dict_create_index(index, trx);
-}
-
-#endif
/*************************************************************************
Creates a table create graph. */
@@ -1198,6 +1154,7 @@ dict_create_add_foreigns_to_dictionary(
que_t* graph;
ulint number = start_id + 1;
ulint len;
+ ulint namelen;
ulint error;
char* ebuf = dict_foreign_err_buf;
ulint i;
@@ -1228,15 +1185,21 @@ loop:
"PROCEDURE ADD_FOREIGN_DEFS_PROC () IS\n"
"BEGIN\n");
+ namelen = strlen(table->name);
+ ut_a(namelen < MAX_TABLE_NAME_LEN);
+
if (foreign->id == NULL) {
/* Generate a new constraint id */
- foreign->id = mem_heap_alloc(foreign->heap,
- ut_strlen(table->name)
- + 20);
+ foreign->id = mem_heap_alloc(foreign->heap, namelen + 20);
+ /* no overflow if number < 1e13 */
sprintf(foreign->id, "%s_ibfk_%lu", table->name, number);
number++;
}
+ ut_a(strlen(foreign->id) < MAX_IDENTIFIER_LEN);
+ ut_a(len < (sizeof buf)
+ - 46 - 2 * MAX_TABLE_NAME_LEN - MAX_IDENTIFIER_LEN - 20);
+
len += sprintf(buf + len,
"INSERT INTO SYS_FOREIGN VALUES('%s', '%s', '%s', %lu);\n",
foreign->id,
@@ -1246,6 +1209,9 @@ loop:
+ (foreign->type << 24));
for (i = 0; i < foreign->n_fields; i++) {
+ ut_a(len < (sizeof buf)
+ - 51 - 2 * MAX_COLUMN_NAME_LEN
+ - MAX_IDENTIFIER_LEN - 20);
len += sprintf(buf + len,
"INSERT INTO SYS_FOREIGN_COLS VALUES('%s', %lu, '%s', '%s');\n",
@@ -1255,6 +1221,7 @@ loop:
foreign->referenced_col_names[i]);
}
+ ut_a(len < (sizeof buf) - 19)
len += sprintf(buf + len,"COMMIT WORK;\nEND;\n");
graph = pars_sql(buf);
@@ -1276,15 +1243,15 @@ loop:
if (error == DB_DUPLICATE_KEY) {
mutex_enter(&dict_foreign_err_mutex);
- ut_sprintf_timestamp(dict_foreign_err_buf);
+ ut_sprintf_timestamp(ebuf);
+ ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN
+ - MAX_TABLE_NAME_LEN - MAX_IDENTIFIER_LEN - 201);
sprintf(ebuf + strlen(ebuf),
-" Error in foreign key constraint creation for table %.500s.\n"
-"A foreign key constraint of name %.500s\n"
+" Error in foreign key constraint creation for table %s.\n"
+"A foreign key constraint of name %s\n"
"already exists (note that internally InnoDB adds 'databasename/'\n"
"in front of the user-defined constraint name).\n", table->name, foreign->id);
- ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN);
-
mutex_exit(&dict_foreign_err_mutex);
return(error);
@@ -1297,8 +1264,10 @@ loop:
mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(ebuf);
+ ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN
+ - MAX_TABLE_NAME_LEN - 124);
sprintf(ebuf + strlen(ebuf),
-" Internal error in foreign key constraint creation for table %.500s.\n"
+" Internal error in foreign key constraint creation for table %s.\n"
"See the MySQL .err log in the datadir for more information.\n", table->name);
mutex_exit(&dict_foreign_err_mutex);