X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 812059DCC1F for ; Sun, 11 Dec 2005 19:52:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64549-01 for ; Sun, 11 Dec 2005 19:52:38 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) by postgresql.org (Postfix) with ESMTP id 488619DCAC3 for ; Sun, 11 Dec 2005 19:52:32 -0400 (AST) Received: from [192.168.1.103] (cpe-024-211-165-134.nc.res.rr.com [24.211.165.134]) (authenticated (0 bits)) by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id jBC0A6Z28111; Sun, 11 Dec 2005 18:10:06 -0600 Message-ID: <439CBBC1.2030700@dunslane.net> Date: Sun, 11 Dec 2005 18:52:33 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Carlos Moreno CC: pgsql-hackers@postgresql.org Subject: Re: Please Help: PostgreSQL Query Optimizer References: <200512111126.18566.josh@agliodbs.com> <439CAE4D.2030208@mochima.com> In-Reply-To: <439CAE4D.2030208@mochima.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/572 X-Sequence-Number: 77420 Actually, there is probably comparatively little to gain from making it a builtin. And SHA1 is already there in the pgcrypto contrib module. Presumably if we wanted a builtin we would start from that code base. cheers andrew Carlos Moreno wrote: > > Hi, > > I'm very new to this list -- I've been using and advocating PostgreSQL > for > no less than 4 or 5 years now, and have participated in some of the other > mailing lists, but never on this one. > > My question is (short version): how would one go about adding a new > (built-in) function to PostgreSQL? > > Long-ish version: > > I know the answer "in theory" -- one goes through the source code, find > out how it all works, and modify/add the code to add or fix whatever > feature we want. > > I guess my point in here would be rather a "feature request" -- except > that I'd find it pretty exciting to implement it myself, and then propose > the new feature by volunteering the implementation that I already wrote > (seems like the spirit of open-source communities, right?) -- then of > course, it would be subject to consensus, whether or not the feature > makes sense and the implementation is good enough. > > I'm interested in adding additional hash functions -- PG supports, as > part > of the built-in SQL functions, MD5 hashing. So, for instance, I can > simply > type, at a psql console, the following: > > select md5('abc'); > > My "feature request" (which again, I'd like to implement it myself) would > be the ability to do: > > select sha1('xyz'), sha256('etc'); > > (At least these two -- maybe for completeness it would be good to have > sha224, 384, and 512, but I guess SHA1 and SHA-256 would be a very good > and sound starting point) > > So, can you offer some advice or pointers on how to go about that? > > I started by doing a search for the string md5 through all the source > code -- the problem is, md5 shows up in many many many places (it is > part of the authentication protocol, among other things), so I got a > little bit lost searching through it all. > > I wonder if you have some documents specifically aimed at providing > advice and documentation for prospective developers (or for people > that want to "tweak" the source code to fix/tuneup or add functionality), > I guess that would be great for me in this case. > >