[Pljava-dev] PL/Java 1.3 compilation error on Solaris

Kris Jurka books at ejurka.com
Tue Jul 31 01:03:34 UTC 2007


Unfortunately with some forwarding involved here, the actual errors are 
not included, so it's tough to say what's going on here...  I tried 
building pljava-1.3.0 against postgresql 8.2.4 on a Solaris 9 x86 machine 
with Sun Workshop 6 Update 2, I got the savepoint related failure that's 
somewhat expected[1].  Once past that it bailed with

"/export/home/jurka/pg/pljava/pljava-1.3.0/src/C/pljava/Function.c", line 
99: warning: unnamed union member
"/export/home/jurka/pg/pljava/pljava-1.3.0/src/C/pljava/Function.c", line 
112: warning: unnamed union member
"/export/home/jurka/pg/pljava/pljava-1.3.0/src/C/pljava/Function.c", line 
113: zero-sized struct/union
"/export/home/jurka/pg/pljava/pljava-1.3.0/src/C/pljava/Function.c", line 
113: warning: unnamed struct member
"/export/home/jurka/pg/pljava/pljava-1.3.0/src/C/pljava/Function.c", line 
139: improper member use: typeMap

So at least the compiler I have (which is quite old) does not support 
unnamed members being accessible in the namespace of the parent.  The 
attached patch makes pljava build for me.

Kris Jurka

[1] http://gborg.postgresql.org/project/pljava/bugs/bugupdate.php?1673


On Tue, 31 Jul 2007, Yin Latt wrote:

