Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion plugins/processor_sql/parser/sql-parser.l
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ NOT return NOT;
IS return IS;
NULL return NUL;

-?[1-9][0-9]*|0 { yylval->integer = atoi(yytext); return INTEGER; }
"true" { yylval->boolean = true; return BOOLTYPE; };
"false" { yylval->boolean = false; return BOOLTYPE; };

-?[1-9][0-9]*|0 { yylval->integer = atol(yytext); return INTEGER; }
(-?[1-9][0-9]*|0)\.[0-9]+ { yylval->fval = atof(yytext); return FLOATING; }
\'([^']|'{2})*\' { yylval->string = remove_dup_qoutes(yytext + 1, yyleng - 2); return STRING; }
[_A-Za-z][A-Za-z0-9_.]* { yylval->string = flb_strdup(yytext); return IDENTIFIER; }
Expand All @@ -72,6 +75,13 @@ NULL return NUL;
")" |
";" { return yytext[0]; }

"!=" return NEQ;
"<>" return NEQ;
"<" return LT;
"<=" return LTE;
">" return GT;
">=" return GTE;

\' return QUOTE;
\n
[ \t]+ /* ignore whitespace */;
Expand Down
4 changes: 2 additions & 2 deletions plugins/processor_sql/parser/sql-parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,14 @@ select: SELECT keys FROM source where ';'
// {
// flb_free($1);
// }
value: INTEGER
value: INTEGER
{
$$ = sql_expression_condition_integer(query, $1);
}
|
FLOATING
{

$$ = sql_expression_condition_float(query, $1);
}
|
Expand Down Expand Up @@ -213,7 +214,6 @@ select: SELECT keys FROM source where ';'
|
record_func '=' value
{
printf("record_func '=' value\n");
$$ = sql_expression_comparison(query, $1, $3, SQL_EXP_EQ);
}
|
Expand Down
10 changes: 8 additions & 2 deletions plugins/processor_sql/parser/sql_expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct sql_expression *sql_expression_condition_float(struct sql_query *query,
}

val->type = SQL_EXP_FLOAT;
val->val.i64 = fval;
val->val.f64 = fval;
cfl_list_add(&val->_head, &query->cond_list);

return (struct sql_expression *) val;
Expand All @@ -148,6 +148,12 @@ struct sql_expression *sql_expression_condition_string(struct sql_query *query,

val->type = SQL_EXP_STRING;
val->val.string = cfl_sds_create(string);
if (!val->val.string) {
flb_errno();
flb_free(val);
return NULL;
}

cfl_list_add(&val->_head, &query->cond_list);

return (struct sql_expression *) val;
Expand Down Expand Up @@ -208,4 +214,4 @@ struct sql_expression *sql_expression_comparison(struct sql_query *query,
cfl_list_add(&expression->_head, &query->cond_list);

return (struct sql_expression *) expression;
}
}
10 changes: 10 additions & 0 deletions plugins/processor_sql/sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,16 @@ static int sql_key_to_value(char *name, struct flb_mp_chunk_record *record, stru
val->type = SQL_EXP_INT;
val->val.i64 = kvpair->val->data.as_int64;
}
else if (var->type == CFL_VARIANT_UINT) {
/*
* Note on uint64 handling: our parsing rules in sql-parser.l handles the strings
* that represents integers through an atol() conversion. If we get a case of a
* long unsigned value, we can adjust it here by extending the sql_val union.
*
*/
val->type = SQL_EXP_INT;
val->val.i64 = kvpair->val->data.as_uint64;
}
else if (var->type == CFL_VARIANT_DOUBLE) {
val->type = SQL_EXP_FLOAT;
val->val.f64 = kvpair->val->data.as_double;
Expand Down
211 changes: 0 additions & 211 deletions plugins/processor_sql/sql_expression.c

This file was deleted.

56 changes: 0 additions & 56 deletions plugins/processor_sql/sql_expression.h

This file was deleted.