An error occurred fetching the project authors.
  1. 30 Nov, 2006 1 commit
  2. 26 Nov, 2006 1 commit
    • unknown's avatar
      Fixed a LOT of compiler warnings · 788ad30f
      unknown authored
      Added missing DBUG_RETURN statements (in mysqldump.c)
      Added missing enums
      Fixed a lot of wrong DBUG_PRINT() statements, some of which could cause crashes
      Removed usage of %lld and %p in printf strings as these are not portable or produces different results on different systems.
      
      
      client/mysqldump.c:
        Fixed some compiler warnings
        Added some missing DBUG_RETURN
        Remove copying of 'cluster' database
      client/mysqlslap.c:
        Fixed compiler warnings
      client/mysqltest.c:
        After merge fix
      extra/yassl/taocrypt/include/algebra.hpp:
        Removed compiler warning
      mysql-test/include/im_check_env.inc:
        Fixed race condition (mysqld1 could report 'starting' or 'online'
      mysql-test/mysql-test-run.pl:
        After merge fixes
        Added missing directory to LD_LIBRARY_PATH
      mysql-test/r/ctype_cp1250_ch.result:
        After merge fix
      mysql-test/r/im_cmd_line.result:
        Fixed race condition
      mysql-test/r/im_daemon_life_cycle.result:
        Fixed race condition
      mysql-test/r/im_instance_conf.result:
        Fixed race condition
      mysql-test/r/im_life_cycle.result:
        Fixed race condition
      mysql-test/r/im_utils.result:
        Fixed race condition
      mysql-test/r/log_tables.result:
        Fixed wrong result
      mysql-test/t/disabled.def:
        Disabled ndb_restore_partion, as ndb_restore_compate caused it to fail, becasue of table 'cluster/def/schema' which is stored in ndb_backup50
      mysys/my_compress.c:
        Removed compiler warnings
      mysys/my_getopt.c:
        Ensure we always have at least one space between option name and value
      plugin/fulltext/plugin_example.c:
        Removed compiler warnings
      server-tools/instance-manager/mysql_connection.cc:
        After merge fix
      sql/event_data_objects.cc:
        Fixed compiler warnings
        Fixed platform compatibility issues (%lld is not portable)
      sql/event_data_objects.h:
        Fixed compiler warnings
      sql/event_db_repository.cc:
        Fixed compiler warnings
      sql/event_queue.cc:
        Fixed compiler warnings
      sql/event_scheduler.cc:
        Fixed compiler warnings
      sql/events.cc:
        Fixed compiler warnings
      sql/field.cc:
        Fixed compiler warnings
      sql/ha_ndbcluster.cc:
        Fixed compiler warnings
      sql/ha_ndbcluster_binlog.cc:
        Fixed compiler warnings
      sql/ha_partition.cc:
        Fixed compiler warnings
      sql/handler.cc:
        Fixed compiler warnings
      sql/item_cmpfunc.cc:
        Fixed DBUG_PRINT style
      sql/item_func.cc:
        Fixed compiler warnings
      sql/log.cc:
        Fixed compiler warnings
      sql/log_event.cc:
        Fixed compiler warnings
      sql/mysqld.cc:
        Fixed compiler warnings
      sql/opt_range.cc:
        Fixed compiler warnings
      sql/repl_failsafe.cc:
        Indentation fixes
      sql/rpl_rli.cc:
        Fixed compiler warnings
      sql/rpl_tblmap.cc:
        Fixed compiler warnings
      sql/set_var.cc:
        Fixed compiler warnings
      sql/slave.cc:
        Fixed compiler warnings
      sql/sp_head.cc:
        Fixed compiler warnings
      sql/sql_base.cc:
        Fixed compiler warnings
        Fixed indentation
      sql/sql_binlog.cc:
        Fixed compiler warnings
      sql/sql_cache.cc:
        Fixed compiler warnings
      sql/sql_class.cc:
        Fixed compiler warnings
      sql/sql_handler.cc:
        Fixed compiler warnings
      sql/sql_lex.cc:
        Fixed compiler warnings
      sql/sql_parse.cc:
        Fixed compiler warnings
      sql/sql_partition.cc:
        Fixed compiler warnings
      sql/sql_prepare.cc:
        Fixed compiler warnings
      sql/sql_table.cc:
        Fixed compiler warnings
      sql/sql_test.cc:
        Fixed DBUG_PRINT style
      sql/sql_trigger.cc:
        Fixed DBUG_PRINT style
      sql/table.cc:
        Fixed compiler warnings
      storage/federated/ha_federated.cc:
        Fixed compiler warnings
      storage/myisam/mi_rsamepos.c:
        Fixed compiler warnings
      storage/ndb/include/ndb_global.h.in:
        After merge fix
      storage/ndb/include/util/NdbOut.hpp:
        Inform gcc that ndbout_c takes a printf() string as argument
      storage/ndb/include/util/SimpleProperties.hpp:
        After merge fixes
      storage/ndb/src/kernel/blocks/backup/Backup.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
        Fixed compiler warnings
        Fixed usage of uninitialized value (Got help from Jonas with patch)
      storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/lgman.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/pgman.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/restore.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/blocks/suma/Suma.cpp:
        Fixed compiler warnings
        Added missing enum's to switch
      storage/ndb/src/kernel/vm/Configuration.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/vm/DLHashTable.hpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/vm/RWPool.hpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/vm/SimulatedBlock.cpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/vm/WOPool.hpp:
        Fixed compiler warnings
      storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp:
        Fixed compiler warnings
      storage/ndb/src/mgmclient/CommandInterpreter.cpp:
        Fixed compiler warnings
      storage/ndb/src/mgmsrv/MgmtSrvr.cpp:
        Fixed compiler warnings
      storage/ndb/src/ndbapi/DictCache.cpp:
        Fixed compiler warnings
      storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
        Fixed compiler warnings
      storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp:
        Fixed compiler warnings
      storage/ndb/src/ndbapi/NdbIndexOperation.cpp:
        Fixed compiler warnings
      storage/ndb/src/ndbapi/NdbIndexStat.cpp:
        Initialize possible uninitialized variable
      storage/ndb/src/ndbapi/NdbOperationInt.cpp:
        Fixed compiler warnings
      storage/ndb/src/ndbapi/NdbRecAttr.cpp:
        Added missing enum's (To avoid compiler warnings)
      storage/ndb/src/ndbapi/NdbScanOperation.cpp:
        Fixed compiler warnings
      storage/ndb/src/ndbapi/ObjectMap.hpp:
        Fixed compiler warnings
      storage/ndb/tools/desc.cpp:
        Fixed compiler warnings
      storage/ndb/tools/restore/Restore.cpp:
        Fixed compiler warnings
      storage/ndb/tools/restore/consumer_restore.cpp:
        Fixed compiler warnings
      unittest/mytap/t/basic-t.c:
        Fixed compiler warnings
      unittest/mytap/tap.c:
        Fixed compiler warnings
      788ad30f
  3. 13 Nov, 2006 1 commit
    • unknown's avatar
      Bug#23703 (DROP TRIGGER needs an IF EXISTS) · 541e9c9a
      unknown authored
      This change set implements the DROP TRIGGER IF EXISTS functionality.
      
      This fix is considered a bug and not a feature, because without it,
      there is no known method to write a database creation script that can create
      a trigger without failing, when executed on a database that may or may not
      contain already a trigger of the same name.
      
      Implementing this functionality closes an orthogonality gap between triggers
      and stored procedures / stored functions (which do support the DROP IF
      EXISTS syntax).
      
      In sql_trigger.cc, in mysql_create_or_drop_trigger,
      the code has been reordered to:
      - perform the tests that do not depend on the file system (access()),
      - get the locks (wait_if_global_read_lock, LOCK_open)
      - call access()
      - perform the operation
      - write to the binlog
      - unlock (LOCK_open, start_waiting_global_read_lock)
      
      This is to ensure that all the code that depends on the presence of the
      trigger file is executed in the same critical section,
      and prevents race conditions similar to the case fixed by Bug 14262 :
      
      - thread 1 executes DROP TRIGGER IF EXISTS, access() returns a failure
      - thread 2 executes CREATE TRIGGER
      - thread 2 logs CREATE TRIGGER
      - thread 1 logs DROP TRIGGER IF EXISTS
      
      The patch itself is based on code contributed by the MySQL community,
      under the terms of the Contributor License Agreement (See Bug 18161).
      
      
      mysql-test/r/rpl_trigger.result:
        DROP TRIGGER IF EXISTS
      mysql-test/r/trigger.result:
        DROP TRIGGER IF EXISTS
      mysql-test/t/rpl_trigger.test:
        DROP TRIGGER IF EXISTS
      mysql-test/t/trigger.test:
        DROP TRIGGER IF EXISTS
      sql/sql_trigger.cc:
        DROP TRIGGER IF EXISTS
      sql/sql_yacc.yy:
        DROP TRIGGER IF EXISTS
      541e9c9a
  4. 21 Oct, 2006 1 commit
  5. 20 Oct, 2006 2 commits
    • unknown's avatar
      Fix bad merge from #14262. · f565eaf2
      unknown authored
      sql/sql_trigger.cc:
        Correct previous patch regarding binlog-entry type.
      f565eaf2
    • unknown's avatar
      Fix for bug#15228 "'invalid access to non-static data member' · 1a793de9
      unknown authored
      warnings in sql_trigger.cc and sql_view.cc".
      
      According to the current version of C++ standard offsetof() macro
      can't be used for non-POD types. So warnings were emitted when we
      tried to use this macro for TABLE_LIST and Table_triggers_list
      classes. Note that despite of these warnings it was probably safe
      thing to do.
      
      This fix tries to circumvent this limitation by implementing
      custom version of offsetof() macro to be used with these
      classes. This hack should go away once we will refactor
      File_parser class.
      
      Alternative approaches such as disabling this warning for
      sql_trigger.cc/sql_view.cc or for the whole server were
      considered less explicit. Also I was unable to find a way
      to disable particular warning for particular _part_ of
      file in GCC.
      
      
      sql/parse_file.h:
        Introduced auxillary macro which can be used instead of offsetof()
        to get offsets of members in class for non-POD types without getting
        warnings (assuming that all instances of the class has same offsets
        for same members).
      sql/sql_trigger.cc:
        Use my_offsetof() macro instead of standard offsetof() macro with
        Table_triggers_list class in order to avoid warnings (offsetof()
        cannot be used for non-POD types according to the standard).
      sql/sql_view.cc:
        Use my_offsetof() macro instead of standard offsetof() macro with
        TABLE_LIST class in order to avoid warnings (offsetof() cannot
        be used for non-POD types according to the standard).
      1a793de9
  6. 12 Oct, 2006 1 commit
    • unknown's avatar
      Additional patch for 5.1 commit for Bug#14262. · 0b48fb08
      unknown authored
      sql/sp.cc:
        Update binlog-writing scheme to 5.1 model.
      sql/sql_acl.cc:
        Update binlog-writing scheme to 5.1 model.
      sql/sql_trigger.cc:
        Update binlog-writing scheme to 5.1 model.
      0b48fb08
  7. 03 Oct, 2006 1 commit
    • unknown's avatar
      Bug #14262: SP: DROP PROCEDURE|VIEW (maybe more) write to binlog too late \ · e6eef5c1
      unknown authored
      	(race cond)
      
      It was possible for one thread to interrupt a Data Definition Language 
      statement and thereby get messages to the binlog out of order.  Consider:
      
      Connection 1: Drop Foo x
      Connection 2: Create or replace Foo x
      Connection 2: Log "Create or replace Foo x"
      Connection 1: Log "Drop Foo x"
      
      Local end would have Foo x, but the replicated slaves would not.
      
      The fix for this is to wrap all DDL and logging of a kind in the same mutex.  
      Since we already use mutexes for the various parts of altering the server, 
      this only entails moving the logging events down close to the action, inside 
      the mutex protection.
      
      
      BitKeeper/etc/collapsed:
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
        ---
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
        ---
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
        ---
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
        ---
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
        ---
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
        ---
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
        ---
        BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
      sql/sp.cc:
        Move logging inside the routine drop and update functions, so it can be 
        protected by a LOCK_open mutex.  (The "create" function already had such 
        a LOCK_open protection.)
      sql/sql_acl.cc:
        Move logging inside the grant functions, so that it can be protected by 
        LOCK_grant .
      sql/sql_db.cc:
        Add comments that describe how each logging event is protected.
      sql/sql_parse.cc:
        Move all logging statements about DDL statements close to the actual event, 
        so each can be protected by the same mutex.
      sql/sql_table.cc:
        Widen the scope of the mutex so that logging events are also protected.
      sql/sql_trigger.cc:
        Widen the scope of the mutex so that logging events are also protected.
      sql/sql_view.cc:
        Pass the head of the table linked-list so we can create a logging statement.
        
        Move the logging statement inside the worker function, and notably inside 
        the LOCK_open mutex.  Widen the same mutex a little to make room for logging.
      sql/sql_view.h:
        Pass the head of the table linked-list so we can create a logging statement.
      e6eef5c1
  8. 30 Sep, 2006 1 commit
  9. 21 Sep, 2006 1 commit
    • unknown's avatar
      Fix for bug#20670 "UPDATE using key and invoking trigger that modifies · 0e4dd85d
      unknown authored
      this key does not stop" (version for 5.0 only).
      
      UPDATE statement which WHERE clause used key and which invoked trigger
      that modified field in this key worked indefinetely.
      
      This problem occured because in cases when UPDATE statement was
      executed in update-on-the-fly mode (in which row is updated right
      during evaluation of select for WHERE clause) the new version of
      the row became visible to select representing WHERE clause and was
      updated again and again.
      We already solve this problem for UPDATE statements which does not
      invoke triggers by detecting the fact that we are going to update
      field in key used for scanning and performing update in two steps,
      during the first step we gather information about the rows to be
      updated and then doing actual updates. We also do this for
      MULTI-UPDATE and in its case we even detect situation when such
      fields are updated in triggers (actually we simply assume that
      we always update fields used in key if we have before update
      trigger).
      
      The fix simply extends this check which is done in check_if_key_used()/
      QUICK_SELECT_I::check_if_keys_used() routine/method in such way that
      it also detects cases when field used in key is updated in trigger.
      As nice side-effect we have more precise and thus more optimal
      perfomance-wise check for the MULTI-UPDATE.
      Also check_if_key_used()/QUICK_SELECT_I::check_if_keys_used() were
      renamed to is_key_used()/QUICK_SELECT_I::is_keys_used() in order to
      better reflect that boolean predicate.
      
      Note that this check is implemented in much more elegant way in 5.1 
      
      
      mysql-test/r/trigger.result:
        Added test case for bug#20670 "UPDATE using key and invoking trigger that
        modifies this key does not stop".
      mysql-test/t/trigger.test:
        Added test case for bug#20670 "UPDATE using key and invoking trigger that
        modifies this key does not stop".
      sql/key.cc:
        Renamed check_if_key_used() to is_key_used(). Also this routine checks if
        key uses field which can be updated by before update trigger defined on the
        table. As result we avoid using update-on-the-fly method in cases when trigger
        updates part of key which is used by select which filters rows to be updated
        and thus avoid infinite updates. By doing such check here we cover both UPDATE
        and MULTI-UPDATE cases.
      sql/mysql_priv.h:
        Renamed check_if_key_used() to is_key_used().
      sql/opt_range.cc:
        Renamed check_if_key_used()/QUICK_SELECT_I::check_if_keys_used() to
        is_key_used()/QUICK_SELECT_I::is_keys_used().
      sql/opt_range.h:
        Renamed QUICK_SELECT_I::check_if_keys_used() method to is_keys_used(),
        also updated comment describing it to reflect its extended semantics
        (this change was caused by change in check_if_key_used()/is_key_used()
         routine semantics).
      sql/sql_trigger.cc:
        Introduced Table_triggers_list::is_updated_in_before_update_triggers()
        method which is needed for checking if field of subject table can be
        changed in before update trigger.
      sql/sql_trigger.h:
        Table_triggers_list:
          Removed has_before_update_triggers() method which is not used any longer.
          Added declaration of is_updated_in_before_update_triggers() which is
          needed for checking if field of subject table can be changed by before
          update trigger.
      sql/sql_update.cc:
        safe_update_on_fly():
          check_if_key_used() routine and check_if_keys_used() method were
          renamed to is_key_used()/is_keys_used(). 
          Now cases when trigger updates fields which are part of key used for
          filtering rows for update are caught directly in is_key_used().
          This also allows to cover both UPDATE and MULTI-UPDATE cases.
      0e4dd85d
  10. 24 Aug, 2006 1 commit
    • unknown's avatar
      Polishing (was the part of original patch for BUG#16899): · 2f0a610f
      unknown authored
      Changed trigger-handling code so that there will be the one
      place for generate statement string for replication log
      and for trigger file.
      
      
      sql/sql_trigger.cc:
        Changed trigger-handling code so that there will be the one
        place for generate statement string for replication log
        and for trigger file.
      sql/sql_trigger.h:
        Changed trigger-handling code so that there will be the one
        place for generate statement string for replication log
        and for trigger file.
      2f0a610f
  11. 17 Aug, 2006 1 commit
    • unknown's avatar
      Cleanup patch. · 728a924c
      unknown authored
      There is an existing macros for initializing LEX_STRINGs
      with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
      (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      
      
      sql/handler.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/item.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/mysql_priv.h:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_acl.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_error.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_error.h:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_lex.h:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_parse.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_partition.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_plugin.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_show.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_trigger.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/sql_view.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      sql/tztime.cc:
        There is an existing macros for initializing LEX_STRINGs
        with constant strings -> C_STRING_WITH_LEN. Change existing code to use it.
        (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN
      728a924c
  12. 14 Aug, 2006 1 commit
    • unknown's avatar
      Manual merge 5.0->5.1. Post-merge fixes. · 21e75cb0
      unknown authored
      client/mysqldump.c:
        A post-merge fix - 'sock' was renamed to 'mysql'
      mysql-test/r/events_bugs.result:
        A post merge fix: now we strip rear comments from the query before
        it gets into the log.
      mysql-test/r/func_group.result:
        A post merge fix: default clause is now printed uppercase.
      mysql-test/r/im_life_cycle.result:
        Fix my mistake in manual resolve.
      mysql-test/r/mysqlcheck.result:
        use test; - after we drop client_test_db there is no current database.
        This cleanup is present in 5.1 only, but the test that was added in 
        5.0 assumes there is a current database, test.
      mysql-test/r/mysqldump.result:
        Ignore results of execution of mysqldump: we can't rely on 
        MASTER_LOG_POS in test results, it's different for statement
        and row level logging.
      mysql-test/r/mysqlshow.result:
        A post-merge fix: information schema contains a few more tables
        in 5.1
      mysql-test/r/mysqltest.result:
        A post merge fix: add 5.1 test end separator.
      mysql-test/r/ndb_basic.result:
        A post-merge fix: add test end separators.
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        A post merge fix: length of varbinary column is now 3 times less.
        Assuming a side effect of some other change. Length of any
        field is not relevant in this test.
      mysql-test/r/rpl_view.result:
        Add an end of test marker.
      mysql-test/r/show_check.result:
        Remove duplicate results. Add results from a merged test case.
      mysql-test/r/sp-error.result:
        Add test end separators.
      mysql-test/r/sp-security.result:
        Post-merge fix: use test after the current database is dropped.
      mysql-test/r/sp.result:
        Remove a duplicate result (bad merge that left a copy of
        the test case for Bug#19862 in the test suite).
      mysql-test/r/strict.result:
        An after-merge fix for a new test case: in 5.1 we issue a more accurate
        error message: "Incorrect value" instead of "Truncated value". I reason
        it so that in case of an error nothing is truncated, really.
        Also found similar changes in other test cases.
      mysql-test/r/type_datetime.result:
        Fix the text of an error.
      mysql-test/r/union.result:
        A post-merge fix: CHARACTER SET is now uppercase.
      mysql-test/t/mysqlcheck.test:
        A post-merge fix: use test, after current database is dropped, there
        is no current database.
      mysql-test/t/mysqldump.test:
        Disable result log: it's dependent on binlog position.
      mysql-test/t/sp-security.test:
        use test
      sql/item_sum.cc:
        Adjust the call to the constructor after the merge.
      sql/sp_head.cc:
        Add a missing DBUG_VOID_RETURN, move security checks out of
        execute_trigger to Table_triggers_list: in 5.1 we check for
        TRIGGER privilege, not SUPER privilege to execute triggers, so these
        checks lack table context inside execute_trigger and have to be
        performed when we have table object on hand.
      sql/sql_db.cc:
        A post-merge fix: adjust load_db_opt_by_name and check_db_dir_existence
        (new functions added in 5.0) to be tablename-to-filename encoding 
        friendly.
      sql/sql_lex.cc:
        A post-merge fix: make skip_rear_comments operate on const uchar *s.
      sql/sql_lex.h:
        A post-merge fix.
      sql/sql_show.cc:
        A post-merge fix: fix a bad merge, rename orig_sql_command -> sql_command.
      sql/sql_trigger.cc:
        A post-merge fix: move security checks to process_triggers
        from execute_trigger.
      sql/sql_view.cc:
        Adjust to the new signature of skip_rear_comments.
      sql/sql_yacc.yy:
        Adjust to the new signature of init_strings.
      21e75cb0
  13. 02 Aug, 2006 1 commit
    • unknown's avatar
      Bug#18775 - Temporary table from alter table visible to other threads · ef976d20
      unknown 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.
      
      
      mysql-test/r/alter_table.result:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added test results.
      mysql-test/r/backup.result:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added test results.
      mysql-test/r/repair.result:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added test results.
      mysql-test/t/alter_table.test:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added test cases.
      mysql-test/t/backup.test:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added test cases.
      mysql-test/t/repair.test:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added a test case.
      sql/ha_myisam.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added missing table name mapping calls to backup() and restore().
      sql/ha_myisammrg.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/ha_ndbcluster.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/ha_ndbcluster_binlog.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/ha_ndbcluster_binlog.h:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Removed unnecessary check for wrong temp file prefix.
      sql/mysql_priv.h:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Extended quick_rm_table(), mysql_rename_table(), and
        build_table_filename() by an flags argument, which can indicate
        temporary table names that should not be converted.
        Added symbolic flag values.
      sql/sql_acl.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/sql_base.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Fixed a comment.
        Added DBUG calls.
      sql/sql_db.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/sql_delete.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/sql_insert.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/sql_partition.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/sql_rename.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/sql_show.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Reverted the former fix for this bug. tmp_file_prefix is now used
        verbatim in the comparison of file names.
      sql/sql_table.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added a check for a tmp_file_prefix file name to
        filename_to_tablename(). These names are now accepted without
        conversion.
        Extended quick_rm_table(), mysql_rename_table(), and
        build_table_filename() by an flags argument, which can indicate
        temporary table names that should not be converted.
        Removed the table to file name conversion from
        build_tmptable_filename().
        Disabled REPAIR TABLE ... USE_FRM for temporary tables.
        Added the forgotten conversion to mysql_alter_table() for the case
        of ALTER TABLE ... RENAME.
        Added comments and DBUG calls.
      sql/sql_trigger.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/sql_view.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Added an zero argument for the new 'flags' parameter.
      sql/table.cc:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Replaced a literal ".frm" by reg_ext.
        Added DBUG calls.
      storage/innobase/row/row0mysql.c:
        Bug#18775 - Temporary table from alter table visible to other threads
        Continued implementation of WL#1324 (table name to filename encoding)
        Changed back the encoded temp file prefix to #sql.
      ef976d20
  14. 27 Jul, 2006 1 commit
    • unknown's avatar
      Fix for BUG#20438: CREATE statements for views, stored routines and triggers · d36f5781
      unknown authored
      can be not replicable.
      
      Now CREATE statements for writing in the binlog are created as follows:
        - the beginning of the statement is re-created;
        - the rest of the statement is copied from the original query.
      
      The problem appears when there is a version-specific comment (produced by
      mysqldump), started in the re-created part of the statement and closed in the
      copied part -- there is closing comment-parenthesis, but there is no opening
      one.
      
      The proper fix could be to re-create original statement, but we can not
      implement it in 5.0. So, for 5.0 the fix is just to cut closing
      comment-parenthesis. This technique is also used for SHOW CREATE PROCEDURE
      statement (so we are able to reuse existing code).
      
      
      mysql-test/r/rpl_sp.result:
        Updated result file.
      mysql-test/r/rpl_trigger.result:
        Updated result file.
      mysql-test/r/rpl_view.result:
        Updated result file.
      mysql-test/t/rpl_sp.test:
        Added test case for BUG#20438.
      mysql-test/t/rpl_trigger.test:
        Added test case for BUG#20438.
      mysql-test/t/rpl_view.test:
        Added test case for BUG#20438.
      sql/sp.cc:
        Trim comments at the end.
      sql/sp_head.cc:
        Moved this code to the separate function to be re-used.
      sql/sql_lex.cc:
        Added a new function.
      sql/sql_lex.h:
        Added a new function.
      sql/sql_trigger.cc:
        Trim comments at the end.
      sql/sql_view.cc:
        Trim comments at the end.
      d36f5781
  15. 13 Jul, 2006 1 commit
    • unknown's avatar
      Bug#18630: Arguments of suid routine calculated in wrong security · 06bf59ad
      unknown authored
                 context.
      
      Routine arguments were evaluated in the security context of the routine
      itself, not in the caller's context.
      
      The bug is fixed the following way:
      
        - Item_func_sp::find_and_check_access() has been split into two
          functions: Item_func_sp::find_and_check_access() itself only
          finds the function and check that the caller have EXECUTE privilege
          on it.  New function set_routine_security_ctx() changes security
          context for SUID routines and checks that definer have EXECUTE
          privilege too.
      
        - new function sp_head::execute_trigger() is called from
          Table_triggers_list::process_triggers() instead of
          sp_head::execute_function(), and is effectively just as the
          sp_head::execute_function() is, with all non-trigger related code
          removed, and added trigger-specific security context switch.
      
        - call to Item_func_sp::find_and_check_access() stays outside
          of sp_head::execute_function(), and there is a code in
          sql_parse.cc before the call to sp_head::execute_procedure() that
          checks that the caller have EXECUTE privilege, but both
          sp_head::execute_function() and sp_head::execute_procedure() call
          set_routine_security_ctx() after evaluating their parameters,
          and restore the context after the body is executed.
      
      
      mysql-test/r/sp-security.result:
        Add test case for bug#18630: Arguments of suid routine calculated
        in wrong security context.
      mysql-test/t/sp-security.test:
        Add result for bug#18630: Arguments of suid routine calculated
        in wrong security context.
      sql/item_func.cc:
        Do not change security context before executing the function, as it
        will be changed after argument evaluation.
        Do not change security context in Item_func_sp::find_and_check_access().
      sql/item_func.h:
        Change prototype for Item_func_sp::find_and_check_access().
      sql/sp_head.cc:
        Add set_routine_security_ctx() function.
        Add sp_head::execute_trigger() method.
        Change security context in sp_head::execute_trigger(), and in
        sp_head::execute_function() and sp_head::execute_procedure()
        after argument evaluation.
        Move pop_all_cursors() call to sp_head::execute().
      sql/sp_head.h:
        Add declaration for sp_head::execute_trigger() and
        set_routine_security_ctx().
      sql/sql_parse.cc:
        Do not change security context before executing the procedure, as it
        will be changed after argument evaluation.
      sql/sql_trigger.cc:
        Call new sp_head::execute_trigger() instead of
        sp_head::execute_function(), which is responsible to switch
        security context.
      06bf59ad
  16. 06 Jul, 2006 1 commit
    • unknown's avatar
      After merge fixes for patch solving bug#18437 "Wrong values inserted with a · 0e47753f
      unknown authored
      before update trigger on NDB table".
      
      Two main changes:
      - We use TABLE::read_set/write_set bitmaps for marking fields used by
        statement instead of Field::query_id in 5.1.
      - Now when we mark columns used by statement we take into account columns 
        used by table's triggers instead of marking all columns as used if table
        has triggers.
      
      
      mysql-test/r/federated.result:
        Changed test in order to make it work with RBR.
        RBR changes the way in which we execute "DELETE FROM t1" statement - we don't
        use handler::delete_all_rows() method if RBR is enabled (see bug#19066).
        As result federated engine produces different sequences of statements for
        remote server in non-RBR and in RBR cases. And this changes order of the
        rows inserted by following INSERT statements.
      mysql-test/t/federated.test:
        Changed test in order to make it work with RBR.
        RBR changes the way in which we execute "DELETE FROM t1" statement - we don't
        use handler::delete_all_rows() method if RBR is enabled (see bug#19066).
        As result federated engine produces different sequences of statements for
        remote server in non-RBR and in RBR cases. And this changes order of the
        rows inserted by following INSERT statements.
      sql/ha_partition.cc:
        Added handling of HA_EXTRA_WRITE_CAN_REPLACE/HA_EXTRA_WRITE_CANNOT_REPLACE
        to ha_partition::extra().
      sql/item.cc:
        Adjusted comment after merge. In 5.1 we use TABLE::read_set/write_set
        bitmaps instead of Field::query_id for marking columns used.
      sql/log_event.cc:
        Write_rows_log_event::do_before_row_operations():
          Now we explicitly inform handler that we want to replace rows so it can
          promote operation done by write_row() to replace.
      sql/mysql_priv.h:
        Removed declaration of mark_fields_used_by_triggers_for_insert_stmt() which
        is no longer used (we have TABLE::mark_columns_needed_for_insert() instead).
      sql/sql_insert.cc:
        Adjusted code after merge. Get rid of mark_fields_used_by_triggers_for_insert_stmt()
        as now we use TABLE::mark_columns_needed_for_insert() for the same purprose.
        Aligned places where we call this method with places where we call
        mark_fields_used_by_triggers_for_insert() in 5.0.
        Finally we no longer need to call handler::extra(HA_EXTRA_WRITE_CAN_REPLACE)
        in case of REPLACE statement since in 5.1 write_record() marks all columns
        as used before doing actual row replacement.
      sql/sql_load.cc:
        Adjusted code after merge. In 5.1 we use TABLE::mark_columns_needed_for_insert() instead of
        mark_fields_used_by_triggers_for_insert_stmt() routine. We also no longer
        need to call handler::extra(HA_EXTRA_RETRIEVE_ALL_COLS) if we execute LOAD
        DATA REPLACE since in 5.1 write_record() will mark all columns as used before
        doing actual row replacement.
      sql/sql_trigger.cc:
        Table_triggers_list::mark_fields_used():
          We use TABLE::read_set/write_set bitmaps for marking fields used instead
          of Field::query_id in 5.1.
      sql/sql_trigger.h:
        TABLE::mark_columns_needed_for_* methods no longer need to be friends of
        Table_triggers_list class as intead of dirrectly accessing its private
        members they can use public Table_triggers_list::mark_fields_used() method.
        Also Table_triggers)list::mark_fields_used() no longer needs THD argument.
      sql/table.cc:
        TABLE::mark_columns_needed_for_*():
          Now we mark columns which are really used by table's triggers instead of
          marking all columns as used if table has triggers.
      0e47753f
  17. 01 Jul, 2006 1 commit
    • unknown's avatar
      Fix for bug#18437 "Wrong values inserted with a before update trigger on · ae9724cc
      unknown authored
      NDB table".
      
      SQL-layer was not marking fields which were used in triggers as such. As
      result these fields were not always properly retrieved/stored by handler
      layer. So one might got wrong values or lost changes in triggers for NDB,
      Federated and possibly InnoDB tables.
      This fix solves the problem by marking fields used in triggers
      appropriately.
      
      Also this patch contains the following cleanup of ha_ndbcluster code:
      
      We no longer rely on reading LEX::sql_command value in handler in order
      to determine if we can enable optimization which allows us to handle REPLACE
      statement in more efficient way by doing replaces directly in write_row()
      method without reporting error to SQL-layer.
      Instead we rely on SQL-layer informing us whether this optimization
      applicable by calling handler::extra() method with
      HA_EXTRA_WRITE_CAN_REPLACE flag.
      As result we no longer apply this optimzation in cases when it should not
      be used (e.g. if we have on delete triggers on table) and use in some
      additional cases when it is applicable (e.g. for LOAD DATA REPLACE).
      
      Finally this patch includes fix for bug#20728 "REPLACE does not work
      correctly for NDB table with PK and unique index".
        
      This was yet another problem which was caused by improper field mark-up.
      During row replacement fields which weren't explicity used in REPLACE
      statement were not marked as fields to be saved (updated) so they have
      retained values from old row version. The fix is to mark all table
      fields as set for REPLACE statement. Note that in 5.1 we already solve
      this problem by notifying handler that it should save values from all
      fields only in case when real replacement happens.
      
      
      include/my_base.h:
        Added HA_EXTRA_WRITE_CAN_REPLACE, HA_EXTRA_WRITE_CANNOT_REPLACE - new
        parameters for ha_extra() method. We use them to inform handler that
        write_row() which tries to insert new row into the table and encounters
        some already existing row with same primary/unique key can replace old
        row with new row instead of reporting error.
      mysql-test/r/federated.result:
        Additional test for bug#18437 "Wrong values inserted with a before update
        trigger on NDB table".
      mysql-test/r/ndb_replace.result:
        Added test for bug #20728 "REPLACE does not work correctly for NDB table
        with PK and unique index". Updated wrong results from older test.
      mysql-test/t/federated.test:
        Additional test for bug#18437 "Wrong values inserted with a before update
        trigger on NDB table".
      mysql-test/t/ndb_replace.test:
        Added test for bug #20728 "REPLACE does not work correctly for NDB table
        with PK and unique index".
      sql/ha_ndbcluster.cc:
        We no longer rely on reading LEX::sql_command value in handler in order
        to determine if we can enable optimization which allows us to handle REPLACE
        statement in more efficient way by doing replaces directly in write_row()
        method without reporting error to SQL-layer.
        Instead we rely on SQL-layer informing us whether this optimization
        applicable by calling handler::extra() method with
        HA_EXTRA_WRITE_CAN_REPLACE flag.
        As result we no longer apply this optimization in cases when it should not
        be used (e.g. if we have on delete triggers on table) and use in some
        additional cases when it is applicable (e.g. for LOAD DATA REPLACE).
      sql/item.cc:
        Item_trigger_field::setup_field():
          Added comment explaining why we don't set Field::query_id in this method.
      sql/mysql_priv.h:
        mysql_alter_table() function no longer takes handle_duplicates argument.
        Added declaration of mark_fields_used_by_triggers_for_insert_stmt() function.
      sql/sql_delete.cc:
        Mark fields which are used by ON DELETE triggers so handler will retrieve
        values for these fields.
      sql/sql_insert.cc:
        Explicitly inform handler that we are doing REPLACE (using ha_extra() method)
        in cases when it can promote insert operation done by write_row() to replace.
        Also when we do REPLACE we want to store values for all columns so we should
        inform handler about it.
        Finally we should mark fields used by ON UPDATE/ON DELETE triggers as such
        so handler can properly retrieve/restore values in these fields during
        execution of REPLACE and INSERT ... ON DUPLICATE KEY UPDATE statements.
      sql/sql_load.cc:
        Explicitly inform handler that we are doing LOAD DATA REPLACE (using
        ha_extra() method) in cases when it can promote insert operation done by
        write_row() to replace.
        Also when we do replace we want to save (replace) values for all columns
        so we should inform handler about it.
        Finally to properly execute LOAD DATA for table with triggers we should
        mark fields used by ON INSERT triggers as such so handler can properly
        store values for these fields.
      sql/sql_parse.cc:
        mysql_alter_table() function no longer takes handle_duplicates argument.
      sql/sql_table.cc:
        Got rid of handle_duplicates argument in mysql_alter_table() and
        copy_data_between_tables() functions. These functions were always
        called with handle_duplicates == DUP_ERROR and thus contained dead
        (and probably incorrect) code.
      sql/sql_trigger.cc:
        Added Table_triggers_list::mark_fields_used() method which is used to mark
        fields read/set by triggers as such so handlers will be able properly
        retrieve/store values in these fields.
      sql/sql_trigger.h:
        Table_triggers_list:
          Added mark_fields_used() method which is used to mark fields read/set by
          triggers as such so handlers will be able properly retrieve/store values
          in these fields. To implement this method added 'trigger_fields' member
          which is array of lists linking items for all fields used in triggers
          grouped by event and action time.
      sql/sql_update.cc:
        Mark fields which are used by ON UPDATE triggers so handler will retrieve
        and save values for these fields.
      mysql-test/r/ndb_trigger.result:
        Added test for bug#18437 "Wrong values inserted with a before update trigger
        on NDB table".
      mysql-test/t/ndb_trigger.test:
        Added test for bug#18437 "Wrong values inserted with a before update trigger
        on NDB table".
      ae9724cc
  18. 28 Jun, 2006 2 commits
    • unknown's avatar
      Bug#10946: Confusing error messeges in the case of duplicate trigger definition · 837c9719
      unknown authored
      It was hard to distinguish case, when one was unable to create trigger
      on the table because trigger with same action time and event already
      existed for this table, from the case, when one tried to create trigger
      with name which was already occupied by some other trigger, since in
      both these cases we emitted ER_TRG_ALREADY_EXISTS error and message.
      Now we emit ER_NOT_SUPPORTED_YET error with appropriate additional
      message in the first case. There is no sense in introducing separate
      error for this situation since we plan to get rid of this limitation
      eventually.
      
      
      mysql-test/r/trigger.result:
        Update result for new error message.
      mysql-test/t/trigger.test:
        Update test for new error code.
      sql/sql_trigger.cc:
        If there is already a trigger with the same activation time, report an
        "Unsupported yet" error.
      837c9719
    • unknown's avatar
      Bug #18005: Creating a trigger on mysql.event leads to server crash on scheduler startup · 88afd72b
      unknown authored
      Bug #18361: Triggers on mysql.user table cause server crash
      
       Because they do not work, we do not allow creating triggers on tables
       within the 'mysql' schema.
      
       (They may be made to work and re-enabled at some later date, but not
       in 5.0 or 5.1.)
      
      
      mysql-test/r/trigger.result:
        Add new results
      mysql-test/t/trigger.test:
        Add new regression test for creating triggers on system schema
      sql/share/errmsg.txt:
        Add new error message
      sql/sql_trigger.cc:
        Disallow creating triggers on tables in the 'mysql' schema
      88afd72b
  19. 26 Jun, 2006 2 commits
    • unknown's avatar
      A fix and a test case for · d6bcbfbe
      unknown authored
       Bug#19022 "Memory bug when switching db during trigger execution"
       Bug#17199 "Problem when view calls function from another database."
       Bug#18444 "Fully qualified stored function names don't work correctly in
                  SELECT statements"
      
       Documentation note: this patch introduces a change in behaviour of prepared
       statements.
      
       This patch adds a few new invariants with regard to how THD::db should
       be used. These invariants should be preserved in future:
      
        - one should never refer to THD::db by pointer and always make a deep copy
          (strmake, strdup)
        - one should never compare two databases by pointer, but use strncmp or
          my_strncasecmp
        - TABLE_LIST object table->db should be always initialized in the parser or
          by creator of the object.
      
          For prepared statements it means that if the current database is changed
          after a statement is prepared, the database that was current at prepare
          remains active. This also means that you can not prepare a statement that
          implicitly refers to the current database if the latter is not set.
          This is not documented, and therefore needs documentation. This is NOT a
          change in behavior for almost all SQL statements except:
           - ALTER TABLE t1 RENAME t2 
           - OPTIMIZE TABLE t1
           - ANALYZE TABLE t1
           - TRUNCATE TABLE t1 --
           until this patch t1 or t2 could be evaluated at the first execution of
           prepared statement. 
      
           CURRENT_DATABASE() still works OK and is evaluated at every execution
           of prepared statement.
      
           Note, that in stored routines this is not an issue as the default
           database is the database of the stored procedure and "use" statement
           is prohibited in stored routines.
      
        This patch makes obsolete the use of check_db_used (it was never used in the
        old code too) and all other places that check for table->db and assign it
        from THD::db if it's NULL, except the parser.
      
       How this patch was created: THD::{db,db_length} were replaced with a
       LEX_STRING, THD::db. All the places that refer to THD::{db,db_length} were
       manually checked and:
        - if the place uses thd->db by pointer, it was fixed to make a deep copy
        - if a place compared two db pointers, it was fixed to compare them by value
          (via strcmp/my_strcasecmp, whatever was approproate)
       Then this intermediate patch was used to write a smaller patch that does the
       same thing but without a rename.
      
       TODO in 5.1:
         - remove check_db_used
         - deploy THD::set_db in mysql_change_db
      
       See also comments to individual files.
      
      
      mysql-test/r/create.result:
        Modify the result file: a database can never be NULL.
      mysql-test/r/ps.result:
        Update test results (Bug#17199 et al)
      mysql-test/r/sp.result:
        Update test results (Bug#17199 et al)
      mysql-test/t/create.test:
        Update the id of the returned error.
      mysql-test/t/ps.test:
        Add test coverage for prepared statements and current database. In scope of
        work on Bug#17199 "Problem when view calls function from another database."
      mysql-test/t/sp.test:
        Add a test case for Bug#17199 "Problem when view calls function from another
        database." and Bug#18444 "Fully qualified stored function names don't work
        correctly in SELECT statements". Test a complementary problem.
      sql/item_strfunc.cc:
        Touch the code that reads thd->db (cleanup).
      sql/log_event.cc:
        While we are at it, replace direct access to thd->db with a method.
        Should simplify future conversion of THD::db to LEX_STRING.
      sql/slave.cc:
        While we are at it, replace direct access to thd->db with a method.
        Should simplify future conversion of THD::db to LEX_STRING.
      sql/slave.h:
        Remove a declaration for a method that is used only in one module.
      sql/sp.cc:
        Rewrite sp_use_new_db: this is a cleanup that I needed in order to understand
        this function and ensure that it has no bugs.
      sql/sp.h:
        Add a new declaration for sp_use_new_db (uses LEX_STRINGs) and a comment.
      sql/sp_head.cc:
        - drop sp_name_current_db_new - a creator of sp_name class that was used
        when sp_name was created for an identifier without an explicitly initialized
        database. Now we pass thd->db to constructor of sp_name right in the 
        parser.
        - rewrite sp_head::init_strings: name->m_db is always set now
        - use the new variant of sp_use_new_db
        - we don't need to update thd->db with SP MEM_ROOT pointer anymore when
        parsing a stored procedure, as noone will refer to it (yes!)
      sql/sp_head.h:
        - remove unneded methods and members
      sql/sql_class.h:
        - introduce 3 THD  methods to work with THD::db:
          .set_db to assign the current database
          .reset_db to reset the current database (temporarily) or set it to NULL
          .opt_copy_db_to - to deep-copy thd->db to a pointer if it's not NULL
      sql/sql_db.cc:
        While we are at it, replace direct access to thd->db with a method.
        Should simplify future conversion of THD::db to LEX_STRING.
      sql/sql_insert.cc:
        - replace checks with asserts: table_list->db must be always set in the parser.
      sql/sql_lex.h:
        - add a comment
      sql/sql_parse.cc:
        - implement the invariant described in the changeset comment.
        - remove juggling with lex->sphead in SQLCOM_CREATE_PROCEDURE:
          now db_load_routine uses its own LEX object and doesn't damage the main
          LEX.
        - add DBUG_ASSERT(0) to unused "check_db_used"
      sql/sql_table.cc:
        - replace a check with an assert (table_ident->db)
      sql/sql_trigger.cc:
        While we are at it, replace direct access to thd->db with a method.
        Should simplify future conversion of THD::db to LEX_STRING.
      sql/sql_udf.cc:
        - use thd->set_db instead of direct modification of to thd->db
      sql/sql_view.cc:
        - replace a check with an assert (view->db)
      sql/sql_yacc.yy:
        - make sure that we always copy table->db or name->db or ident->db or
          select_lex->db from thd->db if the former is not set. If thd->db
          is not set but is accessed, return an error.
      sql/tztime.cc:
        - be nice, never copy thd->db by pointer.
      d6bcbfbe
    • unknown's avatar
      Bug#16218 - Crash on insert delayed · ab5ebc0f
      unknown authored
      Bug#17294 - INSERT DELAYED puting an \n before data
      Bug#16611 - INSERT DELAYED corrupts data
      Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
      Combined as Bug#16218.
      
      INSERT DELAYED crashed in 5.0 on a table with a varchar that 
      could be NULL and was created pre-5.0 (Bugs 16218 and 13707).
      INSERT DELAYED corrupted data in 5.0 on a table with varchar 
      fields that was created pre-5.0 (Bugs 17294 and 16611).
      
      In case of INSERT DELAYED the open table is copied from the
      delayed insert thread to be able to create a record for the 
      queue. When copying the fields, a method was used that did 
      convert old varchar to new varchar fields and did not set up 
      some pointers into the record buffer of the table.
      
      The field conversion was guilty for the misinterpretation of 
      the record contents by the delayed insert thread. The wrong
      pointer setup was guilty for the crashes.
      
      For Bug 13707 (Server crash with INSERT DELAYED on MyISAM table)
      I fixed the above mentioned method to set up one of the pointers.
      For Bug 16218 I set up the other pointers too.
      
      But when looking at the corruptions I got aware that converting
      the field type was totally wrong for INSERT DELAYED. The copied
      table is used to create a record that is to be sent to the
      delayed insert thread. Of course it can interpret the record
      correctly only if all field types are the same in both table
      objects.
      
      So I revoked the fix for Bug 13707 and changed the new_field() 
      method so that it can suppress conversions.
      
      No test case as this is a migration problem. One needs to
      create a table with 4.x and use it with 5.x. I added two
      test scripts to the bug report.
      
      
      sql/field.cc:
        Bug#16218 - Crash on insert delayed
        Bug#17294 - INSERT DELAYED puting an \n before data
        Bug#16611 - INSERT DELAYED corrupts data
        Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
        Combined as Bug#16218.
        
        Added parameter 'keep_type' to Field::new_field().
        
        Undid the change from Bug 13707 (Server crash with INSERT 
        DELAYED on MyISAM table).
        I solved all four bugs in sql/sql_insert.cc by making exact
        duplicates of the fields. The new_field() method converts
        certain field types, which is wrong for INSERT DELAYED.
      sql/field.h:
        Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
        Combined as Bug#16218.
        
        Added parameter 'keep_type' to Field::new_field().
      sql/sql_insert.cc:
        Bug#16218 - Crash on insert delayed
        Bug#17294 - INSERT DELAYED puting an \n before data
        Bug#16611 - INSERT DELAYED corrupts data
        Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
        Combined as Bug#16218.
        
        Added comments. Made small style fixes.
        Used the new parameter 'keep_type' of Field::new_field()
        to avoid field type conversion. The table copy must have
        exactly the same types of fields as the original table.
        Otherwise the record contents created by the foreground 
        thread could be misinterpreted by the delayed insert thread.
      sql/sql_select.cc:
        Bug#16218 - Crash on insert delayed
        Bug#17294 - INSERT DELAYED puting an \n before data
        Bug#16611 - INSERT DELAYED corrupts data
        Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
        Combined as Bug#16218.
        
        Added parameter 'keep_type' to Field::new_field().
        
        Undid the change from Bug 13707 (Server crash with INSERT 
        DELAYED on MyISAM table).
        I solved all four bugs in sql/sql_insert.cc by making exact
        duplicates of the fields. The new_field() method converts
        certain field types, which is wrong for INSERT DELAYED.
      sql/sql_trigger.cc:
        Bug#16218 - Crash on insert delayed
        Bug#17294 - INSERT DELAYED puting an \n before data
        Bug#16611 - INSERT DELAYED corrupts data
        Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
        Combined as Bug#16218.
        
        Added parameter 'keep_type' to Field::new_field().
        
        Undid the change from Bug 13707 (Server crash with INSERT 
        DELAYED on MyISAM table).
        I solved all four bugs in sql/sql_insert.cc by making exact
        duplicates of the fields. The new_field() method converts
        certain field types, which is wrong for INSERT DELAYED.
      sql/table.cc:
        Bug#16218 - Crash on insert delayed
        Bug#17294 - INSERT DELAYED puting an \n before data
        Bug#16611 - INSERT DELAYED corrupts data
        Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
        Combined as Bug#16218.
        
        Added parameter 'keep_type' to Field::new_field().
        
        Undid the change from Bug 13707 (Server crash with INSERT 
        DELAYED on MyISAM table).
        I solved all four bugs in sql/sql_insert.cc by making exact
        duplicates of the fields. The new_field() method converts
        certain field types, which is wrong for INSERT DELAYED.
      ab5ebc0f
  20. 19 May, 2006 1 commit
    • unknown's avatar
      1. Fix compilation on Windows; · 0276916b
      unknown authored
      2. Fix trigger.test.
      
      
      server-tools/instance-manager/log.cc:
        Fix compilation in Windows.
      sql/sql_trigger.cc:
        Use strlen() instead of sizeof() for C-strings.
      0276916b
  21. 18 May, 2006 1 commit
    • unknown's avatar
      This is an implementation of two WL items: · 8b4fcf6e
      unknown authored
        - WL#3158: IM: Instance configuration extensions;
        - WL#3159: IM: --bootstrap and --start-default-instance modes
      
      The following new statements have been added:
        - CREATE INSTANCE;
        - DROP INSTANCE;
      
      The behaviour of the following statements have been changed:
        - SET;
        - UNSET;
        - FLUSH INSTANCES;
        - SHOW INSTANCES;
        - SHOW INSTANCE OPTIONS;
      
      
      BitKeeper/deleted/.del-im_options_set.imtest~b53d9d60e5684833:
        Delete: mysql-test/t/im_options_set.imtest
      BitKeeper/deleted/.del-im_options_set.result~59278f56be61d921:
        Delete: mysql-test/r/im_options_set.result
      BitKeeper/deleted/.del-im_options_unset.imtest~768eb186b51d0048:
        Delete: mysql-test/t/im_options_unset.imtest
      BitKeeper/deleted/.del-im_options_unset.result~20a4790cd3c70a4f:
        Delete: mysql-test/r/im_options_unset.result
      client/get_password.c:
        Change prototype to avoid casting when using C-strings (char *).
      include/m_string.h:
        Moved LEX_STRING to global header from sql/ to be accessible
        from all components (IM for one).
      include/my_sys.h:
        Added constants for modify_defaults_file().
      include/mysql_com.h:
        Removed duplicated declarations. my_sys.h should be used instead.
      libmysql/get_password.c:
        Change prototype to avoid casting when using C-strings (char *).
      mysql-test/mysql-test-run.pl:
        Added environment variables to be used from tests.
      mysql-test/r/im_daemon_life_cycle.result:
        Column name has been changed in SHOW INSTANCES.
      mysql-test/r/im_life_cycle.result:
        1. Column name has been changed in SHOW INSTANCES.
        2. Removed redundant SHOW INSTANCE STATUS statements.
      mysql-test/r/im_utils.result:
        Updated the result file.
      mysql-test/t/im_daemon_life_cycle-im.opt:
        Set minimal monitoring interval for Instance Manager to speed up testing.
      mysql-test/t/im_daemon_life_cycle.imtest:
        Get Instance Manager and managed mysqld-instances enough time to start.
      mysql-test/t/im_life_cycle.imtest:
        1. Polishing;
        2. Fixed a test error in 1.1.2.
      mysql-test/t/im_utils.imtest:
        Get Instance Manager and managed mysqld-instances enough time to start.
      mysys/default.c:
        Pass the name of the section to the handler function as well.
      mysys/default_modify.c:
        Added REMOVE_SECTION functionality.
      server-tools/instance-manager/IMService.cpp:
        Polishing: be more verbose.
      server-tools/instance-manager/IMService.h:
        Polishing: added copyright.
      server-tools/instance-manager/Makefile.am:
        Added new files.
      server-tools/instance-manager/WindowsService.cpp:
        Polishing: according to The Coding Style, TRUE/FALSE must be
        used instead of true/false.
      server-tools/instance-manager/WindowsService.h:
        Polishing: added copyright.
      server-tools/instance-manager/command.h:
        Polishing: provide a comment for the main operation of "Command" class.
      server-tools/instance-manager/commands.cc:
        1. Added support for CREATE INSTANCE, DROP INSTANCE statements;
        2. Added "deprecated" column in output of SHOW INSTANCE OPTIONS;
        3. Modified the behaviour of SET/UNSET, FLUSH INSTANCES statements;
      server-tools/instance-manager/commands.h:
        1. Added support for CREATE INSTANCE, DROP INSTANCE statements;
        2. Added "deprecated" column in output of SHOW INSTANCE OPTIONS;
        3. Modified the behaviour of SET/UNSET, FLUSH INSTANCES statements;
      server-tools/instance-manager/guardian.cc:
        Added operations to retrieve state of managed instances.
      server-tools/instance-manager/guardian.h:
        Added operations to retrieve state of managed instances.
      server-tools/instance-manager/instance.cc:
        1. Provided an operation to check validity of instance name.
        2. Added an attribute to distiguish mysqld-instances,
           whose configuration should be kept backward-compatible.
      server-tools/instance-manager/instance.h:
        1. Provided an operation to check validity of instance name.
        2. Added an attribute to distiguish mysqld-instances,
           whose configuration should be kept backward-compatible.
      server-tools/instance-manager/instance_map.cc:
        1. Used the operation to check validity of instance name;
        2. Added operations to manage instances.
      server-tools/instance-manager/instance_map.h:
        Added operations to manage instances.
      server-tools/instance-manager/instance_options.cc:
        Changed Instance_options so that it will be possible to manage
        options on the fly.
      server-tools/instance-manager/instance_options.h:
        Changed Instance_options so that it will be possible to manage
        options on the fly.
      server-tools/instance-manager/listener.cc:
        1. Remove reference to the instance of Options;
        2. Use new Options naming scheme.
      server-tools/instance-manager/listener.h:
        Remove reference to the instance of Options;
      server-tools/instance-manager/log.cc:
        Polishing: use TRUE/FALSE instead of true/false.
      server-tools/instance-manager/manager.cc:
        Added a common for IM operation to work with configuration file.
      server-tools/instance-manager/manager.h:
        Added a common for IM operation to work with configuration file.
      server-tools/instance-manager/messages.cc:
        Added messages for new errors.
      server-tools/instance-manager/mysql_connection.cc:
        1. Move a constant to common place.
        2. Polishing.
      server-tools/instance-manager/mysql_manager_error.h:
        Added new errors.
      server-tools/instance-manager/mysqlmanager.cc:
        1. Use error code from Options::load();
        2. Eliminate type-casting warning on Windows.
      server-tools/instance-manager/options.cc:
        Added support for user-management command-line options.
      server-tools/instance-manager/options.h:
        Added support for user-management command-line options.
      server-tools/instance-manager/parse.cc:
        1. Added support of new statements:
           - CREATE INSTANCE;
           - DROP INSTANCE.
        2. Modified SET/UNSET.
      server-tools/instance-manager/parse.h:
        1. Added support of new statements:
           - CREATE INSTANCE;
           - DROP INSTANCE.
        2. Modified SET/UNSET.
      server-tools/instance-manager/parse_output.cc:
        Sorted out header files.
      server-tools/instance-manager/parse_output.h:
        Sorted out header files.
      server-tools/instance-manager/portability.h:
        1. Added constants for Windows.
        2. Moved system-dependent defines from instance_options.cc.
      server-tools/instance-manager/priv.cc:
        Updated version.
      server-tools/instance-manager/priv.h:
        Added some global constants.
      server-tools/instance-manager/protocol.cc:
        Replaced NAME_WITH_LENGTH by LEX_STRING.
      server-tools/instance-manager/protocol.h:
        Replaced NAME_WITH_LENGTH by LEX_STRING.
      server-tools/instance-manager/thread_registry.cc:
        Polishing: use TRUE/FALSE instead of true/false.
      server-tools/instance-manager/user_map.cc:
        Added support for managing password database.
      server-tools/instance-manager/user_map.h:
        Added support for managing password database.
      sql/sp.cc:
        Replaced LEX_STRING_WITH_INIT by LEX_STRING + struct initialization.
      sql/sp_head.cc:
        Replaced LEX_STRING_WITH_INIT by LEX_STRING + struct initialization.
      sql/spatial.cc:
        Removed LEX_STRING_WITH_INIT.
      sql/spatial.h:
        Removed LEX_STRING_WITH_INIT.
      sql/sql_string.h:
        Moved STRING_WITH_LEN() macro out from sql (to m_string.h).
      sql/sql_trigger.cc:
        Moved STRING_WITH_LEN() macro out from sql (to m_string.h).
      sql/structs.h:
        Removed LEX_STRING_WITH_INIT.
      support-files/mysql.server.sh:
        Instruct Instance Manager to work in mysqld-safe compatible mode
        for backward compatibility.
      mysql-test/r/im_cmd_line.result:
        Added result file.
      mysql-test/r/im_instance_conf.result:
        Added result file.
      mysql-test/r/im_options.result:
        Added result file.
      mysql-test/t/im_cmd_line.imtest:
        IM command-line options test.
      mysql-test/t/im_instance_conf-im.opt:
        Set minimal monitoring interval for Instance Manager to speed up testing.
      mysql-test/t/im_instance_conf.imtest:
        Added a new test case for checking instance-management.
      mysql-test/t/im_life_cycle-im.opt:
        Set minimal monitoring interval for Instance Manager to speed up testing.
      mysql-test/t/im_options.imtest:
        Join im_options_set and im_options_unset and add new tests.
      mysql-test/t/im_utils-im.opt:
        Set minimal monitoring interval for Instance Manager to speed up testing.
      server-tools/instance-manager/exit_codes.h:
        New file for defining exit codes for user-management mode.
      server-tools/instance-manager/user_management_commands.cc:
        User-management commands implementation.
      server-tools/instance-manager/user_management_commands.h:
        User-management command declarations.
      8b4fcf6e
  22. 27 Mar, 2006 1 commit
    • unknown's avatar
      Fix for BUG#15921: DROP TRIGGER - can't be drop trigger created · e4e2e502
      unknown authored
      in older version.
      
      The problem is that TRN-files created in "old" versions contain
      junk in trigger_table field, which is not acceptable in "new" versions.
      
      
      sql/parse_file.cc:
        1. Made parse_escaped_string() available globally;
        2. Polishing: fixing the comments.
      sql/parse_file.h:
        Made parse_escaped_string() available globally.
      sql/sql_trigger.cc:
        1. Polishing
        2. Removed declaration of global handle_old_incorrect_sql_modes()
           since it is not used anymore.
        3. Added a hook to support invalid "trigger_table" field in TRN-file
           from old versions.
      e4e2e502
  23. 24 Mar, 2006 1 commit
    • unknown's avatar
      Fix for bug #18153 "ALTER/OPTIMIZE/REPAIR on transactional tables corrupt · a389ec0b
      unknown authored
      triggers".
      
      Applying ALTER/OPTIMIZE/REPAIR TABLE statements to transactional table or to
      table of any type on Windows caused disappearance of its triggers.
      Bug was introduced in 5.0.19 by my fix for bug #13525 "Rename table does not
      keep info of triggers" (see comment for sql_table.cc for more info).
      .
      
      
      mysql-test/r/trigger.result:
        Added test-case covering handling of triggers when one does ALTER TABLE which
        should move table to different database.
      mysql-test/t/trigger.test:
        Added test-case covering handling of triggers when one does ALTER TABLE which
        should move table to different database.
      sql/sql_table.cc:
        mysql_alter_table():
          Removal of strdup() which is no longer necessary allows us to preserve
          nice assumption that "(new_db != db || new_table != table_name) indicates
          that table will be renamed. So now we really can use this condition to
          avoid updating trigger definitions when table is not renamed.
          Note that we can't use (alter_info->flags & ALTER_RENAME) condition instead
          since it can be also true when we do "ALTER TABLE t1 RENAME TO t1".
      sql/sql_trigger.cc:
        Table_triggers_list::change_table_name():
          Mentioned assumption that subject table is not renamed to itself in method
          description. Added DBUG_ASSERT() to catch wrong usage of this method.
      mysql-test/r/trigger-trans.result:
        New BitKeeper file ``mysql-test/r/trigger-trans.result''
      mysql-test/t/trigger-trans.test:
        New BitKeeper file ``mysql-test/t/trigger-trans.test''
      a389ec0b
  24. 10 Mar, 2006 1 commit
    • unknown's avatar
      This patch does 1) fix my build breakage 2) Complete the removal of all... · 01d69c4b
      unknown authored
      This patch does 1) fix my build breakage  2) Complete the removal of all symbols which could clash with another parser. 
      
      
      sql/mysql_priv.h:
        Porting update
      sql/mysqld.cc:
        Porting update
      sql/sp.cc:
        Porting update
      sql/sql_lex.cc:
        Porting update
      sql/sql_lex.h:
        Porting update
      sql/sql_parse.cc:
        Porting update
      sql/sql_prepare.cc:
        Portinng update
      sql/sql_trigger.cc:
        Porting update
      sql/sql_view.cc:
        Porting update
      01d69c4b
  25. 04 Mar, 2006 1 commit
    • unknown's avatar
      Fix for bug #17866 "Problem with renaming table with triggers with fully · 350475fa
      unknown authored
      qualified subject table" which was introduced during work on bug #13525
      "Rename table does not keep info of triggers".
      
      The bug was caused by the fact that during reconstruction of CREATE TRIGGER
      statement stored in .TRG file which happened during RENAME TABLE we damaged
      trigger definition in case when it contained fully qualified name of subject
      table (see comment for sql_yacc.yy for more info).
      
      
      mysql-test/r/trigger.result:
        Added test for bug #17866 "Problem with renaming table with triggers with fully
        qualified subject table".
      mysql-test/t/trigger.test:
        Added test for bug #17866 "Problem with renaming table with triggers with fully
        qualified subject table".
      sql/sql_trigger.cc:
        Table_triggers_list::change_table_name_in_triggers():
          Instead of trying to use pointer to the end of subject table identifier
          we use pointer to the beginning of FOR lexeme now, so during reconstruction
          of CREATE TRIGGER statement in this function we need to add extra space
          before part which begins with FOR to get nice trigger definition.
      sql/sql_yacc.yy:
        trigger_tail:
          In this rule we can't rely on using remember_end token after table_ident token,
          since value returned depends on whether table name is fully qualified or not.
          So instead of trying to get pointer to the end of table identifier we use
          pointer to the beginning of FOR lexeme.
      350475fa
  26. 02 Mar, 2006 1 commit
    • unknown's avatar
      Implementation of WL#2897: Complete definer support in the stored routines. · 9a1fed13
      unknown authored
      The idea is to add DEFINER-clause in CREATE PROCEDURE and CREATE FUNCTION
      statements. Almost all support of definer in stored routines had been already
      done before this patch.
      
      NOTE: this patch changes behaviour of dumping stored routines in mysqldump.
      Before this patch, mysqldump did not dump DEFINER-clause for stored routines
      and this was documented behaviour. In order to get full information about stored
      routines, one should have dumped mysql.proc table. This patch changes this
      behaviour, so that DEFINER-clause is dumped.
      
      Since DEFINER-clause is not supported in CREATE PROCEDURE | FUNCTION statements
      before this patch, the clause is covered by additional version-specific comments.
      
      
      client/mysqldump.c:
        Updated the code for dumping stored routines: cover DEFINER-clause
        into version-specific comment.
      mysql-test/r/gis.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/information_schema.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/mysqldump.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/rpl_ddl.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/rpl_sp.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/rpl_trigger.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/sp-security.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/sp.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/r/sql_mode.result:
        Updated result file after adding DEFINER-clause.
      mysql-test/t/sp-security.test:
        Updated result file after adding DEFINER-clause.
      sql/sp.cc:
        Added DEFINER-clause.
      sql/sp_head.cc:
        Added a new convenient variant of set_definer() operation.
      sql/sp_head.h:
        Updated result file after adding DEFINER-clause.
      sql/sql_lex.h:
        Renamed trigger_definition_begin into stmt_definition_begin to be used for
        triggers and stored routines.
      sql/sql_parse.cc:
        Check DEFINER-clause.
      sql/sql_trigger.cc:
        Renamed trigger_definition_begin into stmt_definition_begin to be used for
        triggers and stored routines.
      sql/sql_yacc.yy:
        Added DEFINER-clause.
      9a1fed13
  27. 01 Mar, 2006 1 commit
    • unknown's avatar
      Fix for BUG#16266: Definer is not fully qualified error during replication. · a44a924a
      unknown authored
      The idea of the fix is to extend support of non-SUID triggers for backward
      compatibility. Formerly non-SUID triggers were appeared when "new" server
      is being started against "old" database. Now, they are also created when
      "new" slave receives updates from "old" master.
      
      
      mysql-test/r/rpl_trigger.result:
        Updated the result file with the results of the test for BUG#16266.
      mysql-test/t/rpl_trigger.test:
        Added the test case for BUG#16266.
      sql/mysql_priv.h:
        Added an utility operation to be used from sql_yacc.yy.
      sql/sql_parse.cc:
        Add a utility operation to be used from sql_yacc.yy.
      sql/sql_trigger.cc:
        Extend support of non-SUID triggers.
      sql/sql_view.cc:
        Initialize LEX::definer if DEFINER-clause is missing.
      sql/sql_yacc.yy:
        Extended support of non-SUID triggers.
      mysql-test/std_data/bug16266.000001:
        A new binlog file for testing a patch for BUG#16266.
      a44a924a
  28. 24 Feb, 2006 1 commit
    • unknown's avatar
      Fix for bug #13525 "Rename table does not keep info of triggers". · f8386dfa
      unknown authored
      Let us transfer triggers associated with table when we rename it (but only if
      we are not changing database to which table belongs, in the latter case we will
      emit error).
      
      
      mysql-test/r/trigger.result:
        Added test for bug #13525 "Rename table does not keep info of triggers".
      mysql-test/t/trigger.test:
        Added test for bug #13525 "Rename table does not keep info of triggers".
      sql/sql_rename.cc:
        rename_tables():
          Now after renaming table's .FRM file and updating handler data we call
          Table_triggers_list::change_table_name() which is reponsible for
          updating .TRG and .TRN files.
      sql/sql_table.cc:
        mysql_alter_table():
          Now in case when ALTER should rename table we call
          Table_triggers_list::change_table_name() which is responsible
          for updating .TRG and .TRN files after renaming table.
      sql/sql_trigger.cc:
        Added Table_triggers_list::change_table_name() method and
        change_table_name_in_triggers()/trignames() methods responsible for updating
        .TRG and .TRN files for table during its renaming.
        
        Two small cleanups - removed versioning for .TRG files (since it was not working
        before anyway) and emphasized that type of lock specified in tables list is
        unimportant for DROP TABLE (since this statement uses name-locking).
      sql/sql_trigger.h:
        Table_triggers_list:
          Added on_table_names_list member to store pointers and lenghts of
          "ON table_name" parts in triggers' definitions to be able easily
          change them during RENAME TABLE.
          Added change_table_name() method and change_table_name_in_trignames/triggers()
          helper methods responsible for updating .TRG and .TRN files.
      sql/sql_yacc.yy:
        trigger_tail:
          To be able properly update triggers' definitions with new table names
          when renaming tables we need to know where in CREATE TRIGGER statement
          "ON db_name.table_name" part resides.
          Small cleanup - let us emphasize that for CREATE TRIGGER statement 
          lock type which is specified in table list is unimportant since
          name-locking is used.
      f8386dfa
  29. 13 Feb, 2006 1 commit
    • unknown's avatar
      Polishing: after implementing TRIGGER privilege, mysqld option · 5f1f4023
      unknown authored
      '--log-bin-trust-function-creators' affects not only replication of the
      stored functions, but also replication of the triggers.
      
      
      sql/mysqld.cc:
        Updated the description of mysqld '--log-bin-trust-function-creators' option
        to reflect that after introducing TRIGGER privilege this option also controls
        replication of triggers.
      sql/sql_trigger.cc:
        Updated the comment to be consistent with the new behaviour,
        introduced by TRIGGER privilege.
      5f1f4023
  30. 08 Feb, 2006 1 commit
  31. 01 Feb, 2006 1 commit
    • unknown's avatar
      Fix for BUG#9412: Triggers: should have trigger privilege. · 6aaed733
      unknown authored
      Implement table-level TRIGGER privilege to control access to triggers.
      Before this path global SUPER privilege was used for this purpose, that
      was the big security problem.
      
      In details, before this patch SUPER privilege was required:
        - for the user at CREATE TRIGGER time to create a new trigger;
        - for the user at DROP TRIGGER time to drop the existing trigger;
        - for the definer at trigger activation time to execute the trigger (if the
          definer loses SUPER privilege, all its triggers become unavailable);
      
      This patch changes the behaviour in the following way:
        - TRIGGER privilege on the subject table for trigger is required:
          - for the user at CREATE TRIGGER time to create a new trigger;
          - for the user at DROP TRIGGER time to drop the existing trigger;
          - for the definer at trigger activation time to execute the trigger
            (if the definer loses TRIGGER privilege on the subject table, all its
            triggers on this table become unavailable).
        - SUPER privilege is still required:
          - for the user at CREATE TRIGGER time to explicitly set the trigger
            definer to the user other than CURRENT_USER().
      
      When the server works with database of the previous version (w/o TRIGGER
      privilege), or if the database is being upgraded from the previous versions,
      TRIGGER privilege is granted to whose users, who have CREATE privilege.
      
      
      mysql-test/r/grant.result:
        Updated the result file after adding TRIGGER privilege.
      mysql-test/r/information_schema.result:
        Updated the result file after adding TRIGGER privilege.
      mysql-test/r/lowercase_table_grant.result:
        Updated the result file after adding TRIGGER privilege.
      mysql-test/r/ps.result:
        Updated the result file after adding TRIGGER privilege.
      mysql-test/r/sp.result:
        Updated the result file after adding TRIGGER privilege.
      mysql-test/r/trigger-compat.result:
        Updated the result file after adding TRIGGER privilege.
      mysql-test/r/trigger-grant.result:
        Updated the result file after adding TRIGGER privilege.
      mysql-test/t/trigger-compat.test:
        Grant table-level TRIGGER privilege instead of global SUPER one.
      mysql-test/t/trigger-grant.test:
        1. Grant table-level TRIGGER privilege instead of global SUPER one.
        2. Updated the test case to check that SUPER is required to specify
        the user other than the current as a definer.
      scripts/mysql_create_system_tables.sh:
        Added TRIGGER privilege.
      scripts/mysql_fix_privilege_tables.sql:
        Added TRIGGER privilege.
      sql/sql_acl.cc:
        Added TRIGGER privilege.
      sql/sql_acl.h:
        Added TRIGGER privilege.
      sql/sql_show.cc:
        Added TRIGGER privilege.
      sql/sql_trigger.cc:
        Check TRIGGER privilege instead of SUPER.
      sql/sql_yacc.yy:
        Added TRIGGER privilege.
      6aaed733
  32. 24 Jan, 2006 1 commit
    • unknown's avatar
      Fix for the following bugs: · 8f395ebb
      unknown authored
        - BUG#15166: Wrong update permissions required to execute triggers
        - BUG#15196: Wrong select permission required to execute triggers
      
      The idea of the fix is to check necessary privileges
      in Item_trigger_field::fix_fields(), instead of having "special variables"
      technique. To achieve this, we should pass to an Item_trigger_field instance
      a flag, which will indicate the usage/access type of this trigger variable.
      
      
      mysql-test/r/trigger-grant.result:
        Update the result file.
      mysql-test/t/trigger-grant.test:
        Add test cases for BUG#15166 and BUG#15196
      sql/item.cc:
        Item_trigger_field: check appropriate (SELECT/UPDATE) privilege in fix_fields().
      sql/item.h:
        Add a flag to specify access type for trigger field.
      sql/sql_trigger.cc:
        "Special variable" technique of checking privileges for NEW/OLD variables
        was replaced by checking table- and column-level privileges in
        Item_trigger_field::fix_fields().
      sql/sql_trigger.h:
        "Special variable" technique of checking privileges for NEW/OLD variables
        was replaced by checking table- and column-level privileges in
        Item_trigger_field::fix_fields().
      sql/sql_yacc.yy:
        Specify access type for trigger fields.
      8f395ebb
  33. 10 Jan, 2006 1 commit
    • unknown's avatar
      Fix for BUG#15110: mysqldump --triggers: does not include DEFINER clause · d4d29edb
      unknown authored
      There are two main idea of this fix:
        - introduce a common function for server and client to split user value
          (<user name>@<host name>) into user name and host name parts;
        - dump DEFINER clause in correct format in mysqldump.
      
      
      BitKeeper/etc/ignore:
        added client/my_user.c libmysqld/my_user.c sql/my_user.c
      client/Makefile.am:
        Use my_user.c in linking of mysqldump executable.
      client/mysqldump.c:
        Fix for BUG#15110(mysqldump --triggers: does not include DEFINER clause)
      include/Makefile.am:
        Add my_user.c
      include/mysql_com.h:
        Introduce a constant for max user length.
      libmysqld/Makefile.am:
        Add my_user.c
      mysql-test/r/mysqldump.result:
        Update result file.
      sql-common/Makefile.am:
        Add my_user.c
      sql/Makefile.am:
        Add my_user.c
      sql/sp.cc:
        Use constant for max user length.
      sql/sp_head.cc:
        Use common function to parse user value.
      sql/sql_acl.cc:
        Use constant for max user length.
      sql/sql_parse.cc:
        Use constant for max user length.
      sql/sql_show.cc:
        Use constant for max user length.
      sql/sql_trigger.cc:
        Use constant for max user length.
      include/my_user.h:
        A header file for parse_user().
      sql-common/my_user.c:
        A new file for parse_user() implementation.
      d4d29edb
  34. 06 Jan, 2006 1 commit
  35. 05 Jan, 2006 1 commit
    • unknown's avatar
      Review fixes of new pushed code · 64206b18
      unknown authored
      - Fixed tests
      - Optimized new code
      - Fixed some unlikely core dumps
      - Better bug fixes for:
        - #14397 - OPTIMIZE TABLE with an open HANDLER causes a crash
        - #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null
      
      
      mysql-test/r/create.result:
        Update results after removing wrong warnings for CREATE ... SELECT
        New tests
      mysql-test/r/handler.result:
        Drop used tables
      mysql-test/r/kill.result:
        Make test portable
      mysql-test/r/mysqlshow.result:
        Drop tables used by previous test
      mysql-test/r/trigger.result:
        Reuse old procedure name
      mysql-test/r/view.result:
        Extra tests
      mysql-test/t/create.test:
        New tests to test fix of removing wrong warnings for CREATE ... SELECT
      mysql-test/t/disabled.def:
        Enable 'kill' test (should now be portable)
      mysql-test/t/handler.test:
        Drop used tables
      mysql-test/t/kill.test:
        Make test portable even if kill doesn't work at once
      mysql-test/t/mysqlshow.test:
        Drop tables used by previous test
      mysql-test/t/trigger.test:
        Reuse old procedure name
      mysql-test/t/view.test:
        Extra tests
      sql/field.cc:
        Removed compiler warning
      sql/ha_federated.cc:
        my_snprintf -> strmake()
        (Simple optimization)
      sql/ha_ndbcluster.cc:
        Indentation cleanups and trival optimization
      sql/item.cc:
        Moved save_org_in_field() to item.cc to make it easier to test
        Remove setting of null_value as this is not needed
      sql/item.h:
        Moved save_org_in_field() to item.cc to make it easier to test
      sql/log_event.cc:
        Remove inline of slave_load_file_stem()
        Added 'extension' parameter to slave_load_file_stem() to get smaller code
        Removed not critical (or needed) DBUG_ASSERT()'s
        Cleaned up usage of slave_load_file_stem() to not depend on constant string lengths
        Indentation fixes
      sql/opt_range.cc:
        Moved code from declaration to function body
        (To make it more readable)
      sql/parse_file.cc:
        Fixed DBUG_PRINT
      sql/sp.cc:
        Simple cleanups
        - Removed not needed {} level
        - Ensure saved variables starts with old_
      sql/sp_head.cc:
        Indentation fixes
        Remove core dump when using --debug when m_next_cached_sp == 0
        Fixed compiler warnings
        Trivial optimizations
      sql/sp_head.h:
        Changed argument to set_definer() to const
        Added THD argument to recursion_level_error() to avoid call to current_thd
      sql/sql_acl.cc:
        Removed not needed test (first_not_own_table is the guard)
      sql/sql_base.cc:
        Removed extra empty line
      sql/sql_handler.cc:
        Don't test table version in mysql_ha_read() as this is already tested in lock_tables()
        Moved call to insert_fields to be after lock_table() to guard aganst reopen of tables
        (Better fix for Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash)
      sql/sql_insert.cc:
        Mark fields that are set in CREATE ... SELECT as used
        (Removed wrong warnings about field not having a default value)
      sql/sql_parse.cc:
        Removed not needed test of 'tables' (first_not_own_table is the guard)
        Simplify code
      sql/sql_select.cc:
        Use group->field to check if value is null instead of item called by 'save_org_in_field'
        This is a better bug fix for #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null)
      sql/sql_trigger.cc:
        Move sql_modes_parameters outside of function
        Indentation fixes
        Fixed compiler warning
        Ensure that thd->lex->query_tables_own_last is set properly before calling check_table_access()
        (This allows us to remove the extra test in check_grant() and check_table_access())
      64206b18
  36. 31 Dec, 2005 1 commit
    • unknown's avatar
      WL#1324 table name to file name encoding · 9c7412ca
      unknown authored
      - Encoding itself, implemented as a charset
        "filename". Originally planned to use '.'
        as an escape character, but now changed to '@'
        for two reasons: "ls" does not return
        file names starting with '.' considering them
        as a kind of hidden files; some platforms
        do not allow several dots in a file name.
      - replacing many calls of my_snprintf() and
        strnxmov() to the new build_table_filename().
      - Adding MY_APPEND_EXT mysys flag, to append
        an extention rather that replace it.
      - Replacing all numeric constants in fn_format
        flag arguments to their mysys definitions, e.g.
        MY_UNPACK_FILENAME,
      - Predictability in several function/methods:
        when a table name can appear with or withot .frm
        extension. Some functions/methods were changed
        so accept names strictly with .frm, other - strictly
        without .frm extensions. Several DBUG_ASSERTs were
        added to check whether an extension is passed.
      Many files:
        table name to file name encoding
      mysql_priv.h:
        Prototypes for new table name encoding tools.
      ctype-utf8.c:
        Implementing "filename" charset for
        table name to file name encoding.
      row0mysql.c:
        Fixing table name prefix.
      mf_format.c:
        Adding MY_APPEND_EXT processing.
      Many files:
        Fixing tests.
      my_sys.h:
        Adding new flag to append rather than replace an extension.
      m_ctype.h:
        Adding "filename" charset definition.
      
      
      include/m_ctype.h:
        Adding "filename" charset definition.
      include/my_sys.h:
        Adding new flag to append rather than replace an extension.
      mysql-test/t/alter_table.test:
        Fixing tests.
      mysql-test/t/create.test:
        Fixing tests.
      mysql-test/t/show_check.test:
        Fixing tests.
      mysql-test/r/alter_table.result:
        Fixing tests.
      mysql-test/r/create.result:
        Fixing tests.
      mysql-test/r/mysqldump.result:
        Fixing tests.
      mysys/mf_format.c:
        Adding MY_APPEND_EXT processing.
      sql/discover.cc:
        table name to file name encoding
      sql/ha_berkeley.cc:
        table name to file name encoding
      sql/ha_innodb.cc:
        table name to file name encoding
      sql/ha_myisam.cc:
        table name to file name encoding
      sql/ha_myisammrg.cc:
        table name to file name encoding
      sql/ha_ndbcluster.cc:
        table name to file name encoding
      sql/ha_partition.cc:
        table name to file name encoding
      sql/handler.cc:
        table name to file name encoding.
      sql/init.cc:
        table name to file name encoding
      sql/mysqld.cc:
        table name to file name encoding
      sql/parse_file.cc:
        table name to file name encoding
      sql/sql_acl.cc:
        table name to file name encoding
      sql/sql_base.cc:
        table name to file name encoding
      sql/sql_db.cc:
        table name to file name encoding
      sql/sql_delete.cc:
        table name to file name encoding
      sql/sql_rename.cc:
        table name to file name encoding
      sql/sql_show.cc:
        table name to file name encoding
      sql/sql_table.cc:
        table name to file name encoding
      sql/sql_trigger.cc:
        table name to file name encoding
      sql/sql_view.cc:
        table name to file name encoding
      sql/strfunc.cc:
        table name to file name encoding
      sql/table.cc:
        table name to file name encoding
      sql/unireg.cc:
        table name to file name encoding
      storage/innobase/row/row0mysql.c:
        Fixing table name prefix.
        ,
      storage/myisam/mi_create.c:
        table name to file name encoding
      storage/myisam/mi_delete_table.c:
        table name to file name encoding
      storage/myisam/mi_open.c:
        table name to file name encoding
      storage/myisam/mi_rename.c:
        table name to file name encoding
      strings/ctype-utf8.c:
        Implementing "filename" charset for
        table name to file name encoding.
      sql/mysql_priv.h:
        Prototypes for new table name encoding tools.
      storage/myisammrg/myrg_create.c:
        table name to file name encoding
      storage/myisammrg/myrg_open.c:
        table name to file name encoding
      9c7412ca
  37. 21 Dec, 2005 1 commit