What MySQL is silent about

Test:

1
2
3
4
5
6
7
8
CREATE TABLE test_int (
    u32 INT(10) UNSIGNED,
    i32 INT(10)
);

INSERT INTO test_int (u32, i32) VALUES(4294967295, 4294967295);

SELECT * FROM test_int;

Output:

1
2
3
4
5
+------------+------------+
| u32        | i32        |
+------------+------------+
| 4294967295 | 2147483647 |
+------------+------------+

As you can see, MySQL silently cut the value if doesn’t fit to a column type.

For example, PostgreSQL gives the following error in such case:

1
ERROR:  smallint out of range

Test for PostgreSQL:

1
2
3
4
5
6
CREATE TABLE test_int (
    small smallint,
    medium integer
);

INSERT INTO test_int (small, medium) VALUES(4294967295, 4294967295);

😒