List:Commits« Previous MessageNext Message »
From:monty Date:February 23 2007 11:14am
Subject:bk commit into 5.1 tree (monty:1.2452)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of monty. When monty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-02-23 13:13:55+02:00, monty@stripped +177 -0
  Fixed compiler warnings
  Fixed compile-pentium64 scripts
  Fixed wrong estimate of update_with_key_prefix in sql-bench
  Merge bk-internal.mysql.com:/home/bk/mysql-5.1 into mysql.com:/home/my/mysql-5.1
  Fixed unsafe define of uint4korr()
  Fixed that --extern works with mysql-test-run.pl
  Small trivial cleanups
  This also fixes a bug in counting number of rows that are updated when we have many simultanous queries
  Move all connection handling and command exectuion main loop from sql_parse.cc to sql_connection.cc
  Split handle_one_connection() into reusable sub functions.
  Split create_new_thread() into reusable sub functions.
  Added thread_scheduler; Preliminary interface code for future thread_handling code.
  
  Use 'my_thread_id' for internal thread id's
  Make thr_alarm_kill() to depend on thread_id instead of thread
  Make thr_abort_locks_for_thread() depend on thread_id instead of thread
  In store_globals(), set my_thread_var->id to be thd->thread_id.
  Use my_thread_var->id as basis for my_thread_name()
  The above changes makes the connection we have between THD and threads more soft.
  
  Added a lot of DBUG_PRINT() and DBUG_ASSERT() functions
  Fixed compiler warnings
  Fixed core dumps when running with --debug
  Removed setting of signal masks (was never used)
  Made event code call pthread_exit() (portability fix)
  Fixed that event code doesn't call DBUG_xxx functions before my_thread_init() is called.
  Made handling of thread_id and thd->variables.pseudo_thread_id uniform.
  Removed one common 'not freed memory' warning from mysqltest
  Fixed a couple of usage of not initialized warnings (unlikely cases)
  Suppress compiler warnings from bdb and (for the moment) warnings from ndb

  BUILD/compile-pentium@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +1 -1
    Send command line options to SETUP.sh

  BUILD/compile-pentium64@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +3 -5
    Update this to be in line with compile-pentium

  BUILD/compile-pentium64-max@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +11 -0
    New BitKeeper file ``BUILD/compile-pentium64-max''

  BUILD/compile-pentium64-max@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  BUILD/compile-solaris-sparc@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +12 -5
    Update scripts

  BUILD/compile-solaris-sparc-debug@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +9 -5
    Update scripts

  BUILD/compile-solaris-sparc-forte@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +7 -7
    Update scripts

  BUILD/compile-solaris-sparc-purify@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +5 -5
    Update scripts

  BitKeeper/deleted/.del-DbtupSystemRestart.cpp~15b54d7e4e75d2d@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +0 -2
    Removed compiler warning

  BitKeeper/deleted/.del-SETUP.sh.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: BUILD/SETUP.sh.rej -> BitKeeper/deleted/.del-SETUP.sh.rej

  BitKeeper/deleted/.del-configure.in.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: configure.in.rej -> BitKeeper/deleted/.del-configure.in.rej

  BitKeeper/deleted/.del-ha_berkeley.cc@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +10 -0
    Moved get_auto_primary_key() here as int5store() gives (wrong) compiler warnings in win64

  BitKeeper/deleted/.del-ha_berkeley.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -7
    Moved get_auto_primary_key() to ha_berkeley.cc

  BitKeeper/deleted/.del-my_global.h.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: include/my_global.h.rej -> BitKeeper/deleted/.del-my_global.h.rej

  BitKeeper/deleted/.del-my_pthread.h.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: include/my_pthread.h.rej -> BitKeeper/deleted/.del-my_pthread.h.rej

  BitKeeper/deleted/.del-mysql_client_test.c.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: tests/mysql_client_test.c.rej -> BitKeeper/deleted/.del-mysql_client_test.c.rej

  BitKeeper/deleted/.del-mysqld.cc.rej~35c1c438e11ebd89@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: sql/mysqld.cc.rej -> BitKeeper/deleted/.del-mysqld.cc.rej~35c1c438e11ebd89

  BitKeeper/deleted/.del-mysqlmanager.c~e97636d71145a0b@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    Fixed compiler warnings

  BitKeeper/deleted/.del-sql_parse.cc.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: sql/sql_parse.cc.rej -> BitKeeper/deleted/.del-sql_parse.cc.rej

  BitKeeper/deleted/.del-table.cc.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: sql/table.cc.rej -> BitKeeper/deleted/.del-table.cc.rej

  BitKeeper/deleted/.del-thr_alarm.c.rej@stripped, 2007-02-23 12:59:58+02:00, monty@stripped +0 -0
    Rename: mysys/thr_alarm.c.rej -> BitKeeper/deleted/.del-thr_alarm.c.rej

  BitKeeper/etc/ignore@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -0
    added storage/ndb/src/ndbapi/ndberror_check

  client/mysqlbinlog.cc@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    Removed not needed 'static' (caused compiler warning)

  client/mysqldump.c@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +2 -2
    Fixed compiler warnings from 'max' build

  client/mysqltest.c@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +25 -22
    Free warning and query memory no abort.
    (Removes strange warnings on screen if mysql-test-run fails)
    Removed compiler warnings
    Portability fix for windows (windows doesn't have mode_t)

  client/sql_string.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +0 -2
    Removed compiler warning

  cmd-line-utils/readline/xmalloc.c@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +3 -4
    Fixed compiler warnings from 'max' build

  configure.in@stripped, 2007-02-23 13:13:46+02:00, monty@stripped +5 -5
    Added detection of port_create and port.h (for future)as 
    ---
    manual merge

  extra/charset2html.c@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +2 -0
    Fixed compiler warnings

  extra/comp_err.c@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +4 -0
    Fixed compiler warnings from 'max' build

  extra/yassl/include/lock.hpp@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    Fix for windows64

  extra/yassl/include/openssl/ssl.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +7 -2
    Changed prototype for SSL_set_fd() to fix compiler warnings (and possible errors) on windows 64 bit

  extra/yassl/include/socket_wrapper.hpp@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +3 -5
    Moved socket_t to ssl.h, to be able to removed compiler warnings on windows 64 bit

  extra/yassl/include/yassl.hpp@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    Fix for windows64

  extra/yassl/src/ssl.cpp@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +6 -2
    Removed compiler warning
    Detect wrong parameter (Happens when running test suite on solaris)
    Changed prototype for SSL_set_fd() to fix compiler warnings (and possible errors) on windows 64 bit

  extra/yassl/taocrypt/src/integer.cpp@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    Fixed compiler warnings

  extra/yassl/testsuite/testsuite.cpp@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +2 -2
    Removed compiler warning

  include/config-win.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -0
    Added HAVE_WINSOCK2 (for future)

  include/my_dbug.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    Fixed DBUG_PROCESS() so that we don't get compiler warnings for it

  include/my_global.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +14 -13
    Fixed unsafe define of uint4korr()
    manual merge (ignore changes from 5.0)
    Fixed warnings on win64 when using int5store and int6store

  include/my_pthread.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +5 -4
    Added my_thread_id typedef
    Renamed 'my_thread_id() function to my_thead_dbug_id()

  include/thr_alarm.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +2 -1
    Make thr_alarm_kill() to depend on thread_id instead of thread

  include/thr_lock.h@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +2 -2
    Make thr_abort_locks_for_thread() depend on thread_id instead of thread

  libmysql/libmysql.def@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +0 -1
    Fixed compiler warnings on win64

  libmysqld/CMakeLists.txt@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -0
    Added missing files

  libmysqld/Makefile.am@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +2 -1
    Added new files

  libmysqld/lib_sql.cc@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -9
    Remove not needed code (store_globals() now takes care of things)

  libmysqld/scheduler.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0
    New BitKeeper file ``libmysqld/scheduler.cc''

  libmysqld/scheduler.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  libmysqld/sql_connect.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0
    New BitKeeper file ``libmysqld/sql_connect.cc''

  libmysqld/sql_connect.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  mysql-test/include/one_thread_per_connection.inc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +5 -0
    New BitKeeper file ``mysql-test/include/one_thread_per_connection.inc''

  mysql-test/include/one_thread_per_connection.inc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  mysql-test/lib/mtr_report.pl@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +4 -2
    Removed wrong messages when using --extern

  mysql-test/mysql-test-run.pl@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +111 -83
    Fixed that --extern works
    Print help on stdout instead of stderr (make it easier to pipe it to less)
    Fixed typo that caused mysql-test-run.pl to fail on Solaris

  mysql-test/r/keywords.result@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +13 -13
    manual merge

  mysql-test/r/ndb_lock.result@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    After merge fixes

  mysql-test/r/no-threads.result@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +6 -0
    New BitKeeper file ``mysql-test/r/no-threads.result''

  mysql-test/r/no-threads.result@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  mysql-test/r/one_thread_per_connection.require@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +2 -0
    New BitKeeper file ``mysql-test/r/one_thread_per_connection.require''

  mysql-test/r/one_thread_per_connection.require@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  mysql-test/r/ps.result@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +3 -3
    Portability fix

  mysql-test/t/disabled.def@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -0
    Disabled ndb_alter_table as this very often fails for me (and have done it for a long time)

  mysql-test/t/keywords.test@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +21 -22
    manual merge

  mysql-test/t/ndb_lock.test@stripped, 2007-02-23 13:13:47+02:00, monty@stripped +1 -1
    Added other possible error code

  mysql-test/t/no-threads-master.opt@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +1 -0
    New BitKeeper file ``mysql-test/t/no-threads-master.opt''

  mysql-test/t/no-threads-master.opt@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  mysql-test/t/no-threads.test@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +5 -0
    New BitKeeper file ``mysql-test/t/no-threads.test''

  mysql-test/t/no-threads.test@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  mysql-test/t/ps.test@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +3 -3
    Portability fix (when compiling without DLOPEN)

  mysql-test/t/wait_timeout.test@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -0
    Don't run this if we are not using a thread per connection (as other thread_handling code may not support timeouts)

  mysys/base64.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +2 -2
    Fixed compiler warnings on win64

  mysys/mf_keycache.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +4 -1
    Fixed compiler warnings

  mysys/my_getopt.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +2 -1
    Fixed compiler warning

  mysys/my_init.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +11 -7
    Fixed compiler warning
    Re-indented long comment

  mysys/my_thr_init.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +42 -39
    Always use mysys_var->id to generate thread name (makes things uniform accross thread implementations and thread usage)
    Always generate my_thread_name() when using DBUG
    Ensure mysys_var->pthread_self is set
    Fixed compiler warnings

  mysys/ptr_cmp.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    Fixed compiler warnings from 'max' build

  mysys/thr_alarm.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +6 -5
    Change thr_alarm_kill() to use mysys_var->id instead of thread id
    Fixed compiler warning on windows

  mysys/thr_lock.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +21 -8
    Change thr_abort_locks_for_thread() to use mysys_var->id instead of thread id
    Add purecov statements around not tested code
    Fixed compiler warnings

  mysys/thr_mutex.c@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +2 -2
    my_thread_id() -> my_thread_dbug_id()

  server-tools/instance-manager/guardian.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +2 -2
    Fixed compiler warning

  server-tools/instance-manager/instance.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    Fixed compiler warning

  server-tools/instance-manager/mysql_connection.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    Fixed compiler warnings

  server-tools/instance-manager/mysqlmanager.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    Fixed compiler warnings

  sql-bench/bench-init.pl.sh@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +9 -5
    Added --one-missing-tests

  sql-bench/example@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +18 -1
    Better example

  sql-bench/run-all-tests.sh@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +5 -1
    Added --only-missing-tests

  sql-bench/test-insert.sh@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed wrong estimate of update_with_key_prefix

  sql/CMakeLists.txt@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -0
    Added missing files

  sql/Makefile.am@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +6 -4
    Added new files

  sql/event_scheduler.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +17 -18
    Added pthread_exit() calls
    Ensure DBUG_xxx calls are not made before my_thread_init()
    Use common functions to set up thread handling

  sql/field.h@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    manual merge

  sql/ha_ndbcluster.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +3 -3
    Removed some trivial 'current_thd' calls

  sql/handler.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +3 -3
    Avoid warnings on KILL_CONNECTION
    Don't print out null pointer with printf()  (Causes crashes on Solaris)

  sql/item.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +2 -0
    Fixed compiler warnings from 'max' build

  sql/item_cmpfunc.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +2 -1
    After merge fixes

  sql/item_func.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +4 -14
    Merge embedded and normal code usage
    (GET_LOCK, RELEASE_LOCK now works on my_thread_id instead of pthread_t)
    Fixed compiler warning

  sql/item_strfunc.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    Fixed compiler warning

  sql/item_timefunc.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    Fixed compiler warnings

  sql/lock.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +1 -1
    Use (new) parameter to thr_abort_locks_for_thread()

  sql/log.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +4 -4
    Fixed compiler warning

  sql/log_event.cc@stripped, 2007-02-23 13:13:48+02:00, monty@stripped +8 -7
    Fixed compiler warnings about not used variable

  sql/mysql_priv.h@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +27 -5
    Remove TEST_NO_THREADS (not needed with new scheduler interface)
    Added functions from sql_connect.cc and new functions from sql_parse.cc

  sql/mysqld.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +218 -107
    Use thread_scheduler structure to dispatch calls (make code more dynamic)
    Change --one-thread option to use thread_scheduler interface
    Made ONE_THREAD option independent of DBUG_BUILD
    --one-thread is now depricated. One should instead use '--thread-handling=no-threads'
    Remove not used uname() function.
    Split create_new_thread() into reusable sub functions.
    Preliminary interface code for future thread_handling code.
    Fixed compiler warnings

  sql/parse_file.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +1 -1
    Don't send zero pointer to fn_format() (Causes crashes when using --debug)

  sql/repl_failsafe.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +4 -8
    Setup pseudo_thread_id same way as other code

  sql/scheduler.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +88 -0
    New BitKeeper file ``sql/scheduler.cc''

  sql/scheduler.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  sql/scheduler.h@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +60 -0
    New BitKeeper file ``sql/scheduler.h''

  sql/scheduler.h@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  sql/set_var.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +15 -3
    Added variables 'thread_handling'
    Prepare for future variable 'thread_pool_size'
    Fixed compiler warnings

  sql/set_var.h@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +1 -1
    Fixed compiler warning

  sql/slave.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +1 -8
    Setup pseudo_thread_id same way as other code
    Removed not used signal mask

  sql/sql_acl.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +2 -0
    Fixed compiler warnings from 'max' build

  sql/sql_base.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +37 -15
    Fixed long comments
    Normalized variable setup
    Don't destroy value of thd->variables.pseduo_thread_id
    More DBUG_PRINT()'s
    More DBUG_ASSERT()'s
    Fixed compiler warnings from 'max' build

  sql/sql_class.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +13 -12
    Remove thd->real_id and thd->dbug_thread_id
    Added DBUG_ASSERT()
    Use thread_scheduler to signal threads to be killed.
    In THD::store_globals(), set my_thread_var->id to be thd->thread_id.
    Fixed compiler warnings

  sql/sql_class.h@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +13 -10
    Use 'my_thread_id' for internal thread id's
    Remove not needed THD elements: block_signals and dbug_thread_id
    Added 'thread_scheduler' scheduling extension element to THD

  sql/sql_connect.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +1108 -0
    New BitKeeper file ``sql/sql_connect.cc''
    

  sql/sql_connect.cc@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +0 -0

  sql/sql_insert.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +2 -7
    After merge fixes
    (This actually fixes a bug in old code when many connections are in use)
    Setup pseudo_thread_id same way as other code
    Removed not used signal mask
    Initialize variable that may be used unitialized on error conditions (not fatal)

  sql/sql_parse.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +5 -995
    Move connection related code to sql_connect.cc
    Remove setting of signal mask (not needed)
    Ensure TABLE_LIST->alias is set for generated TABLE_LIST elements (fixed core dumps when running with --debug)
    Added previous 'optional' element to reset_mgh()
    Removed not needed DBUG_PRINT call

  sql/sql_partition.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +1 -1
    Fixed compiler warnings

  sql/sql_prepare.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +2 -1
    Removed not needed casts
    Fixed compiler warnings from 'max' build

  sql/sql_select.cc@stripped, 2007-02-23 13:13:49+02:00, monty@stripped +5 -4
    Fixed compiler warnings

  sql/sql_show.cc@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +4 -7
    Don't send pthread_kill() to threads to detect if they exists.
    (Not that useful and causes problems with future thread_handling code)
    Fixed compiler warnings

  sql/sql_table.cc@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +6 -11
    Simplify code
    Fixed compiler warnings

  sql/sql_test.cc@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +7 -5
    Remove dbug_thread_id from test output

  sql/sql_view.cc@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Don't send zero pointer to fn_format()

  sql/tztime.cc@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +2 -2
    Fixed compiler warning

  sql/udf_example.def@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +0 -1
    Fixed compiler warnings on win64

  sql/unireg.cc@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +3 -0
    Initialize variable that may be used unitialized on error conditions

  storage/archive/archive_test.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +6 -6
    Fixed compiler warnings

  storage/archive/azio.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +6 -4
    Fixed compiler warnings

  storage/innobase/dict/dict0crea.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +2 -2
    Fixed compiler warnings detected on windows64

  storage/innobase/dict/dict0dict.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +5 -5
    Fixed compiler warnings detected on windows64

  storage/innobase/dict/dict0load.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +3 -3
    Fixed compiler warnings detected on windows64

  storage/innobase/dict/dict0mem.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +11 -11
    Fixed compiler warnings detected on windows64

  storage/innobase/eval/eval0proc.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed compiler warnings detected on windows64

  storage/innobase/handler/ha_innodb.cc@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +14 -10
    Fixed compiler warnings detected on windows64

  storage/innobase/include/ut0byte.ic@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +2 -2
    Fixed compiler warnings on win64

  storage/innobase/include/ut0ut.ic@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed compiler warnings on win64

  storage/innobase/mtr/mtr0log.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed compiler warnings detected on windows64

  storage/innobase/pars/pars0lex.l@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed warnings on win64

  storage/innobase/rem/rem0cmp.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed compiler warnings detected on windows64

  storage/innobase/row/row0mysql.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +2 -2
    Fixed compiler warnings detected on windows64

  storage/innobase/row/row0sel.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed compiler warnings detected on windows64

  storage/innobase/sync/sync0rw.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +4 -4
    Fixed compiler warnings detected on windows64

  storage/innobase/trx/trx0trx.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed compiler warnings detected on windows64

  storage/myisam/mi_log.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    my_thread_id() -> my_thread_debug_id()

  storage/myisam/mi_packrec.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -1
    Fixed compiler warnings detected on windows64

  storage/myisam/myisamchk.c@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +1 -0
    Fixed compiler warnings from 'max' build

  storage/ndb/src/common/debugger/EventLogger.cpp@stripped, 2007-02-23 13:13:50+02:00, monty@stripped +9 -8
    Fixed compiler warnings

  storage/ndb/src/common/util/ConfigValues.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +4 -4
    Removed compiler warnings

  storage/ndb/src/common/util/NdbSqlUtil.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -2
    Removed compiler warnings

  storage/ndb/src/cw/cpcd/CPCD.hpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -0
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/backup/Backup.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -3
    Fixed compiler warnings detected on windows64

  storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -0
    Fixed compiler warnings detected on windows64

  storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -2
    Fixed compiler warnings detected on windows64

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +2 -9
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -0
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -3
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -4
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -4
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +3 -0
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -6
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -3
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -1
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +4 -5
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +2 -5
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -1
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -1
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -2
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +2 -0
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -1
    Fixed compiler warnings

  storage/ndb/src/kernel/blocks/diskpage.hpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +3 -0
    Fixed compiler warnings

  storage/ndb/src/kernel/vm/ndbd_malloc.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +2 -0
    Fixed compiler warnings

  storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -0
    Fixed compiler warnings

  storage/ndb/src/mgmclient/main.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -2
    Fixed compiler warnings

  storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +1 -1
    Fixed compiler warnings

  storage/ndb/src/ndbapi/NdbOperationExec.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +2 -2
    Fixed compiler warnings

  storage/ndb/src/ndbapi/SignalSender.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +0 -9
    Fixed compiler warnings

  storage/ndb/tools/restore/consumer_restore.cpp@stripped, 2007-02-23 13:13:51+02:00, monty@stripped +5 -1
    Fixed compiler warnings

  strings/ctype-ucs2.c@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +4 -1
    Fixed compiler warnings

  strings/ctype-utf8.c@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +3 -1
    Fixed compiler warnings

  strings/decimal.c@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +3 -0
    Fixed compiler warnings

  strings/my_strchr.c@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +1 -1
    Fixed conflict between function and prototype

  support-files/compiler_warnings.supp@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +43 -11
    Ignore warnings from sql_yacc.cc that are hard to remove
    Ignore some not important warnings from windows 64 bit build
    Suppress warnings from bdb and (for the moment) warnings from ndb
    Suppress all warnings for all pushbuild platforms (should make all trees green)

  vio/viosslfactories.c@stripped, 2007-02-23 13:13:52+02:00, monty@stripped +8 -0
    Added DBUG_PRINT

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	monty
# Host:	narttu.mysql.fi
# Root:	/home/my/mysql-5.1

--- 1.18/BUILD/compile-pentium	2002-02-11 13:34:11 +02:00
+++ 1.19/BUILD/compile-pentium	2007-02-23 13:13:46 +02:00
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 path=`dirname $0`
-. "$path/SETUP.sh"
+. "$path/SETUP.sh" $@
 
 extra_flags="$pentium_cflags $fast_cflags"
 extra_configs="$pentium_configs $static_link"

--- 1.17/BUILD/compile-solaris-sparc-purify	2006-08-10 03:33:05 +03:00
+++ 1.18/BUILD/compile-solaris-sparc-purify	2007-02-23 13:13:46 +02:00
@@ -31,7 +31,7 @@
   shift
 done
 
-gmake -k clean || true 
+make -k clean || true 
 /bin/rm -f */.deps/*.P config.cache
  
 path=`dirname $0`
@@ -39,7 +39,7 @@
 
 CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-embedded-server --with-innodb $EXTRA_CONFIG_FLAGS
 
-gmake -j 4
+make -j 4
 
 # ----------------------------------------------------------------------
 
@@ -75,17 +75,17 @@
     fi
 
     if [ -n "$mode" -a $mode = purify ] ; then
-      gmake CCLD="purify   $opts gcc"  CXXLD="purify   $opts g++"  $target
+      make CCLD="purify   $opts gcc"  CXXLD="purify   $opts g++"  $target
       mv $binary $binary-purify
     fi
 
     if [ -n "$mode" -a $mode = quantify ] ; then
-      gmake CCLD="quantify $opts gcc"  CXXLD="quantify $opts g++"  $target
+      make CCLD="quantify $opts gcc"  CXXLD="quantify $opts g++"  $target
       mv $binary $binary-quantify
     fi
 
     if [ -n "$mode" -a $mode = purecov ] ; then
-      gmake CCLD="purecov  $opts gcc"  CXXLD="purecov  $opts g++"  $target
+      make CCLD="purecov  $opts gcc"  CXXLD="purecov  $opts g++"  $target
       mv $binary $binary-purecov
     fi
 

--- 1.11/BUILD/compile-solaris-sparc	2006-09-14 08:01:45 +03:00
+++ 1.12/BUILD/compile-solaris-sparc	2007-02-23 13:13:46 +02:00
@@ -1,7 +1,14 @@
-#!/usr/bin/bash
+#! /bin/sh
+
+make -k clean || true
+/bin/rm -f */.deps/*.P config.cache
+ 
+# gcc is often in /usr/ccs/bin or /usr/local/bin
+PATH=$PATH:/usr/ccs/bin:/usr/local/bin
+
 path=`dirname $0`
-. "$path/SETUP.sh"
-extra_flags=""
-extra_configs="$max_configs"
+. "$path/autorun.sh"
+
+CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa" CXX=gcc CXXFLAGS="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa -g" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client
 
-. "$path/FINISH.sh"
+make -j 4

--- 1.266/client/mysqldump.c	2007-01-29 01:47:29 +02:00
+++ 1.267/client/mysqldump.c	2007-02-23 13:13:47 +02:00
@@ -2172,7 +2172,8 @@
 
 */
 
-static void dump_triggers_for_table(char *table, char *db)
+static void dump_triggers_for_table(char *table,
+                                    char *db __attribute__((unused)))
 {
   char       *result_table;
   char       name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
@@ -2181,7 +2182,6 @@
   FILE       *sql_file= md_result_file;
   MYSQL_RES  *result;
   MYSQL_ROW  row;
-
   DBUG_ENTER("dump_triggers_for_table");
   DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
 

--- 1.18/client/sql_string.h	2007-01-22 14:10:36 +02:00
+++ 1.19/client/sql_string.h	2007-02-23 13:13:47 +02:00
@@ -23,8 +23,6 @@
 #define NOT_FIXED_DEC			31
 #endif
 
-#define STRING_WITH_LEN(X)  ((const char*) X), ((uint) (sizeof(X) - 1))
-
 class String;
 int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
 String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);

--- 1.437/configure.in	2007-02-21 12:04:31 +02:00
+++ 1.438/configure.in	2007-02-23 13:13:46 +02:00
@@ -715,7 +715,7 @@
  sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
  unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \
  sys/ioctl.h malloc.h sys/malloc.h sys/ipc.h sys/shm.h linux/config.h \
- sys/resource.h sys/param.h)
+ sys/resource.h sys/param.h port.h)
 
 AC_CHECK_HEADERS([xfs/xfs.h])
 
@@ -983,7 +983,7 @@
     AC_DEFINE([DEFAULT_SKIP_THREAD_PRIORITY], [1], [default to skip thread priority])
     if test "$ac_cv_prog_gcc" = "yes"
     then
-      FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT"
+      FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL"
       CFLAGS="$CFLAGS $FLAGS"
       CXXFLAGS="$CXXFLAGS $FLAGS"
       MAX_C_OPTIMIZE="-O"
@@ -1883,9 +1883,9 @@
   pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
   realpath rename rint rwlock_init setupterm \
   shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
-  sighold sigset sigthreadmask sleep \
-  snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr strtol \
-  strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
+  sighold sigset sigthreadmask port_create sleep \
+  snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr \
+  strtol strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
   posix_fallocate)
 
 #

--- 1.26/extra/comp_err.c	2006-12-23 21:19:44 +02:00
+++ 1.27/extra/comp_err.c	2007-02-23 13:13:47 +02:00
@@ -41,7 +41,9 @@
 static char *STATEFILE= (char*) "sql_state.h";
 static char *TXTFILE= (char*) "../sql/share/errmsg.txt";
 static char *DATADIRECTORY= (char*) "../sql/share/";
+#ifndef DBUG_OFF
 static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace";
+#endif
 
 /* Header for errmsg.sys files */
 uchar file_head[]= { 254, 254, 2, 1 };
@@ -402,6 +404,8 @@
   int rcount= 0;
   DBUG_ENTER("parse_input_file");
 
+  *top_error= 0;
+  *top_lang= 0;
   if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME))))
     DBUG_RETURN(0);
 

--- 1.95/include/config-win.h	2007-02-21 10:43:50 +02:00
+++ 1.96/include/config-win.h	2007-02-23 13:13:47 +02:00
@@ -350,6 +350,7 @@
 #define HAVE_SETFILEPOINTER
 #define HAVE_VIO_READ_BUFF
 #define HAVE_STRNLEN
+#define HAVE_WINSOCK2
 
 #define strcasecmp stricmp
 #define strncasecmp strnicmp

--- 1.24/include/my_dbug.h	2006-12-23 21:19:44 +02:00
+++ 1.25/include/my_dbug.h	2007-02-23 13:13:47 +02:00
@@ -95,7 +95,7 @@
 #define DBUG_SET(a1)
 #define DBUG_SET_INITIAL(a1)
 #define DBUG_POP()
-#define DBUG_PROCESS(a1) (a1)
+#define DBUG_PROCESS(a1)
 #define DBUG_SETJMP(a1) setjmp(a1)
 #define DBUG_LONGJMP(a1) longjmp(a1)
 #define DBUG_DUMP(keyword,a1,a2)

--- 1.106/include/my_pthread.h	2007-02-06 23:37:18 +02:00
+++ 1.107/include/my_pthread.h	2007-02-23 13:13:47 +02:00
@@ -18,7 +18,6 @@
 #ifndef _my_pthread_h
 #define _my_pthread_h
 
-#include <errno.h>
 #ifndef ETIME
 #define ETIME ETIMEDOUT				/* For FreeBSD */
 #endif
@@ -75,6 +74,7 @@
 
 typedef int pthread_mutexattr_t;
 #define win_pthread_self my_thread_var->pthread_self
+#define pthread_self() win_pthread_self
 #define pthread_handler_t EXTERNC void * __cdecl
 typedef void * (__cdecl *pthread_handler)(void *);
 
@@ -130,7 +130,6 @@
 
 #define ETIMEDOUT 145		    /* Win32 doesn't have this */
 #define getpid() GetCurrentThreadId()
-#define pthread_self() win_pthread_self
 #define HAVE_LOCALTIME_R		1
 #define _REENTRANT			1
 #define HAVE_PTHREAD_ATTR_SETSTACKSIZE	1
@@ -638,12 +637,14 @@
 #define MY_MUTEX_INIT_ERRCHK   NULL
 #endif
 
+typedef ulong my_thread_id;
+
 extern my_bool my_thread_global_init(void);
 extern void my_thread_global_end(void);
 extern my_bool my_thread_init(void);
 extern void my_thread_end(void);
 extern const char *my_thread_name(void);
-extern long my_thread_id(void);
+extern my_thread_id my_thread_dbug_id(void);
 extern int pthread_no_free(void *);
 extern int pthread_dummy(int);
 
@@ -670,7 +671,7 @@
   pthread_mutex_t * volatile current_mutex;
   pthread_cond_t * volatile current_cond;
   pthread_t pthread_self;
-  long id;
+  my_thread_id id;
   int cmp_length;
   int volatile abort;
   my_bool init;

--- 1.22/include/thr_alarm.h	2007-02-06 23:37:18 +02:00
+++ 1.23/include/thr_alarm.h	2007-02-23 13:13:47 +02:00
@@ -86,6 +86,7 @@
   ulong expire_time;
   thr_alarm_entry alarmed;		/* set when alarm is due */
   pthread_t thread;
+  my_thread_id thread_id;
   my_bool malloced;
 } ALARM;
 
@@ -94,7 +95,7 @@
 void init_thr_alarm(uint max_alarm);
 void resize_thr_alarm(uint max_alarms);
 my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
-void thr_alarm_kill(pthread_t thread_id);
+void thr_alarm_kill(my_thread_id thread_id);
 void thr_end_alarm(thr_alarm_t *alarmed);
 void end_thr_alarm(my_bool free_structures);
 sig_handler process_alarm(int);

--- 1.20/include/thr_lock.h	2006-12-30 02:36:01 +02:00
+++ 1.21/include/thr_lock.h	2007-02-23 13:13:47 +02:00
@@ -78,7 +78,7 @@
 typedef struct st_thr_lock_info
 {
   pthread_t thread;
-  ulong thread_id;
+  my_thread_id thread_id;
   ulong n_cursors;
 } THR_LOCK_INFO;
 
@@ -144,7 +144,7 @@
                                          uint count, THR_LOCK_OWNER *owner);
 void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
 void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock);
-my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread);
+my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
 void thr_print_locks(void);		/* For debugging */
 my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);
 void    thr_downgrade_write_lock(THR_LOCK_DATA *data,

--- 1.14/storage/myisam/mi_log.c	2006-12-31 02:06:40 +02:00
+++ 1.15/storage/myisam/mi_log.c	2007-02-23 13:13:50 +02:00
@@ -31,7 +31,7 @@
 
 #undef GETPID					/* For HPUX */
 #ifdef THREAD
-#define GETPID() (log_type == 1 ? (long) myisam_pid : (long) my_thread_id());
+#define GETPID() (log_type == 1 ? (long) myisam_pid : (long) my_thread_dbug_id())
 #else
 #define GETPID() myisam_pid
 #endif

--- 1.45/storage/myisam/mi_packrec.c	2007-01-24 23:39:50 +02:00
+++ 1.46/storage/myisam/mi_packrec.c	2007-02-23 13:13:50 +02:00
@@ -564,7 +564,7 @@
   */
   value|= (max_bits - bits) << 8 | IS_CHAR;
 
-  for (end= table + (1 << bits); table < end; table++)
+  for (end= table + (uint) (((uint) 1 << bits)); table < end; table++)
   {
     *table= (uint16) value;
   }

--- 1.124/storage/myisam/myisamchk.c	2006-12-23 21:20:01 +02:00
+++ 1.125/storage/myisam/myisamchk.c	2007-02-23 13:13:50 +02:00
@@ -713,6 +713,7 @@
     case 2:
       method_conv= MI_STATS_METHOD_IGNORE_NULLS;
       break;
+    default: assert(0);                         /* Impossible */
     }
     check_param.stats_method= method_conv;
     break;

--- 1.63/mysys/mf_keycache.c	2007-01-24 19:56:57 +02:00
+++ 1.64/mysys/mf_keycache.c	2007-02-23 13:13:48 +02:00
@@ -159,8 +159,10 @@
                                      struct st_my_thread_var *thread);
 #endif
 static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block);
+#ifndef DBUG_OFF
 static void test_key_cache(KEY_CACHE *keycache,
                            const char *where, my_bool lock);
