Add tab-completion for ALTER TABLE ADD NOT NULL
Hi,
psql already supports tab-completion for ALTER TABLE ADD with constraints
like CHECK and UNIQUE. However, after commit 14e87ffa5c5 introduced
support for adding NOT NULL constraints using ALTER TABLE ADD,
tab-completion for that case was missing.
The attached patch adds tab-completion support for ALTER TABLE ADD NOT NULL.
Thought?
Regards,
--
Fujii Masao
NTT DATA Japan Corporation
Attachments:
v1-0001-psql-Add-tab-completion-for-ALTER-TABLE-ADD-NOT-N.patchtext/plain; charset=UTF-8; name=v1-0001-psql-Add-tab-completion-for-ALTER-TABLE-ADD-NOT-N.patchDownload+5-5
On 2025-Jun-04, Fujii Masao wrote:
Hi,
psql already supports tab-completion for ALTER TABLE ADD with constraints
like CHECK and UNIQUE. However, after commit 14e87ffa5c5 introduced
support for adding NOT NULL constraints using ALTER TABLE ADD,
tab-completion for that case was missing.The attached patch adds tab-completion support for ALTER TABLE ADD NOT NULL.
Thought?
Hmm, did you rewrite the patch I posted at
/messages/by-id/202505111448.bwbfomrymq4b@alvherre.pgsql
?
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)
On 2025/06/04 23:38, Álvaro Herrera wrote:
On 2025-Jun-04, Fujii Masao wrote:
Hi,
psql already supports tab-completion for ALTER TABLE ADD with constraints
like CHECK and UNIQUE. However, after commit 14e87ffa5c5 introduced
support for adding NOT NULL constraints using ALTER TABLE ADD,
tab-completion for that case was missing.The attached patch adds tab-completion support for ALTER TABLE ADD NOT NULL.
Thought?Hmm, did you rewrite the patch I posted at
/messages/by-id/202505111448.bwbfomrymq4b@alvherre.pgsql
?
Oh, I missed that patch, thanks for pointing it out!
COMPLETE_WITH("COLUMN", "CONSTRAINT", "CHECK", "UNIQUE", "PRIMARY KEY",
- "EXCLUDE", "FOREIGN KEY");
+ "NOT NULL", "EXCLUDE", "FOREIGN KEY");
}
/* ALTER TABLE xxx ADD [COLUMN] yyy */
else if (Matches("ALTER", "TABLE", MatchAny, "ADD", "COLUMN", MatchAny) ||
- Matches("ALTER", "TABLE", MatchAny, "ADD", MatchAnyExcept("COLUMN|CONSTRAINT|CHECK|UNIQUE|PRIMARY|EXCLUDE|FOREIGN")))
+ Matches("ALTER", "TABLE", MatchAny, "ADD", MatchAnyExcept("COLUMN|CONSTRAINT|CHECK|UNIQUE|PRIMARY|NOT|EXCLUDE|FOREIGN")))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes);
/* ALTER TABLE xxx ADD CONSTRAINT yyy */
else if (Matches("ALTER", "TABLE", MatchAny, "ADD", "CONSTRAINT", MatchAny))
- COMPLETE_WITH("CHECK", "UNIQUE", "PRIMARY KEY", "EXCLUDE", "FOREIGN KEY");
+ COMPLETE_WITH("CHECK", "UNIQUE", "PRIMARY KEY", "EXCLUDE", "FOREIGN KEY", "NOT NULL");
Just one small style comment: in the documentation, table constraints are
listed in the order CHECK, NOT NULL, UNIQUE, PRIMARY KEY, etc. So it might
be better to follow that same order in the code for consistency in all
three places mentioned above.
Regards,
--
Fujii Masao
NTT DATA Japan Corporation
On 2025-Jun-05, Fujii Masao wrote:
Just one small style comment: in the documentation, table constraints are
listed in the order CHECK, NOT NULL, UNIQUE, PRIMARY KEY, etc. So it might
be better to follow that same order in the code for consistency in all
three places mentioned above.
Done that way, thanks.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"That sort of implies that there are Emacs keystrokes which aren't obscure.
I've been using it daily for 2 years now and have yet to discover any key
sequence which makes any sense." (Paul Thomas)