pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Table cannot be partiotioned using domain in argument
3+ messages / 3 participants
[nested] [flat]

* Table cannot be partiotioned using domain in argument
@ 2018-09-12 02:11  Márcio Antônio Sepp <marcio@zyontecnologia.com.br>
  0 siblings, 1 reply; 3+ messages in thread

From: Márcio Antônio Sepp @ 2018-09-12 02:11 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

 

Hi,

 

 

This query works fine:

 

create table t1

(d date)

PARTITION BY RANGE (d);

CREATE TABLE t1_p1 PARTITION OF t1 FOR VALUES FROM ('2000-01-01') TO
('2019-01-01');

 

 

 

Same query, but now (using domain):

 

CREATE DOMAIN ddate

    AS date;

 

create table t1

(d ddate)

PARTITION BY RANGE (d);

CREATE TABLE t1_p1 PARTITION OF t1 FOR VALUES FROM ('2000-01-01') TO
('2019-01-01');

 

The follow error occur:

 

SQL Error [42804]: ERROR: specified value cannot be cast to type ddate for
column "d"

  Detalhe: The cast requires a non-immutable conversion.

  Dica: Try putting the literal value in single quotes.

  Posição: 55

 

I cannot use domain in this case?

 

 

Thanks in advance!

 

--

Att

Márcio 

 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Table cannot be partiotioned using domain in argument
@ 2018-09-12 03:20  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Márcio Antônio Sepp <marcio@zyontecnologia.com.br>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2018-09-12 03:20 UTC (permalink / raw)
  To: Márcio Antônio Sepp <marcio@zyontecnologia.com.br>; +Cc: pgsql-general@lists.postgresql.org

=?iso-8859-1?Q?M=E1rcio_Ant=F4nio_Sepp?= <marcio@zyontecnologia.com.br> writes:
> The follow error occur:
> SQL Error [42804]: ERROR: specified value cannot be cast to type ddate for
> column "d"
>   Detalhe: The cast requires a non-immutable conversion.

> I cannot use domain in this case?

Nope.  The problem is suggested, if not exactly clearly explained,
by the error message: casting a literal to ddate isn't a guaranteed
fixed process.  For example, suppose you created this table and then
did

alter domain ddate add check (value > '2020-01-01');

thereby rendering the partition bound values illegal for the domain.
What would you expect to happen then?

We might at some point work out plausible semantics for this situation,
but it hasn't been done yet.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Table cannot be partiotioned using domain in argument
@ 2018-09-12 03:46  Márcio A. Sepp <marcio@zyontecnologia.com.br>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Márcio A. Sepp @ 2018-09-12 03:46 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org

<div dir='auto'><div><div class="gmail_extra"><div class="gmail_quote">Hi and thanks for answer,<br><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">
Nope.&nbsp; The problem is suggested, if not exactly clearly explained,
<br>
by the error message: casting a literal to ddate isn't a guaranteed
<br>
fixed process.&nbsp;</p></blockquote></div></div></div><div dir="auto">Wasn't clear enought to me.</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">For example, suppose you created this table and then
<br>
did
<br>

<br>
alter domain ddate add check (value &gt; '2020-01-01');
<br>

<br>
thereby rendering the partition bound values illegal for the domain.
<br>
What would you expect to happen then?</p></blockquote></div></div></div><div dir="auto">Not sure. Maybe check constraint error when insert/update a row?!?! I think this should happen before new record to be routed to the correct partition (in this case there is no partition created to this interval).</div><div dir="auto"><br></div><div dir="auto"></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">
We might at some point work out plausible semantics for this situation,
<br>
but it hasn't been done yet.
<br>

<br>
			regards, tom lane&nbsp;</p></blockquote></div></div></div><div dir="auto">Ok to me. I'll use date instead of domain.</div><div dir="auto"><br></div><div dir="auto"></div><div dir="auto"><div class="gmail_extra">Thank you so much Tom.</div></div></div>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-09-12 03:46 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 02:11 Table cannot be partiotioned using domain in argument Márcio Antônio Sepp <marcio@zyontecnologia.com.br>
2018-09-12 03:20 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-09-12 03:46   ` Márcio A. Sepp <marcio@zyontecnologia.com.br>

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