LCOV - differential code coverage report
Current view: top level - src/backend/access/rmgrdesc - rmgrdesc_utils.c (source / functions) Coverage Total Hit UNC GNC
Current: Differential Code Coverage HEAD vs 15 Lines: 75.0 % 24 18 6 18
Current Date: 2023-04-08 15:15:32 Functions: 60.0 % 5 3 2 3
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           TLA  Line data    Source code
       1                 : /*-------------------------------------------------------------------------
       2                 :  *
       3                 :  * rmgrdesc_utils.c
       4                 :  *    Support functions for rmgrdesc routines
       5                 :  *
       6                 :  * Copyright (c) 2023, PostgreSQL Global Development Group
       7                 :  *
       8                 :  *
       9                 :  * IDENTIFICATION
      10                 :  *    src/backend/access/rmgrdesc/rmgrdesc_utils.c
      11                 :  *
      12                 :  *-------------------------------------------------------------------------
      13                 :  */
      14                 : #include "postgres.h"
      15                 : 
      16                 : #include "access/rmgrdesc_utils.h"
      17                 : #include "storage/off.h"
      18                 : 
      19                 : /*
      20                 :  * Guidelines for formatting desc functions:
      21                 :  *
      22                 :  * member1_name: member1_value, member2_name: member2_value
      23                 :  *
      24                 :  * If the value is a list, please use:
      25                 :  *
      26                 :  * member3_name: [ member3_list_value1, member3_list_value2 ]
      27                 :  *
      28                 :  * The first item appended to the string should not be prepended by any spaces
      29                 :  * or comma, however all subsequent appends to the string are responsible for
      30                 :  * prepending themselves with a comma followed by a space.
      31                 :  *
      32                 :  * Arrays should have a space between the opening square bracket and first
      33                 :  * element and between the last element and closing brace.
      34                 :  *
      35                 :  * Flags should be in ALL CAPS.
      36                 :  *
      37                 :  * For lists/arrays of items, the number of those items should be listed at
      38                 :  * the beginning with all of the other numbers.
      39                 :  *
      40                 :  * List punctuation should still be included even if there are 0 items.
      41                 :  *
      42                 :  * Composite objects in a list should be surrounded with { }.
      43                 :  */
      44                 : void
      45 GNC         154 : array_desc(StringInfo buf, void *array, size_t elem_size, int count,
      46                 :            void (*elem_desc) (StringInfo buf, void *elem, void *data),
      47                 :            void *data)
      48                 : {
      49             154 :     if (count == 0)
      50                 :     {
      51              84 :         appendStringInfoString(buf, " []");
      52              84 :         return;
      53                 :     }
      54              70 :     appendStringInfo(buf, " [");
      55             462 :     for (int i = 0; i < count; i++)
      56                 :     {
      57             392 :         if (i > 0)
      58             322 :             appendStringInfoString(buf, ",");
      59             392 :         appendStringInfoString(buf, " ");
      60                 : 
      61             392 :         elem_desc(buf, (char *) array + elem_size * i, data);
      62                 :     }
      63              70 :     appendStringInfoString(buf, " ]");
      64                 : }
      65                 : 
      66                 : void
      67             351 : offset_elem_desc(StringInfo buf, void *offset, void *data)
      68                 : {
      69             351 :     appendStringInfo(buf, "%u", *(OffsetNumber *) offset);
      70             351 : }
      71                 : 
      72                 : void
      73              41 : redirect_elem_desc(StringInfo buf, void *offset, void *data)
      74                 : {
      75              41 :     OffsetNumber *new_offset = (OffsetNumber *) offset;
      76                 : 
      77              41 :     appendStringInfo(buf, "%u->%u", new_offset[0], new_offset[1]);
      78              41 : }
      79                 : 
      80                 : void
      81 UNC           0 : relid_desc(StringInfo buf, void *relid, void *data)
      82                 : {
      83               0 :     appendStringInfo(buf, "%u", *(Oid *) relid);
      84               0 : }
      85                 : 
      86                 : void
      87               0 : uint16_elem_desc(StringInfo buf, void *value, void *data)
      88                 : {
      89               0 :     appendStringInfo(buf, "%u", *(uint16 *) value);
      90               0 : }
        

Generated by: LCOV version v1.16-55-g56c0a2a