Skip to content

SQL: extract types in "create type t"#4383

Merged
masatake merged 6 commits intouniversal-ctags:masterfrom
masatake:sql--type-for-postgresql
Feb 11, 2026
Merged

SQL: extract types in "create type t"#4383
masatake merged 6 commits intouniversal-ctags:masterfrom
masatake:sql--type-for-postgresql

Conversation

@masatake
Copy link
Member

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 89.47368% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.93%. Comparing base (1bccbf2) to head (39d97ca).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
parsers/sql.c 89.47% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4383      +/-   ##
==========================================
+ Coverage   85.91%   85.93%   +0.02%     
==========================================
  Files         252      252              
  Lines       62683    62715      +32     
==========================================
+ Hits        53854    53895      +41     
+ Misses       8829     8820       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class tagging support for SQL CREATE TYPE statements so type names (e.g., t in CREATE TYPE t ...) can be extracted by the SQL parser, with accompanying unit tests and release notes.

Changes:

  • Introduce a new SQL kind type (k) and emit it from parseType.
  • Suppress the type tag when a more specific kind (record, table, cursor) is emitted for the same name.
  • Add/adjust unit tests covering PostgreSQL CREATE TYPE variants and update news.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
parsers/sql.c Adds SQLTAG_TYPE kind and updates parseType to emit/suppress type tags appropriately.
docs/news/HEAD.rst Documents the new SQL type kind extraction behavior.
Units/parser-sql.r/types.d/input.sql New fixture with PostgreSQL CREATE TYPE examples.
Units/parser-sql.r/types.d/expected.tags Expected tags for the new types.d test case, including k kind outputs.
Units/parser-sql.r/types.d/args.ctags Test args for the new types.d suite.
Units/parser-sql.r/funcions.d/expected.tags Updates expected tags to reflect record tagging behavior for create type ... as (...).
Units/parser-sql.r/funcions.d/args.ctags Enables SQL record kind (+r) for the funcions.d test suite to match updated expectations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

parsers/sql.c Outdated
Comment on lines 1732 to 1733
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_RECORD);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the KEYWORD_record/KEYWORD_object branch, the code always marks the newly-created SQLTAG_TYPE entry as a placeholder before attempting to emit SQLTAG_RECORD. If the record kind is disabled (SqlKinds['r'] is false by default), makeSqlTag(name, SQLTAG_RECORD) returns CORK_NIL and the placeholder call suppresses the only tag for this CREATE TYPE statement. Consider only calling markCorkEntryAsPlaceholder(r, true) when SQLTAG_RECORD is enabled / when makeSqlTag(...) actually created a tag, so a type tag is still emitted when record tags are disabled.

Suggested change
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_RECORD);
if (isLanguageKindEnabled (Lang_sql, SQLTAG_RECORD))
{
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_RECORD);
}

Copilot uses AI. Check for mistakes.
parsers/sql.c Outdated
Comment on lines 1739 to 1748
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_TABLE);
break;

case KEYWORD_ref:
readToken (token);
if (isKeyword (token, KEYWORD_cursor))
{
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_CURSOR);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the record/object branch, the KEYWORD_table and KEYWORD_ref cursor branches unconditionally call markCorkEntryAsPlaceholder(r, true). If the alternative kind (table/cursor) is disabled via --kinds-SQL, this will suppress the type tag and leave the CREATE TYPE statement without any tag. Consider making the placeholder suppression conditional on successfully creating the table/cursor tag (or on isLanguageKindEnabled for that kind).

Suggested change
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_TABLE);
break;
case KEYWORD_ref:
readToken (token);
if (isKeyword (token, KEYWORD_cursor))
{
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_CURSOR);
if (isLanguageKindEnabled (Lang_sql, SQLTAG_TABLE))
{
/* When the table kind is enabled, emit a
* table tag and suppress the type tag. */
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_TABLE);
}
break;
case KEYWORD_ref:
readToken (token);
if (isKeyword (token, KEYWORD_cursor))
{
if (isLanguageKindEnabled (Lang_sql, SQLTAG_CURSOR))
{
/* When the cursor kind is enabled, emit a
* cursor tag and suppress the type tag. */
markCorkEntryAsPlaceholder(r, true);
makeSqlTag (name, SQLTAG_CURSOR);
}

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

So units.py runs the unit test case and can report
"FAILED (broken args.ctags?)" failure.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +685 to +691
/* Make the tag that OLDTAGINDEX specifies a placeholder, then make a new
* tag for TOKEN with KIND kind. */
static int makeSqlTagInstead (tokenInfo *const token, const sqlKind kind, int oldTagIndex)
{
markCorkEntryAsPlaceholder(oldTagIndex, true);
return makeSqlTag (token, kind);
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeSqlTagInstead() only marks the original (leaf) cork entry as a placeholder. If XTAG_QUALIFIED_TAGS is enabled and the original tag had a non-empty scope, makeSqlTagFull() will also have emitted a separate qualified-tag entry; that qualified entry won’t be marked placeholder and can leak into the output even though the leaf tag was suppressed. Consider capturing the qualified-tag cork index when creating the original tag (use makeSqlTagFull(...,&fq)), and when replacing, mark both the leaf and qualified entries as placeholders (and likewise create the replacement tag via makeSqlTagFull so the replacement gets a qualified entry when applicable).

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking fq tags as placeholder is not needed in this pull request.

@masatake masatake merged commit 381d57e into universal-ctags:master Feb 11, 2026
91 of 92 checks passed
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.

2 participants