1 /*
2 * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org>
3 * Copyright (C) 2010 David King <davidk@openismus.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #include <string.h>
22 #include "gda-web.h"
23 #include "gda-web-meta.h"
24 #include "gda-web-provider.h"
25 #include <libgda/gda-meta-store.h>
26 #include <libgda/sql-parser/gda-sql-parser.h>
27 #include <glib/gi18n-lib.h>
28 #include <libgda/gda-server-provider-extra.h>
29 #include <libgda/gda-connection-private.h>
30 #include <libgda/gda-data-model-array.h>
31 #include <libgda/gda-set.h>
32 #include <libgda/gda-holder.h>
33
34 #include "gda-web-util.h"
35
36 /*
37 * Meta initialization
38 */
39 void
_gda_web_provider_meta_init(G_GNUC_UNUSED GdaServerProvider * provider)40 _gda_web_provider_meta_init (G_GNUC_UNUSED GdaServerProvider *provider)
41 {
42 }
43
44 /*
45 * ... is a list of (arg name, arg value) as strings, terminated with NULL
46 */
47 static GdaDataModel *
run_meta_command_args(GdaConnection * cnc,WebConnectionData * cdata,const gchar * type,GError ** error,...)48 run_meta_command_args (GdaConnection *cnc, WebConnectionData *cdata, const gchar *type, GError **error, ...)
49 {
50 /* send message */
51 xmlDocPtr doc;
52 gchar status;
53 gchar *tmp, *token;
54 GString *string;
55 va_list ap;
56 #define MSG__TEMPL "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" \
57 "<request>\n" \
58 " <token>%s</token>\n" \
59 " <cmd type=\"%s\">META%s</cmd>\n" \
60 "</request>"
61
62 string = g_string_new ("");
63 va_start (ap, error);
64 for (tmp = va_arg (ap, gchar*); tmp; tmp = va_arg (ap, gchar*)) {
65 gchar *argval;
66 xmlChar *xargval;
67 argval = va_arg (ap, gchar*);
68 xargval = xmlEncodeSpecialChars (NULL, BAD_CAST argval);
69 g_string_append_printf (string, "<arg name=\"%s\">%s</arg>", tmp, (gchar*) xargval);
70 xmlFree (xargval);
71 }
72 va_end (ap);
73
74 token = _gda_web_compute_token (cdata);
75 tmp = g_strdup_printf (MSG__TEMPL, token, type, string->str);
76 g_string_free (string, TRUE);
77 g_free (token);
78
79 doc = _gda_web_send_message_to_frontend (cnc, cdata, MESSAGE_META, tmp, cdata->key, &status);
80 g_free (tmp);
81 if (!doc)
82 return FALSE;
83 if (status != 'O') {
84 _gda_web_set_connection_error_from_xmldoc (cnc, doc, error);
85 xmlFreeDoc (doc);
86 return FALSE;
87 }
88
89 /* compute returned data model */
90 xmlNodePtr root, node;
91 GdaDataModel *model = NULL;
92 root = xmlDocGetRootElement (doc);
93 for (node = root->children; node; node = node->next) {
94 if (!strcmp ((gchar*) node->name, "gda_array")) {
95 model = gda_data_model_import_new_xml_node (node);
96 break;
97 }
98 }
99 xmlFreeDoc (doc);
100 /*gda_data_model_dump (model, NULL);*/
101
102 if (! model)
103 g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
104 GDA_SERVER_PROVIDER_INTERNAL_ERROR, "%s",
105 _("Can't import data from web server"));
106 return model;
107 }
108
109 static GdaDataModel *
run_meta_command(GdaConnection * cnc,WebConnectionData * cdata,const gchar * type,GError ** error)110 run_meta_command (GdaConnection *cnc, WebConnectionData *cdata, const gchar *type, GError **error)
111 {
112 return run_meta_command_args (cnc, cdata, type, error, NULL);
113 }
114
115 gboolean
_gda_web_meta__info(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)116 _gda_web_meta__info (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
117 GdaMetaStore *store, GdaMetaContext *context, GError **error)
118 {
119 GdaDataModel *model;
120 gboolean retval;
121 WebConnectionData *cdata;
122
123 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
124 if (!cdata)
125 return FALSE;
126
127 /* use reuseable methods if available */
128 if (cdata->reuseable) {
129 if (cdata->reuseable->operations->re_meta_funcs._info)
130 return cdata->reuseable->operations->re_meta_funcs._info (NULL, cnc, store,
131 context, error);
132 else
133 return TRUE;
134 }
135
136 /* fallback to default method */
137 model = run_meta_command (cnc, cdata, "info", error);
138 if (!model)
139 return FALSE;
140 retval = gda_meta_store_modify_with_context (store, context, model, error);
141 g_object_unref (model);
142
143 return retval;
144 }
145
146 gboolean
_gda_web_meta__btypes(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)147 _gda_web_meta__btypes (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
148 GdaMetaStore *store, GdaMetaContext *context, GError **error)
149 {
150 GdaDataModel *model;
151 gboolean retval;
152 WebConnectionData *cdata;
153
154 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
155 if (!cdata)
156 return FALSE;
157
158 /* use reuseable methods if available */
159 if (cdata->reuseable) {
160 if (cdata->reuseable->operations->re_meta_funcs._btypes)
161 return cdata->reuseable->operations->re_meta_funcs._btypes (NULL, cnc, store,
162 context, error);
163 else
164 return TRUE;
165 }
166
167 /* fallback to default method */
168 model = run_meta_command (cnc, cdata, "btypes", error);
169 if (!model)
170 return FALSE;
171 retval = gda_meta_store_modify_with_context (store, context, model, error);
172 g_object_unref (model);
173
174 return retval;
175 }
176
177 gboolean
_gda_web_meta__udt(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)178 _gda_web_meta__udt (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
179 GdaMetaStore *store, GdaMetaContext *context, GError **error)
180 {
181 WebConnectionData *cdata;
182
183 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
184 if (!cdata)
185 return FALSE;
186
187 /* use reuseable methods if available */
188 if (cdata->reuseable) {
189 if (cdata->reuseable->operations->re_meta_funcs._udt)
190 return cdata->reuseable->operations->re_meta_funcs._udt (NULL, cnc, store,
191 context, error);
192 else
193 return TRUE;
194 }
195
196 /* no default method */
197 return TRUE;
198 }
199
200 gboolean
_gda_web_meta_udt(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * udt_catalog,const GValue * udt_schema)201 _gda_web_meta_udt (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
202 GdaMetaStore *store, GdaMetaContext *context, GError **error,
203 const GValue *udt_catalog, const GValue *udt_schema)
204 {
205 WebConnectionData *cdata;
206
207 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
208 if (!cdata)
209 return FALSE;
210
211 /* use reuseable methods if available */
212 if (cdata->reuseable) {
213 if (cdata->reuseable->operations->re_meta_funcs.udt)
214 return cdata->reuseable->operations->re_meta_funcs.udt (NULL, cnc, store,
215 context, error, udt_catalog,
216 udt_schema);
217 else
218 return TRUE;
219 }
220
221 /* no default method */
222 return TRUE;
223 }
224
225
226 gboolean
_gda_web_meta__udt_cols(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)227 _gda_web_meta__udt_cols (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
228 GdaMetaStore *store, GdaMetaContext *context, GError **error)
229 {
230 WebConnectionData *cdata;
231
232 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
233 if (!cdata)
234 return FALSE;
235
236 /* use reuseable methods if available */
237 if (cdata->reuseable) {
238 if (cdata->reuseable->operations->re_meta_funcs._udt_cols)
239 return cdata->reuseable->operations->re_meta_funcs._udt_cols (NULL, cnc, store,
240 context, error);
241 else
242 return TRUE;
243 }
244
245 /* no default method */
246 return TRUE;
247 }
248
249 gboolean
_gda_web_meta_udt_cols(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * udt_catalog,const GValue * udt_schema,const GValue * udt_name)250 _gda_web_meta_udt_cols (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
251 GdaMetaStore *store, GdaMetaContext *context, GError **error,
252 const GValue *udt_catalog, const GValue *udt_schema, const GValue *udt_name)
253 {
254 WebConnectionData *cdata;
255
256 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
257 if (!cdata)
258 return FALSE;
259
260 /* use reuseable methods if available */
261 if (cdata->reuseable) {
262 if (cdata->reuseable->operations->re_meta_funcs.udt_cols)
263 return cdata->reuseable->operations->re_meta_funcs.udt_cols (NULL, cnc, store,
264 context, error,
265 udt_catalog, udt_schema,
266 udt_name);
267 else
268 return TRUE;
269 }
270
271 /* no default method */
272 return TRUE;
273 }
274
275 gboolean
_gda_web_meta__enums(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)276 _gda_web_meta__enums (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
277 GdaMetaStore *store, GdaMetaContext *context, GError **error)
278 {
279 WebConnectionData *cdata;
280
281 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
282 if (!cdata)
283 return FALSE;
284
285 /* use reuseable methods if available */
286 if (cdata->reuseable) {
287 if (cdata->reuseable->operations->re_meta_funcs._enums)
288 return cdata->reuseable->operations->re_meta_funcs._enums (NULL, cnc, store,
289 context, error);
290 else
291 return TRUE;
292 }
293
294 /* no default method */
295 return TRUE;
296 }
297
298 gboolean
_gda_web_meta_enums(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * udt_catalog,const GValue * udt_schema,const GValue * udt_name)299 _gda_web_meta_enums (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
300 GdaMetaStore *store, GdaMetaContext *context, GError **error,
301 const GValue *udt_catalog, const GValue *udt_schema, const GValue *udt_name)
302 {
303 WebConnectionData *cdata;
304
305 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
306 if (!cdata)
307 return FALSE;
308
309 /* use reuseable methods if available */
310 if (cdata->reuseable) {
311 if (cdata->reuseable->operations->re_meta_funcs.enums)
312 return cdata->reuseable->operations->re_meta_funcs.enums (NULL, cnc, store,
313 context, error,
314 udt_catalog, udt_schema,
315 udt_name);
316 else
317 return TRUE;
318 }
319
320 /* no default method */
321 return TRUE;
322 }
323
324
325 gboolean
_gda_web_meta__domains(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)326 _gda_web_meta__domains (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
327 GdaMetaStore *store, GdaMetaContext *context, GError **error)
328 {
329 WebConnectionData *cdata;
330
331 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
332 if (!cdata)
333 return FALSE;
334
335 /* use reuseable methods if available */
336 if (cdata->reuseable) {
337 if (cdata->reuseable->operations->re_meta_funcs._domains)
338 return cdata->reuseable->operations->re_meta_funcs._domains (NULL, cnc, store,
339 context, error);
340 else
341 return TRUE;
342 }
343
344 /* no default method */
345 return TRUE;
346 }
347
348 gboolean
_gda_web_meta_domains(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * domain_catalog,const GValue * domain_schema)349 _gda_web_meta_domains (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
350 GdaMetaStore *store, GdaMetaContext *context, GError **error,
351 const GValue *domain_catalog, const GValue *domain_schema)
352 {
353 WebConnectionData *cdata;
354
355 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
356 if (!cdata)
357 return FALSE;
358
359 /* use reuseable methods if available */
360 if (cdata->reuseable) {
361 if (cdata->reuseable->operations->re_meta_funcs.domains)
362 return cdata->reuseable->operations->re_meta_funcs.domains (NULL, cnc, store,
363 context, error,
364 domain_catalog, domain_schema);
365 else
366 return TRUE;
367 }
368
369 /* no default method */
370 return TRUE;
371 }
372
373 gboolean
_gda_web_meta__constraints_dom(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)374 _gda_web_meta__constraints_dom (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
375 GdaMetaStore *store, GdaMetaContext *context, GError **error)
376 {
377 WebConnectionData *cdata;
378
379 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
380 if (!cdata)
381 return FALSE;
382
383 /* use reuseable methods if available */
384 if (cdata->reuseable) {
385 if (cdata->reuseable->operations->re_meta_funcs._constraints_dom)
386 return cdata->reuseable->operations->re_meta_funcs._constraints_dom (NULL, cnc, store,
387 context, error);
388 else
389 return TRUE;
390 }
391
392 /* no default method */
393 return TRUE;
394 }
395
396 gboolean
_gda_web_meta_constraints_dom(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * domain_catalog,const GValue * domain_schema,const GValue * domain_name)397 _gda_web_meta_constraints_dom (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
398 GdaMetaStore *store, GdaMetaContext *context, GError **error,
399 const GValue *domain_catalog, const GValue *domain_schema,
400 const GValue *domain_name)
401 {
402 WebConnectionData *cdata;
403
404 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
405 if (!cdata)
406 return FALSE;
407
408 /* use reuseable methods if available */
409 if (cdata->reuseable) {
410 if (cdata->reuseable->operations->re_meta_funcs.constraints_dom)
411 return cdata->reuseable->operations->re_meta_funcs.constraints_dom (NULL, cnc, store,
412 context, error,
413 domain_catalog, domain_schema,
414 domain_name);
415 else
416 return TRUE;
417 }
418
419 /* no default method */
420 return TRUE;
421 }
422
423 gboolean
_gda_web_meta__el_types(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)424 _gda_web_meta__el_types (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
425 GdaMetaStore *store, GdaMetaContext *context, GError **error)
426 {
427 WebConnectionData *cdata;
428
429 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
430 if (!cdata)
431 return FALSE;
432
433 /* use reuseable methods if available */
434 if (cdata->reuseable) {
435 if (cdata->reuseable->operations->re_meta_funcs._el_types)
436 return cdata->reuseable->operations->re_meta_funcs._el_types (NULL, cnc, store,
437 context, error);
438 else
439 return TRUE;
440 }
441
442 /* no default method */
443 return TRUE;
444 }
445
446 gboolean
_gda_web_meta_el_types(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * specific_name)447 _gda_web_meta_el_types (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
448 GdaMetaStore *store, GdaMetaContext *context, GError **error,
449 const GValue *specific_name)
450 {
451 WebConnectionData *cdata;
452
453 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
454 if (!cdata)
455 return FALSE;
456
457 /* use reuseable methods if available */
458 if (cdata->reuseable) {
459 if (cdata->reuseable->operations->re_meta_funcs.el_types)
460 return cdata->reuseable->operations->re_meta_funcs.el_types (NULL, cnc, store,
461 context, error,
462 specific_name);
463 else
464 return TRUE;
465 }
466
467 /* no default method */
468 return TRUE;
469 }
470
471 gboolean
_gda_web_meta__collations(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)472 _gda_web_meta__collations (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
473 GdaMetaStore *store, GdaMetaContext *context, GError **error)
474 {
475 WebConnectionData *cdata;
476
477 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
478 if (!cdata)
479 return FALSE;
480
481 /* use reuseable methods if available */
482 if (cdata->reuseable) {
483 if (cdata->reuseable->operations->re_meta_funcs._collations)
484 return cdata->reuseable->operations->re_meta_funcs._collations (NULL, cnc, store,
485 context, error);
486 else
487 return TRUE;
488 }
489
490 /* no default method */
491 return TRUE;
492 }
493
494 gboolean
_gda_web_meta_collations(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * collation_catalog,const GValue * collation_schema,const GValue * collation_name_n)495 _gda_web_meta_collations (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
496 GdaMetaStore *store, GdaMetaContext *context, GError **error,
497 const GValue *collation_catalog, const GValue *collation_schema,
498 const GValue *collation_name_n)
499 {
500 WebConnectionData *cdata;
501
502 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
503 if (!cdata)
504 return FALSE;
505
506 /* use reuseable methods if available */
507 if (cdata->reuseable) {
508 if (cdata->reuseable->operations->re_meta_funcs.collations)
509 return cdata->reuseable->operations->re_meta_funcs.collations (NULL, cnc, store,
510 context, error,
511 collation_catalog,
512 collation_schema,
513 collation_name_n);
514 else
515 return TRUE;
516 }
517
518 /* no default method */
519 return TRUE;
520 }
521
522 gboolean
_gda_web_meta__character_sets(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)523 _gda_web_meta__character_sets (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
524 GdaMetaStore *store, GdaMetaContext *context, GError **error)
525 {
526 WebConnectionData *cdata;
527
528 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
529 if (!cdata)
530 return FALSE;
531
532 /* use reuseable methods if available */
533 if (cdata->reuseable) {
534 if (cdata->reuseable->operations->re_meta_funcs._character_sets)
535 return cdata->reuseable->operations->re_meta_funcs._character_sets (NULL, cnc, store,
536 context, error);
537 else
538 return TRUE;
539 }
540
541 /* no default method */
542 return TRUE;
543 }
544
545 gboolean
_gda_web_meta_character_sets(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * chset_catalog,const GValue * chset_schema,const GValue * chset_name_n)546 _gda_web_meta_character_sets (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
547 GdaMetaStore *store, GdaMetaContext *context, GError **error,
548 const GValue *chset_catalog, const GValue *chset_schema,
549 const GValue *chset_name_n)
550 {
551 WebConnectionData *cdata;
552
553 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
554 if (!cdata)
555 return FALSE;
556
557 /* use reuseable methods if available */
558 if (cdata->reuseable) {
559 if (cdata->reuseable->operations->re_meta_funcs.character_sets)
560 return cdata->reuseable->operations->re_meta_funcs.character_sets (NULL, cnc, store,
561 context, error,
562 chset_catalog, chset_schema,
563 chset_name_n);
564 else
565 return TRUE;
566 }
567
568 /* no default method */
569 return TRUE;
570 }
571
572 gboolean
_gda_web_meta__schemata(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)573 _gda_web_meta__schemata (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
574 GdaMetaStore *store, GdaMetaContext *context, GError **error)
575 {
576 GdaDataModel *model;
577 gboolean retval;
578 WebConnectionData *cdata;
579
580 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
581 if (!cdata)
582 return FALSE;
583
584 /* use reuseable methods if available */
585 if (cdata->reuseable) {
586 if (cdata->reuseable->operations->re_meta_funcs._schemata)
587 return cdata->reuseable->operations->re_meta_funcs._schemata (NULL, cnc, store,
588 context, error);
589 else
590 return TRUE;
591 }
592
593 /* fallback to default method */
594 model = run_meta_command (cnc, cdata, "schemas", error);
595 if (!model)
596 return FALSE;
597 retval = gda_meta_store_modify_with_context (store, context, model, error);
598 g_object_unref (model);
599
600 return retval;
601 }
602
603 gboolean
_gda_web_meta_schemata(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * catalog_name,const GValue * schema_name_n)604 _gda_web_meta_schemata (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
605 GdaMetaStore *store, GdaMetaContext *context, GError **error,
606 const GValue *catalog_name, const GValue *schema_name_n)
607 {
608 GdaDataModel *model;
609 gboolean retval;
610 WebConnectionData *cdata;
611
612 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
613 if (!cdata)
614 return FALSE;
615
616 /* use reuseable methods if available */
617 if (cdata->reuseable) {
618 if (cdata->reuseable->operations->re_meta_funcs.schemata)
619 return cdata->reuseable->operations->re_meta_funcs.schemata (NULL, cnc, store,
620 context, error, catalog_name, schema_name_n);
621 else
622 return TRUE;
623 }
624
625 /* fallback to default method */
626 if (schema_name_n)
627 model = run_meta_command_args (cnc, cdata, "schemas", error,
628 "catalog_name", g_value_get_string (catalog_name),
629 "schema_name", g_value_get_string (schema_name_n), NULL);
630 else
631 model = run_meta_command_args (cnc, cdata, "schemas", error,
632 "catalog_name", g_value_get_string (catalog_name), NULL);
633 if (!model)
634 return FALSE;
635 retval = gda_meta_store_modify_with_context (store, context, model, error);
636 g_object_unref (model);
637
638 return retval;
639 }
640
641 gboolean
_gda_web_meta__tables_views(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)642 _gda_web_meta__tables_views (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
643 GdaMetaStore *store, GdaMetaContext *context, GError **error)
644 {
645 GdaDataModel *tables_model, *views_model;
646 gboolean retval = TRUE;
647 WebConnectionData *cdata;
648
649 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
650 if (!cdata)
651 return FALSE;
652
653 /* use reuseable methods if available */
654 if (cdata->reuseable) {
655 if (cdata->reuseable->operations->re_meta_funcs._tables_views)
656 return cdata->reuseable->operations->re_meta_funcs._tables_views (NULL, cnc, store,
657 context, error);
658 else
659 return TRUE;
660 }
661
662 /* fallback to default method */
663 tables_model = run_meta_command (cnc, cdata, "tables", error);
664 if (!tables_model)
665 return FALSE;
666 views_model = run_meta_command (cnc, cdata, "views", error);
667 if (!views_model) {
668 g_object_unref (tables_model);
669 return FALSE;
670 }
671
672 GdaMetaContext c2;
673 c2 = *context; /* copy contents, just because we need to modify @context->table_name */
674 if (retval) {
675 c2.table_name = "_tables";
676 retval = gda_meta_store_modify_with_context (store, &c2, tables_model, error);
677 }
678 if (retval) {
679 c2.table_name = "_views";
680 retval = gda_meta_store_modify_with_context (store, &c2, views_model, error);
681 }
682 g_object_unref (tables_model);
683 g_object_unref (views_model);
684
685 return retval;
686 }
687
688 gboolean
_gda_web_meta_tables_views(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name_n)689 _gda_web_meta_tables_views (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
690 GdaMetaStore *store, GdaMetaContext *context, GError **error,
691 const GValue *table_catalog, const GValue *table_schema,
692 const GValue *table_name_n)
693 {
694 GdaDataModel *tables_model, *views_model;
695 gboolean retval = TRUE;
696 WebConnectionData *cdata;
697
698 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
699 if (!cdata)
700 return FALSE;
701
702 /* use reuseable methods if available */
703 if (cdata->reuseable) {
704 if (cdata->reuseable->operations->re_meta_funcs.tables_views)
705 return cdata->reuseable->operations->re_meta_funcs.tables_views (NULL, cnc, store,
706 context, error,
707 table_catalog, table_schema,
708 table_name_n);
709 else
710 return TRUE;
711 }
712
713 /* fallback to default method */
714 if (table_name_n)
715 tables_model = run_meta_command_args (cnc, cdata, "tables", error,
716 "table_catalog", g_value_get_string (table_catalog),
717 "table_schema", g_value_get_string (table_schema),
718 "table_name", g_value_get_string (table_name_n), NULL);
719 else
720 tables_model = run_meta_command_args (cnc, cdata, "tables", error,
721 "table_catalog", g_value_get_string (table_catalog),
722 "table_schema", g_value_get_string (table_schema), NULL);
723 if (!tables_model)
724 return FALSE;
725
726 if (table_name_n)
727 views_model = run_meta_command_args (cnc, cdata, "views", error,
728 "table_catalog", g_value_get_string (table_catalog),
729 "table_schema", g_value_get_string (table_schema),
730 "table_name", g_value_get_string (table_name_n), NULL);
731 else
732 views_model = run_meta_command_args (cnc, cdata, "views", error,
733 "table_catalog", g_value_get_string (table_catalog),
734 "table_schema", g_value_get_string (table_schema), NULL);
735 if (!views_model) {
736 g_object_unref (tables_model);
737 return FALSE;
738 }
739
740 GdaMetaContext c2;
741 c2 = *context; /* copy contents, just because we need to modify @context->table_name */
742 if (retval) {
743 c2.table_name = "_tables";
744 retval = gda_meta_store_modify_with_context (store, &c2, tables_model, error);
745 }
746 if (retval) {
747 c2.table_name = "_views";
748 retval = gda_meta_store_modify_with_context (store, &c2, views_model, error);
749 }
750 g_object_unref (tables_model);
751 g_object_unref (views_model);
752
753 return retval;
754 }
755
756 gboolean
_gda_web_meta__columns(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)757 _gda_web_meta__columns (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
758 GdaMetaStore *store, GdaMetaContext *context, GError **error)
759 {
760 GdaDataModel *model;
761 gboolean retval;
762 WebConnectionData *cdata;
763
764 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
765 if (!cdata)
766 return FALSE;
767
768 /* use reuseable methods if available */
769 if (cdata->reuseable) {
770 if (cdata->reuseable->operations->re_meta_funcs._columns)
771 return cdata->reuseable->operations->re_meta_funcs._columns (NULL, cnc, store,
772 context, error);
773 else
774 return TRUE;
775 }
776
777 /* fallback to default method */
778 model = run_meta_command (cnc, cdata, "columns", error);
779 if (!model)
780 return FALSE;
781 retval = gda_meta_store_modify_with_context (store, context, model, error);
782 g_object_unref (model);
783
784 return retval;
785 }
786
787 gboolean
_gda_web_meta_columns(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name)788 _gda_web_meta_columns (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
789 GdaMetaStore *store, GdaMetaContext *context, GError **error,
790 const GValue *table_catalog, const GValue *table_schema,
791 const GValue *table_name)
792 {
793 GdaDataModel *model;
794 gboolean retval;
795 WebConnectionData *cdata;
796
797 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
798 if (!cdata)
799 return FALSE;
800
801 /* use reuseable methods if available */
802 if (cdata->reuseable) {
803 if (cdata->reuseable->operations->re_meta_funcs.columns)
804 return cdata->reuseable->operations->re_meta_funcs.columns (NULL, cnc, store,
805 context, error, table_catalog, table_schema,
806 table_name);
807 else
808 return TRUE;
809 }
810
811 /* fallback to default method */
812 model = run_meta_command_args (cnc, cdata, "columns", error,
813 "table_catalog", g_value_get_string (table_catalog),
814 "table_schema", g_value_get_string (table_schema),
815 "table_name", g_value_get_string (table_name), NULL);
816 if (!model)
817 return FALSE;
818 retval = gda_meta_store_modify_with_context (store, context, model, error);
819 g_object_unref (model);
820
821 return retval;
822 }
823
824 gboolean
_gda_web_meta__view_cols(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)825 _gda_web_meta__view_cols (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
826 GdaMetaStore *store, GdaMetaContext *context, GError **error)
827 {
828 WebConnectionData *cdata;
829
830 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
831 if (!cdata)
832 return FALSE;
833
834 /* use reuseable methods if available */
835 if (cdata->reuseable) {
836 if (cdata->reuseable->operations->re_meta_funcs._view_cols)
837 return cdata->reuseable->operations->re_meta_funcs._view_cols (NULL, cnc, store,
838 context, error);
839 else
840 return TRUE;
841 }
842
843 /* no default method */
844 return TRUE;
845 }
846
847 gboolean
_gda_web_meta_view_cols(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * view_catalog,const GValue * view_schema,const GValue * view_name)848 _gda_web_meta_view_cols (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
849 GdaMetaStore *store, GdaMetaContext *context, GError **error,
850 const GValue *view_catalog, const GValue *view_schema,
851 const GValue *view_name)
852 {
853 WebConnectionData *cdata;
854
855 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
856 if (!cdata)
857 return FALSE;
858
859 /* use reuseable methods if available */
860 if (cdata->reuseable) {
861 if (cdata->reuseable->operations->re_meta_funcs.view_cols)
862 return cdata->reuseable->operations->re_meta_funcs.view_cols (NULL, cnc, store,
863 context, error,
864 view_catalog, view_schema,
865 view_name);
866 else
867 return TRUE;
868 }
869
870 /* no default method */
871 return TRUE;
872 }
873
874 gboolean
_gda_web_meta__constraints_tab(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)875 _gda_web_meta__constraints_tab (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
876 GdaMetaStore *store, GdaMetaContext *context, GError **error)
877 {
878 GdaDataModel *model;
879 gboolean retval;
880 WebConnectionData *cdata;
881
882 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
883 if (!cdata)
884 return FALSE;
885
886 /* use reuseable methods if available */
887 if (cdata->reuseable) {
888 if (cdata->reuseable->operations->re_meta_funcs._constraints_tab)
889 return cdata->reuseable->operations->re_meta_funcs._constraints_tab (NULL, cnc, store,
890 context, error);
891 else
892 return TRUE;
893 }
894
895 /* fallback to default method */
896 model = run_meta_command (cnc, cdata, "constraints_tab", error);
897 if (!model)
898 return FALSE;
899 retval = gda_meta_store_modify_with_context (store, context, model, error);
900 g_object_unref (model);
901
902 return retval;
903 }
904
905 gboolean
_gda_web_meta_constraints_tab(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name,const GValue * constraint_name_n)906 _gda_web_meta_constraints_tab (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
907 GdaMetaStore *store, GdaMetaContext *context, GError **error,
908 const GValue *table_catalog, const GValue *table_schema,
909 const GValue *table_name, const GValue *constraint_name_n)
910 {
911 GdaDataModel *model;
912 gboolean retval;
913 WebConnectionData *cdata;
914
915 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
916 if (!cdata)
917 return FALSE;
918
919 /* use reuseable methods if available */
920 if (cdata->reuseable) {
921 if (cdata->reuseable->operations->re_meta_funcs.constraints_tab)
922 return cdata->reuseable->operations->re_meta_funcs.constraints_tab (NULL, cnc, store,
923 context, error,
924 table_catalog, table_schema,
925 table_name, constraint_name_n);
926 else
927 return TRUE;
928 }
929
930 /* fallback to default method */
931 if (constraint_name_n)
932 model = run_meta_command_args (cnc, cdata, "constraints_tab", error,
933 "table_catalog", g_value_get_string (table_catalog),
934 "table_schema", g_value_get_string (table_schema),
935 "table_name", g_value_get_string (table_name),
936 "constraint_name_", g_value_get_string (table_name), NULL);
937 else
938 model = run_meta_command_args (cnc, cdata, "constraints_tab", error,
939 "table_catalog", g_value_get_string (table_catalog),
940 "table_schema", g_value_get_string (table_schema),
941 "table_name", g_value_get_string (table_name), NULL);
942 if (!model)
943 return FALSE;
944 retval = gda_meta_store_modify_with_context (store, context, model, error);
945 g_object_unref (model);
946
947 return retval;
948 }
949
950 gboolean
_gda_web_meta__constraints_ref(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)951 _gda_web_meta__constraints_ref (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
952 GdaMetaStore *store, GdaMetaContext *context, GError **error)
953 {
954 GdaDataModel *model;
955 gboolean retval;
956 WebConnectionData *cdata;
957
958 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
959 if (!cdata)
960 return FALSE;
961
962 /* use reuseable methods if available */
963 if (cdata->reuseable) {
964 if (cdata->reuseable->operations->re_meta_funcs._constraints_ref)
965 return cdata->reuseable->operations->re_meta_funcs._constraints_ref (NULL, cnc, store,
966 context, error);
967 else
968 return TRUE;
969 }
970
971 /* fallback to default method */
972 model = run_meta_command (cnc, cdata, "constraints_ref", error);
973 if (!model)
974 return FALSE;
975 retval = gda_meta_store_modify_with_context (store, context, model, error);
976 g_object_unref (model);
977
978 return retval;
979 }
980
981 gboolean
_gda_web_meta_constraints_ref(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name,const GValue * constraint_name)982 _gda_web_meta_constraints_ref (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
983 GdaMetaStore *store, GdaMetaContext *context, GError **error,
984 const GValue *table_catalog, const GValue *table_schema, const GValue *table_name,
985 const GValue *constraint_name)
986 {
987 GdaDataModel *model;
988 gboolean retval;
989 WebConnectionData *cdata;
990
991 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
992 if (!cdata)
993 return FALSE;
994
995 /* use reuseable methods if available */
996 if (cdata->reuseable) {
997 if (cdata->reuseable->operations->re_meta_funcs.constraints_ref)
998 return cdata->reuseable->operations->re_meta_funcs.constraints_ref (NULL, cnc, store,
999 context, error,
1000 table_catalog, table_schema,
1001 table_name,
1002 constraint_name);
1003 else
1004 return TRUE;
1005 }
1006
1007 /* fallback to default method */
1008 model = run_meta_command_args (cnc, cdata, "constraints_ref", error,
1009 "table_catalog", g_value_get_string (table_catalog),
1010 "table_schema", g_value_get_string (table_schema),
1011 "table_name", g_value_get_string (table_name),
1012 "constraint_name_", g_value_get_string (table_name), NULL);
1013 if (!model)
1014 return FALSE;
1015 retval = gda_meta_store_modify_with_context (store, context, model, error);
1016 g_object_unref (model);
1017
1018 return retval;
1019 }
1020
1021 gboolean
_gda_web_meta__key_columns(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1022 _gda_web_meta__key_columns (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1023 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1024 {
1025 GdaDataModel *model;
1026 gboolean retval;
1027 WebConnectionData *cdata;
1028
1029 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1030 if (!cdata)
1031 return FALSE;
1032
1033 /* use reuseable methods if available */
1034 if (cdata->reuseable) {
1035 if (cdata->reuseable->operations->re_meta_funcs._key_columns)
1036 return cdata->reuseable->operations->re_meta_funcs._key_columns (NULL, cnc, store,
1037 context, error);
1038 else
1039 return TRUE;
1040 }
1041
1042 /* fallback to default method */
1043 model = run_meta_command (cnc, cdata, "key_columns", error);
1044 if (!model)
1045 return FALSE;
1046 retval = gda_meta_store_modify_with_context (store, context, model, error);
1047 g_object_unref (model);
1048
1049 return retval;
1050 }
1051
1052 gboolean
_gda_web_meta_key_columns(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name,const GValue * constraint_name)1053 _gda_web_meta_key_columns (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1054 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1055 const GValue *table_catalog, const GValue *table_schema,
1056 const GValue *table_name, const GValue *constraint_name)
1057 {
1058 GdaDataModel *model;
1059 gboolean retval;
1060 WebConnectionData *cdata;
1061
1062 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1063 if (!cdata)
1064 return FALSE;
1065
1066 /* use reuseable methods if available */
1067 if (cdata->reuseable) {
1068 if (cdata->reuseable->operations->re_meta_funcs.key_columns)
1069 return cdata->reuseable->operations->re_meta_funcs.key_columns (NULL, cnc, store,
1070 context, error,
1071 table_catalog, table_schema,
1072 table_name,
1073 constraint_name);
1074 else
1075 return TRUE;
1076 }
1077
1078 /* fallback to default method */
1079 model = run_meta_command_args (cnc, cdata, "key_columns", error,
1080 "table_catalog", g_value_get_string (table_catalog),
1081 "table_schema", g_value_get_string (table_schema),
1082 "table_name", g_value_get_string (table_name),
1083 "constraint_name_", g_value_get_string (table_name), NULL);
1084 if (!model)
1085 return FALSE;
1086 retval = gda_meta_store_modify_with_context (store, context, model, error);
1087 g_object_unref (model);
1088
1089 return retval;
1090 }
1091
1092 gboolean
_gda_web_meta__check_columns(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1093 _gda_web_meta__check_columns (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1094 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1095 {
1096 GdaDataModel *model;
1097 gboolean retval;
1098 WebConnectionData *cdata;
1099
1100 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1101 if (!cdata)
1102 return FALSE;
1103
1104 /* use reuseable methods if available */
1105 if (cdata->reuseable) {
1106 if (cdata->reuseable->operations->re_meta_funcs._check_columns)
1107 return cdata->reuseable->operations->re_meta_funcs._check_columns (NULL, cnc, store,
1108 context, error);
1109 else
1110 return TRUE;
1111 }
1112
1113 /* fallback to default method */
1114 model = run_meta_command (cnc, cdata, "check_columns", error);
1115 if (!model)
1116 return FALSE;
1117 retval = gda_meta_store_modify_with_context (store, context, model, error);
1118 g_object_unref (model);
1119
1120 return retval;
1121 }
1122
1123 gboolean
_gda_web_meta_check_columns(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name,const GValue * constraint_name)1124 _gda_web_meta_check_columns (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1125 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1126 const GValue *table_catalog, const GValue *table_schema,
1127 const GValue *table_name, const GValue *constraint_name)
1128 {
1129 GdaDataModel *model;
1130 gboolean retval;
1131 WebConnectionData *cdata;
1132
1133 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1134 if (!cdata)
1135 return FALSE;
1136
1137 /* use reuseable methods if available */
1138 if (cdata->reuseable) {
1139 if (cdata->reuseable->operations->re_meta_funcs.check_columns)
1140 return cdata->reuseable->operations->re_meta_funcs.check_columns (NULL, cnc, store,
1141 context, error,
1142 table_catalog, table_schema,
1143 table_name,
1144 constraint_name);
1145 else
1146 return TRUE;
1147 }
1148
1149 /* fallback to default method */
1150 model = run_meta_command_args (cnc, cdata, "check_columns", error,
1151 "table_catalog", g_value_get_string (table_catalog),
1152 "table_schema", g_value_get_string (table_schema),
1153 "table_name", g_value_get_string (table_name),
1154 "constraint_name_", g_value_get_string (table_name), NULL);
1155 if (!model)
1156 return FALSE;
1157 retval = gda_meta_store_modify_with_context (store, context, model, error);
1158 g_object_unref (model);
1159
1160 return retval;
1161 }
1162
1163 gboolean
_gda_web_meta__triggers(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1164 _gda_web_meta__triggers (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1165 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1166 {
1167 GdaDataModel *model;
1168 gboolean retval;
1169 WebConnectionData *cdata;
1170
1171 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1172 if (!cdata)
1173 return FALSE;
1174
1175 /* use reuseable methods if available */
1176 if (cdata->reuseable) {
1177 if (cdata->reuseable->operations->re_meta_funcs._triggers)
1178 return cdata->reuseable->operations->re_meta_funcs._triggers (NULL, cnc, store,
1179 context, error);
1180 else
1181 return TRUE;
1182 }
1183
1184 /* fallback to default method */
1185 model = run_meta_command (cnc, cdata, "triggers", error);
1186 if (!model)
1187 return FALSE;
1188 retval = gda_meta_store_modify_with_context (store, context, model, error);
1189 g_object_unref (model);
1190
1191 return retval;
1192 }
1193
1194 gboolean
_gda_web_meta_triggers(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name)1195 _gda_web_meta_triggers (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1196 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1197 const GValue *table_catalog, const GValue *table_schema,
1198 const GValue *table_name)
1199 {
1200 GdaDataModel *model;
1201 gboolean retval;
1202 WebConnectionData *cdata;
1203
1204 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1205 if (!cdata)
1206 return FALSE;
1207
1208 /* use reuseable methods if available */
1209 if (cdata->reuseable) {
1210 if (cdata->reuseable->operations->re_meta_funcs.triggers)
1211 return cdata->reuseable->operations->re_meta_funcs.triggers (NULL, cnc, store,
1212 context, error,
1213 table_catalog, table_schema,
1214 table_name);
1215 else
1216 return TRUE;
1217 }
1218
1219 /* fallback to default method */
1220 model = run_meta_command_args (cnc, cdata, "triggers", error,
1221 "table_catalog", g_value_get_string (table_catalog),
1222 "table_schema", g_value_get_string (table_schema),
1223 "table_name", g_value_get_string (table_name), NULL);
1224 if (!model)
1225 return FALSE;
1226 retval = gda_meta_store_modify_with_context (store, context, model, error);
1227 g_object_unref (model);
1228
1229 return retval;
1230 }
1231
1232 gboolean
_gda_web_meta__routines(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1233 _gda_web_meta__routines (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1234 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1235 {
1236 WebConnectionData *cdata;
1237
1238 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1239 if (!cdata)
1240 return FALSE;
1241
1242 /* use reuseable methods if available */
1243 if (cdata->reuseable) {
1244 if (cdata->reuseable->operations->re_meta_funcs._routines)
1245 return cdata->reuseable->operations->re_meta_funcs._routines (NULL, cnc, store,
1246 context, error);
1247 else
1248 return TRUE;
1249 }
1250
1251 /* no default method */
1252 return TRUE;
1253 }
1254
1255 gboolean
_gda_web_meta_routines(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * routine_catalog,const GValue * routine_schema,const GValue * routine_name_n)1256 _gda_web_meta_routines (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1257 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1258 const GValue *routine_catalog, const GValue *routine_schema,
1259 const GValue *routine_name_n)
1260 {
1261 WebConnectionData *cdata;
1262
1263 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1264 if (!cdata)
1265 return FALSE;
1266
1267 /* use reuseable methods if available */
1268 if (cdata->reuseable) {
1269 if (cdata->reuseable->operations->re_meta_funcs.routines)
1270 return cdata->reuseable->operations->re_meta_funcs.routines (NULL, cnc, store,
1271 context, error,
1272 routine_catalog, routine_schema,
1273 routine_name_n);
1274 else
1275 return TRUE;
1276 }
1277
1278 /* no default method */
1279 return TRUE;
1280 }
1281
1282 gboolean
_gda_web_meta__routine_col(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1283 _gda_web_meta__routine_col (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1284 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1285 {
1286 WebConnectionData *cdata;
1287
1288 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1289 if (!cdata)
1290 return FALSE;
1291
1292 /* use reuseable methods if available */
1293 if (cdata->reuseable) {
1294 if (cdata->reuseable->operations->re_meta_funcs._routine_col)
1295 return cdata->reuseable->operations->re_meta_funcs._routine_col (NULL, cnc, store,
1296 context, error);
1297 else
1298 return TRUE;
1299 }
1300
1301 /* no default method */
1302 return TRUE;
1303 }
1304
1305 gboolean
_gda_web_meta_routine_col(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * rout_catalog,const GValue * rout_schema,const GValue * rout_name)1306 _gda_web_meta_routine_col (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1307 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1308 const GValue *rout_catalog, const GValue *rout_schema,
1309 const GValue *rout_name)
1310 {
1311 WebConnectionData *cdata;
1312
1313 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1314 if (!cdata)
1315 return FALSE;
1316
1317 /* use reuseable methods if available */
1318 if (cdata->reuseable) {
1319 if (cdata->reuseable->operations->re_meta_funcs.routine_col)
1320 return cdata->reuseable->operations->re_meta_funcs.routine_col (NULL, cnc, store,
1321 context, error,
1322 rout_catalog, rout_schema,
1323 rout_name);
1324 else
1325 return TRUE;
1326 }
1327
1328 /* no default method */
1329 return TRUE;
1330 }
1331
1332 gboolean
_gda_web_meta__routine_par(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1333 _gda_web_meta__routine_par (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1334 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1335 {
1336 WebConnectionData *cdata;
1337
1338 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1339 if (!cdata)
1340 return FALSE;
1341
1342 /* use reuseable methods if available */
1343 if (cdata->reuseable) {
1344 if (cdata->reuseable->operations->re_meta_funcs._routine_par)
1345 return cdata->reuseable->operations->re_meta_funcs._routine_par (NULL, cnc, store,
1346 context, error);
1347 else
1348 return TRUE;
1349 }
1350
1351 /* no default method */
1352 return TRUE;
1353 }
1354
1355 gboolean
_gda_web_meta_routine_par(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * rout_catalog,const GValue * rout_schema,const GValue * rout_name)1356 _gda_web_meta_routine_par (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1357 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1358 const GValue *rout_catalog, const GValue *rout_schema,
1359 const GValue *rout_name)
1360 {
1361 WebConnectionData *cdata;
1362
1363 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1364 if (!cdata)
1365 return FALSE;
1366
1367 /* use reuseable methods if available */
1368 if (cdata->reuseable) {
1369 if (cdata->reuseable->operations->re_meta_funcs.routine_par)
1370 return cdata->reuseable->operations->re_meta_funcs.routine_par (NULL, cnc, store,
1371 context, error,
1372 rout_catalog, rout_schema,
1373 rout_name);
1374 else
1375 return TRUE;
1376 }
1377
1378 /* no default method */
1379 return TRUE;
1380 }
1381
1382 gboolean
_gda_web_meta__indexes_tab(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1383 _gda_web_meta__indexes_tab (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1384 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1385 {
1386 WebConnectionData *cdata;
1387
1388 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1389 if (!cdata)
1390 return FALSE;
1391
1392 /* use reuseable methods if available */
1393 if (cdata->reuseable) {
1394 if (cdata->reuseable->operations->re_meta_funcs._indexes_tab)
1395 return cdata->reuseable->operations->re_meta_funcs._indexes_tab (NULL, cnc, store,
1396 context, error);
1397 else
1398 return TRUE;
1399 }
1400
1401 /* no default method */
1402 return TRUE;
1403 }
1404
1405 gboolean
_gda_web_meta_indexes_tab(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name,const GValue * index_name_n)1406 _gda_web_meta_indexes_tab (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1407 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1408 const GValue *table_catalog, const GValue *table_schema, const GValue *table_name,
1409 const GValue *index_name_n)
1410 {
1411 WebConnectionData *cdata;
1412
1413 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1414 if (!cdata)
1415 return FALSE;
1416
1417 /* use reuseable methods if available */
1418 if (cdata->reuseable) {
1419 if (cdata->reuseable->operations->re_meta_funcs.indexes_tab)
1420 return cdata->reuseable->operations->re_meta_funcs.indexes_tab (NULL, cnc, store,
1421 context, error,
1422 table_catalog, table_schema,
1423 table_name, index_name_n);
1424 else
1425 return TRUE;
1426 }
1427
1428 /* no default method */
1429 return TRUE;
1430 }
1431
1432 gboolean
_gda_web_meta__index_cols(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error)1433 _gda_web_meta__index_cols (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1434 GdaMetaStore *store, GdaMetaContext *context, GError **error)
1435 {
1436 WebConnectionData *cdata;
1437
1438 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1439 if (!cdata)
1440 return FALSE;
1441
1442 /* use reuseable methods if available */
1443 if (cdata->reuseable) {
1444 if (cdata->reuseable->operations->re_meta_funcs._index_cols)
1445 return cdata->reuseable->operations->re_meta_funcs._index_cols (NULL, cnc, store,
1446 context, error);
1447 else
1448 return TRUE;
1449 }
1450
1451 /* no default method */
1452 return TRUE;
1453 }
1454
1455 gboolean
_gda_web_meta_index_cols(G_GNUC_UNUSED GdaServerProvider * prov,GdaConnection * cnc,GdaMetaStore * store,GdaMetaContext * context,GError ** error,const GValue * table_catalog,const GValue * table_schema,const GValue * table_name,const GValue * index_name)1456 _gda_web_meta_index_cols (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
1457 GdaMetaStore *store, GdaMetaContext *context, GError **error,
1458 const GValue *table_catalog, const GValue *table_schema,
1459 const GValue *table_name, const GValue *index_name)
1460 {
1461 WebConnectionData *cdata;
1462
1463 cdata = (WebConnectionData*) gda_connection_internal_get_provider_data_error (cnc, error);
1464 if (!cdata)
1465 return FALSE;
1466
1467 /* use reuseable methods if available */
1468 if (cdata->reuseable) {
1469 if (cdata->reuseable->operations->re_meta_funcs.index_cols)
1470 return cdata->reuseable->operations->re_meta_funcs.index_cols (NULL, cnc, store,
1471 context, error,
1472 table_catalog, table_schema,
1473 table_name, index_name);
1474 else
1475 return TRUE;
1476 }
1477
1478 /* no default method */
1479 return TRUE;
1480 }
1481