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/4942~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/4942
Choose a head ref
  • 2 commits
  • 44 files changed
  • 2 contributors

Commits on Mar 21, 2025

  1. Avoid orphaned objects dependencies

    It's currently possible to create orphaned objects dependencies, for example:
    
    Scenario 1:
    
    session 1: begin; drop schema schem;
    session 2: create a function in the schema schem
    session 1: commit;
    
    With the above, the function created in session 2 would be linked to a non
    existing schema.
    
    Scenario 2:
    
    session 1: begin; create a function in the schema schem
    session 2: drop schema schem;
    session 1: commit;
    
    With the above, the function created in session 1 would be linked to a non
    existing schema.
    
    To avoid those scenarios, a new lock (that conflicts with a lock taken by DROP)
    has been put in place before the dependencies are being recorded. With this in
    place, the drop schema in scenario 2 would be locked.
    
    Also, after the new lock attempt, the patch checks that the object still exists:
    with this in place session 2 in scenario 1 would be locked and would report an
    error once session 1 committs (that would not be the case should session 1 abort
    the transaction).
    
    The patch takes into account any type of objects except the ones that are pinned
    (they are not droppable because the system requires it).
    
    A special case is done for objects that belong to the RelationRelationId class.
    For those, we should be in one of the two following cases that would already
    prevent the relation to be dropped:
    
    1. The relation is already locked (could be an existing relation or a relation
    that we are creating).
    
    2. The relation is protected indirectly (i.e an index protected by a lock on
    its table, a table protected by a lock on a function that depends of the table...)
    
    To avoid any risks for the RelationRelationId class case, we acquire a lock if
    there is none. That may add unnecessary lock for 2. but that's worth it.
    
    The patch adds a few tests for some dependency cases (that would currently produce
    orphaned objects):
    
    - schema and function (as the above scenarios)
    - alter a dependency (function and schema)
    - function and arg type
    - function and return type
    - function and function
    - domain and domain
    - table and type
    - server and foreign data wrapper
    bdrouvotAWS authored and Commitfest Bot committed Mar 21, 2025
    Configuration menu
    Copy the full SHA
    5b83720 View commit details
    Browse the repository at this point in the history
  2. [CF 4942] v19 - Avoid orphaned objects dependencies, take 3

    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/4942
    
    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/[email protected]
    Author(s): Bertrand Drouvot
    Commitfest Bot committed Mar 21, 2025
    Configuration menu
    Copy the full SHA
    db0778f View commit details
    Browse the repository at this point in the history
Loading