1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-30 11:22:14 +03:00

rename of net_pkg.cc to protocol.cc

Class for sending data from server to client (Protocol)
This handles both the old ( <= 4.0 ) protocol and then new binary protocol that is used for prepared statements.


libmysql/libmysql.c:
  Jump over reserved bits in the binary protocol
libmysqld/Makefile.am:
  rename of net_pkg.cc to protocol.cc
mysql-test/r/case.result:
  Fixed previously wrong test
mysql-test/r/cast.result:
  Fixed previously wrong test
sql/Makefile.am:
  Rename of net_pkg.cc to protocol.cc
sql/field.cc:
  Binary protocol
  Added key handling functions for new VARCHAR type
sql/field.h:
  New protocol
sql/ha_berkeley.cc:
  New protocol
sql/ha_berkeley.h:
  New protocol
sql/ha_innodb.cc:
  New protocol
sql/ha_myisam.cc:
  New protocol
sql/item.cc:
  New protocol
sql/item.h:
  New protocol
sql/item_func.cc:
  Removed old code from 3.23
sql/item_func.h:
  Set cached_result_type as it was previosly used before set
sql/item_subselect.cc:
  Standard make_field() is now good enough
sql/item_subselect.h:
  Use default make_field()
sql/item_sum.cc:
  Clean up Item_sum::make_field()
sql/item_sum.h:
  Use standard make_field()
sql/item_timefunc.h:
  return correct types for casts()
  Use standard make_field()
sql/log_event.cc:
  New protocol
sql/log_event.h:
  New protocol
sql/mysql_priv.h:
  Move things to protocol.h
sql/opt_range.cc:
  Indentation cleanups + small optimization
sql/procedure.h:
  Use MYSQL_TYPE instead of FIELD_TYPE
sql/protocol.cc:
  Class for sending data from server to client.
  This handles both the old ( <= 4.0 ) protocol and then new binary protocol that is used for prepared statements.
sql/repl_failsafe.cc:
  New protocol
sql/slave.cc:
  New protocol
sql/sql_acl.cc:
  New protocol
sql/sql_base.cc:
  Move send_fields() to protocol.cc
sql/sql_class.cc:
  New protocol
sql/sql_class.h:
  New protocol
sql/sql_db.cc:
  New protocol
sql/sql_error.cc:
  New protocol
sql/sql_handler.cc:
  New protocol
sql/sql_help.cc:
  New protocol
sql/sql_parse.cc:
  Remove wrong assert (variable was not initalized at this point)
sql/sql_prepare.cc:
  New protocol
sql/sql_repl.cc:
  New protocol
sql/sql_select.cc:
  New protocol
sql/sql_show.cc:
  New protocol
sql/sql_string.h:
  New functions used by the protocol functions
sql/sql_table.cc:
  New protocol
sql/structs.h:
  Make second_part ulong to prepare for ANSI sub-seconds
sql/time.cc:
  New convert function needed by the new protocol functions
This commit is contained in:
unknown
2002-12-11 09:17:51 +02:00
parent b392b78400
commit f918dfc8b2
48 changed files with 2877 additions and 1659 deletions

View File

