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
89508a84
Commit
89508a84
authored
Mar 27, 2003
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More changes to pgtypeslib and set optimization to -O1.
parent
5e5c5cd3
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
263 additions
and
109 deletions
+263
-109
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+7
-0
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/ecpglib/data.c
+31
-6
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/execute.c
+45
-3
src/interfaces/ecpg/ecpglib/typename.c
src/interfaces/ecpg/ecpglib/typename.c
+3
-1
src/interfaces/ecpg/include/datetime.h
src/interfaces/ecpg/include/datetime.h
+2
-1
src/interfaces/ecpg/include/decimal.h
src/interfaces/ecpg/include/decimal.h
+7
-7
src/interfaces/ecpg/include/ecpgerrno.h
src/interfaces/ecpg/include/ecpgerrno.h
+10
-6
src/interfaces/ecpg/include/ecpgtype.h
src/interfaces/ecpg/include/ecpgtype.h
+2
-1
src/interfaces/ecpg/include/pgtypes_interval.h
src/interfaces/ecpg/include/pgtypes_interval.h
+20
-0
src/interfaces/ecpg/include/pgtypes_numeric.h
src/interfaces/ecpg/include/pgtypes_numeric.h
+25
-18
src/interfaces/ecpg/pgtypeslib/Makefile
src/interfaces/ecpg/pgtypeslib/Makefile
+2
-2
src/interfaces/ecpg/pgtypeslib/common.c
src/interfaces/ecpg/pgtypeslib/common.c
+0
-1
src/interfaces/ecpg/pgtypeslib/numeric.c
src/interfaces/ecpg/pgtypeslib/numeric.c
+48
-49
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
+25
-2
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/ecpg.c
+3
-2
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+19
-7
src/interfaces/ecpg/preproc/type.c
src/interfaces/ecpg/preproc/type.c
+12
-1
src/interfaces/ecpg/test/num_test.pgc
src/interfaces/ecpg/test/num_test.pgc
+2
-2
No files found.
src/interfaces/ecpg/ChangeLog
View file @
89508a84
...
...
@@ -1369,6 +1369,13 @@ Fri Mar 21 15:13:42 CET 2003
- Made sure preprocessor accepts new datatypes.
- Do not free prepared statements at the end of a transaction.
Thu Mar 27 15:23:58 CET 2003
- Some more updates to pgtypeslib.
- Set optimization to -O1 until I find the reason why code is broken
with -O2.
- Set ecpg version to 2.12.0.
- Set ecpg library to 3.4.2.
- Set pgtypes library to 1.0.0
...
...
src/interfaces/ecpg/ecpglib/data.c
View file @
89508a84
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.
2 2003/03/20 15:56:50
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.
3 2003/03/27 14:29:17
meskes Exp $ */
#include "postgres_fe.h"
...
...
@@ -13,6 +13,7 @@
#include "pgtypes_numeric.h"
#include "pgtypes_date.h"
#include "pgtypes_timestamp.h"
#include "pgtypes_interval.h"
bool
ECPGget_data
(
const
PGresult
*
results
,
int
act_tuple
,
int
act_field
,
int
lineno
,
...
...
@@ -100,9 +101,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
unsigned
long
ures
;
double
dres
;
char
*
scan_length
;
Numeric
Var
*
nres
;
Numeric
*
nres
;
Date
ddres
;
Timestamp
tres
;
Interval
*
ires
;
case
ECPGt_short
:
case
ECPGt_int
:
...
...
@@ -392,16 +394,39 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
))
/* Garbage left */
{
ECPGraise
(
lineno
,
ECPG_
FLOAT
_FORMAT
,
pval
);
ECPGraise
(
lineno
,
ECPG_
NUMERIC
_FORMAT
,
pval
);
return
(
false
);
}
}
else
nres
=
PGTYPESnumeric_aton
(
"0.0"
,
&
scan_length
);
PGTYPESnumeric_copy
(
nres
,
(
Numeric
Var
*
)(
var
+
offset
*
act_tuple
));
PGTYPESnumeric_copy
(
nres
,
(
Numeric
*
)(
var
+
offset
*
act_tuple
));
break
;
case
ECPGt_interval
:
if
(
pval
)
{
if
(
isarray
&&
*
pval
==
'"'
)
ires
=
PGTYPESinterval_atoi
(
pval
+
1
,
&
scan_length
);
else
ires
=
PGTYPESinterval_atoi
(
pval
,
&
scan_length
);
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
))
/* Garbage left */
{
ECPGraise
(
lineno
,
ECPG_INTERVAL_FORMAT
,
pval
);
return
(
false
);
}
}
else
ires
=
PGTYPESinterval_atoi
(
"0 seconds"
,
NULL
);
PGTYPESinterval_copy
(
ires
,
(
Interval
*
)(
var
+
offset
*
act_tuple
));
break
;
case
ECPGt_date
:
if
(
pval
)
{
...
...
@@ -416,7 +441,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
))
/* Garbage left */
{
ECPGraise
(
lineno
,
ECPG_
FLOAT
_FORMAT
,
pval
);
ECPGraise
(
lineno
,
ECPG_
DATE
_FORMAT
,
pval
);
return
(
false
);
}
...
...
@@ -438,7 +463,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
))
/* Garbage left */
{
ECPGraise
(
lineno
,
ECPG_
FLOAT
_FORMAT
,
pval
);
ECPGraise
(
lineno
,
ECPG_
TIMESTAMP
_FORMAT
,
pval
);
return
(
false
);
}
...
...
src/interfaces/ecpg/ecpglib/execute.c
View file @
89508a84
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.
5 2003/03/25 02:44:36 momjian
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.
6 2003/03/27 14:29:17 meskes
Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
...
...
@@ -29,6 +29,7 @@
#include "pgtypes_numeric.h"
#include "pgtypes_date.h"
#include "pgtypes_timestamp.h"
#include "pgtypes_interval.h"
/* variables visible to the programs */
struct
sqlca
sqlca
=
...
...
@@ -846,7 +847,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
{
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
{
str
=
PGTYPESnumeric_ntoa
((
Numeric
Var
*
)((
var
+
var
->
offset
*
element
)
->
value
));
str
=
PGTYPESnumeric_ntoa
((
Numeric
*
)((
var
+
var
->
offset
*
element
)
->
value
));
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
5
,
stmt
->
lineno
)))
...
...
@@ -862,7 +863,48 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
}
else
{
str
=
PGTYPESnumeric_ntoa
((
NumericVar
*
)(
var
->
value
));
str
=
PGTYPESnumeric_ntoa
((
Numeric
*
)(
var
->
value
));
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
1
,
stmt
->
lineno
)))
return
false
;
strncpy
(
mallocedval
,
str
,
slen
);
mallocedval
[
slen
]
=
'\0'
;
}
*
tobeinserted_p
=
mallocedval
;
*
malloced_p
=
true
;
free
(
str
);
}
break
;
case
ECPGt_interval
:
{
char
*
str
=
NULL
;
int
slen
;
if
(
var
->
arrsize
>
1
)
{
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
{
str
=
PGTYPESinterval_itoa
((
Interval
*
)((
var
+
var
->
offset
*
element
)
->
value
));
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
5
,
stmt
->
lineno
)))
return
false
;
if
(
!
element
)
strcpy
(
mallocedval
,
"'{"
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
}
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"}'"
);
}
else
{
str
=
PGTYPESinterval_itoa
((
Interval
*
)(
var
->
value
));
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
1
,
stmt
->
lineno
)))
...
...
src/interfaces/ecpg/ecpglib/typename.c
View file @
89508a84
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.
2 2003/03/20 15:56:50
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.
3 2003/03/27 14:29:17
meskes Exp $ */
#include "postgres_fe.h"
...
...
@@ -53,6 +53,8 @@ ECPGtype_name(enum ECPGttype typ)
return
"date"
;
case
ECPGt_timestamp
:
return
"timestamp"
;
case
ECPGt_interval
:
return
"interval"
;
default:
abort
();
}
...
...
src/interfaces/ecpg/include/datetime.h
View file @
89508a84
#include <pgtypes_timestamp.h>
#include <pgtypes_interval.h>
#ifndef dtime_t
#define dtime_t Timestamp
#endif
/* dtime_t */
#ifndef intrvl_t
#define intrvl_t
Timestamp
#define intrvl_t
Interval
#endif
/* intrvl_t */
extern
void
dtcurrent
(
dtime_t
*
);
...
...
src/interfaces/ecpg/include/decimal.h
View file @
89508a84
#include <pgtypes_numeric.h>
#ifndef dec_t
#define dec_t Numeric
Var
#define dec_t Numeric
#endif
/* dec_t */
int
decadd
(
dec_t
*
,
Numeric
Var
*
,
NumericVar
*
);
int
deccmp
(
dec_t
*
,
Numeric
Var
*
);
void
deccopy
(
dec_t
*
,
Numeric
Var
*
);
int
decadd
(
dec_t
*
,
Numeric
*
,
Numeric
*
);
int
deccmp
(
dec_t
*
,
Numeric
*
);
void
deccopy
(
dec_t
*
,
Numeric
*
);
int
deccvasc
(
char
*
,
int
,
dec_t
*
);
int
deccvdbl
(
double
,
dec_t
*
);
int
deccvint
(
int
,
dec_t
*
);
int
deccvlong
(
long
,
dec_t
*
);
int
decdiv
(
dec_t
*
,
Numeric
Var
*
,
NumericVar
*
);
int
decmul
(
dec_t
*
,
Numeric
Var
*
,
NumericVar
*
);
int
decsub
(
dec_t
*
,
Numeric
Var
*
,
NumericVar
*
);
int
decdiv
(
dec_t
*
,
Numeric
*
,
Numeric
*
);
int
decmul
(
dec_t
*
,
Numeric
*
,
Numeric
*
);
int
decsub
(
dec_t
*
,
Numeric
*
,
Numeric
*
);
int
dectoasc
(
dec_t
*
,
char
*
,
int
,
int
);
int
dectodbl
(
dec_t
*
,
double
*
);
int
dectoint
(
dec_t
*
,
int
*
);
...
...
src/interfaces/ecpg/include/ecpgerrno.h
View file @
89508a84
...
...
@@ -20,12 +20,16 @@
#define ECPG_INT_FORMAT -204
#define ECPG_UINT_FORMAT -205
#define ECPG_FLOAT_FORMAT -206
#define ECPG_CONVERT_BOOL -207
#define ECPG_EMPTY -208
#define ECPG_MISSING_INDICATOR -209
#define ECPG_NO_ARRAY -210
#define ECPG_DATA_NOT_ARRAY -211
#define ECPG_ARRAY_INSERT -212
#define ECPG_NUMERIC_FORMAT -207
#define ECPG_INTERVAL_FORMAT -208
#define ECPG_DATE_FORMAT -209
#define ECPG_TIMESTAMP_FORMAT -210
#define ECPG_CONVERT_BOOL -211
#define ECPG_EMPTY -212
#define ECPG_MISSING_INDICATOR -213
#define ECPG_NO_ARRAY -214
#define ECPG_DATA_NOT_ARRAY -215
#define ECPG_ARRAY_INSERT -216
#define ECPG_NO_CONN -220
#define ECPG_NOT_CONN -221
...
...
src/interfaces/ecpg/include/ecpgtype.h
View file @
89508a84
...
...
@@ -54,7 +54,8 @@ enum ECPGttype
ECPGt_descriptor
,
/* sql descriptor, no C variable */
ECPGt_numeric
,
ECPGt_date
,
ECPGt_timestamp
ECPGt_timestamp
,
ECPGt_interval
};
/* descriptor items */
...
...
src/interfaces/ecpg/include/pgtypes_interval.h
0 → 100644
View file @
89508a84
#ifndef PGTYPES_INTERVAL
#define PGTYPES_INTERVAL
#include <pgtypes_timestamp.h>
typedef
struct
{
#ifdef HAVE_INT64_TIMESTAMP
int64
time
;
/* all time units other than months and years */
#else
double
time
;
/* all time units other than months and years */
#endif
long
month
;
/* months and years, after time for alignment */
}
Interval
;
extern
Interval
*
PGTYPESinterval_atoi
(
char
*
,
char
**
);
extern
char
*
PGTYPESinterval_itoa
(
Interval
*
);
extern
int
PGTYPESinterval_copy
(
Interval
*
,
Interval
*
);
#endif
/* PGTYPES_INTERVAL */
src/interfaces/ecpg/include/pgtypes_numeric.h
View file @
89508a84
#ifndef PGTYPES_NUMERIC
#define PGTYPES_NUMERIC
#define NUMERIC_POS 0x0000
#define NUMERIC_NEG 0x4000
#define NUMERIC_MAX_PRECISION 1000
#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
#define NUMERIC_MIN_DISPLAY_SCALE 0
#define NUMERIC_MIN_SIG_DIGITS 16
typedef
unsigned
char
NumericDigit
;
typedef
struct
NumericVar
typedef
struct
{
int
ndigits
;
/* number of digits in digits[] - can be 0! */
int
weight
;
/* weight of first digit */
...
...
@@ -11,23 +18,23 @@ typedef struct NumericVar
int
sign
;
/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
NumericDigit
*
buf
;
/* start of alloc'd space for digits[] */
NumericDigit
*
digits
;
/* decimal digits */
}
Numeric
Var
;
}
Numeric
;
Numeric
Var
*
PGTYPESnew
(
void
);
void
PGTYPESnumeric_free
(
Numeric
Var
*
);
Numeric
Var
*
PGTYPESnumeric_aton
(
char
*
,
char
**
);
char
*
PGTYPESnumeric_ntoa
(
Numeric
Var
*
);
int
PGTYPESnumeric_add
(
Numeric
Var
*
,
NumericVar
*
,
NumericVar
*
);
int
PGTYPESnumeric_sub
(
Numeric
Var
*
,
NumericVar
*
,
NumericVar
*
);
int
PGTYPESnumeric_mul
(
Numeric
Var
*
,
NumericVar
*
,
NumericVar
*
);
int
PGTYPESnumeric_div
(
Numeric
Var
*
,
NumericVar
*
,
NumericVar
*
);
int
PGTYPESnumeric_cmp
(
Numeric
Var
*
,
NumericVar
*
);
int
PGTYPESnumeric_iton
(
signed
int
,
Numeric
Var
*
);
int
PGTYPESnumeric_lton
(
signed
long
int
,
Numeric
Var
*
);
int
PGTYPESnumeric_copy
(
Numeric
Var
*
,
NumericVar
*
);
int
PGTYPESnumeric_dton
(
double
,
Numeric
Var
*
);
int
PGTYPESnumeric_ntod
(
Numeric
Var
*
,
double
*
);
int
PGTYPESnumeric_ntoi
(
Numeric
Var
*
,
int
*
);
int
PGTYPESnumeric_ntol
(
Numeric
Var
*
,
long
*
);
Numeric
*
PGTYPESnew
(
void
);
void
PGTYPESnumeric_free
(
Numeric
*
);
Numeric
*
PGTYPESnumeric_aton
(
char
*
,
char
**
);
char
*
PGTYPESnumeric_ntoa
(
Numeric
*
);
int
PGTYPESnumeric_add
(
Numeric
*
,
Numeric
*
,
Numeric
*
);
int
PGTYPESnumeric_sub
(
Numeric
*
,
Numeric
*
,
Numeric
*
);
int
PGTYPESnumeric_mul
(
Numeric
*
,
Numeric
*
,
Numeric
*
);
int
PGTYPESnumeric_div
(
Numeric
*
,
Numeric
*
,
Numeric
*
);
int
PGTYPESnumeric_cmp
(
Numeric
*
,
Numeric
*
);
int
PGTYPESnumeric_iton
(
signed
int
,
Numeric
*
);
int
PGTYPESnumeric_lton
(
signed
long
int
,
Numeric
*
);
int
PGTYPESnumeric_copy
(
Numeric
*
,
Numeric
*
);
int
PGTYPESnumeric_dton
(
double
,
Numeric
*
);
int
PGTYPESnumeric_ntod
(
Numeric
*
,
double
*
);
int
PGTYPESnumeric_ntoi
(
Numeric
*
,
int
*
);
int
PGTYPESnumeric_ntol
(
Numeric
*
,
long
*
);
#endif
/* PGTYPES_NUMERIC */
src/interfaces/ecpg/pgtypeslib/Makefile
View file @
89508a84
...
...
@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.
2 2003/03/20 15:56:50
meskes Exp $
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.
3 2003/03/27 14:29:17
meskes Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -16,7 +16,7 @@ NAME= pgtypes
SO_MAJOR_VERSION
=
1
SO_MINOR_VERSION
=
0.0
override CPPFLAGS
:
= -g -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS)
override CPPFLAGS
:
= -
O1 -
g -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS)
OBJS
=
numeric.o datetime.o common.o dt_common.o timestamp.o
...
...
src/interfaces/ecpg/pgtypeslib/common.c
View file @
89508a84
#include <errno.h>
#include <stdlib.h>
#include "extern.h"
...
...
src/interfaces/ecpg/pgtypeslib/numeric.c
View file @
89508a84
This diff is collapsed.
Click to expand it.
src/interfaces/ecpg/pgtypeslib/timestamp.c
View file @
89508a84
...
...
@@ -13,6 +13,7 @@
#include "extern.h"
#include "pgtypes_error.h"
#include "pgtypes_timestamp.h"
#include "pgtypes_interval.h"
#include "datetime.h"
#ifdef HAVE_INT64_TIMESTAMP
...
...
@@ -368,7 +369,7 @@ dtcvasc (char *str, Timestamp *ts)
}
int
dtsub
(
Timestamp
*
ts1
,
Timestamp
*
ts2
,
Timestamp
*
iv
)
dtsub
(
Timestamp
*
ts1
,
Timestamp
*
ts2
,
Interval
*
iv
)
{
return
0
;
}
...
...
@@ -386,8 +387,30 @@ dttofmtasc (Timestamp *ts, char *output, int str_len, char *fmtstr)
}
int
intoasc
(
Timestamp
*
i
,
char
*
str
)
intoasc
(
Interval
*
i
,
char
*
str
)
{
return
0
;
}
Interval
*
PGTYPESinterval_atoi
(
char
*
str
,
char
**
endptr
)
{
Interval
*
result
=
NULL
;
return
result
;
}
char
*
PGTYPESinterval_itoa
(
Interval
*
intvl
)
{
char
buf
[
MAXDATELEN
+
1
];
return
pgtypes_strdup
(
buf
);
}
int
PGTYPESinterval_copy
(
Interval
*
intvlsrc
,
Interval
*
intrcldest
)
{
return
0
;
}
src/interfaces/ecpg/preproc/ecpg.c
View file @
89508a84
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.6
3 2003/03/18 10:46:39
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.6
4 2003/03/27 14:29:17
meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
...
...
@@ -157,7 +157,8 @@ main(int argc, char *const argv[])
if
(
strcmp
(
optarg
,
"INFORMIX"
)
==
0
)
{
compat
=
ECPG_COMPAT_INFORMIX
;
add_preprocessor_define
(
"dec_t=NumericVar"
);
add_preprocessor_define
(
"dec_t=Numeric"
);
add_preprocessor_define
(
"intrvl_t=Interval"
);
}
else
{
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
89508a84
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.21
4 2003/03/21 14:17:4
7 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.21
5 2003/03/27 14:29:1
7 meskes Exp $ */
/* Copyright comment */
%{
...
...
@@ -4258,8 +4258,8 @@ single_vt_type: common_type
}
else if (strcmp($1, "interval") == 0)
{
$$.type_enum = ECPGt_
timestamp
;
$$.type_str =
make_str("Timestamp")
;
$$.type_enum = ECPGt_
interval
;
$$.type_str =
EMPTY
;
$$.type_dimension = -1;
$$.type_index = -1;
$$.type_sizeof = NULL;
...
...
@@ -4526,8 +4526,8 @@ var_type: common_type
}
else if (strcmp($1, "interval") == 0)
{
$$.type_enum = ECPGt_
timestamp
;
$$.type_str =
make_str("Timestamp")
;
$$.type_enum = ECPGt_
interval
;
$$.type_str =
EMPTY
;
$$.type_dimension = -1;
$$.type_index = -1;
$$.type_sizeof = NULL;
...
...
@@ -4732,9 +4732,21 @@ variable: opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
if (dimension < 0)
$$ = cat_str(4, mm_strdup(actual_storage[struct_level]), make_str("NumericVar"), mm_strdup($2), $4);
$$ = cat_str(4, mm_strdup(actual_storage[struct_level]), make_str("Numeric"), mm_strdup($2), $4);
else
$$ = cat_str(5, mm_strdup(actual_storage[struct_level]), make_str("Numeric"), mm_strdup($2), mm_strdup(dim), $4);
break;
case ECPGt_interval:
if (dimension < 0)
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
else
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
if (dimension < 0)
$$ = cat_str(4, mm_strdup(actual_storage[struct_level]), make_str("Interval"), mm_strdup($2), $4);
else
$$ = cat_str(5, mm_strdup(actual_storage[struct_level]), make_str("
NumericVar
"), mm_strdup($2), mm_strdup(dim), $4);
$$ = cat_str(5, mm_strdup(actual_storage[struct_level]), make_str("
Interval
"), mm_strdup($2), mm_strdup(dim), $4);
break;
default:
...
...
src/interfaces/ecpg/preproc/type.c
View file @
89508a84
...
...
@@ -172,6 +172,9 @@ get_type(enum ECPGttype type)
case
ECPGt_numeric
:
return
(
"ECPGt_numeric"
);
break
;
case
ECPGt_interval
:
return
(
"ECPGt_interval"
);
break
;
case
ECPGt_descriptor
:
return
(
"ECPGt_descriptor"
);
break
;
...
...
@@ -334,7 +337,15 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
* we have to use a pointer here
*/
sprintf
(
variable
,
"&(%s%s)"
,
prefix
?
prefix
:
""
,
name
);
sprintf
(
offset
,
"sizeof(struct NumericVar)"
);
sprintf
(
offset
,
"sizeof(Numeric)"
);
break
;
case
ECPGt_interval
:
/*
* we have to use a pointer here
*/
sprintf
(
variable
,
"&(%s%s)"
,
prefix
?
prefix
:
""
,
name
);
sprintf
(
offset
,
"sizeof(Interval)"
);
break
;
case
ECPGt_date
:
...
...
src/interfaces/ecpg/test/num_test.pgc
View file @
89508a84
#include <stdio.h>
#include <pgtypes_numeric.h>
#include <decimal.h>
int
main()
{
char *text="error\n";
Numeric
Var
*value1, *value2, *res;
Numeric *value1, *value2, *res;
exec sql begin declare section;
decimal(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
numeric num;
exec sql end declare section;
double d;
FILE *dbgs;
...
...
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