Re: [sqlite] sqlite 3.31.1 crashes in SVN on OpenBSD/sparc64

2020-03-10 Thread Dominique Pellé
Stefan Sperling wrote:

> > Does valgrind give any clues?
>
> Valgrind does not run on the OpenBSD/sparc64 platform, unfortunately.

Would the address sanitizer (i.e. gcc -fsanitize=address, or
clang -fsanitize=address) work on OpenBSD/sparc64?

Regards
Dominique
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite 3.31.1 crashes in SVN on OpenBSD/sparc64

2020-03-10 Thread Stefan Sperling
On Tue, Mar 10, 2020 at 01:21:34PM -0400, Richard Hipp wrote:
> On 3/10/20, Stefan Sperling  wrote:
> > The query being executed is "STMT_INSERT_NODE":
> > -- STMT_INSERT_NODE
> > INSERT OR REPLACE INTO nodes (
> >   wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path,
> >   revision, presence, depth, kind, changed_revision, changed_date,
> >   changed_author, checksum, properties, translated_size, last_mod_time,
> >   dav_cache, symlink_target, file_external, moved_to, moved_here,
> >   inherited_props)
> > VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14,
> > ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23)
> 
> It would be great if you could send us the database schema - or even
> the whole database if it isn't too big.
>
> Probably if I have the schema I will be able to repro the problem.

The schema is public:
https://svn.apache.org/repos/asf/subversion/branches/1.13.x/subversion/libsvn_wc/wc-metadata.sql

> Is this only happening on Sparc, and not on x64 or ARM or PPC, etc?

It looks like it is specific to sparc64 so far.
I cannot reproduce it on amd64 with the same software versions.
I do not have access to arm/ppc machines at present.

> Does valgrind give any clues?

Valgrind does not run on the OpenBSD/sparc64 platform, unfortunately.

> Something else that might be helpful, if you have time:
> 
> Set a breakpoint on the sqlite3VdbeExec() function that fires when the
> statement that is crashing is first executed.  (You can determine that
> it is the correct statement by looking at the value of p->zSql.)  Then
> do:
> 
>  set p->db->flags = p->db->flags | ((0x060)<<32)
> 
> That will turn on bytecode listing and tracing, and might provide
> further clues.  Please record and send in the trace.

I will look into this. Thanks!
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread P Kishor
Hi, 

Besides the most excellent explanation given by Keith Medcalf, I want to point 
out a couple of (hopefully) helpful things –

1. Contrary to your subject line, SQLite actually does give a feedback/returns 
something. It is just not good enough (for many of us). Consider the following:

```
○ → sqlite3
SQLite version 3.30.0 2019-10-04 15:03:17
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT 30 / 2;
15
sqlite> SELECT 30 / 57;
0
sqlite> SELECT 55 / 0;

sqlite>
```

See that blank line after the last operation? That is SQLite “printing” out a 
NULL value. The `.nullvalue STRING` setting in the command line client can 
change that blank like to something more visual/meaningful.

2. The `typeof()` operator is super. It is like the detective cousin of CAST(). 
The latter allows you to change the type of a data value and the former allows 
you to find out the typeof data.

```
sqlite> SELECT typeof(55 / 0);
null
sqlite> SELECT typeof(30 / 2);
integer
sqlite> SELECT typeof(30.0 / 55);
real
sqlite> SELECT 30.0 / 55;
0.545454545454545
sqlite>
```

Good luck. And nice question as it reminded us of this math idiosyncrasy of 
SQLite.

> On Mar 10, 2020, at 8:21 AM, Octopus ZHANG  wrote:
> 
> I try to run a simple math expression, but SQLite gives no feedback :
> 
> sqlite> select 99-(55/(30/57));
> 
> 
> 
> 
> Should I expect it to return nothing?





--
Puneet Kishor
Just Another Creative Commoner
http://punkish.org/About

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite 3.31.1 crashes in SVN on OpenBSD/sparc64