> Dear Thomas,
>
> Is there any clue on this updated error?
>
> Best Regards.
>
> Yin Yin
> Digital Services
> University of Auckland Library
> Phone +64-9-3737599 Ext 88251
>
>
> -----Original Message-----
>> From: Bill Rea [mailto:bsr15 at cantsl.it.canterbury.ac.nz]
> Sent: Thursday, 26 July 2007 2:15 p.m.
> To: Yin Latt
> Cc: Thomas Hallgren; pljava-dev at gborg.postgresql.org
> Subject: RE: [Pljava-dev] PL/Java 1.3 compilation error on Solaris
>
> Thomas and all,
>
> The problems are a bit more complicated. In the output from the
> make which I forwarded to Yin the software is attempting
> to use:-
>
> /ws/on10-tools/SUNWspro/SOS8/bin/cc
>
> This must be buried somewhere in some other piece of software as there
> is no /ws directory tree on our system. I solved that problem by
> creating a directory tree with a few soft links and it now finds
> the compilers. I've looked at the JAVA_HOME environment variable
> and it wasn't correct. I've changed it and the compilation does
> go further but still fails. I've attached the output of the lastest
> make attempt and pruned off the successful portions of the make.
> The remainder of the make output is complete.
>
> Thanks for your help.
>
> Bill Rea, ICT Services, University of Canterbury \_
> E-Mail bill.rea at canterbury.ac.nz                </   New
> Phone 64-3-364-2331, Fax  64-3-364-2332        /)  Zealand
> Unix Systems Administrator                    (/'
>
> On Wed, 25 Jul 2007, Yin Latt wrote:
>
>> Hi Thomas,
>>
>> Yes. It is point to Jdk1.5
>>
>> /usr/jdk/instances/jdk1.5.0/bin/java
>>
>> Regards,
>>
>> Yin Yin
>>
>>
>> -----Original Message-----
>> From: Thomas Hallgren [mailto:thomas at tada.se]
>> Sent: Wednesday, 25 July 2007 12:08 p.m.
>> To: Yin Latt
>> Cc: pljava-dev at gborg.postgresql.org
>> Subject: Re: [Pljava-dev] PL/Java 1.3 compilation error on Solaris
>>
>> Your compiler is unable to find jni.h. Is your JAVA_HOME pointing to a
>> JDK?
>>
>> Regards,
>> Thomas Hallgren
>>
>> Yin Latt wrote:
>>> Hi,
>>>
>>> We are trying to compile pl/java 1.3 in our Solaris Server.
>>>
>>> But receiving huge numbers of syntax errors and missing
> declarations.
>>>
>>> Hope anyone successfully installed this can able to help and suggest
>> to
>>> us.
>>>
>>>
>>> OS
>>>
>>> SunOS gawain 5.10 Generic_118833-33 sun4u sparc SUNW,Sun-Blade-1000
>>>
>>>
>>> java version "1.5.0_07"
>>>
>>> Java(TM) 2 Runtime Environment, Standard Edition (build
> 1.5.0_07-b03)
>>>
>>> Java HotSpot(TM) Server VM (build 1.5.0_07-b03, mixed mode)
>>>
>>>
>>> psql --version
>>>
>>> psql (PostgreSQL) 8.1.4
>>>
>>>
>>>
>>> gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
>>>
>>>
>>>
>>>
>>>
>>> Errors on compilation.
>>>
>>>
>>>
>>> make[1]: Entering directory
>>> `/export/home/bsr15/pljava/pljava-1.3.0/build/classes/pljava'
>>>
>>> make[1]: Nothing to be done for `all'.
>>>
>>> make[1]: Leaving directory
>>> `/export/home/bsr15/pljava/pljava-1.3.0/build/classes/pljava'
>>>
>>> make[1]: Entering directory
>>> `/export/home/bsr15/pljava/pljava-1.3.0/build/classes/deploy'
>>>
>>> make[1]: Nothing to be done for `all'.
>>>
>>> make[1]: Leaving directory
>>> `/export/home/bsr15/pljava/pljava-1.3.0/build/classes/deploy'
>>>
>>> make[1]: Entering directory
>>> `/export/home/bsr15/pljava/pljava-1.3.0/build/objs'
>>>
>>> /ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa -c -xc99=none -xCC -KPIC
> -I.
>>> -I/usr/include/pgsql/server -I/usr/include/pgsql/internal
>>> -I/sfw10/builds/build/sfw10-patch/usr/src/cmd/postgres/rltmp/include
>>> -I/usr/sfw/include -DPKGLIBDIR=\"/usr/lib\"
>>> -I/export/home/bsr15/pljava/pljava-1.3.0/src/C/include
>>> -I/export/home/bsr15/pljava/pljava-1.3.0/build/jni
> -DPGSQL_MAJOR_VER=8
>>> -DPGSQL_MINOR_VER=1 -DPGSQL_PATCH_VER=3 -I"/usr/include"
>>> -I"/usr/include/solaris"
>>>
> /export/home/bsr15/pljava/pljava-1.3.0/src/C/pljava/type/JavaWrapper.c
>>> -o type/JavaWrapper.o
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/build/jni/org_postgresql_pljava_
>>> internal_JavaWrapper.h", line 2: cannot find include file: <jni.h>
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/build/jni/org_postgresql_pljava_
>>> internal_JavaWrapper.h", line 15: warning: old-style declaration or
>>> incorrect type for: JNIEXPORT
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/build/jni/org_postgresql_pljava_
>>> internal_JavaWrapper.h", line 15: syntax error before or at: void
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/build/jni/org_postgresql_pljava_
>>> internal_JavaWrapper.h", line 15: cannot have void object: JNICALL
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/build/jni/org_postgresql_pljava_
>>> internal_JavaWrapper.h", line 16: syntax error before or at: *
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/build/jni/org_postgresql_pljava_
>>> internal_JavaWrapper.h", line 16: warning: function prototype
>> parameters
>>> must have types
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/build/jni/org_postgresql_pljava_
>>> internal_JavaWrapper.h", line 16: warning: old-style declaration or
>>> incorrect type for:
>>> Java_org_postgresql_pljava_internal_JavaWrapper__1free
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/pljava.h",
>>> line 12: cannot find include file: <jni.h>
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/pljava.h",
>>> line 45: syntax error before or at: mainThreadId
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/pljava.h",
>>> line 45: warning: old-style declaration or incorrect type for:
>>> mainThreadId
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/pljava.h",
>>> line 46: syntax error before or at: *
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/pljava.h",
>>> line 47: syntax error before or at: *
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/pljava.h",
>>> line 47: warning: old-style declaration or incorrect type for:
>>> currentJNIEnv
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/pljava.h",
>>> line 105: syntax error before or at: jlong
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 34: syntax error before or at: *
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 35: syntax error before or at: *
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 37: syntax error before or at: ServerException_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 37: warning: old-style declaration or incorrect type for:
>>> ServerException_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 38: syntax error before or at: ServerException_getErrorData
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 38: warning: old-style declaration or incorrect type for:
>>> ServerException_getErrorData
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 39: syntax error before or at: ServerException_init
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 39: warning: old-style declaration or incorrect type for:
>>> ServerException_init
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 41: syntax error before or at: Class_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 41: warning: old-style declaration or incorrect type for:
>>> Class_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 42: syntax error before or at: Class_getName
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 42: warning: old-style declaration or incorrect type for:
>>> Class_getName
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 44: syntax error before or at: Throwable_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 44: warning: old-style declaration or incorrect type for:
>>> Throwable_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 45: syntax error before or at: Throwable_getMessage
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 45: warning: old-style declaration or incorrect type for:
>>> Throwable_getMessage
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 46: syntax error before or at: Throwable_printStackTrace
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 46: warning: old-style declaration or incorrect type for:
>>> Throwable_printStackTrace
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 48: syntax error before or at: IllegalArgumentException_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 48: warning: old-style declaration or incorrect type for:
>>> IllegalArgumentException_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 49: syntax error before or at: IllegalArgumentException_init
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 49: warning: old-style declaration or incorrect type for:
>>> IllegalArgumentException_init
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 51: syntax error before or at: SQLException_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 51: warning: old-style declaration or incorrect type for:
>>> SQLException_class
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 52: syntax error before or at: SQLException_init
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 52: warning: old-style declaration or incorrect type for:
>>> SQLException_init
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 53: syntax error before or at: SQLException_getSQLState
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 53: warning: old-style declaration or incorrect type for:
>>> SQLException_getSQLState
>>>
>>>
>>
> "/export/home/bsr15/pljava/pljava-1.3.0/src/C/include/pljava/JNICalls.h"
>>> , line 55: syntax error before or at:
>>> UnsupportedOperationException_class
>>>
>>> ...........
>>>
>>>
>>> 1.3.0/src/C/pljava/type/JavaWrapper.c", line 54: cannot recover from
>>> previous errors
>>>
>>> cc: acomp failed for
>>>
> /export/home/bsr15/pljava/pljava-1.3.0/src/C/pljava/type/JavaWrapper.c
>>>
>>> make[1]: *** [type/JavaWrapper.o] Error 2
>>>
>>> make[1]: Leaving directory
>>> `/export/home/bsr15/pljava/pljava-1.3.0/build/objs'
>>>
>>> make: *** [c_all] Error 2
>>>
>>>
>>>
>>> Thanks & Regards,
>>>
>>>
>>>
>>> Yin Yin
>>>
>>> Digital Services
>>> University of Auckland Library
>>> Phone +64-9-3737599 Ext 88251
>>>
>>>
>>> _______________________________________________
>>> Pljava-dev mailing list
>>> Pljava-dev at gborg.postgresql.org
>>> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>>>
>>
>>
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>
-------------- next part --------------
diff -rcN pljava-1.3.0.orig/src/C/pljava/Function.c pljava-1.3.0/src/C/pljava/Function.c
*** pljava-1.3.0.orig/src/C/pljava/Function.c	Sun Jun 18 08:44:50 2006
--- pljava-1.3.0/src/C/pljava/Function.c	Mon Jul 30 17:57:38 2007
***************
*** 96,102 ****
  		 * The static method that should be called.
  		 */
  		jmethodID method;
! 		};
  		
  		struct
  		{
--- 96,102 ----
  		 * The static method that should be called.
  		 */
  		jmethodID method;
! 		} nonudt;
  		
  		struct
  		{
***************
*** 109,116 ****
  		 * The UDT function to call
  		 */
  		UDTFunction udtFunction;
! 		};
! 	};
  };
  
  typedef struct ParseResultData
