PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "access/detoast.h"
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_largeobject.h"
#include "libpq/libpq-fs.h"
#include "miscadmin.h"
#include "storage/large_object.h"
#include "utils/acl.h"
#include "utils/fmgroids.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
Go to the source code of this file.
Functions | |
static void | open_lo_relation (void) |
void | close_lo_relation (bool isCommit) |
static void | getdatafield (Form_pg_largeobject tuple, bytea **pdatafield, int *plen, bool *pfreeit) |
Oid | inv_create (Oid lobjId) |
LargeObjectDesc * | inv_open (Oid lobjId, int flags, MemoryContext mcxt) |
void | inv_close (LargeObjectDesc *obj_desc) |
int | inv_drop (Oid lobjId) |
static uint64 | inv_getsize (LargeObjectDesc *obj_desc) |
int64 | inv_seek (LargeObjectDesc *obj_desc, int64 offset, int whence) |
int64 | inv_tell (LargeObjectDesc *obj_desc) |
int | inv_read (LargeObjectDesc *obj_desc, char *buf, int nbytes) |
int | inv_write (LargeObjectDesc *obj_desc, const char *buf, int nbytes) |
void | inv_truncate (LargeObjectDesc *obj_desc, int64 len) |
Variables | |
bool | lo_compat_privileges |
static Relation | lo_heap_r = NULL |
static Relation | lo_index_r = NULL |
void close_lo_relation | ( | bool | isCommit | ) |
Definition at line 97 of file inv_api.c.
References CurrentResourceOwner, index_close(), lo_heap_r, lo_index_r, NoLock, table_close(), and TopTransactionResourceOwner.
Referenced by AtEOXact_LargeObject().
|
static |
Definition at line 131 of file inv_api.c.
References detoast_attr(), ereport, errcode(), ERRCODE_DATA_CORRUPTED, errmsg(), ERROR, len, LOBLKSIZE, VARATT_IS_EXTENDED, VARHDRSZ, and VARSIZE.
Referenced by inv_getsize(), inv_read(), inv_truncate(), and inv_write().
void inv_close | ( | LargeObjectDesc * | obj_desc | ) |
Definition at line 299 of file inv_api.c.
References Assert, pfree(), and PointerIsValid.
Referenced by be_lo_export(), be_lo_from_bytea(), be_lo_put(), closeLOfd(), lo_get_fragment_internal(), and lo_import_internal().
Definition at line 173 of file inv_api.c.
References CommandCounterIncrement(), GetUserId(), InvokeObjectPostCreateHook, LargeObjectCreate(), and recordDependencyOnOwner().
Referenced by be_lo_creat(), be_lo_create(), be_lo_from_bytea(), and lo_import_internal().
int inv_drop | ( | Oid | lobjId | ) |
Definition at line 311 of file inv_api.c.
References ObjectAddress::classId, CommandCounterIncrement(), DROP_CASCADE, and performDeletion().
Referenced by be_lo_unlink().
|
static |
Definition at line 340 of file inv_api.c.
References Assert, BackwardScanDirection, BTEqualStrategyNumber, data, elog, ERROR, getdatafield(), GETSTRUCT, HeapTupleHasNulls, HeapTupleIsValid, LargeObjectDesc::id, if(), len, lo_heap_r, lo_index_r, LOBLKSIZE, ObjectIdGetDatum(), open_lo_relation(), pfree(), PointerIsValid, ScanKeyInit(), LargeObjectDesc::snapshot, systable_beginscan_ordered(), systable_endscan_ordered(), and systable_getnext_ordered().
Referenced by inv_seek().
LargeObjectDesc* inv_open | ( | Oid | lobjId, |
int | flags, | ||
MemoryContext | mcxt | ||
) |
Definition at line 215 of file inv_api.c.
References ACL_SELECT, ACL_UPDATE, ACLCHECK_OK, ereport, errcode(), errmsg(), ERROR, LargeObjectDesc::flags, GetActiveSnapshot(), GetUserId(), LargeObjectDesc::id, IFS_RDLOCK, IFS_WRLOCK, INV_READ, INV_WRITE, InvalidSubTransactionId, LargeObjectExistsWithSnapshot(), lo_compat_privileges, MemoryContextAlloc(), LargeObjectDesc::offset, pg_largeobject_aclcheck_snapshot(), LargeObjectDesc::snapshot, and LargeObjectDesc::subid.
Referenced by be_lo_export(), be_lo_from_bytea(), be_lo_open(), be_lo_put(), lo_get_fragment_internal(), and lo_import_internal().
int inv_read | ( | LargeObjectDesc * | obj_desc, |
char * | buf, | ||
int | nbytes | ||
) |
Definition at line 450 of file inv_api.c.
References Assert, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, buf, data, elog, ereport, errcode(), errmsg(), ERROR, LargeObjectDesc::flags, ForwardScanDirection, getdatafield(), GETSTRUCT, HeapTupleHasNulls, LargeObjectDesc::id, IFS_RDLOCK, Int32GetDatum(), len, lo_heap_r, lo_index_r, LOBLKSIZE, MemSet, ObjectIdGetDatum(), LargeObjectDesc::offset, open_lo_relation(), pfree(), PointerIsValid, ScanKeyInit(), LargeObjectDesc::snapshot, systable_beginscan_ordered(), systable_endscan_ordered(), systable_getnext_ordered(), and VARDATA.
Referenced by be_lo_export(), lo_get_fragment_internal(), and lo_read().
int64 inv_seek | ( | LargeObjectDesc * | obj_desc, |
int64 | offset, | ||
int | whence | ||
) |
Definition at line 388 of file inv_api.c.
References Assert, ereport, errcode(), errmsg(), errmsg_internal(), ERROR, INT64_FORMAT, inv_getsize(), MAX_LARGE_OBJECT_SIZE, LargeObjectDesc::offset, and PointerIsValid.
Referenced by be_lo_lseek(), be_lo_lseek64(), be_lo_put(), and lo_get_fragment_internal().
int64 inv_tell | ( | LargeObjectDesc * | obj_desc | ) |
Definition at line 437 of file inv_api.c.
References Assert, LargeObjectDesc::offset, and PointerIsValid.
Referenced by be_lo_tell(), and be_lo_tell64().
void inv_truncate | ( | LargeObjectDesc * | obj_desc, |
int64 | len | ||
) |
Definition at line 740 of file inv_api.c.
References Assert, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, CatalogCloseIndexes(), CatalogOpenIndexes(), CatalogTupleDelete(), CatalogTupleInsertWithInfo(), CatalogTupleUpdateWithInfo(), CommandCounterIncrement(), data, elog, ereport, errcode(), errmsg(), errmsg_internal(), ERROR, LargeObjectDesc::flags, ForwardScanDirection, getdatafield(), GETSTRUCT, heap_form_tuple(), heap_freetuple(), heap_modify_tuple(), HeapTupleHasNulls, LargeObjectDesc::id, IFS_WRLOCK, Int32GetDatum(), INT64_FORMAT, len, lo_heap_r, lo_index_r, LOBLKSIZE, MAX_LARGE_OBJECT_SIZE, MemSet, ObjectIdGetDatum(), open_lo_relation(), pfree(), PointerGetDatum(), PointerIsValid, RelationData::rd_att, RelationGetDescr, ScanKeyInit(), SET_VARSIZE, LargeObjectDesc::snapshot, systable_beginscan_ordered(), systable_endscan_ordered(), systable_getnext_ordered(), HeapTupleData::t_self, values, VARDATA, and VARHDRSZ.
Referenced by lo_truncate_internal().
int inv_write | ( | LargeObjectDesc * | obj_desc, |
const char * | buf, | ||
int | nbytes | ||
) |
Definition at line 543 of file inv_api.c.
References Assert, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, buf, CatalogCloseIndexes(), CatalogOpenIndexes(), CatalogTupleInsertWithInfo(), CatalogTupleUpdateWithInfo(), CommandCounterIncrement(), data, elog, ereport, errcode(), errmsg(), ERROR, LargeObjectDesc::flags, ForwardScanDirection, getdatafield(), GETSTRUCT, heap_form_tuple(), heap_freetuple(), heap_modify_tuple(), HeapTupleHasNulls, LargeObjectDesc::id, IFS_WRLOCK, Int32GetDatum(), len, lo_heap_r, lo_index_r, LOBLKSIZE, MAX_LARGE_OBJECT_SIZE, MemSet, ObjectIdGetDatum(), LargeObjectDesc::offset, open_lo_relation(), pfree(), PointerGetDatum(), PointerIsValid, RelationData::rd_att, RelationGetDescr, ScanKeyInit(), SET_VARSIZE, LargeObjectDesc::snapshot, systable_beginscan_ordered(), systable_endscan_ordered(), systable_getnext_ordered(), HeapTupleData::t_self, values, VARDATA, and VARHDRSZ.
Referenced by be_lo_from_bytea(), be_lo_put(), lo_import_internal(), and lo_write().
|
static |
Definition at line 73 of file inv_api.c.
References CurrentResourceOwner, index_open(), lo_heap_r, lo_index_r, RowExclusiveLock, table_open(), and TopTransactionResourceOwner.
Referenced by inv_getsize(), inv_read(), inv_truncate(), and inv_write().
bool lo_compat_privileges |
Definition at line 56 of file inv_api.c.
Referenced by be_lo_unlink(), check_object_ownership(), has_lo_priv_byid(), and inv_open().
|
static |
Definition at line 65 of file inv_api.c.
Referenced by close_lo_relation(), inv_getsize(), inv_read(), inv_truncate(), inv_write(), and open_lo_relation().
|
static |
Definition at line 66 of file inv_api.c.
Referenced by close_lo_relation(), inv_getsize(), inv_read(), inv_truncate(), inv_write(), and open_lo_relation().