Обсуждение: Requested addition to the todo list [was]: Re: Altering Domain Constraints on composite types

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

Requested addition to the todo list [was]: Re: Altering Domain Constraints on composite types

От
Richard Broersma
Дата:
I'd like to propose the following items be added to the todo list:
(Any thoughts?)

1) Modify composite types to allow ALTER DOMAIN(s) to ADD CONSTRAINT.
2) Allow  a since ALTER DOMAIN issue multiple ADD and DROP commands in
a single statement.

On Thu, Jun 3, 2010 at 9:12 AM, Richard Broersma
<richard.broersma@gmail.com> wrote:
> While playing with domains and composite types, I discovered a problem
> when I tried to alter a domain constraint.  I don't believe that this
> problem exists for traditional types.
>
> for example:
>
> broersr=> insert into tags values ((84,'PDSL',1,''),(84,'P',1, ''),'TEST TAG');
> ERROR:  invalid regular expression: invalid repetition count(s)
> broersr=> \dD
>
> List of domains
>  Schema |         Name         |         Type          |
>  Modifier                |                         Check
>
--------+----------------------+-----------------------+----------------------------------------+-------------------------------------------------------
> ...
>  public | tag_function         | character varying(4)  | not null
>                         | CHECK (VALUE::text ~ '^[A-Z]{2-4}$'::text)
> ...
> (11 rows)
>
> broersr=> --oops I made a mistake in the definition of my REGEX
> constraint so lets fix it.
>
> broersr=> begin;
> BEGIN
> broersr=> alter domain tag_function drop constraint valid_tag_function;
> ALTER DOMAIN
> broersr=> alter domain tag_function add constraint valid_tag_function
> check(value ~ E'^[A-Z]{2,4}$');
> ERROR:  cannot alter type "tag_function" because column "tags"."tag" uses it
> broersr=> rollback;
> ROLLBACK
>
>
> --
> Regards,
> Richard Broersma Jr.
>
> Visit the Los Angeles PostgreSQL Users Group (LAPUG)
> http://pugs.postgresql.org/lapug
>



--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

Richard Broersma wrote:
> I'd like to propose the following items be added to the todo list:
> (Any thoughts?)
>
> 1) Modify composite types to allow ALTER DOMAIN(s) to ADD CONSTRAINT.
> 2) Allow  a since ALTER DOMAIN issue multiple ADD and DROP commands in
> a single statement.

This is not currently a TODO.  I think the idea of modifying a domain
that is in use is certainly useful, but I am unclear how we would
implement that if the domain is already in use.

---------------------------------------------------------------------------


>
> On Thu, Jun 3, 2010 at 9:12 AM, Richard Broersma
> <richard.broersma@gmail.com> wrote:
> > While playing with domains and composite types, I discovered a problem
> > when I tried to alter a domain constraint. ?I don't believe that this
> > problem exists for traditional types.
> >
> > for example:
> >
> > broersr=> insert into tags values ((84,'PDSL',1,''),(84,'P',1, ''),'TEST TAG');
> > ERROR: ?invalid regular expression: invalid repetition count(s)
> > broersr=> \dD
> >
> > List of domains
> > ?Schema | ? ? ? ? Name ? ? ? ? | ? ? ? ? Type ? ? ? ? ?|
> > ?Modifier ? ? ? ? ? ? ? ?| ? ? ? ? ? ? ? ? ? ? ? ? Check
> >
--------+----------------------+-----------------------+----------------------------------------+-------------------------------------------------------
> > ...
> > ?public | tag_function ? ? ? ? | character varying(4) ?| not null
> > ? ? ? ? ? ? ? ? ? ? ? ? | CHECK (VALUE::text ~ '^[A-Z]{2-4}$'::text)
> > ...
> > (11 rows)
> >
> > broersr=> --oops I made a mistake in the definition of my REGEX
> > constraint so lets fix it.
> >
> > broersr=> begin;
> > BEGIN
> > broersr=> alter domain tag_function drop constraint valid_tag_function;
> > ALTER DOMAIN
> > broersr=> alter domain tag_function add constraint valid_tag_function
> > check(value ~ E'^[A-Z]{2,4}$');
> > ERROR: ?cannot alter type "tag_function" because column "tags"."tag" uses it
> > broersr=> rollback;
> > ROLLBACK
> >
> >
> > --
> > Regards,
> > Richard Broersma Jr.
> >
> > Visit the Los Angeles PostgreSQL Users Group (LAPUG)
> > http://pugs.postgresql.org/lapug
> >
>
>
>
> --
> Regards,
> Richard Broersma Jr.
>
> Visit the Los Angeles PostgreSQL Users Group (LAPUG)
> http://pugs.postgresql.org/lapug
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + None of us is going to be here forever. +