diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index 5f89db5857..028ef10d91 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -1393,6 +1393,30 @@ The commands accepted in walsender mode are: + + SHOW name + SHOW + + + + Requests the server to send the current setting of a run-time parameter. + This is similar to the SQL command . + + + + + name + + + The name of a run-time parameter. Available parameters are documented + in . + + + + + + + TIMELINE_HISTORY tli TIMELINE_HISTORY diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index 54a32c0223..083c0303dc 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -20,6 +20,7 @@ #include "postgres.h" #include "access/htup_details.h" +#include "catalog/pg_collation.h" #include "catalog/pg_type.h" #include "miscadmin.h" #include "parser/parse_type.h" @@ -553,6 +554,84 @@ TupleDescInitEntry(TupleDesc desc, ReleaseSysCache(tuple); } +/* + * TupleDescInitBuiltinEntry + * Initialize a tuple descriptor without catalog access. Only + * a limited range of builtin types are supported. + */ +void +TupleDescInitBuiltinEntry(TupleDesc desc, + AttrNumber attributeNumber, + const char *attributeName, + Oid oidtypeid, + int32 typmod, + int attdim) +{ + Form_pg_attribute att; + + /* sanity checks */ + AssertArg(PointerIsValid(desc)); + AssertArg(attributeNumber >= 1); + AssertArg(attributeNumber <= desc->natts); + + /* initialize the attribute fields */ + att = desc->attrs[attributeNumber - 1]; + att->attrelid = 0; /* dummy value */ + + /* unlike TupleDescInitEntry, we require an attribute name */ + Assert(attributeName != NULL); + namestrcpy(&(att->attname), attributeName); + + att->attstattarget = -1; + att->attcacheoff = -1; + att->atttypmod = typmod; + + att->attnum = attributeNumber; + att->attndims = attdim; + + att->attnotnull = false; + att->atthasdef = false; + att->attisdropped = false; + att->attislocal = true; + att->attinhcount = 0; + /* attacl, attoptions and attfdwoptions are not present in tupledescs */ + + att->atttypid = oidtypeid; + + /* + * Our goal here is to support just enough types to let basic builtin + * commands work without catalog access - e.g. so that we can do certain + * things even in processes that are not connected to a database. + */ + switch (oidtypeid) + { + case TEXTOID: + case TEXTARRAYOID: + att->attlen = -1; + att->attbyval = false; + att->attalign = 'i'; + att->attstorage = 'x'; + att->attcollation = DEFAULT_COLLATION_OID; + break; + + case BOOLOID: + att->attlen = 1; + att->attbyval = true; + att->attalign = 'c'; + att->attstorage = 'p'; + att->attcollation = InvalidOid; + break; + + case INT4OID: + att->attlen = 4; + att->attbyval = true; + att->attalign = 'i'; + att->attstorage = 'p'; + att->attcollation = InvalidOid; + break; + } +} + /* * TupleDescInitEntryCollation * diff --git a/src/backend/replication/repl_gram.y b/src/backend/replication/repl_gram.y index d962c76819..b35d0f0cd1 100644 --- a/src/backend/replication/repl_gram.y +++ b/src/backend/replication/repl_gram.y @@ -61,6 +61,7 @@ Node *replication_parse_result; /* Keyword tokens. */ %token K_BASE_BACKUP %token K_IDENTIFY_SYSTEM +%token K_SHOW %token K_START_REPLICATION %token K_CREATE_REPLICATION_SLOT %token K_DROP_REPLICATION_SLOT @@ -82,14 +83,14 @@ Node *replication_parse_result; %type command %type base_backup start_replication start_logical_replication create_replication_slot drop_replication_slot identify_system - timeline_history + timeline_history show %type base_backup_opt_list %type base_backup_opt %type opt_timeline %type plugin_options plugin_opt_list %type plugin_opt_elem %type plugin_opt_arg -%type opt_slot +%type opt_slot var_name %type opt_reserve_wal opt_temporary %% @@ -112,6 +113,7 @@ command: | create_replication_slot | drop_replication_slot | timeline_history + | show ; /* @@ -124,6 +126,22 @@ identify_system: } ; +/* + * SHOW setting + */ +show: + K_SHOW var_name + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = $2; + $$ = (Node *) n; + } + +var_name: IDENT { $$ = $1; } + | var_name '.' IDENT + { $$ = psprintf("%s.%s", $1, $3); } + ; + /* * BASE_BACKUP [LABEL '