Abstract Syntax Tree crashes when use SELECT FOR UPDATE

I’m make the custom rules to PLSQL analysis and am using the sslr-plsql-toolkit-3.4.1.2576.jar to guide me to find violated rules in the code blocks.

So when i parse code with a simple SELECT the Abstract Syntax Tree is mapped correcly:

CREATE OR REPLACE PACKAGE BODY package_sample_sonar_rules AS
	PROCEDURE rule21_compliant
	IS
	VAR1 INTEGER := 10;
	CURSOR cursor1 IS
		SELECT 
			col1,
			col2
		FROM
			tab1
		WHERE col1 > VAR1;
	BEGIN
		OPEN cursor1;
		CLOSE cursor1;		
	END rule21_compliant;
END package_sample_sonar_rules;
/

But i need find the SELECT WITH FOR UPDATE on code Because my rules do not allow the use of FOR UPDATE. So when add FOR UPDATE on SELECT, the Abstract Syntax Tree crashes and the SELECT on the tree is not similar to SELECT without FOR UPDATE


CREATE OR REPLACE PACKAGE BODY package_sample_sonar_rules AS
	PROCEDURE rule21_compliant
	IS
	VAR1 INTEGER := 10;
	CURSOR cursor1 IS
		SELECT 
			col1,
			col2
		FROM
			tab1
		WHERE col1 > VAR1 FOR UPDATE;
	BEGIN
		OPEN cursor1;
		CLOSE cursor1;		
	END rule21_compliant;
END package_sample_sonar_rules;
/

i dont know if in this forum can publish about tool sslr-plsql-toolkit-3.4.1.2576.jar because the problem is with that tool and not with sonar qube or scanner

The SonarPLSQL parser doesn’t support the “for update” clause. See https://jira.sonarsource.com/browse/SONARPLSQL-201

The SonarSource folks need to fix it. :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.