Re: Couldn't cast to record[] - Mailing list pgsql-general

From Tom Lane
Subject Re: Couldn't cast to record[]
Date
Msg-id 4071820.1646494169@sss.pgh.pa.us
Whole thread Raw
In response to Re: Couldn't cast to record[]  (Suresh Kumar R <suresh.arsenal29@gmail.com>)
List pgsql-general
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



pgsql-general by date:

Previous
From: obi reddy
Date:
Subject: REG:DR DRILL
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: Interesting fail when migrating Pg from Ubuntu Bionic to Focal