Domain Support -- another round

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

Domain Support -- another round

От:
Rod Taylor <rbt@zort.ca>
Дата:
Вложения:
Ok....

gram.y is fixed (no more %expect usage)

Using the copyCreateDomainStmt in the proper place.

Evolution is the mail client of choice for different (improved?) mime
headers.

And attached is a regular diff -c, rather than a cvs diff -c.


I updated the poor descriptions of MergeDomainAttributes().  Hopefully
its current and future use is more obvious.


Am I getting close?

Re: Domain Support -- another round

От:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Дата:
Grr.  Figured out why the patch was pooched.  Basically SAVING it out of
Outlook adds CR's everywhere!  Believe it or not...

BTW, it failed when patching parsenodes.h - you might need to update the
patch against CVS...

Chris

> -----Original Message-----
> From: pgsql-patches-owner@postgresql.org
> [mailto:pgsql-patches-owner@postgresql.org]On Behalf Of Rod Taylor
> Sent: Friday, 8 March 2002 12:21 PM
> To: pgsql-patches@postgresql.org
> Subject: [PATCHES] Domain Support -- another round
>
>
> Ok....
>
> gram.y is fixed (no more %expect usage)
>
> Using the copyCreateDomainStmt in the proper place.
>
> Evolution is the mail client of choice for different (improved?) mime
> headers.
>
> And attached is a regular diff -c, rather than a cvs diff -c.
>
>
> I updated the poor descriptions of MergeDomainAttributes().  Hopefully
> its current and future use is more obvious.
>
>
> Am I getting close?
>
>

Re: Domain Support -- another round

От:
"Rod Taylor" <rbt@zort.ca>
Дата:
Sorry, yes.

As much as I can I've been updating as I go.
--
Rod Taylor

This message represents the official view of the voices in my head 

----- Original Message ----- 
From: "Gavin Sherry" 
To: "Rod Taylor" 
Sent: Friday, March 08, 2002 1:23 AM
Subject: Re: [PATCHES] Domain Support -- another round


> Is this against latest CVS?
> 
> Gavin
> 
> 
> 

Re: Domain Support -- another round

От:
"Rod Taylor" <rbt@zort.ca>
Дата:
Вложения:
Attached is a diff to the patch of the below message to use b_expr
rather than c_expr.

Also includes an improved regress set.  Less redundant failures, and
tests numeric types as they're different from the others enough to
warrent it.
--
Rod Taylor

This message represents the official view of the voices in my head

----- Original Message -----
From: "Rod Taylor" 
To: 
Sent: Thursday, March 07, 2002 11:21 PM
Subject: [PATCHES] Domain Support -- another round


> Ok....
>
> gram.y is fixed (no more %expect usage)
>
> Using the copyCreateDomainStmt in the proper place.
>
> Evolution is the mail client of choice for different (improved?)
mime
> headers.
>
> And attached is a regular diff -c, rather than a cvs diff -c.
>
>
> I updated the poor descriptions of MergeDomainAttributes().
Hopefully
> its current and future use is more obvious.
>
>
> Am I getting close?
>
>


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


>
> ---------------------------(end of
broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)
>

Re: Domain Support -- another round

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Rod indicates this is his final version.

Your patch has been added to the PostgreSQL unapplied patches list at:

	http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

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