--- 109,116 ----
  		 * The UDT function to call
  		 */
  		UDTFunction udtFunction;
! 		} udt;
! 	} func;
  };
  
  typedef struct ParseResultData
***************
*** 136,145 ****
  	JNI_deleteGlobalRef(self->clazz);
  	if(!self->isUDT)
  	{
! 		if(self->typeMap != 0)
! 			JNI_deleteGlobalRef(self->typeMap);
! 		if(self->paramTypes != 0)
! 			pfree(self->paramTypes);
  	}
  }
  
--- 136,145 ----
  	JNI_deleteGlobalRef(self->clazz);
  	if(!self->isUDT)
  	{
! 		if(self->func.nonudt.typeMap != 0)
! 			JNI_deleteGlobalRef(self->func.nonudt.typeMap);
! 		if(self->func.nonudt.paramTypes != 0)
! 			pfree(self->func.nonudt.paramTypes);
  	}
  }
  
***************
*** 160,185 ****
  
  static void buildSignature(Function self, StringInfo sign, Type retType, bool alt)
  {
! 	Type* tp = self->paramTypes;
! 	Type* ep = tp + self->numParams;
  
  	appendStringInfoChar(sign, '(');
  	while(tp < ep)
  		appendStringInfoString(sign, Type_getJNISignature(*tp++));
  
! 	if(!self->isMultiCall && Type_isOutParameter(retType))
  		appendStringInfoString(sign, Type_getJNISignature(retType));
  
  	appendStringInfoChar(sign, ')');
! 	appendStringInfoString(sign, Type_getJNIReturnSignature(retType, self->isMultiCall, alt));
  }
  
  static void parseParameters(Function self, Oid* dfltIds, const char* paramDecl)
  {
  	char c;
  	int idx = 0;
! 	int top = self->numParams;
! 	bool lastIsOut = !self->isMultiCall && Type_isOutParameter(self->returnType);
  	StringInfoData sign;
  	initStringInfo(&sign);
  	for(;;)
--- 160,185 ----
  
  static void buildSignature(Function self, StringInfo sign, Type retType, bool alt)
  {
! 	Type* tp = self->func.nonudt.paramTypes;
! 	Type* ep = tp + self->func.nonudt.numParams;
  
  	appendStringInfoChar(sign, '(');
  	while(tp < ep)
  		appendStringInfoString(sign, Type_getJNISignature(*tp++));
  
! 	if(!self->func.nonudt.isMultiCall && Type_isOutParameter(retType))
  		appendStringInfoString(sign, Type_getJNISignature(retType));
  
  	appendStringInfoChar(sign, ')');
! 	appendStringInfoString(sign, Type_getJNIReturnSignature(retType, self->func.nonudt.isMultiCall, alt));
  }
  
  static void parseParameters(Function self, Oid* dfltIds, const char* paramDecl)
  {
  	char c;
  	int idx = 0;
! 	int top = self->func.nonudt.numParams;
! 	bool lastIsOut = !self->func.nonudt.isMultiCall && Type_isOutParameter(self->func.nonudt.returnType);
  	StringInfoData sign;
  	initStringInfo(&sign);
  	for(;;)
***************
*** 195,201 ****
  		c = *paramDecl++;
  		if(c == 0 || c == ',')
  		{
! 			Type deflt = (idx == top) ? self->returnType : self->paramTypes[idx];
  			const char* jtName = Type_getJavaTypeName(deflt);
  			if(strcmp(jtName, sign.data) != 0)
  			{
--- 195,201 ----
  		c = *paramDecl++;
  		if(c == 0 || c == ',')
  		{
! 			Type deflt = (idx == top) ? self->func.nonudt.returnType : self->func.nonudt.paramTypes[idx];
  			const char* jtName = Type_getJavaTypeName(deflt);
  			if(strcmp(jtName, sign.data) != 0)
  			{
***************
*** 215,223 ****
  					repl = Type_getCoerceIn(repl, deflt);
  
  				if(idx == top)
! 					self->returnType = repl;
  				else
! 					self->paramTypes[idx] = repl;
  			}
  			pfree(sign.data);
  
--- 215,223 ----
  					repl = Type_getCoerceIn(repl, deflt);
  
  				if(idx == top)
! 					self->func.nonudt.returnType = repl;
  				else
! 					self->func.nonudt.paramTypes[idx] = repl;
  			}
  			pfree(sign.data);
  
***************
*** 420,432 ****
  			errcode(ERRCODE_SYNTAX_ERROR),
  			errmsg("Triggers can not have a java parameter declaration")));
  
! 	self->returnType = Type_fromJavaType(InvalidOid, "void");
  
  	/* Parameters are not used when calling triggers.
  		*/
! 	self->numParams  = 1;
! 	self->paramTypes = (Type*)MemoryContextAlloc(GetMemoryChunkContext(self), sizeof(Type));
! 	self->paramTypes[0] = Type_fromJavaType(InvalidOid, "org.postgresql.pljava.TriggerData");
  }
  
  static void setupUDT(Function self, ParseResult info, Form_pg_proc procStruct)
--- 420,432 ----
  			errcode(ERRCODE_SYNTAX_ERROR),
  			errmsg("Triggers can not have a java parameter declaration")));
  
