Обсуждение: Table cannot be partiotioned using domain in argument

Поиск
Список
Период
Сортировка

Table cannot be partiotioned using domain in argument

От
Márcio Antônio Sepp
Дата:

 

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

 

Re: Table cannot be partiotioned using domain in argument

От
Tom Lane
Дата:
=?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