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

Proposed by Ubuntu Package Importer
Status: Rejected
Rejected by: Martin Pitt
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) (has conflicts)
2 files modified
.pc/9.1_api.patch/src/C/pljava/Backend.c (+935/-0)
debian/patches/9.1_api.patch (+74/-0)
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-Tolomelli Disapprove
Ubuntu branches 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.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

usual quilt 3 conflict

review: Disapprove

Unmerged revisions

10. By Martin Pitt

releasing version 1.4.2-4ubuntu1

9. By Martin Pitt

Add 9.1_api.patch: Port to 9.1 API.

8. By Martin Pitt

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

Preview Diff

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