Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Typedefs | Functions | Variables

hashscan.c File Reference

#include "postgres.h"
#include "access/hash.h"
#include "access/relscan.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/resowner.h"
Include dependency graph for hashscan.c:

Go to the source code of this file.

Data Structures

struct  HashScanListData

Typedefs

typedef struct HashScanListData HashScanListData
typedef HashScanListDataHashScanList

Functions

void ReleaseResources_hash (void)
void _hash_regscan (IndexScanDesc scan)
void _hash_dropscan (IndexScanDesc scan)
bool _hash_has_active_scan (Relation rel, Bucket bucket)

Variables

static HashScanList HashScans = NULL

Typedef Documentation

Definition at line 42 of file hashscan.c.


Function Documentation

void _hash_dropscan ( IndexScanDesc  scan  ) 

Definition at line 109 of file hashscan.c.

References elog, ERROR, HashScanListData::hashsl_next, HashScanListData::hashsl_scan, NULL, and pfree().

Referenced by hashendscan().

{
    HashScanList chk,
                last;

    last = NULL;
    for (chk = HashScans;
         chk != NULL && chk->hashsl_scan != scan;
         chk = chk->hashsl_next)
        last = chk;

    if (chk == NULL)
        elog(ERROR, "hash scan list trashed; cannot find 0x%p", (void *) scan);

    if (last == NULL)
        HashScans = chk->hashsl_next;
    else
        last->hashsl_next = chk->hashsl_next;

    pfree(chk);
}

bool _hash_has_active_scan ( Relation  rel,
Bucket  bucket 
)
void _hash_regscan ( IndexScanDesc  scan  ) 
void ReleaseResources_hash ( void   ) 

Definition at line 53 of file hashscan.c.

References CurrentResourceOwner, HashScanListData::hashsl_next, HashScanListData::hashsl_owner, NULL, and pfree().

Referenced by ResourceOwnerReleaseInternal().

{
    HashScanList l;
    HashScanList prev;
    HashScanList next;

    /*
     * Release all HashScanList items belonging to the current ResourceOwner.
     * Note that we do not release the underlying IndexScanDesc; that's in
     * executor memory and will go away on its own (in fact quite possibly has
     * gone away already, so we mustn't try to touch it here).
     *
     * Note: this should be a no-op during normal query shutdown. However, in
     * an abort situation ExecutorEnd is not called and so there may be open
     * index scans to clean up.
     */
    prev = NULL;

    for (l = HashScans; l != NULL; l = next)
    {
        next = l->hashsl_next;
        if (l->hashsl_owner == CurrentResourceOwner)
        {
            if (prev == NULL)
                HashScans = next;
            else
                prev->hashsl_next = next;

            pfree(l);
            /* prev does not change */
        }
        else
            prev = l;
    }
}


Variable Documentation

HashScanList HashScans = NULL [static]

Definition at line 44 of file hashscan.c.