2
Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
4
The MySQL Connector/C++ is licensed under the terms of the GPLv2
5
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
6
MySQL Connectors. There are special exceptions to the terms and
7
conditions of the GPLv2 as it is applied to this software, see the
8
FLOSS License Exception
9
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
11
This program is free software; you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published
13
by the Free Software Foundation; version 2 of the License.
15
This program is distributed in the hope that it will be useful, but
16
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20
You should have received a copy of the GNU General Public License along
21
with this program; if not, write to the Free Software Foundation, Inc.,
22
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
#include <boost/scoped_array.hpp>
33
#include <cppconn/exception.h>
34
#include <cppconn/resultset.h>
35
#include <cppconn/warning.h>
36
#include "mysql_util.h"
37
#include "mysql_resultset.h"
38
#include "mysql_resultset_metadata.h"
39
#include "mysql_statement.h"
41
#include "nativeapi/native_resultset_wrapper.h"
43
#include "mysql_debug.h"
52
/* {{{ MySQL_ResultSet::MySQL_ResultSet() -I- */
53
MySQL_ResultSet::MySQL_ResultSet(boost::shared_ptr< NativeAPI::NativeResultsetWrapper > res, sql::ResultSet::enum_type rset_type,
54
MySQL_Statement * par, boost::shared_ptr< MySQL_DebugLogger > & l
56
: row(NULL), result(res), row_position(0), was_null(false), parent(par),
57
logger(l), resultset_type(rset_type)
59
CPP_ENTER("MySQL_ResultSet::MySQL_ResultSet");
60
num_rows = result->num_rows();
62
num_fields = result->num_fields();
63
for (unsigned int i = 0; i < num_fields; ++i) {
65
std::cout << "Elements=" << field_name_to_index_map.size() << "\n";
67
boost::scoped_array< char > upstring(sql::mysql::util::utf8_strup(getFieldMeta(i + 1)->name, 0));
68
field_name_to_index_map[upstring.get()] = i;
71
std::cout << "Elements=" << field_name_to_index_map.size() << "\n";
73
rs_meta.reset(new MySQL_ResultSetMetaData(result, logger));
78
/* {{{ MySQL_ResultSet::~MySQL_ResultSet() -I- */
79
MySQL_ResultSet::~MySQL_ResultSet()
81
CPP_ENTER("MySQL_ResultSet::~MySQL_ResultSet");
86
/* {{{ MySQL_ResultSet::absolute() -I- */
88
MySQL_ResultSet::absolute(const int new_pos)
90
CPP_ENTER("MySQL_ResultSet::absolute");
94
if (new_pos > (int) num_rows) {
95
row_position = num_rows + 1; /* after last row */
97
row_position = (my_ulonglong) new_pos; /* the cast is inspected and is valid */
101
} else if (new_pos < 0) {
102
if ((-new_pos) > (int) num_rows) {
103
row_position = 0; /* before first new_pos */
105
row_position = num_rows - (-new_pos) + 1;
110
/* According to the JDBC book, absolute(0) means before the result set */
112
/* no seek() here, as we are not on data*/
113
result->data_seek(0);
115
return (row_position > 0 && row_position < (num_rows + 1));
120
/* {{{ MySQL_ResultSet::afterLast() -I- */
122
MySQL_ResultSet::afterLast()
124
CPP_ENTER("MySQL_ResultSet::afterLast");
126
row_position = num_rows + 1;
131
/* {{{ MySQL_ResultSet::beforeFirst() -I- */
133
MySQL_ResultSet::beforeFirst()
135
CPP_ENTER("MySQL_ResultSet::beforeFirst");
138
result->data_seek(0);
144
/* {{{ MySQL_ResultSet::cancelRowUpdates() -U- */
146
MySQL_ResultSet::cancelRowUpdates()
148
CPP_ENTER("MySQL_ResultSet::cancelRowUpdates");
150
throw sql::MethodNotImplementedException("MySQL_ResultSet::cancelRowUpdates()");
155
/* {{{ MySQL_ResultSet::checkScrollable() -I- */
157
MySQL_ResultSet::checkScrollable() const
159
CPP_ENTER("MySQL_ResultSet::checkScrollable");
160
CPP_INFO_FMT("this=%p", this);
161
if (resultset_type == sql::ResultSet::TYPE_FORWARD_ONLY) {
162
throw sql::NonScrollableException("Nonscrollable result set");
168
/* {{{ MySQL_ResultSet::isScrollable() -I- */
170
MySQL_ResultSet::isScrollable() const
172
// CPP_ENTER("MySQL_ResultSet::isScrollable");
173
// CPP_INFO_FMT("this=%p", this);
174
return (resultset_type != sql::ResultSet::TYPE_FORWARD_ONLY);
179
/* {{{ MySQL_ResultSet::checkValid() -I- */
181
MySQL_ResultSet::checkValid() const
183
CPP_ENTER("MySQL_ResultSet::checkValid");
184
CPP_INFO_FMT("this=%p", this);
186
throw sql::InvalidInstanceException("ResultSet has been closed");
192
/* {{{ MySQL_ResultSet::clearWarnings() -U- */
194
MySQL_ResultSet::clearWarnings()
196
CPP_ENTER("MySQL_ResultSet::clearWarnings");
198
throw sql::MethodNotImplementedException("MySQL_ResultSet::clearWarnings()");
203
/* {{{ MySQL_ResultSet::close() -I- */
205
MySQL_ResultSet::close()
207
CPP_ENTER("MySQL_ResultSet::close");
210
// result->dispose();
215
/* {{{ MySQL_ResultSet::findColumn() -I- */
217
MySQL_ResultSet::findColumn(const sql::SQLString& columnLabel) const
219
CPP_ENTER("MySQL_ResultSet::findColumn");
221
boost::scoped_array< char > upstring(sql::mysql::util::utf8_strup(columnLabel.c_str(), 0));
223
std::cout << "Elements=" << field_name_to_index_map.size() << "\n";
224
FieldNameIndexMap::const_iterator tmp_iter = field_name_to_index_map.begin();
225
FieldNameIndexMap::const_iterator tmp_iter_end = field_name_to_index_map.end();
226
for (;tmp_iter != tmp_iter_end; tmp_iter++) {
227
std::cout << "[[" << tmp_iter->first << "]] second=[[" << tmp_iter->second << "]]\n";
229
sql::SQLString tmp(upstring.get());
230
std::cout << "[" << tmp << "]\n";
233
FieldNameIndexMap::const_iterator iter = field_name_to_index_map.find(sql::SQLString(upstring.get()));
234
if (iter == field_name_to_index_map.end()) {
237
/* findColumn returns 1-based indexes */
238
return iter->second + 1;
243
/* {{{ MySQL_ResultSet::first() -I- */
245
MySQL_ResultSet::first()
247
CPP_ENTER("MySQL_ResultSet::first");
254
return num_rows != 0;
259
/* {{{ MySQL_ResultSet::getBlob() -I- */
261
MySQL_ResultSet::getBlob(const uint32_t columnIndex) const
263
CPP_ENTER("MySQL_ResultSet::getBlob(int)");
264
/* isBeforeFirst checks for validity */
265
if (isBeforeFirstOrAfterLast()) {
266
throw sql::InvalidArgumentException("MySQL_ResultSet::getBoolean: can't fetch because not on result set");
268
return new std::istringstream(getString(columnIndex));
273
/* {{{ MySQL_ResultSet::getBlob() -I- */
275
MySQL_ResultSet::getBlob(const sql::SQLString& columnLabel) const
277
CPP_ENTER("MySQL_ResultSet::getBlob(string)");
278
/* isBeforeFirst checks for validity */
279
if (isBeforeFirstOrAfterLast()) {
280
throw sql::InvalidArgumentException("MySQL_ResultSet::getBoolean: can't fetch because not on result set");
282
return new std::istringstream(getString(columnLabel));
287
/* {{{ MySQL_ResultSet::getBoolean() -I- */
289
MySQL_ResultSet::getBoolean(const uint32_t columnIndex) const
291
CPP_ENTER("MySQL_ResultSet::getBoolean(int)");
292
/* isBeforeFirst checks for validity */
293
if (isBeforeFirstOrAfterLast()) {
294
throw sql::InvalidArgumentException("MySQL_ResultSet::getBoolean: can't fetch because not on result set");
296
return getInt(columnIndex)? true:false;
301
/* {{{ MySQL_ResultSet::getBoolean() -I- */
303
MySQL_ResultSet::getBoolean(const sql::SQLString& columnLabel) const
305
CPP_ENTER("MySQL_ResultSet::getBoolean(string)");
306
/* isBeforeFirst checks for validity */
307
if (isBeforeFirstOrAfterLast()) {
308
throw sql::InvalidArgumentException("MySQL_ResultSet::getBoolean: can't fetch because not on result set");
310
return getInt(columnLabel)? true:false;
315
/* {{{ MySQL_ResultSet::getConcurrency() -U- */
317
MySQL_ResultSet::getConcurrency()
319
CPP_ENTER("MySQL_ResultSet::getConcurrency");
321
throw sql::MethodNotImplementedException("MySQL_ResultSet::getConcurrency()");
322
return 0; // fool compilers
327
/* {{{ MySQL_ResultSet::getCursorName() -U- */
329
MySQL_ResultSet::getCursorName()
331
CPP_ENTER("MySQL_ResultSet::getCursorName");
333
throw sql::MethodNotImplementedException("MySQL_ResultSet::getCursorName()");
334
return ""; // fool compilers
339
/* {{{ MySQL_ResultSet::getDouble() -I- */
341
MySQL_ResultSet::getDouble(const uint32_t columnIndex) const
343
CPP_ENTER("MySQL_ResultSet::getDouble(int)");
345
/* isBeforeFirst checks for validity */
346
if (isBeforeFirstOrAfterLast()) {
347
throw sql::InvalidArgumentException("MySQL_ResultSet::getDouble: can't fetch because not on result set");
350
if (columnIndex == 0 || columnIndex > num_fields) {
351
throw sql::InvalidArgumentException("MySQL_ResultSet::getDouble: invalid value of 'columnIndex'");
353
if (row[columnIndex - 1] == NULL) {
358
if (getFieldMeta(columnIndex)->type == MYSQL_TYPE_BIT) {
359
return getInt64(columnIndex);
361
return sql::mysql::util::strtold(row[columnIndex - 1], NULL);
366
/* {{{ MySQL_ResultSet::getDouble() -I- */
368
MySQL_ResultSet::getDouble(const sql::SQLString& columnLabel) const
370
CPP_ENTER("MySQL_ResultSet::getDouble(string)");
371
return getDouble(findColumn(columnLabel));
376
/* {{{ MySQL_ResultSet::getFetchDirection() -U- */
378
MySQL_ResultSet::getFetchDirection()
380
CPP_ENTER("MySQL_ResultSet::getFetchDirection");
382
throw sql::MethodNotImplementedException("MySQL_ResultSet::getFetchDirection()");
383
return 0; // fool compilers
388
/* {{{ MySQL_ResultSet::getFetchSize() -U- */
390
MySQL_ResultSet::getFetchSize()
392
CPP_ENTER("MySQL_ResultSet::getFetchSize");
394
throw sql::MethodNotImplementedException("MySQL_ResultSet::getFetchSize()");
395
return 0; // fool compilers
400
/* {{{ MySQL_ResultSet::getFieldMeta() -U- */
401
MYSQL_FIELD * MySQL_ResultSet::getFieldMeta(unsigned int columnIndex) const
403
return result->fetch_field_direct(columnIndex - 1);
408
/* {{{ MySQL_ResultSet::getHoldability() -U- */
410
MySQL_ResultSet::getHoldability()
412
CPP_ENTER("MySQL_ResultSet::getHoldability");
414
throw sql::MethodNotImplementedException("MySQL_ResultSet::getHoldability()");
415
return 0; // fool compilers
420
/* {{{ MySQL_ResultSet::getInt() -I- */
422
MySQL_ResultSet::getInt(const uint32_t columnIndex) const
424
CPP_ENTER("MySQL_ResultSet::getInt(int)");
425
/* isBeforeFirst checks for validity */
426
if (isBeforeFirstOrAfterLast()) {
427
throw sql::InvalidArgumentException("MySQL_ResultSet::getInt: can't fetch because not on result set");
429
if (columnIndex == 0 || columnIndex > num_fields) {
430
throw sql::InvalidArgumentException("MySQL_ResultSet::getInt: invalid value of 'columnIndex'");
432
CPP_INFO_FMT("%ssigned", (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG)? "un":"");
433
if (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG) {
434
return static_cast<uint32_t>(getInt64(columnIndex));
436
return static_cast<int32_t>(getInt64(columnIndex));
441
/* {{{ MySQL_ResultSet::getInt() -I- */
443
MySQL_ResultSet::getInt(const sql::SQLString& columnLabel) const
445
CPP_ENTER("MySQL_ResultSet::getInt(string)");
446
return getInt(findColumn(columnLabel));
451
/* {{{ MySQL_ResultSet::getUInt() -I- */
453
MySQL_ResultSet::getUInt(const uint32_t columnIndex) const
455
CPP_ENTER("MySQL_ResultSet::getUInt(int)");
456
/* isBeforeFirst checks for validity */
457
if (isBeforeFirstOrAfterLast()) {
458
throw sql::InvalidArgumentException("MySQL_ResultSet::getUInt: can't fetch because not on result set");
460
if (columnIndex == 0 || columnIndex > num_fields) {
461
throw sql::InvalidArgumentException("MySQL_ResultSet::getUInt: invalid value of 'columnIndex'");
463
CPP_INFO_FMT("%ssigned", (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG)? "un":"");
464
return static_cast<uint32_t>(getUInt64(columnIndex));// & 0xffffffff;
469
/* {{{ MySQL_ResultSet::getUInt() -I- */
471
MySQL_ResultSet::getUInt(const sql::SQLString& columnLabel) const
473
CPP_ENTER("MySQL_ResultSet::getUInt(string)");
474
return getUInt(findColumn(columnLabel));
479
/* {{{ MySQL_ResultSet::getInt64() -I- */
481
MySQL_ResultSet::getInt64(const uint32_t columnIndex) const
483
CPP_ENTER("MySQL_ResultSet::getInt64(int)");
485
/* isBeforeFirst checks for validity */
486
if (isBeforeFirstOrAfterLast()) {
487
throw sql::InvalidArgumentException("MySQL_ResultSet::getInt64: can't fetch because not on result set");
490
if (columnIndex == 0 || columnIndex > num_fields) {
491
throw sql::InvalidArgumentException("MySQL_ResultSet::getInt64: invalid value of 'columnIndex'");
494
if (row[columnIndex - 1] == NULL) {
498
CPP_INFO_FMT("%ssigned", (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG)? "un":"");
500
if (getFieldMeta(columnIndex)->type == MYSQL_TYPE_BIT) {
502
std::div_t length= std::div(getFieldMeta(columnIndex)->length, 8);
507
switch (length.quot) {
508
case 8:uval = (uint64_t) bit_uint8korr(row[columnIndex - 1]);break;
509
case 7:uval = (uint64_t) bit_uint7korr(row[columnIndex - 1]);break;
510
case 6:uval = (uint64_t) bit_uint6korr(row[columnIndex - 1]);break;
511
case 5:uval = (uint64_t) bit_uint5korr(row[columnIndex - 1]);break;
512
case 4:uval = (uint64_t) bit_uint4korr(row[columnIndex - 1]);break;
513
case 3:uval = (uint64_t) bit_uint3korr(row[columnIndex - 1]);break;
514
case 2:uval = (uint64_t) bit_uint2korr(row[columnIndex - 1]);break;
515
case 1:uval = (uint64_t) bit_uint1korr(row[columnIndex - 1]);break;
520
if (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG) {
521
return strtoull(row[columnIndex - 1], NULL, 10);
523
return strtoll(row[columnIndex - 1], NULL, 10);
528
/* {{{ MySQL_ResultSet::getInt64() -I- */
530
MySQL_ResultSet::getInt64(const sql::SQLString& columnLabel) const
532
CPP_ENTER("MySQL_ResultSet::getInt64(string)");
533
return getInt64(findColumn(columnLabel));
538
/* {{{ MySQL_ResultSet::getUInt64() -I- */
540
MySQL_ResultSet::getUInt64(const uint32_t columnIndex) const
542
CPP_ENTER("MySQL_ResultSet::getUInt64(int)");
544
/* isBeforeFirst checks for validity */
545
if (isBeforeFirstOrAfterLast()) {
546
throw sql::InvalidArgumentException("MySQL_ResultSet::getUInt64: can't fetch because not on result set");
549
if (columnIndex == 0 || columnIndex > num_fields) {
550
throw sql::InvalidArgumentException("MySQL_ResultSet::getUInt64: invalid value of 'columnIndex'");
553
if (row[columnIndex - 1] == NULL) {
557
CPP_INFO_FMT("%ssigned", (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG)? "un":"");
559
if (getFieldMeta(columnIndex)->type == MYSQL_TYPE_BIT) {
561
std::div_t length= std::div(getFieldMeta(columnIndex)->length, 8);
565
switch (length.quot) {
566
case 8:uval = (uint64_t) bit_uint8korr(row[columnIndex - 1]);break;
567
case 7:uval = (uint64_t) bit_uint7korr(row[columnIndex - 1]);break;
568
case 6:uval = (uint64_t) bit_uint6korr(row[columnIndex - 1]);break;
569
case 5:uval = (uint64_t) bit_uint5korr(row[columnIndex - 1]);break;
570
case 4:uval = (uint64_t) bit_uint4korr(row[columnIndex - 1]);break;
571
case 3:uval = (uint64_t) bit_uint3korr(row[columnIndex - 1]);break;
572
case 2:uval = (uint64_t) bit_uint2korr(row[columnIndex - 1]);break;
573
case 1:uval = (uint64_t) bit_uint1korr(row[columnIndex - 1]);break;
578
if (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG) {
579
return strtoull(row[columnIndex - 1], NULL, 10);
581
return strtoll(row[columnIndex - 1], NULL, 10);
586
/* {{{ MySQL_ResultSet::getUInt64() -I- */
588
MySQL_ResultSet::getUInt64(const sql::SQLString& columnLabel) const
590
CPP_ENTER("MySQL_ResultSet::getUInt64(string)");
591
return getUInt64(findColumn(columnLabel));
596
/* {{{ MySQL_ResultSet::getMetaData() -I- */
597
sql::ResultSetMetaData *
598
MySQL_ResultSet::getMetaData() const
600
CPP_ENTER("MySQL_ResultSet::getMetaData");
602
return rs_meta.get();
607
/* {{{ MySQL_ResultSet::getRow() -I- */
609
MySQL_ResultSet::getRow() const
611
CPP_ENTER("MySQL_ResultSet::getRow");
613
/* row_position is 0 based */
614
return static_cast<size_t>(row_position);
619
/* {{{ MySQL_ResultSet::getRowId() -U- */
621
MySQL_ResultSet::getRowId(uint32_t)
623
CPP_ENTER("MySQL_ResultSet::getRowId");
625
throw sql::MethodNotImplementedException("MySQL_ResultSet::getRowId(uint32_t columnIndex)");
626
return NULL; // fool compilers
631
/* {{{ MySQL_ResultSet::getRowId() -U- */
633
MySQL_ResultSet::getRowId(const sql::SQLString &)
635
CPP_ENTER("MySQL_ResultSet::getRowId");
637
throw sql::MethodNotImplementedException("MySQL_ResultSet::getRowId(const sql::SQLString & columnLabel)");
638
return NULL; // fool compilers
643
/* {{{ MySQL_ResultSet::getStatement() -I- */
644
const sql::Statement *
645
MySQL_ResultSet::getStatement() const
647
CPP_ENTER("MySQL_ResultSet::getStatement");
653
/* {{{ MySQL_ResultSet::getString() -I- */
655
MySQL_ResultSet::getString(const uint32_t columnIndex) const
657
CPP_ENTER("MySQL_ResultSet::getString(int)");
658
CPP_INFO_FMT("this=%p column=%u", this, columnIndex);
660
/* isBeforeFirst checks for validity */
661
if (isBeforeFirstOrAfterLast()) {
662
throw sql::InvalidArgumentException("MySQL_ResultSet::getString: can't fetch because not on result set");
665
if (columnIndex == 0 || columnIndex > num_fields) {
666
throw sql::InvalidArgumentException("MySQL_ResultSet::getString: invalid value of 'columnIndex'");
669
if (row[columnIndex - 1] == NULL) {
674
if (getFieldMeta(columnIndex)->type == MYSQL_TYPE_BIT) {
676
snprintf(buf, sizeof(buf) - 1, "%llu", (unsigned long long) getUInt64(columnIndex));
677
return sql::SQLString(buf);
680
size_t len = result->fetch_lengths()[columnIndex - 1];
681
CPP_INFO_FMT("value=%*s", len> 50? 50:len, row[columnIndex - 1]);
683
return sql::SQLString(row[columnIndex - 1], len);
688
/* {{{ MySQL_ResultSet::getString() -I- */
690
MySQL_ResultSet::getString(const sql::SQLString& columnLabel) const
692
CPP_ENTER("MySQL_ResultSet::getString(string)");
693
return getString(findColumn(columnLabel));
698
/* {{{ MySQL_ResultSet::getType() -I- */
699
sql::ResultSet::enum_type
700
MySQL_ResultSet::getType() const
702
CPP_ENTER("MySQL_ResultSet::getType");
704
return resultset_type;
709
/* {{{ MySQL_ResultSet::getWarnings() -U- */
711
MySQL_ResultSet::getWarnings()
713
CPP_ENTER("MySQL_ResultSet::getWarnings");
715
throw sql::MethodNotImplementedException("MySQL_ResultSet::getWarnings()");
720
/* {{{ MySQL_ResultSet::insertRow() -U- */
722
MySQL_ResultSet::insertRow()
724
CPP_ENTER("MySQL_ResultSet::insertRow");
726
throw sql::MethodNotImplementedException("MySQL_ResultSet::insertRow()");
731
/* {{{ MySQL_ResultSet::isAfterLast() -I- */
733
MySQL_ResultSet::isAfterLast() const
735
CPP_ENTER("MySQL_ResultSet::isAfterLast");
738
return (row_position == num_rows + 1);
743
/* {{{ MySQL_ResultSet::isBeforeFirst() -I- */
745
MySQL_ResultSet::isBeforeFirst() const
747
CPP_ENTER("MySQL_ResultSet::isBeforeFirst");
749
return (row_position == 0);
754
/* {{{ MySQL_ResultSet::isClosed() -I- */
756
MySQL_ResultSet::isClosed() const
758
CPP_ENTER("MySQL_ResultSet::isClosed");
760
// return !result->isValid();
765
/* {{{ MySQL_ResultSet::isFirst() -I- */
767
MySQL_ResultSet::isFirst() const
769
CPP_ENTER("MySQL_ResultSet::isFirst");
771
return (row_position == 1);
776
/* {{{ MySQL_ResultSet::isLast() -I- */
778
MySQL_ResultSet::isLast() const
780
CPP_ENTER("MySQL_ResultSet::isLast");
783
return (row_position == num_rows);
788
/* {{{ MySQL_ResultSet::isNull() -I- */
790
MySQL_ResultSet::isNull(const uint32_t columnIndex) const
792
CPP_ENTER("MySQL_ResultSet::isNull(int)");
795
if (columnIndex == 0 || columnIndex > num_fields) {
796
throw sql::InvalidArgumentException("MySQL_ResultSet::isNull: invalid value of 'columnIndex'");
798
/* isBeforeFirst checks for validity */
799
if (isBeforeFirstOrAfterLast()) {
800
throw sql::InvalidArgumentException("MySQL_ResultSet::getDouble: can't fetch because not on result set");
802
return (row[columnIndex - 1] == NULL);
807
/* {{{ MySQL_ResultSet::isNull() -I- */
809
MySQL_ResultSet::isNull(const sql::SQLString& columnLabel) const
811
CPP_ENTER("MySQL_ResultSet::isNull(string)");
812
int32_t col_idx = findColumn(columnLabel);
814
throw sql::InvalidArgumentException("MySQL_ResultSet::isNull: invalid value of 'columnLabel'");
816
return isNull(col_idx);
821
/* {{{ MySQL_ResultSet::last() -I- */
823
MySQL_ResultSet::last()
825
CPP_ENTER("MySQL_ResultSet::last");
829
row_position = num_rows;
832
return num_rows != 0;
837
/* {{{ MySQL_ResultSet::moveToCurrentRow() -U- */
839
MySQL_ResultSet::moveToCurrentRow()
841
CPP_ENTER("MySQL_ResultSet::moveToCurrentRow");
843
throw sql::MethodNotImplementedException("MySQL_ResultSet::moveToCurrentRow()");
849
/* {{{ MySQL_ResultSet::moveToInsertRow() -U- */
851
MySQL_ResultSet::moveToInsertRow()
853
CPP_ENTER("MySQL_ResultSet::moveToInsertRow");
855
throw sql::MethodNotImplementedException("MySQL_ResultSet::moveToInsertRow()");
861
/* {{{ MySQL_ResultSet::next() -I- */
863
MySQL_ResultSet::next()
865
CPP_ENTER("MySQL_ResultSet::next");
868
if (isScrollable()) {
871
} else if (row_position < num_rows + 1) {
872
row = result->fetch_row();
877
row = result->fetch_row();
881
CPP_INFO_FMT("new_position=%llu num_rows=%llu", row_position, num_rows);
887
/* {{{ MySQL_ResultSet::previous() -I- */
889
MySQL_ResultSet::previous()
891
CPP_ENTER("MySQL_ResultSet::previous");
894
/* isBeforeFirst checks for validity */
895
if (isBeforeFirst()) {
897
} else if (isFirst()) {
900
} else if (row_position > 1) {
905
throw sql::SQLException("Impossible");
910
/* {{{ MySQL_ResultSet::refreshRow() -U- */
912
MySQL_ResultSet::refreshRow()
914
CPP_ENTER("MySQL_ResultSet::refreshRow");
916
throw sql::MethodNotImplementedException("MySQL_ResultSet::refreshRow()");
921
/* {{{ MySQL_ResultSet::relative() -I- */
923
MySQL_ResultSet::relative(const int rows)
925
CPP_ENTER("MySQL_ResultSet::relative");
929
if ((row_position + rows) > num_rows || (row_position + rows) < 1) {
930
row_position = rows > 0? num_rows + 1 : 0; /* after last or before first */
932
row_position += rows;
937
return (row_position > 0 && row_position <= num_rows);
942
/* {{{ MySQL_ResultSet::rowDeleted() -U- */
944
MySQL_ResultSet::rowDeleted()
946
CPP_ENTER("MySQL_ResultSet::rowDeleted");
948
throw sql::MethodNotImplementedException("MySQL_ResultSet::rowDeleted()");
949
return false; // fool compilers
954
/* {{{ MySQL_ResultSet::rowInserted() -U- */
956
MySQL_ResultSet::rowInserted()
958
CPP_ENTER("MySQL_ResultSet::rowInserted");
960
throw sql::MethodNotImplementedException("MySQL_ResultSet::rowInserted()");
961
return false; // fool compilers
966
/* {{{ MySQL_ResultSet::rowUpdated() -U- */
968
MySQL_ResultSet::rowUpdated()
970
CPP_ENTER("MySQL_ResultSet::rowUpdated");
972
throw sql::MethodNotImplementedException("MySQL_ResultSet::rowUpdated()");
973
return false; // fool compilers
978
/* {{{ MySQL_ResultSet::rowsCount() -I- */
980
MySQL_ResultSet::rowsCount() const
982
CPP_ENTER("MySQL_ResultSet::rowsCount");
985
return static_cast<size_t>(result->num_rows());
990
/* {{{ MySQL_ResultSet::setFetchSize() -U- */
992
MySQL_ResultSet::setFetchSize(size_t /* rows */)
994
CPP_ENTER("MySQL_ResultSet::setFetchSize");
996
throw sql::MethodNotImplementedException("MySQL_ResultSet::setFetchSize()");
1001
/* {{{ MySQL_ResultSet::wasNull() -I- */
1003
MySQL_ResultSet::wasNull() const
1005
CPP_ENTER("MySQL_ResultSet::wasNull");
1007
/* isBeforeFirst checks for validity */
1008
if (isBeforeFirstOrAfterLast()) {
1009
throw sql::InvalidArgumentException("MySQL_ResultSet::wasNull: can't fetch because not on result set");
1016
/* {{{ MySQL_ResultSet::isBeforeFirstOrAfterLast() -I- */
1018
MySQL_ResultSet::isBeforeFirstOrAfterLast() const
1020
CPP_ENTER("MySQL_ResultSet::isBeforeFirstOrAfterLast");
1022
return (row_position == 0) || (isScrollable() && (row_position == num_rows + 1));
1027
/* {{{ MySQL_ResultSet::seek() -I- */
1029
MySQL_ResultSet::seek()
1031
CPP_ENTER("MySQL_ResultSet::seek");
1033
result->data_seek(row_position - 1);
1034
row = result->fetch_row();
1039
} /* namespace mysql */
1040
} /* namespace sql */
1047
* vim600: noet sw=4 ts=4 fdm=marker
1048
* vim<600: noet sw=4 ts=4