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: PGobject overhaul (was Re: tightening up on use of oid 0)
Date: Thu, 28 Oct 2004 15:18:13 +1300
Message-ID: <418056E5.9060601@opencloud.com> (raw)
In-Reply-To: <Pine.BSO.4.56.0410140606380.31883@leary.csoft.net>
References: <41660A56.5000107@opencloud.com>
	<4167BC1A.4070809@opencloud.com>
	<Pine.BSO.4.56.0410140523520.31883@leary.csoft.net>
	<416E5B40.1060901@opencloud.com>
	<Pine.BSO.4.56.0410140606380.31883@leary.csoft.net>

Kris Jurka wrote:
> 
> On Thu, 14 Oct 2004, Oliver Jowett wrote:
>   [... PGobject and NULL ...]
>>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.
> 
> Yes, let's think about this a little more.  I unfortunately don't have any 
> brilliant ideas, perhaps just adding a boolean everywhere is simplest.

I've applied the non-PGobject bits of this patch.

For PGobject it turned into a bit of a general overhaul. Currently I have:

PGobject layer:

- PGobject becomes an interface
- Implementations of PGobject should provide a ctor taking a single 
String; this is called by the driver to construct non-null objects.
- PGobject.setType() and PGobject.setValue() go away entirely
- A new helper class, PGunknown, provides an immutable type+value 
implementation of PGobject (i.e. 'new PGunknown("mytype","myvalue")'). 
This gives the functionality currently available via PGobject.setType() 
/ setValue, and is used by the driver when it receives an unhandled type 
in a resultset.

PGobject subclasses:

Mutability:
- Generally, classes become immutable where it's easy to do (PGmoney, 
PGinterval, PGpoint, PGline, PGlseg, PGcircle, PGbox)
- PGpoint.translate() returns a new PGpoint rather than modifying the 
existing point (I'm not sure why this method even exists really..)
- Constant-sized PGpoint[] arrays in PGline, PGlseg, PGbox become 
separate fields; this makes immutability much easier.
- PGpolygon and PGpath remain mutable as it's hard to make them 
immutable without incurring lots of array copies.

NULL-handling:
- No-arg ctors construct NULL objects.
- PGmoney and PGpoint get boolean isNull fields, the other types reuse 
an existing reference field.
- equals(), hashCode(), getValue() take account of NULL-ness.
- Add per-class static NULL singleton fields for convenience; for 
mutable types, I'm not sure whether to just omit the singletons 
(slightly less convenient/readable), or to use PGunknown to get an 
immutable NULL (works, but 'instanceof' on NULL becomes misleading).

Much of the mutability changes here are just personal preference, 
they're not necessary to support NULLs but I thought I'd clean things up 
while I was in the area.

When we come to do binary-format types, I'd expect we would have a 
subinterface (PGbinaryobject?) that adds whatever methods are needed for 
binary parameter formatting. Objects that implement PGbinaryobject 
become candidates for binary transfer.

Any thoughts on this general approach?

-O



view thread (5+ messages)  latest in thread

Message-ID: <418056E5.9060601@opencloud.com>
Permalink:  ../418056E5.9060601@opencloud.com/
Also on:    postgresql.org/message-id/418056E5.9060601@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: PGobject overhaul (was Re: tightening up on use of oid 0)
  In-Reply-To: <418056E5.9060601@opencloud.com>
  References: <41660A56.5000107@opencloud.com> <4167BC1A.4070809@opencloud.com> <Pine.BSO.4.56.0410140523520.31883@leary.csoft.net> <416E5B40.1060901@opencloud.com> <Pine.BSO.4.56.0410140606380.31883@leary.csoft.net> <418056E5.9060601@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