/*-------------------------------------------------------------------------
 *
 * pg_authid.h
 *	  definition of the system "authorization identifier" relation (pg_authid)
 *	  along with the relation's initial contents.
 *		  pg_shadow is now a public accessible view on pg_authid.
 *		  pg_group is now a public accessible view on pg_authid.
 *
 *
 * Portions Copyright (c) 2005, PostgreSQL Global Development Group
 *
 * $Id$
 *
 * NOTES
 *	  the genbki.sh script reads this file and generates .bki
 *	  information from the DATA() statements.
 *
 *		  WHENEVER the definition for pg_authid changes, the
 *		  view creation of pg_shadow/pg_group must be changed in initdb.sh!
 *
 *-------------------------------------------------------------------------
 */
#ifndef PG_AUTHID_H
#define PG_AUTHID_H

#include "utils/timestamp.h"

/* ----------------
 *		pg_authid definition.  cpp turns this into
 *		typedef struct FormData_pg_authid
 * ----------------
 */
#define AuthIdRelationId    1260

CATALOG(pg_authid,1260) BKI_SHARED_RELATION
{
	NameData	rolname;
	bool		rolsuper;		/* read this field via superuser() only */
	bool		rolcreaterole;
	bool		rolcreatedb;
	bool		rolcatupdate;
	bool		rolcanlogin;

	/* remaining fields may be null; use heap_getattr to read them! */
	text		rolpassword;
	text		rolconfig[1];
	TimestampTz	rolvaliduntil;		/* actually abstime */
} FormData_pg_authid;

/* ----------------
 *		Form_pg_authid corresponds to a pointer to a tuple with
 *		the format of pg_authid relation.
 * ----------------
 */
typedef FormData_pg_authid *Form_pg_authid;

/* ----------------
 *		compiler constants for pg_authid
 * ----------------
 */
#define Natts_pg_authid				9
#define Anum_pg_authid_rolname			1
#define Anum_pg_authid_rolsuper			2
#define Anum_pg_authid_rolcreaterole		3
#define Anum_pg_authid_rolcreatedb			4
#define Anum_pg_authid_rolcatupdate		5
#define Anum_pg_authid_rolcanlogin		6
#define Anum_pg_authid_rolpassword			7
#define Anum_pg_authid_rolconfig		8
#define Anum_pg_authid_rolvaliduntil			9

/* ----------------
 *		initial contents of pg_authid
 *
 * The uppercase quantities will be replaced at initdb time with
 * user choices.
 * ----------------
 */
DATA(insert OID = 142 ( "POSTGRES" t t t t t _null_ _null_ _null_ ));

#define SUPERUSEROID 142

#endif   /* PG_AUTHID_H */
