1/*-------------------------------------------------------------------------
2 *
3 * sequence.h
4 * prototypes for sequence.c.
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/commands/sequence.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef SEQUENCE_H
14#define SEQUENCE_H
15
16#include "access/xlogreader.h"
17#include "catalog/objectaddress.h"
18#include "fmgr.h"
19#include "lib/stringinfo.h"
20#include "nodes/parsenodes.h"
21#include "parser/parse_node.h"
22#include "storage/relfilenode.h"
23
24
25typedef struct FormData_pg_sequence_data
26{
27 int64 last_value;
28 int64 log_cnt;
29 bool is_called;
30} FormData_pg_sequence_data;
31
32typedef FormData_pg_sequence_data *Form_pg_sequence_data;
33
34/*
35 * Columns of a sequence relation
36 */
37
38#define SEQ_COL_LASTVAL 1
39#define SEQ_COL_LOG 2
40#define SEQ_COL_CALLED 3
41
42#define SEQ_COL_FIRSTCOL SEQ_COL_LASTVAL
43#define SEQ_COL_LASTCOL SEQ_COL_CALLED
44
45/* XLOG stuff */
46#define XLOG_SEQ_LOG 0x00
47
48typedef struct xl_seq_rec
49{
50 RelFileNode node;
51 /* SEQUENCE TUPLE DATA FOLLOWS AT THE END */
52} xl_seq_rec;
53
54extern int64 nextval_internal(Oid relid, bool check_permissions);
55extern Datum nextval(PG_FUNCTION_ARGS);
56extern List *sequence_options(Oid relid);
57
58extern ObjectAddress DefineSequence(ParseState *pstate, CreateSeqStmt *stmt);
59extern ObjectAddress AlterSequence(ParseState *pstate, AlterSeqStmt *stmt);
60extern void DeleteSequenceTuple(Oid relid);
61extern void ResetSequence(Oid seq_relid);
62extern void ResetSequenceCaches(void);
63
64extern void seq_redo(XLogReaderState *rptr);
65extern void seq_desc(StringInfo buf, XLogReaderState *rptr);
66extern const char *seq_identify(uint8 info);
67extern void seq_mask(char *pagedata, BlockNumber blkno);
68
69#endif /* SEQUENCE_H */
70