Rod Taylor wrote:
> Attached is a diff to the patch of the below message to use b_expr
> rather than c_expr.
> 
> Also includes an improved regress set.  Less redundant failures, and
> tests numeric types as they're different from the others enough to
> warrent it.
> --
> Rod Taylor
> 
> This message represents the official view of the voices in my head
> 
> ----- Original Message -----
> From: "Rod Taylor" 
> To: 
> Sent: Thursday, March 07, 2002 11:21 PM
> Subject: [PATCHES] Domain Support -- another round
> 
> 
> > Ok....
> >
> > gram.y is fixed (no more %expect usage)
> >
> > Using the copyCreateDomainStmt in the proper place.
> >
> > Evolution is the mail client of choice for different (improved?)
> mime
> > headers.
> >
> > And attached is a regular diff -c, rather than a cvs diff -c.
> >
> >
> > I updated the poor descriptions of MergeDomainAttributes().
> Hopefully
> > its current and future use is more obvious.
> >
> >
> > Am I getting close?
> >
> >
> 
> 
> ----------------------------------------------------------------------
> ----------
> 
> 
> >
> > ---------------------------(end of
> broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> >     (send "unregister YourEmailAddressHere" to
> majordomo@postgresql.org)
> >

[ Attachment, skipping... ]

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Domain Support -- another round

От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Random nitpicking below.  Also, have you created a regression test?


> diff -rc pgsql.orig/doc/src/sgml/catalogs.sgml pgsqldomain/doc/src/sgml/catalogs.sgml
> *** pgsql.orig/doc/src/sgml/catalogs.sgml	Thu Mar  7 11:35:32 2002
> --- pgsqldomain/doc/src/sgml/catalogs.sgml	Thu Mar  7 22:24:23 2002
> ***************
> *** 2511,2516 ****
> --- 2511,2563 ----
>        
>
>        
> +       typbasetype
> +       oid
> +       
> +       
> +        typbasetype is the type that this one is based
> +        off of.  Normally references the domains parent type, and is 0 otherwise.

"based on"

> +       
> +      
> +
> + 	 
> + 	  typnotnull
> + 	  boolean
> + 	  
> + 	  
> + 	   typnotnull represents a NOT NULL
> + 	   constraint on a type.  Normally used only for domains.

And unnormally...?

> + 	  
> + 	 
> +
> +      
> +       typmod
> +       integer
> +       
> +       
> +        typmod records type-specific data
> +        supplied at table creation time (for example, the maximum
> +        length of a varchar column).  It is passed to
> +        type-specific input and output functions as the third
> +        argument. The value will generally be -1 for types that do not
> +        need typmod.  This data is copied to
> +        pg_attribute.atttypmod on creation
> +        of a table using a domain as it's field type.
> +        
> +      
> +
> +      
> +       typdefaultbin
> +       text
> +       
> +       
> +        typdefaultbin is NULL for types without a
> +        default value.  If it's not NULL, it contains the internal string
> +        representation of the default expression node.
> +       
> +      
> +
> +      
>         typdefault
>         text
>         
> diff -rc pgsql.orig/doc/src/sgml/ref/allfiles.sgml pgsqldomain/doc/src/sgml/ref/allfiles.sgml
> *** pgsql.orig/doc/src/sgml/ref/allfiles.sgml	Thu Mar  7 11:35:32 2002
> --- pgsqldomain/doc/src/sgml/ref/allfiles.sgml	Thu Mar  7 22:24:23 2002
> ***************
> *** 52,57 ****
> --- 52,58 ----
>   
>   
>   
> + 

I don't see this file included.

>   
>   
>   
> ***************
> *** 69,74 ****
> --- 70,76 ----
>   
>   
>   
> + 
>   
>   
>   
> diff -rc pgsql.orig/doc/src/sgml/ref/comment.sgml pgsqldomain/doc/src/sgml/ref/comment.sgml
> *** pgsql.orig/doc/src/sgml/ref/comment.sgml	Thu Mar  7 11:35:33 2002
> --- pgsqldomain/doc/src/sgml/ref/comment.sgml	Thu Mar  7 22:24:23 2002
> ***************
> *** 25,31 ****
>     
>   COMMENT ON
>   [
> !   [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] object_name |
>     COLUMN table_name.column_name |
>     AGGREGATE agg_name (agg_type) |
>     FUNCTION func_name (arg1, arg2, ...) |
> --- 25,31 ----
>     
>   COMMENT ON
>   [
> !   [ DATABASE | DOMAIN | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] object_name |
>     COLUMN table_name.column_name |
>     AGGREGATE agg_name (agg_type) |
>     FUNCTION func_name (arg1, arg2, ...) |
> ***************
> *** 33,39 ****
>     TRIGGER trigger_name ON table_name
>   ] IS 'text'
>     
> !
>     
>      
>       1999-10-25
> --- 33,39 ----
>     TRIGGER trigger_name ON table_name
>   ] IS 'text'
>     
> !
>     
>      
>       1999-10-25
> ***************
> *** 64,70 ****
>       
>      
>     
> !
>     
>      
>       1998-09-08
> --- 64,70 ----
>       
>      
>     
> !
>     
>      
>       1998-09-08
> ***************
> *** 99,105 ****
>     
>     
>      COMMENT stores a comment about a database object.
> !     Comments can be
>       easily retrieved with psql's
>       \dd, \d+, or \l+
>       commands.  Other user interfaces to retrieve comments can be built atop
> --- 99,105 ----
>     
>     
>      COMMENT stores a comment about a database object.
> !     Comments can be
>       easily retrieved with psql's
>       \dd, \d+, or \l+
>       commands.  Other user interfaces to retrieve comments can be built atop
> ***************
> *** 141,146 ****
> --- 141,147 ----
>
>      
>   COMMENT ON DATABASE my_database IS 'Development Database';
> + COMMENT ON DOMAIN my_domain IS 'Domains are like abstracted fields';

This comment describes domains in general, not a specific domain.

>   COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee id';
>   COMMENT ON RULE my_rule IS 'Logs UPDATES of employee records';
>   COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
> ***************
> *** 155,166 ****
>      
>     
>    
> !
>    
>     
>      Compatibility
>     
> !
>     
>      
>       1998-09-08
> --- 156,167 ----
>      
>     
>    
> !
>    
>     
>      Compatibility
>     
> !
>     
>      
>       1998-09-08
> diff -rc pgsql.orig/doc/src/sgml/reference.sgml pgsqldomain/doc/src/sgml/reference.sgml
> *** pgsql.orig/doc/src/sgml/reference.sgml	Thu Mar  7 11:35:32 2002
> --- pgsqldomain/doc/src/sgml/reference.sgml	Thu Mar  7 22:24:23 2002
> ***************
> *** 61,66 ****
> --- 61,67 ----
>      &createAggregate;
>      &createConstraint;
>      &createDatabase;
> +    &createDomain;
>      &createFunction;
>      &createGroup;
>      &createIndex;
> ***************
> *** 78,83 ****
> --- 79,85 ----
>      &delete;
>      &dropAggregate;
>      &dropDatabase;
> +    &dropDomain;
>      &dropFunction;
>      &dropGroup;
>      &dropIndex;
> ***************
> *** 115,121 ****
>      &unlisten;
>      &update;
>      &vacuum;
> !
>    
>
>   

Re: Domain Support -- another round

От:
"Rod Taylor" <rbt@zort.ca>
Дата:
Вложения:
New set with most of Peters comments corrected.  Left the deal about
schema though :)  Took nearly an hour to do a cvs diff for some reason
this time (normally a couple of minutes is enough).

