Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: sql/sqlite_features_unittest.cc

Issue 2440653002: [sql] Verify regexp not cached with prepared statement. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 base::File f(db_path(), kFlags); 263 base::File f(db_path(), kFlags);
264 ASSERT_TRUE(f.IsValid()); 264 ASSERT_TRUE(f.IsValid());
265 buf[0] = '4'; 265 buf[0] = '4';
266 ASSERT_EQ(f.Write(kOffset, buf, 1), 1); 266 ASSERT_EQ(f.Write(kOffset, buf, 1), 1);
267 } 267 }
268 ASSERT_EQ('4', m.data()[kOffset]); 268 ASSERT_EQ('4', m.data()[kOffset]);
269 } 269 }
270 } 270 }
271 #endif 271 #endif
272 272
273 // Verify that http://crbug.com/248608 is fixed. In this bug, the
274 // compiled regular expression is effectively cached with the prepared
275 // statement, causing errors if the regular expression is rebound.
276 TEST_F(SQLiteFeaturesTest, CachedRegexp) {
277 ASSERT_TRUE(db().Execute("CREATE TABLE r (id INTEGER UNIQUE, x TEXT)"));
278 ASSERT_TRUE(db().Execute("INSERT INTO r VALUES (1, 'this is a test')"));
279 ASSERT_TRUE(db().Execute("INSERT INTO r VALUES (2, 'that was a test')"));
280 ASSERT_TRUE(db().Execute("INSERT INTO r VALUES (3, 'this is a stickup')"));
281 ASSERT_TRUE(db().Execute("INSERT INTO r VALUES (4, 'that sucks')"));
282
283 const char* kSimpleSql = "SELECT SUM(id) FROM r WHERE x REGEXP ?";
284 sql::Statement s(db().GetCachedStatement(SQL_FROM_HERE, kSimpleSql));
285
286 s.BindString(0, "this.*");
287 ASSERT_TRUE(s.Step());
288 EXPECT_EQ(4, s.ColumnInt(0));
289
290 s.Reset(true);
291 s.BindString(0, "that.*");
292 ASSERT_TRUE(s.Step());
293 EXPECT_EQ(6, s.ColumnInt(0));
294
295 s.Reset(true);
296 s.BindString(0, ".*test");
297 ASSERT_TRUE(s.Step());
298 EXPECT_EQ(3, s.ColumnInt(0));
299
300 s.Reset(true);
301 s.BindString(0, ".* s[a-z]+");
302 ASSERT_TRUE(s.Step());
303 EXPECT_EQ(7, s.ColumnInt(0));
304 }
305
273 } // namespace 306 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698