You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by sa...@apache.org on 2017/07/31 05:41:51 UTC
[2/7] incubator-trafodion git commit: [TRAFODION-2308]JDBC support
insert LOB
[TRAFODION-2308]JDBC support insert LOB
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/c82b9124
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/c82b9124
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/c82b9124
Branch: refs/heads/master
Commit: c82b912413a3df4a823cee4b95240ea21412c4ac
Parents: c9ff843
Author: Weiqing Xu <we...@esgyn.cn>
Authored: Fri Jun 2 12:10:50 2017 +0000
Committer: Weiqing Xu <we...@esgyn.cn>
Committed: Thu Jul 6 13:12:56 2017 +0000
----------------------------------------------------------------------
.../jdbcT4/src/main/java/T4Messages.properties | 7 +-
.../trafodion/jdbc/t4/InterfaceStatement.java | 88 +++++-
.../org/trafodion/jdbc/t4/LogicalByteArray.java | 5 +
.../java/org/trafodion/jdbc/t4/TRANSPORT.java | 1 +
.../java/org/trafodion/jdbc/t4/TrafT4Blob.java | 85 ++----
.../java/org/trafodion/jdbc/t4/TrafT4Clob.java | 108 +++----
.../org/trafodion/jdbc/t4/TrafT4Connection.java | 6 +-
.../java/org/trafodion/jdbc/t4/TrafT4Desc.java | 1 -
.../trafodion/jdbc/t4/TrafT4InputStream.java | 38 +++
.../java/org/trafodion/jdbc/t4/TrafT4Lob.java | 213 +++++++++++++
.../trafodion/jdbc/t4/TrafT4OutputStream.java | 55 ++++
.../jdbc/t4/TrafT4PreparedStatement.java | 169 ++++++----
.../org/trafodion/jdbc/t4/TrafT4ResultSet.java | 56 +++-
.../org/trafodion/jdbc/t4/TrafT4Writer.java | 53 ++++
.../org/trafodion/jdbc/t4/UpdateLobMessage.java | 67 ++++
.../org/trafodion/jdbc/t4/UpdateLobReply.java | 47 +++
.../jdbc/t4/odbc_SQLSvc_UpdateLob_exc_.java | 70 +++++
core/conn/odbc/src/odbc/Common/TransportBase.h | 1 +
.../src/odbc/Krypton/generated_incs/odbc_sv.h | 25 ++
.../nsksrvr/Interface/marshalingsrvr_srvr.cpp | 82 ++++-
.../nsksrvr/Interface/marshalingsrvr_srvr.h | 10 +-
.../src/odbc/nsksrvr/Interface/odbcs_srvr.cpp | 66 ++++
.../src/odbc/nsksrvr/Interface/odbcs_srvr.h | 11 +
.../odbc/nsksrvr/Interface/odbcs_srvr_res.cpp | 29 +-
.../src/odbc/nsksrvr/Interface/odbcs_srvr_res.h | 9 +-
core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp | 32 +-
core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.h | 12 +
.../conn/odbc/src/odbc/nsksrvrcore/srvrcommon.h | 14 +-
.../odbc/src/odbc/nsksrvrcore/srvrothers.cpp | 89 +++++-
core/sql/cli/CliExpExchange.cpp | 2 +-
core/sql/cli/Descriptor.cpp | 3 +
core/sql/common/CharType.cpp | 2 +-
core/sql/exp/ExpLOB.cpp | 16 +-
core/sql/exp/ExpLOBinterface.cpp | 4 +-
core/sql/optimizer/BindItemExpr.cpp | 17 +-
core/sql/parser/sqlparser.y | 38 ++-
core/sql/sqlcomp/DefaultConstants.h | 1 +
core/sql/sqlcomp/nadefaults.cpp | 1 +
.../java/org/trafodion/jdbc_test/TestBlob.java | 289 ++++++++++++++++++
.../org/trafodion/jdbc_test/TestBlobBatch.java | 196 ++++++++++++
.../java/org/trafodion/jdbc_test/TestClob.java | 305 ++++++++++++++++++-
.../org/trafodion/jdbc_test/TestClobBatch.java | 232 ++++++++++++++
42 files changed, 2310 insertions(+), 245 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/T4Messages.properties
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/T4Messages.properties b/core/conn/jdbcT4/src/main/java/T4Messages.properties
index 35b5bb3..a8367a8 100644
--- a/core/conn/jdbcT4/src/main/java/T4Messages.properties
+++ b/core/conn/jdbcT4/src/main/java/T4Messages.properties
@@ -583,9 +583,9 @@ translation_of_parameter_failed_sqlcode=29172
#
# New Messages for LOB Support From Type 4
#
-blob_io_error_msg=IO Error while writing bytes to blob: {1}
-blob_io_error_sqlstate=S1000
-blob_io_error_sqlcode=29064
+lob_io_error_msg=IO Error while writing bytes to lob: {1}
+lob_io_error_sqlstate=S1000
+lob_io_error_sqlcode=29064
lob_has_been_freed_msg=Lob object has already been freed
lob_has_been_freed_sqlstate=HY000
@@ -598,6 +598,7 @@ out_of_lob_bound_sqlcode=29063
clob_null_string_para_msg=String to set can not be null
clob_null_string_para_sqlstate=HY000
clob_null_string_para_sqlcode=29065
+
#
# New Messages for LOB Support From Type 2
#
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
index 6ee93bf..50b0207 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
@@ -21,6 +21,8 @@
package org.trafodion.jdbc.t4;
+import java.io.IOException;
+import java.io.InputStream;
import java.math.BigDecimal;
import java.sql.DataTruncation;
import java.sql.Date;
@@ -119,23 +121,28 @@ class InterfaceStatement {
int nullValue = pstmt.inputDesc_[paramNumber].nullValue_;
int dataLength = pstmt.inputDesc_[paramNumber].maxLen_;
- boolean shortLength = precision < Math.pow(2, 15);
- int dataOffset = ((shortLength) ? 2 : 4);
+ int dataOffset = 2;
+ boolean shortLength = false;
+ if (dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH) {
+ shortLength = precision < Math.pow(2, 15);
+ dataOffset = ((shortLength) ? 2 : 4);
+ dataLength += dataOffset;
- if ((dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH)
- || (dataType == InterfaceResultSet.SQLTYPECODE_BLOB)
- || (dataType == InterfaceResultSet.SQLTYPECODE_CLOB)) {
- dataLength += dataOffset;
+ if (dataLength % 2 != 0)
+ dataLength++;
+ } else if (dataType == InterfaceResultSet.SQLTYPECODE_BLOB || dataType == InterfaceResultSet.SQLTYPECODE_CLOB) {
+ shortLength = false;
+ dataOffset = 4;
+ dataLength += dataOffset;
- if (dataLength % 2 != 0)
- dataLength++;
- }
-
- noNullValue = (noNullValue * paramRowCount) + (rowNumber * dataLength);
+ if (dataLength % 2 != 0)
+ dataLength++;
+ }
if (nullValue != -1)
nullValue = (nullValue * paramRowCount) + (rowNumber * 2);
+ noNullValue = (noNullValue * paramRowCount) + (rowNumber * dataLength);
if (paramValue == null) {
if (nullValue == -1) {
throw TrafT4Messages.createSQLException(pstmt.connection_.props_, locale,
@@ -426,8 +433,7 @@ class InterfaceStatement {
break;
case InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH:
case InterfaceResultSet.SQLTYPECODE_VARCHAR_LONG:
- case InterfaceResultSet.SQLTYPECODE_BLOB:
- case InterfaceResultSet.SQLTYPECODE_CLOB:
+
if (paramValue instanceof byte[]) {
tmpBarray = (byte[]) paramValue;
} else if (paramValue instanceof String) {
@@ -470,6 +476,59 @@ class InterfaceStatement {
"VARCHAR data longer than column length: " + paramNumber);
}
break;
+ case InterfaceResultSet.SQLTYPECODE_BLOB:
+ if (paramValue instanceof InputStream) {
+ InputStream is = (InputStream)paramValue;
+ dataLen = 0;
+ try {
+ int bytesRead = is.read(values, noNullValue + dataOffset, maxLength - dataOffset);
+ dataLen = bytesRead;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.arraycopy(Bytes.createIntBytes(dataLen, this.ic_.getByteSwap()), 0, values, noNullValue, dataOffset);
+ }
+ else {
+ tmpBarray = (byte[])paramValue;
+ dataLen = tmpBarray.length;
+ dataOffset = 4;
+ if (maxLength > dataLen) {
+ System.arraycopy(Bytes.createIntBytes(dataLen, this.ic_.getByteSwap()), 0, values, noNullValue, dataOffset);
+ System.arraycopy(tmpBarray, 0, values, (noNullValue + dataOffset), dataLen);
+ } else {
+ throw TrafT4Messages.createSQLException(pstmt.connection_.props_, locale, "23",
+ "BLOB input data is longer than the length for column: " + paramNumber);
+ }
+ }
+ break;
+ case InterfaceResultSet.SQLTYPECODE_CLOB:
+ String charSet = "";
+
+ try {
+ if (this.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
+ && !this.ic_.getEnforceISO() && dataCharSet == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
+ charSet = ic_.t4props_.getISO88591();
+ else
+ {
+ if(dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.ic_.getByteSwap())
+ charSet = "UTF-16LE";
+ else
+ charSet = InterfaceUtilities.getCharsetName(dataCharSet);
+ }
+ tmpBarray = ((String) paramValue).getBytes("UTF-8");
+ } catch (Exception e) {
+ throw TrafT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ charSet);
+ }
+ dataLen = tmpBarray.length;
+ dataOffset = 4;
+ if (maxLength > dataLen) {
+ System.arraycopy(Bytes.createIntBytes(dataLen, this.ic_.getByteSwap()), 0, values, noNullValue, dataOffset);
+ System.arraycopy(tmpBarray, 0, values, (noNullValue + dataOffset), dataLen);
+ }
+
+ break;
case InterfaceResultSet.SQLTYPECODE_INTEGER:
tmpbd = Utility.getBigDecimalValue(locale, paramValue);
if (scale > 0) {
@@ -772,10 +831,11 @@ class InterfaceStatement {
dataValue.buffer = new byte[bufLen];
+
for (int row = 0; row < paramRowCount; row++) {
for (int col = 0; col < paramCount; col++) {
try {
- convertObjectToSQL2(locale, stmt, paramValues[row * paramCount + col], paramRowCount, col,
+ convertObjectToSQL2(locale, stmt, paramValues[row * paramCount + col], paramRowCount, col,
dataValue.buffer, row - clientErrors.size());
} catch (TrafT4Exception e) {
if (paramRowCount == 1) // for single rows we need to
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java
index ce0e3ac..360fb46 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java
@@ -101,6 +101,11 @@ class LogicalByteArray {
loc += len;
}
+ void insertByteArray(byte[] value, int pos, int len) {
+ System.arraycopy(value, pos, array, loc, len);
+
+ loc += len;
+ }
void insertChar(char value) {
array[loc++] = (byte) value;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java
index 031c581..d297c31 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java
@@ -169,6 +169,7 @@ class TRANSPORT {
// extent API used to extract lob data
static final short SRVR_API_EXTRACTLOB = 3030;
+ static final short SRVR_API_UPDATELOB = 3031;
static final short SQL_ATTR_ROWSET_RECOVERY = 2000;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Blob.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Blob.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Blob.java
index 212e2e2..499dd82 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Blob.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Blob.java
@@ -27,57 +27,24 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-public class TrafT4Blob implements Blob {
- private byte[] data_ = null;
- private boolean isFreed_ = false;
- private String lobHandle_ = null;
- private TrafT4Connection connection_ = null;
-
- public TrafT4Blob(TrafT4Connection connection, String lobHandle) throws SQLException{
- if (connection == null) {
- throw TrafT4Messages.createSQLException(connection_.props_, null, null, null);
- }
-
- this.connection_ = connection;
- this.lobHandle_ = lobHandle;
-
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, lobHandle);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getClob", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, lobHandle);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getClob");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- T4Connection t4connection = this.connection_.getServerHandle().getT4Connection();
- LogicalByteArray wbuffer = ExtractLobMessage.marshal(ExtractLobMessage.LOB_EXTRACT_BUFFER, lobHandle_, 1, 0,
- connection_.ic_);
- LogicalByteArray rbuffer = t4connection.getReadBuffer(TRANSPORT.SRVR_API_EXTRACTLOB, wbuffer);
- ExtractLobReply reply = new ExtractLobReply(rbuffer, connection_.ic_);
+import java.sql.Types;
- this.data_ = reply.lobDataValue;
+public class TrafT4Blob extends TrafT4Lob implements Blob
+{
+ public TrafT4Blob(TrafT4Connection connection, String lobHandle, byte[] data) throws SQLException {
+ super(connection, lobHandle, data, Types.BLOB);
}
+ @Override
public InputStream getBinaryStream() throws SQLException {
testAvailability();
- return new ByteArrayInputStream(this.data_);
+ return new ByteArrayInputStream((byte[]) data_);
}
+ @Override
public InputStream getBinaryStream(long pos, long length) throws SQLException {
testAvailability();
- TrafT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(),
- "getBinaryStream()");
- return null;
+ return new ByteArrayInputStream((byte[]) data_);
}
/*
@@ -85,6 +52,8 @@ public class TrafT4Blob implements Blob {
* as an array of bytes. This byte array contains up to length consecutive
* bytes starting at position pos.
* */
+
+ @Override
public byte[] getBytes(long pos, int length) throws SQLException {
testAvailability();
@@ -92,25 +61,28 @@ public class TrafT4Blob implements Blob {
int startPos = (int)pos - 1;
int endPos = startPos + length;
- if((startPos > data_.length) || (startPos < 0) || (length < 0))
+ byte[] binaryData = (byte[]) data_;
+ if ((startPos > binaryData.length) || (startPos < 0) || (length < 0))
throw TrafT4Messages.createSQLException(this.connection_.props_, this.connection_.getLocale(),
"out_of_lob_bound", null);
- if((endPos - 1) > data_.length) {
- length = data_.length - startPos;
+ if ((endPos - 1) > binaryData.length) {
+ length = binaryData.length - startPos;
}
buf = new byte[length];
- System.arraycopy(data_, startPos, buf, 0, length);
+ System.arraycopy(binaryData, startPos, buf, 0, length);
return buf;
}
+ @Override
public int setBytes(long pos, byte[] bytes) throws SQLException {
testAvailability();
return setBytes(pos, bytes, 0, bytes.length);
}
+ @Override
public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
testAvailability();
OutputStream out = setBinaryStream(pos);
@@ -119,7 +91,7 @@ public class TrafT4Blob implements Blob {
out.write(bytes, offset, len);
} catch (IOException e) {
throw TrafT4Messages.createSQLException(this.connection_.props_, this.connection_.getLocale(),
- "blob_io_error", e.getMessage());
+ "lob_io_error", e.getMessage());
} finally {
try {
out.close();
@@ -130,26 +102,28 @@ public class TrafT4Blob implements Blob {
return len;
}
+ @Override
public long position(Blob pattern, long start) throws SQLException {
- TrafT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "position()");
- return 0;
+ return position(pattern.getBytes(0, (int) pattern.length()), start);
}
+ @Override
public long position(byte[] pattern, long start) throws SQLException {
TrafT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "position()");
return 0;
}
+ @Override
public OutputStream setBinaryStream(long pos) throws SQLException {
- TrafT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(),
- "setBinaryStream()");
- return null;
+ testAvailability();
+ return setOutputStream(pos);
}
+ @Override
public void truncate(long len) throws SQLException {
testAvailability();
- if (len < 0 || len > this.data_.length) {
+ if (len < 0 || len > ((byte[]) data_).length) {
throw TrafT4Messages.createSQLException(this.connection_.props_, this.connection_.getLocale(),
"out_of_lob_bound", null);
}
@@ -170,11 +144,14 @@ public class TrafT4Blob implements Blob {
throw TrafT4Messages.createSQLException(null, null, "lob_has_been_freed", null);
}
+
+ @Override
public long length() throws SQLException {
testAvailability();
- return data_.length;
+ return data_ == null ? 0 : ((byte[]) data_).length;
}
+ @Override
public void free() throws SQLException {
data_ = null;
isFreed_ = true;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Clob.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Clob.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Clob.java
index 6f51a8a..c33c4f0 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Clob.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Clob.java
@@ -21,85 +21,61 @@
package org.trafodion.jdbc.t4;
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.sql.Clob;
import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
+import java.sql.Types;
-public class TrafT4Clob implements Clob {
-
- private String data_ = null;
+public class TrafT4Clob extends TrafT4Lob implements Clob {
private boolean isFreed_ = false;
- private String lobHandle_ = null;
private TrafT4Connection connection_ = null;
- public TrafT4Clob(TrafT4Connection connection, String lobHandle) throws SQLException {
- if (connection == null) {
- throw TrafT4Messages.createSQLException(connection_.props_, null, null, null);
- }
-
- this.connection_ = connection;
- this.lobHandle_ = lobHandle;
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, lobHandle);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getClob", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, lobHandle);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getClob");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
+ public TrafT4Clob(TrafT4Connection connection, String lobHandle, String data) throws SQLException {
+ super(connection, lobHandle, data, Types.CLOB);
- T4Connection t4connection = this.connection_.getServerHandle().getT4Connection();
- LogicalByteArray wbuffer = ExtractLobMessage.marshal(ExtractLobMessage.LOB_EXTRACT_BUFFER, lobHandle_, 1, 0,
- connection_.ic_);
- LogicalByteArray rbuffer = t4connection.getReadBuffer(TRANSPORT.SRVR_API_EXTRACTLOB, wbuffer);
- ExtractLobReply reply = new ExtractLobReply(rbuffer, connection_.ic_);
-
- try {
- this.data_ = new String(reply.lobDataValue, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw TrafT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_.ic_.getLocale(),
- "unsupported_encoding", "UTF-8");
- }
+ if (this.data_ == null)
+ this.data_ = "";
}
+
+ @Override
public void free() throws SQLException {
data_ = null;
isFreed_ = true;
}
+ @Override
public InputStream getAsciiStream() throws SQLException {
- // TODO Auto-generated method stub
+ if (data_ != null) {
+ return new ByteArrayInputStream(((String) data_).getBytes());
+ }
+
return null;
}
+ @Override
public Reader getCharacterStream() throws SQLException {
testAvailability();
if (this.data_ != null) {
- return new StringReader(this.data_);
+ return new StringReader((String) data_);
}
return null;
}
+ @Override
public Reader getCharacterStream(long pos, long length) throws SQLException {
testAvailability();
return new StringReader(getSubString(pos, (int) length));
}
+ @Override
public String getSubString(long pos, int length) throws SQLException {
testAvailability();
@@ -110,52 +86,63 @@ public class TrafT4Clob implements Clob {
return null;
}
- if (endIndex > this.data_.length()) {
+ if (endIndex > ((String) data_).length()) {
throw TrafT4Messages.createSQLException(this.connection_.props_, this.connection_.getLocale(), null, null);
}
- return this.data_.substring(beginIndex, endIndex);
+ return ((String) data_).substring(beginIndex, endIndex);
}
+ @Override
public long length() throws SQLException {
testAvailability();
if (data_ != null) {
- return data_.length();
+ return ((String) data_).length();
}
return 0;
}
+ @Override
public long position(String searchstr, long start) throws SQLException {
- start--;
+ //start--;
- if (start <= 0 || start > this.data_.length()) {
+ if (start <= 0 || start > ((String) data_).length()) {
throw TrafT4Messages.createSQLException(this.connection_.props_, null, null, null);
}
- int pos = this.data_.indexOf(searchstr, (int) start);
+ start--;
+
+ int pos = ((String) data_).indexOf(searchstr, (int) start);
if (pos == -1) {
return -1;
}
- return pos - 1;
+ return pos;
}
+ @Override
public long position(Clob searchstr, long start) throws SQLException {
return position(searchstr.getSubString(1L, (int) searchstr.length()), start);
}
+ @Override
public OutputStream setAsciiStream(long pos) throws SQLException {
- TrafT4Messages.throwUnsupportedFeatureException(this.connection_.props_, this.connection_.getLocale(),
- "setAsciiStream()");
- return null;
+ if (pos < 1) {
+ throw TrafT4Messages.createSQLException(this.connection_.props_, this.connection_.getLocale(),
+ "out_of_lob_bound_msg", null);
+ }
+
+ return setOutputStream(pos);
}
+ @Override
public Writer setCharacterStream(long pos) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ TrafT4Writer writer = new TrafT4Writer(this, pos);
+ return writer;
}
+ @Override
public int setString(long pos, String str) throws SQLException {
int startIndex = (int) pos - 1;
if (startIndex < 0) {
@@ -166,32 +153,37 @@ public class TrafT4Clob implements Clob {
throw TrafT4Messages.createSQLException(this.connection_.props_, this.connection_.getLocale(), "clob_null_string_para", null);
}
- StringBuilder buf = new StringBuilder(this.data_);
+ StringBuilder buf = new StringBuilder(((String) data_));
int len = str.length();
buf.replace(startIndex, startIndex + len, str);
this.data_ = buf.toString();
+ this.flush();
return len;
}
+ @Override
public int setString(long pos, String str, int offset, int len) throws SQLException {
int start = (int) pos - 1;
String replacestr = str.substring(offset, offset + len);
- StringBuilder buf = new StringBuilder(this.data_);
+ StringBuilder buf = new StringBuilder(((String) data_));
buf.replace(start, start + replacestr.length(), replacestr);
this.data_ = buf.toString();
+ this.flush();
return len;
}
+ @Override
public void truncate(long len) throws SQLException {
- if (len > this.data_.length()) {
+ if (len > ((String) data_).length()) {
throw TrafT4Messages.createSQLException(connection_.props_, null, null, null);
}
- this.data_ = this.data_.substring(0, (int) len);
+ this.data_ = ((String) data_).substring(0, (int) len);
+ this.flush();
}
private void testAvailability() throws SQLException {
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
index 8be2fd5..2a8e381 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
@@ -1859,13 +1859,11 @@ public class TrafT4Connection extends PreparedStatementManager implements java.s
}
public Clob createClob() throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ return new TrafT4Clob(this, null, null);
}
public Blob createBlob() throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ return new TrafT4Blob(this, null, null);
}
public NClob createNClob() throws SQLException {
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Desc.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Desc.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Desc.java
index 3a12532..f4d8fc0 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Desc.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Desc.java
@@ -524,7 +524,6 @@ class TrafT4Desc {
String columnLabel_;
boolean isAutoIncrement_;
boolean isSearchable_;
-
boolean isValueSet_; // To denote if setXXX method is called for this
// parameter
// String paramValue_; // Contains the value of output parameter value
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4InputStream.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4InputStream.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4InputStream.java
new file mode 100644
index 0000000..0a48b09
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4InputStream.java
@@ -0,0 +1,38 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class TrafT4InputStream extends InputStream {
+
+ @Override
+ public int read() throws IOException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ // Fields
+ TrafT4Lob lob_;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Lob.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Lob.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Lob.java
new file mode 100644
index 0000000..c2df6fe
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Lob.java
@@ -0,0 +1,213 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public abstract class TrafT4Lob {
+
+ protected String lobHandle_ = null;
+ protected TrafT4Connection connection_ = null;
+ protected boolean isFreed_ = true;
+ protected int lobType = Types.BLOB;
+
+ protected Object data_ = null;
+
+ protected TrafT4OutputStream outputStream_ = null;
+
+ public TrafT4Lob(TrafT4Connection connection, String lobHandle, Object data, int type) throws SQLException {
+ data_ = data;
+ lobType = type;
+ this.connection_ = connection;
+ this.lobHandle_ = lobHandle;
+
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, lobHandle);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getClob", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, lobHandle);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getClob");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (lobHandle_ != null)
+ read();
+ isFreed_ = false;
+ }
+
+ public TrafT4Lob(TrafT4Connection connection, byte[] data) throws SQLException {
+ this.connection_ = null;
+ this.data_ = data;
+ this.lobHandle_ = null;
+ this.isFreed_ = false;
+ }
+
+ public void read() throws SQLException {
+ if (this.connection_ == null) {
+ throw TrafT4Messages.createSQLException(connection_.props_, null, null, null);
+ }
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, this.connection_, this.lobHandle_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getClob", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, this.connection_, this.lobHandle_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("retrieveFromDB");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ T4Connection t4connection = this.connection_.getServerHandle().getT4Connection();
+ LogicalByteArray wbuffer = ExtractLobMessage.marshal(ExtractLobMessage.LOB_EXTRACT_BUFFER, lobHandle_, 1, 0,
+ connection_.ic_);
+
+ LogicalByteArray rbuffer = t4connection.getReadBuffer(TRANSPORT.SRVR_API_EXTRACTLOB, wbuffer);
+ ExtractLobReply reply = new ExtractLobReply(rbuffer, connection_.ic_);
+ data_ = reply.lobDataValue;
+ switch (lobType) {
+ case Types.BLOB:
+ data_ = reply.lobDataValue;
+ break;
+ case Types.CLOB:
+ try {
+ if (reply.lobDataLen == 0) {
+ data_ = "";
+ }
+ else {
+ data_ = new String(reply.lobDataValue, "UTF-8");
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw TrafT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_.ic_.getLocale(),
+ "unsupported_encoding", "UTF-8");
+ }
+ break;
+ }
+ }
+
+ void flush() throws SQLException {
+ if (this.connection_ == null) {
+ throw TrafT4Messages.createSQLException(connection_.props_, null, null, null);
+ }
+
+ if (this.lobHandle_ == null)
+ return ;
+ T4Connection t4connection = this.connection_.getServerHandle().getT4Connection();
+
+ final long chunkSize = 100 * 1024 * 1024;
+ LogicalByteArray wbuffer = null;
+
+ byte[] valueBuffer = null;
+
+ try {
+ switch (lobType) {
+ case Types.BLOB:
+ valueBuffer = (byte[]) data_;
+ break;
+
+ case Types.CLOB:
+ if (data_ instanceof String) {
+ valueBuffer = ((String) data_).getBytes("UTF-8");
+ } else if (data_ instanceof char[]) {
+ valueBuffer = String.valueOf(data_).getBytes("UTF-8");
+ } else if (data_ instanceof byte[]) {
+ valueBuffer = (byte[]) data_;
+ }
+ break;
+
+ default:
+ }
+ } catch (Exception e) {
+ throw TrafT4Messages.createSQLException(connection_.props_, connection_.ic_.getLocale(),
+ "unsupported_encoding_msg", null);
+ }
+
+ for (long i = 0; i < valueBuffer.length;) {
+ {
+ System.out.println("before net transform");
+ DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+ Date date = new Date();
+ System.out.println(dateFormat.format(date));
+ }
+ if (valueBuffer.length - i > chunkSize) {
+ wbuffer = UpdateLobMessage.marshal((short) 1, lobHandle_, valueBuffer.length, i, valueBuffer, i,
+ chunkSize,
+ this.connection_.ic_);
+ i += chunkSize;
+ }
+ else {
+ wbuffer = UpdateLobMessage.marshal((short) 1, lobHandle_, valueBuffer.length, i, valueBuffer, i,
+ valueBuffer.length - i, this.connection_.ic_);
+ i = valueBuffer.length;
+ }
+ {
+ System.out.println("after net transform");
+ DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+ Date date = new Date();
+ System.out.println(dateFormat.format(date));
+ }
+ LogicalByteArray rbuffer = t4connection.getReadBuffer(TRANSPORT.SRVR_API_UPDATELOB, wbuffer);
+ UpdateLobReply ur = new UpdateLobReply(rbuffer, connection_.ic_);
+
+ switch (ur.m_p1.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Lob", "flush",
+ "ur_.m_p1.exception_nr = TRANSPORT.CEE_SUCCESS", p);
+ }
+
+ break;
+ default:
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Lob", "flush",
+ "case ur.m_p1.exception_nr deafult", p);
+ }
+ throw TrafT4Messages.createSQLException(connection_.props_, connection_.ic_.getLocale(),
+ "lob_io_error", null);
+ }
+
+ }
+ }
+
+ protected OutputStream setOutputStream(long pos) throws SQLException {
+ outputStream_ = new TrafT4OutputStream(this, pos);
+ return outputStream_;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4OutputStream.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4OutputStream.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4OutputStream.java
new file mode 100644
index 0000000..8fee9a1
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4OutputStream.java
@@ -0,0 +1,55 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.sql.SQLException;
+
+public class TrafT4OutputStream extends ByteArrayOutputStream {
+ private boolean isClosed_ = true;
+ private TrafT4Lob lob_;
+
+ TrafT4OutputStream(TrafT4Lob lob, long pos) throws SQLException {
+ isClosed_ = false;
+ lob_ = lob;
+ }
+
+ private void testAvailability() throws IOException {
+ if (isClosed_) {
+ throw new IOException("Output stream is closed");
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ this.lob_.data_ = this.toByteArray();
+ try {
+ if (lob_.lobHandle_ != null) {
+ lob_.flush();
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
index 66323dc..a286122 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
@@ -301,7 +301,7 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
if (!connection_.props_.getDelayedErrorMode()) {
return (new int[] {});
}
- }
+ }
try {
if (!usingRawRowset_)
@@ -426,7 +426,7 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
"invalid_lob_commit_state", null);
}
- execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_);
+ execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_);
if (isAnyLob_) {
@@ -523,16 +523,18 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
switch (dataType) {
-
+
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
+ case Types.CLOB:
+ case Types.BLOB:
case Types.BINARY: // At this time Database does not have
- // this column data type
+ // this column data type
case Types.VARBINARY: // At this time Database does not
// have this column data type //#endif-java
case Types.LONGVARBINARY: // At this time Database does not
- // have this column data type
+ // have this column data type
byte[] buffer = new byte[length];
try {
x.read(buffer);
@@ -613,7 +615,7 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
dataType = inputDesc_[parameterIndex - 1].dataType_;
switch (dataType) {
-
+
case Types.DOUBLE:
case Types.DECIMAL:
@@ -628,12 +630,14 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
case Types.BINARY: // At this time Database does not have
- // this column data type
+ // this column data type
case Types.VARBINARY: // At this time Database does not
- // have this column data type
+ // have this column data type
case Types.LONGVARBINARY: // At this time Database does not
- // have this column data type
+ // have this column data type
byte[] buffer2 = new byte[length];
try {
@@ -668,10 +672,10 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
* Sets the designated parameter to the given <tt>Blob</tt> object. The
* driver converts this to an SQL <tt>BLOB</tt> value when it sends it to
* the database.
- *
+ *
* @param i the first parameter is 1, the second is 2, ... @param x a <tt>Blob</tt>
* object that maps an SQL <tt>BLOB</tt> value
- *
+ *
* @throws SQLException invalid data type for column
*/
public void setBlob(int parameterIndex, Blob x) throws SQLException {
@@ -695,8 +699,14 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
validateSetInvocation(parameterIndex);
dataType = inputDesc_[parameterIndex - 1].dataType_;
switch (dataType) {
-
-
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ addParamValue(parameterIndex, x.getBytes(1, (int) x.length()));
+ break;
+
default:
throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
"invalid_datatype_for_column", null);
@@ -781,14 +791,16 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
validateSetInvocation(parameterIndex);
dataType = inputDesc_[parameterIndex - 1].dataType_;
switch (dataType) {
-
-
+
+
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
+ case Types.BLOB:
+ case Types.CLOB:
addParamValue(parameterIndex, tmpArray);
break;
default:
@@ -819,7 +831,7 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
validateSetInvocation(parameterIndex);
dataType = inputDesc_[parameterIndex - 1].dataType_;
switch (dataType) {
-
+
case Types.DECIMAL:
case Types.DOUBLE:
@@ -864,12 +876,12 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
* Sets the designated parameter to the given <tt>Clob</tt> object. The
* driver converts this to an SQL <tt>CLOB</tt> value when it sends it to
* the database.
- *
+ *
* @param parameterIndex
* the first parameter is 1, the second is 2, ...
* @param x
* a <tt>Clob</tt> object that maps an SQL <tt>CLOB</tt>
- *
+ *
* @throws SQLException
* invalid data type for column, or restricted data type.
*/
@@ -894,14 +906,13 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
validateSetInvocation(parameterIndex);
dataType = inputDesc_[parameterIndex - 1].dataType_;
switch (dataType) {
-
-
- case Types.DECIMAL:
- case Types.DOUBLE:
- case Types.FLOAT:
- case Types.NUMERIC:
- throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_datatype_for_column", null);
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ addParamValue(parameterIndex, x.getSubString(1, (int) x.length()));
+ break;
default:
throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
null);
@@ -1230,13 +1241,13 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
+ case Types.CLOB:
setString(parameterIndex, x.toString());
break;
case Types.VARBINARY:
case Types.BINARY:
case Types.LONGVARBINARY:
+ case Types.BLOB:
setBytes(parameterIndex, (byte[]) x);
break;
case Types.TIMESTAMP:
@@ -1426,15 +1437,16 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
+ case Types.CLOB:
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
- case Types.OTHER: // This type maps to the Database
+ case Types.OTHER: // This type maps to the Database
// INTERVAL
addParamValue(parameterIndex, x);
break;
-
-
+
+
case Types.ARRAY:
case Types.BINARY:
case Types.BIT:
@@ -1725,12 +1737,12 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
/**
* This method will associate user defined data with the prepared statement.
* The user defined data must be in SQL/MX rowwise rowset format.
- *
+ *
* @param numRows
* the number of rows contained in buffer
* @param buffer
* a buffer containing the rows
- *
+ *
* @exception A
* SQLException is thrown
*/
@@ -1874,7 +1886,7 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
isClosed_ = true;
if (rowsValue_ != null) {
rowsValue_.clear();
-
+
}
if (lobObjects_ != null) {
lobObjects_.clear();
@@ -2386,8 +2398,8 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
String moduleName_;
int moduleVersion_;
long moduleTimestamp_;
- boolean isAnyLob_;
- ArrayList lobObjects_;
+ boolean isAnyLob_;
+ ArrayList lobObjects_;
ArrayList rowsValue_;
Object[] paramsValue_;
@@ -2466,7 +2478,7 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
public void setPoolable(boolean poolable) throws SQLException {
// TODO Auto-generated method stub
-
+
}
public boolean isPoolable() throws SQLException {
@@ -2476,7 +2488,7 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
public void closeOnCompletion() throws SQLException {
// TODO Auto-generated method stub
-
+
}
public boolean isCloseOnCompletion() throws SQLException {
@@ -2496,106 +2508,133 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql
public void setRowId(int parameterIndex, RowId x) throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setNString(int parameterIndex, String value)
throws SQLException {
// TODO Auto-generated method stub
-
+
}
-
+
public void setNCharacterStream(int parameterIndex, Reader value,
long length) throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setNClob(int parameterIndex, NClob value) throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setClob(int parameterIndex, Reader reader, long length)
throws SQLException {
- // TODO Auto-generated method stub
-
+ setCharacterStream(parameterIndex, reader, length);
}
public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException {
- // TODO Auto-generated method stub
-
+ setBinaryStream(parameterIndex, inputStream, (int) length);
}
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setSQLXML(int parameterIndex, SQLXML xmlObject)
throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setAsciiStream(int parameterIndex, InputStream x, long length)
throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setBinaryStream(int parameterIndex, InputStream x, long length)
throws SQLException {
- // TODO Auto-generated method stub
-
+ setBinaryStream(parameterIndex, x, (int)length);
}
public void setCharacterStream(int parameterIndex, Reader reader,
long length) throws SQLException {
- // TODO Auto-generated method stub
-
+ try {
+ char[] c = null;
+ if (length > 0) {
+ c = new char[(int)length];
+ int numRead = 0;
+
+ while (numRead < length) {
+ int count = reader.read(c, numRead, (int) (length - numRead));
+
+ if (count < 0) {
+ break;
+ }
+ numRead += count;
+ }
+ }
+ setString(parameterIndex, new String(c, 0, (int)length));
+ }
+ catch (Exception e) {
+
+ }
+
}
public void setAsciiStream(int parameterIndex, InputStream x)
throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setBinaryStream(int parameterIndex, InputStream x)
throws SQLException {
- // TODO Auto-generated method stub
-
+ addParamValue(parameterIndex, x);
}
public void setCharacterStream(int parameterIndex, Reader reader)
throws SQLException {
- // TODO Auto-generated method stub
-
+ try {
+ char[] c = null;
+ int len = 0;
+
+ c = new char[4096];
+ StringBuilder builder = new StringBuilder();
+
+ while ((len = reader.read(c)) != -1) {
+ builder.append(c, 0, len);
+ }
+
+ setString(parameterIndex, builder.toString());
+ }
+ catch (Exception e) {
+
+ }
}
public void setNCharacterStream(int parameterIndex, Reader value)
throws SQLException {
// TODO Auto-generated method stub
-
+
}
public void setClob(int parameterIndex, Reader reader) throws SQLException {
- // TODO Auto-generated method stub
-
+ setCharacterStream(parameterIndex, reader);
}
public void setBlob(int parameterIndex, InputStream inputStream)
throws SQLException {
- // TODO Auto-generated method stub
-
+ setBinaryStream(parameterIndex, inputStream);
}
public void setNClob(int parameterIndex, Reader reader) throws SQLException {
// TODO Auto-generated method stub
-
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
index e5864c9..fc5de4c 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
@@ -764,8 +764,6 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
case Types.CHAR:
case Types.VARCHAR: // Extension allows varchar and
case Types.LONGVARCHAR: // longvarchar data types
- case Types.BLOB:
- case Types.CLOB:
Object x = getCurrentRow().getUpdatedArrayElement(columnIndex);
if (x == null) {
@@ -782,8 +780,11 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
"invalid_cast_specification", null);
}
}
-
-
+ case Types.BLOB:
+ case Types.CLOB:
+ x = getLocalString(columnIndex);
+ Blob blob = new TrafT4Blob(connection_, (String) x, null);
+ return blob.getBytes(1, (int)blob.length());
default:
throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
null);
@@ -839,14 +840,16 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
- case Types.BLOB:
- case Types.CLOB:
data = getString(columnIndex);
if (data != null) {
return new java.io.StringReader(data);
} else {
return null;
}
+ case Types.BLOB:
+ case Types.CLOB:
+ Clob clob = getClob(columnIndex);
+ return clob.getCharacterStream();
default:
throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
null);
@@ -1837,8 +1840,6 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
}
case Types.VARCHAR:
case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
data = getLocalString(columnIndex);
if (stmt_ != null && stmt_.maxFieldSize_ != 0) {
if (data.length() > stmt_.maxFieldSize_) {
@@ -1846,6 +1847,20 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
}
}
break;
+ case Types.BLOB:
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ Blob blob = new TrafT4Blob(connection_, data, null);
+ return new String((blob.getBytes(1, (int) blob.length())));
+ }
+ break;
+ case Types.CLOB:
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ Clob clob = new TrafT4Clob(connection_, data, null);
+ return clob.getSubString(1, (int)clob.length());
+ }
+ break;
case Types.VARBINARY:
case Types.BINARY:
case Types.LONGVARBINARY:
@@ -4886,9 +4901,26 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
lobHandle = getLocalString(columnIndex);
-
- if (lobHandle != null) {
- return new TrafT4Clob(connection_, lobHandle);
+ int dataType = outputDesc_[columnIndex - 1].dataType_;
+ switch (dataType) {
+ case Types.CLOB:
+ case Types.BLOB:
+ lobHandle = getLocalString(columnIndex);
+ if (lobHandle != null) {
+ return new TrafT4Clob(connection_, lobHandle, null);
+ }
+ break;
+
+ case Types.VARCHAR:
+ case Types.CHAR:
+ case Types.LONGVARCHAR:
+ String data = getString(columnIndex);
+ if (data != null) {
+ return new TrafT4Clob(connection_, null, data);
+ }
+
+ default:
+ return null;
}
return null;
}
@@ -4936,7 +4968,7 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
lobHandle = getLocalString(columnIndex);
if (lobHandle != null) {
- return new TrafT4Blob(connection_, lobHandle);
+ return new TrafT4Blob(connection_, lobHandle, null);
}
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Writer.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Writer.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Writer.java
new file mode 100644
index 0000000..a8ad285
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Writer.java
@@ -0,0 +1,53 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.sql.SQLException;
+
+public class TrafT4Writer extends CharArrayWriter {
+ private boolean isClosed_ = true;
+ private TrafT4Lob lob_;
+
+ TrafT4Writer(TrafT4Lob lob, long pos) throws SQLException {
+ this.lob_ = lob;
+ }
+
+ private void testAvailability() throws IOException {
+ if (isClosed_) {
+ throw new IOException("Output stream is closed");
+ }
+ }
+
+ @Override
+ public void close() {
+ lob_.data_ = new String(this.toCharArray());
+ try {
+ if (lob_.connection_ != null) {
+ lob_.flush();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobMessage.java
new file mode 100644
index 0000000..6bbd092
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobMessage.java
@@ -0,0 +1,67 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.sql.SQLException;
+
+public class UpdateLobMessage {
+ static LogicalByteArray marshal(short type, String lobHandle, long totalLength, long offset, byte[] data, long pos,
+ long length,
+ InterfaceConnection ic) throws SQLException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ wlength += TRANSPORT.size_short;
+
+ byte[] lobHandleByets;
+ try {
+ lobHandleByets = ic.encodeString(lobHandle, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += TRANSPORT.size_int;
+ if (lobHandle.length() > 0) {
+ wlength += TRANSPORT.size_bytesWithCharset(lobHandleByets);
+ }
+
+ wlength += TRANSPORT.size_long;
+ wlength += TRANSPORT.size_long;
+ wlength += TRANSPORT.size_long;
+
+ wlength += data.length;
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(type);
+ buf.insertStringWithCharset(lobHandleByets, InterfaceUtilities.SQLCHARSETCODE_ISO88591);
+
+ buf.insertLong(totalLength);
+ buf.insertLong(offset);
+ buf.insertLong(length);
+
+ buf.insertByteArray(data, (int) pos, (int) length);
+ //buf.setDataBuffer(data_);
+
+ return buf;
+ } catch (Exception e) {
+ throw TrafT4Messages.createSQLException(ic.t4props_, ic.getLocale(), "unsupported_encoding", "UTF-8");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobReply.java
new file mode 100644
index 0000000..92a1069
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/UpdateLobReply.java
@@ -0,0 +1,47 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.sql.SQLException;
+
+public class UpdateLobReply {
+ int totalErrorLength;
+ SQLWarningOrError[] errorList;
+
+ odbc_SQLSvc_UpdateLob_exc_ m_p1;
+ String proxySyntax = "";
+
+ UpdateLobReply(LogicalByteArray buf, InterfaceConnection ic) throws SQLException {
+ buf.setLocation(Header.sizeOf());
+
+ try {
+ m_p1 = new odbc_SQLSvc_UpdateLob_exc_();
+ m_p1.extractFromByteArray(buf, ic);
+ }
+ catch (SQLException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw TrafT4Messages.createSQLException(ic.t4props_, ic.getLocale(), "unsupported_encoding", "UTF-8");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_UpdateLob_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_UpdateLob_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_UpdateLob_exc_.java
new file mode 100644
index 0000000..4ff7d02
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_UpdateLob_exc_.java
@@ -0,0 +1,70 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.sql.SQLException;
+
+public class odbc_SQLSvc_UpdateLob_exc_ {
+ int exception_nr;
+ int exception_detail;
+
+ int p3Index;
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+ int SQLQueryCancelled;
+
+ static final int odbc_SQLSvc_UpdateLob_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_UpdateLob_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_UpdateLob_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_UpdateLob_SQLInvalidHandle_exn_ = 4;
+
+ odbc_SQLSvc_UpdateLob_exc_() {
+ // Do nothing constructor
+ }
+
+ void extractFromByteArray(LogicalByteArray buffer1, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buffer1.extractInt();
+ exception_detail = buffer1.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_UpdateLob_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buffer1, ic);
+ break;
+ case odbc_SQLSvc_UpdateLob_ParamError_exn_:
+ ParamError = ic.decodeBytes(buffer1.extractString(), 1);
+ throw TrafT4Messages.createSQLException(null, ic.getLocale(), "ids_progra _error", ParamError);
+ case odbc_SQLSvc_UpdateLob_SQLInvalidHandle_exn_:
+ break;
+ default:
+ throw TrafT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/Common/TransportBase.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/Common/TransportBase.h b/core/conn/odbc/src/odbc/Common/TransportBase.h
index f40ca77..7128c11 100644
--- a/core/conn/odbc/src/odbc/Common/TransportBase.h
+++ b/core/conn/odbc/src/odbc/Common/TransportBase.h
@@ -136,6 +136,7 @@ enum SRVR_API {
SRVR_API_SQLFASTFETCH_PERF, //OK WMS
SRVR_API_GETSEGMENTS, //OK WMS
SRVR_API_EXTRACTLOB, //OK LOB
+ SRVR_API_UPDATELOB,
SRVR_API_LASTAPI //Add new APIs before this
};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/Krypton/generated_incs/odbc_sv.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/Krypton/generated_incs/odbc_sv.h b/core/conn/odbc/src/odbc/Krypton/generated_incs/odbc_sv.h
index 55fad48..4346390 100644
--- a/core/conn/odbc/src/odbc/Krypton/generated_incs/odbc_sv.h
+++ b/core/conn/odbc/src/odbc/Krypton/generated_incs/odbc_sv.h
@@ -3536,6 +3536,31 @@ struct odbc_SQLsrvr_ExtractLob_exc_ {
};
/***************************************
+ * Operation 'odbc_SQLsvc_UpdateLob'
+ ***************************************/
+/*
+ * Exceptoin number constants for
+ * operation 'odbc_SQLSvc_UpdateLob'
+ */
+#define odbc_SQLSvc_UpdateLob_ParamError_exn_ 1
+#define odbc_SQLSvc_UpdateLob_InvalidConnect_exn_ 2
+#define odbc_SQLSvc_UpdateLob_SQLError_exn_ 3
+#define odbc_SQLSvc_UpdateLob_SQLInvalidhandle_exn_ 4
+
+/*
+ * Exception struct for
+ * Operation "odbc_SQLSvc_UpdateLob"
+ */
+struct odbc_SQLSvc_UpdateLob_exc_ {
+ IDL_long exception_nr;
+ IDL_long exception_detail;
+ union {
+ odbc_SQLSvc_ParamError ParamError;
+ odbc_SQLSvc_SQLError SQLError;
+ } u;
+};
+
+/***************************************
* Operation 'odbc_SQLSvc_ExecuteCall' *
***************************************/
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.cpp b/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.cpp
index 526f8c4..63dfbb7 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.cpp
@@ -2308,7 +2308,7 @@ odbc_SQLsrvr_ExtractLob_param_res_(
, UInt32& message_length
, const struct odbc_SQLsrvr_ExtractLob_exc_ *exception_
, IDL_long_long lobDataLen
- , IDL_char * lobDataValue
+ , BYTE * lobDataValue
)
{
CEE_status sts = CEE_SUCCESS;
@@ -2397,8 +2397,86 @@ odbc_SQLsrvr_ExtractLob_param_res_(
IDL_long_copy((IDL_long *)&lobDataLen, curptr);
if (lobDataValue != NULL)
{
- IDL_charArray_copy(lobDataValue, curptr);
+ IDL_byteArray_copy(lobDataValue, lobDataLen, curptr);
}
return sts;
}
+
+CEE_status
+odbc_SQLsrvr_UpdateLob_param_res_(
+ CInterface * pnode
+ , char* &buffer
+ , UInt32& message_length
+ , const struct odbc_SQLSvc_UpdateLob_exc_ *exception_
+)
+{
+ CEE_status sts = CEE_SUCCESS;
+ IDL_long wlength = 0;
+
+ char * curptr;
+
+ IDL_long exceptionLength = 0;
+
+ wlength += sizeof(HEADER);
+
+ // calculate length of the buffer for each parameter
+
+ //length of odbc_SQLSvc_UpdateLob_exc_
+ wlength += sizeof(exception_->exception_nr);
+ wlength += sizeof(exception_->exception_detail);
+
+ switch (exception_->exception_nr)
+ {
+ case odbc_SQLSvc_UpdateLob_ParamError_exn_:
+ wlength += sizeof(exceptionLength);
+ if (exception_->u.ParamError.ParamDesc != NULL)
+ {
+ exceptionLength = strlen(exception_->u.ParamError.ParamDesc) + 1;
+ wlength += exceptionLength;
+ }
+ break;
+ case odbc_SQLSvc_UpdateLob_InvalidConnect_exn_:
+ ERROR_DESC_LIST_length((ERROR_DESC_LIST_def *)&exception_->u.SQLError.errorList, wlength);
+ break;
+ case odbc_SQLSvc_UpdateLob_SQLError_exn_:
+ case odbc_SQLSvc_UpdateLob_SQLInvalidhandle_exn_:
+ break;
+ default:
+ break;
+ }
+
+
+ message_length = wlength;
+
+ buffer = pnode->w_allocate(message_length);
+ if (buffer == NULL)
+ {
+ return CEE_ALLOCFAIL;
+ }
+ curptr = (IDL_char *)(buffer + sizeof(HEADER));
+
+ IDL_long_copy((IDL_long *)&exception_->exception_nr, curptr);
+ IDL_long_copy((IDL_long *)&exception_->exception_detail, curptr);
+
+ switch(exception_->exception_nr)
+ {
+ case odbc_SQLSvc_UpdateLob_ParamError_exn_:
+ case odbc_SQLSvc_UpdateLob_InvalidConnect_exn_:
+ IDL_long_copy(&exceptionLength, curptr);
+
+ if (exception_->u.ParamError.ParamDesc != NULL)
+ IDL_charArray_copy((const IDL_char *)exception_->u.ParamError.ParamDesc, curptr);
+ break;
+
+ case odbc_SQLSvc_UpdateLob_SQLError_exn_:
+ ERROR_DESC_LIST_copy((ERROR_DESC_LIST_def *)&exception_->u.SQLError.errorList, curptr);
+ break;
+
+ case odbc_SQLSvc_UpdateLob_SQLInvalidhandle_exn_:
+ break;
+
+ default:
+ break;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.h b/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.h
index 6425fd5..8d21291 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.h
+++ b/core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.h
@@ -389,6 +389,14 @@ odbc_SQLsrvr_ExtractLob_param_res_(
, UInt32 & message_length
, const struct odbc_SQLsrvr_ExtractLob_exc_ *exception_
, IDL_long_long lobDataLen
- , IDL_char * lobDataValue
+ , BYTE * lobDataValue
+);
+
+CEE_status
+odbc_SQLsrvr_UpdateLob_param_res_(
+ CInterface * pnode
+ , char* &buffer
+ , UInt32& message_length
+ , const struct odbc_SQLSvc_UpdateLob_exc_ *exception_
);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.cpp b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.cpp
index c1e7313..5fba9e1 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.cpp
@@ -1555,6 +1555,69 @@ EXTRACTLOB_IOMessage(
);
}
+void UPDATELOB_IOMessage(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def *call_id_
+ )
+{
+ CInterface * pnode = (CInterface *)objtag_;
+ CEE_status sts = CEE_SUCCESS;
+
+ IDL_char *curptr;
+ IDL_long inputPosition = 0;
+
+ IDL_long lobUpdateType = 0;
+ IDL_long lobHandleLen = 0;
+ IDL_string lobHandle = NULL;
+ IDL_long lobHandleCharset = 0;
+
+ IDL_long_long totalLength = 0;
+ IDL_long_long offset = 0;
+ IDL_long_long length = 0;
+ BYTE * data = NULL;
+
+ curptr = pnode->r_buffer();
+
+ lobUpdateType = *(IDL_long *)(curptr + inputPosition);
+ inputPosition += sizeof(lobUpdateType);
+
+ lobHandleLen = *(IDL_long *)(curptr + inputPosition);
+ inputPosition += sizeof(lobHandleLen);
+
+ if (lobHandleLen > 0)
+ {
+ lobHandle = curptr + inputPosition;
+ inputPosition += lobHandleLen;
+ lobHandleCharset = *(IDL_long *)(curptr + inputPosition);
+ inputPosition += sizeof(lobHandleCharset);
+ }
+
+ totalLength = *(IDL_long_long *)(curptr + inputPosition);
+ inputPosition += sizeof(IDL_long_long);
+
+ offset = *(IDL_long_long *)(curptr + inputPosition);
+ inputPosition += sizeof(IDL_long_long);
+
+ length = *(IDL_long_long *)(curptr + inputPosition);
+ inputPosition += sizeof(IDL_long_long);
+
+ if (length > 0)
+ {
+ data = (BYTE *)curptr + inputPosition;
+ inputPosition += length;
+ }
+
+ odbc_SQLSrvr_UpdateLob_ame_(
+ objtag_,
+ call_id_,
+ lobUpdateType,
+ lobHandle,
+ totalLength,
+ offset,
+ length,
+ data);
+}
+
void LOG_MSG(CError* ierror, short level)
{
char buffer[500];
@@ -1873,6 +1936,9 @@ void DISPATCH_TCPIPRequest(
case SRVR_API_EXTRACTLOB:
EXTRACTLOB_IOMessage(objtag_, call_id_);
break;
+ case SRVR_API_UPDATELOB:
+ UPDATELOB_IOMessage(objtag_, call_id_);
+ break;
default:
//LCOV_EXCL_START
break;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.h b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.h
index c1a06fc..97184ba 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.h
+++ b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr.h
@@ -176,6 +176,17 @@ ValidateToken_IOMessage(
, /* In */ const CEE_handle_def *call_id_
);
+void
+EXTRACTLOB_IOMessage(
+ /* In */CEE_tag_def objtag_
+ , /* In */const CEE_handle_def *call_id_
+ );
+
+void
+UPDATELOB_IOMessage(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def *call_id_
+ );
void LOG_MSG(CError* ierror, short level);
void LOG_ERROR(CError* ierror);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.cpp b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.cpp
index f4ecdab..48602b7 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.cpp
@@ -648,7 +648,7 @@ odbc_SQLSrvr_ExtractLob_ts_res_(
, /* In */ const CEE_handle_def *call_id_
, /* In */ const struct odbc_SQLsrvr_ExtractLob_exc_ *exception_
, /* In */ IDL_long_long lobDataLen
- , /* In */ IDL_char *lobDataValue
+ , /* In */ BYTE *lobDataValue
)
{
CInterface* pnode = (CInterface *)objtag_;
@@ -681,6 +681,33 @@ odbc_SQLSrvr_ExtractLob_ts_res_(
return sts;
}
+void
+odbc_SQLSrvr_UpdateLob_ts_res_(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def * call_id_
+ , /* In */ const struct odbc_SQLSvc_UpdateLob_exc_ * exception_
+ )
+{
+ CInterface * pnode = (CInterface *) objtag_;
+
+ CEE_status sts = CEE_SUCCESS;
+
+ IDL_short error;
+ CEERCV_IOMessage_reply_seq_ reply;
+
+ char * buffer = NULL;
+ UInt32 message_length = 0;
+
+ sts = odbc_SQLsrvr_UpdateLob_param_res_(
+ pnode
+ , buffer
+ , message_length
+ , exception_
+ );
+
+ if (sts == CEE_SUCCESS)
+ sts = pnode->send_response(buffer, message_length, call_id_);
+}
//LCOV_EXCL_START
//LCOV_EXCL_STOP
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.h b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.h
index ecd6974..fba2e39 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.h
+++ b/core/conn/odbc/src/odbc/nsksrvr/Interface/odbcs_srvr_res.h
@@ -347,6 +347,13 @@ odbc_SQLSrvr_ExtractLob_ts_res_(
, /* In */ const CEE_handle_def *call_id_
, /* In */ const struct odbc_SQLsrvr_ExtractLob_exc_ *exception_
, /* In */ IDL_long_long lobDataLen
- , /* In */ IDL_char * lobDataValue
+ , /* In */ BYTE * lobDataValue
);
+
+void
+odbc_SQLSrvr_UpdateLob_ts_res_(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def * call_id_
+ , /* In */ const struct odbc_SQLSvc_UpdateLob_exc_ * exception_
+ );
#endif
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
index 0ccb927..c439175 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
@@ -8532,7 +8532,7 @@ odbc_SQLSrvr_ExtractLob_ame_(
{
ERROR_DESC_LIST_def sqlWarning = {0, 0};
IDL_long_long lobDataLen = 0;
- IDL_char * lobDataValue = NULL;
+ BYTE * lobDataValue = NULL;
odbc_SQLsrvr_ExtractLob_exc_ exception_ = {0, 0};
@@ -8551,6 +8551,36 @@ odbc_SQLSrvr_ExtractLob_ame_(
lobDataValue);
}
+void
+odbc_SQLSrvr_UpdateLob_ame_(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def *call_id_
+ , /* In */ IDL_short lobUpdateType
+ , /* In */ IDL_string lobHandle
+ , /* In */ IDL_long_long totalLength
+ , /* In */ IDL_long_long offset
+ , /* In */ IDL_long_long length
+ , /* In */ BYTE * data)
+{
+ ERROR_DESC_LIST_def sqlWarning = {0, 0};
+ odbc_SQLSvc_UpdateLob_exc_ exception_ = {0, 0};
+
+ odbc_SQLSrvr_UpdateLob_sme_(objtag_,
+ call_id_,
+ &exception_,
+ lobUpdateType,
+ lobHandle,
+ totalLength,
+ offset,
+ length,
+ data);
+
+ odbc_SQLSrvr_UpdateLob_ts_res_(objtag_,
+ call_id_,
+ &exception_
+ );
+
+}
void getCurrentCatalogSchema()
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.h b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.h
index dac532c..66556e8 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.h
+++ b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.h
@@ -340,6 +340,18 @@ odbc_SQLSrvr_ExtractLob_ame_(
, /* In */ IDL_string lobHandle
);
+void
+odbc_SQLSrvr_UpdateLob_ame_(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def *call_id_
+ , /* In */ IDL_short lobUpdateType
+ , /* In */ IDL_string lobHandle
+ , /* In */ IDL_long_long totalLength
+ , /* In */ IDL_long_long offset
+ , /* In */ IDL_long_long length
+ , /* In */ BYTE * data
+ );
+
bool SetHigherPriorityForMetaDataAccess();
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvrcore/srvrcommon.h
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvrcore/srvrcommon.h b/core/conn/odbc/src/odbc/nsksrvrcore/srvrcommon.h
index 32e09b2..6ed6692 100644
--- a/core/conn/odbc/src/odbc/nsksrvrcore/srvrcommon.h
+++ b/core/conn/odbc/src/odbc/nsksrvrcore/srvrcommon.h
@@ -388,7 +388,19 @@ odbc_SQLSrvr_ExtractLob_sme_(
, /* In */ IDL_long extractLobAPI
, /* In */ IDL_string lobHandle
, /* In */ IDL_long_long &lobDataLen
- , /* In */ IDL_char* &lobDataValue);
+ , /* In */ BYTE* &lobDataValue);
+
+extern "C" void
+odbc_SQLSrvr_UpdateLob_sme_(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def * call_id_
+ , /* In */ odbc_SQLSvc_UpdateLob_exc_ * exception_
+ , /* In */ IDL_short lobUpdateType
+ , /* In */ IDL_string lobHandle
+ , /* In */ IDL_long_long totalLength
+ , /* In */ IDL_long_long offset
+ , /* In */ IDL_long_long length
+ , /* In */ BYTE * data);
extern "C" void
GETMXCSWARNINGORERROR(
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp b/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp
index 50858e8..ccbb689 100644
--- a/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp
@@ -35,6 +35,8 @@
#include <platform_utils.h>
#include <stdio.h>
#include <stdlib.h>
+#include <map>
+#include <string>
// Used to disable and enable dumps via setrlimit in a release env.
#ifndef _DEBUG
@@ -56,7 +58,6 @@
#include "ResStatisticsStatement.h"
#include "NskUtil.h"
-
// reserved names for seabase metadata where SQL table information is kept
#ifndef SEABASE_MD_SCHEMA
#define SEABASE_MD_SCHEMA "\"_MD_\""
@@ -6381,6 +6382,7 @@ ret:
} // odbc_SQLSrvr_FetchPerf_sme_()
+
extern "C" void
odbc_SQLSrvr_ExtractLob_sme_(
/* In */ CEE_tag_def objtag_
@@ -6389,7 +6391,7 @@ odbc_SQLSrvr_ExtractLob_sme_(
, /* In */ IDL_long extractLobAPI
, /* In */ IDL_string lobHandle
, /* Out */ IDL_long_long &lobDataLen
- , /* Out */ IDL_char *& lobDataValue
+ , /* Out */ BYTE *& lobDataValue
)
{
char LobExtractQuery[1000];
@@ -6450,7 +6452,7 @@ odbc_SQLSrvr_ExtractLob_sme_(
exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_EXECDIRECT_FAILED;
}
- lobDataValue = new IDL_char[lobDataLen + 1];
+ lobDataValue = new BYTE[lobDataLen + 1];
if (lobDataValue == NULL)
{
exception_->exception_nr = odbc_SQLsrvr_ExtractLob_ParamError_exn_;
@@ -6510,6 +6512,87 @@ odbc_SQLSrvr_ExtractLob_sme_(
}
}
+extern "C" void
+odbc_SQLSrvr_UpdateLob_sme_(
+ /* In */ CEE_tag_def objtag_
+ , /* In */ const CEE_handle_def * call_id_
+ , /* In */ odbc_SQLSvc_UpdateLob_exc_ * exception_
+ , /* In */ IDL_short lobUpdateType
+ , /* In */ IDL_string lobHandle
+ , /* In */ IDL_long_long totalLength
+ , /* In */ IDL_long_long offset
+ , /* In */ IDL_long_long length
+ , /* In */ BYTE * data)
+{
+ char lobUpdateQuery[1000] = {0};
+ char RequestError[200] = {0};
+
+ SRVR_STMT_HDL * QryLobUpdateSrvrStmt = NULL;
+
+ if ((QryLobUpdateSrvrStmt = getSrvrStmt("MXOSRVR_UPDATELOB", TRUE)) == NULL)
+ {
+ SendEventMsg(MSG_MEMORY_ALLOCATION_ERROR,
+ EVENTLOG_ERROR_TYPE,
+ srvrGlobal->nskProcessInfo.processId,
+ ODBCMX_SERVER,
+ srvrGlobal->srvrObjRef,
+ 2,
+ "LOB UPDATE APIs",
+ "Allocate Statement");
+
+ exception_->exception_nr = odbc_SQLSvc_UpdateLob_ParamError_exn_;
+ exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_UNABLE_TO_ALLOCATE_SQL_STMT;
+ }
+
+ if (offset == 0)
+ {
+ snprintf(lobUpdateQuery, sizeof(lobUpdateQuery), "UPDATE LOB (LOB'%s', LOCATION %Ld, SIZE %Ld)", lobHandle, (Int64)data, length);
+ }
+ else
+ {
+ snprintf(lobUpdateQuery, sizeof(lobUpdateQuery), "UPDATE LOB (LOB'%s', LOCATION %Ld, SIZE %Ld, APPEND)", lobHandle, (Int64)data, length);
+ }
+
+ short retcode = 0;
+ try
+ {
+ retcode = QryLobUpdateSrvrStmt->ExecDirect(NULL, lobUpdateQuery, INTERNAL_STMT, TYPE_UNKNOWN, SQL_ASYNC_ENABLE_OFF, 0);
+
+ if (retcode == SQL_ERROR)
+ {
+ ERROR_DESC_def * p_buffer = QryLobUpdateSrvrStmt->sqlError.errorList._buffer;
+ strncpy(RequestError, p_buffer->errorText, sizeof(RequestError) - 1);
+
+ SendEventMsg(MSG_SQL_ERROR,
+ EVENTLOG_ERROR_TYPE,
+ srvrGlobal->nskProcessInfo.processId,
+ ODBCMX_SERVER,
+ srvrGlobal->srvrObjRef,
+ 2,
+ p_buffer->sqlcode,
+ RequestError);
+ exception_->exception_nr = odbc_SQLSvc_UpdateLob_ParamError_exn_;
+ exception_->u.SQLError.errorList._length = QryLobUpdateSrvrStmt->sqlError.errorList._length;
+ exception_->u.SQLError.errorList._buffer = QryLobUpdateSrvrStmt->sqlError.errorList._buffer;
+ exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_EXECUTE_FAILED;
+ }
+ }
+ catch (...)
+ {
+ SendEventMsg(MSG_PROGRAMMING_ERROR,
+ EVENTLOG_ERROR_TYPE,
+ srvrGlobal->nskProcessInfo.processId,
+ ODBCMX_SERVER,
+ srvrGlobal->srvrObjRef,
+ 1,
+ "Exception in executing UPDATE_LOB");
+
+ exception_->exception_nr = odbc_SQLSvc_UpdateLob_ParamError_exn_;
+ exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_EXECUTE_FAILED;
+ }
+
+}
+
//========================================================================
//LCOV_EXCL_START
short qrysrvc_GetAdaptiveSegment()
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/sql/cli/CliExpExchange.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliExpExchange.cpp b/core/sql/cli/CliExpExchange.cpp
index 8740b9d..953fc8b 100644
--- a/core/sql/cli/CliExpExchange.cpp
+++ b/core/sql/cli/CliExpExchange.cpp
@@ -4191,7 +4191,7 @@ InputOutputExpr::inputValues(atp_struct *atp,
{
// the first 4 bytes of data are actually the variable
// length indicator
- short VCLen;
+ Lng32 VCLen;
str_cpy_all((char *) &VCLen, source, sizeof(Int32));
sourceLen = (Lng32) VCLen;
source = &source[sizeof(Int32)];
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c82b9124/core/sql/cli/Descriptor.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Descriptor.cpp b/core/sql/cli/Descriptor.cpp
index 7e24b27..f501ecc 100644
--- a/core/sql/cli/Descriptor.cpp
+++ b/core/sql/cli/Descriptor.cpp
@@ -361,6 +361,9 @@ char *Descriptor::getVarItem(desc_struct &descItem, Lng32 idxrow)
else if (DFS2REC::isSQLVarChar(descItem.datatype)) {
ptr += idxrow * (descItem.rowsetVarLayoutSize + descItem.vc_ind_length);
}
+ else if (descItem.datatype == REC_BLOB || descItem.datatype == REC_CLOB) {
+ ptr += idxrow * (descItem.rowsetVarLayoutSize + 4);
+ }
else {
ptr += idxrow * descItem.rowsetVarLayoutSize;
}