! 	self->func.nonudt.returnType = Type_fromJavaType(InvalidOid, "void");
  
  	/* Parameters are not used when calling triggers.
  		*/
! 	self->func.nonudt.numParams  = 1;
! 	self->func.nonudt.paramTypes = (Type*)MemoryContextAlloc(GetMemoryChunkContext(self), sizeof(Type));
! 	self->func.nonudt.paramTypes[0] = Type_fromJavaType(InvalidOid, "org.postgresql.pljava.TriggerData");
  }
  
  static void setupUDT(Function self, ParseResult info, Form_pg_proc procStruct)
***************
*** 437,458 ****
  
  	if(strcasecmp("input", info->methodName) == 0)
  	{
! 		self->udtFunction = UDT_input;
  		udtId = procStruct->prorettype;
  	}
  	else if(strcasecmp("output", info->methodName) == 0)
  	{
! 		self->udtFunction = UDT_output;
  		udtId = PARAM_OIDS(procStruct)[0];
  	}
  	else if(strcasecmp("receive", info->methodName) == 0)
  	{
! 		self->udtFunction = UDT_receive;
  		udtId = procStruct->prorettype;
  	}
  	else if(strcasecmp("send", info->methodName) == 0)
  	{
! 		self->udtFunction = UDT_send;
  		udtId = PARAM_OIDS(procStruct)[0];
  	}
  	else
