Commit graph

22 commits

Author SHA1 Message Date
Sergei Petrunia
feaeb27b69 MDEV-29152: Assertion failed ... upon TO_CHAR with wrong argument
Item_func_tochar::check_arguments() didn't check if its arguments
each had one column. Failing to make this check and proceeding would
eventually cause either an assertion failure or the execution would
reach "MY_ASSERT_UNREACHABLE();" which would produce a crash with
a misleading stack trace.

* Fixed Item_func_tochar::check_arguments() to do the required check.

* Also fixed MY_ASSERT_UNREACHABLE() to terminate the program. Just
"executing" __builtin_unreachable() used to cause "undefined results",
which in my experience was a crash with corrupted stack trace.
2023-07-12 12:05:59 +03:00
Marko Mäkelä
7725f870b0 MDEV-15250 fixup: Remove MY_GNUC_PREREQ
The macro MY_GNUC_PREREQ() was used for testing for some minor
GCC 4 versions before GCC 4.8.5, which is the oldest version
that supports C++11, which we depend on ever since
commit d9613b750c
2022-04-26 15:13:39 +03:00
Thirunarayanan Balathandayuthapani
4b80c11f52 MDEV-15250 UPSERT during ALTER TABLE results in 'Duplicate entry' error for alter
- InnoDB DDL results in `Duplicate entry' if concurrent DML throws
duplicate key error. The following scenario explains the problem

connection con1:
  ALTER TABLE t1 FORCE;

connection con2:
  INSERT INTO t1(pk, uk) VALUES (2, 2), (3, 2);

In connection con2, InnoDB throws the 'DUPLICATE KEY' error because
of unique index. Alter operation will throw the error when applying
the concurrent DML log.

- Inserting the duplicate key for unique index logs the insert
operation for online ALTER TABLE. When insertion fails,
transaction does rollback and it leads to logging of
delete operation for online ALTER TABLE.
While applying the insert log entries, alter operation
encounters 'DUPLICATE KEY' error.

- To avoid the above fake duplicate scenario, InnoDB should
not write any log for online ALTER TABLE before DML transaction
commit.

- User thread which does DML can apply the online log if
InnoDB ran out of online log and index is marked as completed.
Set online log error if apply phase encountered any error.
It can also clear all other indexes log, marks the newly
added indexes as corrupted.

- Removed the old online code which was a part of DML operations

commit_inplace_alter_table() : Does apply the online log
for the last batch of secondary index log and does frees
the log for the completed index.

trx_t::apply_online_log: Set to true while writing the undo
log if the modified table has active DDL

trx_t::apply_log(): Apply the DML changes to online DDL tables

dict_table_t::is_active_ddl(): Returns true if the table
has an active DDL

dict_index_t::online_log_make_dummy(): Assign dummy value
for clustered index online log to indicate the secondary
indexes are being rebuild.

dict_index_t::online_log_is_dummy(): Check whether the online
log has dummy value

ha_innobase_inplace_ctx::log_failure(): Handle the apply log
failure for online DDL transaction

row_log_mark_other_online_index_abort(): Clear out all other
online index log after encountering the error during
row_log_apply()

row_log_get_error(): Get the error happened during row_log_apply()

row_log_online_op(): Does apply the online log if index is
completed and ran out of memory. Returns false if apply log fails

UndorecApplier: Introduced a class to maintain the undo log
record, latched undo buffer page, parse the undo log record,
maintain the undo record type, info bits and update vector

UndorecApplier::get_old_rec(): Get the correct version of the
clustered index record that was modified by the current undo
log record

UndorecApplier::clear_undo_rec(): Clear the undo log related
information after applying the undo log record

UndorecApplier::log_update(): Handle the update, delete undo
log and apply it on online indexes

UndorecApplier::log_insert(): Handle the insert undo log
and apply it on online indexes

UndorecApplier::is_same(): Check whether the given roll pointer
is generated by the current undo log record information

trx_t::rollback_low(): Set apply_online_log for the transaction
after partially rollbacked transaction has any active DDL

prepare_inplace_alter_table_dict(): After allocating the online
log, InnoDB does create fulltext common tables. Fulltext index
doesn't allow the index to be online. So removed the dead
code of online log removal

Thanks to Marko Mäkelä for providing the initial prototype and
Matthias Leich for testing the issue patiently.
2022-04-25 18:52:19 +05:30
Marko Mäkelä
6877ef9a7c Merge 10.4 into 10.5 2020-06-05 20:36:43 +03:00
Marko Mäkelä
680463a8d9 Merge 10.2 into 10.3 2020-06-05 16:51:26 +03:00
Marko Mäkelä
eba2d10ac5 MDEV-22721 Remove bloat caused by InnoDB logger class
Introduce a new ATTRIBUTE_NOINLINE to
ib::logger member functions, and add UNIV_UNLIKELY hints to callers.

Also, remove some crash reporting output. If needed, the
information will be available using debugging tools.

Furthermore, remove some fts_enable_diag_print output that included
indexed words in raw form. The code seemed to assume that words are
NUL-terminated byte strings. It is not clear whether a NUL terminator
is always guaranteed to be present. Also, UCS2 or UTF-16 strings would
typically contain many NUL bytes.
2020-06-04 10:24:10 +03:00
Alexander Barkov
a1e330de5a MDEV-21743 Split up SUPER privilege to smaller privileges 2020-03-10 23:49:47 +04:00
Marko Mäkelä
be85d3e61b Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Vicențiu Ciorbaru
5543b75550 Update FSF Address
* Update wrong zip-code
2019-05-11 21:29:06 +03:00
Marko Mäkelä
2c1067166d Merge bb-10.2-ext into 10.3 2017-10-04 08:24:06 +03:00
Vladislav Vaintroub
a3835fad0c Correct definition of ATTRIBUTE_NORETURN on Windows.
Only microsoft compiler, which can be correctly
tested with #ifdef _MSC_VER) has __declspec(noreturn)
2017-09-29 18:15:20 +00:00
Marko Mäkelä
4e1fa7f63d Merge bb-10.2-ext into 10.3 2017-09-01 11:33:45 +03:00
Marko Mäkelä
4386ee8ccc Add ATTRIBUTE_NORETURN and ATTRIBUTE_COLD
ATTRIBUTE_NORETURN is supported on all platforms (MSVS and GCC-like).
It declares that a function will not return; instead, the thread or
the whole process will terminate.

ATTRIBUTE_COLD is supported starting with GCC 4.3. It declares that
a function is supposed to be executed rarely. Rarely used error-handling
functions and functions that emit messages to the error log should be
tagged such.
2017-08-31 09:30:55 +03:00
Michael Widenius
4aaa38d26e Enusure that my_global.h is included first
- Added sql/mariadb.h file that should be included first by files in sql
  directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables
  that must be done before my_global.h is included)
- Removed a lot of include my_global.h from include files
- Removed include's of some files that my_global.h automatically includes
- Removed duplicated include's of my_sys.h
- Replaced include my_config.h with my_global.h
2017-08-24 01:05:44 +02:00
Kent Boortz
02e07e3b51 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Mikael Ronstrom
cb961461f2 Make MY_ALIGNED usable to define alignment of data structures 2011-05-04 10:45:51 +02:00
Mikael Ronstrom
28f5527371 Make MY_ALIGNED usable to define alignment of data structures 2011-05-04 10:42:48 +02:00
Davi Arnaut
cd1c6e220d Bug#58057: 5.1 libmysql/libmysql.c unused variable/compile failure
Bug#57995: Compiler flag change build error on OSX 10.4: my_getncpus.c
Bug#57996: Compiler flag change build error on OSX 10.5 : bind.c
Bug#57994: Compiler flag change build error : my_redel.c
Bug#57993: Compiler flag change build error on FreeBsd 7.0 : regexec.c
Bug#57992: Compiler flag change build error on FreeBsd : mf_keycache.c
Bug#57997: Compiler flag change build error on OSX 10.6: debug_sync.cc

Fix assorted compiler generated warnings.

cmd-line-utils/readline/bind.c:
  Bug#57996: Compiler flag change build error on OSX 10.5 : bind.c
  
  Initialize variable to work around a false positive warning.
include/m_string.h:
  Bug#57994: Compiler flag change build error : my_redel.c
  
  The expansion of stpcpy (in glibc) causes warnings if the
  return value of strmov is not being used. Since stpcpy is
  a GNU extension and the expansion ends up using a built-in
  provided by GCC, use the compiler provided built-in directly
  when possible.
include/my_compiler.h:
  Define a dummy MY_GNUC_PREREQ when not compiling with GCC.
libmysql/libmysql.c:
  Bug#58057: 5.1 libmysql/libmysql.c unused variable/compile failure
  
  Variable might not be used in some cases. So, tag it as unused.
mysys/mf_keycache.c:
  Bug#57992: Compiler flag change build error on FreeBsd : mf_keycache.c
  
  Use UNINIT_VAR to work around a false positive warning.
mysys/my_getncpus.c:
  Bug#57995: Compiler flag change build error on OSX 10.4: my_getncpus.c
  
  Declare variable in the same block where it is used.
regex/regexec.c:
  Bug#57993: Compiler flag change build error on FreeBsd 7.0 : regexec.c
  
  Work around a compiler bug which causes the cast to not be enforced.
sql/debug_sync.cc:
  Bug#57997: Compiler flag change build error on OSX 10.6: debug_sync.cc
  
  Use UNINIT_VAR to work around a false positive warning.
sql/handler.cc:
  Use UNINIT_VAR to work around a false positive warning.
sql/slave.cc:
  Use UNINIT_VAR to work around a false positive warning.
sql/sql_partition.cc:
  Use UNINIT_VAR to work around a false positive warning.
storage/myisam/ft_nlq_search.c:
  Use UNINIT_VAR to work around a false positive warning.
storage/myisam/mi_create.c:
  Use UNINIT_VAR to work around a false positive warning.
storage/myisammrg/myrg_open.c:
  Use UNINIT_VAR to work around a false positive warning.
tests/mysql_client_test.c:
  Change function to take a pointer to const, no need for a cast.
2010-11-10 19:14:47 -02:00
Davi Arnaut
3e9c52250a Bug#45288: pb2 returns a lot of compilation warnings
Fix assorted warnings that are generated in optimized builds.
Most of it is silencing variables that are set but unused.

This patch also introduces the MY_ASSERT_UNREACHABLE macro
which helps the compiler to deduce that a certain piece of
code is unreachable.

include/my_compiler.h:
  Use GCC's __builtin_unreachable if available. It allows
  GCC to deduce the unreachability of certain code paths,
  thus avoiding warnings that, for example, accused that a
  variable could be used without being initialized (due to
  unreachable code paths).
2010-10-20 16:21:40 -02:00
Davi Arnaut
d7944b621e Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.

Post-merge fix: include my_compiler.h before my_attribute.h
as the latter will undef __attribute__ if the compiler is not
GCC. Based on the compiler version, in my_compiler.h we know
for sure whether the aligned attribute is supported. Furthermore,
undefining attribute might cause bugs if some system header
uses it.

include/my_compiler.h:
  Drop aligned attribute support from Sun Studio C++ compiler
  as its not clear exactly which version of it supports the
  attribute.
2010-07-14 16:39:40 -03:00
Davi Arnaut
f317d3a6fb Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.

Another rather noisy violation of strict aliasing rules
is the spatial code which makes use of stack-based memory
(of type Geometry_buffer) to provide placement for Geometry
objects. Although a placement new is allowed to dynamically
change the type of a object, the object returned by the
new placement was being ignored and the original stack-based
object was being casted to the new type, thus violating strict
aliasing rules.

The solution is to reorganize the code so that the object
returned by the new placement is used instead of casting the
original object. Also, to ensure that the stack-based object
is properly aligned with respect to the objects it provides
placement for, a set of compiler-dependent macros and types
are introduced so that the alignment of objects can be inquired
and specified.

include/Makefile.am:
  Add new header.
include/my_compiler.h:
  Add new header.
include/my_global.h:
  Remove now-unnecessary macros.
sql/spatial.cc:
  Make object creation functions return the object whose type
  was dynamically changed by the new placement.
  
  Move static method from the header in order to avoid having
  to access a forward declaration.
sql/spatial.h:
  Object creation callbacks now take a array of chars as the
  storage area.
  
  Move create_by_typeid to a source file as to not access the
  forward declaration of Geometry_buffer.
  
  Ensure that Geometry_buffer is properly aligned.
sql/sql_show.cc:
  Use newly added aligned storage helper.
2010-07-14 09:27:13 -03:00