void IDBObjectStoreBackendImpl::deleteInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks) { SQLiteStatement idQuery(objectStore->sqliteDatabase(), "SELECT id FROM ObjectStoreData " + whereClause(key.get())); bool ok = idQuery.prepare() == SQLResultOk; ASSERT_UNUSED(ok, ok); // FIXME: Better error handling? bindWhereClause(idQuery, objectStore->id(), key.get()); if (idQuery.step() != SQLResultRow) { callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the object store.")); return; } int64_t id = idQuery.getColumnInt64(0); SQLiteStatement osQuery(objectStore->sqliteDatabase(), "DELETE FROM ObjectStoreData WHERE id = ?"); ok = osQuery.prepare() == SQLResultOk; ASSERT_UNUSED(ok, ok); // FIXME: Better error handling? osQuery.bindInt64(1, id); ok = osQuery.step() == SQLResultDone; ASSERT_UNUSED(ok, ok); SQLiteStatement indexQuery(objectStore->sqliteDatabase(), "DELETE FROM IndexData WHERE objectStoreDataId = ?"); ok = indexQuery.prepare() == SQLResultOk; ASSERT_UNUSED(ok, ok); // FIXME: Better error handling? indexQuery.bindInt64(1, id); ok = indexQuery.step() == SQLResultDone; ASSERT_UNUSED(ok, ok); callbacks->onSuccess(); }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializeQuery // // @doc: // Verifies that after parsing the given DXL file into a DXL tree // representing a query, it will be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializeQuery ( IMemoryPool *pmp, const CHAR *szDXLFileName, BOOL fValidate ) { CWStringDynamic str(pmp); COstreamString oss(&str); // read DXL file CHAR *szDXL = CDXLUtils::SzRead(pmp, szDXLFileName); const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } // the root of the parsed DXL tree CQueryToDXLResult *pq2dxlresult = CDXLUtils::PdxlnParseDXLQuery(pmp, szDXL, szValidationPath); GPOS_ASSERT(NULL != pq2dxlresult); oss << "Serializing parsed tree" << std::endl; CDXLNode *pdxlnRoot = const_cast<CDXLNode *>(pq2dxlresult->Pdxln()); DrgPdxln* pdrgpdxln = const_cast<DrgPdxln* >(pq2dxlresult->PdrgpdxlnOutputCols()); DrgPdxln* pdrgpdxlnCTE = const_cast<DrgPdxln* >(pq2dxlresult->PdrgpdxlnCTE()); CWStringDynamic wstrQuery(pmp); COstreamString osQuery(&wstrQuery); CDXLUtils::SerializeQuery(pmp, osQuery, pdxlnRoot, pdrgpdxln, pdrgpdxlnCTE, true /*fSerializeHeaderFooter*/, true /*fIndent*/); CWStringDynamic dstrExpected(pmp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), szDXL); if (!dstrExpected.FEquals(&wstrQuery)) { GPOS_TRACE(wstrQuery.Wsz()); } // cleanup GPOS_DELETE(pq2dxlresult); GPOS_DELETE_ARRAY(szDXL); return GPOS_OK; }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializeQuery // // @doc: // Verifies that after parsing the given DXL file into a DXL tree // representing a query, it will be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializeQuery ( IMemoryPool *mp, const CHAR *dxl_filename, BOOL fValidate ) { CWStringDynamic str(mp); COstreamString oss(&str); // read DXL file CHAR *dxl_string = CDXLUtils::Read(mp, dxl_filename); const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } // the root of the parsed DXL tree CQueryToDXLResult *pq2dxlresult = CDXLUtils::ParseQueryToQueryDXLTree(mp, dxl_string, szValidationPath); GPOS_ASSERT(NULL != pq2dxlresult); oss << "Serializing parsed tree" << std::endl; CDXLNode *root_dxlnode = const_cast<CDXLNode *>(pq2dxlresult->CreateDXLNode()); CDXLNodeArray* dxl_array = const_cast<CDXLNodeArray* >(pq2dxlresult->GetOutputColumnsDXLArray()); CDXLNodeArray* cte_producers = const_cast<CDXLNodeArray* >(pq2dxlresult->GetCTEProducerDXLArray()); CWStringDynamic wstrQuery(mp); COstreamString osQuery(&wstrQuery); CDXLUtils::SerializeQuery(mp, osQuery, root_dxlnode, dxl_array, cte_producers, true /*serialize_header_footer*/, true /*indentation*/); CWStringDynamic dstrExpected(mp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), dxl_string); if (!dstrExpected.Equals(&wstrQuery)) { GPOS_TRACE(wstrQuery.GetBuffer()); } // cleanup GPOS_DELETE(pq2dxlresult); GPOS_DELETE_ARRAY(dxl_string); return GPOS_OK; }