summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d008264)
raw | patch | inline | side by side (parent: d008264)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 14 Feb 2009 13:04:02 +0000 (14:04 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 14 Feb 2009 13:14:11 +0000 (14:14 +0100) |
When passing `1' as `legacy mode' to `udb_query_create', compatibility
with the postgresql plugin in version 4.5 is enabled. This means that
the options `Query', `MinPGVersion' and `MaxPGVersion' are understood in
the <Query> blocks.
Yet to do is support for the `Column' options. The `Param' option should
probably be implemented using the already existing callback function.
with the postgresql plugin in version 4.5 is enabled. This means that
the options `Query', `MinPGVersion' and `MaxPGVersion' are understood in
the <Query> blocks.
Yet to do is support for the `Column' options. The `Param' option should
probably be implemented using the already existing callback function.
src/dbi.c | patch | blob | history | |
src/oracle.c | patch | blob | history | |
src/utils_db_query.c | patch | blob | history | |
src/utils_db_query.h | patch | blob | history |
diff --git a/src/dbi.c b/src/dbi.c
index d970938e0fff0d616c93eeaa435a09a3805d45e5..5be9cae43c1d28cb8b6febbe2161a29e7d8e62ba 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Query", child->key) == 0)
udb_query_create (&queries, &queries_num, child,
- /* callback = */ NULL);
+ /* callback = */ NULL, /* legacy mode = */ 0);
else if (strcasecmp ("Database", child->key) == 0)
cdbi_config_add_database (child);
else
diff --git a/src/oracle.c b/src/oracle.c
index b008e5c52c06a6a8a81cdbfb644fc72ca90a2a2a..324dd4b4becf905f3d4338bbbc5f29041618ee9b 100644 (file)
--- a/src/oracle.c
+++ b/src/oracle.c
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Query", child->key) == 0)
udb_query_create (&queries, &queries_num, child,
- /* callback = */ NULL);
+ /* callback = */ NULL, /* legacy mode = */ 0);
else if (strcasecmp ("Database", child->key) == 0)
o_config_add_database (child);
else
diff --git a/src/utils_db_query.c b/src/utils_db_query.c
index eb001dee93c1ef55356e1fa805d9c12dbfe82d8c..e50bc584ab77fc89faf75813cd0bc4da683442a2 100644 (file)
--- a/src/utils_db_query.c
+++ b/src/utils_db_query.c
char *statement;
void *user_data;
+ int legacy_mode;
+
unsigned int min_version;
unsigned int max_version;
*/
int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */
size_t *ret_query_list_len, oconfig_item_t *ci,
- udb_query_create_callback_t cb)
+ udb_query_create_callback_t cb, int legacy_mode)
{
udb_query_t **query_list;
size_t query_list_len;
return (-1);
}
memset (q, 0, sizeof (*q));
+ q->legacy_mode = legacy_mode;
q->min_version = 0;
q->max_version = UINT_MAX;
status = udb_config_set_uint (&q->min_version, child);
else if (strcasecmp ("MaxVersion", child->key) == 0)
status = udb_config_set_uint (&q->max_version, child);
+
/* PostgreSQL compatibility code */
- else if (strcasecmp ("MinPGVersion", child->key) == 0)
+ else if ((strcasecmp ("Query", child->key) == 0)
+ && (q->legacy_mode == 1))
+ {
+ WARNING ("db query utils: Query `%s': The `Query' option is "
+ "deprecated. Please use `Statement' instead.",
+ q->name);
+ status = udb_config_set_string (&q->statement, child);
+ }
+ else if ((strcasecmp ("MinPGVersion", child->key) == 0)
+ && (q->legacy_mode == 1))
{
WARNING ("db query utils: Query `%s': The `MinPGVersion' option is "
"deprecated. Please use `MinVersion' instead.",
q->name);
status = udb_config_set_uint (&q->min_version, child);
}
- else if (strcasecmp ("MaxPGVersion", child->key) == 0)
+ else if ((strcasecmp ("MaxPGVersion", child->key) == 0)
+ && (q->legacy_mode == 1))
{
WARNING ("db query utils: Query `%s': The `MaxPGVersion' option is "
"deprecated. Please use `MaxVersion' instead.",
q->name);
status = udb_config_set_uint (&q->max_version, child);
}
+
+ /* Call custom callbacks */
else if (cb != NULL)
{
status = (*cb) (q, child);
diff --git a/src/utils_db_query.h b/src/utils_db_query.h
index 3959e88246222d875d731080b603b28d7fa3a9b2..36da9e3dde854a846aa80204b491f47eb09bda1b 100644 (file)
--- a/src/utils_db_query.h
+++ b/src/utils_db_query.h
*/
int udb_query_create (udb_query_t ***ret_query_list,
size_t *ret_query_list_len, oconfig_item_t *ci,
- udb_query_create_callback_t cb);
+ udb_query_create_callback_t cb, int legacy_mode);
void udb_query_free (udb_query_t **query_list, size_t query_list_len);
int udb_query_pick_from_list (oconfig_item_t *ci,