LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/pgtypeslib - dt_test.pgc (source / functions) Coverage Total Hit UBC CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 97.8 % 319 312 7 312
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 2 2 2
Baseline: lcov-20250907-010129-baseline Branches: 47.4 % 19 9 10 9
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 63.2 % 19 12 7 12
(360..) days: 100.0 % 300 300 300
Function coverage date bins:
(30,360] days: 100.0 % 1 1 1
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(30,360] days: 33.3 % 3 1 2 1
(360..) days: 50.0 % 16 8 8 8

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdio.h>
                                  2                 :                : #include <string.h>
                                  3                 :                : #include <stdlib.h>
                                  4                 :                : #include <pgtypes_date.h>
                                  5                 :                : #include <pgtypes_error.h>
                                  6                 :                : #include <pgtypes_timestamp.h>
                                  7                 :                : #include <pgtypes_interval.h>
                                  8                 :                : 
                                  9                 :                : exec sql include ../regression;
                                 10                 :                : 
                                 11                 :                : static void check_errno(void);
                                 12                 :                : 
                                 13                 :                : int
 6976 meskes@postgresql.or       14                 :CBC           1 : main(void)
                                 15                 :                : {
                                 16                 :                :     exec sql begin declare section;
                                 17                 :                :         date date1;
                                 18                 :                :         timestamp ts1;
                                 19                 :                :         interval *iv1, iv2;
                                 20                 :                :         char *text;
                                 21                 :                :     exec sql end declare section;
                                 22                 :                :     date date2;
                                 23                 :              1 :     int mdy[3] = { 4, 19, 1998 };
                                 24                 :                :     char *fmt, *out, *in;
                                 25                 :              1 :     char *d1 = "Mon Jan 17 1966";
                                 26                 :              1 :     char *t1 = "2000-7-12 17:34:29";
                                 27                 :                :     int i;
                                 28                 :                : 
 5402 peter_e@gmx.net            29                 :              1 :     ECPGdebug(1, stderr);
                                 30                 :                :     exec sql whenever sqlerror do sqlprint();
                                 31                 :              1 :     exec sql connect to REGRESSDB1;
                                 32         [ -  + ]:              1 :     exec sql create table date_test (d date, ts timestamp);
 6976 meskes@postgresql.or       33         [ -  + ]:              1 :     exec sql set datestyle to iso;
 6129                            34         [ -  + ]:              1 :     exec sql set intervalstyle to postgres_verbose;
 6976                            35         [ -  + ]:              1 : 
 5402 peter_e@gmx.net            36                 :              1 :     date1 = PGTYPESdate_from_asc(d1, NULL);
                                 37                 :              1 :     ts1 = PGTYPEStimestamp_from_asc(t1, NULL);
                                 38                 :                : 
 6971 meskes@postgresql.or       39                 :              1 :     exec sql insert into date_test(d, ts) values (:date1, :ts1);
 6976                            40         [ -  + ]:              1 : 
 6971                            41                 :              1 :     exec sql select * into :date1, :ts1 from date_test where d=:date1;
 6976                            42         [ -  + ]:              1 : 
                                 43                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                 44                 :              1 :     printf ("Date: %s\n", text);
 2638 tmunro@postgresql.or       45                 :              1 :     PGTYPESchar_free(text);
                                 46                 :                : 
 6976 meskes@postgresql.or       47                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                 48                 :              1 :     printf ("timestamp: %s\n", text);
 2638 tmunro@postgresql.or       49                 :              1 :     PGTYPESchar_free(text);
                                 50                 :                : 
 6971 meskes@postgresql.or       51                 :              1 :     iv1 = PGTYPESinterval_from_asc("13556 days 12 hours 34 minutes 14 seconds ", NULL);
                                 52                 :              1 :     PGTYPESinterval_copy(iv1, &iv2);
                                 53                 :              1 :     text = PGTYPESinterval_to_asc(&iv2);
 6976                            54                 :              1 :     printf ("interval: %s\n", text);
 5500                            55                 :              1 :     PGTYPESinterval_free(iv1);
 2638 tmunro@postgresql.or       56                 :              1 :     PGTYPESchar_free(text);
                                 57                 :                : 
 6976 meskes@postgresql.or       58                 :              1 :     PGTYPESdate_mdyjul(mdy, &date2);
                                 59                 :              1 :     printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
                                 60                 :                :     /* reset */
                                 61                 :              1 :     mdy[0] = mdy[1] = mdy[2] = 0;
                                 62                 :                : 
                                 63                 :              1 :     printf("date seems to get encoded to julian %ld\n", date2);
                                 64                 :                : 
                                 65                 :              1 :     PGTYPESdate_julmdy(date2, mdy);
                                 66                 :              1 :     printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
                                 67                 :                : 
                                 68                 :              1 :     ts1 = PGTYPEStimestamp_from_asc("2003-12-04 17:34:29", NULL);
                                 69                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                 70                 :              1 :     fmt = "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end";
                                 71                 :              1 :     out = (char*) malloc(strlen(fmt) + 1);
                                 72                 :              1 :     date1 = PGTYPESdate_from_timestamp(ts1);
                                 73                 :              1 :     PGTYPESdate_fmt_asc(date1, fmt, out);
 6956                            74                 :              1 :     printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(date1));
 6976                            75                 :              1 :     printf("Above date in format \"%s\" is \"%s\"\n", fmt, out);
 2638 tmunro@postgresql.or       76                 :              1 :     PGTYPESchar_free(text);
 6976 meskes@postgresql.or       77                 :              1 :     free(out);
                                 78                 :                : 
 4433                            79                 :              1 :     out = (char*) malloc(48);
                                 80                 :              1 :     i = PGTYPEStimestamp_fmt_asc(&ts1, out, 47, "Which is day number %j in %Y.");
                                 81                 :              1 :     printf("%s\n", out);
                                 82                 :              1 :     free(out);
                                 83                 :                : 
                                 84                 :                : 
                                 85                 :                :     /* rdate_defmt_asc() */
                                 86                 :                : 
 2930 peter_e@gmx.net            87                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or       88                 :              1 :     fmt = "yy/mm/dd";
                                 89                 :              1 :     in = "In the year 1995, the month of December, it is the 25th day";
                                 90                 :                :     /*    0123456789012345678901234567890123456789012345678901234567890
                                 91                 :                :      *    0         1         2         3         4         5         6
                                 92                 :                :      */
                                 93                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                 94                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                 95                 :              1 :     printf("date_defmt_asc1: %s\n", text);
 2638 tmunro@postgresql.or       96                 :              1 :     PGTYPESchar_free(text);
                                 97                 :                : 
 2930 peter_e@gmx.net            98                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or       99                 :              1 :     fmt = "mmmm. dd. yyyy";
                                100                 :              1 :     in = "12/25/95";
                                101                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                102                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                103                 :              1 :     printf("date_defmt_asc2: %s\n", text);
 2638 tmunro@postgresql.or      104                 :              1 :     PGTYPESchar_free(text);
                                105                 :                : 
 2930 peter_e@gmx.net           106                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      107                 :              1 :     fmt = "yy/mm/dd";
                                108                 :              1 :     in = "95/12/25";
                                109                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                110                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                111                 :              1 :     printf("date_defmt_asc3: %s\n", text);
 2638 tmunro@postgresql.or      112                 :              1 :     PGTYPESchar_free(text);
                                113                 :                : 
 2930 peter_e@gmx.net           114                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      115                 :              1 :     fmt = "yy/mm/dd";
                                116                 :              1 :     in = "1995, December 25th";
                                117                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                118                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                119                 :              1 :     printf("date_defmt_asc4: %s\n", text);
 2638 tmunro@postgresql.or      120                 :              1 :     PGTYPESchar_free(text);
                                121                 :                : 
 2930 peter_e@gmx.net           122                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      123                 :              1 :     fmt = "dd-mm-yy";
                                124                 :              1 :     in = "This is 25th day of December, 1995";
                                125                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                126                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                127                 :              1 :     printf("date_defmt_asc5: %s\n", text);
 2638 tmunro@postgresql.or      128                 :              1 :     PGTYPESchar_free(text);
                                129                 :                : 
 2930 peter_e@gmx.net           130                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      131                 :              1 :     fmt = "mmddyy";
                                132                 :              1 :     in = "Dec. 25th, 1995";
                                133                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                134                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                135                 :              1 :     printf("date_defmt_asc6: %s\n", text);
 2638 tmunro@postgresql.or      136                 :              1 :     PGTYPESchar_free(text);
                                137                 :                : 
 2930 peter_e@gmx.net           138                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      139                 :              1 :     fmt = "mmm. dd. yyyy";
                                140                 :              1 :     in = "dec 25th 1995";
                                141                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                142                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                143                 :              1 :     printf("date_defmt_asc7: %s\n", text);
 2638 tmunro@postgresql.or      144                 :              1 :     PGTYPESchar_free(text);
                                145                 :                : 
 2930 peter_e@gmx.net           146                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      147                 :              1 :     fmt = "mmm. dd. yyyy";
                                148                 :              1 :     in = "DEC-25-1995";
                                149                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                150                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                151                 :              1 :     printf("date_defmt_asc8: %s\n", text);
 2638 tmunro@postgresql.or      152                 :              1 :     PGTYPESchar_free(text);
                                153                 :                : 
 2930 peter_e@gmx.net           154                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      155                 :              1 :     fmt = "mm yy   dd.";
                                156                 :              1 :     in = "12199525";
                                157                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                158                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                159                 :              1 :     printf("date_defmt_asc9: %s\n", text);
 2638 tmunro@postgresql.or      160                 :              1 :     PGTYPESchar_free(text);
                                161                 :                : 
 2930 peter_e@gmx.net           162                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      163                 :              1 :     fmt = "yyyy fierj mm   dd.";
                                164                 :              1 :     in = "19951225";
                                165                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                166                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                167                 :              1 :     printf("date_defmt_asc10: %s\n", text);
 2638 tmunro@postgresql.or      168                 :              1 :     PGTYPESchar_free(text);
                                169                 :                : 
 2930 peter_e@gmx.net           170                 :              1 :     date1 = 0;
 6976 meskes@postgresql.or      171                 :              1 :     fmt = "mm/dd/yy";
                                172                 :              1 :     in = "122595";
                                173                 :              1 :     PGTYPESdate_defmt_asc(&date1, fmt, in);
                                174                 :              1 :     text = PGTYPESdate_to_asc(date1);
                                175                 :              1 :     printf("date_defmt_asc12: %s\n", text);
 2638 tmunro@postgresql.or      176                 :              1 :     PGTYPESchar_free(text);
                                177                 :                : 
 6976 meskes@postgresql.or      178                 :              1 :     PGTYPEStimestamp_current(&ts1);
                                179                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                180                 :                :     /* can't output this in regression mode */
                                181                 :                :     /* printf("timestamp_current: Now: %s\n", text); */
 2638 tmunro@postgresql.or      182                 :              1 :     PGTYPESchar_free(text);
                                183                 :                : 
 6976 meskes@postgresql.or      184                 :              1 :     ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
                                185                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                186                 :              1 :     printf("timestamp_to_asc1: %s\n", text);
 2638 tmunro@postgresql.or      187                 :              1 :     PGTYPESchar_free(text);
                                188                 :                : 
 6976 meskes@postgresql.or      189                 :              1 :     ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
                                190                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                191                 :              1 :     printf("timestamp_to_asc2: %s\n", text);
 2638 tmunro@postgresql.or      192                 :              1 :     PGTYPESchar_free(text);
                                193                 :                : 
 6976 meskes@postgresql.or      194                 :              1 :     ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
                                195                 :                :     /* failure, check error code */
  319 michael@paquier.xyz       196                 :              1 :     check_errno();
 6976 meskes@postgresql.or      197                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                198                 :              1 :     printf("timestamp_to_asc3: %s\n", text);
 2638 tmunro@postgresql.or      199                 :              1 :     PGTYPESchar_free(text);
                                200                 :                : 
  319 michael@paquier.xyz       201                 :              1 :     ts1 = PGTYPEStimestamp_from_asc("AM95000062", NULL);
                                202                 :                :     /* failure, check error code */
                                203                 :              1 :     check_errno();
                                204                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                205                 :              1 :     printf("timestamp_to_asc4: %s\n", text);
                                206                 :              1 :     PGTYPESchar_free(text);
                                207                 :                : 
                                208                 :                : /*  abc-03:10:35-def-02/11/94-gh  */
                                209                 :                : /*      12345678901234567890123456789 */
                                210                 :                : 
 6976 meskes@postgresql.or      211                 :              1 :     out = (char*) malloc(32);
                                212                 :              1 :     i = PGTYPEStimestamp_fmt_asc(&ts1, out, 31, "abc-%X-def-%x-ghi%%");
                                213                 :              1 :     printf("timestamp_fmt_asc: %d: %s\n", i, out);
                                214                 :              1 :     free(out);
                                215                 :                : 
                                216                 :              1 :     fmt = "This is a %m/%d/%y %H-%Ml%Stest";
                                217                 :              1 :     in =  "This is a 4/12/80 3-39l12test";
                                218                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                219                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                220                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      221                 :              1 :     PGTYPESchar_free(text);
                                222                 :                : 
 6976 meskes@postgresql.or      223                 :              1 :     fmt = "%a %b %d %H:%M:%S %z %Y";
                                224                 :              1 :     in =  "Tue Jul 22 17:28:44 +0200 2003";
                                225                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                226                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                227                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      228                 :              1 :     PGTYPESchar_free(text);
                                229                 :                : 
 6976 meskes@postgresql.or      230                 :              1 :     fmt = "%a %b %d %H:%M:%S %z %Y";
                                231                 :              1 :     in =  "Tue Feb 29 17:28:44 +0200 2000";
                                232                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                233                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                234                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      235                 :              1 :     PGTYPESchar_free(text);
                                236                 :                : 
 6976 meskes@postgresql.or      237                 :              1 :     fmt = "%a %b %d %H:%M:%S %z %Y";
                                238                 :              1 :     in =  "Tue Feb 29 17:28:44 +0200 1900";
                                239                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                240                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                241                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      242                 :              1 :     PGTYPESchar_free(text);
                                243                 :                : 
 6976 meskes@postgresql.or      244                 :              1 :     fmt = "%a %b %d %H:%M:%S %z %Y";
                                245                 :              1 :     in =  "Tue Feb 29 17:28:44 +0200 1996";
                                246                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                247                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                248                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      249                 :              1 :     PGTYPESchar_free(text);
                                250                 :                : 
 6976 meskes@postgresql.or      251                 :              1 :     fmt = "%b %d %H:%M:%S %z %Y";
                                252                 :              1 :     in =  "      Jul 31 17:28:44 +0200 1996";
                                253                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                254                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                255                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      256                 :              1 :     PGTYPESchar_free(text);
                                257                 :                : 
 6976 meskes@postgresql.or      258                 :              1 :     fmt = "%b %d %H:%M:%S %z %Y";
                                259                 :              1 :     in =  "      Jul 32 17:28:44 +0200 1996";
                                260                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                261                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                262                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      263                 :              1 :     PGTYPESchar_free(text);
                                264                 :                : 
 6976 meskes@postgresql.or      265                 :              1 :     fmt = "%a %b %d %H:%M:%S %z %Y";
                                266                 :              1 :     in =  "Tue Feb 29 17:28:44 +0200 1997";
                                267                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                268                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                269                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      270                 :              1 :     PGTYPESchar_free(text);
                                271                 :                : 
 6976 meskes@postgresql.or      272                 :              1 :     fmt = "%";
                                273                 :              1 :     in =  "Tue Jul 22 17:28:44 +0200 2003";
                                274                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                275                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                276                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      277                 :              1 :     PGTYPESchar_free(text);
                                278                 :                : 
 6976 meskes@postgresql.or      279                 :              1 :     fmt = "a %";
                                280                 :              1 :     in =  "Tue Jul 22 17:28:44 +0200 2003";
                                281                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                282                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                283                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      284                 :              1 :     PGTYPESchar_free(text);
                                285                 :                : 
 6976 meskes@postgresql.or      286                 :              1 :     fmt = "%b, %d %H_%M`%S %z %Y";
                                287                 :              1 :     in =  "    Jul, 22 17_28 `44 +0200  2003  ";
                                288                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                289                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                290                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      291                 :              1 :     PGTYPESchar_free(text);
                                292                 :                : 
 6976 meskes@postgresql.or      293                 :              1 :     fmt = "%a %b %%%d %H:%M:%S %Z %Y";
                                294                 :              1 :     in =  "Tue Jul %22 17:28:44 CEST 2003";
                                295                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                296                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                297                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      298                 :              1 :     PGTYPESchar_free(text);
                                299                 :                : 
 6976 meskes@postgresql.or      300                 :              1 :     fmt = "%a %b %%%d %H:%M:%S %Z %Y";
                                301                 :              1 :     in =  "Tue Jul %22 17:28:44 CEST 2003";
                                302                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                303                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                304                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      305                 :              1 :     PGTYPESchar_free(text);
                                306                 :                : 
 6976 meskes@postgresql.or      307                 :              1 :     fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
                                308                 :              1 :     in =  "abc\n   19 October %22 17:28:44 CEST 2003";
                                309                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                310                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                311                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      312                 :              1 :     PGTYPESchar_free(text);
                                313                 :                : 
 6976 meskes@postgresql.or      314                 :              1 :     fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
                                315                 :              1 :     in =  "abc\n   18 October %34 17:28:44 CEST 80";
                                316                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                317                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                318                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      319                 :              1 :     PGTYPESchar_free(text);
                                320                 :                : 
 6976 meskes@postgresql.or      321                 :              1 :     fmt = "";
                                322                 :              1 :     in =  "abc\n   18 October %34 17:28:44 CEST 80";
                                323                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                324                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                325                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      326                 :              1 :     PGTYPESchar_free(text);
                                327                 :                : 
 6976 meskes@postgresql.or      328                 :              1 :     fmt = NULL;
                                329                 :              1 :     in =  "1980-04-12 3:49:44      ";
                                330                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                331                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
 6973                           332                 :              1 :     printf("timestamp_defmt_asc(%s, NULL) = %s, error: %d\n", in, text, i);
 2638 tmunro@postgresql.or      333                 :              1 :     PGTYPESchar_free(text);
                                334                 :                : 
 6976 meskes@postgresql.or      335                 :              1 :     fmt = "%B %d, %Y. Time: %I:%M%p";
                                336                 :              1 :     in =  "July 14, 1988. Time: 9:15am";
                                337                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                338                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                339                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      340                 :              1 :     PGTYPESchar_free(text);
                                341                 :                : 
 6976 meskes@postgresql.or      342                 :              1 :     in = "September 6 at 01:30 pm in the year 1983";
                                343                 :              1 :     fmt = "%B %d at %I:%M %p in the year %Y";
                                344                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                345                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                346                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      347                 :              1 :     PGTYPESchar_free(text);
                                348                 :                : 
 6976 meskes@postgresql.or      349                 :              1 :     in = "  1976, July 14. Time: 9:15am";
                                350                 :              1 :     fmt = "%Y,   %B %d. Time: %I:%M %p";
                                351                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                352                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                353                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      354                 :              1 :     PGTYPESchar_free(text);
                                355                 :                : 
 6976 meskes@postgresql.or      356                 :              1 :     in = "  1976, July 14. Time: 9:15 am";
                                357                 :              1 :     fmt = "%Y,   %B %d. Time: %I:%M%p";
                                358                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                359                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                360                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      361                 :              1 :     PGTYPESchar_free(text);
                                362                 :                : 
 6976 meskes@postgresql.or      363                 :              1 :     in = "  1976, P.M. July 14. Time: 9:15";
                                364                 :              1 :     fmt = "%Y, %P  %B %d. Time: %I:%M";
                                365                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                366                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                367                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      368                 :              1 :     PGTYPESchar_free(text);
                                369                 :                : 
 6061 meskes@postgresql.or      370                 :              1 :     in = "1234567890";
                                371                 :              1 :     fmt = "%s";
                                372                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                373                 :              1 :     text = PGTYPEStimestamp_to_asc(ts1);
                                374                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
 2638 tmunro@postgresql.or      375                 :              1 :     PGTYPESchar_free(text);
                                376                 :                : 
 2108 tomas.vondra@postgre      377                 :              1 :     out = (char*) malloc(64);
                                378                 :              1 :     fmt = "%a %b %d %H:%M:%S %Y";
                                379                 :              1 :     in =  "Mon Dec 30 17:28:44 2019";
                                380                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                381                 :              1 :     i = PGTYPEStimestamp_fmt_asc(&ts1, out, 63, fmt);
                                382                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, out, i);
                                383                 :              1 :     free(out);
                                384                 :                : 
                                385                 :              1 :     out = (char*) malloc(64);
                                386                 :              1 :     fmt = "%a %b %d %H:%M:%S %Y";
                                387                 :              1 :     in =  "Mon December 30 17:28:44 2019";
                                388                 :              1 :     i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
                                389                 :              1 :     i = PGTYPEStimestamp_fmt_asc(&ts1, out, 63, fmt);
                                390                 :              1 :     printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, out, i);
                                391                 :              1 :     free(out);
                                392                 :                : 
 6976 meskes@postgresql.or      393                 :              1 :     exec sql rollback;
                                394         [ -  + ]:              1 :         exec sql disconnect;
                                395         [ -  + ]:              1 : 
 2943 peter_e@gmx.net           396                 :              1 :     return 0;
                                397                 :                : }
                                398                 :                : 
                                399                 :                : static void
  319 michael@paquier.xyz       400                 :              2 : check_errno(void)
                                401                 :                : {
                                402      [ -  +  - ]:              2 :     switch(errno)
                                403                 :                :     {
  319 michael@paquier.xyz       404                 :UBC           0 :         case 0:
                                405                 :              0 :             printf("(no errno set) - ");
                                406                 :              0 :             break;
  319 michael@paquier.xyz       407                 :CBC           2 :         case PGTYPES_TS_BAD_TIMESTAMP:
                                408                 :              2 :             printf("(errno == PGTYPES_TS_BAD_TIMESTAMP) - ");
                                409                 :              2 :             break;
  319 michael@paquier.xyz       410                 :UBC           0 :         default:
                                411                 :              0 :             printf("(unknown errno (%d))\n", errno);
                                412                 :              0 :             printf("(libc: (%s)) ", strerror(errno));
                                413                 :              0 :             break;
                                414                 :                :     }
  319 michael@paquier.xyz       415                 :CBC           2 : }
        

Generated by: LCOV version 2.4-beta