/*-------------------------------------------------------------------------
 *
 * pg_depend.h
 *	  definition of the system "depend" relation (pg_depend)
 *	  along with the relation's initial contents.
 *
 *
 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * $Header$
 *
 * NOTES
 *	  the genbki.sh script reads this file and generates .bki
	 *	  information from theDATA() statements.
 *
 *-------------------------------------------------------------------------
 */
#ifndef PG_DEPEND_H
#define PG_DEPEND_H

/* ----------------
 *		postgres.h contains the system type definitions and the
 *		CATALOG(), BOOTSTRAP andDATA() sugar words so this file
 *		can be read by both genbki.sh and the C compiler.
 * ----------------
 */

/* ----------------
 *		pg_depend definition.  cpp turns this into
 *		typedef struct FormData_pg_depend
 * ----------------
 */
CATALOG(pg_depend) BOOTSTRAP BKI_WITHOUT_OIDS
{
	Oid			classid;		/* OID of table containing object */
	Oid			objid;			/* OID of object itself */
	int4		objsubid;		/* column number, or 0 if not used */

	Oid			depclassid;		/* OID of table containing dependee object */
	Oid			depobjid;		/* OID of dependee object itself */
	int4		depobjsubid;	/* dependee column number, or 0 if not used */

	/*
	 * Always cascade to the item, even when the RESTRICT behavior has been
	 * specified.  Used primarily for SERIAL, and ARRAY types.
	 */
	bool		alwayscascade;
} FormData_pg_depend;

/* ----------------
 *		Form_pg_depend corresponds to a pointer to a row with
 *		the format of pg_depend relation.
 * ----------------
 */
typedef FormData_pg_depend *Form_pg_depend;

/* ----------------
 *		compiler constants for pg_depend
 * ----------------
 */
#define Natts_pg_depend				7
#define Anum_pg_depend_classid		1
#define Anum_pg_depend_objid		2
#define Anum_pg_depend_objsubid		3
#define Anum_pg_depend_depclassid	4
#define Anum_pg_depend_depobjid		5
#define Anum_pg_depend_depobjsubid	6
#define Anum_pg_depend_alwayscascade 7


/*
 * Dependencies are automatically discovered in the initdb.sh
 * script via a rather large query.
 *
 * If you modify any system relations, be sure to modify that
 * query.
 */

/* ----------------
 *		pg_type depends on Functions
 * ----------------
 **********************

 ***********************/


/* ----------------
 *		pg_attribute depends on pg_class
 * ----------------
 */


/* ----------------
 *		pg_class depends on Complex Types (table types)
 * ----------------
 */

/* ----------------
 *		pg_class depends on index access methods (pg_am)
 * ----------------
 */

/* ----------------
 *		more...
 * ----------------
 */

typedef struct ObjectAddress
{
	Oid		classId;		/* Class Id from pg_class */
	Oid		objectId;		/* OID of the object */
	int32	objectSubId;	/* Subitem within the object (column of table) */
} ObjectAddress;


extern void dependCreate(const ObjectAddress *depender,
						 const ObjectAddress *dependee, bool behavior);
extern void dependDelete(ObjectAddress *object, int behavior);
extern void dependDeleteTuple(const HeapTuple tup,
							  const Relation relation,
							  int behavior);

#endif   /* PG_DEPEND_H */
