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

Commitb30da7b

Browse files
author
Michael Meskes
committed
Added lots of SoC stuff made by Joachim.
Fixed broken newline on Windows.Fixed a nasty buffer underrun that only occured when using Informixno_indicator NULL setting on timestamps and intervals.
1 parent58538a0 commitb30da7b

File tree

15 files changed

+1531
-377
lines changed

15 files changed

+1531
-377
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,5 +2082,18 @@ We Aug 9 09:28:56 CEST 2006
20822082
- Fixed error handling in numeric conversion (Joachim).
20832083
- Fixed some memory bugs that somehow reappeared.
20842084
- Also fixed a new Coverity report.
2085+
2086+
Su Aug 13 11:01:13 CEST 2006
2087+
2088+
- Applied patch for VPATH builds by Alvaro Herrera
2089+
<alvherre@commandprompt.com>
2090+
- Merged dyntest.pgc and dyntest2.pgc.
2091+
2092+
Mo Aug 14 10:39:59 CEST 2006
2093+
2094+
- Added lots of SoC stuff made by Joachim.
2095+
- Fixed broken newline on Windows.
2096+
- Fixed a nasty buffer underrun that only occured when using Informix
2097+
no_indicator NULL setting on timestamps and intervals.
20852098
- Set ecpg library version to 5.2.
20862099
- Set ecpg version to 4.2.1.

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

Lines changed: 59 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.46 2006/06/26 09:20:09 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.47 2006/08/15 06:40:19 meskes Exp $ */
22

