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.

105 lines
2.8 KiB

17 years ago
17 years ago
17 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
16 years ago
  1. /*****************************************************************************
  2. Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved.
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free Software
  5. Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along with
  10. this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
  12. *****************************************************************************/
  13. /**************************************************//**
  14. @file include/row0sel.ic
  15. Select
  16. Created 12/19/1997 Heikki Tuuri
  17. *******************************************************/
  18. #include "que0que.h"
  19. /*********************************************************************//**
  20. Gets the plan node for the nth table in a join.
  21. @return plan node */
  22. UNIV_INLINE
  23. plan_t*
  24. sel_node_get_nth_plan(
  25. /*==================*/
  26. sel_node_t* node, /*!< in: select node */
  27. ulint i) /*!< in: get ith plan node */
  28. {
  29. ut_ad(i < node->n_tables);
  30. return(node->plans + i);
  31. }
  32. /*********************************************************************//**
  33. Resets the cursor defined by sel_node to the SEL_NODE_OPEN state, which means
  34. that it will start fetching from the start of the result set again, regardless
  35. of where it was before, and it will set intention locks on the tables. */
  36. UNIV_INLINE
  37. void
  38. sel_node_reset_cursor(
  39. /*==================*/
  40. sel_node_t* node) /*!< in: select node */
  41. {
  42. node->state = SEL_NODE_OPEN;
  43. }
  44. /**********************************************************************//**
  45. Performs an execution step of an open or close cursor statement node.
  46. @return query thread to run next or NULL */
  47. UNIV_INLINE
  48. que_thr_t*
  49. open_step(
  50. /*======*/
  51. que_thr_t* thr) /*!< in: query thread */
  52. {
  53. sel_node_t* sel_node;
  54. open_node_t* node;
  55. ulint err;
  56. ut_ad(thr);
  57. node = (open_node_t*) thr->run_node;
  58. ut_ad(que_node_get_type(node) == QUE_NODE_OPEN);
  59. sel_node = node->cursor_def;
  60. err = DB_SUCCESS;
  61. if (node->op_type == ROW_SEL_OPEN_CURSOR) {
  62. /* if (sel_node->state == SEL_NODE_CLOSED) { */
  63. sel_node_reset_cursor(sel_node);
  64. /* } else {
  65. err = DB_ERROR;
  66. } */
  67. } else {
  68. if (sel_node->state != SEL_NODE_CLOSED) {
  69. sel_node->state = SEL_NODE_CLOSED;
  70. } else {
  71. err = DB_ERROR;
  72. }
  73. }
  74. if (err != DB_SUCCESS) {
  75. /* SQL error detected */
  76. fprintf(stderr, "SQL error %lu\n", (ulong) err);
  77. ut_error;
  78. }
  79. thr->run_node = que_node_get_parent(node);
  80. return(thr);
  81. }