Skip to content

Commit 3f20c98

Browse files
committed
Fix handling of length_value for fixed-size temporal types after libmariadb CONC-812 change
libmariadb CONC-812 changed mysql_stmt_bind_result to initialize length_value=0 for fixed-size struct types (DATE/TIME/DATETIME/TIMESTAMP). While the MYSQL_TIME buffer is still correctly filled by ps_fetch_datetime, length_value is no longer set to sizeof(MYSQL_TIME). Use buffer_length as fallback when length_value is 0 for temporal types.
1 parent ec45a0c commit 3f20c98

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/protocol/capi/BinRowProtocolCapi.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ namespace capi
105105
}
106106
else {
107107
length = bind[index].length_value;
108+
/* libmariadb CONC-812 changed mysql_stmt_bind_result to initialize
109+
length_value=0 for fixed-size struct types (DATE/TIME/DATETIME/TIMESTAMP).
110+
The MYSQL_TIME buffer is still correctly filled by ps_fetch_datetime, but
111+
length_value is no longer set to sizeof(MYSQL_TIME). Use buffer_length
112+
(which we set to sizeof(MYSQL_TIME) in the constructor) as fallback. */
113+
if (length == 0 && !bind[index].is_null_value) {
114+
auto bufType= bind[index].buffer_type;
115+
if (bufType == MYSQL_TYPE_DATE || bufType == MYSQL_TYPE_TIME ||
116+
bufType == MYSQL_TYPE_DATETIME || bufType == MYSQL_TYPE_TIMESTAMP ||
117+
bufType == MYSQL_TYPE_NEWDATE) {
118+
length= static_cast<uint32_t>(bind[index].buffer_length);
119+
}
120+
}
108121
fieldBuf.wrap(static_cast<char*>(bind[index].buffer), length);
109122
this->lastValueNull = bind[index].is_null_value ? BIT_LAST_FIELD_NULL : BIT_LAST_FIELD_NOT_NULL;
110123
}

0 commit comments

Comments
 (0)