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

Markus Schaber wrote:
> Hi, Thomas,
> 
> Thomas Hallgren wrote:
> 
>> No, in that case you must have misunderstood. When you do that, you
>> remove the middleman that sets up the correct SQLData semantics. The
>> send/receive functions in PostgreSQL maps to the readSQL/writeSQL
>> methods in SQLData. The readSQL is the method that supposedly populate
>> your VarLenTuple from the byte buffer native presentation (wrapped in
>> the SQLInput). The writeSQL creates the native presentation byte buffer
>> (wrapped in the SQLOutput) from the VarLenTuple. There's absolutely no
>> need for you to create some other send/receive mechanism in Java.
> 
> I just re-read your last mail, and I now see that I misread it.
> 
> But I still don't grasp how the SQLData implementation (readSQL/
> writeSQL) knows whether it's supposed to read or write the internal
> on-disk representation (type C) or the external binary (type B) format?
> 
> Do I need three different SQLData implementations, one for send (read C,
> write B), one for receiving (read B, write C), and one for the type
> mapping (read C, write C)?
 >
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.

> And which of them are supposed to have the toString()/parse() methods?
> 
The parse()/toString() methods are a direct replacements of the mandatory PostgreSQL 
input/output functions.

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

> Anyhow, I'm going to re-read our discussion and the source tomorrow,
> maybe a little more sleep helps. :-)
> 
:-)

Regards,
Thomas Hallgren





view thread (18+ messages)  latest in thread

Message-ID: <451BF32A.7000405@tada.se>
Permalink:  ../451BF32A.7000405@tada.se/
Also on:    postgresql.org/message-id/451BF32A.7000405@tada.se

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: <451BF32A.7000405@tada.se>

* 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