summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-10-09 10:14:15 +0200
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:37 +0200
commitc5a9e0ec391941ae55c5a022961910ae57b4518a (patch)
treef97db86ef9f50c53ca1c3bba0edd3de2e2a613f7
parent02515010001b7b2d79d74c601b71b2c68a0c0770 (diff)
Correctly write empty columns
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
-rw-r--r--include/ulogd/plugin.h1
-rw-r--r--output/pgsql/ulogd_output_PGSQL.c11
2 files changed, 11 insertions, 1 deletions
diff --git a/include/ulogd/plugin.h b/include/ulogd/plugin.h
index 7c3ae6a..2ce77bc 100644
--- a/include/ulogd/plugin.h
+++ b/include/ulogd/plugin.h
@@ -39,6 +39,7 @@ enum ulogd_ktype {
ULOGD_RET_IP6ADDR,
ULOGD_RET_STRING,
ULOGD_RET_RAW,
+ __ULOGD_RET_MAX = ULOGD_RET_RAW,
};
/* key flags */
diff --git a/output/pgsql/ulogd_output_PGSQL.c b/output/pgsql/ulogd_output_PGSQL.c
index e4f3d10..3b9fd22 100644
--- a/output/pgsql/ulogd_output_PGSQL.c
+++ b/output/pgsql/ulogd_output_PGSQL.c
@@ -409,7 +409,16 @@ __pgsql_commit_row(struct ulogd_pluginstance *pi, struct db_row *row)
for (i = 0; i < di->num_cols; i++) {
const struct ulogd_value *val = &row->value[i];
- ulogd_value_to_ascii(val, priv->param_val[i], PARAM_LEN);
+ BUG_ON(row->value[i].type > __ULOGD_RET_MAX);
+ if (row->value[i].type != ULOGD_RET_NONE)
+ ulogd_value_to_ascii(val, priv->param_val[i], PARAM_LEN);
+ else {
+ /*
+ * this may not be correct with string type columns, but may be
+ * easier to solve when using the binary encoding.
+ */
+ strcpy(priv->param_val[i], "0");
+ }
}
priv->pgres = PQexecPrepared(priv->dbh, "insert",