void RingoShadowFetch::prepareExact (OracleEnv &env, int right_part) { RingoExact & instance = _context.exact; if (right_part == 1) env.dbgPrintf("preparing shadow table for exact\n"); else env.dbgPrintf("preparing shadow table for non-exact\n"); _fetch_type = _EXACT; _right_part = right_part; _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _lob_crf.reset(new OracleLOB(_env.ref())); _statement->append("SELECT sh.rid, sh.crf FROM %s sh", _table_name.ptr()); if (right_part == 1) _statement->append(" WHERE hash = :hash"); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_crf.ref()); if (_right_part == 1) { const char *hash_str = instance.getQueryHashStr(); _statement->bindStringByName(":hash", hash_str, strlen(hash_str) + 1); } ArrayOutput output_cnt(_counting_select); output_cnt.printf("SELECT COUNT(*) FROM %s sh", _table_name.ptr()); if (right_part == 1) output_cnt.printf(" WHERE hash = :hash"); }
void MangoShadowFetch::prepareExact (OracleEnv &env, int right_part) { const MangoExact & instance = _context.exact; if (right_part == 1) env.dbgPrintf("preparing shadow table for exact\n"); else env.dbgPrintf("preparing shadow table for non-exact\n"); _fetch_type = _EXACT; _right_part = right_part; _need_xyz = instance.needCoords(); _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _lob_cmf.reset(new OracleLOB(_env.ref())); _statement->append("SELECT sh.mol_rowid, sh.cmf"); if (_need_xyz) _statement->append(", sh.xyz", _table_name.ptr()); _statement->append(" FROM %s sh", _table_name.ptr()); QS_DEF(Array<char>, table_copies); QS_DEF(Array<char>, where_clause); _prepareExactQueryStrings(table_copies, where_clause); _statement->append(table_copies.ptr()); _statement->append(where_clause.ptr()); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_cmf.ref()); if (_need_xyz) { _lob_xyz.reset(new OracleLOB(_env.ref())); _statement->defineBlobByPos(3, _lob_xyz.ref()); } ArrayOutput output_cnt(_counting_select); output_cnt.printf("SELECT COUNT(*) FROM %s sh", _table_name.ptr()); output_cnt.printf("%s", table_copies.ptr()); output_cnt.printf("%s", where_clause.ptr()); }