Ubuntu

Merge lp:~ubuntu-branches/ubuntu/oneiric/postgresql-pljava/oneiric-201109061811 into lp:ubuntu/oneiric/postgresql-pljava

Proposed by Ubuntu Package Importer on 2011-09-06
Status: Rejected
Rejected by: Martin Pitt on 2011-09-08
Proposed branch: lp:~ubuntu-branches/ubuntu/oneiric/postgresql-pljava/oneiric-201109061811
Merge into: lp:ubuntu/oneiric/postgresql-pljava
Diff against target: 1026 lines (+1009/-0) 2 files modified (has conflicts)
Conflict adding file .pc/9.1_api.patch.  Moved existing file to .pc/9.1_api.patch.moved.
Conflict adding file debian/patches/9.1_api.patch.  Moved existing file to debian/patches/9.1_api.patch.moved.
To merge this branch: bzr merge lp:~ubuntu-branches/ubuntu/oneiric/postgresql-pljava/oneiric-201109061811
Reviewer Review Type Date Requested Status
Didier Roche Disapprove on 2011-09-08
Ubuntu branches 2011-09-06 Pending
Review via email: mp+74276@code.launchpad.net

Description of the Change

The package importer has detected a possible inconsistency between the package history in the archve and the history in bzr. As the archive is authoritative the importer has made lp:ubuntu/oneiric/postgresql-pljava reflect what is in the archive and the old bzr branch has been pushed to lp:~ubuntu-branches/ubuntu/oneiric/postgresql-pljava/oneiric-201109061811. This merge proposal was created so that an Ubuntu developer can review the situations and perform a merge/upload if necessary. There are three typical cases where this can happen.
  1. Where someone pushes a change to bzr and someone else uploads the package without that change. This is the reason that this check is done by the importer. If this appears to be the case then a merge/upload should be done if the changes that were in bzr are still desirable.
  2. The importer incorrectly detected the above situation when someone made a change in bzr and then uploaded it.
  3. The importer incorrectly detected the above situation when someone just uploaded a package and didn't touch bzr.

If this case doesn't appear to be the first situation then set the status of the merge proposal to "Rejected" and help avoid the problem in future by filing a bug at https://bugs.launchpad.net/udd linking to this merge proposal.

(this is an automatically generated message)

To post a comment you must log in.
Didier Roche (didrocks) wrote :

usual quilt 3 conflict

review: Disapprove

Unmerged revisions

10. By Martin Pitt on 2011-09-06

releasing version 1.4.2-4ubuntu1

9. By Martin Pitt on 2011-09-06

Add 9.1_api.patch: Port to 9.1 API.

8. By Martin Pitt on 2011-09-06

debian/pgversions: Build for 9.1 only. Regenerate debian/control.

Preview Diff

