Here is an updated partitioning syntax patch.
It implements syntax described here:
http://wiki.postgresql.org/wiki/Table_partitioning#Syntax
Changes:
* New syntax: ALTER TABLE parent ATTACH/DETACH PARTITION.
* Partition keys accepts an opclass name instead of an operator.
* "lo <= key AND key < hi" is used in range check constraints instead of
"key >= lo AND key < hi".
ToDo items:
* pg_get_partitiondef(parentOid, in_alter_format) might be ugly.
It was designed only for psql -d and pg_dump. It might be cleaner
if we move SQL formatter from the core function to client tools.
In psql: pg_get_partitiondef(oid, false)
Partitions: RANGE (sales_date)
(
PARTITION sales_2006 VALUES LESS THAN '...',
...
PARTITION sales_max VALUES LESS THAN MAXVALUE
)
In pg_dump: pg_get_partitiondef(oid, true)
ALTER TABLE parent PARTITION BY RANGE (sales_date);
ALTER TABLE parent ATTACH PARTITION sales_2006 VALUES LESS THAN '...';
...
ALTER TABLE parent ATTACH PARTITION sales_max VALUES LESS THAN MAXVALUE;
* The patch does not contain the following documentation,
but I'll start writing them if the syntax is ok.
- ddl-partitioning.sgml
- alter-partition.sgml (new)
- create-partition.sgml (new)
- drop-partition.sgml (new)
Note:
* In fact, malloc was not a bug because it was the code in pg_dump.
Comments welcome.
Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center