Commit 7c5a561f authored by Michael Meskes's avatar Michael Meskes

Applied patch by Ron Mayer <rm_pg@cheapcomplexdevices.com> to merge the new

interval style into ecpg.
parent cbb3e1cd
...@@ -2394,6 +2394,8 @@ Sat, 25 Oct 2008 16:34:28 +0200 ...@@ -2394,6 +2394,8 @@ Sat, 25 Oct 2008 16:34:28 +0200
Wed, 26 Nov 2008 14:09:08 +0100 Wed, 26 Nov 2008 14:09:08 +0100
- When creating a varchar struct name braces must be discarded. - 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 pgtypes library version to 3.1.
- Set compat library version to 3.1. - Set compat library version to 3.1.
- Set ecpg library version to 6.2. - Set ecpg library version to 6.2.
......
/* $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 #ifndef DT_H
#define DT_H #define DT_H
...@@ -25,6 +25,22 @@ typedef double fsec_t; ...@@ -25,6 +25,22 @@ typedef double fsec_t;
#define USE_SQL_DATES 2 #define USE_SQL_DATES 2
#define USE_GERMAN_DATES 3 #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 DAGO "ago"
#define EPOCH "epoch" #define EPOCH "epoch"
#define INVALID "invalid" #define INVALID "invalid"
...@@ -77,6 +93,9 @@ typedef double fsec_t; ...@@ -77,6 +93,9 @@ typedef double fsec_t;
* Furthermore, the values for YEAR, MONTH, DAY, HOUR, MINUTE, SECOND * Furthermore, the values for YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
* must be in the range 0..14 so that the associated bitmasks can fit * must be in the range 0..14 so that the associated bitmasks can fit
* into the left half of an INTERVAL's typmod value. * 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 #define RESERV 0
...@@ -92,20 +111,23 @@ typedef double fsec_t; ...@@ -92,20 +111,23 @@ typedef double fsec_t;
#define HOUR 10 #define HOUR 10
#define MINUTE 11 #define MINUTE 11
#define SECOND 12 #define SECOND 12
#define DOY 13 #define MILLISECOND 13
#define DOW 14 #define MICROSECOND 14
#define UNITS 15 #define DOY 15
#define ADBC 16 #define DOW 16
#define UNITS 17
#define ADBC 18
/* these are only for relative dates */ /* these are only for relative dates */
#define AGO 17 #define AGO 19
#define ABS_BEFORE 18 #define ABS_BEFORE 20
#define ABS_AFTER 19 #define ABS_AFTER 21
/* generic fields to help with parsing */ /* generic fields to help with parsing */
#define ISODATE 20 #define ISODATE 22
#define ISOTIME 21 #define ISOTIME 23
/* reserved for unrecognized string values */ /* reserved for unrecognized string values */
#define UNKNOWN_FIELD 31 #define UNKNOWN_FIELD 31
/* /*
* Token field definitions for time parsing and decoding. * Token field definitions for time parsing and decoding.
* These need to fit into the datetkn table type. * These need to fit into the datetkn table type.
...@@ -164,13 +186,13 @@ typedef double fsec_t; ...@@ -164,13 +186,13 @@ typedef double fsec_t;
/* /*
* Bit mask definitions for time parsing. * Bit mask definitions for time parsing.
*/ */
/* Copy&pasted these values from src/include/utils/datetime.h */
#define DTK_M(t) (0x01 << (t)) #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_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 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) */ * string (not counting tr. null) */
#define MAXDATEFIELDS 25 /* maximum possible number of fields in a date #define MAXDATEFIELDS 25 /* maximum possible number of fields in a date
* string */ * string */
......
This diff is collapsed.
...@@ -77,6 +77,12 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -77,6 +77,12 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
if (sqlca.sqlcode < 0) sqlprint ( );} if (sqlca.sqlcode < 0) sqlprint ( );}
#line 30 "dt_test.pgc" #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); date1 = PGTYPESdate_from_asc(d1, NULL);
ts1 = PGTYPEStimestamp_from_asc(t1, NULL); ts1 = PGTYPEStimestamp_from_asc(t1, NULL);
...@@ -86,10 +92,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -86,10 +92,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp), ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); 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 ( );} 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 ", { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from date_test where d = $1 ",
...@@ -99,10 +105,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -99,10 +105,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp), ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 37 "dt_test.pgc" #line 38 "dt_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );} if (sqlca.sqlcode < 0) sqlprint ( );}
#line 37 "dt_test.pgc" #line 38 "dt_test.pgc"
text = PGTYPESdate_to_asc(date1); text = PGTYPESdate_to_asc(date1);
...@@ -417,16 +423,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ...@@ -417,16 +423,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
free(text); free(text);
{ ECPGtrans(__LINE__, NULL, "rollback "); { ECPGtrans(__LINE__, NULL, "rollback ");
#line 350 "dt_test.pgc" #line 351 "dt_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );} if (sqlca.sqlcode < 0) sqlprint ( );}
#line 350 "dt_test.pgc" #line 351 "dt_test.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT"); { ECPGdisconnect(__LINE__, "CURRENT");
#line 351 "dt_test.pgc" #line 352 "dt_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );} if (sqlca.sqlcode < 0) sqlprint ( );}
#line 351 "dt_test.pgc" #line 352 "dt_test.pgc"
return (0); return (0);
......
...@@ -14,29 +14,35 @@ ...@@ -14,29 +14,35 @@
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 30: OK: SET [NO_PID]: ecpg_execute on line 30: OK: SET
[NO_PID]: sqlca: code: 0, state: 00000 [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]: 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]: 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]: 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]: 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]: 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]: 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]: 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]: 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]: 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]: 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]: 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]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed [NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
...@@ -28,6 +28,7 @@ main(void) ...@@ -28,6 +28,7 @@ main(void)
exec sql connect to REGRESSDB1; exec sql connect to REGRESSDB1;
exec sql create table date_test (d date, ts timestamp); exec sql create table date_test (d date, ts timestamp);
exec sql set datestyle to iso; exec sql set datestyle to iso;
exec sql set intervalstyle to postgres_verbose;
date1 = PGTYPESdate_from_asc(d1, NULL); date1 = PGTYPESdate_from_asc(d1, NULL);
ts1 = PGTYPEStimestamp_from_asc(t1, NULL); ts1 = PGTYPEStimestamp_from_asc(t1, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment