📄 netstatementrequest.java
字号:
/* Derby - Class org.apache.derby.client.net.NetStatementRequest Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable. Licensed 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.*/package org.apache.derby.client.net;import org.apache.derby.client.am.Blob;import org.apache.derby.client.am.Clob;import org.apache.derby.client.am.ColumnMetaData;import org.apache.derby.client.am.ResultSet;import org.apache.derby.client.am.Section;import org.apache.derby.client.am.SqlException;import org.apache.derby.client.am.Types;// For performance, should we worry about the ordering of our DDM command parameterspublic class NetStatementRequest extends NetPackageRequest implements StatementRequestInterface { java.util.ArrayList extdtaPositions_ = null; // Integers: build EXTDTA for column i int overrideLid_ = FdocaConstants.FIRST_OVERRIDE_LID; // promototed parameters hold parameters that are promotoed to a different // data type because they are too large to represent in PROTOCOL otherwise. // This currently only applies for promotion of (VAR)CHAR -> CLOB and (VAR)BINARY -> BLOB // The key for this structure is the parameter index. Note that having this // collection does not eliminate the need for extdtaPositions_ because that // is still needed for non-promototed LOBs java.util.HashMap promototedParameters_ = new java.util.HashMap(); NetStatementRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize) { super(netAgent, ccsidManager, bufferSize); } //----------------------------- entry points --------------------------------- // Write the message to perform an execute immediate. // The SQL statement sent as command data cannot contain references // to either input variables or output variables. // // preconditions: public void writeExecuteImmediate(NetStatement materialStatement, String sql, Section section) throws SqlException { buildEXCSQLIMM(section, false, //sendQryinsid 0); //qryinsid buildSQLSTTcommandData(sql); // statement follows in sqlstt command data object } // Write the message to preform a prepare into. // Once the SQL statement has been prepared, it is executed until the unit of work, in // which the PRPSQLSTT command was issued, ends. An exception to this is if // Keep Dynamic is being used. // // preconditions: public void writePrepareDescribeOutput(NetStatement materialStatement, String sql, Section section) throws SqlException { buildPRPSQLSTT(section, sql, true, //sendRtnsqlda true, //sendTypsqlda CodePoint.TYPSQLDA_X_OUTPUT); //typsqlda if (((NetStatement) materialStatement).statement_.cursorAttributesToSendOnPrepare_ != null) { buildSQLATTRcommandData(((NetStatement) materialStatement).statement_.cursorAttributesToSendOnPrepare_); } buildSQLSTTcommandData(sql); // statement follows in sqlstt command data object } // Write the message to perform a reprepare. // // preconditions: public void writePrepare(NetStatement materialStatement, String sql, Section section) throws SqlException { buildPRPSQLSTT(section, sql, false, //sendRtnsqlda false, //sendTypsqlda 0); //typsqlda if (((NetStatement) materialStatement).statement_.cursorAttributesToSendOnPrepare_ != null) { buildSQLATTRcommandData(((NetStatement) materialStatement).statement_.cursorAttributesToSendOnPrepare_); } buildSQLSTTcommandData(sql); // statement follows in sqlstt command data object } // Write the message to execute prepared sql statement. // // preconditions: public void writeExecute(NetPreparedStatement materialPreparedStatement, Section section, ColumnMetaData parameterMetaData, Object[] inputs, int numInputColumns, boolean outputExpected, boolean chained) throws SqlException // chained flag for blobs only //dupqry { buildEXCSQLSTT(section, true, // sendOutexp outputExpected, // outexp false, // sendPrcnam null, // prcnam false, // sendQryblksz false, // sendMaxrslcnt, 0, // maxrslcnt, false, // sendMaxblkext 0, // maxblkext false, // sendRslsetflg 0, // resultSetFlag false, // sendQryrowset 0); // qryrowset if (numInputColumns > 0) { if ((extdtaPositions_ != null) && (!extdtaPositions_.isEmpty())) { extdtaPositions_.clear(); // reset extdta column position markers } boolean overrideExists = buildSQLDTAcommandData(numInputColumns, parameterMetaData, inputs); // can we eleminate the chain argument needed for lobs buildEXTDTA(parameterMetaData, inputs, chained); } } // Write the message to open a bound or prepared query with input parameters. // Check this -> For open query with input parameters // // preconditions: public void writeOpenQuery(NetPreparedStatement materialPreparedStatement, Section section, int fetchSize, int resultSetType, int numInputColumns, org.apache.derby.client.am.ColumnMetaData parameterMetaData, Object[] inputs) throws SqlException { boolean sendQryrowset = checkSendQryrowset(fetchSize, resultSetType); fetchSize = checkFetchsize(fetchSize, resultSetType); // think about if there is a way we can call build ddm just passing ddm parameters and not passing the material ps object // maybe not, if sometimes we need to set the caches hanging off the ps object during the ddm build // maybe we can extricate conditionals in the build ddm logic outside buildOPNQRY(section, sendQryrowset, fetchSize); // may be able to merge this with firstContinueQuery_ and push above conditional to common ((NetStatement) materialPreparedStatement).qryrowsetSentOnOpnqry_ = sendQryrowset; if (numInputColumns > 0) { if ((extdtaPositions_ != null) && (!extdtaPositions_.isEmpty())) { extdtaPositions_.clear(); // reset extdta column position markers } // is this the best place for this // EXCSQSTT needs this too // think about having this method return a boolean to // indicate the extdta should be built boolean overrideExists = buildSQLDTAcommandData(numInputColumns, parameterMetaData, inputs); // can we eleminate the chain argument needed for lobs // do we chain after Extdta's on open, verify this buildEXTDTA(parameterMetaData, inputs, false); //chained, do we chain after Extdta's on open } } // Write the message to open a bound or prepared query without input parameters. // Check this-> For open query without input parameters public void writeOpenQuery(NetStatement materialStatement, Section section, int fetchSize, int resultSetType) throws SqlException { boolean sendQryrowset = checkSendQryrowset(fetchSize, resultSetType); fetchSize = checkFetchsize(fetchSize, resultSetType); // think about if there is a way we can call build ddm just passing ddm parameters and not passing the material ps object // maybe not, if sometimes we need to set the caches hanging off the ps object during the ddm build // maybe we can extricate conditionals in the build ddm logic outside buildOPNQRY(section, sendQryrowset, fetchSize); // may be able to merge this with firstContinueQuery_ and push above conditional to common ((NetStatement) materialStatement).qryrowsetSentOnOpnqry_ = sendQryrowset; // net-specific event } // Write the message to peform a describe input. // public void writeDescribeInput(NetPreparedStatement materialPreparedStatement, Section section) throws SqlException { int typsqlda = CodePoint.TYPSQLDA_X_INPUT; buildDSCSQLSTT(section, true, //sendTypsqlda typsqlda); } // Write the message to peform a describe output. // // preconditions: public void writeDescribeOutput(NetPreparedStatement materialPreparedStatement, Section section) throws SqlException { // pick standard, light, extended sqlda. possibly push this up even more // right now use SQLAM level as determining factor and go for the most data. // if standard is the only suported option, don't send the typsqlda // and let server default to standard. This prevents accidentally sending // a typsqlda to a downlevel server. typsqlda is only supported at sqlam 6.//KATHEY CHECK buildDSCSQLSTT(section, true, //sendTypsqlda CodePoint.TYPSQLDA_X_OUTPUT); //typsqlda } // Write the message to execute a stored procedure. // // preconditions: public void writeExecuteCall(NetStatement materialStatement, boolean outputExpected, String procedureName, Section section, int fetchSize, boolean suppressResultSets, // for batch updates == true int resultSetType, ColumnMetaData parameterMetaData, Object[] inputs) throws SqlException // chain is for blobs { // always send QRYROWSET on EXCSQLSTT boolean sendQryrowset = true; fetchSize = (fetchSize == 0) ? org.apache.derby.client.am.Configuration.defaultFetchSize : fetchSize; boolean sendPrcnam = (procedureName != null) ? true : false; int numParameters = (parameterMetaData != null) ? parameterMetaData.columns_ : 0; outputExpected = numParameters > 0; // is it right here to send maxblkext (-1) buildEXCSQLSTT(section, true, // sendOutexp outputExpected, // outexp sendPrcnam, // sendPrcnam procedureName, // prcnam true, // sendQryblksz !suppressResultSets, // sendMaxrslcnt, CodePoint.MAXRSLCNT_NOLIMIT, // maxrslcnt, true, // sendMaxblkext -1, // maxblkext (-1 for AR capable of receiving entire result set) true, // sendRslsetflg calculateResultSetFlags(), // resultSetFlag sendQryrowset, // sendQryrowset fetchSize); // qryrowset if (numParameters > 0) { if ((extdtaPositions_ != null) && (!extdtaPositions_.isEmpty())) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -