Possible Input Parser Issue Inf How to convert SQL file into database when a column value is Inf?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible Input Parser Issue Inf How to convert SQL file into database when a column value is Inf?

Keith Medcalf

The tip of trunk also does not parse "Inf" or "-Inf" floating point values (eg: in an insert statement), but will produce Inf and -Inf output.  The bind and column values interfaces however do handle the IEEE inf/-inf correctly.

Is this a bug/oversight in the parser?

sqlite> create table x(x real);
sqlite> insert into x values(Inf);
Error: no such column: Inf
sqlite> insert into x values(-Inf);
Error: no such column: Inf
sqlite> insert into x values(-1e400);
sqlite> select * from x;
-Inf

Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:22:17) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import apsw
>>> import apswaddins
>>> db = apsw.Connection(':memory:')
>>> db.cursor().execute('create table x(x real);')
<apsw.Cursor object at 0x05EF70A0>
>>> db.cursor().execute('insert into x values (Inf);')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/cursor.c", line 1019, in APSWCursor_execute.sqlite3_prepare
  File "src/statementcache.c", line 386, in sqlite3_prepare
apsw.SQLError: SQLError: no such column: Inf
>>> db.cursor().execute('insert into x values (-1e400);')
<apsw.Cursor object at 0x05EF7060>
>>> for row in db.cursor().execute('select * from x;'): print row
...
Row(x=-inf)
>>> a = row[0]
>>> a
-inf
>>> db.cursor().execute('insert into x values (?);',(a,))
<apsw.Cursor object at 0x05EF7060>
>>> for row in db.cursor().execute('select * from x;'): print row
...
Row(x=-inf)
Row(x=-inf)

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of skywind mailing lists
>Sent: Tuesday, 12 June, 2018 16:06
>To: SQLite mailing list
>Subject: [sqlite] How to convert SQL file into database when a column
>value is Inf?
>
>Hi,
>
>I issued the following commands:
>
>echo .dump | sqlite3 Database.sldb > D.sldb
>sqlite3 -init D.sldb NewDatabase.sldb
>
>Unfortunately, reading the SQL file produced the following error:
>Error: near line 56721: no such column: Inf
>
>The corresponding SQL command is:
>INSERT INTO "Flights"
>VALUES(36,80,1470395806,'','','',NULL,0.0,0,0,0,0,0.0,-Inf,0.0,-
>Inf,0.0,-
>Inf,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,NULL,0,0,NULL,NULL,NULL
>,NULL,4,0,'');
>
>OK, it seems to be that the column values are not really correct (-
>Inf) but I would still like to do the conversion. Is there a
>command/trick in sqlite3 that makes it work?
>
>A workaround is of course to use a text editor and try to find and
>replace all occurrences of Inf or -Info.
>
>Regards,
>Hartwig
>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Possible Input Parser Issue Inf How to convert SQL file into database when a column value is Inf?

Richard Hipp-3
On 6/12/18, Keith Medcalf <[hidden email]> wrote:
>
> The tip of trunk also does not parse "Inf" or "-Inf" floating point values

Maybe use 1e999 and -1e999 instead?
--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Possible Input Parser Issue Inf How to convert SQL file into database when a column value is Inf?

Chris Brody
On Tue, Jun 12, 2018 at 6:40 PM Richard Hipp <[hidden email]> wrote:
> [...]
> Maybe use 1e999 and -1e999 instead?

I can confirm on SQLite versions 3.19.2 & 3.24.0:

sqlite> select 1e999;
Inf
sqlite> select -1e999;
-Inf

I wouldn't mind it if SQLite would be a little more symmetrical, i.e.
output of .dump with Inf or -Inf values would be valid input.

Chris
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Possible Input Parser Issue Inf How to convert SQL file into database when a column value is Inf?

Abroży Nieprzełoży
or .dump should produce output with 1e999 / -1e999 instead of Inf / -Inf

2018-06-13 1:11 GMT+02:00, Chris Brody <[hidden email]>:

> On Tue, Jun 12, 2018 at 6:40 PM Richard Hipp <[hidden email]> wrote:
>> [...]
>> Maybe use 1e999 and -1e999 instead?
>
> I can confirm on SQLite versions 3.19.2 & 3.24.0:
>
> sqlite> select 1e999;
> Inf
> sqlite> select -1e999;
> -Inf
>
> I wouldn't mind it if SQLite would be a little more symmetrical, i.e.
> output of .dump with Inf or -Inf values would be valid input.
>
> Chris
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users