Header And Logo

PostgreSQL
| The world's most advanced open source database.

sequence.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * sequence.h
00004  *    prototypes for sequence.c.
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  * Portions Copyright (c) 1994, Regents of the University of California
00008  *
00009  * src/include/commands/sequence.h
00010  *
00011  *-------------------------------------------------------------------------
00012  */
00013 #ifndef SEQUENCE_H
00014 #define SEQUENCE_H
00015 
00016 #include "access/xlog.h"
00017 #include "fmgr.h"
00018 #include "nodes/parsenodes.h"
00019 #include "storage/relfilenode.h"
00020 
00021 
00022 typedef struct FormData_pg_sequence
00023 {
00024     NameData    sequence_name;
00025     int64       last_value;
00026     int64       start_value;
00027     int64       increment_by;
00028     int64       max_value;
00029     int64       min_value;
00030     int64       cache_value;
00031     int64       log_cnt;
00032     bool        is_cycled;
00033     bool        is_called;
00034 } FormData_pg_sequence;
00035 
00036 typedef FormData_pg_sequence *Form_pg_sequence;
00037 
00038 /*
00039  * Columns of a sequence relation
00040  */
00041 
00042 #define SEQ_COL_NAME            1
00043 #define SEQ_COL_LASTVAL         2
00044 #define SEQ_COL_STARTVAL        3
00045 #define SEQ_COL_INCBY           4
00046 #define SEQ_COL_MAXVALUE        5
00047 #define SEQ_COL_MINVALUE        6
00048 #define SEQ_COL_CACHE           7
00049 #define SEQ_COL_LOG             8
00050 #define SEQ_COL_CYCLE           9
00051 #define SEQ_COL_CALLED          10
00052 
00053 #define SEQ_COL_FIRSTCOL        SEQ_COL_NAME
00054 #define SEQ_COL_LASTCOL         SEQ_COL_CALLED
00055 
00056 /* XLOG stuff */
00057 #define XLOG_SEQ_LOG            0x00
00058 
00059 typedef struct xl_seq_rec
00060 {
00061     RelFileNode node;
00062     /* SEQUENCE TUPLE DATA FOLLOWS AT THE END */
00063 } xl_seq_rec;
00064 
00065 extern Datum nextval(PG_FUNCTION_ARGS);
00066 extern Datum nextval_oid(PG_FUNCTION_ARGS);
00067 extern Datum currval_oid(PG_FUNCTION_ARGS);
00068 extern Datum setval_oid(PG_FUNCTION_ARGS);
00069 extern Datum setval3_oid(PG_FUNCTION_ARGS);
00070 extern Datum lastval(PG_FUNCTION_ARGS);
00071 
00072 extern Datum pg_sequence_parameters(PG_FUNCTION_ARGS);
00073 
00074 extern Oid DefineSequence(CreateSeqStmt *stmt);
00075 extern Oid AlterSequence(AlterSeqStmt *stmt);
00076 extern void ResetSequence(Oid seq_relid);
00077 
00078 extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
00079 extern void seq_desc(StringInfo buf, uint8 xl_info, char *rec);
00080 
00081 #endif   /* SEQUENCE_H */