diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml index 48684cf..b551636 100644 --- a/doc/src/sgml/ecpg.sgml +++ b/doc/src/sgml/ecpg.sgml @@ -2164,11 +2164,13 @@ numeric *PGTYPESnumeric_from_asc(char *str, char **endptr); +3.44, 592.49E07 or -32.84e-4. - If the value could be parsed successfully, a valid pointer is returned, - else the NULL pointer. At the moment ECPG always parses the complete - string and so it currently does not support to store the address of the - first invalid character in *endptr. You can safely - set endptr to NULL. + If the function detects invalid format, + then it stores the address of the first invalid character in + endptr. However, don't assume it successed if + endptr points to end of input because other + processing(e.g. memory allocation) could fails. + Therefore, you should check return value and errno for detecting error. + You can safely endptr to NULL. @@ -2469,12 +2471,20 @@ date PGTYPESdate_from_timestamp(timestamp dt); date PGTYPESdate_from_asc(char *str, char **endptr); The function receives a C char* string str and a pointer to - a C char* string endptr. At the moment ECPG always parses - the complete string and so it currently does not support to store the - address of the first invalid character in *endptr. - You can safely set endptr to NULL. + a C char* string endptr. + If the function detects invalid format, + then it stores the address of the first invalid character in + endptr. However, don't assume it successed if + endptr points to end of input because other + processing(e.g. memory allocation) could fails. + Therefore, you should check errno for detecting error. + You can safely endptr to NULL. + The global variable errno will be set if an error occurs. + In order to detect errors, check errno != 0 after calling. + + Note that the function always assumes MDY-formatted dates and there is currently no variable to change that within ECPG. @@ -2826,6 +2836,10 @@ int PGTYPESdate_defmt_asc(date *d, char *fmt, char *str); day. + Upon success, the function returns 0 and a negative value if an error occurred. + The global variable errno will be set if an error occurs. + + indicates a few possible formats. This will give you an idea of how to use this function. @@ -2935,10 +2949,13 @@ timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr); The function receives the string to parse (str) and a pointer to a C char* (endptr). - At the moment ECPG always parses - the complete string and so it currently does not support to store the - address of the first invalid character in *endptr. - You can safely set endptr to NULL. + If the function detects invalid format, + then it stores the address of the first invalid character in + endptr. However, don't assume it successed if + endptr points to end of input because other + processing(e.g. memory allocation) could fails. + Therefore, you should check return value and errno for detecting error. + You can safely endptr to NULL. The function returns the parsed timestamp on success. On error, @@ -3007,6 +3024,9 @@ char *PGTYPEStimestamp_to_asc(timestamp tstamp); textual representation of the timestamp. The result must be freed with PGTYPESchar_free(). + + The function returns NULL and sets the global variable errno if an error occurred. + @@ -3395,6 +3415,10 @@ int PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d); that d points to. + Upon success, the function returns 0 and 1 if an error occurred. + The global variable errno will not be set if an error occurs. + + If the formatting mask fmt is NULL, the function will fall back to the default formatting mask which is %Y-%m-%d %H:%M:%S. @@ -3465,7 +3489,7 @@ int PGTYPEStimestamp_sub_interval(timestamp *tin, interval *span, timestamp *tou PGTYPESinterval_new - Return a pointer to a newly allocated interval variable. + Return a pointer to a newly allocated interval variable and NULL if an error occurred. interval *PGTYPESinterval_new(void); @@ -3495,10 +3519,16 @@ interval *PGTYPESinterval_from_asc(char *str, char **endptr); The function parses the input string str and returns a pointer to an allocated interval variable. - At the moment ECPG always parses - the complete string and so it currently does not support to store the - address of the first invalid character in *endptr. - You can safely set endptr to NULL. + If the function detects invalid format, + then it stores the address of the first invalid character in + endptr. However, don't assume it successed if + endptr points to end of input because other + processing(e.g. memory allocation) could fails. + Therefore, you should check return value and errno for detecting error. + You can safely endptr to NULL. + + + It returns NULL and sets the global variable errno if an error occurs. @@ -3516,6 +3546,9 @@ char *PGTYPESinterval_to_asc(interval *span); @ 1 day 12 hours 59 mins 10 secs. The result must be freed with PGTYPESchar_free(). + + It returns NULL and sets the global variable errno if an error occurs. + @@ -3532,6 +3565,9 @@ int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest); that you need to allocate the memory for the destination variable before. + + Upon success, the function returns 0 and non-0 value if an error occurred. + @@ -3559,7 +3595,7 @@ int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest); PGTYPESdecimal_new - Request a pointer to a newly allocated decimal variable. + Request a pointer to a newly allocated decimal variable and NULL if an error occurred. decimal *PGTYPESdecimal_new(void);