1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Add a SHOW command to the replication command language.

This is useful infrastructure for an upcoming proposed patch to
allow the WAL segment size to be changed at initdb time; tools like
pg_basebackup need the ability to interrogate the server setting.
But it also doesn't seem like a bad thing to have independently of
that; it may find other uses in the future.

Robert Haas and Beena Emerson.  (The original patch here was by
Beena, but I rewrote it to such a degree that most of the code
being committed here is mine.)

Discussion: http://postgr.es/m/CA+TgmobNo4qz06wHEmy9DszAre3dYx-WNhHSCbU9SAwf+9Ft6g@mail.gmail.com
This commit is contained in:
Robert Haas
2017-01-24 16:59:18 -05:00
parent a84069d935
commit d1ecd53947
7 changed files with 151 additions and 10 deletions

View File

@@ -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
*