1 /**
2 * collectd - src/oracle.c
3 * Copyright (C) 2008,2009 noris network AG
4 * Copyright (C) 2012 Florian octo Forster
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; only version 2 of the License is applicable.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Linking src/oracle.c ("the oracle plugin") statically or dynamically with
20 * other modules is making a combined work based on the oracle plugin. Thus,
21 * the terms and conditions of the GNU General Public License cover the whole
22 * combination.
23 *
24 * In addition, as a special exception, the copyright holders of the oracle
25 * plugin give you permission to combine the oracle plugin with free software
26 * programs or libraries that are released under the GNU LGPL and with code
27 * included in the standard release of the Oracle® Call Interface (OCI) under
28 * the Oracle® Technology Network (OTN) License (or modified versions of such
29 * code, with unchanged license). You may copy and distribute such a system
30 * following the terms of the GNU GPL for the oracle plugin and the licenses of
31 * the other code concerned.
32 *
33 * Note that people who make modified versions of the oracle plugin are not
34 * obligated to grant this special exception for their modified versions; it is
35 * their choice whether to do so. The GNU General Public License gives
36 * permission to release a modified version without this exception; this
37 * exception also makes it possible to release a modified version which carries
38 * forward this exception. However, without this exception the OTN License does
39 * not allow linking with code licensed under the GNU General Public License.
40 *
41 * Oracle® is a registered trademark of Oracle Corporation and/or its
42 * affiliates. Other names may be trademarks of their respective owners.
43 *
44 * Authors:
45 * Florian octo Forster <octo at collectd.org>
46 **/
48 #include "collectd.h"
49 #include "common.h"
50 #include "plugin.h"
51 #include "configfile.h"
52 #include "utils_db_query.h"
54 #include <oci.h>
56 /*
57 * Data types
58 */
59 struct o_database_s
60 {
61 char *name;
62 char *host;
63 char *connect_id;
64 char *username;
65 char *password;
67 udb_query_preparation_area_t **q_prep_areas;
68 udb_query_t **queries;
69 size_t queries_num;
71 OCISvcCtx *oci_service_context;
72 };
73 typedef struct o_database_s o_database_t;
75 /*
76 * Global variables
77 */
78 static udb_query_t **queries = NULL;
79 static size_t queries_num = 0;
80 static o_database_t **databases = NULL;
81 static size_t databases_num = 0;
83 OCIEnv *oci_env = NULL;
84 OCIError *oci_error = NULL;
86 /*
87 * Functions
88 */
89 static void o_report_error (const char *where, /* {{{ */
90 const char *db_name, const char *query_name,
91 const char *what, OCIError *eh)
92 {
93 char buffer[2048];
94 sb4 error_code;
95 int status;
96 unsigned int record_number;
98 if (db_name == NULL)
99 db_name = "(none)";
100 if (query_name == NULL)
101 query_name = "(none)";
103 /* An operation may cause / return multiple errors. Loop until we have
104 * handled all errors available (with a fail-save limit of 16). */
105 for (record_number = 1; record_number <= 16; record_number++)
106 {
107 memset (buffer, 0, sizeof (buffer));
108 error_code = -1;
110 status = OCIErrorGet (eh, (ub4) record_number,
111 /* sqlstate = */ NULL,
112 &error_code,
113 (text *) &buffer[0],
114 (ub4) sizeof (buffer),
115 OCI_HTYPE_ERROR);
116 buffer[sizeof (buffer) - 1] = 0;
118 if (status == OCI_NO_DATA)
119 return;
121 if (status == OCI_SUCCESS)
122 {
123 size_t buffer_length;
125 buffer_length = strlen (buffer);
126 while ((buffer_length > 0) && (buffer[buffer_length - 1] < 32))
127 {
128 buffer_length--;
129 buffer[buffer_length] = 0;
130 }
132 ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed: %s",
133 where, db_name, query_name, what, buffer);
134 }
135 else
136 {
137 ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed. "
138 "Additionally, OCIErrorGet failed with status %i.",
139 where, db_name, query_name, what, status);
140 return;
141 }
142 }
143 } /* }}} void o_report_error */
145 static void o_database_free (o_database_t *db) /* {{{ */
146 {
147 size_t i;
149 if (db == NULL)
150 return;
152 sfree (db->name);
153 sfree (db->connect_id);
154 sfree (db->username);
155 sfree (db->password);
156 sfree (db->queries);
158 if (db->q_prep_areas != NULL)
159 for (i = 0; i < db->queries_num; ++i)
160 udb_query_delete_preparation_area (db->q_prep_areas[i]);
161 free (db->q_prep_areas);
163 sfree (db);
164 } /* }}} void o_database_free */
166 /* Configuration handling functions {{{
167 *
168 * <Plugin oracle>
169 * <Query "plugin_instance0">
170 * Statement "SELECT name, value FROM table"
171 * <Result>
172 * Type "gauge"
173 * InstancesFrom "name"
174 * ValuesFrom "value"
175 * </Result>
176 * </Query>
177 *
178 * <Database "plugin_instance1">
179 * ConnectID "db01"
180 * Username "oracle"
181 * Password "secret"
182 * Query "plugin_instance0"
183 * </Database>
184 * </Plugin>
185 */
187 static int o_config_add_database (oconfig_item_t *ci) /* {{{ */
188 {
189 o_database_t *db;
190 int status;
191 int i;
193 if ((ci->values_num != 1)
194 || (ci->values[0].type != OCONFIG_TYPE_STRING))
195 {
196 WARNING ("oracle plugin: The `Database' block "
197 "needs exactly one string argument.");
198 return (-1);
199 }
201 db = calloc (1, sizeof (*db));
202 if (db == NULL)
203 {
204 ERROR ("oracle plugin: calloc failed.");
205 return (-1);
206 }
207 db->name = NULL;
208 db->host = NULL;
209 db->connect_id = NULL;
210 db->username = NULL;
211 db->password = NULL;
213 status = cf_util_get_string (ci, &db->name);
214 if (status != 0)
215 {
216 sfree (db);
217 return (status);
218 }
220 /* Fill the `o_database_t' structure.. */
221 for (i = 0; i < ci->children_num; i++)
222 {
223 oconfig_item_t *child = ci->children + i;
225 if (strcasecmp ("ConnectID", child->key) == 0)
226 status = cf_util_get_string (child, &db->connect_id);
227 else if (strcasecmp ("Host", child->key) == 0)
228 status = cf_util_get_string (child, &db->host);
229 else if (strcasecmp ("Username", child->key) == 0)
230 status = cf_util_get_string (child, &db->username);
231 else if (strcasecmp ("Password", child->key) == 0)
232 status = cf_util_get_string (child, &db->password);
233 else if (strcasecmp ("Query", child->key) == 0)
234 status = udb_query_pick_from_list (child, queries, queries_num,
235 &db->queries, &db->queries_num);
236 else
237 {
238 WARNING ("oracle plugin: Option `%s' not allowed here.", child->key);
239 status = -1;
240 }
242 if (status != 0)
243 break;
244 }
246 /* Check that all necessary options have been given. */
247 while (status == 0)
248 {
249 if (db->connect_id == NULL)
250 {
251 WARNING ("oracle plugin: `ConnectID' not given for query `%s'", db->name);
252 status = -1;
253 }
254 if (db->username == NULL)
255 {
256 WARNING ("oracle plugin: `Username' not given for query `%s'", db->name);
257 status = -1;
258 }
259 if (db->password == NULL)
260 {
261 WARNING ("oracle plugin: `Password' not given for query `%s'", db->name);
262 status = -1;
263 }
265 break;
266 } /* while (status == 0) */
268 while ((status == 0) && (db->queries_num > 0))
269 {
270 db->q_prep_areas = (udb_query_preparation_area_t **) calloc (
271 db->queries_num, sizeof (*db->q_prep_areas));
273 if (db->q_prep_areas == NULL)
274 {
275 WARNING ("oracle plugin: calloc failed");
276 status = -1;
277 break;
278 }
280 for (i = 0; i < db->queries_num; ++i)
281 {
282 db->q_prep_areas[i]
283 = udb_query_allocate_preparation_area (db->queries[i]);
285 if (db->q_prep_areas[i] == NULL)
286 {
287 WARNING ("oracle plugin: udb_query_allocate_preparation_area failed");
288 status = -1;
289 break;
290 }
291 }
293 break;
294 }
296 /* If all went well, add this query to the list of queries within the
297 * database structure. */
298 if (status == 0)
299 {
300 o_database_t **temp;
302 temp = realloc (databases,
303 sizeof (*databases) * (databases_num + 1));
304 if (temp == NULL)
305 {
306 ERROR ("oracle plugin: realloc failed");
307 status = -1;
308 }
309 else
310 {
311 databases = temp;
312 databases[databases_num] = db;
313 databases_num++;
314 }
315 }
317 if (status != 0)
318 {
319 o_database_free (db);
320 return (-1);
321 }
323 return (0);
324 } /* }}} int o_config_add_database */
326 static int o_config (oconfig_item_t *ci) /* {{{ */
327 {
328 int i;
330 for (i = 0; i < ci->children_num; i++)
331 {
332 oconfig_item_t *child = ci->children + i;
333 if (strcasecmp ("Query", child->key) == 0)
334 udb_query_create (&queries, &queries_num, child,
335 /* callback = */ NULL);
336 else if (strcasecmp ("Database", child->key) == 0)
337 o_config_add_database (child);
338 else
339 {
340 WARNING ("oracle plugin: Ignoring unknown config option `%s'.", child->key);
341 }
343 if (queries_num > 0)
344 {
345 DEBUG ("oracle plugin: o_config: queries_num = %zu; queries[0] = %p; udb_query_get_user_data (queries[0]) = %p;",
346 queries_num, (void *) queries[0], udb_query_get_user_data (queries[0]));
347 }
348 } /* for (ci->children) */
350 return (0);
351 } /* }}} int o_config */
353 /* }}} End of configuration handling functions */
355 static int o_init (void) /* {{{ */
356 {
357 int status;
359 if (oci_env != NULL)
360 return (0);
362 status = OCIEnvCreate (&oci_env,
363 /* mode = */ OCI_THREADED,
364 /* context = */ NULL,
365 /* malloc = */ NULL,
366 /* realloc = */ NULL,
367 /* free = */ NULL,
368 /* user_data_size = */ 0,
369 /* user_data_ptr = */ NULL);
370 if (status != 0)
371 {
372 ERROR ("oracle plugin: OCIEnvCreate failed with status %i.", status);
373 return (-1);
374 }
376 status = OCIHandleAlloc (oci_env, (void *) &oci_error, OCI_HTYPE_ERROR,
377 /* user_data_size = */ 0, /* user_data = */ NULL);
378 if (status != OCI_SUCCESS)
379 {
380 ERROR ("oracle plugin: OCIHandleAlloc (OCI_HTYPE_ERROR) failed "
381 "with status %i.", status);
382 return (-1);
383 }
385 return (0);
386 } /* }}} int o_init */
388 static int o_read_database_query (o_database_t *db, /* {{{ */
389 udb_query_t *q, udb_query_preparation_area_t *prep_area)
390 {
391 char **column_names;
392 char **column_values;
393 size_t column_num;
395 OCIStmt *oci_statement;
397 /* List of `OCIDefine' pointers. These defines map columns to the buffer
398 * space declared above. */
399 OCIDefine **oci_defines;
401 int status;
402 size_t i;
404 oci_statement = udb_query_get_user_data (q);
406 /* Prepare the statement */
407 if (oci_statement == NULL) /* {{{ */
408 {
409 const char *statement;
411 statement = udb_query_get_statement (q);
412 assert (statement != NULL);
414 status = OCIHandleAlloc (oci_env, (void *) &oci_statement,
415 OCI_HTYPE_STMT, /* user_data_size = */ 0, /* user_data = */ NULL);
416 if (status != OCI_SUCCESS)
417 {
418 o_report_error ("o_read_database_query", db->name,
419 udb_query_get_name (q), "OCIHandleAlloc", oci_error);
420 oci_statement = NULL;
421 return (-1);
422 }
424 status = OCIStmtPrepare (oci_statement, oci_error,
425 (text *) statement, (ub4) strlen (statement),
426 /* language = */ OCI_NTV_SYNTAX,
427 /* mode = */ OCI_DEFAULT);
428 if (status != OCI_SUCCESS)
429 {
430 o_report_error ("o_read_database_query", db->name,
431 udb_query_get_name (q), "OCIStmtPrepare", oci_error);
432 OCIHandleFree (oci_statement, OCI_HTYPE_STMT);
433 oci_statement = NULL;
434 return (-1);
435 }
436 udb_query_set_user_data (q, oci_statement);
438 DEBUG ("oracle plugin: o_read_database_query (%s, %s): "
439 "Successfully allocated statement handle.",
440 db->name, udb_query_get_name (q));
441 } /* }}} */
443 assert (oci_statement != NULL);
445 /* Execute the statement */
446 status = OCIStmtExecute (db->oci_service_context, /* {{{ */
447 oci_statement,
448 oci_error,
449 /* iters = */ 0,
450 /* rowoff = */ 0,
451 /* snap_in = */ NULL, /* snap_out = */ NULL,
452 /* mode = */ OCI_DEFAULT);
453 if (status != OCI_SUCCESS)
454 {
455 o_report_error ("o_read_database_query", db->name, udb_query_get_name (q),
456 "OCIStmtExecute", oci_error);
457 return (-1);
458 } /* }}} */
460 /* Acquire the number of columns returned. */
461 do /* {{{ */
462 {
463 ub4 param_counter = 0;
464 status = OCIAttrGet (oci_statement, OCI_HTYPE_STMT, /* {{{ */
465 ¶m_counter, /* size pointer = */ NULL,
466 OCI_ATTR_PARAM_COUNT, oci_error);
467 if (status != OCI_SUCCESS)
468 {
469 o_report_error ("o_read_database_query", db->name,
470 udb_query_get_name (q), "OCIAttrGet", oci_error);
471 return (-1);
472 } /* }}} */
474 column_num = (size_t) param_counter;
475 } while (0); /* }}} */
477 /* Allocate the following buffers:
478 *
479 * +---------------+-----------------------------------+
480 * ! Name ! Size !
481 * +---------------+-----------------------------------+
482 * ! column_names ! column_num x DATA_MAX_NAME_LEN !
483 * ! column_values ! column_num x DATA_MAX_NAME_LEN !
484 * ! oci_defines ! column_num x sizeof (OCIDefine *) !
485 * +---------------+-----------------------------------+
486 *
487 * {{{ */
488 #define NUMBER_BUFFER_SIZE 64
490 #define FREE_ALL \
491 if (column_names != NULL) { \
492 sfree (column_names[0]); \
493 sfree (column_names); \
494 } \
495 if (column_values != NULL) { \
496 sfree (column_values[0]); \
497 sfree (column_values); \
498 } \
499 sfree (oci_defines)
501 #define ALLOC_OR_FAIL(ptr, ptr_size) \
502 do { \
503 size_t alloc_size = (size_t) ((ptr_size)); \
504 (ptr) = calloc (1, alloc_size); \
505 if ((ptr) == NULL) { \
506 FREE_ALL; \
507 ERROR ("oracle plugin: o_read_database_query: calloc failed."); \
508 return (-1); \
509 } \
510 } while (0)
512 /* Initialize everything to NULL so the above works. */
513 column_names = NULL;
514 column_values = NULL;
515 oci_defines = NULL;
517 ALLOC_OR_FAIL (column_names, column_num * sizeof (char *));
518 ALLOC_OR_FAIL (column_names[0], column_num * DATA_MAX_NAME_LEN
519 * sizeof (char));
520 for (i = 1; i < column_num; i++)
521 column_names[i] = column_names[i - 1] + DATA_MAX_NAME_LEN;
523 ALLOC_OR_FAIL (column_values, column_num * sizeof (char *));
524 ALLOC_OR_FAIL (column_values[0], column_num * DATA_MAX_NAME_LEN
525 * sizeof (char));
526 for (i = 1; i < column_num; i++)
527 column_values[i] = column_values[i - 1] + DATA_MAX_NAME_LEN;
529 ALLOC_OR_FAIL (oci_defines, column_num * sizeof (OCIDefine *));
530 /* }}} End of buffer allocations. */
532 /* ``Define'' the returned data, i. e. bind the columns to the buffers
533 * allocated above. */
534 for (i = 0; i < column_num; i++) /* {{{ */
535 {
536 char *column_name;
537 ub4 column_name_length;
538 OCIParam *oci_param;
540 oci_param = NULL;
542 status = OCIParamGet (oci_statement, OCI_HTYPE_STMT, oci_error,
543 (void *) &oci_param, (ub4) (i + 1));
544 if (status != OCI_SUCCESS)
545 {
546 /* This is probably alright */
547 DEBUG ("oracle plugin: o_read_database_query: status = %#x (= %i);",
548 status, status);
549 o_report_error ("o_read_database_query", db->name,
550 udb_query_get_name (q), "OCIParamGet", oci_error);
551 status = OCI_SUCCESS;
552 break;
553 }
555 column_name = NULL;
556 column_name_length = 0;
557 status = OCIAttrGet (oci_param, OCI_DTYPE_PARAM,
558 &column_name, &column_name_length, OCI_ATTR_NAME, oci_error);
559 if (status != OCI_SUCCESS)
560 {
561 OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM);
562 o_report_error ("o_read_database_query", db->name,
563 udb_query_get_name (q), "OCIAttrGet (OCI_ATTR_NAME)", oci_error);
564 continue;
565 }
567 OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM);
568 oci_param = NULL;
570 /* Copy the name to column_names. Warning: The ``string'' returned by OCI
571 * may not be null terminated! */
572 memset (column_names[i], 0, DATA_MAX_NAME_LEN);
573 if (column_name_length >= DATA_MAX_NAME_LEN)
574 column_name_length = DATA_MAX_NAME_LEN - 1;
575 memcpy (column_names[i], column_name, column_name_length);
576 column_names[i][column_name_length] = 0;
578 DEBUG ("oracle plugin: o_read_database_query: column_names[%zu] = %s; "
579 "column_name_length = %"PRIu32";",
580 i, column_names[i], (uint32_t) column_name_length);
582 status = OCIDefineByPos (oci_statement,
583 &oci_defines[i], oci_error, (ub4) (i + 1),
584 column_values[i], DATA_MAX_NAME_LEN, SQLT_STR,
585 NULL, NULL, NULL, OCI_DEFAULT);
586 if (status != OCI_SUCCESS)
587 {
588 o_report_error ("o_read_database_query", db->name,
589 udb_query_get_name (q), "OCIDefineByPos", oci_error);
590 continue;
591 }
592 } /* for (j = 1; j <= param_counter; j++) */
593 /* }}} End of the ``define'' stuff. */
595 status = udb_query_prepare_result (q, prep_area,
596 (db->host != NULL) ? db->host : hostname_g,
597 /* plugin = */ "oracle", db->name, column_names, column_num,
598 /* interval = */ 0);
599 if (status != 0)
600 {
601 ERROR ("oracle plugin: o_read_database_query (%s, %s): "
602 "udb_query_prepare_result failed.",
603 db->name, udb_query_get_name (q));
604 FREE_ALL;
605 return (-1);
606 }
608 /* Fetch and handle all the rows that matched the query. */
609 while (42) /* {{{ */
610 {
611 status = OCIStmtFetch2 (oci_statement, oci_error,
612 /* nrows = */ 1, /* orientation = */ OCI_FETCH_NEXT,
613 /* fetch offset = */ 0, /* mode = */ OCI_DEFAULT);
614 if (status == OCI_NO_DATA)
615 {
616 status = OCI_SUCCESS;
617 break;
618 }
619 else if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO))
620 {
621 o_report_error ("o_read_database_query", db->name,
622 udb_query_get_name (q), "OCIStmtFetch2", oci_error);
623 break;
624 }
626 status = udb_query_handle_result (q, prep_area, column_values);
627 if (status != 0)
628 {
629 WARNING ("oracle plugin: o_read_database_query (%s, %s): "
630 "udb_query_handle_result failed.",
631 db->name, udb_query_get_name (q));
632 }
633 } /* }}} while (42) */
635 /* DEBUG ("oracle plugin: o_read_database_query: This statement succeeded: %s", q->statement); */
636 FREE_ALL;
638 return (0);
639 #undef FREE_ALL
640 #undef ALLOC_OR_FAIL
641 } /* }}} int o_read_database_query */
643 static int o_read_database (o_database_t *db) /* {{{ */
644 {
645 size_t i;
646 int status;
648 if (db->oci_service_context != NULL)
649 {
650 OCIServer *server_handle;
651 ub4 connection_status;
653 server_handle = NULL;
654 status = OCIAttrGet ((void *) db->oci_service_context, OCI_HTYPE_SVCCTX,
655 (void *) &server_handle, /* size pointer = */ NULL,
656 OCI_ATTR_SERVER, oci_error);
657 if (status != OCI_SUCCESS)
658 {
659 o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet",
660 oci_error);
661 return (-1);
662 }
664 if (server_handle == NULL)
665 {
666 connection_status = OCI_SERVER_NOT_CONNECTED;
667 }
668 else /* if (server_handle != NULL) */
669 {
670 connection_status = 0;
671 status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER,
672 (void *) &connection_status, /* size pointer = */ NULL,
673 OCI_ATTR_SERVER_STATUS, oci_error);
674 if (status != OCI_SUCCESS)
675 {
676 o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet",
677 oci_error);
678 return (-1);
679 }
680 }
682 if (connection_status != OCI_SERVER_NORMAL)
683 {
684 INFO ("oracle plugin: Connection to %s lost. Trying to reconnect.",
685 db->name);
686 OCIHandleFree (db->oci_service_context, OCI_HTYPE_SVCCTX);
687 db->oci_service_context = NULL;
688 }
689 } /* if (db->oci_service_context != NULL) */
691 if (db->oci_service_context == NULL)
692 {
693 status = OCILogon (oci_env, oci_error,
694 &db->oci_service_context,
695 (OraText *) db->username, (ub4) strlen (db->username),
696 (OraText *) db->password, (ub4) strlen (db->password),
697 (OraText *) db->connect_id, (ub4) strlen (db->connect_id));
698 if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO))
699 {
700 char errfunc[256];
702 ssnprintf (errfunc, sizeof (errfunc), "OCILogon(\"%s\")", db->connect_id);
704 o_report_error ("o_read_database", db->name, NULL, errfunc, oci_error);
705 DEBUG ("oracle plugin: OCILogon (%s): db->oci_service_context = %p;",
706 db->connect_id, db->oci_service_context);
707 db->oci_service_context = NULL;
708 return (-1);
709 }
710 else if (status == OCI_SUCCESS_WITH_INFO)
711 {
712 /* TODO: Print NOTIFY message. */
713 }
714 assert (db->oci_service_context != NULL);
715 }
717 DEBUG ("oracle plugin: o_read_database: db->connect_id = %s; db->oci_service_context = %p;",
718 db->connect_id, db->oci_service_context);
720 for (i = 0; i < db->queries_num; i++)
721 o_read_database_query (db, db->queries[i], db->q_prep_areas[i]);
723 return (0);
724 } /* }}} int o_read_database */
726 static int o_read (void) /* {{{ */
727 {
728 size_t i;
730 for (i = 0; i < databases_num; i++)
731 o_read_database (databases[i]);
733 return (0);
734 } /* }}} int o_read */
736 static int o_shutdown (void) /* {{{ */
737 {
738 size_t i;
740 for (i = 0; i < databases_num; i++)
741 if (databases[i]->oci_service_context != NULL)
742 {
743 OCIHandleFree (databases[i]->oci_service_context, OCI_HTYPE_SVCCTX);
744 databases[i]->oci_service_context = NULL;
745 }
747 for (i = 0; i < queries_num; i++)
748 {
749 OCIStmt *oci_statement;
751 oci_statement = udb_query_get_user_data (queries[i]);
752 if (oci_statement != NULL)
753 {
754 OCIHandleFree (oci_statement, OCI_HTYPE_STMT);
755 udb_query_set_user_data (queries[i], NULL);
756 }
757 }
759 OCIHandleFree (oci_env, OCI_HTYPE_ENV);
760 oci_env = NULL;
762 udb_query_free (queries, queries_num);
763 queries = NULL;
764 queries_num = 0;
766 return (0);
767 } /* }}} int o_shutdown */
769 void module_register (void) /* {{{ */
770 {
771 plugin_register_complex_config ("oracle", o_config);
772 plugin_register_init ("oracle", o_init);
773 plugin_register_read ("oracle", o_read);
774 plugin_register_shutdown ("oracle", o_shutdown);
775 } /* }}} void module_register */
777 /*
778 * vim: shiftwidth=2 softtabstop=2 et fdm=marker
779 */