|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/htup_details.h"#include "access/multixact.h"#include "access/relation.h"#include "access/sequence.h"#include "access/table.h"#include "access/transam.h"#include "access/xact.h"#include "access/xloginsert.h"#include "catalog/dependency.h"#include "catalog/indexing.h"#include "catalog/namespace.h"#include "catalog/objectaccess.h"#include "catalog/pg_sequence.h"#include "catalog/pg_type.h"#include "catalog/storage_xlog.h"#include "commands/defrem.h"#include "commands/sequence.h"#include "commands/sequence_xlog.h"#include "commands/tablecmds.h"#include "funcapi.h"#include "miscadmin.h"#include "nodes/makefuncs.h"#include "parser/parse_type.h"#include "storage/bufmgr.h"#include "storage/lmgr.h"#include "storage/proc.h"#include "storage/smgr.h"#include "utils/acl.h"#include "utils/builtins.h"#include "utils/lsyscache.h"#include "utils/pg_lsn.h"#include "utils/resowner.h"#include "utils/syscache.h"#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
| struct | SeqTableData |
Macros | |
| #define | SEQ_LOG_VALS 32 |
| #define | PG_GET_SEQUENCE_DATA_COLS 3 |
Typedefs | |
| typedef struct SeqTableData | SeqTableData |
| typedef SeqTableData * | SeqTable |
Variables | |
| static HTAB * | seqhashtab = NULL |
| static SeqTableData * | last_used_seq = NULL |
| #define PG_GET_SEQUENCE_DATA_COLS 3 |
| #define SEQ_LOG_VALS 32 |
Definition at line 58 of file sequence.c.
Definition at line 79 of file sequence.c.
| ObjectAddress AlterSequence | ( | ParseState * | pstate, |
| AlterSeqStmt * | stmt | ||
| ) |
Definition at line 429 of file sequence.c.
References Assert, buf, SeqTableData::cached, CatalogTupleUpdate(), elog, ereport, errmsg(), ERROR, fb(), fill_seq_with_data(), GETSTRUCT(), GetTopTransactionId(), heap_copytuple(), HeapTupleIsValid, init_params(), init_sequence(), InvalidMultiXactId, InvalidObjectAddress, InvalidOid, InvalidTransactionId, InvokeObjectPostAlterHook, SeqTableData::last, NoLock, NOTICE, ObjectAddressSet, ObjectIdGetDatum(), process_owned_by(), RangeVarCallbackOwnsRelation(), RangeVarGetRelidExtended(), read_seq_tuple(), RelationNeedsWAL, RelationSetNewRelfilenumber(), RowExclusiveLock, RVR_MISSING_OK, SearchSysCacheCopy1, sequence_close(), ShareRowExclusiveLock, stmt, table_close(), table_open(), and UnlockReleaseBuffer().
Referenced by ProcessUtilitySlow().
Definition at line 1114 of file sequence.c.
References ctl, HASH_BLOBS, hash_create(), HASH_ELEM, HASHCTL::keysize, and seqhashtab.
Referenced by init_sequence().
| Datum currval_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 867 of file sequence.c.
References ACL_SELECT, ACL_USAGE, ACLCHECK_OK, ereport, errcode(), errmsg(), ERROR, fb(), GetUserId(), init_sequence(), SeqTableData::last, SeqTableData::last_valid, NoLock, pg_class_aclcheck(), PG_GETARG_OID, PG_RETURN_INT64, RelationGetRelationName, SeqTableData::relid, and sequence_close().
| ObjectAddress DefineSequence | ( | ParseState * | pstate, |
| CreateSeqStmt * | seq | ||
| ) |
Definition at line 112 of file sequence.c.
References AccessExclusiveLock, Assert, BoolGetDatum(), CatalogTupleInsert(), checkMembershipInCurrentExtension(), DefineRelation(), ereport, errcode(), errmsg(), fb(), fill_seq_with_data(), FormData_pg_sequence, heap_form_tuple(), heap_freetuple(), i, init_params(), Int64GetDatum(), Int64GetDatumFast, InvalidObjectAddress, InvalidOid, lappend(), makeColumnDef(), makeNode, NIL, NoLock, NOTICE, ObjectAddressSet, ObjectAddress::objectId, ObjectIdGetDatum(), OidIsValid, ONCOMMIT_NOOP, process_owned_by(), RangeVarGetAndCheckCreationNamespace(), RelationGetDescr, RowExclusiveLock, SEQ_COL_CALLED, SEQ_COL_FIRSTCOL, SEQ_COL_LASTCOL, SEQ_COL_LASTVAL, SEQ_COL_LOG, sequence_close(), sequence_open(), stmt, table_close(), table_open(), and value.
Referenced by ProcessUtilitySlow().
Definition at line 571 of file sequence.c.
References CatalogTupleDelete(), elog, ERROR, fb(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by doDeletion().
|
static |
Definition at line 352 of file sequence.c.
References Assert, BMR_REL, buf, BufferGetBlockNumber(), BufferGetPage(), BufferGetPageSize(), EB_LOCK_FIRST, EB_SKIP_EXTENSION_LOCK, elog, END_CRIT_SECTION, ERROR, ExtendBufferedRel(), fb(), FirstCommandId, FirstOffsetNumber, FrozenTransactionId, GetTopTransactionId(), HEAP_XMAX_INVALID, HeapTupleHeaderSetCmin(), HeapTupleHeaderSetXmax(), HeapTupleHeaderSetXmin(), HeapTupleHeaderSetXminFrozen(), INIT_FORKNUM, InvalidOffsetNumber, InvalidTransactionId, ItemPointerSet(), sequence_magic::magic, MarkBufferDirty(), PageAddItem, PageGetSpecialPointer, PageInit(), PageSetLSN(), RelationData::rd_locator, REGBUF_WILL_INIT, RelationNeedsWAL, SEQ_MAGIC, START_CRIT_SECTION, HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleHeaderData::t_infomask, HeapTupleData::t_len, UnlockReleaseBuffer(), XLOG_SEQ_LOG, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by fill_seq_with_data().
Definition at line 331 of file sequence.c.
References fb(), fill_seq_fork_with_data(), FlushRelationBuffers(), INIT_FORKNUM, INVALID_PROC_NUMBER, log_smgrcreate(), MAIN_FORKNUM, RelationData::rd_locator, RelationData::rd_rel, smgrclose(), smgrcreate(), and smgropen().
Referenced by AlterSequence(), DefineSequence(), ResetSequence(), and SequenceChangePersistence().
|
static |
Definition at line 1260 of file sequence.c.
References Assert, BoolIsValid, boolVal, defGetInt64(), defGetQualifiedName(), defGetTypeName(), elog, ereport, errcode(), errmsg(), ERROR, errorConflictingDefElem(), fb(), format_type_be(), lfirst, NIL, parser_errposition(), PG_INT16_MAX, PG_INT16_MIN, PG_INT32_MAX, PG_INT32_MIN, PG_INT64_MAX, PG_INT64_MIN, and typenameTypeId().
Referenced by AlterSequence(), and DefineSequence().
Definition at line 1130 of file sequence.c.
References SeqTableData::cached, create_seq_hashtable(), fb(), SeqTableData::filenumber, HASH_ENTER, hash_search(), InvalidLocalTransactionId, InvalidRelFileNumber, SeqTableData::last, SeqTableData::last_valid, lock_and_open_sequence(), SeqTableData::lxid, and seqhashtab.
Referenced by AlterSequence(), currval_oid(), nextval_internal(), pg_sequence_last_value(), ResetSequence(), SequenceChangePersistence(), and SetSequence().
| Datum lastval | ( | PG_FUNCTION_ARGS | ) |
Definition at line 898 of file sequence.c.
References ACL_SELECT, ACL_USAGE, ACLCHECK_OK, Assert, ereport, errcode(), errmsg(), ERROR, fb(), GetUserId(), SeqTableData::last, last_used_seq, SeqTableData::last_valid, lock_and_open_sequence(), NoLock, ObjectIdGetDatum(), pg_class_aclcheck(), PG_RETURN_INT64, RelationGetRelationName, SeqTableData::relid, SearchSysCacheExists1, and sequence_close().
Definition at line 1086 of file sequence.c.
References CurrentResourceOwner, fb(), LockRelationOid(), PGPROC::lxid, MyProc, NoLock, RowExclusiveLock, sequence_open(), TopTransactionResourceOwner, and PGPROC::vxid.
Referenced by init_sequence(), and lastval().
| Datum nextval | ( | PG_FUNCTION_ARGS | ) |
Definition at line 594 of file sequence.c.
References fb(), makeRangeVarFromNameList(), nextval_internal(), NoLock, PG_GETARG_TEXT_PP, PG_RETURN_INT64, RangeVarGetRelid, and textToQualifiedNameList().
Referenced by autoinc().
Definition at line 624 of file sequence.c.
References ACL_UPDATE, ACL_USAGE, ACLCHECK_OK, Assert, buf, BufferGetPage(), SeqTableData::cached, elog, END_CRIT_SECTION, ereport, errcode(), errmsg(), ERROR, fb(), GetRedoRecPtr(), GETSTRUCT(), GetTopTransactionId(), GetUserId(), HeapTupleIsValid, SeqTableData::increment, init_sequence(), SeqTableData::last, last_used_seq, SeqTableData::last_valid, MarkBufferDirty(), next, NoLock, ObjectIdGetDatum(), PageGetLSN(), PageSetLSN(), pg_class_aclcheck(), PreventCommandIfParallelMode(), PreventCommandIfReadOnly(), read_seq_tuple(), REGBUF_WILL_INIT, RelationGetRelationName, RelationNeedsWAL, ReleaseSysCache(), SeqTableData::relid, SearchSysCache1(), SEQ_LOG_VALS, sequence_close(), START_CRIT_SECTION, UnlockReleaseBuffer(), XLOG_SEQ_LOG, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by ExecEvalNextValueExpr(), nextval(), and nextval_oid().
| Datum nextval_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 616 of file sequence.c.
References nextval_internal(), PG_GETARG_OID, and PG_RETURN_INT64.
| Datum pg_get_sequence_data | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1793 of file sequence.c.
References AccessShareLock, ACL_SELECT, ACLCHECK_OK, BlessTupleDesc(), BoolGetDatum(), buf, BufferGetPage(), CreateTemplateTupleDesc(), fb(), GetUserId(), heap_form_tuple(), HeapTupleGetDatum(), Int64GetDatum(), LSNGetDatum(), PageGetLSN(), pg_class_aclcheck(), PG_GET_SEQUENCE_DATA_COLS, PG_GETARG_OID, PG_RETURN_DATUM, read_seq_tuple(), RecoveryInProgress(), relation_close(), RELATION_IS_OTHER_TEMP, RelationIsPermanent, try_relation_open(), TupleDescInitEntry(), UnlockReleaseBuffer(), and values.
| Datum pg_sequence_last_value | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1858 of file sequence.c.
References ACL_SELECT, ACL_USAGE, ACLCHECK_OK, buf, fb(), GetUserId(), init_sequence(), NoLock, pg_class_aclcheck(), PG_GETARG_OID, PG_RETURN_INT64, PG_RETURN_NULL, read_seq_tuple(), RecoveryInProgress(), RELATION_IS_OTHER_TEMP, RelationIsPermanent, sequence_close(), and UnlockReleaseBuffer().
| Datum pg_sequence_parameters | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1746 of file sequence.c.
References ACL_SELECT, ACL_UPDATE, ACL_USAGE, ACLCHECK_OK, BoolGetDatum(), elog, ereport, errcode(), errmsg(), ERROR, fb(), get_call_result_type(), get_rel_name(), GETSTRUCT(), GetUserId(), heap_form_tuple(), HeapTupleGetDatum(), HeapTupleIsValid, Int64GetDatum(), ObjectIdGetDatum(), pg_class_aclcheck(), PG_GETARG_OID, ReleaseSysCache(), SearchSysCache1(), TYPEFUNC_COMPOSITE, and values.
Definition at line 1598 of file sequence.c.
References AccessShareLock, Assert, attnum, ObjectAddress::classId, deleteDependencyRecordsForClass(), DEPENDENCY_AUTO, DEPENDENCY_INTERNAL, ereport, errcode(), errdetail(), errdetail_relkind_not_supported(), errhint(), errmsg(), ERROR, fb(), get_attnum(), get_rel_name(), InvalidAttrNumber, linitial, list_copy_head(), list_length(), llast, makeRangeVarFromNameList(), NoLock, recordDependencyOn(), relation_close(), relation_openrv(), RelationGetNamespace, RelationGetRelationName, RelationGetRelid, relname, sequenceIsOwned(), and strVal.
Referenced by AlterSequence(), and DefineSequence().
|
static |
Definition at line 1191 of file sequence.c.
References Assert, buf, BUFFER_LOCK_EXCLUSIVE, BufferGetPage(), elog, ERROR, fb(), FirstOffsetNumber, GETSTRUCT(), HEAP_XMAX_INVALID, HEAP_XMAX_IS_MULTI, HeapTupleHeaderGetRawXmax(), HeapTupleHeaderSetXmax(), InvalidTransactionId, ItemIdGetLength, ItemIdIsNormal, LockBuffer(), sequence_magic::magic, MarkBufferDirtyHint(), PageGetItem(), PageGetItemId(), PageGetSpecialPointer, ReadBuffer(), RelationGetRelationName, and SEQ_MAGIC.
Referenced by AlterSequence(), nextval_internal(), pg_get_sequence_data(), pg_sequence_last_value(), ResetSequence(), SequenceChangePersistence(), and SetSequence().
Definition at line 255 of file sequence.c.
References Assert, buf, SeqTableData::cached, elog, ERROR, fb(), fill_seq_with_data(), GETSTRUCT(), heap_copytuple(), HeapTupleIsValid, init_sequence(), InvalidMultiXactId, InvalidTransactionId, SeqTableData::last, NoLock, ObjectIdGetDatum(), read_seq_tuple(), RelationSetNewRelfilenumber(), ReleaseSysCache(), SearchSysCache1(), sequence_close(), and UnlockReleaseBuffer().
Referenced by ExecuteTruncateGuts().
Definition at line 1905 of file sequence.c.
References fb(), hash_destroy(), last_used_seq, and seqhashtab.
Referenced by DiscardAll(), and DiscardCommand().
Definition at line 1712 of file sequence.c.
References elog, ERROR, fb(), GETSTRUCT(), HeapTupleIsValid, INT64_FORMAT, lappend(), makeBoolean(), makeDefElem(), makeFloat(), NIL, ObjectIdGetDatum(), psprintf(), ReleaseSysCache(), and SearchSysCache1().
Referenced by transformTableLikeClause().
Definition at line 542 of file sequence.c.
References AccessExclusiveLock, buf, fb(), fill_seq_with_data(), GetTopTransactionId(), init_sequence(), LockRelationOid(), NoLock, read_seq_tuple(), RelationNeedsWAL, RelationSetNewRelfilenumber(), sequence_close(), and UnlockReleaseBuffer().
Referenced by ATRewriteTables().
Definition at line 946 of file sequence.c.
References ACL_UPDATE, ACLCHECK_OK, buf, BufferGetPage(), SeqTableData::cached, elog, END_CRIT_SECTION, ereport, errcode(), errmsg(), ERROR, fb(), GETSTRUCT(), GetTopTransactionId(), GetUserId(), HeapTupleIsValid, init_sequence(), SeqTableData::last, SeqTableData::last_valid, MarkBufferDirty(), next, NoLock, ObjectIdGetDatum(), PageSetLSN(), pg_class_aclcheck(), PreventCommandIfParallelMode(), PreventCommandIfReadOnly(), read_seq_tuple(), REGBUF_WILL_INIT, RelationGetRelationName, RelationNeedsWAL, ReleaseSysCache(), SeqTableData::relid, SearchSysCache1(), sequence_close(), START_CRIT_SECTION, UnlockReleaseBuffer(), XLOG_SEQ_LOG, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by copy_sequence(), setval3_oid(), and setval_oid().
| Datum setval3_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1065 of file sequence.c.
References fb(), next, PG_GETARG_BOOL, PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_INT64, and SetSequence().
| Datum setval_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1050 of file sequence.c.
References next, PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_INT64, and SetSequence().
|
static |
Definition at line 87 of file sequence.c.
Referenced by lastval(), nextval_internal(), and ResetSequenceCaches().
Definition at line 81 of file sequence.c.
Referenced by create_seq_hashtable(), init_sequence(), and ResetSequenceCaches().