+#endif
 
 #define KEYCACHE_HASH(f, pos)                                                 \
 (((ulong) ((pos) >> keycache->key_cache_shift)+                               \
@@ -2608,7 +2610,8 @@
     0 on success (always because it can't fail)
 */
 
-int reset_key_cache_counters(const char *name, KEY_CACHE *key_cache)
+int reset_key_cache_counters(const char *name __attribute__((unused)),
+                             KEY_CACHE *key_cache)
 {
   DBUG_ENTER("reset_key_cache_counters");
   if (!key_cache->key_cache_inited)

--- 1.54/mysys/my_init.c	2006-12-23 21:19:46 +02:00
+++ 1.55/mysys/my_init.c	2007-02-23 13:13:48 +02:00
@@ -199,7 +199,9 @@
   }
 
   if (!(infoflag & MY_DONT_FREE_DBUG))
+  {
     DBUG_END();                /* Must be done before my_thread_end */
+  }
 #ifdef THREAD
   my_thread_end();
   my_thread_global_end();
@@ -248,14 +250,16 @@
 }
 
 /*
-  my_paramter_handler
-  Invalid paramter handler we will use instead of the one "baked" into the CRT
-  for MSC v8.  This one just prints out what invalid parameter was encountered.
-  By providing this routine, routines like lseek will return -1 when we expect them 
-  to instead of crash.
+  my_parameter_handler
+  
+  Invalid parameter handler we will use instead of the one "baked"
+  into the CRT for MSC v8.  This one just prints out what invalid
+  parameter was encountered.  By providing this routine, routines like
+  lseek will return -1 when we expect them to instead of crash.
 */
-void my_parameter_handler(const wchar_t * expression, const wchar_t * function, 
-                          const wchar_t * file, unsigned int line, 
+
+void my_parameter_handler(const wchar_t * expression, const wchar_t * function,
+                          const wchar_t * file, unsigned int line,
                           uintptr_t pReserved)
 {
   DBUG_PRINT("my",("Expression: %s  function: %s  file: %s, line: %d",

--- 1.48/mysys/my_thr_init.c	2007-02-21 10:43:50 +02:00
+++ 1.49/mysys/my_thr_init.c	2007-02-23 13:13:48 +02:00
@@ -46,23 +46,23 @@
 pthread_mutexattr_t my_errorcheck_mutexattr;
 #endif
 
-#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */
+#ifdef NPTL_PTHREAD_EXIT_BUG                    /* see my_pthread.h */
 
 /*
- Dummy thread spawned in my_thread_global_init() below to avoid
- race conditions in NPTL pthread_exit code.
+  Dummy thread spawned in my_thread_global_init() below to avoid
+  race conditions in NPTL pthread_exit code.
 */
 
-static
-pthread_handler_t nptl_pthread_exit_hack_handler(void *arg)
+static pthread_handler_t
+nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
 {
   /* Do nothing! */
   pthread_exit(0);
   return 0;
 }
-
 #endif
 
+
 /*
   initialize thread environment
 
@@ -83,25 +83,28 @@
   }
   
 #ifdef NPTL_PTHREAD_EXIT_BUG
+  /*
+    BUG#24507: Race conditions inside current NPTL pthread_exit() 
+    implementation.
 
-/*
-  BUG#24507: Race conditions inside current NPTL pthread_exit() implementation.
-
-  To avoid a possible segmentation fault during concurrent executions of 
-  pthread_exit(), a dummy thread is spawned which initializes internal variables
-  of pthread lib. See bug description for thoroughfull explanation. 
+    To avoid a possible segmentation fault during concurrent
+    executions of pthread_exit(), a dummy thread is spawned which
+    initializes internal variables of pthread lib. See bug description
+    for a full explanation.
   
-  TODO: Remove this code when fixed versions of glibc6 are in common use. 
-*/
-
-  pthread_t       dummy_thread;
-  pthread_attr_t  dummy_thread_attr;
-
-  pthread_attr_init(&dummy_thread_attr);
-  pthread_attr_setdetachstate(&dummy_thread_attr,PTHREAD_CREATE_DETACHED);
+    TODO: Remove this code when fixed versions of glibc6 are in common
+    use.
+  */
+  {
+    pthread_t       dummy_thread;
+    pthread_attr_t  dummy_thread_attr;
 
-  pthread_create(&dummy_thread,&dummy_thread_attr,nptl_pthread_exit_hack_handler,NULL);
+    pthread_attr_init(&dummy_thread_attr);
+    pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_DETACHED);
 
+    pthread_create(&dummy_thread,&dummy_thread_attr,
+                   nptl_pthread_exit_hack_handler, NULL);
+  }
 #endif
 
 #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
@@ -206,7 +209,7 @@
 #endif
 }
 
-static long thread_id=0;
+static my_thread_id thread_id= 0;
 
 /*
   Allocate thread specific memory for the thread, used by mysys and dbug
@@ -234,15 +237,16 @@
   my_bool error=0;
 
 #ifdef EXTRA_DEBUG_THREADS
-  fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self());
+  fprintf(stderr,"my_thread_init(): thread_id: 0x%lx\n",
+          (ulong) pthread_self());
 #endif  
 
 #if !defined(__WIN__) || defined(USE_TLS)
   if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
   {
 #ifdef EXTRA_DEBUG_THREADS
-    fprintf(stderr,"my_thread_init() called more than once in thread %ld\n",
-	        pthread_self());
+    fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n",
+            (long) pthread_self());
 #endif    
     goto end;
   }
@@ -262,7 +266,9 @@
   tmp= &THR_KEY_mysys;
 #endif
 #if defined(__WIN__) && defined(EMBEDDED_LIBRARY)
-  tmp->thread_self= (pthread_t)getpid();
+  tmp->pthread_self= (pthread_t) getpid();
+#else
+  tmp->pthread_self= pthread_self();
 #endif
   pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST);
   pthread_cond_init(&tmp->suspend, NULL);
@@ -272,6 +278,11 @@
   tmp->id= ++thread_id;
   ++THR_thread_count;
   pthread_mutex_unlock(&THR_LOCK_threads);
+#ifndef DBUG_OFF
+  /* Generate unique name for thread */
+  (void) my_thread_name();
+#endif
+
 end:
   return error;
 }
@@ -295,8 +306,8 @@
   tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
 
 #ifdef EXTRA_DEBUG_THREADS
-  fprintf(stderr,"my_thread_end(): tmp: 0x%lx  thread_id=%ld\n",
-	  (long) tmp, pthread_self());
+  fprintf(stderr,"my_thread_end(): tmp: 0x%lx  pthread_self: 0x%lx  thread_id: %ld\n",
+	  (long) tmp, (long) pthread_self(), tmp ? (long) tmp->id : 0L);
 #endif  
   if (tmp && tmp->init)
   {
@@ -357,17 +368,9 @@
   Get name of current thread.
 ****************************************************************************/
 
-#define UNKNOWN_THREAD -1
-
-long my_thread_id()
+my_thread_id my_thread_dbug_id()
 {
-#if defined(HAVE_PTHREAD_GETSEQUENCE_NP)
-  return pthread_getsequence_np(pthread_self());
-#elif (defined(__sun) || defined(__sgi) || defined(__linux__))
-  return pthread_self();
-#else
   return my_thread_var->id;
-#endif
 }
 
 #ifdef DBUG_OFF
@@ -384,8 +387,8 @@
   struct st_my_thread_var *tmp=my_thread_var;
   if (!tmp->name[0])
   {
-    long id=my_thread_id();
-    sprintf(name_buff,"T@%ld", id);
+    my_thread_id id= my_thread_dbug_id();
+    sprintf(name_buff,"T@%lu", (ulong) id);
     strmake(tmp->name,name_buff,THREAD_NAME_SIZE);
   }
   return tmp->name;

--- 1.8/mysys/ptr_cmp.c	2006-12-23 21:19:47 +02:00
+++ 1.9/mysys/ptr_cmp.c	2007-02-23 13:13:48 +02:00
@@ -185,7 +185,7 @@
   case 3: pos= (my_off_t) mi_uint3korr(ptr); break;
   case 2: pos= (my_off_t) mi_uint2korr(ptr); break;
   case 1: pos= (my_off_t) *(uchar*) ptr; break;
-  default: DBUG_ASSERT(0);
+  default: DBUG_ASSERT(0); return 0;
   }
  return pos;
 }

--- 1.56/mysys/thr_alarm.c	2007-02-21 10:43:50 +02:00
+++ 1.57/mysys/thr_alarm.c	2007-02-23 13:13:48 +02:00
@@ -146,6 +146,7 @@
   ulong now;
   sigset_t old_mask;
   my_bool reschedule;
+  struct st_my_thread_var *current_my_thread_var= my_thread_var;
   DBUG_ENTER("thr_alarm");
   DBUG_PRINT("enter",("thread: %s  sec: %d",my_thread_name(),sec));
 
@@ -195,7 +196,8 @@
     alarm_data->malloced=0;
   alarm_data->expire_time=now+sec;
   alarm_data->alarmed=0;
-  alarm_data->thread=pthread_self();
+  alarm_data->thread=    current_my_thread_var->pthread_self;
+  alarm_data->thread_id= current_my_thread_var->id;
   queue_insert(&alarm_queue,(byte*) alarm_data);
 
   /* Reschedule alarm if the current one has more than sec left */
@@ -444,7 +446,7 @@
   Remove another thread from the alarm
 */
 
-void thr_alarm_kill(pthread_t thread_id)
+void thr_alarm_kill(my_thread_id thread_id)
 {
   uint i;
   if (alarm_aborted)
@@ -452,8 +454,7 @@
   pthread_mutex_lock(&LOCK_alarm);
   for (i=0 ; i < alarm_queue.elements ; i++)
   {
-    if (pthread_equal(((ALARM*) queue_element(&alarm_queue,i))->thread,
-		      thread_id))
+    if (((ALARM*) queue_element(&alarm_queue,i))->thread_id == thread_id)
     {
       ALARM *tmp=(ALARM*) queue_remove(&alarm_queue,i);
       tmp->expire_time=0;
@@ -567,7 +568,7 @@
 
 #else /* __WIN__ */
 
-void thr_alarm_kill(pthread_t thread_id)
+void thr_alarm_kill(my_thread_id thread_id)
 {
   /* Can't do this yet */
 }

--- 1.57/mysys/thr_lock.c	2006-12-30 02:36:01 +02:00
+++ 1.58/mysys/thr_lock.c	2007-02-23 13:13:48 +02:00
@@ -343,8 +343,9 @@
 
 void thr_lock_info_init(THR_LOCK_INFO *info)
 {
-  info->thread= pthread_self();
-  info->thread_id= my_thread_id();              /* for debugging */
+  struct st_my_thread_var *tmp= my_thread_var;
+  info->thread=    tmp->pthread_self;
+  info->thread_id= tmp->id;
   info->n_cursors= 0;
 }
 
@@ -622,8 +623,10 @@
 	statistic_increment(locks_immediate,&THR_LOCK_lock);
 	goto end;
       }
+      /* purecov: begin inspected */
       DBUG_PRINT("lock",("write locked by thread: 0x%lx",
 			 lock->write.data->owner->info->thread_id));
+      /* purecov: end */
     }
     else
     {
@@ -658,7 +661,7 @@
 	  goto end;
 	}
       }
-      DBUG_PRINT("lock",("write locked by thread: 0x%lx, type: %d",
+      DBUG_PRINT("lock",("write locked by thread: 0x%lx  type: %d",
 			 lock->read.data->owner->info->thread_id, data->type));
     }
     wait_queue= &lock->write_wait;
@@ -720,8 +723,10 @@
       }
       lock->read_no_write_count++;
     }      
+    /* purecov: begin inspected */
     DBUG_PRINT("lock",("giving read lock to thread: 0x%lx",
 		       data->owner->info->thread_id));
+    /* purecov: end */
     data->cond=0;				/* Mark thread free */
     VOID(pthread_cond_signal(cond));
   } while ((data=data->next));
@@ -806,8 +811,10 @@
 	  if (data->type == TL_WRITE_CONCURRENT_INSERT &&
 	      (*lock->check_status)(data->status_param))
 	    data->type=TL_WRITE;			/* Upgrade lock */
+          /* purecov: begin inspected */
 	  DBUG_PRINT("lock",("giving write lock of type %d to thread: 0x%lx",
 			     data->type, data->owner->info->thread_id));
+          /* purecov: end */
 	  {
 	    pthread_cond_t *cond=data->cond;
 	    data->cond=0;				/* Mark thread free */
@@ -1006,7 +1013,7 @@
       thr_unlock(*pos);
     else
     {
-      DBUG_PRINT("lock",("Free lock: data: 0x%lx  thread: %ld  lock: 0x%lx",
+      DBUG_PRINT("lock",("Free lock: data: 0x%lx  thread: 0x%lx  lock: 0x%lx",
                          (long) *pos, (*pos)->owner->info->thread_id,
                          (long) (*pos)->lock));
     }
@@ -1054,7 +1061,7 @@
   This is used to abort all locks for a specific thread
 */
 
-my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
+my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
 {
   THR_LOCK_DATA *data;
   my_bool found= FALSE;
@@ -1063,7 +1070,7 @@
   pthread_mutex_lock(&lock->mutex);
   for (data= lock->read_wait.data; data ; data= data->next)
   {
-    if (pthread_equal(thread, data->owner->info->thread))
+    if (data->owner->info->thread_id == thread_id)    /* purecov: tested */
     {
       DBUG_PRINT("info",("Aborting read-wait lock"));
       data->type= TL_UNLOCK;			/* Mark killed */
@@ -1080,7 +1087,7 @@
   }
   for (data= lock->write_wait.data; data ; data= data->next)
   {
-    if (pthread_equal(thread, data->owner->info->thread))
+    if (data->owner->info->thread_id == thread_id) /* purecov: tested */
     {
       DBUG_PRINT("info",("Aborting write-wait lock"));
       data->type= TL_UNLOCK;
@@ -1133,7 +1140,9 @@
                               enum thr_lock_type new_lock_type)
 {
   THR_LOCK *lock=in_data->lock;
+#ifndef DBUG_OFF
   enum thr_lock_type old_lock_type= in_data->type;
+#endif
 #ifdef TO_BE_REMOVED
   THR_LOCK_DATA *data, *next;
   bool start_writers= FALSE;
@@ -1528,6 +1537,10 @@
 {
 }
 
+static void test_update_status(void* param __attribute__((unused)))
+{
+}
+
 static void test_copy_status(void* to __attribute__((unused)) ,
 			     void *from __attribute__((unused)))
 {
@@ -1620,7 +1633,7 @@
   {
     thr_lock_init(locks+i);
     locks[i].check_status= test_check_status;
-    locks[i].update_status=test_get_status;
+    locks[i].update_status=test_update_status;
     locks[i].copy_status=  test_copy_status;
     locks[i].get_status=   test_get_status;
   }

--- 1.30/mysys/thr_mutex.c	2006-12-23 21:19:47 +02:00
+++ 1.31/mysys/thr_mutex.c	2007-02-23 13:13:48 +02:00
@@ -212,7 +212,7 @@
   {
     fprintf(stderr,
 	    "safe_mutex:  Count was %d in thread 0x%lx when locking mutex at %s, line %d\n",
-	    mp->count-1, my_thread_id(), file, line);
+	    mp->count-1, my_thread_dbug_id(), file, line);
     fflush(stderr);
     abort();
   }
@@ -250,7 +250,7 @@
   {
     fprintf(stderr,
 	    "safe_mutex:  Count was %d in thread 0x%lx when locking mutex at %s, line %d (error: %d (%d))\n",
-	    mp->count-1, my_thread_id(), file, line, error, error);
+	    mp->count-1, my_thread_dbug_id(), file, line, error, error);
     fflush(stderr);
     abort();
   }

--- 1.7/cmd-line-utils/readline/xmalloc.c	2005-07-19 04:00:16 +03:00
+++ 1.8/cmd-line-utils/readline/xmalloc.c	2007-02-23 13:13:47 +02:00
@@ -39,8 +39,7 @@
 /* **************************************************************** */
 
 static void
-memory_error_and_abort (fname)
-     char *fname;
+memory_error_and_abort(const char *fname)
 {
   fprintf (stderr, "%s: out of virtual memory\n", fname);
   exit (2);
@@ -57,7 +56,7 @@
 
   temp = malloc (bytes);
   if (temp == 0)
-    memory_error_and_abort ("xmalloc");
+    memory_error_and_abort("xmalloc");
   return (temp);
 }
 
@@ -71,7 +70,7 @@
   temp = pointer ? realloc (pointer, bytes) : malloc (bytes);
 
   if (temp == 0)
-    memory_error_and_abort ("xrealloc");
+    memory_error_and_abort("xrealloc");
   return (temp);
 }
 

--- 1.34/sql-bench/bench-init.pl.sh	2006-12-31 02:06:37 +02:00
+++ 1.35/sql-bench/bench-init.pl.sh	2007-02-23 13:13:50 +02:00
@@ -39,7 +39,7 @@
 
 $|=1;				# Output data immediately
 
-$opt_skip_test=$opt_skip_create=$opt_skip_delete=$opt_verbose=$opt_fast_insert=$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=$opt_log=$opt_use_old_results=$opt_help=$opt_odbc=$opt_small_test=$opt_small_tables=$opt_samll_key_tables=$opt_stage=$opt_old_headers=$opt_die_on_errors=$opt_tcpip=$opt_random=0;
+$opt_skip_test=$opt_skip_create=$opt_skip_delete=$opt_verbose=$opt_fast_insert=$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=$opt_log=$opt_use_old_results=$opt_help=$opt_odbc=$opt_small_test=$opt_small_tables=$opt_samll_key_tables=$opt_stage=$opt_old_headers=$opt_die_on_errors=$opt_tcpip=$opt_random=$opt_only_missing_tests=0;
 $opt_cmp=$opt_user=$opt_password=$opt_connect_options="";
 $opt_server="mysql"; $opt_dir="output";
 $opt_host="localhost";$opt_database="test";
@@ -59,7 +59,7 @@
 					"use-old-results","skip-test",
 					"optimization","hw",
 					"machine", "dir", "suffix", "log"));
-GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s") || usage();
+GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s","only-missing-tests") || usage();
 
 usage() if ($opt_help);
 $server=get_server($opt_server,$opt_host,$opt_database,$opt_odbc,
@@ -504,6 +504,13 @@
 --odbc
   Use the ODBC DBI driver to connect to the database.
 
+--only-missing-tests
+  Only run test that don\'t have an old test result.
+  This is useful when you want to do a re-run of tests that failed in last run.
+
+--optimization='some comments'
+ Add coments about optimization of DBMS, which was done before the test.
+
 --password='password'
   Password for the current user.
 
@@ -576,9 +583,6 @@
   This is a test specific option that is only used when debugging a test.
   Print more information about what is going on.
 
---optimization='some comments'
- Add coments about optimization of DBMS, which was done before the test.
- 
 --hw='some comments'
  Add coments about hardware used for this test.
 

--- 1.16/sql-bench/run-all-tests.sh	2006-12-31 02:06:37 +02:00
+++ 1.17/sql-bench/run-all-tests.sh	2007-02-23 13:13:50 +02:00
@@ -114,7 +114,6 @@
 print "Optimization:        $opt_optimization\n";
 print "Hardware:            $opt_hw\n\n";
 
-
 $estimated=$warning=$got_warning=0;
 while (<test-*>)
 {
@@ -129,6 +128,11 @@
       $skip_prog = 1;
       last;
     }
+  }
+  if ($opt_only_missing_tests && -f "$opt_dir$dir$prog-$filename")
+  {
+    # Test already run, skip it
+    $skip_prog= 1;
   }
   print "$prog: ";
   if ((!$opt_use_old_results) && (!$skip_prog))

--- 1.45/sql-bench/test-insert.sh	2006-12-31 02:06:37 +02:00
+++ 1.46/sql-bench/test-insert.sh	2007-02-23 13:13:50 +02:00
@@ -998,7 +998,7 @@
 {
   $sth = $dbh->do("update bench1 set dummy1='updated' where id=$i") or die $DBI::errstr;
   $end_time=new Benchmark;
-  last if ($estimated=predict_query_time($loop_time,$end_time,\$i,$tests,
+  last if ($estimated=predict_query_time($loop_time,$end_time,\$i,($i-1)/3,
 					 $opt_loop_count));
 }
 if ($estimated)

--- 1.173/sql/Makefile.am	2007-02-07 16:11:17 +02:00
+++ 1.174/sql/Makefile.am	2007-02-23 13:13:48 +02:00
@@ -64,10 +64,11 @@
 			tztime.h my_decimal.h\
 			sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \
 			parse_file.h sql_view.h	sql_trigger.h \
-			sql_array.h sql_cursor.h events.h \
+			sql_array.h sql_cursor.h events.h scheduler.h \
                         event_db_repository.h event_queue.h \
-			sql_plugin.h authors.h sql_partition.h event_data_objects.h \
-			partition_info.h partition_element.h event_scheduler.h \
+			sql_plugin.h authors.h \
+			event_data_objects.h event_scheduler.h \
+			sql_partition.h partition_info.h partition_element.h \
 			contributors.h sql_servers.h
 mysqld_SOURCES =	sql_lex.cc sql_handler.cc sql_partition.cc \
 			item.cc item_sum.cc item_buff.cc item_func.cc \
@@ -79,7 +80,8 @@
 			lock.cc my_lock.c \
 			sql_string.cc sql_manager.cc sql_map.cc \
 			mysqld.cc password.c hash_filo.cc hostname.cc \
-			set_var.cc sql_parse.cc sql_yacc.yy \
+			sql_connect.cc scheduler.cc sql_parse.cc \
+			set_var.cc sql_yacc.yy \
 			sql_base.cc table.cc sql_select.cc sql_insert.cc \
 			sql_prepare.cc sql_error.cc sql_locale.cc \
 			sql_update.cc sql_delete.cc uniques.cc sql_do.cc \

--- 1.211/sql/field.h	2007-02-14 02:09:33 +02:00
+++ 1.212/sql/field.h	2007-02-23 13:13:48 +02:00
@@ -825,8 +825,8 @@
   void sort_string(char *buff,uint length);
   uint32 pack_length() const { return sizeof(double); }
   void sql_type(String &str) const;
-  uint size_of() const { return sizeof(*this); }
   uint32 max_display_length() { return 53; }
+  uint size_of() const { return sizeof(*this); }
 };
 
 

--- 1.186/BitKeeper/deleted/.del-ha_berkeley.cc	2006-12-31 02:06:32 +02:00
+++ 1.187/BitKeeper/deleted/.del-ha_berkeley.cc	2007-02-23 13:13:46 +02:00
@@ -262,6 +262,7 @@
   return 0;
 }
 
+
 bool berkeley_flush_logs()
 {
   int error;
@@ -509,6 +510,15 @@
     }
   }
   return flags;
+}
+
+
+void ha_berkeley::get_auto_primary_key(byte *to)
+{
+  pthread_mutex_lock(&share->mutex);
+  share->auto_ident++;
+  int5store(to,share->auto_ident);
+  pthread_mutex_unlock(&share->mutex);
 }
 
 

--- 1.87/BitKeeper/deleted/.del-ha_berkeley.h	2006-12-31 02:06:32 +02:00
+++ 1.88/BitKeeper/deleted/.del-ha_berkeley.h	2007-02-23 13:13:47 +02:00
@@ -140,13 +140,7 @@
 			     enum thr_lock_type lock_type);
 
   void get_status();
-  inline void get_auto_primary_key(byte *to)
-  {
-    pthread_mutex_lock(&share->mutex);
-    share->auto_ident++;
-    int5store(to,share->auto_ident);
-    pthread_mutex_unlock(&share->mutex);
-  }
+  void get_auto_primary_key(byte *to);
   virtual void get_auto_increment(ulonglong offset, ulonglong increment,
                                   ulonglong nb_desired_values,
                                   ulonglong *first_value,

--- 1.295/sql/handler.cc	2007-02-05 13:29:22 +02:00
+++ 1.296/sql/handler.cc	2007-02-23 13:13:48 +02:00
@@ -845,7 +845,7 @@
     message in the error log, so we don't send it.
   */
   if (is_real_trans && (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) &&
-      !thd->slave_thread)
+      !thd->slave_thread && thd->killed != THD::KILL_CONNECTION)
     push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                  ER_WARNING_NOT_COMPLETE_ROLLBACK,
                  ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
@@ -2855,8 +2855,8 @@
 {
   int error= 0;
   DBUG_ENTER("ha_find_files");
-  DBUG_PRINT("enter", ("db: %s, path: %s, wild: %s, dir: %d", 
-		       db, path, wild, dir));
+  DBUG_PRINT("enter", ("db: '%s'  path: '%s'  wild: '%s'  dir: %d", 
+		       db, path, wild ? wild : "NULL", dir));
   st_find_files_args args= {db, path, wild, dir, files};
 
   plugin_foreach(thd, find_files_handlerton,

--- 1.242/sql/item.cc	2007-02-14 14:40:50 +02:00
+++ 1.243/sql/item.cc	2007-02-23 13:13:48 +02:00
@@ -1553,6 +1553,8 @@
       doesn't display each argument's characteristics.
     - if nargs is 1, then this error cannot happen.
   */
+  LINT_INIT(safe_args[0]);
+  LINT_INIT(safe_args[1]);
   if (nargs >=2 && nargs <= 3)
   {
     safe_args[0]= args[0];

--- 1.244/sql/item_cmpfunc.cc	2007-02-14 14:40:51 +02:00
+++ 1.245/sql/item_cmpfunc.cc	2007-02-23 13:13:48 +02:00
@@ -903,6 +903,7 @@
 
 longlong Item_in_optimizer::val_int()
 {
+  bool tmp;
   DBUG_ASSERT(fixed == 1);
   cache->store(args[0]);
   
@@ -966,7 +967,7 @@
     }
     return 0;
   }
-  bool tmp= args[1]->val_bool_result();
+  tmp= args[1]->val_bool_result();
   null_value= args[1]->null_value;
   return tmp;
 }

--- 1.355/sql/item_func.cc	2007-02-15 09:09:05 +02:00
+++ 1.356/sql/item_func.cc	2007-02-23 13:13:48 +02:00
@@ -3087,14 +3087,8 @@
   int count;
   bool locked;
   pthread_cond_t cond;
-#ifndef EMBEDDED_LIBRARY
-  pthread_t thread;
-  void set_thread(THD *thd) { thread= thd->real_id; }
-#else
-  THD       *thread;
-  void set_thread(THD *thd) { thread= thd; }
-#endif /*EMBEDDED_LIBRARY*/
-  ulong thread_id;
+  my_thread_id thread_id;
+  void set_thread(THD *thd) { thread_id= thd->thread_id; }
 
   User_level_lock(const char *key_arg,uint length, ulong id) 
     :key_length(length),count(1),locked(1), thread_id(id)
@@ -3411,11 +3405,7 @@
   }
   else
   {
-#ifdef EMBEDDED_LIBRARY
-    if (ull->locked && (current_thd == ull->thread))
-#else
-    if (ull->locked && pthread_equal(pthread_self(),ull->thread))
-#endif
+    if (ull->locked && current_thd->thread_id == ull->thread_id)
     {
       result=1;					// Release is ok
       item_user_lock_release(ull);
@@ -3460,7 +3450,7 @@
   THD *thd=current_thd;
   ulong loop_count;
 
-  loop_count= args[0]->val_int();
+  loop_count= (ulong) args[0]->val_int();
 
   if (args[0]->null_value)
   {

--- 1.309/sql/item_strfunc.cc	2007-01-29 01:51:38 +02:00
+++ 1.310/sql/item_strfunc.cc	2007-02-23 13:13:48 +02:00
@@ -1926,7 +1926,7 @@
   int diff;
   DBUG_ASSERT(fixed == 1);
 
-  dec= args[1]->val_int();
+  dec= (int) args[1]->val_int();
   if (args[1]->null_value)
   {
     null_value=1;

--- 1.157/sql/item_timefunc.cc	2007-02-06 21:24:39 +02:00
+++ 1.158/sql/item_timefunc.cc	2007-02-23 13:13:48 +02:00
@@ -1587,7 +1587,7 @@
 void Item_func_sysdate_local::store_now_in_TIME(TIME *now_time)
 {
   THD *thd= current_thd;
-  thd->variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
+  thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) time(NULL));
   thd->time_zone_used= 1;
 }
 

--- 1.102/sql/lock.cc	2007-01-24 23:39:46 +02:00
+++ 1.103/sql/lock.cc	2007-02-23 13:13:48 +02:00
@@ -485,7 +485,7 @@
     for (uint i=0; i < locked->lock_count; i++)
     {
       if (thr_abort_locks_for_thread(locked->locks[i]->lock,
-                                     table->in_use->real_id))
+                                     table->in_use->thread_id))
         result= TRUE;
     }
     my_free((gptr) locked,MYF(0));

--- 1.255/sql/log.cc	2007-01-29 01:47:30 +02:00
+++ 1.256/sql/log.cc	2007-02-23 13:13:48 +02:00
@@ -267,7 +267,7 @@
     table->table_name_length= 8;
     break;
   default:
-    DBUG_ASSERT(0);
+    assert(0);                                  // Impossible
   }
 
   /*
@@ -1161,7 +1161,7 @@
     log_thd= table_log_handler->general_log_thd;
     break;
   default:
-    DBUG_ASSERT(0);
+    assert(0);                                  // Impossible
   }
 
   if (!(*tmp_opt))
@@ -1310,7 +1310,7 @@
     table= &slow_log;
     break;
   default:
-    DBUG_ASSERT(0);
+    assert(0);                                  // Impossible
   }
 
   /*
@@ -3887,7 +3887,7 @@
 #ifdef HAVE_REPLICATION
     if (expire_logs_days)
     {
-      long purge_time= time(0) - expire_logs_days*24*60*60;
+      long purge_time= (long) (time(0) - expire_logs_days*24*60*60);
       if (purge_time >= 0)
         purge_logs_before_date(purge_time);
     }

--- 1.266/sql/log_event.cc	2007-02-05 07:14:07 +02:00
+++ 1.267/sql/log_event.cc	2007-02-23 13:13:48 +02:00
@@ -1148,7 +1148,6 @@
 {
   const uchar *ptr= (const uchar *)temp_buf;
   uint32 size= uint4korr(ptr + EVENT_LEN_OFFSET);
-
   DBUG_ENTER("Log_event::print_base64");
 
   size_t const tmp_str_sz= base64_needed_encoded_length((int) size);
@@ -1159,8 +1158,10 @@
     DBUG_VOID_RETURN;
   }
 
-  int const res= base64_encode(ptr, (size_t) size, tmp_str);
-  DBUG_ASSERT(res == 0);
+  if (base64_encode(ptr, (size_t) size, tmp_str))
+  {
+    DBUG_ASSERT(0);
+  }
 
   if (my_b_tell(file) == 0)
     my_b_printf(file, "\nBINLOG '\n");
@@ -5471,7 +5472,7 @@
     my_ptrdiff_t const new_alloc= 
         block_size * ((cur_size + length) / block_size + block_size - 1);
 
-    byte* const new_buf= (byte*)my_realloc((gptr)m_rows_buf, new_alloc,
+    byte* const new_buf= (byte*)my_realloc((gptr)m_rows_buf, (uint) new_alloc,
                                            MYF(MY_ALLOW_ZERO_PTR|MY_WME));
     if (unlikely(!new_buf))
       DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -6014,7 +6015,7 @@
                           sbuf_end - sbuf) ||
           my_b_safe_write(file, reinterpret_cast<byte*>(m_cols.bitmap),
                           no_bytes_in_map(&m_cols)) ||
-          my_b_safe_write(file, m_rows_buf, data_size));
+          my_b_safe_write(file, m_rows_buf, (uint) data_size));
 }
 #endif
 
@@ -6367,8 +6368,8 @@
   DBUG_ASSERT(m_dblen < 128);
   DBUG_ASSERT(m_tbllen < 128);
 
-  byte const dbuf[]= { m_dblen };
-  byte const tbuf[]= { m_tbllen };
+  byte const dbuf[]= { (byte) m_dblen };
+  byte const tbuf[]= { (byte) m_tbllen };
 
   char cbuf[sizeof(m_colcnt)];
   char *const cbuf_end= net_store_length((char*) cbuf, (uint) m_colcnt);

--- 1.482/sql/mysql_priv.h	2007-02-16 13:06:57 +02:00
+++ 1.483/sql/mysql_priv.h	2007-02-23 13:13:49 +02:00
@@ -38,6 +38,7 @@
 #include <queues.h>
 #include "sql_bitmap.h"
 #include "sql_array.h"
+#include "scheduler.h"
 
 /* TODO convert all these three maps to Bitmap classes */
 typedef ulonglong table_map;          /* Used for table bits in join */
@@ -282,7 +283,6 @@
 #define TEST_MIT_THREAD		4
 #define TEST_BLOCKING		8
 #define TEST_KEEP_TMP_TABLES	16
-#define TEST_NO_THREADS		32	/* For debugging under Linux */
 #define TEST_READCHECK		64	/* Force use of readcheck */
 #define TEST_NO_EXTRA		128
 #define TEST_CORE_ON_SIGNAL	256	/* Give core if signal */
@@ -787,6 +787,23 @@
 void write_bin_log(THD *thd, bool clear_error,
                    char const *query, ulong query_length);
 
+/* sql_connect.cc */
+int check_user(THD *thd, enum enum_server_command command, 
+	       const char *passwd, uint passwd_len, const char *db,
+	       bool check_count);
+pthread_handler_t handle_one_connection(void *arg);
+bool init_new_connection_handler_thread();
+void reset_mqh(LEX_USER *lu, bool get_them);
+bool check_mqh(THD *thd, uint check_command);
+void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
+int check_for_max_user_connections(THD *thd, USER_CONN *uc);
+void decrease_user_connections(USER_CONN *uc);
+void thd_init_client_charset(THD *thd, uint cs_number);
+bool setup_connection_thread_globals(THD *thd);
+bool login_connection(THD *thd);
+void prepare_new_connection_state(THD* thd);
+void end_connection(THD *thd);
+
 bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
 bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
 bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
@@ -822,10 +839,7 @@
 void init_max_user_conn(void);
 void init_update_queries(void);
 void free_max_user_conn(void);
-pthread_handler_t handle_one_connection(void *arg);
 pthread_handler_t handle_bootstrap(void *arg);
-void end_thread(THD *thd,bool put_in_cache);
-void flush_thread_cache();
 bool mysql_execute_command(THD *thd);
 bool do_command(THD *thd);
 bool dispatch_command(enum enum_server_command command, THD *thd,
@@ -1495,6 +1509,11 @@
 extern void MYSQLerror(const char*);
 void refresh_status(THD *thd);
 my_bool mysql_rm_tmp_tables(void);
+void handle_connection_in_main_thread(THD *thd);
+void create_thread_to_handle_connection(THD *thd);
+void unlink_thd(THD *thd);
+bool one_thread_per_connection_end(THD *thd, bool put_in_cache);
+void flush_thread_cache();
 
 /* item_func.cc */
 extern bool check_reserved_words(LEX_STRING *name);
@@ -1578,7 +1597,7 @@
 extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
 extern ulong max_binlog_size, max_relay_log_size;
 extern ulong opt_binlog_rows_event_max_size;
-extern ulong rpl_recovery_rank, thread_cache_size;
+extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
 extern ulong back_log;
 extern ulong specialflag, current_pid;
 extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
@@ -1663,6 +1682,9 @@
 extern const char* any_db;
 extern struct my_option my_long_options[];
 extern const LEX_STRING view_type;
+extern scheduler_functions thread_scheduler;
+extern TYPELIB thread_handling_typelib;
+extern uint8 uc_update_queries[SQLCOM_END+1];
 extern uint sql_command_flags[];
 extern TYPELIB log_output_typelib;
 

--- 1.147/client/mysqlbinlog.cc	2007-01-29 01:47:29 +02:00
+++ 1.148/client/mysqlbinlog.cc	2007-02-23 13:13:47 +02:00
@@ -1481,7 +1481,7 @@
 
 int main(int argc, char** argv)
 {
-  static char **defaults_argv;
+  char **defaults_argv;
   int exit_value= 0;
   ulonglong save_stop_position;
   MY_INIT(argv[0]);

--- 1.620/sql/mysqld.cc	2007-02-21 17:07:00 +02:00
+++ 1.621/sql/mysqld.cc	2007-02-23 13:13:49 +02:00
@@ -59,10 +59,6 @@
 
 #define mysqld_charset &my_charset_latin1
 
-#ifndef DBUG_OFF
-#define ONE_THREAD
-#endif
-
 #ifdef HAVE_purify
 #define IF_PURIFY(A,B) (A)
 #else
@@ -282,6 +278,16 @@
   array_elements(tc_heuristic_recover_names)-1,"",
   tc_heuristic_recover_names, NULL
 };
+
+static const char *thread_handling_names[]=
+{ "one-thread-per-connection", "no-threads", "pool-of-threads", NullS};
+
+TYPELIB thread_handling_typelib=
+{
+  array_elements(thread_handling_names) - 1, "",
+  thread_handling_names, NULL
+};
+
 const char *first_keyword= "first", *binary_keyword= "BINARY";
 const char *my_localhost= "localhost", *delayed_user= "DELAYED";
 #if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
@@ -467,7 +473,8 @@
 ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
 ulong open_files_limit, max_binlog_size, max_relay_log_size;
 ulong slave_net_timeout, slave_trans_retries;
-ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
+ulong thread_cache_size=0, thread_pool_size= 0;
+ulong binlog_cache_size=0, max_binlog_cache_size=0;
 ulong query_cache_size=0;
 ulong refresh_version, flush_version;	/* Increments on each reload */
 query_id_t global_query_id;
@@ -681,6 +688,8 @@
 HANDLE smem_event_connect_request= 0;
 #endif
 
+scheduler_functions thread_scheduler;
+
 #define SSL_VARS_NOT_STATIC
 #include "sslopt-vars.h"
 #ifdef HAVE_OPENSSL
@@ -861,6 +870,7 @@
       continue;
 
     tmp->killed= THD::KILL_CONNECTION;
+    thread_scheduler.post_kill_notification(tmp);
     if (tmp->mysys_var)
     {
       tmp->mysys_var->abort=1;
@@ -1254,6 +1264,7 @@
   if (!opt_bootstrap)
     (void) my_delete(pidfile_name,MYF(0));	// This may not always exist
 #endif
+  thread_scheduler.end();
   finish_client_errs();
   my_free((gptr) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST),
           MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
@@ -1513,6 +1524,9 @@
   DBUG_ENTER("network_init");
   LINT_INIT(ret);
 
+  if (thread_scheduler.init())
+    unireg_abort(1);			/* purecov: inspected */
+
   set_ports();
 
   if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap)
@@ -1731,21 +1745,55 @@
   if (thd && ! thd->bootstrap)
   {
     statistic_increment(killed_threads, &LOCK_status);
-    end_thread(thd,0);
+    thread_scheduler.end_thread(thd,0);		/* purecov: inspected */
   }
   DBUG_VOID_RETURN;				/* purecov: deadcode */
 }
 
 
-void end_thread(THD *thd, bool put_in_cache)
+/*
+  Unlink thd from global list of available connections and free thd
+
+  SYNOPSIS
+    unlink_thd()
+    thd		 Thread handler
+
+  NOTES
+    LOCK_thread_count is locked and left locked
+*/
+
+void unlink_thd(THD *thd)
 {
-  DBUG_ENTER("end_thread");
+  DBUG_ENTER("unlink_thd");
+  DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
   thd->cleanup();
   (void) pthread_mutex_lock(&LOCK_thread_count);
   thread_count--;
   delete thd;
+  DBUG_VOID_RETURN;
+}
+
 
