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: {
299 (
const timestamp*)(__sqlvar->sqldata),
309 (
const interval*)(__sqlvar->sqldata),
317 if (__sqlvar->sqltype == ECPGt_decimal) {
318 if (PGTYPESnumeric_from_decimal(
319 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
325 else if (__sqlvar->sqltype == ECPGt_numeric) {
326 p = (numeric*)(__sqlvar->sqldata);
331 __DCL_TRACE4(L
"ndigits[%d] weight[%d] rscale[%d] dscale[%d]\n",
332 p->ndigits, p->weight, p->rscale, p->dscale);
334 String::tryString((
const char*)(p->digits), p->ndigits).data()
337 char* s = PGTYPESnumeric_to_asc(p, p->dscale);
338 size_t l = ByteString::length(s);
358 switch (__sqlvar->sqltype) {
360 case ECPGt_unsigned_char:
364 if (__sqlvar->sqllen > 0 && *_size > 0) {
365 size_t nCopy = *_size;
366 if ((
size_t)(__sqlvar->sqllen) < nCopy)
367 nCopy = (size_t)(__sqlvar->sqllen);
369 memcpy(_pv, __sqlvar->sqldata, nCopy);
370 if (nCopy < *_size) {
371 *((
char*)_pv + nCopy) =
'\0';
385 switch (__sqlvar->sqltype) {
387 case ECPGt_unsigned_char:
391 if ((
size_t)(__sqlvar->sqllen) < *_size) {
392 *_size = (size_t)(__sqlvar->sqllen);
420 switch (__sqlvar->sqltype) {
423 case sizeof(int16_t) : {
424 *(int16_t*)_pv = *(int16_t*)(__sqlvar->sqldata);
427 case sizeof(int32_t) : {
428 *(int32_t*)_pv = (int32_t) * (int16_t*)(__sqlvar->sqldata);
431 case sizeof(int64_t) : {
432 *(int64_t*)_pv = (int64_t) * (int16_t*)(__sqlvar->sqldata);
436 *_size =
sizeof(int16_t);
448 case sizeof(int32_t) : {
449 *(int32_t*)_pv = *(int32_t*)(__sqlvar->sqldata);
452 case sizeof(int64_t) : {
453 *(int64_t*)_pv = (int64_t) * (int32_t*)(__sqlvar->sqldata);
457 *_size =
sizeof(int32_t);
467 case ECPGt_long_long: {
468 if (*_size ==
sizeof(int64_t)) {
469 *(int64_t*)_pv = (int64_t) * (int64_t*)(__sqlvar->sqldata);
472 *_size =
sizeof(int64_t);
478 case ECPGt_unsigned_long_long: {
479 if (*_size ==
sizeof(int64_t)) {
480 *(int64_t*)_pv = (int64_t) * (uint64_t*)(__sqlvar->sqldata);
483 *_size =
sizeof(int64_t);
490 case ECPGt_decimal: {
492 if (*_size <=
sizeof(int32_t)) {
495 if (__sqlvar->sqltype == ECPGt_numeric) {
496 if (PGTYPESnumeric_to_long(
497 (numeric*)(__sqlvar->sqldata), &
n) != 0) {
504 if (PGTYPESnumeric_from_decimal(
505 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
509 if (PGTYPESnumeric_to_long(&nu, &
n) != 0) {
516 case sizeof(int8_t) : {
521 *(int8_t*)_pv = (int8_t)
n;
524 case sizeof(int16_t) : {
529 *(int16_t*)_pv = (int16_t)
n;
532 case sizeof(int32_t) : {
539 *(int32_t*)_pv = (int32_t)
n;
542 case sizeof(int64_t) : {
543 *(int64_t*)_pv = (int64_t)
n;
548 *_size =
sizeof(int32_t);
549#elif ALIGNOF_LONG == 8
550 *_size =
sizeof(int64_t);
558 else if (*_size ==
sizeof(int64_t)) {
559 numeric* p = (numeric*)(__sqlvar->sqldata);
561 if (__sqlvar->sqltype == ECPGt_decimal) {
562 if (PGTYPESnumeric_from_decimal(
563 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
569 char* s = PGTYPESnumeric_to_asc(p, 0);
571 long long n = strtoll(s, &endptr, 10);
573 if (
n == LLONG_MAX ||
n == LLONG_MIN) {
580 *_size =
sizeof(int64_t);
595 switch(__sqlvar->sqltype) {
598 case sizeof(uint8_t) : {
599 *(uint8_t*)_pv = (uint8_t) * (uint8_t*)(__sqlvar->sqldata);
602 case sizeof(uint16_t) : {
603 *(uint16_t*)_pv = (uint16_t) * (uint8_t*)(__sqlvar->sqldata);
606 case sizeof(uint32_t) : {
607 *(uint32_t*)_pv = (uint32_t) * (uint8_t*)(__sqlvar->sqldata);
610 case sizeof(uint64_t) : {
611 *(uint64_t*)_pv = (uint64_t) * (uint8_t*)(__sqlvar->sqldata);
615 *_size =
sizeof(uint8_t);
624 case sizeof(uint16_t) : {
625 *(uint16_t*)_pv = (uint16_t) * (int16_t*)(__sqlvar->sqldata);
628 case sizeof(uint32_t) : {
629 *(uint32_t*)_pv = (uint32_t) * (int16_t*)(__sqlvar->sqldata);
632 case sizeof(uint64_t) : {
633 *(uint64_t*)_pv = (uint64_t) * (int16_t*)(__sqlvar->sqldata);
637 *_size =
sizeof(uint16_t);
647 case sizeof(uint32_t) : {
648 *(uint32_t*)_pv = (uint32_t) * (int32_t*)(__sqlvar->sqldata);
651 case sizeof(int64_t) : {
652 *(uint64_t*)_pv = (uint64_t) * (int32_t*)(__sqlvar->sqldata);
656 *_size =
sizeof(int32_t);
663 case ECPGt_long_long: {
664 if (*_size ==
sizeof(int64_t)) {
665 *(uint64_t*)_pv = (uint64_t) * (int64_t*)(__sqlvar->sqldata);
668 *_size =
sizeof(int64_t);
674 case ECPGt_unsigned_long_long: {
675 if (*_size ==
sizeof(int64_t)) {
676 *(uint64_t*)_pv = (uint64_t) * (uint64_t*)(__sqlvar->sqldata);
679 *_size =
sizeof(int64_t);
686 case ECPGt_decimal: {
687 if (*_size <=
sizeof(uint32_t)) {
689 if (__sqlvar->sqltype == ECPGt_numeric) {
690 if (PGTYPESnumeric_to_long(
691 (numeric*)(__sqlvar->sqldata), &
n) != 0) {
698 if (PGTYPESnumeric_from_decimal(
699 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
703 if (PGTYPESnumeric_to_long(&nu, &
n) != 0) {
710 case sizeof(uint8_t) : {
716 *(uint8_t*)_pv = (uint8_t)
n;
719 case sizeof(uint16_t) : {
725 *(uint16_t*)_pv = (uint16_t)
n;
728 case sizeof(uint32_t) : {
729 *(uint32_t*)_pv = (uint32_t)
n;
733 *_size =
sizeof(uint32_t);
739 else if (*_size ==
sizeof(uint64_t)) {
740 numeric* p = (numeric*)(__sqlvar->sqldata);
742 if (__sqlvar->sqltype == ECPGt_decimal) {
743 if (PGTYPESnumeric_from_decimal(
744 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
750 char* s = PGTYPESnumeric_to_asc(p, 0);
752 unsigned long long n = strtoull(s, &endptr, 10);
754 if (
n == ULLONG_MAX) {
761 *_size =
sizeof(int64_t);
775 switch (__sqlvar->sqltype) {
778 case sizeof(float) : {
779 *(
float*)_pv = *(
float*)(__sqlvar->sqldata);
782 case sizeof(double) : {
783 *(
double*)_pv = *(
float*)(__sqlvar->sqldata);
787 *_size =
sizeof(float);
796 case sizeof(double) : {
797 *(
double*)_pv = *(
double*)(__sqlvar->sqldata);
801 *_size =
sizeof(double);
809 case ECPGt_decimal: {
811 if (__sqlvar->sqltype == ECPGt_numeric) {
812 if (PGTYPESnumeric_to_double(
813 (numeric*)(__sqlvar->sqldata), &d) != 0) {
820 if (PGTYPESnumeric_from_decimal(
821 (decimal*)(__sqlvar->sqldata), &nu) != 0) {
825 if (PGTYPESnumeric_to_double(&nu, &d) != 0) {
832 case sizeof(float) : {
833 if (d < FLT_MIN || FLT_MAX < d) {
837 *(
float*)_pv = (
float)d;
840 case sizeof(double) : {
845 *_size =
sizeof(double);