1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* large_object.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* file of info for Postgres large objects. POSTGRES 4.2 supports
|
|
|
|
* zillions of large objects (internal, external, jaquith, inversion).
|
|
|
|
* Now we only support inversion.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* $Id: large_object.h,v 1.20 2001/01/24 19:43:27 momjian Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef LARGE_OBJECT_H
|
|
|
|
#define LARGE_OBJECT_H
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-10-24 03:38:44 +02:00
|
|
|
#include "utils/rel.h"
|
1996-11-05 07:11:08 +01:00
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-10-24 03:38:44 +02:00
|
|
|
/*----------
|
|
|
|
* Data about a currently-open large object.
|
|
|
|
*
|
|
|
|
* id is the logical OID of the large object
|
|
|
|
* offset is the current seek offset within the LO
|
|
|
|
* heap_r holds an open-relation reference to pg_largeobject
|
|
|
|
* index_r holds an open-relation reference to pg_largeobject_loid_pn_index
|
|
|
|
*
|
|
|
|
* NOTE: before 7.1, heap_r and index_r held references to the separate
|
|
|
|
* table and index of a specific large object. Now they all live in one rel.
|
|
|
|
*----------
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
2000-10-24 03:38:44 +02:00
|
|
|
typedef struct LargeObjectDesc {
|
|
|
|
Oid id;
|
1997-09-08 04:41:22 +02:00
|
|
|
uint32 offset; /* current seek pointer */
|
2000-10-24 03:38:44 +02:00
|
|
|
int flags; /* locking info, etc */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-10-24 03:38:44 +02:00
|
|
|
/* flag bits: */
|
1997-09-07 07:04:48 +02:00
|
|
|
#define IFS_RDLOCK (1 << 0)
|
|
|
|
#define IFS_WRLOCK (1 << 1)
|
|
|
|
|
2000-10-24 03:38:44 +02:00
|
|
|
Relation heap_r;
|
|
|
|
Relation index_r;
|
1997-09-08 23:56:23 +02:00
|
|
|
} LargeObjectDesc;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-10-24 03:38:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Each "page" (tuple) of a large object can hold this much data
|
|
|
|
*
|
2000-10-24 05:34:53 +02:00
|
|
|
* We could set this as high as BLCKSZ less some overhead, but it seems
|
|
|
|
* better to make it a smaller value, so that not as much space is used
|
|
|
|
* up when a page-tuple is updated. Note that the value is deliberately
|
|
|
|
* chosen large enough to trigger the tuple toaster, so that we will
|
|
|
|
* attempt to compress page tuples in-line. (But they won't be moved off
|
|
|
|
* unless the user creates a toast-table for pg_largeobject...)
|
|
|
|
*
|
|
|
|
* Also, it seems to be a smart move to make the page size be a power of 2,
|
|
|
|
* since clients will often be written to send data in power-of-2 blocks.
|
|
|
|
* This avoids unnecessary tuple updates caused by partial-page writes.
|
2000-10-24 03:38:44 +02:00
|
|
|
*/
|
2000-10-24 05:34:53 +02:00
|
|
|
#define LOBLKSIZE (BLCKSZ / 4)
|
2000-10-24 03:38:44 +02:00
|
|
|
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
|
|
|
* Function definitions...
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* inversion stuff in inv_api.c */
|
|
|
|
extern LargeObjectDesc *inv_create(int flags);
|
|
|
|
extern LargeObjectDesc *inv_open(Oid lobjId, int flags);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void inv_close(LargeObjectDesc *obj_desc);
|
1999-12-10 04:56:14 +01:00
|
|
|
extern int inv_drop(Oid lobjId);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern int inv_seek(LargeObjectDesc *obj_desc, int offset, int whence);
|
|
|
|
extern int inv_tell(LargeObjectDesc *obj_desc);
|
|
|
|
extern int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
|
|
|
|
extern int inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* LARGE_OBJECT_H */
|