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
1943438f
Commit
1943438f
authored
Aug 21, 2024
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP Linux, ugh
parent
d4910a82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
client/import_util.cc
client/import_util.cc
+30
-3
client/import_util.h
client/import_util.h
+3
-1
No files found.
client/import_util.cc
View file @
1943438f
...
...
@@ -48,14 +48,14 @@ std::string extract_first_create_table(const std::string &script)
TableDDLInfo
::
TableDDLInfo
(
const
std
::
string
&
create_table_stmt
)
{
std
::
regex
primary_key_regex
(
R"(
^
\s*(PRIMARY\s+KEY\s+(.*?)),?\n)"
,
std
::
regex
primary_key_regex
(
R"(
\n
\s*(PRIMARY\s+KEY\s+(.*?)),?\n)"
,
std
::
regex
::
icase
);
std
::
regex
constraint_regex
(
R"(
^
\s*(CONSTRAINT\s+(`?(?:[^`]|``)+`?)\s+.*?),?\n)"
,
std
::
regex
::
icase
);
R"(
\n
\s*(CONSTRAINT\s+(`?(?:[^`]|``)+`?)\s+.*?),?\n)"
,
std
::
regex
::
icase
);
std
::
regex
index_regex
(
R"(
^
\s*((UNIQUE\s+)?(INDEX|KEY)\s+(`?(?:[^`]|``)+`?)\s+.*?),?\n)"
,
R"(
\n
\s*((UNIQUE\s+)?(INDEX|KEY)\s+(`?(?:[^`]|``)+`?)\s+.*?),?\n)"
,
std
::
regex
::
icase
);
std
::
regex
engine_regex
(
R"(\bENGINE\s*=\s*(\w+))"
,
std
::
regex
::
icase
);
...
...
@@ -181,6 +181,33 @@ std::string TableDDLInfo::generate_alter_drop(
return
sql
;
}
std
::
string
TableDDLInfo
::
to_string
()
const
{
std
::
string
result
=
"Table Name: "
+
table_name
+
"
\n
"
;
result
+=
"Primary Key:
\n
"
;
result
+=
"Type: "
+
definition_type_to_string
(
primary_key
.
type
)
+
"
\n
"
;
result
+=
"Definition: "
+
primary_key
.
definition
+
"
\n
"
;
result
+=
"Name: "
+
primary_key
.
name
+
"
\n
"
;
result
+=
"
\n
Constraints: "
+
std
::
to_string
(
constraints
.
size
());
result
+=
"
\n
"
;
for
(
const
auto
&
entry
:
constraints
)
{
result
+=
" Type: "
+
definition_type_to_string
(
entry
.
type
)
+
"
\n
"
;
result
+=
" Definition: "
+
entry
.
definition
+
"
\n
"
;
result
+=
" Name: "
+
entry
.
name
+
"
\n
"
;
}
result
+=
"
\n
Secondary indexes: "
+
std
::
to_string
(
secondary_indexes
.
size
());
result
+=
"
\n
"
;
for
(
const
auto
&
entry
:
secondary_indexes
)
{
result
+=
" Type: "
+
definition_type_to_string
(
entry
.
type
)
+
"
\n
"
;
result
+=
" Definition: "
+
entry
.
definition
+
"
\n
"
;
result
+=
" Name: "
+
entry
.
name
+
"
\n
"
;
}
result
+=
"Storage Engine: "
+
storage_engine
+
"
\n
"
;
return
result
;
}
#ifdef MAIN
int
main
()
{
...
...
client/import_util.h
View file @
1943438f
...
...
@@ -61,8 +61,10 @@ class TableDDLInfo
std
::
string
generate_alter_drop
(
const
std
::
vector
<
KeyDefinition
>
&
definitions
)
const
;
std
::
string
to_string
()
const
;
public:
std
::
string
drop_constraints_sql
()
const
{
return
generate_alter_drop
(
constraints
);
...
...
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