Go Antlr4 Plsql Sql Parser Demo
文章目录
准备
一. antlr/grammars-v4 下载plsql
https://github.com/antlr/grammars-v4/tree/master/sql/plsql
下载2个.g4
的文件
二. 下载antlr-4.10.1-complete.jar
注意运行此jar
包需要jdk11
。
截至2023-01-20,antlr-4.11.0-complete.jar及以上版本生成出的parser本人未能修改并成功跑通,多次降低版本至4.10.1才勉强改动后跑起来了,如有纰漏请指正。
开始
官方的go-target.md可供参考,本人步骤如下:
一. 新建工程目录及初始化
make dir go_antlr4_plsql_parser
cd go_antlr4_plsql_parser
go mod init go_antlr4_plsql_parser
go get github.com/antlr/antlr4/runtime/Go/antlr
二. 目录中加入下载最新的.g4文件及antlr-4.10.1-complete.jar
.
├── PlSqlLexer.g4
├── PlSqlParser.g4
├── antlr-4.10.1-complete.jar
└── go.mod
三. 生成go parser
# 自行替换java路径
D:\java\jdk-11.0.13\bin\java.exe -jar .\antlr-4.10.1-complete.jar -Dlanguage=Go -o parser .\PlSqlLexer.g4 -visitor
D:\java\jdk-11.0.13\bin\java.exe -jar .\antlr-4.10.1-complete.jar -Dlanguage=Go -o parser .\PlSqlParser.g4 -visitor
生成成功后文件结构如下:
.
├── PlSqlLexer.g4
├── PlSqlParser.g4
├── antlr-4.10.1-complete.jar
├── go.mod
└── parser
├── PlSqlLexer.interp
├── PlSqlLexer.tokens
├── PlSqlParser.interp
├── PlSqlParser.tokens
├── plsql_lexer.go
├── plsql_parser.go
├── plsqlparser_base_listener.go
├── plsqlparser_base_visitor.go
├── plsqlparser_listener.go
└── plsqlparser_visitor.go
四. 调整goland 4.19M file size limit for inspection问题
由于生成的plsql_parser.go
比较大,goland里会提示不进行检查,这不利于后续的调试,故需修改默认限制,
help -> Edit Custom Properties
,增加两行:
idea.max.intellisense.filesize=99999999
idea.max.content.load.filesize=99999999
保存重启goland。
五. 实现PlSqlLexerBase和PlSqlParserBase
第三步生成后的parser模块还不能使用,goland打开plsql_lexer.go
、plsql_parser.go
一片红。
实现PlSqlLexerBase
parser目录下新建plsql_base_lexer.go
package parser
import "github.com/antlr/antlr4/runtime/Go/antlr"
// PlSqlBaseLexer state
type PlSqlLexerBase struct {
*antlr.BaseLexer
lastToken antlr.Token
}
// NextToken from the character stream.
func (p *PlSqlLexerBase) NextToken() antlr.Token {
next := p.BaseLexer.NextToken() // Get next token
if next.GetChannel() == antlr.TokenDefaultChannel {
// Keep track of the last token on default channel
p.lastToken = next
}
return next
}
// IsRegexPossible returns true if the lexer can match a
// regex literal.
func (p *PlSqlLexerBase) IsNewlineAtPos(pos int) bool {
if p.lastToken == nil {
return true
}
la := p.GetInputStream().LA(pos)
return la == -1 || la == '\n'
}
实现PlSqlParserBase
parser目录下新建plsql_base_parser.go
package parser
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
)
// PlSqlBaseParser implementation.
type PlSqlParserBase struct {
*antlr.BaseParser
_isVersion12 bool
_isVersion10 bool
}
func (p *PlSqlParserBase) isVersion12() bool {
return p._isVersion12
}
func (p *PlSqlParserBase) setVersion12(value bool) {
p._isVersion12 = value
}
func (p *PlSqlParserBase) isVersion10() bool {
return p._isVersion10
}
func (p *PlSqlParserBase) setVersion10(value bool) {
p._isVersion10 = value
}
此时文件结构如下:
.
├── PlSqlLexer.g4
├── PlSqlParser.g4
├── antlr-4.10.1-complete.jar
├── go.mod
├── go.sum
└── parser
├── PlSqlLexer.interp
├── PlSqlLexer.tokens
├── PlSqlParser.interp
├── PlSqlParser.tokens
├── plsql_base_lexer.go
├── plsql_base_parser.go
├── plsql_lexer.go
├── plsql_parser.go
├── plsqlparser_base_listener.go
├── plsqlparser_base_visitor.go
├── plsqlparser_listener.go
└── plsqlparser_visitor.go
六. 替换plsql_lexer.go
、plsql_parser.go
中的self.
由于go语言没有self
的语法,所以需要分别在这两个文件中批量搜索替换self.
为p.
。plsql_lexer.go
中有3处要替换,plsql_parser.go
中有30处要替换,替换完成后parser模块就没有飘红错误了。
Demo
工程目录新建main.go
package main
import (
//因工程包名为go_antlr4_plsql_parser,如不同自行替换
"go_antlr4_plsql_parser/parser"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
)
type TreeShapeListener struct {
*parser.BasePlSqlParserListener
}
func NewTreeShapeListener() *TreeShapeListener {
return new(TreeShapeListener)
}
func main() {
var sql = "SELECT t.l_fundid AS cpbh, t.vc_code AS cpdm2, ' ' AS dzdm, t.vc_fullname AS cpmc\n\t, substr(t.vc_name, 1, 25) AS cpjc\n\t, t.vc_glr AS glrmc, ' ' AS glrdm, pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE',t.l_class) AS cplx\n\t, ' ' AS cplb, '1' AS yzfs, ' ' AS STZR\n\t, decode(t.l_jjtzlx, 4, '1', '0') AS SFZSJJ\n\t, decode(t.l_class, 13, '1', 14, '1', 15, '1', 0) AS SFETFJJ\n\t, ' ' AS SFLOFJJ\n\t, decode(t.l_class, 9, '1', 15, '1', '0') AS SFQDII\n\t, ' ' AS sfdqlcjj, ' ' AS SFJJZJJ, ' ' AS SFGLRZGLRCP, ' ' AS SFZZCDY, ' ' AS glrzglrcpdm2\n\t, ' ' AS SFCDZH, ' ' AS ZDCPDM, t.d_creat AS CLRQ2, ' ' AS BARQ, t.d_dqrq AS DQRQ3\n\t, t.d_dqrq AS QSJSRQ, 0.0 AS TGFL2, 0 AS GZWCTS2, '系统' AS data_source, ' ' AS czy\n\t, sysdate AS czsj\n\t, CASE \n\t\tWHEN pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) <> '3' THEN '1'\n\t\tWHEN pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) = '3'\n\t\t\tAND z.jgmc IS NOT NULL\n\t\tTHEN '1'\n\t\tELSE '0'\n\tEND AS isenabled, 0 AS qzms\nFROM ods_ftsp_fa26_tfundinfo t\n\tLEFT JOIN urp_ftsp_hd_zqgssmjjzgs z ON t.vc_glr = z.jgmc\nWHERE NOT EXISTS (\n\t\tSELECT 1\n\t\tFROM URP_FTSP_CP_CPJBXX_INFO b\n\t\tWHERE t.l_fundid = b.cpbh\n\t)\n\tAND t.xx = 1"
input := antlr.NewInputStream(sql)
lexer := parser.NewPlSqlLexer(input)
stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
p := parser.NewPlSqlParser(stream)
p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))
tree := p.Sql_script()
fmt.Println(tree.ToStringTree(p.RuleNames, p))
}
运行成功控制台输出如下:
line 1:18 reportAttemptingFullContext d=1527 (atom), input='t.l_fundid AS'
line 1:18 reportAttemptingFullContext d=1677 (variable_name), input='.l_fundid AS'
line 1:9 reportContextSensitivity d=1677 (variable_name), input='.l_fundid'
line 1:25 reportAttemptingFullContext d=1318 (select_list_elements), input='AS cpbh,'
line 1:18 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 1:25 reportAttemptingFullContext d=1652 (column_alias), input='AS cpbh,'
line 1:21 reportContextSensitivity d=1652 (column_alias), input='AS cpbh'
line 1:25 reportAttemptingFullContext d=1651 (column_alias), input='cpbh,'
line 1:37 reportAttemptingFullContext d=1527 (atom), input='t.vc_code AS'
line 1:37 reportAttemptingFullContext d=1677 (variable_name), input='.vc_code AS'
line 1:29 reportContextSensitivity d=1677 (variable_name), input='.vc_code'
line 1:45 reportAttemptingFullContext d=1318 (select_list_elements), input='AS cpdm2,'
line 1:37 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 1:45 reportAttemptingFullContext d=1652 (column_alias), input='AS cpdm2,'
line 1:40 reportContextSensitivity d=1652 (column_alias), input='AS cpdm2'
line 1:45 reportAttemptingFullContext d=1651 (column_alias), input='cpdm2,'
line 1:58 reportAttemptingFullContext d=1318 (select_list_elements), input='AS dzdm,'
line 1:51 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 1:58 reportAttemptingFullContext d=1652 (column_alias), input='AS dzdm,'
line 1:54 reportContextSensitivity d=1652 (column_alias), input='AS dzdm'
line 1:58 reportAttemptingFullContext d=1651 (column_alias), input='dzdm,'
line 1:74 reportAttemptingFullContext d=1527 (atom), input='t.vc_fullname AS'
line 1:74 reportAttemptingFullContext d=1677 (variable_name), input='.vc_fullname AS'
line 1:62 reportContextSensitivity d=1677 (variable_name), input='.vc_fullname'
line 2:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS cpmc
,'
line 1:74 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 2:1 reportAttemptingFullContext d=1652 (column_alias), input='AS cpmc
,'
line 1:77 reportContextSensitivity d=1652 (column_alias), input='AS cpmc'
line 2:1 reportAttemptingFullContext d=1651 (column_alias), input='cpmc
,'
line 2:28 reportAttemptingFullContext d=1511 (unary_expression), input='substr(t.vc_name, 1, 25) AS'
line 2:19 reportAttemptingFullContext d=1527 (atom), input='t.vc_name,'
line 2:26 reportAttemptingFullContext d=1677 (variable_name), input='.vc_name, 1, 25)'
line 2:11 reportContextSensitivity d=1677 (variable_name), input='.'
line 3:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS cpjc
,'
line 2:28 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 3:1 reportAttemptingFullContext d=1652 (column_alias), input='AS cpjc
,'
line 2:31 reportContextSensitivity d=1652 (column_alias), input='AS cpjc'
line 3:1 reportAttemptingFullContext d=1651 (column_alias), input='cpjc
,'
line 3:12 reportAttemptingFullContext d=1527 (atom), input='t.vc_glr AS'
line 3:12 reportAttemptingFullContext d=1677 (variable_name), input='.vc_glr AS'
line 3:5 reportContextSensitivity d=1677 (variable_name), input='.vc_glr'
line 3:20 reportAttemptingFullContext d=1318 (select_list_elements), input='AS glrmc,'
line 3:12 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 3:20 reportAttemptingFullContext d=1652 (column_alias), input='AS glrmc,'
line 3:15 reportContextSensitivity d=1652 (column_alias), input='AS glrmc'
line 3:20 reportAttemptingFullContext d=1651 (column_alias), input='glrmc,'
line 3:34 reportAttemptingFullContext d=1318 (select_list_elements), input='AS glrdm,'
line 3:26 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 3:34 reportAttemptingFullContext d=1652 (column_alias), input='AS glrdm,'
line 3:29 reportContextSensitivity d=1652 (column_alias), input='AS glrdm'
line 3:34 reportAttemptingFullContext d=1651 (column_alias), input='glrdm,'
line 3:102 reportAttemptingFullContext d=1740 (general_element_part), input='.f_get_dict_code('DK_PRODTYPE_CODE',t.l_class) AS'
line 3:100 reportAttemptingFullContext d=1527 (atom), input='t.l_class)'
line 3:102 reportAttemptingFullContext d=1677 (variable_name), input='.l_class) AS'
line 3:92 reportContextSensitivity d=1677 (variable_name), input='.'
line 4:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS cplx
,'
line 3:102 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 4:1 reportAttemptingFullContext d=1652 (column_alias), input='AS cplx
,'
line 3:105 reportContextSensitivity d=1652 (column_alias), input='AS cplx'
line 4:1 reportAttemptingFullContext d=1651 (column_alias), input='cplx
,'
line 4:14 reportAttemptingFullContext d=1318 (select_list_elements), input='AS cplb,'
line 4:7 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 4:14 reportAttemptingFullContext d=1652 (column_alias), input='AS cplb,'
line 4:10 reportContextSensitivity d=1652 (column_alias), input='AS cplb'
line 4:14 reportAttemptingFullContext d=1651 (column_alias), input='cplb,'
line 4:27 reportAttemptingFullContext d=1318 (select_list_elements), input='AS yzfs,'
line 4:20 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 4:27 reportAttemptingFullContext d=1652 (column_alias), input='AS yzfs,'
line 4:23 reportContextSensitivity d=1652 (column_alias), input='AS yzfs'
line 4:27 reportAttemptingFullContext d=1651 (column_alias), input='yzfs,'
line 5:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS STZR
,'
line 4:33 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 5:1 reportAttemptingFullContext d=1652 (column_alias), input='AS STZR
,'
line 4:36 reportContextSensitivity d=1652 (column_alias), input='AS STZR'
line 5:1 reportAttemptingFullContext d=1651 (column_alias), input='STZR
,'
line 5:20 reportAttemptingFullContext d=1527 (atom), input='t.l_jjtzlx,'
line 5:33 reportAttemptingFullContext d=1677 (variable_name), input='.l_jjtzlx, 4, '1', '0')'
line 5:11 reportContextSensitivity d=1677 (variable_name), input='.'
line 5:22 reportAttemptingFullContext d=1468 (expressions), input=', 4'
line 5:20 reportContextSensitivity d=1468 (expressions), input=','
line 5:28 reportAttemptingFullContext d=1468 (expressions), input=', '1','
line 5:23 reportContextSensitivity d=1468 (expressions), input=','
line 5:33 reportAttemptingFullContext d=1468 (expressions), input=', '0')'
line 5:28 reportContextSensitivity d=1468 (expressions), input=','
line 6:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFZSJJ
,'
line 5:35 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 6:1 reportAttemptingFullContext d=1652 (column_alias), input='AS SFZSJJ
,'
line 5:38 reportContextSensitivity d=1652 (column_alias), input='AS SFZSJJ'
line 6:1 reportAttemptingFullContext d=1651 (column_alias), input='SFZSJJ
,'
line 6:19 reportAttemptingFullContext d=1527 (atom), input='t.l_class,'
line 6:49 reportAttemptingFullContext d=1677 (variable_name), input='.l_class, 13, '1', 14, '1', 15, '1', 0)'
line 6:11 reportContextSensitivity d=1677 (variable_name), input='.'
line 6:21 reportAttemptingFullContext d=1468 (expressions), input=', 13'
line 6:19 reportContextSensitivity d=1468 (expressions), input=','
line 6:28 reportAttemptingFullContext d=1468 (expressions), input=', '1','
line 6:23 reportContextSensitivity d=1468 (expressions), input=','
line 6:30 reportAttemptingFullContext d=1468 (expressions), input=', 14'
line 6:28 reportContextSensitivity d=1468 (expressions), input=','
line 6:37 reportAttemptingFullContext d=1468 (expressions), input=', '1','
line 6:32 reportContextSensitivity d=1468 (expressions), input=','
line 6:39 reportAttemptingFullContext d=1468 (expressions), input=', 15'
line 6:37 reportContextSensitivity d=1468 (expressions), input=','
line 6:46 reportAttemptingFullContext d=1468 (expressions), input=', '1','
line 6:41 reportContextSensitivity d=1468 (expressions), input=','
line 6:48 reportAttemptingFullContext d=1468 (expressions), input=', 0'
line 6:46 reportContextSensitivity d=1468 (expressions), input=','
line 7:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFETFJJ
,'
line 6:51 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 7:1 reportAttemptingFullContext d=1652 (column_alias), input='AS SFETFJJ
,'
line 6:54 reportContextSensitivity d=1652 (column_alias), input='AS SFETFJJ'
line 7:1 reportAttemptingFullContext d=1651 (column_alias), input='SFETFJJ
,'
line 8:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFLOFJJ
,'
line 7:7 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 8:1 reportAttemptingFullContext d=1652 (column_alias), input='AS SFLOFJJ
,'
line 7:10 reportContextSensitivity d=1652 (column_alias), input='AS SFLOFJJ'
line 8:1 reportAttemptingFullContext d=1651 (column_alias), input='SFLOFJJ
,'
line 8:19 reportAttemptingFullContext d=1527 (atom), input='t.l_class,'
line 8:41 reportAttemptingFullContext d=1677 (variable_name), input='.l_class, 9, '1', 15, '1', '0')'
line 8:11 reportContextSensitivity d=1677 (variable_name), input='.'
line 8:21 reportAttemptingFullContext d=1468 (expressions), input=', 9'
line 8:19 reportContextSensitivity d=1468 (expressions), input=','
line 8:27 reportAttemptingFullContext d=1468 (expressions), input=', '1','
line 8:22 reportContextSensitivity d=1468 (expressions), input=','
line 8:29 reportAttemptingFullContext d=1468 (expressions), input=', 15'
line 8:27 reportContextSensitivity d=1468 (expressions), input=','
line 8:36 reportAttemptingFullContext d=1468 (expressions), input=', '1','
line 8:31 reportContextSensitivity d=1468 (expressions), input=','
line 8:41 reportAttemptingFullContext d=1468 (expressions), input=', '0')'
line 8:36 reportContextSensitivity d=1468 (expressions), input=','
line 9:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFQDII
,'
line 8:43 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 9:1 reportAttemptingFullContext d=1652 (column_alias), input='AS SFQDII
,'
line 8:46 reportContextSensitivity d=1652 (column_alias), input='AS SFQDII'
line 9:1 reportAttemptingFullContext d=1651 (column_alias), input='SFQDII
,'
line 9:18 reportAttemptingFullContext d=1318 (select_list_elements), input='AS sfdqlcjj,'
line 9:7 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 9:18 reportAttemptingFullContext d=1652 (column_alias), input='AS sfdqlcjj,'
line 9:10 reportContextSensitivity d=1652 (column_alias), input='AS sfdqlcjj'
line 9:18 reportAttemptingFullContext d=1651 (column_alias), input='sfdqlcjj,'
line 9:34 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFJJZJJ,'
line 9:24 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 9:34 reportAttemptingFullContext d=1652 (column_alias), input='AS SFJJZJJ,'
line 9:27 reportContextSensitivity d=1652 (column_alias), input='AS SFJJZJJ'
line 9:34 reportAttemptingFullContext d=1651 (column_alias), input='SFJJZJJ,'
line 9:54 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFGLRZGLRCP,'
line 9:40 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 9:54 reportAttemptingFullContext d=1652 (column_alias), input='AS SFGLRZGLRCP,'
line 9:43 reportContextSensitivity d=1652 (column_alias), input='AS SFGLRZGLRCP'
line 9:54 reportAttemptingFullContext d=1651 (column_alias), input='SFGLRZGLRCP,'
line 9:70 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFZZCDY,'
line 9:60 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 9:70 reportAttemptingFullContext d=1652 (column_alias), input='AS SFZZCDY,'
line 9:63 reportContextSensitivity d=1652 (column_alias), input='AS SFZZCDY'
line 9:70 reportAttemptingFullContext d=1651 (column_alias), input='SFZZCDY,'
line 10:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS glrzglrcpdm2
,'
line 9:76 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 10:1 reportAttemptingFullContext d=1652 (column_alias), input='AS glrzglrcpdm2
,'
line 9:79 reportContextSensitivity d=1652 (column_alias), input='AS glrzglrcpdm2'
line 10:1 reportAttemptingFullContext d=1651 (column_alias), input='glrzglrcpdm2
,'
line 10:16 reportAttemptingFullContext d=1318 (select_list_elements), input='AS SFCDZH,'
line 10:7 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 10:16 reportAttemptingFullContext d=1652 (column_alias), input='AS SFCDZH,'
line 10:10 reportContextSensitivity d=1652 (column_alias), input='AS SFCDZH'
line 10:16 reportAttemptingFullContext d=1651 (column_alias), input='SFCDZH,'
line 10:31 reportAttemptingFullContext d=1318 (select_list_elements), input='AS ZDCPDM,'
line 10:22 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 10:31 reportAttemptingFullContext d=1652 (column_alias), input='AS ZDCPDM,'
line 10:25 reportContextSensitivity d=1652 (column_alias), input='AS ZDCPDM'
line 10:31 reportAttemptingFullContext d=1651 (column_alias), input='ZDCPDM,'
line 10:43 reportAttemptingFullContext d=1527 (atom), input='t.d_creat AS'
line 10:43 reportAttemptingFullContext d=1677 (variable_name), input='.d_creat AS'
line 10:35 reportContextSensitivity d=1677 (variable_name), input='.d_creat'
line 10:51 reportAttemptingFullContext d=1318 (select_list_elements), input='AS CLRQ2,'
line 10:43 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 10:51 reportAttemptingFullContext d=1652 (column_alias), input='AS CLRQ2,'
line 10:46 reportContextSensitivity d=1652 (column_alias), input='AS CLRQ2'
line 10:51 reportAttemptingFullContext d=1651 (column_alias), input='CLRQ2,'
line 10:64 reportAttemptingFullContext d=1318 (select_list_elements), input='AS BARQ,'
line 10:57 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 10:64 reportAttemptingFullContext d=1652 (column_alias), input='AS BARQ,'
line 10:60 reportContextSensitivity d=1652 (column_alias), input='AS BARQ'
line 10:64 reportAttemptingFullContext d=1651 (column_alias), input='BARQ,'
line 10:75 reportAttemptingFullContext d=1527 (atom), input='t.d_dqrq AS'
line 10:75 reportAttemptingFullContext d=1677 (variable_name), input='.d_dqrq AS'
line 10:68 reportContextSensitivity d=1677 (variable_name), input='.d_dqrq'
line 11:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS DQRQ3
,'
line 10:75 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 11:1 reportAttemptingFullContext d=1652 (column_alias), input='AS DQRQ3
,'
line 10:78 reportContextSensitivity d=1652 (column_alias), input='AS DQRQ3'
line 11:1 reportAttemptingFullContext d=1651 (column_alias), input='DQRQ3
,'
line 11:12 reportAttemptingFullContext d=1527 (atom), input='t.d_dqrq AS'
line 11:12 reportAttemptingFullContext d=1677 (variable_name), input='.d_dqrq AS'
line 11:5 reportContextSensitivity d=1677 (variable_name), input='.d_dqrq'
line 11:21 reportAttemptingFullContext d=1318 (select_list_elements), input='AS QSJSRQ,'
line 11:12 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 11:21 reportAttemptingFullContext d=1652 (column_alias), input='AS QSJSRQ,'
line 11:15 reportContextSensitivity d=1652 (column_alias), input='AS QSJSRQ'
line 11:21 reportAttemptingFullContext d=1651 (column_alias), input='QSJSRQ,'
line 11:35 reportAttemptingFullContext d=1318 (select_list_elements), input='AS TGFL2,'
line 11:27 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 11:35 reportAttemptingFullContext d=1652 (column_alias), input='AS TGFL2,'
line 11:30 reportContextSensitivity d=1652 (column_alias), input='AS TGFL2'
line 11:35 reportAttemptingFullContext d=1651 (column_alias), input='TGFL2,'
line 11:49 reportAttemptingFullContext d=1318 (select_list_elements), input='AS GZWCTS2,'
line 11:39 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 11:49 reportAttemptingFullContext d=1652 (column_alias), input='AS GZWCTS2,'
line 11:42 reportContextSensitivity d=1652 (column_alias), input='AS GZWCTS2'
line 11:49 reportAttemptingFullContext d=1651 (column_alias), input='GZWCTS2,'
line 11:70 reportAttemptingFullContext d=1318 (select_list_elements), input='AS data_source,'
line 11:56 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 11:70 reportAttemptingFullContext d=1652 (column_alias), input='AS data_source,'
line 11:59 reportContextSensitivity d=1652 (column_alias), input='AS data_source'
line 11:70 reportAttemptingFullContext d=1651 (column_alias), input='data_source,'
line 12:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS czy
,'
line 11:76 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 12:1 reportAttemptingFullContext d=1652 (column_alias), input='AS czy
,'
line 11:79 reportContextSensitivity d=1652 (column_alias), input='AS czy'
line 12:1 reportAttemptingFullContext d=1651 (column_alias), input='czy
,'
line 12:11 reportAttemptingFullContext d=1527 (atom), input='sysdate AS'
line 13:1 reportAttemptingFullContext d=1318 (select_list_elements), input='AS czsj
,'
line 12:11 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 13:1 reportAttemptingFullContext d=1652 (column_alias), input='AS czsj
,'
line 12:14 reportContextSensitivity d=1652 (column_alias), input='AS czsj'
line 13:1 reportAttemptingFullContext d=1651 (column_alias), input='czsj
,'
line 19:5 reportAttemptingFullContext d=1511 (unary_expression), input='CASE
WHEN pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) <> '3' THEN '1'
WHEN pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) = '3'
AND z.jgmc IS NOT NULL
THEN '1'
ELSE '0'
END AS'
line 14:7 reportContextSensitivity d=1511 (unary_expression), input='CASE
WHEN pkg_urp_ftsp_common'
line 14:74 reportAttemptingFullContext d=1740 (general_element_part), input='.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) <>'
line 14:72 reportAttemptingFullContext d=1527 (atom), input='t.l_class)'
line 14:74 reportAttemptingFullContext d=1677 (variable_name), input='.l_class) <>'
line 14:64 reportContextSensitivity d=1677 (variable_name), input='.'
line 14:77 reportAttemptingFullContext d=1481 (relational_expression), input='<> '3''
line 14:74 reportContextSensitivity d=1481 (relational_expression), input='<>'
line 15:74 reportAttemptingFullContext d=1740 (general_element_part), input='.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) ='
line 15:72 reportAttemptingFullContext d=1527 (atom), input='t.l_class)'
line 15:74 reportAttemptingFullContext d=1677 (variable_name), input='.l_class) ='
line 15:64 reportContextSensitivity d=1677 (variable_name), input='.'
line 15:76 reportAttemptingFullContext d=1481 (relational_expression), input='= '3''
line 15:74 reportContextSensitivity d=1481 (relational_expression), input='='
line 16:3 reportAttemptingFullContext d=1471 (logical_expression), input='AND'
line 16:3 reportContextSensitivity d=1471 (logical_expression), input='AND'
line 16:14 reportAttemptingFullContext d=1527 (atom), input='z.jgmc IS'
line 16:14 reportAttemptingFullContext d=1677 (variable_name), input='.jgmc IS'
line 16:8 reportContextSensitivity d=1677 (variable_name), input='.'
line 16:14 reportAttemptingFullContext d=1474 (unary_logical_expression), input='IS'
line 16:14 reportContextSensitivity d=1474 (unary_logical_expression), input='IS'
line 19:17 reportAttemptingFullContext d=1318 (select_list_elements), input='AS isenabled,'
line 19:5 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 19:17 reportAttemptingFullContext d=1652 (column_alias), input='AS isenabled,'
line 19:8 reportContextSensitivity d=1652 (column_alias), input='AS isenabled'
line 19:17 reportAttemptingFullContext d=1651 (column_alias), input='isenabled,'
line 20:0 reportAttemptingFullContext d=1318 (select_list_elements), input='AS qzms
FROM'
line 19:21 reportContextSensitivity d=1318 (select_list_elements), input='AS'
line 20:0 reportAttemptingFullContext d=1652 (column_alias), input='AS qzms
FROM'
line 19:24 reportContextSensitivity d=1652 (column_alias), input='AS qzms'
line 20:0 reportAttemptingFullContext d=1651 (column_alias), input='qzms
FROM'
line 21:1 reportAttemptingFullContext d=1324 (table_ref_aux), input='t
LEFT'
line 21:1 reportAttemptingFullContext d=1653 (table_alias), input='t
LEFT'
line 21:35 reportAttemptingFullContext d=1321 (table_ref), input='LEFT JOIN urp_ftsp_hd_zqgssmjjzgs z'
line 21:37 reportAttemptingFullContext d=1324 (table_ref_aux), input='z ON'
line 21:37 reportContextSensitivity d=1324 (table_ref_aux), input='z ON'
line 21:37 reportAttemptingFullContext d=1653 (table_alias), input='z ON'
line 21:40 reportAttemptingFullContext d=1334 (join_clause), input='ON t'
line 21:37 reportContextSensitivity d=1334 (join_clause), input='ON'
line 21:49 reportAttemptingFullContext d=1527 (atom), input='t.vc_glr ='
line 21:49 reportAttemptingFullContext d=1677 (variable_name), input='.vc_glr ='
line 21:49 reportContextSensitivity d=1677 (variable_name), input='.vc_glr ='
line 21:51 reportAttemptingFullContext d=1481 (relational_expression), input='= z'
line 21:49 reportContextSensitivity d=1481 (relational_expression), input='='
line 22:0 reportAttemptingFullContext d=1527 (atom), input='z.jgmc
WHERE'
line 22:10 reportAttemptingFullContext d=1677 (variable_name), input='.jgmc
WHERE NOT EXISTS'
line 22:0 reportContextSensitivity d=1677 (variable_name), input='.jgmc
WHERE'
line 22:10 reportAttemptingFullContext d=1310 (query_block), input='WHERE NOT EXISTS'
line 22:0 reportContextSensitivity d=1310 (query_block), input='WHERE'
line 25:2 reportAttemptingFullContext d=1324 (table_ref_aux), input='b
WHERE'
line 24:31 reportContextSensitivity d=1324 (table_ref_aux), input='b'
line 25:2 reportAttemptingFullContext d=1653 (table_alias), input='b
WHERE'
line 25:8 reportAttemptingFullContext d=1310 (query_block), input='WHERE t'
line 25:2 reportContextSensitivity d=1310 (query_block), input='WHERE'
line 25:19 reportAttemptingFullContext d=1527 (atom), input='t.l_fundid ='
line 25:19 reportAttemptingFullContext d=1677 (variable_name), input='.l_fundid ='
line 25:9 reportContextSensitivity d=1677 (variable_name), input='.'
line 25:21 reportAttemptingFullContext d=1481 (relational_expression), input='= b'
line 25:19 reportContextSensitivity d=1481 (relational_expression), input='='
line 26:1 reportAttemptingFullContext d=1527 (atom), input='b.cpbh
)'
line 27:1 reportAttemptingFullContext d=1677 (variable_name), input='.cpbh
)
AND'
line 25:22 reportContextSensitivity d=1677 (variable_name), input='.'
line 27:1 reportAttemptingFullContext d=1471 (logical_expression), input='AND'
line 27:1 reportContextSensitivity d=1471 (logical_expression), input='AND'
line 27:10 reportAttemptingFullContext d=1527 (atom), input='t.xx ='
line 27:10 reportAttemptingFullContext d=1677 (variable_name), input='.xx ='
line 27:10 reportContextSensitivity d=1677 (variable_name), input='.xx ='
line 27:12 reportAttemptingFullContext d=1481 (relational_expression), input='= 1'
line 27:10 reportContextSensitivity d=1481 (relational_expression), input='='
(sql_script (unit_statement (data_manipulation_language_statements (select_statement (select_only_statement (subquery (subquery_basic_elements (query
_block SELECT (selected_list (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_express
ion (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id
t)) . (id_expression (regular_id l_fundid))))))))))))))) (column_alias AS (identifier (id_expression (regular_id cpbh))))) , (select_list_elements (e
xpression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expres
sion (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_id vc_code)))))))))))))
)) (column_alias AS (identifier (id_expression (regular_id cpdm2))))) , (select_list_elements (expression (logical_expression (unary_logical_expressi
on (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string
' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id dzdm))))) , (select_list_elements (expression (logical_expression (unary_log
ical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (
quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_id vc_fullname))))))))))))))) (column_alias AS (identifier (id_
expression (regular_id cpmc))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_e
xpression (compound_expression (concatenation (model_expression (unary_expression (standard_function (string_function substr ( (expression (logical_e
xpression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expressi
on (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_id vc_name))))))))))))))) , (expression (lo
gical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_e
xpression (atom (constant (numeric 1)))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_expression (relational_express
ion (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 25)))))))))))) )))))))))))) (column_alias AS (id
entifier (id_expression (regular_id cpjc))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression
(relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expr
ession (regular_id t)) . (id_expression (regular_id vc_glr))))))))))))))) (column_alias AS (identifier (id_expression (regular_id glrmc))))) , (selec
t_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatena
tion (model_expression (unary_expression (atom (constant (quoted_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id glrdm
))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_express
ion (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id pkg_urp_ftsp_common))
. (id_expression (regular_id f_get_dict_code)) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_exp
ression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string 'DK_PRODTYPE_CO
DE'))))))))))))) , (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expressi
on (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (
regular_id l_class)))))))))))))))) )))))))))))))) (column_alias AS (identifier (id_expression (regular_id cplx))))) , (select_list_elements (expressi
on (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (u
nary_expression (atom (constant (quoted_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id cplb))))) , (select_list_eleme
nts (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_
expression (unary_expression (atom (constant (quoted_string '1')))))))))))) (column_alias AS (identifier (id_expression (regular_id yzfs))))) , (sele
ct_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concaten
ation (model_expression (unary_expression (atom (constant (quoted_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id STZR
))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_express
ion (concatenation (model_expression (unary_expression (standard_function (string_function decode ( (expressions (expression (logical_expression (una
ry_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (cons
tant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_id l_jjtzlx))))))))))))))) , (expression (logical_express
ion (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (at
om (constant (numeric 4)))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound
_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string '1')))))))))))) , (expression (logical_expression (unar
y_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (const
ant (quoted_string '0'))))))))))))) )))))))))))) (column_alias AS (identifier (id_expression (regular_id SFZSJJ))))) , (select_list_elements (express
ion (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (
unary_expression (standard_function (string_function decode ( (expressions (expression (logical_expression (unary_logical_expression (multiset_expres
sion (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id
_expression (regular_id t)) . (id_expression (regular_id l_class))))))))))))))) , (expression (logical_expression (unary_logical_expression (multiset
_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 13)))))))))))) ,
(expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expr
ession (unary_expression (atom (constant (quoted_string '1')))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_express
ion (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 14)))))))))))) , (express
ion (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (
unary_expression (atom (constant (quoted_string '1')))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_expression (rel
ational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 15)))))))))))) , (expression (log
ical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_ex
pression (atom (constant (quoted_string '1')))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_expression (relational_
expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 0))))))))))))) )))))))))))) (column_alias
AS (identifier (id_expression (regular_id SFETFJJ))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_e
xpression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string ' '))))))))))
)) (column_alias AS (identifier (id_expression (regular_id SFLOFJJ))))) , (select_list_elements (expression (logical_expression (unary_logical_expres
sion (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (standard_function (string_f
unction decode ( (expressions (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_express
ion (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression
(regular_id l_class))))))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_
expression (concatenation (model_expression (unary_expression (atom (constant (numeric 9)))))))))))) , (expression (logical_expression (unary_logical
_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quot
ed_string '1')))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expressio
n (concatenation (model_expression (unary_expression (atom (constant (numeric 15)))))))))))) , (expression (logical_expression (unary_logical_express
ion (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_strin
g '1')))))))))))) , (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (conca
tenation (model_expression (unary_expression (atom (constant (quoted_string '0'))))))))))))) )))))))))))) (column_alias AS (identifier (id_expression
(regular_id SFQDII))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expressio
n (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string ' ')))))))))))) (column_alias AS (identifier
(id_expression (regular_id sfdqlcjj))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (rel
ational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string ' ')))))))))))) (column_ali
as AS (identifier (id_expression (regular_id SFJJZJJ))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset
_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string ' '))))))))
)))) (column_alias AS (identifier (id_expression (regular_id SFGLRZGLRCP))))) , (select_list_elements (expression (logical_expression (unary_logical_
expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quote
d_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id SFZZCDY))))) , (select_list_elements (expression (logical_expression
(unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom
(constant (quoted_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id glrzglrcpdm2))))) , (select_list_elements (expressio
n (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (un
ary_expression (atom (constant (quoted_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id SFCDZH))))) , (select_list_elem
ents (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model
_expression (unary_expression (atom (constant (quoted_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id ZDCPDM))))) , (s
elect_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (conca
tenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_i
d d_creat))))))))))))))) (column_alias AS (identifier (id_expression (regular_id CLRQ2))))) , (select_list_elements (expression (logical_expression (
unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (c
onstant (quoted_string ' ')))))))))))) (column_alias AS (identifier (id_expression (regular_id BARQ))))) , (select_list_elements (expression (logical
_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expres
sion (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_id d_dqrq))))))))))))))) (column_alias AS
(identifier (id_expression (regular_id DQRQ3))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expres
sion (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id
_expression (regular_id t)) . (id_expression (regular_id d_dqrq))))))))))))))) (column_alias AS (identifier (id_expression (regular_id QSJSRQ))))) ,
(select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (con
catenation (model_expression (unary_expression (atom (constant (numeric 0.0)))))))))))) (column_alias AS (identifier (id_expression (regular_id TGFL2
))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_express
ion (concatenation (model_expression (unary_expression (atom (constant (numeric 0)))))))))))) (column_alias AS (identifier (id_expression (regular_id
GZWCTS2))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound
_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string '系统')))))))))))) (column_alias AS (identifier (id_exp
ression (regular_id data_source))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relation
al_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string ' ')))))))))))) (column_alias AS
(identifier (id_expression (regular_id czy))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expressi
on (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_e
xpression (regular_id (non_reserved_keywords_pre12c sysdate)))))))))))))))) (column_alias AS (identifier (id_expression (regular_id czsj))))) , (sele
ct_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concaten
ation (model_expression (unary_expression (case_statement (searched_case_statement CASE (searched_case_when_part WHEN (expression (logical_expression
(unary_logical_expression (multiset_expression (relational_expression (relational_expression (compound_expression (concatenation (model_expression (
unary_expression (atom (general_element (general_element_part (id_expression (regular_id pkg_urp_ftsp_common)) . (id_expression (regular_id f_get_dic
t_code)) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compou
nd_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string 'DK_PRODTYPE_CODE'))))))))))))) , (argument (expressi
on (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (u
nary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_id l_class)))))))))))))))) )))
))))))) (relational_operator <>) (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quot
ed_string '3'))))))))))))) THEN (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expre
ssion (concatenation (model_expression (unary_expression (atom (constant (quoted_string '1'))))))))))))) (searched_case_when_part WHEN (expression (l
ogical_expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (relational_expression (compound_expressi
on (concatenation (model_expression (unary_expression (atom (general_element (general_element_part (id_expression (regular_id pkg_urp_ftsp_common)) .
(id_expression (regular_id f_get_dict_code)) (function_argument ( (argument (expression (logical_expression (unary_logical_expression (multiset_expr
ession (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string 'DK_PRODTYPE_COD
E'))))))))))))) , (argument (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expressio
n (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (r
egular_id l_class)))))))))))))))) )))))))))) (relational_operator =) (relational_expression (compound_expression (concatenation (model_expression (un
ary_expression (atom (constant (quoted_string '3')))))))))))) AND (logical_expression (unary_logical_expression (multiset_expression (relational_expr
ession (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_
id z)) . (id_expression (regular_id jgmc)))))))))))) IS NOT (logical_operation NULL))))) THEN (expression (logical_expression (unary_logical_expressi
on (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string
'1'))))))))))))) (case_else_part ELSE (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compoun
d_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string '0'))))))))))))) END))))))))))) (column_alias AS (iden
tifier (id_expression (regular_id isenabled))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expressi
on (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 0)))))))))))) (column_alia
s AS (identifier (id_expression (regular_id qzms)))))) (from_clause FROM (table_ref_list (table_ref (table_ref_aux (table_ref_aux_internal (dml_table
_expression_clause (tableview_name (identifier (id_expression (regular_id ods_ftsp_fa26_tfundinfo)))))) (table_alias (identifier (id_expression (regu
lar_id t))))) (join_clause (outer_join_type LEFT) JOIN (table_ref_aux (table_ref_aux_internal (dml_table_expression_clause (tableview_name (identifie
r (id_expression (regular_id urp_ftsp_hd_zqgssmjjzgs)))))) (table_alias (identifier (id_expression (regular_id z))))) (join_on_part ON (condition (ex
pression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (relational_expression (compound_expression (conca
tenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_i
d vc_glr))))))))))) (relational_operator =) (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (con
stant (quoted_string (variable_name (id_expression (regular_id z)) . (id_expression (regular_id jgmc)))))))))))))))))))))) (where_clause WHERE (expre
ssion (logical_expression (logical_expression (unary_logical_expression NOT (multiset_expression (relational_expression (compound_expression (concate
nation (model_expression (unary_expression (quantified_expression EXISTS ( (select_only_statement (subquery (subquery_basic_elements (query_block SEL
ECT (selected_list (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compo
und_expression (concatenation (model_expression (unary_expression (atom (constant (numeric 1)))))))))))))) (from_clause FROM (table_ref_list (table_r
ef (table_ref_aux (table_ref_aux_internal (dml_table_expression_clause (tableview_name (identifier (id_expression (regular_id URP_FTSP_CP_CPJBXX_INFO
)))))) (table_alias (identifier (id_expression (regular_id b)))))))) (where_clause WHERE (expression (logical_expression (unary_logical_expression (m
ultiset_expression (relational_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (const
ant (quoted_string (variable_name (id_expression (regular_id t)) . (id_expression (regular_id l_fundid))))))))))) (relational_operator =) (relational
_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (reg
ular_id b)) . (id_expression (regular_id cpbh))))))))))))))))))))) )))))))))) AND (logical_expression (unary_logical_expression (multiset_expression
(relational_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string
(variable_name (id_expression (regular_id t)) . (id_expression (regular_id xx))))))))))) (relational_operator =) (relational_expression (compound_exp
ression (concatenation (model_expression (unary_expression (atom (constant (numeric 1)))))))))))))))))))))) <EOF>)
性能压测
func BenchmarkParseComplex(b *testing.B) {
var table = []string{
`SELECT t.l_fundid AS cpbh, t.vc_code AS cpdm2, ' ' AS dzdm, t.vc_fullname AS cpmc
, substr(t.vc_name, 1, 25) AS cpjc
, t.vc_glr AS glrmc, ' ' AS glrdm, pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE',t.l_class) AS cplx
, ' ' AS cplb, '1' AS yzfs, ' ' AS STZR
, decode(t.l_jjtzlx, 4, '1', '0') AS SFZSJJ
, decode(t.l_class, 13, '1', 14, '1', 15, '1', 0) AS SFETFJJ
, ' ' AS SFLOFJJ
, decode(t.l_class, 9, '1', 15, '1', '0') AS SFQDII
, ' ' AS sfdqlcjj, ' ' AS SFJJZJJ, ' ' AS SFGLRZGLRCP, ' ' AS SFZZCDY, ' ' AS glrzglrcpdm2
, ' ' AS SFCDZH, ' ' AS ZDCPDM, t.d_creat AS CLRQ2, ' ' AS BARQ, t.d_dqrq AS DQRQ3
, t.d_dqrq AS QSJSRQ, 0.0 AS TGFL2, 0 AS GZWCTS2, '系统' AS data_source, ' ' AS czy
, sysdate AS czsj
, CASE
WHEN pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) <> '3' THEN '1'
WHEN pkg_urp_ftsp_common.f_get_dict_code('DK_PRODTYPE_CODE', t.l_class) = '3'
AND z.jgmc IS NOT NULL
THEN '1'
ELSE '0'
END AS isenabled, 0 AS qzms
FROM ods_ftsp_fa26_tfundinfo t
LEFT JOIN urp_ftsp_hd_zqgssmjjzgs z ON t.vc_glr = z.jgmc
WHERE NOT EXISTS (
SELECT 1
FROM URP_FTSP_CP_CPJBXX_INFO b
WHERE t.l_fundid = b.cpbh
)
AND t.xx = 1`}
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, sql := range table {
input := antlr.NewInputStream(sql)
lexer := parser.NewPlSqlLexer(input)
stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
p := parser.NewPlSqlParser(stream)
p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))
tree := p.Sql_script()
tree.ToStringTree(p.RuleNames, p)
}
}
b.ReportAllocs()
}
压测结果如下:
goarch: amd64
pkg: antlr4_go_parser
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkParseComplex-8 1 1114407305 ns/op 482770208 B/op 8646102 allocs/op
PASS
BenchmarkParseComplex
执行了1次,每次执行平均时间是1114407305纳秒,即1.1144073 秒!!!太拉跨不敢相信,换个简单sql试下:
SELECT * FROM t WHERE id = 1
goarch: amd64
pkg: antlr4_go_parser
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkParseComplex-8 843 1404329 ns/op 896744 B/op 13333 allocs/op
PASS
每次执行平均时间是1404329纳秒,即1.404329毫秒,还是拉跨。
还是怀疑这个antlr-4.10.1
的这个版本对go
支持不好,详细可以看这个issues,但是高版本生成的又无法使用,本人初学,还望各路大佬不吝赐教。
参考资料
PLSQL/Golang:need a demo how to build a parser for plsql using Golang #2452