/* ---------------- * index_endscan - end a scan * ---------------- */ void index_endscan(IndexScanDesc scan) { SCAN_CHECKS; CHECK_SCAN_PROCEDURE(amendscan); /* Release any held pin on a heap page */ if (BufferIsValid(scan->xs_cbuf)) { ReleaseBuffer(scan->xs_cbuf); scan->xs_cbuf = InvalidBuffer; } /* End the AM's scan */ scan->indexRelation->rd_amroutine->amendscan(scan); /* Release index refcount acquired by index_beginscan */ RelationDecrementReferenceCount(scan->indexRelation); if (scan->xs_temp_snap) UnregisterSnapshot(scan->xs_snapshot); /* Release the scan data structure itself */ IndexScanEnd(scan); }
/* * ConditionalLockRelation * * As above, but only lock if we can get the lock without blocking. * Returns TRUE iff the lock was acquired. * * NOTE: we do not currently need conditional versions of all the * LockXXX routines in this file, but they could easily be added if needed. */ bool ConditionalLockRelation(Relation relation, LOCKMODE lockmode) { LOCKTAG tag; MemSet(&tag, 0, sizeof(tag)); tag.relId = relation->rd_lockInfo.lockRelId.relId; tag.dbId = relation->rd_lockInfo.lockRelId.dbId; tag.objId.blkno = InvalidBlockNumber; if (!LockAcquire(LockTableId, &tag, GetCurrentTransactionId(), lockmode, true)) return false; /* * Check to see if the relcache entry has been invalidated while we * were waiting to lock it. If so, rebuild it, or ereport() trying. * Increment the refcount to ensure that RelationFlushRelation will * rebuild it and not just delete it. */ RelationIncrementReferenceCount(relation); AcceptInvalidationMessages(); RelationDecrementReferenceCount(relation); return true; }
/* ---------------- * index_endscan - end a scan * ---------------- */ void index_endscan(IndexScanDesc scan) { RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(endscan, amendscan); /* Release any held pin on a heap page */ if (BufferIsValid(scan->xs_cbuf)) { ReleaseBuffer(scan->xs_cbuf); scan->xs_cbuf = InvalidBuffer; } /* End the AM's scan */ OidFunctionCall1(procedure, PointerGetDatum(scan)); /* Release index lock and refcount acquired by index_beginscan */ UnlockRelation(scan->indexRelation, AccessShareLock); RelationDecrementReferenceCount(scan->indexRelation); /* Release the scan data structure itself */ IndexScanEnd(scan); }
void parquet_endscan(ParquetScanDesc scan) { ParquetRowGroupReader rowGroupReader = scan->rowGroupReader; RelationDecrementReferenceCount(scan->pqs_rd); CloseScannedFileSeg(scan); MemoryContext oldContext = MemoryContextSwitchTo(scan->parquetScanInitContext); /* Free the column readers information*/ if(rowGroupReader.columnReaders != NULL) { for (int i = 0; i < rowGroupReader.columnReaderCount; ++i) { ParquetColumnReader *reader = &rowGroupReader.columnReaders[i]; if (reader->dataBuffer != NULL) { pfree(reader->dataBuffer); } if (reader->pageBuffer != NULL) { pfree(reader->pageBuffer); } if (reader->geoval != NULL) { pfree(reader->geoval); } if (reader->columnMetadata != NULL) { pfree(reader->columnMetadata); } } pfree(rowGroupReader.columnReaders); } if(scan->hawqAttrToParquetColChunks != NULL){ pfree(scan->hawqAttrToParquetColChunks); } if(scan->aoEntry != NULL){ pfree(scan->aoEntry); } ParquetStorageRead_FinishSession(&(scan->storageRead)); MemoryContextSwitchTo(oldContext); }