-  if (put_in_cache && cached_thread_count < thread_cache_size &&
+/*
+  Store thread in cache for reuse by new connections
+
+  SYNOPSIS
+    cache_thread()
+
+  NOTES
+    LOCK_thread_count has to be locked
+
+  RETURN
+    0  Thread was not put in cache
+    1  Thread is to be reused by new connection.
+       (ie, caller should return, not abort with pthread_exit())
+*/
+
+
+static bool cache_thread()
+{
+  safe_mutex_assert_owner(&LOCK_thread_count);
+  if (cached_thread_count < thread_cache_size &&
       ! abort_loop && !kill_cached_threads)
   {
     /* Don't kill the thread, just put it in cache for reuse */
@@ -1758,31 +1806,56 @@
       pthread_cond_signal(&COND_flush_thread_cache);
     if (wake_thread)
     {
+      THD *thd;
       wake_thread--;
-      thd=thread_cache.get();
-      thd->real_id=pthread_self();
+      thd= thread_cache.get();
       thd->thread_stack= (char*) &thd;          // For store_globals
       (void) thd->store_globals();
       thd->thr_create_time= time(NULL);
       threads.append(thd);
-      pthread_mutex_unlock(&LOCK_thread_count);
-      DBUG_VOID_RETURN;
+      return(1);
     }
   }
+  return(0);
+}
+
+
+/*
+  End thread for the current connection
+
+  SYNOPSIS
+    one_thread_per_connection_end()
+    thd		  Thread handler
+    put_in_cache  Store thread in cache, if there is room in it
+                  Normally this is true in all cases except when we got
+                  out of resources initializing the current thread
+
+  NOTES
+    If thread is cached, we will wait until thread is scheduled to be
+    reused and then we will return.
+    If thread is not cached, we end the thread.
+
+  RETURN
+    0    Signal to handle_one_connection to reuse connection
+*/
+
+bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
+{
+  DBUG_ENTER("one_thread_per_connection_end");
+  unlink_thd(thd);
+  if (put_in_cache)
+    put_in_cache= cache_thread();
+  pthread_mutex_unlock(&LOCK_thread_count);
+  if (put_in_cache)
+    DBUG_RETURN(0);                             // Thread is reused
 
-  /* Tell main we are ready */
-  (void) pthread_mutex_unlock(&LOCK_thread_count);
   /* It's safe to broadcast outside a lock (COND... is not deleted here) */
   DBUG_PRINT("signal", ("Broadcasting COND_thread_count"));
   (void) pthread_cond_broadcast(&COND_thread_count);
-#ifdef ONE_THREAD
-  if (!(test_flags & TEST_NO_THREADS))	// For debugging under Linux
-#endif
-  {
-    my_thread_end();
-    pthread_exit(0);
-  }
-  DBUG_VOID_RETURN;
+
+  my_thread_end();
+  pthread_exit(0);
+  DBUG_RETURN(0);                               // Impossible
 }
 
 
@@ -2123,14 +2196,15 @@
           (ulong) dflt_key_cache->key_cache_mem_size);
   fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
   fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
-  fprintf(stderr, "max_connections=%lu\n", max_connections);
+  fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
   fprintf(stderr, "threads_connected=%u\n", thread_count);
   fprintf(stderr, "It is possible that mysqld could use up to \n\
-key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %lu K\n\
+key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
 bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
 		     (global_system_variables.read_buff_size +
 		      global_system_variables.sortbuff_size) *
-		     max_connections)/ 1024);
+		     thread_scheduler.max_threads +
+                     max_connections * sizeof(THD)) / 1024);
   fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
 
 #if defined(HAVE_LINUXTHREADS)
@@ -2331,7 +2405,7 @@
     This should actually be '+ max_number_of_slaves' instead of +10,
     but the +10 should be quite safe.
   */
-  init_thr_alarm(max_connections +
+  init_thr_alarm(thread_scheduler.max_threads +
 		 global_system_variables.max_insert_delayed_threads + 10);
 #if SIGINT != THR_KILL_SIGNAL
   if (test_flags & TEST_SIGINT)
@@ -2535,18 +2609,6 @@
 
 #ifdef __WIN__
 
-struct utsname
-{
-  char nodename[FN_REFLEN];
-};
-
-
-int uname(struct utsname *a)
-{
-  return -1;
-}
-
-
 pthread_handler_t handle_shutdown(void *arg)
 {
   MSG msg;
@@ -3357,7 +3419,7 @@
 #ifdef HAVE_REPLICATION
   if (opt_bin_log && expire_logs_days)
   {
-    long purge_time= time(0) - expire_logs_days*24*60*60;
+    long purge_time= (long) (time(0) - expire_logs_days*24*60*60);
     if (purge_time >= 0)
       mysql_bin_log.purge_logs_before_date(purge_time);
   }
@@ -4009,7 +4071,7 @@
   my_net_init(&thd->net,(st_vio*) 0);
   thd->max_client_packet_length= thd->net.max_packet;
   thd->security_ctx->master_access= ~(ulong)0;
-  thd->thread_id=thread_id++;
+  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
   thread_count++;
 
   bootstrap_file=file;
@@ -4052,6 +4114,74 @@
 
 
 #ifndef EMBEDDED_LIBRARY
+
+/*
+   Simple scheduler that use the main thread to handle the request
+
+   NOTES
+     This is only used for debugging, when starting mysqld with
+     --thread-handling=no-threads or --one-thread
+
+     When we enter this function, LOCK_thread_count is hold!
+*/
+   
+void handle_connection_in_main_thread(THD *thd)
+{
+  safe_mutex_assert_owner(&LOCK_thread_count);
+  thread_cache_size=0;			// Safety
+  threads.append(thd);
+  (void) pthread_mutex_unlock(&LOCK_thread_count);
+  handle_one_connection((void*) thd);
+}
+
+
+/*
+  Scheduler that uses one thread per connection
+*/
+
+void create_thread_to_handle_connection(THD *thd)
+{
+  if (cached_thread_count > wake_thread)
+  {
+    /* Get thread from cache */
+    thread_cache.append(thd);
+    wake_thread++;
+    pthread_cond_signal(&COND_thread_cache);
+  }
+  else
+  {
+    /* Create new thread to handle connection */
+    int error;
+    thread_created++;
+    threads.append(thd);
+    DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
+    thd->connect_time = time(NULL);
+    if ((error=pthread_create(&thd->real_id,&connection_attrib,
+                              handle_one_connection,
+                              (void*) thd)))
+    {
+      /* purify: begin inspected */
+      DBUG_PRINT("error",
+                 ("Can't create thread to handle request (error %d)",
+                  error));
+      thread_count--;
+      thd->killed= THD::KILL_CONNECTION;			// Safety
+      (void) pthread_mutex_unlock(&LOCK_thread_count);
+      statistic_increment(aborted_connects,&LOCK_status);
+      net_printf_error(thd, ER_CANT_CREATE_THREAD, error);
+      (void) pthread_mutex_lock(&LOCK_thread_count);
+      close_connection(thd,0,0);
+      delete thd;
+      (void) pthread_mutex_unlock(&LOCK_thread_count);
+      return;
+      /* purecov: end */
+    }
+  }
+  (void) pthread_mutex_unlock(&LOCK_thread_count);
+  DBUG_PRINT("info",("Thread created"));
+}
+
+
 /*
   Create new thread to handle incoming connection.
 
@@ -4088,64 +4218,15 @@
     DBUG_VOID_RETURN;
   }
   pthread_mutex_lock(&LOCK_thread_count);
-  thd->thread_id=thread_id++;
-
-  thd->real_id=pthread_self();			// Keep purify happy
+  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
 
   /* Start a new thread to handle connection */
   thread_count++;
 
-#ifdef ONE_THREAD
-  if (test_flags & TEST_NO_THREADS)		// For debugging under Linux
-  {
-    thread_cache_size=0;			// Safety
-    threads.append(thd);
-    thd->real_id=pthread_self();
-    (void) pthread_mutex_unlock(&LOCK_thread_count);
-    handle_one_connection((void*) thd);
-  }
-  else
-#endif
-  {
-    if (thread_count-delayed_insert_threads > max_used_connections)
-      max_used_connections=thread_count-delayed_insert_threads;
+  if (thread_count - delayed_insert_threads > max_used_connections)
+    max_used_connections= thread_count - delayed_insert_threads;
 
-    if (cached_thread_count > wake_thread)
-    {
-      thread_cache.append(thd);
-      wake_thread++;
-      pthread_cond_signal(&COND_thread_cache);
-    }
-    else
-    {
-      int error;
-      thread_created++;
-      threads.append(thd);
-      DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
-      thd->connect_time = time(NULL);
-      if ((error=pthread_create(&thd->real_id,&connection_attrib,
-				handle_one_connection,
-				(void*) thd)))
-      {
-	DBUG_PRINT("error",
-		   ("Can't create thread to handle request (error %d)",
-		    error));
-	thread_count--;
-	thd->killed= THD::KILL_CONNECTION;			// Safety
-	(void) pthread_mutex_unlock(&LOCK_thread_count);
-	statistic_increment(aborted_connects,&LOCK_status);
-	net_printf_error(thd, ER_CANT_CREATE_THREAD, error);
-	(void) pthread_mutex_lock(&LOCK_thread_count);
-	close_connection(thd,0,0);
-	delete thd;
-	(void) pthread_mutex_unlock(&LOCK_thread_count);
-	DBUG_VOID_RETURN;
-      }
-    }
-    (void) pthread_mutex_unlock(&LOCK_thread_count);
-
-  }
-  DBUG_PRINT("info",("Thread created"));
+  thread_scheduler.add_connection(thd);
   DBUG_VOID_RETURN;
 }
 #endif /* EMBEDDED_LIBRARY */
@@ -4895,6 +4976,7 @@
   OPT_GENERAL_LOG,
   OPT_SLOW_LOG,
   OPT_MERGE,
+  OPT_THREAD_HANDLING,
   OPT_INNODB_ROLLBACK_ON_TIMEOUT
 };
 
@@ -5502,11 +5584,9 @@
    (gptr*) &global_system_variables.old_passwords,
    (gptr*) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG,
    0, 0, 0, 0, 0, 0},
-#ifdef ONE_THREAD
   {"one-thread", OPT_ONE_THREAD,
-   "Only use one thread (for debugging under Linux).", 0, 0, 0, GET_NO_ARG,
-   NO_ARG, 0, 0, 0, 0, 0, 0},
-#endif
+   "(deprecated): Only use one thread (for debugging under Linux). Use thread-handling=no-threads instead",
+   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS,
    "Enable old-style user limits (before 5.0.3 user resources were counted per each user+host vs. per account)",
    (gptr*) &opt_old_style_user_limits, (gptr*) &opt_old_style_user_limits,
@@ -5985,7 +6065,7 @@
   // children, to avoid "too many connections" error in a common setup
   {"max_connections", OPT_MAX_CONNECTIONS,
    "The number of simultaneous clients allowed.", (gptr*) &max_connections,
-   (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 16384, 0, 1,
+   (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
    0},
   {"max_delayed_threads", OPT_MAX_DELAYED_THREADS,
    "Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.",
@@ -6276,6 +6356,12 @@
    "Permits the application to give the threads system a hint for the desired number of threads that should be run at the same time.",
    (gptr*) &concurrency, (gptr*) &concurrency, 0, GET_ULONG, REQUIRED_ARG,
    DEFAULT_CONCURRENCY, 1, 512, 0, 1, 0},
+#if HAVE_POOL_OF_THREADS == 1
+  {"thread_pool_size", OPT_THREAD_CACHE_SIZE,
+   "How many threads we should create to handle query requests in case of 'thread_handling=pool-of-threads'",
+   (gptr*) &thread_pool_size, (gptr*) &thread_pool_size, 0, GET_ULONG,
+   REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
+#endif
   {"thread_stack", OPT_THREAD_STACK,
    "The stack size for each thread.", (gptr*) &thread_stack,
    (gptr*) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
@@ -6300,6 +6386,10 @@
    (gptr*) &global_system_variables.trans_prealloc_size,
    (gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
    REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
+  {"thread_handling", OPT_THREAD_HANDLING,
+   "Define threads usage for handling queries:  "
+   "one-thread-per-connection or no-threads", 0, 0,
+   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT,
    "1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO = Prohibit update of a VIEW, which does not contain a key of the underlying table and the query uses a LIMIT clause (usually get from GUI tools).",
    (gptr*) &global_system_variables.updatable_views_with_limit,
@@ -7241,7 +7331,6 @@
     break;
   case 'T':
     test_flags= argument ? (uint) atoi(argument) : 0;
-    test_flags&= ~TEST_NO_THREADS;
     opt_endinfo=1;
     break;
   case (int) OPT_BIG_TABLES:
@@ -7473,11 +7562,6 @@
     opt_skip_show_db=1;
     opt_specialflag|=SPECIAL_SKIP_SHOW_DB;
     break;
-#ifdef ONE_THREAD
-  case (int) OPT_ONE_THREAD:
-    test_flags |= TEST_NO_THREADS;
-#endif
-    break;
   case (int) OPT_WANT_CORE:
     test_flags |= TEST_CORE_ON_SIGNAL;
     break;
@@ -7723,6 +7807,23 @@
 						   sql_mode);
     break;
   }
+  case OPT_ONE_THREAD:
+    global_system_variables.thread_handling= 2;
+    break;
+  case OPT_THREAD_HANDLING:
+  {
+    if ((global_system_variables.thread_handling=
+         find_type(argument, &thread_handling_typelib, 2)) <= 0 ||
+        (global_system_variables.thread_handling == SCHEDULER_POOL_OF_THREADS
+         && !HAVE_POOL_OF_THREADS))
+    {
+      /* purecov: begin tested */
+      fprintf(stderr,"Unknown/unsupported thread-handling: %s\n",argument);
+      exit(1);
+      /* purecov: end */
+    }
+    break;
+  }
   case OPT_FT_BOOLEAN_SYNTAX:
     if (ft_boolean_check_syntax_string((byte*) argument))
     {
@@ -7843,6 +7944,7 @@
   if (mysqld_chroot)
     set_root(mysqld_chroot);
 #else
+  global_system_variables.thread_handling = SCHEDULER_NO_THREADS;
   max_allowed_packet= global_system_variables.max_allowed_packet;
   net_buffer_length= global_system_variables.net_buffer_length;
 #endif
@@ -7873,6 +7975,17 @@
 				  &global_system_variables.datetime_format))
     exit(1);
 
+#ifdef EMBEDDED_LIBRARY
+  one_thread_scheduler(&thread_scheduler);
+#else
+  if (global_system_variables.thread_handling <=
+      SCHEDULER_ONE_THREAD_PER_CONNECTION)
+    one_thread_per_connection_scheduler(&thread_scheduler);
+  else if (global_system_variables.thread_handling == SCHEDULER_NO_THREADS)
+    one_thread_scheduler(&thread_scheduler);
+  else
+    pool_of_threads_scheduler(&thread_scheduler);  /* purecov: tested */
+#endif
 }
 
 
@@ -8213,5 +8326,3 @@
 template class I_List<Statement>;
 template class I_List_iterator<Statement>;
 #endif
-
-

--- 1.306/sql/slave.cc	2007-02-09 01:02:52 +02:00
+++ 1.307/sql/slave.cc	2007-02-23 13:13:49 +02:00
@@ -1425,9 +1425,8 @@
   thd->slave_thread = 1;
   set_slave_thread_options(thd);
   thd->client_capabilities = CLIENT_LOCAL_FILES;
-  thd->real_id=pthread_self();
   pthread_mutex_lock(&LOCK_thread_count);
-  thd->thread_id = thread_id++;
+  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
   pthread_mutex_unlock(&LOCK_thread_count);
 
   if (init_thr_lock() || thd->store_globals())
@@ -1436,12 +1435,6 @@
     delete thd;
     DBUG_RETURN(-1);
   }
-
-#if !defined(__WIN__) && !defined(__NETWARE__)
-  sigset_t set;
-  VOID(sigemptyset(&set));                      // Get mask in use
-  VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
-#endif
 
   if (thd_type == SLAVE_THD_SQL)
     thd->proc_info= "Waiting for the next event in relay log";

--- 1.228/sql/sql_acl.cc	2007-01-17 20:45:40 +02:00
+++ 1.229/sql/sql_acl.cc	2007-02-23 13:13:49 +02:00
@@ -5169,6 +5169,8 @@
       user= grant_name->user;
       host= grant_name->host.hostname;
       break;
+    default:
+      assert(0);
     }
     if (! user)
       user= "";

--- 1.374/sql/sql_base.cc	2007-02-02 08:19:32 +02:00
+++ 1.375/sql/sql_base.cc	2007-02-23 13:13:49 +02:00
@@ -1078,7 +1078,6 @@
   if (!thd->active_transaction())
     thd->transaction.xid_state.xid.null();
 
-  /* VOID(pthread_sigmask(SIG_SETMASK,&thd->block_signals,NULL)); */
   if (!lock_in_use)
     VOID(pthread_mutex_lock(&LOCK_open));
 
@@ -1208,11 +1207,12 @@
   const char stub[]= "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS ";
   uint stub_len= sizeof(stub) - 1;
   char buf[256];
-  memcpy(buf, stub, stub_len);
   String s_query= String(buf, sizeof(buf), system_charset_info);
-  bool found_user_tables= false;
+  bool found_user_tables= FALSE;
   LINT_INIT(next);
 
+  memcpy(buf, stub, stub_len);
+
   /*
      insertion sort of temp tables by pseudo_thread_id to build ordered list
      of sublists of equal pseudo_thread_id
@@ -1263,10 +1263,13 @@
   {
     if (is_user_table(table))
     {
+      my_thread_id save_pseudo_thread_id= thd->variables.pseudo_thread_id;
       /* Set pseudo_thread_id to be that of the processed table */
       thd->variables.pseudo_thread_id= tmpkeyval(thd, table);
-      /* Loop forward through all tables within the sublist of
-         common pseudo_thread_id to create single DROP query */
+      /*
+        Loop forward through all tables within the sublist of
+        common pseudo_thread_id to create single DROP query.
+      */
       for (s_query.length(stub_len);
            table && is_user_table(table) &&
              tmpkeyval(thd, table) == thd->variables.pseudo_thread_id;
@@ -1292,16 +1295,18 @@
                             0, FALSE);
       thd->variables.character_set_client= cs_save;
       /*
-        Imagine the thread had created a temp table, then was doing a SELECT, and
-        the SELECT was killed. Then it's not clever to mark the statement above as
-        "killed", because it's not really a statement updating data, and there
-        are 99.99% chances it will succeed on slave.
-        If a real update (one updating a persistent table) was killed on the
-        master, then this real update will be logged with error_code=killed,
-        rightfully causing the slave to stop.
+        Imagine the thread had created a temp table, then was doing a
+        SELECT, and the SELECT was killed. Then it's not clever to
+        mark the statement above as "killed", because it's not really
+        a statement updating data, and there are 99.99% chances it
+        will succeed on slave.  If a real update (one updating a
+        persistent table) was killed on the master, then this real
+        update will be logged with error_code=killed, rightfully
+        causing the slave to stop.
       */
       qinfo.error_code= 0;
       mysql_bin_log.write(&qinfo);
+      thd->variables.pseudo_thread_id= save_pseudo_thread_id;
     }
     else
     {
@@ -1519,9 +1524,15 @@
   {
     if (table->s->table_cache_key.length == key_length &&
 	!memcmp(table->s->table_cache_key.str, key, key_length))
+    {
+      DBUG_PRINT("info",
+                 ("Found table. server_id: %u  pseudo_thread_id: %lu",
+                  (uint) thd->server_id,
+                  (ulong) thd->variables.pseudo_thread_id));
       DBUG_RETURN(table);
+    }
   }
-  DBUG_RETURN(0);					// Not a temporary table
+  DBUG_RETURN(0);                               // Not a temporary table
 }
 
 
@@ -1857,6 +1868,10 @@
 	if (table->query_id == thd->query_id ||
             thd->prelocked_mode && table->query_id)
 	{
+          DBUG_PRINT("error",
+                     ("query_id: %lu  server_id: %u  pseudo_thread_id: %lu",
+                      (ulong) table->query_id, (uint) thd->server_id,
+                      (ulong) thd->variables.pseudo_thread_id));
 	  my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias);
 	  DBUG_RETURN(0);
 	}
@@ -3507,8 +3522,11 @@
   uint key_length;
   TABLE_LIST table_list;
   DBUG_ENTER("open_temporary_table");
-  DBUG_PRINT("enter", ("table: '%s'.'%s'  path: '%s'",
-                       db, table_name, path));
+  DBUG_PRINT("enter",
+             ("table: '%s'.'%s'  path: '%s'  server_id: %u  "
+              "pseudo_thread_id: %lu",
+              db, table_name, path,
+              (uint) thd->server_id, (ulong) thd->variables.pseudo_thread_id));
 
   table_list.db=         (char*) db;
   table_list.table_name= (char*) table_name;
@@ -3795,6 +3813,7 @@
   if (nj_col->view_field)
   {
     Item *item;
+    LINT_INIT(arena);
     if (register_tree_change)
       arena= thd->activate_stmt_arena_if_needed(&backup);
     /*
@@ -3978,6 +3997,9 @@
 {
   Field *fld;
   DBUG_ENTER("find_field_in_table_ref");
+  DBUG_ASSERT(table_list->alias);
+  DBUG_ASSERT(name);
+  DBUG_ASSERT(item_name);
   DBUG_PRINT("enter",
              ("table: '%s'  field name: '%s'  item name: '%s'  ref 0x%lx",
               table_list->alias, name, item_name, (ulong) ref));

--- 1.312/sql/sql_class.cc	2007-02-03 00:22:14 +02:00
+++ 1.313/sql/sql_class.cc	2007-02-23 13:13:49 +02:00
@@ -243,7 +243,7 @@
   time_after_lock=(time_t) 0;
   current_linfo =  0;
   slave_thread = 0;
-  variables.pseudo_thread_id= 0;
+  thread_id= variables.pseudo_thread_id= 0;
   one_shot_set= 0;
   file_id = 0;
   query_id= 0;
@@ -267,9 +267,6 @@
   cleanup_done= abort_on_warning= no_warnings_for_error= 0;
   peer_port= 0;					// For SHOW PROCESSLIST
   transaction.m_pending_rows_event= 0;
-#ifdef	__WIN__
-  real_id = 0;
-#endif
 #ifdef SIGNAL_WITH_VIO_CLOSE
   active_vio = 0;
 #endif
@@ -401,6 +398,8 @@
 void THD::cleanup(void)
 {
   DBUG_ENTER("THD::cleanup");
+  DBUG_ASSERT(cleanup_done == 0);
+
 #ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
   if (transaction.xid_state.xa_state == XA_PREPARED)
   {
@@ -436,7 +435,6 @@
     pthread_mutex_lock(&LOCK_user_locks);
     item_user_lock_release(ull);
     pthread_mutex_unlock(&LOCK_user_locks);
-    ull= 0;
   }
 
   cleanup_done=1;
@@ -550,7 +548,9 @@
   killed= state_to_set;
   if (state_to_set != THD::KILL_QUERY)
   {
-    thr_alarm_kill(real_id);
+    thr_alarm_kill(thread_id);
+    if (!slave_thread)
+      thread_scheduler.post_kill_notification(this);
 #ifdef SIGNAL_WITH_VIO_CLOSE
     close_active_vio();
 #endif    
@@ -601,18 +601,19 @@
     Assert that thread_stack is initialized: it's necessary to be able
     to track stack overrun.
   */
-  DBUG_ASSERT(this->thread_stack);
+  DBUG_ASSERT(thread_stack);
 
   if (my_pthread_setspecific_ptr(THR_THD,  this) ||
       my_pthread_setspecific_ptr(THR_MALLOC, &mem_root))
     return 1;
   mysys_var=my_thread_var;
-  dbug_thread_id=my_thread_id();
   /*
-    By default 'slave_proxy_id' is 'thread_id'. They may later become different
-    if this is the slave SQL thread.
+    Let mysqld define the thread id (not mysys)
+    This allows us to move THD to different threads if needed.
   */
-  variables.pseudo_thread_id= thread_id;
+  mysys_var->id= thread_id;
+  real_id= pthread_self();                      // For debugging
+
   /*
     We have to call thr_lock_info_init() again here as THD may have been
     created in another thread
@@ -2511,7 +2512,7 @@
     if (bitmap_is_set(cols,i))
     {
       my_ptrdiff_t const offset=
-        field->is_null(rec_offset) ? def_offset : rec_offset;
+        field->is_null((uint) rec_offset) ? def_offset : rec_offset;
       field->move_field_offset(offset);
       ptr= (byte*)field->pack((char *) ptr, field->ptr);
       field->move_field_offset(-offset);

--- 1.339/sql/sql_class.h	2007-01-29 01:51:39 +02:00
+++ 1.340/sql/sql_class.h	2007-02-23 13:13:49 +02:00
@@ -214,7 +214,7 @@
   ulong read_rnd_buff_size;
   ulong div_precincrement;
   ulong sortbuff_size;
-  handlerton *table_type;
+  ulong thread_handling;
   ulong tx_isolation;
   ulong completion_type;
   /* Determines which non-standard SQL behaviour should be enabled */
@@ -231,11 +231,15 @@
   ulong trans_prealloc_size;
   ulong log_warnings;
   ulong group_concat_max_len;
+  ulong ndb_autoincrement_prefetch_sz;
+  ulong ndb_index_stat_cache_entries;
+  ulong ndb_index_stat_update_freq;
+  ulong binlog_format; // binlog format for this thd (see enum_binlog_format)
   /*
     In slave thread we need to know in behalf of which
     thread the query is being run to replicate temp tables properly
   */
-  ulong pseudo_thread_id;
+  my_thread_id pseudo_thread_id;
 
   my_bool low_priority_updates;
   my_bool new_mode;
@@ -248,14 +252,12 @@
   my_bool ndb_use_exact_count;
   my_bool ndb_use_transactions;
   my_bool ndb_index_stat_enable;
-  ulong ndb_autoincrement_prefetch_sz;
-  ulong ndb_index_stat_cache_entries;
-  ulong ndb_index_stat_update_freq;
-  ulong binlog_format; // binlog format for this thd (see enum_binlog_format)
 
   my_bool old_alter_table;
   my_bool old_passwords;
 
+  handlerton *table_type;
+
   /* Only charset part of these variables is sensible */
   CHARSET_INFO  *character_set_filesystem;
   CHARSET_INFO  *character_set_client;
@@ -1064,7 +1066,7 @@
   } transaction;
   Field      *dup_field;
 #ifndef __WIN__
-  sigset_t signals,block_signals;
+  sigset_t signals;
 #endif
 #ifdef SIGNAL_WITH_VIO_CLOSE
   Vio* active_vio;
@@ -1255,7 +1257,7 @@
     update auto-updatable fields (like auto_increment and timestamp).
   */
   query_id_t query_id, warn_id;
-  ulong      thread_id, col_access;
+  ulong      col_access;
 
 #ifdef ERROR_INJECT_SUPPORT
   ulong      error_inject_value;
@@ -1264,8 +1266,8 @@
   ulong      statement_id_counter;
   ulong	     rand_saved_seed1, rand_saved_seed2;
   ulong      row_count;  // Row counter, mainly for errors and warnings
-  long	     dbug_thread_id;
-  pthread_t  real_id;
+  pthread_t  real_id;                           /* For debugging */
+  my_thread_id  thread_id;
   uint	     tmp_table, global_read_lock;
   uint	     server_status,open_options;
   enum enum_thread_type system_thread;
@@ -1629,6 +1631,7 @@
     *p_db_length= db_length;
     return FALSE;
   }
+  thd_scheduler scheduler;
 };
 
 

--- 1.246/sql/sql_insert.cc	2007-02-13 23:15:19 +02:00
+++ 1.247/sql/sql_insert.cc	2007-02-23 13:13:49 +02:00
@@ -396,6 +396,7 @@
 #ifndef EMBEDDED_LIBRARY
   if (lock_type == TL_WRITE_DELAYED)
   {
+    res= 1;
     if (thd->locked_tables)
     {
       DBUG_ASSERT(table_list->db); /* Must be set in the parser */
@@ -1897,7 +1898,7 @@
   pthread_detach_this_thread();
   /* Add thread to THD list so that's it's visible in 'show processlist' */
   pthread_mutex_lock(&LOCK_thread_count);
-  thd->thread_id=thread_id++;
+  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
   thd->end_time();
   threads.append(thd);
   thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
@@ -1928,14 +1929,8 @@
     strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES));
     goto err;
   }
-#if !defined(__WIN__) && !defined(__NETWARE__)
-  sigset_t set;
-  VOID(sigemptyset(&set));			// Get mask in use
-  VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
-#endif
 
   /* open table */
-
   if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED)))
   {
     thd->fatal_error();				// Abort waiting inserts

--- 1.626/sql/sql_parse.cc	2007-02-06 16:52:27 +02:00
+++ 1.627/sql/sql_parse.cc	2007-02-23 13:13:49 +02:00
@@ -28,24 +28,6 @@
 #include "events.h"
 #include "event_data_objects.h"
 
-#ifdef HAVE_OPENSSL
-/*
-  Without SSL the handshake consists of one packet. This packet
-  has both client capabilites and scrambled password.
-  With SSL the handshake might consist of two packets. If the first
-  packet (client capabilities) has CLIENT_SSL flag set, we have to
-  switch to SSL and read the second packet. The scrambled password
-  is in the second packet and client_capabilites field will be ignored.
-  Maybe it is better to accept flags other than CLIENT_SSL from the
-  second packet?
-*/
-#define SSL_HANDSHAKE_SIZE      2
-#define NORMAL_HANDSHAKE_SIZE   6
-#define MIN_HANDSHAKE_SIZE      2
-#else
-#define MIN_HANDSHAKE_SIZE      6
-#endif /* HAVE_OPENSSL */
-
 /* Used in error handling only */
 #define SP_TYPE_STRING(LP) \
   ((LP)->sphead->m_type == TYPE_ENUM_FUNCTION ? "FUNCTION" : "PROCEDURE")
@@ -56,11 +38,6 @@
    (LP)->sql_command == SQLCOM_DROP_FUNCTION ? \
    "FUNCTION" : "PROCEDURE")
 
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-static void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
-static int check_for_max_user_connections(THD *thd, USER_CONN *uc);
-static void decrease_user_connections(USER_CONN *uc);
-#endif /* NO_EMBEDDED_ACCESS_CHECKS */
 static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables);
 
 const char *any_db="*any*";	// Special symbol for check_access
@@ -103,20 +80,6 @@
   "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED"
 };
 
-#ifdef __WIN__
-static void  test_signal(int sig_ptr)
-{
-#if !defined( DBUG_OFF)
-  MessageBox(NULL,"Test signal","DBUG",MB_OK);
-#endif
-}
-static void init_signals(void)
-{
-  int signals[7] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGBREAK,SIGABRT } ;
-  for (int i=0 ; i < 7 ; i++)
-    signal( signals[i], test_signal) ;
-}
-#endif
 
 static void unlock_locked_tables(THD *thd)
 {
@@ -160,6 +123,7 @@
   DBUG_RETURN(error);
 }
 
