Thread

Commits

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

  2. Add pg_constraint rows for not-null constraints

  1. Add tab-completion for ALTER TABLE ADD NOT NULL

    Fujii Masao <masao.fujii@oss.nttdata.com> — 2025-06-04T14:26:59Z

    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
    
  2. Re: Add tab-completion for ALTER TABLE ADD NOT NULL

    Álvaro Herrera <alvherre@kurilemu.de> — 2025-06-04T14:38:32Z

    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
    https://postgr.es/m/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)
    
    
    
    
  3. Re: Add tab-completion for ALTER TABLE ADD NOT NULL

    Fujii Masao <masao.fujii@oss.nttdata.com> — 2025-06-04T15:34:58Z

    
    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
    > https://postgr.es/m/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
    
    
    
    
    
  4. Re: Add tab-completion for ALTER TABLE ADD NOT NULL

    Álvaro Herrera <alvherre@kurilemu.de> — 2025-07-03T14:55:25Z

    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)