Re: add tab-complete for ALTER DOMAIN ADD...

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: jian he <jian.universality@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-04-29T11:16:08Z
Lists: pgsql-hackers
jian he <jian.universality@gmail.com> writes:

> hi.
>
> per https://www.postgresql.org/docs/current/sql-alterdomain.html
>
> we can add tab-complete for ALTER DOMAIN ADD variants:
> ALTER DOMAIN sth ADD CHECK
> ALTER DOMAIN sth ADD CONSTRAINT
> ALTER DOMAIN sth ADD NOT NULL

Good catch.

> +	/* ALTER DOMAIN <sth> ADD */
> +	else if (Matches("ALTER", "DOMAIN", MatchAny, "ADD"))
> +		COMPLETE_WITH("CONSTRAINT", "NOT NULL", "CHECK");

I think the completion for CHECK should include the opening paren too,
since that's required for the expression.  We could also add completion
after CONSTRAINT <name>, like this:

	else if(Matches("ALTER", "DOMAIN", MatchAny, "ADD", "CONSTRAINT", MatchAny))
		COMPLETE_WITH("NOT NULL", "CHECK (");

- ilmari



Commits

  1. Add tab-completion for ALTER TABLE not-nulls

  2. Add tab-complete for ALTER DOMAIN ADD [CONSTRAINT]