Skip to content

fix the function usage in the parser #21

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

Open
wants to merge 2 commits into
base: pypi/0.0.0-alpha
Choose a base branch
from

Conversation

BoyuXiao
Copy link

Fix for Error: name 'ParseRoutineBody' is not defined
Cause of Error: In the createfunc_opt_list method of the PostgreSQLParser class, the call to ParseRoutineBody(_localctx) was made without an instance reference (i.e., missing self.), causing Python to fail to locate the method in the current scope.

Fix for Error: Logger._log() got an unexpected keyword argument 'file'
Cause of Error: In the parse_pg_tree, parse_mysql_tree, and parse_oracle_tree functions, the logging.error(f"An error occurred: {e}", file=sys.stderr) call included the file parameter, which is not supported by Python's Logger._log() method.

@code4DB
Copy link
Collaborator

code4DB commented Jun 10, 2025

@BoyuXiao Hi! Please clarify how you modify the related files in PG parser :)

@BoyuXiao
Copy link
Author

1.在原来的PostgreSQLParser.py中会调用ParseRoutineBody(_localctx),这会出现问题,首先是不存在ParseRoutineBody这个函数,但是在PostgreSQLParserBase.py中存在parse_routine_body函数可以使用。但是不能让类PostgreSQLParser直接继承类PostgreSQLParserBase。因为PostgreSQLParserBase中还有get_postgresql_parser函数未定义,而要定义这个函数需要在PostgreSQLParserBase.py中导入PostgreSQLParser来使用,如果按照前面所说继承的话,就需要在PostgreSQLParser.py中导入PostgreSQLParserBase,这会导致循环导入。所以直接把PostgreSQLParserBase中的函数在PostgreSQLParser中定义。

2.PostgreSQLParser中的_localctx未定义,应该是localctx

3.注意把PostgreSQLParserBase中的函数在PostgreSQLParser中定义后,原来的函数调用ParseRoutineBody(_localctx)修改为self.ParseRoutineBody(localctx)

  1. logging.error(f"An error occurred: {e}", file=sys.stderr)不支持file参数,去掉即可

@code4DB
Copy link
Collaborator

code4DB commented Jun 10, 2025

@BoyuXiao Thanks for your efforts!

For 1. and 2., do you directly copy the function code from PostgreSQLParserBase to PostgreSQLParser? Please attach the successful execution results (e.g., the runtime snapshot) after these code modifications.

Moreover, these files can be automatically generated (see #19 for differences) and the error might be attributed to the error generation manner previously.

@BoyuXiao
Copy link
Author

74510028a91cf6896997c22690165e1

The running process is as shown above. Yes, I directly copy the function code from PostgreSQLParserBase to PostgreSQLParser.

@BoyuXiao
Copy link
Author

fix the bug about rule_rewrite #26

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