Commit a9f1388b authored by unknown's avatar unknown

Some fixes


libmysqld/lib_sql.cc:
  parameters for functions added
libmysqld/lib_vio.c:
  name of option changed
libmysqld/libmysqld.c:
  mysql_fetch_length fixed
sql/field.cc:
  small fix
sql/item.cc:
  fixes about Field::embedded_send
sql/item_strfunc.cc:
  cs parameter added
sql/mysqld.cc:
  small fix
sql/sql_show.cc:
  strange code #ifdef-ed
sql/sql_table.cc:
  small fix
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent 4c668ca7
......@@ -23,6 +23,7 @@ heikki@rescue.
heikki@work.mysql.com
hf@bison.(none)
hf@bisonxp.(none)
hf@deer.mysql.r18.ru
hf@genie.(none)
jani@dsl-jkl1657.dial.inet.fi
jani@hynda.(none)
......
......@@ -380,13 +380,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
error_handler_hook = my_message_sql;
opt_noacl = 1; // No permissions
if (acl_init(opt_noacl))
if (acl_init((THD *)0, opt_noacl))
{
mysql_server_end();
return 1;
}
if (!opt_noacl)
(void) grant_init();
(void) grant_init((THD *)0);
init_max_user_conn();
init_update_queries();
......@@ -664,13 +664,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
exit(1);
}
opt_noacl = 1; // No permissions
if (acl_init((THD*) 0,opt_noacl))
if (acl_init(opt_noacl))
{
mysql_server_end();
return 1;
}
if (!opt_noacl)
(void) grant_init((THD*) 0);
(void) grant_init();
init_max_user_conn();
init_update_queries();
......@@ -1148,9 +1148,10 @@ bool send_fields(THD *thd, List<Item> &list, uint flag)
MYSQL *mysql= thd->mysql;
if (!(mysql->result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
sizeof(ulong) * field_count,
sizeof(ulong) * (field_count + 1),
MYF(MY_WME | MY_ZEROFILL))))
goto err;
mysql->result->lengths= (ulong *)(mysql->result + 1);
mysql->field_count=field_count;
alloc= &mysql->field_alloc;
......@@ -1241,83 +1242,6 @@ net_field_length(uchar **packet)
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)
{
List_iterator_fast<Item> li(items);
......@@ -1474,12 +1398,12 @@ int embedded_send_row(THD *thd, int n_fields, char *data, int data_len)
DBUG_ENTER("embedded_send_row");
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));
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->next;
......
......@@ -219,7 +219,7 @@ int create_vio(NET *net, int separate_thread)
Vio * v = net->vio;
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;
}
return !v;
......
......@@ -1336,28 +1336,17 @@ mysql_fetch_row(MYSQL_RES *res)
ulong * STDCALL
mysql_fetch_lengths(MYSQL_RES *res)
{
ulong *lengths,*prev_length;
byte *start;
ulong *lengths;
MYSQL_ROW column,end;
if (!(column=res->current_row))
return 0; /* Something is wrong */
if (res->data)
{
start=0;
prev_length=0; /* Keep gcc happy */
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=0; /* Null */
continue;
}
if (start) /* Found end of prev string */
*prev_length= (uint) (*column-start-1);
start= *column;
prev_length=lengths;
*lengths= *column ? strlen(*column) : 0;
}
}
return res->lengths;
......
......@@ -5216,12 +5216,11 @@ Field *make_field(char *ptr, uint32 field_length,
if (f_is_geom(pack_flag))
return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, table,
pack_length,f_is_binary(pack_flag) != 0);
pack_length);
if (f_is_blob(pack_flag))
return new Field_blob(ptr,null_pos,null_bit,
unireg_check, field_name, table,
pack_length,f_is_binary(pack_flag) != 0,
default_charset_info);
pack_length, field_charset);
if (interval)
{
if (f_is_enum(pack_flag))
......
......@@ -930,6 +930,12 @@ bool Item::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT
String s(buff, sizeof(buff), charset), *value;
if (!(value=val_str(&s)) ||
!(*result=alloc_root(alloc, value->length() + 1)))
{
*result= NULL;
*length= 0;
return false;
}
if (!(*result=alloc_root(alloc, value->length() + 1)))
return true;
*length= value->length();
if (convert)
......@@ -944,6 +950,7 @@ bool Item_null::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM
char **result, ulong *length)
{
*result= NULL;
*length= 0;
return false;
}
......@@ -952,7 +959,8 @@ bool Item_field::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, ME
{
if (result_field->is_null())
{
result= NULL;
*result= NULL;
*length= 0;
return false;
}
......
......@@ -1380,7 +1380,7 @@ String *Item_func_user::val_str(String *str)
uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
#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;
#else
if (str->alloc(res_length))
......@@ -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);
str->length(res_length);
#endif
str->set_charset(cs);
return str;
#endif
}
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
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
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
strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS);
#else
......@@ -2138,6 +2141,7 @@ int main(int argc, char **argv)
#endif
MY_INIT(argv[0]); // init my_sys library & pthreads
if ((init_error=init_common_variables(MYSQL_CONFIG_NAME,
argc, argv, load_default_groups)))
if (init_error == 2)
......@@ -2145,9 +2149,6 @@ int main(int argc, char **argv)
else
exit(1);
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
init_signals();
if (init_thread_environement())
exit(1);
......@@ -2221,7 +2222,7 @@ The server will not act as a slave.");
*/
error_handler_hook = my_message_sql;
start_signal_handler(); // Creates pidfile
if (acl_init(opt_noacl))
if (acl_init((THD *)0, opt_noacl))
{
abort_loop=1;
select_thread_in_use=0;
......@@ -2233,7 +2234,7 @@ The server will not act as a slave.");
exit(1);
}
if (!opt_noacl)
(void) grant_init();
(void) grant_init((THD *)0);
#ifdef HAVE_DLOPEN
if (!opt_noacl)
......
......@@ -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));
}
// Send first number of fields and records
#ifndef EMBEDDED_LIBRARY
{
char *pos;
pos=net_store_length(tmp, (uint) field_list.elements);
pos=net_store_length(pos,(ulonglong) file->records);
(void) my_net_write(&thd->net,tmp,(uint) (pos-tmp));
}
#endif
if (send_fields(thd,field_list,0))
DBUG_RETURN(1);
restore_record(table,2); // Get empty record
......
......@@ -420,7 +420,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
sql_field->pack_flag=FIELDFLAG_GEOM |
pack_length_to_packflag(sql_field->pack_length -
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->length=8; // Unireg field length
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