mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 15:50:51 +03:00 
			
		
		
		
	The problem was that when converting a string to an exact number, rounding didn't work, because conversion didn't understand approximate numbers notation. Fix: a new function for string-to-number conversion was implemented, which is aware of approxinate number notation (with decimal point and exponent, e.g. -19.55e-1) include/m_ctype.h: Adding new function into MY_CHARSET_HANDLER Adding prototypes for 8bit and ucs2 functions. mysql-test/r/loaddata.result: Fixing results mysql-test/r/ps_2myisam.result: Fixing results mysql-test/r/ps_3innodb.result: Fixing results mysql-test/r/ps_4heap.result: Fixing results mysql-test/r/ps_5merge.result: Fixing results mysql-test/r/ps_6bdb.result: Fixing results mysql-test/r/rpl_rewrite_db.result: Fixing results mysql-test/r/select.result: Fixing results mysql-test/r/sp-vars.result: Fixing results mysql-test/r/strict.result: Fixing results mysql-test/r/view.result: Fixing results mysql-test/r/warnings.result: Fixing results mysql-test/t/strict.test: Fixing results sql/field.cc: Using new function strings/ctype-big5.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-bin.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-cp932.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-euc_kr.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-eucjpms.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-gb2312.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-gbk.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-latin1.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-simple.c: Implementing my_strntoull10_8bit Adding new function into MY_CHARSET_HANDLER strings/ctype-sjis.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-tis620.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-ucs2.c: Implementing UCS2 wrapper for 8bit version Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-ujis.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-utf8.c: Adding new function into the MY_CHARSET_HANDLER structure mysql-test/r/round.result: New BitKeeper file ``mysql-test/r/round.result'' mysql-test/t/round.test: New BitKeeper file ``mysql-test/t/round.test''
		
			
				
	
	
		
			273 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			273 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| DROP TABLE IF EXISTS t1;
 | |
