Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7b85b73

Browse files
author
Michael Meskes
committed
More patches for informix compatibility.
1 parent52bc8ca commit7b85b73

File tree

17 files changed

+772
-234
lines changed

17 files changed

+772
-234
lines changed

‎src/interfaces/ecpg/compatlib/informix.c

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ deccvasc(char *cp, int len, Numeric *np)
6464
ret=-1201;
6565
else
6666
{
67-
np=PGTYPESnumeric_aton(str,NULL);
67+
np=PGTYPESnumeric_from_asc(str,NULL);
6868
if (!np)
6969
{
7070
switch (errno)
@@ -85,19 +85,19 @@ deccvasc(char *cp, int len, Numeric *np)
8585
int
8686
deccvdbl(doubledbl,Numeric*np)
8787
{
88-
return(PGTYPESnumeric_dton(dbl,np));
88+
return(PGTYPESnumeric_from_double(dbl,np));
8989
}
9090

9191
int
9292
deccvint(intin,Numeric*np)
9393
{
94-
return(PGTYPESnumeric_iton(in,np));
94+
return(PGTYPESnumeric_from_int(in,np));
9595
}
9696

9797
int
9898
deccvlong(longlng,Numeric*np)
9999
{
100-
return(PGTYPESnumeric_lton(lng,np));
100+
return(PGTYPESnumeric_from_long(lng,np));
101101
}
102102

103103
int
@@ -159,9 +159,9 @@ dectoasc(Numeric *np, char *cp, int len, int right)
159159
char*str;
160160

161161
if (right >=0)
162-
str=PGTYPESnumeric_ntoa(np,right);
162+
str=PGTYPESnumeric_to_asc(np,right);
163163
else
164-
str=PGTYPESnumeric_ntoa(np,0);
164+
str=PGTYPESnumeric_to_asc(np,0);
165165

166166
if (!str)
167167
return-1;
@@ -176,13 +176,13 @@ dectoasc(Numeric *np, char *cp, int len, int right)
176176
int
177177
dectodbl(Numeric*np,double*dblp)
178178
{
179-
return(PGTYPESnumeric_ntod(np,dblp));
179+
return(PGTYPESnumeric_to_double(np,dblp));
180180
}
181181

182182
int
183183
dectoint(Numeric*np,int*ip)
184184
{
185-
intret=PGTYPESnumeric_ntoi(np,ip);
185+
intret=PGTYPESnumeric_to_int(np,ip);
186186

187187
if (ret==PGTYPES_NUM_OVERFLOW)
188188
ret=-1200;
@@ -193,7 +193,7 @@ dectoint(Numeric *np, int *ip)
193193
int
194194
dectolong(Numeric*np,long*lngp)
195195
{
196-
intret=PGTYPESnumeric_ntol(np,lngp);
196+
intret=PGTYPESnumeric_to_long(np,lngp);
197197

198198
if (ret==PGTYPES_NUM_OVERFLOW)
199199
ret=-1200;
@@ -205,7 +205,7 @@ dectolong(Numeric *np, long *lngp)
205205
int
206206
rdatestr (Dated,char*str)
207207
{
208-
char*tmp=PGTYPESdate_dtoa(d);
208+
char*tmp=PGTYPESdate_to_asc(d);
209209

210210
if (!tmp)
211211
return-1210;
@@ -217,6 +217,15 @@ rdatestr (Date d, char *str)
217217
return0;
218218
}
219219

220+
int
221+
rstrdate (char*str,Date*d)
222+
{
223+
Datedat=PGTYPESdate_from_asc(str,NULL);
224+
225+
/* XXX: ERROR handling hier und in datetime.c */
226+
return0;
227+
}
228+
220229
void
221230
rtoday (Date*d)
222231
{
@@ -237,7 +246,7 @@ rdefmtdate (Date *d, char *fmt, char *str)
237246
/* TODO: take care of DBCENTURY environment variable */
238247
/* PGSQL functions allow all centuries */
239248

240-
if (PGTYPESdate_defmtdate(d,fmt,str)==0)
249+
if (PGTYPESdate_defmt_asc(d,fmt,str)==0)
241250
return0;
242251

243252
switch (errno)
@@ -254,7 +263,7 @@ rdefmtdate (Date *d, char *fmt, char *str)
254263
int
255264
rfmtdate (Dated,char*fmt,char*str)
256265
{
257-
if (PGTYPESdate_fmtdate(d,fmt,str)==0)
266+
if (PGTYPESdate_fmt_asc(d,fmt,str)==0)
258267
return0;
259268

260269
if (errno==ENOMEM)
@@ -275,19 +284,36 @@ rmdyjul (short mdy[3], Date *d)
275284
void
276285
dtcurrent (Timestamp*ts)
277286
{
278-
return;
287+
PGTYPEStimestamp_current (ts);
279288
}
280289

281290
int
282291
dtcvasc (char*str,Timestamp*ts)
283292
{
293+
Timestampts_tmp;
294+
inti;
295+
char**endptr=&str;
296+
297+
ts_tmp=PGTYPEStimestamp_from_asc(str,endptr);
298+
i=errno;
299+
if (i) {
300+
returni;
301+
}
302+
if (**endptr) {
303+
/* extra characters exist at the end */
304+
return-1264;
305+
}
306+
307+
/* everything went fine */
308+
*ts=ts_tmp;
309+
284310
return0;
285311
}
286312

287313
int
288314
dtsub (Timestamp*ts1,Timestamp*ts2,Interval*iv)
289315
{
290-
return0;
316+
returnPGTYPEStimestamp_sub(ts1,ts2,iv);
291317
}
292318

293319
int
@@ -299,22 +325,21 @@ dttoasc (Timestamp *ts, char *output)
299325
int
300326
dttofmtasc (Timestamp*ts,char*output,intstr_len,char*fmtstr)
301327
{
302-
return0;
328+
returnPGTYPEStimestamp_fmt_asc(ts,output,str_len,fmtstr);
303329
}
304330

305331
int
306332
intoasc(Interval*i,char*str)
307333
{
334+
str=PGTYPESinterval_to_asc(i);
335+
336+
if (!str)
337+
return-errno;
338+
308339
return0;
309340
}
310341

311342
/* And finally some misc functions */
312-
int
313-
rstrdate (char*str,Date*d)
314-
{
315-
return0;
316-
}
317-
318343
int
319344
rfmtlong(longlvalue,char*format,char*outbuf)
320345
{
@@ -352,8 +377,10 @@ rtypmsize(int type, int len)
352377
}
353378

354379
void
355-
rupshift(char*s)
380+
rupshift(char*str)
356381
{
382+
for (;*str!='\0';str++)
383+
if (islower(*str))*str=toupper(*str);
357384
return;
358385
}
359386

‎src/interfaces/ecpg/ecpglib/data.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.3 2003/03/27 14:29:17 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.4 2003/04/01 14:37:25 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -384,9 +384,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
384384
if (pval)
385385
{
386386
if (isarray&&*pval=='"')
387-
nres=PGTYPESnumeric_aton(pval+1,&scan_length);
387+
nres=PGTYPESnumeric_from_asc(pval+1,&scan_length);
388388
else
389-
nres=PGTYPESnumeric_aton(pval,&scan_length);
389+
nres=PGTYPESnumeric_from_asc(pval,&scan_length);
390390

391391
if (isarray&&*scan_length=='"')
392392
scan_length++;
@@ -399,7 +399,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
399399
}
400400
}
401401
else
402-
nres=PGTYPESnumeric_aton("0.0",&scan_length);
402+
nres=PGTYPESnumeric_from_asc("0.0",&scan_length);
403403

404404
PGTYPESnumeric_copy(nres, (Numeric*)(var+offset*act_tuple));
405405
break;
@@ -408,9 +408,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
408408
if (pval)
409409
{
410410
if (isarray&&*pval=='"')
411-
ires=PGTYPESinterval_atoi(pval+1,&scan_length);
411+
ires=PGTYPESinterval_from_asc(pval+1,&scan_length);
412412
else
413-
ires=PGTYPESinterval_atoi(pval,&scan_length);
413+
ires=PGTYPESinterval_from_asc(pval,&scan_length);
414414

415415
if (isarray&&*scan_length=='"')
416416
scan_length++;
@@ -423,17 +423,17 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
423423
}
424424
}
425425
else
426-
ires=PGTYPESinterval_atoi("0 seconds",NULL);
426+
ires=PGTYPESinterval_from_asc("0 seconds",NULL);
427427

428428
PGTYPESinterval_copy(ires, (Interval*)(var+offset*act_tuple));
429429
break;
430430
caseECPGt_date:
431431
if (pval)
432432
{
433433
if (isarray&&*pval=='"')
434-
ddres=PGTYPESdate_atod(pval+1,&scan_length);
434+
ddres=PGTYPESdate_from_asc(pval+1,&scan_length);
435435
else
436-
ddres=PGTYPESdate_atod(pval,&scan_length);
436+
ddres=PGTYPESdate_from_asc(pval,&scan_length);
437437

438438
if (isarray&&*scan_length=='"')
439439
scan_length++;
@@ -453,9 +453,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
453453
if (pval)
454454
{
455455
if (isarray&&*pval=='"')
456-
tres=PGTYPEStimestamp_atot(pval+1,&scan_length);
456+
tres=PGTYPEStimestamp_from_asc(pval+1,&scan_length);
457457
else
458-
tres=PGTYPEStimestamp_atot(pval,&scan_length);
458+
tres=PGTYPEStimestamp_from_asc(pval,&scan_length);
459459

460460
if (isarray&&*scan_length=='"')
461461
scan_length++;

‎src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 10 additions & 12 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.7 2003/03/30 11:48:18 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.8 2003/04/01 14:37:25 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -847,7 +847,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
847847
{
848848
for (element=0;element<var->arrsize;element++)
849849
{
850-
str=PGTYPESnumeric_ntoa((Numeric*)((var+var->offset*element)->value),0);
850+
str=PGTYPESnumeric_to_asc((Numeric*)((var+var->offset*element)->value),0);
851851
slen=strlen (str);
852852

853853
if (!(mallocedval=ECPGrealloc(mallocedval,strlen(mallocedval)+slen+5,stmt->lineno)))
@@ -863,7 +863,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
863863
}
864864
else
865865
{
866-
str=PGTYPESnumeric_ntoa((Numeric*)(var->value),0);
866+
str=PGTYPESnumeric_to_asc((Numeric*)(var->value),0);
867867
slen=strlen (str);
868868

869869
if (!(mallocedval=ECPGalloc(slen+1,stmt->lineno)))
@@ -888,7 +888,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
888888
{
889889
for (element=0;element<var->arrsize;element++)
890890
{
891-
str=PGTYPESinterval_itoa((Interval*)((var+var->offset*element)->value));
891+
str=PGTYPESinterval_to_asc((Interval*)((var+var->offset*element)->value));
892892
slen=strlen (str);
893893

894894
if (!(mallocedval=ECPGrealloc(mallocedval,strlen(mallocedval)+slen+5,stmt->lineno)))
@@ -904,7 +904,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
904904
}
905905
else
906906
{
907-
str=PGTYPESinterval_itoa((Interval*)(var->value));
907+
str=PGTYPESinterval_to_asc((Interval*)(var->value));
908908
slen=strlen (str);
909909

910910
if (!(mallocedval=ECPGalloc(slen+1,stmt->lineno)))
@@ -929,7 +929,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
929929
{
930930
for (element=0;element<var->arrsize;element++)
931931
{
932-
str=PGTYPESdate_dtoa(*(Date*)((var+var->offset*element)->value));
932+
str=PGTYPESdate_to_asc(*(Date*)((var+var->offset*element)->value));
933933
slen=strlen (str);
934934

935935
if (!(mallocedval=ECPGrealloc(mallocedval,strlen(mallocedval)+slen+5,stmt->lineno)))
@@ -945,7 +945,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
945945
}
946946
else
947947
{
948-
str=PGTYPESdate_dtoa(*(Date*)(var->value));
948+
str=PGTYPESdate_to_asc(*(Date*)(var->value));
949949
slen=strlen (str);
950950

951951
if (!(mallocedval=ECPGalloc(slen+1,stmt->lineno)))
@@ -970,7 +970,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
970970
{
971971
for (element=0;element<var->arrsize;element++)
972972
{
973-
str=PGTYPEStimestamp_ttoa(*(Timestamp*)((var+var->offset*element)->value));
973+
str=PGTYPEStimestamp_to_asc(*(Timestamp*)((var+var->offset*element)->value));
974974
slen=strlen (str);
975975

976976
if (!(mallocedval=ECPGrealloc(mallocedval,strlen(mallocedval)+slen+5,stmt->lineno)))
@@ -986,7 +986,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
986986
}
987987
else
988988
{
989-
str=PGTYPEStimestamp_ttoa(*(Timestamp*)(var->value));
989+
str=PGTYPEStimestamp_to_asc(*(Timestamp*)(var->value));
990990
slen=strlen (str);
991991

992992
if (!(mallocedval=ECPGalloc(slen+1,stmt->lineno)))
@@ -1239,9 +1239,7 @@ ECPGexecute(struct statement * stmt)
12391239
{
12401240
ECPGlog("ECPGexecute line %d: ASYNC NOTIFY of '%s' from backend pid '%d' received\n",
12411241
stmt->lineno,notify->relname,notify->be_pid);
1242-
/*PQfreemem(notify);*/
1243-
free(notify);
1244-
#warning Remove PQfreemem define
1242+
PQfreemem(notify);
12451243
}
12461244

12471245
returnstatus;

‎src/interfaces/ecpg/include/decimal.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
#definedec_t Numeric
55
#endif/* dec_t */
66

7-
intdecadd(dec_t*,Numeric*,Numeric*);
8-
intdeccmp(dec_t*,Numeric*);
9-
voiddeccopy(dec_t*,Numeric*);
7+
intdecadd(dec_t*,dec_t*,dec_t*);
8+
intdeccmp(dec_t*,dec_t*);
9+
voiddeccopy(dec_t*,dec_t*);
1010
intdeccvasc(char*,int,dec_t*);
1111
intdeccvdbl(double,dec_t*);
1212
intdeccvint(int,dec_t*);
1313
intdeccvlong(long,dec_t*);
14-
intdecdiv(dec_t*,Numeric*,Numeric*);
15-
intdecmul(dec_t*,Numeric*,Numeric*);
16-
intdecsub(dec_t*,Numeric*,Numeric*);
14+
intdecdiv(dec_t*,dec_t*,dec_t*);
15+
intdecmul(dec_t*,dec_t*,dec_t*);
16+
intdecsub(dec_t*,dec_t*,dec_t*);
1717
intdectoasc(dec_t*,char*,int,int);
1818
intdectodbl(dec_t*,double*);
1919
intdectoint(dec_t*,int*);

‎src/interfaces/ecpg/include/pgtypes_date.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
#defineDate long
77

8-
externDatePGTYPESdate_atod(char*,char**);
9-
externchar*PGTYPESdate_dtoa(Date);
10-
externDatePGTYPESdate_ttod(Timestamp);
8+
externDatePGTYPESdate_from_asc(char*,char**);
9+
externchar*PGTYPESdate_to_asc(Date);
10+
externDatePGTYPESdate_from_timestamp(Timestamp);
1111
externvoidPGTYPESdate_julmdy(Date,int*);
1212
externvoidPGTYPESdate_mdyjul(int*,Date*);
1313
externintPGTYPESdate_dayofweek(Date);
1414
externvoidPGTYPESdate_today (Date*);
15-
externintPGTYPESdate_defmtdate(Date*,char*,char*);
16-
externintPGTYPESdate_fmtdate(Date,char*,char*);
15+
externintPGTYPESdate_defmt_asc(Date*,char*,char*);
16+
externintPGTYPESdate_fmt_asc(Date,char*,char*);
1717
#endif/* PGTYPES_DATETIME */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp