##结果集信息
可以通过设置选项--query-print=1
或者--enable-query-print
来启用打印语法树的功能,
同样的,它与其它enable开头的选项是互斥的,不能同时设置,开启之后,再连接goInception,执行返回的结果集所包括的列如下:
- ID:这个用来表示当前语句的一个序列值。
- STATEMENT:这个列用来存储当前被分析的SQL语句。
- ERRLEVEL:这个列用来存储当打印遇到问题时,错误的级别,与审核结果集中的ERRLEVEL意义相同。
- QUERY_TREE:这个列就是对当前语句的分析结果,格式为JSON字符串。
- ERRMSG:这个列与上面的ERRLEVEL对应,当出错时,这里存储分析过程中所有的错误信息,与审核结果集中的同名列意义相同。
###示例
SQL语句:
INSERT INTO t
(sno,
name)
SELECT sno,
name
FROM t alias_t
WHERE sno = (SELECT sno + 1
FROM my
WHERE name LIKE "%zhufeng%"
AND sno > '10010'
AND name = alias_t.name)
ORDER BY name
LIMIT 100, 10;
返回的结果对应的Json可视化的query_tree如下:
{
"text": "insert into t (sno,name)\n select sno, name from t alias_t\n where sno=(\n select sno+1 from my\n where\n name like \"%zhufeng%\" and\n sno > '10010' and\n name=alias_t.name\n )\n order by name\n limit 100, 10",
"IsReplace": false,
"IgnoreErr": false,
"Table": {
"text": "",
"TableRefs": {
"text": "",
"resultFields": null,
"Left": {
"text": "",
"Source": {
"text": "",
"resultFields": null,
"Schema": {
"O": "",
"L": ""
},
"Name": {
"O": "t",
"L": "t"
},
"DBInfo": null,
"TableInfo": null,
"IndexHints": null
},
"AsName": {
"O": "",
"L": ""
}
},
"Right": null,
"Tp": 0,
"On": null,
"Using": null,
"NaturalJoin": false,
"StraightJoin": false
}
},
"Columns": [
{
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "sno",
"L": "sno"
}
},
{
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "name",
"L": "name"
}
}
],
"Lists": null,
"Setlist": null,
"Priority": 0,
"OnDuplicate": null,
"Select": {
"text": "",
"resultFields": null,
"SQLCache": true,
"CalcFoundRows": false,
"StraightJoin": false,
"Priority": 0,
"Distinct": false,
"From": {
"text": "",
"TableRefs": {
"text": "",
"resultFields": null,
"Left": {
"text": "",
"Source": {
"text": "",
"resultFields": null,
"Schema": {
"O": "",
"L": ""
},
"Name": {
"O": "t",
"L": "t"
},
"DBInfo": null,
"TableInfo": null,
"IndexHints": null
},
"AsName": {
"O": "alias_t",
"L": "alias_t"
}
},
"Right": null,
"Tp": 0,
"On": null,
"Using": null,
"NaturalJoin": false,
"StraightJoin": false
}
},
"Where": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 40,
"Op": 7,
"L": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "sno",
"L": "sno"
}
},
"Refer": null
},
"R": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 32,
"Query": {
"text": "select sno+1 from my\n where\n name like \"%zhufeng%\" and\n sno > '10010' and\n name=alias_t.name\n ",
"resultFields": null,
"SQLCache": true,
"CalcFoundRows": false,
"StraightJoin": false,
"Priority": 0,
"Distinct": false,
"From": {
"text": "",
"TableRefs": {
"text": "",
"resultFields": null,
"Left": {
"text": "",
"Source": {
"text": "",
"resultFields": null,
"Schema": {
"O": "",
"L": ""
},
"Name": {
"O": "my",
"L": "my"
},
"DBInfo": null,
"TableInfo": null,
"IndexHints": null
},
"AsName": {
"O": "",
"L": ""
}
},
"Right": null,
"Tp": 0,
"On": null,
"Using": null,
"NaturalJoin": false,
"StraightJoin": false
}
},
"Where": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Op": 1,
"L": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Op": 1,
"L": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Expr": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "name",
"L": "name"
}
},
"Refer": null
},
"Pattern": {
"text": "",
"k": 5,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": "JXpodWZlbmcl",
"x": null,
"Type": {
"Tp": 253,
"Flag": 0,
"Flen": 9,
"Decimal": -1,
"Charset": "utf8",
"Collate": "utf8_bin",
"Elems": null
},
"flag": 0,
"projectionOffset": -1
},
"Not": false,
"Escape": 92,
"PatChars": null,
"PatTypes": null
},
"R": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Op": 10,
"L": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "sno",
"L": "sno"
}
},
"Refer": null
},
"R": {
"text": "",
"k": 5,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": "MTAwMTA=",
"x": null,
"Type": {
"Tp": 253,
"Flag": 0,
"Flen": 5,
"Decimal": -1,
"Charset": "utf8",
"Collate": "utf8_bin",
"Elems": null
},
"flag": 0,
"projectionOffset": -1
}
}
},
"R": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Op": 7,
"L": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "name",
"L": "name"
}
},
"Refer": null
},
"R": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "alias_t",
"L": "alias_t"
},
"Name": {
"O": "name",
"L": "name"
}
},
"Refer": null
}
}
},
"Fields": {
"text": "",
"Fields": [
{
"text": "sno+1",
"Offset": 108,
"WildCard": null,
"Expr": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Op": 11,
"L": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "sno",
"L": "sno"
}
},
"Refer": null
},
"R": {
"text": "",
"k": 1,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 1,
"b": null,
"x": null,
"Type": {
"Tp": 8,
"Flag": 128,
"Flen": 1,
"Decimal": 0,
"Charset": "binary",
"Collate": "binary",
"Elems": null
},
"flag": 0,
"projectionOffset": -1
}
},
"AsName": {
"O": "",
"L": ""
},
"Auxiliary": false
}
]
},
"GroupBy": null,
"Having": null,
"OrderBy": null,
"Limit": null,
"LockTp": 0,
"TableHints": null,
"IsAfterUnionDistinct": false,
"IsInBraces": false
},
"Evaluated": false,
"Correlated": false,
"MultiRows": false,
"Exists": false
}
},
"Fields": {
"text": "",
"Fields": [
{
"text": "sno",
"Offset": 40,
"WildCard": null,
"Expr": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "sno",
"L": "sno"
}
},
"Refer": null
},
"AsName": {
"O": "",
"L": ""
},
"Auxiliary": false
},
{
"text": "name",
"Offset": 45,
"WildCard": null,
"Expr": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "name",
"L": "name"
}
},
"Refer": null
},
"AsName": {
"O": "",
"L": ""
},
"Auxiliary": false
}
]
},
"GroupBy": null,
"Having": null,
"OrderBy": {
"text": "",
"Items": [
{
"text": "",
"Expr": {
"text": "",
"k": 0,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 0,
"b": null,
"x": null,
"Type": {
"Tp": 0,
"Flag": 0,
"Flen": 0,
"Decimal": 0,
"Charset": "",
"Collate": "",
"Elems": null
},
"flag": 8,
"Name": {
"text": "",
"Schema": {
"O": "",
"L": ""
},
"Table": {
"O": "",
"L": ""
},
"Name": {
"O": "name",
"L": "name"
}
},
"Refer": null
},
"Desc": false
}
],
"ForUnion": false
},
"Limit": {
"text": "",
"Count": {
"text": "",
"k": 2,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 10,
"b": null,
"x": null,
"Type": {
"Tp": 8,
"Flag": 160,
"Flen": 2,
"Decimal": 0,
"Charset": "binary",
"Collate": "binary",
"Elems": null
},
"flag": 0,
"projectionOffset": -1
},
"Offset": {
"text": "",
"k": 2,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 100,
"b": null,
"x": null,
"Type": {
"Tp": 8,
"Flag": 160,
"Flen": 3,
"Decimal": 0,
"Charset": "binary",
"Collate": "binary",
"Elems": null
},
"flag": 0,
"projectionOffset": -1
}
},
"LockTp": 0,
"TableHints": null,
"IsAfterUnionDistinct": false,
"IsInBraces": false
}
}