MySql behaves differently on RDS and local docker container

366 Views Asked by At

There is a difference in the behavior of my local MySQL docker container and the RDS instance in another environment. I have read up on the documentation about this error and different options for sql_mode. But I could not figure out where this difference comes from.

  • I am running the exact same script.
  • The version is the same (MySQL 5.7.26) and all the parameters that are relevant look the same
  • Locally for docker I am using the image mysql:5.7 with the default command

The script that I'm running to reproduce the issue:

CREATE DATABASE `test_db`;
USE `test_db`;

SET SESSION `sql_mode`='STRICT_TRANS_TABLES';

CREATE TABLE `my_table` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL,
    `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(),
    PRIMARY KEY (`id`)
);

SHOW SESSION VARIABLES WHERE variable_name = 'sql_mode';
/* outputs: sql_mode STRICT_TRANS_TABLES */

INSERT INTO `my_table` (`id`, `name`, `date_created`) VALUES (NULL, 'John', NULL);

SHOW WARNINGS;

Result on localhost

/* Affected rows: 1  Found rows: 0  Warnings: 0  Duration for 1 query: 0.000 sec. */

Result on RDS

/* SQL Error (1048): Column 'date_created' cannot be null */

Apparently it's not the sql_mode parameter and not the version. Where else could that difference in behavior come from?

0

There are 0 best solutions below