> Random nitpicking below.  Also, have you created a regression test?

They had been posted a few times and haven't changed.  (Attached
anyway)


> > +    typnotnull represents a NOT NULL
> > +    constraint on a type.  Normally used only for domains.
>
> And unnormally...?

Unnormally is when someone sets it by hand on a type which isn't a
domain -- I guess.  Corrected.

> > + 
>
> I don't see this file included.

Other messages.  Full package included on this one however.



> > +  * MergeDomainAttributes
> > +  *      Returns a new table schema with the constraints, types,
and other
> > +  *      attributes of the domain resolved for fields using the
domain as
> > +  * their type.
>
> I didn't know we had schemas yet.  You should probably not overload
that
> term to mean "a list of database objects".

Merge attributes says something very similar about inheritance and
table schemas.  Kinda correct considering
the variable used in both cases is *schema.


The diff weirdness in regards to DROP DATABASE is probably because I
started by copying the DROP DATABASE element, then altered it.  I
don't know why it chose that method to do the diff though, but it is
accurate.  Using -cd flags didn't make it any prettier.

Re: Domain Support -- another round

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Removed, superceeded by new versions.

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

Rod Taylor wrote:
> Attached is a diff to the patch of the below message to use b_expr
> rather than c_expr.
> 
> Also includes an improved regress set.  Less redundant failures, and
> tests numeric types as they're different from the others enough to
> warrent it.
> --
> Rod Taylor
> 
> This message represents the official view of the voices in my head
> 
> ----- Original Message -----
> From: "Rod Taylor" 
> To: 
> Sent: Thursday, March 07, 2002 11:21 PM
> Subject: [PATCHES] Domain Support -- another round
> 
> 
> > Ok....
> >
> > gram.y is fixed (no more %expect usage)
> >
> > Using the copyCreateDomainStmt in the proper place.
> >
> > Evolution is the mail client of choice for different (improved?)
> mime
> > headers.
> >
> > And attached is a regular diff -c, rather than a cvs diff -c.
> >
> >
> > I updated the poor descriptions of MergeDomainAttributes().
> Hopefully
> > its current and future use is more obvious.
> >
> >
> > Am I getting close?
> >
> >
> 
> 
> ----------------------------------------------------------------------
> ----------
> 
> 
> >
> > ---------------------------(end of
> broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> >     (send "unregister YourEmailAddressHere" to
> majordomo@postgresql.org)
> >

[ Attachment, skipping... ]

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Domain Support -- another round

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Your patch has been added to the PostgreSQL unapplied patches list at:

	http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

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


Rod Taylor wrote:
> New set with most of Peters comments corrected.  Left the deal about
> schema though :)  Took nearly an hour to do a cvs diff for some reason
> this time (normally a couple of minutes is enough).
> 
> > Random nitpicking below.  Also, have you created a regression test?
> 
> They had been posted a few times and haven't changed.  (Attached
> anyway)
> 
> 
> > > +    typnotnull represents a NOT NULL
> > > +    constraint on a type.  Normally used only for domains.
> >
> > And unnormally...?
> 
> Unnormally is when someone sets it by hand on a type which isn't a
> domain -- I guess.  Corrected.
> 
> > > + 
> >
> > I don't see this file included.
> 
> Other messages.  Full package included on this one however.
> 
> 
> 
> > > +  * MergeDomainAttributes
> > > +  *      Returns a new table schema with the constraints, types,
> and other
> > > +  *      attributes of the domain resolved for fields using the
> domain as
> > > +  * their type.
> >
> > I didn't know we had schemas yet.  You should probably not overload
> that
> > term to mean "a list of database objects".
> 
> Merge attributes says something very similar about inheritance and
> table schemas.  Kinda correct considering
> the variable used in both cases is *schema.
> 
> 
> The diff weirdness in regards to DROP DATABASE is probably because I
> started by copying the DROP DATABASE element, then altered it.  I
> don't know why it chose that method to do the diff though, but it is
> accurate.  Using -cd flags didn't make it any prettier.

