| OLD | NEW | 
|     1 # 2003 April 4 |     1 # 2003 April 4 | 
|     2 # |     2 # | 
|     3 # The author disclaims copyright to this source code.  In place of |     3 # The author disclaims copyright to this source code.  In place of | 
|     4 # a legal notice, here is a blessing: |     4 # a legal notice, here is a blessing: | 
|     5 # |     5 # | 
|     6 #    May you do good and not evil. |     6 #    May you do good and not evil. | 
|     7 #    May you find forgiveness for yourself and forgive others. |     7 #    May you find forgiveness for yourself and forgive others. | 
|     8 #    May you share freely, never taking more than you give. |     8 #    May you share freely, never taking more than you give. | 
|     9 # |     9 # | 
|    10 #*********************************************************************** |    10 #*********************************************************************** | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    84   do_test auth-1.5 { |    84   do_test auth-1.5 { | 
|    85     proc auth {code arg1 arg2 arg3 arg4 args} { |    85     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|    86       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { |    86       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { | 
|    87         return SQLITE_DENY |    87         return SQLITE_DENY | 
|    88       } |    88       } | 
|    89       return SQLITE_OK |    89       return SQLITE_OK | 
|    90     } |    90     } | 
|    91     catchsql {CREATE TEMP TABLE t1(a,b,c)} |    91     catchsql {CREATE TEMP TABLE t1(a,b,c)} | 
|    92   } {1 {not authorized}} |    92   } {1 {not authorized}} | 
|    93   do_test auth-1.6 { |    93   do_test auth-1.6 { | 
|    94     execsql {SELECT name FROM sqlite_temp_master} |    94     execsql {SELECT name FROM temp.sqlite_master} | 
|    95   } {} |    95   } {} | 
|    96   do_test auth-1.7.1 { |    96   do_test auth-1.7.1 { | 
|    97     proc auth {code arg1 arg2 arg3 arg4 args} { |    97     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|    98       if {$code=="SQLITE_CREATE_TEMP_TABLE"} { |    98       if {$code=="SQLITE_CREATE_TEMP_TABLE"} { | 
|    99         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |    99         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|   100         return SQLITE_DENY |   100         return SQLITE_DENY | 
|   101       } |   101       } | 
|   102       return SQLITE_OK |   102       return SQLITE_OK | 
|   103     } |   103     } | 
|   104     catchsql {CREATE TEMP TABLE t1(a,b,c)} |   104     catchsql {CREATE TEMP TABLE t1(a,b,c)} | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   141   do_test auth-1.13 { |   141   do_test auth-1.13 { | 
|   142     proc auth {code arg1 arg2 arg3 arg4 args} { |   142     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   143       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { |   143       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { | 
|   144         return SQLITE_IGNORE |   144         return SQLITE_IGNORE | 
|   145       } |   145       } | 
|   146       return SQLITE_OK |   146       return SQLITE_OK | 
|   147     } |   147     } | 
|   148     catchsql {CREATE TEMP TABLE t1(a,b,c)} |   148     catchsql {CREATE TEMP TABLE t1(a,b,c)} | 
|   149   } {0 {}} |   149   } {0 {}} | 
|   150   do_test auth-1.14 { |   150   do_test auth-1.14 { | 
|   151     execsql {SELECT name FROM sqlite_temp_master} |   151     execsql {SELECT name FROM temp.sqlite_master} | 
|   152   } {} |   152   } {} | 
|   153   do_test auth-1.15 { |   153   do_test auth-1.15 { | 
|   154     proc auth {code arg1 arg2 arg3 arg4 args} { |   154     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   155       if {$code=="SQLITE_CREATE_TEMP_TABLE"} { |   155       if {$code=="SQLITE_CREATE_TEMP_TABLE"} { | 
|   156         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |   156         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|   157         return SQLITE_IGNORE |   157         return SQLITE_IGNORE | 
|   158       } |   158       } | 
|   159       return SQLITE_OK |   159       return SQLITE_OK | 
|   160     } |   160     } | 
|   161     catchsql {CREATE TEMP TABLE t1(a,b,c)} |   161     catchsql {CREATE TEMP TABLE t1(a,b,c)} | 
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   554   do_test auth-1.77 { |   554   do_test auth-1.77 { | 
|   555     proc auth {code arg1 arg2 arg3 arg4 args} { |   555     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   556       if {$code=="SQLITE_DELETE" && $arg1=="t1"} { |   556       if {$code=="SQLITE_DELETE" && $arg1=="t1"} { | 
|   557          return SQLITE_IGNORE |   557          return SQLITE_IGNORE | 
|   558       } |   558       } | 
|   559       return SQLITE_OK |   559       return SQLITE_OK | 
|   560     } |   560     } | 
|   561     catchsql {DROP TABLE t1} |   561     catchsql {DROP TABLE t1} | 
|   562   } {0 {}} |   562   } {0 {}} | 
|   563   do_test auth-1.78 { |   563   do_test auth-1.78 { | 
|   564     execsql {SELECT name FROM sqlite_temp_master} |   564     execsql {SELECT name FROM temp.sqlite_master} | 
|   565   } {t1} |   565   } {t1} | 
|   566 } |   566 } | 
|   567  |   567  | 
|   568 # Test cases auth-1.79 to auth-1.124 test creating and dropping views. |   568 # Test cases auth-1.79 to auth-1.124 test creating and dropping views. | 
|   569 # Omit these if the library was compiled with views omitted. |   569 # Omit these if the library was compiled with views omitted. | 
|   570 ifcapable view { |   570 ifcapable view { | 
|   571 do_test auth-1.79 { |   571 do_test auth-1.79 { | 
|   572   proc auth {code arg1 arg2 arg3 arg4 args} { |   572   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   573     if {$code=="SQLITE_CREATE_VIEW"} { |   573     if {$code=="SQLITE_CREATE_VIEW"} { | 
|   574       set ::authargs [list $arg1 $arg2 $arg3 $arg4]  |   574       set ::authargs [list $arg1 $arg2 $arg3 $arg4]  | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   625         return SQLITE_IGNORE |   625         return SQLITE_IGNORE | 
|   626       } |   626       } | 
|   627       return SQLITE_OK |   627       return SQLITE_OK | 
|   628     } |   628     } | 
|   629     catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} |   629     catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} | 
|   630   } {0 {}} |   630   } {0 {}} | 
|   631   do_test auth-1.89 { |   631   do_test auth-1.89 { | 
|   632     set ::authargs |   632     set ::authargs | 
|   633   } {v1 {} temp {}} |   633   } {v1 {} temp {}} | 
|   634   do_test auth-1.90 { |   634   do_test auth-1.90 { | 
|   635     execsql {SELECT name FROM sqlite_temp_master} |   635     execsql {SELECT name FROM temp.sqlite_master} | 
|   636   } {t1} |   636   } {t1} | 
|   637 } |   637 } | 
|   638  |   638  | 
|   639 do_test auth-1.91 { |   639 do_test auth-1.91 { | 
|   640   proc auth {code arg1 arg2 arg3 arg4 args} { |   640   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   641     if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { |   641     if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { | 
|   642       return SQLITE_DENY |   642       return SQLITE_DENY | 
|   643     } |   643     } | 
|   644     return SQLITE_OK |   644     return SQLITE_OK | 
|   645   } |   645   } | 
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   772         return SQLITE_DENY |   772         return SQLITE_DENY | 
|   773       } |   773       } | 
|   774       return SQLITE_OK |   774       return SQLITE_OK | 
|   775     } |   775     } | 
|   776     catchsql { |   776     catchsql { | 
|   777       CREATE TEMP VIEW v1 AS SELECT a+1,b+1 FROM t1; |   777       CREATE TEMP VIEW v1 AS SELECT a+1,b+1 FROM t1; | 
|   778       DROP VIEW v1 |   778       DROP VIEW v1 | 
|   779     } |   779     } | 
|   780   } {1 {not authorized}} |   780   } {1 {not authorized}} | 
|   781   do_test auth-1.113 { |   781   do_test auth-1.113 { | 
|   782     execsql {SELECT name FROM sqlite_temp_master} |   782     execsql {SELECT name FROM temp.sqlite_master} | 
|   783   } {t1 v1} |   783   } {t1 v1} | 
|   784   do_test auth-1.114 { |   784   do_test auth-1.114 { | 
|   785     proc auth {code arg1 arg2 arg3 arg4 args} { |   785     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   786       if {$code=="SQLITE_DROP_TEMP_VIEW"} { |   786       if {$code=="SQLITE_DROP_TEMP_VIEW"} { | 
|   787         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |   787         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|   788         return SQLITE_DENY |   788         return SQLITE_DENY | 
|   789       } |   789       } | 
|   790       return SQLITE_OK |   790       return SQLITE_OK | 
|   791     } |   791     } | 
|   792     catchsql {DROP VIEW v1} |   792     catchsql {DROP VIEW v1} | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|   816         return SQLITE_IGNORE |   816         return SQLITE_IGNORE | 
|   817       } |   817       } | 
|   818       return SQLITE_OK |   818       return SQLITE_OK | 
|   819     } |   819     } | 
|   820     catchsql {DROP VIEW v1} |   820     catchsql {DROP VIEW v1} | 
|   821   } {0 {}} |   821   } {0 {}} | 
|   822   do_test auth-1.120 { |   822   do_test auth-1.120 { | 
|   823     set ::authargs |   823     set ::authargs | 
|   824   } {v1 {} temp {}} |   824   } {v1 {} temp {}} | 
|   825   do_test auth-1.121 { |   825   do_test auth-1.121 { | 
|   826     execsql {SELECT name FROM sqlite_temp_master} |   826     execsql {SELECT name FROM temp.sqlite_master} | 
|   827   } {t1 v1} |   827   } {t1 v1} | 
|   828   do_test auth-1.122 { |   828   do_test auth-1.122 { | 
|   829     proc auth {code arg1 arg2 arg3 arg4 args} { |   829     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   830       if {$code=="SQLITE_DROP_TEMP_VIEW"} { |   830       if {$code=="SQLITE_DROP_TEMP_VIEW"} { | 
|   831         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |   831         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|   832         return SQLITE_OK |   832         return SQLITE_OK | 
|   833       } |   833       } | 
|   834       return SQLITE_OK |   834       return SQLITE_OK | 
|   835     } |   835     } | 
|   836     catchsql {DROP VIEW v1} |   836     catchsql {DROP VIEW v1} | 
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   973   catchsql { |   973   catchsql { | 
|   974     CREATE TRIGGER r1 DELETE on t1 BEGIN |   974     CREATE TRIGGER r1 DELETE on t1 BEGIN | 
|   975         SELECT NULL; |   975         SELECT NULL; | 
|   976     END; |   976     END; | 
|   977   } |   977   } | 
|   978 } {1 {not authorized}} |   978 } {1 {not authorized}} | 
|   979 do_test auth-1.139 { |   979 do_test auth-1.139 { | 
|   980   set ::authargs |   980   set ::authargs | 
|   981 } {r1 t1 temp {}} |   981 } {r1 t1 temp {}} | 
|   982 do_test auth-1.140 { |   982 do_test auth-1.140 { | 
|   983   execsql {SELECT name FROM sqlite_temp_master} |   983   execsql {SELECT name FROM temp.sqlite_master} | 
|   984 } {t1} |   984 } {t1} | 
|   985 do_test auth-1.141 { |   985 do_test auth-1.141 { | 
|   986   proc auth {code arg1 arg2 arg3 arg4 args} { |   986   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|   987     if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { |   987     if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { | 
|   988       return SQLITE_DENY |   988       return SQLITE_DENY | 
|   989     } |   989     } | 
|   990     return SQLITE_OK |   990     return SQLITE_OK | 
|   991   } |   991   } | 
|   992   catchsql { |   992   catchsql { | 
|   993     CREATE TRIGGER r1 DELETE on t1 BEGIN |   993     CREATE TRIGGER r1 DELETE on t1 BEGIN | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  1009   catchsql { |  1009   catchsql { | 
|  1010     CREATE TRIGGER r1 DELETE on t1 BEGIN |  1010     CREATE TRIGGER r1 DELETE on t1 BEGIN | 
|  1011         SELECT NULL; |  1011         SELECT NULL; | 
|  1012     END; |  1012     END; | 
|  1013   } |  1013   } | 
|  1014 } {0 {}} |  1014 } {0 {}} | 
|  1015 do_test auth-1.144 { |  1015 do_test auth-1.144 { | 
|  1016   set ::authargs |  1016   set ::authargs | 
|  1017 } {r1 t1 temp {}} |  1017 } {r1 t1 temp {}} | 
|  1018 do_test auth-1.145 { |  1018 do_test auth-1.145 { | 
|  1019   execsql {SELECT name FROM sqlite_temp_master} |  1019   execsql {SELECT name FROM temp.sqlite_master} | 
|  1020 } {t1} |  1020 } {t1} | 
|  1021 do_test auth-1.146 { |  1021 do_test auth-1.146 { | 
|  1022   proc auth {code arg1 arg2 arg3 arg4 args} { |  1022   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1023     if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { |  1023     if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { | 
|  1024       return SQLITE_IGNORE |  1024       return SQLITE_IGNORE | 
|  1025     } |  1025     } | 
|  1026     return SQLITE_OK |  1026     return SQLITE_OK | 
|  1027   } |  1027   } | 
|  1028   catchsql { |  1028   catchsql { | 
|  1029     CREATE TRIGGER r1 DELETE on t1 BEGIN |  1029     CREATE TRIGGER r1 DELETE on t1 BEGIN | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  1045   catchsql { |  1045   catchsql { | 
|  1046     CREATE TRIGGER r1 DELETE on t1 BEGIN |  1046     CREATE TRIGGER r1 DELETE on t1 BEGIN | 
|  1047         SELECT NULL; |  1047         SELECT NULL; | 
|  1048     END; |  1048     END; | 
|  1049   } |  1049   } | 
|  1050 } {0 {}} |  1050 } {0 {}} | 
|  1051 do_test auth-1.149 { |  1051 do_test auth-1.149 { | 
|  1052   set ::authargs |  1052   set ::authargs | 
|  1053 } {r1 t1 temp {}} |  1053 } {r1 t1 temp {}} | 
|  1054 do_test auth-1.150 { |  1054 do_test auth-1.150 { | 
|  1055   execsql {SELECT name FROM sqlite_temp_master} |  1055   execsql {SELECT name FROM temp.sqlite_master} | 
|  1056 } {t1 r1} |  1056 } {t1 r1} | 
|  1057  |  1057  | 
|  1058 do_test auth-1.151 { |  1058 do_test auth-1.151 { | 
|  1059   proc auth {code arg1 arg2 arg3 arg4 args} { |  1059   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1060     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { |  1060     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { | 
|  1061       return SQLITE_DENY |  1061       return SQLITE_DENY | 
|  1062     } |  1062     } | 
|  1063     return SQLITE_OK |  1063     return SQLITE_OK | 
|  1064   } |  1064   } | 
|  1065   catchsql {DROP TRIGGER r2} |  1065   catchsql {DROP TRIGGER r2} | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1135 do_test auth-1.164 { |  1135 do_test auth-1.164 { | 
|  1136   proc auth {code arg1 arg2 arg3 arg4 args} { |  1136   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1137     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { |  1137     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { | 
|  1138       return SQLITE_DENY |  1138       return SQLITE_DENY | 
|  1139     } |  1139     } | 
|  1140     return SQLITE_OK |  1140     return SQLITE_OK | 
|  1141   } |  1141   } | 
|  1142   catchsql {DROP TRIGGER r1} |  1142   catchsql {DROP TRIGGER r1} | 
|  1143 } {1 {not authorized}} |  1143 } {1 {not authorized}} | 
|  1144 do_test auth-1.165 { |  1144 do_test auth-1.165 { | 
|  1145   execsql {SELECT name FROM sqlite_temp_master} |  1145   execsql {SELECT name FROM temp.sqlite_master} | 
|  1146 } {t1 r1} |  1146 } {t1 r1} | 
|  1147 do_test auth-1.166 { |  1147 do_test auth-1.166 { | 
|  1148   proc auth {code arg1 arg2 arg3 arg4 args} { |  1148   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1149     if {$code=="SQLITE_DROP_TEMP_TRIGGER"} { |  1149     if {$code=="SQLITE_DROP_TEMP_TRIGGER"} { | 
|  1150       set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1150       set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1151       return SQLITE_DENY |  1151       return SQLITE_DENY | 
|  1152     } |  1152     } | 
|  1153     return SQLITE_OK |  1153     return SQLITE_OK | 
|  1154   } |  1154   } | 
|  1155   catchsql {DROP TRIGGER r1} |  1155   catchsql {DROP TRIGGER r1} | 
|  1156 } {1 {not authorized}} |  1156 } {1 {not authorized}} | 
|  1157 do_test auth-1.167 { |  1157 do_test auth-1.167 { | 
|  1158   set ::authargs |  1158   set ::authargs | 
|  1159 } {r1 t1 temp {}} |  1159 } {r1 t1 temp {}} | 
|  1160 do_test auth-1.168 { |  1160 do_test auth-1.168 { | 
|  1161   execsql {SELECT name FROM sqlite_temp_master} |  1161   execsql {SELECT name FROM sqlite_temp_master} | 
|  1162 } {t1 r1} |  1162 } {t1 r1} | 
|  1163 do_test auth-1.169 { |  1163 do_test auth-1.169 { | 
|  1164   proc auth {code arg1 arg2 arg3 arg4 args} { |  1164   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1165     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { |  1165     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { | 
|  1166       return SQLITE_IGNORE |  1166       return SQLITE_IGNORE | 
|  1167     } |  1167     } | 
|  1168     return SQLITE_OK |  1168     return SQLITE_OK | 
|  1169   } |  1169   } | 
|  1170   catchsql {DROP TRIGGER r1} |  1170   catchsql {DROP TRIGGER r1} | 
|  1171 } {0 {}} |  1171 } {0 {}} | 
|  1172 do_test auth-1.170 { |  1172 do_test auth-1.170 { | 
|  1173   execsql {SELECT name FROM sqlite_temp_master} |  1173   execsql {SELECT name FROM temp.sqlite_master} | 
|  1174 } {t1 r1} |  1174 } {t1 r1} | 
|  1175 do_test auth-1.171 { |  1175 do_test auth-1.171 { | 
|  1176   proc auth {code arg1 arg2 arg3 arg4 args} { |  1176   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1177     if {$code=="SQLITE_DROP_TEMP_TRIGGER"} { |  1177     if {$code=="SQLITE_DROP_TEMP_TRIGGER"} { | 
|  1178       set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1178       set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1179       return SQLITE_IGNORE |  1179       return SQLITE_IGNORE | 
|  1180     } |  1180     } | 
|  1181     return SQLITE_OK |  1181     return SQLITE_OK | 
|  1182   } |  1182   } | 
|  1183   catchsql {DROP TRIGGER r1} |  1183   catchsql {DROP TRIGGER r1} | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  1195       return SQLITE_OK |  1195       return SQLITE_OK | 
|  1196     } |  1196     } | 
|  1197     return SQLITE_OK |  1197     return SQLITE_OK | 
|  1198   } |  1198   } | 
|  1199   catchsql {DROP TRIGGER r1} |  1199   catchsql {DROP TRIGGER r1} | 
|  1200 } {0 {}} |  1200 } {0 {}} | 
|  1201 do_test auth-1.175 { |  1201 do_test auth-1.175 { | 
|  1202   set ::authargs |  1202   set ::authargs | 
|  1203 } {r1 t1 temp {}} |  1203 } {r1 t1 temp {}} | 
|  1204 do_test auth-1.176 { |  1204 do_test auth-1.176 { | 
|  1205   execsql {SELECT name FROM sqlite_temp_master} |  1205   execsql {SELECT name FROM temp.sqlite_master} | 
|  1206 } {t1} |  1206 } {t1} | 
|  1207 } ;# ifcapable trigger |  1207 } ;# ifcapable trigger | 
|  1208  |  1208  | 
|  1209 do_test auth-1.177 { |  1209 do_test auth-1.177 { | 
|  1210   proc auth {code arg1 arg2 arg3 arg4 args} { |  1210   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1211     if {$code=="SQLITE_CREATE_INDEX"} { |  1211     if {$code=="SQLITE_CREATE_INDEX"} { | 
|  1212       set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1212       set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1213       return SQLITE_DENY |  1213       return SQLITE_DENY | 
|  1214     } |  1214     } | 
|  1215     return SQLITE_OK |  1215     return SQLITE_OK | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1299   do_test auth-1.193 { |  1299   do_test auth-1.193 { | 
|  1300     proc auth {code arg1 arg2 arg3 arg4 args} { |  1300     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1301       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { |  1301       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { | 
|  1302         return SQLITE_DENY |  1302         return SQLITE_DENY | 
|  1303       } |  1303       } | 
|  1304       return SQLITE_OK |  1304       return SQLITE_OK | 
|  1305     } |  1305     } | 
|  1306     catchsql {CREATE INDEX i1 ON t1(b)} |  1306     catchsql {CREATE INDEX i1 ON t1(b)} | 
|  1307   } {1 {not authorized}} |  1307   } {1 {not authorized}} | 
|  1308   do_test auth-1.194 { |  1308   do_test auth-1.194 { | 
|  1309     execsql {SELECT name FROM sqlite_temp_master} |  1309     execsql {SELECT name FROM temp.sqlite_master} | 
|  1310   } {t1} |  1310   } {t1} | 
|  1311   do_test auth-1.195 { |  1311   do_test auth-1.195 { | 
|  1312     proc auth {code arg1 arg2 arg3 arg4 args} { |  1312     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1313       if {$code=="SQLITE_CREATE_TEMP_INDEX"} { |  1313       if {$code=="SQLITE_CREATE_TEMP_INDEX"} { | 
|  1314         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1314         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1315         return SQLITE_IGNORE |  1315         return SQLITE_IGNORE | 
|  1316       } |  1316       } | 
|  1317       return SQLITE_OK |  1317       return SQLITE_OK | 
|  1318     } |  1318     } | 
|  1319     catchsql {CREATE INDEX i1 ON t1(b)} |  1319     catchsql {CREATE INDEX i1 ON t1(b)} | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|  1343         return SQLITE_OK |  1343         return SQLITE_OK | 
|  1344       } |  1344       } | 
|  1345       return SQLITE_OK |  1345       return SQLITE_OK | 
|  1346     } |  1346     } | 
|  1347     catchsql {CREATE INDEX i1 ON t1(a)} |  1347     catchsql {CREATE INDEX i1 ON t1(a)} | 
|  1348   } {0 {}} |  1348   } {0 {}} | 
|  1349   do_test auth-1.201 { |  1349   do_test auth-1.201 { | 
|  1350     set ::authargs |  1350     set ::authargs | 
|  1351   } {i1 t1 temp {}} |  1351   } {i1 t1 temp {}} | 
|  1352   do_test auth-1.202 { |  1352   do_test auth-1.202 { | 
|  1353     execsql {SELECT name FROM sqlite_temp_master} |  1353     execsql {SELECT name FROM temp.sqlite_master} | 
|  1354   } {t1 i1} |  1354   } {t1 i1} | 
|  1355 } |  1355 } | 
|  1356  |  1356  | 
|  1357 do_test auth-1.203 { |  1357 do_test auth-1.203 { | 
|  1358   proc auth {code arg1 arg2 arg3 arg4 args} { |  1358   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1359     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { |  1359     if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { | 
|  1360       return SQLITE_DENY |  1360       return SQLITE_DENY | 
|  1361     } |  1361     } | 
|  1362     return SQLITE_OK |  1362     return SQLITE_OK | 
|  1363   } |  1363   } | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1459   do_test auth-1.221 { |  1459   do_test auth-1.221 { | 
|  1460     proc auth {code arg1 arg2 arg3 arg4 args} { |  1460     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1461       if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { |  1461       if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { | 
|  1462         return SQLITE_IGNORE |  1462         return SQLITE_IGNORE | 
|  1463       } |  1463       } | 
|  1464       return SQLITE_OK |  1464       return SQLITE_OK | 
|  1465     } |  1465     } | 
|  1466     catchsql {DROP INDEX i1} |  1466     catchsql {DROP INDEX i1} | 
|  1467   } {0 {}} |  1467   } {0 {}} | 
|  1468   do_test auth-1.222 { |  1468   do_test auth-1.222 { | 
|  1469     execsql {SELECT name FROM sqlite_temp_master} |  1469     execsql {SELECT name FROM temp.sqlite_master} | 
|  1470   } {t1 i1} |  1470   } {t1 i1} | 
|  1471   do_test auth-1.223 { |  1471   do_test auth-1.223 { | 
|  1472     proc auth {code arg1 arg2 arg3 arg4 args} { |  1472     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1473       if {$code=="SQLITE_DROP_TEMP_INDEX"} { |  1473       if {$code=="SQLITE_DROP_TEMP_INDEX"} { | 
|  1474         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1474         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1475         return SQLITE_IGNORE |  1475         return SQLITE_IGNORE | 
|  1476       } |  1476       } | 
|  1477       return SQLITE_OK |  1477       return SQLITE_OK | 
|  1478     } |  1478     } | 
|  1479     catchsql {DROP INDEX i1} |  1479     catchsql {DROP INDEX i1} | 
|  1480   } {0 {}} |  1480   } {0 {}} | 
|  1481   do_test auth-1.224 { |  1481   do_test auth-1.224 { | 
|  1482     set ::authargs |  1482     set ::authargs | 
|  1483   } {i1 t1 temp {}} |  1483   } {i1 t1 temp {}} | 
|  1484   do_test auth-1.225 { |  1484   do_test auth-1.225 { | 
|  1485     execsql {SELECT name FROM sqlite_temp_master} |  1485     execsql {SELECT name FROM temp.sqlite_master} | 
|  1486   } {t1 i1} |  1486   } {t1 i1} | 
|  1487   do_test auth-1.226 { |  1487   do_test auth-1.226 { | 
|  1488     proc auth {code arg1 arg2 arg3 arg4 args} { |  1488     proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1489       if {$code=="SQLITE_DROP_TEMP_INDEX"} { |  1489       if {$code=="SQLITE_DROP_TEMP_INDEX"} { | 
|  1490         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1490         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1491         return SQLITE_OK |  1491         return SQLITE_OK | 
|  1492       } |  1492       } | 
|  1493       return SQLITE_OK |  1493       return SQLITE_OK | 
|  1494     } |  1494     } | 
|  1495     catchsql {DROP INDEX i1} |  1495     catchsql {DROP INDEX i1} | 
|  1496   } {0 {}} |  1496   } {0 {}} | 
|  1497   do_test auth-1.227 { |  1497   do_test auth-1.227 { | 
|  1498     set ::authargs |  1498     set ::authargs | 
|  1499   } {i1 t1 temp {}} |  1499   } {i1 t1 temp {}} | 
|  1500   do_test auth-1.228 { |  1500   do_test auth-1.228 { | 
|  1501     execsql {SELECT name FROM sqlite_temp_master} |  1501     execsql {SELECT name FROM temp.sqlite_master} | 
|  1502   } {t1} |  1502   } {t1} | 
|  1503 } |  1503 } | 
|  1504  |  1504  | 
|  1505 do_test auth-1.229 { |  1505 do_test auth-1.229 { | 
|  1506   proc auth {code arg1 arg2 arg3 arg4 args} { |  1506   proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1507     if {$code=="SQLITE_PRAGMA"} { |  1507     if {$code=="SQLITE_PRAGMA"} { | 
|  1508       set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1508       set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1509       return SQLITE_DENY |  1509       return SQLITE_DENY | 
|  1510     } |  1510     } | 
|  1511     return SQLITE_OK |  1511     return SQLITE_OK | 
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1758             set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1758             set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1759             return SQLITE_IGNORE |  1759             return SQLITE_IGNORE | 
|  1760           } |  1760           } | 
|  1761           return SQLITE_OK |  1761           return SQLITE_OK | 
|  1762         } |  1762         } | 
|  1763         catchsql { |  1763         catchsql { | 
|  1764           ALTER TABLE t1x RENAME TO t1 |  1764           ALTER TABLE t1x RENAME TO t1 | 
|  1765         } |  1765         } | 
|  1766       } {0 {}} |  1766       } {0 {}} | 
|  1767       do_test auth-1.267 { |  1767       do_test auth-1.267 { | 
|  1768         execsql {SELECT name FROM sqlite_temp_master WHERE type='table'} |  1768         execsql {SELECT name FROM temp.sqlite_master WHERE type='table'} | 
|  1769       } {t1x} |  1769       } {t1x} | 
|  1770       do_test auth-1.268 { |  1770       do_test auth-1.268 { | 
|  1771         set authargs |  1771         set authargs | 
|  1772       } {temp t1x {} {}} |  1772       } {temp t1x {} {}} | 
|  1773       do_test auth-1.269 { |  1773       do_test auth-1.269 { | 
|  1774         proc auth {code arg1 arg2 arg3 arg4 args} { |  1774         proc auth {code arg1 arg2 arg3 arg4 args} { | 
|  1775           if {$code=="SQLITE_ALTER_TABLE"} { |  1775           if {$code=="SQLITE_ALTER_TABLE"} { | 
|  1776             set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  1776             set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  1777             return SQLITE_DENY |  1777             return SQLITE_DENY | 
|  1778           } |  1778           } | 
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2063         set ::authargs [list $arg1 $arg2 $arg3 $arg4] |  2063         set ::authargs [list $arg1 $arg2 $arg3 $arg4] | 
|  2064         return SQLITE_DENY |  2064         return SQLITE_DENY | 
|  2065       } |  2065       } | 
|  2066       return SQLITE_OK |  2066       return SQLITE_OK | 
|  2067     } |  2067     } | 
|  2068     catchsql { |  2068     catchsql { | 
|  2069       ALTER TABLE t5 ADD COLUMN new_col_3 |  2069       ALTER TABLE t5 ADD COLUMN new_col_3 | 
|  2070     } |  2070     } | 
|  2071   } {1 {not authorized}} |  2071   } {1 {not authorized}} | 
|  2072   do_test auth-1.307 { |  2072   do_test auth-1.307 { | 
|  2073     set x [execsql {SELECT sql FROM sqlite_temp_master WHERE type='t5'}] |  2073     set x [execsql {SELECT sql FROM temp.sqlite_master WHERE type='t5'}] | 
|  2074     regexp new_col_3 $x |  2074     regexp new_col_3 $x | 
|  2075   } {0} |  2075   } {0} | 
|  2076  |  2076  | 
|  2077   do_test auth-1.308 { |  2077   do_test auth-1.308 { | 
|  2078     set authargs |  2078     set authargs | 
|  2079   } {main t5 {} {}} |  2079   } {main t5 {} {}} | 
|  2080   execsql {DROP TABLE t5} |  2080   execsql {DROP TABLE t5} | 
|  2081 } ;# ifcapable altertable |  2081 } ;# ifcapable altertable | 
|  2082  |  2082  | 
|  2083 ifcapable {cte} { |  2083 ifcapable {cte} { | 
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2366   } else { |  2366   } else { | 
|  2367     ifcapable stat3 { |  2367     ifcapable stat3 { | 
|  2368       set stat4 "sqlite_stat3 " |  2368       set stat4 "sqlite_stat3 " | 
|  2369     } else { |  2369     } else { | 
|  2370       set stat4 "" |  2370       set stat4 "" | 
|  2371     } |  2371     } | 
|  2372   } |  2372   } | 
|  2373   do_test auth-5.2 { |  2373   do_test auth-5.2 { | 
|  2374     execsql { |  2374     execsql { | 
|  2375       SELECT name FROM ( |  2375       SELECT name FROM ( | 
|  2376         SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) |  2376         SELECT * FROM sqlite_master UNION ALL SELECT * FROM temp.sqlite_master) | 
|  2377       WHERE type='table' |  2377       WHERE type='table' | 
|  2378       ORDER BY name |  2378       ORDER BY name | 
|  2379     } |  2379     } | 
|  2380   } "sqlite_stat1 ${stat4}t1 t2 t3 t4" |  2380   } "sqlite_stat1 ${stat4}t1 t2 t3 t4" | 
|  2381 } |  2381 } | 
|  2382  |  2382  | 
|  2383 # Ticket #3944 |  2383 # Ticket #3944 | 
|  2384 # |  2384 # | 
|  2385 ifcapable trigger { |  2385 ifcapable trigger { | 
|  2386   do_test auth-5.3.1 { |  2386   do_test auth-5.3.1 { | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2425 do_test auth-6.2 { |  2425 do_test auth-6.2 { | 
|  2426   execsql {UPDATE t6 SET rowID=rowID+100} |  2426   execsql {UPDATE t6 SET rowID=rowID+100} | 
|  2427   set ::authargs |  2427   set ::authargs | 
|  2428 } [list SQLITE_READ   t6 ROWID main {} \ |  2428 } [list SQLITE_READ   t6 ROWID main {} \ | 
|  2429         SQLITE_UPDATE t6 ROWID main {} \ |  2429         SQLITE_UPDATE t6 ROWID main {} \ | 
|  2430 ] |  2430 ] | 
|  2431 do_test auth-6.3 { |  2431 do_test auth-6.3 { | 
|  2432   execsql {SELECT rowid, * FROM t6} |  2432   execsql {SELECT rowid, * FROM t6} | 
|  2433 } {101 1 2 3 4 5 6 7 8} |  2433 } {101 1 2 3 4 5 6 7 8} | 
|  2434  |  2434  | 
 |  2435 #------------------------------------------------------------------------- | 
 |  2436 # Test that view names are included as zArg4. | 
 |  2437 # | 
 |  2438 do_execsql_test auth-7.1 { | 
 |  2439   CREATE TABLE t7(a, b, c); | 
 |  2440   CREATE VIEW v7 AS SELECT * FROM t7; | 
 |  2441 } {} | 
 |  2442 set ::authargs [list] | 
 |  2443 proc auth {args} { | 
 |  2444   eval lappend ::authargs [lrange $args 0 4] | 
 |  2445   return SQLITE_OK | 
 |  2446 } | 
 |  2447  | 
 |  2448 do_test auth-7.2 { | 
 |  2449   execsql {SELECT a, c FROM v7} | 
 |  2450   set ::authargs | 
 |  2451 } [list                          \ | 
 |  2452   SQLITE_SELECT {} {} {} {}      \ | 
 |  2453   SQLITE_READ t7 a main v7       \ | 
 |  2454   SQLITE_READ t7 b main v7       \ | 
 |  2455   SQLITE_READ t7 c main v7       \ | 
 |  2456   SQLITE_READ v7 a main {}       \ | 
 |  2457   SQLITE_READ v7 c main {}       \ | 
 |  2458   SQLITE_SELECT {} {} {} v7      \ | 
 |  2459 ] | 
 |  2460  | 
 |  2461 set ::authargs [list] | 
 |  2462 do_test auth-7.3 { | 
 |  2463   execsql {SELECT a, c FROM t7} | 
 |  2464   set ::authargs | 
 |  2465 } [list                          \ | 
 |  2466   SQLITE_SELECT {} {} {} {}      \ | 
 |  2467   SQLITE_READ t7 a main {}       \ | 
 |  2468   SQLITE_READ t7 c main {}       \ | 
 |  2469 ] | 
 |  2470  | 
 |  2471 set ::authargs [list] | 
 |  2472 do_test auth-7.4 { | 
 |  2473   execsql {SELECT a, c FROM t7 AS v7} | 
 |  2474   set ::authargs | 
 |  2475 } [list                          \ | 
 |  2476   SQLITE_SELECT {} {} {} {}      \ | 
 |  2477   SQLITE_READ t7 a main {}       \ | 
 |  2478   SQLITE_READ t7 c main {}       \ | 
 |  2479 ] | 
 |  2480  | 
 |  2481  | 
|  2435 rename proc {} |  2482 rename proc {} | 
|  2436 rename proc_real proc |  2483 rename proc_real proc | 
|  2437  |  | 
|  2438  |  | 
|  2439 finish_test |  2484 finish_test | 
| OLD | NEW |