⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 auth.test

📁 SQLite 2.8.6 源代码,用来在Linux/Unix/Windows上编译安装.它是一个小型的数据库,但是非常好用,速度也快,一般的数据库查询之类的操作据统计比MySQL,PostgreSQL
💻 TEST
📖 第 1 页 / 共 3 页
字号:
  execsql {SELECT name FROM sqlite_master}} {t2 i2}do_test auth-1.190 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_CREATE_TEMP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {CREATE INDEX i1 ON t1(a)}} {1 {not authorized}}do_test auth-1.191 {  set ::authargs} {i1 t1 temp {}}do_test auth-1.192 {  execsql {SELECT name FROM sqlite_temp_master}} {t1}do_test auth-1.193 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {CREATE INDEX i1 ON t1(b)}} {1 {not authorized}}do_test auth-1.194 {  execsql {SELECT name FROM sqlite_temp_master}} {t1}do_test auth-1.195 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_CREATE_TEMP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {CREATE INDEX i1 ON t1(b)}} {0 {}}do_test auth-1.196 {  set ::authargs} {i1 t1 temp {}}do_test auth-1.197 {  execsql {SELECT name FROM sqlite_temp_master}} {t1}do_test auth-1.198 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {CREATE INDEX i1 ON t1(c)}} {0 {}}do_test auth-1.199 {  execsql {SELECT name FROM sqlite_temp_master}} {t1}do_test auth-1.200 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_CREATE_TEMP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_OK    }    return SQLITE_OK  }  catchsql {CREATE INDEX i1 ON t1(a)}} {0 {}}do_test auth-1.201 {  set ::authargs} {i1 t1 temp {}}do_test auth-1.202 {  execsql {SELECT name FROM sqlite_temp_master}} {t1 i1}do_test auth-1.203 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {DROP INDEX i2}} {1 {not authorized}}do_test auth-1.204 {  execsql {SELECT name FROM sqlite_master}} {t2 i2}do_test auth-1.205 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DROP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {DROP INDEX i2}} {1 {not authorized}}do_test auth-1.206 {  set ::authargs} {i2 t2 main {}}do_test auth-1.207 {  execsql {SELECT name FROM sqlite_master}} {t2 i2}do_test auth-1.208 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {DROP INDEX i2}} {0 {}}do_test auth-1.209 {  execsql {SELECT name FROM sqlite_master}} {t2 i2}do_test auth-1.210 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DROP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {DROP INDEX i2}} {0 {}}do_test auth-1.211 {  set ::authargs} {i2 t2 main {}}do_test auth-1.212 {  execsql {SELECT name FROM sqlite_master}} {t2 i2}do_test auth-1.213 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DROP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_OK    }    return SQLITE_OK  }  catchsql {DROP INDEX i2}} {0 {}}do_test auth-1.214 {  set ::authargs} {i2 t2 main {}}do_test auth-1.215 {  execsql {SELECT name FROM sqlite_master}} {t2}do_test auth-1.216 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {DROP INDEX i1}} {1 {not authorized}}do_test auth-1.217 {  execsql {SELECT name FROM sqlite_temp_master}} {t1 i1}do_test auth-1.218 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DROP_TEMP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {DROP INDEX i1}} {1 {not authorized}}do_test auth-1.219 {  set ::authargs} {i1 t1 temp {}}do_test auth-1.220 {  execsql {SELECT name FROM sqlite_temp_master}} {t1 i1}do_test auth-1.221 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {DROP INDEX i1}} {0 {}}do_test auth-1.222 {  execsql {SELECT name FROM sqlite_temp_master}} {t1 i1}do_test auth-1.223 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DROP_TEMP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {DROP INDEX i1}} {0 {}}do_test auth-1.224 {  set ::authargs} {i1 t1 temp {}}do_test auth-1.225 {  execsql {SELECT name FROM sqlite_temp_master}} {t1 i1}do_test auth-1.226 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DROP_TEMP_INDEX"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_OK    }    return SQLITE_OK  }  catchsql {DROP INDEX i1}} {0 {}}do_test auth-1.227 {  set ::authargs} {i1 t1 temp {}}do_test auth-1.228 {  execsql {SELECT name FROM sqlite_temp_master}} {t1}do_test auth-1.229 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_PRAGMA"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {PRAGMA full_column_names=on}} {1 {not authorized}}do_test auth-1.230 {  set ::authargs} {full_column_names on {} {}}do_test auth-1.231 {  execsql2 {SELECT a FROM t2}} {a 11 a 7}do_test auth-1.232 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_PRAGMA"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {PRAGMA full_column_names=on}} {0 {}}do_test auth-1.233 {  set ::authargs} {full_column_names on {} {}}do_test auth-1.234 {  execsql2 {SELECT a FROM t2}} {a 11 a 7}do_test auth-1.235 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_PRAGMA"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_OK    }    return SQLITE_OK  }  catchsql {PRAGMA full_column_names=on}} {0 {}}do_test auth-1.236 {  execsql2 {SELECT a FROM t2}} {t2.a 11 t2.a 7}do_test auth-1.237 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_PRAGMA"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_OK    }    return SQLITE_OK  }  catchsql {PRAGMA full_column_names=OFF}} {0 {}}do_test auth-1.238 {  set ::authargs} {full_column_names OFF {} {}}do_test auth-1.239 {  execsql2 {SELECT a FROM t2}} {a 11 a 7}do_test auth-1.240 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_TRANSACTION"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {BEGIN}} {1 {not authorized}}do_test auth-1.241 {  set ::authargs} {BEGIN {} {} {}}do_test auth-1.242 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_TRANSACTION" && $arg1!="BEGIN"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {BEGIN; INSERT INTO t2 VALUES(44,55,66); COMMIT}} {1 {not authorized}}do_test auth-1.243 {  set ::authargs} {COMMIT {} {} {}}do_test auth-1.244 {  execsql {SELECT * FROM t2}} {11 2 33 7 8 9 44 55 66}do_test auth-1.245 {  catchsql {ROLLBACK}} {1 {not authorized}}do_test auth-1.246 {  set ::authargs} {ROLLBACK {} {} {}}do_test auth-1.247 {  catchsql {END TRANSACTION}} {1 {not authorized}}do_test auth-1.248 {  set ::authargs} {COMMIT {} {} {}}do_test auth-1.249 {  db authorizer {}  catchsql {ROLLBACK}} {0 {}}do_test auth-1.250 {  execsql {SELECT * FROM t2}} {11 2 33 7 8 9}# ticket #340 - authorization for ATTACH and DETACH.#do_test auth-1.251 {  db authorizer ::auth  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_ATTACH"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]    }    return SQLITE_OK  }  catchsql {    ATTACH DATABASE ':memory:' AS test1  }} {0 {}}do_test auth-1.252 {  set ::authargs} {:memory: {} {} {}}do_test auth-1.253 {  catchsql {DETACH DATABASE test1}  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_ATTACH"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {    ATTACH DATABASE ':memory:' AS test1;  }} {1 {not authorized}}do_test auth-1.254 {  lindex [execsql {PRAGMA database_list}] 7} {}do_test auth-1.255 {  catchsql {DETACH DATABASE test1}  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_ATTACH"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {    ATTACH DATABASE ':memory:' AS test1;  }} {0 {}}do_test auth-1.256 {  lindex [execsql {PRAGMA database_list}] 7} {}do_test auth-1.257 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DETACH"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_OK    }    return SQLITE_OK  }  execsql {ATTACH DATABASE ':memory:' AS test1}  catchsql {    DETACH DATABASE test1;  }} {0 {}}do_test auth-1.258 {  lindex [execsql {PRAGMA database_list}] 7} {}do_test auth-1.259 {  execsql {ATTACH DATABASE ':memory:' AS test1}  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DETACH"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {    DETACH DATABASE test1;  }} {0 {}}do_test auth-1.260 {  lindex [execsql {PRAGMA database_list}] 7} {test1}do_test auth-1.261 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_DETACH"} {      set ::authargs [list $arg1 $arg2 $arg3 $arg4]      return SQLITE_DENY    }    return SQLITE_OK  }  catchsql {    DETACH DATABASE test1;  }} {1 {not authorized}}do_test auth-1.262 {  lindex [execsql {PRAGMA database_list}] 7} {test1}db authorizer {}execsql {DETACH DATABASE test1}do_test auth-2.1 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg1=="t3" && $arg2=="x"} {      return SQLITE_DENY    }    return SQLITE_OK  }  db authorizer ::auth  execsql {CREATE TABLE t3(x INTEGER PRIMARY KEY, y, z)}  catchsql {SELECT * FROM t3}} {1 {access to t3.x is prohibited}}do_test auth-2.1 {  catchsql {SELECT y,z FROM t3}} {0 {}}do_test auth-2.2 {  catchsql {SELECT ROWID,y,z FROM t3}} {1 {access to t3.x is prohibited}}do_test auth-2.3 {  catchsql {SELECT OID,y,z FROM t3}} {1 {access to t3.x is prohibited}}do_test auth-2.4 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg1=="t3" && $arg2=="x"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  execsql {INSERT INTO t3 VALUES(44,55,66)}  catchsql {SELECT * FROM t3}} {0 {{} 55 66}}do_test auth-2.5 {  catchsql {SELECT rowid,y,z FROM t3}} {0 {{} 55 66}}do_test auth-2.6 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg1=="t3" && $arg2=="ROWID"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {SELECT * FROM t3}} {0 {44 55 66}}do_test auth-2.7 {  catchsql {SELECT ROWID,y,z FROM t3}} {0 {44 55 66}}do_test auth-2.8 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="ROWID"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {SELECT ROWID,b,c FROM t2}} {0 {{} 2 33 {} 8 9}}do_test auth-2.9.1 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="ROWID"} {      return bogus    }    return SQLITE_OK  }  catchsql {SELECT ROWID,b,c FROM t2}} {1 {illegal return value (999) from the authorization function - should be SQLITE_OK, SQLITE_IGNORE, or SQLITE_DENY}}do_test auth-2.9.2 {  db errorcode} {21}do_test auth-2.10 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_SELECT"} {      return bogus    }    return SQLITE_OK  }  catchsql {SELECT ROWID,b,c FROM t2}} {1 {illegal return value (1) from the authorization function - should be SQLITE_OK, SQLITE_IGNORE, or SQLITE_DENY}}do_test auth-2.11 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg2=="a"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {SELECT * FROM t2, t3}} {0 {{} 2 33 44 55 66 {} 8 9 44 55 66}}do_test auth-2.11 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg2=="x"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  catchsql {SELECT * FROM t2, t3}} {0 {11 2 33 {} 55 66 7 8 9 {} 55 66}}# Make sure the OLD and NEW pseudo-tables of a trigger get authorized.#do_test auth-3.1 {  proc auth {code arg1 arg2 arg3 arg4} {    return SQLITE_OK  }  execsql {    CREATE TABLE tx(a1,a2,b1,b2,c1,c2);    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN      INSERT INTO tx VALUES(OLD.a,NEW.a,OLD.b,NEW.b,OLD.c,NEW.c);    END;    UPDATE t2 SET a=a+1;    SELECT * FROM tx;  }} {11 12 2 2 33 33 7 8 8 8 9 9}do_test auth-3.2 {  proc auth {code arg1 arg2 arg3 arg4} {    if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="c"} {      return SQLITE_IGNORE    }    return SQLITE_OK  }  execsql {    DELETE FROM tx;    UPDATE t2 SET a=a+100;    SELECT * FROM tx;  }} {12 112 2 2 {} {} 8 108 8 8 {} {}}# Make sure the names of views and triggers are passed on on arg4.#do_test auth-4.1 {  proc auth {code arg1 arg2 arg3 arg4} {    lappend ::authargs $code $arg1 $arg2 $arg3 $arg4    return SQLITE_OK  }  set authargs {}  execsql {    UPDATE t2 SET a=a+1;  }  set authargs} [list \  SQLITE_READ   t2 a  main {} \  SQLITE_UPDATE t2 a  main {} \  SQLITE_INSERT tx {} main r1 \  SQLITE_READ   t2 a  main r1 \  SQLITE_READ   t2 a  main r1 \  SQLITE_READ   t2 b  main r1 \  SQLITE_READ   t2 b  main r1 \  SQLITE_READ   t2 c  main r1 \  SQLITE_READ   t2 c  main r1]do_test auth-4.2 {  execsql {    CREATE VIEW v1 AS SELECT a+b AS x FROM t2;    CREATE TABLE v1chng(x1,x2);    CREATE TRIGGER r2 INSTEAD OF UPDATE ON v1 BEGIN      INSERT INTO v1chng VALUES(OLD.x,NEW.x);    END;    SELECT * FROM v1;  }} {115 117}do_test auth-4.3 {  set authargs {}  execsql {    UPDATE v1 SET x=1 WHERE x=117  }  set authargs} [list \  SQLITE_UPDATE v1     x  main {} \  SQLITE_READ   v1     x  main {} \  SQLITE_SELECT {}     {} {}   v1 \  SQLITE_READ   t2     a  main v1 \  SQLITE_READ   t2     b  main v1 \  SQLITE_INSERT v1chng {} main r2 \  SQLITE_READ   v1     x  main r2 \  SQLITE_READ   v1     x  main r2]do_test auth-4.4 {  execsql {    CREATE TRIGGER r3 INSTEAD OF DELETE ON v1 BEGIN      INSERT INTO v1chng VALUES(OLD.x,NULL);    END;    SELECT * FROM v1;  }} {115 117}do_test auth-4.5 {  set authargs {}  execsql {    DELETE FROM v1 WHERE x=117  }  set authargs} [list \  SQLITE_DELETE v1     {} main {} \  SQLITE_READ   v1     x  main {} \  SQLITE_SELECT {}     {} {}   v1 \  SQLITE_READ   t2     a  main v1 \  SQLITE_READ   t2     b  main v1 \  SQLITE_INSERT v1chng {} main r3 \  SQLITE_READ   v1     x  main r3]finish_test

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -