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

psqldef abort with syntax error on valid VIEW with any(ARRAY[]) #454

Open
chumaltd opened this issue Oct 23, 2023 · 3 comments
Open

psqldef abort with syntax error on valid VIEW with any(ARRAY[]) #454

chumaltd opened this issue Oct 23, 2023 · 3 comments
Labels
psqldef Bugs or feature requests related to PostgreSQL

Comments

@chumaltd
Copy link
Contributor

chumaltd commented Oct 23, 2023

Hi, I hit into 2 cases of psqldef parse error on VIEW.
And, I extracted reproducible DDL for each one. They may look meaningless, but taken from actual use cases.

1 case is split into #455, as they have different causes.

I think --skip-view option would be helpful for an escape hatch, as table operation looks much stable and Views can be CREATE OR REPLACEed by psql.

Platform

  • OS: Linux
  • RDBMS: PostgreSQL
  • Version: v0.16.9

Syntax error on any(ARRAY[])

This issue describes a syntax error VIEW while it's valid for PostgreSQL.

--export output

$ psqldef -Upostgres -hlocalhost -p5432 --export some_db

2023/10/23 12:50:14 found syntax error when parsing DDL "CREATE VIEW public.any_array AS SELECT 1 AS "?column?" WHERE (1 = ANY (ARRAY[1, 4, 5]))": syntax error at position 79 near '1'

Input SQL

CREATE VIEW any_array AS SELECT 1 WHERE 1 in (1, 4, 5);

PostgreSQL internally transforms this as follows:

CREATE VIEW any_array AS SELECT 1 WHERE 1 = ANY(ARRAY[1, 4, 5]);
@k0kubun
Copy link
Collaborator

k0kubun commented Oct 27, 2023

I hit into 2 cases of psqldef parse error on VIEW.

Thank you for reporting them. I think both of them are described well. Could you, however, split an issue for these two different cases? They are fairly independent problems, so it'd be useful if they have different issue numbers.

I think --skip-view option would be helpful for an escape hatch

Sure. I'm open to adding one to psqldef while it's currently limited to mysqldef. Would you be interested in filing a pull request to add that to psqldef?

@chumaltd chumaltd changed the title psqldef panics, abort with syntax error on valid VIEWs psqldef abort with syntax error on valid VIEW with any(ARRAY[]) Oct 27, 2023
@chumaltd
Copy link
Contributor Author

@k0kubun Thank you for your confirmation.
Yes, they should have different causes, and I just split into each issue.

Sure. I'm open to adding one to psqldef while it's currently limited to mysqldef. Would you be interested in filing a pull request to add that to psqldef?

It's nice to hear that.
Actually I haven't written a line of golang, but I'll just try for the next several days.
I feel much potential with --skip-view option.

@chumaltd
Copy link
Contributor Author

MATERIALIZED VIEW gets the same behavior as VIEW.

--export output

$ psqldef -Upostgres -hlocalhost -p5432 --export some_db

2023/10/28 11:30:44 found syntax error when parsing DDL "CREATE MATERIALIZED VIEW public.any_array AS SELECT 1 AS "?column?" WHERE (1 = ANY (ARRAY[1, 4, 5]))": syntax error at position 92 near '1'

Input SQL

CREATE MATERIALIZED VIEW any_array AS SELECT 1 WHERE 1 in (1, 4, 5);

@k0kubun k0kubun added the psqldef Bugs or feature requests related to PostgreSQL label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
psqldef Bugs or feature requests related to PostgreSQL
Projects
None yet
Development

No branches or pull requests

2 participants