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
90c9641a
Commit
90c9641a
authored
Feb 24, 2016
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-7331 - information_schema.user_variables
parent
d30ae14c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
243 additions
and
1 deletion
+243
-1
debian/mariadb-server-10.2.files.in
debian/mariadb-server-10.2.files.in
+1
-0
mysql-test/t/mysqld--help.test
mysql-test/t/mysqld--help.test
+1
-1
plugin/user_variables/CMakeLists.txt
plugin/user_variables/CMakeLists.txt
+1
-0
plugin/user_variables/mysql-test/user_variables/basic.result
plugin/user_variables/mysql-test/user_variables/basic.result
+63
-0
plugin/user_variables/mysql-test/user_variables/basic.test
plugin/user_variables/mysql-test/user_variables/basic.test
+24
-0
plugin/user_variables/mysql-test/user_variables/suite.opt
plugin/user_variables/mysql-test/user_variables/suite.opt
+1
-0
plugin/user_variables/mysql-test/user_variables/suite.pm
plugin/user_variables/mysql-test/user_variables/suite.pm
+13
-0
plugin/user_variables/user_variables.cc
plugin/user_variables/user_variables.cc
+139
-0
No files found.
debian/mariadb-server-10.2.files.in
View file @
90c9641a
...
@@ -19,6 +19,7 @@ usr/lib/mysql/plugin/server_audit.so
...
@@ -19,6 +19,7 @@ usr/lib/mysql/plugin/server_audit.so
usr/lib/mysql/plugin/simple_password_check.so
usr/lib/mysql/plugin/simple_password_check.so
usr/lib/mysql/plugin/sql_errlog.so
usr/lib/mysql/plugin/sql_errlog.so
usr/lib/mysql/plugin/wsrep_info.so
usr/lib/mysql/plugin/wsrep_info.so
usr/lib/mysql/plugin/user_variables.so
usr/lib/libhsclient.so.*
usr/lib/libhsclient.so.*
etc/apparmor.d/usr.sbin.mysqld
etc/apparmor.d/usr.sbin.mysqld
usr/share/apport/package-hooks/source_mariadb-10.2.py
usr/share/apport/package-hooks/source_mariadb-10.2.py
...
...
mysql-test/t/mysqld--help.test
View file @
90c9641a
...
@@ -31,7 +31,7 @@ perl;
...
@@ -31,7 +31,7 @@ perl;
connect
null
-
audit
aria
oqgraph
sphinx
thread
-
handling
connect
null
-
audit
aria
oqgraph
sphinx
thread
-
handling
test
-
sql
-
discovery
rpl
-
semi
-
sync
query
-
cache
-
info
test
-
sql
-
discovery
rpl
-
semi
-
sync
query
-
cache
-
info
query
-
response
-
time
metadata
-
lock
-
info
locales
unix
-
socket
query
-
response
-
time
metadata
-
lock
-
info
locales
unix
-
socket
wsrep
file
-
key
-
management
/
;
wsrep
file
-
key
-
management
user
-
variables
/
;
# And substitute the content some environment variables with their
# And substitute the content some environment variables with their
# names:
# names:
...
...
plugin/user_variables/CMakeLists.txt
0 → 100644
View file @
90c9641a
MYSQL_ADD_PLUGIN
(
user_variables user_variables.cc
)
plugin/user_variables/mysql-test/user_variables/basic.result
0 → 100644
View file @
90c9641a
SELECT PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_AUTHOR, PLUGIN_DESCRIPTION, PLUGIN_LICENSE, LOAD_OPTION, PLUGIN_MATURITY FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='user_variables';
PLUGIN_NAME user_variables
PLUGIN_VERSION 1.0
PLUGIN_STATUS ACTIVE
PLUGIN_TYPE INFORMATION SCHEMA
PLUGIN_AUTHOR Sergey Vojtovich
PLUGIN_DESCRIPTION User-defined variables
PLUGIN_LICENSE GPL
LOAD_OPTION ON
PLUGIN_MATURITY Alpha
SHOW CREATE TABLE INFORMATION_SCHEMA.USER_VARIABLES;
Table Create Table
user_variables CREATE TEMPORARY TABLE `user_variables` (
`VARIABLE_NAME` varchar(64) NOT NULL DEFAULT '',
`VARIABLE_VALUE` varchar(2048) DEFAULT NULL,
`VARIABLE_TYPE` varchar(64) NOT NULL DEFAULT '',
`CHARACTER_SET_NAME` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8
FLUSH USER_VARIABLES;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES;
COUNT(*)
0
SET @int_var=1;
SET @uint_var=CAST(2 AS UNSIGNED INTEGER);
SET @str_var='Value of string variable';
SET @utf8str_var=_utf8 'UTF8 string value';
SET @double_var=CAST(1 AS DOUBLE);
SET @dec_var=CAST(1 AS DECIMAL(20, 10));
SET @time_var=CAST('2016-02-25' AS DATE);
SET @' @#^%'='Value of variable with odd name';
SET @''='Value of variable with empty name';
SET @null_var=NULL;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES;
COUNT(*)
10
SELECT * FROM INFORMATION_SCHEMA.USER_VARIABLES ORDER BY VARIABLE_NAME;
VARIABLE_NAME VARIABLE_VALUE VARIABLE_TYPE CHARACTER_SET_NAME
Value of variable with empty name VARCHAR latin1
@#^% Value of variable with odd name VARCHAR latin1
dec_var 1.0000000000 DECIMAL latin1
double_var 1 DOUBLE latin1
int_var 1 INT latin1
null_var NULL VARCHAR binary
str_var Value of string variable VARCHAR latin1
time_var 2016-02-25 VARCHAR latin1
uint_var 2 INT UNSIGNED latin1
utf8str_var UTF8 string value VARCHAR utf8
SHOW USER_VARIABLES;
Variable_name Value
Value of variable with empty name
@#^% Value of variable with odd name
dec_var 1.0000000000
double_var 1
int_var 1
null_var NULL
str_var Value of string variable
time_var 2016-02-25
uint_var 2
utf8str_var UTF8 string value
FLUSH USER_VARIABLES;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES;
COUNT(*)
0
plugin/user_variables/mysql-test/user_variables/basic.test
0 → 100644
View file @
90c9641a
query_vertical
SELECT
PLUGIN_NAME
,
PLUGIN_VERSION
,
PLUGIN_STATUS
,
PLUGIN_TYPE
,
PLUGIN_AUTHOR
,
PLUGIN_DESCRIPTION
,
PLUGIN_LICENSE
,
LOAD_OPTION
,
PLUGIN_MATURITY
FROM
INFORMATION_SCHEMA
.
PLUGINS
WHERE
PLUGIN_NAME
=
'user_variables'
;
SHOW
CREATE
TABLE
INFORMATION_SCHEMA
.
USER_VARIABLES
;
FLUSH
USER_VARIABLES
;
SELECT
COUNT
(
*
)
FROM
INFORMATION_SCHEMA
.
USER_VARIABLES
;
SET
@
int_var
=
1
;
SET
@
uint_var
=
CAST
(
2
AS
UNSIGNED
INTEGER
);
SET
@
str_var
=
'Value of string variable'
;
SET
@
utf8str_var
=
_utf8
'UTF8 string value'
;
SET
@
double_var
=
CAST
(
1
AS
DOUBLE
);
SET
@
dec_var
=
CAST
(
1
AS
DECIMAL
(
20
,
10
));
SET
@
time_var
=
CAST
(
'2016-02-25'
AS
DATE
);
SET
@
' @#^%'
=
'Value of variable with odd name'
;
SET
@
''
=
'Value of variable with empty name'
;
SET
@
null_var
=
NULL
;
SELECT
COUNT
(
*
)
FROM
INFORMATION_SCHEMA
.
USER_VARIABLES
;
SELECT
*
FROM
INFORMATION_SCHEMA
.
USER_VARIABLES
ORDER
BY
VARIABLE_NAME
;
--
sorted_result
SHOW
USER_VARIABLES
;
FLUSH
USER_VARIABLES
;
SELECT
COUNT
(
*
)
FROM
INFORMATION_SCHEMA
.
USER_VARIABLES
;
plugin/user_variables/mysql-test/user_variables/suite.opt
0 → 100644
View file @
90c9641a
--plugin-load-add=$USER_VARIABLES_SO --plugin-user-variables=ON
plugin/user_variables/mysql-test/user_variables/suite.pm
0 → 100644
View file @
90c9641a
package
My::Suite::
User_variables
;
@ISA
=
qw(My::Suite)
;
return
"
No USER_VARIABLES plugin
"
unless
$ENV
{
USER_VARIABLES_SO
}
or
$::mysqld_variables
{'
user-variables
'}
eq
"
ON
";
return
"
Not run for embedded server
"
if
$::opt_embedded_server
;
sub
is_default
{
1
}
bless
{
};
plugin/user_variables/user_variables.cc
0 → 100644
View file @
90c9641a
/* Copyright (C) 2016 MariaDB Foundation and Sergey Vojtovich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define MYSQL_SERVER
#include <sql_class.h>
#include <table.h>
#include <sql_show.h>
static
const
LEX_CSTRING
result_types
[]
=
{
STRING_WITH_LEN
(
"VARCHAR"
),
STRING_WITH_LEN
(
"DOUBLE"
),
STRING_WITH_LEN
(
"INT"
),
STRING_WITH_LEN
(
"<IMPOSSIBLE1>"
),
// ROW_RESULT
STRING_WITH_LEN
(
"DECIMAL"
),
STRING_WITH_LEN
(
"<IMPOSSIBLE2>"
)
// TIME_RESULT
};
static
const
LEX_CSTRING
unsigned_result_types
[]
=
{
STRING_WITH_LEN
(
"<IMPOSSIBLE3>"
),
// UNSIGNED STRING_RESULT
STRING_WITH_LEN
(
"DOUBLE UNSIGNED"
),
STRING_WITH_LEN
(
"INT UNSIGNED"
),
STRING_WITH_LEN
(
"<IMPOSSIBLE4>"
),
// UNSIGNED ROW_RESULT
STRING_WITH_LEN
(
"DECIMAL UNSIGNED"
),
STRING_WITH_LEN
(
"<IMPOSSIBLE5>"
)
// UNSIGNED TIME_RESULT
};
static
ST_FIELD_INFO
user_variables_fields_info
[]
=
{
{
"VARIABLE_NAME"
,
NAME_CHAR_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
"Variable_name"
,
0
},
{
"VARIABLE_VALUE"
,
2048
,
MYSQL_TYPE_STRING
,
0
,
MY_I_S_MAYBE_NULL
,
"Value"
,
0
},
{
"VARIABLE_TYPE"
,
NAME_CHAR_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
0
,
0
},
{
"CHARACTER_SET_NAME"
,
MY_CS_NAME_SIZE
,
MYSQL_TYPE_STRING
,
0
,
MY_I_S_MAYBE_NULL
,
0
,
0
},
{
0
,
0
,
MYSQL_TYPE_NULL
,
0
,
0
,
0
,
0
}
};
static
int
user_variables_fill
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
ulong
i
;
TABLE
*
table
=
tables
->
table
;
Field
**
field
=
table
->
field
;
String
buff
;
bool
is_null
;
for
(
i
=
0
;
i
<
thd
->
user_vars
.
records
;
i
++
)
{
user_var_entry
*
var
=
(
user_var_entry
*
)
my_hash_element
(
&
thd
->
user_vars
,
i
);
field
[
0
]
->
store
(
var
->
name
.
str
,
var
->
name
.
length
,
system_charset_info
);
if
(
var
->
val_str
(
&
is_null
,
&
buff
,
NOT_FIXED_DEC
))
{
field
[
1
]
->
store
(
buff
.
ptr
(),
buff
.
length
(),
buff
.
charset
());
field
[
1
]
->
set_notnull
();
}
else
if
(
is_null
)
field
[
1
]
->
set_null
();
else
return
1
;
const
LEX_CSTRING
*
tmp
=
var
->
unsigned_flag
?
&
unsigned_result_types
[
var
->
type
]
:
&
result_types
[
var
->
type
];
field
[
2
]
->
store
(
tmp
->
str
,
tmp
->
length
,
system_charset_info
);
if
(
var
->
charset
())
{
field
[
3
]
->
store
(
var
->
charset
()
->
csname
,
strlen
(
var
->
charset
()
->
csname
),
system_charset_info
);
field
[
3
]
->
set_notnull
();
}
else
field
[
3
]
->
set_null
();
if
(
schema_table_store_record
(
thd
,
table
))
return
1
;
}
return
0
;
}
int
user_variables_reset
(
void
)
{
THD
*
thd
=
current_thd
;
if
(
thd
)
my_hash_reset
(
&
thd
->
user_vars
);
return
0
;
}
static
int
user_variables_init
(
void
*
p
)
{
ST_SCHEMA_TABLE
*
is
=
(
ST_SCHEMA_TABLE
*
)
p
;
is
->
fields_info
=
user_variables_fields_info
;
is
->
fill_table
=
user_variables_fill
;
is
->
reset_table
=
user_variables_reset
;
return
0
;
}
static
struct
st_mysql_information_schema
user_variables_descriptor
=
{
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
};
maria_declare_plugin
(
user_variables
)
{
MYSQL_INFORMATION_SCHEMA_PLUGIN
,
&
user_variables_descriptor
,
"user_variables"
,
"Sergey Vojtovich"
,
"User-defined variables"
,
PLUGIN_LICENSE_GPL
,
user_variables_init
,
NULL
,
0x0100
,
NULL
,
NULL
,
"1.0"
,
MariaDB_PLUGIN_MATURITY_ALPHA
}
maria_declare_plugin_end
;
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