pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: tightening up on use of oid 0
Date: Thu, 14 Oct 2004 23:56:00 +1300
Message-ID: <416E5B40.1060901@opencloud.com> (raw)
In-Reply-To: <Pine.BSO.4.56.0410140523520.31883@leary.csoft.net>
References: <41660A56.5000107@opencloud.com>
	<4167BC1A.4070809@opencloud.com>
	<Pine.BSO.4.56.0410140523520.31883@leary.csoft.net>

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



view thread (20+ messages)  latest in thread

Message-ID: <416E5B40.1060901@opencloud.com>
Permalink:  ../416E5B40.1060901@opencloud.com/
Also on:    postgresql.org/message-id/416E5B40.1060901@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, books@ejurka.com
  Subject: Re: tightening up on use of oid 0
  In-Reply-To: <416E5B40.1060901@opencloud.com>
  References: <41660A56.5000107@opencloud.com> <4167BC1A.4070809@opencloud.com> <Pine.BSO.4.56.0410140523520.31883@leary.csoft.net> <416E5B40.1060901@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox