agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] CREATE FUNCTION docs inconsistent with implementation
2+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] CREATE FUNCTION docs inconsistent with implementation
@ 2006-08-08 23:39 
  2006-08-14 22:49 ` [Pljava-dev] CREATE FUNCTION docs inconsistent with implementation 
  0 siblings, 1 reply; 2+ messages in thread

From:  @ 2006-08-08 23:39 UTC (permalink / raw)

In case anyone else has been having trouble with this, hopefully this
will save you some time...

The "Function mapping" (long-form) CREATE FUNCTION sample from the Wiki
seems to be out of sync with the backing implementation:

CREATE FUNCTION getsysprop(VARCHAR)
  RETURNS VARCHAR
  AS 'java.lang.String java.lang.System.getProperty(java.lang.String)'
  LANGUAGE java;

When getsysprop is run as is, the Java class name is interpreted as
'java.lang.Stringjava.lang.System' and the return type as 'null', as in:

DEBUG:  className = 'java.lang.Stringjava.lang.System', methodName =
'getProperty', parameters = 'java.lang.String', returnType = 'null'
DEBUG:  Loading class java.lang.Stringjava.lang.System
ERROR:  java.lang.ClassNotFoundException: java.lang.Stringjava.lang.System

The parseFunction function (line 387 in src/C/pljava/Functions.c from
the 1.3.0 source download) looks for '=' between the return type and
class name.  Consequently, the CREATE FUNCTION statement must be:

CREATE FUNCTION getsysprop(VARCHAR)
  RETURNS VARCHAR
  AS 'java.lang.String=java.lang.System.getProperty(java.lang.String)'
  LANGUAGE java;

Is the '=' delimiter expected to be a permanent syntax here, or is the
intention that the implementation eventually will match the docs?

Thanks,
Eric Faulhaber





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* [Pljava-dev] CREATE FUNCTION docs inconsistent with implementation
  2006-08-08 23:39 [Pljava-dev] CREATE FUNCTION docs inconsistent with implementation 
@ 2006-08-14 22:49 ` 
  0 siblings, 0 replies; 2+ messages in thread

From:  @ 2006-08-14 22:49 UTC (permalink / raw)

Eric Faulhaber wrote:
> In case anyone else has been having trouble with this, hopefully this
> will save you some time...
> 
> The "Function mapping" (long-form) CREATE FUNCTION sample from the Wiki
> seems to be out of sync with the backing implementation:
> 
> CREATE FUNCTION getsysprop(VARCHAR)
>   RETURNS VARCHAR
>   AS 'java.lang.String java.lang.System.getProperty(java.lang.String)'
>   LANGUAGE java;
> 
> When getsysprop is run as is, the Java class name is interpreted as
> 'java.lang.Stringjava.lang.System' and the return type as 'null', as in:
> 
> DEBUG:  className = 'java.lang.Stringjava.lang.System', methodName =
> 'getProperty', parameters = 'java.lang.String', returnType = 'null'
> DEBUG:  Loading class java.lang.Stringjava.lang.System
> ERROR:  java.lang.ClassNotFoundException: java.lang.Stringjava.lang.System
> 
Ouch. This is a bug. I'll have to look into that.

> The parseFunction function (line 387 in src/C/pljava/Functions.c from
> the 1.3.0 source download) looks for '=' between the return type and
> class name.  Consequently, the CREATE FUNCTION statement must be:
> 
> CREATE FUNCTION getsysprop(VARCHAR)
>   RETURNS VARCHAR
>   AS 'java.lang.String=java.lang.System.getProperty(java.lang.String)'
>   LANGUAGE java;
> 
> Is the '=' delimiter expected to be a permanent syntax here, or is the
> intention that the implementation eventually will match the docs?
> 
The '=' is only used internally and should not be used in the CREATE FUNCTION declaration. 
PL/Java will strip of every white space in the string very early on in the parse process 
since they are all insignificant. Well, all but the one between the return type and the 
function name. That particular white space is replaced by the '=' sign. The code at line 387 
  comes into play after that.

Regards,
Thomas Hallgren





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-08-14 22:49 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-08 23:39 [Pljava-dev] CREATE FUNCTION docs inconsistent with implementation 
2006-08-14 22:49 ` 

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