LCOV - differential code coverage report
Current view: top level - src/backend/utils/misc - help_config.c (source / functions) Coverage Total Hit UNC UIC UBC EUB DUB
Current: Differential Code Coverage HEAD vs 15 Lines: 0.0 % 33 0 1 22 10 22 1
Current Date: 2023-04-08 15:15:32 Functions: 0.0 % 3 0 1 2 2
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           TLA  Line data    Source code
       1                 : /*-------------------------------------------------------------------------
       2                 :  * help_config.c
       3                 :  *
       4                 :  * Displays available options under grand unified configuration scheme
       5                 :  *
       6                 :  * Options whose flag bits are set to GUC_NO_SHOW_ALL, GUC_NOT_IN_SAMPLE,
       7                 :  * or GUC_DISALLOW_IN_FILE are not displayed, unless the user specifically
       8                 :  * requests that variable by name
       9                 :  *
      10                 :  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
      11                 :  *
      12                 :  * IDENTIFICATION
      13                 :  *    src/backend/utils/misc/help_config.c
      14                 :  *
      15                 :  *-------------------------------------------------------------------------
      16                 :  */
      17                 : #include "postgres.h"
      18                 : 
      19                 : #include <limits.h>
      20                 : #include <unistd.h>
      21                 : 
      22                 : #include "utils/guc_tables.h"
      23                 : #include "utils/help_config.h"
      24                 : 
      25                 : 
      26                 : /*
      27                 :  * This union allows us to mix the numerous different types of structs
      28                 :  * that we are organizing.
      29                 :  */
      30                 : typedef union
      31                 : {
      32                 :     struct config_generic generic;
      33                 :     struct config_bool _bool;
      34                 :     struct config_real real;
      35                 :     struct config_int integer;
      36                 :     struct config_string string;
      37                 :     struct config_enum _enum;
      38                 : } mixedStruct;
      39                 : 
      40                 : 
      41                 : static void printMixedStruct(mixedStruct *structToPrint);
      42                 : static bool displayStruct(mixedStruct *structToDisplay);
      43                 : 
      44                 : 
      45                 : void
      46 UBC           0 : GucInfoMain(void)
      47                 : {
      48                 :     struct config_generic **guc_vars;
      49                 :     int         numOpts,
      50                 :                 i;
      51                 : 
      52                 :     /* Initialize the GUC hash table */
      53               0 :     build_guc_variables();
      54                 : 
      55 UNC           0 :     guc_vars = get_guc_variables(&numOpts);
      56 EUB             : 
      57 UIC           0 :     for (i = 0; i < numOpts; i++)
      58 EUB             :     {
      59 UIC           0 :         mixedStruct *var = (mixedStruct *) guc_vars[i];
      60 EUB             : 
      61 UBC           0 :         if (displayStruct(var))
      62 UIC           0 :             printMixedStruct(var);
      63                 :     }
      64 EUB             : 
      65 UIC           0 :     exit(0);
      66                 : }
      67                 : 
      68                 : 
      69                 : /*
      70                 :  * This function will return true if the struct passed to it
      71                 :  * should be displayed to the user.
      72                 :  */
      73 EUB             : static bool
      74 UIC           0 : displayStruct(mixedStruct *structToDisplay)
      75 EUB             : {
      76 UIC           0 :     return !(structToDisplay->generic.flags & (GUC_NO_SHOW_ALL |
      77                 :                                                GUC_NOT_IN_SAMPLE |
      78                 :                                                GUC_DISALLOW_IN_FILE));
      79                 : }
      80                 : 
      81                 : 
      82                 : /*
      83                 :  * This function prints out the generic struct passed to it. It will print out
      84                 :  * a different format, depending on what the user wants to see.
      85                 :  */
      86 EUB             : static void
      87 UIC           0 : printMixedStruct(mixedStruct *structToPrint)
      88 EUB             : {
      89 UIC           0 :     printf("%s\t%s\t%s\t",
      90                 :            structToPrint->generic.name,
      91                 :            GucContext_Names[structToPrint->generic.context],
      92                 :            _(config_group_names[structToPrint->generic.group]));
      93 EUB             : 
      94 UIC           0 :     switch (structToPrint->generic.vartype)
      95                 :     {
      96 EUB             : 
      97 UBC           0 :         case PGC_BOOL:
      98 UIC           0 :             printf("BOOLEAN\t%s\t\t\t",
      99                 :                    (structToPrint->_bool.reset_val == 0) ?
     100 EUB             :                    "FALSE" : "TRUE");
     101 UIC           0 :             break;
     102 EUB             : 
     103 UBC           0 :         case PGC_INT:
     104 UIC           0 :             printf("INTEGER\t%d\t%d\t%d\t",
     105                 :                    structToPrint->integer.reset_val,
     106                 :                    structToPrint->integer.min,
     107 EUB             :                    structToPrint->integer.max);
     108 UIC           0 :             break;
     109 EUB             : 
     110 UBC           0 :         case PGC_REAL:
     111 UIC           0 :             printf("REAL\t%g\t%g\t%g\t",
     112                 :                    structToPrint->real.reset_val,
     113                 :                    structToPrint->real.min,
     114 EUB             :                    structToPrint->real.max);
     115 UIC           0 :             break;
     116 EUB             : 
     117 UBC           0 :         case PGC_STRING:
     118 UIC           0 :             printf("STRING\t%s\t\t\t",
     119 EUB             :                    structToPrint->string.boot_val ? structToPrint->string.boot_val : "");
     120 UIC           0 :             break;
     121 EUB             : 
     122 UBC           0 :         case PGC_ENUM:
     123 UIC           0 :             printf("ENUM\t%s\t\t\t",
     124                 :                    config_enum_lookup_by_value(&structToPrint->_enum,
     125 EUB             :                                                structToPrint->_enum.boot_val));
     126 UIC           0 :             break;
     127 EUB             : 
     128 UBC           0 :         default:
     129               0 :             write_stderr("internal error: unrecognized run-time parameter type\n");
     130 UIC           0 :             break;
     131                 :     }
     132 EUB             : 
     133 UIC           0 :     printf("%s\t%s\n",
     134                 :            (structToPrint->generic.short_desc == NULL) ? "" : _(structToPrint->generic.short_desc),
     135 EUB             :            (structToPrint->generic.long_desc == NULL) ? "" : _(structToPrint->generic.long_desc));
     136 UIC           0 : }
        

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