| CREATE TABLE t1 (sint8 tinyint not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('127.4');
 | |
| INSERT INTO t1 VALUES ('127.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint8' at row 1
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| INSERT INTO t1 VALUES ('-127.4');
 | |
| INSERT INTO t1 VALUES ('-127.5');
 | |
| INSERT INTO t1 VALUES ('-128.4');
 | |
| INSERT INTO t1 VALUES ('-128.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint8' at row 1
 | |
| SELECT * FROM t1;
 | |
| sint8
 | |
| 0
 | |
| 1
 | |
| 127
 | |
| 127
 | |
| 0
 | |
| -1
 | |
| -127
 | |
| -128
 | |
| -128
 | |
| -128
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (uint8 tinyint unsigned not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('127.4');
 | |
| INSERT INTO t1 VALUES ('127.5');
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint8' at row 1
 | |
| INSERT INTO t1 VALUES ('255.4');
 | |
| INSERT INTO t1 VALUES ('255.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint8' at row 1
 | |
| SELECT * FROM t1;
 | |
| uint8
 | |
| 0
 | |
| 1
 | |
| 127
 | |
| 128
 | |
| 0
 | |
| 0
 | |
| 255
 | |
| 255
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (sint16 smallint not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('32767.4');
 | |
| INSERT INTO t1 VALUES ('32767.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint16' at row 1
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| INSERT INTO t1 VALUES ('-32767.4');
 | |
| INSERT INTO t1 VALUES ('-32767.5');
 | |
| INSERT INTO t1 VALUES ('-32768.4');
 | |
| INSERT INTO t1 VALUES ('-32768.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint16' at row 1
 | |
| SELECT * FROM t1;
 | |
| sint16
 | |
| 0
 | |
| 1
 | |
| 32767
 | |
| 32767
 | |
| 0
 | |
| -1
 | |
| -32767
 | |
| -32768
 | |
| -32768
 | |
| -32768
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (uint16 smallint unsigned not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('32767.4');
 | |
| INSERT INTO t1 VALUES ('32767.5');
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint16' at row 1
 | |
| INSERT INTO t1 VALUES ('65535.4');
 | |
| INSERT INTO t1 VALUES ('65535.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint16' at row 1
 | |
| SELECT * FROM t1;
 | |
| uint16
 | |
| 0
 | |
| 1
 | |
| 32767
 | |
| 32768
 | |
| 0
 | |
| 0
 | |
| 65535
 | |
| 65535
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (sint24 mediumint not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('8388607.4');
 | |
| INSERT INTO t1 VALUES ('8388607.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint24' at row 1
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| INSERT INTO t1 VALUES ('-8388607.4');
 | |
| INSERT INTO t1 VALUES ('-8388607.5');
 | |
| INSERT INTO t1 VALUES ('-8388608.4');
 | |
| INSERT INTO t1 VALUES ('-8388608.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint24' at row 1
 | |
| SELECT * FROM t1;
 | |
| sint24
 | |
| 0
 | |
| 1
 | |
| 8388607
 | |
| 8388607
 | |
| 0
 | |
| -1
 | |
| -8388607
 | |
| -8388608
 | |
| -8388608
 | |
| -8388608
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (uint24 mediumint unsigned not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('8388607.4');
 | |
| INSERT INTO t1 VALUES ('8388607.5');
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint24' at row 1
 | |
| INSERT INTO t1 VALUES ('16777215.4');
 | |
| INSERT INTO t1 VALUES ('16777215.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint24' at row 1
 | |
| SELECT * FROM t1;
 | |
| uint24
 | |
| 0
 | |
| 1
 | |
| 8388607
 | |
| 8388608
 | |
| 0
 | |
| 0
 | |
| 16777215
 | |
| 16777215
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (sint64 bigint not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('9223372036854775807.4');
 | |
| INSERT INTO t1 VALUES ('9223372036854775807.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint64' at row 1
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| INSERT INTO t1 VALUES ('-9223372036854775807.4');
 | |
| INSERT INTO t1 VALUES ('-9223372036854775807.5');
 | |
| INSERT INTO t1 VALUES ('-9223372036854775808.4');
 | |
| INSERT INTO t1 VALUES ('-9223372036854775808.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'sint64' at row 1
 | |
| SELECT * FROM t1;
 | |
| sint64
 | |
| 0
 | |
| 1
 | |
| 9223372036854775807
 | |
| 9223372036854775807
 | |
| 0
 | |
| -1
 | |
| -9223372036854775807
 | |
| -9223372036854775808
 | |
| -9223372036854775808
 | |
| -9223372036854775808
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (uint64 bigint unsigned not null);
 | |
| INSERT INTO t1 VALUES ('0.1');
 | |
| INSERT INTO t1 VALUES ('0.5');
 | |
| INSERT INTO t1 VALUES ('9223372036854775807.4');
 | |
| INSERT INTO t1 VALUES ('9223372036854775807.5');
 | |
| INSERT INTO t1 VALUES ('-0.1');
 | |
| INSERT INTO t1 VALUES ('-0.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint64' at row 1
 | |
| INSERT INTO t1 VALUES ('18446744073709551615.4');
 | |
| INSERT INTO t1 VALUES ('18446744073709551615.5');
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'uint64' at row 1
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.0');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.1');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.2');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.3');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.4');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.5');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.0e1');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.1e1');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.2e1');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.3e1');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.4e1');
 | |
| INSERT INTO t1 VALUES ('1844674407370955161.5e1');
 | |
| INSERT INTO t1 VALUES ('18446744073709551610e-1');
 | |
| INSERT INTO t1 VALUES ('18446744073709551611e-1');
 | |
| INSERT INTO t1 VALUES ('18446744073709551612e-1');
 | |
| INSERT INTO t1 VALUES ('18446744073709551613e-1');
 | |
| INSERT INTO t1 VALUES ('18446744073709551614e-1');
 | |
| INSERT INTO t1 VALUES ('18446744073709551615e-1');
 | |
| SELECT * FROM t1;
 | |
| uint64
 | |
| 0
 | |
| 1
 | |
| 9223372036854775807
 | |
| 9223372036854775808
 | |
| 0
 | |
| 0
 | |
| 18446744073709551615
 | |
| 18446744073709551615
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955162
 | |
| 18446744073709551610
 | |
| 18446744073709551611
 | |
| 18446744073709551612
 | |
| 18446744073709551613
 | |
| 18446744073709551614
 | |
| 18446744073709551615
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955161
 | |
| 1844674407370955162
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1 (str varchar(128), sint64 bigint not null default 0);
 | |
| INSERT INTO t1 (str) VALUES ('1.5');
 | |
| INSERT INTO t1 (str) VALUES ('1.00005e4');
 | |
| INSERT INTO t1 (str) VALUES ('1.0005e3');
 | |
| INSERT INTO t1 (str) VALUES ('1.005e2');
 | |
| INSERT INTO t1 (str) VALUES ('1.05e1');
 | |
| INSERT INTO t1 (str) VALUES ('1.5e0');
 | |
| INSERT INTO t1 (str) VALUES ('100005e-1');
 | |
| INSERT INTO t1 (str) VALUES ('100050e-2');
 | |
| INSERT INTO t1 (str) VALUES ('100500e-3');
 | |
| INSERT INTO t1 (str) VALUES ('105000e-4');
 | |
| INSERT INTO t1 (str) VALUES ('150000e-5');
 | |
| UPDATE t1 SET sint64=str;
 | |
| SELECT * FROM t1;
 | |
| str	sint64
 | |
| 1.5	2
 | |
| 1.00005e4	10001
 | |
| 1.0005e3	1001
 | |
| 1.005e2	101
 | |
| 1.05e1	11
 | |
| 1.5e0	2
 | |
| 100005e-1	10001
 | |
| 100050e-2	1001
 | |
| 100500e-3	101
 | |
| 105000e-4	11
 | |
| 150000e-5	2
 | |
| DROP TABLE t1;
 |