LCOV - code coverage report
Current view: top level - src/backend/utils/misc - help_config.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 0 28 0.0 %
Date: 2019-09-22 08:06:49 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          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-2019, 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           0 : GucInfoMain(void)
      47             : {
      48             :     struct config_generic **guc_vars;
      49             :     int         numOpts,
      50             :                 i;
      51             : 
      52             :     /* Initialize the guc_variables[] array */
      53           0 :     build_guc_variables();
      54             : 
      55           0 :     guc_vars = get_guc_variables();
      56           0 :     numOpts = GetNumConfigOptions();
      57             : 
      58           0 :     for (i = 0; i < numOpts; i++)
      59             :     {
      60           0 :         mixedStruct *var = (mixedStruct *) guc_vars[i];
      61             : 
      62           0 :         if (displayStruct(var))
      63           0 :             printMixedStruct(var);
      64             :     }
      65             : 
      66           0 :     exit(0);
      67             : }
      68             : 
      69             : 
      70             : /*
      71             :  * This function will return true if the struct passed to it
      72             :  * should be displayed to the user.
      73             :  */
      74             : static bool
      75           0 : displayStruct(mixedStruct *structToDisplay)
      76             : {
      77           0 :     return !(structToDisplay->generic.flags & (GUC_NO_SHOW_ALL |
      78             :                                                GUC_NOT_IN_SAMPLE |
      79             :                                                GUC_DISALLOW_IN_FILE));
      80             : }
      81             : 
      82             : 
      83             : /*
      84             :  * This function prints out the generic struct passed to it. It will print out
      85             :  * a different format, depending on what the user wants to see.
      86             :  */
      87             : static void
      88           0 : printMixedStruct(mixedStruct *structToPrint)
      89             : {
      90           0 :     printf("%s\t%s\t%s\t",
      91             :            structToPrint->generic.name,
      92             :            GucContext_Names[structToPrint->generic.context],
      93             :            _(config_group_names[structToPrint->generic.group]));
      94             : 
      95           0 :     switch (structToPrint->generic.vartype)
      96             :     {
      97             : 
      98             :         case PGC_BOOL:
      99           0 :             printf("BOOLEAN\t%s\t\t\t",
     100             :                    (structToPrint->_bool.reset_val == 0) ?
     101             :                    "FALSE" : "TRUE");
     102           0 :             break;
     103             : 
     104             :         case PGC_INT:
     105           0 :             printf("INTEGER\t%d\t%d\t%d\t",
     106             :                    structToPrint->integer.reset_val,
     107             :                    structToPrint->integer.min,
     108             :                    structToPrint->integer.max);
     109           0 :             break;
     110             : 
     111             :         case PGC_REAL:
     112           0 :             printf("REAL\t%g\t%g\t%g\t",
     113             :                    structToPrint->real.reset_val,
     114             :                    structToPrint->real.min,
     115             :                    structToPrint->real.max);
     116           0 :             break;
     117             : 
     118             :         case PGC_STRING:
     119           0 :             printf("STRING\t%s\t\t\t",
     120             :                    structToPrint->string.boot_val ? structToPrint->string.boot_val : "");
     121           0 :             break;
     122             : 
     123             :         case PGC_ENUM:
     124           0 :             printf("ENUM\t%s\t\t\t",
     125             :                    config_enum_lookup_by_value(&structToPrint->_enum,
     126             :                                                structToPrint->_enum.boot_val));
     127           0 :             break;
     128             : 
     129             :         default:
     130           0 :             write_stderr("internal error: unrecognized run-time parameter type\n");
     131           0 :             break;
     132             :     }
     133             : 
     134           0 :     printf("%s\t%s\n",
     135             :            (structToPrint->generic.short_desc == NULL) ? "" : _(structToPrint->generic.short_desc),
     136             :            (structToPrint->generic.long_desc == NULL) ? "" : _(structToPrint->generic.long_desc));
     137           0 : }

Generated by: LCOV version 1.13