summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
authorunknown <holyfoot@deer.(none)>2006-01-04 14:20:28 +0400
committerunknown <holyfoot@deer.(none)>2006-01-04 14:20:28 +0400
commit6b27acbdf41dd3c990af4627ddaf8fbfcd8eb4e6 (patch)
treebcb306f8c631b6b3153296059aae11b7e290ded7 /sql/protocol.cc
parent81ca15813bfc482ac98614de41a867e47dde07d3 (diff)
downloadmariadb-git-6b27acbdf41dd3c990af4627ddaf8fbfcd8eb4e6.tar.gz
Big patch to make embedded-server working in 5.x
Now it supports queries returning several results (particularly important with the SP) include/mysql.h: embedded_query_result structure added libmysql/libmysql.c: embedded-server related fixes libmysqld/emb_qcache.cc: multiple-result support added libmysqld/embedded_priv.h: embedded_query_result struct implemented libmysqld/lib_sql.cc: multiple-result support added libmysqld/libmysqld.c: small fixes mysql-test/t/backup.test: test fixed mysql-test/t/binlog_stm_binlog.test: test fixed mysql-test/t/binlog_stm_blackhole.test: test fixed mysql-test/t/binlog_stm_ctype_cp932.test: test fixed mysql-test/t/compress.test: test fixed mysql-test/t/delayed.test: test fixed mysql-test/t/federated.test: test fixed mysql-test/t/federated_archive.test: test fixed mysql-test/t/federated_bug_13118.test: test fixed mysql-test/t/federated_transactions.test: test fixed mysql-test/t/flush_table.test: test fixed mysql-test/t/handler.test: test fixed mysql-test/t/init_connect.test: test fixed mysql-test/t/innodb.test: test fixed mysql-test/t/mysql.test: test fixed mysql-test/t/mysql_client_test.test: test fixed mysql-test/t/mysqltest.test: test fixed mysql-test/t/query_cache.test: test fixed mysql-test/t/query_cache_notembedded.test: test fixed mysql-test/t/read_only.test: test fixed mysql-test/t/skip_grants.test: test fixed mysql-test/t/sp-destruct.test: test fixed mysql-test/t/sp-error.test: test fixed mysql-test/t/sp-threads.test: test fixed mysql-test/t/sp.test: test fixed mysql-test/t/view.test: test fixed mysql-test/t/wait_timeout.test: test fixed sql-common/client.c: small fixes sql/mysqld.cc: embedded-server related fix sql/protocol.cc: embedded-server related fix sql/protocol.h: embedded-server related fix sql/sql_class.cc: embedded-server related fix sql/sql_class.h: embedded-server related fix sql/sql_cursor.cc: embedded-server related fix sql/sql_parse.cc: embedded-server related fix sql/sql_prepare.cc: embedded-server related fix
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r--sql/protocol.cc82
1 files changed, 43 insertions, 39 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 0a1b42f5236..98cded56871 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -29,6 +29,7 @@
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
static void write_eof_packet(THD *thd, NET *net);
+void net_send_error_packet(THD *thd, uint sql_errno, const char *err);
#ifndef EMBEDDED_LIBRARY
bool Protocol::net_store_data(const char *from, uint length)
@@ -56,10 +57,6 @@ bool Protocol_prep::net_store_data(const char *from, uint length)
void net_send_error(THD *thd, uint sql_errno, const char *err)
{
-#ifndef EMBEDDED_LIBRARY
- uint length;
- char buff[MYSQL_ERRMSG_SIZE+2], *pos;
-#endif
NET *net= &thd->net;
bool generate_warning= thd->killed != THD::KILL_CONNECTION;
DBUG_ENTER("net_send_error");
@@ -106,42 +103,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err);
}
-#ifdef EMBEDDED_LIBRARY
- net->last_errno= sql_errno;
- strmake(net->last_error, err, sizeof(net->last_error)-1);
- strmov(net->sqlstate, mysql_errno_to_sqlstate(sql_errno));
-#else
-
- if (net->vio == 0)
- {
- if (thd->bootstrap)
- {
- /* In bootstrap it's ok to print on stderr */
- fprintf(stderr,"ERROR: %d %s\n",sql_errno,err);
- }
- DBUG_VOID_RETURN;
- }
+ net_send_error_packet(thd, sql_errno, err);
- if (net->return_errno)
- { // new client code; Add errno before message
- int2store(buff,sql_errno);
- pos= buff+2;
- if (thd->client_capabilities & CLIENT_PROTOCOL_41)
- {
- /* The first # is to make the protocol backward compatible */
- buff[2]= '#';
- pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
- }
- length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
- err=buff;
- }
- else
- {
- length=(uint) strlen(err);
- set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
- }
- VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
-#endif /* EMBEDDED_LIBRARY*/
thd->is_fatal_error=0; // Error message is given
thd->net.report_error= 0;
@@ -430,6 +393,47 @@ bool send_old_password_request(THD *thd)
return my_net_write(net, eof_buff, 1) || net_flush(net);
}
+
+void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
+{
+ NET *net= &thd->net;
+ uint length;
+ char buff[MYSQL_ERRMSG_SIZE+2], *pos;
+
+ DBUG_ENTER("send_error_packet");
+
+ if (net->vio == 0)
+ {
+ if (thd->bootstrap)
+ {
+ /* In bootstrap it's ok to print on stderr */
+ fprintf(stderr,"ERROR: %d %s\n",sql_errno,err);
+ }
+ DBUG_VOID_RETURN;
+ }
+
+ if (net->return_errno)
+ { // new client code; Add errno before message
+ int2store(buff,sql_errno);
+ pos= buff+2;
+ if (thd->client_capabilities & CLIENT_PROTOCOL_41)
+ {
+ /* The first # is to make the protocol backward compatible */
+ buff[2]= '#';
+ pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
+ }
+ length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
+ err=buff;
+ }
+ else
+ {
+ length=(uint) strlen(err);
+ set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
+ }
+ VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
+ DBUG_VOID_RETURN;
+}
+
#endif /* EMBEDDED_LIBRARY */
/*