Error in Insert Value "answer" in CDR Database Asterisk

433 Views Asked by At

This error occurs to me sometimes when the call is hung up. The rest is saved normally. I expose a bad record and a good one

[Dec 6 19:47:19] ERROR[31348][C-00000045]: cdr_mysql.c:349 mysql_log: Failed to insert into database: (1292) Incorrect datetime value: ‘SIP/sip_lbascunan/961258985,160,wWTt’ for column ‘answer’ at row 1

Good Row

‘1575675020.46’, ‘1575675020.46’, ‘“343591171” <343591171>’, ‘343591171’, ‘101961258985’, ‘engine’, ‘SIP/asterisk-63-0000002e’, ‘SIP/opsmovil-0000002f’, ‘Hangup’, ‘’, ‘2019-12-06 20:30:20’, NULL, ‘2019-12-06 20:30:20’, ‘0’, ‘0’, ‘NO ANSWER’, ‘3’, ‘’, ‘’, ‘55’, ‘’

Bad Row

‘1575674496.30’, ‘1575674496.30’, ‘“SISTEMAS” <1084>’, ‘1084’, ‘90962108827’, ‘lbascunan’, ‘SIP/1084-0000001e’, ‘SIP/sip_lbascunan-0000001f’, ‘Dial’, ‘SIP/sip_lbascunan/962108827,160,wWTt’, ‘2019-12-06 20:21:36’, ‘SIP/sip_lbascunan/962108827,160,wWTt’, ‘2019-12-06 20:22:00’, ‘24’, ‘0’, ‘NO ANSWER’, ‘3’, ‘’, ‘’, ‘35’, ‘’

I had to change the Answer field from Varchar to Datetime so that I could save.

This is my Table CDR

CREATE TABLE `cdr` (
  `uniqueid` varchar(32) NOT NULL DEFAULT '',
  `linkedid` varchar(32) NOT NULL DEFAULT '',
  `clid` varchar(80) NOT NULL DEFAULT '',
  `src` varchar(80) NOT NULL DEFAULT '',
  `dst` varchar(80) NOT NULL DEFAULT '',
  `dcontext` varchar(80) NOT NULL DEFAULT '',
  `channel` varchar(80) NOT NULL DEFAULT '',
  `dstchannel` varchar(80) NOT NULL DEFAULT '',
  `lastapp` varchar(80) NOT NULL DEFAULT '',
  `lastdata` varchar(80) NOT NULL DEFAULT '',
  `start` datetime NOT NULL,
  `answer` datetime NOT NULL,
  `end` datetime NOT NULL,
  `duration` int(11) NOT NULL DEFAULT '0',
  `billsec` int(11) NOT NULL DEFAULT '0',
  `disposition` varchar(45) NOT NULL DEFAULT '',
  `amaflags` int(11) NOT NULL DEFAULT '0',
  `accountcode` varchar(20) NOT NULL DEFAULT '',
  `userfield` varchar(255) NOT NULL DEFAULT '',
  `sequence` varchar(32) NOT NULL DEFAULT '',
  `peeraccount` varchar(32) NOT NULL DEFAULT '',
  PRIMARY KEY (`uniqueid`),
  KEY `start` (`start`),
  KEY `dst` (`dst`),
  KEY `accountcode` (`accountcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1

There are 1 best solutions below

0
arheops On

Just incorrect quatation. Check special symbols in callerid(name).

Anyway it is nothing to answer. Just bad system design and no check for sql injection.