~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/include/commands/sequence.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * sequence.h
 
4
 *        prototypes for sequence.c.
 
5
 *
 
6
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
7
 * Portions Copyright (c) 1994, Regents of the University of California
 
8
 *
 
9
 * $PostgreSQL: pgsql/src/include/commands/sequence.h,v 1.30 2004-12-31 22:03:28 pgsql Exp $
 
10
 *
 
11
 *-------------------------------------------------------------------------
 
12
 */
 
13
#ifndef SEQUENCE_H
 
14
#define SEQUENCE_H
 
15
 
 
16
#include "nodes/parsenodes.h"
 
17
#include "access/xlog.h"
 
18
#include "fmgr.h"
 
19
 
 
20
 
 
21
/*
 
22
 * On a machine with no 64-bit-int C datatype, sizeof(int64) will not be 8,
 
23
 * but we need this struct type to line up with the way that a sequence
 
24
 * table is defined --- and pg_type will say that int8 is 8 bytes anyway.
 
25
 * So, we need padding.  Ugly but necessary.
 
26
 */
 
27
typedef struct FormData_pg_sequence
 
28
{
 
29
        NameData        sequence_name;
 
30
#ifndef INT64_IS_BUSTED
 
31
        int64           last_value;
 
32
        int64           increment_by;
 
33
        int64           max_value;
 
34
        int64           min_value;
 
35
        int64           cache_value;
 
36
        int64           log_cnt;
 
37
#else
 
38
        int32           last_value;
 
39
        int32           pad1;
 
40
        int32           increment_by;
 
41
        int32           pad2;
 
42
        int32           max_value;
 
43
        int32           pad3;
 
44
        int32           min_value;
 
45
        int32           pad4;
 
46
        int32           cache_value;
 
47
        int32           pad5;
 
48
        int32           log_cnt;
 
49
        int32           pad6;
 
50
#endif
 
51
        bool            is_cycled;
 
52
        bool            is_called;
 
53
} FormData_pg_sequence;
 
54
 
 
55
typedef FormData_pg_sequence *Form_pg_sequence;
 
56
 
 
57
/*
 
58
 * Columns of a sequence relation
 
59
 */
 
60
 
 
61
#define SEQ_COL_NAME                    1
 
62
#define SEQ_COL_LASTVAL                 2
 
63
#define SEQ_COL_INCBY                   3
 
64
#define SEQ_COL_MAXVALUE                4
 
65
#define SEQ_COL_MINVALUE                5
 
66
#define SEQ_COL_CACHE                   6
 
67
#define SEQ_COL_LOG                             7
 
68
#define SEQ_COL_CYCLE                   8
 
69
#define SEQ_COL_CALLED                  9
 
70
 
 
71
#define SEQ_COL_FIRSTCOL                SEQ_COL_NAME
 
72
#define SEQ_COL_LASTCOL                 SEQ_COL_CALLED
 
73
 
 
74
/* XLOG stuff */
 
75
#define XLOG_SEQ_LOG                    0x00
 
76
 
 
77
typedef struct xl_seq_rec
 
78
{
 
79
        RelFileNode node;
 
80
        /* SEQUENCE TUPLE DATA FOLLOWS AT THE END */
 
81
} xl_seq_rec;
 
82
 
 
83
extern Datum nextval(PG_FUNCTION_ARGS);
 
84
extern Datum currval(PG_FUNCTION_ARGS);
 
85
extern Datum setval(PG_FUNCTION_ARGS);
 
86
extern Datum setval_and_iscalled(PG_FUNCTION_ARGS);
 
87
 
 
88
extern void DefineSequence(CreateSeqStmt *stmt);
 
89
extern void AlterSequence(AlterSeqStmt *stmt);
 
90
 
 
91
extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
 
92
extern void seq_undo(XLogRecPtr lsn, XLogRecord *rptr);
 
93
extern void seq_desc(char *buf, uint8 xl_info, char *rec);
 
94
 
 
95
/* Set the upper and lower bounds of a sequence */
 
96
#ifndef INT64_IS_BUSTED
 
97
#ifdef HAVE_LL_CONSTANTS
 
98
#define SEQ_MAXVALUE    ((int64) 0x7FFFFFFFFFFFFFFFLL)
 
99
#else
 
100
#define SEQ_MAXVALUE    ((int64) 0x7FFFFFFFFFFFFFFF)
 
101
#endif
 
102
#else                                                   /* INT64_IS_BUSTED */
 
103
#define SEQ_MAXVALUE    ((int64) 0x7FFFFFFF)
 
104
#endif   /* INT64_IS_BUSTED */
 
105
 
 
106
#define SEQ_MINVALUE    (-SEQ_MAXVALUE)
 
107
 
 
108
#endif   /* SEQUENCE_H */