NdbResultSet.cpp 2.64 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/*****************************************************************************
 * Name:          NdbResultSet.cpp
 * Include:
 * Link:
 * Author:        UABMASD Martin Skld INN/V Alzato
 * Date:          2002-04-01
 * Version:       0.1
 * Description:   Cursor class
 * Documentation:
 * Adjust:  2002-04-01  UABMASD   First version.
 ****************************************************************************/

#include <Ndb.hpp>
#include <NdbConnection.hpp>
#include <NdbResultSet.hpp>
unknown's avatar
unknown committed
32
#include <NdbBlob.hpp>
33

unknown's avatar
unknown committed
34
NdbResultSet::NdbResultSet(NdbScanOperation *owner)
35 36 37 38 39 40 41 42 43 44 45 46 47 48
: m_operation(owner)
{
}
 
NdbResultSet::~NdbResultSet()
{
}

void  NdbResultSet::init()
{
}

int NdbResultSet::nextResult(bool fetchAllowed)
{
unknown's avatar
unknown committed
49 50 51 52 53 54 55 56 57
  int res;
  if ((res = m_operation->nextResult(fetchAllowed)) == 0) {
    // handle blobs
    NdbBlob* tBlob = m_operation->theBlobList;
    while (tBlob != 0) {
      if (tBlob->atNextResult() == -1)
        return -1;
      tBlob = tBlob->theNext;
    }
unknown's avatar
unknown committed
58 59 60 61 62 63 64
    /*
     * Flush blob part ops on behalf of user because
     * - nextResult is analogous to execute(NoCommit)
     * - user is likely to want blob value before next execute
     */
    if (m_operation->m_transConnection->executePendingBlobOps() == -1)
      return -1;
unknown's avatar
unknown committed
65 66 67
    return 0;
  }
  return res;
68 69 70 71 72 73 74 75 76
}

void NdbResultSet::close()
{
  m_operation->closeScan();
}

NdbOperation* 
NdbResultSet::updateTuple(){
unknown's avatar
unknown committed
77
  return updateTuple(m_operation->m_transConnection);
78 79 80 81
}

NdbOperation* 
NdbResultSet::updateTuple(NdbConnection* takeOverTrans){
82 83
  return m_operation->takeOverScanOp(NdbOperation::UpdateRequest, 
				     takeOverTrans);
84 85 86 87
}

int
NdbResultSet::deleteTuple(){
unknown's avatar
unknown committed
88
  return deleteTuple(m_operation->m_transConnection);
89 90 91 92
}

int
NdbResultSet::deleteTuple(NdbConnection * takeOverTrans){
93 94
  void * res = m_operation->takeOverScanOp(NdbOperation::DeleteRequest, 
					   takeOverTrans);
95 96 97 98
  if(res == 0)
    return -1;
  return 0;
}
unknown's avatar
unknown committed
99 100 101 102 103

int
NdbResultSet::restart(){
  return m_operation->restart();
}