pg_depend support

From: Rod Taylor <rbt(at)zort(dot)ca>
To: pgsql-patches(at)postgresql(dot)org
Subject: pg_depend support
Date: 2002-03-31 21:38:23
Message-ID: 1017610704.73074.28.camel@knight.zort.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

I'm far enough along that the code accomplishes everything that used to
happen, plus a couple new tricks. It could use a review. Please don't
apply yet.

I removed a couple of old 'NOTYET' code sections that appeared as if
they were going to attempt to do this, but in a round about way. It
also replaces a few specific cascades when dropping a table. Ie. toast
tables, indecies and complex types are dropped using a single
dependDelete() rather than specifically requesting each.

The new tricks? A few items restrict as they should. Ie. You can't
drop type Oid as something (many things) depends on it.

Created namespaceIdGetNspname() to get the namespace name based on the
id. Probably the wrong name for that function.

I didn't make a syscache for pg_depend as it's only accessed during
schema changes do I didn't see much benefit but it would cause
additional memory usage.

The initdb script doesn't quite gather all the dependencies, but it gets
a large portion.

[-] completed
[*] yet to do
[?] does it need to be done?

- Create Type
* Create View (on precompile set deps)
- Create Trigger
- Create Table (Columns on Types)
* Create Table / Column Defaults (on precompile set additional deps)
* Create Sequence
* Create Rule
* Create Operator
- Create Language
- Create Index
* Create Function
* Create Function (on precompile set additional deps)

* Create Aggregate (on precompile set additional deps)

- Drop Type
- Drop Viewgetch
- Drop Trigger
- Drop Table
- Drop Sequence
- Drop Rule
- Drop Operator
- Drop Language
- Drop Index
- Drop Function
- Drop Aggregate

- Alter Table / Primary Key
- Alter Table / unique index
* Alter Table / Default (Compiled default depends on functions / types
within)
- Alter Table / Add Column
- Alter table / add column which creates toast table

- Base type dependency on array type managed by pg_depend (always
cascaded)
* Table drop sequence created by serial (always cascaded)
* Table drop foreign key triggers as managed by pg_depend (always
cascaded)
* Don't drop foreign keys implicitly when another table created them
(unless CASCADED of course)
* Toast tables depend on relation (always cascade)
* Enable opt_behaviour for most items in gram.y

pg_depend system relations

- pg_attribute.attypid -> pg_type
? pg_class.reltype -> pg_type (type depends on relation covered below)
* pg_class.relam -> pg_am
- pg_class.reltoastrelid -> pg_class
- pg_class.reltoastidxid -> pg_idxid
- pg_proc.prolang -> pg_language
- pg_proc.prorettype -> Return Type
- pg_proc.proargtypes -> (Many input types -- assumption of max 4 oids
in the oidvector)
- pg_type.typinput -> pg_proc
- pg_type.typoutput -> pg_proc
- pg_type.typreceive -> pg_proc
- pg_type.typsend -> pg_proc
- pg_type.typrelid -> pg_class
- pg_type.typelem -> pg_type

OTHER NOTES:

DROP TYPE <complex type> should be restricted. Ie. DROP TYPE pg_class;

CREATE TABLE tab (col1 int4 DEFAULT nextval('seq'));
DROP FUNCTION nextval(text) CASCADE;
Drop the column (col1) or set the default to NULL?

Attachment Content-Type Size
depend.patch text/plain 48.6 KB
pg_depend.c text/x-c 14.3 KB
pg_depend.h text/x-c-header 3.2 KB

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2002-04-01 04:41:33 Re: Nullability patch take 2
Previous Message Ryan Grange 2002-03-31 17:35:07 PGAccess 0.98.7 apostrophe insertion