pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Lorusso Domenico <domenico.l76@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: [bug]? insert returning composite type fails
Date: Thu, 6 Jul 2023 16:20:36 -0700
Message-ID: <86ffb8e8-c847-e1ab-5984-fd3548c53c90@aklaver.com> (raw)
In-Reply-To: <CAJMpnG6zb9B0UdjRcd3R8jqsmbnUxTABjYJWKohvD6zO0Hn-pQ@mail.gmail.com>
References: <CAJMpnG6zb9B0UdjRcd3R8jqsmbnUxTABjYJWKohvD6zO0Hn-pQ@mail.gmail.com>

On 7/6/23 14:52, Lorusso Domenico wrote:
> Hello guys,
> In my db (version 15) I've defined a composite type with some domains
> 
> CREATE DOMAIN my_feat.audit_record_jsonb_domain
>      AS jsonb
>      NOT NULL;
> 
> ALTER DOMAIN my_feat.audit_record_jsonb_domain OWNER TO postgres;
> 
> CREATE DOMAIN my_feat.boolean_true_domain
>      AS boolean
>      DEFAULT true
>      NOT NULL;
> 
> ALTER DOMAIN my_feat.boolean_true_domain OWNER TO postgres;
> CREATE TYPE my_feat.bitemporal_record AS
> (
> user_ts_range tstzrange,
> db_ts_range tstzrange,
> has_future_record timestamp with time zone,
> audit_record my_feat.audit_record_jsonb_domain,
> is_valid my_feat.boolean_true_domain
> );
> 
> ALTER TYPE my_feat.bitemporal_record
>      OWNER TO postgres;
> So I've a table like that:
> CREATE TABLE IF NOT EXISTS my_feat.try_bt_info
> (
>      id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 
> START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
>      bt_info my_feat.bitemporal_record,
>      CONSTRAINT try_bt_info_pk PRIMARY KEY (id)
> )

Seems a long way around to arrive at:

CREATE TABLE IF NOT EXISTS my_feat.try_bt_info
(
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 
1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ) PRIMARY KEY,
user_ts_range tstzrange,
db_ts_range tstzrange,
has_future_record timestamp with time zone,
is_valid boolean NOT NULL 't'
);


> -- 
> Domenico L.
> 
> per stupire mezz'ora basta un libro di storia,
> io cercai di imparare la Treccani a memoria... [F.d.A.]

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (4+ messages)  latest in thread

Message-ID: <86ffb8e8-c847-e1ab-5984-fd3548c53c90@aklaver.com>
Permalink:  ../86ffb8e8-c847-e1ab-5984-fd3548c53c90@aklaver.com/
Also on:    postgresql.org/message-id/86ffb8e8-c847-e1ab-5984-fd3548c53c90@aklaver.com

 · 

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: adrian.klaver@aklaver.com, domenico.l76@gmail.com
  Subject: Re: [bug]? insert returning composite type fails
  In-Reply-To: <86ffb8e8-c847-e1ab-5984-fd3548c53c90@aklaver.com>
  References: <CAJMpnG6zb9B0UdjRcd3R8jqsmbnUxTABjYJWKohvD6zO0Hn-pQ@mail.gmail.com> <86ffb8e8-c847-e1ab-5984-fd3548c53c90@aklaver.com>

* 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