/ Check-in [ac27f38e]
Login

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

Overview
Comment:Permit the 'test_fs' test module to be compiled and used on MinGW.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ac27f38eef7a241d56124c263d9f8c91f372a77f
User & Date: mistachkin 2016-01-05 01:48:29
Context
2016-01-05
03:39
Another attempt to get reuse of excess opcode array space working correctly on all architectures and platforms. check-in: 2f858374 user: drh tags: trunk
01:48
Permit the 'test_fs' test module to be compiled and used on MinGW. check-in: ac27f38e user: mistachkin tags: trunk
2016-01-04
23:43
Fix a corner case in the opcode-array reuse logic where the number of bytes of reusable space might be computed to be a negative number, due to unusual system alignment restrictions and rounding error. check-in: 1aa53014 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_fs.c.

    66     66   
    67     67   #include <stdlib.h>
    68     68   #include <string.h>
    69     69   #include <sys/types.h>
    70     70   #include <sys/stat.h>
    71     71   #include <fcntl.h>
    72     72   
    73         -#if SQLITE_OS_UNIX
           73  +#if SQLITE_OS_UNIX || defined(__MINGW_H)
    74     74   # include <unistd.h>
    75     75   # include <dirent.h>
    76     76   # ifndef DIRENT
    77     77   #  define DIRENT dirent
    78     78   # endif
    79     79   #endif
    80     80   #if SQLITE_OS_WIN
    81     81   # include <io.h>
    82         -# include "test_windirent.h"
           82  +# if !defined(__MINGW_H)
           83  +#  include "test_windirent.h"
           84  +# endif
    83     85   # ifndef S_ISREG
    84     86   #  define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
    85     87   # endif
    86     88   #endif
    87     89   
    88     90   #ifndef SQLITE_OMIT_VIRTUALTABLE
    89     91   
................................................................................
   227    229   ** Skip the cursor to the next entry.
   228    230   */
   229    231   static int fsdirNext(sqlite3_vtab_cursor *cur){
   230    232     FsdirCsr *pCsr = (FsdirCsr*)cur;
   231    233   
   232    234     if( pCsr->pDir ){
   233    235       struct DIRENT *pRes = 0;
          236  +#if defined(__MINGW_H)
          237  +    pRes = readdir(pCsr->pDir);
          238  +    if( pRes!=0 ){
          239  +      memcpy(&pCsr->entry, pRes, sizeof(struct DIRENT));
          240  +    }
          241  +#else
   234    242       readdir_r(pCsr->pDir, &pCsr->entry, &pRes);
          243  +#endif
   235    244       if( pRes==0 ){
   236    245         closedir(pCsr->pDir);
   237    246         pCsr->pDir = 0;
   238    247       }
   239    248       pCsr->iRowid++;
   240    249     }
   241    250   

Changes to test/vtabH.test.

    28     28     CREATE TABLE t6(a, b TEXT);
    29     29     CREATE INDEX i6 ON t6(b, a);
    30     30     CREATE VIRTUAL TABLE e6 USING echo(t6);
    31     31   }
    32     32   
    33     33   foreach {tn sql expect} {
    34     34     1 "SELECT * FROM e6 WHERE b LIKE 'abc'" {
    35         -    xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?} 
           35  +    xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?}
    36     36       xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} abc
    37     37     }
    38     38   
    39     39     2 "SELECT * FROM e6 WHERE b GLOB 'abc'" {
    40         -    xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?} 
           40  +    xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?}
    41     41       xFilter {SELECT rowid, a, b FROM 't6' WHERE b glob ?} abc
    42     42     }
    43     43   } {
    44     44     do_test 1.$tn {
    45     45       set echo_module {}
    46     46       execsql $sql
    47     47       set ::echo_module
................................................................................
   111    111   if {1} {
   112    112     reset_db
   113    113     register_fs_module db
   114    114     do_execsql_test 3.0 {
   115    115       SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db';
   116    116       SELECT name FROM fsdir WHERE dir = '.' AND name = '.'
   117    117     } {test.db .}
   118         -  
          118  +
   119    119     proc list_root_files {} {
   120    120       if {$::tcl_platform(platform) eq "windows"} {
   121    121         set res [list]
   122    122         foreach name [glob -directory $::env(SystemDrive)/ -- *] {
   123    123           if {[string index [file tail $name] 0] eq "."} continue
   124    124           lappend res $name
   125    125         }
................................................................................
   138    138         }
   139    139         return $res
   140    140       } else {
   141    141         return [glob -nocomplain $pattern]
   142    142       }
   143    143     }
   144    144   
   145         -  # Read the first 5 entries from the root directory.  Except, ignore
   146         -  # files that contain the "$" character in their names as these are
   147         -  # special files on some Windows platforms.
   148         -  #
   149         -  set res [list]
   150         -  foreach p [lrange [list_root_files] 0 4] {
   151         -    if {$::tcl_platform(platform) eq "windows"} {
   152         -      if {![regexp {\$} $p]} {lappend res $p}
   153         -    } else {
   154         -      lappend res "/$p"
   155         -    }
   156         -  }
   157         -  do_execsql_test 3.1 {
   158         -    SELECT path FROM fstree WHERE path NOT GLOB '*$*' LIMIT 5;
   159         -  } $res
   160         -  
   161    145     # Read all entries in the current directory.
   162    146     #
   163    147     proc contents {pattern} {
   164    148       set res [list]
   165    149       foreach f [list_files $pattern] {
   166    150         lappend res $f
   167    151         if {[file isdir $f]} {
................................................................................
   171    155       set res
   172    156     }
   173    157     set pwd "[pwd]/*"
   174    158     set res [contents $pwd]
   175    159     do_execsql_test 3.2 {
   176    160       SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1
   177    161     } [lsort $res]
   178         -  
          162  +
   179    163     # Add some sub-directories and files to the current directory.
   180    164     #
   181    165     do_test 3.3 {
   182    166       catch { file delete -force subdir }
   183    167       foreach {path sz} {
   184    168         subdir/x1.txt     143
   185    169         subdir/x2.txt     153
   186         -    } { 
          170  +    } {
   187    171         set dir [file dirname $path]
   188    172         catch { file mkdir $dir }
   189    173         set fd [open $path w]
   190    174         puts -nonewline $fd [string repeat 1 $sz]
   191    175         close $fd
   192    176       }
   193    177     } {}
   194         -  
          178  +
   195    179     set pwd [pwd]
   196    180     do_execsql_test 3.5 {
   197    181       SELECT path, size FROM fstree WHERE path GLOB $pwd || '/subdir/*' ORDER BY 1
   198    182     } [list \
   199    183       "$pwd/subdir/x1.txt" 143 \
   200    184       "$pwd/subdir/x2.txt" 153 \
   201    185     ]