/ Check-in [7fffcee0]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem with virtual table "fsdir" and some join queries.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7fffcee0fc3fe8d036f0d93ec17673992c3edcf2bb454dc90d80142435b37946
User & Date: dan 2018-11-16 08:36:15
Context
2018-11-16
13:06
Fix comments and make magic numbers into #defines in the fsdir implementation. check-in: c537c9c3 user: drh tags: trunk
08:36
Fix a problem with virtual table "fsdir" and some join queries. check-in: 7fffcee0 user: dan tags: trunk
01:42
Improvements to the CSV virtual table. check-in: 0406ecbb user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/fileio.c.

831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
  int idx4 = -1;
  int idx5 = -1;
  const struct sqlite3_index_constraint *pConstraint;

  (void)tab;
  pConstraint = pIdxInfo->aConstraint;
  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
    if( pConstraint->usable==0 ) continue;
    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
    if( pConstraint->iColumn==4 ) idx4 = i;
    if( pConstraint->iColumn==5 ) idx5 = i;
  }

  if( idx4<0 ){
    pIdxInfo->idxNum = 0;
    pIdxInfo->estimatedCost = (double)(((sqlite3_int64)1) << 50);
  }else{
    pIdxInfo->aConstraintUsage[idx4].omit = 1;
    pIdxInfo->aConstraintUsage[idx4].argvIndex = 1;
    if( idx5>=0 ){
      pIdxInfo->aConstraintUsage[idx5].omit = 1;
      pIdxInfo->aConstraintUsage[idx5].argvIndex = 2;
      pIdxInfo->idxNum = 2;







<

|



|

|







831
832
833
834
835
836
837

838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
  int idx4 = -1;
  int idx5 = -1;
  const struct sqlite3_index_constraint *pConstraint;

  (void)tab;
  pConstraint = pIdxInfo->aConstraint;
  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){

    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
    if( pConstraint->iColumn==4 && pConstraint->usable ) idx4 = i;
    if( pConstraint->iColumn==5 ) idx5 = i;
  }

  if( idx4<0 || (idx5>=0 && pIdxInfo->aConstraint[idx5].usable==0) ){
    pIdxInfo->idxNum = 0;
    pIdxInfo->estimatedCost = (double)(((sqlite3_int64)1) << 60);
  }else{
    pIdxInfo->aConstraintUsage[idx4].omit = 1;
    pIdxInfo->aConstraintUsage[idx4].argvIndex = 1;
    if( idx5>=0 ){
      pIdxInfo->aConstraintUsage[idx5].omit = 1;
      pIdxInfo->aConstraintUsage[idx5].argvIndex = 2;
      pIdxInfo->idxNum = 2;

Changes to test/zipfile.test.

757
758
759
760
761
762
763


































764
  SELECT name, data FROM z ORDER BY name;
} {b0 two b2 one}
do_execsql_test 11.11 {
  UPDATE z SET name = name || 'suffix';
  SELECT name, data FROM z ORDER BY name;
} {b0suffix two b2suffix one}



































finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
  SELECT name, data FROM z ORDER BY name;
} {b0 two b2 one}
do_execsql_test 11.11 {
  UPDATE z SET name = name || 'suffix';
  SELECT name, data FROM z ORDER BY name;
} {b0suffix two b2suffix one}


if {$tcl_platform(platform)!="windows"} {
  do_test 12.0 {
    catch { file delete -force subdir }
    foreach {path sz} {
      subdir/x1.txt     143
      subdir/x2.txt     153
    } {
      set dir [file dirname $path]
      catch { file mkdir $dir }
      set fd [open $path w]
      puts -nonewline $fd [string repeat 1 $sz]
      close $fd
    }
  } {}
  
  do_execsql_test 12.1 {
    SELECT name FROM fsdir('subdir') ORDER BY 1;
  } {subdir subdir/x1.txt subdir/x2.txt}
  
  do_execsql_test 12.2 {
    CREATE TABLE d AS SELECT 'subdir' d;
    CREATE TABLE x AS SELECT 1 x;
  }
  
  do_execsql_test 12.4 {
    SELECT name FROM d JOIN x JOIN fsdir(d) ORDER BY 1;
  } {subdir subdir/x1.txt subdir/x2.txt}

  do_execsql_test 12.5 {
    SELECT name FROM d JOIN x JOIN fsdir('.', d) ORDER BY 1;
  } {. ./x1.txt ./x2.txt}
}

finish_test