An error occurred fetching the project authors.
  1. 24 Jan, 2008 1 commit
    • istruewing@stella.local's avatar
      Bug#29182 - MyISAMCHK reports wrong character set · 8aebd394
      istruewing@stella.local authored
      myisamchk did always show Character set: latin1_swedish_ci (8),
      regardless what DEFAULT CHARSET the table had.
      
      When the server created a MyISAM table, it did not copy the
      characterset number into the MyISAM create info structure.
      
      Added assignment of charset number to MI_CREATE_INFO.
      8aebd394
  2. 13 Dec, 2007 1 commit
  3. 15 Nov, 2007 1 commit
    • istruewing@stella.local's avatar
      Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE · 06052741
      istruewing@stella.local authored
                  corrupts a MERGE table
      Bug 26867 - LOCK TABLES + REPAIR + merge table result in
                  memory/cpu hogging
      Bug 26377 - Deadlock with MERGE and FLUSH TABLE
      Bug 25038 - Waiting TRUNCATE
      Bug 25700 - merge base tables get corrupted by
                  optimize/analyze/repair table
      Bug 30275 - Merge tables: flush tables or unlock tables
                  causes server to crash
      Bug 19627 - temporary merge table locking
      Bug 27660 - Falcon: merge table possible
      Bug 30273 - merge tables: Can't lock file (errno: 155)
      
      The problems were:
      
      Bug 26379 - Combination of FLUSH TABLE and REPAIR TABLE
                      corrupts a MERGE table
      
        1. A thread trying to lock a MERGE table performs busy waiting while
           REPAIR TABLE or a similar table administration task is ongoing on
           one or more of its MyISAM tables.
        
        2. A thread trying to lock a MERGE table performs busy waiting until all
           threads that did REPAIR TABLE or similar table administration tasks
           on one or more of its MyISAM tables in LOCK TABLES segments do UNLOCK
           TABLES. The difference against problem #1 is that the busy waiting
           takes place *after* the administration task. It is terminated by
           UNLOCK TABLES only.
        
        3. Two FLUSH TABLES within a LOCK TABLES segment can invalidate the
           lock. This does *not* require a MERGE table. The first FLUSH TABLES
           can be replaced by any statement that requires other threads to
           reopen the table. In 5.0 and 5.1 a single FLUSH TABLES can provoke
           the problem.
      
      Bug 26867 - LOCK TABLES + REPAIR + merge table result in
                  memory/cpu hogging
      
        Trying DML on a MERGE table, which has a child locked and
        repaired by another thread, made an infinite loop in the server.
      
      Bug 26377 - Deadlock with MERGE and FLUSH TABLE
      
        Locking a MERGE table and its children in parent-child order
        and flushing the child deadlocked the server.
      
      Bug 25038 - Waiting TRUNCATE
      
        Truncating a MERGE child, while the MERGE table was in use,
        let the truncate fail instead of waiting for the table to
        become free.
      
      Bug 25700 - merge base tables get corrupted by
                  optimize/analyze/repair table
      
        Repairing a child of an open MERGE table corrupted the child.
        It was necessary to FLUSH the child first.
      
      Bug 30275 - Merge tables: flush tables or unlock tables
                  causes server to crash
      
        Flushing and optimizing locked MERGE children crashed the server.
      
      Bug 19627 - temporary merge table locking
      
        Use of a temporary MERGE table with non-temporary children
        could corrupt the children.
      
        Temporary tables are never locked. So we do now prohibit
        non-temporary chidlren of a temporary MERGE table.
      
      Bug 27660 - Falcon: merge table possible
      
        It was possible to create a MERGE table with non-MyISAM children.
      
      Bug 30273 - merge tables: Can't lock file (errno: 155)
      
        This was a Windows-only bug. Table administration statements
        sometimes failed with "Can't lock file (errno: 155)".
      
      These bugs are fixed by a new implementation of MERGE table open.
      
      When opening a MERGE table in open_tables() we do now add the
      child tables to the list of tables to be opened by open_tables()
      (the "query_list"). The children are not opened in the handler at
      this stage.
      
      After opening the parent, open_tables() opens each child from the
      now extended query_list. When the last child is opened, we remove
      the children from the query_list again and attach the children to
      the parent. This behaves similar to the old open. However it does
      not open the MyISAM tables directly, but grabs them from the already
      open children.
      
      When closing a MERGE table in close_thread_table() we detach the
      children only. Closing of the children is done implicitly because
      they are in thd->open_tables.
      
      For more detail see the comment at the top of ha_myisammrg.cc.
      
      Changed from open_ltable() to open_and_lock_tables() in all places
      that can be relevant for MERGE tables. The latter can handle tables
      added to the list on the fly. When open_ltable() was used in a loop
      over a list of tables, the list must be temporarily terminated
      after every table for open_and_lock_tables().
      table_list->required_type is set to FRMTYPE_TABLE to avoid open of
      special tables. Handling of derived tables is suppressed.
      These details are handled by the new function
      open_n_lock_single_table(), which has nearly the same signature as
      open_ltable() and can replace it in most cases.
      
      In reopen_tables() some of the tables open by a thread can be
      closed and reopened. When a MERGE child is affected, the parent
      must be closed and reopened too. Closing of the parent is forced
      before the first child is closed. Reopen happens in the order of
      thd->open_tables. MERGE parents do not attach their children
      automatically at open. This is done after all tables are reopened.
      So all children are open when attaching them.
      
      Special lock handling like mysql_lock_abort() or mysql_lock_remove()
      needs to be suppressed for MERGE children or forwarded to the parent.
      This depends on the situation. In loops over all open tables one
      suppresses child lock handling. When a single table is touched,
      forwarding is done.
      
      Behavioral changes:
      ===================
      
      This patch changes the behavior of temporary MERGE tables.
      Temporary MERGE must have temporary children.
      The old behavior was wrong. A temporary table is not locked. Hence
      even non-temporary children were not locked. See
      Bug 19627 - temporary merge table locking.
      
      You cannot change the union list of a non-temporary MERGE table
      when LOCK TABLES is in effect. The following does *not* work:
      CREATE TABLE m1 ... ENGINE=MRG_MYISAM ...;
      LOCK TABLES t1 WRITE, t2 WRITE, m1 WRITE;
      ALTER TABLE m1 ... UNION=(t1,t2) ...;
      However, you can do this with a temporary MERGE table.
      
      You cannot create a MERGE table with CREATE ... SELECT, neither
      as a temporary MERGE table, nor as a non-temporary MERGE table.
      CREATE TABLE m1 ... ENGINE=MRG_MYISAM ... SELECT ...;
      Gives error message: table is not BASE TABLE.
      06052741
  4. 21 Sep, 2007 1 commit
  5. 13 Aug, 2007 1 commit
    • monty@mysql.com/nosik.monty.fi's avatar
      Fixed a lot of compiler warnings and errors detected by Forte C++ on Solaris · e53a73e2
      monty@mysql.com/nosik.monty.fi authored
      Faster thr_alarm()
      Added 'Opened_files' status variable to track calls to my_open()
      Don't give warnings when running mysql_install_db
      Added option --source-install to mysql_install_db
      
      I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems
      index_read()      -> index_read_map()
      index_read_idx()  -> index_read_idx_map()
      index_read_last() -> index_read_last_map()
      e53a73e2
  6. 27 Jul, 2007 1 commit
    • malff/marcsql@weblab.(none)'s avatar
      WL#3984 (Revise locking of mysql.general_log and mysql.slow_log) · c7bbd891
      malff/marcsql@weblab.(none) authored
      Bug#25422 (Hang with log tables)
      Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
                thread)
      Bug 23044 (Warnings on flush of a log table)
      Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
                 a deadlock)
      
      Prior to this fix, the server would hang when performing concurrent
      ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
      which are mysql.general_log and mysql.slow_log.
      
      The root cause traces to the following code:
      in sql_base.cc, open_table()
        if (table->in_use != thd)
        {
          /* wait_for_condition will unlock LOCK_open for us */
          wait_for_condition(thd, &LOCK_open, &COND_refresh);
        }
      The problem with this code is that the current implementation of the
      LOGGER creates 'fake' THD objects, like
      - Log_to_csv_event_handler::general_log_thd
      - Log_to_csv_event_handler::slow_log_thd
      which are not associated to a real thread running in the server,
      so that waiting for these non-existing threads to release table locks
      cause the dead lock.
      
      In general, the design of Log_to_csv_event_handler does not fit into the
      general architecture of the server, so that the concept of general_log_thd
      and slow_log_thd has to be abandoned:
      - this implementation does not work with table locking
      - it will not work with commands like SHOW PROCESSLIST
      - having the log tables always opened does not integrate well with DDL
      operations / FLUSH TABLES / SET GLOBAL READ_ONLY
      
      With this patch, the fundamental design of the LOGGER has been changed to:
      - always open and close a log table when writing a log
      - remove totally the usage of fake THD objects
      - clarify how locking of log tables is implemented in general.
      
      See WL#3984 for details related to the new locking design.
      
      Additional changes (misc bugs exposed and fixed):
      
      1)
      
      mysqldump which would ignore some tables in dump_all_tables_in_db(),
       but forget to ignore the same in dump_all_views_in_db().
      
      2)
      
      mysqldump would also issue an empty "LOCK TABLE" command when all the tables
      to lock are to be ignored (numrows == 0), instead of not issuing the query.
      
      3)
      
      Internal errors handlers could intercept errors but not warnings
      (see sql_error.cc).
      
      4)
      
      Implementing a nested call to open tables, for the performance schema tables,
      exposed an existing bug in remove_table_from_cache(), which would perform:
        in_use->some_tables_deleted=1;
      against another thread, without any consideration about thread locking.
      This call inside remove_table_from_cache() was not required anyway,
      since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
      that might hold a lock on a table.
      This line (in_use->some_tables_deleted=1) has been removed.
      c7bbd891
  7. 15 Jun, 2007 1 commit
    • iggy@alf.'s avatar
      Embedded Server doesn't build on Windows. · c15a2647
      iggy@alf. authored
      - Add build configuration parameter EMBEDDED_ONLY which will configure 
      the VS solution to produce only mysql embedded binary.
      - Make necessary updates to successfully compile solution.
      c15a2647
  8. 08 Jun, 2007 1 commit
  9. 28 May, 2007 1 commit
    • mats@kindahl-laptop.dnsalias.net's avatar
      WL#3303 (RBR: Engine-controlled logging format): · 9a92325c
      mats@kindahl-laptop.dnsalias.net authored
      Adding support to allow engines to tell what formats they can handle.
      The server will generate an error if it is not possible to log the
      statement according to the logging mode in effect.
      
      Adding flags to several storage engines to state what they can handle.
      
      Changes to NDB handler removing code that forces row-based mode and
      adding flag saying that NDB can only handle row format.
      
      Adding check that binlog flags are only used for real tables that are
      opened for writing.
      9a92325c
  10. 10 May, 2007 1 commit
    • monty@mysql.com/narttu.mysql.fi's avatar
      WL#3817: Simplify string / memory area types and make things more consistent (first part) · 088e2395
      monty@mysql.com/narttu.mysql.fi authored
      The following type conversions was done:
      
      - Changed byte to uchar
      - Changed gptr to uchar*
      - Change my_string to char *
      - Change my_size_t to size_t
      - Change size_s to size_t
      
      Removed declaration of byte, gptr, my_string, my_size_t and size_s. 
      
      Following function parameter changes was done:
      - All string functions in mysys/strings was changed to use size_t
        instead of uint for string lengths.
      - All read()/write() functions changed to use size_t (including vio).
      - All protocoll functions changed to use size_t instead of uint
      - Functions that used a pointer to a string length was changed to use size_t*
      - Changed malloc(), free() and related functions from using gptr to use void *
        as this requires fewer casts in the code and is more in line with how the
        standard functions work.
      - Added extra length argument to dirname_part() to return the length of the
        created string.
      - Changed (at least) following functions to take uchar* as argument:
        - db_dump()
        - my_net_write()
        - net_write_command()
        - net_store_data()
        - DBUG_DUMP()
        - decimal2bin() & bin2decimal()
      - Changed my_compress() and my_uncompress() to use size_t. Changed one
        argument to my_uncompress() from a pointer to a value as we only return
        one value (makes function easier to use).
      - Changed type of 'pack_data' argument to packfrm() to avoid casts.
      - Changed in readfrm() and writefrom(), ha_discover and handler::discover()
        the type for argument 'frmdata' to uchar** to avoid casts.
      - Changed most Field functions to use uchar* instead of char* (reduced a lot of
        casts).
      - Changed field->val_xxx(xxx, new_ptr) to take const pointers.
      
      Other changes:
      - Removed a lot of not needed casts
      - Added a few new cast required by other changes
      - Added some cast to my_multi_malloc() arguments for safety (as string lengths
        needs to be uint, not size_t).
      - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
        explicitely as this conflict was often hided by casting the function to
        hash_get_key).
      - Changed some buffers to memory regions to uchar* to avoid casts.
      - Changed some string lengths from uint to size_t.
      - Changed field->ptr to be uchar* instead of char*. This allowed us to
        get rid of a lot of casts.
      - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
      - Include zlib.h in some files as we needed declaration of crc32()
      - Changed MY_FILE_ERROR to be (size_t) -1.
      - Changed many variables to hold the result of my_read() / my_write() to be
        size_t. This was needed to properly detect errors (which are
        returned as (size_t) -1).
      - Removed some very old VMS code
      - Changed packfrm()/unpackfrm() to not be depending on uint size
        (portability fix)
      - Removed windows specific code to restore cursor position as this
        causes slowdown on windows and we should not mix read() and pread()
        calls anyway as this is not thread safe. Updated function comment to
        reflect this. Changed function that depended on original behavior of
        my_pwrite() to itself restore the cursor position (one such case).
      - Added some missing checking of return value of malloc().
      - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
      - Changed type of table_def::m_size from my_size_t to ulong to reflect that
        m_size is the number of elements in the array, not a string/memory
        length.
      - Moved THD::max_row_length() to table.cc (as it's not depending on THD).
        Inlined max_row_length_blob() into this function.
      - More function comments
      - Fixed some compiler warnings when compiled without partitions.
      - Removed setting of LEX_STRING() arguments in declaration (portability fix).
      - Some trivial indentation/variable name changes.
      - Some trivial code simplifications:
        - Replaced some calls to alloc_root + memcpy to use
          strmake_root()/strdup_root().
        - Changed some calls from memdup() to strmake() (Safety fix)
        - Simpler loops in client-simple.c
      088e2395
  11. 22 Mar, 2007 1 commit
  12. 21 Mar, 2007 1 commit
  13. 16 Mar, 2007 1 commit
  14. 09 Mar, 2007 1 commit
    • kroki/tomash@moonlight.home's avatar
      BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked · c19affef
      kroki/tomash@moonlight.home authored
      The problem was that some facilities (like CONVERT_TZ() function or
      server HELP statement) may require implicit access to some tables in
      'mysql' database.  This access was done by ordinary means of adding
      such tables to the list of tables the query is going to open.
      However, if we issued LOCK TABLES before that, we would get "table
      was not locked" error trying to open such implicit tables.
      
      The solution is to treat certain tables as MySQL system tables, like
      we already do for mysql.proc.  Such tables may be opened for reading
      at any moment regardless of any locks in effect.  The cost of this is
      that system table may be locked for writing only together with other
      system tables, it is disallowed to lock system tables for writing and
      have any other lock on any other table.
      
      After this patch the following tables are treated as MySQL system
      tables:
        mysql.help_category
        mysql.help_keyword
        mysql.help_relation
        mysql.help_topic
        mysql.proc (it already was)
        mysql.time_zone
        mysql.time_zone_leap_second
        mysql.time_zone_name
        mysql.time_zone_transition
        mysql.time_zone_transition_type
      
      These tables are now opened with open_system_tables_for_read() and
      closed with close_system_tables(), or one table may be opened with
      open_system_table_for_update() and closed with close_thread_tables()
      (the latter is used for mysql.proc table, which is updated as part of
      normal MySQL server operation).  These functions may be used when
      some tables were opened and locked already.
      
      NOTE: online update of time zone tables is not possible during
      replication, because there's no time zone cache flush neither on LOCK
      TABLES, nor on FLUSH TABLES, so the master may serve stale time zone
      data from cache, while on slave updated data will be loaded from the
      time zone tables.
      c19affef
  15. 05 Mar, 2007 1 commit
    • gkodinov/kgeorge@macbook.gmz's avatar
      WL#3527: Extend IGNORE INDEX so places where index is ignored · b9c82eaa
      gkodinov/kgeorge@macbook.gmz authored
               can be specified
      Currently MySQL allows one to specify what indexes to ignore during
      join optimization. The scope of the current USE/FORCE/IGNORE INDEX 
      statement is only the FROM clause, while all other clauses are not 
      affected.
      
      However, in certain cases, the optimizer
      may incorrectly choose an index for sorting and/or grouping, and
      produce an inefficient query plan.
      
      This task provides the means to specify what indexes are
      ignored/used for what operation in a more fine-grained manner, thus
      making it possible to manually force a better plan. We do this
      by extending the current IGNORE/USE/FORCE INDEX syntax to:
      
      IGNORE/USE/FORCE INDEX [FOR {JOIN | ORDER | GROUP BY}]
      
      so that:
      - if no FOR is specified, the index hint will apply everywhere.
      - if MySQL is started with the compatibility option --old_mode then
        an index hint without a FOR clause works as in 5.0 (i.e, the 
        index will only be ignored for JOINs, but can still be used to
        compute ORDER BY).
      
      See the WL#3527 for further details.
      b9c82eaa
  16. 02 Mar, 2007 1 commit
    • antony@ppcg5.local's avatar
      WL#2936 · dc24473c
      antony@ppcg5.local authored
        "Server Variables for Plugins"
        Implement support for plugins to declare server variables.
        Demonstrate functionality by removing InnoDB specific code from sql/*
        New feature for HASH - HASH_UNIQUE flag
        New feature for DYNAMIC_ARRAY - initializer accepts preallocated ptr.
        Completed support for plugin reference counting.
      dc24473c
  17. 13 Feb, 2007 1 commit
  18. 31 Jan, 2007 1 commit
    • istruewing@chilla.local's avatar
      Bug#17332 - changing key_buffer_size on a running server · 48a596ed
      istruewing@chilla.local authored
                  can crash under load
      
      Resizing a key cache while it was in heavy use could crash the
      server. There were several race conditions.
      
      I reworked some of the algorithms to fix the race conditions.
      
      No test case. Repeating the crashes requires heavy concurrent
      load on the key cache. A test script is attached to the bug report.
      
      More explanations to the changes are contained in a text file
      attached to the bug report.
      48a596ed
  19. 29 Jan, 2007 1 commit
  20. 28 Dec, 2006 1 commit
  21. 02 Dec, 2006 1 commit
  22. 21 Nov, 2006 1 commit
    • monty@mysql.com/nosik.monty.fi's avatar
      Added --debug-info to most clients to detect memory leaks in mysql-test-run · f6682e27
      monty@mysql.com/nosik.monty.fi authored
      Moved .progress files into the log directory
      Moved 'cluster' database tables into the MySQL database, to not have 'cluster' beeing a reserved database name
      Fixed bug where mysqld got a core dump when trying to use a table created by MySQL 3.23
      Fixed some compiler warnings
      Fixed small memory leak in libmysql
      Note that this doesn't changeset doesn't include the new mysqldump.c code required to run some tests. This will be added when I merge 5.0 to 5.1
      f6682e27
  23. 13 Oct, 2006 1 commit
    • petr/cps@mysql.com/owlet.local's avatar
      Fix for Bug #17544 "Cannot do atomic log rotate", · 6846f8d9
      petr/cps@mysql.com/owlet.local authored
      Bug #21785 "Server crashes after rename of the log table" and
      Bug #21966 "Strange warnings on create like/repair of the log
                  tables"
      
      According to the patch, from now on, one should use RENAME to
      perform a log table rotation (this should also be reflected in
      the manual).
      
      Here is a sample:
      
      use mysql;
      CREATE TABLE IF NOT EXISTS general_log2 LIKE general_log;
      RENAME TABLE general_log TO general_log_backup, general_log2 TO general_log;
      
      The rules for Rename of the log tables are following:
            IF   1. Log tables are enabled
            AND  2. Rename operates on the log table and nothing is being
                    renamed to the log table.
            DO   3. Throw an error message.
            ELSE 4. Perform rename.
       
      The very RENAME query will go the the old (backup) table. This is
      consistent with the behavoiur we have with binlog ROTATE LOGS
      statement.
      
      Other problems, which are solved by the patch are:
      
      1) Now REPAIR of the log table is exclusive operation (as it should be), this
         also eliminates lock-related warnings. and
      2) CREATE LIKE TABLE now usese usual read lock on the source table rather
         then name lock, which is too restrictive. This way we get rid of another
         log table-related warning, which occured because of the above fact
         (as a side-effect, name lock resulted in a warning).
      6846f8d9
  24. 05 Oct, 2006 1 commit
  25. 30 Sep, 2006 2 commits
  26. 27 Sep, 2006 1 commit
  27. 15 Sep, 2006 2 commits
    • brian@zim.(none)'s avatar
      This changes the order of the universe, black is now the new white. · 7194b6d7
      brian@zim.(none) authored
      In practice this means that handlerton is now created by the server and is passed to the engine. Plugin startups can now also control how plugins are inited (and can optionally pass values). Bit more flexibility to those who want to write plugin interfaces to the database. 
      7194b6d7
    • petr/cps@mysql.com/owlet.local's avatar
      Post-review fixes for · f6663df6
      petr/cps@mysql.com/owlet.local authored
      Bug #18559 "log tables cannot change engine, and
                  gets deadlocked when dropping w/ log on":
      1) Add more generic error messages
      2) Add new handlerton flag for engines, which support
         log tables
      3) Remove (log-tables related) mutex lock in myisam to
         improve performance
      f6663df6
  28. 30 Aug, 2006 1 commit
  29. 22 Aug, 2006 1 commit
    • brian@zim.(none)'s avatar
      This changest: · b5187637
      brian@zim.(none) authored
      Plugins now when compiled or not compiled work correctly with status variables. 
      Status variables from plugins now set their own names (removed bit where plugin name was pre-appended this broke Innodb and Cluster)
      A few Makefile cleanups. 
      b5187637
  30. 20 Aug, 2006 1 commit
  31. 10 Aug, 2006 1 commit
  32. 03 Aug, 2006 1 commit
    • petr/cps@mysql.com/owlet.'s avatar
      Fix Bug #18559 "log tables cannot change engine, and · be2ce261
      petr/cps@mysql.com/owlet. authored
                      gets deadlocked when dropping w/ log on"
      
      Log tables rely on concurrent insert machinery to add data.
      This means that log tables are always opened and locked by
      special (artificial) logger threads. Because of this, the thread
      which tries to drop a log table starts to wait for the table
      to be unlocked. Which will happen only if the log table is disabled.
      Alike situation happens if one tries to alter a log table.
      However in addition to the problem above, alter table calls
      check_if_locking_is_allowed() routine for the engine. The
      routine does not allow alter for the log tables. So, alter
      doesn't start waiting forever for logs to be disabled, but 
      returns with an error.
      Another problem is that not all engines could be used for
      the log tables. That's because they need concurrent insert.
      
      In this patch we:
      (1) Explicitly disallow to drop/alter a log table if it
          is currently used by the logger.
      (2) Update MyISAM to support log tables
      (3) Allow to drop log tables/alter log tables if log is
          disabled
      At the same time we (4) Disallow to alter log tables to
      unsupported engine (after this patch CSV and MyISAM are 
      alowed)
      Recommit with review fixes.
      be2ce261
  33. 02 Aug, 2006 1 commit
    • ingo/istruewing@chilla.local's avatar
      Bug#18775 - Temporary table from alter table visible to other threads · 8e4c36ad
      ingo/istruewing@chilla.local authored
      Continued implementation of WL#1324 (table name to filename encoding)
      
      The intermediate (not temporary) files of the new table
      during ALTER TABLE was visible for SHOW TABLES. These
      intermediate files are copies of the original table with
      the changes done by ALTER TABLE. After all the data is
      copied over from the original table, these files are renamed 
      to the original tables file names. So they are not temporary 
      files. They persist after ALTER TABLE, but just with another 
      name.
      
      In 5.0 the intermediate files are invisible for SHOW TABLES
      because all file names beginning with "#sql" were suppressed.
      
      This failed since 5.1.6 because even temporary table names were
      converted when making file names from them. The prefix became
      converted to "@0023sql". Converting the prefix during SHOW TABLES
      would suppress the listing of user tables that start with "#sql".
      
      The solution of the problem is to continue the implementation of
      the table name to file name conversion feature. One requirement
      is to suppress the conversion for temporary table names.
      
      This change is straightforward for real temporary tables as there
      is a function that creates temporary file names.
      
      But the generated path names are located in TMPDIR and have no
      relation to the internal table name. This cannot be used for
      ALTER TABLE. Its intermediate files need to be in the same
      directory as the old table files. And it is necessary to be
      able to deduce the same path from the same table name repeatedly.
      
      Consequently the intermediate table files must be handled like normal
      tables. Their internal names shall start with tmp_file_prefix
      (#sql) and they shall not be converted like normal table names.
      
      I added a flags parameter to all relevant functions that are
      called from ALTER TABLE. It is used to suppress the conversion
      for the intermediate table files.
      
      The outcome is that the suppression of #sql in SHOW TABLES
      works again. It does not suppress user tables as these are
      converted to @0023sql on file level.
      
      This patch does also fix ALTER TABLE ... RENAME, which could not 
      rename a table with non-ASCII characters in its name.
      
      It does also fix the problem that a user could create a table like
      `#sql-xxxx-yyyy`, where xxxx is mysqld's pid and yyyy is the thread
      ID of some other thread, which prevented this thread from running 
      ALTER TABLE.
      
      Some of the above problems are mentioned in Bug 1405, which can
      be closed with this patch.
      
      This patch does also contain some minor fixes for other forgotten
      conversions. Still known problems are reported as bugs 21370,
      21373, and 21387.
      8e4c36ad
  34. 15 Jul, 2006 1 commit
  35. 04 Jun, 2006 1 commit
    • monty@mysql.com's avatar
      This changeset is largely a handler cleanup changeset (WL#3281), but includes... · 74cc73d4
      monty@mysql.com authored
      This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
      
      Changes that requires code changes in other code of other storage engines.
      (Note that all changes are very straightforward and one should find all issues
      by compiling a --debug build and fixing all compiler errors and all
      asserts in field.cc while running the test suite),
      
      - New optional handler function introduced: reset()
        This is called after every DML statement to make it easy for a handler to
        statement specific cleanups.
        (The only case it's not called is if force the file to be closed)
      
      - handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
        should be moved to handler::reset()
      
      - table->read_set contains a bitmap over all columns that are needed
        in the query.  read_row() and similar functions only needs to read these
        columns
      - table->write_set contains a bitmap over all columns that will be updated
        in the query. write_row() and update_row() only needs to update these
        columns.
        The above bitmaps should now be up to date in all context
        (including ALTER TABLE, filesort()).
      
        The handler is informed of any changes to the bitmap after
        fix_fields() by calling the virtual function
        handler::column_bitmaps_signal(). If the handler does caching of
        these bitmaps (instead of using table->read_set, table->write_set),
        it should redo the caching in this code. as the signal() may be sent
        several times, it's probably best to set a variable in the signal
        and redo the caching on read_row() / write_row() if the variable was
        set.
      
      - Removed the read_set and write_set bitmap objects from the handler class
      
      - Removed all column bit handling functions from the handler class.
        (Now one instead uses the normal bitmap functions in my_bitmap.c instead
        of handler dedicated bitmap functions)
      
      - field->query_id is removed. One should instead instead check
        table->read_set and table->write_set if a field is used in the query.
      
      - handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
        handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
        instead use table->read_set to check for which columns to retrieve.
      
      - If a handler needs to call Field->val() or Field->store() on columns
        that are not used in the query, one should install a temporary
        all-columns-used map while doing so. For this, we provide the following
        functions:
      
        my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
        field->val();
        dbug_tmp_restore_column_map(table->read_set, old_map);
      
        and similar for the write map:
      
        my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
        field->val();
        dbug_tmp_restore_column_map(table->write_set, old_map);
      
        If this is not done, you will sooner or later hit a DBUG_ASSERT
        in the field store() / val() functions.
        (For not DBUG binaries, the dbug_tmp_restore_column_map() and
        dbug_tmp_restore_column_map() are inline dummy functions and should
        be optimized away be the compiler).
      
      - If one needs to temporary set the column map for all binaries (and not
        just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
        methods) one should use the functions tmp_use_all_columns() and
        tmp_restore_column_map() instead of the above dbug_ variants.
      
      - All 'status' fields in the handler base class (like records,
        data_file_length etc) are now stored in a 'stats' struct. This makes
        it easier to know what status variables are provided by the base
        handler.  This requires some trivial variable names in the extra()
        function.
      
      - New virtual function handler::records().  This is called to optimize
        COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
        (stats.records is not supposed to be an exact value. It's only has to
        be 'reasonable enough' for the optimizer to be able to choose a good
        optimization path).
      
      - Non virtual handler::init() function added for caching of virtual
        constants from engine.
      
      - Removed has_transactions() virtual method. Now one should instead return
        HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
        transactions.
      
      - The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
        that is to be used with 'new handler_name()' to allocate the handler
        in the right area.  The xxxx_create_handler() function is also
        responsible for any initialization of the object before returning.
      
        For example, one should change:
      
        static handler *myisam_create_handler(TABLE_SHARE *table)
        {
          return new ha_myisam(table);
        }
      
        ->
      
        static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
        {
          return new (mem_root) ha_myisam(table);
        }
      
      - New optional virtual function: use_hidden_primary_key().
        This is called in case of an update/delete when
        (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
        but we don't have a primary key. This allows the handler to take precisions
        in remembering any hidden primary key to able to update/delete any
        found row. The default handler marks all columns to be read.
      
      - handler::table_flags() now returns a ulonglong (to allow for more flags).
      
      - New/changed table_flags()
        - HA_HAS_RECORDS	    Set if ::records() is supported
        - HA_NO_TRANSACTIONS	    Set if engine doesn't support transactions
        - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
                                  Set if we should mark all primary key columns for
      			    read when reading rows as part of a DELETE
      			    statement. If there is no primary key,
      			    all columns are marked for read.
        - HA_PARTIAL_COLUMN_READ  Set if engine will not read all columns in some
      			    cases (based on table->read_set)
       - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
         			    Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
       - HA_DUPP_POS              Renamed to HA_DUPLICATE_POS
       - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
      			    Set this if we should mark ALL key columns for
      			    read when when reading rows as part of a DELETE
      			    statement. In case of an update we will mark
      			    all keys for read for which key part changed
      			    value.
        - HA_STATS_RECORDS_IS_EXACT
      			     Set this if stats.records is exact.
      			     (This saves us some extra records() calls
      			     when optimizing COUNT(*))
      			    
      
      - Removed table_flags()
        - HA_NOT_EXACT_COUNT     Now one should instead use HA_HAS_RECORDS if
      			   handler::records() gives an exact count() and
      			   HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
        - HA_READ_RND_SAME	   Removed (no one supported this one)
      
      - Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
      
      - Renamed handler::dupp_pos to handler::dup_pos
      
      - Removed not used variable handler::sortkey
      
      
      Upper level handler changes:
      
      - ha_reset() now does some overall checks and calls ::reset()
      - ha_table_flags() added. This is a cached version of table_flags(). The
        cache is updated on engine creation time and updated on open.
      
      
      MySQL level changes (not obvious from the above):
      
      - DBUG_ASSERT() added to check that column usage matches what is set
        in the column usage bit maps. (This found a LOT of bugs in current
        column marking code).
      
      - In 5.1 before, all used columns was marked in read_set and only updated
        columns was marked in write_set. Now we only mark columns for which we
        need a value in read_set.
      
      - Column bitmaps are created in open_binary_frm() and open_table_from_share().
        (Before this was in table.cc)
      
      - handler::table_flags() calls are replaced with handler::ha_table_flags()
      
      - For calling field->val() you must have the corresponding bit set in
        table->read_set. For calling field->store() you must have the
        corresponding bit set in table->write_set. (There are asserts in
        all store()/val() functions to catch wrong usage)
      
      - thd->set_query_id is renamed to thd->mark_used_columns and instead
        of setting this to an integer value, this has now the values:
        MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
        Changed also all variables named 'set_query_id' to mark_used_columns.
      
      - In filesort() we now inform the handler of exactly which columns are needed
        doing the sort and choosing the rows.
      
      - The TABLE_SHARE object has a 'all_set' column bitmap one can use
        when one needs a column bitmap with all columns set.
        (This is used for table->use_all_columns() and other places)
      
      - The TABLE object has 3 column bitmaps:
        - def_read_set     Default bitmap for columns to be read
        - def_write_set    Default bitmap for columns to be written
        - tmp_set          Can be used as a temporary bitmap when needed.
        The table object has also two pointer to bitmaps read_set and write_set
        that the handler should use to find out which columns are used in which way.
      
      - count() optimization now calls handler::records() instead of using
        handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
      
      - Added extra argument to Item::walk() to indicate if we should also
        traverse sub queries.
      
      - Added TABLE parameter to cp_buffer_from_ref()
      
      - Don't close tables created with CREATE ... SELECT but keep them in
        the table cache. (Faster usage of newly created tables).
      
      
      New interfaces:
      
      - table->clear_column_bitmaps() to initialize the bitmaps for tables
        at start of new statements.
      
      - table->column_bitmaps_set() to set up new column bitmaps and signal
        the handler about this.
      
      - table->column_bitmaps_set_no_signal() for some few cases where we need
        to setup new column bitmaps but don't signal the handler (as the handler
        has already been signaled about these before). Used for the momement
        only in opt_range.cc when doing ROR scans.
      
      - table->use_all_columns() to install a bitmap where all columns are marked
        as use in the read and the write set.
      
      - table->default_column_bitmaps() to install the normal read and write
        column bitmaps, but not signaling the handler about this.
        This is mainly used when creating TABLE instances.
      
      - table->mark_columns_needed_for_delete(),
        table->mark_columns_needed_for_delete() and
        table->mark_columns_needed_for_insert() to allow us to put additional
        columns in column usage maps if handler so requires.
        (The handler indicates what it neads in handler->table_flags())
      
      - table->prepare_for_position() to allow us to tell handler that it
        needs to read primary key parts to be able to store them in
        future table->position() calls.
        (This replaces the table->file->ha_retrieve_all_pk function)
      
      - table->mark_auto_increment_column() to tell handler are going to update
        columns part of any auto_increment key.
      
      - table->mark_columns_used_by_index() to mark all columns that is part of
        an index.  It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
        it to quickly know that it only needs to read colums that are part
        of the key.  (The handler can also use the column map for detecting this,
        but simpler/faster handler can just monitor the extra() call).
      
      - table->mark_columns_used_by_index_no_reset() to in addition to other columns,
        also mark all columns that is used by the given key.
      
      - table->restore_column_maps_after_mark_index() to restore to default
        column maps after a call to table->mark_columns_used_by_index().
      
      - New item function register_field_in_read_map(), for marking used columns
        in table->read_map. Used by filesort() to mark all used columns
      
      - Maintain in TABLE->merge_keys set of all keys that are used in query.
        (Simplices some optimization loops)
      
      - Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
        but the field in the clustered key is not assumed to be part of all index.
        (used in opt_range.cc for faster loops)
      
      -  dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
         tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
         mark all columns as usable.  The 'dbug_' version is primarily intended
         inside a handler when it wants to just call Field:store() & Field::val()
         functions, but don't need the column maps set for any other usage.
         (ie:: bitmap_is_set() is never called)
      
      - We can't use compare_records() to skip updates for handlers that returns
        a partial column set and the read_set doesn't cover all columns in the
        write set. The reason for this is that if we have a column marked only for
        write we can't in the MySQL level know if the value changed or not.
        The reason this worked before was that MySQL marked all to be written
        columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
        bug'.
      
      - open_table_from_share() does not anymore setup temporary MEM_ROOT
        object as a thread specific variable for the handler. Instead we
        send the to-be-used MEMROOT to get_new_handler().
        (Simpler, faster code)
      
      
      
      Bugs fixed:
      
      - Column marking was not done correctly in a lot of cases.
        (ALTER TABLE, when using triggers, auto_increment fields etc)
        (Could potentially result in wrong values inserted in table handlers
        relying on that the old column maps or field->set_query_id was correct)
        Especially when it comes to triggers, there may be cases where the
        old code would cause lost/wrong values for NDB and/or InnoDB tables.
      
      - Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
        OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
        This allowed me to remove some wrong warnings about:
        "Some non-transactional changed tables couldn't be rolled back"
      
      - Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
        (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
        some warnings about
        "Some non-transactional changed tables couldn't be rolled back")
      
      - Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
        which could cause delete_table to report random failures.
      
      - Fixed core dumps for some tests when running with --debug
      
      - Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
        (This has probably caused us to not properly remove temporary files after
        crash)
      
      - slow_logs was not properly initialized, which could maybe cause
        extra/lost entries in slow log.
      
      - If we get an duplicate row on insert, change column map to read and
        write all columns while retrying the operation. This is required by
        the definition of REPLACE and also ensures that fields that are only
        part of UPDATE are properly handled.  This fixed a bug in NDB and
        REPLACE where REPLACE wrongly copied some column values from the replaced
        row.
      
      - For table handler that doesn't support NULL in keys, we would give an error
        when creating a primary key with NULL fields, even after the fields has been
        automaticly converted to NOT NULL.
      
      - Creating a primary key on a SPATIAL key, would fail if field was not
        declared as NOT NULL.
      
      
      Cleanups:
      
      - Removed not used condition argument to setup_tables
      
      - Removed not needed item function reset_query_id_processor().
      
      - Field->add_index is removed. Now this is instead maintained in
        (field->flags & FIELD_IN_ADD_INDEX)
      
      - Field->fieldnr is removed (use field->field_index instead)
      
      - New argument to filesort() to indicate that it should return a set of
        row pointers (not used columns). This allowed me to remove some references
        to sql_command in filesort and should also enable us to return column
        results in some cases where we couldn't before.
      
      - Changed column bitmap handling in opt_range.cc to be aligned with TABLE
        bitmap, which allowed me to use bitmap functions instead of looping over
        all fields to create some needed bitmaps. (Faster and smaller code)
      
      - Broke up found too long lines
      
      - Moved some variable declaration at start of function for better code
        readability.
      
      - Removed some not used arguments from functions.
        (setup_fields(), mysql_prepare_insert_check_table())
      
      - setup_fields() now takes an enum instead of an int for marking columns
         usage.
      
      - For internal temporary tables, use handler::write_row(),
        handler::delete_row() and handler::update_row() instead of
        handler::ha_xxxx() for faster execution.
      
      - Changed some constants to enum's and define's.
      
      - Using separate column read and write sets allows for easier checking
        of timestamp field was set by statement.
      
      - Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
      
      - Don't build table->normalized_path as this is now identical to table->path
        (after bar's fixes to convert filenames)
      
      - Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
        do comparision with the 'convert-dbug-for-diff' tool.
      
      
      Things left to do in 5.1:
      
      - We wrongly log failed CREATE TABLE ... SELECT in some cases when using
        row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
        Mats has promised to look into this.
      
      - Test that my fix for CREATE TABLE ... SELECT is indeed correct.
        (I added several test cases for this, but in this case it's better that
        someone else also tests this throughly).
        Lars has promosed to do this.
      74cc73d4
  36. 02 Jun, 2006 1 commit
    • guilhem@mysql.com's avatar
      First push for WL#3146 "less locking in auto_increment". It is a 0-real-change patch. · a4e778f3
      guilhem@mysql.com authored
      New prototype for get_auto_increment() (but new arguments not yet used), to be able
      to reserve a finite interval of auto_increment values from cooperating engines.
      A hint on how many values to reserve is found in handler::estimation_rows_to_insert,
      filled by ha_start_bulk_insert(), new wrapper around start_bulk_insert().
      NOTE: this patch changes nothing, for all engines. But it makes the API ready for those
      engines which will want to do reservation.
      More csets will come to complete WL#3146.
      a4e778f3
  37. 01 Jun, 2006 1 commit
  38. 28 May, 2006 1 commit
    • serg@sergbook.mysql.com's avatar
      handlerton cleanup: · fe97dbb5
      serg@sergbook.mysql.com authored
      duplicate fields removed, st_mysql_storage_engine added to support
      run-time handlerton initialization (no compiler warnings), handler API
      is now tied to MySQL version, handlerton->plugin mapping added
      (slot-based), dummy default_hton removed, plugin-type-specific
      initialization generalized, built-in plugins are now initialized too,
      --default-storage-engine no longer needs a list of storage engines
      in handle_options().
      
      mysql-test-run.pl bugfixes
      fe97dbb5