Commit d5ae0825 authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  neptunus.(none):/home/msvensson/mysql/bug10713_new/my50-bug10713_new
parents 7d787493 ef064015
No related merge requests found
...@@ -29,13 +29,13 @@ id name ...@@ -29,13 +29,13 @@ id name
1 foo 1 foo
2 bar 2 bar
DELETE FROM federated.t1 WHERE id = 1; DELETE FROM federated.t1 WHERE id = 1;
ERROR HY000: There was a problem processing the query on the foreign data source. Data source error: ': 1031 : Table storage engine for 'archive_table' doesn't have t' ERROR HY000: Got error 10000 'Error on remote system: 1031: Table storage engine for 'archive_table' doesn't have this option' from FEDERATED
SELECT * FROM federated.t1; SELECT * FROM federated.t1;
id name id name
1 foo 1 foo
2 bar 2 bar
UPDATE federated.t1 SET name='baz' WHERE id = 1; UPDATE federated.t1 SET name='baz' WHERE id = 1;
ERROR HY000: There was a problem processing the query on the foreign data source. Data source error: ': 1031 : Table storage engine for 'archive_table' doesn't have t' ERROR HY000: Got error 10000 'Error on remote system: 1031: Table storage engine for 'archive_table' doesn't have this option' from FEDERATED
SELECT * FROM federated.t1; SELECT * FROM federated.t1;
id name id name
1 foo 1 foo
......
...@@ -32,19 +32,19 @@ INSERT INTO federated.t1 (id, name) VALUES (2, 'bar'); ...@@ -32,19 +32,19 @@ INSERT INTO federated.t1 (id, name) VALUES (2, 'bar');
SELECT * FROM federated.t1; SELECT * FROM federated.t1;
--error 1430 --error 1296
DELETE FROM federated.t1 WHERE id = 1; DELETE FROM federated.t1 WHERE id = 1;
SELECT * FROM federated.t1; SELECT * FROM federated.t1;
--error 1430 --error 1296
UPDATE federated.t1 SET name='baz' WHERE id = 1; UPDATE federated.t1 SET name='baz' WHERE id = 1;
SELECT * FROM federated.t1; SELECT * FROM federated.t1;
# --error 1430 # --error 1296
# TRUNCATE federated.t1; # TRUNCATE federated.t1;
# #
# SELECT * from federated.t1; # SELECT * from federated.t1;
......
...@@ -473,13 +473,15 @@ static int check_foreign_data_source( ...@@ -473,13 +473,15 @@ static int check_foreign_data_source(
else else
{ {
/* /*
Since we do not support transactions at this version, we can let the client Since we do not support transactions at this version, we can let the
API silently reconnect. For future versions, we will need more logic to deal client API silently reconnect. For future versions, we will need more
with transactions logic to deal with transactions
*/ */
mysql->reconnect= 1; mysql->reconnect= 1;
/* /*
Note: I am not using INORMATION_SCHEMA because this needs to work with < 5.0 Note: I am not using INORMATION_SCHEMA because this needs to work with
versions prior to 5.0
if we can connect, then make sure the table exists if we can connect, then make sure the table exists
the query will be: SELECT * FROM `tablename` WHERE 1=0 the query will be: SELECT * FROM `tablename` WHERE 1=0
...@@ -497,7 +499,8 @@ static int check_foreign_data_source( ...@@ -497,7 +499,8 @@ static int check_foreign_data_source(
query.append(FEDERATED_WHERE); query.append(FEDERATED_WHERE);
query.append(FEDERATED_FALSE); query.append(FEDERATED_FALSE);
DBUG_PRINT("info", ("check_foreign_data_source query %s", query.c_ptr_quick())); DBUG_PRINT("info", ("check_foreign_data_source query %s",
query.c_ptr_quick()));
if (mysql_real_query(mysql, query.ptr(), query.length())) if (mysql_real_query(mysql, query.ptr(), query.length()))
{ {
error_code= table_create_flag ? error_code= table_create_flag ?
...@@ -1449,13 +1452,7 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked) ...@@ -1449,13 +1452,7 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked)
share->port, share->port,
share->socket, 0)) share->socket, 0))
{ {
int error_code; DBUG_RETURN(stash_remote_error());
char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
error_code= ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
my_sprintf(error_buffer, (error_buffer, ": %d : %s",
mysql_errno(mysql), mysql_error(mysql)));
my_error(error_code, MYF(0), error_buffer);
DBUG_RETURN(error_code);
} }
/* /*
Since we do not support transactions at this version, we can let the client Since we do not support transactions at this version, we can let the client
...@@ -1687,13 +1684,7 @@ int ha_federated::write_row(byte *buf) ...@@ -1687,13 +1684,7 @@ int ha_federated::write_row(byte *buf)
if (mysql_real_query(mysql, insert_string.ptr(), insert_string.length())) if (mysql_real_query(mysql, insert_string.ptr(), insert_string.length()))
{ {
int error_code; DBUG_RETURN(stash_remote_error());
char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
error_code= ER_QUERY_ON_FOREIGN_DATA_SOURCE;
my_sprintf(error_buffer, (error_buffer, ": %d : %s",
mysql_errno(mysql), mysql_error(mysql)));
my_error(error_code, MYF(0), error_buffer);
DBUG_RETURN(error_code);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1717,8 +1708,7 @@ int ha_federated::optimize(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1717,8 +1708,7 @@ int ha_federated::optimize(THD* thd, HA_CHECK_OPT* check_opt)
if (mysql_real_query(mysql, query.ptr(), query.length())) if (mysql_real_query(mysql, query.ptr(), query.length()))
{ {
my_error(-1, MYF(0), mysql_error(mysql)); DBUG_RETURN(stash_remote_error());
DBUG_RETURN(-1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1748,8 +1738,7 @@ int ha_federated::repair(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1748,8 +1738,7 @@ int ha_federated::repair(THD* thd, HA_CHECK_OPT* check_opt)
if (mysql_real_query(mysql, query.ptr(), query.length())) if (mysql_real_query(mysql, query.ptr(), query.length()))
{ {
my_error(-1, MYF(0), mysql_error(mysql)); DBUG_RETURN(stash_remote_error());
DBUG_RETURN(-1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1892,12 +1881,7 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) ...@@ -1892,12 +1881,7 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
if (mysql_real_query(mysql, update_string.ptr(), update_string.length())) if (mysql_real_query(mysql, update_string.ptr(), update_string.length()))
{ {
int error_code= ER_QUERY_ON_FOREIGN_DATA_SOURCE; DBUG_RETURN(stash_remote_error());
char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
my_sprintf(error_buffer, (error_buffer, ": %d : %s",
mysql_errno(mysql), mysql_error(mysql)));
my_error(error_code, MYF(0), error_buffer);
DBUG_RETURN(error_code);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1962,12 +1946,7 @@ int ha_federated::delete_row(const byte *buf) ...@@ -1962,12 +1946,7 @@ int ha_federated::delete_row(const byte *buf)
("Delete sql: %s", delete_string.c_ptr_quick())); ("Delete sql: %s", delete_string.c_ptr_quick()));
if (mysql_real_query(mysql, delete_string.ptr(), delete_string.length())) if (mysql_real_query(mysql, delete_string.ptr(), delete_string.length()))
{ {
int error_code= ER_QUERY_ON_FOREIGN_DATA_SOURCE; DBUG_RETURN(stash_remote_error());
char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
my_sprintf(error_buffer, (error_buffer, ": %d : %s",
mysql_errno(mysql), mysql_error(mysql)));
my_error(error_code, MYF(0), error_buffer);
DBUG_RETURN(error_code);
} }
deleted+= mysql->affected_rows; deleted+= mysql->affected_rows;
DBUG_PRINT("info", DBUG_PRINT("info",
...@@ -2262,13 +2241,7 @@ int ha_federated::rnd_init(bool scan) ...@@ -2262,13 +2241,7 @@ int ha_federated::rnd_init(bool scan)
DBUG_RETURN(0); DBUG_RETURN(0);
error: error:
retval= ER_QUERY_ON_FOREIGN_DATA_SOURCE; DBUG_RETURN(stash_remote_error());
my_sprintf(error_buffer, (error_buffer, ": %d : %s",
mysql_errno(mysql), mysql_error(mysql)));
my_error(retval, MYF(0), error_buffer);
DBUG_PRINT("info",
("return error code %d", retval));
DBUG_RETURN(retval);
} }
int ha_federated::rnd_end() int ha_federated::rnd_end()
...@@ -2551,12 +2524,7 @@ int ha_federated::delete_all_rows() ...@@ -2551,12 +2524,7 @@ int ha_federated::delete_all_rows()
deleted+= records; deleted+= records;
if (mysql_real_query(mysql, query.ptr(), query.length())) if (mysql_real_query(mysql, query.ptr(), query.length()))
{ {
int error_code= ER_QUERY_ON_FOREIGN_DATA_SOURCE; DBUG_RETURN(stash_remote_error());
char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
my_sprintf(error_buffer, (error_buffer, ": %d : %s",
mysql_errno(mysql), mysql_error(mysql)));
my_error(error_code, MYF(0), error_buffer);
DBUG_RETURN(error_code);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -2665,4 +2633,33 @@ error: ...@@ -2665,4 +2633,33 @@ error:
DBUG_RETURN(retval); DBUG_RETURN(retval);
} }
int ha_federated::stash_remote_error()
{
DBUG_ENTER("ha_federated::stash_remote_error()");
remote_error_number= mysql_errno(mysql);
snprintf(remote_error_buf, FEDERATED_QUERY_BUFFER_SIZE, mysql_error(mysql));
DBUG_RETURN(HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM);
}
bool ha_federated::get_error_message(int error, String* buf)
{
DBUG_ENTER("ha_federated::get_error_message");
DBUG_PRINT("enter", ("error: %d", error));
if (error == HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM)
{
buf->append("Error on remote system: ");
buf->qs_append(remote_error_number);
buf->append(": ");
buf->append(remote_error_buf, FEDERATED_QUERY_BUFFER_SIZE);
remote_error_number= 0;
remote_error_buf[0]= '\0';
}
DBUG_PRINT("exit", ("message: %s", buf->ptr()));
DBUG_RETURN(FALSE);
}
#endif /* HAVE_FEDERATED_DB */ #endif /* HAVE_FEDERATED_DB */
...@@ -27,6 +27,14 @@ ...@@ -27,6 +27,14 @@
#include <mysql.h> #include <mysql.h>
/*
handler::print_error has a case statement for error numbers.
This value is (10000) is far out of range and will envoke the
default: case.
(Current error range is 120-159 from include/my_base.h)
*/
#define HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM 10000
#define FEDERATED_QUERY_BUFFER_SIZE STRING_BUFFER_USUAL_SIZE * 5 #define FEDERATED_QUERY_BUFFER_SIZE STRING_BUFFER_USUAL_SIZE * 5
#define FEDERATED_RECORDS_IN_RANGE 2 #define FEDERATED_RECORDS_IN_RANGE 2
...@@ -149,6 +157,8 @@ class ha_federated: public handler ...@@ -149,6 +157,8 @@ class ha_federated: public handler
uint ref_length; uint ref_length;
uint fetch_num; // stores the fetch num uint fetch_num; // stores the fetch num
MYSQL_ROW_OFFSET current_position; // Current position used by ::position() MYSQL_ROW_OFFSET current_position; // Current position used by ::position()
int remote_error_number;
char remote_error_buf[FEDERATED_QUERY_BUFFER_SIZE];
private: private:
/* /*
...@@ -160,6 +170,7 @@ private: ...@@ -160,6 +170,7 @@ private:
const key_range *start_key, const key_range *start_key,
const key_range *end_key, const key_range *end_key,
bool records_in_range); bool records_in_range);
int stash_remote_error();
public: public:
ha_federated(TABLE *table_arg); ha_federated(TABLE *table_arg);
...@@ -286,6 +297,7 @@ public: ...@@ -286,6 +297,7 @@ public:
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type); //required enum thr_lock_type lock_type); //required
virtual bool get_error_message(int error, String *buf);
}; };
bool federated_db_init(void); bool federated_db_init(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment