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

SQL: handle "DATABASE" and "SCHEMA" keywords specially only when they come after "CREATE" #3674

Merged
merged 1 commit into from
Mar 23, 2023

Conversation

masatake
Copy link
Member

Close #3636.

The parser emitted the warning, "ignoring null tag in ...", when reading "alter database ..." from an input stream. The unexpected warning was originally reported in
https://twitter.com/fujii_masao/status/1619860698997329920.

This fix is inspired by the comment
(#3636 (comment)) submitted by Fujii Masao (@MasaoFujii).

Fujii Masao illustrated the way for the correct fix:

Probably it's valid to ignore ALTER statement in PostgreSQL, but
what about other DBMS? I'm afraid that ALTER statement is not in
SQL standard and other DBMS may handle the keyword "ALTER"
differently from PostgreSQL.

The cause of the issue seems that the keywords "DATABASE" and
"SCHEMA" are processed even if they don't follow "CREATE". That
is, the following SQL statements can cause ctags to emit warnings.

ALTER DATABASE ...
SELECT * FROM pg_locks WHERE database = ...

To fix the issue, I think that the keywords "DATABASE" and
"SCHEMA" should be processed only just after the keyword "CREATE"
is processed. How about something like the following change?

… come after "CREATE"

Close universal-ctags#3636.

The parser emitted the warning, "ignoring null tag in ...",
when reading "alter database ..." from an input stream.
The unexpected warning was originally reported in
https://twitter.com/fujii_masao/status/1619860698997329920.

This fix is inspired by the comment
(universal-ctags#3636 (comment))
submitted by Fujii Masao (@MasaoFujii).

Fujii Masao illustrated the way for the correct fix:

    Probably it's valid to ignore ALTER statement in PostgreSQL, but
    what about other DBMS? I'm afraid that ALTER statement is not in
    SQL standard and other DBMS may handle the keyword "ALTER"
    differently from PostgreSQL.

    The cause of the issue seems that the keywords "DATABASE" and
    "SCHEMA" are processed even if they don't follow "CREATE". That
    is, the following SQL statements can cause ctags to emit warnings.

	ALTER DATABASE ...
	SELECT * FROM pg_locks WHERE database = ...

    To fix the issue, I think that the keywords "DATABASE" and
    "SCHEMA" should be processed only just after the keyword "CREATE"
    is processed. How about something like the following change?
@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (7015f03) 82.87% compared to head (19f837c) 82.87%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3674   +/-   ##
=======================================
  Coverage   82.87%   82.87%           
=======================================
  Files         223      223           
  Lines       54561    54566    +5     
=======================================
+ Hits        45219    45224    +5     
  Misses       9342     9342           
Impacted Files Coverage Δ
parsers/sql.c 76.40% <100.00%> (+0.10%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@masatake masatake merged commit af30abc into universal-ctags:master Mar 23, 2023
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.

SQL: Warning: ignoring null tag in ... /src/test/regress/sql/collate.icu.utf8.sql(line: 412)
1 participant