Anomie added a comment.

  In T238575#5675210 <https://phabricator.wikimedia.org/T238575#5675210>, 
@Lucas_Werkmeister_WMDE wrote:
  
  > How? It’s a `VARBINARY` field! (`BLOB` in sqlite, I guess, according to 
`DatabaseSqlite::replaceVars()`.)
  
  The declared column types in sqlite are (mostly) advisory, it doesn't enforce 
them. See https://www.sqlite.org/datatype3.html for details.
  
  I think I've determined what's going on here. The critical SQL statements 
from 
https://integration.wikimedia.org/ci/job/wikibase-repo-docker/8812/artifact/log/mw-debug-cli.log.gz
 are these:
  
    CREATE TEMPORARY TABLE "unittest_wb_changes_dispatch" (
     chd_site     BLOB     NOT NULL PRIMARY KEY,  -- client wiki's global site 
ID
     chd_db       BLOB     NOT NULL,              -- client wiki's logical 
database name
     chd_seen     INTEGER               NOT NULL DEFAULT 0,    -- last change 
ID examined (dispatch state)
     chd_touched  BLOB     NOT NULL DEFAULT "00000000000000", -- end of last 
dispatch pass (informative)
     chd_lock     BLOB              DEFAULT NULL, -- name of global lock 
(dispatch state)
     chd_disabled INTEGER   NOT NULL DEFAULT 0     -- flag for temporarily 
disabling a client
     );
    
    INSERT OR IGNORE INTO unittest_wb_changes_dispatch 
(chd_site,chd_db,chd_seen,chd_touched,chd_lock,chd_disabled) VALUES 
(0,'foowiki',0,'00000000000000',NULL,0);
    SELECT  chd_site,chd_db,chd_seen,chd_touched,chd_lock,chd_disabled  FROM 
unittest_wb_changes_dispatch    WHERE chd_site = '0'  LIMIT 1;
  
  But we can simplify the test case a bit:
  
    CREATE TABLE test (chd_site BLOB);
    INSERT INTO test VALUES (0);
    SELECT * FROM test WHERE chd_site = '0';
  
  Because chd_site is a BLOB column, the insert of integer-0 stores integer-0.
  
  Then, for the SELECT with `chd_site = '0'`, the `chd_site` has "BLOB" type 
affinity (second bullet) 
<https://www.sqlite.org/datatype3.html#affinity_of_expressions> and the `'0'` 
has no type affinity (last bullet) 
<https://www.sqlite.org/datatype3.html#affinity_of_expressions>, and so it does 
no type conversion before comparison 
<https://www.sqlite.org/datatype3.html#type_conversions_prior_to_comparison>. 
The comparison between integer-0 (in the table) with string-0 (literal in the 
query) evaluates as false, so the row isn't returned.
  
  One solution would be to not insert integer-0 into the table in the first 
place, either by adding a string cast at SqlChangeDispatchCoordinator.php line 
404 
<https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Wikibase/+/84906663d7c050d043a3afa8e168a348bda51c68/repo/includes/Store/Sql/SqlChangeDispatchCoordinator.php#404>
 or by using a key PHP won't convert to integer when calling `initState()`.
  
  Another solution would be to revert only the change to DatabaseSqlite.php, so 
for sqlite only we continue quoting integers in all cases.

TASK DETAIL
  https://phabricator.wikimedia.org/T238575

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Anomie
Cc: hoo, WMDE-leszek, Anomie, tstarling, Addshore, Aklapper, 
Lucas_Werkmeister_WMDE, Hook696, Daryl-TTMG, RomaAmorRoma, 0010318400, 
E.S.A-Sheild, Iflorez, darthmon_wmde, alaa_wmde, Meekrab2012, joker88john, 
DannyS712, CucyNoiD, Nandana, NebulousIris, Gaboe420, Versusxo, 
Majesticalreaper22, Giuliamocci, Adrian1985, Cpaulf30, Lahi, Gq86, Af420, 
Darkminds3113, Bsandipan, Lordiis, GoranSMilovanovic, Adik2382, Th3d3v1ls, 
Ramalepe, Liugev6, QZanden, LawExplorer, WSH1906, Lewizho99, Maathavan, 
_jensen, rosalieper, Scott_WUaS, Jonas, Wikidata-bugs, aude, Lydia_Pintscher, 
Mbch331
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to