penberg / limbo

Limbo is a work-in-progress, in-process OLTP database management system, compatible with SQLite.
MIT License
896 stars 49 forks source link

`INTEGER` value formatting incompatible with SQLite #114

Closed penberg closed 1 month ago

penberg commented 1 month ago

The cross-join test fails with SQLite because we print out the age column in wrong format:

penberg@vonneumann limbo % SQLITE_EXEC=sqlite3 ./testing/all.test
Running test: cross-join
Test FAILED: 'select * from users, products limit 1;'
returned '1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|1|hat|79.0'
expected '1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|1|hat|79'
pereman2 commented 1 month ago

@penberg time to talk about affinities. https://github.com/penberg/limbo/issues/114 this is due to affinity of values where 79.0 was optimzied as a u8 on disk and then treated as integer on getting a record from a Page. thankfully fix here is simple so I will add it :):

      /* If the column has REAL affinity, it may currently be stored as an
      ** integer. Use OP_RealAffinity to make sure it is really real.
      **
      ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to
      ** floating point when extracting it from the record.  */
      if( iCol>=0 && pTab->aCol[iCol].affinity==SQLITE_AFF_REAL ){
        sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
      }

in the future we might want to separate data type and affinity type