mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
git90.msg + git91.msg
This commit is contained in:
25
storage/connect/.gitattributes
vendored
Normal file
25
storage/connect/.gitattributes
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Explicitly declare text files you want to always be normalized and converted
|
||||||
|
# to native line endings on checkout.
|
||||||
|
*.c text
|
||||||
|
*.cc text
|
||||||
|
*.cpp text
|
||||||
|
*.h text
|
||||||
|
*.test text
|
||||||
|
|
||||||
|
# Declare files that will always have LF line endings on checkout.
|
||||||
|
*.result text eol=lf
|
||||||
|
mysql-test/connect/std_data/*.txt text eol=lf
|
||||||
|
mysql-test/connect/std_data/*.dat text eol=lf
|
||||||
|
|
||||||
|
# Denote all files that are truly binary and should not be modified.
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
|
||||||
|
*.c diff=cpp
|
||||||
|
*.h diff=cpp
|
||||||
|
*.cc diff=cpp
|
||||||
|
*.ic diff=cpp
|
||||||
|
*.cpp diff=cpp
|
264
storage/connect/.gitignore
vendored
Normal file
264
storage/connect/.gitignore
vendored
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
# Edited by Olivier Bertrand
|
||||||
|
*-t
|
||||||
|
*.a
|
||||||
|
*.ctest
|
||||||
|
*.o
|
||||||
|
*.reject
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.spec
|
||||||
|
*~
|
||||||
|
*.bak
|
||||||
|
*.log
|
||||||
|
*.cmake
|
||||||
|
*.tgz
|
||||||
|
*.msg
|
||||||
|
.*.swp
|
||||||
|
*.ninja
|
||||||
|
.ninja_*
|
||||||
|
.gdb_history
|
||||||
|
|
||||||
|
CMakeFiles/
|
||||||
|
connect.dir/
|
||||||
|
connect.dir-Copie/
|
||||||
|
Debug/
|
||||||
|
MinSizeRel/
|
||||||
|
Release/
|
||||||
|
RelWithDebInfo/
|
||||||
|
|
||||||
|
# C and C++
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
*.exp
|
||||||
|
*.manifest
|
||||||
|
*.dep
|
||||||
|
*.idb
|
||||||
|
*.res
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lib
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lai
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
*.ncb
|
||||||
|
*.sln
|
||||||
|
|
||||||
|
*.vcproj
|
||||||
|
*.vcproj.*
|
||||||
|
*.vcproj.*.*
|
||||||
|
*.vcproj.*.*.*
|
||||||
|
*.vcxproj
|
||||||
|
*.vcxproj.*
|
||||||
|
*.vcxproj.*.*
|
||||||
|
*.vcxproj.*.*.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
build/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# Roslyn cache directories
|
||||||
|
*.ide/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
#NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding addin-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# If using the old MSBuild-Integrated Package Restore, uncomment this:
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
# sql/
|
||||||
|
*.Cache
|
||||||
|
ClientBin/
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
@@ -37,7 +37,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
|
|||||||
#
|
#
|
||||||
# Definitions that are shared for all OSes
|
# Definitions that are shared for all OSes
|
||||||
#
|
#
|
||||||
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS )
|
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
|
||||||
add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT )
|
add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT )
|
||||||
|
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON)
|
|||||||
|
|
||||||
IF(CONNECT_WITH_JDBC)
|
IF(CONNECT_WITH_JDBC)
|
||||||
# TODO: detect Java SDK and the presence of JDBC connectors
|
# TODO: detect Java SDK and the presence of JDBC connectors
|
||||||
# TODO: Find how to compile and install the JdbcInterface.java class
|
# TODO: Find how to compile and install the java wrapper class
|
||||||
# Find required libraries and include directories
|
# Find required libraries and include directories
|
||||||
|
|
||||||
FIND_PACKAGE(Java)
|
FIND_PACKAGE(Java)
|
||||||
@@ -251,6 +251,8 @@ IF(CONNECT_WITH_JDBC)
|
|||||||
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY})
|
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY})
|
||||||
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
|
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
|
||||||
JdbcInterface.java JdbcInterface.class
|
JdbcInterface.java JdbcInterface.class
|
||||||
|
JdbcDSInterface.java JdbcDSInterface.class
|
||||||
|
JdbcApacheInterface.java JdbcApacheInterface.class
|
||||||
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h)
|
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h)
|
||||||
add_definitions(-DJDBC_SUPPORT)
|
add_definitions(-DJDBC_SUPPORT)
|
||||||
ELSE()
|
ELSE()
|
||||||
|
BIN
storage/connect/JdbcApacheInterface.class
Normal file
BIN
storage/connect/JdbcApacheInterface.class
Normal file
Binary file not shown.
709
storage/connect/JdbcApacheInterface.java
Normal file
709
storage/connect/JdbcApacheInterface.java
Normal file
@@ -0,0 +1,709 @@
|
|||||||
|
import java.math.*;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
|
||||||
|
public class JdbcApacheInterface {
|
||||||
|
boolean DEBUG = false;
|
||||||
|
String Errmsg = "No error";
|
||||||
|
Connection conn = null;
|
||||||
|
DatabaseMetaData dbmd = null;
|
||||||
|
Statement stmt = null;
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
ResultSetMetaData rsmd = null;
|
||||||
|
static Hashtable<String,BasicDataSource> pool = new Hashtable<String, BasicDataSource>();
|
||||||
|
|
||||||
|
// === Constructors/finalize =========================================
|
||||||
|
public JdbcApacheInterface() {
|
||||||
|
this(true);
|
||||||
|
} // end of default constructor
|
||||||
|
|
||||||
|
public JdbcApacheInterface(boolean b) {
|
||||||
|
DEBUG = b;
|
||||||
|
} // end of constructor
|
||||||
|
|
||||||
|
private void SetErrmsg(Exception e) {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
|
||||||
|
Errmsg = e.toString();
|
||||||
|
} // end of SetErrmsg
|
||||||
|
|
||||||
|
private void SetErrmsg(String s) {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println(s);
|
||||||
|
|
||||||
|
Errmsg = s;
|
||||||
|
} // end of SetErrmsg
|
||||||
|
|
||||||
|
public String GetErrmsg() {
|
||||||
|
String err = Errmsg;
|
||||||
|
|
||||||
|
Errmsg = "No error";
|
||||||
|
return err;
|
||||||
|
} // end of GetErrmsg
|
||||||
|
|
||||||
|
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
|
||||||
|
int rc = 0;
|
||||||
|
String url = parms[1];
|
||||||
|
BasicDataSource ds = null;
|
||||||
|
|
||||||
|
if (url == null) {
|
||||||
|
SetErrmsg("URL cannot be null");
|
||||||
|
return -1;
|
||||||
|
} // endif url
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ((ds = pool.get(url)) == null) {
|
||||||
|
ds = new BasicDataSource();
|
||||||
|
ds.setDriverClassName(parms[0]);
|
||||||
|
ds.setUrl(url);
|
||||||
|
ds.setUsername(parms[2]);
|
||||||
|
ds.setPassword(parms[3]);
|
||||||
|
pool.put(url, ds);
|
||||||
|
} // endif ds
|
||||||
|
|
||||||
|
// Get a connection from the data source
|
||||||
|
conn = ds.getConnection();
|
||||||
|
|
||||||
|
// Get the data base meta data object
|
||||||
|
dbmd = conn.getMetaData();
|
||||||
|
|
||||||
|
// Get a statement from the connection
|
||||||
|
if (scrollable)
|
||||||
|
stmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||||
|
else
|
||||||
|
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Statement type = " + stmt.getResultSetType()
|
||||||
|
+ " concurrency = " + stmt.getResultSetConcurrency());
|
||||||
|
|
||||||
|
if (DEBUG) // Get the fetch size of a statement
|
||||||
|
System.out.println("Default fetch size = " + stmt.getFetchSize());
|
||||||
|
|
||||||
|
if (fsize != 0) {
|
||||||
|
// Set the fetch size
|
||||||
|
stmt.setFetchSize(fsize);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("New fetch size = " + stmt.getFetchSize());
|
||||||
|
|
||||||
|
} // endif fsize
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc = -2;
|
||||||
|
} catch( Exception e ) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
rc = -3;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
} // end of JdbcConnect
|
||||||
|
|
||||||
|
public int CreatePrepStmt(String sql) {
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
pstmt = conn.prepareStatement(sql);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
rc = -2;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
} // end of CreatePrepStmt
|
||||||
|
|
||||||
|
public void SetStringParm(int i, String s) {
|
||||||
|
try {
|
||||||
|
pstmt.setString(i, s);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetStringParm
|
||||||
|
|
||||||
|
public void SetIntParm(int i, int n) {
|
||||||
|
try {
|
||||||
|
pstmt.setInt(i, n);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetIntParm
|
||||||
|
|
||||||
|
public void SetShortParm(int i, short n) {
|
||||||
|
try {
|
||||||
|
pstmt.setShort(i, n);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetShortParm
|
||||||
|
|
||||||
|
public void SetBigintParm(int i, long n) {
|
||||||
|
try {
|
||||||
|
pstmt.setLong(i, n);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetBigintParm
|
||||||
|
|
||||||
|
public void SetFloatParm(int i, float f) {
|
||||||
|
try {
|
||||||
|
pstmt.setFloat(i, f);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetFloatParm
|
||||||
|
|
||||||
|
public void SetDoubleParm(int i, double d) {
|
||||||
|
try {
|
||||||
|
pstmt.setDouble(i, d);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetDoubleParm
|
||||||
|
|
||||||
|
public void SetTimestampParm(int i, Timestamp t) {
|
||||||
|
try {
|
||||||
|
pstmt.setTimestamp(i, t);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetTimestampParm
|
||||||
|
|
||||||
|
public int ExecutePrep() {
|
||||||
|
int n = -3;
|
||||||
|
|
||||||
|
if (pstmt != null) try {
|
||||||
|
n = pstmt.executeUpdate();
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
n = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
n = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return n;
|
||||||
|
} // end of ExecutePrep
|
||||||
|
|
||||||
|
public boolean ClosePrepStmt() {
|
||||||
|
boolean b = false;
|
||||||
|
|
||||||
|
if (pstmt != null) try {
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
b = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
b = true;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return b;
|
||||||
|
} // end of ClosePrepStmt
|
||||||
|
|
||||||
|
public int JdbcDisconnect() {
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
// Cancel pending statement
|
||||||
|
if (stmt != null)
|
||||||
|
try {
|
||||||
|
System.out.println("Cancelling statement");
|
||||||
|
stmt.cancel();
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc += 1;
|
||||||
|
} // nothing more we can do
|
||||||
|
|
||||||
|
// Close the statement and the connection
|
||||||
|
if (rs != null)
|
||||||
|
try {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Closing result set");
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc = 2;
|
||||||
|
} // nothing more we can do
|
||||||
|
|
||||||
|
if (stmt != null)
|
||||||
|
try {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Closing statement");
|
||||||
|
|
||||||
|
stmt.close();
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc += 4;
|
||||||
|
} // nothing more we can do
|
||||||
|
|
||||||
|
ClosePrepStmt();
|
||||||
|
|
||||||
|
if (conn != null)
|
||||||
|
try {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Closing connection");
|
||||||
|
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc += 8;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("All closed");
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
} // end of JdbcDisconnect
|
||||||
|
|
||||||
|
public int GetMaxValue(int n) {
|
||||||
|
int m = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch (n) {
|
||||||
|
case 1: // Max columns in table
|
||||||
|
m = dbmd.getMaxColumnsInTable();
|
||||||
|
break;
|
||||||
|
case 2: // Max catalog name length
|
||||||
|
m = dbmd.getMaxCatalogNameLength();
|
||||||
|
break;
|
||||||
|
case 3: // Max schema name length
|
||||||
|
m = dbmd.getMaxSchemaNameLength();
|
||||||
|
break;
|
||||||
|
case 4: // Max table name length
|
||||||
|
m = dbmd.getMaxTableNameLength();
|
||||||
|
break;
|
||||||
|
case 5: // Max column name length
|
||||||
|
m = dbmd.getMaxColumnNameLength();
|
||||||
|
break;
|
||||||
|
} // endswitch n
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
m = -1;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return m;
|
||||||
|
} // end of GetMaxValue
|
||||||
|
|
||||||
|
public int GetColumns(String[] parms) {
|
||||||
|
int ncol = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (rs != null) rs.close();
|
||||||
|
rs = dbmd.getColumns(parms[0], parms[1], parms[2], parms[3]);
|
||||||
|
|
||||||
|
if (rs != null) {
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
} // endif rs
|
||||||
|
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of GetColumns
|
||||||
|
|
||||||
|
public int GetTables(String[] parms) {
|
||||||
|
int ncol = 0;
|
||||||
|
String[] typ = null;
|
||||||
|
|
||||||
|
if (parms[3] != null) {
|
||||||
|
typ = new String[1];
|
||||||
|
typ[0] = parms[3];
|
||||||
|
} // endif parms
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (rs != null) rs.close();
|
||||||
|
rs = dbmd.getTables(parms[0], parms[1], parms[2], typ);
|
||||||
|
|
||||||
|
if (rs != null) {
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
} // endif rs
|
||||||
|
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of GetColumns
|
||||||
|
|
||||||
|
public int Execute(String query) {
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Executing '" + query + "'");
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean b = stmt.execute(query);
|
||||||
|
|
||||||
|
if (b == false) {
|
||||||
|
n = stmt.getUpdateCount();
|
||||||
|
if (rs != null) rs.close();
|
||||||
|
} // endif b
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Query '" + query + "' executed: n = " + n);
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
n = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
n = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return n;
|
||||||
|
} // end of Execute
|
||||||
|
|
||||||
|
public int GetResult() {
|
||||||
|
int ncol = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
rs = stmt.getResultSet();
|
||||||
|
|
||||||
|
if (rs != null) {
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Result set has " + rsmd.getColumnCount() + " column(s)");
|
||||||
|
|
||||||
|
} // endif rs
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
ncol = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
ncol = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of GetResult
|
||||||
|
|
||||||
|
public int ExecuteQuery(String query) {
|
||||||
|
int ncol = 0;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Executing query '" + query + "'");
|
||||||
|
|
||||||
|
try {
|
||||||
|
rs = stmt.executeQuery(query);
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
System.out.println("Query '" + query + "' executed successfully");
|
||||||
|
System.out.println("Result set has " + rsmd.getColumnCount() + " column(s)");
|
||||||
|
} // endif DEBUG
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
ncol = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
ncol = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of ExecuteQuery
|
||||||
|
|
||||||
|
public int ExecuteUpdate(String query) {
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Executing update query '" + query + "'");
|
||||||
|
|
||||||
|
try {
|
||||||
|
n = stmt.executeUpdate(query);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Update Query '" + query + "' executed: n = " + n);
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
n = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
n = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return n;
|
||||||
|
} // end of ExecuteUpdate
|
||||||
|
|
||||||
|
public int ReadNext() {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
return rs.next() ? 1 : 0;
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
return -1;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
} else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} // end of ReadNext
|
||||||
|
|
||||||
|
public boolean Fetch(int row) {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
return rs.absolute(row);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
return false;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} // end of Fetch
|
||||||
|
|
||||||
|
public String ColumnName(int n) {
|
||||||
|
if (rsmd == null) {
|
||||||
|
System.out.println("No result metadata");
|
||||||
|
} else try {
|
||||||
|
return rsmd.getColumnLabel(n);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of ColumnName
|
||||||
|
|
||||||
|
public int ColumnType(int n, String name) {
|
||||||
|
if (rsmd == null) {
|
||||||
|
System.out.println("No result metadata");
|
||||||
|
} else try {
|
||||||
|
if (n == 0)
|
||||||
|
n = rs.findColumn(name);
|
||||||
|
|
||||||
|
return rsmd.getColumnType(n);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 666; // Not a type
|
||||||
|
} // end of ColumnType
|
||||||
|
|
||||||
|
public String ColumnDesc(int n, int[] val) {
|
||||||
|
if (rsmd == null) {
|
||||||
|
System.out.println("No result metadata");
|
||||||
|
return null;
|
||||||
|
} else try {
|
||||||
|
val[0] = rsmd.getColumnType(n);
|
||||||
|
val[1] = rsmd.getPrecision(n);
|
||||||
|
val[2] = rsmd.getScale(n);
|
||||||
|
val[3] = rsmd.isNullable(n);
|
||||||
|
return rsmd.getColumnLabel(n);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of ColumnDesc
|
||||||
|
|
||||||
|
public String StringField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getString(n) : rs.getString(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of StringField
|
||||||
|
|
||||||
|
public int IntField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getInt(n) : rs.getInt(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of IntField
|
||||||
|
|
||||||
|
public long BigintField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
BigDecimal bigDecimal = (n > 0) ? rs.getBigDecimal(n) : rs.getBigDecimal(name);
|
||||||
|
return bigDecimal != null ? bigDecimal.longValue() : 0;
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of BiginttField
|
||||||
|
|
||||||
|
public double DoubleField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getDouble(n) : rs.getDouble(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0.;
|
||||||
|
} // end of DoubleField
|
||||||
|
|
||||||
|
public float FloatField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getFloat(n) : rs.getFloat(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of FloatField
|
||||||
|
|
||||||
|
public boolean BooleanField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getBoolean(n) : rs.getBoolean(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // end of BooleanField
|
||||||
|
|
||||||
|
public Date DateField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getDate(n) : rs.getDate(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of DateField
|
||||||
|
|
||||||
|
public Time TimeField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getTime(n) : rs.getTime(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of TimeField
|
||||||
|
|
||||||
|
public Timestamp TimestampField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getTimestamp(n) : rs.getTimestamp(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of TimestampField
|
||||||
|
|
||||||
|
public String ObjectField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getObject(n).toString() : rs.getObject(name).toString();
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of ObjectField
|
||||||
|
|
||||||
|
public int GetDrivers(String[] s, int mxs) {
|
||||||
|
int n = 0;
|
||||||
|
List<Driver> drivers = Collections.list(DriverManager.getDrivers());
|
||||||
|
int size = Math.min(mxs, drivers.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
Driver driver = (Driver)drivers.get(i);
|
||||||
|
|
||||||
|
// Get name of driver
|
||||||
|
s[n++] = driver.getClass().getName();
|
||||||
|
|
||||||
|
// Get version info
|
||||||
|
s[n++] = driver.getMajorVersion() + "." + driver.getMinorVersion();
|
||||||
|
s[n++] = driver.jdbcCompliant() ? "Yes" : "No";
|
||||||
|
s[n++] = driver.toString();
|
||||||
|
} // endfor i
|
||||||
|
|
||||||
|
return size;
|
||||||
|
} // end of GetDrivers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified path to the java library path
|
||||||
|
* from Fahd Shariff blog
|
||||||
|
*
|
||||||
|
* @param pathToAdd the path to add
|
||||||
|
static public int addLibraryPath(String pathToAdd) {
|
||||||
|
System.out.println("jpath = " + pathToAdd);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths");
|
||||||
|
usrPathsField.setAccessible(true);
|
||||||
|
|
||||||
|
//get array of paths
|
||||||
|
String[] paths = (String[])usrPathsField.get(null);
|
||||||
|
|
||||||
|
//check if the path to add is already present
|
||||||
|
for (String path : paths) {
|
||||||
|
System.out.println("path = " + path);
|
||||||
|
|
||||||
|
if (path.equals(pathToAdd))
|
||||||
|
return -5;
|
||||||
|
|
||||||
|
} // endfor path
|
||||||
|
|
||||||
|
//add the new path
|
||||||
|
String[] newPaths = Arrays.copyOf(paths, paths.length + 1);
|
||||||
|
newPaths[paths.length] = pathToAdd;
|
||||||
|
usrPathsField.set(null, newPaths);
|
||||||
|
System.setProperty("java.library.path",
|
||||||
|
System.getProperty("java.library.path") + File.pathSeparator + pathToAdd);
|
||||||
|
Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
|
||||||
|
fieldSysPath.setAccessible(true);
|
||||||
|
fieldSysPath.set(null, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
return -1;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of addLibraryPath
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // end of class JdbcApacheInterface
|
BIN
storage/connect/JdbcDSInterface.class
Normal file
BIN
storage/connect/JdbcDSInterface.class
Normal file
Binary file not shown.
743
storage/connect/JdbcDSInterface.java
Normal file
743
storage/connect/JdbcDSInterface.java
Normal file
@@ -0,0 +1,743 @@
|
|||||||
|
import java.math.*;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import org.mariadb.jdbc.MariaDbDataSource;
|
||||||
|
import org.postgresql.jdbc2.optional.PoolingDataSource;
|
||||||
|
import com.mysql.cj.jdbc.MysqlDataSource;
|
||||||
|
import oracle.jdbc.pool.OracleDataSource;
|
||||||
|
|
||||||
|
public class JdbcDSInterface {
|
||||||
|
boolean DEBUG = false;
|
||||||
|
String Errmsg = "No error";
|
||||||
|
Connection conn = null;
|
||||||
|
DatabaseMetaData dbmd = null;
|
||||||
|
Statement stmt = null;
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
ResultSetMetaData rsmd = null;
|
||||||
|
Hashtable<String,DataSource> dst = null;
|
||||||
|
|
||||||
|
// === Constructors/finalize =========================================
|
||||||
|
public JdbcDSInterface() {
|
||||||
|
this(true);
|
||||||
|
} // end of default constructor
|
||||||
|
|
||||||
|
public JdbcDSInterface(boolean b) {
|
||||||
|
DEBUG = b;
|
||||||
|
dst = new Hashtable<String, DataSource>();
|
||||||
|
} // end of constructor
|
||||||
|
|
||||||
|
private void SetErrmsg(Exception e) {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
|
||||||
|
Errmsg = e.toString();
|
||||||
|
} // end of SetErrmsg
|
||||||
|
|
||||||
|
private void SetErrmsg(String s) {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println(s);
|
||||||
|
|
||||||
|
Errmsg = s;
|
||||||
|
} // end of SetErrmsg
|
||||||
|
|
||||||
|
public String GetErrmsg() {
|
||||||
|
String err = Errmsg;
|
||||||
|
|
||||||
|
Errmsg = "No error";
|
||||||
|
return err;
|
||||||
|
} // end of GetErrmsg
|
||||||
|
|
||||||
|
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
|
||||||
|
int rc = 0;
|
||||||
|
String url = parms[1];
|
||||||
|
DataSource ds = null;
|
||||||
|
MysqlDataSource mds = null;
|
||||||
|
MariaDbDataSource ads = null;
|
||||||
|
OracleDataSource ods = null;
|
||||||
|
PoolingDataSource pds = null;
|
||||||
|
|
||||||
|
if (url == null) {
|
||||||
|
SetErrmsg("URL cannot be null");
|
||||||
|
return -1;
|
||||||
|
} // endif driver
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ((ds = dst.get(url)) == null) {
|
||||||
|
if (url.toLowerCase().contains("mysql")) {
|
||||||
|
mds = new MysqlDataSource();
|
||||||
|
mds.setURL(url);
|
||||||
|
mds.setUser(parms[2]);
|
||||||
|
mds.setPassword(parms[3]);
|
||||||
|
ds = mds;
|
||||||
|
} else if (url.toLowerCase().contains("mariadb")) {
|
||||||
|
ads = new MariaDbDataSource();
|
||||||
|
ads.setUrl(url);
|
||||||
|
ads.setUser(parms[2]);
|
||||||
|
ads.setPassword(parms[3]);
|
||||||
|
ds = ads;
|
||||||
|
} else if (url.toLowerCase().contains("oracle")) {
|
||||||
|
ods = new OracleDataSource();
|
||||||
|
ods.setURL(url);
|
||||||
|
ods.setUser(parms[2]);
|
||||||
|
ods.setPassword(parms[3]);
|
||||||
|
ds = ods;
|
||||||
|
} else if (url.toLowerCase().contains("postgresql")) {
|
||||||
|
pds = new PoolingDataSource();
|
||||||
|
pds.setUrl(url);
|
||||||
|
pds.setUser(parms[2]);
|
||||||
|
pds.setPassword(parms[3]);
|
||||||
|
ds = pds;
|
||||||
|
} else {
|
||||||
|
SetErrmsg("Unsupported driver");
|
||||||
|
return -4;
|
||||||
|
} // endif driver
|
||||||
|
|
||||||
|
dst.put(url, ds);
|
||||||
|
} // endif ds
|
||||||
|
|
||||||
|
// Get a connection from the data source
|
||||||
|
conn = ds.getConnection();
|
||||||
|
|
||||||
|
// Get the data base meta data object
|
||||||
|
dbmd = conn.getMetaData();
|
||||||
|
|
||||||
|
// Get a statement from the connection
|
||||||
|
if (scrollable)
|
||||||
|
stmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||||
|
else
|
||||||
|
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Statement type = " + stmt.getResultSetType()
|
||||||
|
+ " concurrency = " + stmt.getResultSetConcurrency());
|
||||||
|
|
||||||
|
if (DEBUG) // Get the fetch size of a statement
|
||||||
|
System.out.println("Default fetch size = " + stmt.getFetchSize());
|
||||||
|
|
||||||
|
if (fsize != 0) {
|
||||||
|
// Set the fetch size
|
||||||
|
stmt.setFetchSize(fsize);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("New fetch size = " + stmt.getFetchSize());
|
||||||
|
|
||||||
|
} // endif fsize
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc = -2;
|
||||||
|
} catch( Exception e ) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
rc = -3;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
} // end of JdbcConnect
|
||||||
|
|
||||||
|
public int CreatePrepStmt(String sql) {
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
pstmt = conn.prepareStatement(sql);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
rc = -2;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
} // end of CreatePrepStmt
|
||||||
|
|
||||||
|
public void SetStringParm(int i, String s) {
|
||||||
|
try {
|
||||||
|
pstmt.setString(i, s);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetStringParm
|
||||||
|
|
||||||
|
public void SetIntParm(int i, int n) {
|
||||||
|
try {
|
||||||
|
pstmt.setInt(i, n);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetIntParm
|
||||||
|
|
||||||
|
public void SetShortParm(int i, short n) {
|
||||||
|
try {
|
||||||
|
pstmt.setShort(i, n);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetShortParm
|
||||||
|
|
||||||
|
public void SetBigintParm(int i, long n) {
|
||||||
|
try {
|
||||||
|
pstmt.setLong(i, n);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetBigintParm
|
||||||
|
|
||||||
|
public void SetFloatParm(int i, float f) {
|
||||||
|
try {
|
||||||
|
pstmt.setFloat(i, f);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetFloatParm
|
||||||
|
|
||||||
|
public void SetDoubleParm(int i, double d) {
|
||||||
|
try {
|
||||||
|
pstmt.setDouble(i, d);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetDoubleParm
|
||||||
|
|
||||||
|
public void SetTimestampParm(int i, Timestamp t) {
|
||||||
|
try {
|
||||||
|
pstmt.setTimestamp(i, t);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
} // end of SetTimestampParm
|
||||||
|
|
||||||
|
public int ExecutePrep() {
|
||||||
|
int n = -3;
|
||||||
|
|
||||||
|
if (pstmt != null) try {
|
||||||
|
n = pstmt.executeUpdate();
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
n = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
n = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return n;
|
||||||
|
} // end of ExecutePrep
|
||||||
|
|
||||||
|
public boolean ClosePrepStmt() {
|
||||||
|
boolean b = false;
|
||||||
|
|
||||||
|
if (pstmt != null) try {
|
||||||
|
pstmt.close();
|
||||||
|
pstmt = null;
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
b = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
b = true;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return b;
|
||||||
|
} // end of ClosePrepStmt
|
||||||
|
|
||||||
|
public int JdbcDisconnect() {
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
// Cancel pending statement
|
||||||
|
if (stmt != null)
|
||||||
|
try {
|
||||||
|
System.out.println("Cancelling statement");
|
||||||
|
stmt.cancel();
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc += 1;
|
||||||
|
} // nothing more we can do
|
||||||
|
|
||||||
|
// Close the statement and the connection
|
||||||
|
if (rs != null)
|
||||||
|
try {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Closing result set");
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc = 2;
|
||||||
|
} // nothing more we can do
|
||||||
|
|
||||||
|
if (stmt != null)
|
||||||
|
try {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Closing statement");
|
||||||
|
|
||||||
|
stmt.close();
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc += 4;
|
||||||
|
} // nothing more we can do
|
||||||
|
|
||||||
|
ClosePrepStmt();
|
||||||
|
|
||||||
|
if (conn != null)
|
||||||
|
try {
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Closing connection");
|
||||||
|
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
rc += 8;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("All closed");
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
} // end of JdbcDisconnect
|
||||||
|
|
||||||
|
public int GetMaxValue(int n) {
|
||||||
|
int m = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch (n) {
|
||||||
|
case 1: // Max columns in table
|
||||||
|
m = dbmd.getMaxColumnsInTable();
|
||||||
|
break;
|
||||||
|
case 2: // Max catalog name length
|
||||||
|
m = dbmd.getMaxCatalogNameLength();
|
||||||
|
break;
|
||||||
|
case 3: // Max schema name length
|
||||||
|
m = dbmd.getMaxSchemaNameLength();
|
||||||
|
break;
|
||||||
|
case 4: // Max table name length
|
||||||
|
m = dbmd.getMaxTableNameLength();
|
||||||
|
break;
|
||||||
|
case 5: // Max column name length
|
||||||
|
m = dbmd.getMaxColumnNameLength();
|
||||||
|
break;
|
||||||
|
} // endswitch n
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
m = -1;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return m;
|
||||||
|
} // end of GetMaxValue
|
||||||
|
|
||||||
|
public int GetColumns(String[] parms) {
|
||||||
|
int ncol = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (rs != null) rs.close();
|
||||||
|
rs = dbmd.getColumns(parms[0], parms[1], parms[2], parms[3]);
|
||||||
|
|
||||||
|
if (rs != null) {
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
} // endif rs
|
||||||
|
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of GetColumns
|
||||||
|
|
||||||
|
public int GetTables(String[] parms) {
|
||||||
|
int ncol = 0;
|
||||||
|
String[] typ = null;
|
||||||
|
|
||||||
|
if (parms[3] != null) {
|
||||||
|
typ = new String[1];
|
||||||
|
typ[0] = parms[3];
|
||||||
|
} // endif parms
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (rs != null) rs.close();
|
||||||
|
rs = dbmd.getTables(parms[0], parms[1], parms[2], typ);
|
||||||
|
|
||||||
|
if (rs != null) {
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
} // endif rs
|
||||||
|
|
||||||
|
} catch(SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of GetColumns
|
||||||
|
|
||||||
|
public int Execute(String query) {
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Executing '" + query + "'");
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean b = stmt.execute(query);
|
||||||
|
|
||||||
|
if (b == false) {
|
||||||
|
n = stmt.getUpdateCount();
|
||||||
|
if (rs != null) rs.close();
|
||||||
|
} // endif b
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Query '" + query + "' executed: n = " + n);
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
n = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
n = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return n;
|
||||||
|
} // end of Execute
|
||||||
|
|
||||||
|
public int GetResult() {
|
||||||
|
int ncol = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
rs = stmt.getResultSet();
|
||||||
|
|
||||||
|
if (rs != null) {
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Result set has " + rsmd.getColumnCount() + " column(s)");
|
||||||
|
|
||||||
|
} // endif rs
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
ncol = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
ncol = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of GetResult
|
||||||
|
|
||||||
|
public int ExecuteQuery(String query) {
|
||||||
|
int ncol = 0;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Executing query '" + query + "'");
|
||||||
|
|
||||||
|
try {
|
||||||
|
rs = stmt.executeQuery(query);
|
||||||
|
rsmd = rs.getMetaData();
|
||||||
|
ncol = rsmd.getColumnCount();
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
System.out.println("Query '" + query + "' executed successfully");
|
||||||
|
System.out.println("Result set has " + rsmd.getColumnCount() + " column(s)");
|
||||||
|
} // endif DEBUG
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
ncol = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
ncol = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return ncol;
|
||||||
|
} // end of ExecuteQuery
|
||||||
|
|
||||||
|
public int ExecuteUpdate(String query) {
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Executing update query '" + query + "'");
|
||||||
|
|
||||||
|
try {
|
||||||
|
n = stmt.executeUpdate(query);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Update Query '" + query + "' executed: n = " + n);
|
||||||
|
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
n = -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
n = -2;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return n;
|
||||||
|
} // end of ExecuteUpdate
|
||||||
|
|
||||||
|
public int ReadNext() {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
return rs.next() ? 1 : 0;
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
return -1;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
} else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} // end of ReadNext
|
||||||
|
|
||||||
|
public boolean Fetch(int row) {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
return rs.absolute(row);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
return false;
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} // end of Fetch
|
||||||
|
|
||||||
|
public String ColumnName(int n) {
|
||||||
|
if (rsmd == null) {
|
||||||
|
System.out.println("No result metadata");
|
||||||
|
} else try {
|
||||||
|
return rsmd.getColumnLabel(n);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of ColumnName
|
||||||
|
|
||||||
|
public int ColumnType(int n, String name) {
|
||||||
|
if (rsmd == null) {
|
||||||
|
System.out.println("No result metadata");
|
||||||
|
} else try {
|
||||||
|
if (n == 0)
|
||||||
|
n = rs.findColumn(name);
|
||||||
|
|
||||||
|
return rsmd.getColumnType(n);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 666; // Not a type
|
||||||
|
} // end of ColumnType
|
||||||
|
|
||||||
|
public String ColumnDesc(int n, int[] val) {
|
||||||
|
if (rsmd == null) {
|
||||||
|
System.out.println("No result metadata");
|
||||||
|
return null;
|
||||||
|
} else try {
|
||||||
|
val[0] = rsmd.getColumnType(n);
|
||||||
|
val[1] = rsmd.getPrecision(n);
|
||||||
|
val[2] = rsmd.getScale(n);
|
||||||
|
val[3] = rsmd.isNullable(n);
|
||||||
|
return rsmd.getColumnLabel(n);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of ColumnDesc
|
||||||
|
|
||||||
|
public String StringField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getString(n) : rs.getString(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of StringField
|
||||||
|
|
||||||
|
public int IntField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getInt(n) : rs.getInt(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of IntField
|
||||||
|
|
||||||
|
public long BigintField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
BigDecimal bigDecimal = (n > 0) ? rs.getBigDecimal(n) : rs.getBigDecimal(name);
|
||||||
|
return bigDecimal != null ? bigDecimal.longValue() : 0;
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of BiginttField
|
||||||
|
|
||||||
|
public double DoubleField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getDouble(n) : rs.getDouble(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0.;
|
||||||
|
} // end of DoubleField
|
||||||
|
|
||||||
|
public float FloatField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getFloat(n) : rs.getFloat(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of FloatField
|
||||||
|
|
||||||
|
public boolean BooleanField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getBoolean(n) : rs.getBoolean(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // end of BooleanField
|
||||||
|
|
||||||
|
public Date DateField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getDate(n) : rs.getDate(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of DateField
|
||||||
|
|
||||||
|
public Time TimeField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getTime(n) : rs.getTime(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of TimeField
|
||||||
|
|
||||||
|
public Timestamp TimestampField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getTimestamp(n) : rs.getTimestamp(name);
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of TimestampField
|
||||||
|
|
||||||
|
public String ObjectField(int n, String name) {
|
||||||
|
if (rs == null) {
|
||||||
|
System.out.println("No result set");
|
||||||
|
} else try {
|
||||||
|
return (n > 0) ? rs.getObject(n).toString() : rs.getObject(name).toString();
|
||||||
|
} catch (SQLException se) {
|
||||||
|
SetErrmsg(se);
|
||||||
|
} //end try/catch
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} // end of ObjectField
|
||||||
|
|
||||||
|
public int GetDrivers(String[] s, int mxs) {
|
||||||
|
int n = 0;
|
||||||
|
List<Driver> drivers = Collections.list(DriverManager.getDrivers());
|
||||||
|
int size = Math.min(mxs, drivers.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
Driver driver = (Driver)drivers.get(i);
|
||||||
|
|
||||||
|
// Get name of driver
|
||||||
|
s[n++] = driver.getClass().getName();
|
||||||
|
|
||||||
|
// Get version info
|
||||||
|
s[n++] = driver.getMajorVersion() + "." + driver.getMinorVersion();
|
||||||
|
s[n++] = driver.jdbcCompliant() ? "Yes" : "No";
|
||||||
|
s[n++] = driver.toString();
|
||||||
|
} // endfor i
|
||||||
|
|
||||||
|
return size;
|
||||||
|
} // end of GetDrivers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified path to the java library path
|
||||||
|
* from Fahd Shariff blog
|
||||||
|
*
|
||||||
|
* @param pathToAdd the path to add
|
||||||
|
static public int addLibraryPath(String pathToAdd) {
|
||||||
|
System.out.println("jpath = " + pathToAdd);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths");
|
||||||
|
usrPathsField.setAccessible(true);
|
||||||
|
|
||||||
|
//get array of paths
|
||||||
|
String[] paths = (String[])usrPathsField.get(null);
|
||||||
|
|
||||||
|
//check if the path to add is already present
|
||||||
|
for (String path : paths) {
|
||||||
|
System.out.println("path = " + path);
|
||||||
|
|
||||||
|
if (path.equals(pathToAdd))
|
||||||
|
return -5;
|
||||||
|
|
||||||
|
} // endfor path
|
||||||
|
|
||||||
|
//add the new path
|
||||||
|
String[] newPaths = Arrays.copyOf(paths, paths.length + 1);
|
||||||
|
newPaths[paths.length] = pathToAdd;
|
||||||
|
usrPathsField.set(null, newPaths);
|
||||||
|
System.setProperty("java.library.path",
|
||||||
|
System.getProperty("java.library.path") + File.pathSeparator + pathToAdd);
|
||||||
|
Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
|
||||||
|
fieldSysPath.setAccessible(true);
|
||||||
|
fieldSysPath.set(null, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SetErrmsg(e);
|
||||||
|
return -1;
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} // end of addLibraryPath
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // end of class JdbcDSInterface
|
@@ -195,6 +195,7 @@ extern "C" {
|
|||||||
#if defined(JDBC_SUPPORT)
|
#if defined(JDBC_SUPPORT)
|
||||||
char *JvmPath;
|
char *JvmPath;
|
||||||
char *ClassPath;
|
char *ClassPath;
|
||||||
|
char *Wrapper;
|
||||||
#endif // JDBC_SUPPORT
|
#endif // JDBC_SUPPORT
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
@@ -1141,7 +1142,7 @@ int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef)
|
|||||||
else if (!stricmp(opname, "Compressed"))
|
else if (!stricmp(opname, "Compressed"))
|
||||||
opval= (options->compressed);
|
opval= (options->compressed);
|
||||||
|
|
||||||
if (opval == (ulonglong)NO_IVAL) {
|
if ((ulonglong) opval == (ulonglong)NO_IVAL) {
|
||||||
char *pv;
|
char *pv;
|
||||||
|
|
||||||
if ((pv= GetListOption(g, opname, options->oplist)))
|
if ((pv= GetListOption(g, opname, options->oplist)))
|
||||||
@@ -1960,7 +1961,7 @@ int ha_connect::MakeRecord(char *buf)
|
|||||||
if (trace > 1)
|
if (trace > 1)
|
||||||
htrc("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n",
|
htrc("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n",
|
||||||
*table->read_set->bitmap, *table->write_set->bitmap,
|
*table->read_set->bitmap, *table->write_set->bitmap,
|
||||||
*table->vcol_set->bitmap,
|
(table->vcol_set) ? *table->vcol_set->bitmap : 0,
|
||||||
*table->def_read_set.bitmap, *table->def_write_set.bitmap);
|
*table->def_read_set.bitmap, *table->def_write_set.bitmap);
|
||||||
|
|
||||||
// Avoid asserts in field::store() for columns that are not updated
|
// Avoid asserts in field::store() for columns that are not updated
|
||||||
@@ -4806,7 +4807,11 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
|
|||||||
DBUG_RETURN(rc);
|
DBUG_RETURN(rc);
|
||||||
|
|
||||||
// Get the share info from the .frm file
|
// Get the share info from the .frm file
|
||||||
if (!open_table_def(thd, share)) {
|
Dummy_error_handler error_handler;
|
||||||
|
thd->push_internal_handler(&error_handler);
|
||||||
|
bool got_error= open_table_def(thd, share);
|
||||||
|
thd->pop_internal_handler();
|
||||||
|
if (!got_error) {
|
||||||
// Now we can work
|
// Now we can work
|
||||||
if ((pos= share->option_struct)) {
|
if ((pos= share->option_struct)) {
|
||||||
if (check_privileges(thd, pos, db))
|
if (check_privileges(thd, pos, db))
|
||||||
@@ -4819,12 +4824,6 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
|
|||||||
|
|
||||||
} // endif open_table_def
|
} // endif open_table_def
|
||||||
|
|
||||||
// This below was done to avoid DBUG_ASSERT in some case that
|
|
||||||
// we don't know anymore what they were. It was suppressed because
|
|
||||||
// it did cause assertion in other cases (see MDEV-7935)
|
|
||||||
// } else // Avoid infamous DBUG_ASSERT
|
|
||||||
// thd->get_stmt_da()->reset_diagnostics_area();
|
|
||||||
|
|
||||||
free_table_share(share);
|
free_table_share(share);
|
||||||
} else // Temporary file
|
} else // Temporary file
|
||||||
ok= true;
|
ok= true;
|
||||||
@@ -5156,7 +5155,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
char *nsp= NULL, *cls= NULL;
|
char *nsp= NULL, *cls= NULL;
|
||||||
#endif // __WIN__
|
#endif // __WIN__
|
||||||
int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0;
|
int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0;
|
||||||
int cop __attribute__((unused))= 0;
|
int cop __attribute__((unused))= 0, lrecl= 0;
|
||||||
#if defined(ODBC_SUPPORT)
|
#if defined(ODBC_SUPPORT)
|
||||||
POPARM sop= NULL;
|
POPARM sop= NULL;
|
||||||
char *ucnc= NULL;
|
char *ucnc= NULL;
|
||||||
@@ -5620,7 +5619,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
len= crp->Length;
|
len= crp->Length;
|
||||||
dec= crp->Prec;
|
dec= crp->Prec;
|
||||||
flg= crp->Flag;
|
flg= crp->Flag;
|
||||||
v= crp->Var;
|
v= (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var;
|
||||||
tm= (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG;
|
tm= (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG;
|
||||||
|
|
||||||
if (!len && typ == TYPE_STRING)
|
if (!len && typ == TYPE_STRING)
|
||||||
@@ -6876,6 +6875,12 @@ static MYSQL_SYSVAR_STR(class_path, ClassPath,
|
|||||||
"Java class path",
|
"Java class path",
|
||||||
// check_class_path, update_class_path,
|
// check_class_path, update_class_path,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
static MYSQL_SYSVAR_STR(java_wrapper, Wrapper,
|
||||||
|
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
|
||||||
|
"Java wrapper class",
|
||||||
|
// check_class_path, update_class_path,
|
||||||
|
NULL, NULL, "JdbcInterface");
|
||||||
#endif // JDBC_SUPPORT
|
#endif // JDBC_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
@@ -6899,6 +6904,7 @@ static struct st_mysql_sys_var* connect_system_variables[]= {
|
|||||||
#if defined(JDBC_SUPPORT)
|
#if defined(JDBC_SUPPORT)
|
||||||
MYSQL_SYSVAR(jvm_path),
|
MYSQL_SYSVAR(jvm_path),
|
||||||
MYSQL_SYSVAR(class_path),
|
MYSQL_SYSVAR(class_path),
|
||||||
|
MYSQL_SYSVAR(java_wrapper),
|
||||||
#endif // JDBC_SUPPORT
|
#endif // JDBC_SUPPORT
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
@@ -6917,6 +6923,6 @@ maria_declare_plugin(connect)
|
|||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
connect_system_variables, /* system variables */
|
connect_system_variables, /* system variables */
|
||||||
"1.04.0006", /* string version */
|
"1.04.0006", /* string version */
|
||||||
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
|
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
|
||||||
}
|
}
|
||||||
maria_declare_plugin_end;
|
maria_declare_plugin_end;
|
||||||
|
@@ -53,8 +53,9 @@ extern "C" HINSTANCE s_hModule; // Saved module handle
|
|||||||
#endif // !__WIN__
|
#endif // !__WIN__
|
||||||
|
|
||||||
int GetConvSize();
|
int GetConvSize();
|
||||||
extern char *JvmPath; // The connect_jvm_path global variable value
|
extern char *JvmPath; // The connect_jvm_path global variable value
|
||||||
extern char *ClassPath; // The connect_class_path global variable value
|
extern char *ClassPath; // The connect_class_path global variable value
|
||||||
|
extern char *Wrapper; // The connect_java_wrapper global variable value
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Static JDBConn objects. */
|
/* Static JDBConn objects. */
|
||||||
@@ -645,8 +646,8 @@ JDBConn::JDBConn(PGLOBAL g, TDBJDBC *tdbp)
|
|||||||
m_Tdb = tdbp;
|
m_Tdb = tdbp;
|
||||||
jvm = nullptr; // Pointer to the JVM (Java Virtual Machine)
|
jvm = nullptr; // Pointer to the JVM (Java Virtual Machine)
|
||||||
env= nullptr; // Pointer to native interface
|
env= nullptr; // Pointer to native interface
|
||||||
jdi = nullptr; // Pointer to the JdbcInterface class
|
jdi = nullptr; // Pointer to the java wrapper class
|
||||||
job = nullptr; // The JdbcInterface class object
|
job = nullptr; // The java wrapper class object
|
||||||
xqid = xuid = xid = grs = readid = fetchid = typid = errid = nullptr;
|
xqid = xuid = xid = grs = readid = fetchid = typid = errid = nullptr;
|
||||||
prepid = xpid = pcid = nullptr;
|
prepid = xpid = pcid = nullptr;
|
||||||
chrfldid = intfldid = dblfldid = fltfldid = datfldid = bigfldid = nullptr;
|
chrfldid = intfldid = dblfldid = fltfldid = datfldid = bigfldid = nullptr;
|
||||||
@@ -1028,11 +1029,11 @@ int JDBConn::Open(PJPARM sop)
|
|||||||
printf("JVM Version %d.%d\n", ((ver>>16)&0x0f), (ver&0x0f));
|
printf("JVM Version %d.%d\n", ((ver>>16)&0x0f), (ver&0x0f));
|
||||||
#endif //_DEBUG
|
#endif //_DEBUG
|
||||||
|
|
||||||
// try to find the JdbcInterface class
|
// try to find the java wrapper class
|
||||||
jdi = env->FindClass("JdbcInterface");
|
jdi = env->FindClass(Wrapper);
|
||||||
|
|
||||||
if (jdi == nullptr) {
|
if (jdi == nullptr) {
|
||||||
strcpy(g->Message, "ERROR: class JdbcInterface not found !");
|
sprintf(g->Message, "ERROR: class %s not found!", Wrapper);
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} // endif jdi
|
} // endif jdi
|
||||||
|
|
||||||
@@ -1078,7 +1079,7 @@ int JDBConn::Open(PJPARM sop)
|
|||||||
jmethodID ctor = env->GetMethodID(jdi, "<init>", "()V");
|
jmethodID ctor = env->GetMethodID(jdi, "<init>", "()V");
|
||||||
|
|
||||||
if (ctor == nullptr) {
|
if (ctor == nullptr) {
|
||||||
strcpy(g->Message, "ERROR: JdbcInterface constructor not found !");
|
sprintf(g->Message, "ERROR: %s constructor not found!", Wrapper);
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} else
|
} else
|
||||||
job = env->NewObject(jdi, ctor);
|
job = env->NewObject(jdi, ctor);
|
||||||
@@ -1087,7 +1088,7 @@ int JDBConn::Open(PJPARM sop)
|
|||||||
// we can then search for the method we want to call,
|
// we can then search for the method we want to call,
|
||||||
// and invoke it for the object:
|
// and invoke it for the object:
|
||||||
if (job == nullptr) {
|
if (job == nullptr) {
|
||||||
strcpy(g->Message, "JdbcInterface class object not constructed !");
|
sprintf(g->Message, "%s class object not constructed!", Wrapper);
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} // endif job
|
} // endif job
|
||||||
|
|
||||||
@@ -1328,6 +1329,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
|||||||
case 4: // INTEGER
|
case 4: // INTEGER
|
||||||
case 5: // SMALLINT
|
case 5: // SMALLINT
|
||||||
case -6: // TINYINT
|
case -6: // TINYINT
|
||||||
|
case -7: // BIT
|
||||||
if (!gmID(g, intfldid, "IntField", "(ILjava/lang/String;)I"))
|
if (!gmID(g, intfldid, "IntField", "(ILjava/lang/String;)I"))
|
||||||
val->SetValue((int)env->CallIntMethod(job, intfldid, rank, jn));
|
val->SetValue((int)env->CallIntMethod(job, intfldid, rank, jn));
|
||||||
else
|
else
|
||||||
@@ -1393,6 +1395,9 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
|||||||
break;
|
break;
|
||||||
case java.sql.Types.BOOLEAN:
|
case java.sql.Types.BOOLEAN:
|
||||||
System.out.print(jdi.BooleanField(i)); */
|
System.out.print(jdi.BooleanField(i)); */
|
||||||
|
case 0: // NULL
|
||||||
|
val->SetNull(true);
|
||||||
|
// passthru
|
||||||
default:
|
default:
|
||||||
val->Reset();
|
val->Reset();
|
||||||
} // endswitch Type
|
} // endswitch Type
|
||||||
|
@@ -152,8 +152,8 @@ protected:
|
|||||||
TDBJDBC *m_Tdb;
|
TDBJDBC *m_Tdb;
|
||||||
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
|
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
|
||||||
JNIEnv *env; // Pointer to native interface
|
JNIEnv *env; // Pointer to native interface
|
||||||
jclass jdi; // Pointer to the JdbcInterface class
|
jclass jdi; // Pointer to the java wrapper class
|
||||||
jobject job; // The JdbcInterface class object
|
jobject job; // The java wrapper class object
|
||||||
jmethodID xqid; // The ExecuteQuery method ID
|
jmethodID xqid; // The ExecuteQuery method ID
|
||||||
jmethodID xuid; // The ExecuteUpdate method ID
|
jmethodID xuid; // The ExecuteUpdate method ID
|
||||||
jmethodID xid; // The Execute method ID
|
jmethodID xid; // The Execute method ID
|
||||||
|
@@ -1433,7 +1433,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
|
|||||||
char *p = args->args[0];
|
char *p = args->args[0];
|
||||||
|
|
||||||
// Is this a file name?
|
// Is this a file name?
|
||||||
if (!strchr("[{ \t\r\n", *p) && (len = GetFileLength(p)))
|
if (p && !strchr("[{ \t\r\n", *p) && (len = GetFileLength(p)))
|
||||||
ml += len * (M + 1);
|
ml += len * (M + 1);
|
||||||
else
|
else
|
||||||
ml += args->lengths[0] * M;
|
ml += args->lengths[0] * M;
|
||||||
@@ -1805,7 +1805,20 @@ my_bool json_array_add_values_init(UDF_INIT *initid, UDF_ARGS *args, char *messa
|
|||||||
} else
|
} else
|
||||||
CalcLen(args, false, reslen, memlen);
|
CalcLen(args, false, reslen, memlen);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
|
// This is a constant function
|
||||||
|
g->N = (initid->const_item) ? 1 : 0;
|
||||||
|
|
||||||
|
// This is to avoid double execution when using prepared statements
|
||||||
|
if (IsJson(args, 0) > 1)
|
||||||
|
initid->const_item = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} // end of json_array_add_values_init
|
} // end of json_array_add_values_init
|
||||||
|
|
||||||
char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -1850,7 +1863,7 @@ char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} // endif str
|
} // endif str
|
||||||
|
|
||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Xchk = (initid->const_item) ? str : NULL;
|
g->Xchk = (g->N) ? str : NULL;
|
||||||
} else
|
} else
|
||||||
str = (char*)g->Xchk;
|
str = (char*)g->Xchk;
|
||||||
|
|
||||||
@@ -1873,7 +1886,7 @@ void json_array_add_values_deinit(UDF_INIT* initid)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool json_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool json_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
unsigned long reslen, memlen;
|
unsigned long reslen, memlen;
|
||||||
|
|
||||||
if (args->arg_count < 2) {
|
if (args->arg_count < 2) {
|
||||||
strcpy(message, "This function must have at least 2 arguments");
|
strcpy(message, "This function must have at least 2 arguments");
|
||||||
@@ -1884,7 +1897,20 @@ my_bool json_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
} else
|
} else
|
||||||
CalcLen(args, false, reslen, memlen, true);
|
CalcLen(args, false, reslen, memlen, true);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
|
// This is a constant function
|
||||||
|
g->N = (initid->const_item) ? 1 : 0;
|
||||||
|
|
||||||
|
// This is to avoid double execution when using prepared statements
|
||||||
|
if (IsJson(args, 0) > 1)
|
||||||
|
initid->const_item = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} // end of json_array_add_init
|
} // end of json_array_add_init
|
||||||
|
|
||||||
char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -1930,7 +1956,7 @@ char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
if (!str)
|
if (!str)
|
||||||
str = MakePSZ(g, args, 0);
|
str = MakePSZ(g, args, 0);
|
||||||
|
|
||||||
if (initid->const_item)
|
if (g->N)
|
||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Xchk = str;
|
g->Xchk = str;
|
||||||
|
|
||||||
@@ -1966,7 +1992,20 @@ my_bool json_array_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
} else
|
} else
|
||||||
CalcLen(args, false, reslen, memlen, true);
|
CalcLen(args, false, reslen, memlen, true);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
|
// This is a constant function
|
||||||
|
g->N = (initid->const_item) ? 1 : 0;
|
||||||
|
|
||||||
|
// This is to avoid double execution when using prepared statements
|
||||||
|
if (IsJson(args, 0) > 1)
|
||||||
|
initid->const_item = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} // end of json_array_delete_init
|
} // end of json_array_delete_init
|
||||||
|
|
||||||
char *json_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -2008,7 +2047,7 @@ char *json_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
if (!str)
|
if (!str)
|
||||||
str = MakePSZ(g, args, 0);
|
str = MakePSZ(g, args, 0);
|
||||||
|
|
||||||
if (initid->const_item)
|
if (g->N)
|
||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Xchk = str;
|
g->Xchk = str;
|
||||||
|
|
||||||
@@ -2184,7 +2223,20 @@ my_bool json_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
} else
|
} else
|
||||||
CalcLen(args, true, reslen, memlen, true);
|
CalcLen(args, true, reslen, memlen, true);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
|
// This is a constant function
|
||||||
|
g->N = (initid->const_item) ? 1 : 0;
|
||||||
|
|
||||||
|
// This is to avoid double execution when using prepared statements
|
||||||
|
if (IsJson(args, 0) > 1)
|
||||||
|
initid->const_item = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} // end of json_object_add_init
|
} // end of json_object_add_init
|
||||||
|
|
||||||
char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -2227,7 +2279,7 @@ char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
if (!str)
|
if (!str)
|
||||||
str = MakePSZ(g, args, 0);
|
str = MakePSZ(g, args, 0);
|
||||||
|
|
||||||
if (initid->const_item)
|
if (g->N)
|
||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Xchk = str;
|
g->Xchk = str;
|
||||||
|
|
||||||
@@ -2266,7 +2318,20 @@ my_bool json_object_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
} else
|
} else
|
||||||
CalcLen(args, true, reslen, memlen, true);
|
CalcLen(args, true, reslen, memlen, true);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
|
// This is a constant function
|
||||||
|
g->N = (initid->const_item) ? 1 : 0;
|
||||||
|
|
||||||
|
// This is to avoid double execution when using prepared statements
|
||||||
|
if (IsJson(args, 0) > 1)
|
||||||
|
initid->const_item = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} // end of json_object_delete_init
|
} // end of json_object_delete_init
|
||||||
|
|
||||||
char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -2307,7 +2372,7 @@ char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
if (!str)
|
if (!str)
|
||||||
str = MakePSZ(g, args, 0);
|
str = MakePSZ(g, args, 0);
|
||||||
|
|
||||||
if (initid->const_item)
|
if (g->N)
|
||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Xchk = str;
|
g->Xchk = str;
|
||||||
|
|
||||||
@@ -2605,7 +2670,20 @@ my_bool json_item_merge_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
} else
|
} else
|
||||||
CalcLen(args, false, reslen, memlen, true);
|
CalcLen(args, false, reslen, memlen, true);
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
|
// This is a constant function
|
||||||
|
g->N = (initid->const_item) ? 1 : 0;
|
||||||
|
|
||||||
|
// This is to avoid double execution when using prepared statements
|
||||||
|
if (IsJson(args, 0) > 1)
|
||||||
|
initid->const_item = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} // end of json_item_merge_init
|
} // end of json_item_merge_init
|
||||||
|
|
||||||
char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -2651,7 +2729,7 @@ char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
if (!str)
|
if (!str)
|
||||||
str = MakePSZ(g, args, 0);
|
str = MakePSZ(g, args, 0);
|
||||||
|
|
||||||
if (initid->const_item)
|
if (g->N)
|
||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Xchk = str;
|
g->Xchk = str;
|
||||||
|
|
||||||
@@ -3552,11 +3630,11 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
PGLOBAL gb = GetMemPtr(g, args, 0);
|
PGLOBAL gb = GetMemPtr(g, args, 0);
|
||||||
|
|
||||||
if (g->N) {
|
if (g->Alchecked) {
|
||||||
str = (char*)g->Activityp;
|
str = (char*)g->Activityp;
|
||||||
goto fin;
|
goto fin;
|
||||||
} else if (initid->const_item)
|
} else if (g->N)
|
||||||
g->N = 1;
|
g->Alchecked = 1;
|
||||||
|
|
||||||
if (!strcmp(result, "$set"))
|
if (!strcmp(result, "$set"))
|
||||||
w = 0;
|
w = 0;
|
||||||
@@ -3632,7 +3710,7 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
if (!(str = MakeResult(g, args, jsp, INT_MAX32)))
|
if (!(str = MakeResult(g, args, jsp, INT_MAX32)))
|
||||||
str = MakePSZ(g, args, 0);
|
str = MakePSZ(g, args, 0);
|
||||||
|
|
||||||
if (initid->const_item)
|
if (g->N)
|
||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)str;
|
g->Activityp = (PACTIVITY)str;
|
||||||
|
|
||||||
@@ -3677,7 +3755,21 @@ my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
} else if (n != 3)
|
} else if (n != 3)
|
||||||
memlen += args->lengths[0] * 3;
|
memlen += args->lengths[0] * 3;
|
||||||
|
|
||||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||||
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
|
// This is a constant function
|
||||||
|
g->N = (initid->const_item) ? 1 : 0;
|
||||||
|
|
||||||
|
// This is to avoid double execution when using prepared statements
|
||||||
|
if (IsJson(args, 0) > 1)
|
||||||
|
initid->const_item = 0;
|
||||||
|
|
||||||
|
g->Alchecked = 0;
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} // end of json_set_item_init
|
} // end of json_set_item_init
|
||||||
|
|
||||||
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -3742,8 +3834,8 @@ my_bool json_file_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
if (args->arg_count < 1 || args->arg_count > 4) {
|
if (args->arg_count < 1 || args->arg_count > 4) {
|
||||||
strcpy(message, "This function only accepts 1 to 4 arguments");
|
strcpy(message, "This function only accepts 1 to 4 arguments");
|
||||||
return true;
|
return true;
|
||||||
} else if (!args->args[0] || args->arg_type[0] != STRING_RESULT) {
|
} else if (args->arg_type[0] != STRING_RESULT) {
|
||||||
strcpy(message, "First argument must be a constant string (file name)");
|
strcpy(message, "First argument must be a string (file name)");
|
||||||
return true;
|
return true;
|
||||||
} // endif's args[0]
|
} // endif's args[0]
|
||||||
|
|
||||||
@@ -3761,7 +3853,12 @@ my_bool json_file_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
|
|
||||||
initid->maybe_null = 1;
|
initid->maybe_null = 1;
|
||||||
CalcLen(args, false, reslen, memlen);
|
CalcLen(args, false, reslen, memlen);
|
||||||
fl = GetFileLength(args->args[0]);
|
|
||||||
|
if (args->args[0])
|
||||||
|
fl = GetFileLength(args->args[0]);
|
||||||
|
else
|
||||||
|
fl = 100; // What can be done here?
|
||||||
|
|
||||||
reslen += fl;
|
reslen += fl;
|
||||||
|
|
||||||
if (initid->const_item)
|
if (initid->const_item)
|
||||||
@@ -4020,7 +4117,18 @@ void jbin_array_deinit(UDF_INIT* initid)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool jbin_array_add_values_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool jbin_array_add_values_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
return json_array_add_values_init(initid, args, message);
|
unsigned long reslen, memlen;
|
||||||
|
|
||||||
|
if (args->arg_count < 2) {
|
||||||
|
strcpy(message, "This function must have at least 2 arguments");
|
||||||
|
return true;
|
||||||
|
} else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) {
|
||||||
|
strcpy(message, "First argument must be a json string or item");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
CalcLen(args, false, reslen, memlen);
|
||||||
|
|
||||||
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
} // end of jbin_array_add_values_init
|
} // end of jbin_array_add_values_init
|
||||||
|
|
||||||
char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -4090,7 +4198,18 @@ void jbin_array_add_values_deinit(UDF_INIT* initid)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool jbin_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool jbin_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
return json_array_add_init(initid, args, message);
|
unsigned long reslen, memlen;
|
||||||
|
|
||||||
|
if (args->arg_count < 2) {
|
||||||
|
strcpy(message, "This function must have at least 2 arguments");
|
||||||
|
return true;
|
||||||
|
} else if (!IsJson(args, 0)) {
|
||||||
|
strcpy(message, "First argument must be a json item");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
CalcLen(args, false, reslen, memlen, true);
|
||||||
|
|
||||||
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
} // end of jbin_array_add_init
|
} // end of jbin_array_add_init
|
||||||
|
|
||||||
char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
@@ -4160,8 +4279,19 @@ void jbin_array_add_deinit(UDF_INIT* initid)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool jbin_array_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool jbin_array_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
return json_array_delete_init(initid, args, message);
|
unsigned long reslen, memlen;
|
||||||
} // end of jbin_array_delete_init
|
|
||||||
|
if (args->arg_count < 2) {
|
||||||
|
strcpy(message, "This function must have at least 2 arguments");
|
||||||
|
return true;
|
||||||
|
} else if (!IsJson(args, 0)) {
|
||||||
|
strcpy(message, "First argument must be a json item");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
CalcLen(args, false, reslen, memlen, true);
|
||||||
|
|
||||||
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
|
} // end of jbin_array_delete_init
|
||||||
|
|
||||||
char *jbin_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
@@ -4383,8 +4513,19 @@ void jbin_object_key_deinit(UDF_INIT* initid)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool jbin_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool jbin_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
return json_object_add_init(initid, args, message);
|
unsigned long reslen, memlen;
|
||||||
} // end of jbin_object_add_init
|
|
||||||
|
if (args->arg_count < 2) {
|
||||||
|
strcpy(message, "This function must have at least 2 arguments");
|
||||||
|
return true;
|
||||||
|
} else if (!IsJson(args, 0)) {
|
||||||
|
strcpy(message, "First argument must be a json item");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
CalcLen(args, true, reslen, memlen, true);
|
||||||
|
|
||||||
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
|
} // end of jbin_object_add_init
|
||||||
|
|
||||||
char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
@@ -4449,8 +4590,22 @@ void jbin_object_add_deinit(UDF_INIT* initid)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool jbin_object_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool jbin_object_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
return json_object_delete_init(initid, args, message);
|
unsigned long reslen, memlen;
|
||||||
} // end of jbin_object_delete_init
|
|
||||||
|
if (args->arg_count < 2) {
|
||||||
|
strcpy(message, "This function must have 2 or 3 arguments");
|
||||||
|
return true;
|
||||||
|
} else if (!IsJson(args, 0)) {
|
||||||
|
strcpy(message, "First argument must be a json item");
|
||||||
|
return true;
|
||||||
|
} else if (args->arg_type[1] != STRING_RESULT) {
|
||||||
|
strcpy(message, "Second argument must be a key string");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
CalcLen(args, true, reslen, memlen, true);
|
||||||
|
|
||||||
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
|
} // end of jbin_object_delete_init
|
||||||
|
|
||||||
char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
@@ -4659,8 +4814,22 @@ void jbin_get_item_deinit(UDF_INIT* initid)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool jbin_item_merge_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool jbin_item_merge_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
return json_item_merge_init(initid, args, message);
|
unsigned long reslen, memlen;
|
||||||
} // end of jbin_item_merge_init
|
|
||||||
|
if (args->arg_count < 2) {
|
||||||
|
strcpy(message, "This function must have at least 2 arguments");
|
||||||
|
return true;
|
||||||
|
} else if (!IsJson(args, 0)) {
|
||||||
|
strcpy(message, "First argument must be a json item");
|
||||||
|
return true;
|
||||||
|
} else if (!IsJson(args, 1)) {
|
||||||
|
strcpy(message, "Second argument must be a json item");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
CalcLen(args, false, reslen, memlen, true);
|
||||||
|
|
||||||
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
|
} // end of jbin_item_merge_init
|
||||||
|
|
||||||
char *jbin_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
@@ -4820,8 +4989,31 @@ fin:
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
my_bool jbin_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
my_bool jbin_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||||
{
|
{
|
||||||
return json_set_item_init(initid, args, message);
|
unsigned long reslen, memlen;
|
||||||
} // end of jbin_set_item_init
|
int n = IsJson(args, 0);
|
||||||
|
|
||||||
|
if (!(args->arg_count % 2)) {
|
||||||
|
strcpy(message, "This function must have an odd number of arguments");
|
||||||
|
return true;
|
||||||
|
} else if (!n && args->arg_type[0] != STRING_RESULT) {
|
||||||
|
strcpy(message, "First argument must be a json item");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
CalcLen(args, false, reslen, memlen);
|
||||||
|
|
||||||
|
if (n == 2 && args->args[0]) {
|
||||||
|
char fn[_MAX_PATH];
|
||||||
|
long fl;
|
||||||
|
|
||||||
|
memcpy(fn, args->args[0], args->lengths[0]);
|
||||||
|
fn[args->lengths[0]] = 0;
|
||||||
|
fl = GetFileLength(fn);
|
||||||
|
memlen += fl * 3;
|
||||||
|
} else if (n != 3)
|
||||||
|
memlen += args->lengths[0] * 3;
|
||||||
|
|
||||||
|
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||||
|
} // end of jbin_set_item_init
|
||||||
|
|
||||||
char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *is_null, char *p)
|
unsigned long *res_length, char *is_null, char *p)
|
||||||
@@ -4992,7 +5184,7 @@ my_bool json_serialize_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
if (args->arg_count != 1) {
|
if (args->arg_count != 1) {
|
||||||
strcpy(message, "This function must have 1 argument");
|
strcpy(message, "This function must have 1 argument");
|
||||||
return true;
|
return true;
|
||||||
} else if (IsJson(args, 0) != 3) {
|
} else if (args->args[0] && IsJson(args, 0) != 3) {
|
||||||
strcpy(message, "Argument must be a Jbin tree");
|
strcpy(message, "Argument must be a Jbin tree");
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
@@ -5002,21 +5194,27 @@ my_bool json_serialize_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
} // end of json_serialize_init
|
} // end of json_serialize_init
|
||||||
|
|
||||||
char *json_serialize(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *json_serialize(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *, char *)
|
unsigned long *res_length, char *, char *error)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
PBSON bsp = (PBSON)args->args[0];
|
if (IsJson(args, 0) == 3) {
|
||||||
|
PBSON bsp = (PBSON)args->args[0];
|
||||||
|
|
||||||
JsonSubSet(g);
|
JsonSubSet(g);
|
||||||
|
|
||||||
if (!(str = Serialize(g, bsp->Jsp, NULL, 0)))
|
if (!(str = Serialize(g, bsp->Jsp, NULL, 0)))
|
||||||
str = strcpy(result, g->Message);
|
str = strcpy(result, g->Message);
|
||||||
|
|
||||||
|
// Keep result of constant function
|
||||||
|
g->Xchk = (initid->const_item) ? str : NULL;
|
||||||
|
} else {
|
||||||
|
*error = 1;
|
||||||
|
str = strcpy(result, "Argument is not a Jbin tree");
|
||||||
|
} // endif
|
||||||
|
|
||||||
// Keep result of constant function
|
|
||||||
g->Xchk = (initid->const_item) ? str : NULL;
|
|
||||||
} else
|
} else
|
||||||
str = (char*)g->Xchk;
|
str = (char*)g->Xchk;
|
||||||
|
|
||||||
@@ -5037,21 +5235,28 @@ my_bool envar_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
|||||||
if (args->arg_count != 1) {
|
if (args->arg_count != 1) {
|
||||||
strcpy(message, "Unique argument must be an environment variable name");
|
strcpy(message, "Unique argument must be an environment variable name");
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else {
|
||||||
|
initid->maybe_null = true;
|
||||||
return false;
|
return false;
|
||||||
|
} // endif count
|
||||||
|
|
||||||
} // end of envar_init
|
} // end of envar_init
|
||||||
|
|
||||||
char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||||
unsigned long *res_length, char *, char *)
|
unsigned long *res_length, char *is_null, char *)
|
||||||
{
|
{
|
||||||
char *str, name[256];
|
char *str, name[256];
|
||||||
int n = MY_MIN(args->lengths[0], sizeof(name) - 1);
|
int n = MY_MIN(args->lengths[0], sizeof(name) - 1);
|
||||||
|
|
||||||
memcpy(name, args->args[0], n);
|
memcpy(name, args->args[0], n);
|
||||||
name[n] = 0;
|
name[n] = 0;
|
||||||
str = getenv(name);
|
|
||||||
*res_length = (str) ? strlen(str) : 0;
|
if (!(str = getenv(name))) {
|
||||||
|
*res_length = 0;
|
||||||
|
*is_null = 1;
|
||||||
|
} else
|
||||||
|
*res_length = strlen(str);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
} // end of envar
|
} // end of envar
|
||||||
|
|
||||||
|
@@ -901,8 +901,12 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
|
|||||||
if (fld->flags & NOT_NULL_FLAG)
|
if (fld->flags & NOT_NULL_FLAG)
|
||||||
crp->Nulls = NULL;
|
crp->Nulls = NULL;
|
||||||
else {
|
else {
|
||||||
crp->Nulls = (char*)PlugSubAlloc(g, NULL, m_Rows);
|
if (m_Rows) {
|
||||||
memset(crp->Nulls, ' ', m_Rows);
|
crp->Nulls = (char*)PlugSubAlloc(g, NULL, m_Rows);
|
||||||
|
memset(crp->Nulls, ' ', m_Rows);
|
||||||
|
} // endif m_Rows
|
||||||
|
|
||||||
|
crp->Kdata->SetNullable(true);
|
||||||
} // endelse fld->flags
|
} // endelse fld->flags
|
||||||
|
|
||||||
} // endfor fld
|
} // endfor fld
|
||||||
|
@@ -516,7 +516,9 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||||||
if (trace)
|
if (trace)
|
||||||
htrc("PlugSubAlloc: %s\n", g->Message);
|
htrc("PlugSubAlloc: %s\n", g->Message);
|
||||||
|
|
||||||
longjmp(g->jumper[g->jump_level], 1);
|
/* Nothing we can do if longjmp is not initialized. */
|
||||||
|
assert(g->jump_level >= 0);
|
||||||
|
longjmp(g->jumper[g->jump_level], 1);
|
||||||
} /* endif size OS32 code */
|
} /* endif size OS32 code */
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
Reference in New Issue
Block a user