java.lang.Object
org.postgresql.pljava.internal.Backend
Provides access to some useful routines in the PostgreSQL server.
- Author:
- Thomas Hallgren
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ThreadLocal
<Boolean> Will beBoolean.TRUE
on the one primordial thread first entered from PG, and null on any other thread.static final Object
All native calls synchronize on this object.static final BooleanSupplier
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static <E extends Throwable>
booleandoInPG
(Checked.BooleanSupplier<E> op) Specialization ofdoInPG
for operations that return a boolean result.static <E extends Throwable>
bytedoInPG
(Checked.ByteSupplier<E> op) Specialization ofdoInPG
for operations that return a byte result.static <E extends Throwable>
chardoInPG
(Checked.CharSupplier<E> op) Specialization ofdoInPG
for operations that return a char result.static <E extends Throwable>
doubledoInPG
(Checked.DoubleSupplier<E> op) Specialization ofdoInPG
for operations that return a double result.static <E extends Throwable>
floatdoInPG
(Checked.FloatSupplier<E> op) Specialization ofdoInPG
for operations that return a float result.static <E extends Throwable>
intdoInPG
(Checked.IntSupplier<E> op) Specialization ofdoInPG
for operations that return an int result.static <E extends Throwable>
longdoInPG
(Checked.LongSupplier<E> op) Specialization ofdoInPG
for operations that return a long result.static <E extends Throwable>
voiddoInPG
(Checked.Runnable<E> op) Specialization ofdoInPG
for operations that return no result.static <E extends Throwable>
shortdoInPG
(Checked.ShortSupplier<E> op) Specialization ofdoInPG
for operations that return a short result.static <T,
E extends Throwable>
TdoInPG
(Checked.Supplier<T, E> op) Do an operation on a thread with serialized access to call into PostgreSQL, returning a result.static String
getConfigOption
(String key) Returns the configuration option as read from the Global Unified Config package (GUC).static List
<Lexicals.Identifier.Simple> static int
Returns the size of the statement cache.static boolean
Returnstrue
if the backend is awaiting a return from a call into the JVM.static boolean
static boolean
Returns the value of the GUC custom variablepljava.release_lingering_savepoints
.static void
Log a message using the internal elog command.static String
Returns the path of PL/Java's shared library.static boolean
Return true if the current thread may JNI-call into Postgres.
-
Field Details
-
THREADLOCK
All native calls synchronize on this object. -
IAMPGTHREAD
Will beBoolean.TRUE
on the one primordial thread first entered from PG, and null on any other thread. -
validateBodies
-
-
Constructor Details
-
Backend
public Backend()
-
-
Method Details
-
doInPG
Do an operation on a thread with serialized access to call into PostgreSQL, returning a result.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return no result. This version must be present, as the Java compiler will not automagically match a void lambda or method reference toSupplier<Void>
.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return a boolean result. This method need not be present: without it, the Java compiler will happily match boolean lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return a double result. This method need not be present: without it, the Java compiler will happily match double lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return an int result. This method need not be present: without it, the Java compiler will happily match int lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return a long result. This method need not be present: without it, the Java compiler will happily match long lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return a float result. This method need not be present: without it, the Java compiler will happily match float lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return a short result. This method need not be present: without it, the Java compiler will happily match short lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return a char result. This method need not be present: without it, the Java compiler will happily match char lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
doInPG
Specialization ofdoInPG
for operations that return a byte result. This method need not be present: without it, the Java compiler will happily match int lambdas or method references to the generic method, at the small cost of some boxing/unboxing; providing this method simply allows that to be avoided.- Throws:
E
-
threadMayEnterPG
public static boolean threadMayEnterPG()Return true if the current thread may JNI-call into Postgres.In PL/Java's threading model, only one thread (or only one thread at a time, depending on the setting of
pljava.java_thread_pg_entry
) may make calls into the native PostgreSQL code.Note: The setting
pljava.java_thread_pg_entry=error
is an exception; under that setting this method will return true for any thread that acquires theTHREADLOCK
monitor, but any such thread that isn't the actual original PG thread will have an exception thrown if it calls into PG.Under the setting
pljava.java_thread_pg_entry=throw
, this method will only return true for the one primordial PG thread (and there is noTHREADLOCK
object to do any monitor operations on).- Returns:
- true if the current thread is the one prepared to enter PG.
-
getConfigOption
Returns the configuration option as read from the Global Unified Config package (GUC).- Parameters:
key
- The name of the option.- Returns:
- The value of the option.
-
getListConfigOption
- Throws:
SQLException
-
getStatementCacheSize
public static int getStatementCacheSize()Returns the size of the statement cache.- Returns:
- the size of the statement cache.
-
log
Log a message using the internal elog command.- Parameters:
logLevel
- The log level as defined inELogHandler
.str
- The message
-
clearFunctionCache
public static void clearFunctionCache() -
isCreatingExtension
public static boolean isCreatingExtension() -
myLibraryPath
Returns the path of PL/Java's shared library.- Throws:
SQLException
- if for some reason it can't be determined.
-
isCallingJava
public static boolean isCallingJava()Returnstrue
if the backend is awaiting a return from a call into the JVM. This method will only returnfalse
when called from a thread other then the main thread and the main thread has returned from the call into the JVM. -
isReleaseLingeringSavepoints
public static boolean isReleaseLingeringSavepoints()Returns the value of the GUC custom variablepljava.release_lingering_savepoints
.
-