Commit graph

238 commits

Author SHA1 Message Date
monty@mysql.com/narttu.mysql.fi
088e2395f1 WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:

- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t

Removed declaration of byte, gptr, my_string, my_size_t and size_s. 

Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
  instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
  as this requires fewer casts in the code and is more in line with how the
  standard functions work.
- Added extra length argument to dirname_part() to return the length of the
  created string.
- Changed (at least) following functions to take uchar* as argument:
  - db_dump()
  - my_net_write()
  - net_write_command()
  - net_store_data()
  - DBUG_DUMP()
  - decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
  argument to my_uncompress() from a pointer to a value as we only return
  one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
  the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
  casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.

Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
  needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
  explicitely as this conflict was often hided by casting the function to
  hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
  get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
  size_t. This was needed to properly detect errors (which are
  returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
  (portability fix)
- Removed windows specific code to restore cursor position as this
  causes slowdown on windows and we should not mix read() and pread()
  calls anyway as this is not thread safe. Updated function comment to
  reflect this. Changed function that depended on original behavior of
  my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
  m_size is the number of elements in the array, not a string/memory
  length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
  Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
  - Replaced some calls to alloc_root + memcpy to use
    strmake_root()/strdup_root().
  - Changed some calls from memdup() to strmake() (Safety fix)
  - Simpler loops in client-simple.c
2007-05-10 12:59:39 +03:00
tomas@whalegate.ndb.mysql.com
caeb6ae034 Bug #27292 restarting a data node makes sql nodes log event buffer status every few seconds 2007-05-09 12:51:37 +02:00
malff/marcsql@weblab.(none)
e22cbec571 Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge
2007-05-02 12:11:25 -06:00
malff/marcsql@weblab.(none)
62fd6aa696 manual merge 5.0-runtime -> 5.1->runtime, with 25411 part I 2007-04-25 21:38:12 -06:00
tomas@whalegate.ndb.mysql.com
138264acab Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-telco-gca
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-single-user
2007-04-25 15:28:56 +02:00
tomas@whalegate.ndb.mysql.com
0183b3d399 ndb: added some retry sleep to not get busy loops 2007-04-25 15:25:23 +02:00
mats@romeo.(none)
875de0e571 Merge romeo.(none):/home/bkroot/mysql-5.1-rpl
into  romeo.(none):/home/bk/merge-mysql-5.1
2007-04-20 10:46:58 +02:00
tomas@whalegate.ndb.mysql.com
9afbeeedec Bug #27076
- test case
2007-04-18 21:39:45 +02:00
tomas@whalegate.ndb.mysql.com
38f9729c2a Bug #27076 Cluster does not honor SQL_LOG_BIN flag
- both for data schema operations
- also make sure schema events vet the right server id when injected into the binlog
- use same mechanism to signal server_id in bug#17095, and reserve some "id's" for flagging special conditions on the event, in this case do not log it
- enable printing of server ids in the testcases to show that we cot it right
2007-04-18 16:02:20 +02:00
monty@mysql.com/narttu.mysql.fi
72d135bec5 Clear field_alloc when it's moved to result set (allows us to always call free_root on field_alloc)
Change to use remove_file instead of 'system rm' in a lot of tests. (Should fix some windows test problems)
Removed memory leak in mysql_test if sync_with_master fails.
Do not terminate ndb_cluster_binary_log before the util thread has finnished. This should fix a shutdown bug where a thread is accessing injector_mutex after it's freed.
Patch may fix Bug#27622 "mysqld shutdown, util thread continues, while binlog thread exits"
2007-04-16 17:08:29 +03:00
mskold/marty@mysql.com/linux.site
5d622943e8 ha_ndbcluster.cc:
Bug #26591  Cluster handler does not set bits in null bytes correctly: Improved comments
ha_ndbcluster_binlog.cc:
  Bug #26591  Cluster handler does not set bits in null bytes correctly: Using empty_record() instead of bzero
2007-04-05 15:59:42 +02:00
tomas@whalegate.ndb.mysql.com
6db3dbcaca Bug #21494 Master Cluster MySQLD is point of failure that can lead to mismatch slave data
- insert gap event on cluster connect
2007-04-03 14:31:46 +02:00
tomas@whalegate.ndb.mysql.com
81ac116dfa Bug #17095 Cluster RBR in circle does not terminate
- add any value to ndb
- use it to update correct server id in binlog thread
2007-04-03 12:57:18 +02:00
tomas@whalegate.ndb.mysql.com
2dc02167df Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-rpl
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-single-user
2007-04-03 07:21:42 +02:00
tomas@whalegate.ndb.mysql.com
8bf9bf001d Bug #26783 replication status unknown after cluster or mysqld failure
- update the ndb_apply_status table with binlog info
2007-04-03 07:20:55 +02:00
tomas@whalegate.ndb.mysql.com
239ab421d8 Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-telco-gca
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-single-user
2007-03-29 18:52:33 +02:00
tomas@whalegate.ndb.mysql.com
af78c954cb Bug #27529: Slave crashes on lots of updates
- do not try to perge binlog when purge comes from slave, it never purges binlog anyways
2007-03-29 18:42:00 +02:00
tomas@poseidon.mysql.com
f4e0bc78dd Merge poseidon.mysql.com:/home/tomas/mysql-5.1-telco-gca-ndb_restore
into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb
2007-03-09 01:01:20 +07:00
tomas@poseidon.mysql.com
afdbe36a3f Bug #26783 replication status unknown after cluster or mysqld failure
- part one, extend apply_status table
2007-03-08 01:39:45 +07:00
malff/marcsql@weblab.(none)
dc98aa82ab Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge
2007-02-28 18:14:56 -07:00
monty@mysql.com/narttu.mysql.fi
cfef5d04b3 Remove compiler warnings 2007-02-27 19:31:49 +02:00
jani@a88-113-38-195.elisa-laajakaista.fi
6163508f85 Fixes for compiler warnings. 2007-02-27 11:27:04 +02:00
thek@kpdesk.mysql.com
bfea428c5a Merge kpdesk.mysql.com:/home/thek/dev/bug23240/my51-bug23240
into  kpdesk.mysql.com:/home/thek/dev/mysql-5.1-runtime
2007-02-19 16:13:13 +01:00
thek@kpdesk.mysql.com
84b96eb5e8 Bug#23240 --init-file statements with NOW() reports '1970-01-01 11:00:00' as the date time
- Merged from 5.0
- Removed redundant call to set_time(); now included in init_for_queries
2007-02-19 16:09:55 +01:00
msvensson@pilot.mysql.com
07dd9a61c1 Bug#26015 valgrind warning PollGuard::unlock_and_signal()/NdbCondition_Destroy
- Add variable "ndbcluster_binlog_terminating" and use that to signal
the cluster binlog thread it's time to shutdown. This allows
exact control of when the thread shutdown, previous implementation 
would start shutdown of the thread as soon as the mysqld started
shutdown. Now we will shutdown cluster binlog thread 
in 'ndbcluster_binlog_end'
2007-02-06 22:06:13 +01:00
tomas@poseidon.mysql.com
54bd795f12 Merge poseidon.mysql.com:/home/tomas/mysql-5.1-telco-cga
into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb
2007-02-06 12:45:42 +07:00
tomas@poseidon.mysql.com
bbe3008a49 Bug #26021 - ndb: valgrind warning handle_trailing_share/ndbcluster_free_share invalid read 2007-02-06 12:40:26 +07:00
tomas@poseidon.mysql.com
77ee8eab9c Merge poseidon.mysql.com:/home/tomas/mysql-5.1-telco-cga
into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb
2007-02-06 00:10:56 +07:00
tomas@poseidon.mysql.com
addb495339 Bug #26021 valgrind warning handle_trailing_share/ndbcluster_free_share invalid read
- revert bugfix, needs more work
2007-02-06 00:09:45 +07:00
tomas@poseidon.mysql.com
771c979514 Merge poseidon.mysql.com:/home/tomas/mysql-5.1-telco-cga
into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb
2007-02-05 13:22:33 +07:00
tomas@poseidon.mysql.com
475da34697 Bug #26021 - valgrind reports error regarding handle_trailing_share and client thread share usage
- add ndb_share connect_count to decide if share can be reused to setup replication
2007-02-05 13:21:18 +07:00
tomas@poseidon.mysql.com
68e0fd6735 Merge poseidon.mysql.com:/home/tomas/mysql-5.1-telco-cga
into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb
2007-02-05 13:10:24 +07:00
tomas@poseidon.mysql.com
3c265e5944 Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1
into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb
2007-02-05 12:19:24 +07:00
tomas@poseidon.mysql.com
b3fa3c8d62 Bug #26019 - valgrind warning ndbcluster_log_schema_op/safe_mutex_lock invalid read
protect the setting of ndb_schema_share = NULL with a mutex
2007-02-05 12:04:36 +07:00
stewart@willster.(none)
48649030cb BUG#25323 NDB binlog timer prints incorrect stats
fix time period calculation
2007-02-01 17:28:41 +11:00
monty@mysql.com/narttu.mysql.fi
410fc81a72 After merge fixes
Removed a lot of compiler warnings
Removed not used variables, functions and labels
Initialize some variables that could be used unitialized (fatal bugs)
%ll -> %l
2007-01-29 01:47:35 +02:00
kent@kent-amd64.(none)
895e442dbf Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.1
into  mysql.com:/home/kent/bk/main/mysql-5.1
2006-12-31 01:04:59 +01:00
kent@mysql.com/kent-amd64.(none)
1e3237fefa Many files:
Changed header to GPL version 2 only
2006-12-27 02:23:51 +01:00
msvensson@pilot.mysql.com
fe89182899 Add call to 'thd::clean_up' before deleting THD 2006-12-21 16:43:11 +01:00
msvensson@pilot.mysql.com
a44f076061 Merge neptunus:mysql/my51-ndb-valgrind
into  pilot.mysql.com:/home/msvensson/mysql/mysql-5.1-new-ndb
2006-12-21 12:08:39 +01:00
msvensson@neptunus.(none)
7e7a0e95d3 Improve ndb thread shutdown handling 2006-12-20 22:57:23 +01:00
tomas@poseidon.
dd2c9ea102 Bug #21806: wrong ndb binlog behaviour when cluster disconnects/restarts
- latest gci is reinitialized to 0 at reconnect, ndb binlog thread needs to wait until valid gci is retrieved
2006-12-20 15:34:45 +01:00
msvensson@neptunus.(none)
2dbdd8ba58 Remove old hack to avoid reception of SUB_DATA signals to destroyed Ndb object 2006-12-13 21:04:10 +01:00
mskold/marty@mysql.com/linux.site
cde79e4f79 Changed mysql.apply_status, mysql.binlog_index, and mysql.schema to mysql.ndb_apply_status, mysql.ndb_binlog_index, and mysql.ndb_schema 2006-12-01 15:49:07 +01:00
mskold/marty@linux.site
d7e375680a Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.1
into  mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
2006-11-30 15:31:20 +01:00
monty@mysql.com/nosik.monty.fi
0e149b7170 Removed compiler warnings
Ensure that my_size_t is always unsigned (to get predictiable results from system to system)
Removed some %lld, as these are not portable
2006-11-27 18:16:08 +02:00
monty@mysql.com/nosik.monty.fi
fa81a82e7f Fixed a LOT of compiler warnings
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.
2006-11-27 01:47:38 +02:00
mskold/marty@mysql.com/linux.site
a0dbb6ffb3 bug #21495 Alter table from x engine to ndb and back can cause issue with drop DB:added error printout to log 2006-11-15 11:38:22 +01:00
mskold/marty@mysql.com/linux.site
1206f28782 bug #21495 Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables 2006-11-15 11:13:49 +01:00
mats@romeo.(none)
b1a0052e71 Merge romeo.(none):/home/bkroot/mysql-5.1-new-rpl
into  romeo.(none):/home/bk/b18581-mysql-5.1-new-rpl
2006-11-13 15:48:39 +01:00
mats@romeo.(none)
851041ec3d Fixing problem in injector code making NDB tests fire an assertion. 2006-11-13 15:42:01 +01:00
monty@mysql.com/nosik.monty.fi
ca99516cc7 Fixed a lot of compiler warnings (Mainly in mysqld and instance manager)
Fixed some possible fatal wrong arguments to printf() style functions
Initialized some not initialized variables
Fixed bug in stored procedure and continue handlers
(Fixes Bug#22150)
2006-11-01 19:41:09 +02:00
brian@zim.(none)
46ae2113ba This patch adds handlerton passing to functions. NDB and Innodb still require a global hanlderton in the main code due to the nature of the sql_cache call back function (should be solveable... another patch).
Partitioning now has a flag to allow disabling of engines from being compatible with partitioning. Cleaned up heap naming convention on panic call.
2006-09-30 12:49:46 -07:00
mskold/marty@linux.site
5e60232da9 Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
into  mysql.com:/windows/Linux_space/MySQL/mysql-5.1
2006-09-22 21:14:58 +02:00
brian@zim.(none)
7194b6d75a This changes the order of the universe, black is now the new white.
In practice this means that handlerton is now created by the server and is passed to the engine. Plugin startups can now also control how plugins are inited (and can optionally pass values). Bit more flexibility to those who want to write plugin interfaces to the database.
2006-09-15 10:28:00 -07:00
mskold/marty@mysql.com/linux.site
6c472b9a9d Bug #21378 Alter table from X storage engine to NDB could cause data loss: post review fix 2006-09-13 13:41:05 +02:00
mskold/marty@mysql.com/linux.site
4f30db1f26 Bug #21378 Alter table from X storage engine to NDB could cause data loss: don't overwrite local tables when pushing out schema changes 2006-09-12 16:34:12 +02:00
mskold/marty@linux.site
04a62eb684 Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.1
into  mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
2006-09-01 15:26:03 +02:00
mskold/marty@mysql.com/linux.site
6bac3b8f40 NDBAPI cleanup 2006-08-30 11:41:21 +02:00
stewart@willster.(none)
0d7beacf31 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  willster.(none):/home/stewart/Documents/MySQL/5.1/ndb
2006-08-15 11:28:27 +08:00
jonas@perch.ndb.mysql.com
3a7d3f20f1 ndb - bug#21363
Add extra sleeps (conditionally) if user-ndb-object still exists during shutdown
  Note: This is not in anyway optimal, but i dont't really know in which order should be shutdown
        but it fixes problem...
2006-08-09 10:22:09 +02:00
ingo/istruewing@chilla.local
8e4c36ad4a Bug#18775 - Temporary table from alter table visible to other threads
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.
2006-08-02 17:57:06 +02:00
tomas@poseidon.ndb.mysql.com
4f7df01b4f Bug #20843 tests fails randomly with assertion in completeClusterFailed
Bug #20902 Alter table invalid schema version with statement-based binlogging
(latter caused by the above)
2006-07-08 03:26:13 +02:00
tomas@poseidon.ndb.mysql.com
26e39baca1 added warning on cluster reconnect and binlog usage, that data may be missing 2006-07-05 18:36:18 +02:00
tomas@poseidon.ndb.mysql.com
7b876a71d0 Bug #20843 tests fails randomly with assertion in completeClusterFailed 2006-07-05 17:36:18 +02:00
tomas@poseidon.ndb.mysql.com
1b7da4b8ed extra logging and asserts to try to track down the spurious completeCluster failure assetion
corrected error in invalidation of dict cache which may be causing the valgrind warning at times
2006-07-05 14:20:14 +02:00
monty@narttu.mysql.fi
91c3e28d77 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  mysql.com:/home/my/mysql-5.1
2006-06-28 20:03:46 +03:00
monty@mysql.com
31fdcd3be0 Added purecov comment for new, not executed code for my recent changeset
(Found by dgcov)
2006-06-28 14:03:08 +03:00
tomas@poseidon.ndb.mysql.com
a23259c2ef Bug #20705 table truncation from one mysqld causes ERROR 1412 on other mysqld servers
- make sure to invalidate even if table is not binlogged
2006-06-28 02:35:13 +02:00
knielsen@rt.int.sifira.dk
22285bb75a Merge mysql.com:/usr/local/mysql/mysql-5.1-bug20549
into  mysql.com:/usr/local/mysql/tmp-5.1
2006-06-26 11:26:24 +02:00
monty@mysql.com
4697deb436 Remove compiler warnings
Fixed wrong table flags type in ndbcluster that caused previous commit to fail
2006-06-23 02:49:19 +03:00
monty@mysql.com
649157954b Fixed failure with rpl_truncate_7ndb.test when using statement based replication.
is_injective -> table_flag() HA_HAS_OWN_BINLOGGING
(Faster and easier to understand)
Allow cluster_binlogging also in mixed replication mode.
2006-06-22 22:44:21 +03:00
knielsen@mysql.com
bd5f334bed BUG#20549: Fix missing memory initialization.
Some values were not initialized, causing Valgrind errors (and potential
random bugs):

 - NDB binlog thread thd->variables.pseudo_thread_id.
 - Table null bits.
 - Field bytes for columns with NULL values.
2006-06-22 16:42:50 +02:00
monty@mysql.com
49a3334889 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  mysql.com:/home/my/mysql-5.1
2006-06-19 13:00:36 +03:00
monty@mysql.com
860661a2dc unsigned char -> uchar
Added missing copyright
Indentation and prototype fixes
Fixed compiler warning
2006-06-19 12:45:34 +03:00
petr@outpost.site
86420b38aa Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  mysql.com:/home/cps/mysql/devel/5.1-csv-remove-mmap
2006-06-15 15:38:14 +04:00
tomas@poseidon.ndb.mysql.com
2d33bb5c94 ndb: add missing LOCK_open 2006-06-14 01:20:39 +02:00
mskold@mysql.com
38a445fee1 sql_delete.cc:
Bug #18864  TRUNCATE TABLE doesn't reset AUTO_INCREMENT value on ndb table: locked lock_OPEN mutex to support TRUNCATE with re-create and cluster binlog
Many files:
  Bug #18864  TRUNCATE TABLE doesn't reset AUTO_INCREMENT value on ndb table: adaption to MySQ Cluster replication
ndb_lock.result, ha_ndbcluster.cc:
  Fix for Bug #18184  SELECT ... FOR UPDATE does not work..: Adaption to 5.1 code
NdbDictionaryImpl.hpp:
  Fix of bad merge
2006-06-12 14:23:21 +02:00
petr@mysql.com
9669d3ae58 Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  mysql.com:/home/cps/mysql/devel/5.1-logs-final
2006-06-07 23:58:08 +04:00
monty@mysql.com
c46fb742b8 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new
into  mysql.com:/home/my/mysql-5.1
2006-06-04 21:05:22 +03:00
monty@mysql.com
74cc73d461 This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),

- New optional handler function introduced: reset()
  This is called after every DML statement to make it easy for a handler to
  statement specific cleanups.
  (The only case it's not called is if force the file to be closed)

- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
  should be moved to handler::reset()

- table->read_set contains a bitmap over all columns that are needed
  in the query.  read_row() and similar functions only needs to read these
  columns
- table->write_set contains a bitmap over all columns that will be updated
  in the query. write_row() and update_row() only needs to update these
  columns.
  The above bitmaps should now be up to date in all context
  (including ALTER TABLE, filesort()).

  The handler is informed of any changes to the bitmap after
  fix_fields() by calling the virtual function
  handler::column_bitmaps_signal(). If the handler does caching of
  these bitmaps (instead of using table->read_set, table->write_set),
  it should redo the caching in this code. as the signal() may be sent
  several times, it's probably best to set a variable in the signal
  and redo the caching on read_row() / write_row() if the variable was
  set.

- Removed the read_set and write_set bitmap objects from the handler class

- Removed all column bit handling functions from the handler class.
  (Now one instead uses the normal bitmap functions in my_bitmap.c instead
  of handler dedicated bitmap functions)

- field->query_id is removed. One should instead instead check
  table->read_set and table->write_set if a field is used in the query.

- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
  handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
  instead use table->read_set to check for which columns to retrieve.

- If a handler needs to call Field->val() or Field->store() on columns
  that are not used in the query, one should install a temporary
  all-columns-used map while doing so. For this, we provide the following
  functions:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
  field->val();
  dbug_tmp_restore_column_map(table->read_set, old_map);

  and similar for the write map:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
  field->val();
  dbug_tmp_restore_column_map(table->write_set, old_map);

  If this is not done, you will sooner or later hit a DBUG_ASSERT
  in the field store() / val() functions.
  (For not DBUG binaries, the dbug_tmp_restore_column_map() and
  dbug_tmp_restore_column_map() are inline dummy functions and should
  be optimized away be the compiler).

- If one needs to temporary set the column map for all binaries (and not
  just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
  methods) one should use the functions tmp_use_all_columns() and
  tmp_restore_column_map() instead of the above dbug_ variants.

- All 'status' fields in the handler base class (like records,
  data_file_length etc) are now stored in a 'stats' struct. This makes
  it easier to know what status variables are provided by the base
  handler.  This requires some trivial variable names in the extra()
  function.

- New virtual function handler::records().  This is called to optimize
  COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
  (stats.records is not supposed to be an exact value. It's only has to
  be 'reasonable enough' for the optimizer to be able to choose a good
  optimization path).

- Non virtual handler::init() function added for caching of virtual
  constants from engine.

- Removed has_transactions() virtual method. Now one should instead return
  HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
  transactions.

- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
  that is to be used with 'new handler_name()' to allocate the handler
  in the right area.  The xxxx_create_handler() function is also
  responsible for any initialization of the object before returning.

  For example, one should change:

  static handler *myisam_create_handler(TABLE_SHARE *table)
  {
    return new ha_myisam(table);
  }

  ->

  static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
  {
    return new (mem_root) ha_myisam(table);
  }

- New optional virtual function: use_hidden_primary_key().
  This is called in case of an update/delete when
  (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
  but we don't have a primary key. This allows the handler to take precisions
  in remembering any hidden primary key to able to update/delete any
  found row. The default handler marks all columns to be read.

- handler::table_flags() now returns a ulonglong (to allow for more flags).

- New/changed table_flags()
  - HA_HAS_RECORDS	    Set if ::records() is supported
  - HA_NO_TRANSACTIONS	    Set if engine doesn't support transactions
  - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
                            Set if we should mark all primary key columns for
			    read when reading rows as part of a DELETE
			    statement. If there is no primary key,
			    all columns are marked for read.
  - HA_PARTIAL_COLUMN_READ  Set if engine will not read all columns in some
			    cases (based on table->read_set)
 - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
   			    Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
 - HA_DUPP_POS              Renamed to HA_DUPLICATE_POS
 - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
			    Set this if we should mark ALL key columns for
			    read when when reading rows as part of a DELETE
			    statement. In case of an update we will mark
			    all keys for read for which key part changed
			    value.
  - HA_STATS_RECORDS_IS_EXACT
			     Set this if stats.records is exact.
			     (This saves us some extra records() calls
			     when optimizing COUNT(*))
			    

- Removed table_flags()
  - HA_NOT_EXACT_COUNT     Now one should instead use HA_HAS_RECORDS if
			   handler::records() gives an exact count() and
			   HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
  - HA_READ_RND_SAME	   Removed (no one supported this one)

- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()

- Renamed handler::dupp_pos to handler::dup_pos

- Removed not used variable handler::sortkey


Upper level handler changes:

- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
  cache is updated on engine creation time and updated on open.


MySQL level changes (not obvious from the above):

- DBUG_ASSERT() added to check that column usage matches what is set
  in the column usage bit maps. (This found a LOT of bugs in current
  column marking code).

- In 5.1 before, all used columns was marked in read_set and only updated
  columns was marked in write_set. Now we only mark columns for which we
  need a value in read_set.

- Column bitmaps are created in open_binary_frm() and open_table_from_share().
  (Before this was in table.cc)

- handler::table_flags() calls are replaced with handler::ha_table_flags()

- For calling field->val() you must have the corresponding bit set in
  table->read_set. For calling field->store() you must have the
  corresponding bit set in table->write_set. (There are asserts in
  all store()/val() functions to catch wrong usage)

- thd->set_query_id is renamed to thd->mark_used_columns and instead
  of setting this to an integer value, this has now the values:
  MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
  Changed also all variables named 'set_query_id' to mark_used_columns.

- In filesort() we now inform the handler of exactly which columns are needed
  doing the sort and choosing the rows.

- The TABLE_SHARE object has a 'all_set' column bitmap one can use
  when one needs a column bitmap with all columns set.
  (This is used for table->use_all_columns() and other places)

- The TABLE object has 3 column bitmaps:
  - def_read_set     Default bitmap for columns to be read
  - def_write_set    Default bitmap for columns to be written
  - tmp_set          Can be used as a temporary bitmap when needed.
  The table object has also two pointer to bitmaps read_set and write_set
  that the handler should use to find out which columns are used in which way.

- count() optimization now calls handler::records() instead of using
  handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).

- Added extra argument to Item::walk() to indicate if we should also
  traverse sub queries.

- Added TABLE parameter to cp_buffer_from_ref()

- Don't close tables created with CREATE ... SELECT but keep them in
  the table cache. (Faster usage of newly created tables).


New interfaces:

- table->clear_column_bitmaps() to initialize the bitmaps for tables
  at start of new statements.

- table->column_bitmaps_set() to set up new column bitmaps and signal
  the handler about this.

- table->column_bitmaps_set_no_signal() for some few cases where we need
  to setup new column bitmaps but don't signal the handler (as the handler
  has already been signaled about these before). Used for the momement
  only in opt_range.cc when doing ROR scans.

- table->use_all_columns() to install a bitmap where all columns are marked
  as use in the read and the write set.

- table->default_column_bitmaps() to install the normal read and write
  column bitmaps, but not signaling the handler about this.
  This is mainly used when creating TABLE instances.

- table->mark_columns_needed_for_delete(),
  table->mark_columns_needed_for_delete() and
  table->mark_columns_needed_for_insert() to allow us to put additional
  columns in column usage maps if handler so requires.
  (The handler indicates what it neads in handler->table_flags())

- table->prepare_for_position() to allow us to tell handler that it
  needs to read primary key parts to be able to store them in
  future table->position() calls.
  (This replaces the table->file->ha_retrieve_all_pk function)

- table->mark_auto_increment_column() to tell handler are going to update
  columns part of any auto_increment key.

- table->mark_columns_used_by_index() to mark all columns that is part of
  an index.  It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
  it to quickly know that it only needs to read colums that are part
  of the key.  (The handler can also use the column map for detecting this,
  but simpler/faster handler can just monitor the extra() call).

- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
  also mark all columns that is used by the given key.

- table->restore_column_maps_after_mark_index() to restore to default
  column maps after a call to table->mark_columns_used_by_index().

- New item function register_field_in_read_map(), for marking used columns
  in table->read_map. Used by filesort() to mark all used columns

- Maintain in TABLE->merge_keys set of all keys that are used in query.
  (Simplices some optimization loops)

- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
  but the field in the clustered key is not assumed to be part of all index.
  (used in opt_range.cc for faster loops)

-  dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
   tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
   mark all columns as usable.  The 'dbug_' version is primarily intended
   inside a handler when it wants to just call Field:store() & Field::val()
   functions, but don't need the column maps set for any other usage.
   (ie:: bitmap_is_set() is never called)

- We can't use compare_records() to skip updates for handlers that returns
  a partial column set and the read_set doesn't cover all columns in the
  write set. The reason for this is that if we have a column marked only for
  write we can't in the MySQL level know if the value changed or not.
  The reason this worked before was that MySQL marked all to be written
  columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
  bug'.

- open_table_from_share() does not anymore setup temporary MEM_ROOT
  object as a thread specific variable for the handler. Instead we
  send the to-be-used MEMROOT to get_new_handler().
  (Simpler, faster code)



Bugs fixed:

- Column marking was not done correctly in a lot of cases.
  (ALTER TABLE, when using triggers, auto_increment fields etc)
  (Could potentially result in wrong values inserted in table handlers
  relying on that the old column maps or field->set_query_id was correct)
  Especially when it comes to triggers, there may be cases where the
  old code would cause lost/wrong values for NDB and/or InnoDB tables.

- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
  OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
  This allowed me to remove some wrong warnings about:
  "Some non-transactional changed tables couldn't be rolled back"

- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
  (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
  some warnings about
  "Some non-transactional changed tables couldn't be rolled back")

- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
  which could cause delete_table to report random failures.

- Fixed core dumps for some tests when running with --debug

- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
  (This has probably caused us to not properly remove temporary files after
  crash)

- slow_logs was not properly initialized, which could maybe cause
  extra/lost entries in slow log.

- If we get an duplicate row on insert, change column map to read and
  write all columns while retrying the operation. This is required by
  the definition of REPLACE and also ensures that fields that are only
  part of UPDATE are properly handled.  This fixed a bug in NDB and
  REPLACE where REPLACE wrongly copied some column values from the replaced
  row.

- For table handler that doesn't support NULL in keys, we would give an error
  when creating a primary key with NULL fields, even after the fields has been
  automaticly converted to NOT NULL.

- Creating a primary key on a SPATIAL key, would fail if field was not
  declared as NOT NULL.


Cleanups:

- Removed not used condition argument to setup_tables

- Removed not needed item function reset_query_id_processor().

- Field->add_index is removed. Now this is instead maintained in
  (field->flags & FIELD_IN_ADD_INDEX)

- Field->fieldnr is removed (use field->field_index instead)

- New argument to filesort() to indicate that it should return a set of
  row pointers (not used columns). This allowed me to remove some references
  to sql_command in filesort and should also enable us to return column
  results in some cases where we couldn't before.

- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
  bitmap, which allowed me to use bitmap functions instead of looping over
  all fields to create some needed bitmaps. (Faster and smaller code)

- Broke up found too long lines

- Moved some variable declaration at start of function for better code
  readability.

- Removed some not used arguments from functions.
  (setup_fields(), mysql_prepare_insert_check_table())

- setup_fields() now takes an enum instead of an int for marking columns
   usage.

- For internal temporary tables, use handler::write_row(),
  handler::delete_row() and handler::update_row() instead of
  handler::ha_xxxx() for faster execution.

- Changed some constants to enum's and define's.

- Using separate column read and write sets allows for easier checking
  of timestamp field was set by statement.

- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()

- Don't build table->normalized_path as this is now identical to table->path
  (after bar's fixes to convert filenames)

- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
  do comparision with the 'convert-dbug-for-diff' tool.


Things left to do in 5.1:

- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
  row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
  Mats has promised to look into this.

- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
  (I added several test cases for this, but in this case it's better that
  someone else also tests this throughly).
  Lars has promosed to do this.
2006-06-04 18:52:22 +03:00
tomas@poseidon.ndb.mysql.com
3ab132bdeb Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb
2006-06-01 08:46:23 +02:00
tomas@poseidon.ndb.mysql.com
586f00b279 Bug #18947 CRBR: order in binlog of create table and insert (on different table) not determ
- move clear of slock until after completion of data events on the binlog
2006-05-31 23:24:25 +02:00
tomas@poseidon.ndb.mysql.com
b6f54a737a Bug #18947 CRBR: order in binlog of create table and insert (on different table) not determ
- wait for schema event also if mysqld is a single one in cluster to ensure serialization with data events
+ some current_thd removals
+ enabling kill of sql thread during shema sync wait
2006-05-31 16:16:03 +02:00
tomas@poseidon.ndb.mysql.com
df507201b2 ndb: release LOCK_open during mysqld schema sync and mysqld sync with binlog (create/drop/rename table)
+ increase timeout for sync... which now should never occur
2006-05-31 01:52:14 +02:00
serg@sergbook.mysql.com
71657322fd Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new
into sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.1
2006-05-28 14:54:28 +02:00
serg@sergbook.mysql.com
fe97dbb587 handlerton cleanup:
duplicate fields removed, st_mysql_storage_engine added to support
run-time handlerton initialization (no compiler warnings), handler API
is now tied to MySQL version, handlerton->plugin mapping added
(slot-based), dummy default_hton removed, plugin-type-specific
initialization generalized, built-in plugins are now initialized too,
--default-storage-engine no longer needs a list of storage engines
in handle_options().

mysql-test-run.pl bugfixes
2006-05-28 14:51:01 +02:00
tomas@poseidon.ndb.mysql.com
83c095ba5c ha_ndbcluster_binlog.cc:
ndb: fix compile error on solaris
2006-05-19 20:31:02 +02:00
tomas@poseidon.ndb.mysql.com
d76b071efe ndb: moved startup order back for ndb binlog thread from previous push that seems to be causing startup issues 2006-05-19 18:11:47 +02:00
tomas@poseidon.ndb.mysql.com
4183ab6d49 Bug #19885 master1 crash in ndb_condition_pushdown test
- record structure wrongly deallocated during online alter on remote mysqld
- change so that ndb handler allocates the buffer itself, so it can be reused after alter
2006-05-19 17:34:50 +02:00
tomas@poseidon.ndb.mysql.com
0ba9208933 ndb: changed to use mem root to allocate table structure for ndb share 2006-05-19 15:44:46 +02:00
tomas@poseidon.ndb.mysql.com
148faca833 Bug #19395 mysqld does not always detect cluster shutdown 2006-05-19 12:54:12 +02:00
tomas@poseidon.ndb.mysql.com
d0fd5ecde8 Bug #19395 mysqld does not always detect cluster shutdown
Bug #17610 ndbapi: dropEventOperation leaves object behind, memleak
2006-05-18 23:38:07 +02:00
tomas@poseidon.ndb.mysql.com
0cb31d7d5f Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail 2006-05-17 08:34:48 +02:00
tomas@poseidon.ndb.mysql.com
c5987ab67a Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail
- adoptions to handle binlog
2006-05-16 20:56:45 +02:00
tomas@poseidon.ndb.mysql.com
f30014f8a4 ndb: added extra printout on failed "internal" discovery for binlog
+ removed extra (not needed) discovery done at online create/drop index
2006-05-10 16:54:29 +02:00
tomas@poseidon.ndb.mysql.com
792f7383ac Bug #19572 Memory leaks in cluster when running make test 2006-05-08 18:09:01 +02:00
tomas@poseidon.ndb.mysql.com
6a48847b1a Bug #19492 --binlog-do-db option cuases tables create issues for ndb master
- ndb system tables not created because of filter, moved chack of filter
2006-05-06 01:25:44 +02:00
petr@mysql.com
fec70c97c9 WL#3153 "Split logs". Recommit with post-review fixes 2006-05-05 10:45:58 +04:00
tomas@poseidon.ndb.mysql.com
f6ede396c0 Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb
2006-05-04 21:55:12 +02:00