You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.7 KiB

20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
  1. /******************************************************
  2. Cursor read
  3. (c) 1997 Innobase Oy
  4. Created 2/16/1997 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef read0read_h
  7. #define read0read_h
  8. #include "univ.i"
  9. #include "ut0byte.h"
  10. #include "ut0lst.h"
  11. #include "trx0trx.h"
  12. #include "read0types.h"
  13. /*************************************************************************
  14. Opens a read view where exactly the transactions serialized before this
  15. point in time are seen in the view. */
  16. read_view_t*
  17. read_view_open_now(
  18. /*===============*/
  19. /* out, own: read view struct */
  20. dulint cr_trx_id, /* in: trx_id of creating
  21. transaction, or (0, 0) used in
  22. purge */
  23. mem_heap_t* heap); /* in: memory heap from which
  24. allocated */
  25. /*************************************************************************
  26. Makes a copy of the oldest existing read view, or opens a new. The view
  27. must be closed with ..._close. */
  28. read_view_t*
  29. read_view_oldest_copy_or_open_new(
  30. /*==============================*/
  31. /* out, own: read view struct */
  32. dulint cr_trx_id, /* in: trx_id of creating
  33. transaction, or (0, 0) used in
  34. purge */
  35. mem_heap_t* heap); /* in: memory heap from which
  36. allocated */
  37. /*************************************************************************
  38. Closes a read view. */
  39. void
  40. read_view_close(
  41. /*============*/
  42. read_view_t* view); /* in: read view */
  43. /*************************************************************************
  44. Closes a consistent read view for MySQL. This function is called at an SQL
  45. statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */
  46. void
  47. read_view_close_for_mysql(
  48. /*======================*/
  49. trx_t* trx); /* in: trx which has a read view */
  50. /*************************************************************************
  51. Checks if a read view sees the specified transaction. */
  52. UNIV_INLINE
  53. ibool
  54. read_view_sees_trx_id(
  55. /*==================*/
  56. /* out: TRUE if sees */
  57. read_view_t* view, /* in: read view */
  58. dulint trx_id);/* in: trx id */
  59. /*************************************************************************
  60. Prints a read view to stderr. */
  61. void
  62. read_view_print(
  63. /*============*/
  64. read_view_t* view); /* in: read view */
  65. /*************************************************************************
  66. Create a consistent cursor view for mysql to be used in cursors. In this
  67. consistent read view modifications done by the creating transaction or future
  68. transactions are not visible. */
  69. cursor_view_t*
  70. read_cursor_view_create_for_mysql(
  71. /*==============================*/
  72. trx_t* cr_trx);/* in: trx where cursor view is created */
  73. /*************************************************************************
  74. Close a given consistent cursor view for mysql and restore global read view
  75. back to a transaction read view. */
  76. void
  77. read_cursor_view_close_for_mysql(
  78. /*=============================*/
  79. trx_t* trx, /* in: trx */
  80. cursor_view_t* curview); /* in: cursor view to be closed */
  81. /*************************************************************************
  82. This function sets a given consistent cursor view to a transaction
  83. read view if given consistent cursor view is not NULL. Otherwise, function
  84. restores a global read view to a transaction read view. */
  85. void
  86. read_cursor_set_for_mysql(
  87. /*======================*/
  88. trx_t* trx, /* in: transaction where cursor is set */
  89. cursor_view_t* curview);/* in: consistent cursor view to be set */
  90. /* Read view lists the trx ids of those transactions for which a consistent
  91. read should not see the modifications to the database. */
  92. struct read_view_struct{
  93. ulint type; /* VIEW_NORMAL, VIEW_HIGH_GRANULARITY */
  94. dulint undo_no; /* (0, 0) or if type is VIEW_HIGH_GRANULARITY
  95. transaction undo_no when this high-granularity
  96. consistent read view was created */
  97. ibool can_be_too_old; /* TRUE if the system has had to purge old
  98. versions which this read view should be able
  99. to access: the read view can bump into the
  100. DB_MISSING_HISTORY error */
  101. dulint low_limit_no; /* The view does not need to see the undo
  102. logs for transactions whose transaction number
  103. is strictly smaller (<) than this value: they
  104. can be removed in purge if not needed by other
  105. views */
  106. dulint low_limit_id; /* The read should not see any transaction
  107. with trx id >= this value */
  108. dulint up_limit_id; /* The read should see all trx ids which
  109. are strictly smaller (<) than this value */
  110. ulint n_trx_ids; /* Number of cells in the trx_ids array */
  111. dulint* trx_ids; /* Additional trx ids which the read should
  112. not see: typically, these are the active
  113. transactions at the time when the read is
  114. serialized, except the reading transaction
  115. itself; the trx ids in this array are in a
  116. descending order */
  117. dulint creator_trx_id; /* trx id of creating transaction, or
  118. (0, 0) used in purge */
  119. UT_LIST_NODE_T(read_view_t) view_list;
  120. /* List of read views in trx_sys */
  121. };
  122. /* Read view types */
  123. #define VIEW_NORMAL 1 /* Normal consistent read view
  124. where transaction does not see changes
  125. made by active transactions except
  126. creating transaction. */
  127. #define VIEW_HIGH_GRANULARITY 2 /* High-granularity read view where
  128. transaction does not see changes
  129. made by active transactions and own
  130. changes after a point in time when this
  131. read view was created. */
  132. /* Implement InnoDB framework to support consistent read views in
  133. cursors. This struct holds both heap where consistent read view
  134. is allocated and pointer to a read view. */
  135. struct cursor_view_struct{
  136. mem_heap_t* heap;
  137. /* Memory heap for the cursor view */
  138. read_view_t* read_view;
  139. /* Consistent read view of the cursor*/
  140. ulint n_mysql_tables_in_use;
  141. /* number of Innobase tables used in the
  142. processing of this cursor */
  143. };
  144. #ifndef UNIV_NONINL
  145. #include "read0read.ic"
  146. #endif
  147. #endif