1 /*------------------------------------------------------------------------- 2 * 3 * toast_internals.h 4 * Internal definitions for the TOAST system. 5 * 6 * Copyright (c) 2000-2020, PostgreSQL Global Development Group 7 * 8 * src/include/access/toast_internals.h 9 * 10 *------------------------------------------------------------------------- 11 */ 12 #ifndef TOAST_INTERNALS_H 13 #define TOAST_INTERNALS_H 14 15 #include "storage/lockdefs.h" 16 #include "utils/relcache.h" 17 #include "utils/snapshot.h" 18 19 /* 20 * The information at the start of the compressed toast data. 21 */ 22 typedef struct toast_compress_header 23 { 24 int32 vl_len_; /* varlena header (do not touch directly!) */ 25 int32 rawsize; 26 } toast_compress_header; 27 28 /* 29 * Utilities for manipulation of header information for compressed 30 * toast entries. 31 */ 32 #define TOAST_COMPRESS_HDRSZ ((int32) sizeof(toast_compress_header)) 33 #define TOAST_COMPRESS_RAWSIZE(ptr) (((toast_compress_header *) (ptr))->rawsize) 34 #define TOAST_COMPRESS_SIZE(ptr) ((int32) VARSIZE_ANY(ptr) - TOAST_COMPRESS_HDRSZ) 35 #define TOAST_COMPRESS_RAWDATA(ptr) \ 36 (((char *) (ptr)) + TOAST_COMPRESS_HDRSZ) 37 #define TOAST_COMPRESS_SET_RAWSIZE(ptr, len) \ 38 (((toast_compress_header *) (ptr))->rawsize = (len)) 39 40 extern Datum toast_compress_datum(Datum value); 41 extern Oid toast_get_valid_index(Oid toastoid, LOCKMODE lock); 42 43 extern void toast_delete_datum(Relation rel, Datum value, bool is_speculative); 44 extern Datum toast_save_datum(Relation rel, Datum value, 45 struct varlena *oldexternal, int options); 46 47 extern int toast_open_indexes(Relation toastrel, 48 LOCKMODE lock, 49 Relation **toastidxs, 50 int *num_indexes); 51 extern void toast_close_indexes(Relation *toastidxs, int num_indexes, 52 LOCKMODE lock); 53 extern void init_toast_snapshot(Snapshot toast_snapshot); 54 55 #endif /* TOAST_INTERNALS_H */ 56