[Pljava-dev] Errors with functions that return the "record" SQL data type

From: agro-29 at hotmail(dot)com (AGRO AGRO)
To:
Subject: [Pljava-dev] Errors with functions that return the "record" SQL data type
Date: 2012-07-12 10:52:28
Message-ID: BLU168-W261150ADCDA281E7AF28FAF2D00@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hi pljava-dev mailing listers, I have recently started using pljava and may be trying to do something it is not intended to do. I am using the latest source (pljava-src-snapshot.20120525.0.tar.gz) but initially tried with the latest precompiled binaries (pljava-x86_64-unknown-linux-gnu-pg8.4-1.4.3.tar.gz) and had the same problem. I am trying to write a function that returns either a single or set of the SQL data type "record". I have written a java class, which implements both the ResultSetProvider and ResultSetHandle interfaces and contains the necessary interface methods plus three static methods with definitions similar to the following: public static boolean complexReturn(ResultSet receiver) throws SQLExceptionpublic static ResultSetProvider listComplexTypes() throws SQLExceptionpublic static ResultSetHandle listComplexTypesAlternate() I have also defined the corresponding functions within my postgres database similar to the following: CREATE FUNCTION complexReturn()
RETURNS record
AS 'myClass.complexReturn' LANGUAGE uJava; CREATE FUNCTION listComplexTypes()
RETURNS SETOF record
AS 'myClass.listComplexTypes' LANGUAGE uJava; CREATE FUNCTION listComplexTypesAlternate()
RETURNS SETOF record
AS 'myClass.listComplexTypesAlternate'
LANGUAGE uJava; I can confirm that that my PostgreSQL functions are in fact calling my Java methods and other pljava functions/methods I've written that don't use ResultSets/the "record" SQL data type work fine. However, if I look at the log files in /var/lib/pgsql/data/pg_log, I can see a call to _Composite_getTupleDesc within pljava.so is failing when trying to use any of the above functions/methods and I receive the error "An I/O error occured while sending to the backend" when calling my SQL functions. If I replace the word "record" in each of my SQL function definitions with the name of one of my tables i.e. a known record structure, everything works fine. The problem with this is that my functions don't return the same column structure everytime they're called i.e. I believe this is referred to as they return a polymorphic data type, hence why I have specifed return types of "record" or "setof record". My question is, is this error caused by a bug within pljava or something wrong with what I'm trying to do? Any advice will be greatly appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20120712/a3482859/attachment.html>

Browse pljava-dev by date

  From Date Subject
Next Message Marc Firth 2012-07-12 13:46:48 [Pljava-dev] Pljava-dev Digest, Vol 96, Issue 1
Previous Message Johann 'Myrkraverk' Oskarsson 2012-06-21 22:25:00 [Pljava-dev] Blog: Performing SQL with PL/Java in PostgreSQL