1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
/*
* csrs.h
*
* $Id$
*
* This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
* project.
*
* Copyright (C) 1998-2018 OpenLink Software
*
* This project is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; only version 2 of the License, dated June 1991.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef _CRSR_H
#define _CRSR_H
#include "sqlcomp.h"
typedef struct id_cols_s
{
caddr_t idc_table;
ptrlong * idc_pos;
} id_cols_t;
#ifndef ST
#define ST struct sql_tree_s
#endif
typedef struct query_cursor_s
{
id_cols_t ** qc_id_cols;
long qc_n_id_cols;
ptrlong * qc_order_cols; /* position of all order cols in result set */
long qc_n_select_cols; /* This many from left to be sent to client */
ST * qc_org_text;
ST ** qc_id_order_col_refs; /*subtree of text_with_ids */
ST ** qc_order_by;
ST * qc_text_with_ids; /* text w/ id + order cols */
ST * qc_referesh_text;
ST * qc_update_text;
ST * qc_delete_text;
ST * qc_insert_text;
ST * qc_pos_where;
ST ** qc_next_text;
ST ** qc_prev_text;
ST * qc_refresh_text;
query_t * qc_refresh;
query_t * qc_update;
query_t * qc_delete;
query_t * qc_insert;
query_t ** qc_prev;
query_t **qc_next;
int qc_cursor_type; /* may differ from qr_cursor_type */
} query_cursor_t;
typedef struct rowset_item_s
{
caddr_t *rsi_id;
caddr_t *rsi_order;
caddr_t rsi_checksum;
caddr_t *rsi_row;
struct rowset_item_s *rsi_next;
struct rowset_item_s *rsi_prev;
}
rowset_item_t;
typedef struct keyset_s
{
int kset_count;
int kset_size;
int kset_is_complete; /* if all rows of cursor fit in */
/* id_hash_t *kset_ids; 2 */
rowset_item_t *kset_first;
rowset_item_t *kset_last;
rowset_item_t *kset_current;
int kset_co_pos;
}
keyset_t;
#define KSET_CO_FIRST 1
#define KSET_CO_LAST 2
#define CS_AT_START 1
#define CS_AT_END 2
#define CS_ON_ROW 3
#define FWD _SQL_FETCH_NEXT
#define BWD _SQL_FETCH_PRIOR
#define FIRST _SQL_FETCH_FIRST
#define LAST _SQL_FETCH_LAST
typedef struct cursor_state_s
{
caddr_t *cs_window_first;
caddr_t *cs_window_last;
caddr_t *cs_window_last_id;
caddr_t *cs_window_first_id;
caddr_t *cs_params;
keyset_t *cs_keyset;
int cs_keyset_pos;
caddr_t cs_error;
int cs_prev_dir;
int cs_state;
caddr_t *cs_from_order;
caddr_t *cs_from_id;
int cs_nth_cont;
query_t *cs_query;
local_cursor_t *cs_lc;
stmt_options_t *cs_opts;
client_connection_t *cs_client; /* 1 arg */
srv_stmt_t *cs_stmt;
int cs_lc_pos;
rowset_item_t **cs_rowset;
int cs_rowset_fill;
long cs_rowset_current_of;
int cs_position; /*index into rowset */
/* for keyset/mixed mode */
void *cs_client_data;
int cs_n_scrolled;
int cs_window_pos;
caddr_t cs_name;
/* PL scrollable cursors */
caddr_t * cs_pl_output_row;
long cs_pl_state;
} cursor_state_t;
#define CS_CR_TYPE(cs) cs->cs_query->qr_cursor->qc_cursor_type
#define CS_PL_ROW 1
#define CS_PL_AT_END 2
#define CS_PL_DELETED 3
#define CS_IS_PL_CURSOR(cs) cs->cs_stmt->sst_is_pl_cursor
#define STMT_IS_PL_CURSOR(stmt) stmt->sst_is_pl_cursor
#define CS_PL_SET_OUTPUT(cs, out) \
{ \
dk_free_tree ((box_t) (cs)->cs_pl_output_row); \
(cs)->cs_pl_output_row = (caddr_t *) box_copy_tree ((box_t) out); \
(cs)->cs_pl_state = CS_PL_ROW; \
}
/* cs_keyset_pos */
#define KSET_AT_START 1
#define KSET_MIDDLE 2
#define KSET_AT_END 3
/* cs_window_pos */
#define CS_WINDOW_START 0
#define CS_WINDOW_ROW 1
#define CS_WINDOW_END 2
/* cs_lc_pos */
#define LC_NONE 0
#define LC_AFTER_WINDOW 1
#define LC_BEFORE_WINDOW 2
#define _SQL_FETCH_NEXT 1
#define _SQL_FETCH_FIRST 2
#define _SQL_FETCH_LAST 3
#define _SQL_FETCH_PRIOR 4
#define _SQL_FETCH_ABSOLUTE 5
#define _SQL_FETCH_RELATIVE 6
#define _SQL_FETCH_BOOKMARK 8
#define IS_FWD(f) (_SQL_FETCH_NEXT == f || _SQL_FETCH_FIRST == f)
#define _SQL_POSITION 0 /* 1.0 FALSE */
#define _SQL_REFRESH 1 /* 1.0 TRUE */
#define _SQL_UPDATE 2
#define _SQL_DELETE 3
#define _SQL_ADD 4
typedef void (*kset_func) (cursor_state_t * cs);
extern long max_static_cursor_rows;
#define MAX_STATIC_CURSOR_ROWS max_static_cursor_rows
#define _MAX_STATIC_CURSOR_ROWS 5000
#define _SQL_BIND_BY_COLUMN 0
#define _SQL_CONCUR_VALUES 4
extern char __scroll_cr_init[17] /* = "__scroll_cr_init" */;
extern char __scroll_cr_open[17] /* = "__scroll_cr_open" */;
extern char __scroll_cr_close[18] /* = "__scroll_cr_close" */;
extern char __scroll_cr_fetch[18] /* = "__scroll_cr_fetch" */;
#define __SCROLL_CR_INIT __scroll_cr_init
#define __SCROLL_CR_OPEN __scroll_cr_open
#define __SCROLL_CR_CLOSE __scroll_cr_close
#define __SCROLL_CR_FETCH __scroll_cr_fetch
#endif /* _CRSR_H */
|