Skip to content

Commit 90dca59

Browse files
filter_checklist: fix compilation if FLB_SQLDB (sqlite3) is disabled
Signed-off-by: Thomas Devoogdt <[email protected]>
1 parent 3b31567 commit 90dca59

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

plugins/filter_checklist/checklist.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#include <fluent-bit/flb_mem.h>
2222
#include <fluent-bit/flb_time.h>
2323
#include <fluent-bit/flb_ra_key.h>
24-
#include <fluent-bit/flb_sqldb.h>
2524
#include <fluent-bit/flb_log_event_decoder.h>
2625
#include <fluent-bit/flb_log_event_encoder.h>
2726

2827
#include "checklist.h"
2928
#include <ctype.h>
3029

30+
#ifdef FLB_HAVE_SQLDB
3131
static int db_init(struct checklist *ctx)
3232
{
3333
int ret;
@@ -124,6 +124,7 @@ static int db_check(struct checklist *ctx, char *buf, size_t size)
124124

125125
return match;
126126
}
127+
#endif
127128

128129
static int load_file_patterns(struct checklist *ctx)
129130
{
@@ -175,9 +176,11 @@ static int load_file_patterns(struct checklist *ctx)
175176
if (ctx->mode == CHECK_EXACT_MATCH) {
176177
ret = flb_hash_table_add(ctx->ht, buf, len, "", 0);
177178
}
179+
#ifdef FLB_HAVE_SQLDB
178180
else if (ctx->mode == CHECK_PARTIAL_MATCH) {
179181
ret = db_insert(ctx, buf, len);
180182
}
183+
#endif
181184

182185
if (ret >= 0) {
183186
flb_plg_debug(ctx->ins, "file list: line=%i adds value='%s'", line, buf);
@@ -209,9 +212,11 @@ static int init_config(struct checklist *ctx)
209212
if (strcasecmp(tmp, "exact") == 0) {
210213
ctx->mode = CHECK_EXACT_MATCH;
211214
}
215+
#ifdef FLB_HAVE_SQLDB
212216
else if (strcasecmp(tmp, "partial") == 0) {
213217
ctx->mode = CHECK_PARTIAL_MATCH;
214218
}
219+
#endif
215220
}
216221

217222
if (ctx->mode == CHECK_EXACT_MATCH) {
@@ -223,12 +228,14 @@ static int init_config(struct checklist *ctx)
223228
return -1;
224229
}
225230
}
231+
#ifdef FLB_HAVE_SQLDB
226232
else if (ctx->mode == CHECK_PARTIAL_MATCH) {
227233
ret = db_init(ctx);
228234
if (ret < 0) {
229235
return -1;
230236
}
231237
}
238+
#endif
232239

233240
/* record accessor pattern / key name */
234241
ctx->ra_lookup_key = flb_ra_create(ctx->lookup_key, FLB_TRUE);
@@ -504,9 +511,11 @@ static int cb_checklist_filter(const void *data, size_t bytes,
504511
found = FLB_TRUE;
505512
}
506513
}
514+
#ifdef FLB_HAVE_SQLDB
507515
else if (ctx->mode == CHECK_PARTIAL_MATCH) {
508516
found = db_check(ctx, cmp_buf, cmp_size);
509517
}
518+
#endif
510519

511520
if (cmp_buf && cmp_buf != (char *) rval->o.via.str.ptr) {
512521
flb_free(cmp_buf);
@@ -592,11 +601,13 @@ static int cb_exit(void *data, struct flb_config *config)
592601
flb_hash_table_destroy(ctx->ht);
593602
}
594603

604+
#ifdef FLB_HAVE_SQLDB
595605
if (ctx->db) {
596606
sqlite3_finalize(ctx->stmt_insert);
597607
sqlite3_finalize(ctx->stmt_check);
598608
flb_sqldb_close(ctx->db);
599609
}
610+
#endif
600611

601612
flb_free(ctx);
602613
return 0;

plugins/filter_checklist/checklist.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@
2121
#define FLB_FILTER_CHECK_H
2222

2323
#include <fluent-bit/flb_info.h>
24-
#include <fluent-bit/flb_sqldb.h>
2524
#include <fluent-bit/flb_hash_table.h>
2625
#include <fluent-bit/flb_record_accessor.h>
2726

27+
#ifdef FLB_HAVE_SQLDB
28+
#include <fluent-bit/flb_sqldb.h>
29+
#endif
30+
2831
#define LINE_SIZE 2048
2932
#define CHECK_HASH_TABLE_SIZE 100000
3033
#define CHECK_EXACT_MATCH 0 /* exact string match */
34+
#ifdef FLB_HAVE_SQLDB
3135
#define CHECK_PARTIAL_MATCH 1 /* partial match */
36+
#endif
3237

3338
/* plugin context */
3439
struct checklist {
@@ -41,9 +46,11 @@ struct checklist {
4146
struct mk_list *records;
4247

4348
/* internal */
49+
#ifdef FLB_HAVE_SQLDB
4450
struct flb_sqldb *db;
4551
sqlite3_stmt *stmt_insert;
4652
sqlite3_stmt *stmt_check;
53+
#endif
4754
struct flb_hash_table *ht;
4855
struct flb_record_accessor *ra_lookup_key;
4956
struct flb_filter_instance *ins;

0 commit comments

Comments
 (0)