Skip to content

Commit

Permalink
db_perlvdb: updated code and documentation for latest db api
Browse files Browse the repository at this point in the history
- GH #1525

(cherry picked from commit 1a15e98)
  • Loading branch information
mshary authored and miconda committed May 9, 2018
1 parent 256d06b commit e5745ca
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/modules/db_perlvdb/db_perlvdb.c
Expand Up @@ -95,7 +95,7 @@ static int db_perlvdb_bind_api(db_func_t *dbb)
dbb->insert = perlvdb_db_insert;
dbb->delete = perlvdb_db_delete;
dbb->update = perlvdb_db_update;
dbb->replace = 0;
dbb->replace = perlvdb_db_replace;

return 0;
}
}
8 changes: 4 additions & 4 deletions src/modules/db_perlvdb/doc/db_perlvdb_admin.xml
Expand Up @@ -31,15 +31,15 @@
operations is supported.
</para>
<para>
Modules can be configured to use the perlvdb module as
Modules can be configured to use the db_perlvdb module as
database backend using the db_url_parameter:
</para>
<programlisting>
modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
</programlisting>
<para>
This configuration options tells acc module that it should use the
perlvdb module which will in turn use the Perl class
db_perlvdb module which will in turn use the Perl class
Kamailio::VDB::Adapter::AccountingSIPtrace
to relay the database requests.
</para>
Expand All @@ -53,7 +53,7 @@ modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para><emphasis>perl</emphasis> -- Perl module</para>
<para><emphasis>app_perl</emphasis> -- Perl Application module</para>
</listitem>
</itemizedlist>
</para>
Expand All @@ -66,7 +66,7 @@ modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
<itemizedlist>
<listitem>
<para>
<emphasis>None</emphasis> (Besides the ones mentioned in the perl
<emphasis>None</emphasis> (Besides the ones mentioned in the app_perl
module documentation).
</para>
</listitem>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/db_perlvdb/doc/db_perlvdb_devel.xml
Expand Up @@ -30,7 +30,7 @@
</section>
<section><title>Base class Kamailio::VDB</title>
<para>
A client module has to be configured to use the perlvdb module in conjunction
A client module has to be configured to use the db_perlvdb module in conjunction
with a Perl class to provide the functions. The configured class needs to
inherit from the base class <literal role="code">Kamailio::VDB</literal>.
</para>
Expand Down
14 changes: 5 additions & 9 deletions src/modules/db_perlvdb/perlvdb_conv.c
Expand Up @@ -148,7 +148,7 @@ SV *valdata(const db_val_t* val) {
return data;
}

SV *val2perlval(db_val_t* val) {
SV *val2perlval(const db_val_t* val) {
SV* retval;
SV *class;

Expand All @@ -167,7 +167,7 @@ SV *val2perlval(db_val_t* val) {

}

SV *pair2perlpair(db_key_t key, const db_val_t* val) {
SV *pair2perlpair(const db_key_t key, const db_val_t* val) {
SV* retval;
SV *class;

Expand Down Expand Up @@ -290,11 +290,9 @@ int perlresult2dbres(SV *perlres, db1_res_t **r) {
currentstring = SvPV(d1, len);
charbuf = pkg_malloc(len+1);
strncpy(charbuf, currentstring, len+1);
(*r)->col.names[i]->s = charbuf;
(*r)->col.names[i]->len = strlen(charbuf);
(*r)->col.names[i] = (db_key_t)charbuf;

SvREFCNT_dec(d1);

}

rowarrayref = perlvdb_perlmethod(perlres, PERL_VDB_ROWSMETHOD,
Expand Down Expand Up @@ -405,13 +403,11 @@ int perlresult2dbres(SV *perlres, db1_res_t **r) {
}

end:
av_undef(colarray);
av_undef(rowarray);
if (colarray) av_undef(colarray);
if (rowarray) av_undef(rowarray);
return retval;
error:
LM_CRIT("broken result set. Exiting, leaving Kamailio in unknown state.\n");
return -1;
}



4 changes: 2 additions & 2 deletions src/modules/db_perlvdb/perlvdb_conv.h
Expand Up @@ -56,8 +56,8 @@ AV *conds2perlarray(const db_key_t* keys, const db_op_t* ops, const db_val_t* va
*/
AV *keys2perlarray(const db_key_t* keys, const int n);

SV *val2perlval(db_val_t* val);
SV *pair2perlpair(db_key_t key, const db_val_t* val);
SV *val2perlval(const db_val_t* val);
SV *pair2perlpair(const db_key_t key, const db_val_t* val);
SV *cond2perlcond(const db_key_t key, const db_op_t op, const db_val_t* val);

int perlresult2dbres(SV *perlres, db1_res_t **r);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/db_perlvdb/perlvdbfunc.c
Expand Up @@ -202,7 +202,7 @@ int perlvdb_db_insert(const db1_con_t* h, const db_key_t* k, const db_val_t* v,
/*
* Just like insert, but replace the row if it exists
*/
int perlvdb_db_replace(db1_con_t* h, db_key_t* k, db_val_t* v, int n) {
int perlvdb_db_replace(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n) {
return perlvdb_db_insertreplace(h, k, v, n, PERL_VDB_REPLACEMETHOD);
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/db_perlvdb/perlvdbfunc.h
Expand Up @@ -48,7 +48,7 @@ void perlvdb_db_close(db1_con_t* h);
int perlvdb_use_table(db1_con_t* h, const str* t);

int perlvdb_db_insert(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n);
int perlvdb_db_replace(db1_con_t* h, db_key_t* k, db_val_t* v, int n);
int perlvdb_db_replace(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n);
int perlvdb_db_delete(const db1_con_t* h, const db_key_t* k, const db_op_t* o,
const db_val_t* v, const int n);
int perlvdb_db_update(const db1_con_t* h, const db_key_t* k, const db_op_t* o,
Expand Down

0 comments on commit e5745ca

Please sign in to comment.