Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions IscDbc/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ class HeadSqlVar
//virtual void setSqlSubType ( short subtype ) = 0;
virtual void setSqlLen ( short len ) = 0;
virtual short getSqlMultiple () = 0;
virtual bool isSqlVarying () = 0;

virtual char * getSqlData() = 0;
virtual short * getSqlInd() = 0;
Expand Down
1 change: 1 addition & 0 deletions IscDbc/IscHeadSqlVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class IscHeadSqlVar : public HeadSqlVar
inline short getSqlMultiple () { return sqlMultiple; }
inline char * getSqlData() { return sqlvar->sqldata; }
inline short * getSqlInd() { return sqlvar->sqlind; }
inline bool isSqlVarying() { return sqlvar->sqltype == SQL_VARYING; }

// not used
//void setSqlInd( short *ind ) { sqlvar->sqlind = ind; }
Expand Down
19 changes: 16 additions & 3 deletions IscDbc/Sqlda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,20 @@ const char* Sqlda::getColumnName(int index)

int Sqlda::getPrecision(int index)
{
CAttrSqlVar *var = Var(index);
CAttrSqlVar *curVar = Var(index);
// Issue #161: for INPUT parameters the conversion code mutates sqlvar
// (via setTypeText/setSqlLen). Reading precision from the current
// sqlvar makes `record->length` shrink after the first row was bound,
// which then causes subsequent numeric→VARCHAR conversions to write
// only the first character of multi-digit values (silent data loss).
// The precision of a prepared parameter is immutable, so read the
// length/type snapshot captured at prepare time for INPUT params.
// SQL_ARRAY still needs the mutable CAttrSqlVar (for the `array`
// pointer), so fall through to Var(index) in that case.
const SqlProperties *var =
(SqldaDir == SQLDA_INPUT && curVar->sqltype != SQL_ARRAY)
? orgVarSqlProperties(index)
: curVar;

switch (var->sqltype)
{
Expand Down Expand Up @@ -798,8 +811,8 @@ int Sqlda::getPrecision(int index)
MAX_DECIMAL_LENGTH,
MAX_QUAD_LENGTH);

case SQL_ARRAY:
return var->array->arrOctetLength;
case SQL_ARRAY:
return curVar->array->arrOctetLength;
// return MAX_ARRAY_LENGTH;

case SQL_BLOB:
Expand Down
Loading