Tom Lane wrote:
One could make a good case that INDEX_MAX_KEYS should be exported along
with FUNC_MAX_ARGS, rather than letting people write client code that
assumes they are the same.

I was intending to propose that we also export the following as
read-only variables:
        * NAMEDATALEN
        * BLCKSZ
        * integer-vs-float datetime flag

OK, the attached includes the above -- result looks like:


regression=# select * from pg_settings where category like 'Compile%';
-[ RECORD 1 ]----------------------------------------------
name       | block_size
setting    | 8192
category   | Compiled-in Options
short_desc | Shows size of a disk block
extra_desc |
context    | internal
vartype    | integer
source     | default
min_val    | 8192
max_val    | 8192
-[ RECORD 2 ]----------------------------------------------
name       | func_max_args
setting    | 32
category   | Compiled-in Options
short_desc | Shows the maximum number of function arguments
extra_desc |
context    | internal
vartype    | integer
source     | default
min_val    | 32
max_val    | 32
-[ RECORD 3 ]----------------------------------------------
name       | index_max_keys
setting    | 32
category   | Compiled-in Options
short_desc | Shows the maximum number of index keys
extra_desc |
context    | internal
vartype    | integer
source     | default
min_val    | 32
max_val    | 32
-[ RECORD 4 ]----------------------------------------------
name       | integer_datetimes
setting    | on
category   | Compiled-in Options
short_desc | Datetimes are integer based
extra_desc |
context    | internal
vartype    | bool
source     | default
min_val    |
max_val    |
-[ RECORD 5 ]----------------------------------------------
name       | name_data_len
setting    | 63
category   | Compiled-in Options
short_desc | Shows the maximum identifier length
extra_desc |
context    | internal
vartype    | integer
source     | default
min_val    | 63
max_val    | 63


If it's there it should be separate.  I think also there was some
feeling it should be called "extra_desc" not "long_desc".

Done. Also added "category" which displays config_group_names[conf->group]



Please set the GUC_NOT_IN_SAMPLE and GUC_DISALLOW_IN_FILE flag bits on
each of these variables, too.  I know we are not using these flags for
anything yet, but we should try to get them right...

Done.


I'll update the docs once I'm sure we're done iterating on these changes.

Any further comments?

Joe

Index: src/backend/catalog/system_views.sql
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/catalog/system_views.sql,v
retrieving revision 1.3
diff -c -r1.3 system_views.sql
*** src/backend/catalog/system_views.sql        29 Nov 2003 22:39:40 -0000      1.3
--- src/backend/catalog/system_views.sql        1 Dec 2003 05:49:21 -0000
***************
*** 260,267 ****
  CREATE VIEW pg_settings AS 
      SELECT * 
      FROM pg_show_all_settings() AS A 
!     (name text, setting text, context text, vartype text, 
!      source text, min_val text, max_val text);
  
  CREATE RULE pg_settings_u AS 
      ON UPDATE TO pg_settings 
--- 260,267 ----
  CREATE VIEW pg_settings AS 
      SELECT * 
      FROM pg_show_all_settings() AS A 
!     (name text, setting text, category text, short_desc text, extra_desc text,
!      context text, vartype text, source text, min_val text, max_val text);
  
  CREATE RULE pg_settings_u AS 
      ON UPDATE TO pg_settings 
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v
retrieving revision 1.173
diff -c -r1.173 guc.c
*** src/backend/utils/misc/guc.c        1 Dec 2003 03:55:21 -0000       1.173
--- src/backend/utils/misc/guc.c        1 Dec 2003 05:49:23 -0000
***************
*** 156,162 ****
  static char *session_authorization_string;
  static char *timezone_string;
  static char *XactIsoLevel_string;
! 
  
  /* Macros for freeing malloc'd pointers only if appropriate to do so */
  /* Some of these tests are probably redundant, but be safe ... */
--- 156,166 ----
  static char *session_authorization_string;
  static char *timezone_string;
  static char *XactIsoLevel_string;
! static int    func_max_args;
! static int    index_max_keys;
! static int    name_data_len;
! static int    block_size;
! static bool integer_datetimes;
  
  /* Macros for freeing malloc'd pointers only if appropriate to do so */
  /* Some of these tests are probably redundant, but be safe ... */
***************
*** 302,307 ****
--- 306,313 ----
        gettext_noop("Version and Platform Compatibility / Other Platforms and 
Clients"),
        /* DEVELOPER_OPTIONS */
        gettext_noop("Developer Options"),
+       /* COMPILE_OPTIONS */
+       gettext_noop("Compiled-in Options"),
        /* help_config wants this array to be null-terminated */
        NULL
  };
