Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-08 Thread elein
On Thu, Sep 07, 2006 at 07:12:17PM -0700, Josh Berkus wrote: Elein, I may have missed some stuff here. Obviously.  For example how to divide and conquer the various aspects of the issues raised here. But this is a high, high level proposal at this time. I'm not quite clear on what in

Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-08 Thread Tom Lane
elein [EMAIL PROTECTED] writes: Domains and subtypes. * Create new child type from values in parent type. * Maintain only checks for constraints * Create implicit casts from child to parent This seems a bit content-free, because it's not clear how it differs from what we do now. We

Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-08 Thread elein
On Fri, Sep 08, 2006 at 02:33:13PM -0400, Tom Lane wrote: elein [EMAIL PROTECTED] writes: Domains and subtypes. * Create new child type from values in parent type. * Maintain only checks for constraints * Create implicit casts from child to parent This seems a bit

Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-08 Thread Tom Lane
elein [EMAIL PROTECTED] writes: a) if subtypes/domains can have constraints then the model should not be different for domains only but for all types. Constraint checking would only occur at check constraint points--and there for any type. You already check for the existance of

Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-08 Thread elein
On Fri, Sep 08, 2006 at 03:47:23PM -0400, Tom Lane wrote: elein [EMAIL PROTECTED] writes: a) if subtypes/domains can have constraints then the model should not be different for domains only but for all types. Constraint checking would only occur at check constraint points--and

Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-08 Thread Tom Lane
elein [EMAIL PROTECTED] writes: I think what you are saying is that the domain checking (proposed constraint existence checking) would need to be done in more places and I'm not sure I understand this. What I'm complaining about is the need to search the catalogs to see if a datatype has

Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-08 Thread elein
On Fri, Sep 08, 2006 at 05:20:18PM -0400, Tom Lane wrote: elein [EMAIL PROTECTED] writes: I think what you are saying is that the domain checking (proposed constraint existence checking) would need to be done in more places and I'm not sure I understand this. What I'm complaining about

[HACKERS] Domains and subtypes, a brief proposal

2006-09-07 Thread elein
As many of you know I've been contemplating the implementation of Domains and subtypes. DISCLAIMER: This is a proposal only. The actual work needs to be picked up by someone in a better place to work on the code than I am. For various reasons, I can only be an active reference and tester on

Re: [HACKERS] Domains and subtypes, a brief proposal

2006-09-07 Thread Josh Berkus
Elein, I may have missed some stuff here. Obviously.  For example how to divide and conquer the various aspects of the issues raised here. But this is a high, high level proposal at this time. I'm not quite clear on what in your proposal is different from current Domain behavior. Or are you

Re: [HACKERS] Domains as Subtypes

2006-04-10 Thread Bruce Momjian
TODO has: * Allow user-defined functions retuning a domain value to enforce domain constraints Is there something we should add to this? --- Tom Lane wrote: elein [EMAIL PROTECTED] writes: On Mon, Mar

Re: [HACKERS] Domains as Subtypes

2006-04-10 Thread Tom Lane
Bruce Momjian pgman@candle.pha.pa.us writes: TODO has: * Allow user-defined functions retuning a domain value to enforce domain constraints Is there something we should add to this? Yeah, a DONE marker ;-) regards, tom lane

Re: [HACKERS] Domains as Subtypes

2006-04-10 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian pgman@candle.pha.pa.us writes: TODO has: * Allow user-defined functions retuning a domain value to enforce domain constraints Is there something we should add to this? Yeah, a DONE marker ;-) OK, marked as done. I assume that's what you mean,

Re: [HACKERS] Domains as Subtypes

2006-03-27 Thread Tom Lane
elein [EMAIL PROTECTED] writes: But I like the idea of centralizing the check in the input/output functions. It seems clearer and cleaner. I remembered the problem with doing it that way: an input function can't enforce a domain NOTNULL constraint, because it won't even get invoked for a null

Re: [HACKERS] Domains as Subtypes

2006-03-27 Thread elein
On Mon, Mar 27, 2006 at 11:41:30AM -0500, Tom Lane wrote: elein [EMAIL PROTECTED] writes: But I like the idea of centralizing the check in the input/output functions. It seems clearer and cleaner. I remembered the problem with doing it that way: an input function can't enforce a domain

Re: [HACKERS] Domains as Subtypes

2006-03-27 Thread Tom Lane
elein [EMAIL PROTECTED] writes: On Mon, Mar 27, 2006 at 11:41:30AM -0500, Tom Lane wrote: I remembered the problem with doing it that way: an input function can't enforce a domain NOTNULL constraint, because it won't even get invoked for a null input value. So there seems no way around having

