Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
7c5a561f
Commit
7c5a561f
authored
Nov 26, 2008
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied patch by Ron Mayer <rm_pg@cheapcomplexdevices.com> to merge the new
interval style into ecpg.
parent
cbb3e1cd
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
791 additions
and
376 deletions
+791
-376
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+2
-0
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt.h
+35
-13
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/interval.c
+721
-343
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
+14
-8
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
+18
-12
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
+1
-0
No files found.
src/interfaces/ecpg/ChangeLog
View file @
7c5a561f
...
...
@@ -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.
...
...
src/interfaces/ecpg/pgtypeslib/dt.h
View file @
7c5a561f
/* $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 1
7
#define ABS_BEFORE
18
#define ABS_AFTER
19
#define AGO 1
9
#define ABS_BEFORE
20
#define ABS_AFTER
21
/* generic fields to help with parsing */
#define ISODATE 2
0
#define ISOTIME 2
1
#define ISODATE 2
2
#define ISOTIME 2
3
/* 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 */
...
...
src/interfaces/ecpg/pgtypeslib/interval.c
View file @
7c5a561f
This diff is collapsed.
Click to expand it.
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
View file @
7c5a561f
...
...
@@ -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 3
5
"dt_test.pgc"
#line 3
6
"dt_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 3
5
"dt_test.pgc"
#line 3
6
"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 3
7
"dt_test.pgc"
#line 3
8
"dt_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 3
7
"dt_test.pgc"
#line 3
8
"dt_test.pgc"
text
=
PGTYPESdate_to_asc
(
date1
);
...
...
@@ -417,16 +423,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
free
(
text
);
{
ECPGtrans
(
__LINE__
,
NULL
,
"rollback "
);
#line 35
0
"dt_test.pgc"
#line 35
1
"dt_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 35
0
"dt_test.pgc"
#line 35
1
"dt_test.pgc"
{
ECPGdisconnect
(
__LINE__
,
"CURRENT"
);
#line 35
1
"dt_test.pgc"
#line 35
2
"dt_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 35
1
"dt_test.pgc"
#line 35
2
"dt_test.pgc"
return
(
0
);
...
...
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
View file @
7c5a561f
...
...
@@ -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 3
5: query: insert into date_test ( d , ts ) values ( $1 , $2 ) ; with 2
parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 3
1: 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 3
5: using PQexecParams
[NO_PID]: ecpg_execute on line 3
1: 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 3
5: OK: INSERT 0 1
[NO_PID]: ecpg_execute on line 3
6: 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 3
7: correctly got 1 tuples with 2 fields
[NO_PID]: ecpg_execute on line 3
8: 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: ye
s
[NO_PID]: ecpg_
execute on line 38: using PQexecParam
s
[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
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
View file @
7c5a561f
...
...
@@ -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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment