File: sqlcomp.h

package info (click to toggle)
virtuoso-opensource 6.1.6+dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (206 lines) | stat: -rw-r--r-- 5,361 bytes parent folder | download | duplicates (2)
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
/*
 *  sqlcomp.h
 *
 *  $Id$
 *
 *  SQL Query Description
 *
 *  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 *  project.
 *
 *  Copyright (C) 1998-2012 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 _SQLCOMP_H
#define _SQLCOMP_H

/*  Answer Tags */
#define QA_ROW		1
#define QA_ERROR	3
#define QA_COMPILED	4
#define QA_NEED_DATA	5
#define QA_PROC_RETURN	6
#define QA_ROWS_AFFECTED 7
#define QA_BLOB_POS	8 /* occurs in sf_sql_get_data_ac answer array */
#define QA_LOGIN	9
#define QA_ROW_ADDED	10
#define QA_ROW_UPDATED	11
#define QA_ROW_DELETED	12
#define QA_ROW_LAST_IN_BATCH 13
#define QA_WARNING	14


/* The QA_ROWS_AFFECTED case */
#define QA_N_AFFECTED	1

/* Fields in QA_LOGIN */
#define LG_QUALIFIER	1
#define LG_DB_VER	2
#define LG_DB_CASEMODE	3
#define LG_DEFAULTS 	4
#define LG_CHARSET 	5
#define QA_LOGIN_FIELDS 6

/* Fields in s_sql_login info param */
#define LGID_APP_NAME	0
#define LGID_PID	1
#define LGID_MACHINE	2
#define LGID_OS		3
#define LGID_CHARSET	4
#define LGID_SHUTDOWN	5
/* The QA_ERROR case */
#define QA_ERRNO	1
#define QA_ERROR_STRING	2

/* Query Compilation Return */
#define QC_STATUS	0

/* Fields for compilation error */
#define QC_ERRNO	1
#define QC_ERROR_STRING	2


typedef struct stmt_compilation_s
  {
    caddr_t *		sc_columns;
    ptrlong		sc_is_select;
    caddr_t *		sc_cursors_used;
    caddr_t *		sc_params;
    ptrlong		sc_hidden_columns;
  } stmt_compilation_t;

/* values for sc_is_select */
#define QT_UPDATE 0
#define QT_SELECT 1
#define QT_PROC_CALL 2

#define SC_HIDDEN_COLUMNS(sc) \
  (sc && (box_length ((caddr_t) sc) > (ptrlong) & (((stmt_compilation_t*)0)->sc_hidden_columns)) \
   ? sc->sc_hidden_columns : 0)


typedef struct param_desc_s
  {
    caddr_t		pd_dtp;
    caddr_t		pd_prec;
    caddr_t		pd_scale;
    caddr_t		pd_nullable;
    /* Access the fileds below only if PARAM_DESC_IS_EXTENDED() is true. */
    caddr_t		pd_name;
    caddr_t		pd_iotype;
  } param_desc_t;

#define PARAM_DESC_IS_EXTENDED(param) \
  (param && (box_length ((caddr_t) param) > (ptrlong) & ((param_desc_t*)0)->pd_iotype))


/* Fields for output column */

typedef struct col_desc_s
  {
    char *		cd_name;
    ptrlong		cd_dtp;
    caddr_t		cd_scale;
    caddr_t		cd_precision;
    caddr_t		cd_nullable;
    caddr_t		cd_updatable;
    caddr_t		cd_searchable;
    /* Access the fileds below only if COL_DESC_IS_EXTENDED() is true. */
    char *		cd_base_catalog_name;
    char *		cd_base_column_name;
    char *		cd_base_schema_name;
    char *		cd_base_table_name;
    caddr_t		cd_flags;
  } col_desc_t;

#define COL_DESC_IS_EXTENDED(col) \
  (col && (box_length ((caddr_t) col) > (ptrlong) & ((col_desc_t*)0)->cd_flags))

#define CDF_KEY			1
#define CDF_AUTOINCREMENT	2
#define CDF_XMLTYPE		4 /* the column contains XML */


/* Statement Options */

typedef struct stmt_options_s {
  ptrlong            so_concurrency;
  ptrlong            so_is_async;
  ptrlong            so_max_rows;
  ptrlong            so_timeout;
  ptrlong            so_prefetch;
  ptrlong            so_autocommit;
  ptrlong            so_rpc_timeout;
  ptrlong		  so_cursor_type;
  ptrlong		  so_keyset_size;
  ptrlong		  so_use_bookmarks;
  ptrlong		  so_isolation;
  ptrlong		  so_prefetch_bytes;
  ptrlong		so_unique_rows;
} stmt_options_t;

#define SO_CURSOR_TYPE(so) \
  (so && (box_length ((caddr_t) so) > (ptrlong) & (((stmt_options_t*)0)->so_cursor_type)) \
   ? so->so_cursor_type : _SQL_CURSOR_FORWARD_ONLY)

#define SO_ISOLATION(so) \
  (so && (box_length ((caddr_t) so) > (ptrlong) & (((stmt_options_t*)0)->so_isolation)) \
   ? so->so_isolation : ISO_REPEATABLE)


#define SO_PREFETCH_BYTES(so) \
  (so && (box_length ((caddr_t) so) > (ptrlong) & (((stmt_options_t*)0)->so_prefetch_bytes)) \
   ? so->so_prefetch_bytes : 0)


#define SO_UNIQUE_ROWS(so) \
  (so && (box_length ((caddr_t) so) > (ptrlong) & (((stmt_options_t*)0)->so_unique_rows)) \
   ? so->so_unique_rows : 0)

#define SET_QR_TEXT(qr,text) \
  qr->qr_text = qr->qr_text_is_constant ?  (caddr_t) text : box_string (text)

#define _SQL_CURSOR_FORWARD_ONLY 	0
#define _SQL_CURSOR_KEYSET_DRIVEN	1
#define _SQL_CURSOR_DYNAMIC		2
#define _SQL_CURSOR_STATIC		3



#define SELECT_PREFETCH_QUOTA	20
#define PREFETCH_ALL -1

#define SO_DEFAULT_TIMEOUT	0 /* indefinite */


/* so_isolation */
#define ISO_UNCOMMITTED		1
#define ISO_COMMITTED		2
#define ISO_REPEATABLE 	4
#define ISO_SERIALIZABLE	8




/* so_isolation */
#define _SQL_TXN_READ_UNCOMMITTED	0x00000001L
#define _SQL_TXN_READ_COMMITTED		0x00000002L
#define _SQL_TXN_REPEATABLE_READ 	0x00000004L
#define _SQL_TXN_SERIALIZABLE		0x00000008L
#define _SQL_TXN_VERSIONING		0x00000010L

#endif /* _SQLCOMP_H */