Skip to content

Commit bdae18e

Browse files
authored
Merge pull request #6875 from bkayranci/master
out_pgsql: pass connection options to postgresql client This new option `connection_options` allows to pass the `pgoptions` argument to PQsetdbLogin() function that are passed to the PostgreSQL backend. When this option it's set, the backend will accept the options with the format of `-c option_name=value`.
2 parents c3696af + 563ea2d commit bdae18e

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

plugins/out_pgsql/pgsql.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ static int cb_pgsql_init(struct flb_output_instance *ins,
9292
ctx->db_table = flb_sds_create(FLB_PGSQL_TABLE);
9393
}
9494

95+
/* connection options */
96+
ctx->conn_options = flb_output_get_property("connection_options", ins);
97+
9598
if (!ctx->db_table) {
9699
flb_errno();
97100
pgsql_conf_destroy(ctx);

plugins/out_pgsql/pgsql.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ struct flb_pgsql_config {
6767
/* instance reference */
6868
struct flb_output_instance *ins;
6969

70+
/* connections options */
71+
const char *conn_options;
72+
7073
/* connections pool */
7174
struct mk_list conn_queue;
7275
struct mk_list _head;

plugins/out_pgsql/pgsql_connections.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ void *pgsql_create_connection(struct flb_pgsql_config *ctx)
5454
flb_errno();
5555
return NULL;
5656
}
57+
5758
conn->conn = PQsetdbLogin(ctx->db_hostname,
5859
ctx->db_port,
59-
NULL, NULL,
60+
ctx->conn_options,
61+
NULL,
6062
ctx->db_name,
6163
ctx->db_user,
6264
ctx->db_passwd);

0 commit comments

Comments
 (0)