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 1nQWLj-0000WS-9h for pgsql-general@arkaria.postgresql.org; Sat, 05 Mar 2022 15:29:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nQWLi-0006b4-7j for pgsql-general@arkaria.postgresql.org; Sat, 05 Mar 2022 15:29:38 +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 1nQWLh-0006au-Ts for pgsql-general@lists.postgresql.org; Sat, 05 Mar 2022 15:29:37 +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 1nQWLb-0001WI-HN for pgsql-general@lists.postgresql.org; Sat, 05 Mar 2022 15:29:36 +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 225FTTVe4071821; Sat, 5 Mar 2022 10:29:29 -0500 From: Tom Lane To: Suresh Kumar R cc: Merlin Moncure , pgsql-general Subject: Re: Couldn't cast to record[] In-reply-to: References: Comments: In-reply-to Suresh Kumar R message dated "Sat, 05 Mar 2022 13:03:10 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4071819.1646494169.1@sss.pgh.pa.us> Date: Sat, 05 Mar 2022 10:29:29 -0500 Message-ID: <4071820.1646494169@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Suresh Kumar R writes: > I needed this because, I use postgres backend along with golang using > pgx driver. When i query address i need to specify OID of > address[](composite type). In my case i couldnt find the oid of that type > since its dynamic. The usual advice is to look it up on the fly. As an example: regression=# create type address as (f1 text, f2 text); CREATE TYPE regression=# select 'address[]'::regtype; regtype ----------- address[] (1 row) regression=# select 'address[]'::regtype::oid; oid -------- 127056 (1 row) If the client-side stack wants a type OID for a result column, it's unlikely to be satisfied with a pseudotype OID anyway. That provides next-to-no useful information about how to interpret values. Are you sure you can't just leave the type unspecified (e.g. zero) in whatever API is giving you trouble? regards, tom lane