SQLite

Check-in [221f3f572e]
Login

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

Overview
Comment:Fix a compilation issue in the "userauth" extension. Also fix a few test script errors that occur with SQLITE_USER_AUTHENTICATION=1 builds.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 221f3f572ed49d7af69a2e7c88741fa5206ea33ca59ee791eac7698bdd11ca4d
User & Date: dan 2018-09-19 17:09:09.208
Context
2018-09-25
01:35
Fix a compilation issue in the "userauth" extension. Also fix a few test script errors that occur with SQLITE_USER_AUTHENTICATION=1 builds. (check-in: e7db5f59ee user: drh tags: branch-3.25)
2018-09-20
19:02
Combine the Expr.pTab and Expr.pWin fields into a union named "y". Add a new EP_WinFunc property that is only true if Expr.y.pWin is a valid pointer. This reduces the size of the Expr object by 8 bytes, reduces the overall amount of code, and shaves over 1 million cycles off of the speed test. (check-in: ad130bb86e user: drh tags: trunk)
08:28
Add a PRAGMA that restores the legacy ALTER TABLE RENAME TO behaviour. (check-in: 5acad2e92c user: dan tags: legacy-alter-table)
2018-09-19
18:17
A minor code simplification, saved in a branch for future reference. (Leaf check-in: 5e458f4a92 user: drh tags: minor-altertab-simplification)
17:09
Fix a compilation issue in the "userauth" extension. Also fix a few test script errors that occur with SQLITE_USER_AUTHENTICATION=1 builds. (check-in: 221f3f572e user: dan tags: trunk)
15:08
Fix the "sqlite3" command in the TCL interface so that it correctly returns an error if invoked with no arguments. (check-in: 2034fa8089 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/userauth/userauth.c.
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
  if( db->auth.zAuthUser==0 ) return SQLITE_NOMEM;
  db->auth.zAuthPW = sqlite3_malloc( nPW+1 );
  if( db->auth.zAuthPW==0 ) return SQLITE_NOMEM;
  memcpy(db->auth.zAuthPW,zPW,nPW);
  db->auth.nAuthPW = nPW;
  rc = sqlite3UserAuthCheckLogin(db, "main", &authLevel);
  db->auth.authLevel = authLevel;
  sqlite3ExpirePreparedStatements(db);
  if( rc ){
    return rc;           /* OOM error, I/O error, etc. */
  }
  if( authLevel<UAUTH_User ){
    return SQLITE_AUTH;  /* Incorrect username and/or password */
  }
  return SQLITE_OK;      /* Successful login */







|







206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
  if( db->auth.zAuthUser==0 ) return SQLITE_NOMEM;
  db->auth.zAuthPW = sqlite3_malloc( nPW+1 );
  if( db->auth.zAuthPW==0 ) return SQLITE_NOMEM;
  memcpy(db->auth.zAuthPW,zPW,nPW);
  db->auth.nAuthPW = nPW;
  rc = sqlite3UserAuthCheckLogin(db, "main", &authLevel);
  db->auth.authLevel = authLevel;
  sqlite3ExpirePreparedStatements(db, 0);
  if( rc ){
    return rc;           /* OOM error, I/O error, etc. */
  }
  if( authLevel<UAUTH_User ){
    return SQLITE_AUTH;  /* Incorrect username and/or password */
  }
  return SQLITE_OK;      /* Successful login */
Changes to test/alterauth.test.
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  return
}
set testprefix alterauth

set ::auth [list]
proc xAuth {type args} {
  if {$type == "SQLITE_ALTER_TABLE"} {
    lappend ::auth [concat $type $args]
  }
  return SQLITE_OK
}
db auth xAuth

do_execsql_test 1.0 { CREATE TABLE t1(a, b, c); }








|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  return
}
set testprefix alterauth

set ::auth [list]
proc xAuth {type args} {
  if {$type == "SQLITE_ALTER_TABLE"} {
    lappend ::auth [concat $type [lrange $args 0 3]]
  }
  return SQLITE_OK
}
db auth xAuth

do_execsql_test 1.0 { CREATE TABLE t1(a, b, c); }

Changes to test/auth.test.
2594
2595
2596
2597
2598
2599
2600
2601

2602
2603
2604
2605
2606
2607
2608
  SQLITE_READ t7 {} {} {}            \
  ]