@@ -1017,20 +1017,18 @@ bool close_cached_table(THD *thd,TABLE *table)
DBUG_RETURN(result);
}
static int send_check_errmsg(THD* thd, TABLE_LIST* table,
static int send_check_errmsg(THD *thd, TABLE_LIST* table,
const char* operator_name, const char* errmsg)
{
String* packet = &thd->packet;
packet->length(0);
net_store_data(packet, table->alias);
net_store_data(packet, (char*)operator_name);
net_store_data(packet, "error");
net_store_data(packet, errmsg);
Protocol *protocol= thd->protocol;
protocol->prepare_for_resend();
protocol->store(table->alias);
protocol->store((char*) operator_name);
protocol->store("error", 5);
protocol->store(errmsg);
thd->net.last_error[0]=0;
if (my_net_write(&thd->net, (char*) thd->packet.ptr(),
packet->length()))
if (protocol->write())
return -1;
return 1;
}
@@ -1176,8 +1174,8 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
{
TABLE_LIST *table;
List<Item> field_list;
Item* item;
String* packet = &thd->packet;
Item *item;
Protocol *protocol= thd->protocol;
DBUG_ENTER("mysql_admin_table");
field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2));
@@ -1188,7 +1186,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
item->maybe_null = 1;
field_list.push_back(item = new Item_empty_string("Msg_text", 255));
item->maybe_null = 1;
if (send_fields(thd, field_list, 1))
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(-1);
for (table = tables; table; table = table->next)
@@ -1201,7 +1199,8 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->open_options|= extra_open_options;
table->table = open_ltable(thd, table, lock_type);
thd->open_options&= ~extra_open_options;
packet->length(0);
protocol->prepare_for_resend();
if (prepare_func)
{
switch ((*prepare_func)(thd, table, check_opt)) {
@@ -1214,30 +1213,30 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
if (!table->table)
{
const char *err_msg;
net_store_data(packet, table_name);
net_store_data(packet, operator_name);
net_store_data(packet, "error");
protocol->prepare_for_resend();
protocol->store(table_name);
protocol->store(operator_name);
protocol->store("error",5);
if (!(err_msg=thd->net.last_error))
err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
net_store_data(packet, err_msg);
protocol->store(err_msg);
thd->net.last_error[0]=0;
if (my_net_write(&thd->net, (char*) thd->packet.ptr(),
packet->length()))
if (protocol->write())
goto err;
continue;
}
if ((table->table->db_stat & HA_READ_ONLY) && open_for_modify)
{
char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
net_store_data(packet, table_name);
net_store_data(packet, operator_name);
net_store_data(packet, "error");
protocol->prepare_for_resend();
protocol->store(table_name);
protocol->store(operator_name);
protocol->store("error", 5);
sprintf(buff, ER(ER_OPEN_AS_READONLY), table_name);
net_store_data(packet, buff);
protocol->store(buff);
close_thread_tables(thd);
table->table=0; // For query cache
if (my_net_write(&thd->net, (char*) thd->packet.ptr(),
packet->length()))
if (protocol->write())
goto err;
continue;
}
@@ -1265,50 +1264,50 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
int result_code = (table->table->file->*operator_func)(thd, check_opt);
packet->length(0);
net_store_data(packet, table_name);
net_store_data(packet, operator_name);
protocol->prepare_for_resend();
protocol->store(table_name);
protocol->store(operator_name);
switch (result_code) {
case HA_ADMIN_NOT_IMPLEMENTED:
{
char buf[ERRMSGSIZE+20];
my_snprintf(buf, ERRMSGSIZE,
ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
net_store_data(packet, "error");
net_store_data(packet, buf);
uint length=my_snprintf(buf, ERRMSGSIZE,
ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
protocol->store("error", 5);
protocol->store(buf, length);
}
break;
case HA_ADMIN_OK:
net_store_data(packet, "status");
net_store_data(packet, "OK");
protocol->store("status", 6);
protocol->store("OK",2);
break;
case HA_ADMIN_FAILED:
net_store_data(packet, "status");
net_store_data(packet, "Operation failed");
protocol->store("status", 6);
protocol->store("Operation failed",16);
break;
case HA_ADMIN_ALREADY_DONE:
net_store_data(packet, "status");
net_store_data(packet, "Table is already up to date");
protocol->store("status", 6);
protocol->store("Table is already up to date", 27);
break;
case HA_ADMIN_CORRUPT:
net_store_data(packet, "error");
net_store_data(packet, "Corrupt");
protocol->store("error", 5);
protocol->store("Corrupt", 8);
fatal_error=1;
break;
case HA_ADMIN_INVALID:
net_store_data(packet, "error");
net_store_data(packet, "Invalid argument");
protocol->store("error", 5);
protocol->store("Invalid argument",16);
break;
default: // Probably HA_ADMIN_INTERNAL_ERROR
net_store_data(packet, "error");
net_store_data(packet, "Unknown - internal error during operation");
protocol->store("error", 5);
protocol->store("Unknown - internal error during operation", 41);
fatal_error=1;
break;
}
@@ -1325,8 +1324,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
close_thread_tables(thd);
table->table=0; // For query cache
if (my_net_write(&thd->net, (char*) packet->ptr(),
packet->length()))
if (protocol->write())
goto err;
}