mariadb/mysql-test/t
Davi Arnaut fc39459504 Bug#45261: Crash, stored procedure + decimal
The problem was that creating a DECIMAL column from a decimal
value could lead to a failed assertion as decimal values can
have a higher precision than those attached to a table. The
assert could be triggered by creating a table from a decimal
with a large (> 30) scale. Also, there was a problem in
calculating the number of digits in the integral and fractional
parts if both exceeded the maximum number of digits permitted
by the new decimal type.

The solution is to ensure that truncation procedure is executed
when deducing a DECIMAL column from a decimal value of higher
precision. If the integer part is equal to or bigger than the
maximum precision for the DECIMAL type (65), the integer part
is truncated to fit and the fractional becomes zero. Otherwise,
the fractional part is truncated to fit into the space left
after the integer part is copied.

This patch borrows code and ideas from Martin Hansson's patch.

mysql-test/r/type_newdecimal.result:
  Add test case result for Bug#45261. Also, update test case to
  reflect that an additive operation increases the precision of
  the resulting type by 1.
mysql-test/t/type_newdecimal.test:
  Add test case for Bug#45261
sql/field.cc:
  Added DBUG_ASSERT to ensure object's invariant is maintained.
  Implement method to create a field to hold a decimal value
  from an item.
sql/field.h:
  Explain member variable. Add method to create a new decimal field.
sql/item.cc:
  The precision should only be capped when storing the value
  on a table. Also, this makes it impossible to calculate the
  integer part if Item::decimals (the scale) is larger than the
  precision.
sql/item.h:
  Simplify calculation of integer part.
sql/item_cmpfunc.cc:
  Do not limit the precision. It will be capped later.
sql/item_func.cc:
  Use new method for allocating a new decimal field.
  Add a specialized method for retrieving the precision
  of a user variable item.
sql/item_func.h:
  Add method to return the precision of a user variable.
sql/item_sum.cc:
  Use new method for allocating a new decimal field.
sql/my_decimal.h:
  The integer part could be improperly calculated for a decimal
  with 31 digits in the fractional part.
sql/sql_select.cc:
  Use new method which truncates the integer or decimal parts
  as needed.
