1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <ndb_global.h>
17
#include "NDBT_ResultRow.hpp"
19
#include <NdbSchemaCon.hpp>
21
NDBT_ResultRow::NDBT_ResultRow(const NdbDictionary::Table& tab,
22
char attrib_delimiter)
25
assert(tab.getObjectStatus() == NdbDictionary::Object::Retrieved);
27
cols = tab.getNoOfColumns();
28
names = new char * [cols];
29
data = new NdbRecAttr * [cols];
31
for(int i = 0; i<cols; i++){
32
names[i] = new char[255];
33
strcpy(names[i], tab.getColumn(i)->getName());
36
ad[0] = attrib_delimiter;
41
NDBT_ResultRow::~NDBT_ResultRow(){
42
for(int i = 0; i<cols; i++){
48
for(int i = 0; i<cols; i++)
55
NDBT_ResultRow::attributeStore(int i){
61
NDBT_ResultRow::attributeStore(int i) const {
67
NDBT_ResultRow::attributeStore(const char* name) const {
68
for(int i = 0; i<cols; i++){
69
if (strcmp(names[i], name) == 0)
77
NDBT_ResultRow::header (NdbOut & out) const {
78
for(int i = 0; i<cols; i++){
86
BaseString NDBT_ResultRow::c_str() const {
91
for(int i = 0; i<cols; i++){
92
if(data[i]->isNULL()){
96
Uint32* p = (Uint32*)data[i]->aRef();
97
Uint32 sizeInBytes = data[i]->get_size_in_bytes();
98
for (Uint32 j = 0; j < sizeInBytes; j+=(sizeof(Uint32))){
100
if (j + 4 < sizeInBytes)
102
sprintf(buf, "%.8x", *p);
107
memcpy(&tmp, p, sizeInBytes - j);
108
sprintf(buf, "%.8x", tmp);
112
if ((j + sizeof(Uint32)) < sizeInBytes)
120
//ndbout << "NDBT_ResultRow::c_str() = " << str.c_str() << endl;
126
operator << (NdbOut& ndbout, const NDBT_ResultRow & res)
130
ndbout << *(res.data[0]);
131
for(int i = 1; i<res.cols; i++)
132
ndbout << res.ad << *(res.data[i]);
138
NDBT_ResultRow::clone () const {
140
NDBT_ResultRow * row = new NDBT_ResultRow(m_table, ad[0]);
141
row->m_ownData = true;
142
Uint32 noOfColumns = m_table.getNoOfColumns();
143
for(Uint32 i = 0; i < noOfColumns; i++){
144
row->data[i] = data[i]->clone();
151
NDBT_ResultRow::operator==(const NDBT_ResultRow& other) const
154
return c_str() == other.c_str();