1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* large_object.h
|
2004-07-28 16:23:31 +02:00
|
|
|
* Declarations for PostgreSQL large objects. POSTGRES 4.2 supported
|
1997-09-07 07:04:48 +02:00
|
|
|
* zillions of large objects (internal, external, jaquith, inversion).
|
|
|
|
* Now we only support inversion.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2006-03-05 16:59:11 +01:00
|
|
|
* Portions Copyright (c) 1996-2006, 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
|
|
|
*
|
2006-03-05 16:59:11 +01:00
|
|
|
* $PostgreSQL: pgsql/src/include/storage/large_object.h,v 1.33 2006/03/05 15:58:59 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
|
|
|
|
2005-06-13 04:26:53 +02:00
|
|
|
#include "utils/tqual.h"
|
|
|
|
|
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
|
2005-06-13 04:26:53 +02:00
|
|
|
* snapshot is the snapshot to use for read/write operations
|
|
|
|
* subid is the subtransaction that opened the desc (or currently owns it)
|
2000-10-24 03:38:44 +02:00
|
|
|
* offset is the current seek offset within the LO
|
2004-07-28 16:23:31 +02:00
|
|
|
* flags contains some flag bits
|
2000-10-24 03:38:44 +02:00
|
|
|
*
|
2004-07-28 16:23:31 +02:00
|
|
|
* NOTE: before 7.1, we also had to store references to the separate table
|
|
|
|
* and index of a specific large object. Now they all live in pg_largeobject
|
|
|
|
* and are accessed via a common relation descriptor.
|
2000-10-24 03:38:44 +02:00
|
|
|
*----------
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef struct LargeObjectDesc
|
|
|
|
{
|
2004-07-28 16:23:31 +02:00
|
|
|
Oid id; /* LO's identifier */
|
2005-06-13 04:26:53 +02:00
|
|
|
Snapshot snapshot; /* snapshot to use */
|
2004-09-16 18:58:44 +02:00
|
|
|
SubTransactionId subid; /* owning subtransaction 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)
|
2005-06-13 04:26:53 +02:00
|
|
|
|
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
|
|
|
*/
|
2001-03-22 05:01:46 +01: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 */
|
2004-07-28 16:23:31 +02:00
|
|
|
extern void close_lo_relation(bool isCommit);
|
2005-06-13 04:26:53 +02:00
|
|
|
extern Oid inv_create(Oid lobjId);
|
1996-08-28 03:59:28 +02:00
|
|
|
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);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* LARGE_OBJECT_H */
|