Skip to content

Commit

Permalink
pass connection options to postgresql client
Browse files Browse the repository at this point in the history
Signed-off-by: Turkalp Burak Kayrancıoğlu <[email protected]>
  • Loading branch information
bkayranci committed Feb 12, 2023
1 parent d9d817d commit 335b384
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions plugins/out_pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ static int cb_pgsql_init(struct flb_output_instance *ins,
ctx->db_table = flb_sds_create(FLB_PGSQL_TABLE);
}

/* connection options */
ctx->conn_options = flb_output_get_property("connection_options", ins);

if (!ctx->db_table) {
flb_errno();
pgsql_conf_destroy(ctx);
Expand Down
3 changes: 3 additions & 0 deletions plugins/out_pgsql/pgsql.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ struct flb_pgsql_config {
/* instance reference */
struct flb_output_instance *ins;

/* connections */
const char *conn_options;

/* connections pool */
struct mk_list conn_queue;
struct mk_list _head;
Expand Down
5 changes: 4 additions & 1 deletion plugins/out_pgsql/pgsql_connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ void *pgsql_create_connection(struct flb_pgsql_config *ctx)
flb_errno();
return NULL;
}

flb_plg_debug(ctx->ins, "connection_options: %s", ctx->conn_options);
conn->conn = PQsetdbLogin(ctx->db_hostname,
ctx->db_port,
NULL, NULL,
ctx->conn_options,
NULL,
ctx->db_name,
ctx->db_user,
ctx->db_passwd);
Expand Down

0 comments on commit 335b384

Please sign in to comment.