--- 437,458 ----
  
  	if(strcasecmp("input", info->methodName) == 0)
  	{
! 		self->func.udt.udtFunction = UDT_input;
  		udtId = procStruct->prorettype;
  	}
  	else if(strcasecmp("output", info->methodName) == 0)
  	{
! 		self->func.udt.udtFunction = UDT_output;
  		udtId = PARAM_OIDS(procStruct)[0];
  	}
  	else if(strcasecmp("receive", info->methodName) == 0)
  	{
! 		self->func.udt.udtFunction = UDT_receive;
  		udtId = procStruct->prorettype;
  	}
  	else if(strcasecmp("send", info->methodName) == 0)
  	{
! 		self->func.udt.udtFunction = UDT_send;
  		udtId = PARAM_OIDS(procStruct)[0];
  	}
  	else
***************
*** 464,470 ****
  
  	typeTup = PgObject_getValidTuple(TYPEOID, udtId, "type");
  	pgType = (Form_pg_type)GETSTRUCT(typeTup);
! 	self->udt = UDT_registerUDT(self->clazz, udtId, pgType, 0, true);
  	ReleaseSysCache(typeTup);
  }
  
--- 464,470 ----
  
  	typeTup = PgObject_getValidTuple(TYPEOID, udtId, "type");
  	pgType = (Form_pg_type)GETSTRUCT(typeTup);
! 	self->func.udt.udt = UDT_registerUDT(self->clazz, udtId, pgType, 0, true);
  	ReleaseSysCache(typeTup);
  }
  
***************
*** 474,495 ****
  	MemoryContext ctx = GetMemoryChunkContext(self);
  	int32 top = (int32)procStruct->pronargs;;
  
! 	self->numParams = top;
! 	self->isMultiCall = procStruct->proretset;
! 	self->returnType = Type_fromOid(procStruct->prorettype, self->typeMap);
  
  	if(top > 0)
  	{
  		int idx;
  		paramOids = PARAM_OIDS(procStruct);
! 		self->paramTypes = (Type*)MemoryContextAlloc(ctx, top * sizeof(Type));
  
  		for(idx = 0; idx < top; ++idx)
! 			self->paramTypes[idx] = Type_fromOid(paramOids[idx], self->typeMap);
  	}
  	else
  	{
! 		self->paramTypes = 0;
  		paramOids = 0;
  	}
  
