|
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.
| typedef SeqTableData* SeqTable |
Definition at line 79 of file sequence.c.
| typedef struct SeqTableData SeqTableData |
| ObjectAddress AlterSequence | ( | ParseState * | pstate, |
| AlterSeqStmt * | stmt | ||
| ) |
Definition at line 429 of file sequence.c.
References Assert(), buf, SeqTableData::cached, CatalogTupleUpdate(), elog, ereport, errmsg(), ERROR, fill_seq_with_data(), GETSTRUCT(), GetTopTransactionId(), heap_copytuple(), HeapTupleIsValid, init_params(), init_sequence(), InvalidMultiXactId, InvalidObjectAddress, InvalidOid, InvalidTransactionId, InvokeObjectPostAlterHook, FormData_pg_sequence_data::is_called, SeqTableData::last, FormData_pg_sequence_data::last_value, FormData_pg_sequence_data::log_cnt, NoLock, NOTICE, ObjectAddressSet, ObjectIdGetDatum(), process_owned_by(), RangeVarCallbackOwnsRelation(), RangeVarGetRelidExtended(), RelationData::rd_rel, read_seq_tuple(), RelationNeedsWAL, RelationSetNewRelfilenumber(), RowExclusiveLock, RVR_MISSING_OK, SearchSysCacheCopy1, sequence_close(), ShareRowExclusiveLock, stmt, HeapTupleData::t_self, table_close(), table_open(), and UnlockReleaseBuffer().
Referenced by ProcessUtilitySlow().
|
static |
Definition at line 1114 of file sequence.c.
References ctl, HASH_BLOBS, hash_create(), HASH_ELEM, 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, 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(), fill_seq_with_data(), CreateSeqStmt::for_identity, FormData_pg_sequence, heap_form_tuple(), heap_freetuple(), i, CreateSeqStmt::if_not_exists, init_params(), Int64GetDatum(), Int64GetDatumFast, InvalidObjectAddress, InvalidOid, ColumnDef::is_not_null, lappend(), makeColumnDef(), makeNode, NIL, NoLock, NOTICE, ObjectAddressSet, ObjectAddress::objectId, ObjectIdGetDatum(), OidIsValid, ONCOMMIT_NOOP, CreateSeqStmt::options, CreateSeqStmt::ownerId, process_owned_by(), RangeVarGetAndCheckCreationNamespace(), RelationGetDescr, RangeVar::relname, RowExclusiveLock, SEQ_COL_CALLED, SEQ_COL_FIRSTCOL, SEQ_COL_LASTCOL, SEQ_COL_LASTVAL, SEQ_COL_LOG, CreateSeqStmt::sequence, sequence_close(), sequence_open(), stmt, table_close(), table_open(), and value.
Referenced by ProcessUtilitySlow().
| void DeleteSequenceTuple | ( | Oid | relid | ) |
Definition at line 571 of file sequence.c.
References CatalogTupleDelete(), elog, ERROR, 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(), FirstCommandId, FirstOffsetNumber, FrozenTransactionId, GetTopTransactionId(), HEAP_XMAX_INVALID, HeapTupleHeaderSetCmin(), HeapTupleHeaderSetXmax(), HeapTupleHeaderSetXmin(), HeapTupleHeaderSetXminFrozen(), INIT_FORKNUM, InvalidOffsetNumber, InvalidTransactionId, ItemPointerSet(), xl_seq_rec::locator, 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 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 DefElem::arg, Assert(), BoolIsValid, boolVal, defGetInt64(), defGetQualifiedName(), defGetTypeName(), DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, errorConflictingDefElem(), format_type_be(), lfirst, DefElem::location, 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(), SeqTableData::filenumber, HASH_ENTER, hash_search(), InvalidLocalTransactionId, InvalidRelFileNumber, SeqTableData::last, SeqTableData::last_valid, lock_and_open_sequence(), SeqTableData::lxid, RelationData::rd_rel, and seqhashtab.
Referenced by AlterSequence(), currval_oid(), nextval_internal(), pg_get_sequence_data(), 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, 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, LockRelationOid(), SeqTableData::lxid, PGPROC::lxid, MyProc, NoLock, SeqTableData::relid, 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 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, GetRedoRecPtr(), GETSTRUCT(), GetTopTransactionId(), GetUserId(), HeapTupleIsValid, SeqTableData::increment, init_sequence(), FormData_pg_sequence_data::is_called, SeqTableData::last, last_used_seq, SeqTableData::last_valid, FormData_pg_sequence_data::last_value, xl_seq_rec::locator, FormData_pg_sequence_data::log_cnt, MarkBufferDirty(), next, NoLock, ObjectIdGetDatum(), PageGetLSN(), PageSetLSN(), pg_class_aclcheck(), PreventCommandIfParallelMode(), PreventCommandIfReadOnly(), RelationData::rd_islocaltemp, RelationData::rd_locator, read_seq_tuple(), REGBUF_WILL_INIT, RelationGetRelationName, RelationNeedsWAL, ReleaseSysCache(), SeqTableData::relid, SearchSysCache1(), SEQ_LOG_VALS, sequence_close(), START_CRIT_SECTION, HeapTupleData::t_data, HeapTupleData::t_len, 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 ACL_SELECT, ACLCHECK_OK, BlessTupleDesc(), BoolGetDatum(), buf, BufferGetPage(), CreateTemplateTupleDesc(), GetUserId(), heap_form_tuple(), HeapTupleGetDatum(), init_sequence(), Int64GetDatum(), FormData_pg_sequence_data::is_called, FormData_pg_sequence_data::last_value, LSNGetDatum(), NoLock, PageGetLSN(), pg_class_aclcheck(), PG_GET_SEQUENCE_DATA_COLS, PG_GETARG_OID, PG_RETURN_DATUM, read_seq_tuple(), RecoveryInProgress(), RELATION_IS_OTHER_TEMP, RelationIsPermanent, sequence_close(), TupleDescInitEntry(), UnlockReleaseBuffer(), and values.
| Datum pg_sequence_last_value | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1856 of file sequence.c.
References ACL_SELECT, ACL_USAGE, ACLCHECK_OK, buf, GetUserId(), init_sequence(), FormData_pg_sequence_data::is_called, FormData_pg_sequence_data::last_value, 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, 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, get_attnum(), get_rel_name(), InvalidAttrNumber, linitial, list_copy_head(), list_length(), llast, makeRangeVarFromNameList(), NoLock, ObjectAddress::objectId, ObjectAddress::objectSubId, RelationData::rd_rel, 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, FirstOffsetNumber, GETSTRUCT(), HEAP_XMAX_INVALID, HEAP_XMAX_IS_MULTI, HeapTupleHeaderGetRawXmax(), HeapTupleHeaderSetXmax(), InvalidTransactionId, ItemIdGetLength, ItemIdIsNormal, LockBuffer(), sequence_magic::magic, MarkBufferDirtyHint(), PageGetItem(), PageGetItemId(), PageGetSpecialPointer, ReadBuffer(), RelationGetRelationName, SEQ_MAGIC, HeapTupleData::t_data, HeapTupleHeaderData::t_infomask, and HeapTupleData::t_len.
Referenced by AlterSequence(), nextval_internal(), pg_get_sequence_data(), pg_sequence_last_value(), ResetSequence(), SequenceChangePersistence(), and SetSequence().
| void ResetSequence | ( | Oid | seq_relid | ) |
Definition at line 255 of file sequence.c.
References Assert(), buf, SeqTableData::cached, elog, ERROR, fill_seq_with_data(), GETSTRUCT(), heap_copytuple(), HeapTupleIsValid, init_sequence(), InvalidMultiXactId, InvalidTransactionId, FormData_pg_sequence_data::is_called, SeqTableData::last, FormData_pg_sequence_data::last_value, FormData_pg_sequence_data::log_cnt, NoLock, ObjectIdGetDatum(), RelationData::rd_rel, read_seq_tuple(), RelationSetNewRelfilenumber(), ReleaseSysCache(), SearchSysCache1(), sequence_close(), and UnlockReleaseBuffer().
Referenced by ExecuteTruncateGuts().
| void ResetSequenceCaches | ( | void | ) |
Definition at line 1903 of file sequence.c.
References hash_destroy(), last_used_seq, and seqhashtab.
Referenced by DiscardAll(), and DiscardCommand().
Definition at line 1712 of file sequence.c.
References elog, ERROR, GETSTRUCT(), HeapTupleIsValid, INT64_FORMAT, lappend(), makeBoolean(), makeDefElem(), makeFloat(), NIL, ObjectIdGetDatum(), options, psprintf(), ReleaseSysCache(), and SearchSysCache1().
Referenced by transformTableLikeClause().
| void SequenceChangePersistence | ( | Oid | relid, |
| char | newrelpersistence | ||
| ) |
Definition at line 542 of file sequence.c.
References AccessExclusiveLock, buf, 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, GETSTRUCT(), GetTopTransactionId(), GetUserId(), HeapTupleIsValid, init_sequence(), FormData_pg_sequence_data::is_called, SeqTableData::last, SeqTableData::last_valid, FormData_pg_sequence_data::last_value, xl_seq_rec::locator, FormData_pg_sequence_data::log_cnt, MarkBufferDirty(), next, NoLock, ObjectIdGetDatum(), PageSetLSN(), pg_class_aclcheck(), PreventCommandIfParallelMode(), PreventCommandIfReadOnly(), RelationData::rd_islocaltemp, RelationData::rd_locator, read_seq_tuple(), REGBUF_WILL_INIT, RelationGetRelationName, RelationNeedsWAL, ReleaseSysCache(), SeqTableData::relid, SearchSysCache1(), sequence_close(), START_CRIT_SECTION, HeapTupleData::t_data, HeapTupleData::t_len, 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 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().
|
static |
Definition at line 81 of file sequence.c.
Referenced by create_seq_hashtable(), init_sequence(), and ResetSequenceCaches().