Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 985282E381F for ; Sat, 8 Dec 2007 15:14:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 76148-01 for ; Sat, 8 Dec 2007 15:13:58 -0400 (AST) Received: from dukecmmtar02.coxmail.com (dukecmmtar02.coxmail.com [68.99.120.49]) by postgresql.org (Postfix) with ESMTP id BFB0C2E38BE for ; Sat, 8 Dec 2007 15:11:32 -0400 (AST) Received: from [127.0.0.1] (really [70.166.0.90]) by dukecmmtar02.coxmail.com (InterMail vM.6.01.06.01 201-2131-130-101-20060113) with ESMTP id <20071208183213.HOBF1201.dukecmmtar02.coxmail.com@[127.0.0.1]>; Sat, 8 Dec 2007 13:32:13 -0500 Message-ID: <475AE32C.9040201@acm.org> Date: Sat, 08 Dec 2007 10:32:12 -0800 From: TJ O'Donnell User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Tom Lane CC: PostgreSQL - SQL Subject: Re: polymorphic functions and domains References: <47584418.1020204@acm.org> <5167.1196988696@sss.pgh.pa.us> In-Reply-To: <5167.1196988696@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/25 X-Sequence-Number: 29717 I'm not sure I can propose a scheme that would work in all situations, but one could simply considered the built-in data type underlying the domain. In my case, this would mean deciding between character varying and bytea, which seems to work just fine. As far as surprising behavior, isn't the scheme for casting literals already prone to surprises? TJ Tom Lane wrote: > "TJ O'Donnell" writes: >> I really want two polymorphic functions, one taking >> a domain data type using varchar and one bytea. > > These aren't polymorphic functions, actually; they're just overloaded. > >> In that case, postgres complains that it cannot decide >> which one to use when called with the >> untyped literal 'abc'. > > Yeah, functions taking domains as arguments are problematic. I believe > that with the current resolution rules, a function taking a domain can > only "win" an ambiguous-function comparison if it's an exact match > to the input types --- which in this case means you have to cast the > literal to the domain type. > > There's been some talk of trying to rejigger the resolution rules to > make them more friendly to functions that're declared to take domains, > but no one's put forward any concrete proposal. It's not at all clear > to me how to do it without introducing a lot of surprising behavior :-( > > regards, tom lane