File: sqlrrun.c

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 (266 lines) | stat: -rw-r--r-- 5,428 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
 *  sqlrrun.c
 *
 *  $Id$
 *
 *  VDB SQL Remote query execution.
 *
 *  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
 *
 */

#include "Dk.h"
#include "odbcinc.h"
#include "sqlnode.h"
#include "sqlopcod.h"
#include "sqlbif.h"
#include "security.h"
#include "remote.h"
#include "list2.h"
#include "date.h"
#include "datesupp.h"
#include "libutil.h"
#if !defined (__APPLE__)
#include <wchar.h>
#endif
#include "multibyte.h"
#include "srvmultibyte.h"
#include "sqlver.h"
#include "statuslog.h"
#include "sqlpar.h"
#include "sqltype.h"
#include "virtext.h"
#include "virtpwd.h"
#include "virtpwd.h"
#include "xmltree.h"

#define SQL_NO_TOTAL			(-4)

#ifdef VIRTTP
#include "2pc.h"
#endif
#include "msdtc.h"

id_hash_t *remote_dss;
id_hash_t *remote_tables;
id_hash_t *remote_procs;
dk_mutex_t *r_mtx;

caddr_t *odbc_error_ex = NULL;
char *vdb_odbc_error_file = NULL;
char *vdb_trim_trailing_spaces = NULL;
dk_hash_t *vdb_clients;		/* those cli_connection_t's with owned caches of rds_connection_t's */
dk_mutex_t *vdb_connect_mtx = NULL;
int32 vdb_client_fixed_thread = 1;
int32 vdb_serialize_connect = 0;
int rc_max_stmts = 50;
int remote_pk_not_unique = 0;
int rst_alloc_count;
int rst_free_count;
long rds_active_cons_freed = 0;
long rds_disconnect_timeout = 1000000;	/* 1000 seconds */
long reconnect_on_vdb_error = 1;
long vdb_no_stmt_cache = 0;
long vdb_use_global_pool = 0;
remote_ds_t *local_rds = NULL;

void odbc_cat_init (void);




remote_ds_t *
find_remote_ds (const char *name, int create)
{
  return NULL;
}


int
vd_dv_to_sql_type (int dv)
{
  switch (dv)
    {
    case DV_SHORT_INT:
      return SQL_SMALLINT;
    case DV_LONG_INT:
      return SQL_INTEGER;
    case DV_DOUBLE_FLOAT:
      return SQL_DOUBLE;
    case DV_NUMERIC:
      return SQL_DECIMAL;
    case DV_SINGLE_FLOAT:
      return SQL_REAL;
    case DV_BLOB:
      return SQL_LONGVARCHAR;
    case DV_BLOB_BIN:
      return SQL_LONGVARBINARY;
    case DV_BLOB_WIDE:
      return SQL_WLONGVARCHAR;
    case DV_DATE:
      return SQL_DATE;
    case DV_TIMESTAMP:
    case DV_DATETIME:
      return SQL_TIMESTAMP;
    case DV_TIME:
      return SQL_TIME;
    case DV_BIN:
      return SQL_VARBINARY;
    case DV_WIDE:
    case DV_LONG_WIDE:
      return SQL_WVARCHAR;
    default:
      return SQL_VARCHAR;
    }
}


remote_table_t *
find_remote_table (char *name, int create)
{
  return NULL;
}


#define B_SET(p,v) dk_free_tree (p), p = v


caddr_t
bif_remote_table (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{
  return NULL;
}




caddr_t
find_pass_through_function (remote_ds_t * rds, int do_mutex, char *ref_name, char *q_def, char *o_def, caddr_t * found_remote)
{
  return NULL;
}


caddr_t
bif_pass_through_function (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{
  return NULL;
}


remote_proc_t *
find_remote_proc (char *name, int create)
{
  return NULL;
}





static caddr_t
bif_proc_is_remote (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{

  return (caddr_t) box_num (0);
}


int
rds_supports_sql_type (remote_ds_t * rds, long sql_type)
{
  return 0;
}

caddr_t
rds_get_info (remote_ds_t * rds, int finfo)
{
  return NULL;
}



caddr_t
bif_vdd_set_password (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{
  return NULL;
}




static caddr_t
bif_vdd_measure_rpc_time (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{
  return NULL;
}



static caddr_t
bif_vdd_init (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{
  return NULL;
}


void
remote_init (void)
{
  bif_define ("vdd_init", bif_vdd_init);
  bif_define ("vdd_remote_table", bif_remote_table);
  bif_define ("vdd_pass_through_function", bif_pass_through_function);
  bif_define_typed ("proc_is_remote", bif_proc_is_remote, &bt_integer);
  bif_define ("vdd_set_password", bif_vdd_set_password);
  bif_define_typed ("vdd_measure_rpc_time", bif_vdd_measure_rpc_time, &bt_float);


  odbc_cat_init ();


  udt_ses_init ();

  ddl_ensure_univ_tables ();
  {
    NEW_VARZ (remote_ds_t, rds);
    rds->rds_dsn = box_string ("__local");
    rds->rds_pass_through_funcs = id_str_hash_create (10);
    rds->rds_pass_through_funcs_mtx = mutex_allocate ();
    local_rds = rds;
    local_rds->rds_connstr = list (2, box_num (SQL_DBMS_NAME), box_dv_short_string (PRODUCT_DBMS));
    if (MSDTC_IS_LOADED)
      local_rds->rds_mts_connections = resource_allocate (1, NULL, NULL, NULL, 0);
  }
}



/*
 *  Define because many funcs compare functions to this pointer. Saves ifdefs
 */
void
remote_table_source_input (remote_table_source_t * rts, caddr_t * inst, caddr_t * state)
{
  GPF_T;
}

void
DoSQLError (SQLHDBC hdbc, SQLHSTMT hstmt)
{
}