Well, as I wrote, I am not a Ruby programmer. I found this phenomena first in a 
CCC test program. CCC is a translator, which translate a Clipper-like language 
to C. So there is a state of a CCC program, which can be considered as pure C. 
There is no Ruby in it  at all. Ruby version was only written so that I can 
show the result on this mailing list. The CCC and the Ruby versions produce 
essentially the same results. 


The wrong output on my Ubuntu Xenial box, SQLite 3.11.0  (Ruby script):
---------------------------------------------------------------------------------
 
 ./sqlite3-regression.rb
no such table: proba
What is in the table?
0 000000000000000000000000 BLACK
1 333333333333333333333333 BLACK
2 666666666666666666666666 BLACK
3 999999999999999999999999 BLACK
4 111111111111111111111111 WHITE
5 222222222222222222222222 WHITE
6 444444444444444444444444 WHITE
7 555555555555555555555555 WHITE
8 777777777777777777777777 WHITE
9 888888888888888888888888 WHITE
Updates
0 000000000000000000000000 BLACK
1 333333333333333333333333 BLACK
2 666666666666666666666666 BLACK
3 999999999999999999999999 BLACK
4 000000000000000000000000 BLACK*
5 333333333333333333333333 BLACK*
6 666666666666666666666666 BLACK*
7 999999999999999999999999 BLACK*
8 000000000000000000000000 BLACK**
9 333333333333333333333333 BLACK**
10 666666666666666666666666 BLACK**
11 999999999999999999999999 BLACK**
12 000000000000000000000000 BLACK***
13 333333333333333333333333 BLACK***
14 666666666666666666666666 BLACK***
15 999999999999999999999999 BLACK***
16 000000000000000000000000 BLACK****
17 333333333333333333333333 BLACK****
18 666666666666666666666666 BLACK****
19 999999999999999999999999 BLACK****
20 000000000000000000000000 BLACK*****
What is in the table?
0 333333333333333333333333 BLACK*****
1 666666666666666666666666 BLACK*****
2 999999999999999999999999 BLACK*****
3 000000000000000000000000 BLACK******
4 111111111111111111111111 WHITE
5 222222222222222222222222 WHITE
6 444444444444444444444444 WHITE
7 555555555555555555555555 WHITE
8 777777777777777777777777 WHITE
9 888888888888888888888888 WHITE
Cleanup


The right output on Ubuntu Precise, SQLite 3.7.9  (Ruby script):
---------------------------------------------------------------------------------
 
 ./sqlite3-regression.rb
What is in the table?
0 000000000000000000000000 BLACK
1 111111111111111111111111 WHITE
2 222222222222222222222222 WHITE
3 333333333333333333333333 BLACK
4 444444444444444444444444 WHITE
5 555555555555555555555555 WHITE
6 666666666666666666666666 BLACK
7 777777777777777777777777 WHITE
8 888888888888888888888888 WHITE
9 999999999999999999999999 BLACK
Updates
0 000000000000000000000000 BLACK
1 111111111111111111111111 WHITE
2 222222222222222222222222 WHITE
3 333333333333333333333333 BLACK
4 444444444444444444444444 WHITE
5 555555555555555555555555 WHITE
6 666666666666666666666666 BLACK
7 777777777777777777777777 WHITE
8 888888888888888888888888 WHITE
9 999999999999999999999999 BLACK
What is in the table?
0 000000000000000000000000 BLACK*
1 111111111111111111111111 WHITE*
2 222222222222222222222222 WHITE*
3 333333333333333333333333 BLACK*
4 444444444444444444444444 WHITE*
5 555555555555555555555555 WHITE*
6 666666666666666666666666 BLACK*
7 777777777777777777777777 WHITE*
8 888888888888888888888888 WHITE*
9 999999999999999999999999 BLACK*
Cleanup
---------------------------------------------------------------------------------
 

You may think that the error was introduced in the Ruby between Precise and 
Xenial. But the CCC program which produce the same behavior is exactly the same 
binary, copied from one machine to the other. 

The list of the CCC program:

function main()

local con
local q,szla,nev
local cnt:=0

    set date format "yyyy-mm-dd"
    
    con:=connect()

    cnt:=0
    q:=con:sqlqueryNew("select szamla, megnevezes from konto.proba")
    while( q:next )
        ? ++cnt, szla:=q:getchar(1), nev:=q:getchar(2)
    end
    q:close
    ?

    //q:=con:sqlqueryNew("select szamla, megnevezes from konto.proba order by 
devnem") //right
    //q:=con:sqlqueryNew("select szamla, megnevezes from konto.proba order by 
szamla") //right
    //q:=con:sqlqueryNew("select szamla, megnevezes from konto.proba order by 
