mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
Merge ssmith@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/stewart/Documents/MySQL/5.0/main
This commit is contained in:
commit
ef29f88c43
17 changed files with 363 additions and 64 deletions
|
@ -86,7 +86,8 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1,
|
|||
opt_delete_master_logs=0, tty_password=0,
|
||||
opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
|
||||
opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
|
||||
opt_complete_insert= 0, opt_drop_database= 0;
|
||||
opt_complete_insert= 0, opt_drop_database= 0,
|
||||
opt_dump_triggers= 0;
|
||||
static ulong opt_max_allowed_packet, opt_net_buffer_length;
|
||||
static MYSQL mysql_connection,*sock=0;
|
||||
static my_bool insert_pat_inited=0;
|
||||
|
@ -371,6 +372,9 @@ static struct my_option my_long_options[] =
|
|||
(gptr*) &path, (gptr*) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"tables", OPT_TABLES, "Overrides option --databases (-B).",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"triggers", '/0', "Dump triggers for each dumped table",
|
||||
(gptr*) &opt_dump_triggers, (gptr*) &opt_dump_triggers, 0, GET_BOOL,
|
||||
NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
#ifndef DONT_ALLOW_USER_CHANGE
|
||||
{"user", 'u', "User for login if not current user.",
|
||||
(gptr*) ¤t_user, (gptr*) ¤t_user, 0, GET_STR, REQUIRED_ARG,
|
||||
|
@ -1315,6 +1319,37 @@ static uint get_table_structure(char *table, char *db)
|
|||
fprintf(sql_file, "%s;\n", row[1]);
|
||||
check_io(sql_file);
|
||||
mysql_free_result(tableRes);
|
||||
if (opt_dump_triggers &&
|
||||
mysql_get_server_version(sock) >= 50009)
|
||||
{
|
||||
my_snprintf(query_buff, sizeof(query_buff),
|
||||
"SHOW TRIGGERS LIKE %s",
|
||||
quote_for_like(table, name_buff));
|
||||
|
||||
|
||||
if (mysql_query_with_error_report(sock, &tableRes, query_buff))
|
||||
{
|
||||
if (path)
|
||||
my_fclose(sql_file, MYF(MY_WME));
|
||||
safe_exit(EX_MYSQLERR);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (mysql_num_rows(tableRes))
|
||||
fprintf(sql_file, "\nDELIMITER //;\n");
|
||||
while ((row=mysql_fetch_row(tableRes)))
|
||||
{
|
||||
fprintf(sql_file, "CREATE TRIGGER %s %s %s ON %s\n"
|
||||
"FOR EACH ROW%s//\n\n",
|
||||
quote_name(row[0], name_buff, 0),
|
||||
row[4],
|
||||
row[1],
|
||||
result_table,
|
||||
row[3]);
|
||||
}
|
||||
if (mysql_num_rows(tableRes))
|
||||
fprintf(sql_file, "DELIMITER ;//");
|
||||
mysql_free_result(tableRes);
|
||||
}
|
||||
}
|
||||
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
|
||||
result_table);
|
||||
|
|
|
@ -522,10 +522,11 @@ extern ibool sync_order_checks_on;
|
|||
extern ibool sync_initialized;
|
||||
|
||||
/* Global list of database mutexes (not OS mutexes) created. */
|
||||
UT_LIST_BASE_NODE_T(mutex_t) mutex_list;
|
||||
typedef UT_LIST_BASE_NODE_T(mutex_t) ut_list_base_node_t;
|
||||
extern ut_list_base_node_t mutex_list;
|
||||
|
||||
/* Mutex protecting the mutex_list variable */
|
||||
mutex_t mutex_list_mutex;
|
||||
extern mutex_t mutex_list_mutex;
|
||||
|
||||
|
||||
#ifndef UNIV_NONINL
|
||||
|
|
|
@ -141,6 +141,12 @@ sync_thread_t* sync_thread_level_arrays;
|
|||
/* Mutex protecting sync_thread_level_arrays */
|
||||
mutex_t sync_thread_mutex;
|
||||
|
||||
/* Global list of database mutexes (not OS mutexes) created. */
|
||||
ut_list_base_node_t mutex_list;
|
||||
|
||||
/* Mutex protecting the mutex_list variable */
|
||||
mutex_t mutex_list_mutex;
|
||||
|
||||
/* Latching order checks start when this is set TRUE */
|
||||
ibool sync_order_checks_on = FALSE;
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ hex(a) hex(@u:=convert(a using utf8)) hex(@l:=convert(@u using latin1)) a=@l
|
|||
7E 7E 7E 1
|
||||
7F 7F 7F 1
|
||||
80 E282AC 80 1
|
||||
81 3F 3F 0
|
||||
81 C281 81 1
|
||||
82 E2809A 82 1
|
||||
83 C692 83 1
|
||||
84 E2809E 84 1
|
||||
|
@ -180,10 +180,10 @@ hex(a) hex(@u:=convert(a using utf8)) hex(@l:=convert(@u using latin1)) a=@l
|
|||
8A C5A0 8A 1
|
||||
8B E280B9 8B 1
|
||||
8C C592 8C 1
|
||||
8D 3F 3F 0
|
||||
8D C28D 8D 1
|
||||
8E C5BD 8E 1
|
||||
8F 3F 3F 0
|
||||
90 3F 3F 0
|
||||
8F C28F 8F 1
|
||||
90 C290 90 1
|
||||
91 E28098 91 1
|
||||
92 E28099 92 1
|
||||
93 E2809C 93 1
|
||||
|
@ -196,7 +196,7 @@ hex(a) hex(@u:=convert(a using utf8)) hex(@l:=convert(@u using latin1)) a=@l
|
|||
9A C5A1 9A 1
|
||||
9B E280BA 9B 1
|
||||
9C C593 9C 1
|
||||
9D 3F 3F 0
|
||||
9D C29D 9D 1
|
||||
9E C5BE 9E 1
|
||||
9F C5B8 9F 1
|
||||
A0 C2A0 A0 1
|
||||
|
|
|
@ -182,13 +182,13 @@ drop database mysqltest;
|
|||
select * from information_schema.CHARACTER_SETS
|
||||
where CHARACTER_SET_NAME like 'latin1%';
|
||||
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
|
||||
latin1 latin1_swedish_ci ISO 8859-1 West European 1
|
||||
latin1 latin1_swedish_ci cp1252 West European 1
|
||||
SHOW CHARACTER SET LIKE 'latin1%';
|
||||
Charset Description Default collation Maxlen
|
||||
latin1 ISO 8859-1 West European latin1_swedish_ci 1
|
||||
latin1 cp1252 West European latin1_swedish_ci 1
|
||||
SHOW CHARACTER SET WHERE charset like 'latin1%';
|
||||
Charset Description Default collation Maxlen
|
||||
latin1 ISO 8859-1 West European latin1_swedish_ci 1
|
||||
latin1 cp1252 West European latin1_swedish_ci 1
|
||||
select * from information_schema.COLLATIONS
|
||||
where COLLATION_NAME like 'latin1%';
|
||||
COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
|
||||
|
@ -501,7 +501,7 @@ create table t1 select * from information_schema.CHARACTER_SETS
|
|||
where CHARACTER_SET_NAME like "latin1";
|
||||
select * from t1;
|
||||
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
|
||||
latin1 latin1_swedish_ci ISO 8859-1 West European 1
|
||||
latin1 latin1_swedish_ci cp1252 West European 1
|
||||
alter table t1 default character set utf8;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
|
|
|
@ -1673,3 +1673,175 @@ a b c
|
|||
3 6 three
|
||||
drop view v1, v2, v3;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int, b bigint default NULL);
|
||||
CREATE TABLE t2 (a int);
|
||||
create trigger trg1 before insert on t1 for each row
|
||||
begin
|
||||
if new.a > 10 then
|
||||
set new.a := 10;
|
||||
set new.a := 11;
|
||||
end if;
|
||||
end|
|
||||
create trigger trg2 before update on t1 for each row begin
|
||||
if old.a % 2 = 0 then set new.b := 12; end if;
|
||||
end|
|
||||
create trigger trg3 after update on t1 for each row
|
||||
begin
|
||||
if new.a = -1 then
|
||||
set @fired:= "Yes";
|
||||
end if;
|
||||
end|
|
||||
create trigger trg4 before insert on t2 for each row
|
||||
begin
|
||||
if new.a > 10 then
|
||||
set @fired:= "No";
|
||||
end if;
|
||||
end|
|
||||
show triggers like "t1";
|
||||
Trigger Event Table Statement Timing Created
|
||||
trg1 INSERT t1
|
||||
begin
|
||||
if new.a > 10 then
|
||||
set new.a := 10;
|
||||
set new.a := 11;
|
||||
end if;
|
||||
end BEFORE 0000-00-00 00:00:00
|
||||
trg2 UPDATE t1 begin
|
||||
if old.a % 2 = 0 then set new.b := 12; end if;
|
||||
end BEFORE 0000-00-00 00:00:00
|
||||
trg3 UPDATE t1
|
||||
begin
|
||||
if new.a = -1 then
|
||||
set @fired:= "Yes";
|
||||
end if;
|
||||
end AFTER 0000-00-00 00:00:00
|
||||
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
|
||||
update t1 set a = 4 where a=3;
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
|
||||
|
||||
USE `test`;
|
||||
DROP TABLE IF EXISTS `t1`;
|
||||
CREATE TABLE `t1` (
|
||||
`a` int(11) default NULL,
|
||||
`b` bigint(20) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
DELIMITER //;
|
||||
CREATE TRIGGER `trg1` BEFORE INSERT ON `t1`
|
||||
FOR EACH ROW
|
||||
begin
|
||||
if new.a > 10 then
|
||||
set new.a := 10;
|
||||
set new.a := 11;
|
||||
end if;
|
||||
end//
|
||||
|
||||
CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1`
|
||||
FOR EACH ROW begin
|
||||
if old.a % 2 = 0 then set new.b := 12; end if;
|
||||
end//
|
||||
|
||||
CREATE TRIGGER `trg3` AFTER UPDATE ON `t1`
|
||||
FOR EACH ROW
|
||||
begin
|
||||
if new.a = -1 then
|
||||
set @fired:= "Yes";
|
||||
end if;
|
||||
end//
|
||||
|
||||
DELIMITER ;//
|
||||
|
||||
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
|
||||
LOCK TABLES `t1` WRITE;
|
||||
INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
|
||||
UNLOCK TABLES;
|
||||
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
|
||||
DROP TABLE IF EXISTS `t2`;
|
||||
CREATE TABLE `t2` (
|
||||
`a` int(11) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
DELIMITER //;
|
||||
CREATE TRIGGER `trg4` BEFORE INSERT ON `t2`
|
||||
FOR EACH ROW
|
||||
begin
|
||||
if new.a > 10 then
|
||||
set @fired:= "No";
|
||||
end if;
|
||||
end//
|
||||
|
||||
DELIMITER ;//
|
||||
|
||||
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
|
||||
LOCK TABLES `t2` WRITE;
|
||||
UNLOCK TABLES;
|
||||
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
|
||||
|
||||
USE `test`;
|
||||
DROP TABLE IF EXISTS `t1`;
|
||||
CREATE TABLE `t1` (
|
||||
`a` int(11) default NULL,
|
||||
`b` bigint(20) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
|
||||
LOCK TABLES `t1` WRITE;
|
||||
INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
|
||||
UNLOCK TABLES;
|
||||
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
|
||||
DROP TABLE IF EXISTS `t2`;
|
||||
CREATE TABLE `t2` (
|
||||
`a` int(11) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
|
||||
LOCK TABLES `t2` WRITE;
|
||||
UNLOCK TABLES;
|
||||
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
drop table t1;
|
||||
show tables;
|
||||
Tables_in_test
|
||||
t1
|
||||
t2
|
||||
DROP TABLE t1, t2;
|
||||
|
|
|
@ -709,3 +709,48 @@ select * from v1;
|
|||
|
||||
drop view v1, v2, v3;
|
||||
drop table t1;
|
||||
#
|
||||
# Test for dumping triggers
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a int, b bigint default NULL);
|
||||
CREATE TABLE t2 (a int);
|
||||
delimiter |;
|
||||
create trigger trg1 before insert on t1 for each row
|
||||
begin
|
||||
if new.a > 10 then
|
||||
set new.a := 10;
|
||||
set new.a := 11;
|
||||
end if;
|
||||
end|
|
||||
create trigger trg2 before update on t1 for each row begin
|
||||
if old.a % 2 = 0 then set new.b := 12; end if;
|
||||
end|
|
||||
create trigger trg3 after update on t1 for each row
|
||||
begin
|
||||
if new.a = -1 then
|
||||
set @fired:= "Yes";
|
||||
end if;
|
||||
end|
|
||||
create trigger trg4 before insert on t2 for each row
|
||||
begin
|
||||
if new.a > 10 then
|
||||
set @fired:= "No";
|
||||
end if;
|
||||
end|
|
||||
delimiter ;|
|
||||
--replace_column 6 '0000-00-00 00:00:00'
|
||||
show triggers like "t1";
|
||||
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
|
||||
update t1 set a = 4 where a=3;
|
||||
# Triggers should be dumped by default
|
||||
--exec $MYSQL_DUMP --skip-comments --databases test
|
||||
# Skip dumping triggers
|
||||
--exec $MYSQL_DUMP --skip-comments --databases --skip-triggers test
|
||||
# Dump and reload...
|
||||
--exec $MYSQL_DUMP --skip-comments --databases test > var/tmp/mysqldump.sql
|
||||
drop table t1;
|
||||
--exec $MYSQL test < var/tmp/mysqldump.sql
|
||||
# Check that tables have been reloaded
|
||||
show tables;
|
||||
DROP TABLE t1, t2;
|
||||
|
|
|
@ -34,6 +34,7 @@ liboptions_a_CXXFLAGS= $(CXXFLAGS) \
|
|||
-DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
|
||||
-DDEFAULT_MONITORING_INTERVAL="20" \
|
||||
-DDEFAULT_PORT="2273" \
|
||||
-DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
|
||||
-DPROTOCOL_VERSION=@PROTOCOL_VERSION@
|
||||
|
||||
liboptions_a_SOURCES= options.h options.cc priv.h priv.cc
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "mysql_manager_error.h"
|
||||
#include "protocol.h"
|
||||
#include "buffer.h"
|
||||
#include "options.h"
|
||||
|
||||
#include <m_string.h>
|
||||
#include <mysql.h>
|
||||
|
@ -643,6 +644,7 @@ Set_option::Set_option(Instance_map *instance_map_arg,
|
|||
if ((instance= instance_map->find(name, len)))
|
||||
{
|
||||
instance_name= instance->options.instance_name;
|
||||
|
||||
/* add prefix for add_option */
|
||||
if ((option_len_arg < MAX_OPTION_LEN - 1) ||
|
||||
(option_value_len_arg < MAX_OPTION_LEN - 1))
|
||||
|
@ -689,15 +691,22 @@ int Set_option::correct_file(int skip)
|
|||
{
|
||||
int error;
|
||||
|
||||
error= modify_defaults_file("/etc/my.cnf", option,
|
||||
option_value, instance_name, skip);
|
||||
if (error > 0)
|
||||
return ER_OUT_OF_RESOURCES;
|
||||
else if (error < 0)
|
||||
return ER_ACCESS_OPTION_FILE;
|
||||
error= modify_defaults_file(Options::config_file, option,
|
||||
option_value, instance_name, skip);
|
||||
|
||||
/* everything was fine */
|
||||
return 0;
|
||||
switch (error)
|
||||
{
|
||||
case 0:
|
||||
return 0; /* everything was fine */
|
||||
case 1:
|
||||
return ER_OUT_OF_RESOURCES;
|
||||
case 2:
|
||||
return ER_ACCESS_OPTION_FILE;
|
||||
default:
|
||||
DBUG_ASSERT(0); /* should never get here */
|
||||
}
|
||||
|
||||
return 0; /* keep compiler happy */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "buffer.h"
|
||||
#include "instance.h"
|
||||
#include "log.h"
|
||||
#include "options.h"
|
||||
|
||||
#include <m_ctype.h>
|
||||
#include <mysql_com.h>
|
||||
|
@ -111,9 +113,8 @@ err_new_instance:
|
|||
C_MODE_END
|
||||
|
||||
|
||||
Instance_map::Instance_map(const char *default_mysqld_path_arg,
|
||||
const char *first_option_arg):
|
||||
mysqld_path(default_mysqld_path_arg), first_option(first_option_arg)
|
||||
Instance_map::Instance_map(const char *default_mysqld_path_arg):
|
||||
mysqld_path(default_mysqld_path_arg)
|
||||
{
|
||||
pthread_mutex_init(&LOCK_instance_map, 0);
|
||||
}
|
||||
|
@ -202,7 +203,8 @@ int Instance_map::complete_initialization()
|
|||
hash_free should handle it's deletion => goto err, not
|
||||
err_instance.
|
||||
*/
|
||||
if (instance->complete_initialization(this, mysqld_path, DEFAULT_SINGLE_INSTANCE))
|
||||
if (instance->complete_initialization(this, mysqld_path,
|
||||
DEFAULT_SINGLE_INSTANCE))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
|
@ -236,18 +238,18 @@ int Instance_map::load()
|
|||
|
||||
/* the name of the program may be orbitrary here in fact */
|
||||
argv_options[0]= "mysqlmanager";
|
||||
if (first_option != NULL)
|
||||
{
|
||||
argc= 2;
|
||||
argv_options[1]= first_option;
|
||||
argv_options[2]= '\0';
|
||||
}
|
||||
else
|
||||
argv_options[1]= '\0';
|
||||
argv_options[1]= '\0';
|
||||
|
||||
if (my_search_option_files("my", &argc, (char ***) &argv, &args_used,
|
||||
process_option, (void*) this) ||
|
||||
complete_initialization())
|
||||
/*
|
||||
If the routine failed, we'll simply fallback to defaults in
|
||||
complete_initialization().
|
||||
*/
|
||||
if (my_search_option_files(Options::config_file, &argc,
|
||||
(char ***) &argv, &args_used,
|
||||
process_option, (void*) this))
|
||||
log_info("Falling back to compiled-in defaults");
|
||||
|
||||
if (complete_initialization())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -64,8 +64,7 @@ public:
|
|||
int unlock();
|
||||
int init();
|
||||
|
||||
Instance_map(const char *default_mysqld_path_arg,
|
||||
const char *first_option_arg);
|
||||
Instance_map(const char *default_mysqld_path_arg);
|
||||
~Instance_map();
|
||||
|
||||
/* loads options from config files */
|
||||
|
@ -80,7 +79,6 @@ public:
|
|||
Guardian_thread *guardian;
|
||||
|
||||
private:
|
||||
const char *first_option;
|
||||
enum { START_HASH_SIZE = 16 };
|
||||
pthread_mutex_t LOCK_instance_map;
|
||||
HASH hash;
|
||||
|
|
|
@ -68,7 +68,7 @@ void manager(const Options &options)
|
|||
*/
|
||||
|
||||
User_map user_map;
|
||||
Instance_map instance_map(options.default_mysqld_path, options.first_option);
|
||||
Instance_map instance_map(options.default_mysqld_path);
|
||||
Guardian_thread guardian_thread(thread_registry,
|
||||
&instance_map,
|
||||
options.monitoring_interval);
|
||||
|
|
|
@ -83,7 +83,7 @@ int main(int argc, char *argv[])
|
|||
if (set_user(options.user, user_info))
|
||||
{
|
||||
options.cleanup();
|
||||
return 1;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME);
|
|||
const char *Options::socket_file_name= QUOTE(DEFAULT_SOCKET_FILE_NAME);
|
||||
const char *Options::password_file_name= QUOTE(DEFAULT_PASSWORD_FILE_NAME);
|
||||
const char *Options::default_mysqld_path= QUOTE(DEFAULT_MYSQLD_PATH);
|
||||
const char *Options::first_option= 0; /* No default value */
|
||||
const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
|
||||
const char *Options::bind_address= 0; /* No default value */
|
||||
const char *Options::user= 0; /* No default value */
|
||||
uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
|
||||
|
@ -143,7 +143,12 @@ static void usage()
|
|||
printf("Usage: %s [OPTIONS] \n", my_progname);
|
||||
|
||||
my_print_help(my_long_options);
|
||||
print_defaults("my", default_groups);
|
||||
printf("\nThe following options may be given as the first argument:\n"
|
||||
"--print-defaults Print the program argument list and exit\n"
|
||||
"--defaults-file=# Only read manager configuration and instance\n"
|
||||
" setings from the given file #. The same file\n"
|
||||
" will be used to modify configuration of instances\n"
|
||||
" with SET commands.\n");
|
||||
my_print_variables(my_long_options);
|
||||
}
|
||||
|
||||
|
@ -204,31 +209,48 @@ C_MODE_END
|
|||
|
||||
|
||||
/*
|
||||
- call load_defaults to load configuration file section
|
||||
- Process argv of original program: get tid of --defaults-extra-file
|
||||
and print a message if met there.
|
||||
- call load_defaults to load configuration file section and save the pointer
|
||||
for free_defaults.
|
||||
- call handle_options to assign defaults and command-line arguments
|
||||
to the class members
|
||||
if either of these function fail, exit the program
|
||||
May not return.
|
||||
to the class members.
|
||||
if either of these function fail, return the error code.
|
||||
*/
|
||||
|
||||
int Options::load(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
saved_argv= argv;
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
if (is_prefix(argv[1],"--defaults-file=") ||
|
||||
is_prefix(argv[1],"--defaults-extra-file="))
|
||||
Options::first_option= argv[1];
|
||||
if (is_prefix(argv[1], "--defaults-file="))
|
||||
{
|
||||
Options::config_file= strchr(argv[1], '=') + 1;
|
||||
}
|
||||
if (is_prefix(argv[1], "--defaults-extra-file=") ||
|
||||
is_prefix(argv[1], "--no-defaults"))
|
||||
{
|
||||
/* the log is not enabled yet */
|
||||
fprintf(stderr, "The --defaults-extra-file and --no-defaults options"
|
||||
" are not supported by\n"
|
||||
"Instance Manager. Program aborted.\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* config-file options are prepended to command-line ones */
|
||||
load_defaults("my", default_groups, &argc, &argv);
|
||||
Options::saved_argv= argv;
|
||||
load_defaults(config_file, default_groups, &argc,
|
||||
&saved_argv);
|
||||
|
||||
if ((handle_options(&argc, &saved_argv, my_long_options,
|
||||
get_one_option)) != 0)
|
||||
goto err;
|
||||
|
||||
if ((rc= handle_options(&argc, &argv, my_long_options, get_one_option)) != 0)
|
||||
return rc;
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Options::cleanup()
|
||||
|
|
|
@ -36,11 +36,12 @@ struct Options
|
|||
static const char *default_mysqld_path;
|
||||
static const char *user;
|
||||
/* the option which should be passed to process_default_option_files */
|
||||
static const char *first_option;
|
||||
static uint monitoring_interval;
|
||||
static uint port_number;
|
||||
static const char *bind_address;
|
||||
static const char *config_file;
|
||||
|
||||
/* argv pointer returned by load_defaults() to be used by free_defaults() */
|
||||
static char **saved_argv;
|
||||
|
||||
static int load(int argc, char **argv);
|
||||
|
|
|
@ -106,7 +106,7 @@ To make maintaining easier please:
|
|||
|
||||
<charset name="latin1">
|
||||
<family>Western</family>
|
||||
<description>ISO 8859-1 West European</description>
|
||||
<description>cp1252 West European</description>
|
||||
<alias>csisolatin1</alias>
|
||||
<alias>iso-8859-1</alias>
|
||||
<alias>iso-ir-100</alias>
|
||||
|
|
|
@ -108,6 +108,13 @@ static uchar sort_order_latin1[] = {
|
|||
|
||||
- continue to pretend the latin1 character set is ISO 8859-1
|
||||
- actually allow the storage of euro etc. so it's actually cp1252
|
||||
|
||||
Also we'll map these five undefined cp1252 character:
|
||||
0x81, 0x8D, 0x8F, 0x90, 0x9D
|
||||
into corresponding control characters:
|
||||
U+0081, U+008D, U+008F, U+0090, U+009D.
|
||||
like ISO-8859-1 does. Otherwise, loading "mysqldump"
|
||||
output doesn't reproduce these undefined characters.
|
||||
*/
|
||||
|
||||
unsigned short cs_to_uni[256]={
|
||||
|
@ -127,10 +134,10 @@ unsigned short cs_to_uni[256]={
|
|||
0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
|
||||
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
|
||||
0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
|
||||
0x20AC,0x0000,0x201A,0x0192,0x201E,0x2026,0x2020,0x2021,
|
||||
0x02C6,0x2030,0x0160,0x2039,0x0152,0x0000,0x017D,0x0000,
|
||||
0x0000,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
|
||||
0x02DC,0x2122,0x0161,0x203A,0x0153,0x0000,0x017E,0x0178,
|
||||
0x20AC,0x0081,0x201A,0x0192,0x201E,0x2026,0x2020,0x2021,
|
||||
0x02C6,0x2030,0x0160,0x2039,0x0152,0x008D,0x017D,0x008F,
|
||||
0x0090,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
|
||||
0x02DC,0x2122,0x0161,0x203A,0x0153,0x009D,0x017E,0x0178,
|
||||
0x00A0,0x00A1,0x00A2,0x00A3,0x00A4,0x00A5,0x00A6,0x00A7,
|
||||
0x00A8,0x00A9,0x00AA,0x00AB,0x00AC,0x00AD,0x00AE,0x00AF,
|
||||
0x00B0,0x00B1,0x00B2,0x00B3,0x00B4,0x00B5,0x00B6,0x00B7,
|
||||
|
@ -161,10 +168,10 @@ unsigned char pl00[256]={
|
|||
0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
|
||||
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,
|
||||
0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x81,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x8D,0x00,0x8F,
|
||||
0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x9D,0x00,0x00,
|
||||
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,
|
||||
0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
|
||||
0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,
|
||||
|
|
Loading…
Add table
Reference in a new issue