pg_depend support - Mailing list pgsql-patches

From Rod Taylor
Subject pg_depend support
Date
Msg-id 1017610704.73074.28.camel@knight.zort.ca
Whole thread Raw
List 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

pgsql-patches by date:

Previous
From: Ryan Grange
Date:
Subject: PGAccess 0.98.7 apostrophe insertion
Next
From: Tom Lane
Date:
Subject: Re: Nullability patch take 2