--- 474,495 ----
  	MemoryContext ctx = GetMemoryChunkContext(self);
  	int32 top = (int32)procStruct->pronargs;;
  
! 	self->func.nonudt.numParams = top;
! 	self->func.nonudt.isMultiCall = procStruct->proretset;
! 	self->func.nonudt.returnType = Type_fromOid(procStruct->prorettype, self->func.nonudt.typeMap);
  
  	if(top > 0)
  	{
  		int idx;
  		paramOids = PARAM_OIDS(procStruct);
! 		self->func.nonudt.paramTypes = (Type*)MemoryContextAlloc(ctx, top * sizeof(Type));
  
  		for(idx = 0; idx < top; ++idx)
! 			self->func.nonudt.paramTypes[idx] = Type_fromOid(paramOids[idx], self->func.nonudt.typeMap);
  	}
  	else
  	{
! 		self->func.nonudt.paramTypes = 0;
  		paramOids = 0;
  	}
  
***************
*** 498,510 ****
  
  	if(info->returnType != 0)
  	{
! 		const char* jtName = Type_getJavaTypeName(self->returnType);
  		if(strcmp(jtName, info->returnType) != 0)
  		{
! 			Type repl = Type_fromJavaType(Type_getOid(self->returnType), info->returnType);
! 			if(!Type_canReplaceType(repl, self->returnType))
! 				repl = Type_getCoerceOut(repl, self->returnType);
! 			self->returnType = repl;
  		}
  	}
  }
--- 498,510 ----
  
  	if(info->returnType != 0)
  	{
! 		const char* jtName = Type_getJavaTypeName(self->func.nonudt.returnType);
  		if(strcmp(jtName, info->returnType) != 0)
  		{
! 			Type repl = Type_fromJavaType(Type_getOid(self->func.nonudt.returnType), info->returnType);
! 			if(!Type_canReplaceType(repl, self->func.nonudt.returnType))
! 				repl = Type_getCoerceOut(repl, self->func.nonudt.returnType);
! 			self->func.nonudt.returnType = repl;
  		}
  	}
  }
***************
*** 523,529 ****
  	 * many other functions (including obtaining the loader) depends on it.
  	 */
  	jobject tmp = JNI_callStaticObjectMethod(s_Loader_class, s_Loader_getTypeMap, schemaName);
! 	self->typeMap = JNI_newGlobalRef(tmp);
  	JNI_deleteLocalRef(tmp);
  
  	self->readOnly = (procStruct->provolatile != PROVOLATILE_VOLATILE);
--- 523,529 ----
  	 * many other functions (including obtaining the loader) depends on it.
  	 */
  	jobject tmp = JNI_callStaticObjectMethod(s_Loader_class, s_Loader_getTypeMap, schemaName);
! 	self->func.nonudt.typeMap = JNI_newGlobalRef(tmp);
  	JNI_deleteLocalRef(tmp);
  
  	self->readOnly = (procStruct->provolatile != PROVOLATILE_VOLATILE);
***************
*** 554,560 ****
  
  	if(CALLED_AS_TRIGGER(fcinfo))
  	{
! 		self->typeMap = 0;
  		setupTriggerParams(self, info);
  	}
  	else
--- 554,560 ----
  
  	if(CALLED_AS_TRIGGER(fcinfo))
  	{
! 		self->func.nonudt.typeMap = 0;
  		setupTriggerParams(self, info);
  	}
  	else
***************
*** 564,583 ****
  
  
  	initStringInfo(&sign);
! 	buildSignature(self, &sign, self->returnType, false);
  
  	elog(DEBUG1, "Obtaining method %s.%s %s", info->className, info->methodName, sign.data);
! 	self->method = JNI_getStaticMethodIDOrNull(self->clazz, info->methodName, sign.data);
  