Re: [HACKERS] Domains as Subtypes

2006-03-25 Thread Jim C. Nasby
On Fri, Mar 24, 2006 at 10:49:00PM -0500, Tom Lane wrote: Josh Berkus josh@agliodbs.com writes: grin you missed one. Domains as parameters to functions are not enforced. I think we've got that one actually. It's domains as PL-function output types that aren't checked. Also plpgsql

Re: [HACKERS] Domains as Subtypes

2006-03-25 Thread Tom Lane
Jim C. Nasby [EMAIL PROTECTED] writes: On Fri, Mar 24, 2006 at 10:49:00PM -0500, Tom Lane wrote: I think we've got that one actually. It's domains as PL-function output types that aren't checked. Also plpgsql fails to enforce domain checks on its local variables. So is this the complete

Re: [HACKERS] Domains as Subtypes

2006-03-25 Thread Jim Nasby
On Mar 25, 2006, at 4:14 PM, Tom Lane wrote: Jim C. Nasby [EMAIL PROTECTED] writes: On Fri, Mar 24, 2006 at 10:49:00PM -0500, Tom Lane wrote: I think we've got that one actually. It's domains as PL-function output types that aren't checked. Also plpgsql fails to enforce domain checks on

Re: [HACKERS] Domains as Subtypes

2006-03-25 Thread elein
On Sat, Mar 25, 2006 at 07:16:13PM +0100, Jim Nasby wrote: On Mar 25, 2006, at 4:14 PM, Tom Lane wrote: Jim C. Nasby [EMAIL PROTECTED] writes: On Fri, Mar 24, 2006 at 10:49:00PM -0500, Tom Lane wrote: I think we've got that one actually. It's domains as PL-function output types that

[HACKERS] Domains as Subtypes

2006-03-24 Thread elein
Background: Domains lay the groundwork for inherited basetypes or subtypes. By defining a domain and overriding operators and possibly creating an operator class, then a domain can be created which inherits the storage method and all of the functions of a basetype. The domain constraint

Re: [HACKERS] Domains as Subtypes

2006-03-24 Thread Tom Lane
elein [EMAIL PROTECTED] writes: Attached is a patch to parse_oper.c which essentially does the following. The major change is in binary_oper_exact(). Instead of checking only one level of the basetype it checks all possible combinations of type and parent types for an exact match (only).

Re: [HACKERS] Domains as Subtypes

2006-03-24 Thread elein
On Fri, Mar 24, 2006 at 03:47:13PM -0500, Tom Lane wrote: elein [EMAIL PROTECTED] writes: Attached is a patch to parse_oper.c which essentially does the following. The major change is in binary_oper_exact(). Instead of checking only one level of the basetype it checks all possible

Re: [HACKERS] Domains as Subtypes

2006-03-24 Thread elein
On Fri, Mar 24, 2006 at 08:33:51PM +0100, Peter Eisentraut wrote: elein wrote: Domains lay the groundwork for inherited basetypes or subtypes. Semantically, a domain and a subtype are completely different things. A domain restricts the possible values of a type but behaves exactly like

Re: [HACKERS] Domains as Subtypes

2006-03-24 Thread Tom Lane
elein [EMAIL PROTECTED] writes: Operators have the single distinction from functions in that when one argument has an unknown type, then an exact match is tried with the unknown arg type set to the known type. This code has always been in there. Yeah, but it's just a fast special case of the

Re: [HACKERS] Domains as Subtypes

2006-03-24 Thread elein
On Fri, Mar 24, 2006 at 06:27:13PM -0500, Tom Lane wrote: elein [EMAIL PROTECTED] writes: Operators have the single distinction from functions in that when one argument has an unknown type, then an exact match is tried with the unknown arg type set to the known type. This code has

Re: [HACKERS] Domains as Subtypes

2006-03-24 Thread Josh Berkus
Elein, Domains enable people to create basetype subtypes using SQL and procedural languages only.  Current belief is that this doesn't work.  However, all of this has worked since domains were implemented with three exceptions. grin you missed one. Domains as parameters to functions are not

Re: [HACKERS] Domains as Subtypes

2006-03-24 Thread Tom Lane
Josh Berkus josh@agliodbs.com writes: grin you missed one. Domains as parameters to functions are not enforced. I think we've got that one actually. It's domains as PL-function output types that aren't checked. Also plpgsql fails to enforce domain checks on its local variables.