+
 bool begin_trans(THD *thd)
 {
   int error=0;
@@ -211,413 +175,6 @@
   return 0;
 }
 
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-static HASH hash_user_connections;
-
-static int get_or_create_user_conn(THD *thd, const char *user,
-				   const char *host,
-				   USER_RESOURCES *mqh)
-{
-  int return_val= 0;
-  uint temp_len, user_len;
-  char temp_user[USER_HOST_BUFF_SIZE];
-  struct  user_conn *uc;
-
-  DBUG_ASSERT(user != 0);
-  DBUG_ASSERT(host != 0);
-
-  user_len= strlen(user);
-  temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
-  (void) pthread_mutex_lock(&LOCK_user_conn);
-  if (!(uc = (struct  user_conn *) hash_search(&hash_user_connections,
-					       (byte*) temp_user, temp_len)))
-  {
-    /* First connection for user; Create a user connection object */
-    if (!(uc= ((struct user_conn*)
-	       my_malloc(sizeof(struct user_conn) + temp_len+1,
-			 MYF(MY_WME)))))
-    {
-      net_send_error(thd, 0, NullS);		// Out of memory
-      return_val= 1;
-      goto end;
-    }
-    uc->user=(char*) (uc+1);
-    memcpy(uc->user,temp_user,temp_len+1);
-    uc->host= uc->user + user_len +  1;
-    uc->len= temp_len;
-    uc->connections= uc->questions= uc->updates= uc->conn_per_hour= 0;
-    uc->user_resources= *mqh;
-    uc->intime= thd->thr_create_time;
-    if (my_hash_insert(&hash_user_connections, (byte*) uc))
-    {
-      my_free((char*) uc,0);
-      net_send_error(thd, 0, NullS);		// Out of memory
-      return_val= 1;
-      goto end;
-    }
-  }
-  thd->user_connect=uc;
-  uc->connections++;
-end:
-  (void) pthread_mutex_unlock(&LOCK_user_conn);
-  return return_val;
-
-}
-#endif /* !NO_EMBEDDED_ACCESS_CHECKS */
-
-
-/*
-  Check if user exist and password supplied is correct. 
-
-  SYNOPSIS
-    check_user()
-    thd          thread handle, thd->security_ctx->{host,user,ip} are used
-    command      originator of the check: now check_user is called
-                 during connect and change user procedures; used for 
-                 logging.
-    passwd       scrambled password received from client
-    passwd_len   length of scrambled password
-    db           database name to connect to, may be NULL
-    check_count  dont know exactly
-
-    Note, that host, user and passwd may point to communication buffer.
-    Current implementation does not depend on that, but future changes
-    should be done with this in mind; 'thd' is INOUT, all other params
-    are 'IN'.
-
-  RETURN VALUE
-    0  OK; thd->security_ctx->user/master_access/priv_user/db_access and
-       thd->db are updated; OK is sent to client;
-   -1  access denied or handshake error; error is sent to client;
-   >0  error, not sent to client
-*/
-
-int check_user(THD *thd, enum enum_server_command command, 
-	       const char *passwd, uint passwd_len, const char *db,
-	       bool check_count)
-{
-  DBUG_ENTER("check_user");
-  
-#ifdef NO_EMBEDDED_ACCESS_CHECKS
-  thd->main_security_ctx.master_access= GLOBAL_ACLS;       // Full rights
-  /* Change database if necessary */
-  if (db && db[0])
-  {
-    /*
-      thd->db is saved in caller and needs to be freed by caller if this
-      function returns 0
-    */
-    thd->reset_db(NULL, 0);
-    if (mysql_change_db(thd, db, FALSE))
-    {
-      /* Send the error to the client */
-      net_send_error(thd);
-      DBUG_RETURN(-1);
-    }
-  }
-  send_ok(thd);
-  DBUG_RETURN(0);
-#else
-
-  my_bool opt_secure_auth_local;
-  pthread_mutex_lock(&LOCK_global_system_variables);
-  opt_secure_auth_local= opt_secure_auth;
-  pthread_mutex_unlock(&LOCK_global_system_variables);
-  
-  /*
-    If the server is running in secure auth mode, short scrambles are 
-    forbidden.
-  */
-  if (opt_secure_auth_local && passwd_len == SCRAMBLE_LENGTH_323)
-  {
-    net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
-    general_log_print(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
-    DBUG_RETURN(-1);
-  }
-  if (passwd_len != 0 &&
-      passwd_len != SCRAMBLE_LENGTH &&
-      passwd_len != SCRAMBLE_LENGTH_323)
-    DBUG_RETURN(ER_HANDSHAKE_ERROR);
-
-  /*
-    Clear thd->db as it points to something, that will be freed when 
-    connection is closed. We don't want to accidentally free a wrong pointer
-    if connect failed. Also in case of 'CHANGE USER' failure, current
-    database will be switched to 'no database selected'.
-  */
-  thd->reset_db(NULL, 0);
-
-  USER_RESOURCES ur;
-  int res= acl_getroot(thd, &ur, passwd, passwd_len);
-#ifndef EMBEDDED_LIBRARY
-  if (res == -1)
-  {
-    /*
-      This happens when client (new) sends password scrambled with
-      scramble(), but database holds old value (scrambled with
-      scramble_323()). Here we please client to send scrambled_password
-      in old format.
-    */
-    NET *net= &thd->net;
-    if (opt_secure_auth_local)
-    {
-      net_printf_error(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE,
-                       thd->main_security_ctx.user,
-                       thd->main_security_ctx.host_or_ip);
-      general_log_print(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE),
-                        thd->main_security_ctx.user,
-                        thd->main_security_ctx.host_or_ip);
-      DBUG_RETURN(-1);
-    }
-    /* We have to read very specific packet size */
-    if (send_old_password_request(thd) ||
-        my_net_read(net) != SCRAMBLE_LENGTH_323 + 1)
-    {
-      inc_host_errors(&thd->remote.sin_addr);
-      DBUG_RETURN(ER_HANDSHAKE_ERROR);
-    }
-    /* Final attempt to check the user based on reply */
-    /* So as passwd is short, errcode is always >= 0 */
-    res= acl_getroot(thd, &ur, (char *) net->read_pos, SCRAMBLE_LENGTH_323);
-  }
-#endif /*EMBEDDED_LIBRARY*/
-  /* here res is always >= 0 */
-  if (res == 0)
-  {
-    if (!(thd->main_security_ctx.master_access &
-          NO_ACCESS)) // authentication is OK
-    {
-      DBUG_PRINT("info",
-                 ("Capabilities: %lu  packet_length: %ld  Host: '%s'  "
-                  "Login user: '%s' Priv_user: '%s'  Using password: %s "
-                  "Access: %lu  db: '%s'",
-                  thd->client_capabilities,
-                  thd->max_client_packet_length,
-                  thd->main_security_ctx.host_or_ip,
-                  thd->main_security_ctx.user,
-                  thd->main_security_ctx.priv_user,
-                  passwd_len ? "yes": "no",
-                  thd->main_security_ctx.master_access,
-                  (thd->db ? thd->db : "*none*")));
-
-      if (check_count)
-      {
-        VOID(pthread_mutex_lock(&LOCK_thread_count));
-        bool count_ok= thread_count <= max_connections + delayed_insert_threads
-                       || (thd->main_security_ctx.master_access & SUPER_ACL);
-        VOID(pthread_mutex_unlock(&LOCK_thread_count));
-        if (!count_ok)
-        {                                         // too many connections
-          net_send_error(thd, ER_CON_COUNT_ERROR);
-          DBUG_RETURN(-1);
-        }
-      }
-
-      /*
-        Log the command before authentication checks, so that the user can
-        check the log for the tried login tried and also to detect
-        break-in attempts.
-      */
-      general_log_print(thd, command,
-                        (thd->main_security_ctx.priv_user ==
-                         thd->main_security_ctx.user ?
-                         (char*) "%s@%s on %s" :
-                         (char*) "%s@%s as anonymous on %s"),
-                        thd->main_security_ctx.user,
-                        thd->main_security_ctx.host_or_ip,
-                        db ? db : (char*) "");
-
-      /*
-        This is the default access rights for the current database.  It's
-        set to 0 here because we don't have an active database yet (and we
-        may not have an active database to set.
-      */
-      thd->main_security_ctx.db_access=0;
-
-      /* Don't allow user to connect if he has done too many queries */
-      if ((ur.questions || ur.updates || ur.conn_per_hour || ur.user_conn ||
-	   max_user_connections) &&
-	  get_or_create_user_conn(thd,
-            (opt_old_style_user_limits ? thd->main_security_ctx.user :
-             thd->main_security_ctx.priv_user),
-            (opt_old_style_user_limits ? thd->main_security_ctx.host_or_ip :
-             thd->main_security_ctx.priv_host),
-            &ur))
-	DBUG_RETURN(-1);
-      if (thd->user_connect &&
-	  (thd->user_connect->user_resources.conn_per_hour ||
-	   thd->user_connect->user_resources.user_conn ||
-	   max_user_connections) &&
-	  check_for_max_user_connections(thd, thd->user_connect))
-	DBUG_RETURN(-1);
-
-      /* Change database if necessary */
-      if (db && db[0])
-      {
-        if (mysql_change_db(thd, db, FALSE))
-        {
-          /* Send error to the client */
-          net_send_error(thd);
-          if (thd->user_connect)
-            decrease_user_connections(thd->user_connect);
-          DBUG_RETURN(-1);
-        }
-      }
-      send_ok(thd);
-      thd->password= test(passwd_len);          // remember for error messages 
-      /* Ready to handle queries */
-      DBUG_RETURN(0);
-    }
-  }
-  else if (res == 2) // client gave short hash, server has long hash
-  {
-    net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
-    general_log_print(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
-    DBUG_RETURN(-1);
-  }
-  net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
-                   thd->main_security_ctx.user,
-                   thd->main_security_ctx.host_or_ip,
-                   passwd_len ? ER(ER_YES) : ER(ER_NO));
-  general_log_print(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
-                    thd->main_security_ctx.user,
-                    thd->main_security_ctx.host_or_ip,
-                    passwd_len ? ER(ER_YES) : ER(ER_NO));
-  DBUG_RETURN(-1);
-#endif /* NO_EMBEDDED_ACCESS_CHECKS */
-}
-
-/*
-  Check for maximum allowable user connections, if the mysqld server is
-  started with corresponding variable that is greater then 0.
-*/
-
-extern "C" byte *get_key_conn(user_conn *buff, uint *length,
-			      my_bool not_used __attribute__((unused)))
-{
-  *length=buff->len;
-  return (byte*) buff->user;
-}
-
-extern "C" void free_user(struct user_conn *uc)
-{
-  my_free((char*) uc,MYF(0));
-}
-
-void init_max_user_conn(void)
-{
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-  (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-		   0,0,
-		   (hash_get_key) get_key_conn, (hash_free_key) free_user,
-		   0);
-#endif
-}
-
-
-/*
-  check if user has already too many connections
-  
-  SYNOPSIS
-  check_for_max_user_connections()
-  thd			Thread handle
-  uc			User connect object
-
-  NOTES
-    If check fails, we decrease user connection count, which means one
-    shouldn't call decrease_user_connections() after this function.
-
-  RETURN
-    0	ok
-    1	error
-*/
-
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-
-static int check_for_max_user_connections(THD *thd, USER_CONN *uc)
-{
-  int error=0;
-  DBUG_ENTER("check_for_max_user_connections");
-
-  (void) pthread_mutex_lock(&LOCK_user_conn);
-  if (max_user_connections && !uc->user_resources.user_conn &&
-      max_user_connections < (uint) uc->connections)
-  {
-    net_printf_error(thd, ER_TOO_MANY_USER_CONNECTIONS, uc->user);
-    error=1;
-    goto end;
-  }
-  time_out_user_resource_limits(thd, uc);
-  if (uc->user_resources.user_conn &&
-      uc->user_resources.user_conn < uc->connections)
-  {
-    net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user,
-                     "max_user_connections",
-                     (long) uc->user_resources.user_conn);
-    error= 1;
-    goto end;
-  }
-  if (uc->user_resources.conn_per_hour &&
-      uc->user_resources.conn_per_hour <= uc->conn_per_hour)
-  {
-    net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user,
-                     "max_connections_per_hour",
-                     (long) uc->user_resources.conn_per_hour);
-    error=1;
-    goto end;
-  }
-  uc->conn_per_hour++;
-
-  end:
-  if (error)
-    uc->connections--; // no need for decrease_user_connections() here
-  (void) pthread_mutex_unlock(&LOCK_user_conn);
-  DBUG_RETURN(error);
-}
-
-/*
-  Decrease user connection count
-
-  SYNOPSIS
-    decrease_user_connections()
-    uc			User connection object
-
-  NOTES
-    If there is a n user connection object for a connection
-    (which only happens if 'max_user_connections' is defined or
-    if someone has created a resource grant for a user), then
-    the connection count is always incremented on connect.
-
-    The user connect object is not freed if some users has
-    'max connections per hour' defined as we need to be able to hold
-    count over the lifetime of the connection.
-*/
-
-static void decrease_user_connections(USER_CONN *uc)
-{
-  DBUG_ENTER("decrease_user_connections");
-  (void) pthread_mutex_lock(&LOCK_user_conn);
-  DBUG_ASSERT(uc->connections);
-  if (!--uc->connections && !mqh_used)
-  {
-    /* Last connection for user; Delete it */
-    (void) hash_delete(&hash_user_connections,(byte*) uc);
-  }
-  (void) pthread_mutex_unlock(&LOCK_user_conn);
-  DBUG_VOID_RETURN;
-}
-
-#endif /* NO_EMBEDDED_ACCESS_CHECKS */
-
-
-void free_max_user_conn(void)
-{
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-  hash_free(&hash_user_connections);
-#endif /* NO_EMBEDDED_ACCESS_CHECKS */
-}
-
-
 
 /*
   Mark all commands that somehow changes a table
@@ -701,402 +258,6 @@
   return (sql_command_flags[command] & CF_CHANGES_DATA) != 0;
 }
 
-/*
-  Reset per-hour user resource limits when it has been more than
-  an hour since they were last checked
-
-  SYNOPSIS:
-    time_out_user_resource_limits()
-    thd			Thread handler
-    uc			User connection details
-
-  NOTE:
-    This assumes that the LOCK_user_conn mutex has been acquired, so it is
-    safe to test and modify members of the USER_CONN structure.
-*/
-
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-
-static void time_out_user_resource_limits(THD *thd, USER_CONN *uc)
-{
-  time_t check_time = thd->start_time ?  thd->start_time : time(NULL);
-  DBUG_ENTER("time_out_user_resource_limits");
-
-  /* If more than a hour since last check, reset resource checking */
-  if (check_time  - uc->intime >= 3600)
-  {
-    uc->questions=1;
-    uc->updates=0;
-    uc->conn_per_hour=0;
-    uc->intime=check_time;
-  }
-
-  DBUG_VOID_RETURN;
-}
-
-/*
-  Check if maximum queries per hour limit has been reached
-  returns 0 if OK.
-*/
-
-static bool check_mqh(THD *thd, uint check_command)
-{
-  bool error= 0;
-  USER_CONN *uc=thd->user_connect;
-  DBUG_ENTER("check_mqh");
-  DBUG_ASSERT(uc != 0);
-
-  (void) pthread_mutex_lock(&LOCK_user_conn);
-
-  time_out_user_resource_limits(thd, uc);
-
-  /* Check that we have not done too many questions / hour */
-  if (uc->user_resources.questions &&
-      uc->questions++ >= uc->user_resources.questions)
-  {
-    net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_questions",
-                     (long) uc->user_resources.questions);
-    error=1;
-    goto end;
-  }
-  if (check_command < (uint) SQLCOM_END)
-  {
-    /* Check that we have not done too many updates / hour */
-    if (uc->user_resources.updates &&
-        (sql_command_flags[check_command] & CF_CHANGES_DATA) &&
-	uc->updates++ >= uc->user_resources.updates)
-    {
-      net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_updates",
-                       (long) uc->user_resources.updates);
-      error=1;
-      goto end;
-    }
-  }
-end:
-  (void) pthread_mutex_unlock(&LOCK_user_conn);
-  DBUG_RETURN(error);
-}
-
-#endif /* NO_EMBEDDED_ACCESS_CHECKS */
-
-
-static void reset_mqh(LEX_USER *lu, bool get_them= 0)
-{
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-  (void) pthread_mutex_lock(&LOCK_user_conn);
-  if (lu)  // for GRANT
-  {
-    USER_CONN *uc;
-    uint temp_len=lu->user.length+lu->host.length+2;
-    char temp_user[USER_HOST_BUFF_SIZE];
-
-    memcpy(temp_user,lu->user.str,lu->user.length);
-    memcpy(temp_user+lu->user.length+1,lu->host.str,lu->host.length);
-    temp_user[lu->user.length]='\0'; temp_user[temp_len-1]=0;
-    if ((uc = (struct  user_conn *) hash_search(&hash_user_connections,
-						(byte*) temp_user, temp_len)))
-    {
-      uc->questions=0;
-      get_mqh(temp_user,&temp_user[lu->user.length+1],uc);
-      uc->updates=0;
-      uc->conn_per_hour=0;
-    }
-  }
-  else
-  {
-    /* for FLUSH PRIVILEGES and FLUSH USER_RESOURCES */
-    for (uint idx=0;idx < hash_user_connections.records; idx++)
-    {
-      USER_CONN *uc=(struct user_conn *) hash_element(&hash_user_connections,
-						      idx);
-      if (get_them)
-	get_mqh(uc->user,uc->host,uc);
-      uc->questions=0;
-      uc->updates=0;
-      uc->conn_per_hour=0;
-    }
-  }
-  (void) pthread_mutex_unlock(&LOCK_user_conn);
-#endif /* NO_EMBEDDED_ACCESS_CHECKS */
-}
-
-void thd_init_client_charset(THD *thd, uint cs_number)
-{
-  /*
-   Use server character set and collation if
-   - opt_character_set_client_handshake is not set
-   - client has not specified a character set
-   - client character set is the same as the servers
-   - client character set doesn't exists in server
-  */
-  if (!opt_character_set_client_handshake ||
-      !(thd->variables.character_set_client= get_charset(cs_number, MYF(0))) ||
-      !my_strcasecmp(&my_charset_latin1,
-                     global_system_variables.character_set_client->name,
-                     thd->variables.character_set_client->name))
-  {
-    thd->variables.character_set_client=
-      global_system_variables.character_set_client;
-    thd->variables.collation_connection=
-      global_system_variables.collation_connection;
-    thd->variables.character_set_results=
-      global_system_variables.character_set_results;
-  }
-  else
-  {
-    thd->variables.character_set_results=
-      thd->variables.collation_connection= 
-      thd->variables.character_set_client;
-  }
-}
-
-
-/*
-    Perform handshake, authorize client and update thd ACL variables.
-  SYNOPSIS
-    check_connection()
-    thd  thread handle
-
-  RETURN
-     0  success, OK is sent to user, thd is updated.
-    -1  error, which is sent to user
-   > 0  error code (not sent to user)
-*/
-
-#ifndef EMBEDDED_LIBRARY
-static int check_connection(THD *thd)
-{
-  uint connect_errors= 0;
-  NET *net= &thd->net;
-  ulong pkt_len= 0;
-  char *end;
-
-  DBUG_PRINT("info",
-             ("New connection received on %s", vio_description(net->vio)));
-#ifdef SIGNAL_WITH_VIO_CLOSE
-  thd->set_active_vio(net->vio);
-#endif
-
-  if (!thd->main_security_ctx.host)         // If TCP/IP connection
-  {
-    char ip[30];
-
-    if (vio_peer_addr(net->vio, ip, &thd->peer_port))
-      return (ER_BAD_HOST_ERROR);
-    if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(0))))
-      return (ER_OUT_OF_RESOURCES);
-    thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip;
-    vio_in_addr(net->vio,&thd->remote.sin_addr);
-    if (!(specialflag & SPECIAL_NO_RESOLVE))
-    {
-      vio_in_addr(net->vio,&thd->remote.sin_addr);
-      thd->main_security_ctx.host=
-        ip_to_hostname(&thd->remote.sin_addr, &connect_errors);
-      /* Cut very long hostnames to avoid possible overflows */
-      if (thd->main_security_ctx.host)
-      {
-        if (thd->main_security_ctx.host != my_localhost)
-          thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-                                          HOSTNAME_LENGTH)]= 0;
-        thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
-      }
-      if (connect_errors > max_connect_errors)
-        return(ER_HOST_IS_BLOCKED);
-    }
-    DBUG_PRINT("info",("Host: %s  ip: %s",
-		       (thd->main_security_ctx.host ?
-                        thd->main_security_ctx.host : "unknown host"),
-		       (thd->main_security_ctx.ip ?
-                        thd->main_security_ctx.ip : "unknown ip")));
-    if (acl_check_host(thd->main_security_ctx.host, thd->main_security_ctx.ip))
-      return(ER_HOST_NOT_PRIVILEGED);
-  }
-  else /* Hostname given means that the connection was on a socket */
-  {
-    DBUG_PRINT("info",("Host: %s", thd->main_security_ctx.host));
-    thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
-    thd->main_security_ctx.ip= 0;
-    /* Reset sin_addr */
-    bzero((char*) &thd->remote, sizeof(thd->remote));
-  }
-  vio_keepalive(net->vio, TRUE);
-  {
-    /* buff[] needs to big enough to hold the server_version variable */
-    char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH + 64];
-    ulong client_flags = (CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB |
-			  CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION);
-
-    if (opt_using_transactions)
-      client_flags|=CLIENT_TRANSACTIONS;
-#ifdef HAVE_COMPRESS
-    client_flags |= CLIENT_COMPRESS;
-#endif /* HAVE_COMPRESS */
-#ifdef HAVE_OPENSSL
-    if (ssl_acceptor_fd)
-      client_flags |= CLIENT_SSL;       /* Wow, SSL is available! */
-#endif /* HAVE_OPENSSL */
-
-    end= strnmov(buff, server_version, SERVER_VERSION_LENGTH) + 1;
-    int4store((uchar*) end, thd->thread_id);
-    end+= 4;
-    /*
-      So as check_connection is the only entry point to authorization
-      procedure, scramble is set here. This gives us new scramble for
-      each handshake.
-    */
-    create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand);
-    /*
-      Old clients does not understand long scrambles, but can ignore packet
-      tail: that's why first part of the scramble is placed here, and second
-      part at the end of packet.
-    */
-    end= strmake(end, thd->scramble, SCRAMBLE_LENGTH_323) + 1;
-   
-    int2store(end, client_flags);
-    /* write server characteristics: up to 16 bytes allowed */
-    end[2]=(char) default_charset_info->number;
-    int2store(end+3, thd->server_status);
-    bzero(end+5, 13);
-    end+= 18;
-    /* write scramble tail */
-    end= strmake(end, thd->scramble + SCRAMBLE_LENGTH_323, 
-                 SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323) + 1;
-
-    /* At this point we write connection message and read reply */
-    if (net_write_command(net, (uchar) protocol_version, "", 0, buff,
-			  (uint) (end-buff)) ||
-	(pkt_len= my_net_read(net)) == packet_error ||
-	pkt_len < MIN_HANDSHAKE_SIZE)
-    {
-      inc_host_errors(&thd->remote.sin_addr);
-      return(ER_HANDSHAKE_ERROR);
-    }
-  }
-#ifdef _CUSTOMCONFIG_
-#include "_cust_sql_parse.h"
-#endif
-  if (connect_errors)
-    reset_host_errors(&thd->remote.sin_addr);
-  if (thd->packet.alloc(thd->variables.net_buffer_length))
-    return(ER_OUT_OF_RESOURCES);
-
-  thd->client_capabilities=uint2korr(net->read_pos);
-  if (thd->client_capabilities & CLIENT_PROTOCOL_41)
-  {
-    thd->client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
-    thd->max_client_packet_length= uint4korr(net->read_pos+4);
-    DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
-    thd_init_client_charset(thd, (uint) net->read_pos[8]);
-    thd->update_charset();
-    end= (char*) net->read_pos+32;
-  }
-  else
-  {
-    thd->max_client_packet_length= uint3korr(net->read_pos+2);
-    end= (char*) net->read_pos+5;
-  }
-
-  if (thd->client_capabilities & CLIENT_IGNORE_SPACE)
-    thd->variables.sql_mode|= MODE_IGNORE_SPACE;
-#ifdef HAVE_OPENSSL
-  DBUG_PRINT("info", ("client capabilities: %lu", thd->client_capabilities));
-  if (thd->client_capabilities & CLIENT_SSL)
-  {
-    /* Do the SSL layering. */
-    if (!ssl_acceptor_fd)
-    {
-      inc_host_errors(&thd->remote.sin_addr);
-      return(ER_HANDSHAKE_ERROR);
-    }
-    DBUG_PRINT("info", ("IO layer change in progress..."));
-    if (sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout))
-    {
-      DBUG_PRINT("error", ("Failed to accept new SSL connection"));
-      inc_host_errors(&thd->remote.sin_addr);
-      return(ER_HANDSHAKE_ERROR);
-    }
-    DBUG_PRINT("info", ("Reading user information over SSL layer"));
-    if ((pkt_len= my_net_read(net)) == packet_error ||
-	pkt_len < NORMAL_HANDSHAKE_SIZE)
-    {
-      DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)",
-			   pkt_len));
-      inc_host_errors(&thd->remote.sin_addr);
-      return(ER_HANDSHAKE_ERROR);
-    }
-  }
-#endif
-
-  if (end >= (char*) net->read_pos+ pkt_len +2)
-  {
-    inc_host_errors(&thd->remote.sin_addr);
-    return(ER_HANDSHAKE_ERROR);
-  }
-
-  if (thd->client_capabilities & CLIENT_INTERACTIVE)
-    thd->variables.net_wait_timeout= thd->variables.net_interactive_timeout;
-  if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
-      opt_using_transactions)
-    net->return_status= &thd->server_status;
-
-  char *user= end;
-  char *passwd= strend(user)+1;
-  uint user_len= passwd - user - 1;
-  char *db= passwd;
-  char db_buff[NAME_LEN + 1];           // buffer to store db in utf8
-  char user_buff[USERNAME_LENGTH + 1];	// buffer to store user in utf8
-  uint dummy_errors;
-
-  /*
-    Old clients send null-terminated string as password; new clients send
-    the size (1 byte) + string (not null-terminated). Hence in case of empty
-    password both send '\0'.
-
-    This strlen() can't be easily deleted without changing protocol.
-  */
-  uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
-    *passwd++ : strlen(passwd);
-  db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ?
-    db + passwd_len + 1 : 0;
-  /* strlen() can't be easily deleted without changing protocol */
-  uint db_len= db ? strlen(db) : 0;
-
-  if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len)
-  {
-    inc_host_errors(&thd->remote.sin_addr);
-    return ER_HANDSHAKE_ERROR;
-  }
-
-  /* Since 4.1 all database names are stored in utf8 */
-  if (db)
-  {
-    db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1,
-                             system_charset_info,
-                             db, db_len,
-                             thd->charset(), &dummy_errors)]= 0;
-    db= db_buff;
-  }
-
-  user_buff[user_len= copy_and_convert(user_buff, sizeof(user_buff)-1,
-                                       system_charset_info, user, user_len,
-                                       thd->charset(), &dummy_errors)]= '\0';
-  user= user_buff;
-
-  /* If username starts and ends in "'", chop them off */
-  if (user_len > 1 && user[0] == '\'' && user[user_len - 1] == '\'')
-  {
-    user[user_len-1]= 0;
-    user++;
-    user_len-= 2;
-  }
-
-  if (thd->main_security_ctx.user)
-    x_free(thd->main_security_ctx.user);
-  if (!(thd->main_security_ctx.user= my_strdup(user, MYF(0))))
-    return (ER_OUT_OF_RESOURCES);
-  return check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE);
-}
-
 
 void execute_init_command(THD *thd, sys_var_str *init_command_var,
 			  rw_lock_t *var_mutex)
@@ -1129,153 +290,6 @@
 }
 
 
-pthread_handler_t handle_one_connection(void *arg)
-{
-  THD *thd=(THD*) arg;
-  uint launch_time  =
-    (uint) ((thd->thr_create_time = time(NULL)) - thd->connect_time);
-  if (launch_time >= slow_launch_time)
-    statistic_increment(slow_launch_threads,&LOCK_status );
-
-  pthread_detach_this_thread();
-
-#if !defined( __WIN__) // Win32 calls this in pthread_create
-  /* The following calls needs to be done before we call DBUG_ macros */
-  if (!(test_flags & TEST_NO_THREADS) & my_thread_init())
-  {
-    close_connection(thd, ER_OUT_OF_RESOURCES, 1);
-    statistic_increment(aborted_connects,&LOCK_status);
-    end_thread(thd,0);
-    return 0;
-  }
-#endif
-
-  /*
-    handle_one_connection() is the only way a thread would start
-    and would always be on top of the stack, therefore, the thread
-    stack always starts at the address of the first local variable
-    of handle_one_connection, which is thd. We need to know the
-    start of the stack so that we could check for stack overruns.
-  */
-  DBUG_PRINT("info", ("handle_one_connection called by thread %lu\n",
-		      thd->thread_id));
-  /* now that we've called my_thread_init(), it is safe to call DBUG_* */
-
-#if defined(__WIN__)
-  init_signals();
-#elif !defined(__NETWARE__)
-  sigset_t set;
-  VOID(sigemptyset(&set));			// Get mask in use
-  VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
-#endif
-  thd->thread_stack= (char*) &thd;
-  if (thd->store_globals())
-  {
-    close_connection(thd, ER_OUT_OF_RESOURCES, 1);
-    statistic_increment(aborted_connects,&LOCK_status);
-    end_thread(thd,0);
-    return 0;
-  }
-
-  do
-  {
-    int error;
-    NET *net= &thd->net;
-    Security_context *sctx= thd->security_ctx;
-    net->no_send_error= 0;
-
-    /* Use "connect_timeout" value during connection phase */
-    net_set_read_timeout(net, connect_timeout);
-    net_set_write_timeout(net, connect_timeout);
-
-    if ((error=check_connection(thd)))
-    {						// Wrong permissions
-      if (error > 0)
-	net_printf_error(thd, error, sctx->host_or_ip);
-#ifdef __NT__
-      if (vio_type(net->vio) == VIO_TYPE_NAMEDPIPE)
-	my_sleep(1000);				/* must wait after eof() */
-#endif
-      statistic_increment(aborted_connects,&LOCK_status);
-      goto end_thread;
-    }
-#ifdef __NETWARE__
-    netware_reg_user(sctx->ip, sctx->user, "MySQL");
-#endif
-    if (thd->variables.max_join_size == HA_POS_ERROR)
-      thd->options |= OPTION_BIG_SELECTS;
-    if (thd->client_capabilities & CLIENT_COMPRESS)
-      net->compress=1;				// Use compression
-
-    thd->version= refresh_version;
-    thd->proc_info= 0;
-    thd->command= COM_SLEEP;
-    thd->set_time();
-    thd->init_for_queries();
-
-    if (sys_init_connect.value_length && !(sctx->master_access & SUPER_ACL))
-    {
-      execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect);
-      if (thd->query_error)
-      {
-	thd->killed= THD::KILL_CONNECTION;
-        sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),
-                          thd->thread_id,(thd->db ? thd->db : "unconnected"),
-                          sctx->user ? sctx->user : "unauthenticated",
-                          sctx->host_or_ip, "init_connect command failed");
-        sql_print_warning("%s", net->last_error);
-      }
-      thd->proc_info=0;
-      thd->set_time();
-      thd->init_for_queries();
-    }
-
-    /* Connect completed, set read/write timeouts back to tdefault */
-    net_set_read_timeout(net, thd->variables.net_read_timeout);
-    net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-    while (!net->error && net->vio != 0 &&
-           !(thd->killed == THD::KILL_CONNECTION))
-    {
-      net->no_send_error= 0;
-      if (do_command(thd))
-	break;
-    }
-    if (thd->user_connect)
-      decrease_user_connections(thd->user_connect);
-    if (net->error && net->vio != 0 && net->report_error)
-    {
-      if (!thd->killed && thd->variables.log_warnings > 1)
-	sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),
-                          thd->thread_id,(thd->db ? thd->db : "unconnected"),
-                          sctx->user ? sctx->user : "unauthenticated",
-                          sctx->host_or_ip,
-                          (net->last_errno ? ER(net->last_errno) :
-                           ER(ER_UNKNOWN_ERROR)));
-      net_send_error(thd, net->last_errno, NullS);
-      statistic_increment(aborted_threads,&LOCK_status);
-    }
-    else if (thd->killed)
-    {
-      statistic_increment(aborted_threads,&LOCK_status);
-    }
-    
-end_thread:
-    close_connection(thd, 0, 1);
-    end_thread(thd,1);
-    /*
-      If end_thread returns, we are either running with --one-thread
-      or this thread has been schedule to handle the next query
-    */
-    thd= current_thd;
-    thd->thread_stack= (char*) &thd;
-  } while (!(test_flags & TEST_NO_THREADS));
-  /* The following is only executed if we are not using --one-thread */
-  return(0);					/* purecov: deadcode */
-}
-
-#endif /* EMBEDDED_LIBRARY */
-
 /*
   Execute commands from bootstrap_file.
   Used when creating the initial grant tables
@@ -1302,11 +316,6 @@
 #ifndef EMBEDDED_LIBRARY
   pthread_detach_this_thread();
   thd->thread_stack= (char*) &thd;
-#if !defined(__WIN__) && !defined(__NETWARE__)
-  sigset_t set;
-  VOID(sigemptyset(&set));			// Get mask in use
-  VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
-#endif
 #endif /* EMBEDDED_LIBRARY */
 
   if (thd->variables.max_join_size == HA_POS_ERROR)
@@ -2085,7 +1094,6 @@
     */
     enum mysql_enum_shutdown_level level=
       (enum mysql_enum_shutdown_level) (uchar) packet[0];
-    DBUG_PRINT("quit",("Got shutdown command for level %u", level));
     if (level == SHUTDOWN_DEFAULT)
       level= SHUTDOWN_WAIT_ALL_BUFFERS; // soon default will be configurable
     else if (level != SHUTDOWN_WAIT_ALL_BUFFERS)
@@ -4230,7 +3238,7 @@
           {
             if (!(user= get_current_user(thd, tmp_user)))
               goto error;
-	    reset_mqh(user);
+	    reset_mqh(user, 0);
           }
 	}
       }
@@ -6580,6 +5588,7 @@
   join_list->push_front(ptr);
   ptr->embedding= embedding;
   ptr->join_list= join_list;
+  ptr->alias= (char*) "(nested_join)";
   embedding= ptr;
   join_list= &nested_join->join_list;
   join_list->empty();
@@ -6664,6 +5673,7 @@
 
   ptr->embedding= embedding;
   ptr->join_list= join_list;
+  ptr->alias= (char*) "(nest_last_join)";
   embedded_list= &nested_join->join_list;
   embedded_list->empty();
 
@@ -7158,7 +6168,7 @@
  }
 #endif
  if (options & REFRESH_USER_RESOURCES)
-   reset_mqh((LEX_USER *) NULL);
+   reset_mqh((LEX_USER *) NULL, 0);		/* purecov: inspected */
  *write_to_binlog= tmp_write_to_binlog;
  return result;
 }

--- 1.492/sql/sql_select.cc	2007-02-14 14:40:51 +02:00
+++ 1.493/sql/sql_select.cc	2007-02-23 13:13:49 +02:00
@@ -8264,7 +8264,7 @@
       */
       if (nested_join->join_list.elements != 1)
       {
-        nested_join->nj_map= 1 << first_unused++;
+        nested_join->nj_map= (nested_join_map) 1 << first_unused++;
         first_unused= build_bitmap_for_nested_joins(&nested_join->join_list,
                                                     first_unused);
       }
@@ -9166,7 +9166,8 @@
   uint  hidden_null_count, hidden_null_pack_length, hidden_field_count;
   uint  blob_count,group_null_items, string_count;
   uint  temp_pool_slot=MY_BIT_NONE;
-  ulong reclength, string_total_length, fieldnr= 0;
+  uint fieldnr= 0;
+  ulong reclength, string_total_length;
   bool  using_unique_constraint= 0;
   bool  use_packed_rows= 0;
   bool  not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS);
@@ -10332,7 +10333,6 @@
   else
   {
     DBUG_ASSERT(join->tables);
-    DBUG_ASSERT(join_tab);
     error= sub_select(join,join_tab,0);
     if (error == NESTED_LOOP_OK || error == NESTED_LOOP_NO_MORE_ROWS)
       error= sub_select(join,join_tab,1);
@@ -15196,7 +15196,8 @@
         Item_float *filtered;
         float f; 
         if (examined_rows)
-          f= 100.0 * join->best_positions[i].records_read / examined_rows;
+          f= (float) (100.0 * join->best_positions[i].records_read /
+                      examined_rows);
         else
           f= 0.0;
         item_list.push_back((filtered= new Item_float(f)));

--- 1.391/sql/sql_show.cc	2007-02-13 10:30:01 +02:00
+++ 1.392/sql/sql_show.cc	2007-02-23 13:13:50 +02:00
@@ -1687,10 +1687,6 @@
         if (mysys_var)
           pthread_mutex_unlock(&mysys_var->mutex);
 
-#if !defined(DONT_USE_THR_ALARM) && ! defined(SCO)
-        if (pthread_kill(tmp->real_id,0))
-          tmp->proc_info="*** DEAD ***";        // This shouldn't happen
-#endif
 #ifdef EXTRA_DEBUG
         thd_info->start_time= tmp->time_after_lock;
 #else
@@ -2942,20 +2938,21 @@
     if (file->stats.create_time)
     {
       thd->variables.time_zone->gmt_sec_to_TIME(&time,
-                                                file->stats.create_time);
+                                                (my_time_t) file->stats.create_time);
       table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
       table->field[14]->set_notnull();
     }
     if (file->stats.update_time)
     {
       thd->variables.time_zone->gmt_sec_to_TIME(&time,
-                                                file->stats.update_time);
+                                                (my_time_t) file->stats.update_time);
       table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
       table->field[15]->set_notnull();
     }
     if (file->stats.check_time)
     {
-      thd->variables.time_zone->gmt_sec_to_TIME(&time, file->stats.check_time);
+      thd->variables.time_zone->gmt_sec_to_TIME(&time,
+                                                (my_time_t) file->stats.check_time);
       table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
       table->field[16]->set_notnull();
     }

--- 1.388/sql/sql_table.cc	2007-01-29 01:51:40 +02:00
+++ 1.389/sql/sql_table.cc	2007-02-23 13:13:50 +02:00
@@ -460,10 +460,10 @@
             global_ddl_log.num_entries);
   const_var= FN_LEN;
   int4store(&global_ddl_log.file_entry_buf[DDL_LOG_NAME_LEN_POS],
-            const_var);
+            (ulong) const_var);
   const_var= IO_SIZE;
   int4store(&global_ddl_log.file_entry_buf[DDL_LOG_IO_SIZE_POS],
-            const_var);
+            (ulong) const_var);
   if (write_ddl_log_file_entry(0UL))
   {
     sql_print_error("Error writing ddl log header");
@@ -3416,16 +3416,11 @@
   {
  #ifdef FN_DEVCHAR
     /* check if the table name contains FN_DEVCHAR when defined */
-    const char *start= alias;
-    while (*start != '\0')
+    if (strchr(alias, FN_DEVCHAR))
     {
-      if (*start == FN_DEVCHAR)
-      {
-        my_error(ER_WRONG_TABLE_NAME, MYF(0), alias);
-        DBUG_RETURN(TRUE);
-      }
-      start++;
-    }	  
+      my_error(ER_WRONG_TABLE_NAME, MYF(0), alias);
+      DBUG_RETURN(TRUE);
+    }
 #endif
     path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext,
                                       internal_tmp_table ? FN_IS_TMP : 0);

--- 1.50/sql/sql_test.cc	2006-12-31 02:06:37 +02:00
+++ 1.51/sql/sql_test.cc	2007-02-23 13:13:50 +02:00
@@ -73,17 +73,18 @@
   uint idx,count,unused;
   TABLE *start_link,*lnk;
 
+  /* purecov: begin tested */
   VOID(pthread_mutex_lock(&LOCK_open));
-  puts("DB             Table                            Version  Thread  L.thread  Open  Lock");
+  puts("DB             Table                            Version  Thread  Open  Lock");
 
   for (idx=unused=0 ; idx < open_cache.records ; idx++)
   {
     TABLE *entry=(TABLE*) hash_element(&open_cache,idx);
-    printf("%-14.14s %-32s%6ld%8ld%10ld%6d  %s\n",
-	   entry->s->db.str, entry->s->table_name.str, entry->s->version,
+    printf("%-14.14s %-32s%6ld%8ld%6d  %s\n",
+           entry->s->db.str, entry->s->table_name.str, entry->s->version,
 	   entry->in_use ? entry->in_use->thread_id : 0L,
-	   entry->in_use ? entry->in_use->dbug_thread_id : 0L,
-	   entry->db_stat ? 1 : 0, entry->in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : "Not in use");
+	   entry->db_stat ? 1 : 0,
+           entry->in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : "Not in use");
     if (!entry->in_use)
       unused++;
   }
@@ -110,6 +111,7 @@
     printf("Error: File hash table is corrupted\n");
   fflush(stdout);
   VOID(pthread_mutex_unlock(&LOCK_open));
+  /* purecov: end */
   return;
 }
 

--- 1.96/sql/unireg.cc	2007-02-13 11:27:24 +02:00
+++ 1.97/sql/unireg.cc	2007-02-23 13:13:50 +02:00
@@ -913,7 +913,10 @@
                                 field->interval, 
                                 field->field_name);
     if (!regfield)
+    {
+      error= 1;
       goto err;                                 // End of memory
+    }
 
     /* save_in_field() will access regfield->table->in_use */
     regfield->init(&table);

--- 1.31/sql/event_scheduler.cc	2006-12-23 21:33:28 +02:00
+++ 1.32/sql/event_scheduler.cc	2007-02-23 13:13:48 +02:00
@@ -104,25 +104,22 @@
   SYNOPSIS
     post_init_event_thread()
       thd  Thread
