DCL 3.7.4
Loading...
Searching...
No Matches
IBField.cpp
Go to the documentation of this file.
1#include <dcl/Config.h>
2
3#include <stdlib.h> // malloc, free
4#include <string.h> // strncpy
5#include <time.h> // struct tm
6
7#include <ibase.h>
8
9#include <dcl/Object.h>
10#if __DCL_HAVE_ALLOC_DEBUG
11#undef __DCL_ALLOC_LEVEL
12#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
13#endif
14
15#include <dcl/Numeric.h>
17#include <dcl/Charset.h>
18#include <dcl/SQLCore.h>
19
20#include "IBConnection.h"
21#include "IBQuery.h"
22#include "IBField.h"
23
24#define __TRACE_THIS 0
25#if __TRACE_THIS
26#define __DCL_TRACE0_N __DCL_TRACE0
27#define __DCL_TRACE1_N __DCL_TRACE1
28#define __DCL_TRACE2_N __DCL_TRACE2
29#define __DCL_TRACE3_N __DCL_TRACE3
30#define __DCL_TRACE4_N __DCL_TRACE4
31#else
32#define __DCL_TRACE0_N(fmt)
33#define __DCL_TRACE1_N(fmt, arg)
34#define __DCL_TRACE2_N(fmt, arg1, arg2)
35#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
36#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
37#endif
38
39#undef __THIS_FILE__
40static const char_t __THIS_FILE__[] = __T("dcl/sql/IBField.cpp");
41
42__DCL_BEGIN_NAMESPACE
43
44#define __SET_ERROR(_error) \
45 conn()->setErrorHandle(_error, __THIS_FILE__, __LINE__)
46#define __SET_ERROR_MSG(_msg) \
47 conn()->setErrorMessage(_msg, __THIS_FILE__, __LINE__)
48
50
51#define __SQLTYPE_IS(__sqltype) ((__sqlvar->sqltype & ~1) == __sqltype)
52
54 : Field(NULL)
55{
56 __sqlvar = NULL;
57 __indicator = 0; /* NOT NULL의 경우 체크하지 않는다. 때문에 초기값은
58 NOT NULL (0) 으로 둔다. */
59
60 __maxDataSize = 0;
61 __dataSize = 0;
62}
63
65{
66// cerr << "~IBField:" << name() << endl;
67}
68
69bool IBField::init(SQL::Query* _queryHandle, XSQLVAR* _sqlvar)
70{
71 __DCL_ASSERT((Field::__queryHandle == NULL) && (__sqlvar == NULL));
72 __DCL_ASSERT((_sqlvar != NULL) && (_sqlvar->sqldata != NULL));
73
74 Field::__queryHandle = _queryHandle;
75 __sqlvar = _sqlvar;
76 __sqlvar->sqlind = &__indicator;
77
78 try {
79 Field::__name = UTF8Decoder::decode(__sqlvar->sqlname,
80 __sqlvar->sqlname_length).toUpperCase();
81 }
82 catch (CharsetConvertException* _e) {
83 __SET_ERROR_MSG(UTF8Encoder::encode(_e->toStringAll()));
84 _e->destroy();
85 return false;
86 }
87
88#ifndef FIREBIRD_IBASE_H
89 Field::__precision = __sqlvar->sqlprecision;
90#endif
91 Field::__scale = __sqlvar->sqlscale;
92
93 switch(__sqlvar->sqltype & ~1) {
94 case SQL_BOOLEAN: {
95 Field::__dataType = SQL::typeInteger;
96 __maxDataSize = sizeof(int8_t);
97 break;
98 }
99 case SQL_SHORT: {
100 if (__sqlvar->sqlscale == 0) {
101 Field::__dataType = SQL::typeInteger;
102 __maxDataSize = sizeof(int16_t);
103 }
104 else {
105 Field::__dataType = SQL::typeNumeric;
106 __maxDataSize = 5 + 2; // "-32768."
107 }
108 break;
109 }
110 case SQL_LONG: {
111 if (__sqlvar->sqlscale == 0) {
112 Field::__dataType = SQL::typeInteger;
113 __maxDataSize = sizeof(int32_t);
114 }
115 else {
116 Field::__dataType = SQL::typeNumeric;
117 __maxDataSize = 10 + 2; // "-2147483648."
118 }
119 break;
120 }
121 case SQL_INT64: {
122 if (__sqlvar->sqlscale == 0) {
123 Field::__dataType = SQL::typeInteger;
124 __maxDataSize = sizeof(int64_t);
125 }
126 else {
127 Field::__dataType = SQL::typeNumeric;
128 __maxDataSize = 19 + 2; // "-9223372036854775807."
129
130 }
131 break;
132 }
133 case SQL_FLOAT: {
134 Field::__dataType = SQL::typeFloat;
135 __maxDataSize = sizeof(float);
136 break;
137 }
138 case SQL_DOUBLE: {
139 Field::__dataType = SQL::typeFloat;
140 __maxDataSize = sizeof(double);
141 break;
142 }
143 case SQL_TYPE_DATE: {
144 Field::__dataType = SQL::typeDate;
145 __maxDataSize = sizeof(SQL::Date);
146 break;
147 }
148 case SQL_TYPE_TIME: {
149 Field::__dataType = SQL::typeTime;
150 __maxDataSize = sizeof(SQL::Time);
151 break;
152 }
153 case SQL_TIMESTAMP: {
154 Field::__dataType = SQL::typeTimeStamp;
155 __maxDataSize = sizeof(SQL::TimeStamp);
156 break;
157 }
158#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
159 case SQL_TIME_TZ_EX: {
160 Field::__dataType = SQL::typeTimeTz;
161 __maxDataSize = sizeof(SQL::Time);
162 break;
163 }
164 case SQL_TIMESTAMP_TZ_EX: {
165 Field::__dataType = SQL::typeTimeStampTz;
166 __maxDataSize = sizeof(SQL::TimeStamp);
167 break;
168 }
169#endif
170 case SQL_TEXT: {
171 Field::__dataType = SQL::typeText;
172 __maxDataSize = __sqlvar->sqllen; // 32767;
173 break;
174 }
175 case SQL_VARYING: {
176 Field::__dataType = SQL::typeText;
177 __maxDataSize = __sqlvar->sqllen; // 32765;
178 break;
179 }
180 case SQL_BLOB: {
181 if (__sqlvar->sqlsubtype == isc_blob_text)
182 Field::__dataType = SQL::typeLongText;
183 else
184 Field::__dataType = SQL::typeLongBinary;
185 __maxDataSize = 64 * 1024; // 64KB
186 break;
187 }
188 default: {
189 __DCL_ASSERT(false);
190 }
191 }
192 return true;
193}
194
195static size_t __get_decimal_length(void* _buf, short _sqltype, short _sqlscale);
196
198{
199 if (__indicator != -1) {
200 // not null
201 if (Field::__dataType == SQL::typeNumeric) {
202 __dataSize = __get_decimal_length(__sqlvar->sqldata,
203 __sqlvar->sqltype, __sqlvar->sqlscale);
204 }
205 else if (Field::__dataType == SQL::typeLongText
206 || Field::__dataType == SQL::typeLongBinary) {
207 __DCL_ASSERT(__SQLTYPE_IS(SQL_BLOB));
208
209 isc_blob_handle hBlob = NULL_HANDLE;
210 ISC_QUAD* pBlobID = (ISC_QUAD*)(__sqlvar->sqldata);
211
212 if (isc_open_blob2(
213 conn()->statusVector(),
214 conn()->dbHandlePtr(),
215 conn()->trHandlePtr(),
216 &hBlob,
217 pBlobID,
218 0,
219 NULL
220 )) {
222 return false;
223 }
224
225 bool b = getBlobInfo(&hBlob, isc_info_blob_total_length, &__dataSize);
226 ISC_STATUS status2[ISC_STATUS_VECTOR_LENGTH];
227 isc_close_blob(status2, &hBlob);
228
229 if (!b) {
231 return false;
232 }
233 }
234 }
235 return true;
236}
237
238#define SQLTYPE_NAME(_dataType, name) case _dataType : return L ## name
239
240const wchar_t* __dataTypeName(const XSQLVAR* _sqlvar)
241{
242 switch(_sqlvar->sqltype & ~1) {
243 SQLTYPE_NAME(SQL_BOOLEAN, "BOOLEAN");
244 case SQL_SHORT:
245 case SQL_LONG:
246 case SQL_INT64: {
247 if (_sqlvar->sqlscale) {
248 switch (_sqlvar->sqltype & ~1) {
249 SQLTYPE_NAME(SQL_SHORT, "DECIMAL16");
250 SQLTYPE_NAME(SQL_LONG, "DECIMAL32");
251 SQLTYPE_NAME(SQL_INT64, "DECIMAL64");
252 }
253 }
254 else {
255 switch (_sqlvar->sqltype & ~1) {
256 SQLTYPE_NAME(SQL_SHORT, "SMALLINT");
257 SQLTYPE_NAME(SQL_LONG, "INTEGER");
258 SQLTYPE_NAME(SQL_INT64, "INT64");
259 }
260 }
261 }
262 SQLTYPE_NAME(SQL_FLOAT, "FLOAT");
263 SQLTYPE_NAME(SQL_DOUBLE, "DOUBLE");
264 SQLTYPE_NAME(SQL_TYPE_DATE, "DATE");
265 SQLTYPE_NAME(SQL_TYPE_TIME, "TIME");
266 SQLTYPE_NAME(SQL_TIMESTAMP, "TIMESTAMP");
267#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
268 SQLTYPE_NAME(SQL_TIME_TZ_EX, "TIME WITH TIMEZONE");
269 SQLTYPE_NAME(SQL_TIMESTAMP_TZ_EX, "TIMESTAMP WITH TIMEZONE");
270#endif
271 SQLTYPE_NAME(SQL_TEXT, "CHAR");
272 SQLTYPE_NAME(SQL_VARYING, "VARCHAR");
273 case SQL_BLOB: {
274 if (_sqlvar->sqlsubtype == 1)
275 return L"BLOB(TEXT)";
276 else
277 return L"BLOB";
278 }
279 }
280 return L"Unknown Type: Driver is not Support";
281}
282
283const wchar_t* IBField::serverDataTypeName() const
284{
285 return __dataTypeName(__sqlvar);
286}
287
288bool IBField::__getDataSize(size_t* _size, bool _maxsize)
289{
290 if (_maxsize) {
291 *_size = __maxDataSize;
292 return true;
293 }
294
295 if (__indicator == -1) {
296 *_size = (size_t)-1;
297 }
298 else {
299 switch (Field::__dataType) {
300 case SQL::typeText: {
301 if (__SQLTYPE_IS(SQL_TEXT))
302 *_size = __sqlvar->sqllen;
303 else {
304 __DCL_ASSERT(__SQLTYPE_IS(SQL_VARYING));
305 *_size = *(short*)(__sqlvar->sqldata);
306 }
307 break;
308 }
309 case SQL::typeNumeric:
311 case SQL::typeLongBinary: {
312 *_size = __dataSize;
313 break;
314 }
315 default: {
316 // typeInteger, typeUInteger, typeFloat, typeNumeric
317 // typeDate, typeTime, typeTimeStamp
318 // *_size = __maxDataSize;
319 *_size = __sqlvar->sqllen;
320 }
321 }
322 }
323 return true;
324}
325
327 void* _buf,
328 size_t* _size,
329 SQL::DataType _bufType
330)
331{
332#if 0
333 if (query()->stmtType() == isc_info_sql_stmt_select) {
334 if (!query()->inState(SQL::Query::stFetched)) {
336 return false;
337 }
338 }
339 else {
340 // isc_info_sql_stmt_exec_procedure
341 if (!__queryHandle->inState(SQL::Query::stExecuted)) {
343 return false;
344 }
345 }
346#endif
347 switch(_bufType) {
348 case SQL::typeInteger:
349 return getInteger(_buf, _size);
351 return getUInteger(_buf, _size);
352 case SQL::typeFloat:
353 return getFloat(_buf, _size);
354 case SQL::typeDate:
355 return getDate((SQL::Date*)_buf, _size);
356 case SQL::typeTime:
357 return getTime((SQL::Time*)_buf, _size);
359 return getTimeStamp((SQL::TimeStamp*)_buf, _size);
362 return false;
363 case SQL::typeText:
364 if (Field::__dataType == SQL::typeNumeric)
365 return getDecimal((char*)_buf, _size);
366 case SQL::typeBinary:
367 return getBytes((byte_t*)_buf, _size);
369 return writeTo((OutputStream*)_buf, _size);
370 default :
371 __DCL_ASSERT(false); // SQL::Field::getData bug
372 }
373
374 return true;
375}
376
377static int32_t __divider32 [] =
378{
379 1, // 0
380 10, // -1
381 100, // -2
382 1000, // -3
383 10000, // -4
384 100000, // -5
385 1000000, // -6
386 10000000, // -7
387 100000000, // -8
388 1000000000 // -9
389};
390
391static int64_t __divider64 [] =
392{
393#ifdef _MSC_VER
394 1I64, // 0
395 10I64, // -1
396 100I64, // -2
397 1000I64, // -3
398 10000I64, // -4
399 100000I64, // -5
400 1000000I64, // -6
401 10000000I64, // -7
402 100000000I64, // -8
403 1000000000I64, // -9
404 10000000000I64, // -10
405 100000000000I64, // -11
406 1000000000000I64, // -12
407 10000000000000I64, // -13
408 100000000000000I64, // -14
409 1000000000000000I64, // -15
410 10000000000000000I64, // -16
411 100000000000000000I64, // -17
412 1000000000000000000I64 // -18
413#else // __GNUC__
414 1LL, // 0
415 10LL, // -1
416 100LL, // -2
417 1000LL, // -3
418 10000LL, // -4
419 100000LL, // -5
420 1000000LL, // -6
421 10000000LL, // -7
422 100000000LL, // -8
423 1000000000LL, // -9
424 10000000000LL, // -10
425 100000000000LL, // -11
426 1000000000000LL, // -12
427 10000000000000LL, // -13
428 100000000000000LL, // -14
429 1000000000000000LL, // -15
430 10000000000000000LL, // -16
431 100000000000000000LL, // -17
432 1000000000000000000LL // -18
433#endif
434};
435
437{
438 int16_t i16;
439 int32_t i32;
440 int64_t i64;
441};
442
443bool IBField::getInteger(void* _buf, size_t* _size)
444{
445 if (__sqlvar->sqlscale == 0) {
446 // integer
447 switch(__sqlvar->sqltype & ~1) {
448 case SQL_BOOLEAN: {
449 switch (*_size) {
450 case sizeof(int8_t) : {
451 *(int8_t*)_buf = *(int8_t*)(__sqlvar->sqldata);
452 break;
453 }
454 case sizeof(int16_t) : {
455 *(int16_t*)_buf = *(int8_t*)(__sqlvar->sqldata);
456 break;
457 }
458 case sizeof(int32_t) : {
459 *(int32_t*)_buf = *(int8_t*)(__sqlvar->sqldata);
460 break;
461 }
462 case sizeof(int64_t) : {
463 *(int64_t*)_buf = *(int8_t*)(__sqlvar->sqldata);
464 break;
465 }
466 default: {
467 *_size = sizeof(int8_t);
469 return false;
470 }
471 }
472 break;
473 }
474 case SQL_SHORT: {
475 switch (*_size) {
476 case sizeof(int16_t) : {
477 *(int16_t*)_buf = *(int16_t*)(__sqlvar->sqldata);
478 break;
479 }
480 case sizeof(int32_t) : {
481 *(int32_t*)_buf = *(int16_t*)(__sqlvar->sqldata);
482 break;
483 }
484 case sizeof(int64_t) : {
485 *(int64_t*)_buf = *(int16_t*)(__sqlvar->sqldata);
486 break;
487 }
488 default: {
489 *_size = sizeof(int16_t);
491 return false;
492 }
493 }
494 break;
495 }
496 case SQL_LONG: {
497 switch (*_size) {
498 case sizeof(int32_t) : {
499 *(int32_t*)_buf = *(int32_t*)(__sqlvar->sqldata);
500 break;
501 }
502 case sizeof(int64_t) : {
503 *(int64_t*)_buf = *(int32_t*)(__sqlvar->sqldata);
504 break;
505 }
506 default: {
507 *_size = sizeof(int32_t);
509 return false;
510 }
511 }
512 break;
513 }
514 case SQL_INT64: {
515 switch (*_size) {
516 case sizeof(int64_t) : {
517 *(int64_t*)_buf = *(int64_t*)(__sqlvar->sqldata);
518 break;
519 }
520 default: {
521 *_size = sizeof(int64_t);
523 return false;
524 }
525 }
526 break;
527 }
528 default: {
529 __DCL_ASSERT(false); // IBField::init bug
530 }
531 }
532 }
533 else {
534 // decimal
535 __INT_TYPE n;
536 switch(__sqlvar->sqltype & ~1) {
537 case SQL_SHORT: {
538 n.i16 = (int16_t)(
539 (*(int16_t*)(__sqlvar->sqldata))
540 / __divider32[-(__sqlvar->sqlscale)]
541 );
542 switch (*_size) {
543 case sizeof(int8_t) : {
544 if (n.i16 < INT8_MIN || INT8_MAX < n.i16) {
546 return false;
547 }
548 *(int8_t*)_buf = (int8_t)n.i16;
549 break;
550 }
551 case sizeof(int16_t) : {
552 *(int16_t*)_buf = n.i16;
553 break;
554 }
555 case sizeof(int32_t) : {
556 *(int32_t*)_buf = (int32_t)n.i16;
557 break;
558 }
559 case sizeof(int64_t) : {
560 *(int64_t*)_buf = (int64_t)n.i16;
561 break;
562 }
563 default: {
564 *_size = sizeof(int16_t);
566 return false;
567 }
568 }
569 break;
570 }
571 case SQL_LONG: {
572 n.i32 = (int32_t)(
573 (*(int32_t*)(__sqlvar->sqldata))
574 / __divider32[-(__sqlvar->sqlscale)]
575 );
576 switch (*_size) {
577 case sizeof(int8_t) : {
578 if (n.i32 < INT8_MIN || INT8_MAX < n.i32) {
580 return false;
581 }
582 *(int8_t*)_buf = (int8_t)n.i32;
583 break;
584 }
585 case sizeof(int16_t) : {
586 if (n.i32 < INT16_MIN || INT16_MAX < n.i32) {
588 return false;
589 }
590 *(int16_t*)_buf = (int16_t)n.i32;
591 break;
592 }
593 case sizeof(int32_t) : {
594 *(int32_t*)_buf = n.i32;
595 break;
596 }
597 case sizeof(int64_t) : {
598 *(int64_t*)_buf = (int64_t)n.i32;
599 break;
600 }
601 default: {
602 *_size = sizeof(int32_t);
604 return false;
605 }
606 }
607 break;
608 }
609 case SQL_INT64: {
610 n.i64 = *(int64_t*)(__sqlvar->sqldata)
611 / __divider64[-(__sqlvar->sqlscale)];
612 switch (*_size) {
613 case sizeof(int8_t) : {
614 if (n.i64 < INT8_MIN || INT8_MAX < n.i64) {
616 return false;
617 }
618 *(int8_t*)_buf = (int8_t)n.i64;
619 break;
620 }
621 case sizeof(int16_t) : {
622 if (n.i64 < INT16_MIN || INT16_MAX < n.i64) {
624 return false;
625 }
626 *(int16_t*)_buf = (int16_t)n.i64;
627 break;
628 }
629 case sizeof(int32_t) : {
630 if (n.i64 < INT32_MIN || INT32_MAX < n.i64) {
632 return false;
633 }
634 *(int32_t*)_buf = (int32_t)n.i64;
635 break;
636 }
637 case sizeof(int64_t) : {
638 *(int64_t*)_buf = n.i64;
639 break;
640 }
641 default: {
642 *_size = sizeof(int64_t);
644 return false;
645 }
646 }
647 break;
648 }
649 default: {
650 __DCL_ASSERT(false); // IBField::init bug
651 }
652 }
653 }
654 return true;
655}
656
657bool IBField::getUInteger(void* _buf, size_t* _size)
658{
659 if (__sqlvar->sqlscale == 0) {
660 // integer
661 switch(__sqlvar->sqltype & ~1) {
662 case SQL_BOOLEAN: {
663 switch (*_size) {
664 case sizeof(uint8_t) : {
665 *(uint8_t*)_buf = *(uint8_t*)(__sqlvar->sqldata);
666 break;
667 }
668 case sizeof(uint16_t) : {
669 *(uint16_t*)_buf = *(uint8_t*)(__sqlvar->sqldata);
670 break;
671 }
672 case sizeof(uint32_t) : {
673 *(uint32_t*)_buf = *(uint8_t*)(__sqlvar->sqldata);
674 break;
675 }
676 case sizeof(uint64_t) : {
677 *(uint64_t*)_buf = *(uint8_t*)(__sqlvar->sqldata);
678 break;
679 }
680 default: {
681 *_size = sizeof(uint8_t);
683 return false;
684 }
685 }
686 break;
687 }
688 case SQL_SHORT: {
689 switch (*_size) {
690 case sizeof(uint16_t) : {
691 *(uint16_t*)_buf = *(int16_t*)(__sqlvar->sqldata);
692 break;
693 }
694 case sizeof(uint32_t) : {
695 *(uint32_t*)_buf = *(int16_t*)(__sqlvar->sqldata);
696 break;
697 }
698 case sizeof(uint64_t) : {
699 *(uint64_t*)_buf = *(int16_t*)(__sqlvar->sqldata);
700 break;
701 }
702 default: {
703 *_size = sizeof(uint16_t);
705 return false;
706 }
707 }
708 break;
709 }
710 case SQL_LONG: {
711 switch (*_size) {
712 case sizeof(uint32_t) : {
713 *(uint32_t*)_buf = *(int32_t*)(__sqlvar->sqldata);
714 break;
715 }
716 case sizeof(int64_t) : {
717 *(uint64_t*)_buf = *(int32_t*)(__sqlvar->sqldata);
718 break;
719 }
720 default: {
721 *_size = sizeof(uint32_t);
723 return false;
724 }
725 }
726 break;
727 }
728 case SQL_INT64: {
729 switch (*_size) {
730 case sizeof(uint64_t) : {
731 *(uint64_t*)_buf = *(int64_t*)(__sqlvar->sqldata);
732 break;
733 }
734 default: {
735 *_size = sizeof(uint64_t);
737 return false;
738 }
739 }
740 break;
741 }
742 default: {
743 __DCL_ASSERT(false); // IBField::init bug
744 }
745 }
746 }
747 else {
748 // decimal
749 __INT_TYPE n;
750 switch(__sqlvar->sqltype & ~1) {
751 case SQL_SHORT: {
752 n.i16 = (int16_t)(
753 (*(int16_t*)(__sqlvar->sqldata))
754 / __divider32[-(__sqlvar->sqlscale)]
755 );
756 switch (*_size) {
757 case sizeof(int8_t) : {
758 if (n.i16 < INT8_MIN || INT8_MAX < n.i16) {
760 return false;
761 }
762 *(uint8_t*)_buf = (uint8_t)n.i16;
763 break;
764 }
765 case sizeof(int16_t) : {
766 *(uint16_t*)_buf = (uint16_t)n.i16;
767 break;
768 }
769 case sizeof(int32_t) : {
770 *(uint32_t*)_buf = (uint32_t)n.i16;
771 break;
772 }
773 case sizeof(int64_t) : {
774 *(uint64_t*)_buf = (uint64_t)n.i16;
775 break;
776 }
777 default: {
778 *_size = sizeof(uint16_t);
780 return false;
781 }
782 }
783 break;
784 }
785 case SQL_LONG: {
786 n.i32 = (int32_t)(
787 (*(int32_t*)(__sqlvar->sqldata))
788 / __divider32[-(__sqlvar->sqlscale)]
789 );
790 switch (*_size) {
791 case sizeof(int8_t) : {
792 if (n.i32 < INT8_MIN || INT8_MAX < n.i32) {
794 return false;
795 }
796 *(uint8_t*)_buf = (uint8_t)n.i32;
797 break;
798 }
799 case sizeof(int16_t) : {
800 if (n.i32 < INT16_MIN || INT16_MAX < n.i32) {
802 return false;
803 }
804 *(uint16_t*)_buf = (uint16_t)n.i32;
805 break;
806 }
807 case sizeof(int32_t) : {
808 *(uint32_t*)_buf = (uint32_t)n.i32;
809 break;
810 }
811 case sizeof(int64_t) : {
812 *(uint64_t*)_buf = (uint64_t)n.i32;
813 break;
814 }
815 default: {
816 *_size = sizeof(uint32_t);
818 return false;
819 }
820 }
821 break;
822 }
823 case SQL_INT64: {
824 n.i64 = *(int64_t*)(__sqlvar->sqldata)
825 / __divider64[-(__sqlvar->sqlscale)];
826 switch (*_size) {
827 case sizeof(int8_t) : {
828 if (n.i64 < INT8_MIN || INT8_MAX < n.i64) {
830 return false;
831 }
832 *(uint8_t*)_buf = (uint8_t)n.i64;
833 break;
834 }
835 case sizeof(int16_t) : {
836 if (n.i64 < INT16_MIN || INT16_MAX < n.i64) {
838 return false;
839 }
840 *(uint16_t*)_buf = (uint16_t)n.i64;
841 break;
842 }
843 case sizeof(int32_t) : {
844 if (n.i64 < INT32_MIN || INT32_MAX < n.i64) {
846 return false;
847 }
848 *(uint32_t*)_buf = (uint32_t)n.i64;
849 break;
850 }
851 case sizeof(int64_t) : {
852 *(uint64_t*)_buf = (uint64_t)n.i64;
853 break;
854 }
855 default: {
856 *_size = sizeof(int64_t);
858 return false;
859 }
860 }
861 break;
862 }
863 default: {
864 __DCL_ASSERT(false); // IBField::init bug
865 }
866 }
867 }
868 return true;
869}
870
871bool IBField::getFloat(void* _buf, size_t* _size)
872{
873 switch(__sqlvar->sqltype & ~1) {
874 case SQL_FLOAT: {
875 switch (*_size) {
876 case sizeof(float) : {
877 *(float*)_buf =
878 *(float*)(__sqlvar->sqldata);
879 break;
880 }
881 case sizeof(double) : {
882 *(double*)_buf = *(float*)(__sqlvar->sqldata);
883 break;
884 }
885 default: {
886 *_size = sizeof(float);
888 return false;
889 }
890 }
891 break;
892 }
893 case SQL_DOUBLE: {
894 switch (*_size) {
895 case sizeof(double) : {
896 *(double*)_buf = *(double*)(__sqlvar->sqldata);
897 break;
898 }
899 default: {
900 *_size = sizeof(double);
902 return false;
903 }
904 }
905 break;
906 }
907 case SQL_SHORT: {
908 __DCL_ASSERT(Field::__dataType == SQL::typeNumeric);
909 __DCL_ASSERT(__sqlvar->sqlscale < 0);
910 switch (*_size) {
911 case sizeof(float) : {
912 *(float*)_buf =
913 (float)(*(int16_t*)(__sqlvar->sqldata))
914 / (float)__divider32[-(__sqlvar->sqlscale)];
915 break;
916 }
917 case sizeof(double) : {
918 *(double*)_buf = (double)(*(int16_t*)(__sqlvar->sqldata))
919 / (double)__divider32[-(__sqlvar->sqlscale)];
920 break;
921 }
922 default: {
923 *_size = sizeof(float);
925 return false;
926 }
927 }
928 break;
929 }
930 case SQL_LONG: {
931 __DCL_ASSERT(Field::__dataType == SQL::typeNumeric);
932 __DCL_ASSERT(__sqlvar->sqlscale < 0);
933 switch (*_size) {
934 case sizeof(float) : {
935 *(float*)_buf =
936 (float)(*(int32_t*)(__sqlvar->sqldata))
937 / (float)__divider32[-(__sqlvar->sqlscale)];
938 break;
939 }
940 case sizeof(double) : {
941 *(double*)_buf = (double)(*(int32_t*)(__sqlvar->sqldata))
942 / (double)__divider32[-(__sqlvar->sqlscale)];
943 break;
944 }
945 default: {
946 *_size = sizeof(double);
948 return false;
949 }
950 }
951 break;
952 }
953 case SQL_INT64: {
954 __DCL_ASSERT(Field::__dataType == SQL::typeNumeric);
955 __DCL_ASSERT(__sqlvar->sqlscale < 0);
956 switch (*_size) {
957 case sizeof(float) : {
958 *(float*)_buf =
959 (float)(*(int64_t*)(__sqlvar->sqldata))
960 / (float)__divider32[-(__sqlvar->sqlscale)];
961 break;
962 }
963 case sizeof(double) : {
964 *(double*)_buf = (double)(*(int64_t*)(__sqlvar->sqldata))
965 / (double)__divider64[-(__sqlvar->sqlscale)];
966 break;
967 }
968 default: {
969 *_size = sizeof(double);
971 return false;
972 }
973 }
974 break;
975 }
976 default: {
977 __DCL_ASSERT(false); // IBField::init bug
978 }
979 }
980 return true;
981}
982
983bool IBField::getDate(SQL::Date* _buf, size_t* _size)
984{
985 if (*_size != sizeof(SQL::Date)) {
987 return false;
988 }
989
990 struct tm tm;
991
992 switch(__sqlvar->sqltype & ~1) {
993#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
994 case SQL_TIMESTAMP_TZ_EX:
995#endif
996 case SQL_TIMESTAMP:
997 case SQL_TYPE_DATE: {
998 isc_decode_sql_date((ISC_DATE*)(__sqlvar->sqldata), &tm);
999 break;
1000 }
1001#if 0
1002 case SQL_TIMESTAMP: {
1003 isc_decode_timestamp((ISC_TIMESTAMP*)(__sqlvar->sqldata), &tm);
1004 break;
1005 }
1006#endif
1007 default: {
1008 __DCL_ASSERT(false); // IBField::init bug
1009 }
1010 }
1011
1012 _buf->year = tm.tm_year + 1900;
1013 _buf->month = tm.tm_mon + 1;
1014 _buf->day = tm.tm_mday;
1015 return true;
1016}
1017
1018bool IBField::getTime(SQL::Time* _buf, size_t* _size)
1019{
1020 if (*_size != sizeof(SQL::Time)) {
1022 return false;
1023 }
1024
1025 struct tm tm;
1026 ISC_TIME t = 0;
1027
1028 _buf->tzoff = INT16_MIN;
1029
1030 switch(__sqlvar->sqltype & ~1) {
1031#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
1032 case SQL_TIME_TZ_EX: {
1033 _buf->tzoff = ((ISC_TIME_TZ_EX*)(__sqlvar->sqldata))->ext_offset;
1034 }
1035#endif
1036 case SQL_TYPE_TIME: {
1037 isc_decode_sql_time((ISC_TIME*)(__sqlvar->sqldata), &tm);
1038 t = *(ISC_TIME*)(__sqlvar->sqldata);
1039 break;
1040 }
1041#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
1042 case SQL_TIMESTAMP_TZ_EX: {
1043 _buf->tzoff = ((ISC_TIMESTAMP_TZ_EX*)(__sqlvar->sqldata))->ext_offset;
1044 }
1045#endif
1046 case SQL_TIMESTAMP: {
1047 isc_decode_timestamp((ISC_TIMESTAMP*)(__sqlvar->sqldata), &tm);
1048 t = ((ISC_TIMESTAMP*)(__sqlvar->sqldata))->timestamp_time;
1049 break;
1050 }
1051 default: {
1052 __DCL_ASSERT(false); // IBField::init bug
1053 }
1054 }
1055
1056 _buf->hour = tm.tm_hour;
1057 _buf->min = tm.tm_min;
1058 _buf->sec = tm.tm_sec;
1059// #define ISC_TIME_SECONDS_PRECISION 10000
1060// #define ISC_TIME_SECONDS_PRECISION_SCALE (-4)
1061 _buf->frac = (t % ISC_TIME_SECONDS_PRECISION) * 100000;
1062
1063 return true;
1064}
1065
1066bool IBField::getTimeStamp(SQL::TimeStamp* _buf, size_t* _size)
1067{
1068 if (*_size != sizeof(SQL::TimeStamp)) {
1070 return false;
1071 }
1072
1073 struct tm tm;
1074 ISC_TIME t = 0;
1075
1076 _buf->tzoff = INT16_MIN;
1077
1078 switch(__sqlvar->sqltype & ~1) {
1079 case SQL_TYPE_DATE : {
1080 isc_decode_sql_date((ISC_DATE*)(__sqlvar->sqldata), &tm);
1081 break;
1082 }
1083#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
1084 case SQL_TIME_TZ_EX: {
1085 _buf->tzoff = ((ISC_TIME_TZ_EX*)(__sqlvar->sqldata))->ext_offset;
1086 }
1087#endif
1088 case SQL_TYPE_TIME: {
1089 isc_decode_sql_time((ISC_TIME*)(__sqlvar->sqldata), &tm);
1090 t = *(ISC_TIME*)(__sqlvar->sqldata);
1091 break;
1092 }
1093#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
1094 case SQL_TIMESTAMP_TZ_EX: {
1095 _buf->tzoff = ((ISC_TIMESTAMP_TZ_EX*)(__sqlvar->sqldata))->ext_offset;
1096 }
1097#endif
1098 case SQL_TIMESTAMP: {
1099 isc_decode_timestamp((ISC_TIMESTAMP*)(__sqlvar->sqldata), &tm);
1100 t = ((ISC_TIMESTAMP*)(__sqlvar->sqldata))->timestamp_time;
1101 break;
1102 }
1103 default: {
1104 __DCL_ASSERT(false); // IBField::init bug
1105 }
1106 }
1107
1108 _buf->year = tm.tm_year + 1900;
1109 _buf->month = tm.tm_mon + 1;
1110 _buf->day = tm.tm_mday;
1111 _buf->hour = tm.tm_hour;
1112 _buf->min = tm.tm_min;
1113 _buf->sec = tm.tm_sec;
1114// #define ISC_TIME_SECONDS_PRECISION 10000
1115// #define ISC_TIME_SECONDS_PRECISION_SCALE (-4)
1116 _buf->frac = (t % ISC_TIME_SECONDS_PRECISION) * 100000;
1117
1118 return true;
1119}
1120
1121inline unsigned int __ABS(int _n)
1122{
1123 return _n < 0 ? -_n : _n;
1124}
1125
1126static size_t __get_decimal_length(void* _buf, short _sqltype, short _sqlscale)
1127{
1128 unsigned int scale = _sqlscale < 0 ? -_sqlscale : _sqlscale;
1129 int64_t n = 0;
1130 switch (_sqltype & ~1) {
1131 case SQL_SHORT: {
1132 n = (int32_t) * (short*)_buf;
1133 break;
1134 }
1135 case SQL_LONG: {
1136 n = *(int32_t*)_buf;
1137 break;
1138 }
1139 case SQL_INT64: {
1140 n = *(int64_t*)_buf;
1141 break;
1142 }
1143 default: {
1144 __DCL_ASSERT(false);
1145 }
1146 }
1147 int64_t u = n < 0 ? -n : n;
1148 unsigned int count = 1;
1149 while ((u /= 10)) count++;
1150 // 음수인 경우 부호 '-' 1
1151 // scale < count 인 경우 소숫점 '.' 1
1152 // scale >= count 이면 '0.' + (scale - count)
1153 return count + (n < 0 ? 1 : 0) + (scale < count ? 1 : (scale - count + 2));
1154}
1155
1156static ByteString __get_decimal_string(void* _buf, short _sqltype, short _sqlscale)
1157{
1158 __DCL_ASSERT(_sqlscale < 0);
1159 int64_t n = 0;
1160 switch (_sqltype & ~1) {
1161 case SQL_SHORT: {
1162 n = (int32_t) * (short*)_buf;
1163 break;
1164 }
1165 case SQL_LONG: {
1166 n = *(int32_t*)_buf;
1167 break;
1168 }
1169 case SQL_INT64: {
1170 n = *(int64_t*)_buf;
1171 break;
1172 }
1173 default: {
1174 __DCL_ASSERT(false);
1175 }
1176 }
1177 int64_t u = n < 0 ? -n : n;
1178 ByteString num = UInt64::toByteString(u);
1179 ByteStringBuilder sb;
1180 if (n < 0) {
1181 sb.append('-');
1182 }
1183 if (num.length() <= __ABS(_sqlscale)) {
1184 ByteString pad('0', __ABS((int) num.length() + _sqlscale - 1));
1185 sb.append(pad);
1186 }
1187 sb.append(num);
1188 sb.insert(sb.length() + _sqlscale, '.');
1189
1190 return sb.toByteString();
1191}
1192
1193bool IBField::getDecimal(char* _buf, size_t* _size)
1194{
1195 __DCL_ASSERT(__sqlvar->sqlscale != 0);
1196 ByteString r = __get_decimal_string(
1197 __sqlvar->sqldata,
1198 __sqlvar->sqltype,
1199 __sqlvar->sqlscale
1200 );
1201 if (*_size < (size_t)r.length()) {
1202 __DCL_TRACE3_N(L"_size[%zd] r[%zd][%hs]\n",
1203 *_size, r.length(), r.data());
1205 return false;
1206 }
1207 strncpy(_buf, r.data(), r.length());
1208 if (*_size > (size_t)r.length()) {
1209 *_size = (size_t)r.length();
1210 _buf[*_size] = '\0';
1211 }
1212
1213 return true;
1214}
1215
1216bool IBField::getBytes(byte_t* _buf, size_t* _size)
1217{
1218 if (__SQLTYPE_IS(SQL_TEXT) || __SQLTYPE_IS(SQL_VARYING)) {
1219 char* pSrc = (char*)(__sqlvar->sqldata);
1220 size_t nCopy = (size_t)(__sqlvar->sqllen);
1221 if (__SQLTYPE_IS(SQL_VARYING)) {
1222 pSrc += sizeof(short);
1223 nCopy = (size_t)(*(short*)pSrc);
1224 }
1225
1226 if (nCopy > *_size)
1227 nCopy = *_size;
1228
1229 if (nCopy) {
1230 memcpy(_buf, pSrc, nCopy);
1231 if (nCopy < *_size)
1232 *(_buf + nCopy) = '\0';
1233 }
1234 *_size = nCopy;
1235 }
1236 else if (__SQLTYPE_IS(SQL_BLOB)) {
1237 if (*_size)
1238 return getBytesFromBlob(_buf, _size);
1239 }
1240 else {
1241 __DCL_ASSERT(false); // IBField::init bug
1242 }
1243
1244 return true;
1245}
1246
1247bool IBField::writeTo(OutputStream* _buf, size_t* _size)
1248{
1249 if (__SQLTYPE_IS(SQL_TEXT) || __SQLTYPE_IS(SQL_VARYING)) {
1250 char* pSrc = (char*)(__sqlvar->sqldata);
1251 size_t nCopy = (size_t)(__sqlvar->sqllen);
1252 if (__SQLTYPE_IS(SQL_VARYING)) {
1253 pSrc += sizeof(short);
1254 nCopy = (size_t)(*(short*)pSrc);
1255 }
1256
1257 if (nCopy > *_size)
1258 nCopy = *_size;
1259
1260 if (nCopy) {
1261 try {
1262 _buf->write(pSrc, nCopy);
1263 }
1264 catch(IOException* e) {
1265 __SET_ERROR_MSG(UTF8Encoder::encode(e->toStringAll()));
1266 e->destroy();
1267 return false;
1268 }
1269 }
1270 *_size = nCopy;
1271 }
1272 else if (__SQLTYPE_IS(SQL_BLOB)) {
1273 if (*_size)
1274 return writeToFromBlob(_buf, _size);
1275 }
1276 else {
1277 __DCL_ASSERT(false); // IBField::init bug
1278 }
1279
1280 return true;
1281}
1282
1283/*
1284static char blob_info_items[] = {
1285 isc_info_blob_num_segments,
1286 isc_info_blob_max_segment,
1287 isc_info_blob_total_length,
1288 isc_info_end
1289};
1290*/
1291
1293 isc_blob_handle* _blobHandle,
1294 char _blob_info_item, size_t* _buf
1295)
1296{
1297 char res_buffer[10]; // 1 + 2 + 4 == 7
1298 if (isc_blob_info(
1299 conn()->statusVector(),
1300 _blobHandle,
1301 sizeof(_blob_info_item),
1302 &_blob_info_item,
1303 sizeof(res_buffer),
1304 res_buffer
1305 )) {
1307 return false;
1308 }
1309
1310 char* p = res_buffer;
1311 __DCL_ASSERT(*p == _blob_info_item);
1312 p++;
1313 unsigned short length = (unsigned short)isc_vax_integer(p, 2);
1314 p += 2;
1315 *_buf = isc_vax_integer(p, length);
1316
1317 return true;
1318}
1319
1320inline size_t __MIN(size_t x, size_t y)
1321{
1322 return x < y ? x : y;
1323}
1324
1325bool IBField::getBytesFromBlob(byte_t* _buf, size_t* _size)
1326{
1327 isc_blob_handle hBlob = NULL_HANDLE;
1328 ISC_QUAD* pBlobID = (ISC_QUAD*)(__sqlvar->sqldata);
1329
1330 if(isc_open_blob2(
1331 conn()->statusVector(),
1332 conn()->dbHandlePtr(),
1333 conn()->trHandlePtr(),
1334 &hBlob,
1335 pBlobID,
1336 0,
1337 NULL
1338 )) {
1340 return false;
1341 }
1342
1343 size_t nMaxSegment = 0;
1344 if(!getBlobInfo(&hBlob, isc_info_blob_max_segment, &nMaxSegment)) {
1345 ISC_STATUS status2[ISC_STATUS_VECTOR_LENGTH];
1346 isc_close_blob(status2, &hBlob);
1347
1349 return false;
1350 }
1351
1352 size_t nRemain = *_size;
1353 unsigned short nRead = 0;
1354 unsigned short nActualRead = 0;
1355 char* pch = (char*)_buf;
1356 ISC_STATUS rs = 0;
1357 while(nRemain) {
1358 nRead = (unsigned short) __MIN(nRemain, nMaxSegment);
1359 rs = isc_get_segment(
1360 conn()->statusVector(),
1361 &hBlob,
1362 &nActualRead,
1363 nRead,
1364 pch
1365 );
1366
1367// if (nActualRead == 0) // 혹여나...
1368// break;
1369
1370 if (rs)
1371 break;
1372/*
1373 if ((rs != 0) && (conn()->statusVector()[1] != isc_segment))
1374 break;
1375*/
1376 nRemain -= nActualRead;
1377 pch += nActualRead;
1378 }
1379
1380 if ((conn()->statusVector()[0])
1381 && (conn()->statusVector()[1])
1382 && (conn()->statusVector()[1] != isc_segstr_eof)
1383 ) {
1384 ISC_STATUS status2[ISC_STATUS_VECTOR_LENGTH];
1385 isc_close_blob(status2, &hBlob);
1386
1387 // 심각한 오류 !
1389 return false;
1390 }
1391
1392 if (isc_close_blob(conn()->statusVector(), &hBlob)) {
1394 return false;
1395 }
1396
1397 *_size -= nRemain;
1398
1399 return true;
1400}
1401
1402bool IBField::writeToFromBlob(OutputStream* _output, size_t* _size)
1403{
1404 isc_blob_handle hBlob = NULL_HANDLE;
1405 ISC_QUAD* pBlobID = (ISC_QUAD*)(__sqlvar->sqldata);
1406
1407 if(isc_open_blob2(
1408 conn()->statusVector(),
1409 conn()->dbHandlePtr(),
1410 conn()->trHandlePtr(),
1411 &hBlob,
1412 pBlobID,
1413 0,
1414 NULL
1415 )) {
1417 return false;
1418 }
1419
1420 size_t nMaxSegment = 0;
1421 if(!getBlobInfo(&hBlob, isc_info_blob_max_segment, &nMaxSegment)) {
1422 ISC_STATUS status2[ISC_STATUS_VECTOR_LENGTH];
1423 isc_close_blob(status2, &hBlob);
1424
1426 return false;
1427 }
1428
1429 char* _buf = (char*)malloc(nMaxSegment);
1430 if (!_buf) {
1432 ISC_STATUS status2[ISC_STATUS_VECTOR_LENGTH];
1433 isc_close_blob(status2, &hBlob);
1434 return false;
1435 }
1436
1437 ISC_STATUS rs = 0;
1438 size_t nRemain = *_size;
1439 unsigned short nActualRead = 0;
1440 unsigned short nRead = 0;
1441
1442 while(nRemain) {
1443 nRead = (unsigned short) __MIN(nRemain, nMaxSegment);
1444 rs = isc_get_segment(
1445 conn()->statusVector(),
1446 &hBlob,
1447 &nActualRead,
1448 nRead,
1449 _buf
1450 );
1451
1452 if (nActualRead) {
1453 try {
1454 _output->write(_buf, nActualRead);
1455 }
1456 catch(IOException* e) {
1457 __SET_ERROR_MSG(UTF8Encoder::encode(e->toStringAll()));
1458 e->destroy();
1459 free(_buf);
1460 ISC_STATUS status2[ISC_STATUS_VECTOR_LENGTH];
1461 isc_close_blob(status2, &hBlob);
1462 return false;
1463 }
1464 nRemain -= nActualRead;
1465 }
1466
1467 if (rs)
1468 break;
1469 }
1470 *_size -= nRemain;
1471
1472 free(_buf);
1473
1474 if ((conn()->statusVector()[0])
1475 && (conn()->statusVector()[1])
1476 && (conn()->statusVector()[1] != isc_segstr_eof)
1477 ) {
1478 ISC_STATUS status2[ISC_STATUS_VECTOR_LENGTH];
1479 isc_close_blob(status2, &hBlob);
1480
1481 // 심각한 오류 !
1483 return false;
1484 }
1485
1486 if (isc_close_blob(conn()->statusVector(), &hBlob)) {
1488 return false;
1489 }
1490
1491 return true;
1492}
1493
1494__DCL_END_NAMESPACE
#define __THIS_FILE__
Definition _trace.h:14
#define NULL
Definition Config.h:312
#define INT32_MAX
Definition Config.h:290
wchar_t char_t
Definition Config.h:247
#define INT32_MIN
Definition Config.h:285
unsigned char byte_t
Definition Config.h:246
#define INT8_MIN
Definition Config.h:283
#define INT8_MAX
Definition Config.h:288
#define INT16_MAX
Definition Config.h:289
#define INT16_MIN
Definition Config.h:284
#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
#define ISC_STATUS_VECTOR_LENGTH
#define NULL_HANDLE
const wchar_t * __dataTypeName(const XSQLVAR *_sqlvar)
Definition IBField.cpp:240
size_t __MIN(size_t x, size_t y)
Definition IBField.cpp:1320
#define SQLTYPE_NAME(_dataType, name)
Definition IBField.cpp:238
const wchar_t * __dataTypeName(const XSQLVAR *_sqlvar)
Definition IBField.cpp:240
#define __SET_ERROR_MSG(_message)
#define __SQLTYPE_IS(_sqltype)
Definition IFXField.cpp:68
IOException *size_t r
Definition MediaInfo.cpp:82
#define __ABS(n)
Definition MyParam.cpp:145
#define __DCL_ASSERT(expr)
Definition Object.h:394
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
Definition Object.h:245
#define __T(str)
Definition Object.h:60
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:149
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
bool getBlobInfo(isc_blob_handle *_blobHandle, char _blob_info_item, size_t *_buf)
Definition IBField.cpp:1292
bool getInteger(void *_buf, size_t *_size)
Definition IBField.cpp:443
bool onAfterFetch()
Definition IBField.cpp:197
bool getDecimal(char *_buf, size_t *_size)
Definition IBField.cpp:1193
bool writeToFromBlob(OutputStream *_output, size_t *_size)
Definition IBField.cpp:1402
bool getUInteger(void *_buf, size_t *_size)
Definition IBField.cpp:657
bool writeTo(OutputStream *_output, size_t *_size)
Definition IBField.cpp:1247
virtual bool __getDataSize(size_t *_size, bool _maxsize)
Definition IBField.cpp:288
bool getBytesFromBlob(byte_t *_buf, size_t *_size)
Definition IBField.cpp:1325
bool getBytes(byte_t *_buf, size_t *_size)
Definition IBField.cpp:1216
bool init(SQL::Query *_query, XSQLVAR *_sqlvar)
Definition IBField.cpp:69
virtual ~IBField()
Definition IBField.cpp:64
bool getTimeStamp(SQL::TimeStamp *_buf, size_t *_size)
Definition IBField.cpp:1066
bool getTime(SQL::Time *_buf, size_t *_size)
Definition IBField.cpp:1018
IBQuery * query() const
Definition IBField.h:57
bool getFloat(void *_buf, size_t *_size)
Definition IBField.cpp:871
virtual const wchar_t * serverDataTypeName() const
Definition IBField.cpp:283
bool getDate(SQL::Date *_buf, size_t *_size)
Definition IBField.cpp:983
IBConnection * conn() const
Definition IBField.h:62
virtual bool __getData(void *_buf, size_t *_size, SQL::DataType _bufType)
Definition IBField.cpp:326
Query * __queryHandle
Definition SQLCore.h:186
DataType
Definition SQLCore.h:59
@ typeBinary
Definition SQLCore.h:74
@ typeNumeric
Definition SQLCore.h:64
@ typeTime
Definition SQLCore.h:66
@ typeLongBinary
Definition SQLCore.h:76
@ typeUInteger
Definition SQLCore.h:62
@ typeTimeStamp
Definition SQLCore.h:68
@ typeTimeStampTz
Definition SQLCore.h:69
@ typeInterval
Definition SQLCore.h:70
@ typeDate
Definition SQLCore.h:65
@ typeOutputStream
Definition SQLCore.h:82
@ typeText
Definition SQLCore.h:73
@ typeTimeTz
Definition SQLCore.h:67
@ typeFloat
Definition SQLCore.h:63
@ typeInteger
Definition SQLCore.h:61
@ typeLongText
Definition SQLCore.h:75
@ eOutOfRange
Definition SQLCore.h:52
@ eOutOfMemory
Definition SQLCore.h:24
@ eNotExecuted
Definition SQLCore.h:42
@ eInvalidBufferSize
Definition SQLCore.h:50
@ eNotSupportDataType
Definition SQLCore.h:48
@ eServerError
Definition SQLCore.h:21
@ eNotFetched
Definition SQLCore.h:43
static ByteString toByteString(uint64_t _u, unsigned _base=10)
Definition Numeric.cpp:692
size_t __MIN(size_t x, size_t y)
Definition size_t.h:27
int16_t year
Definition SQLCore.h:96
uint8_t month
Definition SQLCore.h:97
uint8_t day
Definition SQLCore.h:98
uint8_t hour
Definition SQLCore.h:103
uint8_t sec
Definition SQLCore.h:105
uint32_t frac
Definition SQLCore.h:106
uint8_t min
Definition SQLCore.h:104
int16_t tzoff
Definition SQLCore.h:107
uint32_t frac
Definition SQLCore.h:118
int16_t tzoff
Definition SQLCore.h:119
uint8_t min
Definition SQLCore.h:116
uint8_t sec
Definition SQLCore.h:117
uint8_t hour
Definition SQLCore.h:115
uint8_t day
Definition SQLCore.h:114
int16_t year
Definition SQLCore.h:112
uint8_t month
Definition SQLCore.h:113
int32_t i32
Definition IBField.cpp:439
int16_t i16
Definition IBField.cpp:438
int64_t i64
Definition IBField.cpp:440