tulmenflag") //right
    q:=con:sqlqueryNew("select szamla, megnevezes from konto.proba") //wrong

    cnt:=0
    while( q:next .and. cnt<20 )
        ? ++cnt, szla:=q:getchar(1), nev:=q:getchar(2)
        con:sqlexec("update konto.proba set megnevezes=:2 where 
szamla=:1",{szla,nev+"!"})
    end
    q:close
    ?

    cnt:=0
    q:=con:sqlqueryNew("select szamla, megnevezes from konto.proba") //wrong
    while( q:next )
        ? ++cnt, szla:=q:getchar(1), nev:=q:getchar(2)
    end
    q:close
    con:sqlcommit


The (wrong) output of the above program with SQLite version 3.11.0 (CCC, the 
same binary)
---------------------------------------------------------------------------------
 
         1 000000000000000000000000 BLACK
         2 333333333333333333333333 BLACK
         3 666666666666666666666666 BLACK
         4 999999999999999999999999 BLACK
         5 111111111111111111111111 WHITE
         6 222222222222222222222222 WHITE
         7 444444444444444444444444 WHITE
         8 555555555555555555555555 WHITE
         9 777777777777777777777777 WHITE
        10 888888888888888888888888 WHITE

         1 000000000000000000000000 BLACK
         2 333333333333333333333333 BLACK
         3 666666666666666666666666 BLACK
         4 999999999999999999999999 BLACK
         5 000000000000000000000000 BLACK!
         6 333333333333333333333333 BLACK!
         7 666666666666666666666666 BLACK!
         8 999999999999999999999999 BLACK!
         9 000000000000000000000000 BLACK!!
        10 333333333333333333333333 BLACK!!
        11 666666666666666666666666 BLACK!!
        12 999999999999999999999999 BLACK!!
        13 000000000000000000000000 BLACK!!!
        14 333333333333333333333333 BLACK!!!
        15 666666666666666666666666 BLACK!!!
        16 999999999999999999999999 BLACK!!!
        17 000000000000000000000000 BLACK!!!!
        18 333333333333333333333333 BLACK!!!!
        19 666666666666666666666666 BLACK!!!!
        20 999999999999999999999999 BLACK!!!!

         1 000000000000000000000000 BLACK!!!!!
         2 333333333333333333333333 BLACK!!!!!
         3 666666666666666666666666 BLACK!!!!!
         4 999999999999999999999999 BLACK!!!!!
         5 111111111111111111111111 WHITE
         6 222222222222222222222222 WHITE
         7 444444444444444444444444 WHITE
         8 555555555555555555555555 WHITE
         9 777777777777777777777777 WHITE
        10 888888888888888888888888 WHITE


The (right) output with SQLite version 3.7.9 (CCC, the same binary)
---------------------------------------------------------------------------------
 
         1 000000000000000000000000 BLACK
         2 111111111111111111111111 WHITE
         3 222222222222222222222222 WHITE
         4 333333333333333333333333 BLACK
         5 444444444444444444444444 WHITE
         6 555555555555555555555555 WHITE
         7 666666666666666666666666 BLACK
         8 777777777777777777777777 WHITE
         9 888888888888888888888888 WHITE
        10 999999999999999999999999 BLACK

         1 000000000000000000000000 BLACK
         2 111111111111111111111111 WHITE
         3 222222222222222222222222 WHITE
         4 333333333333333333333333 BLACK
         5 444444444444444444444444 WHITE
         6 555555555555555555555555 WHITE
         7 666666666666666666666666 BLACK
         8 777777777777777777777777 WHITE
         9 888888888888888888888888 WHITE
        10 999999999999999999999999 BLACK

         1 000000000000000000000000 BLACK!
         2 111111111111111111111111 WHITE!
         3 222222222222222222222222 WHITE!
         4 333333333333333333333333 BLACK!
         5 444444444444444444444444 WHITE!
         6 555555555555555555555555 WHITE!
         7 666666666666666666666666 BLACK!
         8 777777777777777777777777 WHITE!
         9 888888888888888888888888 WHITE!
        10 999999999999999999999999 BLACK!
---------------------------------------------------------------------------------
 

There is very small probability, that the CCC and Ruby programs contain the 
same error, unless the bug is in the common part of the two. The common part is 
only the SQLite library.  While these are not an exact proof certainly a strong 
argument. So I think that the SQLite library contains a regression at least 
since 3.8.7.


> Well, therein lies the rub. We can't find what the bug is. There 
> certainly is no bug, no endless execution and no wrong answer when we do 
> the same script in pure SQL (See details below) nor if we do it in C 
> using the C API (on which the system below runs and I have tested in C, 
> just to be sure). So this means either you have a Ruby connector that is 
> bugged, or you have a real case of SQLite regression, but until you can 
> show the problem in SQL script or C code using the C API, there is no 
> bug we can reproduce.
> 
> To put this another way: The devs can't fix Ruby code, they can only fix 
> faulty SQL execution and faulty C API's.

-- 
Vermes Mátyás  <vermes.mat...@comfirm.hu>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to