Skip to content

[BUG] JSQLParser 5.4-SNAPSHOT : Postgresql : Parser considers subsequent "CREATE FUNCTION" statements as a single statement #2322

@LouizFC

Description

@LouizFC

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

Failing SQL Feature:

  • What I encountered is not exactly an error, because the parser does not throw an exception, but subsequent CREATE FUNCTION statements are put into a single CreateFunction object, with everything in-between the start of the first one until the end of the last one becoming part of CreateFunction#getFunctionDeclarationParts.

SQL Example:

  • Simplified Query Example, focusing on the failing feature
create table if not exists test_table (
  id bigint not null
);

create or replace function test_fn_1(
  target text,
  characters text
) returns boolean as $$
  select trim($2 from $1) <> $1
$$ language sql immutable;

create or replace function test_fn_2(
  target text,
  characters text
) returns boolean as $$
  select position(repeat(first_char, 2) in translate(
    $1, $2, repeat(first_char, length($2))
  )) > 0
  from (values (left($2, 1))) params(first_char)
$$ language sql immutable;

create table if not exists test_table_2 (
  id bigint not null
);

Software Information:

  • JSqlParser version 5.4-SNAPSHOT
  • Database: PostgreSQL

Extra info

The AST can be seem here, the parser consider both functions one single "node"/"statement", while the create table statements are parsed correctly

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions