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

feature: 添加masking功能-语法树解析功能升级,返回select涉及的对象(库.表.列) #355

Merged
merged 3 commits into from
Jul 4, 2021

Conversation

hanchuanchuan
Copy link
Owner

@hanchuanchuan hanchuanchuan commented Jun 21, 2021

*** 语法树功能升级

使用方式:--masking替换--query-print

返回解析和原语法树查询功能一致(引用自文档语法树说明)

  1. ID:这个用来表示当前语句的一个序列值。
  2. STATEMENT:这个列用来存储当前被分析的SQL语句。
  3. ERRLEVEL:这个列用来存储当打印遇到问题时,错误的级别,与审核结果集中的ERRLEVEL意义相同。
  4. QUERY_TREE:这个列就是对当前语句的分析结果,格式为JSON字符串。
  5. ERRMSG:这个列与上面的ERRLEVEL对应,当出错时,这里存储分析过程中所有的错误信息,与审核结果集中的同名列意义相同。

其中,唯一有改动的QUERY_TREE返回格式如下:

select MOD(id,2)as col1,IFNULL(c1,id) from t1; -- 示例SQL
[
    {
        "index":0,
        "field":"id",
        "type":"int(11)",
        "table":"t1",
        "schema":"test_inc",
        "alias":"col1"
    },
    {
        "index":1,
        "field":"c1",
        "type":"int(11)",
        "table":"t1",
        "schema":"test_inc",
        "alias":"IFNULL(c1,id)"
    },
    {
        "index":1,
        "field":"id",
        "type":"int(11)",
        "table":"t1",
        "schema":"test_inc",
        "alias":"IFNULL(c1,id)"
    }
]

字段说明:

  • index: 列索引,标识为第几列,可能重复(如函数引用了多列时)
  • field: 原始列名
  • type: 列类型,扩展属性,以供自定义使用
  • table: 原始表名
  • schema: 数据库
  • alias: 列别名,该值可能不准确(如未定义列别名或列名重复时)

@codecov
Copy link

codecov bot commented Jun 21, 2021

Codecov Report

Merging #355 (116c1e4) into master (5223276) will decrease coverage by 0.2621%.
The diff coverage is 0.0000%.

@@               Coverage Diff                @@
##             master       #355        +/-   ##
================================================
- Coverage   57.4500%   57.1879%   -0.2622%     
================================================
  Files           375        376         +1     
  Lines         74402      74757       +355     
================================================
+ Hits          42744      42752         +8     
- Misses        27178      27527       +349     
+ Partials       4480       4478         -2     

@hanchuanchuan hanchuanchuan merged commit d975de9 into master Jul 4, 2021
@hanchuanchuan hanchuanchuan deleted the select-masking-function branch July 4, 2021 13:47
@Alex-wwei
Copy link

image
我更新最新版本1.2.5了,为啥没有这个select字段,返回的语法树信息和旧版本的一样呢

@hanchuanchuan
Copy link
Owner Author

更新了使用方式说明:将--masking替换--query-print

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.

2 participants