Hi All

I'm trying to create a new database using the embedded server (MySQL 4.0.13). I 
compiled the source distribution on linux as follows:

./configure --prefix=/fs32/b/sgsubram/bin/MySQL-with-new-hash/LINUX --enable-assembler 
--with-mysqld-ldflags=-all-static 
--localstatedir=/fs32/b/sgsubram/bin/MySQL-with-new-hash/LINUX/data 
--with-client-ldflags=-all-static -enable-thread-safe-client --enable-local-infile 
--with-extra-charsets=complex

gmake; gmake install

The installation went smoothly without any problems. I tested the sample 
test_libmysqld.c program and it went through fine.

Then I tried the following. I changed the code for the functions db_connect and main 
in test_libmysqld.c to create a new database if there is no database by that name. 

The changed code segment is as follows (changes are in bold):

int
main(int argc, char **argv)
{
  MYSQL *one, *two;
  mysql_server_init(argc, argv, (char **)server_groups);
  one = db_connect("hello");
  two = db_connect(NULL);
  db_do_query(one, "SHOW TABLE STATUS");
  db_do_query(two, "SHOW DATABASES");
  mysql_close(two);
  mysql_close(one);
  /* This must be called after all other mysql functions */
  mysql_server_end();
  exit(EXIT_SUCCESS);
}

MYSQL *
db_connect(const char *dbname)
{
  MYSQL *db = mysql_init(NULL);
  if (!db)
    die(db, "mysql_init failed: no memory");
  /*
   * Notice that the client and server use separate group names.
   * This is critical, because the server will not accept the
   * client's options, and vice versa.
   */
  mysql_options(db, MYSQL_READ_DEFAULT_GROUP, "test_libmysqld_CLIENT");
  if (!mysql_real_connect(db, NULL, NULL, NULL, dbname, 0, NULL, 0)) {
    char query[1024];
    sprintf(query, "CREATE DATABASE %s", dbname);
    if (mysql_query(db, query) != 0) {
      die(db, "mysql_real_connect failed: %s", mysql_error(db));
    } else {
      if (!mysql_real_connect(db, NULL, NULL, NULL, dbname, 0, NULL, 0)) {
        die(db, "mysql_real_connect failed: %s", mysql_error(db));
      }
    }
  }
  return db;
}

There is no database by name "hello". The crash happens in mysql_server_init(). The 
crash does not happen if I try to connect to an existing database by name "test". The 
stack trace that I get when I run it inside gdb is as follows:

(gdb) where
#0  0x0828c416 in __sigsuspend (set=0xbfffb870) at 
../sysdeps/unix/sysv/linux/sigsuspend.c:45
#1  0x082804b5 in __pthread_wait_for_restart_signal (self=0x83c4900) at pthread.c:978
#2  0x08280591 in __pthread_create_2_1 (thread=0xbfffba10, attr=0xbfffba14, 
start_routine=0x81eaa00 <io_handler_thread>, arg=0x841bba0) at restart.h:34
#3  0x081a171f in os_thread_create ()
#4  0x081ebecb in innobase_start_or_create_for_mysql ()
#5  0x08051672 in innobase_init ()
#6  0x08058f44 in ha_init ()
#7  0x080500b4 in mysql_server_init ()
#8  0x080481eb in main (argc=1, argv=0xbfffc434) at test_libmysqld.c:45
#9  0x082885f2 in __libc_start_main (main=0x80481d0 <main at test_libmysqld.c:20>, 
argc=1, ubp_av=0xbfffc434, init=0x80480b4 <_init>, fini=0x82ff480 <_fini>, 
rtld_fini=0, stack_end=0xbfffc42c) at ../sysdeps/generic/libc-start.c:129

Any help with this problem would be greatly appreciated.

Thanks
Satheesh


____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005

Reply via email to