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
f2e5f652
Commit
f2e5f652
authored
Dec 17, 2002
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge vvagin@work.mysql.com:/home/bk/mysql-4.1
into eagle.mysql.r18.ru:/home/vva/work/MANY_INIT_COMMANDS/4.1
parents
c22b4907
6e128a31
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
25 deletions
+98
-25
include/mysql.h
include/mysql.h
+2
-1
libmysql/libmysql.c
libmysql/libmysql.c
+48
-12
libmysqld/libmysqld.c
libmysqld/libmysqld.c
+48
-12
No files found.
include/mysql.h
View file @
f2e5f652
...
@@ -119,7 +119,8 @@ typedef struct st_mysql_data {
...
@@ -119,7 +119,8 @@ typedef struct st_mysql_data {
struct
st_mysql_options
{
struct
st_mysql_options
{
unsigned
int
connect_timeout
,
client_flag
;
unsigned
int
connect_timeout
,
client_flag
;
unsigned
int
port
;
unsigned
int
port
;
char
*
host
,
*
init_command
,
*
user
,
*
password
,
*
unix_socket
,
*
db
;
char
*
host
,
*
user
,
*
password
,
*
unix_socket
,
*
db
;
struct
st_dynamic_array
*
init_commands
;
char
*
my_cnf_file
,
*
my_cnf_group
,
*
charset_dir
,
*
charset_name
;
char
*
my_cnf_file
,
*
my_cnf_group
,
*
charset_dir
,
*
charset_name
;
char
*
ssl_key
;
/* PEM key file */
char
*
ssl_key
;
/* PEM key file */
char
*
ssl_cert
;
/* PEM cert file */
char
*
ssl_cert
;
/* PEM cert file */
...
...
libmysql/libmysql.c
View file @
f2e5f652
...
@@ -935,6 +935,27 @@ static const char *default_options[]=
...
@@ -935,6 +935,27 @@ static const char *default_options[]=
static
TYPELIB
option_types
=
{
array_elements
(
default_options
)
-
1
,
static
TYPELIB
option_types
=
{
array_elements
(
default_options
)
-
1
,
"options"
,
default_options
};
"options"
,
default_options
};
static
int
add_init_command
(
struct
st_mysql_options
*
options
,
const
char
*
cmd
)
{
char
**
ptr
,
*
tmp
;
if
(
!
options
->
init_commands
)
{
options
->
init_commands
=
(
DYNAMIC_ARRAY
*
)
my_malloc
(
sizeof
(
DYNAMIC_ARRAY
),
MYF
(
MY_WME
));
init_dynamic_array
(
options
->
init_commands
,
sizeof
(
char
*
),
0
,
5
CALLER_INFO
);
}
if
(
!
(
tmp
=
my_strdup
(
cmd
,
MYF
(
MY_WME
)))
||
insert_dynamic
(
options
->
init_commands
,
&
tmp
))
{
my_free
(
tmp
,
MYF
(
MY_ALLOW_ZERO_PTR
));
return
1
;
}
return
0
;
}
static
void
mysql_read_default_options
(
struct
st_mysql_options
*
options
,
static
void
mysql_read_default_options
(
struct
st_mysql_options
*
options
,
const
char
*
filename
,
const
char
*
group
)
const
char
*
filename
,
const
char
*
group
)
{
{
...
@@ -1003,11 +1024,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
...
@@ -1003,11 +1024,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
}
}
break
;
break
;
case
8
:
/* init-command */
case
8
:
/* init-command */
if
(
opt_arg
)
add_init_command
(
options
,
opt_arg
);
{
my_free
(
options
->
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
options
->
init_command
=
my_strdup
(
opt_arg
,
MYF
(
MY_WME
));
}
break
;
break
;
case
9
:
/* host */
case
9
:
/* host */
if
(
opt_arg
)
if
(
opt_arg
)
...
@@ -2328,13 +2345,29 @@ Try also with PIPE or TCP/IP
...
@@ -2328,13 +2345,29 @@ Try also with PIPE or TCP/IP
net
->
compress
=
1
;
net
->
compress
=
1
;
if
(
db
&&
mysql_select_db
(
mysql
,
db
))
if
(
db
&&
mysql_select_db
(
mysql
,
db
))
goto
error
;
goto
error
;
if
(
mysql
->
options
.
init_command
)
if
(
mysql
->
options
.
init_commands
)
{
{
DYNAMIC_ARRAY
*
init_commands
=
mysql
->
options
.
init_commands
;
char
**
ptr
=
(
char
**
)
init_commands
->
buffer
;
char
**
end
=
ptr
+
init_commands
->
elements
;
my_bool
reconnect
=
mysql
->
reconnect
;
my_bool
reconnect
=
mysql
->
reconnect
;
mysql
->
reconnect
=
0
;
mysql
->
reconnect
=
0
;
if
(
mysql_query
(
mysql
,
mysql
->
options
.
init_command
))
for
(;
ptr
<
end
;
ptr
++
)
{
MYSQL_RES
*
res
;
if
(
mysql_query
(
mysql
,
*
ptr
))
goto
error
;
if
(
mysql
->
fields
)
{
if
(
!
(
res
=
mysql_use_result
(
mysql
)))
goto
error
;
goto
error
;
mysql_free_result
(
mysql_use_result
(
mysql
));
mysql_free_result
(
res
);
}
}
mysql
->
reconnect
=
reconnect
;
mysql
->
reconnect
=
reconnect
;
}
}
...
@@ -2579,7 +2612,6 @@ mysql_close(MYSQL *mysql)
...
@@ -2579,7 +2612,6 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
passwd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
passwd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
host
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
host
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
@@ -2589,6 +2621,11 @@ mysql_close(MYSQL *mysql)
...
@@ -2589,6 +2621,11 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
options
.
my_cnf_group
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
my_cnf_group
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_dir
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_dir
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_name
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_name
,
MYF
(
MY_ALLOW_ZERO_PTR
));
if
(
mysql
->
options
.
init_commands
)
{
delete_dynamic
(
mysql
->
options
.
init_commands
);
my_free
((
char
*
)
mysql
->
options
.
init_commands
,
MYF
(
MY_WME
));
}
#ifdef HAVE_OPENSSL
#ifdef HAVE_OPENSSL
mysql_ssl_free
(
mysql
);
mysql_ssl_free
(
mysql
);
#endif
/* HAVE_OPENSSL */
#endif
/* HAVE_OPENSSL */
...
@@ -3334,8 +3371,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
...
@@ -3334,8 +3371,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
mysql
->
options
.
client_flag
&=
~
CLIENT_LOCAL_FILES
;
mysql
->
options
.
client_flag
&=
~
CLIENT_LOCAL_FILES
;
break
;
break
;
case
MYSQL_INIT_COMMAND
:
case
MYSQL_INIT_COMMAND
:
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
add_init_command
(
&
mysql
->
options
,
arg
);
mysql
->
options
.
init_command
=
my_strdup
(
arg
,
MYF
(
MY_WME
));
break
;
break
;
case
MYSQL_READ_DEFAULT_FILE
:
case
MYSQL_READ_DEFAULT_FILE
:
my_free
(
mysql
->
options
.
my_cnf_file
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
my_cnf_file
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
libmysqld/libmysqld.c
View file @
f2e5f652
...
@@ -451,6 +451,27 @@ static const char *default_options[]=
...
@@ -451,6 +451,27 @@ static const char *default_options[]=
static
TYPELIB
option_types
=
{
array_elements
(
default_options
)
-
1
,
static
TYPELIB
option_types
=
{
array_elements
(
default_options
)
-
1
,
"options"
,
default_options
};
"options"
,
default_options
};
static
int
add_init_command
(
struct
st_mysql_options
*
options
,
const
char
*
cmd
)
{
char
**
ptr
,
*
tmp
;
if
(
!
options
->
init_commands
)
{
options
->
init_commands
=
(
DYNAMIC_ARRAY
*
)
my_malloc
(
sizeof
(
DYNAMIC_ARRAY
),
MYF
(
MY_WME
));
init_dynamic_array
(
options
->
init_commands
,
sizeof
(
char
*
),
0
,
5
CALLER_INFO
);
}
if
(
!
(
tmp
=
my_strdup
(
cmd
,
MYF
(
MY_WME
)))
||
insert_dynamic
(
options
->
init_commands
,
&
tmp
))
{
my_free
(
tmp
,
MYF
(
MY_ALLOW_ZERO_PTR
));
return
1
;
}
return
0
;
}
static
void
mysql_read_default_options
(
struct
st_mysql_options
*
options
,
static
void
mysql_read_default_options
(
struct
st_mysql_options
*
options
,
const
char
*
filename
,
const
char
*
group
)
const
char
*
filename
,
const
char
*
group
)
{
{
...
@@ -520,11 +541,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
...
@@ -520,11 +541,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
}
}
break
;
break
;
case
8
:
/* init-command */
case
8
:
/* init-command */
if
(
opt_arg
)
add_init_command
(
options
,
opt_arg
);
{
my_free
(
options
->
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
options
->
init_command
=
my_strdup
(
opt_arg
,
MYF
(
MY_WME
));
}
break
;
break
;
case
9
:
/* host */
case
9
:
/* host */
if
(
opt_arg
)
if
(
opt_arg
)
...
@@ -1005,13 +1022,29 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
...
@@ -1005,13 +1022,29 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
goto
error
;
goto
error
;
if
(
db
&&
mysql_select_db
(
mysql
,
db
))
if
(
db
&&
mysql_select_db
(
mysql
,
db
))
goto
error
;
goto
error
;
if
(
mysql
->
options
.
init_command
)
if
(
mysql
->
options
.
init_commands
)
{
{
DYNAMIC_ARRAY
*
init_commands
=
mysql
->
options
.
init_commands
;
char
**
ptr
=
(
char
**
)
init_commands
->
buffer
;
char
**
end
=
ptr
+
init_commands
->
elements
;
my_bool
reconnect
=
mysql
->
reconnect
;
my_bool
reconnect
=
mysql
->
reconnect
;
mysql
->
reconnect
=
0
;
mysql
->
reconnect
=
0
;
if
(
mysql_query
(
mysql
,
mysql
->
options
.
init_command
))
for
(;
ptr
<
end
;
ptr
++
)
{
MYSQL_RES
*
res
;
if
(
mysql_query
(
mysql
,
*
ptr
))
goto
error
;
if
(
mysql
->
fields
)
{
if
(
!
(
res
=
mysql_use_result
(
mysql
)))
goto
error
;
goto
error
;
mysql_free_result
(
mysql_use_result
(
mysql
));
mysql_free_result
(
res
);
}
}
mysql
->
reconnect
=
reconnect
;
mysql
->
reconnect
=
reconnect
;
}
}
...
@@ -1108,7 +1141,6 @@ mysql_close(MYSQL *mysql)
...
@@ -1108,7 +1141,6 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
passwd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
passwd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
host
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
host
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
@@ -1118,6 +1150,11 @@ mysql_close(MYSQL *mysql)
...
@@ -1118,6 +1150,11 @@ mysql_close(MYSQL *mysql)
my_free
(
mysql
->
options
.
my_cnf_group
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
my_cnf_group
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_dir
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_dir
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_name
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
charset_name
,
MYF
(
MY_ALLOW_ZERO_PTR
));
if
(
mysql
->
options
.
init_commands
)
{
delete_dynamic
(
mysql
->
options
.
init_commands
);
my_free
((
char
*
)
mysql
->
options
.
init_commands
,
MYF
(
MY_WME
));
}
/* Clear pointers for better safety */
/* Clear pointers for better safety */
mysql
->
host_info
=
mysql
->
user
=
mysql
->
passwd
=
mysql
->
db
=
0
;
mysql
->
host_info
=
mysql
->
user
=
mysql
->
passwd
=
mysql
->
db
=
0
;
bzero
((
char
*
)
&
mysql
->
options
,
sizeof
(
mysql
->
options
));
bzero
((
char
*
)
&
mysql
->
options
,
sizeof
(
mysql
->
options
));
...
@@ -1820,8 +1857,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
...
@@ -1820,8 +1857,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
mysql
->
options
.
client_flag
&=
~
CLIENT_LOCAL_FILES
;
mysql
->
options
.
client_flag
&=
~
CLIENT_LOCAL_FILES
;
break
;
break
;
case
MYSQL_INIT_COMMAND
:
case
MYSQL_INIT_COMMAND
:
my_free
(
mysql
->
options
.
init_command
,
MYF
(
MY_ALLOW_ZERO_PTR
));
add_init_command
(
&
mysql
->
options
,
arg
);
mysql
->
options
.
init_command
=
my_strdup
(
arg
,
MYF
(
MY_WME
));
break
;
break
;
case
MYSQL_READ_DEFAULT_FILE
:
case
MYSQL_READ_DEFAULT_FILE
:
my_free
(
mysql
->
options
.
my_cnf_file
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
options
.
my_cnf_file
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
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