54 Field::__queryHandle = _queryHandle;
58 Field::__name = UTF8Decoder::decode(__sqlvar->sqlname.data,
59 __sqlvar->sqlname.length).toUpperCase();
67 switch (__sqlvar->sqltype) {
70 __maxDataSize =
sizeof(int16_t);
73 case ECPGt_unsigned_short: {
75 __maxDataSize =
sizeof(int16_t);
80 __maxDataSize =
sizeof(int32_t);
83 case ECPGt_unsigned_int: {
85 __maxDataSize =
sizeof(int32_t);
91 __maxDataSize =
sizeof(int64_t);
93 __maxDataSize =
sizeof(int32_t);
97 case ECPGt_unsigned_long: {
100 __maxDataSize =
sizeof(int64_t);
102 __maxDataSize =
sizeof(int32_t);
106 case ECPGt_long_long: {
108 __maxDataSize =
sizeof(int64_t);
111 case ECPGt_unsigned_long_long: {
113 __maxDataSize =
sizeof(int64_t);
118 __maxDataSize =
sizeof(bool);
123 __maxDataSize =
sizeof(float);
128 __maxDataSize =
sizeof(double);
132 case ECPGt_decimal: {
145 case ECPGt_timestamp: {
150 case ECPGt_interval: {
156 case ECPGt_unsigned_char:
158 case ECPGt_varchar2: {
302 (
const timestamp*)(__sqlvar->sqldata),
310 (
const interval*)(__sqlvar->sqldata),
318 if (__sqlvar->sqltype == ECPGt_decimal) {
319 if (PGTYPESnumeric_from_decimal(
320 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
326 else if (__sqlvar->sqltype == ECPGt_numeric) {
327 p = (numeric*)(__sqlvar->sqldata);
332 __DCL_TRACE4(L
"ndigits[%d] weight[%d] rscale[%d] dscale[%d]\n",
333 p->ndigits, p->weight, p->rscale, p->dscale);
335 String::tryString((
const char*)(p->digits), p->ndigits).data()
338 char* s = PGTYPESnumeric_to_asc(p, p->dscale);
339 size_t l = ByteString::length(s);
357 switch (__sqlvar->sqltype) {
359 case ECPGt_unsigned_char:
363 if (__sqlvar->sqllen > 0 && *_size > 0) {
364 size_t nCopy = *_size;
365 if ((
size_t)(__sqlvar->sqllen) < nCopy)
366 nCopy = (size_t)(__sqlvar->sqllen);
368 memcpy(_pv, __sqlvar->sqldata, nCopy);
369 if (nCopy < *_size) {
370 *((
char*)_pv + nCopy) =
'\0';
384 switch (__sqlvar->sqltype) {
386 case ECPGt_unsigned_char:
390 if ((
size_t)(__sqlvar->sqllen) < *_size) {
391 *_size = (size_t)(__sqlvar->sqllen);
419 switch (__sqlvar->sqltype) {
422 case sizeof(int16_t) : {
423 *(int16_t*)_pv = *(int16_t*)(__sqlvar->sqldata);
426 case sizeof(int32_t) : {
427 *(int32_t*)_pv = (int32_t) * (int16_t*)(__sqlvar->sqldata);
430 case sizeof(int64_t) : {
431 *(int64_t*)_pv = (int64_t) * (int16_t*)(__sqlvar->sqldata);
435 *_size =
sizeof(int16_t);
447 case sizeof(int32_t) : {
448 *(int32_t*)_pv = *(int32_t*)(__sqlvar->sqldata);
451 case sizeof(int64_t) : {
452 *(int64_t*)_pv = (int64_t) * (int32_t*)(__sqlvar->sqldata);
456 *_size =
sizeof(int32_t);
466 case ECPGt_long_long: {
467 if (*_size ==
sizeof(int64_t)) {
468 *(int64_t*)_pv = (int64_t) * (int64_t*)(__sqlvar->sqldata);
471 *_size =
sizeof(int64_t);
477 case ECPGt_unsigned_long_long: {
478 if (*_size ==
sizeof(int64_t)) {
479 *(int64_t*)_pv = (int64_t) * (uint64_t*)(__sqlvar->sqldata);
482 *_size =
sizeof(int64_t);
489 case ECPGt_decimal: {
491 if (*_size <=
sizeof(int32_t)) {
494 if (__sqlvar->sqltype == ECPGt_numeric) {
495 if (PGTYPESnumeric_to_long(
496 (numeric*)(__sqlvar->sqldata), &
n) != 0) {
503 if (PGTYPESnumeric_from_decimal(
504 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
508 if (PGTYPESnumeric_to_long(&nu, &
n) != 0) {
515 case sizeof(int8_t) : {
520 *(int8_t*)_pv = (int8_t)
n;
523 case sizeof(int16_t) : {
528 *(int16_t*)_pv = (int16_t)
n;
531 case sizeof(int32_t) : {
538 *(int32_t*)_pv = (int32_t)
n;
541 case sizeof(int64_t) : {
542 *(int64_t*)_pv = (int64_t)
n;
547 *_size =
sizeof(int32_t);
548#elif ALIGNOF_LONG == 8
549 *_size =
sizeof(int64_t);
557 else if (*_size ==
sizeof(int64_t)) {
558 numeric* p = (numeric*)(__sqlvar->sqldata);
560 if (__sqlvar->sqltype == ECPGt_decimal) {
561 if (PGTYPESnumeric_from_decimal(
562 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
568 char* s = PGTYPESnumeric_to_asc(p, 0);
570 long long n = strtoll(s, &endptr, 10);
572 if (
n == LLONG_MAX ||
n == LLONG_MIN) {
579 *_size =
sizeof(int64_t);
594 switch(__sqlvar->sqltype) {
597 case sizeof(uint8_t) : {
598 *(uint8_t*)_pv = (uint8_t) * (uint8_t*)(__sqlvar->sqldata);
601 case sizeof(uint16_t) : {
602 *(uint16_t*)_pv = (uint16_t) * (uint8_t*)(__sqlvar->sqldata);
605 case sizeof(uint32_t) : {
606 *(uint32_t*)_pv = (uint32_t) * (uint8_t*)(__sqlvar->sqldata);
609 case sizeof(uint64_t) : {
610 *(uint64_t*)_pv = (uint64_t) * (uint8_t*)(__sqlvar->sqldata);
614 *_size =
sizeof(uint8_t);
623 case sizeof(uint16_t) : {
624 *(uint16_t*)_pv = (uint16_t) * (int16_t*)(__sqlvar->sqldata);
627 case sizeof(uint32_t) : {
628 *(uint32_t*)_pv = (uint32_t) * (int16_t*)(__sqlvar->sqldata);
631 case sizeof(uint64_t) : {
632 *(uint64_t*)_pv = (uint64_t) * (int16_t*)(__sqlvar->sqldata);
636 *_size =
sizeof(uint16_t);
646 case sizeof(uint32_t) : {
647 *(uint32_t*)_pv = (uint32_t) * (int32_t*)(__sqlvar->sqldata);
650 case sizeof(int64_t) : {
651 *(uint64_t*)_pv = (uint64_t) * (int32_t*)(__sqlvar->sqldata);
655 *_size =
sizeof(int32_t);
662 case ECPGt_long_long: {
663 if (*_size ==
sizeof(int64_t)) {
664 *(uint64_t*)_pv = (uint64_t) * (int64_t*)(__sqlvar->sqldata);
667 *_size =
sizeof(int64_t);
673 case ECPGt_unsigned_long_long: {
674 if (*_size ==
sizeof(int64_t)) {
675 *(uint64_t*)_pv = (uint64_t) * (uint64_t*)(__sqlvar->sqldata);
678 *_size =
sizeof(int64_t);
685 case ECPGt_decimal: {
686 if (*_size <=
sizeof(uint32_t)) {
688 if (__sqlvar->sqltype == ECPGt_numeric) {
689 if (PGTYPESnumeric_to_long(
690 (numeric*)(__sqlvar->sqldata), &
n) != 0) {
697 if (PGTYPESnumeric_from_decimal(
698 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
702 if (PGTYPESnumeric_to_long(&nu, &
n) != 0) {
709 case sizeof(uint8_t) : {
715 *(uint8_t*)_pv = (uint8_t)
n;
718 case sizeof(uint16_t) : {
724 *(uint16_t*)_pv = (uint16_t)
n;
727 case sizeof(uint32_t) : {
728 *(uint32_t*)_pv = (uint32_t)
n;
732 *_size =
sizeof(uint32_t);
738 else if (*_size ==
sizeof(uint64_t)) {
739 numeric* p = (numeric*)(__sqlvar->sqldata);
741 if (__sqlvar->sqltype == ECPGt_decimal) {
742 if (PGTYPESnumeric_from_decimal(
743 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
749 char* s = PGTYPESnumeric_to_asc(p, 0);
751 unsigned long long n = strtoull(s, &endptr, 10);
753 if (
n == ULLONG_MAX) {
760 *_size =
sizeof(int64_t);
774 switch (__sqlvar->sqltype) {
777 case sizeof(float) : {
778 *(
float*)_pv = *(
float*)(__sqlvar->sqldata);
781 case sizeof(double) : {
782 *(
double*)_pv = *(
float*)(__sqlvar->sqldata);
786 *_size =
sizeof(float);
795 case sizeof(double) : {
796 *(
double*)_pv = *(
double*)(__sqlvar->sqldata);
800 *_size =
sizeof(double);
808 case ECPGt_decimal: {
810 if (__sqlvar->sqltype == ECPGt_numeric) {
811 if (PGTYPESnumeric_to_double(
812 (numeric*)(__sqlvar->sqldata), &d) != 0) {
819 if (PGTYPESnumeric_from_decimal(
820 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
824 if (PGTYPESnumeric_to_double(&nu, &d) != 0) {
831 case sizeof(float) : {
832 if (d < FLT_MIN || FLT_MAX < d) {
836 *(
float*)_pv = (
float)d;
839 case sizeof(double) : {
844 *_size =
sizeof(double);