Subject | Re: Stored Procedures Memory Usage |
---|---|
Author | jssahdra |
Post date | 2004-10-19T11:02:43Z |
--- In firebird-support@yahoogroups.com, "Alan McDonald" <alan@m...>
wrote:
My Idea of posting this message is to know the difference in memory
usage when I use Stored Procedures vs the direct updates. Now I am
using direct update, the memory usage increase is low as compared to
when I was using Stored Procedure. If you rememver we had a
discussion with you in my last thread also. I had sent you code for
the SP also.
JS
Here is the db_error routine.
long db_error (long SQLCODE,isc_tr_handle *gds__trans,long isc_status
[20],const char *message,sigjmp_buf env,int *is_retry)
{
if (SQLCODE)
{
char msg[513];
long db_error;
isc_sql_interprete(SQLCODE, msg, 512);
ERROR("%ld(%ld) %s.%s,\n",SQLCODE,isc_status
[1],msg,message);
//printf("%ld (%ld) %s.%s\n",SQLCODE,msg,message);
/*EXEC SQL
ROLLBACK;*/
//now check if the errors can be retried
db_error=isc_status[1];
isc_rollback_transaction (isc_status,
(FRBRD**) gds__trans);
*gds__trans=0L;
if (!(*is_retry) &&
(db_error==isc_network_error || db_error==isc_net_connect_err ||
isc_deadlock)) {
int i;
if (db_error==isc_network_error ||
db_error==isc_net_connect_err) { //could be due to db restart or
broken pipe
//set the connection pool
status to 0, which means not connected
for (i=0;i<max_conn_count;i++)
conn_pool[i].status=0;
}
if (env != NULL) { //env is the
buffer holding the state. it should be saved be db_connect
DEBUG("fbauth:Sending
retry..");
*is_retry=1; //this should be
initially 0 before calling db_connect
sleep(3); //wait for 3
seconds. Usefull in deadlock
siglongjmp(env,1);
}
}
{
SQLCODE = isc_sqlcode (isc_status);
}
}
return (SQLCODE);
}
long pr_error (long SQLCODE,isc_tr_handle *gds__trans,long isc_status
[20],const char *message)
{
if (SQLCODE)
{
char msg[513];
isc_sql_interprete(SQLCODE, msg, 512);
ERROR("%ld(%ld) %s.%s\n",SQLCODE,isc_status
[1],msg,message);
//printf("%ld (%ld) %s.%s\n",SQLCODE,msg,message);
/*EXEC SQL
ROLLBACK;*/
{
isc_rollback_transaction (isc_status, (FRBRD**)
gds__trans);
*gds__trans=0L;
SQLCODE = isc_sqlcode (isc_status);
}
}
return (SQLCODE);
}
wrote:
> > You are right, I am new to firebird. Here is the part of codewhich
> > called frequently. As far as I know, this the hard commit. Tellme if
> > there is anything wrong in it.(SQLCODE,&gds__trans,isc_status,"accountupdate.execute",env,&retry))
> >
> >
> > EXEC SQL
> > SET DATABASE DB='/opt/firebird/data/ssg.gdb';
> >
> > connect_db(&dbconn)
> > DB=dbconn.conn;
> > sigsetjmp(env,1);
> > EXEC SQL
> > SET TRANSACTION USING DB;
> > EXEC SQL
> > UPDATE session SET bytesin=:ses->bytesin, bytesout=:ses-
> > >bytesout, lastupd='NOW', trfratein=:ratein,trfrateout=:rateout
> > WHERE sesno=:ses->session_id AND
> > state='A';
> >
> > if (db_error
> >
> > goto return_error;back the
> >
> > EXEC SQL
> > COMMIT;
> > pr_error
> > (SQLCODE,&gds__trans,isc_status,"accountupdate.end");
> > disconnect_db(&dbconn);
> > return retval;
> >
>
> so if there's an error you return to return_error without rolling
> transaction?No, the function db_error will rollback the transaction.
> Am I reading it correctly?
> Alan
My Idea of posting this message is to know the difference in memory
usage when I use Stored Procedures vs the direct updates. Now I am
using direct update, the memory usage increase is low as compared to
when I was using Stored Procedure. If you rememver we had a
discussion with you in my last thread also. I had sent you code for
the SP also.
JS
Here is the db_error routine.
long db_error (long SQLCODE,isc_tr_handle *gds__trans,long isc_status
[20],const char *message,sigjmp_buf env,int *is_retry)
{
if (SQLCODE)
{
char msg[513];
long db_error;
isc_sql_interprete(SQLCODE, msg, 512);
ERROR("%ld(%ld) %s.%s,\n",SQLCODE,isc_status
[1],msg,message);
//printf("%ld (%ld) %s.%s\n",SQLCODE,msg,message);
/*EXEC SQL
ROLLBACK;*/
//now check if the errors can be retried
db_error=isc_status[1];
isc_rollback_transaction (isc_status,
(FRBRD**) gds__trans);
*gds__trans=0L;
if (!(*is_retry) &&
(db_error==isc_network_error || db_error==isc_net_connect_err ||
isc_deadlock)) {
int i;
if (db_error==isc_network_error ||
db_error==isc_net_connect_err) { //could be due to db restart or
broken pipe
//set the connection pool
status to 0, which means not connected
for (i=0;i<max_conn_count;i++)
conn_pool[i].status=0;
}
if (env != NULL) { //env is the
buffer holding the state. it should be saved be db_connect
DEBUG("fbauth:Sending
retry..");
*is_retry=1; //this should be
initially 0 before calling db_connect
sleep(3); //wait for 3
seconds. Usefull in deadlock
siglongjmp(env,1);
}
}
{
SQLCODE = isc_sqlcode (isc_status);
}
}
return (SQLCODE);
}
long pr_error (long SQLCODE,isc_tr_handle *gds__trans,long isc_status
[20],const char *message)
{
if (SQLCODE)
{
char msg[513];
isc_sql_interprete(SQLCODE, msg, 512);
ERROR("%ld(%ld) %s.%s\n",SQLCODE,isc_status
[1],msg,message);
//printf("%ld (%ld) %s.%s\n",SQLCODE,msg,message);
/*EXEC SQL
ROLLBACK;*/
{
isc_rollback_transaction (isc_status, (FRBRD**)
gds__trans);
*gds__trans=0L;
SQLCODE = isc_sqlcode (isc_status);
}
}
return (SQLCODE);
}