[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Domain Support -- another round

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Patch applied.  I am attaching the expected/domain.out file that I
generated when I added your domain test file to the regression tests. 
Please verify that the output is correct.  Thanks.

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

Rod Taylor wrote:
> New set with most of Peters comments corrected.  Left the deal about
> schema though :)  Took nearly an hour to do a cvs diff for some reason
> this time (normally a couple of minutes is enough).
> 
> > Random nitpicking below.  Also, have you created a regression test?
> 
> They had been posted a few times and haven't changed.  (Attached
> anyway)
> 
> 
> > > +    typnotnull represents a NOT NULL
> > > +    constraint on a type.  Normally used only for domains.
> >
> > And unnormally...?
> 
> Unnormally is when someone sets it by hand on a type which isn't a
> domain -- I guess.  Corrected.
> 
> > > + 
> >
> > I don't see this file included.
> 
> Other messages.  Full package included on this one however.
> 
> 
> 
> > > +  * MergeDomainAttributes
> > > +  *      Returns a new table schema with the constraints, types,
> and other
> > > +  *      attributes of the domain resolved for fields using the
> domain as
> > > +  * their type.
> >
> > I didn't know we had schemas yet.  You should probably not overload
> that
> > term to mean "a list of database objects".
> 
> Merge attributes says something very similar about inheritance and
> table schemas.  Kinda correct considering
> the variable used in both cases is *schema.
> 
> 
> The diff weirdness in regards to DROP DATABASE is probably because I
> started by copying the DROP DATABASE element, then altered it.  I
> don't know why it chose that method to do the diff though, but it is
> accurate.  Using -cd flags didn't make it any prettier.

