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] Prostgres Procedural DO $$BEGIN ... END$$ #1946

Open
zdhuangelephant opened this issue Jan 15, 2024 · 4 comments
Open

[Feature] Prostgres Procedural DO $$BEGIN ... END$$ #1946

zdhuangelephant opened this issue Jan 15, 2024 · 4 comments
Labels
postgres Procedural Procedural language features Sponsor needed

Comments

@zdhuangelephant
Copy link

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

  • Brief description of the failing SQL feature
  • Example: Encountered unexpected token: "DO" "DO" can't be parsed

SQL Example:

  • Simplified Query Example, focusing on the failing feature

DO $$
BEGIN
IF NOT EXISTS( select 1 from comm.permission_operation where permission_operation_code = 'ecg_report_time_modify') and EXISTS( select 1 from comm.permission where permission_code = 'data_modify')
THEN
INSERT INTO comm.permission_operation
(permission_operation_id,
permission_id,
permission_operation_code,
permission_operation_name,
"type",
"version",
his_org_id,
his_creater_id,
his_creater_name,
his_create_time,
his_updater_id,
his_update_time)
VALUES
((select max(permission_operation_id) + 1 from comm.permission_operation),
(select permission_id from comm.permission where permission_code = 'data_modify' limit 1),
'ecg_report_time_modify',
'心电报告时间修改',
'1',
0,
(select his_org_id from comm.hospital limit 1),
1,
'系统管理员',
now(),
1,
now()) on conflict(permission_operation_id) do nothing;
END IF;
END $$;
```

Software Information:

  • JSqlParser 4.7
  • Database PostgreSQL

Exception in thread "main" net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "DO" "DO" at line 1, column 1.

@zdhuangelephant
Copy link
Author

image

@manticore-projects
Copy link
Contributor

Greetings!

PostgreSQL specific DO is not supported and you will need to provide or sponsor an implementation when you are interested in this particular feature.

@zdhuangelephant
Copy link
Author

image
is that not working ?

@manticore-projects manticore-projects changed the title [BUG] JSQLParser Version : RDBMS : failing feature description [Feature] Prostgres Procedural DO $$BEGIN ... END$$ Jan 15, 2024
@manticore-projects
Copy link
Contributor

is that not working ?

It is working by only passing through the text block. You would at least introduce a DO $$BEGIN ... END$$ statement and certainly you will want to parse this block in order to get the AST of your INSERT ... statement.

@manticore-projects manticore-projects added the Procedural Procedural language features label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
postgres Procedural Procedural language features Sponsor needed
Projects
None yet
Development

No branches or pull requests

2 participants