Commit 17c845bc authored by konstantin@mysql.com's avatar konstantin@mysql.com

Microsoft VC++ won't compile class C { static const int I=1; }.

Putting initialization into .cc will reduce compiler's abilities
to optimize this constant away.
Defines are not OK as they bloat global namespace.
Looking for a way to declare an efficient named constant in reduced
namespace (i. e. in  a class).
Let's try enums: normally they should be implicitly casted to int.
Let's see if we really have a compiler which won't do that.
parent f7234385
...@@ -568,7 +568,7 @@ int check_embedded_connection(MYSQL *mysql) ...@@ -568,7 +568,7 @@ int check_embedded_connection(MYSQL *mysql)
C_MODE_END C_MODE_END
bool Protocol::send_fields(List<Item> *list, uint flags) bool Protocol::send_fields(List<Item> *list, int flags)
{ {
List_iterator_fast<Item> it(*list); List_iterator_fast<Item> it(*list);
Item *item; Item *item;
...@@ -615,7 +615,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags) ...@@ -615,7 +615,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
if (INTERNAL_NUM_FIELD(client_field)) if (INTERNAL_NUM_FIELD(client_field))
client_field->flags|= NUM_FLAG; client_field->flags|= NUM_FLAG;
if (flags & Protocol::SEND_DEFAULTS) if (flags & (int) Protocol::SEND_DEFAULTS)
{ {
char buff[80]; char buff[80];
String tmp(buff, sizeof(buff), default_charset_info), *res; String tmp(buff, sizeof(buff), default_charset_info), *res;
......
...@@ -498,7 +498,7 @@ void Protocol::init(THD *thd_arg) ...@@ -498,7 +498,7 @@ void Protocol::init(THD *thd_arg)
*/ */
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
bool Protocol::send_fields(List<Item> *list, uint flags) bool Protocol::send_fields(List<Item> *list, int flags)
{ {
List_iterator_fast<Item> it(*list); List_iterator_fast<Item> it(*list);
Item *item; Item *item;
......
...@@ -51,10 +51,8 @@ class Protocol ...@@ -51,10 +51,8 @@ class Protocol
virtual ~Protocol() {} virtual ~Protocol() {}
void init(THD* thd_arg); void init(THD* thd_arg);
static const uint SEND_NUM_ROWS= 1; enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
static const uint SEND_DEFAULTS= 2; virtual bool send_fields(List<Item> *list, int flags);
static const uint SEND_EOF= 4;
virtual bool send_fields(List<Item> *list, uint flags);
bool send_records_num(List<Item> *list, ulonglong records); bool send_records_num(List<Item> *list, ulonglong records);
bool store(I_List<i_string> *str_list); bool store(I_List<i_string> *str_list);
...@@ -168,7 +166,7 @@ class Protocol_cursor :public Protocol_simple ...@@ -168,7 +166,7 @@ class Protocol_cursor :public Protocol_simple
prev_record= &data; prev_record= &data;
return Protocol_simple::prepare_for_send(item_list); return Protocol_simple::prepare_for_send(item_list);
} }
bool send_fields(List<Item> *list, uint flags); bool send_fields(List<Item> *list, int flags);
bool write(); bool write();
uint get_field_count() { return field_count; } uint get_field_count() { return field_count; }
}; };
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include <mysql.h> #include <mysql.h>
bool Protocol_cursor::send_fields(List<Item> *list, uint flags) bool Protocol_cursor::send_fields(List<Item> *list, int flags)
{ {
List_iterator_fast<Item> it(*list); List_iterator_fast<Item> it(*list);
Item *item; Item *item;
...@@ -67,7 +67,7 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flags) ...@@ -67,7 +67,7 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flags)
if (INTERNAL_NUM_FIELD(client_field)) if (INTERNAL_NUM_FIELD(client_field))
client_field->flags|= NUM_FLAG; client_field->flags|= NUM_FLAG;
if (flags & Protocol::SEND_DEFAULTS) if (flags & (int) Protocol::SEND_DEFAULTS)
{ {
char buff[80]; char buff[80];
String tmp(buff, sizeof(buff), default_charset_info), *res; String tmp(buff, sizeof(buff), default_charset_info), *res;
......
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