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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
aca476f5
Commit
aca476f5
authored
Oct 11, 2019
by
Will DeVries
Committed by
Sergei Petrunia
Mar 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decode database names from paths like table names.
parent
0696d50b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
21 deletions
+30
-21
storage/clustrixdb/ha_clustrixdb.cc
storage/clustrixdb/ha_clustrixdb.cc
+30
-21
No files found.
storage/clustrixdb/ha_clustrixdb.cc
View file @
aca476f5
...
@@ -213,12 +213,32 @@ size_t estimate_row_size(TABLE *table)
...
@@ -213,12 +213,32 @@ size_t estimate_row_size(TABLE *table)
*
*
* Used in delete and rename DDL processing.
* Used in delete and rename DDL processing.
**/
**/
void
decode_objectname
(
char
*
buf
,
const
char
*
path
,
size_t
buf_size
)
static
void
decode_objectname
(
char
*
buf
,
const
char
*
path
,
size_t
buf_size
)
{
{
size_t
new_path_len
=
filename_to_tablename
(
path
,
buf
,
buf_size
);
size_t
new_path_len
=
filename_to_tablename
(
path
,
buf
,
buf_size
);
buf
[
new_path_len
]
=
'\0'
;
buf
[
new_path_len
]
=
'\0'
;
}
}
static
void
decode_file_path
(
const
char
*
path
,
char
*
decoded_dbname
,
char
*
decoded_tbname
)
{
// The format cont ains './' in the beginning of a path.
char
*
dbname_start
=
(
char
*
)
path
+
2
;
char
*
dbname_end
=
dbname_start
;
while
(
*
dbname_end
!=
'/'
)
dbname_end
++
;
int
cnt
=
dbname_end
-
dbname_start
;
char
*
dbname
=
(
char
*
)
my_alloca
(
cnt
+
1
);
memcpy
(
dbname
,
dbname_start
,
cnt
);
dbname
[
cnt
]
=
'\0'
;
decode_objectname
(
decoded_dbname
,
dbname
,
FN_REFLEN
);
my_afree
(
dbname
);
char
*
tbname_start
=
dbname_end
+
1
;
decode_objectname
(
decoded_tbname
,
tbname_start
,
FN_REFLEN
);
}
clustrix_connection
*
get_trx
(
THD
*
thd
,
int
*
error_code
)
clustrix_connection
*
get_trx
(
THD
*
thd
,
int
*
error_code
)
{
{
*
error_code
=
0
;
*
error_code
=
0
;
...
@@ -317,17 +337,13 @@ int ha_clustrixdb::delete_table(const char *path)
...
@@ -317,17 +337,13 @@ int ha_clustrixdb::delete_table(const char *path)
if
(
!
trx
)
if
(
!
trx
)
return
error_code
;
return
error_code
;
// The format cont ains './' in the beginning of a path.
char
decoded_dbname
[
FN_REFLEN
];
char
*
dbname_end
=
(
char
*
)
path
+
2
;
while
(
*
dbname_end
!=
'/'
)
dbname_end
++
;
char
decoded_tbname
[
FN_REFLEN
];
char
decoded_tbname
[
FN_REFLEN
];
decode_
objectname
(
decoded_tbname
,
dbname_end
+
1
,
FN_REFLEN
);
decode_
file_path
(
path
,
decoded_dbname
,
decoded_tbname
);
String
delete_cmd
;
String
delete_cmd
;
delete_cmd
.
append
(
"DROP TABLE `"
);
delete_cmd
.
append
(
"DROP TABLE `"
);
delete_cmd
.
append
(
path
+
2
,
dbname_end
-
path
-
2
);
delete_cmd
.
append
(
decoded_dbname
);
delete_cmd
.
append
(
"`.`"
);
delete_cmd
.
append
(
"`.`"
);
delete_cmd
.
append
(
decoded_tbname
);
delete_cmd
.
append
(
decoded_tbname
);
delete_cmd
.
append
(
"`"
);
delete_cmd
.
append
(
"`"
);
...
@@ -343,28 +359,21 @@ int ha_clustrixdb::rename_table(const char* from, const char* to)
...
@@ -343,28 +359,21 @@ int ha_clustrixdb::rename_table(const char* from, const char* to)
if
(
!
trx
)
if
(
!
trx
)
return
error_code
;
return
error_code
;
// The format contains './' in the beginning of a path.
char
decoded_from_dbname
[
FN_REFLEN
];
char
*
from_dbname_end
=
(
char
*
)
from
+
2
;
while
(
*
from_dbname_end
!=
'/'
)
from_dbname_end
++
;
char
decoded_from_tbname
[
FN_REFLEN
];
char
decoded_from_tbname
[
FN_REFLEN
];
decode_objectname
(
decoded_from_tbname
,
from_dbname_end
+
1
,
FN_REFLEN
);
decode_file_path
(
from
,
decoded_from_dbname
,
decoded_from_tbname
);
char
*
to_dbname_end
=
(
char
*
)
to
+
2
;
while
(
*
to_dbname_end
!=
'/'
)
to_dbname_end
++
;
char
decoded_to_dbname
[
FN_REFLEN
];
char
decoded_to_tbname
[
FN_REFLEN
];
char
decoded_to_tbname
[
FN_REFLEN
];
decode_
objectname
(
decoded_to_tbname
,
to_dbname_end
+
1
,
FN_REFLEN
);
decode_
file_path
(
to
,
decoded_to_dbname
,
decoded_to_tbname
);
String
rename_cmd
;
String
rename_cmd
;
rename_cmd
.
append
(
"RENAME TABLE `"
);
rename_cmd
.
append
(
"RENAME TABLE `"
);
rename_cmd
.
append
(
from
+
2
,
from_dbname_end
-
from
-
2
);
rename_cmd
.
append
(
decoded_from_dbname
);
rename_cmd
.
append
(
"`.`"
);
rename_cmd
.
append
(
"`.`"
);
rename_cmd
.
append
(
decoded_from_tbname
);
rename_cmd
.
append
(
decoded_from_tbname
);
rename_cmd
.
append
(
"` TO `"
);
rename_cmd
.
append
(
"` TO `"
);
rename_cmd
.
append
(
to
+
2
,
to_dbname_end
-
to
-
2
);
rename_cmd
.
append
(
decoded_to_dbname
);
rename_cmd
.
append
(
"`.`"
);
rename_cmd
.
append
(
"`.`"
);
rename_cmd
.
append
(
decoded_to_tbname
);
rename_cmd
.
append
(
decoded_to_tbname
);
rename_cmd
.
append
(
"`;"
);
rename_cmd
.
append
(
"`;"
);
...
...
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