2 34.6. pgtypes Library #
4 34.6.1. Character Strings
5 34.6.2. The numeric Type
7 34.6.4. The timestamp Type
8 34.6.5. The interval Type
9 34.6.6. The decimal Type
10 34.6.7. errno Values of pgtypeslib
11 34.6.8. Special Constants of pgtypeslib
13 The pgtypes library maps PostgreSQL database types to C equivalents
14 that can be used in C programs. It also offers functions to do basic
15 calculations with those types within C, i.e., without the help of the
16 PostgreSQL server. See the following example:
17 EXEC SQL BEGIN DECLARE SECTION;
22 EXEC SQL END DECLARE SECTION;
24 PGTYPESdate_today(&date1);
25 EXEC SQL SELECT started, duration INTO :ts1, :iv1 FROM datetbl WHERE d=:date1;
26 PGTYPEStimestamp_add_interval(&ts1, &iv1, &tsout);
27 out = PGTYPEStimestamp_to_asc(&tsout);
28 printf("Started + duration: %s\n", out);
29 PGTYPESchar_free(out);
32 34.6.1. Character Strings #
34 Some functions such as PGTYPESnumeric_to_asc return a pointer to a
35 freshly allocated character string. These results should be freed with
36 PGTYPESchar_free instead of free. (This is important only on Windows,
37 where memory allocation and release sometimes need to be done by the
40 34.6.2. The numeric Type #
42 The numeric type offers to do calculations with arbitrary precision.
43 See Section 8.1 for the equivalent type in the PostgreSQL server.
44 Because of the arbitrary precision this variable needs to be able to
45 expand and shrink dynamically. That's why you can only create numeric
46 variables on the heap, by means of the PGTYPESnumeric_new and
47 PGTYPESnumeric_free functions. The decimal type, which is similar but
48 limited in precision, can be created on the stack as well as on the
51 The following functions can be used to work with the numeric type:
54 Request a pointer to a newly allocated numeric variable.
56 numeric *PGTYPESnumeric_new(void);
59 Free a numeric type, release all of its memory.
61 void PGTYPESnumeric_free(numeric *var);
63 PGTYPESnumeric_from_asc #
64 Parse a numeric type from its string notation.
66 numeric *PGTYPESnumeric_from_asc(char *str, char **endptr);
68 Valid formats are for example: -2, .794, +3.44, 592.49E07 or
69 -32.84e-4. If the value could be parsed successfully, a valid
70 pointer is returned, else the NULL pointer. At the moment ECPG
71 always parses the complete string and so it currently does not
72 support to store the address of the first invalid character in
73 *endptr. You can safely set endptr to NULL.
75 PGTYPESnumeric_to_asc #
76 Returns a pointer to a string allocated by malloc that contains
77 the string representation of the numeric type num.
79 char *PGTYPESnumeric_to_asc(numeric *num, int dscale);
81 The numeric value will be printed with dscale decimal digits,
82 with rounding applied if necessary. The result must be freed
83 with PGTYPESchar_free().
86 Add two numeric variables into a third one.
88 int PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result);
90 The function adds the variables var1 and var2 into the result
91 variable result. The function returns 0 on success and -1 in
95 Subtract two numeric variables and return the result in a third
98 int PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result);
100 The function subtracts the variable var2 from the variable var1.
101 The result of the operation is stored in the variable result.
102 The function returns 0 on success and -1 in case of error.
105 Multiply two numeric variables and return the result in a third
108 int PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result);
110 The function multiplies the variables var1 and var2. The result
111 of the operation is stored in the variable result. The function
112 returns 0 on success and -1 in case of error.
115 Divide two numeric variables and return the result in a third
118 int PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result);
120 The function divides the variables var1 by var2. The result of
121 the operation is stored in the variable result. The function
122 returns 0 on success and -1 in case of error.
125 Compare two numeric variables.
127 int PGTYPESnumeric_cmp(numeric *var1, numeric *var2)
129 This function compares two numeric variables. In case of error,
130 INT_MAX is returned. On success, the function returns one of
131 three possible results:
133 + 1, if var1 is bigger than var2
134 + -1, if var1 is smaller than var2
135 + 0, if var1 and var2 are equal
137 PGTYPESnumeric_from_int #
138 Convert an int variable to a numeric variable.
140 int PGTYPESnumeric_from_int(signed int int_val, numeric *var);
142 This function accepts a variable of type signed int and stores
143 it in the numeric variable var. Upon success, 0 is returned and
144 -1 in case of a failure.
146 PGTYPESnumeric_from_long #
147 Convert a long int variable to a numeric variable.
149 int PGTYPESnumeric_from_long(signed long int long_val, numeric *var);
151 This function accepts a variable of type signed long int and
152 stores it in the numeric variable var. Upon success, 0 is
153 returned and -1 in case of a failure.
155 PGTYPESnumeric_copy #
156 Copy over one numeric variable into another one.
158 int PGTYPESnumeric_copy(numeric *src, numeric *dst);
160 This function copies over the value of the variable that src
161 points to into the variable that dst points to. It returns 0 on
162 success and -1 if an error occurs.
164 PGTYPESnumeric_from_double #
165 Convert a variable of type double to a numeric.
167 int PGTYPESnumeric_from_double(double d, numeric *dst);
169 This function accepts a variable of type double and stores the
170 result in the variable that dst points to. It returns 0 on
171 success and -1 if an error occurs.
173 PGTYPESnumeric_to_double #
174 Convert a variable of type numeric to double.
176 int PGTYPESnumeric_to_double(numeric *nv, double *dp)
178 The function converts the numeric value from the variable that
179 nv points to into the double variable that dp points to. It
180 returns 0 on success and -1 if an error occurs, including
181 overflow. On overflow, the global variable errno will be set to
182 PGTYPES_NUM_OVERFLOW additionally.
184 PGTYPESnumeric_to_int #
185 Convert a variable of type numeric to int.
187 int PGTYPESnumeric_to_int(numeric *nv, int *ip);
189 The function converts the numeric value from the variable that
190 nv points to into the integer variable that ip points to. It
191 returns 0 on success and -1 if an error occurs, including
192 overflow. On overflow, the global variable errno will be set to
193 PGTYPES_NUM_OVERFLOW additionally.
195 PGTYPESnumeric_to_long #
196 Convert a variable of type numeric to long.
198 int PGTYPESnumeric_to_long(numeric *nv, long *lp);
200 The function converts the numeric value from the variable that
201 nv points to into the long integer variable that lp points to.
202 It returns 0 on success and -1 if an error occurs, including
203 overflow and underflow. On overflow, the global variable errno
204 will be set to PGTYPES_NUM_OVERFLOW and on underflow errno will
205 be set to PGTYPES_NUM_UNDERFLOW.
207 PGTYPESnumeric_to_decimal #
208 Convert a variable of type numeric to decimal.
210 int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst);
212 The function converts the numeric value from the variable that
213 src points to into the decimal variable that dst points to. It
214 returns 0 on success and -1 if an error occurs, including
215 overflow. On overflow, the global variable errno will be set to
216 PGTYPES_NUM_OVERFLOW additionally.
218 PGTYPESnumeric_from_decimal #
219 Convert a variable of type decimal to numeric.
221 int PGTYPESnumeric_from_decimal(decimal *src, numeric *dst);
223 The function converts the decimal value from the variable that
224 src points to into the numeric variable that dst points to. It
225 returns 0 on success and -1 if an error occurs. Since the
226 decimal type is implemented as a limited version of the numeric
227 type, overflow cannot occur with this conversion.
229 34.6.3. The date Type #
231 The date type in C enables your programs to deal with data of the SQL
232 type date. See Section 8.5 for the equivalent type in the PostgreSQL
235 The following functions can be used to work with the date type:
237 PGTYPESdate_from_timestamp #
238 Extract the date part from a timestamp.
240 date PGTYPESdate_from_timestamp(timestamp dt);
242 The function receives a timestamp as its only argument and
243 returns the extracted date part from this timestamp.
245 PGTYPESdate_from_asc #
246 Parse a date from its textual representation.
248 date PGTYPESdate_from_asc(char *str, char **endptr);
250 The function receives a C char* string str and a pointer to a C
251 char* string endptr. At the moment ECPG always parses the
252 complete string and so it currently does not support to store
253 the address of the first invalid character in *endptr. You can
254 safely set endptr to NULL.
256 Note that the function always assumes MDY-formatted dates and
257 there is currently no variable to change that within ECPG.
259 Table 34.2 shows the allowed input formats.
261 Table 34.2. Valid Input Formats for PGTYPESdate_from_asc
264 January 8, 1999 January 8, 1999
265 1999-01-08 January 8, 1999
266 1/8/1999 January 8, 1999
267 1/18/1999 January 18, 1999
268 01/02/03 February 1, 2003
269 1999-Jan-08 January 8, 1999
270 Jan-08-1999 January 8, 1999
271 08-Jan-1999 January 8, 1999
272 99-Jan-08 January 8, 1999
273 08-Jan-99 January 8, 1999
274 08-Jan-06 January 8, 2006
275 Jan-08-99 January 8, 1999
276 19990108 ISO 8601; January 8, 1999
277 990108 ISO 8601; January 8, 1999
278 1999.008 year and day of year
280 January 8, 99 BC year 99 before the Common Era
283 Return the textual representation of a date variable.
285 char *PGTYPESdate_to_asc(date dDate);
287 The function receives the date dDate as its only parameter. It
288 will output the date in the form 1999-01-18, i.e., in the
289 YYYY-MM-DD format. The result must be freed with
293 Extract the values for the day, the month and the year from a
294 variable of type date.
296 void PGTYPESdate_julmdy(date d, int *mdy);
298 The function receives the date d and a pointer to an array of 3
299 integer values mdy. The variable name indicates the sequential
300 order: mdy[0] will be set to contain the number of the month,
301 mdy[1] will be set to the value of the day and mdy[2] will
305 Create a date value from an array of 3 integers that specify the
306 day, the month and the year of the date.
308 void PGTYPESdate_mdyjul(int *mdy, date *jdate);
310 The function receives the array of the 3 integers (mdy) as its
311 first argument and as its second argument a pointer to a
312 variable of type date that should hold the result of the
315 PGTYPESdate_dayofweek #
316 Return a number representing the day of the week for a date
319 int PGTYPESdate_dayofweek(date d);
321 The function receives the date variable d as its only argument
322 and returns an integer that indicates the day of the week for
334 Get the current date.
336 void PGTYPESdate_today(date *d);
338 The function receives a pointer to a date variable (d) that it
339 sets to the current date.
341 PGTYPESdate_fmt_asc #
342 Convert a variable of type date to its textual representation
345 int PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf);
347 The function receives the date to convert (dDate), the format
348 mask (fmtstring) and the string that will hold the textual
349 representation of the date (outbuf).
351 On success, 0 is returned and a negative value if an error
354 The following literals are the field specifiers you can use:
356 + dd - The number of the day of the month.
357 + mm - The number of the month of the year.
358 + yy - The number of the year as a two digit number.
359 + yyyy - The number of the year as a four digit number.
360 + ddd - The name of the day (abbreviated).
361 + mmm - The name of the month (abbreviated).
363 All other characters are copied 1:1 to the output string.
365 Table 34.3 indicates a few possible formats. This will give you
366 an idea of how to use this function. All output lines are based
367 on the same date: November 23, 1959.
369 Table 34.3. Valid Input Formats for PGTYPESdate_fmt_asc
378 .mm.yyyy.dd. .11.1959.23.
379 mmm. dd, yyyy Nov. 23, 1959
380 mmm dd yyyy Nov 23 1959
381 yyyy dd mm 1959 23 11
382 ddd, mmm. dd, yyyy Mon, Nov. 23, 1959
383 (ddd) mmm. dd, yyyy (Mon) Nov. 23, 1959
385 PGTYPESdate_defmt_asc #
386 Use a format mask to convert a C char* string to a value of type
389 int PGTYPESdate_defmt_asc(date *d, char *fmt, char *str);
391 The function receives a pointer to the date value that should
392 hold the result of the operation (d), the format mask to use for
393 parsing the date (fmt) and the C char* string containing the
394 textual representation of the date (str). The textual
395 representation is expected to match the format mask. However you
396 do not need to have a 1:1 mapping of the string to the format
397 mask. The function only analyzes the sequential order and looks
398 for the literals yy or yyyy that indicate the position of the
399 year, mm to indicate the position of the month and dd to
400 indicate the position of the day.
402 Table 34.4 indicates a few possible formats. This will give you
403 an idea of how to use this function.
405 Table 34.4. Valid Input Formats for rdefmtdate
408 ddmmyy 21-2-54 1954-02-21
409 ddmmyy 2-12-54 1954-12-02
410 ddmmyy 20111954 1954-11-20
411 ddmmyy 130464 1964-04-13
412 mmm.dd.yyyy MAR-12-1967 1967-03-12
413 yy/mm/dd 1954, February 3rd 1954-02-03
414 mmm.dd.yyyy 041269 1969-04-12
415 yy/mm/dd In the year 2525, in the month of July, mankind will be alive
416 on the 28th day 2525-07-28
417 dd-mm-yy I said on the 28th of July in the year 2525 2525-07-28
418 mmm.dd.yyyy 9/14/58 1958-09-14
419 yy/mm/dd 47/03/29 1947-03-29
420 mmm.dd.yyyy oct 28 1975 1975-10-28
421 mmddyy Nov 14th, 1985 1985-11-14
423 34.6.4. The timestamp Type #
425 The timestamp type in C enables your programs to deal with data of the
426 SQL type timestamp. See Section 8.5 for the equivalent type in the
429 The following functions can be used to work with the timestamp type:
431 PGTYPEStimestamp_from_asc #
432 Parse a timestamp from its textual representation into a
435 timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr);
437 The function receives the string to parse (str) and a pointer to
438 a C char* (endptr). At the moment ECPG always parses the
439 complete string and so it currently does not support to store
440 the address of the first invalid character in *endptr. You can
441 safely set endptr to NULL.
443 The function returns the parsed timestamp on success. On error,
444 PGTYPESInvalidTimestamp is returned and errno is set to
445 PGTYPES_TS_BAD_TIMESTAMP. See PGTYPESInvalidTimestamp for
446 important notes on this value.
448 In general, the input string can contain any combination of an
449 allowed date specification, a whitespace character and an
450 allowed time specification. Note that time zones are not
451 supported by ECPG. It can parse them but does not apply any
452 calculation as the PostgreSQL server does for example. Timezone
453 specifiers are silently discarded.
455 Table 34.5 contains a few examples for input strings.
457 Table 34.5. Valid Input Formats for PGTYPEStimestamp_from_asc
460 1999-01-08 04:05:06 1999-01-08 04:05:06
461 January 8 04:05:06 1999 PST 1999-01-08 04:05:06
462 1999-Jan-08 04:05:06.789-8 1999-01-08 04:05:06.789 (time zone specifier
464 J2451187 04:05-08:00 1999-01-08 04:05:00 (time zone specifier ignored)
466 PGTYPEStimestamp_to_asc #
467 Converts a date to a C char* string.
469 char *PGTYPEStimestamp_to_asc(timestamp tstamp);
471 The function receives the timestamp tstamp as its only argument
472 and returns an allocated string that contains the textual
473 representation of the timestamp. The result must be freed with
476 PGTYPEStimestamp_current #
477 Retrieve the current timestamp.
479 void PGTYPEStimestamp_current(timestamp *ts);
481 The function retrieves the current timestamp and saves it into
482 the timestamp variable that ts points to.
484 PGTYPEStimestamp_fmt_asc #
485 Convert a timestamp variable to a C char* using a format mask.
487 int PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmt
490 The function receives a pointer to the timestamp to convert as
491 its first argument (ts), a pointer to the output buffer
492 (output), the maximal length that has been allocated for the
493 output buffer (str_len) and the format mask to use for the
496 Upon success, the function returns 0 and a negative value if an
499 You can use the following format specifiers for the format mask.
500 The format specifiers are the same ones that are used in the
501 strftime function in libc. Any non-format specifier will be
502 copied into the output buffer.
504 + %A - is replaced by national representation of the full
506 + %a - is replaced by national representation of the abbreviated
508 + %B - is replaced by national representation of the full month
510 + %b - is replaced by national representation of the abbreviated
512 + %C - is replaced by (year / 100) as decimal number; single
513 digits are preceded by a zero.
514 + %c - is replaced by national representation of time and date.
515 + %D - is equivalent to %m/%d/%y.
516 + %d - is replaced by the day of the month as a decimal number
518 + %E* %O* - POSIX locale extensions. The sequences %Ec %EC %Ex
519 %EX %Ey %EY %Od %Oe %OH %OI %Om %OM %OS %Ou %OU %OV %Ow %OW
520 %Oy are supposed to provide alternative representations.
521 Additionally %OB implemented to represent alternative months
522 names (used standalone, without day mentioned).
523 + %e - is replaced by the day of month as a decimal number
524 (1–31); single digits are preceded by a blank.
525 + %F - is equivalent to %Y-%m-%d.
526 + %G - is replaced by a year as a decimal number with century.
527 This year is the one that contains the greater part of the
528 week (Monday as the first day of the week).
529 + %g - is replaced by the same year as in %G, but as a decimal
530 number without century (00–99).
531 + %H - is replaced by the hour (24-hour clock) as a decimal
533 + %h - the same as %b.
534 + %I - is replaced by the hour (12-hour clock) as a decimal
536 + %j - is replaced by the day of the year as a decimal number
538 + %k - is replaced by the hour (24-hour clock) as a decimal
539 number (0–23); single digits are preceded by a blank.
540 + %l - is replaced by the hour (12-hour clock) as a decimal
541 number (1–12); single digits are preceded by a blank.
542 + %M - is replaced by the minute as a decimal number (00–59).
543 + %m - is replaced by the month as a decimal number (01–12).
544 + %n - is replaced by a newline.
545 + %O* - the same as %E*.
546 + %p - is replaced by national representation of either “ante
547 meridiem” or “post meridiem” as appropriate.
548 + %R - is equivalent to %H:%M.
549 + %r - is equivalent to %I:%M:%S %p.
550 + %S - is replaced by the second as a decimal number (00–60).
551 + %s - is replaced by the number of seconds since the Epoch,
553 + %T - is equivalent to %H:%M:%S
554 + %t - is replaced by a tab.
555 + %U - is replaced by the week number of the year (Sunday as the
556 first day of the week) as a decimal number (00–53).
557 + %u - is replaced by the weekday (Monday as the first day of
558 the week) as a decimal number (1–7).
559 + %V - is replaced by the week number of the year (Monday as the
560 first day of the week) as a decimal number (01–53). If the
561 week containing January 1 has four or more days in the new
562 year, then it is week 1; otherwise it is the last week of the
563 previous year, and the next week is week 1.
564 + %v - is equivalent to %e-%b-%Y.
565 + %W - is replaced by the week number of the year (Monday as the
566 first day of the week) as a decimal number (00–53).
567 + %w - is replaced by the weekday (Sunday as the first day of
568 the week) as a decimal number (0–6).
569 + %X - is replaced by national representation of the time.
570 + %x - is replaced by national representation of the date.
571 + %Y - is replaced by the year with century as a decimal number.
572 + %y - is replaced by the year without century as a decimal
574 + %Z - is replaced by the time zone name.
575 + %z - is replaced by the time zone offset from UTC; a leading
576 plus sign stands for east of UTC, a minus sign for west of
577 UTC, hours and minutes follow with two digits each and no
578 delimiter between them (common form for RFC 822 date headers).
579 + %+ - is replaced by national representation of the date and
581 + %-* - GNU libc extension. Do not do any padding when
582 performing numerical outputs.
583 + $_* - GNU libc extension. Explicitly specify space for
585 + %0* - GNU libc extension. Explicitly specify zero for padding.
586 + %% - is replaced by %.
588 PGTYPEStimestamp_sub #
589 Subtract one timestamp from another one and save the result in a
590 variable of type interval.
592 int PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv);
594 The function will subtract the timestamp variable that ts2
595 points to from the timestamp variable that ts1 points to and
596 will store the result in the interval variable that iv points
599 Upon success, the function returns 0 and a negative value if an
602 PGTYPEStimestamp_defmt_asc #
603 Parse a timestamp value from its textual representation using a
606 int PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d);
608 The function receives the textual representation of a timestamp
609 in the variable str as well as the formatting mask to use in the
610 variable fmt. The result will be stored in the variable that d
613 If the formatting mask fmt is NULL, the function will fall back
614 to the default formatting mask which is %Y-%m-%d %H:%M:%S.
616 This is the reverse function to PGTYPEStimestamp_fmt_asc. See
617 the documentation there in order to find out about the possible
618 formatting mask entries.
620 PGTYPEStimestamp_add_interval #
621 Add an interval variable to a timestamp variable.
623 int PGTYPEStimestamp_add_interval(timestamp *tin, interval *span, timestamp *tou
626 The function receives a pointer to a timestamp variable tin and
627 a pointer to an interval variable span. It adds the interval to
628 the timestamp and saves the resulting timestamp in the variable
631 Upon success, the function returns 0 and a negative value if an
634 PGTYPEStimestamp_sub_interval #
635 Subtract an interval variable from a timestamp variable.
637 int PGTYPEStimestamp_sub_interval(timestamp *tin, interval *span, timestamp *tou
640 The function subtracts the interval variable that span points to
641 from the timestamp variable that tin points to and saves the
642 result into the variable that tout points to.
644 Upon success, the function returns 0 and a negative value if an
647 34.6.5. The interval Type #
649 The interval type in C enables your programs to deal with data of the
650 SQL type interval. See Section 8.5 for the equivalent type in the
653 The following functions can be used to work with the interval type:
655 PGTYPESinterval_new #
656 Return a pointer to a newly allocated interval variable.
658 interval *PGTYPESinterval_new(void);
660 PGTYPESinterval_free #
661 Release the memory of a previously allocated interval variable.
663 void PGTYPESinterval_free(interval *intvl);
665 PGTYPESinterval_from_asc #
666 Parse an interval from its textual representation.
668 interval *PGTYPESinterval_from_asc(char *str, char **endptr);
670 The function parses the input string str and returns a pointer
671 to an allocated interval variable. At the moment ECPG always
672 parses the complete string and so it currently does not support
673 to store the address of the first invalid character in *endptr.
674 You can safely set endptr to NULL.
676 PGTYPESinterval_to_asc #
677 Convert a variable of type interval to its textual
680 char *PGTYPESinterval_to_asc(interval *span);
682 The function converts the interval variable that span points to
683 into a C char*. The output looks like this example: @ 1 day 12
684 hours 59 mins 10 secs. The result must be freed with
687 PGTYPESinterval_copy #
688 Copy a variable of type interval.
690 int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest);
692 The function copies the interval variable that intvlsrc points
693 to into the variable that intvldest points to. Note that you
694 need to allocate the memory for the destination variable before.
696 34.6.6. The decimal Type #
698 The decimal type is similar to the numeric type. However it is limited
699 to a maximum precision of 30 significant digits. In contrast to the
700 numeric type which can be created on the heap only, the decimal type
701 can be created either on the stack or on the heap (by means of the
702 functions PGTYPESdecimal_new and PGTYPESdecimal_free). There are a lot
703 of other functions that deal with the decimal type in the Informix
704 compatibility mode described in Section 34.15.
706 The following functions can be used to work with the decimal type and
707 are not only contained in the libcompat library.
710 Request a pointer to a newly allocated decimal variable.
712 decimal *PGTYPESdecimal_new(void);
714 PGTYPESdecimal_free #
715 Free a decimal type, release all of its memory.
717 void PGTYPESdecimal_free(decimal *var);
719 34.6.7. errno Values of pgtypeslib #
721 PGTYPES_NUM_BAD_NUMERIC #
722 An argument should contain a numeric variable (or point to a
723 numeric variable) but in fact its in-memory representation was
726 PGTYPES_NUM_OVERFLOW #
727 An overflow occurred. Since the numeric type can deal with
728 almost arbitrary precision, converting a numeric variable into
729 other types might cause overflow.
731 PGTYPES_NUM_UNDERFLOW #
732 An underflow occurred. Since the numeric type can deal with
733 almost arbitrary precision, converting a numeric variable into
734 other types might cause underflow.
736 PGTYPES_NUM_DIVIDE_ZERO #
737 A division by zero has been attempted.
739 PGTYPES_DATE_BAD_DATE #
740 An invalid date string was passed to the PGTYPESdate_from_asc
743 PGTYPES_DATE_ERR_EARGS #
744 Invalid arguments were passed to the PGTYPESdate_defmt_asc
747 PGTYPES_DATE_ERR_ENOSHORTDATE #
748 An invalid token in the input string was found by the
749 PGTYPESdate_defmt_asc function.
751 PGTYPES_INTVL_BAD_INTERVAL #
752 An invalid interval string was passed to the
753 PGTYPESinterval_from_asc function, or an invalid interval value
754 was passed to the PGTYPESinterval_to_asc function.
756 PGTYPES_DATE_ERR_ENOTDMY #
757 There was a mismatch in the day/month/year assignment in the
758 PGTYPESdate_defmt_asc function.
760 PGTYPES_DATE_BAD_DAY #
761 An invalid day of the month value was found by the
762 PGTYPESdate_defmt_asc function.
764 PGTYPES_DATE_BAD_MONTH #
765 An invalid month value was found by the PGTYPESdate_defmt_asc
768 PGTYPES_TS_BAD_TIMESTAMP #
769 An invalid timestamp string pass passed to the
770 PGTYPEStimestamp_from_asc function, or an invalid timestamp
771 value was passed to the PGTYPEStimestamp_to_asc function.
773 PGTYPES_TS_ERR_EINFTIME #
774 An infinite timestamp value was encountered in a context that
777 34.6.8. Special Constants of pgtypeslib #
779 PGTYPESInvalidTimestamp #
780 A value of type timestamp representing an invalid time stamp.
781 This is returned by the function PGTYPEStimestamp_from_asc on
782 parse error. Note that due to the internal representation of the
783 timestamp data type, PGTYPESInvalidTimestamp is also a valid
784 timestamp at the same time. It is set to 1899-12-31 23:59:59. In
785 order to detect errors, make sure that your application does not
786 only test for PGTYPESInvalidTimestamp but also for errno != 0
787 after each call to PGTYPEStimestamp_from_asc.