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
189d1dd6
Commit
189d1dd6
authored
Jul 02, 2002
by
bar@gw.udmsearch.izhnet.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SHOW CREATE DATABASE name;
Small fixes in database default charset code
parent
a2f2d799
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
2 deletions
+115
-2
sql/mysql_priv.h
sql/mysql_priv.h
+1
-0
sql/sql_db.cc
sql/sql_db.cc
+90
-1
sql/sql_lex.h
sql/sql_lex.h
+1
-0
sql/sql_parse.cc
sql/sql_parse.cc
+18
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+5
-0
No files found.
sql/mysql_priv.h
View file @
189d1dd6
...
@@ -472,6 +472,7 @@ int mysqld_show_logs(THD *thd);
...
@@ -472,6 +472,7 @@ int mysqld_show_logs(THD *thd);
void
mysqld_list_fields
(
THD
*
thd
,
TABLE_LIST
*
table
,
const
char
*
wild
);
void
mysqld_list_fields
(
THD
*
thd
,
TABLE_LIST
*
table
,
const
char
*
wild
);
int
mysqld_dump_create_info
(
THD
*
thd
,
TABLE
*
table
,
int
fd
=
-
1
);
int
mysqld_dump_create_info
(
THD
*
thd
,
TABLE
*
table
,
int
fd
=
-
1
);
int
mysqld_show_create
(
THD
*
thd
,
TABLE_LIST
*
table_list
);
int
mysqld_show_create
(
THD
*
thd
,
TABLE_LIST
*
table_list
);
int
mysqld_show_create_db
(
THD
*
thd
,
const
char
*
dbname
);
void
mysqld_list_processes
(
THD
*
thd
,
const
char
*
user
,
bool
verbose
);
void
mysqld_list_processes
(
THD
*
thd
,
const
char
*
user
,
bool
verbose
);
int
mysqld_show_status
(
THD
*
thd
);
int
mysqld_show_status
(
THD
*
thd
);
...
...
sql/sql_db.cc
View file @
189d1dd6
...
@@ -106,7 +106,7 @@ static int load_db_opt(THD *thd,const char *db,HA_CREATE_INFO *create,char *fn)
...
@@ -106,7 +106,7 @@ static int load_db_opt(THD *thd,const char *db,HA_CREATE_INFO *create,char *fn)
for
(
;
(
le
[
0
]
==
'\r'
||
le
[
0
]
==
'\n'
)
;
le
++
);
for
(
;
(
le
[
0
]
==
'\r'
||
le
[
0
]
==
'\n'
)
;
le
++
);
if
(
!
strcmp
(
ln
,
"default-character-set"
)
&&
val
&&
val
[
0
])
if
(
!
strcmp
(
ln
,
"default-character-set"
)
&&
val
&&
val
[
0
])
{
{
thd
->
db
_charset
=
get_charset_by_name
(
val
,
MYF
(
0
));
create
->
table
_charset
=
get_charset_by_name
(
val
,
MYF
(
0
));
}
}
goto
cnt
;
goto
cnt
;
break
;
break
;
...
@@ -568,3 +568,92 @@ bool mysql_change_db(THD *thd,const char *name)
...
@@ -568,3 +568,92 @@ bool mysql_change_db(THD *thd,const char *name)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
int
mysqld_show_create_db
(
THD
*
thd
,
const
char
*
name
)
{
int
length
,
db_length
;
char
*
dbname
=
my_strdup
((
char
*
)
name
,
MYF
(
MY_WME
));
char
path
[
FN_REFLEN
];
uint
db_access
;
HA_CREATE_INFO
create
;
CONVERT
*
convert
=
thd
->
convert_set
;
DBUG_ENTER
(
"mysql_show_create_db"
);
if
(
!
dbname
||
!
(
db_length
=
strip_sp
(
dbname
)))
{
x_free
(
dbname
);
/* purecov: inspected */
send_error
(
&
thd
->
net
,
ER_NO_DB_ERROR
);
/* purecov: inspected */
DBUG_RETURN
(
1
);
/* purecov: inspected */
}
if
((
db_length
>
NAME_LEN
)
||
check_db_name
(
dbname
))
{
net_printf
(
&
thd
->
net
,
ER_WRONG_DB_NAME
,
dbname
);
x_free
(
dbname
);
DBUG_RETURN
(
1
);
}
if
(
test_all_bits
(
thd
->
master_access
,
DB_ACLS
))
db_access
=
DB_ACLS
;
else
db_access
=
(
acl_get
(
thd
->
host
,
thd
->
ip
,(
char
*
)
&
thd
->
remote
.
sin_addr
,
thd
->
priv_user
,
dbname
)
|
thd
->
master_access
);
if
(
!
(
db_access
&
DB_ACLS
)
&&
(
!
grant_option
||
check_grant_db
(
thd
,
dbname
)))
{
net_printf
(
&
thd
->
net
,
ER_DBACCESS_DENIED_ERROR
,
thd
->
priv_user
,
thd
->
host_or_ip
,
dbname
);
mysql_log
.
write
(
thd
,
COM_INIT_DB
,
ER
(
ER_DBACCESS_DENIED_ERROR
),
thd
->
priv_user
,
thd
->
host_or_ip
,
dbname
);
my_free
(
dbname
,
MYF
(
0
));
DBUG_RETURN
(
1
);
}
(
void
)
sprintf
(
path
,
"%s/%s"
,
mysql_data_home
,
dbname
);
length
=
unpack_dirname
(
path
,
path
);
// Convert if not unix
if
(
length
&&
path
[
length
-
1
]
==
FN_LIBCHAR
)
path
[
length
-
1
]
=
0
;
// remove ending '\'
if
(
access
(
path
,
F_OK
))
{
net_printf
(
&
thd
->
net
,
ER_BAD_DB_ERROR
,
dbname
);
my_free
(
dbname
,
MYF
(
0
));
DBUG_RETURN
(
1
);
}
strcat
(
path
,
"/"
);
unpack_dirname
(
path
,
path
);
strcat
(
path
,
MY_DB_OPT_FILE
);
bzero
(
&
create
,
sizeof
(
create
));
load_db_opt
(
thd
,
name
,
&
create
,
path
);
List
<
Item
>
field_list
;
field_list
.
push_back
(
new
Item_empty_string
(
"Database"
,
NAME_LEN
));
field_list
.
push_back
(
new
Item_empty_string
(
"Create Database"
,
1024
));
if
(
send_fields
(
thd
,
field_list
,
1
))
DBUG_RETURN
(
1
);
String
*
packet
=
&
thd
->
packet
;
packet
->
length
(
0
);
net_store_data
(
packet
,
convert
,
name
);
sprintf
(
path
,
"CREATE DATABASE %s"
,
name
);
if
(
create
.
table_charset
)
{
strcat
(
path
,
" DEFAULT CHARACTER SET "
);
strcat
(
path
,
create
.
table_charset
->
name
);
}
net_store_data
(
packet
,
convert
,
path
);
if
(
my_net_write
(
&
thd
->
net
,(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
1
);
send_eof
(
&
thd
->
net
);
DBUG_RETURN
(
0
);
}
sql/sql_lex.h
View file @
189d1dd6
...
@@ -42,6 +42,7 @@ enum enum_sql_command {
...
@@ -42,6 +42,7 @@ enum enum_sql_command {
SQLCOM_SHOW_KEYS
,
SQLCOM_SHOW_VARIABLES
,
SQLCOM_SHOW_LOGS
,
SQLCOM_SHOW_STATUS
,
SQLCOM_SHOW_KEYS
,
SQLCOM_SHOW_VARIABLES
,
SQLCOM_SHOW_LOGS
,
SQLCOM_SHOW_STATUS
,
SQLCOM_SHOW_PROCESSLIST
,
SQLCOM_SHOW_MASTER_STAT
,
SQLCOM_SHOW_SLAVE_STAT
,
SQLCOM_SHOW_PROCESSLIST
,
SQLCOM_SHOW_MASTER_STAT
,
SQLCOM_SHOW_SLAVE_STAT
,
SQLCOM_SHOW_GRANTS
,
SQLCOM_SHOW_CREATE
,
SQLCOM_SHOW_CHARSETS
,
SQLCOM_SHOW_GRANTS
,
SQLCOM_SHOW_CREATE
,
SQLCOM_SHOW_CHARSETS
,
SQLCOM_SHOW_CREATE_DB
,
SQLCOM_LOAD
,
SQLCOM_SET_OPTION
,
SQLCOM_LOCK_TABLES
,
SQLCOM_UNLOCK_TABLES
,
SQLCOM_LOAD
,
SQLCOM_SET_OPTION
,
SQLCOM_LOCK_TABLES
,
SQLCOM_UNLOCK_TABLES
,
SQLCOM_GRANT
,
SQLCOM_GRANT
,
...
...
sql/sql_parse.cc
View file @
189d1dd6
...
@@ -2335,7 +2335,7 @@ mysql_execute_command(void)
...
@@ -2335,7 +2335,7 @@ mysql_execute_command(void)
net_printf
(
&
thd
->
net
,
ER_WRONG_DB_NAME
,
lex
->
name
);
net_printf
(
&
thd
->
net
,
ER_WRONG_DB_NAME
,
lex
->
name
);
break
;
break
;
}
}
if
(
check_access
(
thd
,
DROP
_ACL
,
lex
->
name
,
0
,
1
))
if
(
check_access
(
thd
,
ALTER
_ACL
,
lex
->
name
,
0
,
1
))
break
;
break
;
if
(
thd
->
locked_tables
||
thd
->
active_transaction
())
if
(
thd
->
locked_tables
||
thd
->
active_transaction
())
{
{
...
@@ -2345,6 +2345,23 @@ mysql_execute_command(void)
...
@@ -2345,6 +2345,23 @@ mysql_execute_command(void)
res
=
mysql_alter_db
(
thd
,
lex
->
name
,
&
lex
->
create_info
,
0
);
res
=
mysql_alter_db
(
thd
,
lex
->
name
,
&
lex
->
create_info
,
0
);
break
;
break
;
}
}
case
SQLCOM_SHOW_CREATE_DB
:
{
if
(
!
strip_sp
(
lex
->
name
)
||
check_db_name
(
lex
->
name
))
{
net_printf
(
&
thd
->
net
,
ER_WRONG_DB_NAME
,
lex
->
name
);
break
;
}
if
(
check_access
(
thd
,
DROP_ACL
,
lex
->
name
,
0
,
1
))
break
;
if
(
thd
->
locked_tables
||
thd
->
active_transaction
())
{
send_error
(
&
thd
->
net
,
ER_LOCK_OR_ACTIVE_TRANSACTION
);
goto
error
;
}
res
=
mysqld_show_create_db
(
thd
,
lex
->
name
);
break
;
}
case
SQLCOM_CREATE_FUNCTION
:
case
SQLCOM_CREATE_FUNCTION
:
if
(
check_access
(
thd
,
INSERT_ACL
,
"mysql"
,
0
,
1
))
if
(
check_access
(
thd
,
INSERT_ACL
,
"mysql"
,
0
,
1
))
break
;
break
;
...
...
sql/sql_yacc.yy
View file @
189d1dd6
...
@@ -2851,6 +2851,11 @@ show_param:
...
@@ -2851,6 +2851,11 @@ show_param:
lex->grant_user=$3;
lex->grant_user=$3;
lex->grant_user->password.str=NullS;
lex->grant_user->password.str=NullS;
}
}
| CREATE DATABASE ident
{
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
Lex->name=$3.str;
}
| CREATE TABLE_SYM table_ident
| CREATE TABLE_SYM table_ident
{
{
Lex->sql_command = SQLCOM_SHOW_CREATE;
Lex->sql_command = SQLCOM_SHOW_CREATE;
...
...
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