33
#include<stdlib.h>
44
#include<string.h>
@@ -122,12 +122,15 @@ deccall3(decimal *arg1, decimal *arg2, decimal *result, int (*ptr) (numeric *, n
122122
int
123123
decadd(decimal*arg1,decimal*arg2,decimal*sum)
124124
{
125+
errno=0;
125126
deccall3(arg1,arg2,sum,PGTYPESnumeric_add);
126127

127128
if (errno==PGTYPES_NUM_OVERFLOW)
128129
returnECPG_INFORMIX_NUM_OVERFLOW;
129-
elseif (errno!=0)
130+
elseif (errno==PGTYPES_NUM_UNDERFLOW)
130131
returnECPG_INFORMIX_NUM_UNDERFLOW;
132+
elseif (errno!=0)
133+
return-1;
131134
else
132135
return0;
133136
}
@@ -179,6 +182,7 @@ deccvasc(char *cp, int len, decimal *np)
179182
ret=ECPG_INFORMIX_NUM_UNDERFLOW;
180183
else
181184
{
185+
errno=0;
182186
result=PGTYPESnumeric_from_asc(str,NULL);
183187
if (!result)
184188
{
@@ -280,6 +284,7 @@ decdiv(decimal *n1, decimal *n2, decimal *result)
280284

281285
inti;
282286

287+
errno=0;
283288
i=deccall3(n1,n2,result,PGTYPESnumeric_div);
284289

285290
if (i!=0)
@@ -304,6 +309,7 @@ decmul(decimal *n1, decimal *n2, decimal *result)
304309
{
305310
inti;
306311

312+
errno=0;
307313
i=deccall3(n1,n2,result,PGTYPESnumeric_mul);
308314

309315
if (i!=0)
@@ -325,6 +331,7 @@ decsub(decimal *n1, decimal *n2, decimal *result)
325331
{
326332
inti;
327333

334+
errno=0;
328335
i=deccall3(n1,n2,result,PGTYPESnumeric_sub);
329336

330337
if (i!=0)
@@ -371,13 +378,25 @@ dectoasc(decimal *np, char *cp, int len, int right)
371378
return-1;
372379

373380
/*
374-
* TODO: have to take care of len here and createexponatial notion if
375-
* necessary
381+
* TODO: have to take care of len here and createexponential notation
382+
*ifnecessary
376383
*/
377-
strncpy(cp,str,len);
378-
free(str);
379-
380-
return0;
384+
if ((int) (strlen(str)+1)>len)
385+
{
386+
if (len>1)
387+
{
388+
cp[0]='*';
389+
cp[1]='\0';
390+
}
391+
free(str);
392+
return-1;
393+
}
394+
else
395+
{
396+
strcpy(cp,str);
397+
free(str);
398+
return0;
399+
}
381400
}
382401

383402
int
@@ -474,59 +493,7 @@ rdatestr(date d, char *str)
474493
int
475494
rstrdate(char*str,date*d)
476495
{
477-
datedat;
478-
charstrbuf[10];
479-
inti,
480-
j;
481-
482-
rsetnull(CDATETYPE, (char*)&dat);
483-
484-
/*
485-
* we have to flip the year month date around for postgres expects
486-
* yyyymmdd
487-
*
488-
*/
489-
490-
for (i=0,j=0;i<10;i++)
491-
{
492-
/* ignore non-digits */
493-
if (isdigit((unsignedchar)str[i]))
494-
{
495-
496-
/* j only increments if it is a digit */
497-
switch (j)
498-
{
499-
/* stick the month into the 4th, 5th position */
500-
case0:
501-
case1:
502-
strbuf[j+4]=str[i];
503-
break;
504-
/* stick the day into the 6th, and 7th position */
505-
case2:
506-
case3:
507-
strbuf[j+4]=str[i];
508-
break;
509-
510-
/* stick the year into the first 4 positions */
511-
case4:
512-
case5:
513-
case6:
514-
case7:
515-
strbuf[j-4]=str[i];
516-
break;
517-
518-
}
519-
j++;
520-
}
521-
}
522-
strbuf[8]='\0';
523-
dat=PGTYPESdate_from_asc(strbuf,NULL);
524-
525-
if (errno&&errno!=PGTYPES_DATE_BAD_DATE)
526-
returnECPG_INFORMIX_BAD_DATE;
527-
528-
*d=dat;
529-
return0;
496+
returnrdefmtdate(d,"mm/dd/yyyy",str);
530497
}
531498

532499
void
@@ -554,6 +521,7 @@ rdefmtdate(date * d, char *fmt, char *str)
554521
/* TODO: take care of DBCENTURY environment variable */
555522
/* PGSQL functions allow all centuries */
556523

524+
errno=0;
557525
if (PGTYPESdate_defmt_asc(d,fmt,str)==0)
558526
return0;
559527

@@ -576,6 +544,7 @@ rdefmtdate(date * d, char *fmt, char *str)
576544
int
577545
rfmtdate(dated,char*fmt,char*str)
578546
{
547+
errno=0;
579548
if (PGTYPESdate_fmt_asc(d,fmt,str)==0)
580549
return0;
581550

@@ -618,22 +587,31 @@ dtcvasc(char *str, timestamp * ts)
618587
inti;
619588
char**endptr=&str;
620589

590+
errno=0;
621591
ts_tmp=PGTYPEStimestamp_from_asc(str,endptr);
622592
i=errno;
623593
if (i)
594+
/* TODO: rewrite to Informix error codes */
624595
returni;
625596
if (**endptr)
626597
{
627598
/* extra characters exist at the end */
628599
returnECPG_INFORMIX_EXTRA_CHARS;
629600
}
601+
/* TODO: other Informix error codes missing */
630602

631603
/* everything went fine */
632604
*ts=ts_tmp;
633605

634606
return0;
635607
}
636608

609+
int
610+
dtcvfmtasc(char*inbuf,char*fmtstr,timestamp*dtvalue)
611+
{
612+
returnPGTYPEStimestamp_defmt_asc(inbuf,fmtstr,dtvalue);
613+
}
614+
637615
int
638616
dtsub(timestamp*ts1,timestamp*ts2,interval*iv)
639617
{
@@ -659,6 +637,7 @@ dttofmtasc(timestamp * ts, char *output, int str_len, char *fmtstr)
659637
int
660638
intoasc(interval*i,char*str)
661639
{
640+
errno=0;
662641
str=PGTYPESinterval_to_asc(i);
663642

664643
if (!str)
@@ -797,17 +776,21 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
797776
/* qualify, where we are in the value_string */
798777
if (k<0)
799778
{
800-
if (leftalign)
801-
{
802-
/* can't use strncat(,,0) here, Solaris would freek out */
803-
temp[j]='\0';
804-
break;
805-
}
806779
blank=1;
807780
if (k==-2)
808781
entity=1;
809782
elseif (k==-1)
810783
sign=1;
784+
if (leftalign)
785+
{
786+
/* can't use strncat(,,0) here, Solaris would freek out */
787+
if (sign)
788+
if (signdone)
789+
{
790+
temp[j]='\0';
791+
break;
792+
}
793+
}
811794
}
812795
/* if we're right side of the right-most dot, print '0' */
813796
if (dotpos >=0&&dotpos <=i)
@@ -829,6 +812,9 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
829812
fmtchar=lastfmt;
830813
else
831814
fmtchar=fmt[i];
815+
/* waiting for the sign */
816+
if (k<0&&leftalign&&sign&& !signdone&&fmtchar!='+'&&fmtchar!='-')
817+
continue;
832818
/* analyse this format-char */
833819
switch (fmtchar)
834820
{
@@ -854,9 +840,6 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
854840
else
855841
tmp[0]=value.val_string[k];
856842
break;
857-
case'<':
858-
tmp[0]=value.val_string[k];
859-
break;
860843
case'-':
861844
if (sign&&value.sign=='-'&& !signdone)
862845
{
@@ -904,6 +887,9 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
904887
else
905888
tmp[0]=value.val_string[k];
906889
break;
890+
case'<':
891+
tmp[0]=value.val_string[k];
892+
break;
907893
default:
908894
tmp[0]=fmt[i];
909895
}
@@ -950,8 +936,9 @@ byleng(char *str, int len)
950936
void
951937
ldchar(char*src,intlen,char*dest)
952938
{
953-
memmove(dest,src,len);
954-
dest[len]=0;
939+
intdlen=byleng(src,len);
940+
memmove(dest,src,dlen);
941+
dest[dlen]='\0';
955942
}
956943

957944
int
@@ -978,12 +965,6 @@ rtypwidth(int sqltype, int sqllen)
978965
return0;
979966
}
980967

981-
int
982-
dtcvfmtasc(char*inbuf,char*fmtstr,timestamp*dtvalue)
983-
{
984-
returnPGTYPEStimestamp_defmt_asc(inbuf,fmtstr,dtvalue);
985-
}
986-
987968
staticstructvar_list
988969
{
989970
intnumber;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.30 2006/08/08 11:51:24 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.31 2006/08/15 06:40:19 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -346,8 +346,8 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
346346
staticbool
347347
_check(unsignedchar*ptr,intlength)
348348
{
349-
for (;ptr[--length]==0xff&&length >=0;length--);
350-
if (length<0)
349+
for (;length>0&&ptr[--length]==0xff;);
350+
if (length <=0)
351351
return true;
352352
return false;
353353
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_error.h,v 1.7 2006/03/11 04:38:39 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_error.h,v 1.8 2006/08/15 06:40:19 meskes Exp $ */
22

33
#definePGTYPES_NUM_OVERFLOW301
44
#definePGTYPES_NUM_BAD_NUMERIC302
55
#definePGTYPES_NUM_DIVIDE_ZERO303
6+
#definePGTYPES_NUM_UNDERFLOW304
67

78
#definePGTYPES_DATE_BAD_DATE310
89
#definePGTYPES_DATE_ERR_EARGS311

‎src/interfaces/ecpg/pgtypeslib/datetime.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.29 2006/06/21 10:24:41 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.30 2006/08/15 06:40:19 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -230,7 +230,7 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf)
230230
replace_type=PGTYPES_TYPE_UINT_4_LZ;
231231
break;
232232
casePGTYPES_FMTDATE_YEAR_DIGITS_SHORT:
233-
replace_val.uint_val=tm.tm_year %1000;
233+
replace_val.uint_val=tm.tm_year %100;
234234
replace_type=PGTYPES_TYPE_UINT_2_LZ;
235235
break;
236236
default:
@@ -537,7 +537,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
537537
* matches
538538
*/
539539
free(str_copy);
540-
errno=PGTYPES_DATE_ERR_ENOTDMY;
540+
errno=PGTYPES_DATE_ERR_ENOSHORTDATE;
541541
return-1;
542542
}
543543

‎src/interfaces/ecpg/pgtypeslib/numeric.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.31 2006/08/13 10:18:30 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.32 2006/08/15 06:40:19 meskes Exp $ */
22

33
#include"postgres_fe.h"
44
#include<ctype.h>
@@ -1512,7 +1512,10 @@ numericvar_to_double(numeric *var, double *dp)
15121512
if (errno==ERANGE)
15131513
{
15141514
free(tmp);
1515-
errno=PGTYPES_NUM_OVERFLOW;
1515+
if (val==0)
1516+
errno=PGTYPES_NUM_UNDERFLOW;
1517+
else
1518+
errno=PGTYPES_NUM_OVERFLOW;
15161519
return-1;
15171520
}
15181521

@@ -1576,7 +1579,10 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp)
15761579
return-1;
15771580
if (errno==ERANGE)
15781581
{
1579-
errno=PGTYPES_NUM_OVERFLOW;
1582+
if (*lp==LONG_MIN)
1583+
errno=PGTYPES_NUM_UNDERFLOW;
1584+
else
1585+
errno=PGTYPES_NUM_OVERFLOW;
15801586
return-1;
15811587
}
15821588
free(s);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp