db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r165585 [31/42] - in /incubator/derby/code/trunk/java/client/org/apache/derby: client/ client/am/ client/net/ client/resources/ jdbc/
Date Mon, 02 May 2005 06:26:03 GMT
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java Sun May  1 23:25:59 2005
@@ -19,203 +19,205 @@
 */
 package org.apache.derby.client.net;
 
-import org.apache.derby.client.am.SqlException;
-import org.apache.derby.client.am.DisconnectException;
 import org.apache.derby.client.am.Cursor;
+import org.apache.derby.client.am.DisconnectException;
 import org.apache.derby.client.am.Section;
+import org.apache.derby.client.am.SqlException;
+
+
+public class NetResultSet extends org.apache.derby.client.am.ResultSet {
+    // Alias for (NetConnection) super.statement.connection
+    private final NetConnection netConnection_;
+
+    // Alias for (NetStatement) super.statement
+    private final NetStatement netStatement_;
+
+    // Alias for (NetCursor) super.cursor
+    final NetCursor netCursor_;
+
+    // Alias for (NetAgent) super.agent
+    final private NetAgent netAgent_;
+
+    //-----------------------------state------------------------------------------
+
+    // This is used to avoid sending multiple outovr over subsequent next()'s
+    public boolean firstOutovrBuilt_ = false;
+
+    //---------------------constructors/finalizer---------------------------------
+
+    // parseOpnqrym() is called right after this constructor is called.
+
+    NetResultSet(NetAgent netAgent,
+                 NetStatement netStatement,
+                 Cursor cursor,
+                 //int qryprctyp,  //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
+                 int sqlcsrhld, // holdOption, 0xF0 for false (default) | 0xF1 for true.
+                 int qryattscr, // scrollOption, 0xF0 for false (default) | 0xF1 for true.
+                 int qryattsns, // sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
+                 int qryattset, // rowsetCursor, 0xF0 for false (default) | 0xF1 for true.
+                 long qryinsid, // instanceIdentifier, 0 (if not returned, check default) or number
+                 int actualResultSetType,
+                 int actualResultSetConcurrency,
+                 int actualResultSetHoldability) //throws DisconnectException
+    {
+        super(netAgent,
+                netStatement.statement_,
+                //new NetCursor (netAgent, qryprctyp),
+                cursor,
+                // call the constructor with the real resultSetType and resultSetConcurrency
+                // returned from the server
+                actualResultSetType,
+                actualResultSetConcurrency,
+                actualResultSetHoldability);
+
+        netAgent_ = netAgent;
+
+        // Set up cheat-links
+        netCursor_ = (NetCursor) cursor_;
+        netStatement_ = netStatement;
+        netConnection_ = netStatement.netConnection_;
+
+        netCursor_.netResultSet_ = this;
+
+        cursorHold_ = (sqlcsrhld != 0xf0);
+        if (qryattscr == 0xF1) {
+            scrollable_ = true;
+        }
+
+        switch (qryattsns) {
+        case CodePoint.QRYUNK:
+            sensitivity_ = sensitivity_unknown__;
+            break;
+        case CodePoint.QRYINS:
+            sensitivity_ = sensitivity_insensitive__;
+            break;
+        default:   // shouldn't happen
+            break;
+        }
+
+        if (qryattset == 0xF1) {
+            isRowsetCursor_ = true;
+        }
+
+        queryInstanceIdentifier_ = qryinsid;
+        nestingLevel_ = (int) ((queryInstanceIdentifier_ >>> 48) & 0xFFFF);
+    }
+
 
+    //-------------------------------flow methods---------------------------------
 
-public class NetResultSet extends org.apache.derby.client.am.ResultSet
-{
-  // Alias for (NetConnection) super.statement.connection
-  private final NetConnection netConnection_;
-
-  // Alias for (NetStatement) super.statement
-  private final NetStatement netStatement_;
-
-  // Alias for (NetCursor) super.cursor
-  final NetCursor netCursor_;
-
-  // Alias for (NetAgent) super.agent
-  final private NetAgent netAgent_;
-
-  //-----------------------------state------------------------------------------
-
-  // This is used to avoid sending multiple outovr over subsequent next()'s
-  public boolean firstOutovrBuilt_ = false;
-
-  //---------------------constructors/finalizer---------------------------------
-
-  // parseOpnqrym() is called right after this constructor is called.
-
-  NetResultSet (NetAgent netAgent,
-               NetStatement netStatement,
-               Cursor cursor,
-               //int qryprctyp,  //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
-               int sqlcsrhld,  // holdOption, 0xF0 for false (default) | 0xF1 for true.
-               int qryattscr,  // scrollOption, 0xF0 for false (default) | 0xF1 for true.
-               int qryattsns,  // sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
-               int qryattset,  // rowsetCursor, 0xF0 for false (default) | 0xF1 for true.
-               long qryinsid,  // instanceIdentifier, 0 (if not returned, check default) or number
-               int actualResultSetType,
-               int actualResultSetConcurrency,
-               int actualResultSetHoldability
-               ) //throws DisconnectException
-  {
-    super (netAgent,
-           netStatement.statement_,
-           //new NetCursor (netAgent, qryprctyp),
-           cursor,
-           // call the constructor with the real resultSetType and resultSetConcurrency
-           // returned from the server
-           actualResultSetType,
-           actualResultSetConcurrency,
-           actualResultSetHoldability);
-
-    netAgent_ = netAgent;
-
-    // Set up cheat-links
-    netCursor_ = (NetCursor) cursor_;
-    netStatement_ = netStatement;
-    netConnection_ = netStatement.netConnection_;
-
-    netCursor_.netResultSet_ = this;
-
-    cursorHold_ = (sqlcsrhld != 0xf0);
-    if (qryattscr == 0xF1) scrollable_ = true;
-
-    switch (qryattsns) {
-    case CodePoint.QRYUNK:
-      sensitivity_ = sensitivity_unknown__;
-      break;
-    case CodePoint.QRYINS:
-      sensitivity_ = sensitivity_insensitive__;
-      break;
-    default:   // shouldn't happen
-      break;
-    }
-
-    if (qryattset == 0xF1) isRowsetCursor_ = true;
-
-    queryInstanceIdentifier_ = qryinsid;
-    nestingLevel_ = (int)((queryInstanceIdentifier_ >>> 48) & 0xFFFF);
-  }
-
-
-  //-------------------------------flow methods---------------------------------
-
-  // Go through the QRYDTA's received, and calculate the column offsets for each row.
-  protected void parseRowset_ () throws SqlException
-  {
-    int row = 0;
-    // Parse all the rows received in the rowset
-    // The index we are passing will keep track of which row in the rowset we are parsing
-    // so we can reuse the columnDataPosition/Length/IsNull arrays.
-    while (netCursor_.calculateColumnOffsetsForRow_(row)) {
-      rowsReceivedInCurrentRowset_++;
-      row++;
-    }
-
-    // if rowset is not complete and an endqryrm was received, will skip the while loop
-    // and go to the checkAndThrow method.  otherwise flow an cntqry to try to complete
-    // the rowset.
-    // -- there is no need to complete the rowset for rowset cursors.  fetching stops when
-    //    the end of data is returned or when an error occurs.  all successfully fetched rows
-    //    are returned to the user.  the specific error is not returned until the next fetch.
-    while (rowsReceivedInCurrentRowset_ != fetchSize_ &&
-           !netCursor_.allRowsReceivedFromServer_ && !isRowsetCursor_ &&
-           sensitivity_ != sensitivity_sensitive_dynamic__) {
-      flowFetchToCompleteRowset ();
-      while (netCursor_.calculateColumnOffsetsForRow_(row)) {
-        rowsReceivedInCurrentRowset_++;
-        row++;
-      }
-    }
-    checkAndThrowReceivedQueryTerminatingException();
-  }
-
-  public void setFetchSize_ (int rows) { fetchSize_ = (rows == 0) ? 64 : rows; }
-
-  //-----------------------------helper methods---------------------------------
-
-  void flowFetchToCompleteRowset () throws DisconnectException
-  {
-    try {
-      agent_.beginWriteChain (statement_);
-
-      writeScrollableFetch_ ((generatedSection_ == null) ? statement_.section_ : generatedSection_,
-                            fetchSize_ - rowsReceivedInCurrentRowset_,
-                            scrollOrientation_relative__,
-                            1,
-                            false);  // false means do not disard pending
-                                     // partial row and pending query blocks
-
-      agent_.flow (statement_);
-      readScrollableFetch_ ();
-      agent_.endReadChain ();
-    }
-    catch (SqlException e) {
-      throw new DisconnectException (agent_, e);
-    }
-  }
-
-  void queryDataWasReturnedOnOpen() throws DisconnectException
-  {
-  }
-
-  // ------------------------------- abstract box car methods --------------------------------------
-  public void writeFetch_ (Section section) throws SqlException
-  {
-    if (resultSetType_ == java.sql.ResultSet.TYPE_FORWARD_ONLY && fetchSize_ != 0 &&
-        rowsYetToBeReceivedForRowset_ > 0)
-      netAgent_.resultSetRequest_.writeFetch (this,
-                                             section,
-                                             rowsYetToBeReceivedForRowset_);
-    else
-      netAgent_.resultSetRequest_.writeFetch (this,
-                                             section,
-                                             fetchSize_);
-  }
-
-  public void readFetch_ () throws SqlException
-  { netAgent_.resultSetReply_.readFetch (this); }
-
-  public void writeScrollableFetch_ (Section section,
-                                    int fetchSize,
-                                    int orientation,
-                                    long rowToFetch,
-                                    boolean resetQueryBlocks) throws SqlException
-  {
-    netAgent_.resultSetRequest_.writeScrollableFetch (
-      this,
-      section,
-      fetchSize,
-      orientation,
-      rowToFetch,
-      resetQueryBlocks);
-  }
-
-  // think about splitting out the position cursor stuff from the fetch stuff
-  // use commented out abstract position cursor methods above
-  public void readScrollableFetch_ () throws SqlException
-  { netAgent_.resultSetReply_.readScrollableFetch (this); }
-
-  public void writePositioningFetch_ (Section section,
-                                     int orientation,
-                                     long rowToFetch) throws SqlException
-  {
-    netAgent_.resultSetRequest_.writePositioningFetch (
-      this,
-      section,
-      orientation,
-      rowToFetch);
-  }
-
-  public void readPositioningFetch_ () throws SqlException
-  { netAgent_.resultSetReply_.readPositioningFetch (this); }
-
-  public void writeCursorClose_ (Section section) throws SqlException
-  { netAgent_.resultSetRequest_.writeCursorClose (this, section); }
-  public void readCursorClose_ () throws SqlException
-  { netAgent_.resultSetReply_.readCursorClose (this); }
+    // Go through the QRYDTA's received, and calculate the column offsets for each row.
+    protected void parseRowset_() throws SqlException {
+        int row = 0;
+        // Parse all the rows received in the rowset
+        // The index we are passing will keep track of which row in the rowset we are parsing
+        // so we can reuse the columnDataPosition/Length/IsNull arrays.
+        while (netCursor_.calculateColumnOffsetsForRow_(row)) {
+            rowsReceivedInCurrentRowset_++;
+            row++;
+        }
+
+        // if rowset is not complete and an endqryrm was received, will skip the while loop
+        // and go to the checkAndThrow method.  otherwise flow an cntqry to try to complete
+        // the rowset.
+        // -- there is no need to complete the rowset for rowset cursors.  fetching stops when
+        //    the end of data is returned or when an error occurs.  all successfully fetched rows
+        //    are returned to the user.  the specific error is not returned until the next fetch.
+        while (rowsReceivedInCurrentRowset_ != fetchSize_ &&
+                !netCursor_.allRowsReceivedFromServer_ && !isRowsetCursor_ &&
+                sensitivity_ != sensitivity_sensitive_dynamic__) {
+            flowFetchToCompleteRowset();
+            while (netCursor_.calculateColumnOffsetsForRow_(row)) {
+                rowsReceivedInCurrentRowset_++;
+                row++;
+            }
+        }
+        checkAndThrowReceivedQueryTerminatingException();
+    }
+
+    public void setFetchSize_(int rows) {
+        fetchSize_ = (rows == 0) ? 64 : rows;
+    }
+
+    //-----------------------------helper methods---------------------------------
+
+    void flowFetchToCompleteRowset() throws DisconnectException {
+        try {
+            agent_.beginWriteChain(statement_);
+
+            writeScrollableFetch_((generatedSection_ == null) ? statement_.section_ : generatedSection_,
+                    fetchSize_ - rowsReceivedInCurrentRowset_,
+                    scrollOrientation_relative__,
+                    1,
+                    false);  // false means do not disard pending
+            // partial row and pending query blocks
+
+            agent_.flow(statement_);
+            readScrollableFetch_();
+            agent_.endReadChain();
+        } catch (SqlException e) {
+            throw new DisconnectException(agent_, e);
+        }
+    }
+
+    void queryDataWasReturnedOnOpen() throws DisconnectException {
+    }
+
+    // ------------------------------- abstract box car methods --------------------------------------
+    public void writeFetch_(Section section) throws SqlException {
+        if (resultSetType_ == java.sql.ResultSet.TYPE_FORWARD_ONLY && fetchSize_ != 0 &&
+                rowsYetToBeReceivedForRowset_ > 0) {
+            netAgent_.resultSetRequest_.writeFetch(this,
+                    section,
+                    rowsYetToBeReceivedForRowset_);
+        } else {
+            netAgent_.resultSetRequest_.writeFetch(this,
+                    section,
+                    fetchSize_);
+        }
+    }
+
+    public void readFetch_() throws SqlException {
+        netAgent_.resultSetReply_.readFetch(this);
+    }
+
+    public void writeScrollableFetch_(Section section,
+                                      int fetchSize,
+                                      int orientation,
+                                      long rowToFetch,
+                                      boolean resetQueryBlocks) throws SqlException {
+        netAgent_.resultSetRequest_.writeScrollableFetch(this,
+                section,
+                fetchSize,
+                orientation,
+                rowToFetch,
+                resetQueryBlocks);
+    }
+
+    // think about splitting out the position cursor stuff from the fetch stuff
+    // use commented out abstract position cursor methods above
+    public void readScrollableFetch_() throws SqlException {
+        netAgent_.resultSetReply_.readScrollableFetch(this);
+    }
+
+    public void writePositioningFetch_(Section section,
+                                       int orientation,
+                                       long rowToFetch) throws SqlException {
+        netAgent_.resultSetRequest_.writePositioningFetch(this,
+                section,
+                orientation,
+                rowToFetch);
+    }
+
+    public void readPositioningFetch_() throws SqlException {
+        netAgent_.resultSetReply_.readPositioningFetch(this);
+    }
+
+    public void writeCursorClose_(Section section) throws SqlException {
+        netAgent_.resultSetRequest_.writeCursorClose(this, section);
+    }
+
+    public void readCursorClose_() throws SqlException {
+        netAgent_.resultSetReply_.readCursorClose(this);
+    }
 }

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java Sun May  1 23:25:59 2005
@@ -20,326 +20,320 @@
 
 package org.apache.derby.client.net;
 
-import org.apache.derby.client.am.SqlState;
-
-import org.apache.derby.client.am.SqlException;
 import org.apache.derby.client.am.DisconnectException;
-
 import org.apache.derby.client.am.ResultSet;
 import org.apache.derby.client.am.ResultSetCallbackInterface;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.am.SqlState;
 
-public class NetResultSetReply extends NetStatementReply implements ResultSetReplyInterface
-{
-  public NetResultSetReply (NetAgent netAgent, int bufferSize)
-  {
-    super (netAgent, bufferSize);
-  }
-
-  //----------------------------- entry points ---------------------------------
-
-  public void readFetch (ResultSetCallbackInterface resultSet) throws DisconnectException
-  {
-    startSameIdChainParse();
-    parseCNTQRYreply (resultSet, true); // true means we expect row data
-    endOfSameIdChainData();
-  }
-
-  public void readPositioningFetch (ResultSetCallbackInterface resultSet) throws DisconnectException
-  {
-    startSameIdChainParse();
-    parseCNTQRYreply (resultSet, false);  // false means return data is not expected
-    endOfSameIdChainData();
-  }
-
-  public void readScrollableFetch (ResultSetCallbackInterface resultSet) throws DisconnectException
-  {
-    startSameIdChainParse();
-    parseCNTQRYreply (resultSet, true);   // true means return data is expected
-    endOfSameIdChainData();
-  }
-
-  public void readCursorClose (ResultSetCallbackInterface resultSet) throws DisconnectException
-  {
-    startSameIdChainParse();
-    parseCLSQRYreply (resultSet);
-    endOfSameIdChainData();
-  }
-
-  //----------------------helper methods----------------------------------------
-
-  //------------------parse reply for specific command--------------------------
-
-  // These methods are "private protected", which is not a recognized java privilege,
-  // but means that these methods are private to this class and to subclasses,
-  // and should not be used as package-wide friendly methods.
-
-  // Parse the reply for the Close Query Command.
-  // This method handles the parsing of all command replies and reply data
-  // for the clsqry command.
-  private void parseCLSQRYreply (ResultSetCallbackInterface resultSet) throws DisconnectException
-  {
-    int peekCP = parseTypdefsOrMgrlvlovrs ();
-
-    if (peekCP == CodePoint.SQLCARD) {
-      NetSqlca netSqlca = parseSQLCARD (null);  //@f48553sxg - null means rowsetSqlca_ is null
-      // Set the cursor state if null SQLCA or sqlcode is equal to 0.
-      resultSet.completeSqlca (netSqlca);
-    }
-    else
-      parseCloseError (resultSet);
-  }
-
-  // Parse the reply for the Continue Query Command.
-  // This method handles the parsing of all command replies and reply data for the cntqry command.
-  // If doCopyQrydta==false, then there is no data, and we're only parsing out the sqlca to get the row count.
-  private void parseCNTQRYreply (ResultSetCallbackInterface resultSetI,
-                                 boolean doCopyQrydta) throws DisconnectException
-  {
-    boolean found = false;
-    int peekCP = peekCodePoint();
-    if (peekCP == CodePoint.RDBUPDRM) {
-      found = true;
-      parseRDBUPDRM();
-      peekCP = peekCodePoint();
+public class NetResultSetReply extends NetStatementReply implements ResultSetReplyInterface {
+    public NetResultSetReply(NetAgent netAgent, int bufferSize) {
+        super(netAgent, bufferSize);
     }
 
-    if (peekCP == CodePoint.QRYDTA) {
-      found = true;
-      if (!doCopyQrydta) {
-        parseLengthAndMatchCodePoint (CodePoint.QRYDTA);
-        //we don't need to copy QRYDTA since there is no data
-        if (longValueForDecryption_ != null)
-          longValueForDecryption_ = null;
-        if (longBufferForDecryption_ != null)
-          longBufferForDecryption_ = null;
-
-        int ddmLength = getDdmLength();
-        ensureBLayerDataInBuffer (ddmLength);
-        ((ResultSet)resultSetI).expandRowsetSqlca ();
-        NetSqlca sqlca = parseSQLCARDrow (((ResultSet)resultSetI).rowsetSqlca_);  
-        int daNullIndicator = readFastByte();
-        adjustLengths (getDdmLength());
-        // define event interface and use the event method
-        // only get the rowCount_ if sqlca is not null and rowCount_ is unknown
-        if (sqlca != null && sqlca.containsSqlcax())
-          ((ResultSet) resultSetI).setRowCountEvent (sqlca.getRowCount(netAgent_.targetTypdef_));
+    //----------------------------- entry points ---------------------------------
 
-        peekCP = peekCodePoint();
-        if (peekCP == CodePoint.RDBUPDRM) {
-          parseRDBUPDRM();
-          peekCP = peekCodePoint();
-        }
-        return;
-      }
-      do {
-        parseQRYDTA ((NetResultSet) resultSetI);
-        peekCP = peekCodePoint();
-      } while (peekCP == CodePoint.QRYDTA);
+    public void readFetch(ResultSetCallbackInterface resultSet) throws DisconnectException {
+        startSameIdChainParse();
+        parseCNTQRYreply(resultSet, true); // true means we expect row data
+        endOfSameIdChainData();
     }
 
-    if (peekCP == CodePoint.EXTDTA) {
-      found = true;
-      do {
-        copyEXTDTA ((NetCursor)((ResultSet) resultSetI).cursor_);
-        if (longBufferForDecryption_ != null ) {//encrypted EXTDTA
-          buffer_ = longBufferForDecryption_;
-          pos_ = longPosForDecryption_;
-          if (longBufferForDecryption_ != null && count_ > longBufferForDecryption_.length)
-            count_ = longBufferForDecryption_.length;
-        }
-
-        peekCP = peekCodePoint();
-      } while (peekCP == CodePoint.EXTDTA);
+    public void readPositioningFetch(ResultSetCallbackInterface resultSet) throws DisconnectException {
+        startSameIdChainParse();
+        parseCNTQRYreply(resultSet, false);  // false means return data is not expected
+        endOfSameIdChainData();
     }
 
-    if (peekCP == CodePoint.SQLCARD) {
-      found = true;
-      ((ResultSet)resultSetI).expandRowsetSqlca ();
-      NetSqlca netSqlca = parseSQLCARD (((ResultSet)resultSetI).rowsetSqlca_);
-      // for an atomic operation, the SQLCA contains the sqlcode for the first (statement
-      // terminating)error, the last warning, or zero.  all multi-row fetch operatons are
-      // atomic.  (the only operation that is not atomic is multi-row insert).
-      if (((ResultSet)resultSetI).sensitivity_ != ResultSet.sensitivity_sensitive_dynamic__) {
-        if (netSqlca != null && netSqlca.containsSqlcax() && netSqlca.getRowsetRowCount() == 0)
-          ((ResultSet) resultSetI).setRowCountEvent (netSqlca.getRowCount(netAgent_.targetTypdef_));
-      }
-      resultSetI.completeSqlca (netSqlca);
-      peekCP = peekCodePoint();
+    public void readScrollableFetch(ResultSetCallbackInterface resultSet) throws DisconnectException {
+        startSameIdChainParse();
+        parseCNTQRYreply(resultSet, true);   // true means return data is expected
+        endOfSameIdChainData();
     }
 
-    if (peekCP == CodePoint.ENDQRYRM) {
-      found = true;
-      parseEndQuery (resultSetI);
-      peekCP = peekCodePoint();
+    public void readCursorClose(ResultSetCallbackInterface resultSet) throws DisconnectException {
+        startSameIdChainParse();
+        parseCLSQRYreply(resultSet);
+        endOfSameIdChainData();
     }
 
-    if (peekCP == CodePoint.RDBUPDRM) {
-      found = true;
-      parseRDBUPDRM();
-    }
+    //----------------------helper methods----------------------------------------
 
-    if (!found)
-      parseFetchError (resultSetI);
+    //------------------parse reply for specific command--------------------------
 
-    if (longBufferForDecryption_ != null) {
-      // Not a good idea to create a new buffer_
-      buffer_ = new byte[DEFAULT_BUFFER_SIZE];
-      longBufferForDecryption_ = null;
-  }
-  }
-
-  void parseCloseError (ResultSetCallbackInterface resultSetI) throws DisconnectException
-  {
-    int peekCP = peekCodePoint();
-    switch (peekCP) {
-    case CodePoint.ABNUOWRM: {
-      NetSqlca sqlca = parseAbnormalEndUow (resultSetI.getConnectionCallbackInterface());
-      resultSetI.completeSqlca (sqlca);
-      break;
-    }
-    case CodePoint.CMDCHKRM:
-      parseCMDCHKRM();
-      break;
-    case CodePoint.QRYNOPRM:
-      parseQRYNOPRM (resultSetI);
-      break;
-    case CodePoint.RDBNACRM:
-      parseRDBNACRM();
-      break;
-    default:
-      parseCommonError (peekCP);
-    }
-  }
+    // These methods are "private protected", which is not a recognized java privilege,
+    // but means that these methods are private to this class and to subclasses,
+    // and should not be used as package-wide friendly methods.
 
-  void parseFetchError (ResultSetCallbackInterface resultSetI) throws DisconnectException
-  {
-    int peekCP = peekCodePoint();
-    switch (peekCP) {
-    case CodePoint.ABNUOWRM: {
-      NetSqlca sqlca = parseAbnormalEndUow (resultSetI.getConnectionCallbackInterface());
-      resultSetI.completeSqlca (sqlca);
-      break;
-    }
-    case CodePoint.CMDCHKRM:
-      parseCMDCHKRM();
-      break;
-    case CodePoint.CMDNSPRM:
-      parseCMDNSPRM();
-      break;
-    case CodePoint.QRYNOPRM:
-      parseQRYNOPRM (resultSetI);
-      break;
-    case CodePoint.RDBNACRM:
-      parseRDBNACRM();
-      break;
-    default:
-      parseCommonError (peekCP);
+    // Parse the reply for the Close Query Command.
+    // This method handles the parsing of all command replies and reply data
+    // for the clsqry command.
+    private void parseCLSQRYreply(ResultSetCallbackInterface resultSet) throws DisconnectException {
+        int peekCP = parseTypdefsOrMgrlvlovrs();
+
+        if (peekCP == CodePoint.SQLCARD) {
+            NetSqlca netSqlca = parseSQLCARD(null);  //@f48553sxg - null means rowsetSqlca_ is null
+            // Set the cursor state if null SQLCA or sqlcode is equal to 0.
+            resultSet.completeSqlca(netSqlca);
+        } else {
+            parseCloseError(resultSet);
+        }
     }
-  }
 
-  //-----------------------------parse DDM Reply Messages-----------------------
+    // Parse the reply for the Continue Query Command.
+    // This method handles the parsing of all command replies and reply data for the cntqry command.
+    // If doCopyQrydta==false, then there is no data, and we're only parsing out the sqlca to get the row count.
+    private void parseCNTQRYreply(ResultSetCallbackInterface resultSetI,
+                                  boolean doCopyQrydta) throws DisconnectException {
+        boolean found = false;
+        int peekCP = peekCodePoint();
+        if (peekCP == CodePoint.RDBUPDRM) {
+            found = true;
+            parseRDBUPDRM();
+            peekCP = peekCodePoint();
+        }
+
+        if (peekCP == CodePoint.QRYDTA) {
+            found = true;
+            if (!doCopyQrydta) {
+                parseLengthAndMatchCodePoint(CodePoint.QRYDTA);
+                //we don't need to copy QRYDTA since there is no data
+                if (longValueForDecryption_ != null) {
+                    longValueForDecryption_ = null;
+                }
+                if (longBufferForDecryption_ != null) {
+                    longBufferForDecryption_ = null;
+                }
+
+                int ddmLength = getDdmLength();
+                ensureBLayerDataInBuffer(ddmLength);
+                ((ResultSet) resultSetI).expandRowsetSqlca();
+                NetSqlca sqlca = parseSQLCARDrow(((ResultSet) resultSetI).rowsetSqlca_);
+                int daNullIndicator = readFastByte();
+                adjustLengths(getDdmLength());
+                // define event interface and use the event method
+                // only get the rowCount_ if sqlca is not null and rowCount_ is unknown
+                if (sqlca != null && sqlca.containsSqlcax()) {
+                    ((ResultSet) resultSetI).setRowCountEvent(sqlca.getRowCount(netAgent_.targetTypdef_));
+                }
+
+                peekCP = peekCodePoint();
+                if (peekCP == CodePoint.RDBUPDRM) {
+                    parseRDBUPDRM();
+                    peekCP = peekCodePoint();
+                }
+                return;
+            }
+            do {
+                parseQRYDTA((NetResultSet) resultSetI);
+                peekCP = peekCodePoint();
+            } while (peekCP == CodePoint.QRYDTA);
+        }
+
+        if (peekCP == CodePoint.EXTDTA) {
+            found = true;
+            do {
+                copyEXTDTA((NetCursor) ((ResultSet) resultSetI).cursor_);
+                if (longBufferForDecryption_ != null) {//encrypted EXTDTA
+                    buffer_ = longBufferForDecryption_;
+                    pos_ = longPosForDecryption_;
+                    if (longBufferForDecryption_ != null && count_ > longBufferForDecryption_.length) {
+                        count_ = longBufferForDecryption_.length;
+                    }
+                }
+
+                peekCP = peekCodePoint();
+            } while (peekCP == CodePoint.EXTDTA);
+        }
 
-  // Query Not Opened Reply Message is issued if a CNTQRY or CLSQRY
-  // command is issued for a query that is not open.  A previous
-  // ENDQRYRM, ENDUOWRM, or ABNUOWRM reply message might have
-  // terminated the command.
-  // PROTOCOL architects the SQLSTATE value depending on SVRCOD
-  // SVRCOD 4 -> SQLSTATE is 24501
-  // SVRCOD 8 -> SQLSTATE of 58008 or 58009
-  //
-  // if SVRCOD is 4 then SQLSTATE 24501, SQLCODE -501
-  // else SQLSTATE 58009, SQLCODE -30020
-  //
-  // Messages
-  // SQLSTATE : 24501
-  //     The identified cursor is not open.
-  //     SQLCODE : -501
-  //     The cursor specified in a FETCH or CLOSE statement is not open.
-  //     The statement cannot be processed.
-  // SQLSTATE : 58009
-  //     Execution failed due to a distribution protocol error that caused deallocation of the conversation.
-  //     SQLCODE : -30020
-  //     Execution failed because of a Distributed Protocol
-  //         Error that will affect the successful execution of subsequent
-  //         commands and SQL statements: Reason Code <reason-code>.
-  //     Some possible reason codes include:
-  //     121C Indicates that the user is not authorized to perform the requested command.
-  //     1232 The command could not be completed because of a permanent error.
-  //         In most cases, the server will be in the process of an abend.
-  //     220A The target server has received an invalid data description.
-  //         If a user SQLDA is specified, ensure that the fields are
-  //         initialized correctly. Also, ensure that the length does not exceed
-  //         the maximum allowed length for the data type being used.
-  //
-  //     The command or statement cannot be processed.  The current
-  //         transaction is rolled back and the application is disconnected
-  //         from the remote database.
-  //
-  // Returned from Server:
-  // SVRCOD - required  (4 - WARNING, 8 - ERROR)
-  // RDBNAM - required
-  // PKGNAMCSN - required
-  //
-  private void parseQRYNOPRM (ResultSetCallbackInterface resultSet) throws DisconnectException
-  {
-    boolean svrcodReceived = false;
-    int svrcod = CodePoint.SVRCOD_INFO;
-    boolean rdbnamReceived = false;
-    String rdbnam = null;
-    boolean pkgnamcsnReceived = false;
-    Object pkgnamcsn = null;
-
-    parseLengthAndMatchCodePoint (CodePoint.QRYNOPRM);
-    pushLengthOnCollectionStack();
-    int peekCP = peekCodePoint();
-
-    while (peekCP != Reply.END_OF_COLLECTION) {
-
-      boolean foundInPass = false;
-
-      if (peekCP == CodePoint.SVRCOD) {
-        foundInPass = true;
-        svrcodReceived = checkAndGetReceivedFlag (svrcodReceived);
-        svrcod = parseSVRCOD (CodePoint.SVRCOD_WARNING, CodePoint.SVRCOD_ERROR);
-        peekCP = peekCodePoint();
-      }
-
-      if (peekCP == CodePoint.RDBNAM) {
-        foundInPass = true;
-        rdbnamReceived = checkAndGetReceivedFlag (rdbnamReceived);
-        rdbnam = parseRDBNAM (true);
-        peekCP = peekCodePoint();
-      }
-
-      if (peekCP == CodePoint.PKGNAMCSN) {
-        foundInPass = true;
-        pkgnamcsnReceived = checkAndGetReceivedFlag (pkgnamcsnReceived);
-        pkgnamcsn = parsePKGNAMCSN (true);
-        peekCP = peekCodePoint();
-      }
+        if (peekCP == CodePoint.SQLCARD) {
+            found = true;
+            ((ResultSet) resultSetI).expandRowsetSqlca();
+            NetSqlca netSqlca = parseSQLCARD(((ResultSet) resultSetI).rowsetSqlca_);
+            // for an atomic operation, the SQLCA contains the sqlcode for the first (statement
+            // terminating)error, the last warning, or zero.  all multi-row fetch operatons are
+            // atomic.  (the only operation that is not atomic is multi-row insert).
+            if (((ResultSet) resultSetI).sensitivity_ != ResultSet.sensitivity_sensitive_dynamic__) {
+                if (netSqlca != null && netSqlca.containsSqlcax() && netSqlca.getRowsetRowCount() == 0) {
+                    ((ResultSet) resultSetI).setRowCountEvent(netSqlca.getRowCount(netAgent_.targetTypdef_));
+                }
+            }
+            resultSetI.completeSqlca(netSqlca);
+            peekCP = peekCodePoint();
+        }
 
-      if (!foundInPass)
-        doPrmnsprmSemantics (peekCP);
+        if (peekCP == CodePoint.ENDQRYRM) {
+            found = true;
+            parseEndQuery(resultSetI);
+            peekCP = peekCodePoint();
+        }
 
+        if (peekCP == CodePoint.RDBUPDRM) {
+            found = true;
+            parseRDBUPDRM();
+        }
+
+        if (!found) {
+            parseFetchError(resultSetI);
+        }
+
+        if (longBufferForDecryption_ != null) {
+            // Not a good idea to create a new buffer_
+            buffer_ = new byte[DEFAULT_BUFFER_SIZE];
+            longBufferForDecryption_ = null;
+        }
     }
-    popCollectionStack();
-    checkRequiredObjects (svrcodReceived, rdbnamReceived, pkgnamcsnReceived);
 
-    // move into a method
-    netAgent_.setSvrcod (svrcod);
-    if (svrcod == CodePoint.SVRCOD_WARNING) {
-      netAgent_.accumulateReadException (new SqlException (netAgent_.logWriter_,
-        "The identified cursor is not open.",
-        SqlState._24501));
+    void parseCloseError(ResultSetCallbackInterface resultSetI) throws DisconnectException {
+        int peekCP = peekCodePoint();
+        switch (peekCP) {
+        case CodePoint.ABNUOWRM:
+            {
+                NetSqlca sqlca = parseAbnormalEndUow(resultSetI.getConnectionCallbackInterface());
+                resultSetI.completeSqlca(sqlca);
+                break;
+            }
+        case CodePoint.CMDCHKRM:
+            parseCMDCHKRM();
+            break;
+        case CodePoint.QRYNOPRM:
+            parseQRYNOPRM(resultSetI);
+            break;
+        case CodePoint.RDBNACRM:
+            parseRDBNACRM();
+            break;
+        default:
+            parseCommonError(peekCP);
+        }
     }
-    else {
-      agent_.accumulateChainBreakingReadExceptionAndThrow (new DisconnectException (
-        agent_,
-        "Execution failed due to a distribution protocol error that " +
-        "caused deallocation of the conversation.  " +
-        "The identified cursor is not open.",
-        SqlState._58009));
+
+    void parseFetchError(ResultSetCallbackInterface resultSetI) throws DisconnectException {
+        int peekCP = peekCodePoint();
+        switch (peekCP) {
+        case CodePoint.ABNUOWRM:
+            {
+                NetSqlca sqlca = parseAbnormalEndUow(resultSetI.getConnectionCallbackInterface());
+                resultSetI.completeSqlca(sqlca);
+                break;
+            }
+        case CodePoint.CMDCHKRM:
+            parseCMDCHKRM();
+            break;
+        case CodePoint.CMDNSPRM:
+            parseCMDNSPRM();
+            break;
+        case CodePoint.QRYNOPRM:
+            parseQRYNOPRM(resultSetI);
+            break;
+        case CodePoint.RDBNACRM:
+            parseRDBNACRM();
+            break;
+        default:
+            parseCommonError(peekCP);
+        }
+    }
+
+    //-----------------------------parse DDM Reply Messages-----------------------
+
+    // Query Not Opened Reply Message is issued if a CNTQRY or CLSQRY
+    // command is issued for a query that is not open.  A previous
+    // ENDQRYRM, ENDUOWRM, or ABNUOWRM reply message might have
+    // terminated the command.
+    // PROTOCOL architects the SQLSTATE value depending on SVRCOD
+    // SVRCOD 4 -> SQLSTATE is 24501
+    // SVRCOD 8 -> SQLSTATE of 58008 or 58009
+    //
+    // if SVRCOD is 4 then SQLSTATE 24501, SQLCODE -501
+    // else SQLSTATE 58009, SQLCODE -30020
+    //
+    // Messages
+    // SQLSTATE : 24501
+    //     The identified cursor is not open.
+    //     SQLCODE : -501
+    //     The cursor specified in a FETCH or CLOSE statement is not open.
+    //     The statement cannot be processed.
+    // SQLSTATE : 58009
+    //     Execution failed due to a distribution protocol error that caused deallocation of the conversation.
+    //     SQLCODE : -30020
+    //     Execution failed because of a Distributed Protocol
+    //         Error that will affect the successful execution of subsequent
+    //         commands and SQL statements: Reason Code <reason-code>.
+    //     Some possible reason codes include:
+    //     121C Indicates that the user is not authorized to perform the requested command.
+    //     1232 The command could not be completed because of a permanent error.
+    //         In most cases, the server will be in the process of an abend.
+    //     220A The target server has received an invalid data description.
+    //         If a user SQLDA is specified, ensure that the fields are
+    //         initialized correctly. Also, ensure that the length does not exceed
+    //         the maximum allowed length for the data type being used.
+    //
+    //     The command or statement cannot be processed.  The current
+    //         transaction is rolled back and the application is disconnected
+    //         from the remote database.
+    //
+    // Returned from Server:
+    // SVRCOD - required  (4 - WARNING, 8 - ERROR)
+    // RDBNAM - required
+    // PKGNAMCSN - required
+    //
+    private void parseQRYNOPRM(ResultSetCallbackInterface resultSet) throws DisconnectException {
+        boolean svrcodReceived = false;
+        int svrcod = CodePoint.SVRCOD_INFO;
+        boolean rdbnamReceived = false;
+        String rdbnam = null;
+        boolean pkgnamcsnReceived = false;
+        Object pkgnamcsn = null;
+
+        parseLengthAndMatchCodePoint(CodePoint.QRYNOPRM);
+        pushLengthOnCollectionStack();
+        int peekCP = peekCodePoint();
+
+        while (peekCP != Reply.END_OF_COLLECTION) {
+
+            boolean foundInPass = false;
+
+            if (peekCP == CodePoint.SVRCOD) {
+                foundInPass = true;
+                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
+                svrcod = parseSVRCOD(CodePoint.SVRCOD_WARNING, CodePoint.SVRCOD_ERROR);
+                peekCP = peekCodePoint();
+            }
+
+            if (peekCP == CodePoint.RDBNAM) {
+                foundInPass = true;
+                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
+                rdbnam = parseRDBNAM(true);
+                peekCP = peekCodePoint();
+            }
+
+            if (peekCP == CodePoint.PKGNAMCSN) {
+                foundInPass = true;
+                pkgnamcsnReceived = checkAndGetReceivedFlag(pkgnamcsnReceived);
+                pkgnamcsn = parsePKGNAMCSN(true);
+                peekCP = peekCodePoint();
+            }
+
+            if (!foundInPass) {
+                doPrmnsprmSemantics(peekCP);
+            }
+
+        }
+        popCollectionStack();
+        checkRequiredObjects(svrcodReceived, rdbnamReceived, pkgnamcsnReceived);
+
+        // move into a method
+        netAgent_.setSvrcod(svrcod);
+        if (svrcod == CodePoint.SVRCOD_WARNING) {
+            netAgent_.accumulateReadException(new SqlException(netAgent_.logWriter_,
+                    "The identified cursor is not open.",
+                    SqlState._24501));
+        } else {
+            agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
+                    "Execution failed due to a distribution protocol error that " +
+                    "caused deallocation of the conversation.  " +
+                    "The identified cursor is not open.",
+                    SqlState._58009));
+        }
     }
-  }
 }
 

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java Sun May  1 23:25:59 2005
@@ -20,309 +20,300 @@
 
 package org.apache.derby.client.net;
 
+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.ResultSet;
-import org.apache.derby.client.am.ColumnMetaData;
 
 public class NetResultSetRequest extends NetStatementRequest
-                                implements ResultSetRequestInterface
-{
-  public NetResultSetRequest (NetAgent netAgent, CcsidManager ccsidManager, int bufferSize)
-  {
-    super (netAgent, ccsidManager, bufferSize);
-  }
-
-  //----------------------------- entry points ---------------------------------
-  public void writeFetch (NetResultSet resultSet,
-                          Section section,
-                          int fetchSize) throws SqlException
-  {
-    // - for forward-only cursors we do not send qryrowset on OPNQRY, fetchSize is ignored.
-    //   but qryrowset is sent on EXCSQLSTT for a stored procedure call.
-    boolean sendQryrowset =
-         ((NetStatement) resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_;
-
-    boolean sendRtnextdta = false;
-    if (sendQryrowset && resultSet.resultSetType_ == java.sql.ResultSet.TYPE_FORWARD_ONLY &&
-        ((NetCursor) resultSet.cursor_).hasLobs_) {
-      fetchSize = 1;
-      resultSet.fetchSize_ = 1;
-      sendRtnextdta = true;
-      ((NetCursor) resultSet.cursor_).rtnextrow_ = false;
-    }
-    // if one of the result sets returned from a stored procedure is scrollable,
-    // then we set netStatement_.qryrowsetSentOnOpnqry_ to true even though we didn't really
-    // send a qryrowset on excsqlstt for sqlam >= 7.  this is ok for scrollable cursors,
-    // but will cause a problem for forward-only cursors.  Because if fetchSize was never
-    // set, we will send qryrowset(0), which will cause a syntaxrm.
-    else if (resultSet.fetchSize_ == 0) {
-      sendQryrowset = false;
-    }
-
-    buildCNTQRY (section,
-                 sendQryrowset,
-                 resultSet.queryInstanceIdentifier_,
-                 fetchSize,
-                 sendRtnextdta);
-
-    buildOUTOVR (resultSet,
-                 resultSet.resultSetMetaData_,
-                 resultSet.firstOutovrBuilt_,
-                 ((NetCursor) resultSet.cursor_).hasLobs_);
-  }
-
-  public void writeScrollableFetch (NetResultSet resultSet,
-                                    Section section,
-                                    int fetchSize,
-                                    int orientation,
-                                    long rowToFetch,
-                                    boolean resetQueryBlocks) throws SqlException
-  {
-    int protocolOrientation = computePROTOCOLOrientation (orientation);
-
-    // - for sensitive-static cursors:
-    //     * qryrowset must be sent on opnqry to indicate to the server that the cursor is
-    //       going to be used in a scrollable fashion.  (sqlam<7)
-    //     * if qryrowset is sent on opnqry, then it must be sent on all subsequent cntqry's
-    // - for sensitive-dynamic non-rowset cursors: (we should never be in this case)
-    //     * qryrowset is NOT ALLOWED on cntqry's
-    // - for rowset cursors:
-    //     * qryrowset is optional.  it is ignored on opnqry.  if not sent on cntqry,
-    //       then the fetch is going fetch next row as opposed to fetch next rowset.
-    boolean sendQryrowset =
-        (resultSet.isRowsetCursor_ ||
-         (((NetStatement) resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_ &&
-          (resultSet.sensitivity_ == ResultSet.sensitivity_sensitive_static__ ||
-          ((NetCursor)resultSet.cursor_).blocking_)));
-
-    buildScrollCNTQRY (protocolOrientation,
-                       rowToFetch,
-                       section,
-                       sendQryrowset,
-                       resultSet.queryInstanceIdentifier_,
-                       fetchSize,
-                       resetQueryBlocks);
-
-    buildOUTOVR (resultSet,
-                 resultSet.resultSetMetaData_,
-                 resultSet.firstOutovrBuilt_,
-                 ((NetCursor) resultSet.cursor_).hasLobs_);
-  }
+        implements ResultSetRequestInterface {
+    public NetResultSetRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize) {
+        super(netAgent, ccsidManager, bufferSize);
+    }
+
+    //----------------------------- entry points ---------------------------------
+    public void writeFetch(NetResultSet resultSet,
+                           Section section,
+                           int fetchSize) throws SqlException {
+        // - for forward-only cursors we do not send qryrowset on OPNQRY, fetchSize is ignored.
+        //   but qryrowset is sent on EXCSQLSTT for a stored procedure call.
+        boolean sendQryrowset =
+                ((NetStatement) resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_;
+
+        boolean sendRtnextdta = false;
+        if (sendQryrowset && resultSet.resultSetType_ == java.sql.ResultSet.TYPE_FORWARD_ONLY &&
+                ((NetCursor) resultSet.cursor_).hasLobs_) {
+            fetchSize = 1;
+            resultSet.fetchSize_ = 1;
+            sendRtnextdta = true;
+            ((NetCursor) resultSet.cursor_).rtnextrow_ = false;
+        }
+        // if one of the result sets returned from a stored procedure is scrollable,
+        // then we set netStatement_.qryrowsetSentOnOpnqry_ to true even though we didn't really
+        // send a qryrowset on excsqlstt for sqlam >= 7.  this is ok for scrollable cursors,
+        // but will cause a problem for forward-only cursors.  Because if fetchSize was never
+        // set, we will send qryrowset(0), which will cause a syntaxrm.
+        else if (resultSet.fetchSize_ == 0) {
+            sendQryrowset = false;
+        }
+
+        buildCNTQRY(section,
+                sendQryrowset,
+                resultSet.queryInstanceIdentifier_,
+                fetchSize,
+                sendRtnextdta);
+
+        buildOUTOVR(resultSet,
+                resultSet.resultSetMetaData_,
+                resultSet.firstOutovrBuilt_,
+                ((NetCursor) resultSet.cursor_).hasLobs_);
+    }
 
-  public void writePositioningFetch (NetResultSet resultSet,
+    public void writeScrollableFetch(NetResultSet resultSet,
                                      Section section,
+                                     int fetchSize,
                                      int orientation,
-                                     long rowToFetch) throws SqlException
-  {
-    int protocolOrientation = computePROTOCOLOrientation (orientation);
-
-    // do not send qryrowste if the cursor is a non-rowset, sensitive dynamic cursor
-    boolean sendQryrowset =
-        resultSet.isRowsetCursor_ ||
-        (((NetStatement) resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_ &&
-         resultSet.sensitivity_ != resultSet.sensitivity_sensitive_dynamic__);
-
-    buildPositioningCNTQRY (protocolOrientation,
-                            rowToFetch,
-                            section,
-                            sendQryrowset,
-                            resultSet.queryInstanceIdentifier_,
-                            resultSet.fetchSize_);
-
-    buildOUTOVR (resultSet,
-                 resultSet.resultSetMetaData_,
-                 resultSet.firstOutovrBuilt_,
-                 ((NetCursor) resultSet.cursor_).hasLobs_);
-  }
-
-  public void writeCursorClose (NetResultSet resultSet,
-                                Section section) throws SqlException
-  {
-    buildCLSQRY (section,
-                 resultSet.queryInstanceIdentifier_);
-  }
-
-  //----------------------helper methods----------------------------------------
-  // These methods are "private protected", which is not a recognized java privilege,
-  // but means that these methods are private to this class and to subclasses,
-  // and should not be used as package-wide friendly methods.
-
-  private void buildCLSQRY (Section section,
-                            long queryInstanceIdentifier)
-			    throws SqlException
-  {
-    createCommand ();
-    markLengthBytes (CodePoint.CLSQRY);
-    buildPKGNAMCSN (section);
-    buildQRYINSID (queryInstanceIdentifier);
-    updateLengthBytes();
-  }
-
-  private void buildCNTQRY (Section section,
-                            boolean sendQryrowset,
-                            long queryInstanceIdentifier,
-                            int qryrowsetSize,
-                            boolean sendRtnextdta) throws SqlException
-  {
-    buildCoreCNTQRY (section,
-                     sendQryrowset,
-                     queryInstanceIdentifier,
-                     qryrowsetSize);
-
-    // We will always let RTNEXTDTA default to RTNEXTROW.  The only time we need to send
-    // RTNEXTDTA RTNEXTALL is for a stored procedure returned forward-only ResultSet
-    // that has LOB columns.  Since there are LOBs in the
-    // ResultSet, no QRYDTA is returned on execute.  On the CNTQRY's, we will
-    // send qryrowset(1) and rtnextall.
-    if (sendRtnextdta) buildRTNEXTDTA (CodePoint.RTNEXTALL);
-
-
-    updateLengthBytes();
-  }
-
-  // buildCoreCntqry builds the common parameters
-  private void buildCoreCNTQRY (Section section,
-                                boolean sendQryrowset,
-                                long queryInstanceIdentifier,
-                                int qryrowsetSize)
-				 throws SqlException
-  {
-    createCommand ();
-    markLengthBytes (CodePoint.CNTQRY);
-
-    buildPKGNAMCSN (section); // 1. packageNameAndConsistencyToken
-    buildQRYBLKSZ (); // 2. qryblksz
-
-    // maxblkext (-1) tells the server that the client is capable of receiving any number of query blocks
-    if (sendQryrowset)
-      buildMAXBLKEXT (-1); // 3. maxblkext
-
-    // 4. qryinsid
-	buildQRYINSID (queryInstanceIdentifier);
-
-    if (sendQryrowset) buildQRYROWSET (qryrowsetSize);  // 5. qryrowset
-  }
-
-  // Send CNTQRY to get a new rowset from the target server.
-  private void buildScrollCNTQRY (int scrollOrientation,
-                                  long rowNumber,
-                                  Section section,
-                                  boolean sendQryrowset,
-                                  long queryInstanceIdentifier,
-                                  int qryrowsetSize,
-				  boolean resetQueryBlocks)
-				    throws SqlException
-  {
-    buildCoreCNTQRY (section,
-                     sendQryrowset,
-                     queryInstanceIdentifier,
-                     qryrowsetSize);
-
-    buildQRYSCRORN (scrollOrientation); // qryscrorn
-
-    if (scrollOrientation == CodePoint.QRYSCRABS || scrollOrientation == CodePoint.QRYSCRREL)
-      buildQRYROWNBR (rowNumber);
-
-    if (resetQueryBlocks)
-      buildQRYBLKRST (0xF1);  // do reset the rowset
-    else
-      buildQRYBLKRST (0xF0);  // do not reset the rowset
-
-    buildQRYRTNDTA (0xF1);    // do return data
-
-    updateLengthBytes();
-  }
-
-  // Send CTNQRY to reposition the cursor on the target server.
-  private void buildPositioningCNTQRY (int scrollOrientation,
-                                       long rowNumber,
-                                       Section section,
-                                       boolean sendQryrowset,
-                                       long queryInstanceIdentifier,
-                                       int qryrowsetSize)
-                                        throws SqlException
-  {
-    createCommand ();
-    markLengthBytes (CodePoint.CNTQRY);
-
-    buildPKGNAMCSN (section); // 1. pkgnamcsn
-    buildQRYBLKSZ (); // 2. qryblksz
-
-    buildQRYINSID (queryInstanceIdentifier); // 3. qryinsid
-
-    if (sendQryrowset)
-      buildQRYROWSET (qryrowsetSize);   // 4. qryrowset
-
-    buildQRYSCRORN (scrollOrientation); // 5. qryscrorn
-
-    if (scrollOrientation == CodePoint.QRYSCRABS || scrollOrientation == CodePoint.QRYSCRREL)
-    buildQRYROWNBR (rowNumber); // 6. qryrownbr
-
-    buildQRYBLKRST (0xF1); // 7. do reset the rowset
-    buildQRYRTNDTA (0xF0); // 8. do not return data
-
-
-    updateLengthBytes(); // for cntqry
-  }
-
-  private void buildOUTOVR (ResultSet resultSet,
-                            ColumnMetaData resultSetMetaData,
-                            boolean firstOutovrBuilt,
-                            boolean hasLobs) throws SqlException
-  {
-    return;
-  }
-
-  private void buildRTNEXTDTA (int rtnextdta) throws SqlException
-  {
-    writeScalar1Byte (CodePoint.RTNEXTDTA, rtnextdta);
-  }
-
-  private void buildQRYSCRORN (int scrollOrientation) throws SqlException
-  {
-    writeScalar1Byte (CodePoint.QRYSCRORN, scrollOrientation);
-  }
-
-  private void buildQRYBLKRST (int qryblkrst) throws SqlException
-  {
-    writeScalar1Byte (CodePoint.QRYBLKRST, qryblkrst);
-  }
-
-  private void buildQRYROWNBR (long rowNumber) throws SqlException
-  {
-    writeScalar8Bytes (CodePoint.QRYROWNBR, rowNumber);
-  }
-
-  private void buildQRYRTNDTA (int qryrtndta) throws SqlException
-  {
-    writeScalar1Byte (CodePoint.QRYRTNDTA, qryrtndta);
-  }
-
-  //----------------------non-parsing computational helper methods--------------
-  // These methods are "private protected", which is not a recognized java privilege,
-  // but means that these methods are private to this class and to subclasses,
-  // and should not be used as package-wide friendly methods.
-
-  // Called by NetResultSetRequest.writeScrollableFetch()
-  private int computePROTOCOLOrientation (int orientation) throws SqlException
-  {
-    switch (orientation) {
-    case ResultSet.scrollOrientation_absolute__ :
-      return CodePoint.QRYSCRABS;
-
-    case ResultSet.scrollOrientation_after__ :
-      return CodePoint.QRYSCRAFT;
-
-    case ResultSet.scrollOrientation_before__ :
-      return CodePoint.QRYSCRBEF;
+                                     long rowToFetch,
+                                     boolean resetQueryBlocks) throws SqlException {
+        int protocolOrientation = computePROTOCOLOrientation(orientation);
+
+        // - for sensitive-static cursors:
+        //     * qryrowset must be sent on opnqry to indicate to the server that the cursor is
+        //       going to be used in a scrollable fashion.  (sqlam<7)
+        //     * if qryrowset is sent on opnqry, then it must be sent on all subsequent cntqry's
+        // - for sensitive-dynamic non-rowset cursors: (we should never be in this case)
+        //     * qryrowset is NOT ALLOWED on cntqry's
+        // - for rowset cursors:
+        //     * qryrowset is optional.  it is ignored on opnqry.  if not sent on cntqry,
+        //       then the fetch is going fetch next row as opposed to fetch next rowset.
+        boolean sendQryrowset =
+                (resultSet.isRowsetCursor_ ||
+                (((NetStatement) resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_ &&
+                (resultSet.sensitivity_ == ResultSet.sensitivity_sensitive_static__ ||
+                ((NetCursor) resultSet.cursor_).blocking_)));
+
+        buildScrollCNTQRY(protocolOrientation,
+                rowToFetch,
+                section,
+                sendQryrowset,
+                resultSet.queryInstanceIdentifier_,
+                fetchSize,
+                resetQueryBlocks);
+
+        buildOUTOVR(resultSet,
+                resultSet.resultSetMetaData_,
+                resultSet.firstOutovrBuilt_,
+                ((NetCursor) resultSet.cursor_).hasLobs_);
+    }
+
+    public void writePositioningFetch(NetResultSet resultSet,
+                                      Section section,
+                                      int orientation,
+                                      long rowToFetch) throws SqlException {
+        int protocolOrientation = computePROTOCOLOrientation(orientation);
+
+        // do not send qryrowste if the cursor is a non-rowset, sensitive dynamic cursor
+        boolean sendQryrowset =
+                resultSet.isRowsetCursor_ ||
+                (((NetStatement) resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_ &&
+                resultSet.sensitivity_ != resultSet.sensitivity_sensitive_dynamic__);
+
+        buildPositioningCNTQRY(protocolOrientation,
+                rowToFetch,
+                section,
+                sendQryrowset,
+                resultSet.queryInstanceIdentifier_,
+                resultSet.fetchSize_);
+
+        buildOUTOVR(resultSet,
+                resultSet.resultSetMetaData_,
+                resultSet.firstOutovrBuilt_,
+                ((NetCursor) resultSet.cursor_).hasLobs_);
+    }
+
+    public void writeCursorClose(NetResultSet resultSet,
+                                 Section section) throws SqlException {
+        buildCLSQRY(section,
+                resultSet.queryInstanceIdentifier_);
+    }
 
-    case ResultSet.scrollOrientation_relative__ :
-      return CodePoint.QRYSCRREL;
+    //----------------------helper methods----------------------------------------
+    // These methods are "private protected", which is not a recognized java privilege,
+    // but means that these methods are private to this class and to subclasses,
+    // and should not be used as package-wide friendly methods.
+
+    private void buildCLSQRY(Section section,
+                             long queryInstanceIdentifier)
+            throws SqlException {
+        createCommand();
+        markLengthBytes(CodePoint.CLSQRY);
+        buildPKGNAMCSN(section);
+        buildQRYINSID(queryInstanceIdentifier);
+        updateLengthBytes();
+    }
+
+    private void buildCNTQRY(Section section,
+                             boolean sendQryrowset,
+                             long queryInstanceIdentifier,
+                             int qryrowsetSize,
+                             boolean sendRtnextdta) throws SqlException {
+        buildCoreCNTQRY(section,
+                sendQryrowset,
+                queryInstanceIdentifier,
+                qryrowsetSize);
+
+        // We will always let RTNEXTDTA default to RTNEXTROW.  The only time we need to send
+        // RTNEXTDTA RTNEXTALL is for a stored procedure returned forward-only ResultSet
+        // that has LOB columns.  Since there are LOBs in the
+        // ResultSet, no QRYDTA is returned on execute.  On the CNTQRY's, we will
+        // send qryrowset(1) and rtnextall.
+        if (sendRtnextdta) {
+            buildRTNEXTDTA(CodePoint.RTNEXTALL);
+        }
+
+
+        updateLengthBytes();
+    }
+
+    // buildCoreCntqry builds the common parameters
+    private void buildCoreCNTQRY(Section section,
+                                 boolean sendQryrowset,
+                                 long queryInstanceIdentifier,
+                                 int qryrowsetSize)
+            throws SqlException {
+        createCommand();
+        markLengthBytes(CodePoint.CNTQRY);
+
+        buildPKGNAMCSN(section); // 1. packageNameAndConsistencyToken
+        buildQRYBLKSZ(); // 2. qryblksz
+
+        // maxblkext (-1) tells the server that the client is capable of receiving any number of query blocks
+        if (sendQryrowset) {
+            buildMAXBLKEXT(-1); // 3. maxblkext
+        }
+
+        // 4. qryinsid
+        buildQRYINSID(queryInstanceIdentifier);
+
+        if (sendQryrowset) {
+            buildQRYROWSET(qryrowsetSize);  // 5. qryrowset
+        }
+    }
+
+    // Send CNTQRY to get a new rowset from the target server.
+    private void buildScrollCNTQRY(int scrollOrientation,
+                                   long rowNumber,
+                                   Section section,
+                                   boolean sendQryrowset,
+                                   long queryInstanceIdentifier,
+                                   int qryrowsetSize,
+                                   boolean resetQueryBlocks)
+            throws SqlException {
+        buildCoreCNTQRY(section,
+                sendQryrowset,
+                queryInstanceIdentifier,
+                qryrowsetSize);
+
+        buildQRYSCRORN(scrollOrientation); // qryscrorn
+
+        if (scrollOrientation == CodePoint.QRYSCRABS || scrollOrientation == CodePoint.QRYSCRREL) {
+            buildQRYROWNBR(rowNumber);
+        }
+
+        if (resetQueryBlocks) {
+            buildQRYBLKRST(0xF1);  // do reset the rowset
+        } else {
+            buildQRYBLKRST(0xF0);  // do not reset the rowset
+        }
+
+        buildQRYRTNDTA(0xF1);    // do return data
+
+        updateLengthBytes();
+    }
+
+    // Send CTNQRY to reposition the cursor on the target server.
+    private void buildPositioningCNTQRY(int scrollOrientation,
+                                        long rowNumber,
+                                        Section section,
+                                        boolean sendQryrowset,
+                                        long queryInstanceIdentifier,
+                                        int qryrowsetSize)
+            throws SqlException {
+        createCommand();
+        markLengthBytes(CodePoint.CNTQRY);
+
+        buildPKGNAMCSN(section); // 1. pkgnamcsn
+        buildQRYBLKSZ(); // 2. qryblksz
+
+        buildQRYINSID(queryInstanceIdentifier); // 3. qryinsid
+
+        if (sendQryrowset) {
+            buildQRYROWSET(qryrowsetSize);   // 4. qryrowset
+        }
+
+        buildQRYSCRORN(scrollOrientation); // 5. qryscrorn
+
+        if (scrollOrientation == CodePoint.QRYSCRABS || scrollOrientation == CodePoint.QRYSCRREL) {
+            buildQRYROWNBR(rowNumber); // 6. qryrownbr
+        }
+
+        buildQRYBLKRST(0xF1); // 7. do reset the rowset
+        buildQRYRTNDTA(0xF0); // 8. do not return data
+
+
+        updateLengthBytes(); // for cntqry
+    }
+
+    private void buildOUTOVR(ResultSet resultSet,
+                             ColumnMetaData resultSetMetaData,
+                             boolean firstOutovrBuilt,
+                             boolean hasLobs) throws SqlException {
+        return;
+    }
+
+    private void buildRTNEXTDTA(int rtnextdta) throws SqlException {
+        writeScalar1Byte(CodePoint.RTNEXTDTA, rtnextdta);
+    }
+
+    private void buildQRYSCRORN(int scrollOrientation) throws SqlException {
+        writeScalar1Byte(CodePoint.QRYSCRORN, scrollOrientation);
+    }
+
+    private void buildQRYBLKRST(int qryblkrst) throws SqlException {
+        writeScalar1Byte(CodePoint.QRYBLKRST, qryblkrst);
+    }
+
+    private void buildQRYROWNBR(long rowNumber) throws SqlException {
+        writeScalar8Bytes(CodePoint.QRYROWNBR, rowNumber);
+    }
+
+    private void buildQRYRTNDTA(int qryrtndta) throws SqlException {
+        writeScalar1Byte(CodePoint.QRYRTNDTA, qryrtndta);
+    }
 
-    default:
-      throw new SqlException (netAgent_.logWriter_, "Bug check: invalid scroll orientation");
+    //----------------------non-parsing computational helper methods--------------
+    // These methods are "private protected", which is not a recognized java privilege,
+    // but means that these methods are private to this class and to subclasses,
+    // and should not be used as package-wide friendly methods.
+
+    // Called by NetResultSetRequest.writeScrollableFetch()
+    private int computePROTOCOLOrientation(int orientation) throws SqlException {
+        switch (orientation) {
+        case ResultSet.scrollOrientation_absolute__:
+            return CodePoint.QRYSCRABS;
+
+        case ResultSet.scrollOrientation_after__:
+            return CodePoint.QRYSCRAFT;
+
+        case ResultSet.scrollOrientation_before__:
+            return CodePoint.QRYSCRBEF;
+
+        case ResultSet.scrollOrientation_relative__:
+            return CodePoint.QRYSCRREL;
+
+        default:
+            throw new SqlException(netAgent_.logWriter_, "Bug check: invalid scroll orientation");
+        }
     }
-  }
 
 }

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java Sun May  1 23:25:59 2005
@@ -22,45 +22,39 @@
 
 import org.apache.derby.client.am.Sqlca;
 
-public class NetSqlca extends Sqlca
-{
-  // these are the same variables that are in the Sqlca except ccsids
-  // are a little different
+public class NetSqlca extends Sqlca {
+    // these are the same variables that are in the Sqlca except ccsids
+    // are a little different
 
-  NetSqlca (org.apache.derby.client.am.Connection connection,
-         int sqlCode,
-         byte[] sqlStateBytes,
-         byte[] sqlErrpBytes,
-         int ccsid)
-  {
-    super(connection);
-    sqlCode_ = sqlCode;
-    sqlStateBytes_ = sqlStateBytes;
-    sqlErrpBytes_ = sqlErrpBytes;
-    ccsid_ = ccsid;
-  }
+    NetSqlca(org.apache.derby.client.am.Connection connection,
+             int sqlCode,
+             byte[] sqlStateBytes,
+             byte[] sqlErrpBytes,
+             int ccsid) {
+        super(connection);
+        sqlCode_ = sqlCode;
+        sqlStateBytes_ = sqlStateBytes;
+        sqlErrpBytes_ = sqlErrpBytes;
+        ccsid_ = ccsid;
+    }
 
-  protected void setSqlerrd (int[] sqlErrd)
-  {
-    sqlErrd_ = sqlErrd;
-  }
+    protected void setSqlerrd(int[] sqlErrd) {
+        sqlErrd_ = sqlErrd;
+    }
 
-  protected void setSqlwarnBytes (byte[] sqlWarnBytes)
-  {
-    sqlWarnBytes_ = sqlWarnBytes;
-  }
+    protected void setSqlwarnBytes(byte[] sqlWarnBytes) {
+        sqlWarnBytes_ = sqlWarnBytes;
+    }
 
-  protected void setSqlerrmcBytes (byte[] sqlErrmcBytes, int sqlErrmcCcsid)
-  {
-    sqlErrmcBytes_ = sqlErrmcBytes;
-    sqlErrmcCcsid_ = sqlErrmcCcsid;
-  }
+    protected void setSqlerrmcBytes(byte[] sqlErrmcBytes, int sqlErrmcCcsid) {
+        sqlErrmcBytes_ = sqlErrmcBytes;
+        sqlErrmcCcsid_ = sqlErrmcCcsid;
+    }
 
-  public long getRowCount (Typdef typdef) throws org.apache.derby.client.am.DisconnectException
-  {
-    int byteOrder = typdef.getByteOrder();
-    long num = (byteOrder == org.apache.derby.client.am.SignedBinary.BIG_ENDIAN) ?
-      super.getRowCount() : ((long)sqlErrd_[1]<<32) + sqlErrd_[0];
-    return num;
-  }
+    public long getRowCount(Typdef typdef) throws org.apache.derby.client.am.DisconnectException {
+        int byteOrder = typdef.getByteOrder();
+        long num = (byteOrder == org.apache.derby.client.am.SignedBinary.BIG_ENDIAN) ?
+                super.getRowCount() : ((long) sqlErrd_[1] << 32) + sqlErrd_[0];
+        return num;
+    }
 }

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java Sun May  1 23:25:59 2005
@@ -21,138 +21,136 @@
 package org.apache.derby.client.net;
 
 
+public class NetSqldta extends NetCursor {
+    private NetConnection netConnection_;
 
-public class NetSqldta extends NetCursor
-{
-  private NetConnection netConnection_;
-
-
-  public NetSqldta (NetAgent netAgent)
-  {
-    super (netAgent);
-    netConnection_ = netAgent.netConnection_;
-  }
-
-  public boolean next () throws org.apache.derby.client.am.SqlException
-  {
-    if (allRowsReceivedFromServer_)
-      return false;
-    else {
-      allRowsReceivedFromServer_ = true;
-      return true;
-    }
-  }
-
-  protected boolean calculateColumnOffsetsForRow ()
-  {
-    int colNullIndicator = CodePoint.NULLDATA;
-    int length ;
-
-    extdtaPositions_.clear();  // reset positions for this row
-
-    // read the da null indicator
-    if (readFdocaOneByte() == 0xff)
-      return false;
-
-    incrementRowsReadEvent();
-    // Use the arrays defined on the Cursor for forward-only cursors.
-    // can they ever be null
-    if (columnDataPosition_ == null || columnDataComputedLength_ == null || isNull_ == null)
-      allocateColumnOffsetAndLengthArrays ();
-
-    // Loop through the columns
-    for (int index = 0; index < columns_; index++) {
-      // If column is nullable, read the 1-byte null indicator.
-      if (nullable_[index])
-        // Need to pass the column index so all previously calculated offsets can be
-        // readjusted if the query block splits on a column null indicator.
-
-        // null indicators from FD:OCA data
-        // 0 to 127: a data value will flow.
-        // -1 to -128: no data value will flow.
-        colNullIndicator = readFdocaOneByte ();
-
-      // If non-null column data
-      if (!nullable_[index] || (colNullIndicator >= 0 && colNullIndicator <= 127)) {
-        isNull_[index] = false;
-
-        switch (typeToUseForComputingDataLength_[index]) {
-        // for variable character string and variable byte string,
-        // there are 2-byte of length in front of the data
-        case Typdef.TWOBYTELENGTH:
-          columnDataPosition_[index] = position_;
-          length = readFdocaTwoByteLength ();
-          // skip length + the 2-byte length field
-          if (isGraphic_[index])
-            columnDataComputedLength_[index] = skipFdocaBytes (length*2) + 2;
-          else
-            columnDataComputedLength_[index] = skipFdocaBytes (length) + 2;
-          break;
-
-          // for short variable character string and short variable byte string,
-          // there is a 1-byte length in front of the data
-        case Typdef.ONEBYTELENGTH:
-          columnDataPosition_[index] = position_;
-          length = readFdocaOneByte ();
-          // skip length + the 1-byte length field
-          if (isGraphic_[index])
-            columnDataComputedLength_[index] = skipFdocaBytes (length*2) + 1;
-          else
-            columnDataComputedLength_[index] = skipFdocaBytes (length) + 1;
-          break;
-
-        // For decimal columns, determine the precision, scale, and the representation
-        case Typdef.DECIMALLENGTH:
-          columnDataPosition_[index] = position_;
-          columnDataComputedLength_[index] = skipFdocaBytes (getDecimalLength(index));
-          break;
-
-        case Typdef.LOBLENGTH:
-          columnDataPosition_[index] = position_;
-          columnDataComputedLength_[index] = this.skipFdocaBytes (fdocaLength_[index] & 0x7fff);
-          break;
-
-        default:
-          columnDataPosition_[index] = position_;
-          if (isGraphic_[index])
-            columnDataComputedLength_[index] = skipFdocaBytes (fdocaLength_[index]*2);
-          else
-            columnDataComputedLength_[index] = skipFdocaBytes (fdocaLength_[index]);
-          break;
+
+    public NetSqldta(NetAgent netAgent) {
+        super(netAgent);
+        netConnection_ = netAgent.netConnection_;
+    }
+
+    public boolean next() throws org.apache.derby.client.am.SqlException {
+        if (allRowsReceivedFromServer_) {
+            return false;
+        } else {
+            allRowsReceivedFromServer_ = true;
+            return true;
         }
-      }
-      else if ((colNullIndicator & 0x80) == 0x80) {
-        // Null data. Set the isNull indicator to true.
-        isNull_[index] = true;
-      }
     }
 
-    if (!allRowsReceivedFromServer_)
-      calculateLobColumnPositionsForRow();
+    protected boolean calculateColumnOffsetsForRow() {
+        int colNullIndicator = CodePoint.NULLDATA;
+        int length;
+
+        extdtaPositions_.clear();  // reset positions for this row
+
+        // read the da null indicator
+        if (readFdocaOneByte() == 0xff) {
+            return false;
+        }
 
-    return true; // hardwired for now, this means the current row position is a valid position
-  }
+        incrementRowsReadEvent();
+        // Use the arrays defined on the Cursor for forward-only cursors.
+        // can they ever be null
+        if (columnDataPosition_ == null || columnDataComputedLength_ == null || isNull_ == null) {
+            allocateColumnOffsetAndLengthArrays();
+        }
 
+        // Loop through the columns
+        for (int index = 0; index < columns_; index++) {
+            // If column is nullable, read the 1-byte null indicator.
+            if (nullable_[index])
+            // Need to pass the column index so all previously calculated offsets can be
+            // readjusted if the query block splits on a column null indicator.
+
+            // null indicators from FD:OCA data
+            // 0 to 127: a data value will flow.
+            // -1 to -128: no data value will flow.
+            {
+                colNullIndicator = readFdocaOneByte();
+            }
+
+            // If non-null column data
+            if (!nullable_[index] || (colNullIndicator >= 0 && colNullIndicator <= 127)) {
+                isNull_[index] = false;
+
+                switch (typeToUseForComputingDataLength_[index]) {
+                // for variable character string and variable byte string,
+                // there are 2-byte of length in front of the data
+                case Typdef.TWOBYTELENGTH:
+                    columnDataPosition_[index] = position_;
+                    length = readFdocaTwoByteLength();
+                    // skip length + the 2-byte length field
+                    if (isGraphic_[index]) {
+                        columnDataComputedLength_[index] = skipFdocaBytes(length * 2) + 2;
+                    } else {
+                        columnDataComputedLength_[index] = skipFdocaBytes(length) + 2;
+                    }
+                    break;
+
+                    // for short variable character string and short variable byte string,
+                    // there is a 1-byte length in front of the data
+                case Typdef.ONEBYTELENGTH:
+                    columnDataPosition_[index] = position_;
+                    length = readFdocaOneByte();
+                    // skip length + the 1-byte length field
+                    if (isGraphic_[index]) {
+                        columnDataComputedLength_[index] = skipFdocaBytes(length * 2) + 1;
+                    } else {
+                        columnDataComputedLength_[index] = skipFdocaBytes(length) + 1;
+                    }
+                    break;
+
+                    // For decimal columns, determine the precision, scale, and the representation
+                case Typdef.DECIMALLENGTH:
+                    columnDataPosition_[index] = position_;
+                    columnDataComputedLength_[index] = skipFdocaBytes(getDecimalLength(index));
+                    break;
+
+                case Typdef.LOBLENGTH:
+                    columnDataPosition_[index] = position_;
+                    columnDataComputedLength_[index] = this.skipFdocaBytes(fdocaLength_[index] & 0x7fff);
+                    break;
+
+                default:
+                    columnDataPosition_[index] = position_;
+                    if (isGraphic_[index]) {
+                        columnDataComputedLength_[index] = skipFdocaBytes(fdocaLength_[index] * 2);
+                    } else {
+                        columnDataComputedLength_[index] = skipFdocaBytes(fdocaLength_[index]);
+                    }
+                    break;
+                }
+            } else if ((colNullIndicator & 0x80) == 0x80) {
+                // Null data. Set the isNull indicator to true.
+                isNull_[index] = true;
+            }
+        }
 
+        if (!allRowsReceivedFromServer_) {
+            calculateLobColumnPositionsForRow();
+        }
 
-  private int skipFdocaBytes (int length)
-  {
-    position_ += length;
-    return length;
-  }
+        return true; // hardwired for now, this means the current row position is a valid position
+    }
+
+
+    private int skipFdocaBytes(int length) {
+        position_ += length;
+        return length;
+    }
 
-  private int readFdocaOneByte ()
-  {
-    return dataBuffer_[position_++] & 0xff;
-  }
+    private int readFdocaOneByte() {
+        return dataBuffer_[position_++] & 0xff;
+    }
 
 
-  private int readFdocaTwoByteLength ()
-  {
-    return
-      ((dataBuffer_[position_++] & 0xff) << 8) +
-      ((dataBuffer_[position_++] & 0xff) << 0);
-  }
+    private int readFdocaTwoByteLength() {
+        return
+                ((dataBuffer_[position_++] & 0xff) << 8) +
+                ((dataBuffer_[position_++] & 0xff) << 0);
+    }
 
 
 }



Mime
View raw message