From: Stephen Frost <sfrost@snowman.net>
To: Melvin Davidson <melvin6925@gmail.com>
Cc: Edson Carlos Ericksson Richter <richter@simkorp.com.br>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Does PostgreSQL check database integrity at startup?
Date: Fri, 29 Dec 2017 21:22:10 -0500
Message-ID: <20171230022210.GE2416@tamriel.snowman.net> (raw)
In-Reply-To: <CANu8FizkQcod6277BV-0ON7OdXdK95dNhR=68-0V9jG-mNz_wA@mail.gmail.com>
References: <20171228121651.GZ4628@tamriel.snowman.net>
<42cda197-fead-a7e5-a7e2-750d98bc4eb2@simkorp.com.br>
<743808611.5608368.1514484408822@mail.yahoo.com>
<20171228182636.GG4628@tamriel.snowman.net>
<CAGBW59fasv0KxRg6YTfQM7+zzmJ6jnwBvDGEiNi0aJH9HyqCzA@mail.gmail.com>
<48a4bcfa-6b85-81ca-9b59-9e47af8fa5af@simkorp.com.br>
<20171230011315.GC2416@tamriel.snowman.net>
<CANu8Fiwv9WFAWdhiTKYTjd7W7tUum7yDn=k-eVwo3E1G+m8WPA@mail.gmail.com>
<20171230020706.GD2416@tamriel.snowman.net>
<CANu8FizkQcod6277BV-0ON7OdXdK95dNhR=68-0V9jG-mNz_wA@mail.gmail.com>
Melvin,
* Melvin Davidson (melvin6925@gmail.com) wrote:
> On Fri, Dec 29, 2017 at 9:07 PM, Stephen Frost <sfrost@snowman.net> wrote:
> > * Melvin Davidson (melvin6925@gmail.com) wrote:
> > > >There should be a "catalog" that point where tables are stored in
> > physical
> > > files...
> > >
> > > Here is the query that gives you that information.
> > >
> > > SELECT c.oid,
> > > n.nspname as schema,
> > > c.relname as table,
> > > (SELECT oid FROM pg_database WHERE datname =
> > > current_database() ) as db_dir,
> > > c.relfilenode as filename
> > > FROM pg_class c
> > > JOIN pg_namespace n ON (n.oid = c.relnamespace)
> > > WHERE relname NOT LIKE 'pg_%'
> > > AND relname NOT LIKE 'information%'
> > > AND relname NOT LIKE 'sql_%'
> > > AND relkind = 'r'
> > > ORDER BY 2, relname;
> >
> > This isn't a terribly good query- it's entirely valid to have 'pg_blah'
> > and 'informationblah' tables in user schemas. If you'd like to filter
> > out the catalogs/internal schemas, filter based on schema name instead.
> >
> > Also, this doesn't actually provide what Edson is asking for. Edson's
> > asking for a query that uses pg_ls_dir() or some custom function which
> > will run 'stat' on each file and return the size, according to the OS.
>
> *Edson's original request was for a query that shows the FILENAMEs for the
> table.*
As quoted previously, he request included:
---
> Based on information from this catalog, would I have a tool (perhaps, a C
> function) that check that data is really there?
---
Which is asking about having a function to 'stat' the files and check
their length ('data is really there').
> *As for "qood" query, that is entirely an opinion. The query WILL show all
> files associated*
> *with ALL tables. You are free to edit and reconstruct as you choose. *
No, it won't, it'll filter out tables which exist in user schemas that
happen to start with one of the strings that the query includes ('pg_',
'information', and 'sql_').
I encourage you to test it- create a table in the public schema called
'pg_whatever' and see if your query picks it up or not. This isn't a
minor complaint about style, the query is outright wrong.
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: sfrost@snowman.net, melvin6925@gmail.com, richter@simkorp.com.br
Subject: Re: Does PostgreSQL check database integrity at startup?
In-Reply-To: <20171230022210.GE2416@tamriel.snowman.net>
References: <20171228121651.GZ4628@tamriel.snowman.net> <42cda197-fead-a7e5-a7e2-750d98bc4eb2@simkorp.com.br> <743808611.5608368.1514484408822@mail.yahoo.com> <20171228182636.GG4628@tamriel.snowman.net> <CAGBW59fasv0KxRg6YTfQM7+zzmJ6jnwBvDGEiNi0aJH9HyqCzA@mail.gmail.com> <48a4bcfa-6b85-81ca-9b59-9e47af8fa5af@simkorp.com.br> <20171230011315.GC2416@tamriel.snowman.net> <CANu8Fiwv9WFAWdhiTKYTjd7W7tUum7yDn=k-eVwo3E1G+m8WPA@mail.gmail.com> <20171230020706.GD2416@tamriel.snowman.net> <CANu8FizkQcod6277BV-0ON7OdXdK95dNhR=68-0V9jG-mNz_wA@mail.gmail.com> <20171230022210.GE2416@tamriel.snowman.net>
* 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