X-Original-To: pgadmin-support-postgresql.org@localhost.postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id EC2ACB439B6 for ; Tue, 8 Jul 2003 21:05:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 50031-09 for ; Tue, 8 Jul 2003 18:05:13 -0300 (ADT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by svr1.postgresql.org (Postfix) with ESMTP id 5D176B438A2 for ; Tue, 8 Jul 2003 18:05:13 -0300 (ADT) Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 19ZzeE-0006yV-00; Tue, 08 Jul 2003 23:05:14 +0200 Received: from [80.129.130.245] (helo=pse-consulting.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 19ZzeE-0001Uu-00; Tue, 08 Jul 2003 23:05:14 +0200 Message-ID: <3F0B3210.1080508@pse-consulting.de> Date: Tue, 08 Jul 2003 23:05:20 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Donald Fraser Cc: "[pgADMIN]" Subject: Re: Overloading functions that are used by operators. References: <00c801c3458b$8c139490$1664a8c0@DEMOLITION> In-Reply-To: <00c801c3458b$8c139490$1664a8c0@DEMOLITION> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/70 X-Sequence-Number: 1670 Donald Fraser wrote: > I have a question regarding operators which are causing problems with > the new pgAdmin III software being developed and my database. > The problem has been discussed in depth with the pgAdmin III > development team and they have not been able to resolve the issue and > suggested that I have either done something that I shouldn't have of > or that there is a possible bug with postgresql. > > Background information: > I have my own data type ('citext') that uses many of the built-in > system functions based on the fact that the storage is identical to > the data type 'text'. > For example I have overloaded the function 'textcat' and the > definition I have used is: > CREATE FUNCTION pg_catalog.textcat(citext, citext) RETURNS citext AS > 'textcat' LANGUAGE 'internal' IMMUTABLE STRICT; > When you view the functions via the pg_proc table you will see that > there are two functions with 'textcat' in the column pg_proc.proname. > I have been using the database for over a year and had no reported > problems with using the operator || on data types 'text', 'varchar', > 'bpchar' or calling the overloaded function 'textcat(citext, citext)'. > > First question: > Am I allowed to overload functions, for example the > 'textcat' function, when they are being used by system operators? > > If the answer is no then read no further - the problem is mine and I > will have to work around it. > > The system has at least three operators such as: > ||(text,text) > ||(varchar, text) > ||(bpchar, text) > All use the function 'textcat'. > > Now the new pgAdmin III software interrogates the pg_operator table to > extract as much information as possible about the operators. > They are using the following SQL statement to retrieve the information > that they want. > > SELECT op.oid, op.oprname, pg_get_userbyid(op.oprowner) as opowner, > op.oprkind, op.oprcanhash, > op.oprleft, op.oprright, > lt.typname as lefttype, > rt.typname as righttype, > et.typname as resulttype, > co.oprname as compop, > ne.oprname as negop, > lso.oprname as leftsortop, > rso.oprname as rightsortop, > lco.oprname as lscmpop, > gco.oprname as gtcmpop, > po.proname as operproc, > pj.proname as joinproc, > pr.proname as restrproc, > description > FROM pg_operator op > JOIN pg_type lt ON lt.oid=op.oprleft > JOIN pg_type rt ON rt.oid=op.oprright > JOIN pg_type et on et.oid=op.oprresult > LEFT OUTER JOIN pg_operator co ON co.oid=op.oprcom > LEFT OUTER JOIN pg_operator ne ON ne.oid=op.oprnegate > LEFT OUTER JOIN pg_operator lso ON lso.oid=op.oprlsortop > LEFT OUTER JOIN pg_operator rso ON rso.oid=op.oprrsortop > LEFT OUTER JOIN pg_operator lco ON lco.oid=op.oprltcmpop > LEFT OUTER JOIN pg_operator gco ON gco.oid=op.oprgtcmpop > JOIN pg_proc po ON po.oid=op.oprcode > LEFT OUTER JOIN pg_proc pr ON pr.oid=op.oprrest > LEFT OUTER JOIN pg_proc pj ON pj.oid=op.oprjoin > LEFT OUTER JOIN pg_description des ON des.objoid=op.oid > WHERE op.oprnamespace = 2200::oid > ORDER BY op.oprname > > The offending part of this SQL statement is the join: > JOIN pg_proc po ON po.oid=op.oprcode > > It produces the error message "ERROR: There is more than one procedure > named textcat". > Investigation into this has shown that the type conversion of the > column named pg_operator.oprcode to type oid is done by the function > call to: > regprocin('textcat') > My question would be - what is the correct way to find the function's > oid that this operator uses? But first read on in case it is not > necessary... > It seems to me that the join statements they are using are unnecessary > so long as the column pg_operator.oprcode has the identical name to > its matching function that has its name defined by column > pg_proc.proname, which seems to be the only data that they are using. > > On a similar basis, do the columns named pg_operator.oprjoin and > pg_operator.oprrest have identical names defined by the column > pg_proc.proname for which they are also retrieving? If so then those > corresponding joins are also unnecessarily. > Donald, we discussed that this should go to pgsql-bugs, not any admin list. While there might be some question if joining pg_proc to pg_type is necessary for pgAdmin3, but it's certainly legal to query which pg_proc is used for a type. The underlying question for your case is whether it's allowed to create overloaded functions of a function that's used for a type. regprocin will not like this, so CREATE TYPE should deny creation if input or output function isn't unique by name. Regards, Andreas