+
+  NOTES
+    Before this is called, one should not do any DBUG_XXX() calls.
+
 */
 
 bool
 post_init_event_thread(THD *thd)
 {
-  my_thread_init();
-  pthread_detach_this_thread();
-  thd->real_id= pthread_self();
+  (void) init_new_connection_handler_thread();
   if (init_thr_lock() || thd->store_globals())
   {
     thd->cleanup();
     return TRUE;
   }
 
-#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
-  sigset_t set;
-    VOID(sigemptyset(&set));                    // Get mask in use
-  VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
-#endif
   pthread_mutex_lock(&LOCK_thread_count);
   threads.append(thd);
   thread_count++;
@@ -187,7 +184,7 @@
   thd->options|= OPTION_AUTO_IS_NULL;
   thd->client_capabilities|= CLIENT_MULTI_RESULTS;
   pthread_mutex_lock(&LOCK_thread_count);
-  thd->thread_id= thread_id++;
+  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
   pthread_mutex_unlock(&LOCK_thread_count);
 
   /*
@@ -218,20 +215,20 @@
 event_scheduler_thread(void *arg)
 {
   /* needs to be first for thread_stack */
-  THD *thd= (THD *)((struct scheduler_param *) arg)->thd;
+  THD *thd= (THD *) ((struct scheduler_param *) arg)->thd;
   Event_scheduler *scheduler= ((struct scheduler_param *) arg)->scheduler;
+  bool res;
 
-  my_free((char*)arg, MYF(0));
-
-  thd->thread_stack= (char *)&thd;              // remember where our stack is
+  thd->thread_stack= (char*) &thd;              // remember where our stack is
+  res= post_init_event_thread(thd);
 
   DBUG_ENTER("event_scheduler_thread");
-
-  if (!post_init_event_thread(thd))
+  my_free((char*)arg, MYF(0));
+  if (!res)
     scheduler->run(thd);
 
   deinit_event_thread(thd);
-
+  pthread_exit(0);
   DBUG_RETURN(0);                               // Against gcc warnings
 }
 
@@ -255,13 +252,14 @@
   THD *thd; 
   Event_job_data *event= (Event_job_data *)arg;
   int ret;
+  bool res;
 
   thd= event->thd;
-
   thd->thread_stack= (char *) &thd;             // remember where our stack is
+  res= post_init_event_thread(thd);
   DBUG_ENTER("event_worker_thread");
 
-  if (!post_init_event_thread(thd))
+  if (!res)
   {
     DBUG_PRINT("info", ("Baikonur, time is %ld, BURAN reporting and operational."
                         "THD: 0x%lx",
@@ -295,6 +293,7 @@
 
   deinit_event_thread(thd);
 
+  pthread_exit(0);
   DBUG_RETURN(0);                               // Can't return anything here
 }
 

--- 1.65/strings/ctype-ucs2.c	2006-12-23 21:20:33 +02:00
+++ 1.66/strings/ctype-ucs2.c	2007-02-23 13:13:52 +02:00
@@ -206,6 +206,7 @@
   const uchar *se=s+slen;
   const uchar *te=t+tlen;
   MY_UNICASE_INFO **uni_plane= cs->caseinfo;
+  LINT_INIT(s_wc);
 
   while ( s < se && t < te )
   {
@@ -320,7 +321,8 @@
   const char *se=s+len;
   const char *te=t+len;
   MY_UNICASE_INFO **uni_plane= cs->caseinfo;
-  
+  LINT_INIT(s_wc);
+
   while ( s < se && t < te )
   {
     int plane;
@@ -1382,6 +1384,7 @@
   my_wc_t s_wc,t_wc;
   const uchar *se=s+slen;
   const uchar *te=t+tlen;
+  LINT_INIT(s_wc);
 
   while ( s < se && t < te )
   {

--- 1.9/extra/charset2html.c	2006-12-23 21:04:04 +02:00
+++ 1.10/extra/charset2html.c	2007-02-23 13:13:47 +02:00
@@ -153,7 +153,9 @@
   my_init();
 
   if (argc > argcnt && argv[argcnt][0] == '-' && argv[argcnt][1] == '#')
+  {
     DBUG_PUSH(argv[argcnt++]+2);
+  }
 
   if (argc > argcnt)
     the_set = argv[argcnt++];

--- 1.109/strings/ctype-utf8.c	2007-01-24 19:57:04 +02:00
+++ 1.110/strings/ctype-utf8.c	2007-02-23 13:13:52 +02:00
@@ -2312,6 +2312,7 @@
   const uchar *se=s+slen;
   const uchar *te=t+tlen;
   MY_UNICASE_INFO **uni_plane= cs->caseinfo;
+  LINT_INIT(s_wc);
 
   while ( s < se && t < te )
   {
@@ -2381,6 +2382,7 @@
   my_wc_t s_wc,t_wc;
   const uchar *se= s+slen, *te= t+tlen;
   MY_UNICASE_INFO **uni_plane= cs->caseinfo;
+  LINT_INIT(s_wc);
 
 #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
   diff_if_only_endspace_difference= 0;
@@ -4101,7 +4103,7 @@
   char hex[]= "0123456789abcdef";
   if (wc < 128 && filename_safe_char[wc])
   {
-    *s= wc;
+    *s= (uchar) wc;
     return 1;
   }
   

--- 1.26/sql/parse_file.cc	2006-12-23 21:19:51 +02:00
+++ 1.27/sql/parse_file.cc	2007-02-23 13:13:49 +02:00
@@ -228,7 +228,7 @@
 
   if (dir)
   {
-    fn_format(path, file_name->str, dir->str, 0, MY_UNPACK_FILENAME);
+    fn_format(path, file_name->str, dir->str, "", MY_UNPACK_FILENAME);
     path_end= strlen(path);
   }
   else

--- 1.121/sql/sql_view.cc	2007-02-13 10:30:02 +02:00
+++ 1.122/sql/sql_view.cc	2007-02-23 13:13:50 +02:00
@@ -713,7 +713,7 @@
     File_parser *parser;
 
     path.str= path_buff;
-    fn_format(path_buff, file.str, dir.str, 0, MY_UNPACK_FILENAME);
+    fn_format(path_buff, file.str, dir.str, "", MY_UNPACK_FILENAME);
     path.length= strlen(path_buff);
 
     if (!access(path.str, F_OK))

--- 1.10/storage/archive/archive_test.c	2007-01-24 20:30:03 +02:00
+++ 1.11/storage/archive/archive_test.c	2007-02-23 13:13:50 +02:00
@@ -36,9 +36,9 @@
 
 char test_string[BUFFER_LEN];
 
-#define TWOGIG 2147483648
-#define FOURGIG 4294967296
-#define EIGHTGIG 8589934592
+#define TWOGIG LL(2147483648)
+#define FOURGIG LL(4294967296)
+#define EIGHTGIG LL(8589934592)
 
 /* prototypes */
 int size_test(unsigned long long length, unsigned long long rows_to_test_for);
@@ -222,9 +222,9 @@
 
   /* Start size tests */
   printf("About to run 2/4/8 gig tests now, you may want to hit CTRL-C\n");
-  size_test(TWOGIG, 2097152);
-  size_test(FOURGIG, 4194304);
-  size_test(EIGHTGIG, 8388608);
+  size_test(TWOGIG, 2097152L);
+  size_test(FOURGIG, 4194304L);
+  size_test(EIGHTGIG, 8388608L);
 
   return 0;
 }

--- 1.15/storage/archive/azio.c	2007-01-24 20:30:03 +02:00
+++ 1.16/storage/archive/azio.c	2007-02-23 13:13:50 +02:00
@@ -140,7 +140,8 @@
   else if (s->mode == 'w') 
   {
     unsigned char buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE];
-    my_pread(s->file, buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0, MYF(0));
+    my_pread(s->file, (byte*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0,
+             MYF(0));
     read_header(s, buffer); /* skip the .az header */
     my_seek(s->file, 0, MY_SEEK_END, MYF(0));
   }
@@ -609,7 +610,8 @@
   if (s->mode == 'r') 
   {
     unsigned char buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE];
-    my_pread(s->file, buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0, MYF(0));
+    my_pread(s->file, (byte*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0,
+             MYF(0));
     read_header(s, buffer); /* skip the .az header */
 
     return Z_OK;
@@ -810,7 +812,7 @@
   if (s->rows > 0) 
     return 1;
 
-  s->frm_start_pos= s->start;
+  s->frm_start_pos= (uint) s->start;
   s->frm_length= length;
   s->start+= length;
 
@@ -841,7 +843,7 @@
   if (s->rows > 0) 
     return 1;
 
-  s->comment_start_pos= s->start;
+  s->comment_start_pos= (uint) s->start;
   s->comment_length= length;
   s->start+= length;
 

--- 1.47/sql/tztime.cc	2007-01-24 19:57:01 +02:00
+++ 1.48/sql/tztime.cc	2007-02-23 13:13:50 +02:00
@@ -546,8 +546,8 @@
   int yleap;
   const uint *ip;
 
-  days= t / SECS_PER_DAY;
-  rem= t % SECS_PER_DAY;
+  days= (long) (t / SECS_PER_DAY);
+  rem=  (long) (t % SECS_PER_DAY);
 
   /*
     We do this as separate step after dividing t, because this

--- 1.2/sql/udf_example.def	2006-11-16 17:19:27 +02:00
+++ 1.3/sql/udf_example.def	2007-02-23 13:13:50 +02:00
@@ -1,5 +1,4 @@
 LIBRARY		udf_example
-DESCRIPTION	'MySQL Sample for UDF'
 VERSION		1.0
 EXPORTS
   lookup

--- 1.64/mysys/my_getopt.c	2007-02-14 02:09:32 +02:00
+++ 1.65/mysys/my_getopt.c	2007-02-23 13:13:48 +02:00
@@ -194,6 +194,7 @@
 	  Find first the right option. Return error in case of an ambiguous,
 	  or unknown option
 	*/
+        LINT_INIT(prev_found);
 	optp= longopts;
 	if (!(opt_found= findopt(opt_str, length, &optp, &prev_found)))
 	{
@@ -960,7 +961,7 @@
 	printf("%d\n", *((uint*) value));
 	break;
       case GET_LONG:
-	printf("%lu\n", *((long*) value));
+	printf("%ld\n", *((long*) value));
 	break;
       case GET_ULONG:
 	printf("%lu\n", *((ulong*) value));

--- 1.4/support-files/compiler_warnings.supp	2007-01-29 16:13:15 +02:00
+++ 1.5/support-files/compiler_warnings.supp	2007-02-23 13:13:52 +02:00
@@ -1,17 +1,49 @@
+integer.cpp: .*control reaches end of non-void function.*: 1288-1427
 DictTabInfo.cpp : .*invalid access to non-static.*
 DictTabInfo.cpp : .*macro was used incorrectly.*
-EventLogger.cpp : .*defined but not used.* : 916
-NdbSqlUtil.cpp : .*unused variable.* : 684 - 685
-DbdihMain.cpp : .*unused variable.* : 6666
-DbtcMain.cpp : .*unused variable.* : 6947
-DbtcMain.cpp : .*unused variable.* : 11870
-DbtupExecQuery.cpp : .*unused variable.* : 1449
-DbtupSystemRestart.cpp : .*unused variable.* : 95 - 96
-DbtupIndex.cpp : .*unused variable.* : 188 - 242
-ndbd_malloc.cpp : .*defined but not used.* : 25
-main.cpp : .*unused variable.* : 131 - 132
+DbdihMain.cpp : .*unused variable.* : 6666-7013
+DbtupExecQuery.cpp : .*unused variable.* : 1823
 kernel_types.h : .*only defines private constructors and has no friends.* : 51
 Dbtup.hpp:   .*only defines private constructors and has no friends.*
 diskpage.hpp:   .*only defines private constructors and has no friends.*
 tuppage.hpp:   .*only defines private constructors and has no friends.*
-NdbScanOperation.cpp: .*unused variable '__align'.* : 1192
+NdbScanOperation.cpp: .*unused variable '__align'.* : 1190-1200
+sql_yacc.cc : .*label 'yyerrlab1' defined but not used.*
+kernel_types.h : .*'struct Local_key' only defines private constructors and has no friends.*
+lgman.hpp : .*'struct Lgman::Buffer_idx' only defines private constructors and has no friends.*
+SchemaFile.hpp : .*'struct SchemaFile::TableEntry' only defines private constructors and has no friends.*
+sql_yacc.cc : .*switch statement contains 'default' but no 'case' labels.*
+
+#
+# Things that can be ignored in InnoDB
+#
+pars0grm.tab.c: .*'yyerrorlab' : unreferenced label.*
+_flex_tmp.c: .*not enough actual parameters for macro 'yywrap'.*
+
+#
+# bdb is not critical to keep up to date
+#
+.*/bdb/.* : .*discards qualifiers from pointer target type.*
+.*/bdb/.* : .*unused parameter.*
+.*/bdb/.* : .*may be used uninitialized.*
+.*/bdb/.* : .*empty body in an if-statement.*
+db_vrfy.c : .*comparison is always false due to limited range of data type.*
+
+#
+# Ignore all conversion warnings on windows 64
+# (Is safe as we are not yet supporting strings >= 2G)
+#
+.* : conversion from 'size_t' to .*int'.*
+.* : conversion from '__int64' to .*int'.*
+
+#
+# The following should be fixed by the ndb team
+#
+.*/ndb/.* : .*used uninitialized in this function.*
+
+#
+# Unexplanable (?) stuff
+#
+listener.cc : .*conversion from 'SOCKET' to 'int'.*
+net_serv.c : .*conversion from 'SOCKET' to 'int'.*
+mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 567

--- 1.12/mysql-test/t/wait_timeout.test	2007-01-24 19:56:57 +02:00
+++ 1.13/mysql-test/t/wait_timeout.test	2007-02-23 13:13:48 +02:00
@@ -1,5 +1,6 @@
 # This tests not performed with embedded server
 -- source include/not_embedded.inc
+-- source include/one_thread_per_connection.inc
 
 #
 # Bug #8731: wait_timeout does not work on Mac OS X

--- 1.21/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp	2007-01-15 22:05:11 +02:00
+++ 1.22/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp	2007-02-23 13:13:51 +02:00
@@ -153,12 +153,10 @@
     return;
   
   Uint32 min_size= 4*tabPtrP->m_offsets[DD].m_fix_header_size;
-  Uint32 var_size= tabPtrP->m_offsets[DD].m_max_var_offset;
   
   if (tabPtrP->m_attributes[DD].m_no_of_varsize == 0)
   {
     Uint32 recs_per_page= (4*Tup_fixsize_page::DATA_WORDS)/min_size;
-    Uint32 pct_free= 0;
     m_page_free_bits_map[0] = recs_per_page; // 100% free
     m_page_free_bits_map[1] = 1;
     m_page_free_bits_map[2] = 0;
@@ -317,7 +315,7 @@
 			    0, 0, 0);
     unsigned uncommitted, committed;
     uncommitted = committed = ~(unsigned)0;
-    int ret = tsman.get_page_free_bits(&page, &uncommitted, &committed);
+    (void) tsman.get_page_free_bits(&page, &uncommitted, &committed);
     
     idx = alloc.calc_page_free_bits(real_free);
     ddassert(idx == committed);
@@ -858,9 +856,6 @@
 
   if (DBG_DISK)
     ndbout << " disk_page_set_dirty " << key << endl;
-  
-  Uint32 tableId = pagePtr.p->m_table_id;
-  Uint32 fragId = pagePtr.p->m_fragment_id;
   
   Ptr<Tablerec> tabPtr;
   tabPtr.i= pagePtr.p->m_table_id;

--- 1.5/storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp	2006-12-23 21:33:30 +02:00
+++ 1.6/storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp	2007-02-23 13:13:51 +02:00
@@ -163,7 +163,6 @@
   /**
    * TODO free fix + var part
    */
-  Uint32 page_idx= key->m_page_idx;
   Uint32 *ptr = ((Fix_page*)pagePtr.p)->get_ptr(key->m_page_idx, 0);
   Tuple_header* tuple = (Tuple_header*)ptr;
 

--- 1.3/storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp	2006-12-23 21:33:30 +02:00
+++ 1.4/storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp	2007-02-23 13:13:51 +02:00
@@ -461,9 +461,8 @@
       << " free: " << page.free_space;
   
   out << " free list: " << hex << page.next_free_index << " " << flush;
-  Uint32 startTuple = page.next_free_index >> 16;
-  
 #if 0
+  Uint32 startTuple = page.next_free_index >> 16;
   Uint32 cnt = 0;
   Uint32 next= startTuple;
   while((next & 0xFFFF) != 0xFFFF)

--- 1.4/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp	2006-12-23 21:33:30 +02:00
+++ 1.5/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp	2007-02-23 13:13:51 +02:00
@@ -94,6 +94,7 @@
    * Alloc record from page
    *   return page_idx
    **/
+  Tup_fixsize_page() {}
   Uint32 alloc_record();
   Uint32 alloc_record(Uint32 page_idx);
   Uint32 free_record(Uint32 page_idx);
@@ -148,6 +149,7 @@
   
   Uint32 m_data[DATA_WORDS];
   
+  Tup_varsize_page() {}
   void init();
   
   Uint32* get_free_space_ptr() { 

--- 1.4/storage/ndb/src/kernel/blocks/diskpage.hpp	2006-12-31 02:04:56 +02:00
+++ 1.5/storage/ndb/src/kernel/blocks/diskpage.hpp	2007-02-23 13:13:51 +02:00
@@ -54,6 +54,7 @@
     Uint32 m_node_id;
     Uint32 m_file_type;
     Uint32 m_time; // time(0)
+    Zero_page_header() {}
     void init(File_type ft, Uint32 node_id, Uint32 version, Uint32 now);
     int validate(File_type ft, Uint32 node_id, Uint32 version, Uint32 now);
   };
@@ -86,6 +87,7 @@
 	Uint32 m_fragment_id;
 	Uint32 m_next_free_extent;
       };
+      Extent_header() {}
       Uint32 m_page_bitmask[1]; // (BitsPerPage*ExtentSize)/(32*PageSize)
       Uint32 get_free_bits(Uint32 page) const;
       Uint32 get_free_word_offset(Uint32 page) const;
@@ -102,6 +104,7 @@
       struct Page_header m_page_header;
       Extent_header m_extents[1];
       
+      Extent_page() {}
       Extent_header* get_header(Uint32 extent_no, Uint32 extent_size);
     };
     

--- 1.12/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp	2007-01-29 16:13:14 +02:00
+++ 1.13/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp	2007-02-23 13:13:51 +02:00
@@ -220,6 +220,7 @@
   while (cnt < MAX_CHUNKS && allocated < pages)
   {
     InitChunk chunk; 
+    LINT_INIT(chunk.m_start);
     
 #if defined(_lint) || defined(FORCE_INIT_OF_VARS)
     memset((char*) &chunk, 0 , sizeof(chunk));

--- 1.15/storage/ndb/src/common/util/ConfigValues.cpp	2007-01-29 16:13:14 +02:00
+++ 1.16/storage/ndb/src/common/util/ConfigValues.cpp	2007-02-23 13:13:51 +02:00
@@ -88,18 +88,18 @@
 ConfigValues::getByPos(Uint32 pos, Entry * result) const {
   assert(pos < (2 * m_size));
   Uint32 keypart = m_values[pos];
-  Uint32 val = m_values[pos+1];
+  Uint32 val2 = m_values[pos+1];
 
   switch(::getTypeOf(keypart)){
   case IntType:
   case SectionType:
-    result->m_int = val;
+    result->m_int = val2;
     break;
   case StringType:
-    result->m_string = * getString(val);
+    result->m_string = * getString(val2);
     break;
   case Int64Type:
-    result->m_int64 = * get64(val);
+    result->m_int64 = * get64(val2);
     break;
   case InvalidType: 
   default:

--- 1.43/mysql-test/lib/mtr_report.pl	2006-12-31 02:06:32 +02:00
+++ 1.44/mysql-test/lib/mtr_report.pl	2007-02-23 13:13:47 +02:00
@@ -236,8 +236,10 @@
       "the documentation at\n",
       "http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
   }
-  print
-      "The servers were restarted $tot_restarts times\n";
+  if (!$::opt_extern)
+  {
+    print "The servers where restarted $tot_restarts times\n";
+  }
 
   if ( $::opt_timer )
   {

--- 1.270/mysql-test/mysql-test-run.pl	2007-02-06 17:38:53 +02:00
+++ 1.271/mysql-test/mysql-test-run.pl	2007-02-23 13:13:47 +02:00
@@ -700,7 +700,9 @@
 				       "$glob_basedir/client",
 				       "$glob_basedir/bin");
 
-  $exe_mysqld=         mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
+  if (!$opt_extern)
+  {
+    $exe_mysqld=       mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
 				       "$glob_basedir/sql/mysqld",
 				       "$path_client_bindir/mysqld-max-nt",
 				       "$path_client_bindir/mysqld-max",
@@ -712,8 +714,16 @@
 				       "$glob_basedir/bin/mysqld",
 				       "$glob_basedir/sbin/mysqld");
 
-  # Use the mysqld found above to find out what features are available
-  collect_mysqld_features();
+    # Use the mysqld found above to find out what features are available
+    collect_mysqld_features();
+  }
+  else
+  {
+    $mysqld_variables{'port'}= 3306;
+    $mysqld_variables{'master-port'}= 3306;
+    $opt_skip_ndbcluster= 1;
+    $opt_skip_im= 1;
+  }
 
   if ( $opt_comment )
   {
@@ -750,7 +760,7 @@
   # --------------------------------------------------------------------------
   # NOTE if the default binlog format is changed, this has to be changed
   $used_binlog_format= "stmt";
-  if ( $mysql_version_id >= 50100 )
+  if (!$opt_extern && $mysql_version_id >= 50100 )
   {
     $used_binlog_format= "mixed"; # Default value for binlog format
 
@@ -836,19 +846,20 @@
   # --------------------------------------------------------------------------
   # Check im suport
   # --------------------------------------------------------------------------
-  if ( $mysql_version_id < 50000 )
+  if (!$opt_extern)
   {
-    # Instance manager is not supported until 5.0
-    $opt_skip_im= 1;
+    if ( $mysql_version_id < 50000 ) {
+      # Instance manager is not supported until 5.0
+      $opt_skip_im= 1;
 
-  }
+    }
 
-  if ( $glob_win32 )
-  {
-    mtr_report("Disable Instance manager - not supported on Windows");
-    $opt_skip_im= 1;
-  }
+    if ( $glob_win32 ) {
+      mtr_report("Disable Instance manager - not supported on Windows");
+      $opt_skip_im= 1;
+    }
 
+  }
   # --------------------------------------------------------------------------
   # Record flag
   # --------------------------------------------------------------------------
@@ -1212,7 +1223,7 @@
     $opt_skip_rpl= 1;
 
     # Setup master->[0] with the settings for the extern server
-    $master->[0]->{'path_sock'}=  $opt_socket if $opt_socket;
+    $master->[0]->{'path_sock'}=  $opt_socket ? $opt_socket : "/tmp/mysql.sock";
     mtr_report("Using extern server at '$master->[0]->{path_sock}'");
   }
   else
@@ -1478,61 +1489,66 @@
   $exe_mysqlbinlog=    mtr_exe_exists("$path_client_bindir/mysqlbinlog");
   $exe_mysqladmin=     mtr_exe_exists("$path_client_bindir/mysqladmin");
   $exe_mysql=          mtr_exe_exists("$path_client_bindir/mysql");
-  if ( $mysql_version_id >= 50100 )
-  {
-    $exe_mysqlslap=    mtr_exe_exists("$path_client_bindir/mysqlslap");
-  }
-  if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server )
-  {
-    $exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade")
-  }
-  else
-  {
-    $exe_mysql_upgrade= "";
-  }
 
-  if ( ! $glob_win32 )
+  if (!$opt_extern)
   {
-    # Look for mysql_fix_system_table script
-    $exe_mysql_fix_system_tables=
-      mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
-			"$path_client_bindir/mysql_fix_privilege_tables");
-  }
-
-  # Look for mysql_fix_privilege_tables.sql script
-  $file_mysql_fix_privilege_tables=
-    mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql",
-		    "$glob_basedir/share/mysql_fix_privilege_tables.sql");
-
-  if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
-  {
-    mtr_warning("Could not find all required ndb binaries, " .
-		"all ndb tests will fail, use --skip-ndbcluster to " .
-		"skip testing it.");
+    if ( $mysql_version_id >= 50100 )
+    {
+      $exe_mysqlslap=    mtr_exe_exists("$path_client_bindir/mysqlslap");
+    }
+    if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server )
+    {
+      $exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade")
+    }
+    else
+    {
+      $exe_mysql_upgrade= "";
+    }
 
-    foreach my $cluster (@{$clusters})
+    if ( ! $glob_win32 )
     {
-      $cluster->{"executable_setup_failed"}= 1;
+      # Look for mysql_fix_system_table script
+      $exe_mysql_fix_system_tables=
+        mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
+  			"$path_client_bindir/mysql_fix_privilege_tables");
     }
-  }
 
-  if ( ! $opt_skip_im and executable_setup_im())
-  {
-    mtr_warning("Could not find all required instance manager binaries, " .
-		"all im tests will fail, use --skip-im to " .
-		"continue without instance manager");
-    $instance_manager->{"executable_setup_failed"}= 1;
-  }
+    # Look for mysql_fix_privilege_tables.sql script
+    $file_mysql_fix_privilege_tables=
+      mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql",
+  		    "$glob_basedir/share/mysql_fix_privilege_tables.sql");
+
+    if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
+    {
+      mtr_warning("Could not find all required ndb binaries, " .
+  		"all ndb tests will fail, use --skip-ndbcluster to " .
+  		"skip testing it.");
+
+      foreach my $cluster (@{$clusters})
+      {
+        $cluster->{"executable_setup_failed"}= 1;
+      }
+    }
 
-  # Look for the udf_example library
-  $lib_udf_example=
-    mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
-                    "$glob_basedir/sql/.libs/udf_example.so",);
+    if ( ! $opt_skip_im and executable_setup_im())
+    {
+      mtr_warning("Could not find all required instance manager binaries, " .
+  		"all im tests will fail, use --skip-im to " .
+  		"continue without instance manager");
+      $instance_manager->{"executable_setup_failed"}= 1;
+    }
+
+    # Look for the udf_example library
+    $lib_udf_example=
+      mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
+                      "$glob_basedir/sql/.libs/udf_example.so",);
+
+    # Look for the ha_example library
+    $lib_example_plugin=
+      mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
+                      "$glob_basedir/storage/example/.libs/ha_example.so",);
 
-  # Look for the ha_example library
-  $lib_example_plugin=
-    mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
-                    "$glob_basedir/storage/example/.libs/ha_example.so",);
+  }
 
   # Look for mysqltest executable
   if ( $glob_use_embedded_server )
@@ -1599,7 +1615,7 @@
   mtr_add_arg($args, "--port=$master->[0]->{'port'}");
   mtr_add_arg($args, "--socket=$master->[0]->{'path_sock'}");
 
-  if ( $mysql_version_id >= 50000 )
+  if ( $opt_extern || $mysql_version_id >= 50000 )
   {
     mtr_add_arg($args, "--vardir=$opt_vardir")
   }
@@ -1718,7 +1734,7 @@
   }
 
   $ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths,
-				$ENV{'LD_LIBRARY_PATHS'} ?
+				$ENV{'LD_LIBRARY_PATH'} ?
 				split(':', $ENV{'LD_LIBRARY_PATH'}) : ());
   mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
 
@@ -1899,7 +1915,7 @@
   my $cmdline_mysqlbinlog=
     "$exe_mysqlbinlog" .
       " --no-defaults --disable-force-if-open --debug-info --local-load=$opt_tmpdir";
-  if ( $mysql_version_id >= 50000 )
+  if ( !$opt_extern && $mysql_version_id >= 50000 )
   {
     $cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir";
   }
@@ -1930,7 +1946,7 @@
   # ----------------------------------------------------
   # Setup env so childs can execute mysql_upgrade
   # ----------------------------------------------------
-  if ( $mysql_version_id >= 50000 )
+  if ( !$opt_extern && $mysql_version_id >= 50000 )
   {
     $ENV{'MYSQL_UPGRADE'}= mysql_upgrade_arguments();
   }
@@ -1938,7 +1954,7 @@
   # ----------------------------------------------------
   # Setup env so childs can execute mysql_fix_system_tables
   # ----------------------------------------------------
-  if ( ! $glob_win32 )
+  if ( !$opt_extern && ! $glob_win32 )
   {
     my $cmdline_mysql_fix_system_tables=
       "$exe_mysql_fix_system_tables --no-defaults --host=localhost " .
@@ -1948,7 +1964,10 @@
       "--socket=$master->[0]->{'path_sock'}";
     $ENV{'MYSQL_FIX_SYSTEM_TABLES'}=  $cmdline_mysql_fix_system_tables;
   }
-  $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}=  $file_mysql_fix_privilege_tables;
+  if (!$opt_extern)
+  {
+    $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}=  $file_mysql_fix_privilege_tables;
+  }
 
   # ----------------------------------------------------
   # Setup env so childs can execute my_print_defaults
@@ -2253,7 +2272,10 @@
 
   if ($opt_skip_ssl || $opt_extern)
   {
-    mtr_report("Skipping SSL");
+    if (!$opt_extern)
+    {
+      mtr_report("Skipping SSL");
+    }
     $opt_ssl_supported= 0;
     $opt_ssl= 0;
     return;
@@ -2328,9 +2350,12 @@
 sub check_ndbcluster_support ($) {
   my $mysqld_variables= shift;
 
-  if ($opt_skip_ndbcluster)
+  if ($opt_skip_ndbcluster || $opt_extern)
   {
-    mtr_report("Skipping ndbcluster");
+    if (!$opt_extern)
+    {
+      mtr_report("Skipping ndbcluster");
+    }
     $opt_skip_ndbcluster_slave= 1;
     return;
   }
@@ -2746,7 +2771,10 @@
     }
     else
     {
-      mtr_report("No need to create '$opt_vardir' it already exists");
+      if ($opt_verbose)
+      {
+	mtr_report("No need to create '$opt_vardir' it already exists");
+      }
     }
   }
   else
@@ -3143,17 +3171,17 @@
   unlink("$result_dir/$tname.log");
   unlink("$result_dir/$tname.warnings");
 
-  if ( $mysql_version_id < 50000 )
-  {
-    # Set environment variable NDB_STATUS_OK to 1
-    # if script decided to run mysqltest cluster _is_ installed ok
-    $ENV{'NDB_STATUS_OK'} = "1";
-  }
-  elsif ( $mysql_version_id < 50100 )
+  if (!$opt_extern)
   {
-    # Set environment variable NDB_STATUS_OK to YES
-    # if script decided to run mysqltest cluster _is_ installed ok
-    $ENV{'NDB_STATUS_OK'} = "YES";
+    if ( $mysql_version_id < 50000 ) {
+      # Set environment variable NDB_STATUS_OK to 1
+      # if script decided to run mysqltest cluster _is_ installed ok
+      $ENV{'NDB_STATUS_OK'} = "1";
+    } elsif ( $mysql_version_id < 50100 ) {
+      # Set environment variable NDB_STATUS_OK to YES
+      # if script decided to run mysqltest cluster _is_ installed ok
+      $ENV{'NDB_STATUS_OK'} = "YES";
+    }
   }
 }
 
@@ -4932,10 +4960,10 @@
 
   if ( $message )
   {
-    print STDERR "$message \n";
+    print STDERR "$message\n";
   }
 
-  print STDERR <<HERE;
+  print <<HERE;
 
 $0 [ OPTIONS ] [ TESTCASE ]
 

--- 1.231/mysql-test/t/disabled.def	2007-02-06 16:50:19 +02:00
+++ 1.232/mysql-test/t/disabled.def	2007-02-23 13:13:47 +02:00
@@ -39,3 +39,4 @@
 mysql_upgrade            : Bug#25074 mysql_upgrade gives inconsisten results
 plugin                   : Bug#25659 memory leak via "plugins" test
 rpl_ndb_dd_advance	 : Bug#25913 rpl_ndb_dd_advance fails randomly
+ndb_alter_table		 : Bug##25774 ndb_alter_table.test fails in DBUG_ASSERT() on Linux x64

--- 1.12/libmysqld/CMakeLists.txt	2007-01-12 13:24:31 +02:00
+++ 1.13/libmysqld/CMakeLists.txt	2007-02-23 13:13:47 +02:00
@@ -74,6 +74,7 @@
             ../sql/strfunc.cc ../sql/table.cc ../sql/thr_malloc.cc
             ../sql/time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc
             ../sql/partition_info.cc ../sql/sql_locale.cc
+	    ../sql/sql_connect.cc ../sql/scheduler.cc
             ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c
             ../vio/viosslfactories.c
             ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc

--- 1.25/server-tools/instance-manager/mysqlmanager.cc	2006-12-31 02:06:33 +02:00
+++ 1.26/server-tools/instance-manager/mysqlmanager.cc	2007-02-23 13:13:48 +02:00
@@ -225,7 +225,7 @@
   MY_INIT(progname);
   log_init();
   umask(0117);
-  srand((unsigned int) time(0));
+  srand((uint) time(0));
 }
 
 

--- 1.36/storage/ndb/src/common/debugger/EventLogger.cpp	2007-02-14 10:29:13 +02:00
+++ 1.37/storage/ndb/src/common/debugger/EventLogger.cpp	2007-02-23 13:13:50 +02:00
@@ -608,21 +608,21 @@
   lenth = sizeof(TransporterErrorString)/sizeof(struct myTransporterError);
   for(i=0; i<lenth; i++)
   {
-    if(theData[2] == TransporterErrorString[i].errorNum)
+    if(theData[2] == (Uint32) TransporterErrorString[i].errorNum)
     {
       BaseString::snprintf(m_text, m_text_len,
-                          "Transporter to node %d reported error 0x%x: %s",
-                          theData[1],
-			  theData[2],
-                          TransporterErrorString[i].errorString);
+                           "Transporter to node %d reported error 0x%x: %s",
+                           theData[1],
+                           theData[2],
+                           TransporterErrorString[i].errorString);
       break;
     }
   }
   if(i == lenth)
     BaseString::snprintf(m_text, m_text_len,   
-                        "Transporter to node %d reported error 0x%x: unknown error",
-                          theData[1],
-			  theData[2]);
+                         "Transporter to node %d reported error 0x%x: unknown error",
+                         theData[1],
+                         theData[2]);
 }
 void getTextTransporterWarning(QQQQ) {
   getTextTransporterError(m_text, m_text_len, theData);
@@ -1043,6 +1043,7 @@
 }
 
 #ifdef NOT_USED
+
 static NdbOut&
 operator<<(NdbOut& out, const LogLevel & ll)
 {

--- 1.17/mysys/base64.c	2006-12-23 21:19:45 +02:00
+++ 1.18/mysys/base64.c	2007-02-23 13:13:48 +02:00
@@ -100,10 +100,10 @@
 }
 
 
-static inline unsigned
+static inline uint
 pos(unsigned char c)
 {
-  return strchr(base64_table, c) - base64_table;
+  return (uint) (strchr(base64_table, c) - base64_table);
 }
 
 

--- 1.35/storage/ndb/src/common/util/NdbSqlUtil.cpp	2006-12-23 21:20:13 +02:00
+++ 1.36/storage/ndb/src/common/util/NdbSqlUtil.cpp	2007-02-23 13:13:51 +02:00
@@ -681,8 +681,6 @@
 NdbSqlUtil::cmpBit(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
 { 
   Uint32 n = (n1 < n2) ? n1 : n2;
-  char* c1 = (char*)p1;
-  char* c2 = (char*)p2;
   int ret = memcmp(p1, p2, n);
   return ret;
 }

--- 1.6/storage/ndb/src/cw/cpcd/CPCD.hpp	2006-12-23 21:20:14 +02:00
+++ 1.7/storage/ndb/src/cw/cpcd/CPCD.hpp	2007-02-23 13:13:51 +02:00
@@ -62,6 +62,7 @@
 
 struct EventSubscriber {
   virtual void report(const CPCEvent &) = 0;
+  EventSubscriber() {}
   virtual ~EventSubscriber() {}
 };
 

--- 1.63/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2007-02-01 19:34:07 +02:00
+++ 1.64/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2007-02-23 13:13:51 +02:00
@@ -1488,7 +1488,6 @@
   const Uint32 ptrI = conf->getConnectionPtr();
   const Uint32 tableId = conf->getTableId();
   const TriggerEvent::Value type = conf->getTriggerEvent();
-  const Uint32 triggerId = conf->getTriggerId();
 
   BackupRecordPtr ptr LINT_SET_PTR;
   c_backupPool.getPtr(ptr, ptrI);
@@ -2152,7 +2151,6 @@
   
   DropTrigConf* conf = (DropTrigConf*)signal->getDataPtr();
   const Uint32 ptrI = conf->getConnectionPtr();
-  const Uint32 triggerId= conf->getTriggerId();
 
   BackupRecordPtr ptr LINT_SET_PTR;
   c_backupPool.getPtr(ptr, ptrI);
@@ -4658,7 +4656,6 @@
   }
   ndbrequire(ok);
   
