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

📄 trigger6.test

📁 sqlite-3.4.1,嵌入式数据库.是一个功能强大的开源数据库,给学习和研发以及小型公司的发展带来了全所未有的好处.
💻 TEST
字号:
# 2004 December 07## The author disclaims copyright to this source code.  In place of# a legal notice, here is a blessing:##    May you do good and not evil.#    May you find forgiveness for yourself and forgive others.#    May you share freely, never taking more than you give.##***********************************************************************# This file implements regression tests for SQLite library.## This file implements tests to make sure expression of an INSERT# and UPDATE statement are only evaluated once.  See ticket #980.# If an expression uses a function that has side-effects or which# is not deterministic (ex: random()) then we want to make sure# that the same evaluation occurs for the actual INSERT/UPDATE and# for the NEW.* fields of any triggers that fire.## $Id: trigger6.test,v 1.2 2005/05/05 11:04:50 drh Exp $set testdir [file dirname $argv0]source $testdir/tester.tclifcapable {!trigger} {  finish_test  return}do_test trigger6-1.1 {  execsql {    CREATE TABLE t1(x, y);    CREATE TABLE log(a, b, c);    CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN      INSERT INTO log VALUES(1, new.x, new.y);    END;    CREATE TRIGGER r2 BEFORE UPDATE ON t1 BEGIN      INSERT INTO log VALUES(2, new.x, new.y);    END;  }  set ::trigger6_cnt 0  proc trigger6_counter {args} {    incr ::trigger6_cnt    return $::trigger6_cnt  }  db function counter trigger6_counter  execsql {    INSERT INTO t1 VALUES(1,counter());    SELECT * FROM t1;  }} {1 1}do_test trigger6-1.2 {  execsql {    SELECT * FROM log;  }} {1 1 1}do_test trigger6-1.3 {  execsql {    DELETE FROM t1;    DELETE FROM log;    INSERT INTO t1 VALUES(2,counter(2,3)+4);    SELECT * FROM t1;  }} {2 6}do_test trigger6-1.4 {  execsql {    SELECT * FROM log;  }} {1 2 6}do_test trigger6-1.5 {  execsql {    DELETE FROM log;    UPDATE t1 SET y=counter(5);    SELECT * FROM t1;  }} {2 3}do_test trigger6-1.6 {  execsql {    SELECT * FROM log;  }} {2 2 3}finish_test

⌨️ 快捷键说明

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