61 Field::__queryHandle = _queryHandle;
65 Field::__name = UTF8Decoder::decode(__sqlvar->sqlname.data,
66 __sqlvar->sqlname.length).toUpperCase();
74 switch (__sqlvar->sqltype) {
77 __maxDataSize =
sizeof(int16_t);
80 case ECPGt_unsigned_short: {
82 __maxDataSize =
sizeof(int16_t);
87 __maxDataSize =
sizeof(int32_t);
90 case ECPGt_unsigned_int: {
92 __maxDataSize =
sizeof(int32_t);
98 __maxDataSize =
sizeof(int64_t);
100 __maxDataSize =
sizeof(int32_t);
104 case ECPGt_unsigned_long: {
107 __maxDataSize =
sizeof(int64_t);
109 __maxDataSize =
sizeof(int32_t);
113 case ECPGt_long_long: {
115 __maxDataSize =
sizeof(int64_t);
118 case ECPGt_unsigned_long_long: {
120 __maxDataSize =
sizeof(int64_t);
125 __maxDataSize =
sizeof(bool);
130 __maxDataSize =
sizeof(float);
135 __maxDataSize =
sizeof(double);
139 case ECPGt_decimal: {
152 case ECPGt_timestamp: {
157 case ECPGt_interval: {
163 case ECPGt_unsigned_char:
165 case ECPGt_varchar2: {
290 (
const timestamp*)(__sqlvar->sqldata),
298 (
const interval*)(__sqlvar->sqldata),
306 if (__sqlvar->sqltype == ECPGt_decimal) {
307 if (PGTYPESnumeric_from_decimal(
308 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
314 else if (__sqlvar->sqltype == ECPGt_numeric) {
315 p = (numeric*)(__sqlvar->sqldata);
320 __DCL_TRACE4(L
"ndigits[%d] weight[%d] rscale[%d] dscale[%d]\n",
321 p->ndigits, p->weight, p->rscale, p->dscale);
323 String::tryString((
const char*)(p->digits), p->ndigits).data()
326 char* s = PGTYPESnumeric_to_asc(p, p->dscale);
327 size_t l = ByteString::length(s);
345 switch (__sqlvar->sqltype) {
347 case ECPGt_unsigned_char:
351 if (__sqlvar->sqllen > 0 && *_size > 0) {
352 size_t nCopy = *_size;
353 if ((
size_t)(__sqlvar->sqllen) < nCopy)
354 nCopy = (size_t)(__sqlvar->sqllen);
356 memcpy(_buf, __sqlvar->sqldata, nCopy);
357 if (nCopy < *_size) {
358 *((
char*)_buf + nCopy) =
'\0';
372 switch (__sqlvar->sqltype) {
374 case ECPGt_unsigned_char:
378 if ((
size_t)(__sqlvar->sqllen) < *_size) {
379 *_size = (size_t)(__sqlvar->sqllen);
407 switch (__sqlvar->sqltype) {
410 case sizeof(int16_t) : {
411 *(int16_t*)_buf = *(int16_t*)(__sqlvar->sqldata);
414 case sizeof(int32_t) : {
415 *(int32_t*)_buf = (int32_t) * (int16_t*)(__sqlvar->sqldata);
418 case sizeof(int64_t) : {
419 *(int64_t*)_buf = (int64_t) * (int16_t*)(__sqlvar->sqldata);
423 *_size =
sizeof(int16_t);
435 case sizeof(int32_t) : {
436 *(int32_t*)_buf = *(int32_t*)(__sqlvar->sqldata);
439 case sizeof(int64_t) : {
440 *(int64_t*)_buf = (int64_t) * (int32_t*)(__sqlvar->sqldata);
444 *_size =
sizeof(int32_t);
454 case ECPGt_long_long: {
455 if (*_size ==
sizeof(int64_t)) {
456 *(int64_t*)_buf = (int64_t) * (int64_t*)(__sqlvar->sqldata);
459 *_size =
sizeof(int64_t);
465 case ECPGt_unsigned_long_long: {
466 if (*_size ==
sizeof(int64_t)) {
467 *(int64_t*)_buf = (int64_t) * (uint64_t*)(__sqlvar->sqldata);
470 *_size =
sizeof(int64_t);
477 case ECPGt_decimal: {
479 if (*_size <=
sizeof(int32_t)) {
482 if (__sqlvar->sqltype == ECPGt_numeric) {
483 if (PGTYPESnumeric_to_long(
484 (numeric*)(__sqlvar->sqldata), &n) != 0) {
491 if (PGTYPESnumeric_from_decimal(
492 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
496 if (PGTYPESnumeric_to_long(&nu, &n) != 0) {
503 case sizeof(int8_t) : {
508 *(int8_t*)_buf = (int8_t)n;
511 case sizeof(int16_t) : {
516 *(int16_t*)_buf = (int16_t)n;
519 case sizeof(int32_t) : {
526 *(int32_t*)_buf = (int32_t)n;
529 case sizeof(int64_t) : {
530 *(int64_t*)_buf = (int64_t)n;
535 *_size =
sizeof(int32_t);
536#elif ALIGNOF_LONG == 8
537 *_size =
sizeof(int64_t);
545 else if (*_size ==
sizeof(int64_t)) {
546 numeric* p = (numeric*)(__sqlvar->sqldata);
548 if (__sqlvar->sqltype == ECPGt_decimal) {
549 if (PGTYPESnumeric_from_decimal(
550 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
556 char* s = PGTYPESnumeric_to_asc(p, 0);
558 long long n = strtoll(s, &endptr, 10);
560 if (n == LLONG_MAX || n == LLONG_MIN) {
567 *_size =
sizeof(int64_t);
582 switch(__sqlvar->sqltype) {
585 case sizeof(uint8_t) : {
586 *(uint8_t*)_buf = (uint8_t) * (uint8_t*)(__sqlvar->sqldata);
589 case sizeof(uint16_t) : {
590 *(uint16_t*)_buf = (uint16_t) * (uint8_t*)(__sqlvar->sqldata);
593 case sizeof(uint32_t) : {
594 *(uint32_t*)_buf = (uint32_t) * (uint8_t*)(__sqlvar->sqldata);
597 case sizeof(uint64_t) : {
598 *(uint64_t*)_buf = (uint64_t) * (uint8_t*)(__sqlvar->sqldata);
602 *_size =
sizeof(uint8_t);
611 case sizeof(uint16_t) : {
612 *(uint16_t*)_buf = (uint16_t) * (int16_t*)(__sqlvar->sqldata);
615 case sizeof(uint32_t) : {
616 *(uint32_t*)_buf = (uint32_t) * (int16_t*)(__sqlvar->sqldata);
619 case sizeof(uint64_t) : {
620 *(uint64_t*)_buf = (uint64_t) * (int16_t*)(__sqlvar->sqldata);
624 *_size =
sizeof(uint16_t);
634 case sizeof(uint32_t) : {
635 *(uint32_t*)_buf = (uint32_t) * (int32_t*)(__sqlvar->sqldata);
638 case sizeof(int64_t) : {
639 *(uint64_t*)_buf = (uint64_t) * (int32_t*)(__sqlvar->sqldata);
643 *_size =
sizeof(int32_t);
650 case ECPGt_long_long: {
651 if (*_size ==
sizeof(int64_t)) {
652 *(uint64_t*)_buf = (uint64_t) * (int64_t*)(__sqlvar->sqldata);
655 *_size =
sizeof(int64_t);
661 case ECPGt_unsigned_long_long: {
662 if (*_size ==
sizeof(int64_t)) {
663 *(uint64_t*)_buf = (uint64_t) * (uint64_t*)(__sqlvar->sqldata);
666 *_size =
sizeof(int64_t);
673 case ECPGt_decimal: {
674 if (*_size <=
sizeof(uint32_t)) {
676 if (__sqlvar->sqltype == ECPGt_numeric) {
677 if (PGTYPESnumeric_to_long(
678 (numeric*)(__sqlvar->sqldata), &n) != 0) {
685 if (PGTYPESnumeric_from_decimal(
686 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
690 if (PGTYPESnumeric_to_long(&nu, &n) != 0) {
697 case sizeof(uint8_t) : {
703 *(uint8_t*)_buf = (uint8_t)n;
706 case sizeof(uint16_t) : {
712 *(uint16_t*)_buf = (uint16_t)n;
715 case sizeof(uint32_t) : {
716 *(uint32_t*)_buf = (uint32_t)n;
720 *_size =
sizeof(uint32_t);
726 else if (*_size ==
sizeof(uint64_t)) {
727 numeric* p = (numeric*)(__sqlvar->sqldata);
729 if (__sqlvar->sqltype == ECPGt_decimal) {
730 if (PGTYPESnumeric_from_decimal(
731 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
737 char* s = PGTYPESnumeric_to_asc(p, 0);
739 unsigned long long n = strtoull(s, &endptr, 10);
741 if (n == ULLONG_MAX) {
745 *(uint64_t*)_buf = n;
748 *_size =
sizeof(int64_t);
762 switch (__sqlvar->sqltype) {
765 case sizeof(float) : {
766 *(
float*)_buf = *(
float*)(__sqlvar->sqldata);
769 case sizeof(double) : {
770 *(
double*)_buf = *(
float*)(__sqlvar->sqldata);
774 *_size =
sizeof(float);
783 case sizeof(double) : {
784 *(
double*)_buf = *(
double*)(__sqlvar->sqldata);
788 *_size =
sizeof(double);
796 case ECPGt_decimal: {
798 if (__sqlvar->sqltype == ECPGt_numeric) {
799 if (PGTYPESnumeric_to_double(
800 (numeric*)(__sqlvar->sqldata), &d) != 0) {
807 if (PGTYPESnumeric_from_decimal(
808 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
812 if (PGTYPESnumeric_to_double(&nu, &d) != 0) {
819 case sizeof(float) : {
820 if (d < -FLT_MAX || FLT_MAX < d) {
824 *(
float*)_buf = (
float)d;
827 case sizeof(double) : {
828 *(
double*)_buf = (
double)d;
832 *_size =
sizeof(double);