8000 Inline frequently called functions. · postgrespro/postgres_cluster@8cb4154 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8cb4154

Browse files
committed
Inline frequently called functions.
1 parent bbe2c10 commit 8cb4154

File tree

16 files changed

+1098
-793
lines changed
  • lmgr
  • utils/cache
  • include
  • 16 files changed

    +1098
    -793
    lines changed

    src/backend/access/common/heapvalid.c

    Lines changed: 1 addition & 129 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,143 +7,15 @@
    77
    *
    88
    *
    99
    * IDENTIFICATION
    10-
    * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.19 1997/09/12 04:07:09 momjian Exp $
    10+
    * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.20 1997/09/18 14:19:27 momjian Exp $
    1111
    *
    1212
    *-------------------------------------------------------------------------
    1313
    */
    1414

    1515
    #include <postgres.h>
    1616

    17-
    #include <fmgr.h>
    1817
    #include <access/heapam.h>
    19-
    #include <access/valid.h>
    2018
    #include <access/xact.h>
    21-
    #include <storage/bufpage.h>
    22-
    #include <utils/rel.h>
    23-
    #include <utils/tqual.h>
    24-
    #include <storage/bufmgr.h>
    25-
    #include <utils/builtins.h>
    26-
    27-
    /* ----------------
    28-
    * heap_keytest
    29-
    *
    30-
    * Test a heap tuple with respect to a scan key.
    31-
    * ----------------
    32-
    */
    33-
    bool
    34-
    heap_keytest(HeapTuple t,
    35-
    TupleDesc tupdesc,
    36-
    int nkeys,
    37-
    ScanKey keys)
    38-
    {
    39-
    bool isnull;
    40-
    Datum atp;
    41-
    int test;
    42-
    43-
    for (; nkeys--; keys++)
    44-
    {
    45-
    atp = heap_getattr(t, InvalidBuffer,
    46-
    keys->sk_attno,
    47-
    tupdesc,
    48-
    &isnull);
    49-
    50-
    if (isnull)
    51-
    /* XXX eventually should check if SK_ISNULL */
    52-
    return false;
    53-
    54-
    if (keys->sk_flags & SK_ISNULL)
    55-
    {
    56-
    return (false);
    57-
    }
    58-
    59-
    if (keys->sk_func == (func_ptr) oideq) /* optimization */
    60-
    test = (keys->sk_argument == atp);
    61-
    else if (keys->sk_flags & SK_COMMUTE)
    62-
    test = (long) FMGR_PTR2(keys->sk_func, keys->sk_procedure,
    63-
    keys->sk_argument, atp);
    64-
    else
    65-
    test = (long) FMGR_PTR2(keys->sk_func, keys->sk_procedure,
    66-
    atp, keys->sk_argument);
    67-
    68-
    if (!test == !(keys->sk_flags & SK_NEGATE))
    69-
    return false;
    70-
    }
    71-
    72-
    return true;
    73-
    }
    74-
    75-
    /* ----------------
    76-
    * heap_tuple_satisfies
    77-
    *
    78-
    * Returns a valid HeapTuple if it satisfies the timequal and keytest.
    79-
    * Returns NULL otherwise. Used to be heap_satisifies (sic) which
    80-
    * returned a boolean. It now returns a tuple so that we can avoid doing two
    81-
    * PageGetItem's per tuple.
    82-
    *
    83-
    * Complete check of validity including LP_CTUP and keytest.
    84-
    * This should perhaps be combined with valid somehow in the
    85-
    * future. (Also, additional rule tests/time range tests.)
    86-
    *
    87-
    * on 8/21/92 mao says: i rearranged the tests here to do keytest before
    88-
    * SatisfiesTimeQual. profiling indicated that even for vacuumed relations,
    89-
    * time qual checking was more expensive than key testing. time qual is
    90-
    * least likely to fail, too. we should really add the time qual test to
    91-
    * the restriction and optimize it in the normal way. this has interactions
    92-
    * with joey's expensive function work.
    93-
    * ----------------
    94-
    */
    95-
    HeapTuple
    96-
    heap_tuple_satisfies(ItemId itemId,
    97-
    Relation relation,
    98-
    Buffer buffer,
    99-
    PageHeader disk_page,
    100-
    TimeQual qual,
    101-
    int nKeys,
    102-
    ScanKey key)
    103-
    {
    104-
    HeapTuple tuple,
    105-
    result;
    106-
    bool res;
    107-
    TransactionId old_tmin,
    108-
    old_tmax;
    109-
    110-
    if (!ItemIdIsUsed(itemId))
    111-
    return NULL;
    112-
    113-
    tuple = (HeapTuple) PageGetItem((Page) disk_page, itemId);
    114-
    115-
    if (key != NULL)
    116-
    res = heap_keytest(tuple, RelationGetTupleDescriptor(relation),
    117-
    nKeys, key);
    118-
    else
    119-
    res = TRUE;
    120-
    121-
    result = (HeapTuple) NULL;
    122-
    if (res)
    123-
    {
    124-
    if (relation->rd_rel->relkind == RELKIND_UNCATALOGED)
    125-
    {
    126-
    result = tuple;
    127-
    }
    128-
    else
    129-
    {
    130-
    old_tmin = tuple->t_tmin;
    131-
    old_tmax = tuple->t_tmax;
    132-
    res = HeapTupleSatisfiesTimeQual(tuple, qual);
    133-
    if (tuple->t_tmin != old_tmin ||
    134-
    tuple->t_tmax != old_tmax)
    135-
    {
    136-
    SetBufferCommitInfoNeedsSave(buffer);
    137-
    }
    138-
    if (res)
    139-
    {
    140-
    result = tuple;
    141-
    }
    142-
    }
    143-
    }
    144-
    145-
    return result;
    146-
    }
    14719

    14820
    /*
    14921
    * TupleUpdatedByCurXactAndCmd() -- Returns true if this tuple has

    src/backend/access/heap/heapam.c

    Lines changed: 20 additions & 15 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,7 +7,7 @@
    77
    *
    88
    *
    99
    * IDENTIFICATION
    10-
    * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.19 1997/09/08 21:40:57 momjian Exp $
    10+
    * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.20 1997/09/18 14:19:30 momjian Exp $
    1111
    *
    1212
    *
    1313
    * INTERFACE ROUTINES
    @@ -429,8 +429,9 @@ heapgettup(Relation relation,
    429429
    * if current tuple qualifies, return it.
    430430
    * ----------------
    431431
    */
    432-
    if ((rtup = heap_tuple_satisfies(lpp, relation, *b, (PageHeader) dp,
    433-
    timeQual, nkeys, key)) != NULL)
    432+
    HeapTupleSatisfies(lpp, relation, *b, (PageHeader) dp,
    433+
    timeQual, nkeys, key, rtup);
    434+
    if (rtup != NULL)
    434435
    {
    435436
    ItemPointer iptr = &(rtup->t_ctid);
    436437

    @@ -1092,8 +1093,8 @@ heap_fetch(Relation relation,
    10921093
    * ----------------
    10931094
    */
    10941095

    1095-
    tuple = heap_tuple_satisfies(lp, relation, buffer, dp,
    1096-
    timeQual, 0, (ScanKey) NULL);
    1096+
    HeapTupleSatisfies(lp, relation, buffer, dp,
    1097+
    timeQual, 0, (ScanKey) NULL, tuple);
    10971098

    10981099
    if (tuple == NULL)
    10991100
    {
    @@ -1257,8 +1258,9 @@ heap_delete(Relation relation, ItemPointer tid)
    12571258
    * check that we're deleteing a valid item
    12581259
    * ----------------
    12591260
    */
    1260-
    if (!(tp = heap_tuple_satisfies(lp, relation, b, dp,
    1261-
    NowTimeQual, 0, (ScanKey) NULL)))
    1261+
    HeapTupleSatisfies(lp, relation, b, dp,
    1262+
    NowTimeQual, 0, (ScanKey) NULL, tp);
    1263+
    if (!tp)
    12621264
    {
    12631265

    12641266
    /* XXX call something else */
    @@ -1317,7 +1319,8 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
    13171319 57AE
    HeapTuple tp;
    13181320
    Page dp;
    13191321
    Buffer buffer;
    1320-
    1322+
    HeapTuple tuple;
    1323+
    13211324
    /* ----------------
    13221325
    * increment access statistics
    13231326
    * ----------------
    @@ -1388,13 +1391,15 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
    13881391
    * xact, we only want to flag the 'non-functional' NOTICE. -mer
    13891392
    * ----------------
    13901393
    */
    1391-
    if (!heap_tuple_satisfies(lp,
    1392-
    relation,
    1393-
    buffer,
    1394-
    (PageHeader) dp,
    1395-
    NowTimeQual,
    1396-
    0,
    1397-
    (ScanKey) NULL))
    1394+
    HeapTupleSatisfies(lp,
    1395+
    relation,
    1396+
    buffer,
    1397+
    (PageHeader) dp,
    1398+
    NowTimeQual,
    1399+
    0,
    1400+
    (ScanKey) NULL,
    1401+
    tuple);
    1402+
    if (!tuple)
    13981403
    {
    13991404
    ReleaseBuffer(buffer);
    14001405
    elog(WARN, "heap_replace: (am)invalid otid");

    src/backend/commands/trigger.c

    Lines changed: 3 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -792,8 +792,9 @@ GetTupleForTrigger(Relation relation, ItemPointer tid, bool before)
    792792
    return (NULL);
    793793
    }
    794794

    795-
    if (!(tuple = heap_tuple_satisfies(lp, relation, b, dp,
    796-
    NowTimeQual, 0, (ScanKey) NULL)))
    795+
    HeapTupleSatisfies(lp, relation, b, dp,
    796+
    NowTimeQual, 0, (ScanKey) NULL, tuple);
    797+
    if (!tuple)
    797798
    {
    798799
    ReleaseBuffer(b);
    799800
    elog(WARN, "GetTupleForTrigger: (am)invalid tid");

    src/backend/storage/buffer/buf_init.c

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -7,7 +7,7 @@
    77
    *
    88
    *
    99
    * IDENTIFICATION
    10-
    * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.12 1997/09/08 02:28:27 momjian Exp $
    10+
    * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.13 1997/09/18 14:19:58 momjian Exp $
    1111
    *
    1212
    *-------------------------------------------------------------------------
    1313
    */
    @@ -26,6 +26,7 @@
    2626

    2727
    #include "storage/fd.h"
    2828
    #include "storage/ipc.h"
    29+
    #include "storage/s_lock.h"
    2930
    #include "storage/shmem.h"
    3031
    #include "storage/spin.h"
    3132
    #include "storage/smgr.h"

    src/backend/storage/buffer/bufmgr.c

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -7,7 +7,7 @@
    77
    *
    88
    *
    99
    * IDENTIFICATION
    10-
    * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.23 1997/09/08 21:46:50 momjian Exp $
    10+
    * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.24 1997/09/18 14:20:00 momjian Exp $
    1111
    *
    1212
    *-------------------------------------------------------------------------
    1313
    */
    @@ -56,6 +56,7 @@
    5656

    5757
    #include "storage/fd.h"
    5858
    #include "storage/ipc.h"
    59+
    #include "storage/s_lock.h"
    5960
    #include "storage/shmem.h"
    6061
    #include "storage/spin.h"
    6162
    #include "storage/smgr.h"

    src/backend/storage/ipc/Makefile

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,7 +4,7 @@
    44
    # Makefile for storage/ipc
    55
    #
    66
    # IDENTIFICATION
    7-
    # $Header: /cvsroot/pgsql/src/backend/storage/ipc/Makefile,v 1.3 1996/11/09 06:21:47 momjian Exp $
    7+
    # $Header: /cvsroot/pgsql/src/backend/storage/ipc/Makefile,v 1.4 1997/09/18 14:20:08 momjian Exp $
    88
    #
    99
    #-------------------------------------------------------------------------
    1010

    @@ -17,7 +17,7 @@ INCLUDE_OPT = -I../.. \
    1717

    1818
    CFLAGS+=$(INCLUDE_OPT)
    1919

    20-
    OBJS = ipc.o ipci.o s_lock.o shmem.o shmqueue.o sinval.o \
    20+
    OBJS = ipc.o ipci.o shmem.o shmqueue.o sinval.o \
    2121
    sinvaladt.o spin.o
    2222

    2323
    all: SUBSYS.o

    0 commit comments

    Comments
     (0)
    0