freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] "Data conversion resulted in overflow" with float constants
- From: "James K. Lowden" <jklowden AT freetds.org>
- To: freetds AT lists.ibiblio.org
- Subject: Re: [freetds] "Data conversion resulted in overflow" with float constants
- Date: Wed, 26 Jun 2013 20:17:45 -0400
On Fri, 21 Jun 2013 18:14:10 -0430
arielCo <arielco AT gmail.com> wrote:
> James, I substituted dbwillconvert() successfully in the 0.91 tarball,
> but in Git it now boolean-izes the result of tds_willconvert:
> return tds_willconvert(srctype, desttype) ? TRUE : FALSE;
> Which makes more sense given the function name, but dbwillconvert
> remains a scalar.
>
> Since there are three mostly-redundant switch statements, and the one
> in tds_willconvert is almost complete, maybe:
> * have a single switch statement in, say, get_printable_size
> (type,size)
> * _get_printable_size(colinfo) would be a wrapper
> * tds_willconvert(srctype, desttype) calls get_printable_size(),
> perhaps mapping SYBINTN to SYBINT8 since the size doesn't matter
> * dbwillconvert stays a wrapper
> * both *willconvert() functions return a boolean
Hi Ariel,
Thanks for working on this, first of all, on behalf of the community.
My preference would be:
1. put all the work in tds_willconvert()
2. #define PRINTABLE_SIZE(x, SYBCHAR)
3. remove _get_printable_size() and get_printable_size
4. return int
because
1. get_printable_size() could otherwise return a
value for an input type that tds_convert() cannot handle (or that
tds_willconvert() says cannot be handled). This way, an invalid input
is uniformly and correctly handled.
2. This is C, and the rule in C is that 0 is false and anything else
is true. Reducing the return code from "size of output" to "yes or no"
removes information to no advantage. (I have no sympathy for the C
programmer who writes
if (dbwillconvert(SYBINT, SYBCHAR) == TRUE)
because, well, there oughta be a law.)
3. No self-respecting C function, except I/O, should begin with "get".
It's a *function*! It maps input to output. Observe:
int len = get_printable_size(SYBINT);
int len = printable_size(SYBINT);
The "get" is just nonce noise. In the same way we don't say
double x = compute_square_root(y);
or
double x = get_sqrt(y);
but
double x = sqrt(y);
Save typing. Read faster. Go home early. ;-)
Hope you're convinced, and thanks again for putting in the time.
--jkl
> On Fri, Jun 14, 2013 at 10:00 PM, arielCo <arielco AT gmail.com> wrote:
> > On Thu, Jun 13, 2013 at 6:06 PM, James K. Lowden
> > <jklowden AT freetds.org> wrote:
> >> The right thing to do -- your mission, should you choose to accept
> >> it
> >> -- is to use tdswillconvert() instead to determine the size.
> > Challenge accepted. I'll keep you posted.
> >
> >
> > Ariel Cornejo
> > +58·412·8083546
> > +58·416·6189113
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] "Data conversion resulted in overflow" with float constants,
arielCo, 06/12/2013
- Re: [freetds] "Data conversion resulted in overflow" with float constants, James K. Lowden, 06/12/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
David Chang, 06/12/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
arielCo, 06/13/2013
- Re: [freetds] "Data conversion resulted in overflow" with float constants, Frediano Ziglio, 06/13/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
James K. Lowden, 06/13/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
arielCo, 06/14/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
arielCo, 06/21/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
James K. Lowden, 06/26/2013
- Re: [freetds] "Data conversion resulted in overflow" with float constants, arielCo, 06/27/2013
- Re: [freetds] "Data conversion resulted in overflow" with float constants, James K. Lowden, 06/27/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
James K. Lowden, 06/26/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
arielCo, 06/21/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
arielCo, 06/14/2013
-
Re: [freetds] "Data conversion resulted in overflow" with float constants,
arielCo, 06/13/2013
Archive powered by MHonArc 2.6.24.