Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't read .psqlrc for automated DB export #9246

Merged
merged 1 commit into from
Aug 11, 2024

Conversation

domodwyer
Copy link
Contributor

The dump_db_and_reimport_dump test fails on my machine because my .psqlrc sets the session into "read-only" mode by default, causing the import step to fail.

Looking at how this is used, I don't think sourcing the .psqlrc file is intended - a user might have it do anything! It's not uncommon to SET various options on the connection, some of which might cause problems (timeouts, search paths, etc).


  • fix: don't read .psqlrc for automated DB export (0c492d2)

    The dump_db::run_psql() function spawns a psql child process to run a an
    export script, but psql will automatically load and execute the content
    of the user's ~/.psqlrc file if it exists and execute it before the
    export script.
    
    The statements executed from the psqlrc file might change connection
    parameters (for example, the search path) in a way that causes the
    script to fail.
    
    This commit stops psql sourcing the psqlrc file at startup, meaning the
    connection should always be in a fresh / clean state.
    

The dump_db::run_psql() function spawns a psql child process to run a an
export script, but psql will automatically load and execute the content
of the user's ~/.psqlrc file if it exists and execute it before the
export script.

The statements executed from the psqlrc file might change connection
parameters (for example, the search path) in a way that causes the
script to fail.

This commit stops psql sourcing the psqlrc file at startup, meaning the
connection should always be in a fresh / clean state.
Copy link

codecov bot commented Aug 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.28%. Comparing base (e80b035) to head (0c492d2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9246   +/-   ##
=======================================
  Coverage   89.27%   89.28%           
=======================================
  Files         282      282           
  Lines       28589    28590    +1     
=======================================
+ Hits        25524    25526    +2     
+ Misses       3065     3064    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Turbo87 Turbo87 changed the title fix: don't read .psqlrc for automated DB export Don't read .psqlrc for automated DB export Aug 11, 2024
@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Aug 11, 2024
Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't even aware such a file is supported... 😅

While I don't yet see the reasons for setting such things globally, ignoring the file for this call doesn't hurt either, so thanks for the PR :)

@Turbo87 Turbo87 merged commit e5a155a into rust-lang:main Aug 11, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants