shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

sharding-proxy run insert sql find error

Open archerForzmy opened this issue 7 years ago • 2 comments

INSERT INTO undo_log ( branch_id, xid, context, rollback_info, log_status, log_created, log_modified )
VALUES
	( 2018714708, '192.168.32.2:8091:2018714707', 'serializer=jackson', '{}', 1, now(), now() )

Execute in a separate mysql, no problem! Execute in a sharding proxy, the following exceptions occur!

1292 - Data truncation: Incorrect datetime value: 'now()' for column 'log_created' at row 1

Here I provide the piecewise table structure.

CREATE TABLE `undo_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `branch_id` bigint(20) NOT NULL,
  `xid` varchar(100) NOT NULL,
  `context` varchar(128) NOT NULL,
  `rollback_info` longblob NOT NULL,
  `log_status` int(11) NOT NULL,
  `log_created` datetime NOT NULL,
  `log_modified` datetime NOT NULL,
  `ext` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

I followed it up and found some problems.

Sharding-proxy translates the insert statement into the following statement and sends it to MySQL for execution

INSERT INTO undo_log ( branch_id, xid, context, rollback_info, log_status, log_created, log_modified )
VALUES
	( 2018714708, '192.168.32.2:8091:2018714707', 'serializer=jackson', '{}', 1, 'now()', 'now()' )

The problem arises with functions with single quotes!!!

archerForzmy avatar Aug 05 '19 07:08 archerForzmy

Duplicate with #1497, #2225 and #2745

terrymanu avatar Aug 05 '19 11:08 terrymanu

Is this problem fixed?

xiaoyuge avatar Jul 09 '24 08:07 xiaoyuge