• Twitter
  • LinkedIn
  • Facebook
  • Youtube
  • Mail
  • English
    • French
    • Italian
    • Spanish
    • German
2ndQuadrant | PostgreSQL
PostgreSQL Solutions for the Enterprise
  • Contact Us
  • Support & Services
    • Support
      • 24/7 Production Support
      • Developer Support
      • IBM Z Production Support
    • DBA Services
      • Remote DBA
      • Database Monitoring
    • Consulting Services
      • Health Check
      • Performance Tuning
      • Database Security Audit
      • PostgreSQL Upgrade
    • Migration Services
      • Migrate to PostgreSQL
      • Migration Assessment
  • Products
    • HA Postgres Clusters
    • Postgres-BDR
    • 2ndQPostgres
    • pglogical
      • Installation instruction for pglogical
      • Documentation
    • repmgr
      • Installation instruction for repmgr
    • Barman
    • Postgres Cloud Manager
    • SQL Firewall
    • Postgres-XL
    • OmniDB
    • Postgres Installer
    • 2UDA
  • Downloads
    • Whitepapers
      • Highly Available Postgres Clusters
      • AlwaysOn Postgres
      • Postgres-BDR
      • PostgreSQL Security Best Practices
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • Healthcare Software Solutions (HSS)
        • Navionics
    • Installers
      • Postgres Installer
      • 2UDA – Unified Data Analytics
  • Training
    • Training Catalog and Scheduled Courses
      • Advanced Development & Performance
      • Linux for PostgreSQL DBAs
      • Postgres-BDR
      • PostgreSQL Database Administration
      • PostgreSQL Data Warehousing & Partitioning
      • PostgreSQL for Developers
      • PostgreSQL Immersion
      • PostgreSQL Immersion for Cloud Databases
      • PostgreSQL Security
      • Postgres-XL-10
      • Practical SQL
      • Replication, Backup & Disaster Recovery
    • PostgreSQL Training Chicago
    • PostgreSQL Training London
  • Books
    • PostgreSQL 11 Administration Cookbook
    • PostgreSQL 10 Administration Cookbook
    • PostgreSQL High Availability Cookbook – 2nd Edition
    • PostgreSQL 9 Administration Cookbook – 3rd Edition
    • PostgreSQL Server Programming Cookbook – 2nd Edition
    • PostgreSQL 9 Cookbook – Chinese Edition
  • PostgreSQL
    • PostgreSQL – History
    • 2ndQuadrant’s Passion for PostgreSQL
    • Who uses PostgreSQL?
    • PostgreSQL FAQ
    • PostgreSQL vs MySQL
    • Business Case for PostgreSQL
    • Security Information
  • Webinars
    • Using SSL with PostgreSQL and pgbouncer
  • About Us
    • About 2ndQuadrant
    • What Does “2ndQuadrant” Mean?
    • News
    • Events
    • Careers
    • Team Profile
  • Blog
  • Menu
You are here: Home / Blog / Craig's PlanetPostgreSQL / A convenient way to launch psql against postgres while running pg_regr...
A convenient way to launch psql against postgres while running pg_regress
craig.ringer

A convenient way to launch psql against postgres while running pg_regress

October 10, 2019/0 Comments/in Craig's PlanetPostgreSQL /by craig.ringer

I got tired of looking up regression_output/log/postmaster.log to find the PGSOCKET to use to connect to a running pg_regress‘s temp-install postgres so I wrote a little shell function for it. My patch to print a connst in pg_regress never got merged so I needed a workaround.

I’m sure I’m not the only one, so here’s regress_psql for your convenience.

Pop it in your bashrc and invoke it from the directory you run make check in.

 # Launch a psql against a running pg_regress instance
 # without messing around reading the logs.
 #
 function regress_psql() {
     pgpidf="tmp_check/data/postmaster.pid"
     if ! [ -e "$pgpidf" ]
     then
         echo "no postmaster.pid at $pgpidf"
         return 1
     fi
  
     PGPORT="$(awk 'NR==4 { print $0; }' "$pgpidf")"
     PGHOST="$(awk 'NR==5 { print $0; }' "$pgpidf")"
     connstr="host='$PGHOST' port=$PGPORT dbname='postgres'"
     echo "connstr: \"$connstr\""
     psql -v PROMPT1="%M:%> [%p] %[email protected]%/=%# " -v PROMPT2="%M:%> [%p] %[email protected]%/+%# " -q "$connstr" "[email protected]"
}

Usage:

$ regress_psql 
connstr: "host='/tmp/pg_regress-SdmFxp' port=60853 dbname='postgres'"
[local:/tmp/pg_regress-SdmFxp]:60853 [30043] [email protected]=# 

As a side note, I recommend keeping such aliases in a separate ~/.bash_aliases that you can source from your .bashrc. It’s easier to reload just the aliases then.

Share this entry
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on LinkedIn
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Recent Posts

  • Postgres-BDR: It is also about fast safe upgrades October 15, 2019
  • Managing another PostgreSQL Commitfest October 15, 2019
  • PostgreSQL 12: Foreign Keys and Partitioned Tables October 14, 2019
  • A convenient way to launch psql against postgres while running pg_regress October 10, 2019
  • Replication configuration changes in PostgreSQL 12 October 7, 2019

Featured External Blogs

Tomas Vondra's Blog

Our Bloggers

  • Simon Riggs
  • Alvaro Herrera
  • Andrew Dunstan
  • Craig Ringer
  • Francesco Canovai
  • Gabriele Bartolini
  • Giulio Calacoci
  • Ian Barwick
  • Marco Nenciarini
  • Mark Wong
  • Pavan Deolasee
  • Petr Jelinek
  • Shaun Thomas
  • Tomas Vondra
  • Umair Shahid

PostgreSQL Cloud

2QLovesPG 9.6 backup Barman BDR Business Continuity community conference database DBA development devops disaster recovery greenplum Hot Standby JSON JSONB kanban logical decoding logical replication monitoring open source performance PG12 pgbarman pgday pglogical PG Phriday postgres Postgres-BDR postgres-xl PostgreSQL PostgreSQL 9.6 PostgreSQL10 PostgreSQL 11 PostgreSQL11 PostgreSQL 11 New Features postgresql repmgr Recovery release replication sql standby wal webinar
UK +44 (0)870 766 7756

US +1 650 378 1218

Support & Services

24/7 Production Support

Developer Support

Remote DBA for PostgreSQL

PostgreSQL Database Monitoring

PostgreSQL Health Check

PostgreSQL Performance Tuning

Database Security Audit

Upgrade PostgreSQL

PostgreSQL Migration Assessment

Migrate from Oracle to PostgreSQL

Products

HA Postgres Clusters

Postgres-BDR

2ndQPostgres

pglogical

repmgr

Barman

Postgres Cloud Manager

SQL Firewall

Postgres-XL

OmniDB

Postgres Installer

2UDA

Postgres Learning Center

Introducing Postgres

Blog

Webinars

Books

Videos

Training

Case Studies

Events

About Us

About 2ndQuadrant

What does 2ndQuadrant Mean?

News

Careers 

Team Profile

©2001-2019 2ndQuadrant Ltd. All rights reserved | Privacy Policy
  • Twitter
  • LinkedIn
  • Facebook
  • Youtube
  • Mail
Replication configuration changes in PostgreSQL 12 Replication configuration changes in PostgreSQL 12 PostgreSQL 12 Foreign Keys and Partitioned Tables PostgreSQL 12: Foreign Keys and Partitioned Tables
Scroll to top
×