agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] VarLenTuple example code
Date: Fri, 29 Sep 2006 12:14:41 +0200
Message-ID: <451CF211.7000000@logix-tt.com> (raw)
In-Reply-To: <451BF32A.7000405@tada.se>
References: <451BD0B1.8000408@logix-tt.com>
	<451BD2F4.60202@tada.se>
	<451BD650.2080201@logix-tt.com>
	<451BDB5E.1020107@tada.se>
	<451BE12B.6060809@logix-tt.com>
	<451BF32A.7000405@tada.se>

Hi, Thomas,

Let's recall the 4 representations I enumerated:

A) the "canonical text representation"
B) the "canonical binary representation"
C) the "internal" representation
D) Java Objects.

Thomas Hallgren wrote:

> No. Just one SQLData implementation per type. The parameter to
> readSQL should be an SQLInput wrapping the exact bytes that you would
> expect to be the parameter to the receive function. The writeSQL will
> create the bytes that would otherwise be be created by the send
> function.

Ok, so then the writeSQL and readSQL are meant to convert between the
representations B and D.

From the examples and some points of our discussion, I had the
impression they should convert between C and D.

> Normally when you create a type in PostgreSQL you'd create four
> functions in C. Now you create four methods in Java instead:
> 
> input -> parse 
> output -> toString
> receive -> readSQL
> send -> writeSQL

Yes. Those four functions, as I understand it, do the following
representation conversions:

input:    A -> C
output:   C -> A
receive:  B -> C
send:     C -> B

The java methods should do the following tasks:

parse:    A -> D
toString: D -> A
readSQL:  B -> A & C -> A
writeSQL: A -> B & A -> D

The whole thing only makes sense for me under the assumption that the
representations B and C are identical.

But having them different is the whole point of why explicit send/
receive functions were invented in PostgreSQL, IIRC.

They are not equal for all PostgreSQL numerical datatypes I checked in
source, those convert to network byte order in send(), and back to
platform in receive().

The same is for PostGIS, which uses a compatible extension of the
OpenGIS defined "Well Known Binary" standard format for B, and an
optimized format in platform endiannes that tends to change between
major releases for C.


Thanks,
Markus
-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org




view thread (18+ messages)  latest in thread

Message-ID: <451CF211.7000000@logix-tt.com>
Permalink:  ../451CF211.7000000@logix-tt.com/
Also on:    postgresql.org/message-id/451CF211.7000000@logix-tt.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 using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] VarLenTuple example code
  In-Reply-To: <451CF211.7000000@logix-tt.com>

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

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