@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
28
28
#include < stdlib.h>
29
29
#include < stdio.h>
30
30
#include < sstream>
31
+ #include < limits>
31
32
#include < boost/scoped_array.hpp>
32
33
33
34
#include < cppconn/exception.h>
@@ -100,7 +101,7 @@ MySQL_ResultSet::absolute(const int new_pos)
100
101
return true ;
101
102
}
102
103
} else if (new_pos < 0 ) {
103
- if ((-new_pos) > (int ) num_rows) {
104
+ if ((-new_pos) > (int ) num_rows || (new_pos == std::numeric_limits< int >:: min ()) ) {
104
105
row_position = 0 ; /* before first new_pos */
105
106
} else {
106
107
row_position = num_rows - (-new_pos) + 1 ;
@@ -162,6 +163,8 @@ MySQL_ResultSet::checkScrollable() const
162
163
if (resultset_type == sql::ResultSet::TYPE_FORWARD_ONLY) {
163
164
throw sql::NonScrollableException (" Nonscrollable result set" );
164
165
}
166
+ // reset last_queried_column
167
+ last_queried_column = -1 ;
165
168
}
166
169
/* }}} */
167
170
@@ -351,12 +354,14 @@ MySQL_ResultSet::getDouble(const uint32_t columnIndex) const
351
354
if (columnIndex == 0 || columnIndex > num_fields) {
352
355
throw sql::InvalidArgumentException (" MySQL_ResultSet::getDouble: invalid value of 'columnIndex'" );
353
356
}
357
+
358
+ last_queried_column = columnIndex;
359
+
354
360
if (row[columnIndex - 1 ] == NULL ) {
355
361
was_null = true ;
356
362
return 0.0 ;
357
363
}
358
364
was_null = false ;
359
- last_queried_column = columnIndex;
360
365
if (getFieldMeta (columnIndex)->type == MYSQL_TYPE_BIT) {
361
366
return static_cast <long double >(getInt64 (columnIndex));
362
367
}
@@ -493,13 +498,16 @@ MySQL_ResultSet::getInt64(const uint32_t columnIndex) const
493
498
throw sql::InvalidArgumentException (" MySQL_ResultSet::getInt64: invalid value of 'columnIndex'" );
494
499
}
495
500
501
+ last_queried_column = columnIndex;
502
+
496
503
if (row[columnIndex - 1 ] == NULL ) {
497
504
was_null = true ;
498
505
return 0 ;
499
506
}
507
+
508
+
500
509
CPP_INFO_FMT (" %ssigned" , (getFieldMeta (columnIndex)->flags & UNSIGNED_FLAG)? " un" :" " );
501
510
was_null = false ;
502
- last_queried_column = columnIndex;
503
511
if (getFieldMeta (columnIndex)->type == MYSQL_TYPE_BIT &&
504
512
getFieldMeta (columnIndex)->flags != (BINARY_FLAG|UNSIGNED_FLAG)) {
505
513
uint64_t uval = 0 ;
@@ -554,13 +562,16 @@ MySQL_ResultSet::getUInt64(const uint32_t columnIndex) const
554
562
throw sql::InvalidArgumentException (" MySQL_ResultSet::getUInt64: invalid value of 'columnIndex'" );
555
563
}
556
564
565
+ last_queried_column = columnIndex;
566
+
557
567
if (row[columnIndex - 1 ] == NULL ) {
558
568
was_null = true ;
559
569
return 0 ;
560
570
}
571
+
572
+
561
573
CPP_INFO_FMT (" %ssigned" , (getFieldMeta (columnIndex)->flags & UNSIGNED_FLAG)? " un" :" " );
562
574
was_null = false ;
563
- last_queried_column = columnIndex;
564
575
if (getFieldMeta (columnIndex)->type == MYSQL_TYPE_BIT &&
565
576
getFieldMeta (columnIndex)->flags != (BINARY_FLAG|UNSIGNED_FLAG)) {
566
577
uint64_t uval = 0 ;
@@ -673,12 +684,13 @@ MySQL_ResultSet::getString(const uint32_t columnIndex) const
673
684
throw sql::InvalidArgumentException (" MySQL_ResultSet::getString: invalid value of 'columnIndex'" );
674
685
}
675
686
687
+ last_queried_column = columnIndex;
688
+
676
689
if (row == NULL || row[columnIndex - 1 ] == NULL ) {
677
690
was_null = true ;
678
691
return " " ;
679
692
}
680
693
681
- last_queried_column = columnIndex;
682
694
if (getFieldMeta (columnIndex)->type == MYSQL_TYPE_BIT) {
683
695
char buf[30 ];
684
696
snprintf (buf, sizeof (buf) - 1 , " %llu" , (unsigned long long ) getUInt64 (columnIndex));
0 commit comments