Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
idoutils: fix logentry_type as int, not unsigned long
Browse files Browse the repository at this point in the history
refs #4953
  • Loading branch information
Michael Friedrich committed Oct 28, 2013
1 parent eca694a commit 32831fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Changelog
Expand Up @@ -18,6 +18,9 @@ UPGRADE NOTES
* core/idoutils: revert check_source attribute due to mod_gearman manipulating in-memory checkresult list #4958 - MF
** classic ui/idoutils schema: functionality is kept only for Icinga 2 support

* idoutils: fix pgsql update script #4953
* idoutils: fix logentry_type being integer, not unsigned long #4953


1.10.0 - 24/10/2013

Expand Down
22 changes: 11 additions & 11 deletions module/idoutils/src/dbhandlers.c
Expand Up @@ -1167,7 +1167,7 @@ int ido2db_handle_logentry(ido2db_idi *idi) {
char *es[1];
time_t etime = 0L;
char *ts[1];
unsigned long type = 0L;
int type = 0;
unsigned long object_id = 0L;
int result = IDO_OK;
int duplicate_record = IDO_FALSE;
Expand Down Expand Up @@ -1305,15 +1305,15 @@ int ido2db_handle_logentry(ido2db_idi *idi) {
if (object_id != 0) {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %lu, E'%s', '0', '0', %lu)",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %d, E'%s', '0', '0', %lu)",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0], object_id) == -1)
buf = NULL;
} else {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %lu, E'%s', '0', '0')",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %d, E'%s', '0', '0')",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0]) == -1)
Expand All @@ -1324,15 +1324,15 @@ int ido2db_handle_logentry(ido2db_idi *idi) {
if (object_id != 0) {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %lu, '%s', '0', '0', %lu)",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %d, '%s', '0', '0', %lu)",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0], object_id) == -1)
buf = NULL;
} else {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %lu, '%s', '0', '0')",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %d, '%s', '0', '0')",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0]) == -1)
Expand Down Expand Up @@ -1733,7 +1733,7 @@ int ido2db_handle_logdata(ido2db_idi *idi) {
int type, flags, attr;
struct timeval tstamp;
time_t etime = 0L;
unsigned long letype = 0L;
int letype = 0;
unsigned long object_id = 0L;
char *ts[2];
char *es[1];
Expand All @@ -1756,7 +1756,7 @@ int ido2db_handle_logdata(ido2db_idi *idi) {
&tstamp);

/* convert data */
result = ido2db_convert_string_to_unsignedlong(
result = ido2db_convert_string_to_int(
idi->buffered_input[IDO_DATA_LOGENTRYTYPE], &letype);
result = ido2db_convert_string_to_unsignedlong(
idi->buffered_input[IDO_DATA_LOGENTRYTIME],
Expand Down Expand Up @@ -1790,15 +1790,15 @@ int ido2db_handle_logdata(ido2db_idi *idi) {
if (object_id != 0) {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %lu, E'%s', '1', '1', %lu)",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %d, E'%s', '1', '1', %lu)",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0], object_id) == -1)
buf = NULL;
} else {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %lu, E'%s', '1', '1')",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %d, E'%s', '1', '1')",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0]) == -1)
Expand All @@ -1809,15 +1809,15 @@ int ido2db_handle_logdata(ido2db_idi *idi) {
if (object_id != 0) {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %lu, '%s', '1', '1', %lu)",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted, object_id) VALUES (%lu, %s, %s, '0', %d, '%s', '1', '1', %lu)",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0], object_id) == -1)
buf = NULL;
} else {
if (asprintf(
&buf,
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %lu, '%s', '1', '1')",
"INSERT INTO %s (instance_id, logentry_time, entry_time, entry_time_usec, logentry_type, logentry_data, realtime_data, inferred_data_extracted) VALUES (%lu, %s, %s, '0', %d, '%s', '1', '1')",
ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES],
idi->dbinfo.instance_id, ts[0], ts[0], type, (es[0] == NULL) ? ""
: es[0]) == -1)
Expand Down

0 comments on commit 32831fd

Please sign in to comment.