PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode& ec) { RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); if (ec) return 0; return openCursor(context, keyRange.release(), direction, ec); }
void QgsPostgresConn::deduceEndian() { // need to store the PostgreSQL endian format used in binary cursors // since it appears that starting with // version 7.4, binary cursors return data in XDR whereas previous versions // return data in the endian of the server QgsPostgresResult res = PQexec( "select regclass('pg_class')::oid" ); QString oidValue = res.PQgetvalue( 0, 0 ); QgsDebugMsg( "Creating binary cursor" ); // get the same value using a binary cursor openCursor( "oidcursor", "select regclass('pg_class')::oid" ); QgsDebugMsg( "Fetching a record and attempting to get check endian-ness" ); res = PQexec( "fetch forward 1 from oidcursor" ); mSwapEndian = true; if ( res.PQntuples() > 0 ) { // get the oid value from the binary cursor qint64 oid = getBinaryInt( res, 0, 0 ); QgsDebugMsg( QString( "Got oid of %1 from the binary cursor" ).arg( oid ) ); QgsDebugMsg( QString( "First oid is %1" ).arg( oidValue ) ); // compare the two oid values to determine if we need to do an endian swap if ( oid != oidValue.toLongLong() ) mSwapEndian = false; } closeCursor( "oidcursor" ); }
PassRefPtr<IDBRequest> IDBIndex::openCursor(ExecutionContext* context, const ScriptValue& range, const String& directionString, ExceptionState& exceptionState) { IDB_TRACE("IDBIndex::openCursor"); if (isDeleted()) { exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMessage); return 0; } if (m_transaction->isFinished()) { exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage); return 0; } if (!m_transaction->isActive()) { exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage); return 0; } IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, exceptionState); if (exceptionState.hadException()) return 0; RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, range, exceptionState); if (exceptionState.hadException()) return 0; return openCursor(context, keyRange.release(), direction); }
IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& name, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState& exceptionState) { IDB_TRACE("IDBObjectStore::createIndex"); if (!m_transaction->isVersionChange()) { exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTransactionErrorMessage); return nullptr; } if (isDeleted()) { exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectStoreDeletedErrorMessage); return nullptr; } if (m_transaction->isFinished() || m_transaction->isFinishing()) { exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage); return nullptr; } if (!m_transaction->isActive()) { exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage); return nullptr; } if (!keyPath.isValid()) { exceptionState.throwDOMException(SyntaxError, "The keyPath argument contains an invalid key path."); return nullptr; } if (containsIndex(name)) { exceptionState.throwDOMException(ConstraintError, "An index with the specified name already exists."); return nullptr; } if (keyPath.type() == IDBKeyPath::ArrayType && options.multiEntry()) { exceptionState.throwDOMException(InvalidAccessError, "The keyPath argument was an array and the multiEntry option is true."); return nullptr; } if (!backendDB()) { exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage); return nullptr; } int64_t indexId = m_metadata.maxIndexId + 1; backendDB()->createIndex(m_transaction->id(), id(), indexId, name, keyPath, options.unique(), options.multiEntry()); ++m_metadata.maxIndexId; IDBIndexMetadata metadata(name, indexId, keyPath, options.unique(), options.multiEntry()); IDBIndex* index = IDBIndex::create(metadata, this, m_transaction.get()); m_indexMap.set(name, index); m_metadata.indexes.set(indexId, metadata); m_transaction->db()->indexCreated(id(), metadata); ASSERT(!exceptionState.hadException()); if (exceptionState.hadException()) return nullptr; IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDirectionNext, WebIDBTaskTypePreemptive); indexRequest->preventPropagation(); // This is kept alive by being the success handler of the request, which is in turn kept alive by the owning transaction. RefPtrWillBeRawPtr<IndexPopulator> indexPopulator = IndexPopulator::create(scriptState, transaction()->db(), m_transaction->id(), id(), metadata); indexRequest->setOnsuccess(indexPopulator); return index; }
IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& range, const String& directionString, ExceptionState& exceptionState) { IDB_TRACE("IDBIndex::openCursor"); if (isDeleted()) { exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMessage); return nullptr; } if (m_transaction->isFinished() || m_transaction->isFinishing()) { exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage); return nullptr; } if (!m_transaction->isActive()) { exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage); return nullptr; } WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionString); IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecutionContext(), range, exceptionState); if (exceptionState.hadException()) return nullptr; if (!backendDB()) { exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage); return nullptr; } return openCursor(scriptState, keyRange, direction); }
FB::JSOutObject IndexSync::openObjectCursor(const FB::CatchAll& args) { const FB::VariantList& values = args.value; if(values.size() > 2) throw FB::invalid_arguments(); else if(values.size() >= 1 && (!values[0].is_of_type<FB::JSObject>() || !values[0].cast<FB::JSObject>()->HasProperty("left") || !values[0].cast<FB::JSObject>()->HasProperty("right") || !values[0].cast<FB::JSObject>()->HasProperty("flags") || !values[0].cast<FB::JSObject>()->GetProperty("flags").is_of_type<int>())) throw FB::invalid_arguments(); else if(values.size() == 2 && !values[1].is_of_type<int>()) throw FB::invalid_arguments(); optional<KeyRange> range = values.size() >= 1 ? KeyRange(values[0].cast<FB::JSObject>()->GetProperty("left"), values[0].cast<FB::JSObject>()->GetProperty("right"), values[0].cast<FB::JSObject>()->GetProperty("flags").cast<int>()) : optional<KeyRange>(); const Cursor::Direction direction = values.size() == 2 ? static_cast<Cursor::Direction>(values[1].cast<int>()) : Cursor::NEXT; return static_cast<FB::JSOutObject>(openCursor(range, direction, false)); }
RefPtr<IDBRequest> LegacyIndex::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode& ec) { LOG(StorageAPI, "LegacyIndex::openCursor"); RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); if (ec) return 0; return openCursor(context, keyRange.get(), direction, ec); }
PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, const String& direction, ExceptionCode& ec) { IDB_TRACE("IDBIndex::openCursor"); RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(key, ec); if (ec) return 0; return openCursor(context, keyRange.release(), direction, ec); }
PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, unsigned short direction, ExceptionCode& ec) { IDB_TRACE("IDBObjectStore::openCursor"); RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(key, ec); if (ec) return 0; return openCursor(context, keyRange.release(), direction, ec); }
RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode& ec) { LOG(IndexedDB, "IDBIndex::openCursor"); RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); if (ec) return nullptr; return openCursor(context, keyRange.get(), direction, ec); }
PassRefPtr<IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext* context, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, ExceptionCode& ec) { IDB_TRACE("IDBObjectStore::createIndex"); if (!m_transaction->isVersionChange() || isDeleted()) { ec = IDBDatabaseException::InvalidStateError; return 0; } if (!m_transaction->isActive()) { ec = IDBDatabaseException::TransactionInactiveError; return 0; } if (!keyPath.isValid()) { ec = IDBDatabaseException::SyntaxError; return 0; } if (name.isNull()) { ec = TypeError; return 0; } if (containsIndex(name)) { ec = IDBDatabaseException::ConstraintError; return 0; } if (keyPath.type() == IDBKeyPath::ArrayType && multiEntry) { ec = IDBDatabaseException::InvalidAccessError; return 0; } int64_t indexId = m_metadata.maxIndexId + 1; backendDB()->createIndex(m_transaction->id(), id(), indexId, name, keyPath, unique, multiEntry); ++m_metadata.maxIndexId; IDBIndexMetadata metadata(name, indexId, keyPath, unique, multiEntry); RefPtr<IDBIndex> index = IDBIndex::create(metadata, this, m_transaction.get()); m_indexMap.set(name, index); m_metadata.indexes.set(indexId, metadata); m_transaction->db()->indexCreated(id(), metadata); ASSERT(!ec); if (ec) return 0; RefPtr<IDBRequest> indexRequest = openCursor(context, static_cast<IDBKeyRange*>(0), IDBCursor::directionNext(), IDBDatabaseBackendInterface::PreemptiveTask, ec); ASSERT(!ec); if (ec) return 0; indexRequest->preventPropagation(); // This is kept alive by being the success handler of the request, which is in turn kept alive by the owning transaction. RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(backendDB(), m_transaction->id(), id(), metadata); indexRequest->setOnsuccess(indexPopulator); return index.release(); }
PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> range, unsigned short direction, ExceptionCode& ec) { IDB_TRACE("IDBObjectStore::openCursor"); DEFINE_STATIC_LOCAL(String, consoleMessage, ("Numeric direction values are deprecated in IDBObjectStore.openCursor. Use\"next\", \"nextunique\", \"prev\", or \"prevunique\".")); context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, consoleMessage); const String& directionString = IDBCursor::directionToString(direction, ec); if (ec) return 0; return openCursor(context, range, directionString, ec); }
RefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, JSValue key, const String& direction, ExceptionCodeWithMessage& ec) { RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code); if (ec.code) { ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The parameter is not a valid key."); return 0; } return openCursor(context, keyRange.get(), direction, ec); }
void IDBServer::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info) { LOG(IndexedDB, "IDBServer::openCursor"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->openCursor(requestData, info); }
ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, JSValue key, const String& direction) { LOG(IndexedDB, "IDBIndex::openCursor"); ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID()); auto keyRange = IDBKeyRange::only(execState, key); if (keyRange.hasException()) return Exception { IDBDatabaseException::DataError, ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The parameter is not a valid key.") }; return openCursor(execState, keyRange.releaseReturnValue().ptr(), direction); }
RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBIndex::openCursor"); RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code); if (ec.code) { ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The parameter is not a valid key."); return nullptr; } return openCursor(context, keyRange.get(), direction, ec); }
PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); }
RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, ExceptionCodeWithMessage& ec) { return openCursor(context, static_cast<IDBKeyRange*>(nullptr), ec); }
PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> range, const String& direction, ExceptionCode& ec) { return openCursor(context, range, direction, IDBDatabaseBackend::NormalTask, ec); }
PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec) { return openCursor(context, key, IDBCursor::directionNext(), ec); }
RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); }
PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, static_cast<IDBKeyRange*>(0), ec); }