***************
*** 832,837 ****
--- 838,857 ----
                true, NULL, NULL
        },
  
+       {
+               {"integer_datetimes", PGC_INTERNAL, COMPILE_OPTIONS,
+                       gettext_noop("Datetimes are integer based"),
+                       NULL,
+                       GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+               },
+               &integer_datetimes,
+ #ifdef HAVE_INT64_TIMESTAMP
+               true, NULL, NULL
+ #else
+               false, NULL, NULL
+ #endif
+       },
+ 
        /* End-of-list marker */
        {
                {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
***************
*** 1228,1233 ****
--- 1248,1293 ----
                100, 1, 1000, NULL, NULL
        },
  
+       {
+               {"func_max_args", PGC_INTERNAL, COMPILE_OPTIONS,
+                       gettext_noop("Shows the maximum number of function arguments"),
+                       NULL,
+                       GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+               },
+               &func_max_args,
+               FUNC_MAX_ARGS, FUNC_MAX_ARGS, FUNC_MAX_ARGS, NULL, NULL
+       },
+ 
+       {
+               {"index_max_keys", PGC_INTERNAL, COMPILE_OPTIONS,
+                       gettext_noop("Shows the maximum number of index keys"),
+                       NULL,
+                       GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+               },
+               &index_max_keys,
+               INDEX_MAX_KEYS, INDEX_MAX_KEYS, INDEX_MAX_KEYS, NULL, NULL
+       },
+ 
+       {
+               {"name_data_len", PGC_INTERNAL, COMPILE_OPTIONS,
+                       gettext_noop("Shows the maximum identifier length"),
+                       NULL,
+                       GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+               },
+               &name_data_len,
+               NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1, NULL, NULL
+       },
+ 
+       {
+               {"block_size", PGC_INTERNAL, COMPILE_OPTIONS,
+                       gettext_noop("Shows size of a disk block"),
+                       NULL,
+                       GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+               },
+               &block_size,
+               BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
+       },
+ 
        /* End-of-list marker */
        {
                {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL
***************
*** 3468,3481 ****
        /* setting : use _ShowOption in order to avoid duplicating the logic */
        values[1] = _ShowOption(conf);
  
        /* context */
!       values[2] = GucContext_Names[conf->context];
  
        /* vartype */
!       values[3] = config_type_names[conf->vartype];
  
        /* source */
!       values[4] = GucSource_Names[conf->source];
  
        /* now get the type specifc attributes */
        switch (conf->vartype)
--- 3528,3550 ----
        /* setting : use _ShowOption in order to avoid duplicating the logic */
        values[1] = _ShowOption(conf);
  
+       /* group */
+       values[2] = config_group_names[conf->group];
+ 
+       /* short_desc */
+       values[3] = conf->short_desc;
+ 
+       /* extra_desc */
+       values[4] = conf->long_desc;
+ 
        /* context */
!       values[5] = GucContext_Names[conf->context];
  
        /* vartype */
!       values[6] = config_type_names[conf->vartype];
  
        /* source */
!       values[7] = GucSource_Names[conf->source];
  
        /* now get the type specifc attributes */
        switch (conf->vartype)
***************
*** 3483,3492 ****
                case PGC_BOOL:
                        {
                                /* min_val */
!                               values[5] = NULL;
  
                                /* max_val */
!                               values[6] = NULL;
                        }
                        break;
  
--- 3552,3561 ----
                case PGC_BOOL:
                        {
                                /* min_val */
!                               values[8] = NULL;
  
                                /* max_val */
!                               values[9] = NULL;
                        }
                        break;
  
***************
*** 3496,3506 ****
  
                                /* min_val */
                                snprintf(buffer, sizeof(buffer), "%d", lconf->min);
!                               values[5] = pstrdup(buffer);
  
                                /* max_val */
                                snprintf(buffer, sizeof(buffer), "%d", lconf->max);
!                               values[6] = pstrdup(buffer);
                        }
                        break;
  
--- 3565,3575 ----
  
                                /* min_val */
                                snprintf(buffer, sizeof(buffer), "%d", lconf->min);
!                               values[8] = pstrdup(buffer);
  
                                /* max_val */
                                snprintf(buffer, sizeof(buffer), "%d", lconf->max);
!                               values[9] = pstrdup(buffer);
                        }
                        break;
  
***************
*** 3510,3530 ****
  
                                /* min_val */
                                snprintf(buffer, sizeof(buffer), "%g", lconf->min);
!                               values[5] = pstrdup(buffer);
  
                                /* max_val */
                                snprintf(buffer, sizeof(buffer), "%g", lconf->max);
!                               values[6] = pstrdup(buffer);
                        }
                        break;
  
                case PGC_STRING:
                        {
                                /* min_val */
!                               values[5] = NULL;
  
                                /* max_val */
!                               values[6] = NULL;
                        }
                        break;
  
