X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5481532BA80 for ; Thu, 14 Oct 2004 11:56:16 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48838-09 for ; Thu, 14 Oct 2004 10:56:08 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 3A7B532B2B5 for ; Thu, 14 Oct 2004 11:56:08 +0100 (BST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1CI3HA-0000dg-00; Thu, 14 Oct 2004 23:56:04 +1300 Message-ID: <416E5B40.1060901@opencloud.com> Date: Thu, 14 Oct 2004 23:56:00 +1300 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kris Jurka Cc: "pgsql-jdbc@postgresql.org" Subject: Re: tightening up on use of oid 0 References: <41660A56.5000107@opencloud.com> <4167BC1A.4070809@opencloud.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/146 X-Sequence-Number: 11251 Kris Jurka wrote: > I was looking at the assorted changes to the PGobject extensions and I'm > unclear on exactly how NULL is handled. Consider PGmoney has tests for > NULL in equals, clone, and getValue, but PGbox does not. Is this simply > an oversight or is there something more profound going on here. I ended up with two approaches for this. For those types where there was already a field I could hijack to represent NULL -- e.g. PGbox's points array -- I used that to represent null values. The singleton NULL is just a normal object that happens to have a null value. You can have several different objects that all represent null if you like, and you can mutate an object representing a null value just like any other object of the type. This is consistent with the way other instances of the type operate, but it's slightly dangerous as it's possible to modify the NULL singleton so it no longer has a null value (pity we don't have 'const'..) For the other types that didn't have a suitable field, I'd have needed to add a field to every instance of the type to indicate whether the object was a null or not. Instead, I used the identity of the NULL singleton to decide when an object is null. In that case, there is only ever one object that represents a null, and the actual value it holds is irrelevant -- getValue() etc. check the identity of 'this' before looking at the actual value. It's hardly ideal but it kept the changes to a minimum. If you don't mind a more invasive set of changes, I can probably come up with something better. -O