Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5907~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5907
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Aug 9, 2025

  1. no table rewrite when set column type to constrained domain

    per https://www.postgresql.org/docs/devel/sql-altertable.html
    says changing the type of an existing column to a constrained domain
    will trigger a table rewrite. However, after reviewing the relevant context [1]
    and experimenting with it, I found that it's doable to just a table scan.
    
    the main gotcha is struct NewColumnValue.
    we do ``palloc0(sizeof(NewColumnValue));`` in ATExecAddColumn,
    ATExecSetExpression, ATPrepAlterColumnType.
    ATExecAddColumn:  Adding a new column with domain with constraints will cause
                      table rewrite.
    ATExecSetExpression: for stored generated column will cause table rewrite, we do
                         not support domain over virtual generated columns now.
    ATPrepAlterColumnType: we only do table rewriting occasionally.see ATColumnChangeRequiresRewrite.
    
    If table rewrite is required, then there is nothing we can do.
    we can add a new boolean field, coerce_to_domain, to NewColumnValue. this field
    is set to true only when changing an existing column's type to a constrained
    domain. In such cases, a table scan is enough—no table rewrite is needed.
    
    [1]: https://www.postgresql.org/message-id/[email protected]
    discussion: https://postgr.es/m/XXX
    commitfest: https://commitfest.postgresql.org/patch/XXX
    jianhe-fun authored and Commitfest Bot committed Aug 9, 2025
    Configuration menu
    Copy the full SHA
    2786dbd View commit details
    Browse the repository at this point in the history
  2. [CF 5907] v1 - no table rewrite when set column type to constrained d…

    …omain
    
    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/5907
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/CACJufxFX0DupbF5+DBNF3mXCFNTZ1Y7jpT11+tCD_FcyADHs2A@mail.gmail.com
    Author(s): Jian He
    Commitfest Bot committed Aug 9, 2025
    Configuration menu
    Copy the full SHA
    6c858ad View commit details
    Browse the repository at this point in the history
Loading