! 	if(self->method == 0)
  	{
  		char* origSign = sign.data;
  		Type altType = 0;
! 		Type realRetType = self->returnType;
  
  		elog(DEBUG1, "Method %s.%s %s not found", info->className, info->methodName, origSign);
  
! 		if(Type_isPrimitive(self->returnType))
  		{
  			/*
  			 * One valid reason for not finding the method is when
--- 564,583 ----
  
  
  	initStringInfo(&sign);
! 	buildSignature(self, &sign, self->func.nonudt.returnType, false);
  
  	elog(DEBUG1, "Obtaining method %s.%s %s", info->className, info->methodName, sign.data);
! 	self->func.nonudt.method = JNI_getStaticMethodIDOrNull(self->clazz, info->methodName, sign.data);
  
! 	if(self->func.nonudt.method == 0)
  	{
  		char* origSign = sign.data;
  		Type altType = 0;
! 		Type realRetType = self->func.nonudt.returnType;
  
  		elog(DEBUG1, "Method %s.%s %s not found", info->className, info->methodName, origSign);
  
! 		if(Type_isPrimitive(self->func.nonudt.returnType))
  		{
  			/*
  			 * One valid reason for not finding the method is when
***************
*** 585,594 ****
  			 * the true return type of the method is the object class that
  			 * corresponds to that primitive.
  			 */
! 			altType = Type_getObjectType(self->returnType);
  			realRetType = altType;
  		}
! 		else if(strcmp(Type_getJavaTypeName(self->returnType), "java.sql.ResultSet") == 0)
  		{
  			/*
  			 * Another reason might be that we expected a ResultSetProvider
--- 585,594 ----
  			 * the true return type of the method is the object class that
  			 * corresponds to that primitive.
  			 */
! 			altType = Type_getObjectType(self->func.nonudt.returnType);
  			realRetType = altType;
  		}
! 		else if(strcmp(Type_getJavaTypeName(self->func.nonudt.returnType), "java.sql.ResultSet") == 0)
  		{
  			/*
  			 * Another reason might be that we expected a ResultSetProvider
***************
*** 606,617 ****
  			buildSignature(self, &sign, altType, true);
  
  			elog(DEBUG1, "Obtaining method %s.%s %s", info->className, info->methodName, sign.data);
! 			self->method = JNI_getStaticMethodIDOrNull(self->clazz, info->methodName, sign.data);
  	
! 			if(self->method != 0)
! 				self->returnType = realRetType;
  		}
! 		if(self->method == 0)
  			PgObject_throwMemberError(self->clazz, info->methodName, origSign, true, true);
  
  		if(sign.data != origSign)
--- 606,617 ----
  			buildSignature(self, &sign, altType, true);
  
  			elog(DEBUG1, "Obtaining method %s.%s %s", info->className, info->methodName, sign.data);
! 			self->func.nonudt.method = JNI_getStaticMethodIDOrNull(self->clazz, info->methodName, sign.data);
  	
! 			if(self->func.nonudt.method != 0)
! 				self->func.nonudt.returnType = realRetType;
  		}
! 		if(self->func.nonudt.method == 0)
  			PgObject_throwMemberError(self->clazz, info->methodName, origSign, true, true);
  
  		if(sign.data != origSign)
***************
*** 649,655 ****
  
  jobject Function_getTypeMap(Function self)
  {
! 	return self->typeMap;
  }
  
  static bool Function_inUse(Function func)
--- 649,655 ----
  
  jobject Function_getTypeMap(Function self)
  {
! 	return self->func.nonudt.typeMap;
  }
  
  static bool Function_inUse(Function func)
***************
*** 706,734 ****
  	currentInvocation->function = self;
  
  	if(self->isUDT)
! 		return self->udtFunction(self->udt, fcinfo);
  
! 	if(self->isMultiCall && SRF_IS_FIRSTCALL())
  		Invocation_assertDisconnect();
  
! 	top = self->numParams;
  	
  	/* Leave room for one extra parameter. Functions that returns unmapped
  	 * composite types must have a single row ResultSet as an OUT parameter.
  	 */
  	args  = (jvalue*)palloc((top + 1) * sizeof(jvalue));
! 	invokerType = self->returnType;
  
  	if(top > 0)
  	{
  		int32 idx;
! 		Type* types = self->paramTypes;
  
  		/* a class loader or other mechanism might have connected already. This
  		 * connection must be dropped since its parent context is wrong.
  		 */
  		if(Type_isDynamic(invokerType))
! 			invokerType = Type_getRealType(invokerType, get_fn_expr_rettype(fcinfo->flinfo), self->typeMap);
  
  		for(idx = 0; idx < top; ++idx)
  		{
--- 706,734 ----
  	currentInvocation->function = self;
  
  	if(self->isUDT)
! 		return self->func.udt.udtFunction(self->func.udt.udt, fcinfo);
  
! 	if(self->func.nonudt.isMultiCall && SRF_IS_FIRSTCALL())
  		Invocation_assertDisconnect();
  
! 	top = self->func.nonudt.numParams;
  	
  	/* Leave room for one extra parameter. Functions that returns unmapped
  	 * composite types must have a single row ResultSet as an OUT parameter.
  	 */
  	args  = (jvalue*)palloc((top + 1) * sizeof(jvalue));
! 	invokerType = self->func.nonudt.returnType;
  
  	if(top > 0)
  	{
  		int32 idx;
! 		Type* types = self->func.nonudt.paramTypes;
  
  		/* a class loader or other mechanism might have connected already. This
  		 * connection must be dropped since its parent context is wrong.
  		 */
  		if(Type_isDynamic(invokerType))
! 			invokerType = Type_getRealType(invokerType, get_fn_expr_rettype(fcinfo->flinfo), self->func.nonudt.typeMap);
  
  		for(idx = 0; idx < top; ++idx)
  		{
***************
*** 741,755 ****
  			{
  				Type paramType = types[idx];
  				if(Type_isDynamic(paramType))
! 					paramType = Type_getRealType(paramType, get_fn_expr_argtype(fcinfo->flinfo, idx), self->typeMap);
  				args[idx] = Type_coerceDatum(paramType, PG_GETARG_DATUM(idx));
  			}
  		}
  	}
  
! 	retVal = self->isMultiCall
! 		? Type_invokeSRF(invokerType, self->clazz, self->method, args, fcinfo)
! 		: Type_invoke(invokerType, self->clazz, self->method, args, fcinfo);
  
  	pfree(args);
  	return retVal;
--- 741,755 ----
  			{
  				Type paramType = types[idx];
  				if(Type_isDynamic(paramType))
! 					paramType = Type_getRealType(paramType, get_fn_expr_argtype(fcinfo->flinfo, idx), self->func.nonudt.typeMap);
  				args[idx] = Type_coerceDatum(paramType, PG_GETARG_DATUM(idx));
  			}
  		}
  	}
  
! 	retVal = self->func.nonudt.isMultiCall
! 		? Type_invokeSRF(invokerType, self->clazz, self->func.nonudt.method, args, fcinfo)
! 		: Type_invoke(invokerType, self->clazz, self->func.nonudt.method, args, fcinfo);
  
  	pfree(args);
  	return retVal;
***************
*** 765,771 ****
  		return 0;
  
  	currentInvocation->function = self;
! 	Type_invoke(self->returnType, self->clazz, self->method, &arg, fcinfo);
  
  	fcinfo->isnull = false;
  	if(JNI_exceptionCheck())
--- 765,771 ----
  		return 0;
  
  	currentInvocation->function = self;
! 	Type_invoke(self->func.nonudt.returnType, self->clazz, self->func.nonudt.method, &arg, fcinfo);
  
  	fcinfo->isnull = false;
  	if(JNI_exceptionCheck())
diff -rcN pljava-1.3.0.orig/src/C/pljava/XactListener.c pljava-1.3.0/src/C/pljava/XactListener.c
*** pljava-1.3.0.orig/src/C/pljava/XactListener.c	Sun Jun 18 08:44:50 2006
--- pljava-1.3.0/src/C/pljava/XactListener.c	Mon Jul 30 17:25:10 2007
***************
*** 12,17 ****
--- 12,18 ----
  
  #if ((PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER >= 1) || PGSQL_MAJOR_VER > 8)
  #define HAS_2PC 1
+ #include "access/xact.h"
  #endif
  
  static jclass s_XactListener_class;


More information about the Pljava-dev mailing list