Error while passing CDR record to PostgreSQL

Hello. An error occurs while passing cdr records to PostgreSQL. This happens ONLY during the considered call from Asternik. qlog-queuedial - context from extension_custom_asternic_outbound-freepbx.conf. All other CDR call data is recorded normally. Apparently, it swears at the calldate entry having the form { ts ‘2023-07-26 07:10:36’ }. I tried to do a separate INSERT this entry - Postgre gives a syntax error, swearing at the characters { ts }. At the same time, in MySQL (MariaDB) it is noticed normally, without extra characters.

Database encoding UTF-8
Calldate column in PostgreSQL has data type timestamp
MySQL - date and time

Error type:

[2023-07-26 07:10:36] WARNING[1308]: res_odbc.c:538 ast_odbc_print_errors: SQL Execute returned an error: 22021: ERROR: invalid byte sequence for encoding "UTF8": 0xd0 0x27;
Error while executing the query
[2023-07-26 07:10:36] WARNING[1308]: res_odbc.c:433 ast_odbc_prepare_and_execute: SQL Execute error -1!
[2023-07-26 07:10:36] WARNING[1308]: cdr_adaptive_odbc.c:765 odbc_log: cdr_adaptive_odbc: Insert failed on 'asteriskcdrdb:cdr'.  CDR failed: INSERT INTO cdr (calldate, clid, src, dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, accountcode, uniqueid, linkedid, recordingfile, cnum, cnam, outbound_cnum, peeraccount, sequence) VALUES ({ ts '2023-07-26 07:10:36' }, '"" <89204445555>', '89204445555', '89204445555', 'qlog-queuedial', 'PJSIP/101-00000035', 'SIP/Trunk-00000035', 'Dial', 'SIP/Trunk/89204445555,300,gM(queuedial-answer^1123456789.123^User', 5, 5, 'ANSWERED', 5, 'Lable', '1123456789.123', '1123456789.123', 'out-89204445555-101-20620689-203687-1123456789.123.wav', '101', 'User', '89204445555', 'Lable', 109)

Can you solve the problem?

That INSERT is in MySQL/MariaDB SQL format. How are you defining your ODBC settings?

Please post some of your ODBC configuration files (no passwords.)

As far as I can tell, the syntax is the same for both MySQL and Postgres… What in the insert is MySQL/MariaDB specific?

Re-read it and agree with you… issue could be the UTF-8 typo, or length of data in field is too long (for the .wav file name column in particular.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.