2009-08-24 16:47:08 -03:00
..
1st.test
alias.test
almost_full.test
alter_table-big.test
alter_table.test
analyse.test
analyze.test
ansi.test
archive-big.test
archive.test
archive_bitfield.test
archive_gis.test
auto_increment.test Bug#46616: Merge 2009-08-20 14:30:59 +02:00
backup-master.sh
backup.test
bench_count_distinct.test
bigint.test
binary.test
bool.test
bootstrap.test
bug40113-master.opt Bug #40113: Embedded SELECT inside UPDATE or DELETE can timeout 2009-07-13 18:11:16 +03:00
bug40113.test Bug #40113: Embedded SELECT inside UPDATE or DELETE can timeout 2009-07-13 18:11:16 +03:00
bug46080-master.opt Bug #46080: group_concat(... order by) crashes server when 2009-07-10 15:00:34 +03:00
bug46080.test Addendum to the fix for bug #46080: fixed the error handling 2009-07-13 14:17:14 +03:00
bulk_replace.test
cache_innodb-master.opt
cache_innodb.test
case.test
cast.test
change_user-master.opt
change_user.test
check.test
client_xml.test
comments.test
commit_1innodb.test
compare.test
compress.test
concurrent_innodb_safelog-master.opt
concurrent_innodb_safelog.test
concurrent_innodb_unsafelog-master.opt
concurrent_innodb_unsafelog.test
connect.test Bug #44922 mysqltest's query_get_value function can't work with queries containing ',' 2009-05-25 17:19:20 +02:00
consistent_snapshot.test
constraints.test
contributors.test
count_distinct.test
count_distinct2-master.opt
count_distinct2.test
count_distinct3.test Tag count_distinct3.test as a big test. 2009-06-08 20:03:01 -03:00
crash_commit_before-master.opt
crash_commit_before.test
create-big.test
create.test Bug#45829 "CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing": 2009-07-29 10:54:20 +02:00
create_not_windows.test
create_select_tmp.test
csv.test
csv_alter_table.test
csv_not_null.test
ctype_ascii.test
ctype_big5.test
ctype_collate.test
ctype_cp932_binlog_row.test
ctype_cp932_binlog_stm.test test case fix 2009-06-25 13:44:50 +05:00
ctype_cp1250_ch.test
ctype_cp1251.test
ctype_create.test
ctype_eucjpms.test
ctype_euckr.test Backporting "WL#3332 Korean Enhancements" and 2009-07-24 11:27:23 +05:00
ctype_filename.test
ctype_filesystem-master.opt
ctype_filesystem.test
ctype_gb2312.test
ctype_gbk.test
ctype_gbk_binlog.test test case fix 2009-06-25 13:44:50 +05:00
ctype_hebrew.test
ctype_latin1.test
ctype_latin1_de-master.opt
ctype_latin1_de.test
ctype_latin2.test
ctype_latin2_ch.test
ctype_ldml-master.opt
ctype_ldml.test Bug#43827 Server closes connections and restarts 2009-06-04 14:35:29 +05:00
ctype_many.test
ctype_mb.test
ctype_recoding.test
ctype_sjis.test
ctype_tis620.test
ctype_uca.test
ctype_ucs.test
ctype_ucs2_def-master.opt
ctype_ucs2_def.test
ctype_ujis.test
ctype_ujis_ucs2.test
ctype_utf8.test
date_formats-master.opt
date_formats.test
ddl_i18n_koi8r.test
ddl_i18n_utf8.test
deadlock_innodb.test
default.test
delayed.test
delete.test
derived.test Bug #41156: List of derived tables acts like a chain of 2009-07-11 23:44:29 +05:00
dirty_close.test
disabled.def Bug#44920: MTR2 is not processing master.opt input properly on Windows. 2009-07-06 18:20:17 -04:00
distinct.test
drop.test
empty_table.test
endspace.test
error_simulation.test
errors.test
events_1.test
events_2.test
events_bugs-master.opt
events_bugs.test
events_embedded.test
events_grant.test
events_logs_tests-master.opt
events_logs_tests.test
events_microsec.test
events_restart-master.opt
events_restart.test
events_scheduling.test
events_stress.test
events_time_zone.test
events_trans.test
events_trans_notembedded.test
exampledb.test
execution_constants.test
explain.test
fix_priv_tables.test
flush.test
flush2-master.opt
flush2.test
flush_block_commit.test
flush_block_commit_notembedded.test
flush_read_lock_kill-master.opt
flush_read_lock_kill.test
flush_table.test
foreign_key.test
fulltext.test merging with 5.0 bugteam tree 2009-07-15 15:43:45 +05:30
fulltext2.test
fulltext3.test
fulltext_cache.test
fulltext_distinct.test
fulltext_left_join.test
fulltext_multi.test
fulltext_order_by.test
fulltext_plugin-master.opt
fulltext_plugin.test
fulltext_update.test
fulltext_var.test
func_compress.test Bug #32223 SETting max_allowed_packet variable 2009-06-19 11:27:19 +02:00
func_concat.test
func_crypt.test Bug #44767: invalid memory reads in password() and 2009-05-27 14:20:57 +04:00
func_date_add.test
func_default.test
func_des_encrypt.test
func_encrypt-master.opt
func_encrypt.test
func_encrypt_nossl.test
func_equal.test
func_gconcat.test
func_group.test
func_group_innodb.test
func_if.test
func_in.test Bug #44399 : crash with statement using TEXT columns, aggregates, GROUP BY, and 2009-05-25 11:00:40 +03:00
func_isnull.test
func_like.test
func_math.test Backport into build-200907211706-5.0.82sp1 2009-07-21 19:56:35 +02:00
func_misc.test
func_op.test
func_regexp.test
func_rollback.test
func_sapdb.test
func_set.test Bug#45168: assertion with convert() and empty set value 2009-06-16 16:36:15 +02:00
func_str.test
func_system.test
func_test.test
func_time.test
func_timestamp.test
gcc296.test
gis-rtree.test
gis.test Bug#44684: valgrind reports invalid reads in 2009-06-17 16:58:33 +02:00
grant.test Bug#44658 Create procedure makes server crash when user does not have ALL privilege 2009-05-29 15:37:54 +02:00
grant2.test
grant3-master.opt
grant3.test
grant_cache_no_prot.test
grant_cache_ps_prot.test
greedy_optimizer.test
group_by.test
group_min_max.test Bug #40113: Embedded SELECT inside UPDATE or DELETE can timeout 2009-07-13 18:11:16 +03:00
group_min_max_innodb.test
handler_innodb.test
handler_myisam.test Fix for bug #46456 [Ver->Prg]: HANDLER OPEN + TRUNCATE + DROP 2009-08-21 10:55:35 +05:00
having.test
heap.test
heap_auto_increment.test
heap_btree.test
heap_hash.test
help.test
index_merge_innodb.test
index_merge_myisam.test
information_schema.test
information_schema_chmod.test
information_schema_db.test
information_schema_inno.test
information_schema_part.test
init_connect-master.opt
init_connect.test Bug#44920: MTR2 is not processing master.opt input properly on Windows. 2009-07-06 18:20:17 -04:00
init_file-master.opt
init_file.test
innodb-autoinc-optimize.test
innodb-autoinc.test
innodb-lock.test
innodb-master.opt
innodb-replace.test
innodb-semi-consistent-master.opt
innodb-semi-consistent.test
innodb-ucs2.test
innodb.test
innodb_autoinc_lock_mode_zero-master.opt
innodb_autoinc_lock_mode_zero.test
innodb_bug21704.test Applying InnoDB snapshot 5.1-ss5488,part 4. Fixes BUG#21704 2009-07-10 17:05:53 +05:30
innodb_bug30919-master.opt
innodb_bug30919.test
innodb_bug34053.test
innodb_bug34300.test
innodb_bug35220.test
innodb_bug38231.test
innodb_bug39438-master.opt
innodb_bug39438.test
innodb_bug40565.test Applying InnoDB snashot 5.0-ss5406, part 2. Fixes BUG#40565 2009-06-25 15:20:26 +05:30
innodb_bug42101-nonzero-master.opt
innodb_bug42101-nonzero.test Applying InnoDB snapshot 5.1-ss5488,part 2. Fixes BUG#45749 2009-07-10 16:06:07 +05:30
innodb_bug42101.test Applying InnoDB snapshot 5.1-ss5488,part 2. Fixes BUG#45749 2009-07-10 16:06:07 +05:30
innodb_bug42419.test
innodb_bug45357.test Applying InnoDB snashot 5.1-ss5343, Fixes BUG#45357 2009-06-22 16:58:00 +05:30
innodb_gis.test
innodb_ignore_builtin-master.opt
innodb_ignore_builtin.test
innodb_mysql-master.opt
innodb_mysql.test Bug #36259 (Optimizing with ORDER BY) and bug#45828 (Optimizer won't 2009-07-07 15:52:34 +03:00
innodb_mysql_rbk-master.opt
innodb_mysql_rbk.test
innodb_notembedded.test Merge 5.0 -> 5.1 of fix for bug 44493 2009-07-30 16:31:45 +02:00
innodb_timeout_rollback-master.opt
innodb_timeout_rollback.test
innodb_trx_weight.test
insert.test
insert_notembedded.test
insert_select.test Manual merge. 2009-07-24 16:09:35 +04:00
insert_update.test
join.test
join_crash.test
join_nested.test
join_outer.test
join_outer_innodb.test
key.test
key_cache-master.opt
key_cache.test
key_diff.test
key_primary.test
keywords.test
kill.test
limit.test
loaddata.test
loaddata_autocom_innodb.test
lock.test
lock_multi.test
lock_multi_bug38499.test Bug #38499 : test marked as a big test : takes approx 275 secs on a P4 2.4 2009-07-06 13:15:40 +03:00
lock_multi_bug38691.test
lock_tables_lost_commit-master.opt
lock_tables_lost_commit.test
log_state-master.opt
log_state.test
log_tables-big-master.opt
log_tables-big.test
log_tables-master.opt
log_tables.test
log_tables_debug.test Post-merge fix: modify regular expression to better handle 24 hour 2009-06-15 20:27:27 -03:00
long_tmpdir-master.opt
long_tmpdir-master.sh
long_tmpdir.test
lowercase_fs_off.test
lowercase_mixed_tmpdir-master.opt
lowercase_mixed_tmpdir-master.sh
lowercase_mixed_tmpdir.test
lowercase_table-master.opt
lowercase_table.test
lowercase_table2.test
lowercase_table3-master.opt
lowercase_table3.test
lowercase_table_grant-master.opt
lowercase_table_grant.test
lowercase_table_qcache-master.opt
lowercase_table_qcache.test
lowercase_utf8-master.opt
lowercase_utf8.test
lowercase_view-master.opt
lowercase_view.test
merge-big.test
merge.test Fix for bug #46614: Assertion in show_create_trigger() 2009-08-14 00:49:28 +05:00
merge_innodb.test
metadata.test
mix2_myisam.test
mix2_myisam_ucs2.test
multi_statement-master.opt
multi_statement.test
multi_update-master.opt
multi_update.test
multi_update2-master.opt
multi_update2.test Test is very resource intensive under debug and valgrind runs. 2009-06-08 19:18:31 -03:00
multi_update_tiny_hash-master.opt
multi_update_tiny_hash.test
myisam-blob-master.opt
myisam-blob.test
myisam-system.test
myisam.test
myisam_crash_before_flush_keys-master.opt
myisam_crash_before_flush_keys.test
myisam_debug.test
myisampack.test
mysql-bug41486.test
mysql-bug45236.test Disabled embedded server for the test case for bug #45236. 2009-06-17 20:10:48 +04:00
mysql.test Merge bug fix. 2009-07-30 17:51:25 -07:00
mysql_client_test-master.opt
mysql_client_test.test
mysql_comments.sql
mysql_comments.test
mysql_cp932.test
mysql_delimiter.sql
mysql_delimiter_19799.sql
mysql_delimiter_source.sql
mysql_protocols.test
mysql_upgrade.test If running the mysql_upgrade test case with Valgrind, the resource 2009-07-28 16:59:38 -03:00
mysqladmin.test
mysqlbinlog-cp932-master.opt
mysqlbinlog-cp932.test
mysqlbinlog-master.opt
mysqlbinlog.test
mysqlbinlog2.test
mysqlbinlog_base64.test
mysqlbinlog_row.test
mysqlbinlog_row_big.test
mysqlbinlog_row_innodb.test
mysqlbinlog_row_myisam.test
mysqlbinlog_row_trans.test
mysqlcheck.test
mysqldump-compat.opt
mysqldump-compat.test
mysqldump-max.test
mysqldump-no-binlog-master.opt
mysqldump-no-binlog.test
mysqldump.test Bug# 30946: mysqldump silently ignores --default-character-set 2009-07-31 22:14:52 +05:00
mysqldump_restore.test Bug#40465 - mysqldump.test does no checking of dump or restore 2009-05-22 10:38:17 -04:00
mysqlshow.test
mysqlslap.test
mysqltest.test cherry picking fix for Bug #39542 from 6.0-runtime 2009-05-27 22:54:40 +02:00
named_pipe-master.opt
named_pipe.test
negation_elimination.test
no-threads-master.opt
no-threads.test
not_embedded_server-master.opt
not_embedded_server.test
not_partition.test
null.test
null_key.test
odbc.test
olap.test
openssl_1.test Bug#42158: leak: SSL_get_peer_certificate() doesn't have matching X509_free() 2009-05-25 10:00:18 -03:00
order_by.test Bug#46454: MySQL wrong index optimisation leads to incorrect result & crashes 2009-08-07 13:51:40 +02:00
order_fill_sortbuf-master.opt
order_fill_sortbuf.test
outfile.test
outfile_loaddata.test Bug# 30946: mysqldump silently ignores --default-character-set 2009-07-31 22:14:52 +05:00
overflow.test
packet.test Bug #32223 SETting max_allowed_packet variable 2009-06-19 11:27:19 +02:00
parser.test
parser_bug21114_innodb.test
parser_not_embedded.test
parser_precedence.test
parser_stack.test
partition-master.opt
partition.test Bug#46639: 1030 (HY000): Got error 124 from storage engine on 2009-08-21 17:38:29 +02:00
partition_archive.test
partition_blackhole.test
partition_bug18198.test
partition_charset.test
partition_csv.test Test case clean up: Move test cases that depend on the CSV storage 2009-07-31 20:39:26 -03:00
partition_datatype.test
partition_disabled-master.opt
partition_disabled.test manual merge 2009-08-12 12:03:05 +02:00
partition_error.test
partition_federated.test
partition_grant.test
partition_hash.test
partition_innodb.test
partition_innodb_semi_consistent-master.opt
partition_innodb_semi_consistent.test
partition_innodb_stmt.test
partition_list.test
partition_mgm.test
partition_mgm_err.test
partition_mgm_err2.test
partition_not_embedded.test Bug #30102 rename table does corrupt tables with partition files on failure. 2009-07-27 16:50:43 +05:30
partition_not_windows-master.opt
partition_not_windows.test
partition_order.test
partition_pruning.test
partition_range.test
partition_rename_longfilename.test Bug #30102 rename table does corrupt tables with partition files on failure. 2009-07-27 16:50:43 +05:30
partition_symlink.test
partition_windows.test
perror-win.test
perror.test
plugin-master.opt
plugin.test Backport WL#3653 to 5.1 to enable bundled innodb plugin. 2009-06-10 10:59:49 +02:00
plugin_load-master.opt Backport WL#3653 to 5.1 to enable bundled innodb plugin. 2009-06-10 10:59:49 +02:00
plugin_load.test
preload.test
profiling.test
ps-master.opt
ps.test Bug #38159: Function parsing problem generates misleading error message 2009-05-27 16:05:29 +03:00
ps_1general.test
ps_2myisam.test
ps_3innodb.test
ps_4heap.test
ps_5merge.test
ps_10nestset.test
ps_11bugs.test
ps_ddl.test
ps_ddl1.test
ps_grant.test
ps_not_windows.test
query_cache.test
query_cache_28249.test
query_cache_debug.test Bug#43758 Query cache can lock up threads in 'freeing items' state 2009-06-17 16:28:11 +02:00
query_cache_merge.test
query_cache_notembedded.test
query_cache_ps_no_prot.test
query_cache_ps_ps_prot.test
query_cache_with_views.test
range.test
read_many_rows_innodb.test
read_only.test
read_only_innodb.test
rename.test
renamedb.test
repair.test
replace.test
rollback.test
round.test
row.test
rowid_order_innodb.test
schema.test
select.test Bug#45266: Uninitialized variable lead to an empty result. 2009-06-26 19:57:42 +00:00
select_found.test
select_safe.test
shm-master.opt
shm.test
show_check-master.opt
show_check.test
skip_grants-master.opt
skip_grants.test
skip_log_bin-master.opt
skip_log_bin.test
skip_name_resolve-master.opt
skip_name_resolve.test
sp-big.test
sp-code.test
sp-destruct.test
sp-dynamic.test
sp-error.test merged 5.0-bugteam to 5.1-bugteam 2009-05-27 18:19:44 +03:00
sp-fib.test Bug#15866 Prepared for push on 5.0 2009-07-03 10:19:32 +02:00
sp-prelocking.test
sp-security.test
sp-threads.test
sp-ucs2.test
sp-vars.test
sp.test Bug#15866 ported from 5.0-gca 2009-06-04 13:53:15 +02:00
sp_gis.test
sp_notembedded.test Bug#44521 Executing a stored procedure as a prepared statement can sometimes cause 2009-07-29 22:07:08 +02:00
sp_stress_case.test
sp_trans.test
sp_trans_log.test
sql_mode.test Bug#45100: Incomplete DROP USER in case of SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH' 2009-06-12 18:11:19 -03:00
ssl-big.test
ssl.test
ssl_8k_key.test
ssl_compress.test
ssl_connect.test
status.test Bug #29971 status.test fails 2009-06-10 11:58:36 +03:00
status2.test
strict.test
strict_autoinc_1myisam.test
strict_autoinc_2innodb.test
strict_autoinc_3heap.test
subselect.test Merged fix for the bug#46051. 2009-07-19 16:49:40 +04:00
subselect2.test
subselect3.test Backport into build-200907211706-5.0.82sp1 2009-07-21 19:55:33 +02:00
subselect_debug.test
subselect_gis.test
subselect_innodb.test
subselect_notembedded.test
sum_distinct-big.test
sum_distinct.test
symlink.test
synchronization.test
sysdate_is_now-master.opt
sysdate_is_now.test
system_mysql_db.test
system_mysql_db_fix30020-master.opt
system_mysql_db_fix30020.test
system_mysql_db_fix40123-master.opt
system_mysql_db_fix40123.test
system_mysql_db_fix50030-master.opt
system_mysql_db_fix50030.test
system_mysql_db_fix50117-master.opt
system_mysql_db_fix50117.test
system_mysql_db_refs.test
tablelock.test
temp_table-master.opt
temp_table.test
timezone-master.opt
timezone.test
timezone2.test
timezone3-master.opt
timezone3.test
timezone4-master.opt
timezone4.test
timezone_grant.test
trigger-compat.test
trigger-trans.test
trigger.test Bug#44653: Server crash noticed when executing random queries with partitions. 2009-06-22 14:51:33 +02:00
trigger_notembedded.test Bug#45412 SHOW CREATE TRIGGER does not require privileges to disclose trigger data 2009-06-25 15:52:50 +05:00
truncate.test
type_binary.test
type_bit.test
type_bit_innodb.test
type_blob.test
type_date.test
type_datetime.test
type_decimal.test
type_enum.test
type_float.test
type_nchar.test
type_newdecimal-big.test
type_newdecimal.test Bug#45261: Crash, stored procedure + decimal 2009-08-24 16:47:08 -03:00
type_ranges.test
type_set.test
type_time.test
type_timestamp.test
type_uint.test
type_varchar.test
type_year.test
udf-master.opt
udf.test
udf_skip_grants-master.opt
udf_skip_grants.test
union-master.opt
union.test
unsafe_binlog_innodb-master.opt
unsafe_binlog_innodb.test
update.test
upgrade.test
user_limits.test
user_var-binlog.test
user_var.test
varbinary.test
variables+c.test
variables-big.test
variables-notembedded-master.opt
variables-notembedded.test
variables.test Bug #32223 SETting max_allowed_packet variable 2009-06-19 11:27:19 +02:00
variables_debug.test
view.test Merge from mysql-5.0-bugteam. 2009-08-11 13:29:45 -03:00
view_grant.test reverted the fix for bug #46019 from 5.1-bugteam 2009-08-21 17:41:48 +03:00
wait_timeout.test
warnings-master.opt
warnings.test Fix for bug#42364 reverted. 2009-07-06 11:55:53 +05:00
warnings_engine_disabled-master.opt
warnings_engine_disabled.test
windows.test
xa.test Bug#45548: XA transaction without access to InnoDB tables crashes the server 2009-06-25 12:25:23 -03:00
xml.test