Commit dcb52935 authored by hf@deer.mysql.r18.ru's avatar hf@deer.mysql.r18.ru

Some fixes

parent 5e8b27c0
...@@ -23,6 +23,7 @@ heikki@rescue. ...@@ -23,6 +23,7 @@ heikki@rescue.
heikki@work.mysql.com heikki@work.mysql.com
hf@bison.(none) hf@bison.(none)
hf@bisonxp.(none) hf@bisonxp.(none)
hf@deer.mysql.r18.ru
hf@genie.(none) hf@genie.(none)
jani@dsl-jkl1657.dial.inet.fi jani@dsl-jkl1657.dial.inet.fi
jani@hynda.(none) jani@hynda.(none)
......
...@@ -380,13 +380,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) ...@@ -380,13 +380,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
error_handler_hook = my_message_sql; error_handler_hook = my_message_sql;
opt_noacl = 1; // No permissions opt_noacl = 1; // No permissions
if (acl_init(opt_noacl)) if (acl_init((THD *)0, opt_noacl))
{ {
mysql_server_end(); mysql_server_end();
return 1; return 1;
} }
if (!opt_noacl) if (!opt_noacl)
(void) grant_init(); (void) grant_init((THD *)0);
init_max_user_conn(); init_max_user_conn();
init_update_queries(); init_update_queries();
...@@ -664,13 +664,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) ...@@ -664,13 +664,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
exit(1); exit(1);
} }
opt_noacl = 1; // No permissions opt_noacl = 1; // No permissions
if (acl_init((THD*) 0,opt_noacl)) if (acl_init(opt_noacl))
{ {
mysql_server_end(); mysql_server_end();
return 1; return 1;
} }
if (!opt_noacl) if (!opt_noacl)
(void) grant_init((THD*) 0); (void) grant_init();
init_max_user_conn(); init_max_user_conn();
init_update_queries(); init_update_queries();
...@@ -1148,9 +1148,10 @@ bool send_fields(THD *thd, List<Item> &list, uint flag) ...@@ -1148,9 +1148,10 @@ bool send_fields(THD *thd, List<Item> &list, uint flag)
MYSQL *mysql= thd->mysql; MYSQL *mysql= thd->mysql;
if (!(mysql->result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+ if (!(mysql->result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
sizeof(ulong) * field_count, sizeof(ulong) * (field_count + 1),
MYF(MY_WME | MY_ZEROFILL)))) MYF(MY_WME | MY_ZEROFILL))))
goto err; goto err;
mysql->result->lengths= (ulong *)(mysql->result + 1);
mysql->field_count=field_count; mysql->field_count=field_count;
alloc= &mysql->field_alloc; alloc= &mysql->field_alloc;
...@@ -1241,83 +1242,6 @@ net_field_length(uchar **packet) ...@@ -1241,83 +1242,6 @@ net_field_length(uchar **packet)
return (ulong) uint4korr(pos+1); return (ulong) uint4korr(pos+1);
} }
#ifdef __DUMMY
bool select_send___send_data(List<Item> &items)
{
List_iterator_fast<Item> li(items);
Item *item;
String *packet= &thd->packet;
MYSQL *mysql= thd->mysql;
MYSQL_DATA *result= mysql->result->data;
MYSQL_ROWS **prev_ptr= &mysql->result->data->data;
MYSQL_ROWS *cur;
MEM_ROOT *alloc= &mysql->result->data->alloc;
char *to;
int n_fields= items.elements;
uchar *cp;
MYSQL_FIELD *mysql_fields= mysql->result->fields;
MYSQL_ROW cur_field, end_field;
ulong len;
DBUG_ENTER("send_data");
if (unit->offset_limit_cnt)
{ // using limit offset,count
unit->offset_limit_cnt--;
DBUG_RETURN(0);
}
thd->packet.length(0);
while ((item=li++))
{
if (item->send(thd, packet))
{
packet->free();
my_error(ER_OUT_OF_RESOURCES, MYF(0));
DBUG_RETURN(1);
}
}
result->rows++;
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS))) ||
!(cur->data= (MYSQL_ROW)alloc_root(alloc,
(n_fields + 1) * sizeof(char *) + packet->length())))
{
my_error(ER_OUT_OF_RESOURCES,MYF(0));
DBUG_RETURN(1);
}
*result->prev_ptr= cur;
result->prev_ptr= &cur->next;
to= (char*) (cur->data+n_fields+1);
cp= (uchar *)packet->ptr();
end_field= cur->data + n_fields;
for (cur_field=cur->data; cur_field<end_field; ++cur_field, ++mysql_fields)
{
if ((len= (ulong) net_field_length(&cp)) == NULL_LENGTH)
{
*cur_field = 0;
}
else
{
*cur_field= to;
memcpy(to,(char*) cp,len);
to[len]=0;
to+=len+1;
cp+=len;
if (mysql_fields->max_length < len)
mysql_fields->max_length=len;
}
}
*cur_field= to;
DBUG_RETURN(0);
}
#endif
bool select_send::send_data(List<Item> &items) bool select_send::send_data(List<Item> &items)
{ {
List_iterator_fast<Item> li(items); List_iterator_fast<Item> li(items);
...@@ -1474,12 +1398,12 @@ int embedded_send_row(THD *thd, int n_fields, char *data, int data_len) ...@@ -1474,12 +1398,12 @@ int embedded_send_row(THD *thd, int n_fields, char *data, int data_len)
DBUG_ENTER("embedded_send_row"); DBUG_ENTER("embedded_send_row");
result->rows++; result->rows++;
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS) + (n_fields + 1) * sizeof(char *) + data_len))) if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS) + (n_fields + 1) * sizeof(MYSQL_ROW) + data_len)))
{ {
my_error(ER_OUT_OF_RESOURCES,MYF(0)); my_error(ER_OUT_OF_RESOURCES,MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
cur->data= (MYSQL_ROW)((char *)cur) + sizeof(MYSQL_ROWS); cur->data= (MYSQL_ROW)(cur + 1);
*result->prev_ptr= cur; *result->prev_ptr= cur;
result->prev_ptr= &cur->next; result->prev_ptr= &cur->next;
......
...@@ -219,7 +219,7 @@ int create_vio(NET *net, int separate_thread) ...@@ -219,7 +219,7 @@ int create_vio(NET *net, int separate_thread)
Vio * v = net->vio; Vio * v = net->vio;
if (!v) if (!v)
{ {
v = vio_new(0, separate_thread ? VIO_SHARED_MEMORY : VIO_BUFFER, 0); v = vio_new(0, separate_thread ? VIO_TYPE_SHARED_MEMORY : VIO_TYPE_BUFFER, 0);
net->vio = v; net->vio = v;
} }
return !v; return !v;
......
...@@ -1336,28 +1336,17 @@ mysql_fetch_row(MYSQL_RES *res) ...@@ -1336,28 +1336,17 @@ mysql_fetch_row(MYSQL_RES *res)
ulong * STDCALL ulong * STDCALL
mysql_fetch_lengths(MYSQL_RES *res) mysql_fetch_lengths(MYSQL_RES *res)
{ {
ulong *lengths,*prev_length; ulong *lengths;
byte *start;
MYSQL_ROW column,end; MYSQL_ROW column,end;
if (!(column=res->current_row)) if (!(column=res->current_row))
return 0; /* Something is wrong */ return 0; /* Something is wrong */
if (res->data) if (res->data)
{ {
start=0;
prev_length=0; /* Keep gcc happy */
lengths=res->lengths; lengths=res->lengths;
for (end=column+res->field_count+1 ; column != end ; column++,lengths++) for (end=column+res->field_count; column != end ; column++,lengths++)
{ {
if (!*column) *lengths= *column ? strlen(*column) : 0;
{
*lengths=0; /* Null */
continue;
}
if (start) /* Found end of prev string */
*prev_length= (uint) (*column-start-1);
start= *column;
prev_length=lengths;
} }
} }
return res->lengths; return res->lengths;
......
...@@ -5216,12 +5216,11 @@ Field *make_field(char *ptr, uint32 field_length, ...@@ -5216,12 +5216,11 @@ Field *make_field(char *ptr, uint32 field_length,
if (f_is_geom(pack_flag)) if (f_is_geom(pack_flag))
return new Field_geom(ptr,null_pos,null_bit, return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, table, unireg_check, field_name, table,
pack_length,f_is_binary(pack_flag) != 0); pack_length);
if (f_is_blob(pack_flag)) if (f_is_blob(pack_flag))
return new Field_blob(ptr,null_pos,null_bit, return new Field_blob(ptr,null_pos,null_bit,
unireg_check, field_name, table, unireg_check, field_name, table,
pack_length,f_is_binary(pack_flag) != 0, pack_length, field_charset);
default_charset_info);
if (interval) if (interval)
{ {
if (f_is_enum(pack_flag)) if (f_is_enum(pack_flag))
......
...@@ -930,6 +930,12 @@ bool Item::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT ...@@ -930,6 +930,12 @@ bool Item::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT
String s(buff, sizeof(buff), charset), *value; String s(buff, sizeof(buff), charset), *value;
if (!(value=val_str(&s)) || if (!(value=val_str(&s)) ||
!(*result=alloc_root(alloc, value->length() + 1))) !(*result=alloc_root(alloc, value->length() + 1)))
{
*result= NULL;
*length= 0;
return false;
}
if (!(*result=alloc_root(alloc, value->length() + 1)))
return true; return true;
*length= value->length(); *length= value->length();
if (convert) if (convert)
...@@ -944,6 +950,7 @@ bool Item_null::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM ...@@ -944,6 +950,7 @@ bool Item_null::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM
char **result, ulong *length) char **result, ulong *length)
{ {
*result= NULL; *result= NULL;
*length= 0;
return false; return false;
} }
...@@ -952,7 +959,8 @@ bool Item_field::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, ME ...@@ -952,7 +959,8 @@ bool Item_field::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, ME
{ {
if (result_field->is_null()) if (result_field->is_null())
{ {
result= NULL; *result= NULL;
*length= 0;
return false; return false;
} }
......
...@@ -1380,7 +1380,7 @@ String *Item_func_user::val_str(String *str) ...@@ -1380,7 +1380,7 @@ String *Item_func_user::val_str(String *str)
uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen; uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
if (str->copy("localuser@localhost", (uint)strlen("localuser@localhost"))) if (str->copy("localuser@localhost", (uint)strlen("localuser@localhost"), cs))
return &empty_string; return &empty_string;
#else #else
if (str->alloc(res_length)) if (str->alloc(res_length))
...@@ -1390,9 +1390,9 @@ String *Item_func_user::val_str(String *str) ...@@ -1390,9 +1390,9 @@ String *Item_func_user::val_str(String *str)
} }
res_length=cs->snprintf(cs, (char*)str->ptr(), res_length, "%s@%s",thd->user,host); res_length=cs->snprintf(cs, (char*)str->ptr(), res_length, "%s@%s",thd->user,host);
str->length(res_length); str->length(res_length);
#endif
str->set_charset(cs); str->set_charset(cs);
return str; return str;
#endif
} }
void Item_func_soundex::fix_length_and_dec() void Item_func_soundex::fix_length_and_dec()
......
...@@ -1857,6 +1857,9 @@ static int init_common_variables(const char *conf_file_name, int argc, char **ar ...@@ -1857,6 +1857,9 @@ static int init_common_variables(const char *conf_file_name, int argc, char **ar
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0) if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql"); strmov(glob_hostname,"mysql");
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
#ifndef DBUG_OFF #ifndef DBUG_OFF
strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS); strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS);
#else #else
...@@ -2138,6 +2141,7 @@ int main(int argc, char **argv) ...@@ -2138,6 +2141,7 @@ int main(int argc, char **argv)
#endif #endif
MY_INIT(argv[0]); // init my_sys library & pthreads MY_INIT(argv[0]); // init my_sys library & pthreads
if ((init_error=init_common_variables(MYSQL_CONFIG_NAME, if ((init_error=init_common_variables(MYSQL_CONFIG_NAME,
argc, argv, load_default_groups))) argc, argv, load_default_groups)))
if (init_error == 2) if (init_error == 2)
...@@ -2145,9 +2149,6 @@ int main(int argc, char **argv) ...@@ -2145,9 +2149,6 @@ int main(int argc, char **argv)
else else
exit(1); exit(1);
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
init_signals(); init_signals();
if (init_thread_environement()) if (init_thread_environement())
exit(1); exit(1);
...@@ -2221,7 +2222,7 @@ The server will not act as a slave."); ...@@ -2221,7 +2222,7 @@ The server will not act as a slave.");
*/ */
error_handler_hook = my_message_sql; error_handler_hook = my_message_sql;
start_signal_handler(); // Creates pidfile start_signal_handler(); // Creates pidfile
if (acl_init(opt_noacl)) if (acl_init((THD *)0, opt_noacl))
{ {
abort_loop=1; abort_loop=1;
select_thread_in_use=0; select_thread_in_use=0;
...@@ -2233,7 +2234,7 @@ The server will not act as a slave."); ...@@ -2233,7 +2234,7 @@ The server will not act as a slave.");
exit(1); exit(1);
} }
if (!opt_noacl) if (!opt_noacl)
(void) grant_init(); (void) grant_init((THD *)0);
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
if (!opt_noacl) if (!opt_noacl)
......
...@@ -683,13 +683,14 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, ...@@ -683,13 +683,14 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
field_list.push_back(new Item_empty_string("Comment",255)); field_list.push_back(new Item_empty_string("Comment",255));
} }
// Send first number of fields and records // Send first number of fields and records
#ifndef EMBEDDED_LIBRARY
{ {
char *pos; char *pos;
pos=net_store_length(tmp, (uint) field_list.elements); pos=net_store_length(tmp, (uint) field_list.elements);
pos=net_store_length(pos,(ulonglong) file->records); pos=net_store_length(pos,(ulonglong) file->records);
(void) my_net_write(&thd->net,tmp,(uint) (pos-tmp)); (void) my_net_write(&thd->net,tmp,(uint) (pos-tmp));
} }
#endif
if (send_fields(thd,field_list,0)) if (send_fields(thd,field_list,0))
DBUG_RETURN(1); DBUG_RETURN(1);
restore_record(table,2); // Get empty record restore_record(table,2); // Get empty record
......
...@@ -420,7 +420,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -420,7 +420,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
sql_field->pack_flag=FIELDFLAG_GEOM | sql_field->pack_flag=FIELDFLAG_GEOM |
pack_length_to_packflag(sql_field->pack_length - pack_length_to_packflag(sql_field->pack_length -
portable_sizeof_char_ptr); portable_sizeof_char_ptr);
if (sql_field->flags & BINARY_FLAG) if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY; sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->length=8; // Unireg field length sql_field->length=8; // Unireg field length
sql_field->unireg_check=Field::BLOB_FIELD; sql_field->unireg_check=Field::BLOB_FIELD;
......
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