SQLite

Check-in [19e95f6335]
Login

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

Overview
Comment:Fix the TCL interface to test_quota.c so that it works with empty callback scripts.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: 19e95f63359589766da673aac99d19a355a92678
User & Date: drh 2010-09-01 15:11:39.000
Original Comment: Fix the TCL interface to test_quota.c so that it works with empty callback scripts.
Context
2010-09-01
15:22
Merge the test_quota.c module into the trunk. (check-in: 2e1a02026a user: drh tags: trunk)
15:11
Fix the TCL interface to test_quota.c so that it works with empty callback scripts. (Closed-Leaf check-in: 19e95f6335 user: drh tags: experimental)
14:58
Variable name and comment changes to test_quota.c for clearer presentation. (check-in: 38ed1992c8 user: drh tags: experimental)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test_quota.c.
722
723
724
725
726
727
728

729
730
731
732
733
734
735
  TclQuotaCallback *p;            /* Callback script object */
  Tcl_Obj *pEval;                 /* Script to evaluate */
  Tcl_Obj *pVarname;              /* Name of variable to pass as 2nd arg */
  unsigned int rnd;               /* Random part of pVarname */
  int rc;                         /* Tcl error code */

  p = (TclQuotaCallback *)pArg;


  pVarname = Tcl_NewStringObj("::piLimit_", -1);
  Tcl_IncrRefCount(pVarname);
  sqlite3_randomness(sizeof(rnd), (void *)&rnd);
  Tcl_AppendObjToObj(pVarname, Tcl_NewIntObj((int)(rnd&0x7FFFFFFF)));
  Tcl_ObjSetVar2(p->interp, pVarname, 0, Tcl_NewWideIntObj(*piLimit), 0);








>







722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
  TclQuotaCallback *p;            /* Callback script object */
  Tcl_Obj *pEval;                 /* Script to evaluate */
  Tcl_Obj *pVarname;              /* Name of variable to pass as 2nd arg */
  unsigned int rnd;               /* Random part of pVarname */
  int rc;                         /* Tcl error code */

  p = (TclQuotaCallback *)pArg;
  if( p==0 ) return;

  pVarname = Tcl_NewStringObj("::piLimit_", -1);
  Tcl_IncrRefCount(pVarname);
  sqlite3_randomness(sizeof(rnd), (void *)&rnd);
  Tcl_AppendObjToObj(pVarname, Tcl_NewIntObj((int)(rnd&0x7FFFFFFF)));
  Tcl_ObjSetVar2(p->interp, pVarname, 0, Tcl_NewWideIntObj(*piLimit), 0);

Changes to test/quota.test.
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181




























182
183
184
185
proc quota_list {} {
  set allq {}
  foreach q [sqlite3_quota_dump] {
    lappend allq [lindex $q 0]
  }
  return [lsort $allq]
}

do_test quota-4.1 {
  sqlite3_quota_set *test.db 0 {}
  quota_list
} {}
do_test quota-4.2 {
  sqlite3_quota_set *test.db 4096 {}
  quota_list
} {*test.db}
do_test quota-4.3 {
  sqlite3_quota_set *test2.db 0 {}
  quota_list
} {*test.db}
do_test quota-4.4 {
  sqlite3_quota_set *test2.db 12345 {}
  quota_list
} {*test.db *test2.db}
do_test quota-4.5 {
  sqlite3_quota_set *test.db 0 {}
  quota_list
} {*test2.db}






























sqlite3_quota_shutdown 
finish_test







>













|






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




155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
proc quota_list {} {
  set allq {}
  foreach q [sqlite3_quota_dump] {
    lappend allq [lindex $q 0]
  }
  return [lsort $allq]
}

do_test quota-4.1 {
  sqlite3_quota_set *test.db 0 {}
  quota_list
} {}
do_test quota-4.2 {
  sqlite3_quota_set *test.db 4096 {}
  quota_list
} {*test.db}
do_test quota-4.3 {
  sqlite3_quota_set *test2.db 0 {}
  quota_list
} {*test.db}
do_test quota-4.4 {
  sqlite3_quota_set *test2.db 100000 {}
  quota_list
} {*test.db *test2.db}
do_test quota-4.5 {
  sqlite3_quota_set *test.db 0 {}
  quota_list
} {*test2.db}
do_test quota-4.6 {
  file delete -force test2.db test2.db-journal test2.db-wal
  sqlite3 db test2.db
  db eval {CREATE TABLE t2(x); INSERT INTO t2 VALUES('tab-t2');}
  quota_list
} {*test2.db}
do_test quota-4.7 {
  catchsql {INSERT INTO t2 VALUES(zeroblob(200000))}
} {1 {database or disk is full}}
do_test quota-4.8 {
  sqlite3 db2 test2.db
  db2 eval {SELECT * FROM t2}
} {tab-t2}
do_test quota-4.9 {
  sqlite3_quota_set *test2.db 0 {}
  catchsql {INSERT INTO t2 VALUES(zeroblob(200000))}
} {0 {}}
do_test quota-4.10 {
  quota_list
} {*test2.db}
do_test quota-4.11 {
  db2 close
  quota_list
} {*test2.db}
do_test quota-4.12 {
  db close
  quota_list
} {}


sqlite3_quota_shutdown 
finish_test