[asterisk-bugs] [JIRA] (ASTERISK-25032) cel_odbc sometimes inserts CEL with wrong eventtime

Etienne Lessard (JIRA) noreply at issues.asterisk.org
Thu Apr 30 07:23:32 CDT 2015


    [ https://issues.asterisk.org/jira/browse/ASTERISK-25032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=226062#comment-226062 ] 

Etienne Lessard commented on ASTERISK-25032:
--------------------------------------------

I've attached a patch.

In cel_odbc, when you are in the "case SQL_TIMESTAMP", it parse colptr (which is expected to be in a certain format) into its different component. At this stage, you don't know exactly the format of colptr; i.e. colptr could come from the "eventime" member of the CEL event or the "extra" member of the CEL event or it could come from a static value (doesn't make much sense I agree, but its possible). So you don't know if the time portion of colptr will have a fractional part, and if it does, what the precision will be (i.e. it could be .1 or .000001), so you can't parse it simply with %d. The patch parse the fractional part (if it exists) up to microsecond precision, and its this value that will be inserted in the DBMS.

I've done some tests with postgresql (9.1) and mysql (5.5).

> cel_odbc sometimes inserts CEL with wrong eventtime
> ---------------------------------------------------
>
>                 Key: ASTERISK-25032
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-25032
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: CEL/cel_odbc
>    Affects Versions: 11.17.1, 13.3.2
>            Reporter: Etienne Lessard
>            Severity: Minor
>
> Given I have a postgresql server with a "cel" table with a column "eventtime" of type timestamp
> Given I have cel_odbc configured to insert CEL in the "cel" table of my postgresql server
> When a CEL (struct ast_cel_event_record) is generated with eventtime.tv_usec between 1 and 99999, inclusively
> Then the record inserted in postgresql has the wrong eventtime
> For example, a CEL created at 1430309985.000009 will be inserted in postgresql with an eventtime of 1430309985.9.
> I took postgresql as an example, but the bug will show up for any DBMS with timestamp with sub-second precision.
> The bug does not show up if the column "eventtime" is of type varchar instead of timestamp.
> I wrote a small module to do some manual test: https://github.com/elessard1/asterisk-lab/blob/cel-odbc-wrong-eventtime/lab.c
> After compiling and loading the module, you can call "lab cel <us>" from the CLI, and it will generate a dummy CEL event with the given microsecond part.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list