mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Fixed bug in %s handling.
This commit is contained in:
parent
5e21197c7b
commit
77ca045384
@ -2405,6 +2405,10 @@ Wed, 17 Dec 2008 17:49:11 +0100
|
||||
|
||||
- Applied patch by ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> to
|
||||
fix segfault on non-glibc systems.
|
||||
|
||||
Mon, 02 Feb 2009 16:34:53 +0100
|
||||
|
||||
- Fixed bug in handling of "%s" pattern in PGTYPEStimestamp_defmt_asc().
|
||||
- Set pgtypes library version to 3.1.
|
||||
- Set compat library version to 3.1.
|
||||
- Set ecpg library version to 6.2.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.44 2007/11/15 21:14:45 momjian Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.45 2009/02/02 15:35:28 meskes Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@ -990,17 +990,13 @@ GetEpochTime(struct tm * tm)
|
||||
|
||||
t0 = gmtime(&epoch);
|
||||
|
||||
tm->tm_year = t0->tm_year;
|
||||
tm->tm_mon = t0->tm_mon;
|
||||
tm->tm_year = t0->tm_year + 1900;
|
||||
tm->tm_mon = t0->tm_mon + 1;
|
||||
tm->tm_mday = t0->tm_mday;
|
||||
tm->tm_hour = t0->tm_hour;
|
||||
tm->tm_min = t0->tm_min;
|
||||
tm->tm_sec = t0->tm_sec;
|
||||
|
||||
if (tm->tm_year < 1900)
|
||||
tm->tm_year += 1900;
|
||||
tm->tm_mon++;
|
||||
|
||||
return;
|
||||
} /* GetEpochTime() */
|
||||
|
||||
@ -2856,8 +2852,8 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
|
||||
time_t et = (time_t) scan_val.luint_val;
|
||||
|
||||
tms = gmtime(&et);
|
||||
*year = tms->tm_year;
|
||||
*month = tms->tm_mon;
|
||||
*year = tms->tm_year + 1900;
|
||||
*month = tms->tm_mon + 1;
|
||||
*day = tms->tm_mday;
|
||||
*hour = tms->tm_hour;
|
||||
*minute = tms->tm_min;
|
||||
|
@ -422,17 +422,24 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
free(text);
|
||||
|
||||
in = "1234567890";
|
||||
fmt = "%s";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
free(text);
|
||||
|
||||
{ ECPGtrans(__LINE__, NULL, "rollback");
|
||||
#line 351 "dt_test.pgc"
|
||||
#line 358 "dt_test.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 351 "dt_test.pgc"
|
||||
#line 358 "dt_test.pgc"
|
||||
|
||||
{ ECPGdisconnect(__LINE__, "CURRENT");
|
||||
#line 352 "dt_test.pgc"
|
||||
#line 359 "dt_test.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 352 "dt_test.pgc"
|
||||
#line 359 "dt_test.pgc"
|
||||
|
||||
|
||||
return (0);
|
||||
|
@ -42,7 +42,7 @@
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_get_data on line 38: RESULT: 2000-07-12 17:34:29 offset: -1; array: yes
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ECPGtrans on line 351: action "rollback"; connection "regress1"
|
||||
[NO_PID]: ECPGtrans on line 358: action "rollback"; connection "regress1"
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_finish: connection regress1 closed
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
|
@ -46,3 +46,4 @@ timestamp_defmt_asc(September 6 at 01:30 pm in the year 1983, %B %d at %I:%M %p
|
||||
timestamp_defmt_asc( 1976, July 14. Time: 9:15am, %Y, %B %d. Time: %I:%M %p) = 1976-07-14 09:15:00, error: 0
|
||||
timestamp_defmt_asc( 1976, July 14. Time: 9:15 am, %Y, %B %d. Time: %I:%M%p) = 1976-07-14 09:15:00, error: 0
|
||||
timestamp_defmt_asc( 1976, P.M. July 14. Time: 9:15, %Y, %P %B %d. Time: %I:%M) = 1976-07-14 21:15:00, error: 0
|
||||
timestamp_defmt_asc(1234567890, %s) = 2009-02-13 23:31:30, error: 0
|
||||
|
@ -348,6 +348,13 @@ main(void)
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
free(text);
|
||||
|
||||
in = "1234567890";
|
||||
fmt = "%s";
|
||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||
text = PGTYPEStimestamp_to_asc(ts1);
|
||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||
free(text);
|
||||
|
||||
exec sql rollback;
|
||||
exec sql disconnect;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user