Skip to content

Commit f8de755

Browse files
committed
Make SQLDA logic more solid
1 parent f96bc8c commit f8de755

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

IscDbc/IscStatement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ namespace IscDbcLibrary {
106106
//////////////////////////////////////////////////////////////////////
107107

108108
IscStatement::IscStatement(IscConnection *connect) :
109-
inputSqlda{connect},
110-
outputSqlda{connect}
109+
inputSqlda{connect, Sqlda::SQLDA_INPUT},
110+
outputSqlda{connect, Sqlda::SQLDA_OUTPUT}
111111
{
112112
connection = connect;
113113
useCount = 1;

IscDbc/Sqlda.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class CDataStaticCursor
313313
// Construction/Destruction Sqlda
314314
//////////////////////////////////////////////////////////////////////
315315

316-
Sqlda::Sqlda(IscConnection* conn) : connection{ conn }, buffer{}, execBuffer{}, useExecBufferMeta{ false }
316+
Sqlda::Sqlda(IscConnection* conn, e_sqlda_dir dir) : connection{ conn }, buffer{}, execBuffer{}, useExecBufferMeta{ false }, SqldaDir{ dir }
317317
{
318318
init();
319319
}
@@ -684,7 +684,7 @@ void Sqlda::print()
684684
//
685685
int Sqlda::getColumnDisplaySize(int index)
686686
{
687-
const SqlProperties *var = orgVarSqlProperties(index);
687+
const SqlProperties *var = (SqldaDir == SQLDA_INPUT) ? orgVarSqlProperties(index) : Var(index);
688688

689689
switch (var->sqltype)
690690
{

IscDbc/Sqlda.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,16 @@ class Sqlda
160160
public:
161161
using buffer_t = std::vector<char>;
162162

163+
enum e_sqlda_dir {
164+
SQLDA_INPUT,
165+
SQLDA_OUTPUT,
166+
};
167+
163168
protected:
164169
buffer_t& initStaticCursor(IscStatement* stmt);
165170
buffer_t& addRowSqldaInBufferStaticCursor();
166171
void restoreOrgAdressFieldsStaticCursor();
172+
e_sqlda_dir SqldaDir;
167173

168174
public:
169175
const char* getOwnerName(int index);
@@ -202,7 +208,7 @@ class Sqlda
202208
CAttrSqlVar* Var(int index) { return &sqlvar.at(index - 1); }
203209
const SqlProperties* orgVarSqlProperties(int index) { return &sqlvar.at(index - 1).orgSqlProperties; }
204210

205-
Sqlda(IscConnection* conn);
211+
Sqlda(IscConnection* conn, e_sqlda_dir dir);
206212
~Sqlda();
207213

208214
int isBlobOrArray(int index);

IscDbc/TypesResultSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static Types types [] =
136136

137137
TypesResultSet::TypesResultSet(int dataType, int appOdbcVersion, int bytesPerCharacter, IscConnection* conn) :
138138
IscResultSet{nullptr},
139-
outputSqlda {conn}
139+
outputSqlda {conn, Sqlda::SQLDA_OUTPUT}
140140
{
141141
dataTypes = dataType;
142142

0 commit comments

Comments
 (0)