pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Suresh Kumar R <suresh.arsenal29@gmail.com>
Cc: Merlin Moncure <mmoncure@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Couldn't cast to record[]
Date: Sat, 05 Mar 2022 10:29:29 -0500
Message-ID: <4071820.1646494169@sss.pgh.pa.us> (raw)
In-Reply-To: <CAH+y2+bvJu+Ng2rWx_hsnEMZ0HEcPX+XgAhQVg4FwJTZUV=0bg@mail.gmail.com>
References: <CAH+y2+ZJcGmtO_qtyROHzoZYWKXn1tvVPKtQNDi1kxrwusM-Tg@mail.gmail.com>
	<CAHyXU0wxMeEMiASOrNjeDiTnqOGNBhf5PngS3ugW=pAPcg0D2w@mail.gmail.com>
	<CAH+y2+bvJu+Ng2rWx_hsnEMZ0HEcPX+XgAhQVg4FwJTZUV=0bg@mail.gmail.com>

Suresh Kumar R <suresh.arsenal29@gmail.com> 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





view thread (6+ messages)

Message-ID: <4071820.1646494169@sss.pgh.pa.us>
Permalink:  ../4071820.1646494169@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4071820.1646494169@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, suresh.arsenal29@gmail.com, mmoncure@gmail.com
  Subject: Re: Couldn't cast to record[]
  In-Reply-To: <4071820.1646494169@sss.pgh.pa.us>
  References: <CAH+y2+ZJcGmtO_qtyROHzoZYWKXn1tvVPKtQNDi1kxrwusM-Tg@mail.gmail.com> <CAHyXU0wxMeEMiASOrNjeDiTnqOGNBhf5PngS3ugW=pAPcg0D2w@mail.gmail.com> <CAH+y2+bvJu+Ng2rWx_hsnEMZ0HEcPX+XgAhQVg4FwJTZUV=0bg@mail.gmail.com> <4071820.1646494169@sss.pgh.pa.us>

* 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