2020-03-10 Thread Richard Hipp
On 3/10/20, Stefan Sperling  wrote:
> The query being executed is "STMT_INSERT_NODE":
> -- STMT_INSERT_NODE
> INSERT OR REPLACE INTO nodes (
>   wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path,
>   revision, presence, depth, kind, changed_revision, changed_date,
>   changed_author, checksum, properties, translated_size, last_mod_time,
>   dav_cache, symlink_target, file_external, moved_to, moved_here,
>   inherited_props)
> VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14,
> ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23)

It would be great if you could send us the database schema - or even
the whole database if it isn't too big.  You can send to my private
email if you like.

Probably if I have the schema I will be able to repro the problem.

Is this only happening on Sparc, and not on x64 or ARM or PPC, etc?

Does valgrind give any clues?

Something else that might be helpful, if you have time:

Set a breakpoint on the sqlite3VdbeExec() function that fires when the
statement that is crashing is first executed.  (You can determine that
it is the correct statement by looking at the value of p->zSql.)  Then
do:

 set p->db->flags = p->db->flags | ((0x060)<<32)

That will turn on bytecode listing and tracing, and might provide
further clues.  Please record and send in the trace.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3: .width counts bytes, not characters

2020-03-10 Thread Software

> I think the enhancement is here:
> https://sqlite.org/src/timeline?c=ed0842c156ab1a78
>
> That would correspond to version 3.20.0.
>
> --
> D. Richard Hipp

Thank you. The upcoming Ubuntu LTS release (20.04) includes sqlite version 
3.31.1, so the issue should disappear soon also for me.
@Keith: I aim to stay with the packages in the distribution; to avoid 
incompatibilities and as I have to maintain 7 linux installations for me and my 
family.

Best regards

Andreas
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite 3.31.1 crashes in SVN on OpenBSD/sparc64

2020-03-10 Thread Stefan Sperling
Hi,

We have seen sqlite segfault on OpenBSD/sparc64 in the context
of running Subversion's regression test suite:
https://ci.apache.org/builders/svn-bb-openbsd/builds/498

The log files show that a simple 'svn update' triggers the problem:
https://ci.apache.org/builders/svn-bb-openbsd/builds/498/steps/Cleanup/logs/stdio
https://ci.apache.org/builders/svn-bb-openbsd/builds/498/steps/svn/logs/stdio

The trace within sqlite for this crash looks like :

