src/backend/utils/misc/guc.c
void
GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
{
	char		buffer[256];
	struct config_generic *conf;

	/* check requested variable number valid */
	Assert((varnum >= 0) && (varnum < num_guc_variables));

	conf = guc_variables[varnum];

	if (noshow)
	{
		if ((conf->flags & GUC_NO_SHOW_ALL) ||
			((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
			*noshow = true;
		else
			*noshow = false;
	}

	/* first get the generic attributes */

	/* name */
	values[0] = conf->name;

	/* setting : use _ShowOption in order to avoid duplicating the logic */
	values[1] = _ShowOption(conf, false);

	/* unit */
	if (conf->vartype == PGC_INT)
	{
		static char buf[8];

		switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
		{
			case GUC_UNIT_KB:
				values[2] = "kB";
				break;
			case GUC_UNIT_BLOCKS:
				snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
				values[2] = buf;
				break;
			case GUC_UNIT_XBLOCKS:
				snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
				values[2] = buf;
				break;
			case GUC_UNIT_MS:
				values[2] = "ms";
				break;
			case GUC_UNIT_S:
				values[2] = "s";
				break;
			case GUC_UNIT_MIN:
				values[2] = "min";
				break;
			default:
				values[2] = "";
				break;
		}
	}
	else
		values[2] = NULL;

	/* group */
	values[3] = config_group_names[conf->group];

	/* short_desc */
	values[4] = conf->short_desc;

	/* extra_desc */
	values[5] = conf->long_desc;

	/* context */
	values[6] = GucContext_Names[conf->context];

	/* vartype */
	values[7] = config_type_names[conf->vartype];

	/* source */
	values[8] = GucSource_Names[conf->source];

	/* now get the type specifc attributes */
	switch (conf->vartype)
	{
		case PGC_BOOL:
			{
				/* min_val */
				values[9] = NULL;

				/* max_val */
				values[10] = NULL;
			}
			break;

		case PGC_INT:
			{
				struct config_int *lconf = (struct config_int *) conf;

				/* min_val */
				snprintf(buffer, sizeof(buffer), "%d", lconf->min);
				values[9] = pstrdup(buffer);

				/* max_val */
				snprintf(buffer, sizeof(buffer), "%d", lconf->max);
				values[10] = pstrdup(buffer);
			}
			break;

		case PGC_REAL:
			{
				struct config_real *lconf = (struct config_real *) conf;

				/* min_val */
				snprintf(buffer, sizeof(buffer), "%g", lconf->min);
				values[9] = pstrdup(buffer);

				/* max_val */
				snprintf(buffer, sizeof(buffer), "%g", lconf->max);
				values[10] = pstrdup(buffer);
			}
			break;

		case PGC_STRING:
			{
				/* min_val */
				values[9] = NULL;

				/* max_val */
				values[10] = NULL;
			}
			break;

		default:
			{
				/*
				 * should never get here, but in case we do, set 'em to NULL
				 */

				/* min_val */
				values[9] = NULL;

				/* max_val */
				values[10] = NULL;
			}
			break;
	}

	/* gp_segment_id */
	snprintf(buffer, sizeof(buffer), "%d", GetQEIndex());
	values[11] = pstrdup(buffer);
}
/*
 * Return GUC variable value by variable number; optionally return canonical
 * form of name.  Return value is palloc'd.
 */
Return GUC variable value by variable number; optionally return canonical
form of name.  Return value is palloc'd.
Return GUC variable value by variable number ; optionally return canonical form of name . Return value is palloc ' d .
void
GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
{
	char		buffer[256];
	struct config_generic *conf;
	Assert((varnum >= 0) && (varnum < num_guc_variables));
	conf = guc_variables[varnum];
	if (noshow)
	{
		if ((conf->flags & GUC_NO_SHOW_ALL) ||
			((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
			*noshow = true;
		else
			*noshow = false;
	}
	values[0] = conf->name;
	values[1] = _ShowOption(conf, false);
	if (conf->vartype == PGC_INT)
	{
		static char buf[8];
		switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
		{
			case GUC_UNIT_KB:
				values[2] = "kB";
				break;
			case GUC_UNIT_BLOCKS:
				snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
				values[2] = buf;
				break;
			case GUC_UNIT_XBLOCKS:
				snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
				values[2] = buf;
				break;
			case GUC_UNIT_MS:
				values[2] = "ms";
				break;
			case GUC_UNIT_S:
				values[2] = "s";
				break;
			case GUC_UNIT_MIN:
				values[2] = "min";
				break;
			default:
				values[2] = "";
				break;
		}
	}
	else
		values[2] = NULL;
	values[3] = config_group_names[conf->group];
	values[4] = conf->short_desc;
	values[5] = conf->long_desc;
	values[6] = GucContext_Names[conf->context];
	values[7] = config_type_names[conf->vartype];
	values[8] = GucSource_Names[conf->source];
	switch (conf->vartype)
	{
		case PGC_BOOL:
			{
				values[9] = NULL;
				values[10] = NULL;
			}
			break;
		case PGC_INT:
			{
				struct config_int *lconf = (struct config_int *) conf;
				snprintf(buffer, sizeof(buffer), "%d", lconf->min);
				values[9] = pstrdup(buffer);
				snprintf(buffer, sizeof(buffer), "%d", lconf->max);
				values[10] = pstrdup(buffer);
			}
			break;
		case PGC_REAL:
			{
				struct config_real *lconf = (struct config_real *) conf;
				snprintf(buffer, sizeof(buffer), "%g", lconf->min);
				values[9] = pstrdup(buffer);
				snprintf(buffer, sizeof(buffer), "%g", lconf->max);
				values[10] = pstrdup(buffer);
			}
			break;
		case PGC_STRING:
			{
				values[9] = NULL;
				values[10] = NULL;
			}
			break;
		default:
			{
				values[9] = NULL;
				values[10] = NULL;
			}
			break;
	}
	snprintf(buffer, sizeof(buffer), "%d", GetQEIndex());
	values[11] = pstrdup(buffer);
}
void GetConfigOptionByNum ( int varnum , const char * * values , bool * noshow ) { char buffer [ 256 ] ; struct config_generic * conf ; Assert ( ( varnum >= 0 ) && ( varnum < num_guc_variables ) ) ; conf = guc_variables [ varnum ] ; if ( noshow ) { if ( ( conf -> flags & GUC_NO_SHOW_ALL ) || ( ( conf -> flags & GUC_SUPERUSER_ONLY ) && ! superuser ( ) ) ) * noshow = true ; else * noshow = false ; } values [ 0 ] = conf -> name ; values [ 1 ] = _ShowOption ( conf , false ) ; if ( conf -> vartype == PGC_INT ) { static char buf [ 8 ] ; switch ( conf -> flags & ( GUC_UNIT_MEMORY | GUC_UNIT_TIME ) ) { case GUC_UNIT_KB : values [ 2 ] = " " ; break ; case GUC_UNIT_BLOCKS : snprintf ( buf , sizeof ( buf ) , " " , BLCKSZ / 1024 ) ; values [ 2 ] = buf ; break ; case GUC_UNIT_XBLOCKS : snprintf ( buf , sizeof ( buf ) , " " , XLOG_BLCKSZ / 1024 ) ; values [ 2 ] = buf ; break ; case GUC_UNIT_MS : values [ 2 ] = " " ; break ; case GUC_UNIT_S : values [ 2 ] = " " ; break ; case GUC_UNIT_MIN : values [ 2 ] = " " ; break ; default : values [ 2 ] = " " ; break ; } } else values [ 2 ] = NULL ; values [ 3 ] = config_group_names [ conf -> group ] ; values [ 4 ] = conf -> short_desc ; values [ 5 ] = conf -> long_desc ; values [ 6 ] = GucContext_Names [ conf -> context ] ; values [ 7 ] = config_type_names [ conf -> vartype ] ; values [ 8 ] = GucSource_Names [ conf -> source ] ; switch ( conf -> vartype ) { case PGC_BOOL : { values [ 9 ] = NULL ; values [ 10 ] = NULL ; } break ; case PGC_INT : { struct config_int * lconf = ( struct config_int * ) conf ; snprintf ( buffer , sizeof ( buffer ) , " " , lconf -> min ) ; values [ 9 ] = pstrdup ( buffer ) ; snprintf ( buffer , sizeof ( buffer ) , " " , lconf -> max ) ; values [ 10 ] = pstrdup ( buffer ) ; } break ; case PGC_REAL : { struct config_real * lconf = ( struct config_real * ) conf ; snprintf ( buffer , sizeof ( buffer ) , " " , lconf -> min ) ; values [ 9 ] = pstrdup ( buffer ) ; snprintf ( buffer , sizeof ( buffer ) , " " , lconf -> max ) ; values [ 10 ] = pstrdup ( buffer ) ; } break ; case PGC_STRING : { values [ 9 ] = NULL ; values [ 10 ] = NULL ; } break ; default : { values [ 9 ] = NULL ; values [ 10 ] = NULL ; } break ; } snprintf ( buffer , sizeof ( buffer ) , " " , GetQEIndex ( ) ) ; values [ 11 ] = pstrdup ( buffer ) ; }
Return GUC variable value by variable number; optionally return canonical
 form of name.
Return GUC variable value by variable number ; optionally return canonical form of name .
/* check requested variable number valid */ /* first get the generic attributes */ /* name */ /* setting : use _ShowOption in order to avoid duplicating the logic */ /* unit */ /* group */ /* short_desc */ /* extra_desc */ /* context */ /* vartype */ /* source */ /* now get the type specifc attributes */ /* min_val */ /* max_val */ /* min_val */ /* max_val */ /* min_val */ /* max_val */ /* min_val */ /* max_val */ /*
				 * should never get here, but in case we do, set 'em to NULL
				 */ /* min_val */ /* max_val */ /* gp_segment_id */