mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
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
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: fmgr.h,v 1.18 2001/11/05 17:46:31 momjian Exp $
|
||||
* $Id: fmgr.h,v 1.19 2002/03/05 05:33:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -135,11 +135,16 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo,
|
||||
*/
|
||||
extern struct varlena *pg_detoast_datum(struct varlena * datum);
|
||||
extern struct varlena *pg_detoast_datum_copy(struct varlena * datum);
|
||||
extern struct varlena *pg_detoast_datum_slice(struct varlena * datum,
|
||||
int32 first, int32 count);
|
||||
|
||||
#define PG_DETOAST_DATUM(datum) \
|
||||
pg_detoast_datum((struct varlena *) DatumGetPointer(datum))
|
||||
#define PG_DETOAST_DATUM_COPY(datum) \
|
||||
pg_detoast_datum_copy((struct varlena *) DatumGetPointer(datum))
|
||||
#define PG_DETOAST_DATUM_SLICE(datum,f,c) \
|
||||
pg_detoast_datum_slice((struct varlena *) DatumGetPointer(datum), \
|
||||
(int32) f, (int32) c)
|
||||
|
||||
/*
|
||||
* Support for cleaning up detoasted copies of inputs. This must only
|
||||
@@ -187,6 +192,11 @@ extern struct varlena *pg_detoast_datum_copy(struct varlena * datum);
|
||||
#define DatumGetTextPCopy(X) ((text *) PG_DETOAST_DATUM_COPY(X))
|
||||
#define DatumGetBpCharPCopy(X) ((BpChar *) PG_DETOAST_DATUM_COPY(X))
|
||||
#define DatumGetVarCharPCopy(X) ((VarChar *) PG_DETOAST_DATUM_COPY(X))
|
||||
/* Variants which return n bytes starting at pos. m */
|
||||
#define DatumGetByteaPSlice(X,m,n) ((bytea *) PG_DETOAST_DATUM_SLICE(X,m,n))
|
||||
#define DatumGetTextPSlice(X,m,n) ((text *) PG_DETOAST_DATUM_SLICE(X,m,n))
|
||||
#define DatumGetBpCharPSlice(X,m,n) ((BpChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
|
||||
#define DatumGetVarCharPSlice(X,m,n) ((VarChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
|
||||
/* GETARG macros for varlena types will typically look like this: */
|
||||
#define PG_GETARG_BYTEA_P(n) DatumGetByteaP(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_TEXT_P(n) DatumGetTextP(PG_GETARG_DATUM(n))
|
||||
@@ -197,6 +207,11 @@ extern struct varlena *pg_detoast_datum_copy(struct varlena * datum);
|
||||
#define PG_GETARG_TEXT_P_COPY(n) DatumGetTextPCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_BPCHAR_P_COPY(n) DatumGetBpCharPCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_VARCHAR_P_COPY(n) DatumGetVarCharPCopy(PG_GETARG_DATUM(n))
|
||||
/* And a b-byte slice from position a -also OK to write */
|
||||
#define PG_GETARG_BYTEA_P_SLICE(n,a,b) DatumGetByteaPSlice(PG_GETARG_DATUM(n),a,b)
|
||||
#define PG_GETARG_TEXT_P_SLICE(n,a,b) DatumGetTextPSlice(PG_GETARG_DATUM(n),a,b)
|
||||
#define PG_GETARG_BPCHAR_P_SLICE(n,a,b) DatumGetBpCharPSlice(PG_GETARG_DATUM(n),a,b)
|
||||
#define PG_GETARG_VARCHAR_P_SLICE(n,a,b) DatumGetVarCharPSlice(PG_GETARG_DATUM(n),a,b)
|
||||
|
||||
/* To return a NULL do this: */
|
||||
#define PG_RETURN_NULL() \
|
||||
|
||||
Reference in New Issue
Block a user