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

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

@ -110,7 +110,7 @@ let FormWrapper = {
createStatement: function createStatement(query) { createStatement: function createStatement(query) {
try { try {
// Just return the statement right away if it's okay // 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) { catch(ex) {
// Assume guid column must not exist yet, so add it with an index // Assume guid column must not exist yet, so add it with an index
@ -121,7 +121,7 @@ let FormWrapper = {
"ON moz_formhistory (guid)"); "ON moz_formhistory (guid)");
// Try creating the query now that the column exists // 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]; return this._stmts[query];
this._log.trace("Creating SQL statement: " + 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() { get _haveTempTablesStm() {

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

@ -147,6 +147,15 @@ let Utils = {
}; };
}, },
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) { queryAsync: function(query, names) {
// Allow array of names, single name, and no name // Allow array of names, single name, and no name
if (!Utils.isArray(names)) if (!Utils.isArray(names))