Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krsBk-00049x-GM for pgsql-general@arkaria.postgresql.org; Wed, 23 Dec 2020 00:39:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krsBi-0003Uw-4P for pgsql-general@arkaria.postgresql.org; Wed, 23 Dec 2020 00:39:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krsBh-0003Uo-Sw for pgsql-general@lists.postgresql.org; Wed, 23 Dec 2020 00:39:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krsBZ-0001c2-7a for pgsql-general@postgresql.org; Wed, 23 Dec 2020 00:39:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0BN0dMoX669320; Tue, 22 Dec 2020 19:39:22 -0500 From: Tom Lane To: Adrian Klaver cc: pgsql-general Subject: Re: Information schema sql_identifier In-reply-to: <653c81a9-bc2b-e7a6-1ece-eab59f007400@aklaver.com> References: <653c81a9-bc2b-e7a6-1ece-eab59f007400@aklaver.com> Comments: In-reply-to Adrian Klaver message dated "Tue, 22 Dec 2020 16:07:44 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <669318.1608683962.1@sss.pgh.pa.us> Date: Tue, 22 Dec 2020 19:39:22 -0500 Message-ID: <669319.1608683962@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Adrian Klaver writes: > So how does one go about using a table name from > information_schema.tables in pg_table_size()? You want something like select pg_table_size(quote_ident(table_schema)||'.'||quote_ident(table_name)) from information_schema.tables; I imagine that the failures you got are a consequence of having some table names that aren't valid unless quoted (ie contain spaces, funny characters, etc). In a general-purpose query, you can't ignore the schema name either. I might be more excited about v12's failure to provide an implicit cast to regclass if there were any prospect of queries like this working in a bulletproof way without accounting for schema names and funny characters. But there isn't, so the query shown in SO is a house of cards to start with. When you do it right, with quote_ident() or format(), no special casting is needed. regards, tom lane