Skip to content

Commit d9e011e

Browse files
committed
Bug #19192707 PREPARE/EXECUTE FOR SELECT OF GEOMETRY FIELD RETURNS ERROR
Allow getting GEOMETRY fields on prepared statmens Change-Id: I0680a07218863408596e1f9ac95dc4aa6f437a10
1 parent 527da03 commit d9e011e

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

driver/mysql_ps_resultset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,11 +1053,11 @@ MySQL_Prepared_ResultSet::getString(const uint32_t columnIndex) const
10531053
case sql::DataType::SET:
10541054
case sql::DataType::ENUM:
10551055
case sql::DataType::JSON:
1056+
case sql::DataType::GEOMETRY:
10561057
CPP_INFO("It's a string");
10571058
return sql::SQLString(static_cast<char *>(result_bind->rbind[columnIndex - 1].buffer), *result_bind->rbind[columnIndex - 1].length);
10581059
default:
10591060
break;
1060-
// ToDo : Geometry? default ?
10611061
}
10621062

10631063
CPP_ERR("MySQL_Prepared_ResultSet::getString: unhandled type. Please, report");

driver/mysql_resultbind.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static struct st_buffer_size_type
113113
case MYSQL_TYPE_BIT:
114114
return st_buffer_size_type(new char[8], 8, MYSQL_TYPE_BIT);
115115
case MYSQL_TYPE_GEOMETRY:
116+
return st_buffer_size_type(new char[field->max_length], field->max_length, MYSQL_TYPE_BIT);
116117
default:
117118
// TODO: Andrey, there can be crashes when we go through this. Please fix.
118119
throw sql::InvalidArgumentException("allocate_buffer_for_field: invalid rbind data type");

test/unit/bugs/bugs.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,39 @@ void bugs::bug23235968()
12701270

12711271
}
12721272

1273+
void bugs::bug19192707()
1274+
{
1275+
logMsg("bugs::bug19192707");
1276+
1277+
sql::SQLString direct, ps;
1278+
1279+
stmt->executeUpdate("drop table if exists bug19192707");
1280+
stmt->executeUpdate("create table bug19192707 (i1 point)");
1281+
1282+
pstmt.reset(con->prepareStatement("insert into bug19192707 (i1) values(ST_PointFromText('POINT(1 2)',4326))"));
1283+
pstmt->executeUpdate();
1284+
1285+
logMsg("Select with Direct execute : ");
1286+
1287+
res.reset(stmt->executeQuery("select i1 from bug19192707"));
1288+
1289+
res->next();
1290+
direct = res->getString(1);
1291+
1292+
logMsg("Select with Prepare/execute : ");
1293+
1294+
pstmt.reset(con->prepareStatement("select i1 from bug19192707"));
1295+
1296+
res.reset(pstmt->executeQuery());
1297+
1298+
res->next();
1299+
ps = res->getString(1);
1300+
1301+
ASSERT_EQUALS(direct, ps);
1302+
1303+
stmt->executeUpdate("drop table if exists bug19192707");
1304+
1305+
}
12731306

12741307
} /* namespace regression */
12751308
} /* namespace testsuite */

test/unit/bugs/bugs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class bugs : public unit_fixture
8080
TEST_CASE(bug30126457);
8181
TEST_CASE(bug32695580);
8282
TEST_CASE(bug23235968);
83+
TEST_CASE(bug19192707);
8384
}
8485

8586
/**
@@ -151,6 +152,7 @@ class bugs : public unit_fixture
151152

152153
void bug23235968();
153154

155+
void bug19192707();
154156
};
155157

156158
REGISTER_FIXTURE(bugs);

0 commit comments

Comments
 (0)