Re: java stored procedures

From: Barry Lind <barry(at)xythos(dot)com>
To: hornyakl(at)users(dot)sourceforge(dot)net
Cc: pgsql-general(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: java stored procedures
Date: 2001-12-05 01:34:21
Message-ID: 3C0D799D.4010808@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-jdbc

Laszlo,

> I am very far from features like this.
> PL/JAVA now:
> -there is a separate process running java (kaffe). this process creates
> a sys v message queue, that holds requests. almost forgot, a shared
> memory segment too. I didn`t find better way to tell postgres the
> informations about the java process.

Does the mechanism you are planning support running any JVM? In my
opionion Kaffe isn't good enough to be widely useful. I think you
should be able to plugin whatever jvm is best on your platform, which
will likely be either the Sun or IBM JVMs.

Also, can you explain this a little bit more. How does the jvm process
get started? (I would hope that the postgresql server processes would
start it when needed, as opposed to requiring that it be started
separately.) How does the jvm access these shared memory structures?
Since there aren't any methods in the java API to do such things that I
am aware of.

> -the java request_handler function on the server side attaches to the
> shared memory, reads the key of the message queue., attaches to it,
> sends the data of the function, and a signal for the pl/java. after, it
> is waiting for a signal from the java thread.

I don't understand how you do this in java? I must not be understanding
something correctly here.

> -when java thread receives the signal, it reads the message(s) from the
> queue, and starts some actions. When done it tells postgres with a
> signal that it is ready, and it can come for its results. This will be
> rewritten see below problems.

Are signals the best way to accomplish this?

> -And postgres is runing, while java is waiting for postgres to say
> something.

But in reality if the postgres process is executing a stored function it
needs to wait for the result of that function call before continuing
doesn't it?

>
> Threading on the java process side is not done yet, ok, it is not that
> hard, I will write it, if it will be realy neccessary.

Agreed, this is important.

>
> The problems, for now:
> I had a very simple system, that passed a very limited scale of argument
> types, with a very limited quantity of parameters (int, varchar, bool).
> Postgres has limits for the argument count too, but not for types. It
> had too much limits, so I am working (or to tell the truth now only
> thinking) on a new type handling that fits the felxibility of
> Postgresql`s type flexibility. For this I will have to learn a lot about
> Postgres`s type system. This will be my program this weekend. :)

Shouldn't this code use all or most of the logic found in the FE/BE
protocol? Why invent and code another mechanism to transfer data when
one already exists. (I will admit that the current FE/BE mechanism
isn't the ideal choice, but it seems easier to reuse what exists for now
and improve on it later).

>
> thanks,
> Laszlo Hornyak
>

You didn't mention how you plan to deal with the transaction symantics.
So what happens when the pl/java function calls through jdbc back to
the server to insert some data? That should happen in the same
transaction as the caller correct?

thanks,
--Barry

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Peltonen 2001-12-05 08:20:05 Re: postgres idle process and other problems
Previous Message Tom Innes 2001-12-04 23:38:29 When will JDBC support error codes?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2001-12-05 02:49:16 SunOS4 port
Previous Message Tatsuo Ishii 2001-12-05 00:57:30 Re: Undocumented feature costs a lot of performance in

Browse pgsql-jdbc by date

  From Date Subject
Next Message Laszlo Hornyak 2001-12-05 09:06:10 Re: java stored procedures
Previous Message Rene Pijlman 2001-12-04 20:53:58 Re: Encoding weirdness with JDBC, driver crashing?