--- 3579,3599 ----
  
                                /* min_val */
                                snprintf(buffer, sizeof(buffer), "%g", lconf->min);
!                               values[8] = pstrdup(buffer);
  
                                /* max_val */
                                snprintf(buffer, sizeof(buffer), "%g", lconf->max);
!                               values[9] = pstrdup(buffer);
                        }
                        break;
  
                case PGC_STRING:
                        {
                                /* min_val */
!                               values[8] = NULL;
  
                                /* max_val */
!                               values[9] = NULL;
                        }
                        break;
  
***************
*** 3536,3545 ****
                                 */
  
                                /* min_val */
!                               values[5] = NULL;
  
                                /* max_val */
!                               values[6] = NULL;
                        }
                        break;
        }
--- 3605,3614 ----
                                 */
  
                                /* min_val */
!                               values[8] = NULL;
  
                                /* max_val */
!                               values[9] = NULL;
                        }
                        break;
        }
***************
*** 3582,3588 ****
   * show_all_settings - equiv to SHOW ALL command but implemented as
   * a Table Function.
   */
! #define NUM_PG_SETTINGS_ATTS  7
  
  Datum
  show_all_settings(PG_FUNCTION_ARGS)
--- 3651,3657 ----
   * show_all_settings - equiv to SHOW ALL command but implemented as
   * a Table Function.
   */
! #define NUM_PG_SETTINGS_ATTS  10
  
  Datum
  show_all_settings(PG_FUNCTION_ARGS)
***************
*** 3616,3630 ****
                                                   TEXTOID, -1, 0, false);
                TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 3, "context",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 4, "vartype",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 5, "source",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 6, "min_val",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 7, "max_val",
                                                   TEXTOID, -1, 0, false);
  
                /* allocate a slot for a tuple with this tupdesc */
--- 3685,3705 ----
                                                   TEXTOID, -1, 0, false);
                TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 3, "category",
!                                                  TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 4, "short_desc",
!                                                  TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 5, "extra_desc",
!                                                  TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 6, "context",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 7, "vartype",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 8, "source",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 9, "min_val",
                                                   TEXTOID, -1, 0, false);
!               TupleDescInitEntry(tupdesc, (AttrNumber) 10, "max_val",
                                                   TEXTOID, -1, 0, false);
  
                /* allocate a slot for a tuple with this tupdesc */
Index: src/include/utils/guc_tables.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/utils/guc_tables.h,v
retrieving revision 1.7
diff -c -r1.7 guc_tables.h
*** src/include/utils/guc_tables.h      29 Nov 2003 22:41:15 -0000      1.7
--- src/include/utils/guc_tables.h      1 Dec 2003 05:49:23 -0000
***************
*** 50,56 ****
        COMPAT_OPTIONS,
        COMPAT_OPTIONS_PREVIOUS,
        COMPAT_OPTIONS_CLIENT,
