-
Notifications
You must be signed in to change notification settings - Fork 1
/
DescRecord.cpp
228 lines (200 loc) · 4.9 KB
/
DescRecord.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* https://www.firebirdsql.org/en/initial-developer-s-public-license-version-1-0/
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
*
* The Original Code was created by James A. Starkey for IBPhoenix.
*
* Copyright (c) 1999, 2000, 2001 James A. Starkey
* All Rights Reserved.
*/
// DescRecord.cpp: implementation of the DescRecord class.
//
//////////////////////////////////////////////////////////////////////
#include <memory.h>
#include <string.h>
#include "OdbcEnv.h"
#include "OdbcConnection.h"
#include "IscDbc/Connection.h"
#include "OdbcDesc.h"
#include "DescRecord.h"
namespace OdbcJdbcLibrary {
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DescRecord::DescRecord()
{
isDefined = false;
isPrepared = false;
isIndicatorSqlDa = false;
isZeroColumn = false;
isLocalDataPtr = false;
localDataPtr = NULL;
callType = 0;
isBlobOrArray = 0;
data_at_exec = false;
startedTransfer = false;
sizeColumnExtendedFetch = 0;
dataOffset = 0;
currentFetched = 0;
headSqlVarPtr = NULL;
dataBlobPtr = NULL;
type = SQL_C_DEFAULT;
datetimeIntervalCode = 0;
conciseType = SQL_C_DEFAULT;
autoUniqueValue = 0;
caseSensitive = 0;
datetimeIntervalPrecision =0;
displaySize = 0;
fixedPrecScale = 0;
numPrecRadix = 0;
length = 0;
nullable = 0;
octetLength = 0;
octetLengthPtr = (SQLLEN*)NULL;
parameterType = SQL_PARAM_INPUT;
precision = 0;
scale = 0;
searchable = 0;
unSigned = 0;
updaTable = 0;
indicatorPtr = NULL;
unNamed = SQL_NAMED;
dataPtr = NULL;
fnConv = NULL;
#ifdef _WINDOWS
WcsToMbs = _WcsToMbs;
MbsToWcs = _MbsToWcs;
#else
WcsToMbs = wcstombs;
MbsToWcs = mbstowcs;
#endif
}
DescRecord::~DescRecord()
{
releaseAllocMemory();
}
void DescRecord::releaseAllocMemory()
{
if ( headSqlVarPtr )
{
headSqlVarPtr->release();
headSqlVarPtr = NULL;
}
if ( dataBlobPtr )
{
dataBlobPtr->release();
dataBlobPtr = NULL;
}
freeLocalDataPtr();
}
void DescRecord::setDefault(DescRecord *recTo)
{
SQLLEN *saveIndicatorPtr = recTo->indicatorPtr;
SQLPOINTER saveDataPtr = recTo->dataPtr;
*recTo = this;
recTo->indicatorPtr = saveIndicatorPtr;
recTo->dataPtr = saveDataPtr;
}
void DescRecord::allocateLocalDataPtr(int length)
{
freeLocalDataPtr();
isLocalDataPtr = true;
if ( !length )
length = getBufferLength();
localDataPtr = (char*)malloc( length );
}
void DescRecord::freeLocalDataPtr()
{
if ( isLocalDataPtr )
{
isLocalDataPtr = false;
free ( localDataPtr );
localDataPtr = NULL;
}
}
bool DescRecord::operator =(DescRecord *rec)
{
if ( !rec )
return false;
if ( !this )
return false;
data_at_exec = rec->data_at_exec;
startedTransfer = rec->startedTransfer;
type = rec->type;
datetimeIntervalCode = rec->datetimeIntervalCode;
conciseType = rec->conciseType;
if ( type != SQL_C_DEFAULT && conciseType == SQL_C_DEFAULT )
conciseType = type;
autoUniqueValue = rec->autoUniqueValue;
caseSensitive = rec->caseSensitive;
datetimeIntervalPrecision = rec->datetimeIntervalPrecision;
displaySize = rec->displaySize;
fixedPrecScale = rec->fixedPrecScale;
numPrecRadix = rec->numPrecRadix;
length = rec->length;
nullable = rec->nullable;
octetLength = rec->octetLength;
octetLengthPtr = rec->octetLengthPtr;
// parameterType = rec->parameterType;
precision = rec->precision;
scale = rec->scale;
searchable = rec->searchable;
unSigned = rec->unSigned;
updaTable = rec->updaTable;
indicatorPtr = rec->indicatorPtr;
if ( indicatorPtr && !octetLengthPtr )
octetLengthPtr = indicatorPtr;
unNamed = rec->unNamed;
dataPtr = rec->dataPtr;
return true;
}
void DescRecord::initZeroColumn()
{
autoUniqueValue = SQL_FALSE;
caseSensitive = SQL_FALSE;
catalogName = "";
datetimeIntervalCode = 0;
displaySize = 8;
fixedPrecScale = SQL_FALSE;
numPrecRadix = 0;
label = "";
literalPrefix = "";
literalSuffix = "";
localTypeName = "";
name = "";
nullable = SQL_NO_NULLS;
octetLength = 4;
precision = 4;
scale = 0;
schemaName = "";
searchable = SQL_PRED_NONE;
tableName = "";
typeName = "";
unNamed = SQL_UNNAMED;
unSigned = SQL_FALSE;
updaTable = SQL_ATTR_READONLY;
}
void DescRecord::beginBlobDataTransfer()
{
dataBlobPtr->clear();
startedTransfer = true;
}
void DescRecord::putBlobSegmentData (int length, const void *bytes)
{
dataBlobPtr->putLongSegment (length, (char*)bytes);
}
void DescRecord::endBlobDataTransfer()
{
startedTransfer = false;
}
}; // end namespace OdbcJdbcLibrary