Reading symbols from svn...(no debugging symbols found)...done.
[New process 486437]
Core was generated by `svn'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  sqlite3VdbeRecordUnpack (pKeyInfo=0x4868586788, nKey=-538976289, 
pKey=0xdfdfdfdfdfdfdfdf, p=0x48d0b05008) at sqlite3.c:81298
81298 idx = getVarint32(aKey, szHdr);
(gdb) bt
#0  sqlite3VdbeRecordUnpack (pKeyInfo=0x4868586788, nKey=-538976289, 
pKey=0xdfdfdfdfdfdfdfdf, p=0x48d0b05008) at sqlite3.c:81298
#1  0x004951fca230 in sqlite3VdbeExec (p=0x48a9ed9208) at sqlite3.c:89382
#2  0x004951fcda40 in sqlite3Step (p=) at sqlite3.c:83210
#3  sqlite3_step (pStmt=0x48a9ed9208) at sqlite3.c:17739


Note that on OpenBSD 0xdfdfdfdfdfdfdfdf is written to memory which
has been freed.

With sqlite compiled with debugging enabled the problem triggers a
few lines f code earlier and manifests itself as an assertion failure:

#1  0x00e27e089f48 in *_libc___assert2 (file=0xe2eb9d90e0 "sqlite3.c",
line=89376, func=0xe2eb9ec9d8 <__func__.59513> "sqlite3VdbeExec",
failedexpr=0xe2eb9ee570 "pIn3->flags & MEM_Blob")
at /usr/src/lib/libc/gen/assert.c:52
#2  0x00e2eb72d42c in sqlite3VdbeExec (p=0xe2a3d0a408) at sqlite3.c:89376


I have been trying to isolate the problem for a couple of hours and
don't believe I'll get much further without help.

What's going on in Subversion is that a 'base node' row is being
inserted into the NODES table in the working copy database.
The query being executed is "STMT_INSERT_NODE":
-- STMT_INSERT_NODE
INSERT OR REPLACE INTO nodes (
  wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path,
  revision, presence, depth, kind, changed_revision, changed_date,
  changed_author, checksum, properties, translated_size, last_mod_time,
  dav_cache, symlink_target, file_external, moved_to, moved_here,
  inherited_props)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14,
?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23)

The input values bound to this query by Subversion all seem fine.

I also know that Subversion was working fine before I upgraded this
sparc64 machine to a newer OpenBSD -current snapshot on March 8, at
which point among many unrelated updates the sqlite package on the
system was upgraded from 3.30.1 to 3.31.1. As you can see on this page,
builds were green before I upgraded the system:
https://ci.apache.org/builders/svn-bb-openbsd

Below is a full back trace with debug symbols, compiled from the
sqlite-autoconf-3310100 release. At the end I've included values from
some data structures that seem relevant.

Is this enough information? I can reproduce the problem reliably,
so if you need more information just let me know what you want to see.

Cheers,
Stefan


This trace is from 'svn up' in a working copy of svn.apache.org's
"repos/asf/apr/trunk" folder, which I happened to have available.

(gdb) bt
#0  *_libc_abort () at /usr/src/lib/libc/stdlib/abort.c:57
#1  0x00e27e089f48 in *_libc___assert2 (file=0xe2eb9d90e0 "sqlite3.c",
line=89376, func=0xe2eb9ec9d8 <__func__.59513> "sqlite3VdbeExec",
failedexpr=0xe2eb9ee570 "pIn3->flags & MEM_Blob")
at /usr/src/lib/libc/gen/assert.c:52
#2  0x00e2eb72d42c in sqlite3VdbeExec (p=0xe2a3d0a408) at sqlite3.c:89376
#3  0x00e2eb71a370 in sqlite3Step (p=0xe2a3d0a408) at sqlite3.c:83210
#4  0x00e2eb71a894 in sqlite3_step (pStmt=0xe2a3d0a408) at sqlite3.c:83275
#5  0x00e30cfff5fc in svn_sqlite__step (got_row=0xfffeb734,
stmt=0xe332deb910) at subversion/libsvn_subr/sqlite.c:347
#6  0x00e30cfff6d8 in svn_sqlite__insert (row_id=0x0, stmt=0xe332deb910)
at subversion/libsvn_subr/sqlite.c:371
#7  0x00e2896d9034 in insert_base_node (pibb=0xfffeb9a0,
wcroot=0xe2754a2d60, local_relpath=0xe27a8481a1 "file_io/os2",
scratch_pool=0xe27a848028) at subversion/libsvn_wc/wc_db.c:812
#8  0x00e2896dd1a4 in svn_wc__db_base_add_directory (db=,
local_abspath=0xe27a848188 "/home/stsp/src/apr-trunk/file_io/os2",
wri_abspath=,
repos_relpath=0xe27a8482d8 "apr/apr/trunk/file_io/os2",
repos_root_url=0xe2754a7628 "https://svn.apache.org/repos/asf;,
repos_uuid=0xe2754a7650 "13f79535-47bb-0310-9956-ffa450edef68",
revision=1875042, props=0xe27a848890, changed_rev=1866019,
changed_date=1566976038342098, changed_author=0xe27a848ba8 "jorton",
children=0x0, depth=svn_depth_empty, dav_cache=0x0, update_actual_props=1,
new_actual_props=0xe27a848988, new_iprops=0x0, conflict=0x0,
work_items=0x0, 

Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Jose Isaias Cabrera

Simon Slavin, on Tuesday, March 10, 2020 09:23 AM, wrote...
>
> On 10 Mar 2020, at 12:40pm, Jose Isaias Cabrera 
> wrote:
>
> > Simon Slavin, on Tuesday, March 10, 2020 03:25 AM, wrote...
> >
> >> That's going in my list of annoying questions.  Thank you.
> >
> > Simon, with all due respect, and grateful for all the answers you have
> provided to me, this is not an annoying question. Not everyone in the world
> knows what you know.
>
> Jose, I must apologise for not explaining myself better.
>
> It's a delightful annoying question. Anyone who asks that question should
> be annoyed, at computers in general and the one they're swearing at in
> particular. I love those questions and I giggle over them when people tell
> me that programming must be easy because computers are simple and logical.

Apologies, Simon.  I knew there was something wrong, here: me.  Yes, I said to 
myself, "that is not like Simon to answer that harsh!" But you actually were 
talking about the SQL syntax itself.  It's hard with emails to see the faces, 
intentions, meanings, etc., behind the content. Thanks for explaining yourself. 
:-)  I knew I was wrong.

josé
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is this an SQL parsing / ambiguity bug ?

2020-03-10 Thread Richard Hipp
On 3/10/20, Simon Slavin  wrote:
> On 9 Mar 2020, at 8:40pm, Vladimir Vysotsky  wrote:
>
>> sqlite> insert into dst(id) select id from src on conflict do nothing;
>> Error: near "do": syntax error
>
> SQLite does not understand "DO NOTHING".  You probably want "ON CONFLICT
> IGNORE".

I think Vlad is trying to do an upsert, which does have a DO NOTHING
syntax that I copied from postgres.

The parsing ambiguity that Vlad is complaining about (if I understand
him correctly) is documented at the bottom of the upsert page:
https://www.sqlite.org/lang_UPSERT.html#parseambig

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is this an SQL parsing / ambiguity bug ?

2020-03-10 Thread Simon Slavin
On 9 Mar 2020, at 8:40pm, Vladimir Vysotsky  wrote:

> sqlite> insert into dst(id) select id from src on conflict do nothing;
> Error: near "do": syntax error

SQLite does not understand "DO NOTHING".  You probably want "ON CONFLICT 
IGNORE".


___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Simon Slavin
On 10 Mar 2020, at 12:40pm, Jose Isaias Cabrera  wrote:

> Simon Slavin, on Tuesday, March 10, 2020 03:25 AM, wrote...
> 
>> That's going in my list of annoying questions.  Thank you.
> 
> Simon, with all due respect, and grateful for all the answers you have 
> provided to me, this is not an annoying question.  Not everyone in the world 
> knows what you know.

Jose, I must apologise for not explaining myself better.

It's a delightful annoying question.  Anyone who asks that question should be 
annoyed, at computers in general and the one they're swearing at in particular. 
 I love those questions and I giggle over them when people tell me that 
programming must be easy because computers are simple and logical.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Jose Isaias Cabrera

Keith Medcalf, on Tuesday, March 10, 2020 03:57 AM, wrote...
>
>
> On Tuesday, 10 March, 2020 01:22, Octopus ZHANG 
> wrote:
>
> >I try to run a simple math expression, but SQLite gives no feedback :
>
> >sqlite> select 99-(55/(30/57));
>
> >Should I expect it to return nothing?
>
> It is returning something.  It is returning NULL.
>
> sqlite> .nullvalue 
> sqlite> select 99-(55/(30/57));
> 
> sqlite>
>
> 99 - (55 / (30 / 57))
>
> 30 / 57 -> 0
>
> 55 / 0 -> NULL
>
> 99 - NULL -> NULL
>
> If you want the result of 30/57 to be a floating point number (ie, not
> zero), you need to have one of those numbers be floating point, after which
> each successive operation will be carried out in floating point rather than
> integer arithmetic.
>
> 30. / 57 == 30 / 57. == 30. / 57. -> 0.526315789473684
>
> 55 / 0.526315789473684 -> 104.5
>
> 99 - 104.5 -> -5.5
>
Thanks Keith for the lesson of the day. ;-)

josé
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Jose Isaias Cabrera

Simon Slavin, on Tuesday, March 10, 2020 03:25 AM, wrote...
>
> On 10 Mar 2020, at 7:21am, Octopus ZHANG  wrote:
>
> > sqlite> select 99-(55/(30/57));
> >
> > Should I expect it to return nothing?
>
> That's going in my list of annoying questions.  Thank you.

Simon, with all due respect, and grateful for all the answers you have provided 
to me, this is not an annoying question.  Not everyone in the world knows what 
you know.  Some people do answer questions because they don't know.  I actually 
was going to add other ones that I found trying to figure this one out.  But, 
Keith has provided the answer.  Otherwise, I would have added some more.  In 
this forum, email-list, most people ask questions because we just don't know, 
and we want to learn.  Thanks.

josé
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sqlite error code 14 when using 3.31.0+

2020-03-10 Thread Daniel Polski

Den 2020-03-10 kl. 02:33, skrev Rowan Worth:

On Mon, 9 Mar 2020 at 23:22, Daniel Polski  wrote:


Updated to 3.31.1 but my application started spitting out an error when
opening the database, so I tested some earlier sqlite versions to figure
out when the problem starts.
I don't get the message in versions <= 3.30.1.

(from the applications log)
SQLite Version: 3.31.0
INFO: Database opened: /tmp/database.sqlite
WARNING: SQLITE error code: 14 cannot open file at line 36982 of
[3bfa9cc97d]
WARNING: SQLITE error code: 14 os_unix.c:36982: (40) openDirectory(/tmp) -


errno 40 is ELOOP, "Too many symbolic links encountered". open(2) says:

ELOOP  Too many symbolic links were encountered in resolving
  pathname,  or  O_NOFOLLOW  was
   specified but pathname was a symbolic link.

Is your /tmp/ a symlink? Sqlite seems to use O_NOFOLLOW unconditionally in
openDirectory() since this checkin:

https://www.sqlite.org/src/info/6a64fb6a2da6c98f


/tmp/ is a directly mounted ramdisk.


Probably a bug? The changelog for sqlite 3.31.0 include this which is
likely related:

- * Add the SQLITE_OPEN_NOFOLLOW
 option to
sqlite3_open_v2()  that prevents
SQLite from opening symbolic links.


Ok.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sqlite error code 14 when using 3.31.0+

2020-03-10 Thread Graham Holden
Tuesday, March 10, 2020, 1:33:13 AM, Rowan Worth  wrote:

> On Mon, 9 Mar 2020 at 23:22, Daniel Polski  wrote:

>> Updated to 3.31.1 but my application started spitting out an error when
>> opening the database, so I tested some earlier sqlite versions to figure
>> out when the problem starts.
>> I don't get the message in versions <= 3.30.1.
>>
>> (from the applications log)
>> SQLite Version: 3.31.0
>> INFO: Database opened: /tmp/database.sqlite
>> WARNING: SQLITE error code: 14 cannot open file at line 36982 of
>> [3bfa9cc97d]
>> WARNING: SQLITE error code: 14 os_unix.c:36982: (40) openDirectory(/tmp) -
>>

> errno 40 is ELOOP, "Too many symbolic links encountered". open(2) says:

>ELOOP  Too many symbolic links were encountered in resolving
>  pathname,  or  O_NOFOLLOW  was
>   specified but pathname was a symbolic link.

> Is your /tmp/ a symlink? Sqlite seems to use O_NOFOLLOW unconditionally in
> openDirectory() since this checkin:

> https://www.sqlite.org/src/info/6a64fb6a2da6c98f

> Probably a bug? The changelog for sqlite 3.31.0 include this which is
> likely related:

> - * Add the SQLITE_OPEN_NOFOLLOW
>  option to
> sqlite3_open_v2()  that prevents
> SQLite from opening symbolic links.

Assuming /tmp IS a symlink, then since it's the parent directory of
the SQLite file that openDirectory fails on, I would hazard a wild
guess that this has something to do with SQLite's handling of journal
files, about which that above check-in comment notes "O_NOFOLLOW is
always included in open() system calls for journal files".

Graham Holden

(There were an earlier pair of emails to the list on 13th Feb this
year where use of O_NOFOLLOW was triggering ELOOP, but I suspect that
wasn't directly related as the problem there was "protection" code in
SQLite that was opening /dev/null was failing because /dev/null under
Solaris was itself a symbolic link (see
https://www.sqlite.org/src/timeline?c=0c683c43a62fe25c)


___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Is this an SQL parsing / ambiguity bug ?

2020-03-10 Thread Vladimir Vysotsky
I found a case where an "on conflict" clause generates an unexpected error,
could this be an SQL parsing bug or grammar ambiguity?

trivee@work:~/test$ sqlite3 --version
3.29.0 2019-07-10 17:32:03
fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88alt1
trivee@work:~/test$ sqlite3 test.db
SQLite version 3.29.0 2019-07-10 17:32:03
Enter ".help" for usage hints.
sqlite> create table src(id integer primary key);
sqlite> create table dst(id integer primary key);
sqlite> insert into dst(id) select id from src on conflict do nothing;
Error: near "do": syntax error
sqlite> insert into dst(id) select id from src where 1 on conflict do
nothing;
sqlite>

-=- Vlad
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread P Kishor
A very helpful and clear explanation to many of us not familiar with SQLite’s 
math idiosyncracies, or simply needing a refresher. Many thanks Keith.

> On Mar 10, 2020, at 8:57 AM, Keith Medcalf  wrote:
> 
> 
> On Tuesday, 10 March, 2020 01:22, Octopus ZHANG  
> wrote:
> 
>> I try to run a simple math expression, but SQLite gives no feedback :
> 
>> sqlite> select 99-(55/(30/57));
> 
>> Should I expect it to return nothing?
> 
> It is returning something.  It is returning NULL.
> 
> sqlite> .nullvalue 
> sqlite> select 99-(55/(30/57));
> 
> sqlite>
> 
> 99 - (55 / (30 / 57))
> 
> 30 / 57 -> 0
> 
> 55 / 0 -> NULL
> 
> 99 - NULL -> NULL
> 
> If you want the result of 30/57 to be a floating point number (ie, not zero), 
> you need to have one of those numbers be floating point, after which each 
> successive operation will be carried out in floating point rather than 
> integer arithmetic.
> 
> 30. / 57 == 30 / 57. == 30. / 57. -> 0.526315789473684
> 
> 55 / 0.526315789473684 -> 104.5
> 
> 99 - 104.5 -> -5.5
> 




___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Octopus ZHANG
I will use floating point as you all suggested. Thank you!

Simon Slavin  于2020年3月10日周二 下午3:25写道:

> On 10 Mar 2020, at 7:21am, Octopus ZHANG  wrote:
>
> > sqlite> select 99-(55/(30/57));
> >
> > Should I expect it to return nothing?
>
> That's going in my list of annoying questions.  Thank you.
>
> sqlite> select 99.0-(55.0/(30.0/57.0));
> -5.5
>
> Now you can work out what the problem is.
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 

Yushan
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Octopus ZHANG
Thanks for the detailed explanation!

Keith Medcalf  于2020年3月10日周二 下午3:58写道:

>
> On Tuesday, 10 March, 2020 01:22, Octopus ZHANG 
> wrote:
>
> >I try to run a simple math expression, but SQLite gives no feedback :
>
> >sqlite> select 99-(55/(30/57));
>
> >Should I expect it to return nothing?
>
> It is returning something.  It is returning NULL.
>
> sqlite> .nullvalue 
> sqlite> select 99-(55/(30/57));
> 
> sqlite>
>
> 99 - (55 / (30 / 57))
>
> 30 / 57 -> 0
>
> 55 / 0 -> NULL
>
> 99 - NULL -> NULL
>
> If you want the result of 30/57 to be a floating point number (ie, not
> zero), you need to have one of those numbers be floating point, after which
> each successive operation will be carried out in floating point rather than
> integer arithmetic.
>
> 30. / 57 == 30 / 57. == 30. / 57. -> 0.526315789473684
>
> 55 / 0.526315789473684 -> 104.5
>
> 99 - 104.5 -> -5.5
>
> --
> The fact that there's a Highway to Hell but only a Stairway to Heaven says
> a lot about anticipated traffic volume.
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 

Yushan
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Octopus ZHANG
Yeah, I expected it should show the error message. I will check the related
threads.


radovan5  于2020年3月10日周二 下午4:02写道:

> Hi,
>
> because sqlite calculate expression 30/57 as zero or 0.
> So this give then divide by zero error when 55/0 is calculated.
> Search more on google "Divide by 0 not giving error in sqlite".
>
> If you need to calculate you must change this so that one number
> has affinity real like this:
>
> select 99-(55/(30.0/57))
>
> But I like that when you have integer numbers is like div function.
> You remember div function like: 10 div 5 = 2.
>
>
> On 10.03.2020 08:21, Octopus ZHANG wrote:
> > Hi all,
> >
> >
> > I try to run a simple math expression, but SQLite gives no feedback :
> >
> > sqlite> select 99-(55/(30/57));
> >
> >
> >
> >
> > Should I expect it to return nothing?
> >
> >
> > Thank you
> >
>
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 

Yushan
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread radovan5

Hi,

because sqlite calculate expression 30/57 as zero or 0.
So this give then divide by zero error when 55/0 is calculated.
Search more on google "Divide by 0 not giving error in sqlite".

If you need to calculate you must change this so that one number
has affinity real like this:

select 99-(55/(30.0/57))

But I like that when you have integer numbers is like div function.
You remember div function like: 10 div 5 = 2.


On 10.03.2020 08:21, Octopus ZHANG wrote:

Hi all,


I try to run a simple math expression, but SQLite gives no feedback :

sqlite> select 99-(55/(30/57));




Should I expect it to return nothing?


Thank you



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Keith Medcalf

On Tuesday, 10 March, 2020 01:22, Octopus ZHANG  wrote:

>I try to run a simple math expression, but SQLite gives no feedback :

>sqlite> select 99-(55/(30/57));

>Should I expect it to return nothing?

It is returning something.  It is returning NULL.

sqlite> .nullvalue 
sqlite> select 99-(55/(30/57));

sqlite>

99 - (55 / (30 / 57))

30 / 57 -> 0

55 / 0 -> NULL

99 - NULL -> NULL

If you want the result of 30/57 to be a floating point number (ie, not zero), 
you need to have one of those numbers be floating point, after which each 
successive operation will be carried out in floating point rather than integer 
arithmetic.

30. / 57 == 30 / 57. == 30. / 57. -> 0.526315789473684

55 / 0.526315789473684 -> 104.5

99 - 104.5 -> -5.5

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



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Simon Slavin
On 10 Mar 2020, at 7:21am, Octopus ZHANG  wrote:

> sqlite> select 99-(55/(30/57));
> 
> Should I expect it to return nothing?

That's going in my list of annoying questions.  Thank you.

sqlite> select 99.0-(55.0/(30.0/57.0));
-5.5

Now you can work out what the problem is.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] No feedback for executing a mathematical expression

2020-03-10 Thread Octopus ZHANG
Hi all,


I try to run a simple math expression, but SQLite gives no feedback :

sqlite> select 99-(55/(30/57));




Should I expect it to return nothing?


Thank you

-- 

Yushan
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users