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"
50 #include "common.h"
51 #include "plugin.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;
97 if (db_name == NULL)
98 db_name = "(none)";
99 if (query_name == NULL)
100 query_name = "(none)";
102 /* An operation may cause / return multiple errors. Loop until we have
103 * handled all errors available (with a fail-save limit of 16). */
104 for (unsigned int record_number = 1; record_number <= 16; record_number++)
105 {
106 memset (buffer, 0, sizeof (buffer));
107 error_code = -1;
109 status = OCIErrorGet (eh, (ub4) record_number,
110 /* sqlstate = */ NULL,
111 &error_code,
112 (text *) &buffer[0],
113 (ub4) sizeof (buffer),
114 OCI_HTYPE_ERROR);
115 buffer[sizeof (buffer) - 1] = 0;
117 if (status == OCI_NO_DATA)
118 return;
120 if (status == OCI_SUCCESS)
121 {
122 size_t buffer_length;
124 buffer_length = strlen (buffer);
125 while ((buffer_length > 0) && (buffer[buffer_length - 1] < 32))
126 {
127 buffer_length--;
128 buffer[buffer_length] = 0;
129 }
131 ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed: %s",
132 where, db_name, query_name, what, buffer);
133 }
134 else
135 {
136 ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed. "
137 "Additionally, OCIErrorGet failed with status %i.",
138 where, db_name, query_name, what, status);
139 return;
140 }
141 }
142 } /* }}} void o_report_error */
144 static void o_database_free (o_database_t *db) /* {{{ */
145 {
146 if (db == NULL)
147 return;
149 sfree (db->name);
150 sfree (db->connect_id);
151 sfree (db->username);
152 sfree (db->password);
153 sfree (db->queries);
155 if (db->q_prep_areas != NULL)
156 for (size_t i = 0; i < db->queries_num; ++i)
157 udb_query_delete_preparation_area (db->q_prep_areas[i]);
158 free (db->q_prep_areas);
160 sfree (db);
161 } /* }}} void o_database_free */
163 /* Configuration handling functions {{{
164 *
165 * <Plugin oracle>
166 * <Query "plugin_instance0">
167 * Statement "SELECT name, value FROM table"
168 * <Result>
169 * Type "gauge"
170 * InstancesFrom "name"
171 * ValuesFrom "value"
172 * </Result>
173 * </Query>
174 *
175 * <Database "plugin_instance1">
176 * ConnectID "db01"
177 * Username "oracle"
178 * Password "secret"
179 * Query "plugin_instance0"
180 * </Database>
181 * </Plugin>
182 */
184 static int o_config_add_database (oconfig_item_t *ci) /* {{{ */
185 {
186 o_database_t *db;
187 int status;
189 if ((ci->values_num != 1)
190 || (ci->values[0].type != OCONFIG_TYPE_STRING))
191 {
192 WARNING ("oracle plugin: The `Database' block "
193 "needs exactly one string argument.");
194 return (-1);
195 }
197 db = calloc (1, sizeof (*db));
198 if (db == NULL)
199 {
200 ERROR ("oracle plugin: calloc failed.");
201 return (-1);
202 }
203 db->name = NULL;
204 db->host = NULL;
205 db->connect_id = NULL;
206 db->username = NULL;
207 db->password = NULL;
209 status = cf_util_get_string (ci, &db->name);
210 if (status != 0)
211 {
212 sfree (db);
213 return (status);
214 }
216 /* Fill the `o_database_t' structure.. */
217 for (int i = 0; i < ci->children_num; i++)
218 {
219 oconfig_item_t *child = ci->children + i;
221 if (strcasecmp ("ConnectID", child->key) == 0)
222 status = cf_util_get_string (child, &db->connect_id);
223 else if (strcasecmp ("Host", child->key) == 0)
224 status = cf_util_get_string (child, &db->host);
225 else if (strcasecmp ("Username", child->key) == 0)
226 status = cf_util_get_string (child, &db->username);
227 else if (strcasecmp ("Password", child->key) == 0)
228 status = cf_util_get_string (child, &db->password);
229 else if (strcasecmp ("Query", child->key) == 0)
230 status = udb_query_pick_from_list (child, queries, queries_num,
231 &db->queries, &db->queries_num);
232 else
233 {
234 WARNING ("oracle plugin: Option `%s' not allowed here.", child->key);
235 status = -1;
236 }
238 if (status != 0)
239 break;
240 }
242 /* Check that all necessary options have been given. */
243 while (status == 0)
244 {
245 if (db->connect_id == NULL)
246 {
247 WARNING ("oracle plugin: `ConnectID' not given for query `%s'", db->name);
248 status = -1;
249 }
250 if (db->username == NULL)
251 {
252 WARNING ("oracle plugin: `Username' not given for query `%s'", db->name);
253 status = -1;
254 }
255 if (db->password == NULL)
256 {
257 WARNING ("oracle plugin: `Password' not given for query `%s'", db->name);
258 status = -1;
259 }
261 break;
262 } /* while (status == 0) */
264 while ((status == 0) && (db->queries_num > 0))
265 {
266 db->q_prep_areas = (udb_query_preparation_area_t **) calloc (
267 db->queries_num, sizeof (*db->q_prep_areas));
269 if (db->q_prep_areas == NULL)
270 {
271 WARNING ("oracle plugin: calloc failed");
272 status = -1;
273 break;
274 }
276 for (int i = 0; i < db->queries_num; ++i)
277 {
278 db->q_prep_areas[i]
279 = udb_query_allocate_preparation_area (db->queries[i]);
281 if (db->q_prep_areas[i] == NULL)
282 {
283 WARNING ("oracle plugin: udb_query_allocate_preparation_area failed");
284 status = -1;
285 break;
286 }
287 }
289 break;
290 }
292 /* If all went well, add this query to the list of queries within the
293 * database structure. */
294 if (status == 0)
295 {
296 o_database_t **temp;
298 temp = realloc (databases,
299 sizeof (*databases) * (databases_num + 1));
300 if (temp == NULL)
301 {
302 ERROR ("oracle plugin: realloc failed");
303 status = -1;
304 }
305 else
306 {
307 databases = temp;
308 databases[databases_num] = db;
309 databases_num++;
310 }
311 }
313 if (status != 0)
314 {
315 o_database_free (db);
316 return (-1);
317 }
319 return (0);
320 } /* }}} int o_config_add_database */
322 static int o_config (oconfig_item_t *ci) /* {{{ */
323 {
324 for (int i = 0; i < ci->children_num; i++)
325 {
326 oconfig_item_t *child = ci->children + i;
327 if (strcasecmp ("Query", child->key) == 0)
328 udb_query_create (&queries, &queries_num, child,
329 /* callback = */ NULL);
330 else if (strcasecmp ("Database", child->key) == 0)
331 o_config_add_database (child);
332 else
333 {
334 WARNING ("oracle plugin: Ignoring unknown config option `%s'.", child->key);
335 }
337 if (queries_num > 0)
338 {
339 DEBUG ("oracle plugin: o_config: queries_num = %zu; queries[0] = %p; udb_query_get_user_data (queries[0]) = %p;",
340 queries_num, (void *) queries[0], udb_query_get_user_data (queries[0]));
341 }
342 } /* for (ci->children) */
344 return (0);
345 } /* }}} int o_config */
347 /* }}} End of configuration handling functions */
349 static int o_init (void) /* {{{ */
350 {
351 int status;
353 if (oci_env != NULL)
354 return (0);
356 status = OCIEnvCreate (&oci_env,
357 /* mode = */ OCI_THREADED,
358 /* context = */ NULL,
359 /* malloc = */ NULL,
360 /* realloc = */ NULL,
361 /* free = */ NULL,
362 /* user_data_size = */ 0,
363 /* user_data_ptr = */ NULL);
364 if (status != 0)
365 {
366 ERROR ("oracle plugin: OCIEnvCreate failed with status %i.", status);
367 return (-1);
368 }
370 status = OCIHandleAlloc (oci_env, (void *) &oci_error, OCI_HTYPE_ERROR,
371 /* user_data_size = */ 0, /* user_data = */ NULL);
372 if (status != OCI_SUCCESS)
373 {
374 ERROR ("oracle plugin: OCIHandleAlloc (OCI_HTYPE_ERROR) failed "
375 "with status %i.", status);
376 return (-1);
377 }
379 return (0);
380 } /* }}} int o_init */
382 static int o_read_database_query (o_database_t *db, /* {{{ */
383 udb_query_t *q, udb_query_preparation_area_t *prep_area)
384 {
385 char **column_names;
386 char **column_values;
387 size_t column_num;
389 OCIStmt *oci_statement;
391 /* List of `OCIDefine' pointers. These defines map columns to the buffer
392 * space declared above. */
393 OCIDefine **oci_defines;
395 int status;
397 oci_statement = udb_query_get_user_data (q);
399 /* Prepare the statement */
400 if (oci_statement == NULL) /* {{{ */
401 {
402 const char *statement;
404 statement = udb_query_get_statement (q);
405 assert (statement != NULL);
407 status = OCIHandleAlloc (oci_env, (void *) &oci_statement,
408 OCI_HTYPE_STMT, /* user_data_size = */ 0, /* user_data = */ NULL);
409 if (status != OCI_SUCCESS)
410 {
411 o_report_error ("o_read_database_query", db->name,
412 udb_query_get_name (q), "OCIHandleAlloc", oci_error);
413 oci_statement = NULL;
414 return (-1);
415 }
417 status = OCIStmtPrepare (oci_statement, oci_error,
418 (text *) statement, (ub4) strlen (statement),
419 /* language = */ OCI_NTV_SYNTAX,
420 /* mode = */ OCI_DEFAULT);
421 if (status != OCI_SUCCESS)
422 {
423 o_report_error ("o_read_database_query", db->name,
424 udb_query_get_name (q), "OCIStmtPrepare", oci_error);
425 OCIHandleFree (oci_statement, OCI_HTYPE_STMT);
426 oci_statement = NULL;
427 return (-1);
428 }
429 udb_query_set_user_data (q, oci_statement);
431 DEBUG ("oracle plugin: o_read_database_query (%s, %s): "
432 "Successfully allocated statement handle.",
433 db->name, udb_query_get_name (q));
434 } /* }}} */
436 assert (oci_statement != NULL);
438 /* Execute the statement */
439 status = OCIStmtExecute (db->oci_service_context, /* {{{ */
440 oci_statement,
441 oci_error,
442 /* iters = */ 0,
443 /* rowoff = */ 0,
444 /* snap_in = */ NULL, /* snap_out = */ NULL,
445 /* mode = */ OCI_DEFAULT);
446 if (status != OCI_SUCCESS)
447 {
448 o_report_error ("o_read_database_query", db->name, udb_query_get_name (q),
449 "OCIStmtExecute", oci_error);
450 return (-1);
451 } /* }}} */
453 /* Acquire the number of columns returned. */
454 do /* {{{ */
455 {
456 ub4 param_counter = 0;
457 status = OCIAttrGet (oci_statement, OCI_HTYPE_STMT, /* {{{ */
458 ¶m_counter, /* size pointer = */ NULL,
459 OCI_ATTR_PARAM_COUNT, oci_error);
460 if (status != OCI_SUCCESS)
461 {
462 o_report_error ("o_read_database_query", db->name,
463 udb_query_get_name (q), "OCIAttrGet", oci_error);
464 return (-1);
465 } /* }}} */
467 column_num = (size_t) param_counter;
468 } while (0); /* }}} */
470 /* Allocate the following buffers:
471 *
472 * +---------------+-----------------------------------+
473 * ! Name ! Size !
474 * +---------------+-----------------------------------+
475 * ! column_names ! column_num x DATA_MAX_NAME_LEN !
476 * ! column_values ! column_num x DATA_MAX_NAME_LEN !
477 * ! oci_defines ! column_num x sizeof (OCIDefine *) !
478 * +---------------+-----------------------------------+
479 *
480 * {{{ */
481 #define NUMBER_BUFFER_SIZE 64
483 #define FREE_ALL \
484 if (column_names != NULL) { \
485 sfree (column_names[0]); \
486 sfree (column_names); \
487 } \
488 if (column_values != NULL) { \
489 sfree (column_values[0]); \
490 sfree (column_values); \
491 } \
492 sfree (oci_defines)
494 #define ALLOC_OR_FAIL(ptr, ptr_size) \
495 do { \
496 size_t alloc_size = (size_t) ((ptr_size)); \
497 (ptr) = calloc (1, alloc_size); \
498 if ((ptr) == NULL) { \
499 FREE_ALL; \
500 ERROR ("oracle plugin: o_read_database_query: calloc failed."); \
501 return (-1); \
502 } \
503 } while (0)
505 /* Initialize everything to NULL so the above works. */
506 column_names = NULL;
507 column_values = NULL;
508 oci_defines = NULL;
510 ALLOC_OR_FAIL (column_names, column_num * sizeof (char *));
511 ALLOC_OR_FAIL (column_names[0], column_num * DATA_MAX_NAME_LEN
512 * sizeof (char));
513 for (size_t i = 1; i < column_num; i++)
514 column_names[i] = column_names[i - 1] + DATA_MAX_NAME_LEN;
516 ALLOC_OR_FAIL (column_values, column_num * sizeof (char *));
517 ALLOC_OR_FAIL (column_values[0], column_num * DATA_MAX_NAME_LEN
518 * sizeof (char));
519 for (size_t i = 1; i < column_num; i++)
520 column_values[i] = column_values[i - 1] + DATA_MAX_NAME_LEN;
522 ALLOC_OR_FAIL (oci_defines, column_num * sizeof (OCIDefine *));
523 /* }}} End of buffer allocations. */
525 /* ``Define'' the returned data, i. e. bind the columns to the buffers
526 * allocated above. */
527 for (size_t i = 0; i < column_num; i++) /* {{{ */
528 {
529 char *column_name;
530 ub4 column_name_length;
531 OCIParam *oci_param;
533 oci_param = NULL;
535 status = OCIParamGet (oci_statement, OCI_HTYPE_STMT, oci_error,
536 (void *) &oci_param, (ub4) (i + 1));
537 if (status != OCI_SUCCESS)
538 {
539 /* This is probably alright */
540 DEBUG ("oracle plugin: o_read_database_query: status = %#x (= %i);",
541 status, status);
542 o_report_error ("o_read_database_query", db->name,
543 udb_query_get_name (q), "OCIParamGet", oci_error);
544 status = OCI_SUCCESS;
545 break;
546 }
548 column_name = NULL;
549 column_name_length = 0;
550 status = OCIAttrGet (oci_param, OCI_DTYPE_PARAM,
551 &column_name, &column_name_length, OCI_ATTR_NAME, oci_error);
552 if (status != OCI_SUCCESS)
553 {
554 OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM);
555 o_report_error ("o_read_database_query", db->name,
556 udb_query_get_name (q), "OCIAttrGet (OCI_ATTR_NAME)", oci_error);
557 continue;
558 }
560 OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM);
561 oci_param = NULL;
563 /* Copy the name to column_names. Warning: The ``string'' returned by OCI
564 * may not be null terminated! */
565 memset (column_names[i], 0, DATA_MAX_NAME_LEN);
566 if (column_name_length >= DATA_MAX_NAME_LEN)
567 column_name_length = DATA_MAX_NAME_LEN - 1;
568 memcpy (column_names[i], column_name, column_name_length);
569 column_names[i][column_name_length] = 0;
571 DEBUG ("oracle plugin: o_read_database_query: column_names[%zu] = %s; "
572 "column_name_length = %"PRIu32";",
573 i, column_names[i], (uint32_t) column_name_length);
575 status = OCIDefineByPos (oci_statement,
576 &oci_defines[i], oci_error, (ub4) (i + 1),
577 column_values[i], DATA_MAX_NAME_LEN, SQLT_STR,
578 NULL, NULL, NULL, OCI_DEFAULT);
579 if (status != OCI_SUCCESS)
580 {
581 o_report_error ("o_read_database_query", db->name,
582 udb_query_get_name (q), "OCIDefineByPos", oci_error);
583 continue;
584 }
585 } /* for (j = 1; j <= param_counter; j++) */
586 /* }}} End of the ``define'' stuff. */
588 status = udb_query_prepare_result (q, prep_area,
589 (db->host != NULL) ? db->host : hostname_g,
590 /* plugin = */ "oracle", db->name, column_names, column_num,
591 /* interval = */ 0);
592 if (status != 0)
593 {
594 ERROR ("oracle plugin: o_read_database_query (%s, %s): "
595 "udb_query_prepare_result failed.",
596 db->name, udb_query_get_name (q));
597 FREE_ALL;
598 return (-1);
599 }
601 /* Fetch and handle all the rows that matched the query. */
602 while (42) /* {{{ */
603 {
604 status = OCIStmtFetch2 (oci_statement, oci_error,
605 /* nrows = */ 1, /* orientation = */ OCI_FETCH_NEXT,
606 /* fetch offset = */ 0, /* mode = */ OCI_DEFAULT);
607 if (status == OCI_NO_DATA)
608 {
609 status = OCI_SUCCESS;
610 break;
611 }
612 else if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO))
613 {
614 o_report_error ("o_read_database_query", db->name,
615 udb_query_get_name (q), "OCIStmtFetch2", oci_error);
616 break;
617 }
619 status = udb_query_handle_result (q, prep_area, column_values);
620 if (status != 0)
621 {
622 WARNING ("oracle plugin: o_read_database_query (%s, %s): "
623 "udb_query_handle_result failed.",
624 db->name, udb_query_get_name (q));
625 }
626 } /* }}} while (42) */
628 /* DEBUG ("oracle plugin: o_read_database_query: This statement succeeded: %s", q->statement); */
629 FREE_ALL;
631 return (0);
632 #undef FREE_ALL
633 #undef ALLOC_OR_FAIL
634 } /* }}} int o_read_database_query */
636 static int o_read_database (o_database_t *db) /* {{{ */
637 {
638 int status;
640 if (db->oci_service_context != NULL)
641 {
642 OCIServer *server_handle;
643 ub4 connection_status;
645 server_handle = NULL;
646 status = OCIAttrGet ((void *) db->oci_service_context, OCI_HTYPE_SVCCTX,
647 (void *) &server_handle, /* size pointer = */ NULL,
648 OCI_ATTR_SERVER, oci_error);
649 if (status != OCI_SUCCESS)
650 {
651 o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet",
652 oci_error);
653 return (-1);
654 }
656 if (server_handle == NULL)
657 {
658 connection_status = OCI_SERVER_NOT_CONNECTED;
659 }
660 else /* if (server_handle != NULL) */
661 {
662 connection_status = 0;
663 status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER,
664 (void *) &connection_status, /* size pointer = */ NULL,
665 OCI_ATTR_SERVER_STATUS, oci_error);
666 if (status != OCI_SUCCESS)
667 {
668 o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet",
669 oci_error);
670 return (-1);
671 }
672 }
674 if (connection_status != OCI_SERVER_NORMAL)
675 {
676 INFO ("oracle plugin: Connection to %s lost. Trying to reconnect.",
677 db->name);
678 OCIHandleFree (db->oci_service_context, OCI_HTYPE_SVCCTX);
679 db->oci_service_context = NULL;
680 }
681 } /* if (db->oci_service_context != NULL) */
683 if (db->oci_service_context == NULL)
684 {
685 status = OCILogon (oci_env, oci_error,
686 &db->oci_service_context,
687 (OraText *) db->username, (ub4) strlen (db->username),
688 (OraText *) db->password, (ub4) strlen (db->password),
689 (OraText *) db->connect_id, (ub4) strlen (db->connect_id));
690 if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO))
691 {
692 char errfunc[256];
694 ssnprintf (errfunc, sizeof (errfunc), "OCILogon(\"%s\")", db->connect_id);
696 o_report_error ("o_read_database", db->name, NULL, errfunc, oci_error);
697 DEBUG ("oracle plugin: OCILogon (%s): db->oci_service_context = %p;",
698 db->connect_id, db->oci_service_context);
699 db->oci_service_context = NULL;
700 return (-1);
701 }
702 else if (status == OCI_SUCCESS_WITH_INFO)
703 {
704 /* TODO: Print NOTIFY message. */
705 }
706 assert (db->oci_service_context != NULL);
707 }
709 DEBUG ("oracle plugin: o_read_database: db->connect_id = %s; db->oci_service_context = %p;",
710 db->connect_id, db->oci_service_context);
712 for (size_t i = 0; i < db->queries_num; i++)
713 o_read_database_query (db, db->queries[i], db->q_prep_areas[i]);
715 return (0);
716 } /* }}} int o_read_database */
718 static int o_read (void) /* {{{ */
719 {
720 size_t i;
722 for (i = 0; i < databases_num; i++)
723 o_read_database (databases[i]);
725 return (0);
726 } /* }}} int o_read */
728 static int o_shutdown (void) /* {{{ */
729 {
730 size_t i;
732 for (i = 0; i < databases_num; i++)
733 if (databases[i]->oci_service_context != NULL)
734 {
735 OCIHandleFree (databases[i]->oci_service_context, OCI_HTYPE_SVCCTX);
736 databases[i]->oci_service_context = NULL;
737 }
739 for (i = 0; i < queries_num; i++)
740 {
741 OCIStmt *oci_statement;
743 oci_statement = udb_query_get_user_data (queries[i]);
744 if (oci_statement != NULL)
745 {
746 OCIHandleFree (oci_statement, OCI_HTYPE_STMT);
747 udb_query_set_user_data (queries[i], NULL);
748 }
749 }
751 OCIHandleFree (oci_env, OCI_HTYPE_ENV);
752 oci_env = NULL;
754 udb_query_free (queries, queries_num);
755 queries = NULL;
756 queries_num = 0;
758 return (0);
759 } /* }}} int o_shutdown */
761 void module_register (void) /* {{{ */
762 {
763 plugin_register_complex_config ("oracle", o_config);
764 plugin_register_init ("oracle", o_init);
765 plugin_register_read ("oracle", o_read);
766 plugin_register_shutdown ("oracle", o_shutdown);
767 } /* }}} void module_register */
769 /*
770 * vim: shiftwidth=2 softtabstop=2 et fdm=marker
771 */