/* * This function prints out the generic struct passed to it. It will print out * a different format, depending on what the user wants to see. */ static void printMixedStruct(mixedStruct *structToPrint) { printf("%s\t%s\t%s\t", structToPrint->generic.name, GucContext_Names[structToPrint->generic.context], _(config_group_names[structToPrint->generic.group])); switch (structToPrint->generic.vartype) { case PGC_BOOL: printf("BOOLEAN\t%s\t\t\t", (structToPrint->_bool.reset_val == 0) ? "FALSE" : "TRUE"); break; case PGC_INT: printf("INTEGER\t%d\t%d\t%d\t", structToPrint->integer.reset_val, structToPrint->integer.min, structToPrint->integer.max); break; case PGC_REAL: printf("REAL\t%g\t%g\t%g\t", structToPrint->real.reset_val, structToPrint->real.min, structToPrint->real.max); break; case PGC_STRING: printf("STRING\t%s\t\t\t", structToPrint->string.boot_val ? structToPrint->string.boot_val : ""); break; case PGC_ENUM: printf("ENUM\t%s\t\t\t", config_enum_lookup_by_value(&structToPrint->_enum, structToPrint->_enum.boot_val)); break; default: write_stderr("internal error: unrecognized run-time parameter type\n"); break; } printf("%s\t%s\n", (structToPrint->generic.short_desc == NULL) ? "" : _(structToPrint->generic.short_desc), (structToPrint->generic.long_desc == NULL) ? "" : _(structToPrint->generic.long_desc)); }
/* * These routines dump out all non-default GUC options into a binary * file that is read by all exec'ed backends. The format is: * * variable name, string, null terminated * variable value, string, null terminated * variable sourcefile, string, null terminated (empty if none) * variable sourceline, integer * variable source, integer * variable scontext, integer */ static void write_one_nondefault_variable(FILE *fp, struct config_generic *gconf) { if (gconf->source == PGC_S_DEFAULT) return; fprintf(fp, "%s", gconf->name); fputc(0, fp); switch (gconf->vartype) { case PGC_BOOL: { struct config_bool *conf = (struct config_bool *) gconf; if (*conf->variable) fprintf(fp, "true"); else fprintf(fp, "false"); } break; case PGC_INT: { struct config_int *conf = (struct config_int *) gconf; fprintf(fp, "%d", *conf->variable); } break; case PGC_REAL: { struct config_real *conf = (struct config_real *) gconf; fprintf(fp, "%.17g", *conf->variable); } break; case PGC_STRING: { struct config_string *conf = (struct config_string *) gconf; fprintf(fp, "%s", *conf->variable); } break; case PGC_ENUM: { struct config_enum *conf = (struct config_enum *) gconf; fprintf(fp, "%s", config_enum_lookup_by_value(conf, *conf->variable)); } break; } fputc(0, fp); if (gconf->sourcefile) fprintf(fp, "%s", gconf->sourcefile); fputc(0, fp); fwrite(&gconf->sourceline, 1, sizeof(gconf->sourceline), fp); fwrite(&gconf->source, 1, sizeof(gconf->source), fp); fwrite(&gconf->scontext, 1, sizeof(gconf->scontext), fp); }