1=== added directory '.pc/9.1_api.patch'
2=== renamed directory '.pc/9.1_api.patch' => '.pc/9.1_api.patch.moved'
3=== added file '.pc/9.1_api.patch/.timestamp'
4=== added directory '.pc/9.1_api.patch/src'
5=== added directory '.pc/9.1_api.patch/src/C'
6=== added directory '.pc/9.1_api.patch/src/C/pljava'
7=== added file '.pc/9.1_api.patch/src/C/pljava/Backend.c'
8--- .pc/9.1_api.patch/src/C/pljava/Backend.c 1970-01-01 00:00:00 +0000
9+++ .pc/9.1_api.patch/src/C/pljava/Backend.c 2011-09-06 19:13:35 +0000
10@@ -0,0 +1,935 @@
11+/*
12+ * Copyright (c) 2004, 2005, 2006 TADA AB - Taby Sweden
13+ * Distributed under the terms shown in the file COPYRIGHT
14+ * found in the root folder of this project or at
15+ * http://eng.tada.se/osprojects/COPYRIGHT.html
16+ *
17+ * @author Thomas Hallgren
18+ */
19+#include <postgres.h>
20+#include <miscadmin.h>
21+#ifndef WIN32
22+#include <libpq/pqsignal.h>
23+#endif
24+#include <executor/spi.h>
25+#include <commands/trigger.h>
26+#include <utils/elog.h>
27+#include <utils/guc.h>
28+#include <fmgr.h>
29+#include <access/heapam.h>
30+#include <utils/syscache.h>
31+#include <catalog/catalog.h>
32+#include <catalog/pg_proc.h>
33+#include <catalog/pg_type.h>
34+#include <storage/ipc.h>
35+#include <storage/proc.h>
36+#include <stdio.h>
37+#include <ctype.h>
38+#include <unistd.h>
39+
40+#include "org_postgresql_pljava_internal_Backend.h"
41+#include "pljava/Invocation.h"
42+#include "pljava/Function.h"
43+#include "pljava/HashMap.h"
44+#include "pljava/Exception.h"
45+#include "pljava/Backend.h"
46+#include "pljava/Session.h"
47+#include "pljava/SPI.h"
48+#include "pljava/type/String.h"
49+/* Example format: "/usr/local/pgsql/lib" */
50+#ifndef PKGLIBDIR
51+#error "PKGLIBDIR needs to be defined to compile this file."
52+#endif
53+
54+/* Include the 'magic block' that PostgreSQL 8.2 and up will use to ensure
55+ * that a module is not loaded into an incompatible server.
56+ */
57+#ifdef PG_MODULE_MAGIC
58+PG_MODULE_MAGIC;
59+#endif
60+
61+#define LOCAL_REFERENCE_COUNT 128
62+
63+jlong mainThreadId;
64+
65+static JavaVM* s_javaVM = 0;
66+static jclass s_Backend_class;
67+static jmethodID s_setTrusted;
68+static char* vmoptions;
69+static char* classpath;
70+static int statementCacheSize;
71+static bool pljavaDebug;
72+static bool pljavaReleaseLingeringSavepoints;
73+static bool s_currentTrust;
74+static int s_javaLogLevel;
75+
76+bool integerDateTimes = false;
77+
78+extern void Invocation_initialize(void);
79+extern void Exception_initialize(void);
80+extern void Exception_initialize2(void);
81+extern void HashMap_initialize(void);
82+extern void SPI_initialize(void);
83+extern void Type_initialize(void);
84+extern void Function_initialize(void);
85+extern void Session_initialize(void);
86+extern void PgSavepoint_initialize(void);
87+extern void XactListener_initialize(void);
88+extern void SubXactListener_initialize(void);
89+extern void SQLInputFromChunk_initialize(void);
90+extern void SQLOutputToChunk_initialize(void);
91+extern void SQLInputFromTuple_initialize(void);
92+extern void SQLOutputToTuple_initialize(void);
93+
94+static void initPLJavaClasses(void)
95+{
96+ jfieldID tlField;
97+ JNINativeMethod backendMethods[] =
98+ {
99+ {
100+ "isCallingJava",
101+ "()Z",
102+ Java_org_postgresql_pljava_internal_Backend_isCallingJava
103+ },
104+ {
105+ "isReleaseLingeringSavepoints",
106+ "()Z",
107+ Java_org_postgresql_pljava_internal_Backend_isReleaseLingeringSavepoints
108+ },
109+ {
110+ "_getConfigOption",
111+ "(Ljava/lang/String;)Ljava/lang/String;",
112+ Java_org_postgresql_pljava_internal_Backend__1getConfigOption
113+ },
114+ {
115+ "_getStatementCacheSize",
116+ "()I",
117+ Java_org_postgresql_pljava_internal_Backend__1getStatementCacheSize
118+ },
119+ {
120+ "_log",
121+ "(ILjava/lang/String;)V",
122+ Java_org_postgresql_pljava_internal_Backend__1log
123+ },
124+ {
125+ "_clearFunctionCache",
126+ "()V",
127+ Java_org_postgresql_pljava_internal_Backend__1clearFunctionCache
128+ },
129+ { 0, 0, 0 }
130+ };
131+
132+ Exception_initialize();
133+
134+ elog(DEBUG1, "Getting Backend class pljava.jar");
135+ s_Backend_class = PgObject_getJavaClass("org/postgresql/pljava/internal/Backend");
136+ elog(DEBUG1, "Backend class was there");
137+ PgObject_registerNatives2(s_Backend_class, backendMethods);
138+
139+ tlField = PgObject_getStaticJavaField(s_Backend_class, "THREADLOCK", "Ljava/lang/Object;");
140+ JNI_setThreadLock(JNI_getStaticObjectField(s_Backend_class, tlField));
141+
142+ Invocation_initialize();
143+ Exception_initialize2();
144+ SPI_initialize();
145+ Type_initialize();
146+ Function_initialize();
147+ Session_initialize();
148+ PgSavepoint_initialize();
149+ XactListener_initialize();
150+ SubXactListener_initialize();
151+ SQLInputFromChunk_initialize();
152+ SQLOutputToChunk_initialize();
153+ SQLInputFromTuple_initialize();
154+ SQLOutputToTuple_initialize();
155+
156+ s_setTrusted = PgObject_getStaticJavaMethod(s_Backend_class, "setTrusted", "(Z)V");
157+}
158+
159+/**
160+ * Initialize security
161+ */
162+void Backend_setJavaSecurity(bool trusted)
163+{
164+ if(trusted != s_currentTrust)
165+ {
166+ /* GCJ has major issues here. Real work on SecurityManager and
167+ * related classes has just started in version 4.0.0.
168+ */
169+#ifndef GCJ
170+ JNI_callStaticVoidMethod(s_Backend_class, s_setTrusted, (jboolean)trusted);
171+ if(JNI_exceptionCheck())
172+ {
173+ JNI_exceptionDescribe();
174+ JNI_exceptionClear();
175+ ereport(ERROR, (
176+ errcode(ERRCODE_INTERNAL_ERROR),
177+ errmsg("Unable to initialize java security")));
178+ }
179+#endif
180+ s_currentTrust = trusted;
181+ }
182+}
183+
184+int Backend_setJavaLogLevel(int logLevel)
185+{
186+ int oldLevel = s_javaLogLevel;
187+ s_javaLogLevel = logLevel;
188+ return oldLevel;
189+}
190+
191+/**
192+ * Special purpose logging function called from JNI when verbose is enabled.
193+ */
194+static jint JNICALL my_vfprintf(FILE* fp, const char* format, va_list args)
195+{
196+ char buf[1024];
197+ char* ep;
198+ char* bp = buf;
199+
200+ vsnprintf(buf, sizeof(buf), format, args);
201+
202+ /* Trim off trailing newline and other whitespace.
203+ */
204+ ep = bp + strlen(bp) - 1;
205+ while(ep >= bp && isspace(*ep))
206+ --ep;
207+ ++ep;
208+ *ep = 0;
209+
210+ elog(s_javaLogLevel, buf);
211+ return 0;
212+}
213+
214+/*
215+ * Append those parts of path that has not yet been appended. The HashMap unique is
216+ * keeping track of what has been appended already. First appended part will be
217+ * prefixed with prefix.
218+ */
219+static void appendPathParts(const char* path, StringInfoData* bld, HashMap unique, const char* prefix)
220+{
221+ StringInfoData buf;
222+ if(path == 0 || strlen(path) == 0)
223+ return;
224+
225+ for (;;)
226+ {
227+ char* pathPart;
228+ size_t len;
229+ if(*path == 0)
230+ break;
231+
232+ len = strcspn(path, ";:");
233+
234+ if(len == 1 && *(path+1) == ':' && isalnum(*path))
235+ /*
236+ * Windows drive designator, leave it "as is".
237+ */
238+ len = strcspn(path+2, ";:") + 2;
239+ else
240+ if(len == 0)
241+ {
242+ /* Ignore zero length components.
243+ */
244+ ++path;
245+ continue;
246+ }
247+
248+ initStringInfo(&buf);
249+ if(*path == '$')
250+ {
251+ if(len == 7 || (strcspn(path, "/\\") == 7 && strncmp(path, "$libdir", 7) == 0))
252+ {
253+ len -= 7;
254+ path += 7;
255+ appendStringInfo(&buf, PKGLIBDIR);
256+ }
257+ else
258+ ereport(ERROR, (
259+ errcode(ERRCODE_INVALID_NAME),
260+ errmsg("invalid macro name '%*s' in dynamic library path", (int)len, path)));
261+ }
262+
263+ if(len > 0)
264+ {
265+ appendBinaryStringInfo(&buf, path, len);
266+ path += len;
267+ }
268+
269+ pathPart = buf.data;
270+ if(HashMap_getByString(unique, pathPart) == 0)
271+ {
272+ if(HashMap_size(unique) == 0)
273+ appendStringInfo(bld, prefix);
274+ else
275+#if defined(WIN32)
276+ appendStringInfoChar(bld, ';');
277+#else
278+ appendStringInfoChar(bld, ':');
279+#endif
280+ appendStringInfo(bld, pathPart);
281+ HashMap_putByString(unique, pathPart, (void*)1);
282+ }
283+ pfree(pathPart);
284+ if(*path == 0)
285+ break;
286+ ++path; /* Skip ':' */
287+ }
288+}
289+
290+/*
291+ * Get the CLASSPATH. Result is always freshly palloc'd.
292+ */
293+static char* getClassPath(const char* prefix)
294+{
295+ char* path;
296+ HashMap unique = HashMap_create(13, CurrentMemoryContext);
297+ StringInfoData buf;
298+ initStringInfo(&buf);
299+ appendPathParts(classpath, &buf, unique, prefix);
300+ appendPathParts(getenv("CLASSPATH"), &buf, unique, prefix);
301+ PgObject_free((PgObject)unique);
302+ path = buf.data;
303+ if(strlen(path) == 0)
304+ {
305+ pfree(path);
306+ path = 0;
307+ }
308+ return path;
309+}
310+
311+#if !defined(WIN32)
312+
313+static void pljavaStatementCancelHandler(int signum)
314+{
315+ if(!proc_exit_inprogress)
316+ {
317+ /* Never service the interrupt immediately. In order to find out if
318+ * its safe, we would need to know what kind of threading mechanism
319+ * the VM uses. That would count for a lot of conditional code.
320+ */
321+ QueryCancelPending = true;
322+ InterruptPending = true;
323+ }
324+}
325+
326+static void pljavaDieHandler(int signum)
327+{
328+ if(!proc_exit_inprogress)
329+ {
330+ /* Never service the interrupt immediately. In order to find out if
331+ * its safe, we would need to know what kind of threading mechanism
332+ * the VM uses. That would count for a lot of conditional code.
333+ */
334+ ProcDiePending = true;
335+ InterruptPending = true;
336+ }
337+}
338+
339+static void pljavaQuickDieHandler(int signum)
340+{
341+ /* Just die. No ereporting here since we don't know what thread this is.
342+ */
343+ exit(1);
344+}
345+
346+static sigjmp_buf recoverBuf;
347+static void terminationTimeoutHandler(int signum)
348+{
349+ kill(MyProcPid, SIGQUIT);
350+
351+ /* Some sleep to get the SIGQUIT a chance to generate
352+ * the needed output.
353+ */
354+ pg_usleep(1);
355+
356+ /* JavaVM did not die within the alloted time
357+ */
358+ siglongjmp(recoverBuf, 1);
359+}
360+#endif
361+
362+/*
363+ * proc_exit callback to tear down the JVM
364+ */
365+static void _destroyJavaVM(int status, Datum dummy)
366+{
367+ if(s_javaVM != 0)
368+ {
369+ Invocation ctx;
370+#if !defined(WIN32)
371+ pqsigfunc saveSigAlrm;
372+
373+ Invocation_pushInvocation(&ctx, false);
374+ if(sigsetjmp(recoverBuf, 1) != 0)
375+ {
376+ elog(DEBUG1, "JavaVM destroyed with force");
377+ s_javaVM = 0;
378+ return;
379+ }
380+
381+ saveSigAlrm = pqsignal(SIGALRM, terminationTimeoutHandler);
382+ enable_sig_alarm(5000, false);
383+
384+ elog(DEBUG1, "Destroying JavaVM...");
385+ JNI_destroyVM(s_javaVM);
386+ disable_sig_alarm(false);
387+ pqsignal(SIGALRM, saveSigAlrm);
388+#else
389+ Invocation_pushInvocation(&ctx, false);
390+ elog(DEBUG1, "Destroying JavaVM...");
391+ JNI_destroyVM(s_javaVM);
392+#endif
393+ elog(DEBUG1, "JavaVM destroyed");
394+ s_javaVM = 0;
395+ currentInvocation = 0;
396+ }
397+}
398+
399+typedef struct {
400+ JavaVMOption* options;
401+ unsigned int size;
402+ unsigned int capacity;
403+} JVMOptList;
404+
405+static void JVMOptList_init(JVMOptList* jol)
406+{
407+ jol->options = (JavaVMOption*)palloc(10 * sizeof(JavaVMOption));
408+ jol->size = 0;
409+ jol->capacity = 10;
410+}
411+
412+static void JVMOptList_delete(JVMOptList* jol)
413+{
414+ JavaVMOption* opt = jol->options;
415+ JavaVMOption* top = opt + jol->size;
416+ while(opt < top)
417+ {
418+ pfree(opt->optionString);
419+ opt++;
420+ }
421+ pfree(jol->options);
422+}
423+
424+static void JVMOptList_add(JVMOptList* jol, const char* optString, void* extraInfo, bool mustCopy)
425+{
426+ JavaVMOption* added;
427+
428+ int newPos = jol->size;
429+ if(newPos >= jol->capacity)
430+ {
431+ int newCap = jol->capacity * 2;
432+ JavaVMOption* newOpts = (JavaVMOption*)palloc(newCap * sizeof(JavaVMOption));
433+ memcpy(newOpts, jol->options, newPos * sizeof(JavaVMOption));
434+ pfree(jol->options);
435+ jol->options = newOpts;
436+ jol->capacity = newCap;
437+ }
438+ added = jol->options + newPos;
439+ if(mustCopy)
440+ optString = pstrdup(optString);
441+
442+ added->optionString = (char*)optString;
443+ added->extraInfo = extraInfo;
444+ jol->size++;
445+
446+ elog(DEBUG1, "Added JVM option string \"%s\"", optString);
447+}
448+
449+/* Split JVM options. The string is split on whitespace unless the
450+ * whitespace is found within a string or is escaped by backslash. A
451+ * backslash escaped quote is not considered a string delimiter.
452+ */
453+static void addUserJVMOptions(JVMOptList* optList)
454+{
455+ const char* cp = vmoptions;
456+
457+ if(cp != NULL)
458+ {
459+ StringInfoData buf;
460+ char quote = 0;
461+ char c;
462+
463+ initStringInfo(&buf);
464+ for(;;)
465+ {
466+ c = *cp++;
467+ switch(c)
468+ {
469+ case 0:
470+ break;
471+
472+ case '"':
473+ case '\'':
474+ if(quote == c)
475+ quote = 0;
476+ else
477+ quote = c;
478+ appendStringInfoChar(&buf, c);
479+ continue;
480+
481+ case '\\':
482+ appendStringInfoChar(&buf, '\\');
483+ c = *cp++; /* Interpret next character verbatim */
484+ if(c == 0)
485+ break;
486+ appendStringInfoChar(&buf, c);
487+ continue;
488+
489+ default:
490+ if(quote == 0 && isspace((int)c))
491+ {
492+ while((c = *cp++) != 0)
493+ {
494+ if(!isspace((int)c))
495+ break;
496+ }
497+
498+ if(c == 0)
499+ break;
500+
501+ if(c != '-')
502+ appendStringInfoChar(&buf, ' ');
503+ else if(buf.len > 0)
504+ {
505+ /* Whitespace followed by '-' triggers new
506+ * option declaration.
507+ */
508+ JVMOptList_add(optList, buf.data, 0, true);
509+ buf.len = 0;
510+ buf.data[0] = 0;
511+ }
512+ }
513+ appendStringInfoChar(&buf, c);
514+ continue;
515+ }
516+ break;
517+ }
518+ if(buf.len > 0)
519+ JVMOptList_add(optList, buf.data, 0, true);
520+ pfree(buf.data);
521+ }
522+}
523+
524+/**
525+ * Initialize the session
526+ */
527+static void initJavaSession(void)
528+{
529+ jclass sessionClass = PgObject_getJavaClass("org/postgresql/pljava/internal/Session");
530+ jmethodID init = PgObject_getStaticJavaMethod(sessionClass, "init", "()J");
531+ mainThreadId = JNI_callStaticLongMethod(sessionClass, init);
532+ JNI_deleteLocalRef(sessionClass);
533+
534+ if(JNI_exceptionCheck())
535+ {
536+ JNI_exceptionDescribe();
537+ JNI_exceptionClear();
538+ ereport(ERROR, (
539+ errcode(ERRCODE_INTERNAL_ERROR),
540+ errmsg("Unable to initialize java session")));
541+ }
542+}
543+
544+static void checkIntTimeType(void)
545+{
546+ #if (PGSQL_MAJOR_VER > 8)
547+ const char* idt = GetConfigOption("integer_datetimes", true);
548+ #else
549+ const char* idt = GetConfigOption("integer_datetimes");
550+ #endif
551+
552+ integerDateTimes = (strcmp(idt, "on") == 0);
553+ elog(DEBUG1, integerDateTimes ? "Using integer_datetimes" : "Not using integer_datetimes");
554+}
555+
556+static bool s_firstTimeInit = true;
557+
558+static void initializeJavaVM(void)
559+{
560+ jboolean jstat;
561+ JavaVMInitArgs vm_args;
562+ JVMOptList optList;
563+
564+ JVMOptList_init(&optList);
565+
566+ if(s_firstTimeInit)
567+ {
568+ s_firstTimeInit = false;
569+ s_javaLogLevel = INFO;
570+
571+ checkIntTimeType();
572+ HashMap_initialize();
573+
574+ DefineCustomStringVariable(
575+ "pljava.vmoptions",
576+ "Options sent to the JVM when it is created",
577+ NULL,
578+ &vmoptions,
579+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
580+ NULL,
581+ #endif
582+ PGC_USERSET,
583+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
584+ 0,
585+ #endif
586+ NULL, NULL);
587+
588+ DefineCustomStringVariable(
589+ "pljava.classpath",
590+ "Classpath used by the JVM",
591+ NULL,
592+ &classpath,
593+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
594+ NULL,
595+ #endif
596+ PGC_USERSET,
597+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
598+ 0,
599+ #endif
600+ NULL, NULL);
601+
602+ DefineCustomBoolVariable(
603+ "pljava.debug",
604+ "Stop the backend to attach a debugger",
605+ NULL,
606+ &pljavaDebug,
607+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
608+ false,
609+ #endif
610+ PGC_USERSET,
611+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
612+ 0,
613+ #endif
614+ NULL, NULL);
615+
616+ DefineCustomIntVariable(
617+ "pljava.statement_cache_size",
618+ "Size of the prepared statement MRU cache",
619+ NULL,
620+ &statementCacheSize,
621+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
622+ 11,
623+ #endif
624+ 0, 512,
625+ PGC_USERSET,
626+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
627+ 0,
628+ #endif
629+ NULL, NULL);
630+
631+ DefineCustomBoolVariable(
632+ "pljava.release_lingering_savepoints",
633+ "If true, lingering savepoints will be released on function exit. If false, the will be rolled back",
634+ NULL,
635+ &pljavaReleaseLingeringSavepoints,
636+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
637+ false,
638+ #endif
639+ PGC_USERSET,
640+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
641+ 0,
642+ #endif
643+ NULL, NULL);
644+
645+ EmitWarningsOnPlaceholders("pljava");
646+ s_firstTimeInit = false;
647+ }
648+
649+#ifdef PLJAVA_DEBUG
650+ /* Hard setting for debug. Don't forget to recompile...
651+ */
652+ pljavaDebug = 1;
653+#endif
654+
655+ addUserJVMOptions(&optList);
656+ effectiveClassPath = getClassPath("-Djava.class.path=");
657+ if(effectiveClassPath != 0)
658+ {
659+ JVMOptList_add(&optList, effectiveClassPath, 0, true);
660+ }
661+
662+ /**
663+ * As stipulated by JRT-2003
664+ */
665+ JVMOptList_add(&optList,
666+ "-Dsqlj.defaultconnection=jdbc:default:connection",
667+ 0, true);
668+
669+ JVMOptList_add(&optList, "vfprintf", (void*)my_vfprintf, true);
670+#ifndef GCJ
671+ JVMOptList_add(&optList, "-Xrs", 0, true);
672+#endif
673+ if(pljavaDebug)
674+ {
675+ elog(INFO, "Backend pid = %d. Attach the debugger and set pljavaDebug to false to continue", getpid());
676+ while(pljavaDebug)
677+ pg_usleep(1000000L);
678+ }
679+
680+ vm_args.nOptions = optList.size;
681+ vm_args.options = optList.options;
682+ vm_args.version = JNI_VERSION_1_4;
683+ vm_args.ignoreUnrecognized = JNI_FALSE;
684+
685+ elog(DEBUG1, "Creating JavaVM");
686+
687+ jstat = JNI_createVM(&s_javaVM, &vm_args);
688+
689+ if(jstat == JNI_OK && JNI_exceptionCheck())
690+ {
691+ JNI_exceptionDescribe();
692+ JNI_exceptionClear();
693+ jstat = JNI_ERR;
694+ }
695+ JVMOptList_delete(&optList);
696+
697+ if(jstat != JNI_OK)
698+ ereport(ERROR, (errmsg("Failed to create Java VM")));
699+
700+#if !defined(WIN32)
701+ pqsignal(SIGINT, pljavaStatementCancelHandler);
702+ pqsignal(SIGTERM, pljavaDieHandler);
703+ pqsignal(SIGQUIT, pljavaQuickDieHandler);
704+#endif
705+ elog(DEBUG1, "JavaVM created");
706+
707+ /* Register an on_proc_exit handler that destroys the VM
708+ */
709+ on_proc_exit(_destroyJavaVM, 0);
710+ initPLJavaClasses();
711+ initJavaSession();
712+}
713+
714+static Datum internalCallHandler(bool trusted, PG_FUNCTION_ARGS);
715+
716+extern Datum javau_call_handler(PG_FUNCTION_ARGS);
717+PG_FUNCTION_INFO_V1(javau_call_handler);
718+
719+/*
720+ * This is the entry point for all untrusted calls.
721+ */
722+Datum javau_call_handler(PG_FUNCTION_ARGS)
723+{
724+ return internalCallHandler(false, fcinfo);
725+}
726+
727+extern Datum java_call_handler(PG_FUNCTION_ARGS);
728+PG_FUNCTION_INFO_V1(java_call_handler);
729+
730+/*
731+ * This is the entry point for all trusted calls.
732+ */
733+Datum java_call_handler(PG_FUNCTION_ARGS)
734+{
735+ return internalCallHandler(true, fcinfo);
736+}
737+
738+static Datum internalCallHandler(bool trusted, PG_FUNCTION_ARGS)
739+{
740+ Invocation ctx;
741+ Datum retval = 0;
742+
743+ if(s_javaVM == 0)
744+ {
745+ Invocation_pushBootContext(&ctx);
746+ PG_TRY();
747+ {
748+ initializeJavaVM();
749+ Invocation_popBootContext();
750+ }
751+ PG_CATCH();
752+ {
753+ Invocation_popBootContext();
754+
755+ /* JVM initialization failed for some reason. Destroy
756+ * the VM if it exists. Perhaps the user will try
757+ * fixing the pljava.classpath and make a new attempt.
758+ */
759+ _destroyJavaVM(0, 0);
760+
761+ /* We can't stay here...
762+ */
763+ PG_RE_THROW();
764+ }
765+ PG_END_TRY();
766+
767+ /* Force initial setting
768+ */
769+ s_currentTrust = !trusted;
770+ }
771+
772+ Invocation_pushInvocation(&ctx, trusted);
773+ PG_TRY();
774+ {
775+ Function function = Function_getFunction(fcinfo);
776+ if(CALLED_AS_TRIGGER(fcinfo))
777+ {
778+ /* Called as a trigger procedure
779+ */
780+ retval = Function_invokeTrigger(function, fcinfo);
781+ }
782+ else
783+ {
784+ /* Called as a function
785+ */
786+ retval = Function_invoke(function, fcinfo);
787+ }
788+ Invocation_popInvocation(false);
789+ }
790+ PG_CATCH();
791+ {
792+ Invocation_popInvocation(true);
793+ PG_RE_THROW();
794+ }
795+ PG_END_TRY();
796+ return retval;
797+}
798+
799+/****************************************
800+ * JNI methods
801+ ****************************************/
802+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
803+{
804+ return JNI_VERSION_1_4;
805+}
806+
807+/*
808+ * Class: org_postgresql_pljava_internal_Backend
809+ * Method: _getConfigOption
810+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
811+ */
812+JNIEXPORT jstring JNICALL
813+JNICALL Java_org_postgresql_pljava_internal_Backend__1getConfigOption(JNIEnv* env, jclass cls, jstring jkey)
814+{
815+ jstring result = 0;
816+
817+ BEGIN_NATIVE
818+ char* key = String_createNTS(jkey);
819+ if(key != 0)
820+ {
821+ PG_TRY();
822+ {
823+ #if (PGSQL_MAJOR_VER > 8)
824+ const char* value = GetConfigOption(key, true);
825+ #else
826+ const char* value = GetConfigOption(key);
827+ #endif
828+
829+ pfree(key);
830+ if(value != 0)
831+ result = String_createJavaStringFromNTS(value);
832+ }
833+ PG_CATCH();
834+ {
835+ Exception_throw_ERROR("GetConfigOption");
836+ }
837+ PG_END_TRY();
838+ }
839+ END_NATIVE
840+ return result;
841+}
842+
843+
844+/*
845+ * Class: org_postgresql_pljava_internal_Backend
846+ * Method: _getStatementCacheSize
847+ * Signature: ()I
848+ */
849+JNIEXPORT jint JNICALL
850+Java_org_postgresql_pljava_internal_Backend__1getStatementCacheSize(JNIEnv* env, jclass cls)
851+{
852+ return statementCacheSize;
853+}
854+
855+/*
856+ * Class: org_postgresql_pljava_internal_Backend
857+ * Method: _log
858+ * Signature: (ILjava/lang/String;)V
859+ */
860+JNIEXPORT void JNICALL
861+JNICALL Java_org_postgresql_pljava_internal_Backend__1log(JNIEnv* env, jclass cls, jint logLevel, jstring jstr)
862+{
863+ BEGIN_NATIVE_NO_ERRCHECK
864+ char* str = String_createNTS(jstr);
865+ if(str != 0)
866+ {
867+ /* elog uses printf formatting but the logger does not so we must escape all
868+ * '%' in the string.
869+ */
870+ char c;
871+ const char* cp;
872+ int percentCount = 0;
873+ for(cp = str; (c = *cp) != 0; ++cp)
874+ {
875+ if(c == '%')
876+ ++percentCount;
877+ }
878+
879+ if(percentCount > 0)
880+ {
881+ /* Make room to expand all "%" to "%%"
882+ */
883+ char* str2 = palloc((cp - str) + percentCount + 1);
884+ char* cp2 = str2;
885+
886+ /* Expand... */
887+ for(cp = str; (c = *cp) != 0; ++cp)
888+ {
889+ if(c == '%')
890+ *cp2++ = c;
891+ *cp2++ = c;
892+ }
893+ *cp2 = 0;
894+ pfree(str);
895+ str = str2;
896+ }
897+
898+ PG_TRY();
899+ {
900+ elog(logLevel, str);
901+ pfree(str);
902+ }
903+ PG_CATCH();
904+ {
905+ Exception_throw_ERROR("ereport");
906+ }
907+ PG_END_TRY();
908+ }
909+ END_NATIVE
910+}
911+
912+/*
913+ * Class: org_postgresql_pljava_internal_Backend
914+ * Method: isCallingJava
915+ * Signature: ()Z
916+ */
917+JNIEXPORT jboolean JNICALL
918+Java_org_postgresql_pljava_internal_Backend_isCallingJava(JNIEnv* env, jclass cls)
919+{
920+ return JNI_isCallingJava();
921+}
922+
923+/*
924+ * Class: org_postgresql_pljava_internal_Backend
925+ * Method: isReleaseLingeringSavepoints
926+ * Signature: ()Z
927+ */
928+JNIEXPORT jboolean JNICALL
929+Java_org_postgresql_pljava_internal_Backend_isReleaseLingeringSavepoints(JNIEnv* env, jclass cls)
930+{
931+ return pljavaReleaseLingeringSavepoints ? JNI_TRUE : JNI_FALSE;
932+}
933+
934+/*
935+ * Class: org_postgresql_pljava_internal_Backend
936+ * Method: _clearFunctionCache
937+ * Signature: ()V
938+ */
939+JNIEXPORT void JNICALL
940+Java_org_postgresql_pljava_internal_Backend__1clearFunctionCache(JNIEnv* env, jclass cls)
941+{
942+ BEGIN_NATIVE_NO_ERRCHECK
943+ Function_clearFunctionCache();
944+ END_NATIVE
945+}
946
947=== added file 'debian/patches/9.1_api.patch'
948--- debian/patches/9.1_api.patch 1970-01-01 00:00:00 +0000
949+++ debian/patches/9.1_api.patch 2011-09-06 19:13:35 +0000
950@@ -0,0 +1,74 @@
951+Description: Port to 9.1 API.
952+Author: Martin Pitt <martin.pitt@ubuntu.com>
953+Bug-Debian: http://bugs.debian.org/639461
954+
955+Index: postgresql-pljava/src/C/pljava/Backend.c
956+===================================================================
957+--- postgresql-pljava.orig/src/C/pljava/Backend.c 2011-09-06 19:16:02.775995582 +0200
958++++ postgresql-pljava/src/C/pljava/Backend.c 2011-09-06 19:18:04.105996380 +0200
959+@@ -534,9 +534,9 @@
960+ static void checkIntTimeType(void)
961+ {
962+ #if (PGSQL_MAJOR_VER > 8)
963+- const char* idt = GetConfigOption("integer_datetimes", true);
964++ const char* idt = GetConfigOption("integer_datetimes", true, false);
965+ #else
966+- const char* idt = GetConfigOption("integer_datetimes");
967++ const char* idt = GetConfigOption("integer_datetimes", false);
968+ #endif
969+
970+ integerDateTimes = (strcmp(idt, "on") == 0);
971+@@ -573,7 +573,7 @@
972+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
973+ 0,
974+ #endif
975+- NULL, NULL);
976++ NULL, NULL, NULL);
977+
978+ DefineCustomStringVariable(
979+ "pljava.classpath",
980+@@ -587,7 +587,7 @@
981+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
982+ 0,
983+ #endif
984+- NULL, NULL);
985++ NULL, NULL, NULL);
986+
987+ DefineCustomBoolVariable(
988+ "pljava.debug",
989+@@ -601,7 +601,7 @@
990+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
991+ 0,
992+ #endif
993+- NULL, NULL);
994++ NULL, NULL, NULL);
995+
996+ DefineCustomIntVariable(
997+ "pljava.statement_cache_size",
998+@@ -616,7 +616,7 @@
999+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
1000+ 0,
1001+ #endif
1002+- NULL, NULL);
1003++ NULL, NULL, NULL);
1004+
1005+ DefineCustomBoolVariable(
1006+ "pljava.release_lingering_savepoints",
1007+@@ -630,7 +630,7 @@
1008+ #if (PGSQL_MAJOR_VER > 8 || (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER > 3))
1009+ 0,
1010+ #endif
1011+- NULL, NULL);
1012++ NULL, NULL, NULL);
1013+
1014+ EmitWarningsOnPlaceholders("pljava");
1015+ s_firstTimeInit = false;
1016+@@ -811,7 +811,7 @@
1017+ PG_TRY();
1018+ {
1019+ #if (PGSQL_MAJOR_VER > 8)
1020+- const char* value = GetConfigOption(key, true);
1021++ const char* value = GetConfigOption(key, true, false);
1022+ #else
1023+ const char* value = GetConfigOption(key);
1024+ #endif
1025
1026=== renamed file 'debian/patches/9.1_api.patch' => 'debian/patches/9.1_api.patch.moved'

Subscribers

People subscribed via source and target branches

to all changes: