Skip to content

Commit

Permalink
Merge pull request #19 from asifnaeem/PG93Fix
Browse files Browse the repository at this point in the history
Looks good to me so I'll merge it. For future commit messages, please use one line first (80 characters or less) followed by an empty line and then a more elaborate description (where all lines are 80 chars or less). Reason being that such one liners show up in many lists where you can click on a link to get the more elaborated text.
  • Loading branch information
thallgren committed Jul 4, 2013
2 parents fbf5aeb + d5c603e commit 191c2fb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Expand Up @@ -98,7 +98,7 @@
({
"ddr.name.trusted", // default "java"
"ddr.name.untrusted", // default "javaU"
"ddr.output", // name of ddr file to write

This comment has been minimized.

Copy link
@jcflack

jcflack Jul 12, 2013

Contributor

Trailing comma here is explicitly legal in the Java Language Specification, see the production for ElementValueArrayInitializer in section 9.7 (of JLS3) or 9.7.1 (Jave SE 7 Edition). It's also legal to not have one. A Java toolchain that gives an error either way would seem to have a bug.

"ddr.output" // name of ddr file to write
})
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class DDRProcessor extends AbstractProcessor
Expand Down
21 changes: 21 additions & 0 deletions pljava-so/src/main/c/Backend.c
Expand Up @@ -38,6 +38,11 @@
#include "pljava/Session.h"
#include "pljava/SPI.h"
#include "pljava/type/String.h"

#if (PGSQL_MAJOR_VER > 9 || (PGSQL_MAJOR_VER == 9 && PGSQL_MINOR_VER >= 3))
#include "utils/timeout.h"
#endif

/* Example format: "/usr/local/pgsql/lib" */
#ifndef PKGLIBDIR
#error "PKGLIBDIR needs to be defined to compile this file."
Expand Down Expand Up @@ -374,7 +379,12 @@ static void _destroyJavaVM(int status, Datum dummy)
{
Invocation ctx;
#if !defined(WIN32)

#if (PGSQL_MAJOR_VER > 9 || (PGSQL_MAJOR_VER == 9 && PGSQL_MINOR_VER >= 3))
TimeoutId tid;
#else
pqsigfunc saveSigAlrm;
#endif

Invocation_pushInvocation(&ctx, false);
if(sigsetjmp(recoverBuf, 1) != 0)
Expand All @@ -384,13 +394,24 @@ static void _destroyJavaVM(int status, Datum dummy)
return;
}

#if (PGSQL_MAJOR_VER > 9 || (PGSQL_MAJOR_VER == 9 && PGSQL_MINOR_VER >= 3))
InitializeTimeouts(); /* establishes SIGALRM handler */
tid = RegisterTimeout(USER_TIMEOUT, terminationTimeoutHandler);
#else
saveSigAlrm = pqsignal(SIGALRM, terminationTimeoutHandler);
enable_sig_alarm(5000, false);
#endif

elog(DEBUG1, "Destroying JavaVM...");
JNI_destroyVM(s_javaVM);

#if (PGSQL_MAJOR_VER > 9 || (PGSQL_MAJOR_VER == 9 && PGSQL_MINOR_VER >= 3))
disable_timeout(tid, false);
#else
disable_sig_alarm(false);
pqsignal(SIGALRM, saveSigAlrm);
#endif

#else
Invocation_pushInvocation(&ctx, false);
elog(DEBUG1, "Destroying JavaVM...");
Expand Down
8 changes: 8 additions & 0 deletions pljava-so/src/main/include/pljava/pljava.h
Expand Up @@ -34,6 +34,14 @@ extern int vsnprintf(char* buf, size_t count, const char* format, va_list arg);
#include <utils/memutils.h>
#include <tcop/tcopprot.h>

/*
* GETSTRUCT require "access/htup_details.h" to be included in PG9.3
*/
#if (PGSQL_MAJOR_VER > 9 || (PGSQL_MAJOR_VER == 9 && PGSQL_MINOR_VER >= 3))
#include "access/htup_details.h"
#endif


/* The errorOccured will be set when a call from Java into one of the
* backend functions results in a elog that causes a longjmp (Levels >= ERROR)
* that was trapped using the PLJAVA_TRY/PLJAVA_CATCH macros.
Expand Down

1 comment on commit 191c2fb

@jcflack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The submitter gives the reason for the DDRProcessor change as fixing an "illegal start of expression error" but did not mention what Java compiler or toolchain was being used. It would be good to report a bug against that compiler or toolchain, because the optional trailing comma is definitely legal in the Java Language Specification (I just checked to make sure).

Please sign in to comment.