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
f79c4469
Commit
f79c4469
authored
Sep 25, 2017
by
Eugene Kosov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: helpers to get archive tables list [closes #199]
parent
7f206478
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
1 deletion
+79
-1
sql/sql_show.cc
sql/sql_show.cc
+1
-1
sql/sql_show.h
sql/sql_show.h
+3
-0
sql/vtmd.cc
sql/vtmd.cc
+71
-0
sql/vtmd.h
sql/vtmd.h
+4
-0
No files found.
sql/sql_show.cc
View file @
f79c4469
...
...
@@ -4218,7 +4218,7 @@ int schema_tables_add(THD *thd, Dynamic_array<LEX_STRING*> *files,
@retval 2 Not fatal error; Safe to ignore this file list
*/
static
int
int
make_table_name_list
(
THD
*
thd
,
Dynamic_array
<
LEX_STRING
*>
*
table_names
,
LEX
*
lex
,
LOOKUP_FIELD_VALUES
*
lookup_field_vals
,
LEX_STRING
*
db_name
)
...
...
sql/sql_show.h
View file @
f79c4469
...
...
@@ -199,6 +199,9 @@ typedef struct st_lookup_field_values
bool
wild_table_value
;
}
LOOKUP_FIELD_VALUES
;
int
make_table_name_list
(
THD
*
thd
,
Dynamic_array
<
LEX_STRING
*>
*
table_names
,
LEX
*
lex
,
LOOKUP_FIELD_VALUES
*
lookup_field_vals
,
LEX_STRING
*
db_name
);
/*
INFORMATION_SCHEMA: Execution plan for get_all_tables() call
...
...
sql/vtmd.cc
View file @
f79c4469
...
...
@@ -6,6 +6,7 @@
#include "sql_select.h"
#include "table_cache.h" // tdc_remove_table()
#include "key.h"
#include "sql_show.h"
LString
VERS_VTMD_TEMPLATE
(
C_STRING_WITH_LEN
(
"vtmd_template"
));
...
...
@@ -573,3 +574,73 @@ bool VTMD_table::find_archive_name(THD *thd, String &out)
close_log_table
(
thd
,
&
open_tables_backup
);
return
error
?
true
:
false
;
}
Dynamic_array
<
String
>
VTMD_table
::
get_archive_tables
(
THD
*
thd
)
{
Dynamic_array
<
String
>
result
;
Dynamic_array
<
LEX_STRING
*>
vtmd_tables
=
get_vtmd_tables
(
thd
);
for
(
uint
i
=
0
;
i
<
vtmd_tables
.
elements
();
i
++
)
{
LEX_STRING
table_name
=
*
vtmd_tables
.
at
(
i
);
Open_tables_backup
open_tables_backup
;
TABLE_LIST
table_list
;
// Assume VTMD tables belongs to current db.
table_list
.
init_one_table
(
thd
->
db
,
strlen
(
thd
->
db
),
LEX_STRING_WITH_LEN
(
table_name
),
table_name
.
str
,
TL_READ
);
TABLE
*
table
=
open_log_table
(
thd
,
&
table_list
,
&
open_tables_backup
);
if
(
!
table
)
return
result
;
READ_RECORD
read_record
;
int
error
=
0
;
SQL_SELECT
*
sql_select
=
make_select
(
table
,
0
,
0
,
NULL
,
NULL
,
0
,
&
error
);
if
(
error
)
goto
error1
;
if
(
error
=
init_read_record
(
&
read_record
,
thd
,
table
,
sql_select
,
NULL
,
1
,
1
,
false
))
goto
error2
;
while
(
!
(
error
=
read_record
.
read_record
(
&
read_record
)))
{
Field
*
field
=
table
->
field
[
FLD_ARCHIVE_NAME
];
if
(
field
->
is_null
())
continue
;
String
archive_name
;
field
->
val_str
(
&
archive_name
);
archive_name
.
set_ascii
(
strmake_root
(
thd
->
mem_root
,
archive_name
.
c_ptr
(),
archive_name
.
length
()),
archive_name
.
length
());
result
.
push
(
archive_name
);
}
end_read_record
(
&
read_record
);
error2:
delete
sql_select
;
error1:
close_log_table
(
thd
,
&
open_tables_backup
);
if
(
error
)
break
;
}
return
result
;
}
Dynamic_array
<
LEX_STRING
*>
get_vtmd_tables
(
THD
*
thd
)
{
// Note function retrieves table names from current db only.
LOOKUP_FIELD_VALUES
lookup_field_values
=
{
*
thd
->
make_lex_string
(
thd
->
db
,
strlen
(
thd
->
db
)),
*
thd
->
make_lex_string
(
C_STRING_WITH_LEN
(
"%_vtmd"
)),
false
,
true
};
Dynamic_array
<
LEX_STRING
*>
table_names
;
make_table_name_list
(
thd
,
&
table_names
,
thd
->
lex
,
&
lookup_field_values
,
&
lookup_field_values
.
db_value
);
return
table_names
;
}
sql/vtmd.h
View file @
f79c4469
...
...
@@ -87,8 +87,12 @@ class VTMD_table
}
bool
find_archive_name
(
THD
*
thd
,
String
&
out
);
static
Dynamic_array
<
String
>
get_archive_tables
(
THD
*
thd
);
};
Dynamic_array
<
LEX_STRING
*>
get_vtmd_tables
(
THD
*
thd
);
class
VTMD_exists
:
public
VTMD_table
{
protected:
...
...
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