* Open the next file segment to scan and allocate all resources needed for it. */
| 139 | * Open the next file segment to scan and allocate all resources needed for it. |
| 140 | */ |
| 141 | bool |
| 142 | SetNextFileSegForRead(AppendOnlyScanDesc scan) |
| 143 | { |
| 144 | Relation reln = scan->aos_rd; |
| 145 | int segno = -1; |
| 146 | int64 eof = 0; |
| 147 | int formatversion = -2; /* some invalid value */ |
| 148 | bool finished_all_files = true; /* assume */ |
| 149 | int32 fileSegNo; |
| 150 | bool isParallel = false; |
| 151 | ParallelBlockTableScanDesc pbscan = NULL; |
| 152 | |
| 153 | if (scan->rs_base.rs_parallel != NULL) |
| 154 | { |
| 155 | isParallel = true; |
| 156 | pbscan = (ParallelBlockTableScanDesc) scan->rs_base.rs_parallel; |
| 157 | } |
| 158 | |
| 159 | |
| 160 | Assert(scan->aos_need_new_segfile); /* only call me when last segfile |
| 161 | * completed */ |
| 162 | Assert(!scan->aos_done_all_segfiles); /* don't call me if I told you to |
| 163 | * stop */ |
| 164 | |
| 165 | |
| 166 | if (!scan->initedStorageRoutines) |
| 167 | { |
| 168 | PGFunction *fns = NULL; |
| 169 | RelationOpenSmgr(reln); |
| 170 | |
| 171 | AppendOnlyStorageRead_Init( |
| 172 | &scan->storageRead, |
| 173 | scan->aoScanInitContext, |
| 174 | scan->usableBlockSize, |
| 175 | NameStr(scan->aos_rd->rd_rel->relname), |
| 176 | RelationGetRelid(scan->aos_rd), |
| 177 | scan->title, |
| 178 | &scan->storageAttributes, |
| 179 | &scan->aos_rd->rd_node, reln->rd_smgr->smgr_ao); |
| 180 | |
| 181 | /* |
| 182 | * There is no guarantee that the current memory context will be |
| 183 | * preserved between calls, so switch to a safe memory context for |
| 184 | * retrieving compression information. |
| 185 | */ |
| 186 | MemoryContext oldMemoryContext = MemoryContextSwitchTo(scan->aoScanInitContext); |
| 187 | |
| 188 | /* Get the relation specific compression functions */ |
| 189 | |
| 190 | fns = get_funcs_for_compression(scan->storageAttributes.compressType); |
| 191 | scan->storageRead.compression_functions = fns; |
| 192 | |
| 193 | if (scan->storageRead.compression_functions != NULL) |
| 194 | { |
| 195 | PGFunction cons = fns[COMPRESSION_CONSTRUCTOR]; |
| 196 | CompressionState *cs; |
| 197 | StorageAttributes sa; |
| 198 |
no test coverage detected