PostgreSQL Source Code git master
data.c
Go to the documentation of this file.
1/* src/interfaces/ecpg/ecpglib/data.c */
2
3#define POSTGRES_ECPG_INTERNAL
4#include "postgres_fe.h"
5
6#include <math.h>
7
8#include "ecpgerrno.h"
9#include "ecpglib.h"
10#include "ecpglib_extern.h"
11#include "ecpgtype.h"
12#include "pgtypes_date.h"
13#include "pgtypes_interval.h"
14#include "pgtypes_numeric.h"
15#include "pgtypes_timestamp.h"
16#include "sqlca.h"
17
18/* returns true if character c is a delimiter for the given array type */
19static bool
20array_delimiter(enum ARRAY_TYPE isarray, char c)
21{
22 if (isarray == ECPG_ARRAY_ARRAY && c == ',')
23 return true;
24
25 if (isarray == ECPG_ARRAY_VECTOR && c == ' ')
26 return true;
27
28 return false;
29}
30
31/* returns true if character c marks the boundary for the given array type */
32static bool
33array_boundary(enum ARRAY_TYPE isarray, char c)
34{
35 if (isarray == ECPG_ARRAY_ARRAY && c == '}')
36 return true;
37
38 if (isarray == ECPG_ARRAY_VECTOR && c == '\0')
39 return true;
40
41 return false;
42}
43
44/* returns true if some garbage is found at the end of the scanned string */
45static bool
46garbage_left(enum ARRAY_TYPE isarray, char **scan_length, enum COMPAT_MODE compat)
47{
48 /*
49 * INFORMIX allows for selecting a numeric into an int, the result is
50 * truncated
51 */
52 if (isarray == ECPG_ARRAY_NONE)
53 {
54 if (INFORMIX_MODE(compat) && **scan_length == '.')
55 {
56 /* skip invalid characters */
57 do
58 {
59 (*scan_length)++;
60 } while (isdigit((unsigned char) **scan_length));
61 }
62
63 if (**scan_length != ' ' && **scan_length != '\0')
64 return true;
65 }
66 else if (ECPG_IS_ARRAY(isarray) && !array_delimiter(isarray, **scan_length) && !array_boundary(isarray, **scan_length))
67 return true;
68
69 return false;
70}
71
72
73/*
74 * Portability wrappers borrowed from src/include/utils/float.h
75 */
76static double
78{
79 return (double) INFINITY;
80}
81
82static double
84{
85 return (double) NAN;
86}
87
88
89static bool
90check_special_value(char *ptr, double *retval, char **endptr)
91{
92 if (pg_strncasecmp(ptr, "NaN", 3) == 0)
93 {
94 *retval = get_float8_nan();
95 *endptr = ptr + 3;
96 return true;
97 }
98 else if (pg_strncasecmp(ptr, "Infinity", 8) == 0)
99 {
100 *retval = get_float8_infinity();
101 *endptr = ptr + 8;
102 return true;
103 }
104 else if (pg_strncasecmp(ptr, "-Infinity", 9) == 0)
105 {
106 *retval = -get_float8_infinity();
107 *endptr = ptr + 9;
108 return true;
109 }
110
111 return false;
112}
113
114/* imported from src/backend/utils/adt/encode.c */
115
116unsigned
117ecpg_hex_enc_len(unsigned srclen)
118{
119 return srclen << 1;
120}
121
122unsigned
123ecpg_hex_dec_len(unsigned srclen)
124{
125 return srclen >> 1;
126}
127
128static inline char
130{
131 static const int8 hexlookup[128] = {
132 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
133 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
134 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
135 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
136 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
137 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
138 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
139 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
140 };
141 int res = -1;
142
143 if (c > 0 && c < 127)
144 res = hexlookup[(unsigned char) c];
145
146 return (char) res;
147}
148
149static unsigned
150hex_decode(const char *src, unsigned len, char *dst)
151{
152 const char *s,
153 *srcend;
154 char v1,
155 v2,
156 *p;
157
158 srcend = src + len;
159 s = src;
160 p = dst;
161 while (s < srcend)
162 {
163 if (*s == ' ' || *s == '\n' || *s == '\t' || *s == '\r')
164 {
165 s++;
166 continue;
167 }
168 v1 = get_hex(*s++) << 4;
169 if (s >= srcend)
170 return -1;
171
172 v2 = get_hex(*s++);
173 *p++ = v1 | v2;
174 }
175
176 return p - dst;
177}
178
179unsigned
180ecpg_hex_encode(const char *src, unsigned len, char *dst)
181{
182 static const char hextbl[] = "0123456789abcdef";
183 const char *end = src + len;
184
185 while (src < end)
186 {
187 *dst++ = hextbl[(*src >> 4) & 0xF];
188 *dst++ = hextbl[*src & 0xF];
189 src++;
190 }
191 return len * 2;
192}
193
194bool
195ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
196 enum ECPGttype type, enum ECPGttype ind_type,
197 char *var, char *ind, long varcharsize, long offset,
198 long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator)
199{
200 struct sqlca_t *sqlca = ECPGget_sqlca();
201 char *pval = (char *) PQgetvalue(results, act_tuple, act_field);
202 int binary = PQfformat(results, act_field);
203 int size = PQgetlength(results, act_tuple, act_field);
204 int value_for_indicator = 0;
205 long log_offset;
206
207 if (sqlca == NULL)
208 {
211 return false;
212 }
213
214 /*
215 * If we are running in a regression test, do not log the offset variable,
216 * it depends on the machine's alignment.
217 */
219 log_offset = -1;
220 else
221 log_offset = offset;
222
223 ecpg_log("ecpg_get_data on line %d: RESULT: %s offset: %ld; array: %s\n", lineno, pval ? (binary ? "BINARY" : pval) : "EMPTY", log_offset, ECPG_IS_ARRAY(isarray) ? "yes" : "no");
224
225 /* pval is a pointer to the value */
226 if (!pval)
227 {
228 /*
229 * This should never happen because we already checked that we found
230 * at least one tuple, but let's play it safe.
231 */
233 return false;
234 }
235
236 /* We will have to decode the value */
237
238 /*
239 * check for null value and set indicator accordingly, i.e. -1 if NULL and
240 * 0 if not
241 */
242 if (PQgetisnull(results, act_tuple, act_field))
243 value_for_indicator = -1;
244
245 switch (ind_type)
246 {
247 case ECPGt_short:
249 *((short *) (ind + ind_offset * act_tuple)) = value_for_indicator;
250 break;
251 case ECPGt_int:
253 *((int *) (ind + ind_offset * act_tuple)) = value_for_indicator;
254 break;
255 case ECPGt_long:
257 *((long *) (ind + ind_offset * act_tuple)) = value_for_indicator;
258 break;
259 case ECPGt_long_long:
261 *((long long int *) (ind + ind_offset * act_tuple)) = value_for_indicator;
262 break;
264 if (value_for_indicator == -1)
265 {
266 if (force_indicator == false)
267 {
268 /*
269 * Informix has an additional way to specify NULLs note
270 * that this uses special values to denote NULL
271 */
272 ECPGset_noind_null(type, var + offset * act_tuple);
273 }
274 else
275 {
278 NULL);
279 return false;
280 }
281 }
282 break;
283 default:
286 ecpg_type_name(ind_type));
287 return false;
288 break;
289 }
290
291 if (value_for_indicator == -1)
292 return true;
293
294 /* let's check if it really is an array if it should be one */
295 if (isarray == ECPG_ARRAY_ARRAY)
296 {
297 if (*pval != '{')
298 {
301 return false;
302 }
303
304 switch (type)
305 {
306 case ECPGt_char:
308 case ECPGt_varchar:
309 case ECPGt_string:
310 break;
311
312 default:
313 pval++;
314 break;
315 }
316 }
317
318 do
319 {
320 if (binary)
321 {
322 if (varcharsize == 0 || varcharsize * offset >= size)
323 memcpy(var + offset * act_tuple, pval, size);
324 else
325 {
326 memcpy(var + offset * act_tuple, pval, varcharsize * offset);
327
328 if (varcharsize * offset < size)
329 {
330 /* truncation */
331 switch (ind_type)
332 {
333 case ECPGt_short:
335 *((short *) (ind + ind_offset * act_tuple)) = size;
336 break;
337 case ECPGt_int:
339 *((int *) (ind + ind_offset * act_tuple)) = size;
340 break;
341 case ECPGt_long:
343 *((long *) (ind + ind_offset * act_tuple)) = size;
344 break;
345 case ECPGt_long_long:
347 *((long long int *) (ind + ind_offset * act_tuple)) = size;
348 break;
349 default:
350 break;
351 }
352 sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
353 }
354 }
355 pval += size;
356 }
357 else
358 {
359 switch (type)
360 {
361 long res;
362 unsigned long ures;
363 double dres;
364 char *scan_length;
365 numeric *nres;
366 date ddres;
367 timestamp tres;
368 interval *ires;
369 char *endptr,
370 endchar;
371
372 case ECPGt_short:
373 case ECPGt_int:
374 case ECPGt_long:
375 res = strtol(pval, &scan_length, 10);
376 if (garbage_left(isarray, &scan_length, compat))
377 {
380 return false;
381 }
382 pval = scan_length;
383
384 switch (type)
385 {
386 case ECPGt_short:
387 *((short *) (var + offset * act_tuple)) = (short) res;
388 break;
389 case ECPGt_int:
390 *((int *) (var + offset * act_tuple)) = (int) res;
391 break;
392 case ECPGt_long:
393 *((long *) (var + offset * act_tuple)) = (long) res;
394 break;
395 default:
396 /* Cannot happen */
397 break;
398 }
399 break;
400
404 ures = strtoul(pval, &scan_length, 10);
405 if (garbage_left(isarray, &scan_length, compat))
406 {
409 return false;
410 }
411 pval = scan_length;
412
413 switch (type)
414 {
416 *((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures;
417 break;
419 *((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures;
420 break;
422 *((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures;
423 break;
424 default:
425 /* Cannot happen */
426 break;
427 }
428 break;
429
430 case ECPGt_long_long:
431 *((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
432 if (garbage_left(isarray, &scan_length, compat))
433 {
435 return false;
436 }
437 pval = scan_length;
438
439 break;
440
442 *((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
443 if (garbage_left(isarray, &scan_length, compat))
444 {
446 return false;
447 }
448 pval = scan_length;
449
450 break;
451
452 case ECPGt_float:
453 case ECPGt_double:
454 if (isarray && *pval == '"')
455 pval++;
456
457 if (!check_special_value(pval, &dres, &scan_length))
458 dres = strtod(pval, &scan_length);
459
460 if (isarray && *scan_length == '"')
461 scan_length++;
462
463 /* no special INFORMIX treatment for floats */
464 if (garbage_left(isarray, &scan_length, ECPG_COMPAT_PGSQL))
465 {
468 return false;
469 }
470 pval = scan_length;
471
472 switch (type)
473 {
474 case ECPGt_float:
475 *((float *) (var + offset * act_tuple)) = dres;
476 break;
477 case ECPGt_double:
478 *((double *) (var + offset * act_tuple)) = dres;
479 break;
480 default:
481 /* Cannot happen */
482 break;
483 }
484 break;
485
486 case ECPGt_bool:
487 if (pval[0] == 'f' && pval[1] == '\0')
488 {
489 *((bool *) (var + offset * act_tuple)) = false;
490 pval++;
491 break;
492 }
493 else if (pval[0] == 't' && pval[1] == '\0')
494 {
495 *((bool *) (var + offset * act_tuple)) = true;
496 pval++;
497 break;
498 }
499 else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
500 {
501 /* NULL is valid */
502 break;
503 }
504
507 return false;
508 break;
509
510 case ECPGt_bytea:
511 {
513 (struct ECPGgeneric_bytea *) (var + offset * act_tuple);
514 long dst_size,
515 src_size,
516 dec_size;
517
518 dst_size = ecpg_hex_enc_len(varcharsize);
519 src_size = size - 2; /* exclude backslash + 'x' */
520 dec_size = src_size < dst_size ? src_size : dst_size;
521 variable->len = hex_decode(pval + 2, dec_size, variable->arr);
522
523 if (dst_size < src_size)
524 {
525 long rcv_size = ecpg_hex_dec_len(size - 2);
526
527 /* truncation */
528 switch (ind_type)
529 {
530 case ECPGt_short:
532 *((short *) (ind + ind_offset * act_tuple)) = rcv_size;
533 break;
534 case ECPGt_int:
536 *((int *) (ind + ind_offset * act_tuple)) = rcv_size;
537 break;
538 case ECPGt_long:
540 *((long *) (ind + ind_offset * act_tuple)) = rcv_size;
541 break;
542 case ECPGt_long_long:
544 *((long long int *) (ind + ind_offset * act_tuple)) = rcv_size;
545 break;
546 default:
547 break;
548 }
549 sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
550 }
551
552 pval += size;
553 }
554 break;
555
556 case ECPGt_char:
558 case ECPGt_string:
559 {
560 char *str = (char *) (var + offset * act_tuple);
561
562 /*
563 * If varcharsize is unknown and the offset is that of
564 * char *, then this variable represents the array of
565 * character pointers. So, use extra indirection.
566 */
567 if (varcharsize == 0 && offset == sizeof(char *))
568 str = *(char **) str;
569
570 if (varcharsize > size)
571 {
572 /*
573 * compatibility mode, blank pad and null
574 * terminate char array
575 */
577 {
578 memset(str, ' ', varcharsize);
579 memcpy(str, pval, size);
580 str[varcharsize - 1] = '\0';
581
582 /*
583 * compatibility mode empty string gets -1
584 * indicator but no warning
585 */
586 if (size == 0)
587 {
588 /* truncation */
589 switch (ind_type)
590 {
591 case ECPGt_short:
593 *((short *) (ind + ind_offset * act_tuple)) = -1;
594 break;
595 case ECPGt_int:
597 *((int *) (ind + ind_offset * act_tuple)) = -1;
598 break;
599 case ECPGt_long:
601 *((long *) (ind + ind_offset * act_tuple)) = -1;
602 break;
603 case ECPGt_long_long:
605 *((long long int *) (ind + ind_offset * act_tuple)) = -1;
606 break;
607 default:
608 break;
609 }
610 }
611 }
612 else
613 {
614 strncpy(str, pval, size + 1);
615 }
616 /* do the rtrim() */
617 if (type == ECPGt_string)
618 {
619 char *last = str + size;
620
621 while (last > str && (*last == ' ' || *last == '\0'))
622 {
623 *last = '\0';
624 last--;
625 }
626 }
627 }
628 else
629 {
630 int charsize = varcharsize;
631
632 /*
633 * assume that the caller provided storage exactly
634 * fit when varcharsize is zero.
635 */
636 if (varcharsize == 0)
637 charsize = size + 1;
638
639 strncpy(str, pval, charsize);
640
641 /* compatibility mode, null terminate char array */
642 if (ORACLE_MODE(compat) && (charsize - 1) < size)
643 {
645 str[charsize - 1] = '\0';
646 }
647
648 if (charsize < size || (ORACLE_MODE(compat) && (charsize - 1) < size))
649 {
650 /* truncation */
651 switch (ind_type)
652 {
653 case ECPGt_short:
655 *((short *) (ind + ind_offset * act_tuple)) = size;
656 break;
657 case ECPGt_int:
659 *((int *) (ind + ind_offset * act_tuple)) = size;
660 break;
661 case ECPGt_long:
663 *((long *) (ind + ind_offset * act_tuple)) = size;
664 break;
665 case ECPGt_long_long:
667 *((long long int *) (ind + ind_offset * act_tuple)) = size;
668 break;
669 default:
670 break;
671 }
672 sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
673 }
674 }
675 pval += size;
676 }
677 break;
678
679 case ECPGt_varchar:
680 {
682 (struct ECPGgeneric_varchar *) (var + offset * act_tuple);
683
684 variable->len = size;
685 if (varcharsize == 0)
686 strncpy(variable->arr, pval, variable->len);
687 else
688 {
689 strncpy(variable->arr, pval, varcharsize);
690
691 if (variable->len > varcharsize)
692 {
693 /* truncation */
694 switch (ind_type)
695 {
696 case ECPGt_short:
698 *((short *) (ind + ind_offset * act_tuple)) = variable->len;
699 break;
700 case ECPGt_int:
702 *((int *) (ind + ind_offset * act_tuple)) = variable->len;
703 break;
704 case ECPGt_long:
706 *((long *) (ind + ind_offset * act_tuple)) = variable->len;
707 break;
708 case ECPGt_long_long:
710 *((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
711 break;
712 default:
713 break;
714 }
715 sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
716
717 variable->len = varcharsize;
718 }
719 }
720 pval += size;
721 }
722 break;
723
724 case ECPGt_decimal:
725 case ECPGt_numeric:
726 for (endptr = pval; *endptr && *endptr != ',' && *endptr != '}'; endptr++);
727 endchar = *endptr;
728 *endptr = '\0';
729 nres = PGTYPESnumeric_from_asc(pval, &scan_length);
730 *endptr = endchar;
731
732 /* did we get an error? */
733 if (nres == NULL)
734 {
735 ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
736 lineno, pval, errno);
737
739 {
740 /*
741 * Informix wants its own NULL value here instead
742 * of an error
743 */
744 nres = PGTYPESnumeric_new();
745 if (nres)
747 else
748 {
751 return false;
752 }
753 }
754 else
755 {
758 return false;
759 }
760 }
761 else
762 {
763 if (!isarray && garbage_left(isarray, &scan_length, compat))
764 {
765 free(nres);
768 return false;
769 }
770 }
771 pval = scan_length;
772
773 if (type == ECPGt_numeric)
774 PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
775 else
776 PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
777
779 break;
780
781 case ECPGt_interval:
782 if (*pval == '"')
783 pval++;
784
785 for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
786 endchar = *endptr;
787 *endptr = '\0';
788 ires = PGTYPESinterval_from_asc(pval, &scan_length);
789 *endptr = endchar;
790
791 /* did we get an error? */
792 if (ires == NULL)
793 {
794 ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
795 lineno, pval, errno);
796
798 {
799 /*
800 * Informix wants its own NULL value here instead
801 * of an error
802 */
803 ires = (interval *) ecpg_alloc(sizeof(interval), lineno);
804 if (!ires)
805 return false;
806
808 }
809 else
810 {
813 return false;
814 }
815 }
816 else
817 {
818 if (*scan_length == '"')
819 scan_length++;
820
821 if (!isarray && garbage_left(isarray, &scan_length, compat))
822 {
823 free(ires);
826 return false;
827 }
828 }
829 pval = scan_length;
830
831 PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
832 free(ires);
833 break;
834
835 case ECPGt_date:
836 if (*pval == '"')
837 pval++;
838
839 for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
840 endchar = *endptr;
841 *endptr = '\0';
842 ddres = PGTYPESdate_from_asc(pval, &scan_length);
843 *endptr = endchar;
844
845 /* did we get an error? */
846 if (errno != 0)
847 {
848 ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
849 lineno, pval, errno);
850
852 {
853 /*
854 * Informix wants its own NULL value here instead
855 * of an error
856 */
858 }
859 else
860 {
863 return false;
864 }
865 }
866 else
867 {
868 if (*scan_length == '"')
869 scan_length++;
870
871 if (!isarray && garbage_left(isarray, &scan_length, compat))
872 {
875 return false;
876 }
877 }
878
879 *((date *) (var + offset * act_tuple)) = ddres;
880 pval = scan_length;
881 break;
882
883 case ECPGt_timestamp:
884 if (*pval == '"')
885 pval++;
886
887 for (endptr = pval; *endptr && *endptr != ',' && *endptr != '"' && *endptr != '}'; endptr++);
888 endchar = *endptr;
889 *endptr = '\0';
890 tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
891 *endptr = endchar;
892
893 /* did we get an error? */
894 if (errno != 0)
895 {
896 ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n",
897 lineno, pval, errno);
898
900 {
901 /*
902 * Informix wants its own NULL value here instead
903 * of an error
904 */
906 }
907 else
908 {
911 return false;
912 }
913 }
914 else
915 {
916 if (*scan_length == '"')
917 scan_length++;
918
919 if (!isarray && garbage_left(isarray, &scan_length, compat))
920 {
923 return false;
924 }
925 }
926
927 *((timestamp *) (var + offset * act_tuple)) = tres;
928 pval = scan_length;
929 break;
930
931 default:
935 return false;
936 break;
937 }
938 if (ECPG_IS_ARRAY(isarray))
939 {
940 bool string = false;
941
942 /* set array to next entry */
943 ++act_tuple;
944
945 /* set pval to the next entry */
946
947 /*
948 * *pval != '\0' should not be needed, but is used as a safety
949 * guard
950 */
951 for (; *pval != '\0' && (string || (!array_delimiter(isarray, *pval) && !array_boundary(isarray, *pval))); ++pval)
952 if (*pval == '"')
953 string = string ? false : true;
954
955 if (array_delimiter(isarray, *pval))
956 ++pval;
957 }
958 }
959 } while (*pval != '\0' && !array_boundary(isarray, *pval));
960
961 return true;
962}
int8_t int8
Definition: c.h:537
unsigned ecpg_hex_enc_len(unsigned srclen)
Definition: data.c:117
static char get_hex(char c)
Definition: data.c:129
static bool garbage_left(enum ARRAY_TYPE isarray, char **scan_length, enum COMPAT_MODE compat)
Definition: data.c:46
unsigned ecpg_hex_dec_len(unsigned srclen)
Definition: data.c:123
bool ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, enum ECPGttype type, enum ECPGttype ind_type, char *var, char *ind, long varcharsize, long offset, long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator)
Definition: data.c:195
static double get_float8_nan(void)
Definition: data.c:83
static unsigned hex_decode(const char *src, unsigned len, char *dst)
Definition: data.c:150
unsigned ecpg_hex_encode(const char *src, unsigned len, char *dst)
Definition: data.c:180
static bool array_delimiter(enum ARRAY_TYPE isarray, char c)
Definition: data.c:20
static double get_float8_infinity(void)
Definition: data.c:77
static bool array_boundary(enum ARRAY_TYPE isarray, char c)
Definition: data.c:33
static bool check_special_value(char *ptr, double *retval, char **endptr)
Definition: data.c:90
enum COMPAT_MODE compat
Definition: ecpg.c:26
bool force_indicator
Definition: ecpg.c:18
#define ECPG_CONVERT_BOOL
Definition: ecpgerrno.h:29
#define ECPG_UNSUPPORTED
Definition: ecpgerrno.h:18
#define ECPG_FLOAT_FORMAT
Definition: ecpgerrno.h:24
#define ECPG_INT_FORMAT
Definition: ecpgerrno.h:22
#define ECPG_MISSING_INDICATOR
Definition: ecpgerrno.h:31
#define ECPG_INTERVAL_FORMAT
Definition: ecpgerrno.h:26
#define ECPG_UINT_FORMAT
Definition: ecpgerrno.h:23
#define ECPG_OUT_OF_MEMORY
Definition: ecpgerrno.h:15
#define ECPG_NOT_FOUND
Definition: ecpgerrno.h:10
#define ECPG_DATA_NOT_ARRAY
Definition: ecpgerrno.h:33
#define ECPG_NUMERIC_FORMAT
Definition: ecpgerrno.h:25
#define ECPG_DATE_FORMAT
Definition: ecpgerrno.h:27
#define ECPG_TIMESTAMP_FORMAT
Definition: ecpgerrno.h:28
#define ECPG_SQLSTATE_NO_DATA
#define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY
COMPAT_MODE
@ ECPG_COMPAT_PGSQL
char * ecpg_alloc(long size, int lineno)
Definition: memory.c:19
#define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
#define ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER
void ecpg_log(const char *format,...) pg_attribute_printf(1
#define ORACLE_MODE(X)
#define INFORMIX_MODE(X)
const char * ecpg_type_name(enum ECPGttype typ)
Definition: typename.c:17
#define ECPG_SQLSTATE_DATATYPE_MISMATCH
#define ECPG_IS_ARRAY(X)
void ecpg_raise(int line, int code, const char *sqlstate, const char *str)
Definition: error.c:13
bool ecpg_internal_regression_mode
Definition: misc.c:29
ARRAY_TYPE
@ ECPG_ARRAY_ARRAY
@ ECPG_ARRAY_VECTOR
@ ECPG_ARRAY_NONE
ECPGttype
Definition: ecpgtype.h:42
@ ECPGt_float
Definition: ecpgtype.h:47
@ ECPGt_long_long
Definition: ecpgtype.h:45
@ ECPGt_short
Definition: ecpgtype.h:43
@ ECPGt_decimal
Definition: ecpgtype.h:51
@ ECPGt_bytea
Definition: ecpgtype.h:67
@ ECPGt_numeric
Definition: ecpgtype.h:49
@ ECPGt_varchar
Definition: ecpgtype.h:48
@ ECPGt_timestamp
Definition: ecpgtype.h:54
@ ECPGt_unsigned_short
Definition: ecpgtype.h:43
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_long
Definition: ecpgtype.h:44
@ ECPGt_unsigned_char
Definition: ecpgtype.h:43
@ ECPGt_double
Definition: ecpgtype.h:47
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_date
Definition: ecpgtype.h:53
@ ECPGt_interval
Definition: ecpgtype.h:55
@ ECPGt_unsigned_long
Definition: ecpgtype.h:44
@ ECPGt_bool
Definition: ecpgtype.h:46
@ ECPGt_unsigned_long_long
Definition: ecpgtype.h:45
@ ECPGt_unsigned_int
Definition: ecpgtype.h:44
@ ECPGt_char
Definition: ecpgtype.h:43
@ ECPGt_string
Definition: ecpgtype.h:65
static const int8 hexlookup[128]
Definition: encode.c:174
int PQfformat(const PGresult *res, int field_num)
Definition: fe-exec.c:3724
const char * str
#define free(a)
Definition: header.h:65
struct sqlca_t * ECPGget_sqlca(void)
Definition: misc.c:108
void ECPGset_noind_null(enum ECPGttype type, void *ptr)
Definition: misc.c:292
return false
Definition: isn.c:135
#define PQgetvalue
Definition: libpq-be-fe.h:253
#define PQgetlength
Definition: libpq-be-fe.h:254
#define PQgetisnull
Definition: libpq-be-fe.h:255
const void size_t len
static const char hextbl[]
Definition: pgp-info.c:87
long date
Definition: pgtypes_date.h:9
date PGTYPESdate_from_asc(char *str, char **endptr)
Definition: datetime.c:47
int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest)
Definition: interval.c:1082
interval * PGTYPESinterval_from_asc(char *str, char **endptr)
Definition: interval.c:1003
int PGTYPESnumeric_copy(numeric *src, numeric *dst)
Definition: numeric.c:1388
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:42
int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst)
Definition: numeric.c:1547
void PGTYPESnumeric_free(numeric *var)
Definition: numeric.c:385
numeric * PGTYPESnumeric_from_asc(char *str, char **endptr)
Definition: numeric.c:321
timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr)
Definition: timestamp.c:202
int64 timestamp
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: pgstrcasecmp.c:69
char * c
#define sqlca
Definition: sqlca.h:59
Definition: sqlca.h:20
const char * type