!       DEVELOPER_OPTIONS
  };
  
  /*
--- 50,57 ----
        COMPAT_OPTIONS,
        COMPAT_OPTIONS_PREVIOUS,
        COMPAT_OPTIONS_CLIENT,
!       DEVELOPER_OPTIONS,
!       COMPILE_OPTIONS
  };
  
  /*
Index: src/test/regress/expected/rules.out
===================================================================
RCS file: /cvsroot/pgsql-server/src/test/regress/expected/rules.out,v
retrieving revision 1.82
diff -c -r1.82 rules.out
*** src/test/regress/expected/rules.out 21 Nov 2003 22:32:49 -0000      1.82
--- src/test/regress/expected/rules.out 1 Dec 2003 05:49:23 -0000
***************
*** 1278,1284 ****
   pg_indexes               | SELECT n.nspname AS schemaname, c.relname AS tablename, 
i.relname AS indexname, pg_get_indexdef(i.oid) AS indexdef FROM (((pg_index x JOIN 
pg_class c ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) 
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE ((c.relkind = 
'r'::"char") AND (i.relkind = 'i'::"char"));
   pg_locks                 | SELECT l.relation, l."database", l."transaction", l.pid, 
l."mode", l.granted FROM pg_lock_status() l(relation oid, "database" oid, 
"transaction" xid, pid integer, "mode" text, granted boolean);
   pg_rules                 | SELECT n.nspname AS schemaname, c.relname AS tablename, 
r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r JOIN pg_class c ON 
((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE 
(r.rulename <> '_RETURN'::name);
!  pg_settings              | SELECT a.name, a.setting, a.context, a.vartype, 
a.source, a.min_val, a.max_val FROM pg_show_all_settings() a(name text, setting text, 
context text, vartype text, source text, min_val text, max_val text);
   pg_stat_activity         | SELECT d.oid AS datid, d.datname, 
pg_stat_get_backend_pid(s.backendid) AS procpid, 
pg_stat_get_backend_userid(s.backendid) AS usesysid, u.usename, 
pg_stat_get_backend_activity(s.backendid) AS current_query, 
pg_stat_get_backend_activity_start(s.backendid) AS query_start FROM pg_database d, 
(SELECT pg_stat_get_backend_idset() AS backendid) s, pg_shadow u WHERE 
((pg_stat_get_backend_dbid(s.backendid) = d.oid) AND 
(pg_stat_get_backend_userid(s.backendid) = u.usesysid));
   pg_stat_all_indexes      | SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS 
schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS 
idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, 
pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM (((pg_class c JOIN pg_index x 
ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN 
pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = 'r'::"char");
   pg_stat_all_tables       | SELECT c.oid AS relid, n.nspname AS schemaname, 
c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) 
AS seq_tup_read, sum(pg_stat_get_numscans(i.indexrelid)) AS idx_scan, 
sum(pg_stat_get_tuples_fetched(i.indexrelid)) AS idx_tup_fetch, 
pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS 
n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del FROM ((pg_class c LEFT JOIN 
pg_index i ON ((c.oid = i.indrelid))) LEFT JOIN pg_namespace n ON ((n.oid = 
c.relnamespace))) WHERE (c.relkind = 'r'::"char") GROUP BY c.oid, n.nspname, c.relname;
--- 1278,1284 ----
   pg_indexes               | SELECT n.nspname AS schemaname, c.relname AS tablename, 
i.relname AS indexname, pg_get_indexdef(i.oid) AS indexdef FROM (((pg_index x JOIN 
pg_class c ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) 
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE ((c.relkind = 
'r'::"char") AND (i.relkind = 'i'::"char"));
   pg_locks                 | SELECT l.relation, l."database", l."transaction", l.pid, 
l."mode", l.granted FROM pg_lock_status() l(relation oid, "database" oid, 
"transaction" xid, pid integer, "mode" text, granted boolean);
   pg_rules                 | SELECT n.nspname AS schemaname, c.relname AS tablename, 
r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r JOIN pg_class c ON 
((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE 
(r.rulename <> '_RETURN'::name);
!  pg_settings              | SELECT a.name, a.setting, a.category, a.short_desc, 
a.extra_desc, a.context, a.vartype, a.source, a.min_val, a.max_val FROM 
pg_show_all_settings() a(name text, setting text, category text, short_desc text, 
extra_desc text, context text, vartype text, source text, min_val text, max_val text);
   pg_stat_activity         | SELECT d.oid AS datid, d.datname, 
pg_stat_get_backend_pid(s.backendid) AS procpid, 
pg_stat_get_backend_userid(s.backendid) AS usesysid, u.usename, 
pg_stat_get_backend_activity(s.backendid) AS current_query, 
pg_stat_get_backend_activity_start(s.backendid) AS query_start FROM pg_database d, 
(SELECT pg_stat_get_backend_idset() AS backendid) s, pg_shadow u WHERE 
((pg_stat_get_backend_dbid(s.backendid) = d.oid) AND 
(pg_stat_get_backend_userid(s.backendid) = u.usesysid));
   pg_stat_all_indexes      | SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS 
schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS 
idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, 
pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM (((pg_class c JOIN pg_index x 
ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN 
pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = 'r'::"char");
   pg_stat_all_tables       | SELECT c.oid AS relid, n.nspname AS schemaname, 
c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) 
AS seq_tup_read, sum(pg_stat_get_numscans(i.indexrelid)) AS idx_scan, 
sum(pg_stat_get_tuples_fetched(i.indexrelid)) AS idx_tup_fetch, 
pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS 
n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del FROM ((pg_class c LEFT JOIN 
pg_index i ON ((c.oid = i.indrelid))) LEFT JOIN pg_namespace n ON ((n.oid = 
c.relnamespace))) WHERE (c.relkind = 'r'::"char") GROUP BY c.oid, n.nspname, c.relname;
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to