>   PostgreSQL version : 6.3-980326
> Problem Description:
> --------------------
> Parser generated error message when script was inserting
> a value equal -1 into column of float8 type.
> If exchange -1 to -1.0 - no errors. 
> 
> --------------------------------------------------------------------------
> 
> Test Case:
> ----------
> create table templ_arg(accii int2,type char,sign float8);
> create table a1 () inherits (templ_arg);
> insert into a1 values (9999,'a',1); -- working;
> insert into a1 values (9999,'a',-1); -- ERROR;
> insert into a1 values (9999,'a',-1.0); --working
Yep, it is a bug, and I will add it to the TODO list.  In float8out, we
use:
	printf("%.*g", CONST, value)

and the %g is causing it to print as:

             equal to the precision.  Trailing zeros are removed from the
             fractional part of the result; a decimal point appears only if it
             is followed by at least one digit.

Now, what we should probably be doing is to allow -1 (without decimal
point) to be promoted to float8 in the INSERT, and I think we are going
to be able to do that in 6.4.

I know this is crummy, but I can't even think of a workaround for it.


-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Sat, 28 Mar 1998 15:16:46 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [PORTS] Port Bug Report: pg_dump -d database >unload.file;
	cat unload.file|psql database ARE NOT EQUAL
> Problem Description:
> --------------------
> Parser generated error message when script was inserting
> a value equal -1 into column of float8 type.
> If exchange -1 to -1.0 - no errors. 
> 
> --------------------------------------------------------------------------
> 
> Test Case:
> ----------
> create table templ_arg(accii int2,type char,sign float8);
> create table a1 () inherits (templ_arg);
> insert into a1 values (9999,'a',1); -- working;
> insert into a1 values (9999,'a',-1); -- ERROR;
> insert into a1 values (9999,'a',-1.0); --working

OK, it is more compilcated that I realized.  I now see that:

	> insert into a1 values (9999,'a',1); -- working;

works but:
	
	> insert into a1 values (9999,'a',-1); -- ERROR;

does not.  Thomas, any idea why this would happen?


-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Sat, 28 Mar 1998 15:52:19 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [PORTS] Port Bug Report: pg_dump -d database >unload.file;
	cat unload.file|psql database ARE NOT EQUAL
> create table templ_arg(accii int2,type char,sign float8);
> create table a1 () inherits (templ_arg);
> insert into a1 values (9999,'a',1); -- working;
> insert into a1 values (9999,'a',-1); -- ERROR;
> insert into a1 values (9999,'a',-1.0); --working

Looking at the grammar, I think that -1 is being interpreted as the
expression minus and 1, as in (no_expression - 1), and the complaint is
that that expression is not a float8.  We already have code to promote
constants to float4.  Thomas will have to comment, because he
understands the handling of the minuses.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Sat, 28 Mar 1998 16:14:10 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [PORTS] Port Bug Report: pg_dump -d database >unload.file;
	cat unload.file|psql database ARE NOT EQUAL
> create table templ_arg(accii int2,type char,sign float8);
> create table a1 () inherits (templ_arg);
> insert into a1 values (9999,'a',1); -- working;
> insert into a1 values (9999,'a',-1); -- ERROR;
> insert into a1 values (9999,'a',-1.0); --working

Yep, the problem gram.y line is:

        | '-' a_expr %prec UMINUS
                {   $$ = makeA_Expr(OP, "-", NULL, $2);}

This is being executed rather than the code that reads in negative
integer constants.
 
-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Sat, 28 Mar 1998 16:22:44 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [PORTS] Port Bug Report: pg_dump -d database >unload.file;
	cat unload.file|psql database ARE NOT EQUAL
> > create table templ_arg(accii int2,type char,sign float8);
> > create table a1 () inherits (templ_arg);
> > insert into a1 values (9999,'a',1); -- working;
> > insert into a1 values (9999,'a',-1); -- ERROR;
> > insert into a1 values (9999,'a',-1.0); --working
> 
> Yep, the problem gram.y line is:
> 
>         | '-' a_expr %prec UMINUS
>                 {   $$ = makeA_Expr(OP, "-", NULL, $2);}
> 
> This is being executed rather than the code that reads in negative
> integer constants.

Yes. It's a problem because the scanner assigned types to integer and
floating point constants, but does not have a sense of context so the
negative sign must be stripped off since it could be in the middle of a
math expression. We will need to fix this in gram.y or by using the new
type conversion stuff farther back. But, I don't know how much new type
conversion capabilities there will be until I've tried to address most
of the pieces; still working out lingering problems in the function call
portion.

Will put this one on my list of things to look at.

                          - Tom

Mon, 30 Mar 1998 06:42:36 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [PORTS] Port Bug Report: pg_dump -d database >unload.file;
	cat unload.file|psql database ARE NOT EQUAL