asterisk/cel
George Joseph 1a1c86239d cel_odbc: Fix timestamp processing for microseconds
When a column is of type timestamp, the fraction part of the event
field's seconds was frequently parsed incorrectly especially if
there were leading zeros.  For instance "2017-05-23 23:55:03.023"
would be parsed into an int as "23" then when the timestamp was
formatted again to be inserted into the database column it'd be
"2017-05-23 23:55:03.23" which is now 230 milliseconds instead of
23 milliseconds.  "03.000001" would be transformed to "03.1", etc.

* If the event field is 'eventtime' and the db column is timestamp,
  then existing processing has already correctly formatted the
  timestamp so now we simply use it rather than parsing it and
  re-printing it. This is the most common use case anyway.

* If the event field is other than 'eventtime' and the db column
  is timestamp, we now parse the seconds, including the fractional
  part into a double rather than 2 ints.  This preserves the
  magnitude and precision of the fractional part.  When we print
  it, we now print it as a "%09.6lf" which correctly represents the
  input.

To be honest, why we parse the string timestamp into components,
test the components, then print the components back into a string
timestamp is beyond me.  We should use parse it, test it, then if
it passes, use the original string representation in the database
call.  Maybe someone thought that some implementations wouldn't
take a partial timestamp string like "2017-05-06" and decided to
always produce a full timestamp string even if an abbreviated one
was supplied.  Anyway, I'm leaving it as it is.

ASTERISK-25032 #close
Reported-by: Etienne Lessard

Change-Id: Id407e6221f79a5c1120e1a70bc7e893bbcaf1938
2017-05-09 07:25:36 -05:00
..
cel_custom.c modules: change module LOAD_FAILUREs to LOAD_DECLINES 2017-04-12 15:57:21 -06:00
cel_manager.c Remove ASTERISK_REGISTER_FILE. 2016-10-27 09:53:55 -04:00
cel_odbc.c cel_odbc: Fix timestamp processing for microseconds 2017-05-09 07:25:36 -05:00
cel_pgsql.c cdr_pgsql: Fix buffer overflow calling libpq 2017-03-30 17:48:42 -05:00
cel_radius.c Add support for building RADIUS with radcli 2016-11-14 19:40:03 +02:00
cel_sqlite3_custom.c Remove ASTERISK_REGISTER_FILE. 2016-10-27 09:53:55 -04:00
cel_tds.c Remove ASTERISK_REGISTER_FILE. 2016-10-27 09:53:55 -04:00
Makefile Title update 2012-10-14 21:56:13 +00:00