LCOV - differential code coverage report
Current view: top level - src/backend/access/sequence - sequence.c (source / functions) Coverage Total Hit UNC GNC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 100.0 % 11 11 11
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 3 3 3
Baseline: 16@8cea358b128 Branches: 75.0 % 4 3 1 3
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed [..60] days: 100.0 % 11 11 11
Function coverage date bins:
[..60] days: 100.0 % 3 3 3
Branch coverage date bins:
[..60] days: 75.0 % 4 3 1 3

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * sequence.c
                                  4                 :                :  *    Generic routines for sequence-related code.
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
                                  7                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :                :  *
                                  9                 :                :  *
                                 10                 :                :  * IDENTIFICATION
                                 11                 :                :  *    src/backend/access/sequence/sequence.c
                                 12                 :                :  *
                                 13                 :                :  *
                                 14                 :                :  * NOTES
                                 15                 :                :  *    This file contains sequence_ routines that implement access to sequences
                                 16                 :                :  *    (in contrast to other relation types like indexes).
                                 17                 :                :  *
                                 18                 :                :  *-------------------------------------------------------------------------
                                 19                 :                :  */
                                 20                 :                : 
                                 21                 :                : #include "postgres.h"
                                 22                 :                : 
                                 23                 :                : #include "access/relation.h"
                                 24                 :                : #include "access/sequence.h"
                                 25                 :                : #include "storage/lmgr.h"
                                 26                 :                : 
                                 27                 :                : static inline void validate_relation_kind(Relation r);
                                 28                 :                : 
                                 29                 :                : /* ----------------
                                 30                 :                :  *      sequence_open - open a sequence relation by relation OID
                                 31                 :                :  *
                                 32                 :                :  *      This is essentially relation_open plus check that the relation
                                 33                 :                :  *      is a sequence.
                                 34                 :                :  * ----------------
                                 35                 :                :  */
                                 36                 :                : Relation
   48 michael@paquier.xyz        37                 :GNC      193431 : sequence_open(Oid relationId, LOCKMODE lockmode)
                                 38                 :                : {
                                 39                 :                :     Relation    r;
                                 40                 :                : 
                                 41                 :         193431 :     r = relation_open(relationId, lockmode);
                                 42                 :                : 
                                 43                 :         193431 :     validate_relation_kind(r);
                                 44                 :                : 
                                 45                 :         193428 :     return r;
                                 46                 :                : }
                                 47                 :                : 
                                 48                 :                : /* ----------------
                                 49                 :                :  *      sequence_close - close a sequence
                                 50                 :                :  *
                                 51                 :                :  *      If lockmode is not "NoLock", we then release the specified lock.
                                 52                 :                :  *
                                 53                 :                :  *      Note that it is often sensible to hold a lock beyond relation_close;
                                 54                 :                :  *      in that case, the lock is released automatically at xact end.
                                 55                 :                :  * ----------------
                                 56                 :                :  */
                                 57                 :                : void
                                 58                 :         193363 : sequence_close(Relation relation, LOCKMODE lockmode)
                                 59                 :                : {
                                 60                 :         193363 :     relation_close(relation, lockmode);
                                 61                 :         193363 : }
                                 62                 :                : 
                                 63                 :                : /* ----------------
                                 64                 :                :  *      validate_relation_kind - check the relation's kind
                                 65                 :                :  *
                                 66                 :                :  *      Make sure relkind is from a sequence.
                                 67                 :                :  * ----------------
                                 68                 :                :  */
                                 69                 :                : static inline void
                                 70                 :         193431 : validate_relation_kind(Relation r)
                                 71                 :                : {
                                 72         [ +  + ]:         193431 :     if (r->rd_rel->relkind != RELKIND_SEQUENCE)
                                 73         [ +  - ]:              3 :         ereport(ERROR,
                                 74                 :                :                 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 75                 :                :                  errmsg("cannot open relation \"%s\"",
                                 76                 :                :                         RelationGetRelationName(r)),
                                 77                 :                :                  errdetail_relkind_not_supported(r->rd_rel->relkind)));
                                 78                 :         193428 : }
        

Generated by: LCOV version 2.1-beta2-3-g6141622