pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bug correction
3+ messages / 3 participants
[nested] [flat]

* Bug correction
@ 2003-12-16 02:40  George A.J <jinujosein@yahoo.com>
  0 siblings, 1 reply; 3+ messages in thread

From: George A.J @ 2003-12-16 02:40 UTC (permalink / raw)
  To: pgsql-odbc


hi all,

i am using postgresql 7.3.2 with ODBC 7.3.1 

i have fixed a bug in the ODBC driver. ie the bug when numeric input 0.009 is given it reached database as .9 . how can i add this fix to the source. the bug is still in the latest ODBC. 

pls inform about how can i send this fix..

regards

jinujose  


---------------------------------
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Bug correction
@ 2003-12-19 14:35  Hiroshi Inoue <inoue@tpf.co.jp>
  parent: George A.J <jinujosein@yahoo.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Hiroshi Inoue @ 2003-12-19 14:35 UTC (permalink / raw)
  To: pgsql-odbc

Please post your patch(diff -c style) to pgsql-odbc ML.

regards,,
Hiroshi Inoue

> ""George A.J"" <jinujosein@yahoo.com> wrote in message
news:20031216024053.4324.qmail@web14906.mail.yahoo.com...
> hi all,
> i am using postgresql 7.3.2 with ODBC 7.3.1
> i have fixed a bug in the ODBC driver. ie the bug when numeric input 0.009
is given it reached database as .9 .
> how can i add this fix to the source. the bug is still in the latest ODBC.
> pls inform about how can i send this fix..




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Bug correction
@ 2004-01-05 09:36  Hiroshi Inoue <Inoue@tpf.co.jp>
  0 siblings, 0 replies; 3+ messages in thread

From: Hiroshi Inoue @ 2004-01-05 09:36 UTC (permalink / raw)
  To: George A.J <jinujosein@yahoo.com>; +Cc: pgsql-odbc

"George A.J" wrote:
> 
> Hi,
> i don't know how to send a fix in the diff format so i am sending the
> corected file.
> i have changed the function ResolveNumericParam() in the file
> convert.c
> the function is given billow. i have commented the added/deleted
> lines. also attaching the file convert.c.

The first bug (0.0 -> .) is fixed in CVS already.
I would fix the second bug (.009 -> .9) according to
your code.

regards,
Hiroshi Inoue
 
> static BOOL
> ResolveNumericParam(const SQL_NUMERIC_STRUCT *ns, char *chrform)
> {
>  static const int prec[] = {1, 3, 5, 8, 10, 13, 15, 17, 20, 22, 25,
> 29, 32, 34, 37, 39};
>  Int4 i, j, k, ival, vlen, len, newlen;
>  unsigned char  calv[40];
>  const unsigned char *val = (const unsigned char *) ns->val;
>  BOOL next_figure;
> 
>  if (0 == ns->precision)
>  {
>   strcpy(chrform, "0");
>   return TRUE;
>  }
>  else if (ns->precision < prec[sizeof(Int4)])
>  {
>   for (i = 0, ival = 0; i < sizeof(Int4) && prec[i] <= ns->precision;
> i++)
>   {
>    ival += (val[i] << (8 * i)); /* ns->val is little endian */
>   }
>   if (0 == ns->scale)
>   {
>    if (0 == ns->sign)
>     ival *= -1;
>    sprintf(chrform, "%d", ival);
>   }
>   else if (ns->scale > 0)
>   {
>    Int4 i, div, o1val, o2val;
> 
>    for (i = 0, div = 1; i < ns->scale; i++)
>     div *= 10;
>    o1val = ival / div;
>    o2val = ival % div;
>    if (0 == ns->sign)
>     o1val *= -1;
>    sprintf(chrform, "%d.%0.*d", o1val, ns->scale, o2val);
>   }
>   return TRUE;
>  }
> 
>  for (i = 0; i < SQL_MAX_NUMERIC_LEN && prec[i] <= ns->precision; i++)
>   ;
>  vlen = i;
>  len = 0;
>  memset(calv, 0, sizeof(calv));
>  for (i = vlen - 1; i >= 0; i--)
>  {
>   for (j = len - 1; j >= 0; j--)
>   {
>    if (!calv[j])
>     continue;
>    ival = (((Int4)calv[j]) << 8);
>    calv[j] = (ival % 10);
>    ival /= 10;
>    calv[j + 1] += (ival % 10);
>    ival /= 10;
>    calv[j + 2] += (ival % 10);
>    ival /= 10;
>    calv[j + 3] += ival;
>    for (k = j;; k++)
>    {
>     next_figure = FALSE;
>     if (calv[k] > 0)
>     {
>      if (k >= len)
>       len = k + 1;
>      while (calv[k] > 9)
>      {
>       calv[k + 1]++;
>       calv[k] -= 10;
>       next_figure = TRUE;
>      }
>     }
>     if (k >= j + 3 && !next_figure)
>      break;
>    }
>   }
>   ival = val[i];
>   if (!ival)
>    continue;
>   calv[0] += (ival % 10);
>   ival /= 10;
>   calv[1] += (ival % 10);
>   ival /= 10;
>   calv[2] += ival;
>   for (j = 0;; j++)
>   {
>    next_figure = FALSE;
>    if (calv[j] > 0)
>    {
>     if (j >= len)
>      len = j + 1;
>     while (calv[j] > 9)
>     {
>      calv[j + 1]++;
>      calv[j] -= 10;
>      next_figure = TRUE;
>     }
>    }
>    if (j >= 2 && !next_figure)
>     break;
>   }
>  }
> 
>  /********* New code:*/
> 
>  /*Added to fix the numeric convertion bug.
>  BUG:When 0.0 is the input function returns '.' Also if 0.0009 is
> input
>   the fnction returns '.9'*/
> 
>  if (len <= ns->scale)
>   len = ns->scale + 1;
> 
>  /********* End New code: */
> 
>  newlen = 0;
>  if (0 == ns->sign)
>   chrform[newlen++] = '-';
>  for (i = len - 1; i >= ns->scale; i--)
>   chrform[newlen++] = calv[i] + '0';
>  if (ns->scale > 0)
>  {
>   chrform[newlen++] = '.';
>   for (; i >= 0; i--)
>    chrform[newlen++] = calv[i] + '0';
>  }
> 
>  /********* deleted code:*/
> 
>  /*deleted to fix the numeric convertion bug. these lines are not
> needed
>  if (0 == len)
>   chrform[newlen++] = '0';*/
>  /********* end deleted code:*/
> 
>  chrform[newlen] = '\0';
>  return TRUE;
> }



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-01-05 09:36 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-12-16 02:40 Bug correction George A.J <jinujosein@yahoo.com>
2003-12-19 14:35 ` Hiroshi Inoue <inoue@tpf.co.jp>
2004-01-05 09:36 Re: Bug correction Hiroshi Inoue <Inoue@tpf.co.jp>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox