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
000828e0
Commit
000828e0
authored
Jun 21, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
database default character set is now stored in database directory
parent
17b4e3ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
4 deletions
+59
-4
sql/mysql_priv.h
sql/mysql_priv.h
+1
-1
sql/sql_db.cc
sql/sql_db.cc
+56
-2
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-0
No files found.
sql/mysql_priv.h
View file @
000828e0
...
@@ -289,7 +289,7 @@ inline THD *_current_thd(void)
...
@@ -289,7 +289,7 @@ inline THD *_current_thd(void)
#define prepare_execute(A) ((A)->command == COM_EXECUTE)
#define prepare_execute(A) ((A)->command == COM_EXECUTE)
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
uint
create_info
,
bool
silent
);
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
HA_CREATE_INFO
*
create_info
,
bool
silent
);
int
mysql_rm_db
(
THD
*
thd
,
char
*
db
,
bool
if_exists
,
bool
silent
);
int
mysql_rm_db
(
THD
*
thd
,
char
*
db
,
bool
if_exists
,
bool
silent
);
void
mysql_binlog_send
(
THD
*
thd
,
char
*
log_ident
,
ulong
pos
,
ushort
flags
);
void
mysql_binlog_send
(
THD
*
thd
,
char
*
log_ident
,
ulong
pos
,
ushort
flags
);
int
mysql_rm_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
my_bool
if_exists
);
int
mysql_rm_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
my_bool
if_exists
);
...
...
sql/sql_db.cc
View file @
000828e0
...
@@ -31,13 +31,15 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
...
@@ -31,13 +31,15 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
/* db-name is already validated when we come here */
/* db-name is already validated when we come here */
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
uint
create_options
,
bool
silent
)
int
mysql_create_db
(
THD
*
thd
,
char
*
db
,
HA_CREATE_INFO
*
create_info
,
bool
silent
)
{
{
char
path
[
FN_REFLEN
+
16
];
char
path
[
FN_REFLEN
+
16
];
MY_DIR
*
dirp
;
MY_DIR
*
dirp
;
long
result
=
1
;
long
result
=
1
;
int
error
=
0
;
int
error
=
0
;
DBUG_ENTER
(
"mysql_create_db"
);
DBUG_ENTER
(
"mysql_create_db"
);
register
File
file
;
uint
create_options
=
create_info
?
create_info
->
options
:
0
;
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
...
@@ -73,6 +75,37 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
...
@@ -73,6 +75,37 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
}
}
}
}
/*
Create database options file:
Currently databse default charset is only stored there.
*/
strcat
(
path
,
"/"
);
unpack_dirname
(
path
,
path
);
strcat
(
path
,
"db.opt"
);
if
((
file
=
my_create
(
path
,
CREATE_MODE
,
O_RDWR
|
O_TRUNC
,
MYF
(
MY_WME
)))
>=
0
)
{
sprintf
(
path
,
"CREATE DATABASE %s DEFAULT CHARACTER SET=%s
\n
"
,
db
,
(
create_info
&&
create_info
->
table_charset
)
?
create_info
->
table_charset
->
name
:
"DEFAULT"
);
if
(
my_write
(
file
,(
byte
*
)
path
,
strlen
(
path
),
MYF
(
MY_NABP
+
MY_WME
)))
{
// QQ : should we send more suitable error message?
my_error
(
ER_CANT_CREATE_DB
,
MYF
(
0
),
db
,
my_errno
);
error
=
-
1
;
goto
exit
;
}
my_close
(
file
,
MYF
(
0
));
}
else
{
// QQ : should we send more suitable error message?
my_error
(
ER_CANT_CREATE_DB
,
MYF
(
0
),
db
,
my_errno
);
error
=
-
1
;
goto
exit
;
}
if
(
!
silent
)
if
(
!
silent
)
{
{
if
(
!
thd
->
query
)
if
(
!
thd
->
query
)
...
@@ -104,7 +137,7 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
...
@@ -104,7 +137,7 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
const
char
*
del_exts
[]
=
{
".frm"
,
".BAK"
,
".TMD"
,
NullS
};
const
char
*
del_exts
[]
=
{
".frm"
,
".BAK"
,
".TMD"
,
".opt"
,
NullS
};
static
TYPELIB
deletable_extentions
=
static
TYPELIB
deletable_extentions
=
{
array_elements
(
del_exts
)
-
1
,
"del_exts"
,
del_exts
};
{
array_elements
(
del_exts
)
-
1
,
"del_exts"
,
del_exts
};
...
@@ -333,6 +366,7 @@ bool mysql_change_db(THD *thd,const char *name)
...
@@ -333,6 +366,7 @@ bool mysql_change_db(THD *thd,const char *name)
char
path
[
FN_REFLEN
];
char
path
[
FN_REFLEN
];
uint
db_access
;
uint
db_access
;
DBUG_ENTER
(
"mysql_change_db"
);
DBUG_ENTER
(
"mysql_change_db"
);
register
File
file
;
if
(
!
dbname
||
!
(
db_length
=
strip_sp
(
dbname
)))
if
(
!
dbname
||
!
(
db_length
=
strip_sp
(
dbname
)))
{
{
...
@@ -382,5 +416,25 @@ bool mysql_change_db(THD *thd,const char *name)
...
@@ -382,5 +416,25 @@ bool mysql_change_db(THD *thd,const char *name)
thd
->
db
=
dbname
;
thd
->
db
=
dbname
;
thd
->
db_length
=
db_length
;
thd
->
db_length
=
db_length
;
thd
->
db_access
=
db_access
;
thd
->
db_access
=
db_access
;
/*
Load database options file:
*/
strcat
(
path
,
"/"
);
unpack_dirname
(
path
,
path
);
strcat
(
path
,
"db.opt"
);
if
((
file
=
my_open
(
path
,
O_RDWR
|
O_BINARY
,
MYF
(
MY_WME
)))
>=
0
)
{
int
nbytes
=
my_read
(
file
,(
byte
*
)
path
,
sizeof
(
path
),
MYF
(
0
));
if
(
nbytes
>=
0
)
{
path
[
nbytes
]
=
'\0'
;
// BAR TODO: parse create options
// and extract database default charset
}
my_close
(
file
,
MYF
(
0
));
}
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
sql/sql_parse.cc
View file @
000828e0
...
@@ -2308,7 +2308,7 @@ mysql_execute_command(void)
...
@@ -2308,7 +2308,7 @@ mysql_execute_command(void)
}
}
if
(
check_access
(
thd
,
CREATE_ACL
,
lex
->
name
,
0
,
1
))
if
(
check_access
(
thd
,
CREATE_ACL
,
lex
->
name
,
0
,
1
))
break
;
break
;
res
=
mysql_create_db
(
thd
,
lex
->
name
,
lex
->
create_info
.
options
,
0
);
res
=
mysql_create_db
(
thd
,
lex
->
name
,
&
lex
->
create_info
,
0
);
break
;
break
;
}
}
case
SQLCOM_DROP_DB
:
case
SQLCOM_DROP_DB
:
...
...
sql/sql_yacc.yy
View file @
000828e0
...
@@ -798,6 +798,7 @@ create:
...
@@ -798,6 +798,7 @@ create:
lex->sql_command=SQLCOM_CREATE_DB;
lex->sql_command=SQLCOM_CREATE_DB;
lex->name=$4.str;
lex->name=$4.str;
lex->create_info.options=$3;
lex->create_info.options=$3;
lex->create_info.table_charset=lex->charset;
}
}
| CREATE udf_func_type UDF_SYM ident
| CREATE udf_func_type UDF_SYM ident
{
{
...
...
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