Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
360e597c
Commit
360e597c
authored
Jul 31, 2015
by
Jan Lindström
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure name buffer has string end marker on correct place.
parent
1ad294e0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
66 deletions
+110
-66
storage/innobase/dict/dict0crea.c
storage/innobase/dict/dict0crea.c
+29
-18
storage/innobase/dict/dict0dict.c
storage/innobase/dict/dict0dict.c
+26
-15
storage/xtradb/dict/dict0crea.c
storage/xtradb/dict/dict0crea.c
+29
-18
storage/xtradb/dict/dict0dict.c
storage/xtradb/dict/dict0dict.c
+26
-15
No files found.
storage/innobase/dict/dict0crea.c
View file @
360e597c
...
@@ -1433,10 +1433,12 @@ dict_foreign_def_get(
...
@@ -1433,10 +1433,12 @@ dict_foreign_def_get(
const
char
*
tbname
;
const
char
*
tbname
;
char
tablebuf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
tablebuf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
int
i
;
int
i
;
char
*
bufend
;
tbname
=
dict_remove_db_name
(
foreign
->
id
);
tbname
=
dict_remove_db_name
(
foreign
->
id
);
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
tbname
,
strlen
(
tbname
),
trx
->
mysql_thd
,
FALSE
);
tbname
,
strlen
(
tbname
),
trx
->
mysql_thd
,
FALSE
);
tablebuf
[
bufend
-
tablebuf
]
=
'\0'
;
sprintf
(
fk_def
,
sprintf
(
fk_def
,
(
char
*
)
"CONSTRAINT %s FOREIGN KEY ("
,
(
char
*
)
tablebuf
);
(
char
*
)
"CONSTRAINT %s FOREIGN KEY ("
,
(
char
*
)
tablebuf
);
...
@@ -1455,20 +1457,22 @@ dict_foreign_def_get(
...
@@ -1455,20 +1457,22 @@ dict_foreign_def_get(
strcat
(
fk_def
,(
char
*
)
") REFERENCES "
);
strcat
(
fk_def
,(
char
*
)
") REFERENCES "
);
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_table_name
,
foreign
->
referenced_table_name
,
strlen
(
foreign
->
referenced_table_name
),
strlen
(
foreign
->
referenced_table_name
),
trx
->
mysql_thd
,
TRUE
);
trx
->
mysql_thd
,
TRUE
);
tablebuf
[
bufend
-
tablebuf
]
=
'\0'
;
strcat
(
fk_def
,
tablebuf
);
strcat
(
fk_def
,
tablebuf
);
strcat
(
fk_def
,
" ("
);
strcat
(
fk_def
,
" ("
);
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_col_names
[
i
],
foreign
->
referenced_col_names
[
i
],
strlen
(
foreign
->
referenced_col_names
[
i
]),
strlen
(
foreign
->
referenced_col_names
[
i
]),
trx
->
mysql_thd
,
FALSE
);
trx
->
mysql_thd
,
FALSE
);
buf
[
bufend
-
buf
]
=
'\0'
;
strcat
(
fk_def
,
buf
);
strcat
(
fk_def
,
buf
);
if
(
i
<
foreign
->
n_fields
-
1
)
{
if
(
i
<
foreign
->
n_fields
-
1
)
{
strcat
(
fk_def
,
(
char
*
)
","
);
strcat
(
fk_def
,
(
char
*
)
","
);
...
@@ -1492,18 +1496,25 @@ dict_foreign_def_get_fields(
...
@@ -1492,18 +1496,25 @@ dict_foreign_def_get_fields(
char
**
field2
,
/*!< out: referenced column */
char
**
field2
,
/*!< out: referenced column */
int
col_no
)
/*!< in: column number */
int
col_no
)
/*!< in: column number */
{
{
*
field
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
char
*
bufend
;
*
field2
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
char
*
fieldbuf
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
char
*
fieldbuf2
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
innobase_convert_name
(
*
field
,
MAX_TABLE_NAME_LEN
,
foreign
->
foreign_col_names
[
col_no
],
bufend
=
innobase_convert_name
(
fieldbuf
,
MAX_TABLE_NAME_LEN
,
strlen
(
foreign
->
foreign_col_names
[
col_no
]),
foreign
->
foreign_col_names
[
col_no
],
trx
->
mysql_thd
,
FALSE
);
strlen
(
foreign
->
foreign_col_names
[
col_no
]),
trx
->
mysql_thd
,
FALSE
);
innobase_convert_name
(
*
field
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_col_names
[
col_no
],
fieldbuf
[
bufend
-
fieldbuf
]
=
'\0'
;
strlen
(
foreign
->
referenced_col_names
[
col_no
]),
trx
->
mysql_thd
,
FALSE
);
bufend
=
innobase_convert_name
(
fieldbuf2
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_col_names
[
col_no
],
strlen
(
foreign
->
referenced_col_names
[
col_no
]),
trx
->
mysql_thd
,
FALSE
);
fieldbuf2
[
bufend
-
fieldbuf2
]
=
'\0'
;
*
field
=
fieldbuf
;
*
field2
=
fieldbuf2
;
}
}
/********************************************************************//**
/********************************************************************//**
...
...
storage/innobase/dict/dict0dict.c
View file @
360e597c
...
@@ -3746,7 +3746,7 @@ dict_create_foreign_constraints_low(
...
@@ -3746,7 +3746,7 @@ dict_create_foreign_constraints_low(
const
char
*
referenced_table_name
;
const
char
*
referenced_table_name
;
const
char
*
create_table_name
;
const
char
*
create_table_name
;
const
char
*
orig
;
const
char
*
orig
;
c
onst
char
create_name
[
MAX_TABLE_NAME_LEN
+
1
];
c
har
create_name
[
MAX_TABLE_NAME_LEN
+
1
];
const
char
operation
[
8
];
const
char
operation
[
8
];
ut_ad
(
mutex_own
(
&
(
dict_sys
->
mutex
)));
ut_ad
(
mutex_own
(
&
(
dict_sys
->
mutex
)));
...
@@ -3770,14 +3770,18 @@ dict_create_foreign_constraints_low(
...
@@ -3770,14 +3770,18 @@ dict_create_foreign_constraints_low(
}
}
if
(
success
)
{
if
(
success
)
{
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
char
*
bufend
;
create_table_name
,
strlen
(
create_table_name
),
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
trx
->
mysql_thd
,
TRUE
);
create_table_name
,
strlen
(
create_table_name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
ptr
=
orig
;
ptr
=
orig
;
}
else
{
}
else
{
char
*
bufend
;
ptr
=
orig
;
ptr
=
orig
;
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
name
,
strlen
(
name
),
trx
->
mysql_thd
,
TRUE
);
name
,
strlen
(
name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
}
}
goto
loop
;
goto
loop
;
...
@@ -3819,13 +3823,18 @@ dict_create_foreign_constraints_low(
...
@@ -3819,13 +3823,18 @@ dict_create_foreign_constraints_low(
&
success
,
heap
,
&
referenced_table_name
);
&
success
,
heap
,
&
referenced_table_name
);
if
(
table_to_alter
)
{
if
(
table_to_alter
)
{
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
char
*
bufend
;
table_to_alter
->
name
,
strlen
(
table_to_alter
->
name
),
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
trx
->
mysql_thd
,
TRUE
);
table_to_alter
->
name
,
strlen
(
table_to_alter
->
name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
}
else
{
}
else
{
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
char
*
bufend
;
referenced_table_name
,
strlen
(
referenced_table_name
),
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
trx
->
mysql_thd
,
TRUE
);
referenced_table_name
,
strlen
(
referenced_table_name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
}
}
if
(
!
success
)
{
if
(
!
success
)
{
...
@@ -4128,10 +4137,12 @@ col_loop1:
...
@@ -4128,10 +4137,12 @@ col_loop1:
if
(
!
success
||
(
!
referenced_table
&&
trx
->
check_foreigns
))
{
if
(
!
success
||
(
!
referenced_table
&&
trx
->
check_foreigns
))
{
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
*
bufend
;
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
referenced_table_name
,
strlen
(
referenced_table_name
),
referenced_table_name
,
strlen
(
referenced_table_name
),
trx
->
mysql_thd
,
TRUE
);
trx
->
mysql_thd
,
TRUE
);
buf
[
bufend
-
buf
]
=
'\0'
;
ib_push_warning
(
trx
,
DB_CANNOT_ADD_CONSTRAINT
,
ib_push_warning
(
trx
,
DB_CANNOT_ADD_CONSTRAINT
,
"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
...
...
storage/xtradb/dict/dict0crea.c
View file @
360e597c
...
@@ -1640,10 +1640,12 @@ dict_foreign_def_get(
...
@@ -1640,10 +1640,12 @@ dict_foreign_def_get(
const
char
*
tbname
;
const
char
*
tbname
;
char
tablebuf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
tablebuf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
int
i
;
int
i
;
char
*
bufend
;
tbname
=
dict_remove_db_name
(
foreign
->
id
);
tbname
=
dict_remove_db_name
(
foreign
->
id
);
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
tbname
,
strlen
(
tbname
),
trx
->
mysql_thd
,
FALSE
);
tbname
,
strlen
(
tbname
),
trx
->
mysql_thd
,
FALSE
);
tablebuf
[
bufend
-
tablebuf
]
=
'\0'
;
sprintf
(
fk_def
,
sprintf
(
fk_def
,
(
char
*
)
"CONSTRAINT %s FOREIGN KEY ("
,
(
char
*
)
tablebuf
);
(
char
*
)
"CONSTRAINT %s FOREIGN KEY ("
,
(
char
*
)
tablebuf
);
...
@@ -1662,20 +1664,22 @@ dict_foreign_def_get(
...
@@ -1662,20 +1664,22 @@ dict_foreign_def_get(
strcat
(
fk_def
,(
char
*
)
") REFERENCES "
);
strcat
(
fk_def
,(
char
*
)
") REFERENCES "
);
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
tablebuf
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_table_name
,
foreign
->
referenced_table_name
,
strlen
(
foreign
->
referenced_table_name
),
strlen
(
foreign
->
referenced_table_name
),
trx
->
mysql_thd
,
TRUE
);
trx
->
mysql_thd
,
TRUE
);
tablebuf
[
bufend
-
tablebuf
]
=
'\0'
;
strcat
(
fk_def
,
tablebuf
);
strcat
(
fk_def
,
tablebuf
);
strcat
(
fk_def
,
" ("
);
strcat
(
fk_def
,
" ("
);
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_col_names
[
i
],
foreign
->
referenced_col_names
[
i
],
strlen
(
foreign
->
referenced_col_names
[
i
]),
strlen
(
foreign
->
referenced_col_names
[
i
]),
trx
->
mysql_thd
,
FALSE
);
trx
->
mysql_thd
,
FALSE
);
buf
[
bufend
-
buf
]
=
'\0'
;
strcat
(
fk_def
,
buf
);
strcat
(
fk_def
,
buf
);
if
(
i
<
foreign
->
n_fields
-
1
)
{
if
(
i
<
foreign
->
n_fields
-
1
)
{
strcat
(
fk_def
,
(
char
*
)
","
);
strcat
(
fk_def
,
(
char
*
)
","
);
...
@@ -1699,18 +1703,25 @@ dict_foreign_def_get_fields(
...
@@ -1699,18 +1703,25 @@ dict_foreign_def_get_fields(
char
**
field2
,
/*!< out: referenced column */
char
**
field2
,
/*!< out: referenced column */
int
col_no
)
/*!< in: column number */
int
col_no
)
/*!< in: column number */
{
{
*
field
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
char
*
bufend
;
*
field2
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
char
*
fieldbuf
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
char
*
fieldbuf2
=
mem_heap_alloc
(
foreign
->
heap
,
MAX_TABLE_NAME_LEN
+
1
);
innobase_convert_name
(
*
field
,
MAX_TABLE_NAME_LEN
,
foreign
->
foreign_col_names
[
col_no
],
bufend
=
innobase_convert_name
(
fieldbuf
,
MAX_TABLE_NAME_LEN
,
strlen
(
foreign
->
foreign_col_names
[
col_no
]),
foreign
->
foreign_col_names
[
col_no
],
trx
->
mysql_thd
,
FALSE
);
strlen
(
foreign
->
foreign_col_names
[
col_no
]),
trx
->
mysql_thd
,
FALSE
);
innobase_convert_name
(
*
field
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_col_names
[
col_no
],
fieldbuf
[
bufend
-
fieldbuf
]
=
'\0'
;
strlen
(
foreign
->
referenced_col_names
[
col_no
]),
trx
->
mysql_thd
,
FALSE
);
bufend
=
innobase_convert_name
(
fieldbuf2
,
MAX_TABLE_NAME_LEN
,
foreign
->
referenced_col_names
[
col_no
],
strlen
(
foreign
->
referenced_col_names
[
col_no
]),
trx
->
mysql_thd
,
FALSE
);
fieldbuf2
[
bufend
-
fieldbuf2
]
=
'\0'
;
*
field
=
fieldbuf
;
*
field2
=
fieldbuf2
;
}
}
/********************************************************************//**
/********************************************************************//**
...
...
storage/xtradb/dict/dict0dict.c
View file @
360e597c
...
@@ -3879,7 +3879,7 @@ dict_create_foreign_constraints_low(
...
@@ -3879,7 +3879,7 @@ dict_create_foreign_constraints_low(
const
char
*
referenced_table_name
;
const
char
*
referenced_table_name
;
const
char
*
create_table_name
;
const
char
*
create_table_name
;
const
char
*
orig
;
const
char
*
orig
;
c
onst
char
create_name
[
MAX_TABLE_NAME_LEN
+
1
];
c
har
create_name
[
MAX_TABLE_NAME_LEN
+
1
];
const
char
operation
[
8
];
const
char
operation
[
8
];
ut_ad
(
mutex_own
(
&
(
dict_sys
->
mutex
)));
ut_ad
(
mutex_own
(
&
(
dict_sys
->
mutex
)));
...
@@ -3903,14 +3903,18 @@ dict_create_foreign_constraints_low(
...
@@ -3903,14 +3903,18 @@ dict_create_foreign_constraints_low(
}
}
if
(
success
)
{
if
(
success
)
{
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
char
*
bufend
;
create_table_name
,
strlen
(
create_table_name
),
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
trx
->
mysql_thd
,
TRUE
);
create_table_name
,
strlen
(
create_table_name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
ptr
=
orig
;
ptr
=
orig
;
}
else
{
}
else
{
char
*
bufend
;
ptr
=
orig
;
ptr
=
orig
;
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
name
,
strlen
(
name
),
trx
->
mysql_thd
,
TRUE
);
name
,
strlen
(
name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
}
}
goto
loop
;
goto
loop
;
...
@@ -3952,13 +3956,18 @@ dict_create_foreign_constraints_low(
...
@@ -3952,13 +3956,18 @@ dict_create_foreign_constraints_low(
&
success
,
heap
,
&
referenced_table_name
);
&
success
,
heap
,
&
referenced_table_name
);
if
(
table_to_alter
)
{
if
(
table_to_alter
)
{
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
char
*
bufend
;
table_to_alter
->
name
,
strlen
(
table_to_alter
->
name
),
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
trx
->
mysql_thd
,
TRUE
);
table_to_alter
->
name
,
strlen
(
table_to_alter
->
name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
}
else
{
}
else
{
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
char
*
bufend
;
referenced_table_name
,
strlen
(
referenced_table_name
),
bufend
=
innobase_convert_name
((
char
*
)
create_name
,
MAX_TABLE_NAME_LEN
,
trx
->
mysql_thd
,
TRUE
);
referenced_table_name
,
strlen
(
referenced_table_name
),
trx
->
mysql_thd
,
TRUE
);
create_name
[
bufend
-
create_name
]
=
'\0'
;
}
}
if
(
!
success
)
{
if
(
!
success
)
{
...
@@ -4261,10 +4270,12 @@ col_loop1:
...
@@ -4261,10 +4270,12 @@ col_loop1:
if
(
!
success
||
(
!
referenced_table
&&
trx
->
check_foreigns
))
{
if
(
!
success
||
(
!
referenced_table
&&
trx
->
check_foreigns
))
{
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
buf
[
MAX_TABLE_NAME_LEN
+
1
]
=
""
;
char
*
bufend
;
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
bufend
=
innobase_convert_name
(
buf
,
MAX_TABLE_NAME_LEN
,
referenced_table_name
,
strlen
(
referenced_table_name
),
referenced_table_name
,
strlen
(
referenced_table_name
),
trx
->
mysql_thd
,
TRUE
);
trx
->
mysql_thd
,
TRUE
);
buf
[
bufend
-
buf
]
=
'\0'
;
ib_push_warning
(
trx
,
DB_CANNOT_ADD_CONSTRAINT
,
ib_push_warning
(
trx
,
DB_CANNOT_ADD_CONSTRAINT
,
"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment