* Fetch the tuple from the block indicated by the block directory entry that * covers the tuple. */
| 2166 | * covers the tuple. |
| 2167 | */ |
| 2168 | static void |
| 2169 | fetchFromCurrentBlock(AppendOnlyFetchDesc aoFetchDesc, |
| 2170 | int64 rowNum, |
| 2171 | TupleTableSlot *slot) |
| 2172 | { |
| 2173 | bool fetched; |
| 2174 | AOFetchBlockMetadata *currentBlock = &aoFetchDesc->currentBlock; |
| 2175 | AppendOnlyExecutorReadBlock *executorReadBlock = &aoFetchDesc->executorReadBlock; |
| 2176 | AppendOnlyBlockDirectoryEntry *entry = ¤tBlock->blockDirectoryEntry; |
| 2177 | |
| 2178 | if (!currentBlock->gotContents) |
| 2179 | { |
| 2180 | /* |
| 2181 | * Do decompression if necessary and get contents. |
| 2182 | */ |
| 2183 | AppendOnlyExecutorReadBlock_GetContents(executorReadBlock); |
| 2184 | |
| 2185 | currentBlock->gotContents = true; |
| 2186 | } |
| 2187 | |
| 2188 | fetched = AppendOnlyExecutorReadBlock_FetchTuple(executorReadBlock, |
| 2189 | rowNum, |
| 2190 | /* nkeys */ 0, |
| 2191 | /* key */ NULL, |
| 2192 | slot); |
| 2193 | if (!fetched) |
| 2194 | { |
| 2195 | if (AppendOnlyBlockDirectoryEntry_RangeHasRow(entry, rowNum)) |
| 2196 | { |
| 2197 | /* |
| 2198 | * We fell into a hole inside the resolved block directory entry |
| 2199 | * we obtained from AppendOnlyBlockDirectory_GetEntry(). |
| 2200 | * This should not be happening for versions >= CB2. Scream |
| 2201 | * appropriately. See AppendOnlyBlockDirectoryEntry for details. |
| 2202 | */ |
| 2203 | ereportif(AORelationVersion_Get(aoFetchDesc->relation) >= AORelationVersion_CB2, |
| 2204 | ERROR, |
| 2205 | (errcode(ERRCODE_INTERNAL_ERROR), |
| 2206 | errmsg("tuple with row number %ld not found in block directory entry range", rowNum), |
| 2207 | errdetail("block directory entry: (fileOffset = %ld, firstRowNum = %ld, " |
| 2208 | "afterFileOffset = %ld, lastRowNum = %ld)", |
| 2209 | entry->range.fileOffset, |
| 2210 | entry->range.firstRowNum, |
| 2211 | entry->range.afterFileOffset, |
| 2212 | entry->range.lastRowNum))); |
| 2213 | } |
| 2214 | else |
| 2215 | { |
| 2216 | /* |
| 2217 | * The resolved block directory entry we obtained from |
| 2218 | * AppendOnlyBlockDirectory_GetEntry() has range s.t. |
| 2219 | * firstRowNum < lastRowNum < rowNum |
| 2220 | * This can happen when rowNum maps to an aborted transaction, and |
| 2221 | * we find an earlier committed block directory row due to the |
| 2222 | * <= scan condition in AppendOnlyBlockDirectory_GetEntry(). |
| 2223 | */ |
| 2224 | } |
| 2225 | } |
no test coverage detected