| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 namespace WebCore { | 43 namespace WebCore { |
| 44 | 44 |
| 45 SQLStatementSync::SQLStatementSync(const String& statement, const Vector<SQLValu
e>& arguments, int permissions) | 45 SQLStatementSync::SQLStatementSync(const String& statement, const Vector<SQLValu
e>& arguments, int permissions) |
| 46 : m_statement(statement) | 46 : m_statement(statement) |
| 47 , m_arguments(arguments) | 47 , m_arguments(arguments) |
| 48 , m_permissions(permissions) | 48 , m_permissions(permissions) |
| 49 { | 49 { |
| 50 ASSERT(!m_statement.isEmpty()); | 50 ASSERT(!m_statement.isEmpty()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 PassRefPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db, ExceptionSt
ate& exceptionState) | 53 PassRefPtrWillBeRawPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db,
ExceptionState& exceptionState) |
| 54 { | 54 { |
| 55 db->setAuthorizerPermissions(m_permissions); | 55 db->setAuthorizerPermissions(m_permissions); |
| 56 | 56 |
| 57 SQLiteDatabase* database = &db->sqliteDatabase(); | 57 SQLiteDatabase* database = &db->sqliteDatabase(); |
| 58 | 58 |
| 59 SQLiteStatement statement(*database, m_statement); | 59 SQLiteStatement statement(*database, m_statement); |
| 60 int result = statement.prepare(); | 60 int result = statement.prepare(); |
| 61 if (result != SQLResultOk) { | 61 if (result != SQLResultOk) { |
| 62 if (result == SQLResultInterrupt) | 62 if (result == SQLResultInterrupt) |
| 63 exceptionState.throwDOMException(SQLDatabaseError, "Connection to th
e database interrupted."); | 63 exceptionState.throwDOMException(SQLDatabaseError, "Connection to th
e database interrupted."); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 84 return nullptr; | 84 return nullptr; |
| 85 } | 85 } |
| 86 | 86 |
| 87 if (result != SQLResultOk) { | 87 if (result != SQLResultOk) { |
| 88 exceptionState.throwDOMException(SQLDatabaseError, "Could not bind v
alue."); | 88 exceptionState.throwDOMException(SQLDatabaseError, "Could not bind v
alue."); |
| 89 db->setLastErrorMessage("could not bind value", result, database->la
stErrorMsg()); | 89 db->setLastErrorMessage("could not bind value", result, database->la
stErrorMsg()); |
| 90 return nullptr; | 90 return nullptr; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 RefPtr<SQLResultSet> resultSet = SQLResultSet::create(); | 94 RefPtrWillBeRawPtr<SQLResultSet> resultSet = SQLResultSet::create(); |
| 95 | 95 |
| 96 // Step so we can fetch the column names. | 96 // Step so we can fetch the column names. |
| 97 result = statement.step(); | 97 result = statement.step(); |
| 98 if (result == SQLResultRow) { | 98 if (result == SQLResultRow) { |
| 99 int columnCount = statement.columnCount(); | 99 int columnCount = statement.columnCount(); |
| 100 SQLResultSetRowList* rows = resultSet->rows(); | 100 SQLResultSetRowList* rows = resultSet->rows(); |
| 101 | 101 |
| 102 for (int i = 0; i < columnCount; i++) | 102 for (int i = 0; i < columnCount; i++) |
| 103 rows->addColumn(statement.getColumnName(i)); | 103 rows->addColumn(statement.getColumnName(i)); |
| 104 | 104 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 127 exceptionState.throwDOMException(ConstraintError, "A constraint was viol
ated."); | 127 exceptionState.throwDOMException(ConstraintError, "A constraint was viol
ated."); |
| 128 db->setLastErrorMessage("statement failed due to a constraint failure"); | 128 db->setLastErrorMessage("statement failed due to a constraint failure"); |
| 129 return nullptr; | 129 return nullptr; |
| 130 } else { | 130 } else { |
| 131 exceptionState.throwDOMException(SQLDatabaseError, "Could not execute st
atement."); | 131 exceptionState.throwDOMException(SQLDatabaseError, "Could not execute st
atement."); |
| 132 db->setLastErrorMessage("could not execute statement", result, database-
>lastErrorMsg()); | 132 db->setLastErrorMessage("could not execute statement", result, database-
>lastErrorMsg()); |
| 133 return nullptr; | 133 return nullptr; |
| 134 } | 134 } |
| 135 | 135 |
| 136 resultSet->setRowsAffected(database->lastChanges()); | 136 resultSet->setRowsAffected(database->lastChanges()); |
| 137 resultSet->setValid(); |
| 137 return resultSet.release(); | 138 return resultSet.release(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace WebCore | 141 } // namespace WebCore |
| OLD | NEW |