[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
-- Test Comment / Drop
create domain domaindroptest int4;
comment on domain domaindroptest is 'About to drop this..';
create domain basetypetest domaindroptest;
ERROR:  DefineDomain: domaindroptest is not a basetype
drop domain domaindroptest;
ERROR:  parser: parse error at or near ";"
drop domain domaindroptest restrict;
-- TEST Domains.
create domain domainvarchar varchar(5);
create domain domainnumeric numeric(8,2);
create domain domainint4 int4;
create domain domaintext text;
-- Test tables using domains
create table basictest
           ( testint4 domainint4
           , testtext domaintext
           , testvarchar domainvarchar
           , testnumeric domainnumeric
           );
INSERT INTO basictest values ('88', 'haha', 'short', '123.12');      -- Good
INSERT INTO basictest values ('88', 'haha', 'short text', '123.12'); -- Bad varchar
ERROR:  value too long for type character varying(5)
INSERT INTO basictest values ('88', 'haha', 'short', '123.1212');    -- Truncate numeric
select * from basictest;
 testint4 | testtext | testvarchar | testnumeric 
----------+----------+-------------+-------------
 88       | haha     | short       | 123.12
 88       | haha     | short       | 123.12
(2 rows)

drop table basictest;
drop domain domainvarchar restrict;
drop domain domainnumeric restrict;
drop domain domainint4 restrict;
drop domain domaintext restrict;
-- Array Test
create domain domainint4arr int4[1];
create domain domaintextarr text[2][3];
create table domarrtest
           ( testint4arr domainint4arr
           , testtextarr domaintextarr
            );
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"}{"c","d"}}');
INSERT INTO domarrtest values ('{{2,2}{2,2}}', '{{"a","b"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"}{"c","d"}{"e"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a"}{"c"}}');
INSERT INTO domarrtest values (NULL, '{{"a","b"}{"c","d","e"}}');
drop table domarrtest;
drop domain domainint4arr restrict;
drop domain domaintextarr restrict;
create domain dnotnull varchar(15) NOT NULL;
create domain dnull    varchar(15) NULL;
create table nulltest
           ( col1 dnotnull
           , col2 dnotnull NULL  -- NOT NULL in the domain cannot be overridden
           , col3 dnull    NOT NULL
           , col4 dnull
           );
INSERT INTO nulltest DEFAULT VALUES;
ERROR:  ExecAppend: Fail to add null value in not null attribute col1
INSERT INTO nulltest values ('a', 'b', 'c', 'd');  -- Good
INSERT INTO nulltest values (NULL, 'b', 'c', 'd');
ERROR:  ExecAppend: Fail to add null value in not null attribute col1
INSERT INTO nulltest values ('a', NULL, 'c', 'd');
ERROR:  ExecAppend: Fail to add null value in not null attribute col2
INSERT INTO nulltest values ('a', 'b', NULL, 'd');
ERROR:  ExecAppend: Fail to add null value in not null attribute col3
INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
select * from nulltest;
 col1 | col2 | col3 | col4 
------+------+------+------
 a    | b    | c    | d
 a    | b    | c    | 
(2 rows)

drop table nulltest;
drop domain dnotnull restrict;
drop domain dnull restrict;
create domain ddef1 int4 DEFAULT 3;
create domain ddef2 oid DEFAULT '12';
-- Type mixing, function returns int8
create domain ddef3 text DEFAULT 5;
create sequence ddef4_seq;
create domain ddef4 int4 DEFAULT nextval(cast('ddef4_seq' as text));
create domain ddef5 numeric(8,2) NOT NULL DEFAULT '12.12';
create table defaulttest
            ( col1 ddef1
            , col2 ddef2
            , col3 ddef3
            , col4 ddef4
            , col5 ddef1 NOT NULL DEFAULT NULL
            , col6 ddef2 DEFAULT '88'
            , col7 ddef4 DEFAULT 8000
		, col8 ddef5
            );
insert into defaulttest default values;
insert into defaulttest default values;
insert into defaulttest default values;
select * from defaulttest;
 col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8  
------+------+------+------+------+------+------+-------
 3    | 12   | 5    | 1    | 3    | 88   | 8000 | 12.12
 3    | 12   | 5    | 2    | 3    | 88   | 8000 | 12.12
 3    | 12   | 5    | 3    | 3    | 88   | 8000 | 12.12
(3 rows)

drop sequence ddef4_seq;
drop table defaulttest;
drop domain ddef1 restrict;
drop domain ddef2 restrict;
drop domain ddef3 restrict;
drop domain ddef4 restrict;
drop domain ddef5 restrict;

Re: Domain Support -- another round

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Rod Taylor wrote:
> Output looks good, but I always got a bunch of NOTICE statements.
> 
> I'll assume the lack of those is related to the logging changes that
> have been going on?

Uh, that is very possible, though the messages would now be INFO
perhaps.  I don't think we actually removed messages in the default
install.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Domain Support -- another round

От:
"Rod Taylor" <rbt@barchord.com>
Дата:
Output looks good, but I always got a bunch of NOTICE statements.

I'll assume the lack of those is related to the logging changes that
have been going on?
--
Rod Taylor

This message represents the official view of the voices in my head

----- Original Message -----
From: "Bruce Momjian" 
To: "Rod Taylor" 
Cc: "Peter Eisentraut" ;

Sent: Monday, March 18, 2002 9:16 PM
Subject: Re: [PATCHES] Domain Support -- another round


>
> Patch applied.  I am attaching the expected/domain.out file that I
> generated when I added your domain test file to the regression
tests.
> Please verify that the output is correct.  Thanks.
>
> --------------------------------------------------------------------
-------
>
> Rod Taylor wrote:
> > New set with most of Peters comments corrected.  Left the deal
about
> > schema though :)  Took nearly an hour to do a cvs diff for some
reason
> > this time (normally a couple of minutes is enough).
> >
> > > Random nitpicking below.  Also, have you created a regression
test?
> >
> > They had been posted a few times and haven't changed.  (Attached
> > anyway)
> >
> >
> > > > +    typnotnull represents a NOT
NULL
> > > > +    constraint on a type.  Normally used only for domains.
> > >
> > > And unnormally...?
> >
> > Unnormally is when someone sets it by hand on a type which isn't a
> > domain -- I guess.  Corrected.
> >
> > > > + 
> > >
> > > I don't see this file included.
> >
> > Other messages.  Full package included on this one however.
> >
> >
> >
> > > > +  * MergeDomainAttributes
> > > > +  *      Returns a new table schema with the constraints,
types,
> > and other
> > > > +  *      attributes of the domain resolved for fields using
the
> > domain as
> > > > +  * their type.
> > >
> > > I didn't know we had schemas yet.  You should probably not
overload
> > that
> > > term to mean "a list of database objects".
> >
> > Merge attributes says something very similar about inheritance and
> > table schemas.  Kinda correct considering
> > the variable used in both cases is *schema.
> >
> >
> > The diff weirdness in regards to DROP DATABASE is probably because
I
> > started by copying the DROP DATABASE element, then altered it.  I
> > don't know why it chose that method to do the diff though, but it
is
> > accurate.  Using -cd flags didn't make it any prettier.
>
> [ Attachment, skipping... ]
>
> [ Attachment, skipping... ]
>
> [ Attachment, skipping... ]
>
> [ Attachment, skipping... ]
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania
19026
>


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


