From 03194432de712f7afb4ddc2ade2bc44f0536dae1 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 5 Mar 2002 05:33:31 +0000 Subject: I attach a version of my toast-slicing patch, against current CVS (current as of a few hours ago.) This patch: 1. Adds PG_GETARG_xxx_P_SLICE() macros and associated support routines. 2. Adds routines in src/backend/access/tuptoaster.c for fetching only necessary chunks of a toasted value. (Modelled on latest changes to assume chunks are returned in order). 3. Amends text_substr and bytea_substr to use new methods. It now handles multibyte cases -and should still lead to a performance improvement in the multibyte case where the substring is near the beginning of the string. 4. Added new command: ALTER TABLE tabname ALTER COLUMN colname SET STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN} to parser and documented in alter-table.sgml. (NB I used ColId as the item type for the storage mode string, rather than a new production - I hope this makes sense!). All this does is sets attstorage for the specified column. 4. AlterTableAlterColumnStatistics is now AlterTableAlterColumnFlags and handles both statistics and storage (it uses the subtype code to distinguish). The previous version of my patch also re-arranged other code in backend/commands/command.c but I have dropped that from this patch.(I plan to return to it separately). 5. Documented new macros (and also the PG_GETARG_xxx_P_COPY macros) in xfunc.sgml. ref/alter_table.sgml also contains documentation for ALTER COLUMN SET STORAGE. John Gray --- doc/src/sgml/ref/alter_table.sgml | 15 ++++++++++++++- doc/src/sgml/xfunc.sgml | 31 ++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 6bc5ac54459..2d87902b2f4 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -1,5 +1,5 @@ @@ -30,6 +30,8 @@ ALTER TABLE [ ONLY ] table [ * ] class="PARAMETER">value | DROP DEFAULT } ALTER TABLE [ ONLY ] table [ * ] ALTER [ COLUMN ] column SET STATISTICS integer +ALTER TABLE [ ONLY ] table [ * ] + ALTER [ COLUMN ] column SET STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN} ALTER TABLE [ ONLY ] table [ * ] RENAME [ COLUMN ] column TO newcolumn @@ -169,6 +171,17 @@ ALTER TABLE table The ALTER COLUMN SET STATISTICS form allows you to set the statistics-gathering target for subsequent operations. + The ALTER COLUMN SET STORAGE form allows the + column storage mode to be set. This controls whether this column is + held inline or in a supplementary table, and whether the data + should be compressed or not. PLAIN must be used + for fixed-length values such as INTEGER and is + inline, uncompressed. MAIN is for inline, + compressible data. EXTERNAL is for external, + uncompressed data and EXTENDED is for external, + compressed data. The use of EXTERNAL will make + substring operations on a column faster, at the penalty of + increased storage space. The RENAME clause causes the name of a table, column, index, or sequence to change without changing any of the data. The data will remain of the same type and size after the diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 20341077c9c..94c664cbce1 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1,5 +1,5 @@ @@ -1296,6 +1296,35 @@ concat_text(PG_FUNCTION_ARGS) this works in both strict and nonstrict functions. + + Other options provided in the new-style interface are two + variants of the + PG_GETARG_xxx() + macros. The first of these, + PG_GETARG_xxx_COPY() + guarantees to return a copy of the specified parameter which is + safe for writing into. (The normal macros will sometimes return a + pointer to the value which must not be written to. Using the + PG_GETARG_xxx_COPY() + macros guarantees a writable result.) + + + + The second variant consists of the + PG_GETARG_xxx_SLICE() + macros which take three parameters. The first is the number of the + parameter (as above). The second and third are the offset and + length of the segment to be returned. Offsets are counted from + zero, and a negative length requests that the remainder of the + value be returned. These routines provide more efficient access to + parts of large values in the case where they have storage type + "external". (The storage type of a column can be specified using + ALTER TABLE tablename ALTER + COLUMN colname SET STORAGE + storagetype. Storage type is one of + plain, external, extended or main.) + + The version-1 function call conventions make it possible to return set results and implement trigger functions and -- cgit v1.2.3