-  Uint32 ref= ptr.p->masterRef;
   ptr.p->masterRef = reference();
   ptr.p->nodes.clear();
   ptr.p->nodes.set(getOwnNodeId());

--- 1.35/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp	2007-02-14 07:35:28 +02:00
+++ 1.36/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp	2007-02-23 13:13:51 +02:00
@@ -537,6 +537,7 @@
     ,OP_INITIAL             = ~(Uint32)0
   };
   
+  Operationrec() {}
   bool is_same_trans(const Operationrec* op) const {
     return 
       transId1 == op->transId1 && transId2 == op->transId2;

--- 1.82/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp	2007-02-14 07:35:28 +02:00
+++ 1.83/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp	2007-02-23 13:13:51 +02:00
@@ -698,7 +698,6 @@
 
 void Dbacc::releaseRootFragResources(Signal* signal, Uint32 tableId)
 {
-  FragmentrecPtr rootPtr;
   TabrecPtr tabPtr;
   tabPtr.i = tableId;
   ptrCheckGuard(tabPtr, ctablesize, tabrec);
@@ -2266,7 +2265,6 @@
   Page8Ptr ulkPageidptr;
   Uint32 tulkLocalPtr;
   Uint32 tlocalkey1, tlocalkey2;
-  Uint32 TlogStart;
 
   jamEntry();
   operationRecPtr.i = signal->theData[0];

--- 1.114/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2007-01-27 03:46:41 +02:00
+++ 1.115/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2007-02-23 13:13:51 +02:00
@@ -291,7 +291,6 @@
     for(; ok; ok = c_obj_hash.next(iter))
     {
       Rope name(c_rope_pool, iter.curr.p->m_name);
-      const Uint32 size = name.size();
       char buf[1024];
       name.copy(buf);
       ndbout_c("%s m_ref_count: %d", buf, iter.curr.p->m_ref_count); 
@@ -3793,7 +3792,7 @@
     createTabPtr.p->m_dihAddFragPtr = RNIL;
 
     Uint32 key = c_opRecordSequence + 1;
-    Uint32 *theData = signal->getDataPtrSend(), i;
+    Uint32 *theData = signal->getDataPtrSend();
     Uint16 *frag_data= (Uint16*)&signal->theData[25];
     CreateFragmentationReq * const req = (CreateFragmentationReq*)theData;
     req->senderRef = reference();
@@ -4940,7 +4939,6 @@
   packTableIntoPages(w, tabPtr);
   
   SegmentedSectionPtr spDataPtr;
-  Ptr<SectionSegment> tmpTsPtr;
   w.getPtr(spDataPtr);
   
   signal->setSection(spDataPtr, CreateTabReq::DICT_TAB_INFO);
@@ -5425,7 +5423,6 @@
   Uint32 fragCount = req->totalFragments;
   Uint32 requestInfo = req->requestInfo;
   Uint32 startGci = req->startGci;
-  Uint32 tablespace_id= req->tablespaceId;
   Uint32 logPart = req->logPartId;
 
   ndbrequire(node == getOwnNodeId());
@@ -7538,7 +7535,6 @@
 Dbdict::execLIST_TABLES_REQ(Signal* signal)
 {
   jamEntry();
-  Uint32 i;
   ListTablesReq * req = (ListTablesReq*)signal->getDataPtr();
   Uint32 senderRef  = req->senderRef;
   Uint32 senderData = req->senderData;
@@ -9415,7 +9411,6 @@
     evntRecPtr.i = ref->getSenderData();
     ndbrequire((evntRecPtr.p = c_opCreateEvent.getPtr(evntRecPtr.i)) != NULL);
 
-    Uint32 err;
     interpretUtilPrepareErrorCode(errorCode, evntRecPtr.p->m_errorCode,
 				  evntRecPtr.p->m_errorLine);
     evntRecPtr.p->m_errorNode = reference();
@@ -15184,7 +15179,6 @@
   const Uint32 objId = req->objId;
   const Uint32 objVersion = req->objVersion;
   const Uint32 objType = req->objType;
-  const Uint32 requestInfo = req->requestInfo;
   
   DropObjRecordPtr dropObjPtr;  
   ndbrequire(c_opDropObj.seize(dropObjPtr));
@@ -15683,8 +15677,7 @@
 
 void
 Dbdict::create_fg_abort_start(Signal* signal, SchemaOp* op){
-  CreateFilegroupImplReq* req = 
-    (CreateFilegroupImplReq*)signal->getDataPtrSend();
+  (void) signal->getDataPtrSend();
 
   if (op->m_obj_ptr_i != RNIL)
   {

--- 1.47/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2007-01-27 03:46:41 +02:00
+++ 1.48/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2007-02-23 13:13:51 +02:00
@@ -1975,6 +1975,7 @@
     NodeBitmask m_nodes;
     
     Uint32 m_errorCode;
+    SchemaTransaction() {}
     void setErrorCode(Uint32 c){ if(m_errorCode == 0) m_errorCode = c;}
 
     /**

--- 1.108/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2007-02-21 16:45:06 +02:00
+++ 1.109/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2007-02-23 13:13:51 +02:00
@@ -2965,7 +2965,6 @@
     if (replicaPtr.p->lcpStatus[idx] == ZVALID) 
     {
       ndbrequire(replicaPtr.p->lcpId[idx] > maxLcpId);
-      Uint32 startGci = replicaPtr.p->maxGciCompleted[idx];
       Uint32 stopGci = replicaPtr.p->maxGciStarted[idx];
       for (;j < replicaPtr.p->noCrashedReplicas; j++)
       {
@@ -10620,8 +10619,6 @@
   ndbrequire(!isMaster());
   Uint32 lcpNo = rep->lcpNo;
   Uint32 lcpId = rep->lcpId;
-  Uint32 replicaLcpNo = replicaPtr.p->nextLcp;
-  Uint32 prevReplicaLcpNo = prevLcpNo(replicaLcpNo);
 
   warningEvent("Detected previous node failure of %d during lcp",
 	       rep->nodeId);

--- 1.138/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2007-02-21 16:45:06 +02:00
+++ 1.139/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2007-02-23 13:13:51 +02:00
@@ -599,7 +599,7 @@
     case DefineBackupRef::FailedInsertTableList: 
       jam();
       err_code = NDBD_EXIT_INVALID_CONFIG;
-      extra_msg = "Probably Backup parameters configuration error, Please consult the manual";
+      extra_msg = (char*) "Probably Backup parameters configuration error, Please consult the manual";
       progError(__LINE__, err_code, extra_msg);
   }
 
@@ -3963,7 +3963,6 @@
 Dblqh::handle_nr_copy(Signal* signal, Ptr<TcConnectionrec> regTcPtr)
 {
   jam();
-  Uint32 tableId = regTcPtr.p->tableref;
   Uint32 fragPtr = fragptr.p->tupFragptr;
   Uint32 op = regTcPtr.p->operation;
 
@@ -6728,7 +6727,6 @@
   }//if
   
   TcConnectionrec * const regTcPtr = tcConnectptr.p;
-  Uint32 activeCreat = regTcPtr->activeCreat;
   if (ERROR_INSERTED(5100))
   {
     SET_ERROR_INSERT_VALUE(5101);
@@ -6808,7 +6806,6 @@
     return;
   }//if
   TcConnectionrec * const regTcPtr = tcConnectptr.p;
-  Uint32 activeCreat = regTcPtr->activeCreat;
   if (regTcPtr->transactionState != TcConnectionrec::PREPARED) {
     warningReport(signal, 10);
     return;

--- 1.134/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2007-02-14 07:35:29 +02:00
+++ 1.135/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2007-02-23 13:13:51 +02:00
@@ -6937,7 +6937,6 @@
 /*****************************************************************************/
 void Dbtc::execNODE_FAILREP(Signal* signal) 
 {
-  HostRecordPtr tmpHostptr;
   jamEntry();
 
   NodeFailRep * const nodeFail = (NodeFailRep *)&signal->theData[0];
@@ -11841,8 +11840,6 @@
   }
   const UintR TconnectIndex = indexOp->connectionIndex;
   ApiConnectRecord * const regApiPtr = &apiConnectRecord[TconnectIndex];
-  Uint32 tcKeyRequestInfo  = indexOp->tcIndxReq.requestInfo;
-  Uint32 commitFlg = TcKeyReq::getCommitFlag(tcKeyRequestInfo);
 
   switch(indexOp->indexOpState) {
   case(IOS_NOOP): {
@@ -13305,7 +13302,6 @@
   Uint32 dstRef = ord->dstRef;
   Uint32 srcRef = ord->srcRef;
   Uint32 gsn = ord->gsn;
-  Uint32 cnt = ord->cnt;
 
   if (likely(getNodeInfo(refToNode(dstRef)).m_connected))
   {

--- 1.58/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2007-02-14 07:35:29 +02:00
+++ 1.59/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2007-02-23 13:13:51 +02:00
@@ -516,6 +516,7 @@
       return (m_key.m_file_no << 16) ^ m_key.m_page_idx;
     }
 
+    Extent_info() {}
     bool equal(const Extent_info & rec) const {
       return m_key.m_file_no == rec.m_key.m_file_no &&
 	m_key.m_page_idx == rec.m_key.m_page_idx;
@@ -667,6 +668,7 @@
     Uint32 currentAttrinbufLen; //Used until copyAttrinfo
   };
 
+  Operationrec() {}
   bool is_first_operation() const { return prevActiveOp == RNIL;}
   bool is_last_operation() const { return nextActiveOp == RNIL;}
 
@@ -1241,6 +1243,7 @@
     STATIC_CONST( LCP_KEEP    = 0x02000000 ); // Should be returned in LCP
     STATIC_CONST( FREE        = 0x02800000 ); // Is free
     
+    Tuple_header() {}
     Uint32 get_tuple_version() const { 
       return m_header_bits & TUP_VERSION_MASK;
     }

--- 1.52/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2007-02-06 04:54:22 +02:00
+++ 1.53/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2007-02-23 13:13:51 +02:00
@@ -451,7 +451,6 @@
   Tuple_header* ptr= (Tuple_header*)tmp;
   
   int res= 1;
-  Uint32 opPtr= ptr->m_operation_ptr_i;
   if(ptr->m_header_bits & Tuple_header::DISK_PART)
   {
     Page_cache_client::Request req;
@@ -536,7 +535,6 @@
   Tuple_header* ptr= (Tuple_header*)tmp;
   
   int res= 1;
-  Uint32 opPtr= ptr->m_operation_ptr_i;
   if(ptr->m_header_bits & Tuple_header::DISK_PART)
   {
     Page_cache_client::Request req;
@@ -2923,7 +2921,6 @@
   ptrCheckGuard(tablePtr, cnoOfTablerec, tablerec);
 
   Local_key tmp = *key;
-  Uint32 pages = fragPtr.p->noOfPages;
   
   int ret;
   PagePtr page_ptr;

--- 1.7/storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp	2006-12-23 21:20:17 +02:00
+++ 1.8/storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp	2007-02-23 13:13:51 +02:00
@@ -123,7 +123,6 @@
 			  Uint32 mm) 
 {
   Uint32 nextTuple = regTabPtr->m_offsets[mm].m_fix_header_size;
-  Uint32 endOfList;
   /*
   ASSUMES AT LEAST ONE TUPLE HEADER FITS AND THEREFORE NO HANDLING
   OF ZERO AS EXTREME CASE

--- 1.33/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp	2006-12-27 11:58:04 +02:00
+++ 1.34/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp	2007-02-23 13:13:51 +02:00
@@ -53,7 +53,6 @@
   regTabPtr.i           = tupFragReq->tableId;
   Uint32 noOfAttributes = tupFragReq->noOfAttr;
   Uint32 fragId         = tupFragReq->fragId;
-  Uint32 noOfNullAttr = tupFragReq->noOfNullAttr;
   /*  Uint32 schemaVersion = tupFragReq->schemaVersion;*/
   Uint32 noOfKeyAttr = tupFragReq->noOfKeyAttr;
   Uint32 noOfCharsets = tupFragReq->noOfCharsets;
@@ -594,8 +593,8 @@
       Uint32 sz= sizeof(Disk_undo::Create) >> 2;
       
       Logfile_client lgman(this, c_lgman, regFragPtr.p->m_logfile_group_id);
-      int r0 = c_lgman->alloc_log_space(regFragPtr.p->m_logfile_group_id,
-					sz);
+      (void)  c_lgman->alloc_log_space(regFragPtr.p->m_logfile_group_id,
+                                       sz);
       
       int res= lgman.get_log_buffer(signal, sz, &cb);
       switch(res){
@@ -951,7 +950,7 @@
     cb.m_callbackFunction = 
       safe_cast(&Dbtup::drop_table_log_buffer_callback);
     Uint32 sz= sizeof(Disk_undo::Drop) >> 2;
-    int r0 = c_lgman->alloc_log_space(logfile_group_id, sz);
+    (void) c_lgman->alloc_log_space(logfile_group_id, sz);
     
     Logfile_client lgman(this, c_lgman, logfile_group_id);
     int res= lgman.get_log_buffer(signal, sz, &cb);
@@ -1081,7 +1080,7 @@
 	  safe_cast(&Dbtup::drop_fragment_free_extent_log_buffer_callback);
 #if NOT_YET_UNDO_FREE_EXTENT
 	Uint32 sz= sizeof(Disk_undo::FreeExtent) >> 2;
-	int r0 = c_lgman->alloc_log_space(fragPtr.p->m_logfile_group_id, sz);
+	(void) c_lgman->alloc_log_space(fragPtr.p->m_logfile_group_id, sz);
 	
 	Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
 	

--- 1.32/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp	2006-12-27 11:58:04 +02:00
+++ 1.33/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp	2007-02-23 13:13:51 +02:00
@@ -341,7 +341,6 @@
     Uint32 maxIndexBuf = indexBuf + (dstLen >> 2);
     if (maxIndexBuf <= maxRead && ok) {
       ljam();
-      const char* ssrcPtr = (const char*)srcPtr;
       int n = NdbSqlUtil::strnxfrm_bug7284(cs, dstPtr, dstLen, srcPtr + lb, len);
       ndbrequire(n != -1);
       int m = n;
@@ -510,7 +509,6 @@
     Uint32 maxIndexBuf = index_buf + (dstLen >> 2);
     if (maxIndexBuf <= max_read && ok) {
       ljam();
-      const char* ssrcPtr = (const char*)srcPtr;
       int n = NdbSqlUtil::strnxfrm_bug7284(cs, dstPtr, dstLen, srcPtr + lb, len);
       ndbrequire(n != -1);
       int m = n;
@@ -618,7 +616,6 @@
     Uint32 maxIndexBuf = indexBuf + (dstLen >> 2);
     if (maxIndexBuf <= maxRead && ok) {
       ljam();
-      const char* ssrcPtr = (const char*)srcPtr;
       int n = NdbSqlUtil::strnxfrm_bug7284(cs, dstPtr, dstLen, srcPtr + lb, len);
       ndbrequire(n != -1);
       int m = n;
@@ -1025,7 +1022,7 @@
                             Uint32 attr_des2)
 {
   Uint32 attr_descriptor, index_buf, in_buf_len, var_index, null_ind;
-  Uint32 vsize_in_bytes, vsize_in_words, new_index, max_var_size;
+  Uint32 vsize_in_words, new_index, max_var_size;
   Uint32 var_attr_pos;
   char *var_data_start;
   Uint16 *vpos_array;
@@ -1445,7 +1442,7 @@
                             Uint32 attr_des2)
 {
   Uint32 attr_descriptor, index_buf, in_buf_len, var_index, null_ind;
-  Uint32 vsize_in_bytes, vsize_in_words, new_index, max_var_size;
+  Uint32 vsize_in_words, new_index, max_var_size;
   Uint32 var_attr_pos;
   char *var_data_start;
   Uint16 *vpos_array;

--- 1.9/BitKeeper/deleted/.del-DbtupSystemRestart.cpp~15b54d7e4e75d2d	2006-12-23 21:19:40 +02:00
+++ 1.10/BitKeeper/deleted/.del-DbtupSystemRestart.cpp~15b54d7e4e75d2d	2007-02-23 13:13:46 +02:00
@@ -92,8 +92,6 @@
   seizeDiskBufferSegmentRecord(dbsiPtr);
   riPtr.p->sriDataBufferSegmentP = dbsiPtr.i;
   Uint32 retPageRef = RNIL;
-  Uint32 noAllocPages = 1;
-  Uint32 noOfPagesAllocated;
   {
     /**
      * Use low pages for 0-pages during SR

--- 1.28/storage/ndb/src/mgmclient/main.cpp	2006-12-23 21:20:21 +02:00
+++ 1.29/storage/ndb/src/mgmclient/main.cpp	2007-02-23 13:13:51 +02:00
@@ -128,8 +128,6 @@
 
 int main(int argc, char** argv){
   NDB_INIT(argv[0]);
-  const char *_host = 0;
-  int _port = 0;
 
   load_defaults("my",load_default_groups,&argc,&argv);
   int ho_error;

--- 1.81/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2007-02-06 10:02:36 +02:00
+++ 1.82/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2007-02-23 13:13:51 +02:00
@@ -1586,7 +1586,7 @@
       ndbout_c(" moved %ld rows -> %ld", (long) bucket->m_data.m_count,
 	       (long) m_complete_data.m_data.m_count);
 #else
-      ndbout_c("");
+      ndbout_c(" ");
 #endif
     }
     bzero(bucket, sizeof(Gci_container));

--- 1.27/storage/ndb/src/ndbapi/NdbOperationExec.cpp	2007-02-05 07:51:32 +02:00
+++ 1.28/storage/ndb/src/ndbapi/NdbOperationExec.cpp	2007-02-23 13:13:51 +02:00
@@ -200,14 +200,14 @@
 
   OperationType tOperationType = theOperationType;
   Uint32 tTupKeyLen = theTupKeyLen;
-  Uint8 abortOption = (ao == DefaultAbortOption) ? m_abortOption : ao;
+  Uint8 abortOption = (ao == DefaultAbortOption) ? (Uint8) m_abortOption : (Uint8) ao;
 
   tcKeyReq->setDirtyFlag(tReqInfo, tDirtyIndicator);
   tcKeyReq->setOperationType(tReqInfo, tOperationType);
   tcKeyReq->setKeyLength(tReqInfo, tTupKeyLen);
   
   // A simple read is always ignore error
-  abortOption = tSimpleState ? AO_IgnoreError : abortOption;
+  abortOption = tSimpleState ? (Uint8) AO_IgnoreError : (Uint8) abortOption;
   tcKeyReq->setAbortOption(tReqInfo, abortOption);
   m_abortOption = abortOption;
   

--- 1.411/sql/ha_ndbcluster.cc	2007-02-14 10:29:13 +02:00
+++ 1.412/sql/ha_ndbcluster.cc	2007-02-23 13:13:48 +02:00
@@ -2820,7 +2820,7 @@
 
 int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
 {
-  THD *thd= current_thd;
+  THD *thd= table->in_use;
   NdbTransaction *trans= m_active_trans;
   NdbScanOperation* cursor= m_active_cursor;
   NdbOperation *op;
@@ -3007,7 +3007,7 @@
 
 int ha_ndbcluster::delete_row(const byte *record)
 {
-  THD *thd= current_thd;
+  THD *thd= table->in_use;
   NdbTransaction *trans= m_active_trans;
   NdbScanOperation* cursor= m_active_cursor;
   NdbOperation *op;
@@ -6016,7 +6016,7 @@
 int ha_ndbcluster::close(void)
 {
   DBUG_ENTER("close");
-  THD *thd= current_thd;
+  THD *thd= table->in_use;
   Ndb *ndb= thd ? check_ndb_in_thd(thd) : g_ndb;
   /* ndb_share reference handler free */
   DBUG_PRINT("NDB_SHARE", ("%s handler free  use_count: %u",

--- 1.45/libmysql/libmysql.def	2006-04-30 23:13:53 +03:00
+++ 1.46/libmysql/libmysql.def	2007-02-23 13:13:47 +02:00
@@ -1,5 +1,4 @@
 LIBRARY		LIBMYSQL
-DESCRIPTION	'MySQL 5.0 Client Library'
 VERSION		6.0
 EXPORTS
 	_dig_vec_lower

--- 1.5/BUILD/compile-solaris-sparc-debug	2006-09-14 08:01:56 +03:00
+++ 1.6/BUILD/compile-solaris-sparc-debug	2007-02-23 13:13:46 +02:00
@@ -1,7 +1,11 @@
-#!/usr/bin/bash
+#!/bin/sh
+
+make -k clean || true
+/bin/rm -f */.deps/*.P config.cache
+ 
 path=`dirname $0`
-. "$path/SETUP.sh"
-extra_flags="$debug_cflags"
-extra_configs="$debug_configs $max_configs"
+. "$path/autorun.sh"
+ 
+CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa" CXX=gcc CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa -g" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug
 
-. "$path/FINISH.sh"
+make -j 4

--- 1.5/BUILD/compile-solaris-sparc-forte	2005-05-18 23:26:19 +03:00
+++ 1.6/BUILD/compile-solaris-sparc-forte	2007-02-23 13:13:46 +02:00
@@ -1,16 +1,16 @@
 #! /bin/sh
 
-gmake -k clean || true
+# Assume Forte is installed in /opt/SUNWSpro and ld is installed in
+# /usr/ccs/bin
+
+PATH=/opt/SUNWspro/bin/:/usr/ccs/bin:$PATH
+
+make -k clean || true
 /bin/rm -f */.deps/*.P config.cache
  
 path=`dirname $0`
 . "$path/autorun.sh"
 
-
-# Assume Forte is installed in /opt/SUNWSpro
-
-PATH=/opt/SUNWspro/bin/:$PATH
-
 # For "optimal" code for this computer add -fast to EXTRA
 # To compile 64 bit, add -xarch=v9 to EXTRA_64_BIT
 
@@ -27,7 +27,7 @@
 CXX=CC CXXFLAGS="-noex $STD" \
 ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client
 
-gmake -j 4
+make -j 4
 if [ $? = 0 ]
 then
   make test

--- 1.42/storage/innobase/dict/dict0crea.c	2006-11-09 06:23:53 +02:00
+++ 1.43/storage/innobase/dict/dict0crea.c	2007-02-23 13:13:50 +02:00
@@ -255,7 +255,7 @@
 		error = fil_create_new_single_table_tablespace(
 			&space, path_or_name, is_path,
 			FIL_IBD_FILE_INITIAL_SIZE);
-		table->space = space;
+		table->space = (unsigned int) space;
 
 		if (error != DB_SUCCESS) {
 
@@ -806,7 +806,7 @@
 
 	root_page_no = btr_create(type, space, index_id, comp, mtr);
 	if (index) {
-		index->page = root_page_no;
+		index->page = (unsigned int) root_page_no;
 	} else {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,

--- 1.100/storage/innobase/dict/dict0dict.c	2007-01-22 05:30:40 +02:00
+++ 1.101/storage/innobase/dict/dict0dict.c	2007-02-23 13:13:50 +02:00
@@ -1415,7 +1415,7 @@
 		dict_index_get_nth_field(new_index, i)->col->ord_part = 1;
 	}
 
-	new_index->page = page_no;
+	new_index->page = (unsigned int) page_no;
 	rw_lock_create(&new_index->lock, SYNC_INDEX_TREE);
 
 	if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) {
@@ -1531,10 +1531,10 @@
 	field = dict_index_get_nth_field(index, index->n_def - 1);
 
 	field->col = col;
-	field->fixed_len = dict_col_get_fixed_size(col);
+	field->fixed_len = (unsigned int) dict_col_get_fixed_size(col);
 
 	if (prefix_len && field->fixed_len > prefix_len) {
-		field->fixed_len = prefix_len;
+		field->fixed_len = (unsigned int) prefix_len;
 	}
 
 	/* Long fixed-length fields that need external storage are treated as
@@ -1736,7 +1736,7 @@
 				break;
 			}
 
-			new_index->trx_id_offset += fixed_size;
+			new_index->trx_id_offset += (unsigned int) fixed_size;
 		}
 
 	}
@@ -3045,7 +3045,7 @@
 	foreign->foreign_table_name = mem_heap_strdup(foreign->heap,
 						      table->name);
 	foreign->foreign_index = index;
-	foreign->n_fields = i;
+	foreign->n_fields = (unsigned int) i;
 	foreign->foreign_col_names = mem_heap_alloc(foreign->heap,
 						    i * sizeof(void*));
 	for (i = 0; i < foreign->n_fields; i++) {

--- 1.53/storage/innobase/dict/dict0load.c	2007-01-22 03:18:09 +02:00
+++ 1.54/storage/innobase/dict/dict0load.c	2007-02-23 13:13:50 +02:00
@@ -843,7 +843,7 @@
 	table = dict_mem_table_create(name, space, n_cols & ~0x80000000UL,
 				      flags);
 
-	table->ibd_file_missing = ibd_file_missing;
+	table->ibd_file_missing = (unsigned int) ibd_file_missing;
 
 	ut_a(name_of_col_is(sys_tables, sys_index, 3, "ID"));
 
@@ -1180,8 +1180,8 @@
 
 	/* We store the type in the bits 24..29 of n_fields_and_type. */
 
-	foreign->type = n_fields_and_type >> 24;
-	foreign->n_fields = n_fields_and_type & 0x3FFUL;
+	foreign->type = (unsigned int) (n_fields_and_type >> 24);
+	foreign->n_fields = (unsigned int) (n_fields_and_type & 0x3FFUL);
 
 	foreign->id = mem_heap_strdup(foreign->heap, id);
 

--- 1.24/storage/innobase/dict/dict0mem.c	2006-09-21 10:38:40 +03:00
+++ 1.25/storage/innobase/dict/dict0mem.c	2007-02-23 13:13:50 +02:00
@@ -50,14 +50,14 @@
 
 	table->heap = heap;
 
-	table->flags = flags;
+	table->flags = (unsigned int) flags;
 	table->name = mem_heap_strdup(heap, name);
 	table->dir_path_of_temp_table = NULL;
-	table->space = space;
+	table->space = (unsigned int) space;
 	table->ibd_file_missing = FALSE;
 	table->tablespace_discarded = FALSE;
 	table->n_def = 0;
-	table->n_cols = n_cols + DATA_N_SYS_COLS;
+	table->n_cols = (unsigned int) (n_cols + DATA_N_SYS_COLS);
 
 	table->n_mysql_handles_opened = 0;
 	table->n_foreign_key_checks_running = 0;
@@ -208,14 +208,14 @@
 	col->ind = table->n_def - 1;
 	col->ord_part = 0;
 
-	col->mtype = mtype;
-	col->prtype = prtype;
-	col->len = len;
+	col->mtype = (unsigned int) mtype;
+	col->prtype = (unsigned int) prtype;
+	col->len = (unsigned int) len;
 
 	dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
 
-	col->mbminlen = mbminlen;
-	col->mbmaxlen = mbmaxlen;
+	col->mbminlen = (unsigned int) mbminlen;
+	col->mbmaxlen = (unsigned int) mbmaxlen;
 }
 
 /**************************************************************************
@@ -245,13 +245,13 @@
 	index->heap = heap;
 
 	index->type = type;
-	index->space = space;
+	index->space = (unsigned int) space;
 	index->page = 0;
 	index->name = mem_heap_strdup(heap, index_name);
 	index->table_name = table_name;
 	index->table = NULL;
 	index->n_def = index->n_nullable = 0;
-	index->n_fields = n_fields;
+	index->n_fields = (unsigned int) n_fields;
 	index->fields = mem_heap_alloc(heap, 1 + n_fields
 				       * sizeof(dict_field_t));
 	/* The '1 +' above prevents allocation
@@ -326,7 +326,7 @@
 	field = dict_index_get_nth_field(index, index->n_def - 1);
 
 	field->name = name;
-	field->prefix_len = prefix_len;
+	field->prefix_len = (unsigned int) prefix_len;
 }
 
 /**************************************************************************

--- 1.7/storage/innobase/eval/eval0proc.c	2006-09-21 10:38:40 +03:00
+++ 1.8/storage/innobase/eval/eval0proc.c	2007-02-23 13:13:50 +02:00
@@ -194,7 +194,7 @@
 		loop_var_value = eval_node_get_int_val(node->loop_start_limit);
 
 		node->loop_end_value
-			= eval_node_get_int_val(node->loop_end_limit);
+                  = (int) eval_node_get_int_val(node->loop_end_limit);
 	}
 
 	/* Check if we should do another loop */

--- 1.7/storage/innobase/include/ut0byte.ic	2006-09-05 02:16:16 +03:00
+++ 1.8/storage/innobase/include/ut0byte.ic	2007-02-23 13:13:50 +02:00
@@ -390,8 +390,8 @@
 # error "TRUE != 1"
 #endif
 	if (val) {
-		return((1 << n) | a);
+		return(((ulint) 1 << n) | a);
 	} else {
-		return(~(1 << n) & a);
+		return(~((ulint) 1 << n) & a);
 	}
 }

--- 1.5/storage/innobase/include/ut0ut.ic	2006-03-10 18:22:09 +02:00
+++ 1.6/storage/innobase/include/ut0ut.ic	2007-02-23 13:13:50 +02:00
@@ -170,5 +170,5 @@
 			/* out: 2 to power n */
 	ulint	n)	/* in: number */
 {
-	return(1 << n);
+	return((ulint) 1 << n);
 }

--- 1.15/storage/innobase/mtr/mtr0log.c	2006-09-21 10:38:50 +03:00
+++ 1.16/storage/innobase/mtr/mtr0log.c	2007-02-23 13:13:50 +02:00
@@ -529,7 +529,7 @@
 	ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY",
 				    DICT_HDR_SPACE, 0, n);
 	ind->table = table;
-	ind->n_uniq = n_uniq;
+	ind->n_uniq = (unsigned int) n_uniq;
 	if (n_uniq != n) {
 		ind->type = DICT_CLUSTERED;
 	}

--- 1.14/storage/innobase/pars/pars0lex.l	2006-07-26 12:28:43 +03:00
+++ 1.15/storage/innobase/pars/pars0lex.l	2007-02-23 13:13:50 +02:00
@@ -109,7 +109,7 @@
 			yylval = sym_tab_add_bound_lit(pars_sym_tab_global,
 				yytext + 1, &type);
 
-			return(type);
+			return((int) type);
 }
 
 {BOUND_ID}	{

--- 1.34/storage/innobase/rem/rem0cmp.c	2006-09-21 10:38:52 +03:00
+++ 1.35/storage/innobase/rem/rem0cmp.c	2007-02-23 13:13:50 +02:00
@@ -597,7 +597,7 @@
 				dtuple_byte = cmp_collate(dtuple_byte);
 			}
 
-			ret = dtuple_byte - rec_byte;
+			ret = (int) (dtuple_byte - rec_byte);
 			if (UNIV_UNLIKELY(ret)) {
 				if (ret < 0) {
 					ret = -1;

--- 1.138/storage/innobase/row/row0mysql.c	2006-12-21 00:46:32 +02:00
+++ 1.139/storage/innobase/row/row0mysql.c	2007-02-23 13:13:50 +02:00
@@ -3423,7 +3423,7 @@
 
 	pars_info_add_str_literal(info, "id", id);
 
-	return(que_eval_sql(info,
+	return((int) que_eval_sql(info,
 			    "PROCEDURE DELETE_CONSTRAINT () IS\n"
 			    "BEGIN\n"
 			    "DELETE FROM SYS_FOREIGN_COLS WHERE ID = :id;\n"
@@ -3462,7 +3462,7 @@
 		err = row_delete_constraint_low(id, trx);
 	}
 
-	return(err);
+	return((int) err);
 }
 
 /*************************************************************************

--- 1.115/storage/innobase/row/row0sel.c	2007-01-05 04:51:30 +02:00
+++ 1.116/storage/innobase/row/row0sel.c	2007-02-23 13:13:50 +02:00
@@ -2116,7 +2116,7 @@
 	ut_a(len == 4);
 
 	tmp = mach_read_from_4(dfield_get_data(dfield));
-	*val = tmp;
+	*val = (ib_uint32_t) tmp;
 
 	return(NULL);
 }

--- 1.30/storage/innobase/sync/sync0rw.c	2007-01-18 02:18:03 +02:00
+++ 1.31/storage/innobase/sync/sync0rw.c	2007-02-23 13:13:50 +02:00
@@ -127,7 +127,7 @@
 	lock->magic_n = RW_LOCK_MAGIC_N;
 
 	lock->cfile_name = cfile_name;
-	lock->cline = cline;
+	lock->cline = (unsigned int) cline;
 
 	lock->last_s_file_name = "not yet reserved";
 	lock->last_x_file_name = "not yet reserved";
@@ -356,7 +356,7 @@
 					       file_name, line);
 #endif
 			lock->last_x_file_name = file_name;
-			lock->last_x_line = line;
+			lock->last_x_line = (unsigned int) line;
 
 			/* Locking succeeded, we may return */
 			return(RW_LOCK_EX);
@@ -393,7 +393,7 @@
 #endif
 
 			lock->last_x_file_name = file_name;
-			lock->last_x_line = line;
+			lock->last_x_line = (unsigned int) line;
 
 			/* Locking succeeded, we may return */
 			return(RW_LOCK_EX);
@@ -415,7 +415,7 @@
 #endif
 
 		lock->last_x_file_name = file_name;
-		lock->last_x_line = line;
+		lock->last_x_line = (unsigned int) line;
 
 		/* Locking succeeded, we may return */
 		return(RW_LOCK_EX);

--- 1.70/storage/innobase/trx/trx0trx.c	2007-01-05 04:51:30 +02:00
+++ 1.71/storage/innobase/trx/trx0trx.c	2007-02-23 13:13:50 +02:00
@@ -2023,7 +2023,7 @@
 			(ulong) count);
 	}
 
-	return (count);
+	return ((int) count);
 }
 
 /***********************************************************************

--- 1.9/mysql-test/r/keywords.result	2007-02-09 01:13:51 +02:00
+++ 1.10/mysql-test/r/keywords.result	2007-02-23 13:13:47 +02:00
@@ -16,19 +16,6 @@
 binlog
 1
 drop table events;
-create table t1 (connection int, b int);
-create procedure p1()
-begin
-declare connection int;
-select max(t1.connection) into connection from t1;
-select concat("max=",connection) 'p1';
-end|
-insert into t1 (connection) values (1);
-call p1();
-p1
-max=1
-drop procedure p1;
-drop table t1;
 create procedure p1()
 begin
 declare n int default 2;
@@ -45,3 +32,16 @@
 end|
 drop procedure p1;
 drop procedure p2;
+create table t1 (connection int, b int);
+create procedure p1()
+begin
+declare connection int;
+select max(t1.connection) into connection from t1;
+select concat("max=",connection) 'p1';
+end|
+insert into t1 (connection) values (1);
+call p1();
+p1
+max=1
+drop procedure p1;
+drop table t1;

--- 1.9/mysql-test/t/keywords.test	2007-02-09 01:13:51 +02:00
+++ 1.10/mysql-test/t/keywords.test	2007-02-23 13:13:47 +02:00
@@ -20,28 +20,6 @@
 
 # End of 4.1 tests
 
-
-#
-# Bug#12204 - CONNECTION should not be a reserved word
-#
-
-create table t1 (connection int, b int);
-delimiter |;
-create procedure p1()
-begin
-  declare connection int;
-  select max(t1.connection) into connection from t1;
-  select concat("max=",connection) 'p1';
-end|
-delimiter ;|
-insert into t1 (connection) values (1);
-call p1();
-drop procedure p1;
-drop table t1;
-
-
-# End of 5.0 tests
-
 #
 # Bug#19939 "AUTHORS is not a keyword"
 #
@@ -65,3 +43,24 @@
 drop procedure p2;
 
 # End of 5.1 tests
+
+#
+# Bug#12204 - CONNECTION should not be a reserved word
+#
+
+create table t1 (connection int, b int);
+delimiter |;
+create procedure p1()
+begin
+  declare connection int;
+  select max(t1.connection) into connection from t1;
+  select concat("max=",connection) 'p1';
+end|
+delimiter ;|
+insert into t1 (connection) values (1);
+call p1();
+drop procedure p1;
+drop table t1;
+
+
+# End of 5.0 tests

--- 1.320/storage/innobase/handler/ha_innodb.cc	2007-01-15 11:39:27 +02:00
+++ 1.321/storage/innobase/handler/ha_innodb.cc	2007-02-23 13:13:50 +02:00
@@ -695,7 +695,7 @@
 	uint	errors;
 
 	strconvert(current_thd->charset(), from,
-		   &my_charset_filename, to, len, &errors);
+		   &my_charset_filename, to, (uint) len, &errors);
 }
 
 /**********************************************************************
@@ -714,7 +714,7 @@
 	uint	errors;
 
 	strconvert(current_thd->charset(), from,
-		   system_charset_info, to, len, &errors);
+		   system_charset_info, to, (uint) len, &errors);
 }
 
 /**********************************************************************
@@ -839,8 +839,9 @@
 	CHARSET_INFO*	from_cs,
 	uint*		errors)
 {
-	return(copy_and_convert((char*)to, to_length, to_cs,
-		       (const char*)from, from_length, from_cs, errors));
+  return(copy_and_convert((char*)to, (uint32) to_length, to_cs,
+                          (const char*)from, (uint32) from_length, from_cs,
+                          errors));
 }
 
 /*************************************************************************
@@ -1203,9 +1204,9 @@
 		output strings buffers must not be shared.  The function
 		only produces more output when the name contains other
 		characters than [0-9A-Z_a-z]. */
-		char*	temp_name = my_malloc(namelen + 1, MYF(MY_WME));
-		uint	qnamelen = namelen
-				+ (1 + sizeof srv_mysql50_table_name_prefix);
+          char*	temp_name = my_malloc((uint) namelen + 1, MYF(MY_WME));
+          uint	qnamelen = (uint) (namelen
+                                   + (1 + sizeof srv_mysql50_table_name_prefix));
 
 		if (temp_name) {
 			qname = my_malloc(qnamelen, MYF(MY_WME));
@@ -2866,7 +2867,8 @@
 				true_len = (ulint) cs->cset->well_formed_len(cs,
 						(const char *) data,
 						(const char *) data + len,
-						key_len / cs->mbmaxlen,
+                                                (uint) (key_len /
+                                                        cs->mbmaxlen),
 						&error);
 			}
 
@@ -2935,7 +2937,8 @@
 						(const char *) blob_data,
 						(const char *) blob_data
 							+ blob_len,
-						key_len / cs->mbmaxlen,
+                                                (uint) (key_len /
+                                                        cs->mbmaxlen),
 						&error);
 			}
 
@@ -3007,7 +3010,8 @@
 							(const char *)src_start,
 							(const char *)src_start
 								+ key_len,
-							key_len / cs->mbmaxlen,
+                                                        (uint) (key_len /
+                                                                cs->mbmaxlen),
 							&error);
 				}
 			}

--- 1.157/include/my_global.h	2007-02-05 13:29:22 +02:00
+++ 1.158/include/my_global.h	2007-02-23 13:13:47 +02:00
@@ -932,7 +932,6 @@
 #define my_offsetof(TYPE, MEMBER) \
         ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
 
-
 #define NullS		(char *) 0
 /* Nowdays we do not support MessyDos */
 #ifndef NEAR
@@ -1171,7 +1170,7 @@
 */
 #define uint3korr(A)	(long) (*((unsigned int *) (A)) & 0xFFFFFF)
 #endif
-#define uint4korr(A)	(*((unsigned long *) (A)))
+#define uint4korr(A)	(*((uint32 *) (A)))
 #define uint5korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
 				    (((uint32) ((uchar) (A)[1])) << 8) +\
 				    (((uint32) ((uchar) (A)[2])) << 16) +\
@@ -1285,17 +1284,19 @@
                                   *(((char *)(T))+1)=(char) (((A) >> 8));\
                                   *(((char *)(T))+2)=(char) (((A) >> 16));\
                                   *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
-#define int5store(T,A)       do { *((char *)(T))=((A));\
-                                  *(((char *)(T))+1)=(((A) >> 8));\
-                                  *(((char *)(T))+2)=(((A) >> 16));\
-                                  *(((char *)(T))+3)=(((A) >> 24)); \
-                                  *(((char *)(T))+4)=(((A) >> 32)); } while(0)
-#define int6store(T,A)       do { *((char *)(T))=((A));\
-                                  *(((char *)(T))+1)=(((A) >> 8));  \
-                                  *(((char *)(T))+2)=(((A) >> 16)); \
-                                  *(((char *)(T))+3)=(((A) >> 24)); \
-                                  *(((char *)(T))+4)=(((A) >> 32)); \
-                                  *(((char *)(T))+5)=(((A) >> 40)); } while(0)
+#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
+                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
+                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
+                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
+                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
+		                } while(0)
+#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
+                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
+                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
+                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
+                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
+                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
+                                } while(0)
 #define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
                                   int4store((T),def_temp); \
                                   int4store((T+4),def_temp2); } while(0)

--- 1.215/sql/set_var.cc	2007-02-06 16:52:25 +02:00
+++ 1.216/sql/set_var.cc	2007-02-23 13:13:49 +02:00
@@ -396,6 +396,10 @@
 sys_var_thd_ulong	sys_trans_prealloc_size("transaction_prealloc_size",
 						&SV::trans_prealloc_size,
 						0, fix_trans_mem_root);
+sys_var_thd_enum        sys_thread_handling("thread_handling",
+                                            &SV::thread_handling,
+                                            &thread_handling_typelib,
+                                            NULL);
 
 #ifdef HAVE_QUERY_CACHE
 sys_var_long_ptr	sys_query_cache_limit("query_cache_limit",
@@ -464,6 +468,10 @@
                                                     &table_lock_wait_timeout);
 sys_var_long_ptr	sys_thread_cache_size("thread_cache_size",
 					      &thread_cache_size);
+#if HAVE_POOL_OF_THREADS == 1
+sys_var_long_ptr	sys_thread_pool_size("thread_pool_size",
+					      &thread_pool_size);
+#endif
 sys_var_thd_enum	sys_tx_isolation("tx_isolation",
 					 &SV::tx_isolation,
 					 &tx_isolation_typelib,
@@ -1007,6 +1015,10 @@
 #ifdef HAVE_THR_SETCONCURRENCY
   {"thread_concurrency",      (char*) &concurrency,                 SHOW_LONG},
 #endif
+  {sys_thread_handling.name,  (char*) &sys_thread_handling,         SHOW_SYS},
+#if HAVE_POOL_OF_THREADS == 1
+  {sys_thread_pool_size.name, (char*) &sys_thread_pool_size,        SHOW_SYS},
+#endif
   {"thread_stack",            (char*) &thread_stack,                SHOW_LONG},
   {sys_time_format.name,      (char*) &sys_time_format,		    SHOW_SYS},
   {"time_zone",               (char*) &sys_time_zone,               SHOW_SYS},
@@ -2587,7 +2599,7 @@
     file_log= logger.get_log_file_handler();
     break;
   default:
-    DBUG_ASSERT(0);
+    assert(0);                                  // Impossible
   }
 
   if (!old_value)
@@ -3626,7 +3638,7 @@
 */
 
 byte *sys_var_thd_sql_mode::symbolic_mode_representation(THD *thd,
-                                                         ulong val,
+                                                         ulonglong val,
                                                          ulong *len)
 {
   char buff[256];
@@ -4002,7 +4014,7 @@
     res= Events::get_instance()->stop_execution_of_events();
   else
   {
-    DBUG_ASSERT(0);
+    assert(0);                                  // Impossible
   }
   if (res)
     my_error(ER_EVENT_SET_VAR_ERROR, MYF(0));

--- 1.100/sql/set_var.h	2007-02-06 16:12:12 +02:00
+++ 1.101/sql/set_var.h	2007-02-23 13:13:49 +02:00
@@ -440,7 +440,7 @@
   }
   void set_default(THD *thd, enum_var_type type);
   byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-  static byte *symbolic_mode_representation(THD *thd, ulong sql_mode,
+  static byte *symbolic_mode_representation(THD *thd, ulonglong sql_mode,
                                             ulong *length);
 };
 
--- New file ---
+++ BUILD/compile-pentium64-max	07/02/23 13:13:52
#! /bin/sh

path=`dirname $0`
. "$path/SETUP.sh" $@

extra_flags="$pentium64_cflags $fast_cflags"
extra_configs="$pentium_configs $max_configs $static_link"
CC="$CC --pipe"
strip=yes

. "$path/FINISH.sh"

--- New file ---
+++ libmysqld/scheduler.cc	07/02/23 13:13:52
SYMLINK -> ../sql/scheduler.cc

--- New file ---
+++ libmysqld/sql_connect.cc	07/02/23 13:13:52
SYMLINK -> ../sql/sql_connect.cc

--- New file ---
+++ mysql-test/include/one_thread_per_connection.inc	07/02/23 13:13:52
-- require r/one_thread_per_connection.require
disable_query_log;
select @@thread_handling;
enable_query_log;


--- New file ---
+++ mysql-test/r/no-threads.result	07/02/23 13:13:52
select 1+1;
1+1
2
select 1+2;
1+2
3

--- New file ---
+++ mysql-test/r/one_thread_per_connection.require	07/02/23 13:13:52
@@thread_handling
one-thread-per-connection

--- New file ---
+++ mysql-test/t/no-threads-master.opt	07/02/23 13:13:52
--one-thread --thread-handling=no-threads

--- New file ---
+++ mysql-test/t/no-threads.test	07/02/23 13:13:52
#
# Test the --thread-handler=no-threads option
#
select 1+1;
select 1+2;


--- 1.1/sql-bench/example	2007-01-22 18:42:50 +02:00
+++ 1.2/sql-bench/example	2007-02-23 13:13:50 +02:00
@@ -1,3 +1,20 @@
 #/bin/sh
-run-all-tests --prefix=-innodb --hw="AMD Athlon 4000+; 2400 MHz 1M cache, 3G memory" --optimization="gcc 4.0.2 -O3" --comments="Engine=InnoDB" --create-options="ENGINE=InnoDB"
 
+hw="2xPentium(R) 3.2 GHz, 1M cache, 4G memory"
+optimization="gcc 4.1.2 -m64 -O3 --static"
+machine="Linux-x64"
+
+# InnoDB tests
+
+./run-all-tests --suffix=-innodb --comments="Engine=InnoDB --innodb_log_file_size=100M" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --log
+
+./run-all-tests --suffix=_fast-innodb --comments="Engine=InnoDB --innodb_log_file_size=100M" --create-options="ENGINE=InnoDB" --hw="$hw" --optimization="$optimization" --machine="$machine" --fast --log
+
+
+# MyISAM tests
+
+./run-all-tests --suffix=-myisam --comments="Engine=MyISAM key_buffer_size=16M" --create-options="ENGINE=myisam" --hw="$hw" --optimization="$optimization" --machine="$machine" --log
+
+./run-all-tests --suffix=_fast-myisam --comments="Engine=MyISAM key_buffer_size=16M" --create-options="ENGINE=myisam" --hw="$hw" --optimization="$optimization" --machine="$machine" --fast --log
+
+compare-results --relative output/RUN-mysql-myisam-* output/RUN-mysql_fast-myisam* output/RUN-mysql*
--- New file ---
+++ sql/scheduler.cc	07/02/23 13:13:52
/* Copyright (C) 2007 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/*
  Implementation for the thread scheduler
*/

#ifdef USE_PRAGMA_INTERFACE
#pragma implementation
#endif

#include <mysql_priv.h>

/*
  'Dummy' functions to be used when we don't need any handling for a scheduler
  event
 */

static bool init_dummy(void) {return 0;}
static void post_kill_dummy(THD* thd) {}  
static void end_dummy(void) {}
static bool end_thread_dummy(THD *thd, bool cache_thread) { return 0; }

/*
  Initialize default scheduler with dummy functions so that setup functions
  only need to declare those that are relvant for their usage
*/

scheduler_functions::scheduler_functions()
  :init(init_dummy),
   init_new_connection_thread(init_new_connection_handler_thread),
   add_connection(0),                           // Must be defined
   post_kill_notification(post_kill_dummy),
   end_thread(end_thread_dummy), end(end_dummy)
{}


/*
  End connection, in case when we are using 'no-threads'
*/

static bool no_threads_end(THD *thd, bool put_in_cache)
{
  unlink_thd(thd);
  pthread_mutex_unlock(&LOCK_thread_count);
  return 1;                                     // Abort handle_one_connection
}


/*
  Initailize scheduler for --thread-handling=no-threads
*/

void one_thread_scheduler(scheduler_functions* func)
{
  func->max_threads= 1;
#ifndef EMBEDDED_LIBRARY
  func->add_connection= handle_connection_in_main_thread;
#endif
  func->init_new_connection_thread= init_dummy;
  func->end_thread= no_threads_end;
}


/*
  Initialize scheduler for --thread-handling=one-thread-per-connection
*/

#ifndef EMBEDDED_LIBRARY
void one_thread_per_connection_scheduler(scheduler_functions* func)
{
  func->max_threads= max_connections;
  func->add_connection= create_thread_to_handle_connection;
  func->end_thread= one_thread_per_connection_end;
}
#endif /* EMBEDDED_LIBRARY */

--- New file ---
+++ sql/scheduler.h	07/02/23 13:13:52
/* Copyright (C) 2007 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/*
  Classes for the thread scheduler
*/

#ifdef USE_PRAGMA_INTERFACE
#pragma interface
#endif

class THD;

/* Functions used when manipulating threads */

class scheduler_functions
{
public:
  uint max_threads;
  bool (*init)(void);
  bool (*init_new_connection_thread)(void);
  void (*add_connection)(THD *thd);
  void (*post_kill_notification)(THD *thd);
  bool (*end_thread)(THD *thd, bool cache_thread);
  void (*end)(void);
  scheduler_functions();
};

enum scheduler_types
{
  SCHEDULER_ONE_THREAD_PER_CONNECTION=1,
  SCHEDULER_NO_THREADS,
  SCHEDULER_POOL_OF_THREADS
};

void one_thread_per_connection_scheduler(scheduler_functions* func);
void one_thread_scheduler(scheduler_functions* func);

enum pool_command_op
{
  NOT_IN_USE_OP= 0, NORMAL_OP= 1, CONNECT_OP, KILL_OP, DIE_OP
};

#define HAVE_POOL_OF_THREADS 0                  /* For easyer tests */
#define pool_of_threads_scheduler(A) one_thread_per_connection_scheduler(A)

class thd_scheduler
{};

--- New file ---
+++ sql/sql_connect.cc	07/02/23 13:13:52
/* Copyright (C) 2007 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */


/*
  Functions to autenticate and handle reqests for a connection
*/

#include "mysql_priv.h"

#ifdef HAVE_OPENSSL
/*
  Without SSL the handshake consists of one packet. This packet
  has both client capabilites and scrambled password.
  With SSL the handshake might consist of two packets. If the first
  packet (client capabilities) has CLIENT_SSL flag set, we have to
  switch to SSL and read the second packet. The scrambled password
  is in the second packet and client_capabilites field will be ignored.
  Maybe it is better to accept flags other than CLIENT_SSL from the
  second packet?
*/
#define SSL_HANDSHAKE_SIZE      2
#define NORMAL_HANDSHAKE_SIZE   6
#define MIN_HANDSHAKE_SIZE      2
#else
#define MIN_HANDSHAKE_SIZE      6
#endif /* HAVE_OPENSSL */

#ifdef __WIN__
static void  test_signal(int sig_ptr)
{
#if !defined( DBUG_OFF)
  MessageBox(NULL,"Test signal","DBUG",MB_OK);
#endif
#if defined(OS2)
  fprintf(stderr, "Test signal %d\n", sig_ptr);
  fflush(stderr);
#endif
}
static void init_signals(void)
{
  int signals[7] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGBREAK,SIGABRT } ;
  for (int i=0 ; i < 7 ; i++)
    signal( signals[i], test_signal) ;
}
#endif

/*
  Get structure for logging connection data for the current user
*/

#ifndef NO_EMBEDDED_ACCESS_CHECKS
static HASH hash_user_connections;

static int get_or_create_user_conn(THD *thd, const char *user,
				   const char *host,
				   USER_RESOURCES *mqh)
{
  int return_val= 0;
  uint temp_len, user_len;
  char temp_user[USER_HOST_BUFF_SIZE];
  struct  user_conn *uc;

  DBUG_ASSERT(user != 0);
  DBUG_ASSERT(host != 0);

  user_len= strlen(user);
  temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
  (void) pthread_mutex_lock(&LOCK_user_conn);
  if (!(uc = (struct  user_conn *) hash_search(&hash_user_connections,
					       (byte*) temp_user, temp_len)))
  {
    /* First connection for user; Create a user connection object */
    if (!(uc= ((struct user_conn*)
	       my_malloc(sizeof(struct user_conn) + temp_len+1,
			 MYF(MY_WME)))))
    {
      net_send_error(thd, 0, NullS);		// Out of memory
      return_val= 1;
      goto end;
    }
    uc->user=(char*) (uc+1);
    memcpy(uc->user,temp_user,temp_len+1);
    uc->host= uc->user + user_len +  1;
    uc->len= temp_len;
    uc->connections= uc->questions= uc->updates= uc->conn_per_hour= 0;
    uc->user_resources= *mqh;
    uc->intime= thd->thr_create_time;
    if (my_hash_insert(&hash_user_connections, (byte*) uc))
    {
      my_free((char*) uc,0);
      net_send_error(thd, 0, NullS);		// Out of memory
      return_val= 1;
      goto end;
    }
  }
  thd->user_connect=uc;
  uc->connections++;
end:
  (void) pthread_mutex_unlock(&LOCK_user_conn);
  return return_val;

}


/*
  check if user has already too many connections
  
  SYNOPSIS
  check_for_max_user_connections()
  thd			Thread handle
  uc			User connect object

  NOTES
    If check fails, we decrease user connection count, which means one
    shouldn't call decrease_user_connections() after this function.

  RETURN
    0	ok
    1	error
*/

int check_for_max_user_connections(THD *thd, USER_CONN *uc)
{
  int error=0;
  DBUG_ENTER("check_for_max_user_connections");

  (void) pthread_mutex_lock(&LOCK_user_conn);
  if (max_user_connections && !uc->user_resources.user_conn &&
      max_user_connections < (uint) uc->connections)
  {
    net_printf_error(thd, ER_TOO_MANY_USER_CONNECTIONS, uc->user);
    error=1;
    goto end;
  }
  time_out_user_resource_limits(thd, uc);
  if (uc->user_resources.user_conn &&
      uc->user_resources.user_conn < uc->connections)
  {
    net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user,
                     "max_user_connections",
                     (long) uc->user_resources.user_conn);
    error= 1;
    goto end;
  }
  if (uc->user_resources.conn_per_hour &&
      uc->user_resources.conn_per_hour <= uc->conn_per_hour)
  {
    net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user,
                     "max_connections_per_hour",
                     (long) uc->user_resources.conn_per_hour);
    error=1;
    goto end;
  }
  uc->conn_per_hour++;

  end:
  if (error)
    uc->connections--; // no need for decrease_user_connections() here
  (void) pthread_mutex_unlock(&LOCK_user_conn);
  DBUG_RETURN(error);
}