> -- Test Comment / Drop
> create domain domaindroptest int4;
> comment on domain domaindroptest is 'About to drop this..';
> create domain basetypetest domaindroptest;
> ERROR:  DefineDomain: domaindroptest is not a basetype
> drop domain domaindroptest;
> ERROR:  parser: parse error at or near ";"
> drop domain domaindroptest restrict;
> -- TEST Domains.
> create domain domainvarchar varchar(5);
> create domain domainnumeric numeric(8,2);
> create domain domainint4 int4;
> create domain domaintext text;
> -- Test tables using domains
> create table basictest
>            ( testint4 domainint4
>            , testtext domaintext
>            , testvarchar domainvarchar
>            , testnumeric domainnumeric
>            );
> INSERT INTO basictest values ('88', 'haha', 'short',
12');      -- Good
> INSERT INTO basictest values ('88', 'haha', 'short text',
'123.12'); -- Bad varchar
> ERROR:  value too long for type character varying(5)
> INSERT INTO basictest values ('88', 'haha', 'short',
3.1212');    -- Truncate numeric
> select * from basictest;
>  testint4 | testtext | testvarchar | testnumeric
> ----------+----------+-------------+-------------
>  88       | haha     | short       | 123.12
>  88       | haha     | short       | 123.12
> (2 rows)
>
> drop table basictest;
> drop domain domainvarchar restrict;
> drop domain domainnumeric restrict;
> drop domain domainint4 restrict;
> drop domain domaintext restrict;
> -- Array Test
> create domain domainint4arr int4[1];
> create domain domaintextarr text[2][3];
> create table domarrtest
>            ( testint4arr domainint4arr
>            , testtextarr domaintextarr
>             );
> INSERT INTO domarrtest values ('{2,2}', '{{"a","b"}{"c","d"}}');
> INSERT INTO domarrtest values ('{{2,2}{2,2}}', '{{"a","b"}}');
> INSERT INTO domarrtest values ('{2,2}',
'{{"a","b"}{"c","d"}{"e"}}');
> INSERT INTO domarrtest values ('{2,2}', '{{"a"}{"c"}}');
> INSERT INTO domarrtest values (NULL, '{{"a","b"}{"c","d","e"}}');
> drop table domarrtest;
> drop domain domainint4arr restrict;
> drop domain domaintextarr restrict;
> create domain dnotnull varchar(15) NOT NULL;
> create domain dnull    varchar(15) NULL;
> create table nulltest
>            ( col1 dnotnull
>            , col2 dnotnull NULL  -- NOT NULL in the domain cannot be
overridden
>            , col3 dnull    NOT NULL
>            , col4 dnull
>            );
> INSERT INTO nulltest DEFAULT VALUES;
> ERROR:  ExecAppend: Fail to add null value in not null attribute
col1
> INSERT INTO nulltest values ('a', 'b', 'c', 'd');  -- Good
> INSERT INTO nulltest values (NULL, 'b', 'c', 'd');
> ERROR:  ExecAppend: Fail to add null value in not null attribute
col1
> INSERT INTO nulltest values ('a', NULL, 'c', 'd');
> ERROR:  ExecAppend: Fail to add null value in not null attribute
col2
> INSERT INTO nulltest values ('a', 'b', NULL, 'd');
> ERROR:  ExecAppend: Fail to add null value in not null attribute
col3
> INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
> select * from nulltest;
>  col1 | col2 | col3 | col4
> ------+------+------+------
>  a    | b    | c    | d
>  a    | b    | c    |
> (2 rows)
>
> drop table nulltest;
> drop domain dnotnull restrict;
> drop domain dnull restrict;
> create domain ddef1 int4 DEFAULT 3;
> create domain ddef2 oid DEFAULT '12';
> -- Type mixing, function returns int8
> create domain ddef3 text DEFAULT 5;
> create sequence ddef4_seq;
> create domain ddef4 int4 DEFAULT nextval(cast('ddef4_seq' as text));
> create domain ddef5 numeric(8,2) NOT NULL DEFAULT '12.12';
> create table defaulttest
>             ( col1 ddef1
>             , col2 ddef2
>             , col3 ddef3
>             , col4 ddef4
>             , col5 ddef1 NOT NULL DEFAULT NULL
>             , col6 ddef2 DEFAULT '88'
>             , col7 ddef4 DEFAULT 8000
> , col8 ddef5
>             );
> insert into defaulttest default values;
> insert into defaulttest default values;
> insert into defaulttest default values;
> select * from defaulttest;
>  col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8
> ------+------+------+------+------+------+------+-------
>  3    | 12   | 5    | 1    | 3    | 88   | 8000 | 12.12
>  3    | 12   | 5    | 2    | 3    | 88   | 8000 | 12.12
>  3    | 12   | 5    | 3    | 3    | 88   | 8000 | 12.12
> (3 rows)
>
> drop sequence ddef4_seq;
> drop table defaulttest;
> drop domain ddef1 restrict;
> drop domain ddef2 restrict;
> drop domain ddef3 restrict;
> drop domain ddef4 restrict;
> drop domain ddef5 restrict;
>

Re: Domain Support -- another round

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
I've committed a bunch of changes after code review of your DOMAIN
patch.  There were a number of minor bugs as well as some stylistic
things I didn't like.

Probably the largest change was that I concluded we had to revert the
handling of default values for base types to the old way: simple literal
stored as a string.  You can't meaningfully deal with an expression that
represents a value of a type you haven't defined yet --- since you
surely haven't defined any functions or operators that yield it, either.
Therefore the apparent flexibility is illusory.  Also, the code just
plain didn't work: after I fixed preptlist.c to do what it should be
doing, I was getting "can't coerce" failures in the create_type
regression test.  (For example, it didn't believe that an int4 literal
"42" was a valid default for the test's type int42, which is correct
given that the test doesn't define any conversion function...)  So all
in all I just don't see any way that can work.  I've set it up so that
you can have *either* an expression default (if typdefaultbin is not
null) *or* a simple literal default (if typdefaultbin is null but
typdefault isn't).  The former case will work for domains, the latter
for base types.

There are still some things that need to be worked on:

1. pg_dump.  We *cannot* release this feature in 7.3 if there's not
pg_dump support for it.

2. Arrays.  I don't much care for the fact that arrays of domain-type
values aren't supported.  The handling of domains that are themselves
arrays seems a tad odd as well: the array-ish nature of the domain is
exposed, which doesn't make a lot of sense to me.  Perhaps we'd be
better off to forbid array domains.

3. Domains on domains.  Why shouldn't I be able to make a domain that's
a further restriction of another domain?

4. CHECK constraints for domains (which after all is the real point,
no?)

			regards, tom lane

Re: Domain Support -- another round

От:
Fernando Nasser <fnasser@redhat.com>
Дата:
Tom Lane wrote:
> 
> 2. Arrays.  I don't much care for the fact that arrays of domain-type
> values aren't supported.  The handling of domains that are themselves
> arrays seems a tad odd as well: the array-ish nature of the domain is
> exposed, which doesn't make a lot of sense to me.  Perhaps we'd be
> better off to forbid array domains.
> 

From SQL99 11.23 Syntax Rule 6)

" should not specify a reference type, user-defined type,
or an array type."
      ==========

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

Re: Domain Support -- another round

От:
"Rod Taylor" <rbt@zort.ca>
Дата:
> There are still some things that need to be worked on:
>
> 1. pg_dump.  We *cannot* release this feature in 7.3 if there's not
> pg_dump support for it.

I intend to try to do this next week.

> 2. Arrays.  I don't much care for the fact that arrays of
domain-type
> values aren't supported.  The handling of domains that are
themselves
> arrays seems a tad odd as well: the array-ish nature of the domain
is
> exposed, which doesn't make a lot of sense to me.  Perhaps we'd be
> better off to forbid array domains.

The reason I didn't make array types for domains is that I have
absolutly no idea how to manage the below case once point 4 is
implemented.

create domain dom as int4 check (VALUE > 5);
create table tab (col1 dom[2][3]);


> 3. Domains on domains.  Why shouldn't I be able to make a domain
that's
> a further restriction of another domain?

Not entirely sure, except the book I had (SQL99 Complete, Really)
specifically forbids it.

> 4. CHECK constraints for domains (which after all is the real point,
> no?)

Yes, I'm slow and only capable of one step at a time.  Foreign key
constraints are the other real point.

Re: Domain Support -- another round

От:
Fernando Nasser <fnasser@redhat.com>
Дата:
Rod Taylor wrote:
> 
> > 2. Arrays.  I don't much care for the fact that arrays of
> domain-type
> > values aren't supported.  The handling of domains that are
> themselves
> > arrays seems a tad odd as well: the array-ish nature of the domain
> is
> > exposed, which doesn't make a lot of sense to me.  Perhaps we'd be
> > better off to forbid array domains.
> 
> The reason I didn't make array types for domains is that I have
> absolutly no idea how to manage the below case once point 4 is
> implemented.
> 
> create domain dom as int4 check (VALUE > 5);
> create table tab (col1 dom[2][3]);
> 

SQL'99 explicitly forbids it.  Please refer to my posting to HACKERS
for the SQL document reference.



> > 3. Domains on domains.  Why shouldn't I be able to make a domain
> that's
> > a further restriction of another domain?
> 
> Not entirely sure, except the book I had (SQL99 Complete, Really)
> specifically forbids it.
> 

Yes, but this is their interpretation of the standard. There is an
error in that page anyway, as the standard explicitly forbids 
arrays and UDTs and they list REF and ARRAY as valid data types.
(they also get confused with SESSION_USER and CURENT_USER on page
281, so it does not surprise me). 

I couldn't find anything in the standard explicitly forbidden it.
But I don't think this is a very useful feature anyway.  As one is
creating another domain, he /she can as well specify constraints
that represent a further reduction of the valid values range.



-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

Re: Domain Support -- another round

От:
Thomas Lockhart <thomas@fourpalms.org>
Дата:
> SQL'99 explicitly forbids it.  Please refer to my posting to HACKERS
> for the SQL document reference.

The fact that a standard "forbids" something does not necessarily mean
it is a bad idea, as I'm sure you know. Is there any reason that the
standard forbids using domains inside arrays, other than someone on the
standards committee realized that it would be hard for their company to
implement it? That is, does allowing domains in arrays lead to
inconsistancies or fundamental issues with relational algebra or other
set logic that should keep it out of the next set of standards?

If Postgres was developed to only the current standard, it would never
have been written. And since the start of the open source days, if we
had worked solely to get it to conform to the current standard we'd be
starting at ground zero for implementing SQL99, since many of our
features now appear in that standard. Someone cheated and looked at what
we could already do... ;)

                     - Thomas

Re: Domain Support -- another round

От:
Fernando Nasser <fnasser@redhat.com>
Дата:
Thomas Lockhart wrote:
> 
> > SQL'99 explicitly forbids it.  Please refer to my posting to HACKERS
> > for the SQL document reference.
> 
> The fact that a standard "forbids" something does not necessarily mean
> it is a bad idea, as I'm sure you know. Is there any reason that the
> standard forbids using domains inside arrays, other than someone on the
> standards committee realized that it would be hard for their company to
> implement it? That is, does allowing domains in arrays lead to
> inconsistancies or fundamental issues with relational algebra or other
> set logic that should keep it out of the next set of standards?
> 

I partially agree, but I guess Tom has already given some of the reasons
not to do it.


> If Postgres was developed to only the current standard, it would never
> have been written. And since the start of the open source days, if we
> had worked solely to get it to conform to the current standard we'd be
> starting at ground zero for implementing SQL99, since many of our
> features now appear in that standard. Someone cheated and looked at what
> we could already do... ;)
> 

Again, I only partially agree with that,  Adding significant features
that 
will allow people to solve significantly different problems that can not
be solved with the vanilla standard is a good think.  And I believe it
is
acknowledged in many places that many SQL3 features were inspired on
Postgres.

However, adding extensions to the SQL standard otherwise is a bad thing.
If affects portability.  Actually, "extending" standards has been a
weapon
used by some proprietary companies to hurt the competition.  Standards
are
friends of Open Source software and we should try to stick to them 
whenever possible.

In the case of DOMAINS, which are already considered by some as not very
useful and passive of removal from next editions of the standard (by one
SQL editor, at least -- I can give you the book reference this
afternoon),
adding extension to the SQL to it would just aggravate the issue.

So, although I agree with you in principle, I believe that in these
cases
we should stick to the standard and avoid gratuitous extensions.


-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

Re: Domain Support -- another round

От:
Thomas Lockhart <thomas@fourpalms.org>
Дата:
...
> So, although I agree with you in principle, I believe that in these
> cases we should stick to the standard and avoid gratuitous extensions.

Hmm. In any case, supporting arrays (esp. if it is not allowed in the
standard) should not be a requirement for implementing the DOMAIN
functionality. No point in arguing principles on just, uh, principles,
when we could actually be getting something good done ;)

                    - Thomas

Re: Domain Support -- another round

От:
Fernando Nasser <fnasser@redhat.com>
Дата:
Thomas Lockhart wrote:
> 
> ...
> > So, although I agree with you in principle, I believe that in these
> > cases we should stick to the standard and avoid gratuitous extensions.
> 
> Hmm. In any case, supporting arrays (esp. if it is not allowed in the
> standard) should not be a requirement for implementing the DOMAIN
> functionality. No point in arguing principles on just, uh, principles,
> when we could actually be getting something good done ;)
> 

I couldn't agree more.

Cheers,
Fernando

-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9
FAQ