Skip to content

Commit c7fddd3

Browse files
author
Michael Meskes
committed
date, interval and timestamp data should be quoted.
1 parent 23e4fc1 commit c7fddd3

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,10 @@ Wed Jul 2 09:45:59 CEST 2003
15461546

15471547
- Fixed initialization bug in compatlib.
15481548
- Added postgres_fe.h to all files in pgtypeslib.
1549+
1550+
Fri Jul 4 13:51:11 CEST 2003
1551+
1552+
- date, interval and timestamp data should be quoted.
15491553
- Set ecpg version to 3.0.0
15501554
- Set ecpg library to 4.0.0
15511555
- Set pgtypes library to 1.0.0

src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.15 2003/07/04 11:30:48 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.16 2003/07/04 12:00:52 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -885,7 +885,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
885885
{
886886
for (element = 0; element < var->arrsize; element++)
887887
{
888-
str = PGTYPESinterval_to_asc((Interval *)((var + var->offset * element)->value));
888+
str = quote_postgres(PGTYPESinterval_to_asc((Interval *)((var + var->offset * element)->value)), stmt->lineno);
889889
slen = strlen (str);
890890

891891
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + 5, stmt->lineno)))
@@ -901,7 +901,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
901901
}
902902
else
903903
{
904-
str = PGTYPESinterval_to_asc((Interval *)(var->value));
904+
str = quote_postgres(PGTYPESinterval_to_asc((Interval *)(var->value)), stmt->lineno);
905905
slen = strlen (str);
906906

907907
if (!(mallocedval = ECPGalloc(slen + 1, stmt->lineno)))
@@ -926,7 +926,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
926926
{
927927
for (element = 0; element < var->arrsize; element++)
928928
{
929-
str = PGTYPESdate_to_asc(*(Date *)((var + var->offset * element)->value));
929+
str = quote_postgres(PGTYPESdate_to_asc(*(Date *)((var + var->offset * element)->value)), stmt->lineno);
930930
slen = strlen (str);
931931

932932
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + 5, stmt->lineno)))
@@ -942,7 +942,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
942942
}
943943
else
944944
{
945-
str = PGTYPESdate_to_asc(*(Date *)(var->value));
945+
str = quote_postgres(PGTYPESdate_to_asc(*(Date *)(var->value)), stmt->lineno);
946946
slen = strlen (str);
947947

948948
if (!(mallocedval = ECPGalloc(slen + 1, stmt->lineno)))
@@ -967,7 +967,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
967967
{
968968
for (element = 0; element < var->arrsize; element++)
969969
{
970-
str = PGTYPEStimestamp_to_asc(*(Timestamp *)((var + var->offset * element)->value));
970+
str = quote_postgres(PGTYPEStimestamp_to_asc(*(Timestamp *)((var + var->offset * element)->value)), stmt->lineno);
971971
slen = strlen (str);
972972

973973
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + 5, stmt->lineno)))
@@ -983,7 +983,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
983983
}
984984
else
985985
{
986-
str = PGTYPEStimestamp_to_asc(*(Timestamp *)(var->value));
986+
str = quote_postgres(PGTYPEStimestamp_to_asc(*(Timestamp *)(var->value)), stmt->lineno);
987987
slen = strlen (str);
988988

989989
if (!(mallocedval = ECPGalloc(slen + 1, stmt->lineno)))

src/interfaces/ecpg/pgtypeslib/datetime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ PGTYPESdate_to_asc(Date dDate)
8787
{
8888
struct tm tt, *tm = &tt;
8989
char buf[MAXDATELEN + 1];
90-
int DateStyle=0;
90+
int DateStyle=1;
9191
bool EuroDates = FALSE;
9292

9393
j2date((dDate + date2j(2000, 1, 1)), &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday));

src/interfaces/ecpg/test/dt_test.pgc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ main()
1717
Date date2;
1818
int mdy[3] = { 4, 19, 1998 };
1919
char *fmt, *out, *in;
20+
char *d1 = "Mon Jan 17 1966";
21+
char *t1 = "2000-7-12 17:34:29";
2022

2123
FILE *dbgs;
2224

@@ -25,8 +27,12 @@ main()
2527
exec sql whenever sqlerror do sqlprint();
2628
exec sql connect to mm;
2729
exec sql create table date_test (d date, ts timestamp, iv interval);
30+
exec sql set datestyle to iso;
2831

29-
exec sql insert into date_test(d, ts, iv) values ('Mon Jan 17 1966', '2000-7-12 17:34:29', now()-'Mon Jan 17 1966');
32+
date1 = PGTYPESdate_from_asc(d1, NULL);
33+
ts1 = PGTYPEStimestamp_from_asc(t1, NULL);
34+
35+
exec sql insert into date_test(d, ts, iv) values (:date1, :ts1, now()-'Mon Jan 17 1966');
3036

3137
exec sql select * into :date1, :ts1 , :iv1 from date_test;
3238

@@ -38,7 +44,7 @@ main()
3844

3945
text = PGTYPESinterval_to_asc(&iv1);
4046
printf ("interval: %s\n", text);
41-
47+
4248
PGTYPESdate_mdyjul(mdy, &date2);
4349
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
4450
/* reset */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy