From: David Fetter <david@fetter.org>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: PostgreSQL Development <pgsql-hackers@postgresql.org>
Subject: Re: [PATCH v1] Show whether tables are logged in \dt+
Date: Wed, 24 Apr 2019 08:26:23 +0200
Message-ID: <20190424062623.GF28936@fetter.org> (raw)
In-Reply-To: <alpine.DEB.2.21.1904230656210.29102@lancre>
References: <20190423005642.GZ28936@fetter.org>
<alpine.DEB.2.21.1904230656210.29102@lancre>
On Tue, Apr 23, 2019 at 07:03:58AM +0200, Fabien COELHO wrote:
>
> Hello David,
>
> > I noticed that there wasn't a bulk way to see table logged-ness in psql,
> > so I made it part of \dt+.
>
> Applies, compiles, works for me.
>
> ISTM That temporary-ness is not shown either. Maybe the persistence column
> should be shown as is?
Temporariness added, but not raw.
> Also I'd suggest that the column should be displayed before the
> "description" column to keep the length-varying one last?
Done.
> > What say?
>
> Tests?
Included, but they're not stable for temp tables. I'm a little stumped
as to how to either stabilize them or test some other way.
> Doc?
What further documentation does it need?
Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donateAttachments:
[text/x-diff] v2-0001-Show-table-persistence-in-dt.patch (2.6K, ../20190424062623.GF28936@fetter.org/2-v2-0001-Show-table-persistence-in-dt.patch)
download | inline diff:
From 9e82160c2fe2f554e3417b3fbff147bc6024e3fe Mon Sep 17 00:00:00 2001
From: David Fetter <david.fetter@onelogin.com>
Date: Mon, 22 Apr 2019 17:50:48 -0700
Subject: [PATCH v2] Show table persistence in \dt+
To: hackers
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.20.1"
This is a multi-part message in MIME format.
--------------2.20.1
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit
\d would show this for individual tables, but there wasn't an
overarching view of all tables. Now, there is.
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.cindex 5ef567c123..02e7eb0862 100644--- a/src/bin/psql/describe.c+++ b/src/bin/psql/describe.c@@ -3679,6 +3679,13 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
if (verbose)
{
+ /*+ * Show whether the table is permanent, temporary, or unlogged.+ */+ if (pset.sversion >= 91000)+ appendPQExpBuffer(&buf,+ ",\n case c.relpersistence when 'p' then 'permanent' when 't' then 'temporary' when 'u' then 'unlogged' else 'unknown' end as \"%s\"",+ gettext_noop("Persistence"));
/*
* As of PostgreSQL 9.0, use pg_table_size() to show a more accurate
* size of a table, including FSM, VM and TOAST tables.
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.outindex 35856bffdd..f4f468804f 100644--- a/src/test/regress/expected/psql.out+++ b/src/test/regress/expected/psql.out@@ -4729,3 +4729,16 @@ drop schema testpart;
set search_path to default;
set role to default;
drop role testrole_partitioning;
+create table foo(id integer);+create temp table tfoo(id integer);+create unlogged table ufoo(id integer);+\dt+ *.*foo+ List of relations+ Schema | Name | Type | Owner | Persistence | Size | Description +-----------+------+-------+---------+-------------+---------+-------------+ pg_temp_3 | tfoo | table | shackle | temporary | 0 bytes | + public | foo | table | shackle | permanent | 0 bytes | + public | ufoo | table | shackle | unlogged | 0 bytes | +(3 rows)++drop table foo, tfoo, ufoo;diff --git a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sqlindex 78f4b5d7d5..c9ad6ffd9c 100644--- a/src/test/regress/sql/psql.sql+++ b/src/test/regress/sql/psql.sql@@ -1115,3 +1115,10 @@ set search_path to default;
set role to default;
drop role testrole_partitioning;
++set search_path = public, pg_temp;+create table foo(id integer);+create temp table tfoo(id integer);+create unlogged table ufoo(id integer);+\dt+ *.*foo+drop table foo, tfoo, ufoo;--------------2.20.1--
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: david@fetter.org, coelho@cri.ensmp.fr
Subject: Re: [PATCH v1] Show whether tables are logged in \dt+
In-Reply-To: <20190424062623.GF28936@fetter.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox