Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eV6mx-0007Hn-B9 for pgsql-general@arkaria.postgresql.org; Sat, 30 Dec 2017 02:22:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eV6mw-0005aW-Jt for pgsql-general@arkaria.postgresql.org; Sat, 30 Dec 2017 02:22:18 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eV6mw-0005aN-9U for pgsql-general@lists.postgresql.org; Sat, 30 Dec 2017 02:22:18 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eV6mp-0002v5-F2 for pgsql-general@lists.postgresql.org; Sat, 30 Dec 2017 02:22:16 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 035AD5F79C; Fri, 29 Dec 2017 21:22:10 -0500 (EST) Date: Fri, 29 Dec 2017 21:22:10 -0500 From: Stephen Frost To: Melvin Davidson Cc: Edson Carlos Ericksson Richter , pgsql-general@lists.postgresql.org Subject: Re: Does PostgreSQL check database integrity at startup? Message-ID: <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> <48a4bcfa-6b85-81ca-9b59-9e47af8fa5af@simkorp.com.br> <20171230011315.GC2416@tamriel.snowman.net> <20171230020706.GD2416@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="TD8GDToEDw0WLGOL" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --TD8GDToEDw0WLGOL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Melvin, * Melvin Davidson (melvin6925@gmail.com) wrote: > On Fri, Dec 29, 2017 at 9:07 PM, Stephen Frost 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 =3D > > > current_database() ) as db_dir, > > > c.relfilenode as filename > > > FROM pg_class c > > > JOIN pg_namespace n ON (n.oid =3D c.relnamespace) > > > WHERE relname NOT LIKE 'pg_%' > > > AND relname NOT LIKE 'information%' > > > AND relname NOT LIKE 'sql_%' > > > AND relkind =3D '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. >=20 > *Edson's original request was for a query that shows the FILENAMEs for t= he > table.* As quoted previously, he request included: --- > Based on information from this catalog, would I have a tool (perhaps, a C= =20 > 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 --TD8GDToEDw0WLGOL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaRvhSAAoJEO1sijiDR2RV0UcQAI4bzoE/3Zo7GnUg2r6Tte09 BDXglfMb1Vv63mxU7H6I1AMx54Y5o8C3R+c9l9wYReWHoy2WBpQY9DTsxr45JheK ubO3+7grgQGtMDvhTlYXcEzxCzjGnCM4uVw4bjQxewAxpK7uWL9UZV4OnonK6P1q vtFPfr1aBNOP9MF8o32YZQo6CqDtW5qCvmfAVDvG01sA/HDIomvLeZEE3JrJtfPH V+MHXUcd48EhoB24GXQed7K6KG9FZnghUB4c/dGcTYIG9k7sWHkKxRd4pGFwo7fr S86UAAQh8i7yy7cgU9Xft6nfjslaLWxkVd6OzGkcVgMweL9/JwSckrH0Wc9EK6fj 6OMj75gWnr47DHBLBhS/cLaqsyN6AUyKNzDxU7ttrydPDuRXKPuIZd6Nt7K4tC/g h9xW1Sswnyr0rPLMAVQOamGf0otpU5KCwH+kNzcNo6PFV6PQGis4/WBS86O88NKZ AwvrI5MMCU6b+fVpl32RdnCKTC9RQLnJCzA8B4dFoqczKj+eaxN4guw7+x6I1pmd ozRxq5t2t1iCE+lQ4o2JXsYUtCoMNZep1DgM1ealPeacHQYqtm6Yj5rk/CwVopGj OxQAu3/XR/dH2UhJbr9pTT3mQHfdh4NNbznl0oV5NBRYw6nCHBg4YzP9B8vojh7U jmcnLBKDmgRVS3Rp2tPI =LKB1 -----END PGP SIGNATURE----- --TD8GDToEDw0WLGOL--