mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Applied patch by Ron Mayer <rm_pg@cheapcomplexdevices.com> to merge the new
interval style into ecpg.
This commit is contained in:
parent
cbb3e1cda7
commit
7c5a561f31
@ -2394,6 +2394,8 @@ Sat, 25 Oct 2008 16:34:28 +0200
|
||||
Wed, 26 Nov 2008 14:09:08 +0100
|
||||
|
||||
- When creating a varchar struct name braces must be discarded.
|
||||
- Applied patch by Ron Mayer <rm_pg@cheapcomplexdevices.com> to merge
|
||||
the new interval style into ecpg.
|
||||
- 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.h,v 1.39 2007/11/15 21:14:45 momjian Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.40 2008/11/26 16:31:02 meskes Exp $ */
|
||||
|
||||
#ifndef DT_H
|
||||
#define DT_H
|
||||
@ -25,6 +25,22 @@ typedef double fsec_t;
|
||||
#define USE_SQL_DATES 2
|
||||
#define USE_GERMAN_DATES 3
|
||||
|
||||
#define INTSTYLE_POSTGRES 0
|
||||
#define INTSTYLE_POSTGRES_VERBOSE 1
|
||||
#define INTSTYLE_SQL_STANDARD 2
|
||||
#define INTSTYLE_ISO_8601 3
|
||||
|
||||
#define INTERVAL_FULL_RANGE (0x7FFF)
|
||||
#define INTERVAL_MASK(b) (1 << (b))
|
||||
#define MAX_INTERVAL_PRECISION 6
|
||||
|
||||
#define DTERR_BAD_FORMAT (-1)
|
||||
#define DTERR_FIELD_OVERFLOW (-2)
|
||||
#define DTERR_MD_FIELD_OVERFLOW (-3) /* triggers hint about DateStyle */
|
||||
#define DTERR_INTERVAL_OVERFLOW (-4)
|
||||
#define DTERR_TZDISP_OVERFLOW (-5)
|
||||
|
||||
|
||||
#define DAGO "ago"
|
||||
#define EPOCH "epoch"
|
||||
#define INVALID "invalid"
|
||||
@ -77,6 +93,9 @@ typedef double fsec_t;
|
||||
* Furthermore, the values for YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
|
||||
* must be in the range 0..14 so that the associated bitmasks can fit
|
||||
* into the left half of an INTERVAL's typmod value.
|
||||
*
|
||||
* Copy&pasted these values from src/include/utils/datetime.h
|
||||
* 2008-11-20, changing a number of their values.
|
||||
*/
|
||||
|
||||
#define RESERV 0
|
||||
@ -92,20 +111,23 @@ typedef double fsec_t;
|
||||
#define HOUR 10
|
||||
#define MINUTE 11
|
||||
#define SECOND 12
|
||||
#define DOY 13
|
||||
#define DOW 14
|
||||
#define UNITS 15
|
||||
#define ADBC 16
|
||||
#define MILLISECOND 13
|
||||
#define MICROSECOND 14
|
||||
#define DOY 15
|
||||
#define DOW 16
|
||||
#define UNITS 17
|
||||
#define ADBC 18
|
||||
/* these are only for relative dates */
|
||||
#define AGO 17
|
||||
#define ABS_BEFORE 18
|
||||
#define ABS_AFTER 19
|
||||
#define AGO 19
|
||||
#define ABS_BEFORE 20
|
||||
#define ABS_AFTER 21
|
||||
/* generic fields to help with parsing */
|
||||
#define ISODATE 20
|
||||
#define ISOTIME 21
|
||||
#define ISODATE 22
|
||||
#define ISOTIME 23
|
||||
/* reserved for unrecognized string values */
|
||||
#define UNKNOWN_FIELD 31
|
||||
|
||||
|
||||
/*
|
||||
* Token field definitions for time parsing and decoding.
|
||||
* These need to fit into the datetkn table type.
|
||||
@ -164,13 +186,13 @@ typedef double fsec_t;
|
||||
/*
|
||||
* Bit mask definitions for time parsing.
|
||||
*/
|
||||
|
||||
/* Copy&pasted these values from src/include/utils/datetime.h */
|
||||
#define DTK_M(t) (0x01 << (t))
|
||||
|
||||
#define DTK_ALL_SECS_M (DTK_M(SECOND) | DTK_M(MILLISECOND) | DTK_M(MICROSECOND))
|
||||
#define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
|
||||
#define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND))
|
||||
|
||||
#define MAXDATELEN 51 /* maximum possible length of an input date
|
||||
#define MAXDATELEN 63 /* maximum possible length of an input date
|
||||
* string (not counting tr. null) */
|
||||
#define MAXDATEFIELDS 25 /* maximum possible number of fields in a date
|
||||
* string */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -77,6 +77,12 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 30 "dt_test.pgc"
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set intervalstyle to postgres_verbose", ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 31 "dt_test.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 31 "dt_test.pgc"
|
||||
|
||||
|
||||
date1 = PGTYPESdate_from_asc(d1, NULL);
|
||||
ts1 = PGTYPEStimestamp_from_asc(t1, NULL);
|
||||
@ -86,10 +92,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 35 "dt_test.pgc"
|
||||
#line 36 "dt_test.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 35 "dt_test.pgc"
|
||||
#line 36 "dt_test.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from date_test where d = $1 ",
|
||||
@ -99,10 +105,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
|
||||
#line 37 "dt_test.pgc"
|
||||
#line 38 "dt_test.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 37 "dt_test.pgc"
|
||||
#line 38 "dt_test.pgc"
|
||||
|
||||
|
||||
text = PGTYPESdate_to_asc(date1);
|
||||
@ -417,16 +423,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
free(text);
|
||||
|
||||
{ ECPGtrans(__LINE__, NULL, "rollback ");
|
||||
#line 350 "dt_test.pgc"
|
||||
#line 351 "dt_test.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 350 "dt_test.pgc"
|
||||
#line 351 "dt_test.pgc"
|
||||
|
||||
{ ECPGdisconnect(__LINE__, "CURRENT");
|
||||
#line 351 "dt_test.pgc"
|
||||
#line 352 "dt_test.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint ( );}
|
||||
#line 351 "dt_test.pgc"
|
||||
#line 352 "dt_test.pgc"
|
||||
|
||||
|
||||
return (0);
|
||||
|
@ -14,29 +14,35 @@
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 30: OK: SET
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 35: query: insert into date_test ( d , ts ) values ( $1 , $2 ) ; with 2 parameter(s) on connection regress1
|
||||
[NO_PID]: ecpg_execute on line 31: query: set intervalstyle to postgres_verbose; with 0 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 35: using PQexecParams
|
||||
[NO_PID]: ecpg_execute on line 31: using PQexec
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: free_params on line 35: parameter 1 = 1966-01-17
|
||||
[NO_PID]: ecpg_execute on line 31: OK: SET
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: free_params on line 35: parameter 2 = 2000-07-12 17:34:29
|
||||
[NO_PID]: ecpg_execute on line 36: query: insert into date_test ( d , ts ) values ( $1 , $2 ) ; with 2 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
|
||||
[NO_PID]: ecpg_execute on line 36: using PQexecParams
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 37: query: select * from date_test where d = $1 ; with 1 parameter(s) on connection regress1
|
||||
[NO_PID]: free_params on line 36: parameter 1 = 1966-01-17
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 37: using PQexecParams
|
||||
[NO_PID]: free_params on line 36: parameter 2 = 2000-07-12 17:34:29
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: free_params on line 37: parameter 1 = 1966-01-17
|
||||
[NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 37: correctly got 1 tuples with 2 fields
|
||||
[NO_PID]: ecpg_execute on line 38: query: select * from date_test where d = $1 ; with 1 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_get_data on line 37: RESULT: 1966-01-17 offset: -1; array: yes
|
||||
[NO_PID]: ecpg_execute on line 38: using PQexecParams
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_get_data on line 37: RESULT: 2000-07-12 17:34:29 offset: -1; array: yes
|
||||
[NO_PID]: free_params on line 38: parameter 1 = 1966-01-17
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ECPGtrans on line 350: action "rollback "; connection "regress1"
|
||||
[NO_PID]: ecpg_execute on line 38: correctly got 1 tuples with 2 fields
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_get_data on line 38: RESULT: 1966-01-17 offset: -1; array: yes
|
||||
[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]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_finish: connection regress1 closed
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
|
@ -28,6 +28,7 @@ main(void)
|
||||
exec sql connect to REGRESSDB1;
|
||||
exec sql create table date_test (d date, ts timestamp);
|
||||
exec sql set datestyle to iso;
|
||||
exec sql set intervalstyle to postgres_verbose;
|
||||
|
||||
date1 = PGTYPESdate_from_asc(d1, NULL);
|
||||
ts1 = PGTYPEStimestamp_from_asc(t1, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user