2 * collectd - src/utils_db_query.c
3 * Copyright (C) 2008,2009 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
25 #include "configfile.h"
26 #include "utils_db_query.h"
31 struct udb_result_s; /* {{{ */
32 typedef struct udb_result_s udb_result_t;
36 char *instance_prefix;
42 /* Preparation area */
44 size_t *instances_pos;
46 char **instances_buffer;
51 size_t legacy_position;
52 /* When in legacy mode:
53 * - type/ds hold the format of the data
54 * - instance_prefix is used as type-instance if non-NULL
55 * - legacy_position holds the index of the column to use as value.
61 struct udb_query_s /* {{{ */
69 unsigned int min_version;
70 unsigned int max_version;
72 /* Preparation area */
78 udb_result_t *results;
82 * Config Private functions
84 static int udb_config_set_string (char **ret_string, /* {{{ */
89 if ((ci->values_num != 1)
90 || (ci->values[0].type != OCONFIG_TYPE_STRING))
92 WARNING ("db query utils: The `%s' config option "
93 "needs exactly one string argument.", ci->key);
97 string = strdup (ci->values[0].value.string);
100 ERROR ("db query utils: strdup failed.");
104 if (*ret_string != NULL)
106 *ret_string = string;
109 } /* }}} int udb_config_set_string */
111 static int udb_config_add_string (char ***ret_array, /* {{{ */
112 size_t *ret_array_len, oconfig_item_t *ci)
118 if (ci->values_num < 1)
120 WARNING ("db query utils: The `%s' config option "
121 "needs at least one argument.", ci->key);
125 for (i = 0; i < ci->values_num; i++)
127 if (ci->values[i].type != OCONFIG_TYPE_STRING)
129 WARNING ("db query utils: Argument %i to the `%s' option "
130 "is not a string.", i + 1, ci->key);
135 array_len = *ret_array_len;
136 array = (char **) realloc (*ret_array,
137 sizeof (char *) * (array_len + ci->values_num));
140 ERROR ("db query utils: realloc failed.");
145 for (i = 0; i < ci->values_num; i++)
147 array[array_len] = strdup (ci->values[i].value.string);
148 if (array[array_len] == NULL)
150 ERROR ("db query utils: strdup failed.");
151 *ret_array_len = array_len;
157 *ret_array_len = array_len;
159 } /* }}} int udb_config_add_string */
161 static int udb_config_set_uint (unsigned int *ret_value, /* {{{ */
166 if ((ci->values_num != 1)
167 || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
169 WARNING ("db query utils: The `%s' config option "
170 "needs exactly one numeric argument.", ci->key);
174 tmp = ci->values[0].value.number;
175 if ((tmp < 0.0) || (tmp > ((double) UINT_MAX)))
178 *ret_value = (unsigned int) (tmp + .5);
180 } /* }}} int udb_config_set_uint */
183 * Legacy result private functions
185 static void udb_legacy_result_finish_result (udb_result_t *r) /* {{{ */
190 assert (r->legacy_mode == 1);
193 } /* }}} void udb_legacy_result_finish_result */
195 static int udb_legacy_result_handle_result (udb_result_t *r, /* {{{ */
196 udb_query_t *q, char **column_values)
198 value_list_t vl = VALUE_LIST_INIT;
202 assert (r->legacy_mode == 1);
203 assert (r->ds != NULL);
204 assert (r->ds->ds_num == 1);
209 value_str = column_values[r->legacy_position];
210 if (0 != parse_value (value_str, &vl.values[0], r->ds->ds[0].type))
212 ERROR ("db query utils: udb_legacy_result_handle_result: "
213 "Parsing `%s' as %s failed.", value_str,
214 DS_TYPE_TO_STRING (r->ds->ds[0].type));
219 sstrncpy (vl.host, q->host, sizeof (vl.host));
220 sstrncpy (vl.plugin, q->plugin, sizeof (vl.plugin));
221 sstrncpy (vl.plugin_instance, q->db_name, sizeof (vl.type_instance));
222 sstrncpy (vl.type, r->type, sizeof (vl.type));
224 if (r->instance_prefix != NULL)
225 sstrncpy (vl.type_instance, r->instance_prefix,
226 sizeof (vl.type_instance));
228 plugin_dispatch_values (&vl);
231 } /* }}} int udb_legacy_result_handle_result */
233 static int udb_legacy_result_prepare_result (udb_result_t *r, /* {{{ */
234 char **column_names, size_t column_num)
239 assert (r->legacy_mode == 1);
241 /* Make sure previous preparations are cleaned up. */
242 udb_legacy_result_finish_result (r);
244 if (r->legacy_position >= column_num)
246 ERROR ("db query utils: The legacy configuration specified (at least) "
247 "%zu `Column's, but the query returned only %zu columns!",
248 r->legacy_position + 1, column_num);
252 /* Read `ds' and check number of values {{{ */
253 r->ds = plugin_get_ds (r->type);
256 ERROR ("db query utils: udb_result_prepare_result: Type `%s' is not "
257 "known by the daemon. See types.db(5) for details.",
262 if (r->ds->ds_num != 1)
264 ERROR ("db query utils: udb_result_prepare_result: The type `%s' "
265 "requires exactly %i values, but the legacy configuration "
266 "requires exactly one!",
274 } /* }}} int udb_legacy_result_prepare_result */
276 static int udb_legacy_result_create (const char *query_name, /* {{{ */
277 udb_result_t **r_head, oconfig_item_t *ci, size_t position)
281 if ((ci->values_num < 1) || (ci->values_num > 2)
282 || (ci->values[0].type != OCONFIG_TYPE_STRING)
283 || ((ci->values_num == 2)
284 && (ci->values[1].type != OCONFIG_TYPE_STRING)))
286 WARNING ("db query utils: The `Column' block needs either one or two "
287 "string arguments.");
291 r = (udb_result_t *) malloc (sizeof (*r));
294 ERROR ("db query utils: malloc failed.");
297 memset (r, 0, sizeof (*r));
300 r->legacy_position = position;
302 r->type = strdup (ci->values[0].value.string);
305 ERROR ("db query utils: strdup failed.");
310 r->instance_prefix = NULL;
311 if (ci->values_num == 2)
313 r->instance_prefix = strdup (ci->values[1].value.string);
314 if (r->instance_prefix == NULL)
316 ERROR ("db query utils: strdup failed.");
323 /* If all went well, add this result to the list of results. */
333 while (last->next != NULL)
340 } /* }}} int udb_legacy_result_create */
343 * Result private functions
345 static int udb_result_submit (udb_result_t *r, udb_query_t *q) /* {{{ */
347 value_list_t vl = VALUE_LIST_INIT;
351 assert (r->legacy_mode == 0);
352 assert (r->ds != NULL);
353 assert (((size_t) r->ds->ds_num) == r->values_num);
355 vl.values = (value_t *) calloc (r->ds->ds_num, sizeof (value_t));
356 if (vl.values == NULL)
358 ERROR ("db query utils: malloc failed.");
361 vl.values_len = r->ds->ds_num;
363 for (i = 0; i < r->values_num; i++)
365 char *value_str = r->values_buffer[i];
367 if (0 != parse_value (value_str, &vl.values[i], r->ds->ds[i].type))
369 ERROR ("db query utils: udb_result_submit: Parsing `%s' as %s failed.",
370 value_str, DS_TYPE_TO_STRING (r->ds->ds[i].type));
376 sstrncpy (vl.host, q->host, sizeof (vl.host));
377 sstrncpy (vl.plugin, q->plugin, sizeof (vl.plugin));
378 sstrncpy (vl.plugin_instance, q->db_name, sizeof (vl.type_instance));
379 sstrncpy (vl.type, r->type, sizeof (vl.type));
381 /* Set vl.type_instance {{{ */
382 if (r->instances_num <= 0)
384 if (r->instance_prefix == NULL)
385 vl.type_instance[0] = 0;
387 sstrncpy (vl.type_instance, r->instance_prefix,
388 sizeof (vl.type_instance));
390 else /* if ((r->instances_num > 0) */
392 if (r->instance_prefix == NULL)
394 strjoin (vl.type_instance, sizeof (vl.type_instance),
395 r->instances_buffer, r->instances_num, "-");
399 char tmp[DATA_MAX_NAME_LEN];
401 strjoin (tmp, sizeof (tmp), r->instances_buffer, r->instances_num, "-");
402 tmp[sizeof (tmp) - 1] = 0;
404 snprintf (vl.type_instance, sizeof (vl.type_instance), "%s-%s",
405 r->instance_prefix, tmp);
408 vl.type_instance[sizeof (vl.type_instance) - 1] = 0;
411 plugin_dispatch_values (&vl);
415 } /* }}} void udb_result_submit */
417 static void udb_result_finish_result (udb_result_t *r) /* {{{ */
422 if (r->legacy_mode == 1)
424 udb_legacy_result_finish_result (r);
428 assert (r->legacy_mode == 0);
431 sfree (r->instances_pos);
432 sfree (r->values_pos);
433 sfree (r->instances_buffer);
434 sfree (r->values_buffer);
435 } /* }}} void udb_result_finish_result */
437 static int udb_result_handle_result (udb_result_t *r, /* {{{ */
438 udb_query_t *q, char **column_values)
442 if (r->legacy_mode == 1)
443 return (udb_legacy_result_handle_result (r, q, column_values));
445 assert (r->legacy_mode == 0);
447 for (i = 0; i < r->instances_num; i++)
448 r->instances_buffer[i] = column_values[r->instances_pos[i]];
450 for (i = 0; i < r->values_num; i++)
451 r->values_buffer[i] = column_values[r->values_pos[i]];
453 return udb_result_submit (r, q);
454 } /* }}} int udb_result_handle_result */
456 static int udb_result_prepare_result (udb_result_t *r, /* {{{ */
457 char **column_names, size_t column_num)
464 if (r->legacy_mode == 1)
465 return (udb_legacy_result_prepare_result (r, column_names, column_num));
467 assert (r->legacy_mode == 0);
469 #define BAIL_OUT(status) \
471 sfree (r->instances_pos); \
472 sfree (r->values_pos); \
473 sfree (r->instances_buffer); \
474 sfree (r->values_buffer); \
477 /* Make sure previous preparations are cleaned up. */
478 udb_result_finish_result (r);
479 r->instances_pos = NULL;
480 r->values_pos = NULL;
482 /* Read `ds' and check number of values {{{ */
483 r->ds = plugin_get_ds (r->type);
486 ERROR ("db query utils: udb_result_prepare_result: Type `%s' is not "
487 "known by the daemon. See types.db(5) for details.",
492 if (((size_t) r->ds->ds_num) != r->values_num)
494 ERROR ("db query utils: udb_result_prepare_result: The type `%s' "
495 "requires exactly %i value%s, but the configuration specifies %zu.",
497 r->ds->ds_num, (r->ds->ds_num == 1) ? "" : "s",
503 /* Allocate r->instances_pos, r->values_pos, r->instances_buffer, and
504 * r->values_buffer {{{ */
505 if (r->instances_num > 0)
507 r->instances_pos = (size_t *) calloc (r->instances_num, sizeof (size_t));
508 if (r->instances_pos == NULL)
510 ERROR ("db query utils: udb_result_prepare_result: malloc failed.");
514 r->instances_buffer = (char **) calloc (r->instances_num, sizeof (char *));
515 if (r->instances_buffer == NULL)
517 ERROR ("db query utils: udb_result_prepare_result: malloc failed.");
520 } /* if (r->instances_num > 0) */
522 r->values_pos = (size_t *) calloc (r->values_num, sizeof (size_t));
523 if (r->values_pos == NULL)
525 ERROR ("db query utils: udb_result_prepare_result: malloc failed.");
529 r->values_buffer = (char **) calloc (r->values_num, sizeof (char *));
530 if (r->values_buffer == NULL)
532 ERROR ("db query utils: udb_result_prepare_result: malloc failed.");
537 /* Determine the position of the instance columns {{{ */
538 for (i = 0; i < r->instances_num; i++)
542 for (j = 0; j < column_num; j++)
544 if (strcasecmp (r->instances[i], column_names[j]) == 0)
546 r->instances_pos[i] = j;
553 ERROR ("db query utils: udb_result_prepare_result: "
554 "Column `%s' could not be found.",
558 } /* }}} for (i = 0; i < r->instances_num; i++) */
560 /* Determine the position of the value columns {{{ */
561 for (i = 0; i < r->values_num; i++)
565 for (j = 0; j < column_num; j++)
567 if (strcasecmp (r->values[i], column_names[j]) == 0)
569 r->values_pos[i] = j;
576 ERROR ("db query utils: udb_result_prepare_result: "
577 "Column `%s' could not be found.",
581 } /* }}} for (i = 0; i < r->values_num; i++) */
585 } /* }}} int udb_result_prepare_result */
587 static void udb_result_free (udb_result_t *r) /* {{{ */
596 for (i = 0; i < r->instances_num; i++)
597 sfree (r->instances[i]);
598 sfree (r->instances);
600 for (i = 0; i < r->values_num; i++)
601 sfree (r->values[i]);
604 udb_result_free (r->next);
607 } /* }}} void udb_result_free */
609 static int udb_result_create (const char *query_name, /* {{{ */
610 udb_result_t **r_head, oconfig_item_t *ci)
616 if (ci->values_num != 0)
618 WARNING ("db query utils: The `Result' block doesn't accept "
619 "any arguments. Ignoring %i argument%s.",
620 ci->values_num, (ci->values_num == 1) ? "" : "s");
623 r = (udb_result_t *) malloc (sizeof (*r));
626 ERROR ("db query utils: malloc failed.");
629 memset (r, 0, sizeof (*r));
631 r->instance_prefix = NULL;
636 /* Fill the `udb_result_t' structure.. */
638 for (i = 0; i < ci->children_num; i++)
640 oconfig_item_t *child = ci->children + i;
642 if (strcasecmp ("Type", child->key) == 0)
643 status = udb_config_set_string (&r->type, child);
644 else if (strcasecmp ("InstancePrefix", child->key) == 0)
645 status = udb_config_set_string (&r->instance_prefix, child);
646 else if (strcasecmp ("InstancesFrom", child->key) == 0)
647 status = udb_config_add_string (&r->instances, &r->instances_num, child);
648 else if (strcasecmp ("ValuesFrom", child->key) == 0)
649 status = udb_config_add_string (&r->values, &r->values_num, child);
652 WARNING ("db query utils: Query `%s': Option `%s' not allowed here.",
653 query_name, child->key);
661 /* Check that all necessary options have been given. */
666 WARNING ("db query utils: `Type' not given for "
667 "result in query `%s'", query_name);
670 if (r->values == NULL)
672 WARNING ("db query utils: `ValuesFrom' not given for "
673 "result in query `%s'", query_name);
678 } /* while (status == 0) */
686 /* If all went well, add this result to the list of results. */
696 while (last->next != NULL)
703 } /* }}} int udb_result_create */
706 * Query private functions
708 void udb_query_free_one (udb_query_t *q) /* {{{ */
714 sfree (q->statement);
716 udb_result_free (q->results);
719 } /* }}} void udb_query_free_one */
722 * Query public functions
724 int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */
725 size_t *ret_query_list_len, oconfig_item_t *ci,
726 udb_query_create_callback_t cb, int legacy_mode)
728 udb_query_t **query_list;
729 size_t query_list_len;
735 size_t legacy_position;
737 if ((ret_query_list == NULL) || (ret_query_list_len == NULL))
739 query_list = *ret_query_list;
740 query_list_len = *ret_query_list_len;
742 if ((ci->values_num != 1)
743 || (ci->values[0].type != OCONFIG_TYPE_STRING))
745 WARNING ("db query utils: The `Query' block "
746 "needs exactly one string argument.");
750 q = (udb_query_t *) malloc (sizeof (*q));
753 ERROR ("db query utils: malloc failed.");
756 memset (q, 0, sizeof (*q));
757 q->legacy_mode = legacy_mode;
759 q->max_version = UINT_MAX;
763 status = udb_config_set_string (&q->name, ci);
770 /* Fill the `udb_query_t' structure.. */
771 for (i = 0; i < ci->children_num; i++)
773 oconfig_item_t *child = ci->children + i;
775 if (strcasecmp ("Statement", child->key) == 0)
776 status = udb_config_set_string (&q->statement, child);
777 else if (strcasecmp ("Result", child->key) == 0)
778 status = udb_result_create (q->name, &q->results, child);
779 else if (strcasecmp ("MinVersion", child->key) == 0)
780 status = udb_config_set_uint (&q->min_version, child);
781 else if (strcasecmp ("MaxVersion", child->key) == 0)
782 status = udb_config_set_uint (&q->max_version, child);
784 /* PostgreSQL compatibility code */
785 else if ((strcasecmp ("Query", child->key) == 0)
786 && (q->legacy_mode == 1))
788 WARNING ("db query utils: Query `%s': The `Query' option is "
789 "deprecated. Please use `Statement' instead.",
791 status = udb_config_set_string (&q->statement, child);
793 else if ((strcasecmp ("Column", child->key) == 0)
794 && (q->legacy_mode == 1))
796 WARNING ("db query utils: Query `%s': The `Column' option is "
797 "deprecated. Please use the new syntax instead.",
799 status = udb_legacy_result_create (q->name, &q->results, child,
803 else if ((strcasecmp ("MinPGVersion", child->key) == 0)
804 && (q->legacy_mode == 1))
806 WARNING ("db query utils: Query `%s': The `MinPGVersion' option is "
807 "deprecated. Please use `MinVersion' instead.",
809 status = udb_config_set_uint (&q->min_version, child);
811 else if ((strcasecmp ("MaxPGVersion", child->key) == 0)
812 && (q->legacy_mode == 1))
814 WARNING ("db query utils: Query `%s': The `MaxPGVersion' option is "
815 "deprecated. Please use `MaxVersion' instead.",
817 status = udb_config_set_uint (&q->max_version, child);
820 /* Call custom callbacks */
823 status = (*cb) (q, child);
826 WARNING ("db query utils: The configuration callback failed "
827 "to handle `%s'.", child->key);
832 WARNING ("db query utils: Query `%s': Option `%s' not allowed here.",
833 q->name, child->key);
841 /* Check that all necessary options have been given. */
844 if (q->statement == NULL)
846 WARNING ("db query utils: Query `%s': No `Statement' given.", q->name);
849 if (q->results == NULL)
851 WARNING ("db query utils: Query `%s': No (valid) `Result' block given.",
855 } /* if (status == 0) */
857 /* If all went well, add this query to the list of queries within the
858 * database structure. */
863 temp = (udb_query_t **) realloc (query_list,
864 sizeof (*query_list) * (query_list_len + 1));
867 ERROR ("db query utils: realloc failed");
873 query_list[query_list_len] = q;
880 udb_query_free_one (q);
884 *ret_query_list = query_list;
885 *ret_query_list_len = query_list_len;
888 } /* }}} int udb_query_create */
890 void udb_query_free (udb_query_t **query_list, size_t query_list_len) /* {{{ */
894 if (query_list == NULL)
897 for (i = 0; i < query_list_len; i++)
898 udb_query_free_one (query_list[i]);
901 } /* }}} void udb_query_free */
903 int udb_query_pick_from_list_by_name (const char *name, /* {{{ */
904 udb_query_t **src_list, size_t src_list_len,
905 udb_query_t ***dst_list, size_t *dst_list_len)
910 if ((name == NULL) || (src_list == NULL) || (dst_list == NULL)
911 || (dst_list_len == NULL))
913 ERROR ("db query utils: udb_query_pick_from_list_by_name: "
914 "Invalid argument.");
919 for (i = 0; i < src_list_len; i++)
921 udb_query_t **tmp_list;
924 if (strcasecmp (name, src_list[i]->name) != 0)
927 tmp_list_len = *dst_list_len;
928 tmp_list = (udb_query_t **) realloc (*dst_list, (tmp_list_len + 1)
929 * sizeof (udb_query_t *));
930 if (tmp_list == NULL)
932 ERROR ("db query utils: realloc failed.");
936 tmp_list[tmp_list_len] = src_list[i];
939 *dst_list = tmp_list;
940 *dst_list_len = tmp_list_len;
943 } /* for (i = 0; i < src_list_len; i++) */
947 ERROR ("db query utils: Cannot find query `%s'. Make sure the <Query> "
948 "block is above the database definition!",
954 DEBUG ("db query utils: Added %i versions of query `%s'.",
959 } /* }}} int udb_query_pick_from_list_by_name */
961 int udb_query_pick_from_list (oconfig_item_t *ci, /* {{{ */
962 udb_query_t **src_list, size_t src_list_len,
963 udb_query_t ***dst_list, size_t *dst_list_len)
967 if ((ci == NULL) || (src_list == NULL) || (dst_list == NULL)
968 || (dst_list_len == NULL))
970 ERROR ("db query utils: udb_query_pick_from_list: "
971 "Invalid argument.");
975 if ((ci->values_num != 1)
976 || (ci->values[0].type != OCONFIG_TYPE_STRING))
978 ERROR ("db query utils: The `%s' config option "
979 "needs exactly one string argument.", ci->key);
982 name = ci->values[0].value.string;
984 return (udb_query_pick_from_list_by_name (name,
985 src_list, src_list_len,
986 dst_list, dst_list_len));
987 } /* }}} int udb_query_pick_from_list */
989 const char *udb_query_get_name (udb_query_t *q) /* {{{ */
995 } /* }}} const char *udb_query_get_name */
997 const char *udb_query_get_statement (udb_query_t *q) /* {{{ */
1002 return (q->statement);
1003 } /* }}} const char *udb_query_get_statement */
1005 void udb_query_set_user_data (udb_query_t *q, void *user_data) /* {{{ */
1010 q->user_data = user_data;
1011 } /* }}} void udb_query_set_user_data */
1013 void *udb_query_get_user_data (udb_query_t *q) /* {{{ */
1018 return (q->user_data);
1019 } /* }}} void *udb_query_get_user_data */
1021 int udb_query_check_version (udb_query_t *q, unsigned int version) /* {{{ */
1026 if ((version < q->min_version) || (version > q->max_version))
1030 } /* }}} int udb_query_check_version */
1032 void udb_query_finish_result (udb_query_t *q) /* {{{ */
1044 for (r = q->results; r != NULL; r = r->next)
1045 udb_result_finish_result (r);
1046 } /* }}} void udb_query_finish_result */
1048 int udb_query_handle_result (udb_query_t *q, char **column_values) /* {{{ */
1057 if ((q->column_num < 1) || (q->host == NULL) || (q->plugin == NULL)
1058 || (q->db_name == NULL))
1060 ERROR ("db query utils: Query `%s': Query is not prepared; "
1061 "can't handle result.", q->name);
1065 #if defined(COLLECT_DEBUG) && COLLECT_DEBUG /* {{{ */
1070 for (i = 0; i < q->column_num; i++)
1072 DEBUG ("db query utils: udb_query_handle_result (%s, %s): "
1073 "column[%zu] = %s;",
1074 q->db_name, q->name, i, column_values[i]);
1080 for (r = q->results; r != NULL; r = r->next)
1082 status = udb_result_handle_result (r, q, column_values);
1089 ERROR ("db query utils: udb_query_handle_result (%s, %s): "
1090 "All results failed.", q->db_name, q->name);
1095 } /* }}} int udb_query_handle_result */
1097 int udb_query_prepare_result (udb_query_t *q, /* {{{ */
1098 const char *host, const char *plugin, const char *db_name,
1099 char **column_names, size_t column_num)
1107 udb_query_finish_result (q);
1109 q->column_num = column_num;
1110 q->host = strdup (host);
1111 q->plugin = strdup (plugin);
1112 q->db_name = strdup (db_name);
1114 if ((q->host == NULL) || (q->plugin == NULL) || (q->db_name == NULL))
1116 ERROR ("db query utils: Query `%s': Prepare failed: Out of memory.", q->name);
1117 udb_query_finish_result (q);
1121 #if defined(COLLECT_DEBUG) && COLLECT_DEBUG
1126 for (i = 0; i < column_num; i++)
1128 DEBUG ("db query utils: udb_query_prepare_result: "
1129 "query = %s; column[%zu] = %s;",
1130 q->name, i, column_names[i]);
1135 for (r = q->results; r != NULL; r = r->next)
1137 status = udb_result_prepare_result (r, column_names, column_num);
1140 udb_query_finish_result (q);
1146 } /* }}} int udb_query_prepare_result */
1148 /* vim: set sw=2 sts=2 et fdm=marker : */