sequence.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*-------------------------------------------------------------------------
  2. *
  3. * sequence.h
  4. * prototypes for sequence.c.
  5. *
  6. * Portions Copyright (c) 1996-2016, 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. #include "access/xlogreader.h"
  16. #include "catalog/objectaddress.h"
  17. #include "fmgr.h"
  18. #include "lib/stringinfo.h"
  19. #include "nodes/parsenodes.h"
  20. #include "storage/relfilenode.h"
  21. typedef struct FormData_pg_sequence
  22. {
  23. NameData sequence_name;
  24. int64 last_value;
  25. int64 start_value;
  26. int64 increment_by;
  27. int64 max_value;
  28. int64 min_value;
  29. int64 cache_value;
  30. int64 log_cnt;
  31. bool is_cycled;
  32. bool is_called;
  33. } FormData_pg_sequence;
  34. typedef FormData_pg_sequence *Form_pg_sequence;
  35. /*
  36. * Columns of a sequence relation
  37. */
  38. #define SEQ_COL_NAME 1
  39. #define SEQ_COL_LASTVAL 2
  40. #define SEQ_COL_STARTVAL 3
  41. #define SEQ_COL_INCBY 4
  42. #define SEQ_COL_MAXVALUE 5
  43. #define SEQ_COL_MINVALUE 6
  44. #define SEQ_COL_CACHE 7
  45. #define SEQ_COL_LOG 8
  46. #define SEQ_COL_CYCLE 9
  47. #define SEQ_COL_CALLED 10
  48. #define SEQ_COL_FIRSTCOL SEQ_COL_NAME
  49. #define SEQ_COL_LASTCOL SEQ_COL_CALLED
  50. /* XLOG stuff */
  51. #define XLOG_SEQ_LOG 0x00
  52. typedef struct xl_seq_rec
  53. {
  54. RelFileNode node;
  55. /* SEQUENCE TUPLE DATA FOLLOWS AT THE END */
  56. } xl_seq_rec;
  57. extern Datum nextval(PG_FUNCTION_ARGS);
  58. extern Datum nextval_oid(PG_FUNCTION_ARGS);
  59. extern Datum currval_oid(PG_FUNCTION_ARGS);
  60. extern Datum setval_oid(PG_FUNCTION_ARGS);
  61. extern Datum setval3_oid(PG_FUNCTION_ARGS);
  62. extern Datum lastval(PG_FUNCTION_ARGS);
  63. extern Datum pg_sequence_parameters(PG_FUNCTION_ARGS);
  64. extern ObjectAddress DefineSequence(CreateSeqStmt *stmt);
  65. extern ObjectAddress AlterSequence(AlterSeqStmt *stmt);
  66. extern void ResetSequence(Oid seq_relid);
  67. extern void ResetSequenceCaches(void);
  68. extern void seq_redo(XLogReaderState *rptr);
  69. extern void seq_desc(StringInfo buf, XLogReaderState *rptr);
  70. extern const char *seq_identify(uint8 info);
  71. #endif /* SEQUENCE_H */