summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-12-11 09:17:51 +0200
committerunknown <monty@mashka.mysql.fi>2002-12-11 09:17:51 +0200
commitf918dfc8b2e449fc55c6f8466bc1a923f47e5a44 (patch)
tree2f31768712119785f5bf2520a2d7e6dd4dfe37b5 /sql/sql_base.cc
parentb392b78400abf319550eedd636faa9eae66b9510 (diff)
downloadmariadb-git-f918dfc8b2e449fc55c6f8466bc1a923f47e5a44.tar.gz
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
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc244
1 files changed, 0 insertions, 244 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index e2b36106fb0..87cc0d616a9 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -196,250 +196,6 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild)
}
-/*
- Send name and type of result to client converted to a given char set
-
- SYNOPSIS
- send_convert_fields()
- THD Thread data object
- list List of items to send to client
- convert object used to convertation to another character set
- flag Bit mask with the following functions:
- 2 send default values
- 4 Don't convert field names
-
- DESCRIPTION
- Sum fields has table name empty and field_name.
-
- RETURN VALUES
- 0 ok
- 1 Error (Note that in this case the error is not sent to the client)
-*/
-
-bool
-send_convert_fields(THD *thd,List<Item> &list,CONVERT *convert,uint flag)
-{
- List_iterator_fast<Item> it(list);
- Item *item;
- char buff[80];
- String tmp((char*) buff,sizeof(buff),default_charset_info);
- String *res,*packet= &thd->packet;
- DBUG_ENTER("send_convert_fields");
-
- while ((item=it++))
- {
- char *pos;
- Send_field field;
- item->make_field(&field);
- packet->length(0);
-
- if (thd->client_capabilities & CLIENT_PROTOCOL_41)
- {
- if (convert->store(packet,field.db_name,
- (uint) strlen(field.db_name)) ||
- convert->store(packet,field.table_name,
- (uint) strlen(field.table_name)) ||
- convert->store(packet,field.org_table_name,
- (uint) strlen(field.org_table_name)) ||
- convert->store(packet,field.col_name,
- (uint) strlen(field.col_name)) ||
- convert->store(packet,field.org_col_name,
- (uint) strlen(field.org_col_name)) ||
- packet->realloc(packet->length()+10))
- goto err;
- }
- else
- {
- if (convert->store(packet,field.table_name,
- (uint) strlen(field.table_name)) ||
- convert->store(packet,field.col_name,
- (uint) strlen(field.col_name)) ||
- packet->realloc(packet->length()+10))
- goto err;
- }
- pos= (char*) packet->ptr()+packet->length();
-
- if (!(thd->client_capabilities & CLIENT_LONG_FLAG))
- {
- packet->length(packet->length()+9);
- pos[0]=3; int3store(pos+1,field.length);
- pos[4]=1; pos[5]=field.type;
- pos[6]=2; pos[7]=(char) field.flags; pos[8]= (char) field.decimals;
- }
- else
- {
- packet->length(packet->length()+10);
- pos[0]=3; int3store(pos+1,field.length);
- pos[4]=1; pos[5]=field.type;
- pos[6]=3; int2store(pos+7,field.flags); pos[9]= (char) field.decimals;
- }
- if (flag & 2)
- { // Send default value
- if (!(res=item->val_str(&tmp)))
- {
- if (net_store_null(packet))
- goto err;
- }
- else if (convert->store(packet,res->ptr(),res->length()))
- goto err;
- }
- if (my_net_write(&thd->net, (char*) packet->ptr(),packet->length()))
- break; /* purecov: inspected */
- }
- DBUG_RETURN(0);
-
-err:
- DBUG_RETURN(1);
-}
-
-
-/*
- Send name and type of result to client.
-
- SYNOPSIS
- send_non_convert_fields()
- THD Thread data object
- list List of items to send to client
- flag Bit mask with the following functions:
- 2 send default values
- 4 Don't convert field names
-
- DESCRIPTION
- Sum fields has table name empty and field_name.
-
- RETURN VALUES
- 0 ok
- 1 Error
-*/
-
-bool
-send_non_convert_fields(THD *thd,List<Item> &list,uint flag)
-{
- List_iterator_fast<Item> it(list);
- Item *item;
- char buff[80];
-
- String tmp((char*) buff,sizeof(buff),default_charset_info);
- String *res,*packet= &thd->packet;
-
- while ((item=it++))
- {
- char *pos;
- Send_field field;
- item->make_field(&field);
- packet->length(0);
-
- if (thd->client_capabilities & CLIENT_PROTOCOL_41)
- {
- if (net_store_data(packet,field.db_name) ||
- net_store_data(packet,field.table_name) ||
- net_store_data(packet,field.org_table_name) ||
- net_store_data(packet,field.col_name) ||
- net_store_data(packet,field.org_col_name) ||
- packet->realloc(packet->length()+10))
- return 1;
- }
- else
- {
- if (net_store_data(packet,field.table_name) ||
- net_store_data(packet,field.col_name) ||
- packet->realloc(packet->length()+10))
- return 1;
- }
-
- pos= (char*) packet->ptr()+packet->length();
-
- if (!(thd->client_capabilities & CLIENT_LONG_FLAG))
- {
- packet->length(packet->length()+9);
- pos[0]=3; int3store(pos+1,field.length);
- pos[4]=1; pos[5]=field.type;
- pos[6]=2; pos[7]=(char) field.flags; pos[8]= (char) field.decimals;
- }
- else
- {
- packet->length(packet->length()+10);
- pos[0]=3; int3store(pos+1,field.length);
- pos[4]=1; pos[5]=field.type;
- pos[6]=3; int2store(pos+7,field.flags); pos[9]= (char) field.decimals;
- }
- if (flag & 2)
- { // Send default value
- if (!(res=item->val_str(&tmp)))
- {
- if (net_store_null(packet))
- return 1;
- }
- else if (net_store_data(packet,res->ptr(),res->length()))
- return 1;
- }
- if (my_net_write(&thd->net, (char*) packet->ptr(),packet->length()))
- break;
- }
- return 0;
-}
-
-
-/*
- Send name and type of result to client.
-
- SYNOPSIS
- send_fields()
- THD Thread data object
- list List of items to send to client
- convert object used to convertation to another character set
- flag Bit mask with the following functions:
- 1 send number of rows
- 2 send default values
- 4 Don't convert field names
-
- DESCRIPTION
- Sum fields has table name empty and field_name.
- Uses send_fields_convert() and send_fields() depending on
- if we have an active character set convert or not.
-
- RETURN VALUES
- 0 ok
- 1 Error (Note that in this case the error is not sent to the client)
-*/
-
-bool
-send_fields(THD *thd, List<Item> &list, uint flag)
-{
- char buff[9]; // Big enough for store_length
- CONVERT *convert= (flag & 4) ? (CONVERT*) 0 : thd->variables.convert_set;
- DBUG_ENTER("send_fields");
-
- if (thd->fatal_error) // We have got an error
- goto err;
-
- if (flag & 1)
- { // Packet with number of elements
- char *pos=net_store_length(buff, (uint) list.elements);
- (void) my_net_write(&thd->net, buff,(uint) (pos-buff));
- }
-
- /*
- Avoid check conditions on convert() for each field
- by having two different functions
- */
- if (convert)
- {
- if (send_convert_fields(thd, list, convert, flag))
- goto err;
- }
- else if (send_non_convert_fields(thd, list, flag))
- goto err;
-
- send_eof(thd);
- DBUG_RETURN(0);
-
-err:
- send_error(thd,ER_OUT_OF_RESOURCES); /* purecov: inspected */
- DBUG_RETURN(1); /* purecov: inspected */
-}
-
-
/*****************************************************************************
* Functions to free open table cache
****************************************************************************/