Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mc-soi/cce26e0e6186d416a9cc to your computer and use it in GitHub Desktop.
Save mc-soi/cce26e0e6186d416a9cc to your computer and use it in GitHub Desktop.
jdbc_fdw patch for PostgreSQL 9.5 and side by side installation of jdbc2_fdw
diff --git a/JDBC1DriverLoader.java b/JDBC1DriverLoader.java
index 4ccc8f1..31969db 100644
--- a/JDBC1DriverLoader.java
+++ b/JDBC1DriverLoader.java
@@ -9,7 +9,7 @@
* Author: Atri Sharma <atri.jiit@gmail.com>
*
* IDENTIFICATION
- * jdbc_fdw/JDBCDriverLoader.java
+ * jdbc_fdw/JDBC1DriverLoader.java
*
*-------------------------------------------------------------------------
*/
@@ -19,15 +19,15 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.net.MalformedURLException;
-public class JDBCDriverLoader extends URLClassLoader
+public class JDBC1DriverLoader extends URLClassLoader
{
/*
- * JDBCDriverLoader
- * Constructor of JDBCDriverLoader class.
+ * JDBC1DriverLoader
+ * Constructor of JDBC1DriverLoader class.
*/
public
- JDBCDriverLoader(URL[] path)
+ JDBC1DriverLoader(URL[] path)
{
super(path);
}
diff --git a/JDBC1Utils.java b/JDBC1Utils.java
index 31425f5..a393124 100644
--- a/JDBC1Utils.java
+++ b/JDBC1Utils.java
@@ -9,7 +9,7 @@
* Author: Atri Sharma <atri.jiit@gmail.com>
*
* IDENTIFICATION
- * jdbc_fdw/JDBCUtils.java
+ * jdbc_fdw/JDBC1Utils.java
*
*-------------------------------------------------------------------------
*/
@@ -21,7 +21,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.net.MalformedURLException;
import java.util.*;
-public class JDBCUtils
+public class JDBC1Utils
{
private ResultSet result_set;
private Connection conn;
@@ -29,7 +29,7 @@ public class JDBCUtils
private int NumberOfRows;
private Statement sql;
private String[] Iterate;
- private static JDBCDriverLoader JDBC_Driver_Loader;
+ private static JDBC1DriverLoader JDBC_Driver_Loader;
private StringWriter exception_stack_trace_string_writer;
private PrintWriter exception_stack_trace_print_writer;
@@ -68,7 +68,7 @@ public class JDBCUtils
{
/* If JDBC_Driver_Loader is being
* created. */
- JDBC_Driver_Loader = new JDBCDriverLoader(new URL[]{JarFile.toURI().toURL()});
+ JDBC_Driver_Loader = new JDBC1DriverLoader(new URL[]{JarFile.toURI().toURL()});
}
else if (JDBC_Driver_Loader.CheckIfClassIsLoaded(DriverClassName) == null)
{
diff --git a/Makefile b/Makefile
index bab9846..c3d7249 100644
--- a/Makefile
+++ b/Makefile
@@ -34,8 +34,8 @@ endif
TRGTS = JAVAFILES
JAVA_SOURCES = \
- JDBCUtils.java \
- JDBCDriverLoader.java \
+ JDBC1Utils.java \
+ JDBC1DriverLoader.java \
PG_CPPFLAGS=-D'PKG_LIB_DIR=$(pkglibdir)'
diff --git a/jdbc_fdw.c b/jdbc_fdw.c
index b79ba10..a4506f7 100644
--- a/jdbc_fdw.c
+++ b/jdbc_fdw.c
@@ -186,18 +186,18 @@ SIGINTInterruptCheckProcess()
if (InterruptFlag == true)
{
- jclass JDBCUtilsClass;
+ jclass JDBC1UtilsClass;
jmethodID id_cancel;
jstring cancel_result = NULL;
char *cancel_result_cstring = NULL;
- JDBCUtilsClass = (*env)->FindClass(env, "JDBCUtils");
- if (JDBCUtilsClass == NULL)
+ JDBC1UtilsClass = (*env)->FindClass(env, "JDBC1Utils");
+ if (JDBC1UtilsClass == NULL)
{
- elog(ERROR, "JDBCUtilsClass is NULL");
+ elog(ERROR, "JDBC1UtilsClass is NULL");
}
- id_cancel = (*env)->GetMethodID(env, JDBCUtilsClass, "Cancel", "()Ljava/lang/String;");
+ id_cancel = (*env)->GetMethodID(env, JDBC1UtilsClass, "Cancel", "()Ljava/lang/String;");
if (id_cancel == NULL)
{
elog(ERROR, "id_cancel is NULL");
@@ -780,7 +780,7 @@ jdbcBeginForeignScan(ForeignScanState *node, int eflags)
int svr_maxheapsize = 0;
jdbcFdwExecutionState *festate;
char *query;
- jclass JDBCUtilsClass;
+ jclass JDBC1UtilsClass;
jclass JavaString;
jstring StringArray[7];
jstring initialize_result = NULL;
@@ -830,19 +830,19 @@ jdbcBeginForeignScan(ForeignScanState *node, int eflags)
festate->NumberOfRows = 0;
/* Connect to the server and execute the query */
- JDBCUtilsClass = (*env)->FindClass(env, "JDBCUtils");
- if (JDBCUtilsClass == NULL)
+ JDBC1UtilsClass = (*env)->FindClass(env, "JDBC1Utils");
+ if (JDBC1UtilsClass == NULL)
{
- elog(ERROR, "JDBCUtilsClass is NULL");
+ elog(ERROR, "JDBC1UtilsClass is NULL");
}
- id_initialize = (*env)->GetMethodID(env, JDBCUtilsClass, "Initialize", "([Ljava/lang/String;)Ljava/lang/String;");
+ id_initialize = (*env)->GetMethodID(env, JDBC1UtilsClass, "Initialize", "([Ljava/lang/String;)Ljava/lang/String;");
if (id_initialize == NULL)
{
elog(ERROR, "id_initialize is NULL");
}
- id_numberofcolumns = (*env)->GetFieldID(env, JDBCUtilsClass, "NumberOfColumns" , "I");
+ id_numberofcolumns = (*env)->GetFieldID(env, JDBC1UtilsClass, "NumberOfColumns" , "I");
if (id_numberofcolumns == NULL)
{
elog(ERROR, "id_numberofcolumns is NULL");
@@ -885,7 +885,7 @@ jdbcBeginForeignScan(ForeignScanState *node, int eflags)
(*env)->SetObjectArrayElement(env, arg_array, counter, StringArray[counter]);
}
- java_call = (*env)->AllocObject(env, JDBCUtilsClass);
+ java_call = (*env)->AllocObject(env, JDBC1UtilsClass);
if (java_call == NULL)
{
elog(ERROR, "java_call is NULL");
@@ -924,7 +924,7 @@ jdbcIterateForeignScan(ForeignScanState *node)
char **values;
HeapTuple tuple;
jmethodID id_returnresultset;
- jclass JDBCUtilsClass;
+ jclass JDBC1UtilsClass;
jobjectArray java_rowarray;
int i = 0;
int j = 0;
@@ -945,13 +945,13 @@ jdbcIterateForeignScan(ForeignScanState *node)
}
- JDBCUtilsClass = (*env)->FindClass(env, "JDBCUtils");
- if (JDBCUtilsClass == NULL)
+ JDBC1UtilsClass = (*env)->FindClass(env, "JDBC1Utils");
+ if (JDBC1UtilsClass == NULL)
{
- elog(ERROR, "JDBCUtilsClass is NULL");
+ elog(ERROR, "JDBC1UtilsClass is NULL");
}
- id_returnresultset = (*env)->GetMethodID(env, JDBCUtilsClass, "ReturnResultSet", "()[Ljava/lang/String;");
+ id_returnresultset = (*env)->GetMethodID(env, JDBC1UtilsClass, "ReturnResultSet", "()[Ljava/lang/String;");
if (id_returnresultset == NULL)
{
elog(ERROR, "id_returnresultset is NULL");
@@ -996,7 +996,7 @@ static void
jdbcEndForeignScan(ForeignScanState *node)
{
jmethodID id_close;
- jclass JDBCUtilsClass;
+ jclass JDBC1UtilsClass;
jstring close_result = NULL;
char *close_result_cstring = NULL;
jdbcFdwExecutionState *festate = (jdbcFdwExecutionState *) node->fdw_state;
@@ -1004,13 +1004,13 @@ jdbcEndForeignScan(ForeignScanState *node)
SIGINTInterruptCheckProcess();
- JDBCUtilsClass = (*env)->FindClass(env, "JDBCUtils");
- if (JDBCUtilsClass == NULL)
+ JDBC1UtilsClass = (*env)->FindClass(env, "JDBC1Utils");
+ if (JDBC1UtilsClass == NULL)
{
- elog(ERROR, "JDBCUtilsClass is NULL");
+ elog(ERROR, "JDBC1UtilsClass is NULL");
}
- id_close = (*env)->GetMethodID(env, JDBCUtilsClass, "Close", "()Ljava/lang/String;");
+ id_close = (*env)->GetMethodID(env, JDBC1UtilsClass, "Close", "()Ljava/lang/String;");
if (id_close == NULL)
{
elog(ERROR, "id_close is NULL");
@@ -1076,7 +1076,7 @@ jdbcGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid, F
scan_clauses = extract_actual_clauses(scan_clauses, false);
/* Create the ForeignScan node */
- return (make_foreignscan(tlist, scan_clauses, scan_relid, NIL, NIL));
+ return (make_foreignscan(tlist, scan_clauses, scan_relid, NIL, NIL, NIL));
}
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment