Bug 583847 - Weave should be using createAsyncStatement instead of createStatement [r=mconnor]

This commit is contained in:
Philipp von Weitershausen 2010-08-09 18:38:18 +02:00
Родитель 5a745d9fdb
Коммит 76e998252a
4 изменённых файлов: 20 добавлений и 13 удалений

Просмотреть файл

@ -851,10 +851,12 @@ BookmarksStore.prototype = {
get _frecencyStm() {
if (!this.__frecencyStm) {
this._log.trace("Creating SQL statement: _frecencyStm");
this.__frecencyStm = Svc.History.DBConnection.createStatement(
this.__frecencyStm = Utils.createStatement(
Svc.History.DBConnection,
"SELECT frecency " +
"FROM moz_places " +
"WHERE url = :url");
"WHERE url = :url " +
"LIMIT 1");
}
return this.__frecencyStm;
},
@ -868,14 +870,10 @@ BookmarksStore.prototype = {
// Add in the bookmark's frecency if we have something
if (record.bmkUri != null) {
try {
this._frecencyStm.params.url = record.bmkUri;
if (this._frecencyStm.step())
index += this._frecencyStm.row.frecency;
}
finally {
this._frecencyStm.reset();
}
this._frecencyStm.params.url = record.bmkUri;
let result = Utils.queryAsync(this._frecencyStm, ["frecency"]);
if (result.length)
index += result.frecency;
}
return index;

Просмотреть файл

@ -110,7 +110,7 @@ let FormWrapper = {
createStatement: function createStatement(query) {
try {
// Just return the statement right away if it's okay
return Svc.Form.DBConnection.createStatement(query);
return Utils.createStatement(Svc.Form.DBConnection, query);
}
catch(ex) {
// Assume guid column must not exist yet, so add it with an index
@ -121,7 +121,7 @@ let FormWrapper = {
"ON moz_formhistory (guid)");
// Try creating the query now that the column exists
return Svc.Form.DBConnection.createStatement(query);
return Utils.createStatement(Svc.Form.DBConnection, query);
}
}
};

Просмотреть файл

@ -119,7 +119,7 @@ HistoryStore.prototype = {
return this._stmts[query];
this._log.trace("Creating SQL statement: " + query);
return this._stmts[query] = this._db.createStatement(query);
return this._stmts[query] = Utils.createStatement(this._db, query);
},
get _haveTempTablesStm() {

Просмотреть файл

@ -146,6 +146,15 @@ let Utils = {
throw batchEx;
};
},
createStatement: function createStatement(db, query) {
// Gecko 2.0
if (db.createAsyncStatement)
return db.createAsyncStatement(query);
// Gecko <2.0
return db.createStatement(query);
},
queryAsync: function(query, names) {
// Allow array of names, single name, and no name