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 1ks6en-0007eF-1S for pgsql-general@arkaria.postgresql.org; Wed, 23 Dec 2020 16:06:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ks6el-0001tt-V0 for pgsql-general@arkaria.postgresql.org; Wed, 23 Dec 2020 16:06:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks6ek-0001rw-C4 for pgsql-general@lists.postgresql.org; Wed, 23 Dec 2020 16:06:31 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ks6ef-0007uM-Ly for pgsql-general@postgresql.org; Wed, 23 Dec 2020 16:06:29 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1CA755C01AC; Wed, 23 Dec 2020 11:06:23 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 23 Dec 2020 11:06:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=c f6O+1q6vb5rTCtP/ihaCV4Gt6QUyo8ITTT9beTqaQs=; b=mrYq3clx1s/EUFVWL mn0FTsiERwK7U9lEjOs+NabIgl3tIgDhl0ooLVl3fgTWg4wdGyuHKre3EO4cIbkI JWQLtS4XnZs/rfy0Shic3GpIOH7uCU0qvmvG9UYZziEu/hp4Q0GO8DMG9RyLnzcw 07ZXdAsZ6kyURtYtpoh2F7JIngqxIZdQ2lLsnfmFu1ZmxNDKPDavZVVZ/aRQSoLT fM/Uv2TRNzHFiRGQIDUzPADrILkoGGBF6Sok+Uvh8YxiW1Zyluwf/KSLUOnY3Zv1 9I3jnM08V06tmlLzYrT9qleRIvv1pVfRxMAccKD7jOv8fe6mvyk+DU1stR5E2PJp WRKgA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=cf6O+1q6vb5rTCtP/ihaCV4Gt6QUyo8ITTT9beTqa Qs=; b=Ik9hppCY/LVhoeQ+OEuK4tUOEWAWGw2ssVSkkIzttUVbNlA+4fhawdLT4 UR/UIYDztLCqR1fcyzfryw4kDRavyuyjSLmBO9+56T85gB1PO8kVQzByC16tysIu hJtvmOKtC++f0JW0vfYgXJH5fCEp+T5gSYx16+UGMLURaVItufDh8IA7VBwLk823 dwVKzZfqteWP9cv92dOCufHb0Vrzj75wx/RrgEFu0mUREK+85fJDmgh3DYllFZPb GGXx6PSt9oJw4OKikvhfp+WNrjn6rBNYWj0bZX3JfKpWSaT4Mi6Pm+gbBEIrWVak HDJilX+r2sjAcfkGBfPpiphQCwv1g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddtjedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpefhueegfeevudevteefjeejffdtudekjeehhefgieet teekgfejhefgtdeutdetudenucffohhmrghinhepshhtrggtkhhovhgvrhhflhhofidrtg homhenucfkphepjeehrddujedvrddugedrudejnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvh gvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.4] (75-172-14-17.tukw.qwest.net [75.172.14.17]) by mail.messagingengine.com (Postfix) with ESMTPA id E52A7240057; Wed, 23 Dec 2020 11:06:21 -0500 (EST) Subject: Re: Information schema sql_identifier To: Laurenz Albe , pgsql-general References: <653c81a9-bc2b-e7a6-1ece-eab59f007400@aklaver.com> <612fdeaf511c9eca2ccfff50e605461213890604.camel@cybertec.at> From: Adrian Klaver Message-ID: Date: Wed, 23 Dec 2020 08:06:21 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <612fdeaf511c9eca2ccfff50e605461213890604.camel@cybertec.at> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/22/20 11:21 PM, Laurenz Albe wrote: > On Tue, 2020-12-22 at 16:07 -0800, Adrian Klaver wrote: >> This came up in this SO question: >> >> https://stackoverflow.com/questions/65416748/postgres-12-4-gives-function-does-not-exists-error >> >> Where the query is: >> >> SELECT (TABLE_SCHEMA || '"."' || TABLE_NAME) as table_name, >> pg_size_pretty(pg_table_size(table_name)) as table_size, >> pg_size_pretty(pg_indexes_size(table_name)) AS indexes_size, >> pg_size_pretty(pg_total_relation_size(table_name)) as total_size >> from information_schema.TABLES nowait >> where TABLE_SCHEMA='myschema' >> order by pg_total_relation_size(table_name) desc; >> >> And the error is: >> >> "ERROR: function pg_table_size(information_schema.sql_identifier) does not exist >> LINE 1: ..."."' || TABLE_NAME) as table_name, pg_size_pretty(pg_table_s..." > > I don't see the problem. > > Cast "table_name" and "table_schema" to "text" wherever it occurs. SELECT pg_table_size(table_name::text) from information_schema.tables where table_schema = 'public'; ERROR: invalid name syntax Per Tom's post this does not cover special cases of identifiers. The above was run on my test database that has all manner of weird things it. So: SELECT table_name from information_schema.tables where table_schema = 'public' and table_name ilike 'space%'; table_name ------------- space table SELECT pg_table_size('space table') ; ERROR: invalid name syntax SELECT pg_table_size(quote_ident('space table')) ; pg_table_size --------------- 8192 > > Yours, > Laurenz Albe > -- Adrian Klaver adrian.klaver@aklaver.com