/*
  Decrease user connection count

  SYNOPSIS
    decrease_user_connections()
    uc			User connection object

  NOTES
    If there is a n user connection object for a connection
    (which only happens if 'max_user_connections' is defined or
    if someone has created a resource grant for a user), then
    the connection count is always incremented on connect.

    The user connect object is not freed if some users has
    'max connections per hour' defined as we need to be able to hold
    count over the lifetime of the connection.
*/

void decrease_user_connections(USER_CONN *uc)
{
  DBUG_ENTER("decrease_user_connections");
  (void) pthread_mutex_lock(&LOCK_user_conn);
  DBUG_ASSERT(uc->connections);
  if (!--uc->connections && !mqh_used)
  {
    /* Last connection for user; Delete it */
    (void) hash_delete(&hash_user_connections,(byte*) uc);
  }
  (void) pthread_mutex_unlock(&LOCK_user_conn);
  DBUG_VOID_RETURN;
}


/*
  Reset per-hour user resource limits when it has been more than
  an hour since they were last checked

  SYNOPSIS:
    time_out_user_resource_limits()
    thd			Thread handler
    uc			User connection details

  NOTE:
    This assumes that the LOCK_user_conn mutex has been acquired, so it is
    safe to test and modify members of the USER_CONN structure.
*/

void time_out_user_resource_limits(THD *thd, USER_CONN *uc)
{
  time_t check_time = thd->start_time ?  thd->start_time : time(NULL);
  DBUG_ENTER("time_out_user_resource_limits");

  /* If more than a hour since last check, reset resource checking */
  if (check_time  - uc->intime >= 3600)
  {
    uc->questions=1;
    uc->updates=0;
    uc->conn_per_hour=0;
    uc->intime=check_time;
  }

  DBUG_VOID_RETURN;
}

/*
  Check if maximum queries per hour limit has been reached
  returns 0 if OK.
*/

bool check_mqh(THD *thd, uint check_command)
{
  bool error= 0;
  USER_CONN *uc=thd->user_connect;
  DBUG_ENTER("check_mqh");
  DBUG_ASSERT(uc != 0);

  (void) pthread_mutex_lock(&LOCK_user_conn);

  time_out_user_resource_limits(thd, uc);

  /* Check that we have not done too many questions / hour */
  if (uc->user_resources.questions &&
      uc->questions++ >= uc->user_resources.questions)
  {
    net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_questions",
                     (long) uc->user_resources.questions);
    error=1;
    goto end;
  }
  if (check_command < (uint) SQLCOM_END)
  {
    /* Check that we have not done too many updates / hour */
    if (uc->user_resources.updates &&
        (sql_command_flags[check_command] & CF_CHANGES_DATA) &&
	uc->updates++ >= uc->user_resources.updates)
    {
      net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_updates",
                       (long) uc->user_resources.updates);
      error=1;
      goto end;
    }
  }
end:
  (void) pthread_mutex_unlock(&LOCK_user_conn);
  DBUG_RETURN(error);
}

#endif /* NO_EMBEDDED_ACCESS_CHECKS */


/*
  Check if user exist and password supplied is correct. 

  SYNOPSIS
    check_user()
    thd          thread handle, thd->security_ctx->{host,user,ip} are used
    command      originator of the check: now check_user is called
                 during connect and change user procedures; used for 
                 logging.
    passwd       scrambled password received from client
    passwd_len   length of scrambled password
    db           database name to connect to, may be NULL
    check_count  dont know exactly

    Note, that host, user and passwd may point to communication buffer.
    Current implementation does not depend on that, but future changes
    should be done with this in mind; 'thd' is INOUT, all other params
    are 'IN'.

  RETURN VALUE
    0  OK; thd->security_ctx->user/master_access/priv_user/db_access and
       thd->db are updated; OK is sent to client;
   -1  access denied or handshake error; error is sent to client;
   >0  error, not sent to client
*/

int check_user(THD *thd, enum enum_server_command command, 
	       const char *passwd, uint passwd_len, const char *db,
	       bool check_count)
{
  DBUG_ENTER("check_user");
  
#ifdef NO_EMBEDDED_ACCESS_CHECKS
  thd->main_security_ctx.master_access= GLOBAL_ACLS;       // Full rights
  /* Change database if necessary */
  if (db && db[0])
  {
    /*
      thd->db is saved in caller and needs to be freed by caller if this
      function returns 0
    */
    thd->reset_db(NULL, 0);
    if (mysql_change_db(thd, db, FALSE))
    {
      /* Send the error to the client */
      net_send_error(thd);
      DBUG_RETURN(-1);
    }
  }
  send_ok(thd);
  DBUG_RETURN(0);
#else

  my_bool opt_secure_auth_local;
  pthread_mutex_lock(&LOCK_global_system_variables);
  opt_secure_auth_local= opt_secure_auth;
  pthread_mutex_unlock(&LOCK_global_system_variables);
  
  /*
    If the server is running in secure auth mode, short scrambles are 
    forbidden.
  */
  if (opt_secure_auth_local && passwd_len == SCRAMBLE_LENGTH_323)
  {
    net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
    general_log_print(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
    DBUG_RETURN(-1);
  }
  if (passwd_len != 0 &&
      passwd_len != SCRAMBLE_LENGTH &&
      passwd_len != SCRAMBLE_LENGTH_323)
    DBUG_RETURN(ER_HANDSHAKE_ERROR);

  /*
    Clear thd->db as it points to something, that will be freed when 
    connection is closed. We don't want to accidentally free a wrong pointer
    if connect failed. Also in case of 'CHANGE USER' failure, current
    database will be switched to 'no database selected'.
  */
  thd->reset_db(NULL, 0);

  USER_RESOURCES ur;
  int res= acl_getroot(thd, &ur, passwd, passwd_len);
#ifndef EMBEDDED_LIBRARY
  if (res == -1)
  {
    /*
      This happens when client (new) sends password scrambled with
      scramble(), but database holds old value (scrambled with
      scramble_323()). Here we please client to send scrambled_password
      in old format.
    */
    NET *net= &thd->net;
    if (opt_secure_auth_local)
    {
      net_printf_error(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE,
                       thd->main_security_ctx.user,
                       thd->main_security_ctx.host_or_ip);
      general_log_print(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE),
                        thd->main_security_ctx.user,
                        thd->main_security_ctx.host_or_ip);
      DBUG_RETURN(-1);
    }
    /* We have to read very specific packet size */
    if (send_old_password_request(thd) ||
        my_net_read(net) != SCRAMBLE_LENGTH_323 + 1)
    {
      inc_host_errors(&thd->remote.sin_addr);
      DBUG_RETURN(ER_HANDSHAKE_ERROR);
    }
    /* Final attempt to check the user based on reply */
    /* So as passwd is short, errcode is always >= 0 */
    res= acl_getroot(thd, &ur, (char *) net->read_pos, SCRAMBLE_LENGTH_323);
  }
#endif /*EMBEDDED_LIBRARY*/
  /* here res is always >= 0 */
  if (res == 0)
  {
    if (!(thd->main_security_ctx.master_access &
          NO_ACCESS)) // authentication is OK
    {
      DBUG_PRINT("info",
                 ("Capabilities: %lu  packet_length: %ld  Host: '%s'  "
                  "Login user: '%s' Priv_user: '%s'  Using password: %s "
                  "Access: %lu  db: '%s'",
                  thd->client_capabilities,
                  thd->max_client_packet_length,
                  thd->main_security_ctx.host_or_ip,
                  thd->main_security_ctx.user,
                  thd->main_security_ctx.priv_user,
                  passwd_len ? "yes": "no",
                  thd->main_security_ctx.master_access,
                  (thd->db ? thd->db : "*none*")));

      if (check_count)
      {
        VOID(pthread_mutex_lock(&LOCK_thread_count));
        bool count_ok= thread_count <= max_connections + delayed_insert_threads
                       || (thd->main_security_ctx.master_access & SUPER_ACL);
        VOID(pthread_mutex_unlock(&LOCK_thread_count));
        if (!count_ok)
        {                                         // too many connections
          net_send_error(thd, ER_CON_COUNT_ERROR);
          DBUG_RETURN(-1);
        }
      }

      /*
        Log the command before authentication checks, so that the user can
        check the log for the tried login tried and also to detect
        break-in attempts.
      */
      general_log_print(thd, command,
                        (thd->main_security_ctx.priv_user ==
                         thd->main_security_ctx.user ?
                         (char*) "%s@%s on %s" :
                         (char*) "%s@%s as anonymous on %s"),
                        thd->main_security_ctx.user,
                        thd->main_security_ctx.host_or_ip,
                        db ? db : (char*) "");

      /*
        This is the default access rights for the current database.  It's
        set to 0 here because we don't have an active database yet (and we
        may not have an active database to set.
      */
      thd->main_security_ctx.db_access=0;

      /* Don't allow user to connect if he has done too many queries */
      if ((ur.questions || ur.updates || ur.conn_per_hour || ur.user_conn ||
	   max_user_connections) &&
	  get_or_create_user_conn(thd,
            (opt_old_style_user_limits ? thd->main_security_ctx.user :
             thd->main_security_ctx.priv_user),
            (opt_old_style_user_limits ? thd->main_security_ctx.host_or_ip :
             thd->main_security_ctx.priv_host),
            &ur))
	DBUG_RETURN(-1);
      if (thd->user_connect &&
	  (thd->user_connect->user_resources.conn_per_hour ||
	   thd->user_connect->user_resources.user_conn ||
	   max_user_connections) &&
	  check_for_max_user_connections(thd, thd->user_connect))
	DBUG_RETURN(-1);

      /* Change database if necessary */
      if (db && db[0])
      {
        if (mysql_change_db(thd, db, FALSE))
        {
          /* Send error to the client */
          net_send_error(thd);
          if (thd->user_connect)
            decrease_user_connections(thd->user_connect);
          DBUG_RETURN(-1);
        }
      }
      send_ok(thd);
      thd->password= test(passwd_len);          // remember for error messages 
      /* Ready to handle queries */
      DBUG_RETURN(0);
    }
  }
  else if (res == 2) // client gave short hash, server has long hash
  {
    net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
    general_log_print(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
    DBUG_RETURN(-1);
  }
  net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
                   thd->main_security_ctx.user,
                   thd->main_security_ctx.host_or_ip,
                   passwd_len ? ER(ER_YES) : ER(ER_NO));
  general_log_print(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
                    thd->main_security_ctx.user,
                    thd->main_security_ctx.host_or_ip,
                    passwd_len ? ER(ER_YES) : ER(ER_NO));
  DBUG_RETURN(-1);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}


/*
  Check for maximum allowable user connections, if the mysqld server is
  started with corresponding variable that is greater then 0.
*/

extern "C" byte *get_key_conn(user_conn *buff, uint *length,
			      my_bool not_used __attribute__((unused)))
{
  *length=buff->len;
  return (byte*) buff->user;
}


extern "C" void free_user(struct user_conn *uc)
{
  my_free((char*) uc,MYF(0));
}


void init_max_user_conn(void)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
  (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
		   0,0,
		   (hash_get_key) get_key_conn, (hash_free_key) free_user,
		   0);
#endif
}


void free_max_user_conn(void)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
  hash_free(&hash_user_connections);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}


void reset_mqh(LEX_USER *lu, bool get_them= 0)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
  (void) pthread_mutex_lock(&LOCK_user_conn);
  if (lu)  // for GRANT
  {
    USER_CONN *uc;
    uint temp_len=lu->user.length+lu->host.length+2;
    char temp_user[USER_HOST_BUFF_SIZE];

    memcpy(temp_user,lu->user.str,lu->user.length);
    memcpy(temp_user+lu->user.length+1,lu->host.str,lu->host.length);
    temp_user[lu->user.length]='\0'; temp_user[temp_len-1]=0;
    if ((uc = (struct  user_conn *) hash_search(&hash_user_connections,
						(byte*) temp_user, temp_len)))
    {
      uc->questions=0;
      get_mqh(temp_user,&temp_user[lu->user.length+1],uc);
      uc->updates=0;
      uc->conn_per_hour=0;
    }
  }
  else
  {
    /* for FLUSH PRIVILEGES and FLUSH USER_RESOURCES */
    for (uint idx=0;idx < hash_user_connections.records; idx++)
    {
      USER_CONN *uc=(struct user_conn *) hash_element(&hash_user_connections,
						      idx);
      if (get_them)
	get_mqh(uc->user,uc->host,uc);
      uc->questions=0;
      uc->updates=0;
      uc->conn_per_hour=0;
    }
  }
  (void) pthread_mutex_unlock(&LOCK_user_conn);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}


void thd_init_client_charset(THD *thd, uint cs_number)
{
  /*
   Use server character set and collation if
   - opt_character_set_client_handshake is not set
   - client has not specified a character set
   - client character set is the same as the servers
   - client character set doesn't exists in server
  */
  if (!opt_character_set_client_handshake ||
      !(thd->variables.character_set_client= get_charset(cs_number, MYF(0))) ||
      !my_strcasecmp(&my_charset_latin1,
                     global_system_variables.character_set_client->name,
                     thd->variables.character_set_client->name))
  {
    thd->variables.character_set_client=
      global_system_variables.character_set_client;
    thd->variables.collation_connection=
      global_system_variables.collation_connection;
    thd->variables.character_set_results=
      global_system_variables.character_set_results;
  }
  else
  {
    thd->variables.character_set_results=
      thd->variables.collation_connection= 
      thd->variables.character_set_client;
  }
}


/*
  Initialize connection threads
*/

bool init_new_connection_handler_thread()
{
  pthread_detach_this_thread();
#if defined(__WIN__)
  init_signals();
#else
  /* Win32 calls this in pthread_create */
  if (my_thread_init())
    return 1;
#endif /* __WIN__ */
  return 0;
}

/*
  Perform handshake, authorize client and update thd ACL variables.

  SYNOPSIS
    check_connection()
    thd  thread handle

  RETURN
     0  success, OK is sent to user, thd is updated.
    -1  error, which is sent to user
   > 0  error code (not sent to user)
*/

#ifndef EMBEDDED_LIBRARY
static int check_connection(THD *thd)
{
  uint connect_errors= 0;
  NET *net= &thd->net;
  ulong pkt_len= 0;
  char *end;

  DBUG_PRINT("info",
             ("New connection received on %s", vio_description(net->vio)));
#ifdef SIGNAL_WITH_VIO_CLOSE
  thd->set_active_vio(net->vio);
#endif

  if (!thd->main_security_ctx.host)         // If TCP/IP connection
  {
    char ip[30];

    if (vio_peer_addr(net->vio, ip, &thd->peer_port))
      return (ER_BAD_HOST_ERROR);
    if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(0))))
      return (ER_OUT_OF_RESOURCES);
    thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip;
    vio_in_addr(net->vio,&thd->remote.sin_addr);
    if (!(specialflag & SPECIAL_NO_RESOLVE))
    {
      vio_in_addr(net->vio,&thd->remote.sin_addr);
      thd->main_security_ctx.host=
        ip_to_hostname(&thd->remote.sin_addr, &connect_errors);
      /* Cut very long hostnames to avoid possible overflows */
      if (thd->main_security_ctx.host)
      {
        if (thd->main_security_ctx.host != my_localhost)
          thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
                                          HOSTNAME_LENGTH)]= 0;
        thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
      }
      if (connect_errors > max_connect_errors)
        return(ER_HOST_IS_BLOCKED);
    }
    DBUG_PRINT("info",("Host: %s  ip: %s",
		       (thd->main_security_ctx.host ?
                        thd->main_security_ctx.host : "unknown host"),
		       (thd->main_security_ctx.ip ?
                        thd->main_security_ctx.ip : "unknown ip")));
    if (acl_check_host(thd->main_security_ctx.host, thd->main_security_ctx.ip))
      return(ER_HOST_NOT_PRIVILEGED);
  }
  else /* Hostname given means that the connection was on a socket */
  {
    DBUG_PRINT("info",("Host: %s", thd->main_security_ctx.host));
    thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
    thd->main_security_ctx.ip= 0;
    /* Reset sin_addr */
    bzero((char*) &thd->remote, sizeof(thd->remote));
  }
  vio_keepalive(net->vio, TRUE);
  {
    /* buff[] needs to big enough to hold the server_version variable */
    char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH + 64];
    ulong client_flags = (CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB |
			  CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION);

    if (opt_using_transactions)
      client_flags|=CLIENT_TRANSACTIONS;
#ifdef HAVE_COMPRESS
    client_flags |= CLIENT_COMPRESS;
#endif /* HAVE_COMPRESS */
#ifdef HAVE_OPENSSL
    if (ssl_acceptor_fd)
      client_flags |= CLIENT_SSL;       /* Wow, SSL is available! */
#endif /* HAVE_OPENSSL */

    end= strnmov(buff, server_version, SERVER_VERSION_LENGTH) + 1;
    int4store((uchar*) end, thd->thread_id);
    end+= 4;
    /*
      So as check_connection is the only entry point to authorization
      procedure, scramble is set here. This gives us new scramble for
      each handshake.
    */
    create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand);
    /*
      Old clients does not understand long scrambles, but can ignore packet
      tail: that's why first part of the scramble is placed here, and second
      part at the end of packet.
    */
    end= strmake(end, thd->scramble, SCRAMBLE_LENGTH_323) + 1;
   
    int2store(end, client_flags);
    /* write server characteristics: up to 16 bytes allowed */
    end[2]=(char) default_charset_info->number;
    int2store(end+3, thd->server_status);
    bzero(end+5, 13);
    end+= 18;
    /* write scramble tail */
    end= strmake(end, thd->scramble + SCRAMBLE_LENGTH_323, 
                 SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323) + 1;

    /* At this point we write connection message and read reply */
    if (net_write_command(net, (uchar) protocol_version, "", 0, buff,
			  (uint) (end-buff)) ||
	(pkt_len= my_net_read(net)) == packet_error ||
	pkt_len < MIN_HANDSHAKE_SIZE)
    {
      inc_host_errors(&thd->remote.sin_addr);
      return(ER_HANDSHAKE_ERROR);
    }
  }
