table: fix shared query filtering#6166
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 11 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
wargio
left a comment
There was a problem hiding this comment.
split this into 2 PRs. one for windows console and one for the table query
I thought in this case, could be considered. Np, will split. |
i think you should fix first only the table, then we can fix the terminal |
ba9dfab to
5252255
Compare
| static const char *const addr_aliases[] = { | ||
| "vaddr", | ||
| "address", | ||
| "paddr", | ||
| NULL | ||
| }; | ||
| static const char *const length_aliases[] = { | ||
| "len", | ||
| NULL | ||
| }; | ||
| if (table_index_of_column(t, name, index)) { | ||
| return true; | ||
| } | ||
| // Keep stable query names working across tables with slightly different headers. | ||
| if (RZ_STR_EQ(name, "addr")) { | ||
| for (size_t i = 0; addr_aliases[i]; i++) { | ||
| if (table_index_of_column(t, addr_aliases[i], index)) { | ||
| return true; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
i think you should check the type. usually when you define a row you use xxssXsu etc.. to define if is a number or a string.
There was a problem hiding this comment.
yep, now table_column_is_numeric() treats NUMBER and BOOL cols as num comaptible, table_query_index_of_numeric_column() resolves header name first & rejects it unless the target col is num, & in table_query_index_of_column(), the addr and length alias fallback goes through the num only helper...
have used ex2 and 3 from book for test as well
wargio
left a comment
There was a problem hiding this comment.
it's a quite nice improvement.
Please test the book queries: https://book.rizin.re/src/tools/rz-bin/tables.html
ex 2 and 3 seem to be successfull (#6166 (comment)), however, for ex1, this is the quote from book: and this is the ex1 provided,
however, |
569f6a2 to
9325f01
Compare
Your checklist for this pull request
RZ_APIfunction and struct this PR changes.RZ_API).Detailed description
This PR fixes a table filtering issue that was reported while testing table query syntax on binaries. (as described in rizinorg/book#159, i used
curl-example-dbgfrom testbins for reproducibility and testing)The issue is the shared table query/filter engine behind commands like
izz,isand other table cmds. This caused cmds such as:to emit
rz_num_calcerrors on ordinary str contents, and cmds such as:to behave incorrectly when the query used common names like
addrorlengththat do not always exactly match the underlying table headers.The changes do three things:
They make num parsing lazy in
rz_table_query()/table_filter().Before this change, row values were eagerly sent to
rz_num_math()even for str-only operations such asstr,minlen, andmaxlen. That is what produced therz_num_calcerrors.After this change, num parsing only happens for operators that actually require num semantics.
They make string eq/ineq stay str based on str columns.
This avoids accidental numeric treatment of values such as
"16","010", and"0x10"when the column itself is txt.They add query time column resolution for stable aliases such as
addr -> vaddr/address/paddrandlength -> len, while preserving the existingcolsbehavior expected by older query chains.Tests were also added:
izzstring/minlen case and theisaddr-alias casenameafter filtering byaddr, so it doesn't depend on platform specific ordering of eq-addr rowsTest plan
Before:


After:


Closing issues
closes #5993