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
3131static 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
128129static 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 ;
0 commit comments