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
6a0d6d00
Commit
6a0d6d00
authored
Jul 25, 2003
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added explicit casts for date/interval/timestamp.
parent
f1a27b12
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
51 deletions
+61
-51
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+4
-0
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/execute.c
+56
-50
src/interfaces/ecpg/test/dt_test.pgc
src/interfaces/ecpg/test/dt_test.pgc
+1
-1
No files found.
src/interfaces/ecpg/ChangeLog
View file @
6a0d6d00
...
@@ -1591,6 +1591,10 @@ Fri Jul 18 16:31:10 CEST 2003
...
@@ -1591,6 +1591,10 @@ Fri Jul 18 16:31:10 CEST 2003
Thu Jul 24 10:33:51 CEST 2003
Thu Jul 24 10:33:51 CEST 2003
- Fixed mdy functions to use correct offset.
- Fixed mdy functions to use correct offset.
Fri Jul 25 18:08:18 CEST 2003
- Added explicit casts for date/timestamp/interval.
- Set ecpg version to 3.0.0
- Set ecpg version to 3.0.0
- Set ecpg library to 4.0.0
- Set ecpg library to 4.0.0
- Set pgtypes library to 1.0.0
- Set pgtypes library to 1.0.0
...
...
src/interfaces/ecpg/ecpglib/execute.c
View file @
6a0d6d00
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.
19 2003/07/15 12:38:38
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.
20 2003/07/25 16:10:26
meskes Exp $ */
/*
/*
* The aim is to get a simpler inteface to the database routines.
* The aim is to get a simpler inteface to the database routines.
...
@@ -543,12 +543,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -543,12 +543,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%hd,"
,
((
short
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%hd,"
,
((
short
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%hd"
,
*
((
short
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%hd"
,
*
((
short
*
)
var
->
value
));
...
@@ -563,12 +563,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -563,12 +563,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%d,"
,
((
int
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%d,"
,
((
int
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%d"
,
*
((
int
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%d"
,
*
((
int
*
)
var
->
value
));
...
@@ -583,12 +583,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -583,12 +583,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%hu,"
,
((
unsigned
short
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%hu,"
,
((
unsigned
short
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%hu"
,
*
((
unsigned
short
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%hu"
,
*
((
unsigned
short
*
)
var
->
value
));
...
@@ -603,12 +603,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -603,12 +603,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%u,"
,
((
unsigned
int
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%u,"
,
((
unsigned
int
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%u"
,
*
((
unsigned
int
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%u"
,
*
((
unsigned
int
*
)
var
->
value
));
...
@@ -623,12 +623,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -623,12 +623,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%ld,"
,
((
long
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%ld,"
,
((
long
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%ld"
,
*
((
long
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%ld"
,
*
((
long
*
)
var
->
value
));
...
@@ -643,12 +643,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -643,12 +643,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%lu,"
,
((
unsigned
long
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%lu,"
,
((
unsigned
long
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%lu"
,
*
((
unsigned
long
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%lu"
,
*
((
unsigned
long
*
)
var
->
value
));
...
@@ -658,17 +658,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -658,17 +658,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
break
;
break
;
#ifdef HAVE_LONG_LONG_INT_64
#ifdef HAVE_LONG_LONG_INT_64
case
ECPGt_long_long
:
case
ECPGt_long_long
:
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
25
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
30
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%lld,"
,
((
long
long
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%lld,"
,
((
long
long
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%lld"
,
*
((
long
long
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%lld"
,
*
((
long
long
*
)
var
->
value
));
...
@@ -678,17 +678,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -678,17 +678,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
break
;
break
;
case
ECPGt_unsigned_long_long
:
case
ECPGt_unsigned_long_long
:
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
25
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
30
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%llu,"
,
((
unsigned
long
long
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%llu,"
,
((
unsigned
long
long
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%llu"
,
*
((
unsigned
long
long
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%llu"
,
*
((
unsigned
long
long
*
)
var
->
value
));
...
@@ -698,17 +698,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -698,17 +698,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
break
;
break
;
#endif
/* HAVE_LONG_LONG_INT_64 */
#endif
/* HAVE_LONG_LONG_INT_64 */
case
ECPGt_float
:
case
ECPGt_float
:
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
2
1
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
2
5
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%.14g,"
,
((
float
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%.14g,"
,
((
float
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%.14g"
,
*
((
float
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%.14g"
,
*
((
float
*
)
var
->
value
));
...
@@ -718,17 +718,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -718,17 +718,17 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
break
;
break
;
case
ECPGt_double
:
case
ECPGt_double
:
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
2
1
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
2
5
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%.14g,"
,
((
double
*
)
var
->
value
)[
element
]);
sprintf
(
mallocedval
+
strlen
(
mallocedval
),
"%.14g,"
,
((
double
*
)
var
->
value
)[
element
]);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
sprintf
(
mallocedval
,
"%.14g"
,
*
((
double
*
)
var
->
value
));
sprintf
(
mallocedval
,
"%.14g"
,
*
((
double
*
)
var
->
value
));
...
@@ -738,12 +738,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -738,12 +738,12 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
break
;
break
;
case
ECPGt_bool
:
case
ECPGt_bool
:
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
*
2
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
var
->
arrsize
+
sizeof
(
"array []"
)
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
var
->
arrsize
>
1
)
if
(
var
->
arrsize
>
1
)
{
{
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
if
(
var
->
offset
==
sizeof
(
char
))
if
(
var
->
offset
==
sizeof
(
char
))
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
for
(
element
=
0
;
element
<
var
->
arrsize
;
element
++
)
...
@@ -759,7 +759,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -759,7 +759,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
else
else
ECPGraise
(
stmt
->
lineno
,
ECPG_CONVERT_BOOL
,
"different size"
);
ECPGraise
(
stmt
->
lineno
,
ECPG_CONVERT_BOOL
,
"different size"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
{
{
...
@@ -854,16 +854,16 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -854,16 +854,16 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
PGTYPESnumeric_free
(
nval
);
PGTYPESnumeric_free
(
nval
);
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
5
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
sizeof
(
"array [] "
)
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
!
element
)
if
(
!
element
)
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
}
}
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
{
{
...
@@ -902,27 +902,29 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -902,27 +902,29 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
str
=
quote_postgres
(
PGTYPESinterval_to_asc
((
Interval
*
)((
var
+
var
->
offset
*
element
)
->
value
)),
stmt
->
lineno
);
str
=
quote_postgres
(
PGTYPESinterval_to_asc
((
Interval
*
)((
var
+
var
->
offset
*
element
)
->
value
)),
stmt
->
lineno
);
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
5
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
sizeof
(
"array [],interval "
)
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
!
element
)
if
(
!
element
)
strcpy
(
mallocedval
,
"'{"
);
strcpy
(
mallocedval
,
"array ["
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
"interval "
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
}
}
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
{
{
str
=
quote_postgres
(
PGTYPESinterval_to_asc
((
Interval
*
)(
var
->
value
)),
stmt
->
lineno
);
str
=
quote_postgres
(
PGTYPESinterval_to_asc
((
Interval
*
)(
var
->
value
)),
stmt
->
lineno
);
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
1
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
sizeof
(
"interval "
)
+
1
,
stmt
->
lineno
)))
return
false
;
return
false
;
strncpy
(
mallocedval
,
str
,
slen
);
strcpy
(
mallocedval
,
"interval "
);
mallocedval
[
slen
]
=
'\0'
;
/* also copy trailing '\0' */
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
}
}
*
tobeinserted_p
=
mallocedval
;
*
tobeinserted_p
=
mallocedval
;
...
@@ -943,27 +945,29 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -943,27 +945,29 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
str
=
quote_postgres
(
PGTYPESdate_to_asc
(
*
(
Date
*
)((
var
+
var
->
offset
*
element
)
->
value
)),
stmt
->
lineno
);
str
=
quote_postgres
(
PGTYPESdate_to_asc
(
*
(
Date
*
)((
var
+
var
->
offset
*
element
)
->
value
)),
stmt
->
lineno
);
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
5
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
sizeof
(
"array [],date "
)
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
!
element
)
if
(
!
element
)
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
"date "
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
}
}
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
{
{
str
=
quote_postgres
(
PGTYPESdate_to_asc
(
*
(
Date
*
)(
var
->
value
)),
stmt
->
lineno
);
str
=
quote_postgres
(
PGTYPESdate_to_asc
(
*
(
Date
*
)(
var
->
value
)),
stmt
->
lineno
);
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
1
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
sizeof
(
"date "
)
+
1
,
stmt
->
lineno
)))
return
false
;
return
false
;
strncpy
(
mallocedval
,
str
,
slen
);
strcpy
(
mallocedval
,
"date "
);
mallocedval
[
slen
]
=
'\0'
;
/* also copy trailing '\0' */
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
}
}
*
tobeinserted_p
=
mallocedval
;
*
tobeinserted_p
=
mallocedval
;
...
@@ -984,27 +988,29 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
...
@@ -984,27 +988,29 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
str
=
quote_postgres
(
PGTYPEStimestamp_to_asc
(
*
(
Timestamp
*
)((
var
+
var
->
offset
*
element
)
->
value
)),
stmt
->
lineno
);
str
=
quote_postgres
(
PGTYPEStimestamp_to_asc
(
*
(
Timestamp
*
)((
var
+
var
->
offset
*
element
)
->
value
)),
stmt
->
lineno
);
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
5
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGrealloc
(
mallocedval
,
strlen
(
mallocedval
)
+
slen
+
sizeof
(
"array [], timestamp "
)
,
stmt
->
lineno
)))
return
false
;
return
false
;
if
(
!
element
)
if
(
!
element
)
strcpy
(
mallocedval
,
"
'{
"
);
strcpy
(
mallocedval
,
"
array [
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
"timestamp "
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
),
","
);
}
}
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
}'
"
);
strcpy
(
mallocedval
+
strlen
(
mallocedval
)
-
1
,
"
]
"
);
}
}
else
else
{
{
str
=
quote_postgres
(
PGTYPEStimestamp_to_asc
(
*
(
Timestamp
*
)(
var
->
value
)),
stmt
->
lineno
);
str
=
quote_postgres
(
PGTYPEStimestamp_to_asc
(
*
(
Timestamp
*
)(
var
->
value
)),
stmt
->
lineno
);
slen
=
strlen
(
str
);
slen
=
strlen
(
str
);
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
1
,
stmt
->
lineno
)))
if
(
!
(
mallocedval
=
ECPGalloc
(
slen
+
sizeof
(
"timestamp"
)
+
1
,
stmt
->
lineno
)))
return
false
;
return
false
;
strncpy
(
mallocedval
,
str
,
slen
);
strcpy
(
mallocedval
,
"timestamp "
);
mallocedval
[
slen
]
=
'\0'
;
/* also copy trailing '\0' */
strncpy
(
mallocedval
+
strlen
(
mallocedval
),
str
,
slen
+
1
);
}
}
*
tobeinserted_p
=
mallocedval
;
*
tobeinserted_p
=
mallocedval
;
...
...
src/interfaces/ecpg/test/dt_test.pgc
View file @
6a0d6d00
...
@@ -34,7 +34,7 @@ main()
...
@@ -34,7 +34,7 @@ main()
exec sql insert into date_test(d, ts, iv) values (:date1, :ts1, now()-'Mon Jan 17 1966');
exec sql insert into date_test(d, ts, iv) values (:date1, :ts1, now()-'Mon Jan 17 1966');
exec sql select * into :date1, :ts1 , :iv1 from date_test;
exec sql select * into :date1, :ts1 , :iv1 from date_test
where d=:date1
;
text = PGTYPESdate_to_asc(date1);
text = PGTYPESdate_to_asc(date1);
printf ("Date: %s\n", text);
printf ("Date: %s\n", text);
...
...
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