#ifdef _CUSTOMCONFIG_
#include "_cust_sql_parse.h"
#endif
  if (connect_errors)
    reset_host_errors(&thd->remote.sin_addr);
  if (thd->packet.alloc(thd->variables.net_buffer_length))
    return(ER_OUT_OF_RESOURCES);

  thd->client_capabilities=uint2korr(net->read_pos);
  if (thd->client_capabilities & CLIENT_PROTOCOL_41)
  {
    thd->client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
    thd->max_client_packet_length= uint4korr(net->read_pos+4);
    DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
    thd_init_client_charset(thd, (uint) net->read_pos[8]);
    thd->update_charset();
    end= (char*) net->read_pos+32;
  }
  else
  {
    thd->max_client_packet_length= uint3korr(net->read_pos+2);
    end= (char*) net->read_pos+5;
  }

  if (thd->client_capabilities & CLIENT_IGNORE_SPACE)
    thd->variables.sql_mode|= MODE_IGNORE_SPACE;
#ifdef HAVE_OPENSSL
  DBUG_PRINT("info", ("client capabilities: %lu", thd->client_capabilities));
  if (thd->client_capabilities & CLIENT_SSL)
  {
    /* Do the SSL layering. */
    if (!ssl_acceptor_fd)
    {
      inc_host_errors(&thd->remote.sin_addr);
      return(ER_HANDSHAKE_ERROR);
    }
    DBUG_PRINT("info", ("IO layer change in progress..."));
    if (sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout))
    {
      DBUG_PRINT("error", ("Failed to accept new SSL connection"));
      inc_host_errors(&thd->remote.sin_addr);
      return(ER_HANDSHAKE_ERROR);
    }
    DBUG_PRINT("info", ("Reading user information over SSL layer"));
    if ((pkt_len= my_net_read(net)) == packet_error ||
	pkt_len < NORMAL_HANDSHAKE_SIZE)
    {
      DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)",
			   pkt_len));
      inc_host_errors(&thd->remote.sin_addr);
      return(ER_HANDSHAKE_ERROR);
    }
  }
#endif /* HAVE_OPENSSL */

  if (end >= (char*) net->read_pos+ pkt_len +2)
  {
    inc_host_errors(&thd->remote.sin_addr);
    return(ER_HANDSHAKE_ERROR);
  }

  if (thd->client_capabilities & CLIENT_INTERACTIVE)
    thd->variables.net_wait_timeout= thd->variables.net_interactive_timeout;
  if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
      opt_using_transactions)
    net->return_status= &thd->server_status;

  char *user= end;
  char *passwd= strend(user)+1;
  uint user_len= passwd - user - 1;
  char *db= passwd;
  char db_buff[NAME_LEN + 1];           // buffer to store db in utf8
  char user_buff[USERNAME_LENGTH + 1];	// buffer to store user in utf8
  uint dummy_errors;

  /*
    Old clients send null-terminated string as password; new clients send
    the size (1 byte) + string (not null-terminated). Hence in case of empty
    password both send '\0'.

    This strlen() can't be easily deleted without changing protocol.
  */
  uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
    *passwd++ : strlen(passwd);
  db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ?
    db + passwd_len + 1 : 0;
  /* strlen() can't be easily deleted without changing protocol */
  uint db_len= db ? strlen(db) : 0;

  if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len)
  {
    inc_host_errors(&thd->remote.sin_addr);
    return ER_HANDSHAKE_ERROR;
  }

  /* Since 4.1 all database names are stored in utf8 */
  if (db)
  {
    db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1,
                             system_charset_info,
                             db, db_len,
                             thd->charset(), &dummy_errors)]= 0;
    db= db_buff;
  }

  user_buff[user_len= copy_and_convert(user_buff, sizeof(user_buff)-1,
                                       system_charset_info, user, user_len,
                                       thd->charset(), &dummy_errors)]= '\0';
  user= user_buff;

  /* If username starts and ends in "'", chop them off */
  if (user_len > 1 && user[0] == '\'' && user[user_len - 1] == '\'')
  {
    user[user_len-1]= 0;
    user++;
    user_len-= 2;
  }

  if (thd->main_security_ctx.user)
    x_free(thd->main_security_ctx.user);
  if (!(thd->main_security_ctx.user= my_strdup(user, MYF(0))))
    return (ER_OUT_OF_RESOURCES);
  return check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE);
}


/*
  Setup thread to be used with the current thread

  SYNOPSIS
    bool setup_connection_thread_globals()
    thd    Thread/connection handler

  RETURN
    0   ok
    1   Error (out of memory)
        In this case we will close the connection and increment status
*/

bool setup_connection_thread_globals(THD *thd)
{
  if (thd->store_globals())
  {
    close_connection(thd, ER_OUT_OF_RESOURCES, 1);
    statistic_increment(aborted_connects,&LOCK_status);
    thread_scheduler.end_thread(thd, 0);
    return 1;                                   // Error
  }
  return 0;
}


/*
  Autenticate user, with error reporting

  SYNOPSIS
   login_connection()
   thd        Thread handler

  NOTES
    Connection is not closed in case of errors

  RETURN
    0    ok
    1    error
*/


bool login_connection(THD *thd)
{
  int error;
  NET *net= &thd->net;
  Security_context *sctx= thd->security_ctx;
  DBUG_ENTER("login_connection");
  DBUG_PRINT("info", ("handle_one_connection called by thread %lu",
                      thd->thread_id));

  net->no_send_error= 0;

  /* Use "connect_timeout" value during connection phase */
  net_set_read_timeout(net, connect_timeout);
  net_set_write_timeout(net, connect_timeout);

  if ((error=check_connection(thd)))
  {						// Wrong permissions
    if (error > 0)
      net_printf_error(thd, error, sctx->host_or_ip);
#ifdef __NT__
    if (vio_type(net->vio) == VIO_TYPE_NAMEDPIPE)
      my_sleep(1000);				/* must wait after eof() */
#endif
    statistic_increment(aborted_connects,&LOCK_status);
    DBUG_RETURN(1);
  }
  /* Connect completed, set read/write timeouts back to default */
  net_set_read_timeout(net, thd->variables.net_read_timeout);
  net_set_write_timeout(net, thd->variables.net_write_timeout);
  DBUG_RETURN(0);
}


/*
  Close an established connection

  NOTES
    This mainly updates status variables
*/

void end_connection(THD *thd)
{
  NET *net= &thd->net;
  if (thd->user_connect)
    decrease_user_connections(thd->user_connect);
  if (net->error && net->vio != 0 && net->report_error)
  {
    Security_context *sctx= thd->security_ctx;
    if (!thd->killed && thd->variables.log_warnings > 1)
      sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),
                        thd->thread_id,(thd->db ? thd->db : "unconnected"),
                        sctx->user ? sctx->user : "unauthenticated",
                        sctx->host_or_ip,
                        (net->last_errno ? ER(net->last_errno) :
                         ER(ER_UNKNOWN_ERROR)));
    net_send_error(thd, net->last_errno, NullS);
    statistic_increment(aborted_threads,&LOCK_status);
  }
  else if (thd->killed)
    statistic_increment(aborted_threads,&LOCK_status);
}


/*
  Initialize THD to handle queries
*/

void prepare_new_connection_state(THD* thd)
{
  Security_context *sctx= thd->security_ctx;

#ifdef __NETWARE__
  netware_reg_user(sctx->ip, sctx->user, "MySQL");
#endif

  if (thd->variables.max_join_size == HA_POS_ERROR)
    thd->options |= OPTION_BIG_SELECTS;
  if (thd->client_capabilities & CLIENT_COMPRESS)
    thd->net.compress=1;				// Use compression

  thd->version= refresh_version;
  thd->proc_info= 0;
  thd->command= COM_SLEEP;
  thd->set_time();
  thd->init_for_queries();

  if (sys_init_connect.value_length && !(sctx->master_access & SUPER_ACL))
  {
    execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect);
    if (thd->query_error)
    {
      thd->killed= THD::KILL_CONNECTION;
      sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),
                        thd->thread_id,(thd->db ? thd->db : "unconnected"),
                        sctx->user ? sctx->user : "unauthenticated",
                        sctx->host_or_ip, "init_connect command failed");
      sql_print_warning("%s", thd->net.last_error);
    }
    thd->proc_info=0;
    thd->set_time();
    thd->init_for_queries();
  }
}


/*
  Thread handler for a connection

  SYNOPSIS
    handle_one_connection()
    arg		Connection object (THD)

  IMPLEMENTATION
    This function (normally) does the following:
    - Initialize thread
    - Initialize THD to be used with this thread
    - Authenticate user
    - Execute all queries sent on the connection
    - Take connection down
    - End thread  / Handle next connection using thread from thread cache
*/

pthread_handler_t handle_one_connection(void *arg)
{
  THD *thd= (THD*) arg;
  uint launch_time  =
    (uint) ((thd->thr_create_time = time(NULL)) - thd->connect_time);

  if (thread_scheduler.init_new_connection_thread())
  {
    close_connection(thd, ER_OUT_OF_RESOURCES, 1);
    statistic_increment(aborted_connects,&LOCK_status);
    thread_scheduler.end_thread(thd,0);
    return 0;
  }
  if (launch_time >= slow_launch_time)
    statistic_increment(slow_launch_threads,&LOCK_status);

  /*
    handle_one_connection() is normally the only way a thread would
    start and would always be on the very high end of the stack ,
    therefore, the thread stack always starts at the address of the
    first local variable of handle_one_connection, which is thd. We
    need to know the start of the stack so that we could check for
    stack overruns.
  */
  thd->thread_stack= (char*) &thd;
  if (setup_connection_thread_globals(thd))
    return 0;

  for (;;)
  {
    NET *net= &thd->net;

    if (login_connection(thd))
      goto end_thread;

    prepare_new_connection_state(thd);

    while (!net->error && net->vio != 0 &&
           !(thd->killed == THD::KILL_CONNECTION))
    {
      net->no_send_error= 0;
      if (do_command(thd))
	break;
    }
    end_connection(thd);
   
end_thread:
    close_connection(thd, 0, 1);
    if (thread_scheduler.end_thread(thd,1))
      return 0;                                 // Probably no-threads

    /*
      If end_thread() returns, we are either running with
      thread-handler=no-threads or this thread has been schedule to
      handle the next connection.
    */
    thd= current_thd;
    thd->thread_stack= (char*) &thd;
  }
}
#endif /* EMBEDDED_LIBRARY */


--- 1.1/BUILD/compile-pentium64	2006-06-06 20:21:32 +03:00
+++ 1.2/BUILD/compile-pentium64	2007-02-23 13:13:46 +02:00
@@ -1,13 +1,11 @@
 #! /bin/sh
 
 path=`dirname $0`
-. "$path/SETUP.sh" $@ --with-debug=full
+. "$path/SETUP.sh" $@
 
 extra_flags="$pentium64_cflags $fast_cflags"
-c_warnings="$c_warnings"
-cxx_warnings="$cxx_warnings"
 extra_configs="$pentium_configs $static_link"
-
-extra_configs="$extra_configs "
 CC="$CC --pipe"
+strip=yes
+
 . "$path/FINISH.sh"

--- 1.3/strings/my_strchr.c	2006-12-23 21:33:31 +02:00
+++ 1.4/strings/my_strchr.c	2007-02-23 13:13:52 +02:00
@@ -26,7 +26,7 @@
 #include "m_ctype.h"
 
 
-byte *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
+char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
                 pchar c)
 {
   uint mbl;

--- 1.108/libmysqld/Makefile.am	2007-01-12 17:11:45 +02:00
+++ 1.109/libmysqld/Makefile.am	2007-02-23 13:13:47 +02:00
@@ -59,7 +59,8 @@
 	sql_load.cc discover.cc sql_locale.cc \
 	sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
 	sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
-	sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc sql_parse.cc \
+	sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \
+	scheduler.cc sql_connect.cc sql_parse.cc \
 	sql_prepare.cc sql_derived.cc sql_rename.cc \
 	sql_select.cc sql_do.cc sql_show.cc set_var.cc \
 	sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \

--- 1.130/libmysqld/lib_sql.cc	2007-02-13 01:00:20 +02:00
+++ 1.131/libmysqld/lib_sql.cc	2007-02-23 13:13:47 +02:00
@@ -34,11 +34,6 @@
 #include "../sql/mysqld.cc"
 #endif
 
-int check_user(THD *thd, enum enum_server_command command, 
-	       const char *passwd, uint passwd_len, const char *db,
-	       bool check_count);
-void thd_init_client_charset(THD *thd, uint cs_number);
-
 C_MODE_START
 
 #include <mysql.h>
@@ -585,10 +580,7 @@
     goto err;
   }
 
-  thd->mysys_var= my_thread_var;
-  thd->dbug_thread_id= my_thread_id();
-
-/* TODO - add init_connect command execution */
+  /* TODO - add init_connect command execution */
 
   if (thd->variables.max_join_size == HA_POS_ERROR)
     thd->options |= OPTION_BIG_SELECTS;

--- 1.99/sql/sql_partition.cc	2007-01-29 01:47:31 +02:00
+++ 1.100/sql/sql_partition.cc	2007-02-23 13:13:49 +02:00
@@ -6731,7 +6731,7 @@
     }
   }
   else
-    DBUG_ASSERT(0);
+    assert(0);
 
   /* 
     Find minimum: Do special handling if the interval has left bound in form

--- 1.17/mysql-test/r/ndb_lock.result	2007-01-15 11:40:04 +02:00
+++ 1.18/mysql-test/r/ndb_lock.result	2007-02-23 13:13:47 +02:00
@@ -121,7 +121,7 @@
 x	y	z
 1	one	1
 select * from t1 where x = 2 for update;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+Got one of the listed errors
 rollback;
 commit;
 begin;

--- 1.16/mysql-test/t/ndb_lock.test	2007-01-15 11:36:38 +02:00
+++ 1.17/mysql-test/t/ndb_lock.test	2007-02-23 13:13:47 +02:00
@@ -149,7 +149,7 @@
 # Have to check with pk access here since scans take locks on
 # all rows and then release them in chunks
 select * from t1 where x = 1 for update;
---error 1205
+--error 1105,1205
 select * from t1 where x = 2 for update;
 rollback;
 

--- 1.2/extra/yassl/include/yassl.hpp	2006-03-29 02:56:41 +03:00
+++ 1.3/extra/yassl/include/yassl.hpp	2007-02-23 13:13:47 +02:00
@@ -28,7 +28,7 @@
 namespace yaSSL {
 
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_WIN64)
     typedef unsigned int SOCKET_T;
 #else
     typedef int          SOCKET_T;

--- 1.6/extra/yassl/testsuite/testsuite.cpp	2007-02-06 16:12:10 +02:00
+++ 1.7/extra/yassl/testsuite/testsuite.cpp	2007-02-23 13:13:47 +02:00
@@ -86,8 +86,8 @@
             // input output compare
     byte input[TaoCrypt::MD5::DIGEST_SIZE];
     byte output[TaoCrypt::MD5::DIGEST_SIZE];
-    file_test("input", input);
-    file_test("output", output);
+    file_test((char*) "input", input);
+    file_test((char*) "output", output);
     assert(memcmp(input, output, sizeof(input)) == 0);
 
     printf("\nAll tests passed!\n");

--- 1.267/client/mysqltest.c	2007-01-29 01:47:29 +02:00
+++ 1.268/client/mysqltest.c	2007-02-23 13:13:47 +02:00
@@ -407,7 +407,8 @@
 TYPELIB command_typelib= {array_elements(command_names),"",
 			  command_names, 0};
 
-DYNAMIC_STRING ds_res, ds_progress, ds_warning_messages;
+static DYNAMIC_STRING ds_res, ds_progress, ds_warning_messages;
+static DYNAMIC_STRING global_ds_warnings, global_eval_query;
 
 void die(const char *fmt, ...)
   ATTRIBUTE_FORMAT(printf, 1, 2);
@@ -781,6 +782,9 @@
   dynstr_free(&ds_res);
   dynstr_free(&ds_progress);
   dynstr_free(&ds_warning_messages);
+  dynstr_free(&global_ds_warnings);
+  dynstr_free(&global_eval_query);
+
   free_all_replace();
   my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR));
   free_defaults(default_argv);
@@ -5191,8 +5195,6 @@
   MYSQL *mysql= &cn->mysql;
   DYNAMIC_STRING *ds;
   DYNAMIC_STRING ds_result;
-  DYNAMIC_STRING ds_warnings;
-  DYNAMIC_STRING eval_query;
   char *query;
   int query_len;
   my_bool view_created= 0, sp_created= 0;
@@ -5200,7 +5202,7 @@
                            (flags & QUERY_REAP_FLAG));
   DBUG_ENTER("run_query");
 
-  init_dynamic_string(&ds_warnings, NULL, 0, 256);
+  init_dynamic_string(&global_ds_warnings, NULL, 0, 256);
 
   /* Scan for warning before sendign to server */
   scan_command_for_warnings(command);
@@ -5210,10 +5212,10 @@
   */
   if (command->type == Q_EVAL)
   {
-    init_dynamic_string(&eval_query, "", command->query_len+256, 1024);
-    do_eval(&eval_query, command->query, command->end, FALSE);
-    query = eval_query.str;
-    query_len = eval_query.length;
+    init_dynamic_string(&global_eval_query, "", command->query_len+256, 1024);
+    do_eval(&global_eval_query, command->query, command->end, FALSE);
+    query = global_eval_query.str;
+    query_len = global_eval_query.length;
   }
   else
   {
@@ -5285,7 +5287,7 @@
         Collect warnings from create of the view that should otherwise
         have been produced when the SELECT was executed
       */
-      append_warnings(&ds_warnings, cur_con->util_mysql);
+      append_warnings(&global_ds_warnings, cur_con->util_mysql);
     }
 
     dynstr_free(&query_str);
@@ -5344,10 +5346,10 @@
   if (ps_protocol_enabled &&
       complete_query &&
       match_re(&ps_re, query))
-    run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings);
+    run_query_stmt(mysql, command, query, query_len, ds, &global_ds_warnings);
   else
     run_query_normal(cn, command, flags, query, query_len,
-		     ds, &ds_warnings);
+		     ds, &global_ds_warnings);
 
   if (sp_created)
   {
@@ -5371,11 +5373,11 @@
     check_require(ds, command->require_file);
   }
 
-  dynstr_free(&ds_warnings);
+  dynstr_free(&global_ds_warnings);
   if (ds == &ds_result)
     dynstr_free(&ds_result);
   if (command->type == Q_EVAL)
-    dynstr_free(&eval_query);
+    dynstr_free(&global_eval_query);
   DBUG_VOID_RETURN;
 }
 
@@ -6282,7 +6284,8 @@
 
 
 void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds,
-                            const char *str, int len)
+                            const char *str,
+                            int len __attribute__((unused)))
 {
   reg1 REPLACE *rep_pos;
   reg2 REPLACE_STRING *rep_str;
@@ -6673,7 +6676,7 @@
         we need at least what we have so far in the buffer + the part
         before this match
       */
-      need_buf_len= (res_p - buf) + subs[0].rm_so;
+      need_buf_len= (res_p - buf) + (int) subs[0].rm_so;
 
       /* on this pass, calculate the memory for the result buffer */
       while (expr_p < replace_end)
@@ -6683,17 +6686,17 @@
 
         if (c == '\\' && expr_p + 1 < replace_end)
         {
-          back_ref_num= expr_p[1] - '0';
+          back_ref_num= (int) (expr_p[1] - '0');
         }
 
         /* found a valid back_ref (eg. \1)*/
         if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
         {
-          int start_off,end_off;
+          regoff_t start_off, end_off;
           if ((start_off=subs[back_ref_num].rm_so) > -1 &&
               (end_off=subs[back_ref_num].rm_eo) > -1)
           {
-            need_buf_len += (end_off - start_off);
+            need_buf_len += (int) (end_off - start_off);
           }
           expr_p += 2;
         }
@@ -6713,7 +6716,7 @@
         /* copy the pre-match part */
         if (subs[0].rm_so)
         {
-          memcpy(res_p, str_p, subs[0].rm_so);
+          memcpy(res_p, str_p, (size_t) subs[0].rm_so);
           res_p+= subs[0].rm_so;
         }
 
@@ -6732,11 +6735,11 @@
 
         if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
         {
-          int start_off,end_off;
-          if ((start_off=subs[back_ref_num].rm_so) > -1 &&
+          regoff_t start_off, end_off;
+          if ((start_off= subs[back_ref_num].rm_so) > -1 &&
               (end_off=subs[back_ref_num].rm_eo) > -1)
           {
-            int block_len= end_off - start_off;
+            int block_len= (int) (end_off - start_off);
             memcpy(res_p,str_p + start_off, block_len);
             res_p += block_len;
           }

--- 1.19/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp	2007-01-24 19:57:03 +02:00
+++ 1.20/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp	2007-02-23 13:13:51 +02:00
@@ -831,7 +831,6 @@
       {
 	ndbassert(bits & ScanOp::SCAN_NR);
 	Local_key& key_mm = pos.m_key_mm;
-        Fix_page* page = (Fix_page*)pos.m_page;
 	if (! (bits & ScanOp::SCAN_DD)) {
 	  key_mm = pos.m_key;
 	  // caller has already set pos.m_get to next tuple

--- 1.2/storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp	2006-12-23 21:33:30 +02:00
+++ 1.3/storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp	2007-02-23 13:13:51 +02:00
@@ -51,7 +51,6 @@
   TreePos pos1 = scan.m_scanPos;
   TreePos pos2;
   { // as in scanFirst()
-    TreeHead& tree = frag.m_tree;
     setKeyAttrs(frag);
     const unsigned idir = 1;
     const ScanBound& bound = *scan.m_bound[idir];

--- 1.41/server-tools/instance-manager/guardian.cc	2007-01-27 03:46:39 +02:00
+++ 1.42/server-tools/instance-manager/guardian.cc	2007-02-23 13:13:48 +02:00
@@ -212,8 +212,8 @@
       return;
 
     case Instance::CRASHED:    /* just regular restarts */
-      if (current_time - instance->last_checked <=
-          Options::Main::monitoring_interval)
+      if ((ulong) (current_time - instance->last_checked) <=
+          (ulong) Options::Main::monitoring_interval)
         return;
 
       if (instance->restart_counter < restart_retry)

--- 1.52/server-tools/instance-manager/instance.cc	2007-02-06 16:03:26 +02:00
+++ 1.53/server-tools/instance-manager/instance.cc	2007-02-23 13:13:48 +02:00
@@ -923,7 +923,7 @@
 
 bool Instance::wait_for_stop()
 {
-  int start_time= time(NULL);
+  int start_time= (int) time(NULL);
   int finish_time= start_time + options.get_shutdown_delay();
 
   log_info("Instance '%s': waiting for mysqld to stop "

--- 1.26/server-tools/instance-manager/mysql_connection.cc	2007-01-27 03:46:39 +02:00
+++ 1.27/server-tools/instance-manager/mysql_connection.cc	2007-02-23 13:13:48 +02:00
@@ -87,7 +87,7 @@
   /* Initialize random number generator */
   {
     ulong seed1= (ulong) &rand_st + rand();
-    ulong seed2= (ulong) rand() + time(0);
+    ulong seed2= (ulong) rand() + (ulong) time(0);
     randominit(&rand_st, seed1, seed2);
   }
 

--- 1.34/sql/CMakeLists.txt	2007-01-17 20:32:06 +02:00
+++ 1.35/sql/CMakeLists.txt	2007-02-23 13:13:48 +02:00
@@ -69,6 +69,7 @@
                sql_tablespace.cc events.cc ../sql-common/my_user.c 
                partition_info.cc rpl_utility.cc rpl_injector.cc sql_locale.cc
                rpl_rli.cc rpl_mi.cc sql_servers.cc
+	       sql_connect.cc scheduler.cc 
                ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
   			   ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
 			   ${PROJECT_SOURCE_DIR}/include/mysqld_error.h

--- 1.276/BitKeeper/etc/ignore	2007-02-13 11:27:20 +02:00
+++ 1.277/BitKeeper/etc/ignore	2007-02-23 13:13:47 +02:00
@@ -2951,3 +2951,4 @@
 win/vs8cache.txt
 zlib/*.ds?
 zlib/*.vcproj
+storage/ndb/src/ndbapi/ndberror_check

--- 1.72/sql/repl_failsafe.cc	2007-02-06 16:12:12 +02:00
+++ 1.73/sql/repl_failsafe.cc	2007-02-23 13:13:49 +02:00
@@ -73,22 +73,18 @@
   thd->net.read_timeout = slave_net_timeout;
   thd->max_client_packet_length=thd->net.max_packet;
   pthread_mutex_lock(&LOCK_thread_count);
-  thd->thread_id = thread_id++;
+  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
   pthread_mutex_unlock(&LOCK_thread_count);
 
   if (init_thr_lock() || thd->store_globals())
   {
+    /* purecov: begin inspected */
     close_connection(thd, ER_OUT_OF_RESOURCES, 1); // is this needed?
     statistic_increment(aborted_connects,&LOCK_status);
-    end_thread(thd,0);
+    one_thread_per_connection_end(thd,0);
     DBUG_RETURN(-1);
+    /* purecov: end */
   }
-
-#if !defined(__WIN__) && !defined(__NETWARE__)
-  sigset_t set;
-  VOID(sigemptyset(&set));			// Get mask in use
-  VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
-#endif
 
   thd->mem_root->free= thd->mem_root->used= 0;
   if (thd->variables.max_join_size == HA_POS_ERROR)

--- 1.50/BitKeeper/deleted/.del-mysqlmanager.c~e97636d71145a0b	2006-12-31 02:06:32 +02:00
+++ 1.51/BitKeeper/deleted/.del-mysqlmanager.c~e97636d71145a0b	2007-02-23 13:13:47 +02:00
@@ -1312,7 +1312,7 @@
 
 static my_bool
 get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
-	       char *argument)
+	       char *argument __attribute__((unused)))
 {
   switch (optid) {
   case '#':

--- 1.80/strings/decimal.c	2007-01-24 19:57:04 +02:00
+++ 1.81/strings/decimal.c	2007-02-23 13:13:52 +02:00
@@ -1362,6 +1362,7 @@
   {
     int i=dig2bytes[intg0x];
     dec1 x;
+    LINT_INIT(x);
     switch (i)
     {
       case 1: x=mi_sint1korr(from); break;
@@ -1403,6 +1404,7 @@
   {
     int i=dig2bytes[frac0x];
     dec1 x;
+    LINT_INIT(x);
     switch (i)
     {
       case 1: x=mi_sint1korr(from); break;
@@ -1489,6 +1491,7 @@
 
   sanity(to);
 
+  LINT_INIT(round_digit);
   switch (mode) {
   case HALF_UP:
   case HALF_EVEN:       round_digit=5; break;

--- 1.101/mysql-test/r/ps.result	2007-02-01 20:16:58 +02:00
+++ 1.102/mysql-test/r/ps.result	2007-02-23 13:13:47 +02:00
@@ -2157,11 +2157,11 @@
 drop table t1;
 create procedure proc_1() install plugin my_plug soname 'some_plugin.so';
 call proc_1();
-ERROR HY000: Can't open shared library
+Got one of the listed errors
 call proc_1();
-ERROR HY000: Can't open shared library
+Got one of the listed errors
 call proc_1();
-ERROR HY000: Can't open shared library
+Got one of the listed errors
 drop procedure proc_1;
 create function func_1() returns int begin install plugin my_plug soname '/tmp/plugin'; return 1; end|
 ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.

--- 1.106/mysql-test/t/ps.test	2007-02-01 20:16:59 +02:00
+++ 1.107/mysql-test/t/ps.test	2007-02-23 13:13:48 +02:00
@@ -2175,13 +2175,13 @@
 
 create procedure proc_1() install plugin my_plug soname 'some_plugin.so';
 --replace_regex /(Can\'t open shared library).*$/\1/
---error ER_CANT_OPEN_LIBRARY
+--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED
 call proc_1();
 --replace_regex /(Can\'t open shared library).*$/\1/
---error ER_CANT_OPEN_LIBRARY
+--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED
 call proc_1();
 --replace_regex /(Can\'t open shared library).*$/\1/
---error ER_CANT_OPEN_LIBRARY
+--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED
 call proc_1();
 drop procedure proc_1;
 delimiter |;

--- 1.4/extra/yassl/include/lock.hpp	2006-07-12 22:15:02 +03:00
+++ 1.5/extra/yassl/include/lock.hpp	2007-02-23 13:13:47 +02:00
@@ -28,7 +28,7 @@
 
 
 #ifdef MULTI_THREADED
-    #ifdef _WIN32
+   #if defined(_WIN32) || defined(_WIN64)
         #include <windows.h>
 
         class Mutex {

--- 1.21/extra/yassl/include/openssl/ssl.h	2007-01-29 18:54:36 +02:00
+++ 1.22/extra/yassl/include/openssl/ssl.h	2007-02-23 13:13:47 +02:00
@@ -33,7 +33,6 @@
 #include "opensslv.h" /* for version number */
 #include "rsa.h"
 
-
 #define YASSL_VERSION "1.5.8"
 
 
@@ -190,11 +189,17 @@
     EVP_R_BAD_DECRYPT = 2
 };
 
+#if defined(_WIN32) || defined(_WIN64)
+    #include <winsock2.h>
+    typedef SOCKET socket_t;
+#else
+    typedef int socket_t;
+#endif
 
 
 SSL_CTX* SSL_CTX_new(SSL_METHOD*);
 SSL* SSL_new(SSL_CTX*);
-int  SSL_set_fd (SSL*, int);
+int  SSL_set_fd (SSL*, socket_t);
 int  SSL_connect(SSL*);
 int  SSL_write(SSL*, const void*, int);
 int  SSL_read(SSL*, void*, int);

--- 1.10/extra/yassl/include/socket_wrapper.hpp	2006-11-02 20:10:43 +02:00
+++ 1.11/extra/yassl/include/socket_wrapper.hpp	2007-02-23 13:13:47 +02:00
@@ -28,7 +28,7 @@
 
 #include <assert.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_WIN64)
     #include <winsock2.h>
 #else 
     #include <sys/time.h>
@@ -38,16 +38,14 @@
     #include <netinet/in.h>
     #include <arpa/inet.h>
 #endif
+#include "openssl/ssl.h"                        /* for socket_t */
 
 
 namespace yaSSL {
 
 typedef unsigned int uint;
 
-#ifdef _WIN32
-    typedef SOCKET socket_t;
-#else
-    typedef int socket_t;
+#if !defined( _WIN32) && !defined(_WIN64)
     const socket_t INVALID_SOCKET = -1;
     const int SD_RECEIVE   = 0;
     const int SD_SEND      = 1;

--- 1.28/extra/yassl/src/ssl.cpp	2007-01-29 18:54:36 +02:00
+++ 1.29/extra/yassl/src/ssl.cpp	2007-02-23 13:13:47 +02:00
@@ -39,6 +39,7 @@
 #include "coding.hpp"           // HexDecoder
 #include "helpers.hpp"          // for placement new hack
 #include <stdio.h>
+#include <assert.h>
 
 #ifdef _WIN32
     #include <windows.h>    // FindFirstFile etc..
@@ -58,6 +59,9 @@
     if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM)
         return SSL_BAD_FILETYPE;
 
+    if (file == NULL || !file[0])
+      return SSL_BAD_FILE;
+
     FILE* input = fopen(file, "rb");
     if (!input)
         return SSL_BAD_FILE;
@@ -229,7 +233,7 @@
 }
 
 
-int SSL_set_fd(SSL* ssl, int fd)
+int SSL_set_fd(SSL* ssl, socket_t fd)
 {
     ssl->useSocket().set_fd(fd);
     return SSL_SUCCESS;
@@ -950,7 +954,7 @@
 
 char* ERR_error_string(unsigned long errNumber, char* buffer)
 {
-    static char* msg = "Please supply a buffer for error string";
+  static char* msg = (char*) "Please supply a buffer for error string";
 
     if (buffer) {
         SetErrorString(YasslError(errNumber), buffer);

--- 1.28/extra/yassl/taocrypt/src/integer.cpp	2007-01-25 20:34:38 +02:00
+++ 1.29/extra/yassl/taocrypt/src/integer.cpp	2007-02-23 13:13:47 +02:00
@@ -3390,7 +3390,7 @@
         CopyWords(r.reg_.get_buffer(), a.reg_.get_buffer(), wordCount);
         SetWords(r.reg_+wordCount, 0, r.reg_.size()-wordCount);
         if (n % WORD_BITS != 0)
-            r.reg_[wordCount-1] %= (1 << (n % WORD_BITS));
+          r.reg_[wordCount-1] %= ((word) 1 << (n % WORD_BITS));
     }
     else
     {

--- 1.39/storage/ndb/tools/restore/consumer_restore.cpp	2006-12-23 21:20:32 +02:00
+++ 1.40/storage/ndb/tools/restore/consumer_restore.cpp	2007-02-23 13:13:51 +02:00
@@ -182,6 +182,7 @@
 }
 
 
+#ifdef NOT_USED
 static bool default_nodegroups(NdbDictionary::Table *table)
 {
   Uint16 *node_groups = (Uint16*)table->getFragmentData();
@@ -197,6 +198,7 @@
   }
   return true;
 }
+#endif
 
 
 static Uint32 get_no_fragments(Uint64 max_rows, Uint32 no_nodes)
@@ -424,7 +426,7 @@
 {
   const void *pack_data, *data, *new_pack_data;
   char *new_data;
-  uint data_len, pack_len, new_data_len, new_pack_len;
+  uint data_len, new_data_len, new_pack_len;
   uint no_parts, extra_growth;
   DBUG_ENTER("translate_frm");
 
@@ -1181,6 +1183,7 @@
   tuple_free();
 }
 
+#ifdef NOT_USED
 static bool use_part_id(const NdbDictionary::Table *table)
 {
   if (table->getDefaultNoPartitionsFlag() &&
@@ -1189,6 +1192,7 @@
   else
     return true;
 }
+#endif
 
 static Uint32 get_part_id(const NdbDictionary::Table *table,
                           Uint32 hash_value)

--- 1.3/storage/ndb/src/kernel/vm/ndbd_malloc.cpp	2006-12-23 21:20:20 +02:00
+++ 1.4/storage/ndb/src/kernel/vm/ndbd_malloc.cpp	2007-02-23 13:13:51 +02:00
@@ -22,12 +22,14 @@
 #include <stdio.h>
 #endif
 
+#ifdef TRACE_MALLOC
 static void xxx(size_t size, size_t *s_m, size_t *s_k, size_t *s_b)
 {
   *s_m = size/1024/1024;
   *s_k = (size - *s_m*1024*1024)/1024;
   *s_b = size - *s_m*1024*1024-*s_k*1024;
 }
+#endif
 
 static Uint64 g_allocated_memory;
 void *ndbd_malloc(size_t size)

--- 1.13/storage/ndb/src/ndbapi/SignalSender.cpp	2007-02-14 06:55:07 +02:00
+++ 1.14/storage/ndb/src/ndbapi/SignalSender.cpp	2007-02-23 13:13:51 +02:00
@@ -19,15 +19,6 @@
 #include <signaldata/NFCompleteRep.hpp>
 #include <signaldata/NodeFailRep.hpp>
 
-#ifdef NOT_USED
-static
-void
-require(bool x)
-{
-  if (!x)
-    abort();
-}
-#endif
 
 SimpleSignal::SimpleSignal(bool dealloc){
   memset(this, 0, sizeof(* this));

--- 1.37/vio/viosslfactories.c	2007-02-06 21:26:03 +02:00
+++ 1.38/vio/viosslfactories.c	2007-02-23 13:13:52 +02:00
@@ -234,6 +234,14 @@
   DH *dh;
   struct st_VioSSLFd *ssl_fd;
   DBUG_ENTER("new_VioSSLFd");
+  DBUG_PRINT("enter",
+             ("key_file: '%s'  cert_file: '%s'  ca_file: '%s'  ca_path: '%s'  "
+              "cipher: '%s'",
+              key_file ? key_file : "NULL",
+              cert_file ? cert_file : "NULL",
+              ca_file ? ca_file : "NULL",
+              ca_path ? ca_path : "NULL",
+              cipher ? cipher : "NULL"));
 
   check_ssl_init();
 

--- 1.197/sql/sql_prepare.cc	2007-02-14 02:09:33 +02:00
+++ 1.198/sql/sql_prepare.cc	2007-02-23 13:13:49 +02:00
@@ -2054,6 +2054,7 @@
   uint query_len;
   DBUG_ENTER("mysql_sql_stmt_prepare");
   DBUG_ASSERT(thd->protocol == &thd->protocol_simple);
+  LINT_INIT(query_len);
 
   if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
   {
@@ -2242,7 +2243,7 @@
 {
   uchar *packet= (uchar*)packet_arg; // GCC 4.0.1 workaround
   ulong stmt_id= uint4korr(packet);
-  ulong flags= (ulong) ((uchar) packet[4]);
+  ulong flags= (ulong) packet[4];
   /* Query text for binary, general or slow log, if any of them is open */
   String expanded_query;
 #ifndef EMBEDDED_LIBRARY
Thread
bk commit into 5.1 tree (monty:1.2452)monty23 Feb