Search Postgresql Archives

Re: lack of consequence with domains and types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 24, 2008 at 6:41 PM, Erik Jones <ejones@xxxxxxxxxxxxxx> wrote:>> On Dec 24, 2008, at 12:04 PM, Grzegorz Jaśkiewicz wrote:>>> On Wed, Dec 24, 2008 at 6:12 PM, Erik Jones <ejones@xxxxxxxxxxxxxx> wrote:>>>>>> Yes, and columns have default values, too, which are not tied to their>>> datatype's default value (if it even has one).  ALTER TABLE initializes>>> rows>>> to have the new *column's* default.  A column of some domain type could>>> easily have some default other than the domain's default and, in fact, if>>> you don't specify a default for the column then it's default is NULL.>>>> the whole thing about domains, is that you specify type and default,>> and even check constraint. And I did specify default - hence I would>> expect it to be set to that value!!>> You really need to understand the difference between a domain's default and> a column's default.  The ALTER TABLE docs specifically say that if you don't> specify a default for the new *column* then that column is set to NULL for> all rows.  That is not the same as not providing a value for a column of> some  domain type with a default in an INSERT statement.  A domain with a> default does not specify that it can not be set to null:
I disagree.  It's quite natural and reasonable to have defaults passedthrough the composite type as the OP expects.  This is a possibleimprovement (TODO?) in the way composite types are handled.  There area couple of other loopholes in domans/composite types:
* domains can't be stacked in an array (but you can if they arewrapped in a composite type)* check constraints not enforced for composite type on cast (but arefor domains)* alter type should be expanded to allow things that are currentlypossible via alter table (currently a TODO, IIRC), or createtable/alter table should be adjusted for better handling of types, and'create type as' should be deprecated.  The latter is what I thinkshould happen, but it's controversial :-).
In the meantime the OP has to decide what he wants to use more,composite types or default values on domains.
merlin
-- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux