Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter: Accept deep stack #1380

Merged
merged 5 commits into from
Aug 1, 2022
Merged

Conversation

HashidaTKS
Copy link
Contributor

@HashidaTKS HashidaTKS commented Aug 1, 2022

We get a syntax error when we specify deep stack filter at --filter.

Example:


table_create Logs TABLE_NO_KEY
[[0,0.0,0.0],true]
column_create Logs is_critical COLUMN_SCALAR Bool
[[0,0.0,0.0],true]
load --table Logs
[
{"is_critical": true}
]
[[0,0.0,0.0],1]
select Logs --filter '(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((is_critical)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'
[
  [
    [
      -63,
      0.0,
      0.0
    ],
    "Syntax error: <(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((is_critical|)"
  ]
]
#|e| Syntax error: <(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((is_critical|)|))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))>

The default max stack size is 100.

This patch changes to accept deep stack over 100.
The stack is dynamically sized using realloc().

This macro changes the stack size in grn_ecmascript.c, which is parser of "--filter".
If YYSTACKDEPTH=0, the stack is dynamically sized using realloc().
@kou
Copy link
Member

kou commented Aug 1, 2022

Does this work?

diff --git a/lib/expr.c b/lib/expr.c
index 0bb6ba178..2351cf1a0 100644
--- a/lib/expr.c
+++ b/lib/expr.c
@@ -4131,6 +4131,7 @@ section_weight_cb(grn_ctx *ctx, grn_hash *r, const void *rid, int sid, void *arg
 }
 #endif
 
+#define YYSTACKDEPTH 0
 #include "grn_ecmascript.h"
 #include "grn_ecmascript.c"

@HashidaTKS
Copy link
Contributor Author

Does this work?

diff --git a/lib/expr.c b/lib/expr.c
index 0bb6ba178..2351cf1a0 100644
--- a/lib/expr.c
+++ b/lib/expr.c
@@ -4131,6 +4131,7 @@ section_weight_cb(grn_ctx *ctx, grn_hash *r, const void *rid, int sid, void *arg
 }
 #endif
 
+#define YYSTACKDEPTH 0
 #include "grn_ecmascript.h"
 #include "grn_ecmascript.c"

Oh, I'll try this!

This macro changes the stack size in grn_ecmascript.c which is parser of "--filter".
 If YYSTACKDEPTH=0, the stack is dynamically sized using realloc().
@HashidaTKS
Copy link
Contributor Author

It worked!
I have changed to use this approach.

@kou kou merged commit cfbf593 into groonga:master Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants