[Devel] openser contributions
Mike P. Mikhailov
mike at ics-ware.com
Thu May 10 16:02:58 CEST 2007
Hello devel,
I would like to contribute several patches to the openser version
1.2.0, which we've made in the our recent project to achieve required
goals. Patches are addressing following issues we've found:
1. extensions to the sql drivers to support literal values in the
queries like:
update ts=now(), cnt=cnt+1 where id=12345;
2. proper handling of the null values in the sql query:
... where val1 is null or val2 is not null
3. several macros to make life easy when using sql in our module.
Here some examples how now quieries may looks like:
int mod_ucb_db_find_local_contact(mod_ucb_register_request_p _rr) {
UCB_DBG("_rr->local_contact='%.*s'",
_rr->local_contact.len, _rr->local_contact.s
);
UCB_LOCAL_NODES()
SELECT(1)
KEY("id")
WHERE(1)
KEY("local_contact") EQ() STR(_rr->local_contact)
EXECUTE()
IF_NO_ROWS()
DB_RETURN(1, "no local node found")
FETCH()
ASINT(0, _rr->id)
IF_MORE_ROWS()
DB_RETURN(2, "more than one local contact found")
DB_OK("local node found, id='%d'", _rr->id)
}
or:
int mod_ucb_db_update_local_node_status(int _id, int _sc, str *_rp) {
UCB_DBG("id='%d', status_code='%d', reason_phrase='%.*s'",
_id, _sc, _rp->len, _rp->s
);
UCB_LOCAL_NODES()
UPDATE(4)
KEY("last_register") LITERAL("now()")
KEY("count_register") LITERAL("coalesce(count_register,0)+1")
KEY("status_code") INT(_sc)
KEY("reason_phrase") STR(*_rp)
FORID(_id)
EXECUTE()
DB_OK("local node status updated");
}
#1 & #2 with patches for postgres & mysql drivers.
#3 may be contributed as additional header file without intervention
in the existing code.
Please, reply to me if changes mentioned above is interesting for
the openser community.
--
Best regards,
Mike mailto:mike at ics-ware.com
More information about the Devel
mailing list