# Test also that if SQLITE_DENY is returned from an SQLITE_READ authorizer 
# invocation with no column name specified, compilation fails.
#
set ::authargs [list]
proc auth {op a b c d} {

  lappend ::authargs $op $a $b $c $d
  if {$op == "SQLITE_READ"} { return "SQLITE_DENY" }
  return "SQLITE_OK"
}
set ::authargs [list]
do_catchsql_test auth-8.3 {
  SELECT count(*) FROM t7







|
>







2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
  SQLITE_READ t7 {} {} {}            \
  ]

# Test also that if SQLITE_DENY is returned from an SQLITE_READ authorizer 
# invocation with no column name specified, compilation fails.
#
set ::authargs [list]
proc auth {op args} {
  foreach {a b c d} $args break
  lappend ::authargs $op $a $b $c $d
  if {$op == "SQLITE_READ"} { return "SQLITE_DENY" }
  return "SQLITE_OK"
}
set ::authargs [list]
do_catchsql_test auth-8.3 {
  SELECT count(*) FROM t7
Changes to test/releasetest.tcl.
132
133
134
135
136
137
138

139
140
141
142
143
144
145
  "Fast-One" {
    -O6
    -DSQLITE_ENABLE_FTS4=1
    -DSQLITE_ENABLE_RTREE=1
    -DSQLITE_ENABLE_STAT4
    -DSQLITE_ENABLE_RBU
    -DSQLITE_MAX_ATTACHED=125

    -DLONGDOUBLE_TYPE=double
    --enable-session
  }
  "Device-One" {
    -O2
    -DSQLITE_DEBUG=1
    -DSQLITE_DEFAULT_AUTOVACUUM=1







>







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
  "Fast-One" {
    -O6
    -DSQLITE_ENABLE_FTS4=1
    -DSQLITE_ENABLE_RTREE=1
    -DSQLITE_ENABLE_STAT4
    -DSQLITE_ENABLE_RBU
    -DSQLITE_MAX_ATTACHED=125
    -DSQLITE_USER_AUTHENTICATION=1
    -DLONGDOUBLE_TYPE=double
    --enable-session
  }
  "Device-One" {
    -O2
    -DSQLITE_DEBUG=1
    -DSQLITE_DEFAULT_AUTOVACUUM=1
Changes to test/view.test.
678
679
680
681
682
683
684
685

686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
  db eval {
    CREATE TABLE t25 (x);
    INSERT INTO t25 (x) VALUES (1);
    ANALYZE;
  }
  proc authLogDelete {code arg1 arg2 arg3 arg4 args} {
    if {$code=="SQLITE_DELETE" && [string match sqlite_stat* $arg1]} {
      lappend ::log [list $code $arg1 $arg2 $arg3 $arg4 $args]

    }
    return SQLITE_OK
  }
  set log ""
  db authorizer ::authLogDelete
  db eval {DROP VIEW x1;}
  set log
} {}

set res [list {SQLITE_DELETE sqlite_stat1 {} main {} {}}]
ifcapable stat4 { lappend res {SQLITE_DELETE sqlite_stat4 {} main {} {}} }
do_test view-25.2 {
  set log ""
  db eval {DROP TABLE t25;}
  set log
} $res

finish_test







|
>









|
|







678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
  db eval {
    CREATE TABLE t25 (x);
    INSERT INTO t25 (x) VALUES (1);
    ANALYZE;
  }
  proc authLogDelete {code arg1 arg2 arg3 arg4 args} {
    if {$code=="SQLITE_DELETE" && [string match sqlite_stat* $arg1]} {
      # lappend ::log [list $code $arg1 $arg2 $arg3 $arg4 $args]
      lappend ::log [list $code $arg1 $arg2 $arg3 $arg4]
    }
    return SQLITE_OK
  }
  set log ""
  db authorizer ::authLogDelete
  db eval {DROP VIEW x1;}
  set log
} {}

set res [list {SQLITE_DELETE sqlite_stat1 {} main {}}]
ifcapable stat4 { lappend res {SQLITE_DELETE sqlite_stat4 {} main {}} }
do_test view-25.2 {
  set log ""
  db eval {DROP TABLE t25;}
  set log
} $res

finish_test