Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
toast_internals.h64 linesDownload Raw Back to access
1/*-------------------------------------------------------------------------2 *3 * toast_internals.h4 *	  Internal definitions for the TOAST system.5 *6 * Copyright (c) 2000-2023, PostgreSQL Global Development Group7 *8 * src/include/access/toast_internals.h9 *10 *-------------------------------------------------------------------------11 */12#ifndef TOAST_INTERNALS_H13#define TOAST_INTERNALS_H14 15#include "access/toast_compression.h"16#include "storage/lockdefs.h"17#include "utils/relcache.h"18#include "utils/snapshot.h"19 20/*21 *	The information at the start of the compressed toast data.22 */23typedef struct toast_compress_header24{25	int32		vl_len_;		/* varlena header (do not touch directly!) */26	uint32		tcinfo;			/* 2 bits for compression method and 30 bits27								 * external size; see va_extinfo */28} toast_compress_header;29 30/*31 * Utilities for manipulation of header information for compressed32 * toast entries.33 */34#define TOAST_COMPRESS_EXTSIZE(ptr) \35	(((toast_compress_header *) (ptr))->tcinfo & VARLENA_EXTSIZE_MASK)36#define TOAST_COMPRESS_METHOD(ptr) \37	(((toast_compress_header *) (ptr))->tcinfo >> VARLENA_EXTSIZE_BITS)38 39#define TOAST_COMPRESS_SET_SIZE_AND_COMPRESS_METHOD(ptr, len, cm_method) \40	do { \41		Assert((len) > 0 && (len) <= VARLENA_EXTSIZE_MASK); \42		Assert((cm_method) == TOAST_PGLZ_COMPRESSION_ID || \43			   (cm_method) == TOAST_LZ4_COMPRESSION_ID); \44		((toast_compress_header *) (ptr))->tcinfo = \45			(len) | ((uint32) (cm_method) << VARLENA_EXTSIZE_BITS); \46	} while (0)47 48extern Datum toast_compress_datum(Datum value, char cmethod);49extern Oid	toast_get_valid_index(Oid toastoid, LOCKMODE lock);50 51extern void toast_delete_datum(Relation rel, Datum value, bool is_speculative);52extern Datum toast_save_datum(Relation rel, Datum value,53							  struct varlena *oldexternal, int options);54 55extern int	toast_open_indexes(Relation toastrel,56							   LOCKMODE lock,57							   Relation **toastidxs,58							   int *num_indexes);59extern void toast_close_indexes(Relation *toastidxs, int num_indexes,60								LOCKMODE lock);61extern void init_toast_snapshot(Snapshot toast_snapshot);62 63#endif							/* TOAST_INTERNALS_H */64 
codekingpro/portable-devtools · Team Ai