From: Marco van Wieringen Date: Sun, 4 Apr 2010 18:14:00 +0000 (+0200) Subject: Fix logic error introduced when implementing multi thread support, overwriting rowcount X-Git-Tag: Release-5.0.2~107 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1dcd347a86b7edd99d3c48dc2e28016ea4a3be6f;p=bacula%2Fbacula Fix logic error introduced when implementing multi thread support, overwriting rowcount with INGcheck value lets use a seperate variable. --- diff --git a/bacula/src/cats/myingres.c b/bacula/src/cats/myingres.c index 7fe5a3977c..f9bd3f6279 100644 --- a/bacula/src/cats/myingres.c +++ b/bacula/src/cats/myingres.c @@ -360,9 +360,9 @@ static inline int INGfetchAll(const char *query, INGresult *ing_res) /* # line 378 "myingres.sc" */ /* open */ { IIsqInit(&sqlca); - IIcsOpen((char *)"c2",10631,20435); + IIcsOpen((char *)"c2",22166,10460); IIwritio(0,(short *)0,1,32,0,(char *)"s2"); - IIcsQuery((char *)"c2",10631,20435); + IIcsQuery((char *)"c2",22166,10460); } /* # line 379 "myingres.sc" */ /* host code */ if ((check = INGcheck()) < 0) { @@ -373,7 +373,7 @@ static inline int INGfetchAll(const char *query, INGresult *ing_res) /* # line 385 "myingres.sc" */ /* fetch */ { IIsqInit(&sqlca); - if (IIcsRetScroll((char *)"c2",10631,20435,-1,-1) != 0) { + if (IIcsRetScroll((char *)"c2",22166,10460,-1,-1) != 0) { IIcsDaGet(0,desc); IIcsERetrieve(); } /* IIcsRetrieve */ @@ -398,7 +398,7 @@ static inline int INGfetchAll(const char *query, INGresult *ing_res) /* # line 405 "myingres.sc" */ /* close */ { IIsqInit(&sqlca); - IIcsClose((char *)"c2",10631,20435); + IIcsClose((char *)"c2",22166,10460); } /* # line 407 "myingres.sc" */ /* host code */ ing_res->status = ING_COMMAND_OK; @@ -467,12 +467,13 @@ short INGftype(const INGresult *res, int column_number) } int INGexec(INGconn *conn, const char *query) { -/* # line 487 "myingres.sc" */ + int check; +/* # line 488 "myingres.sc" */ int sess_id; int rowcount; char *stmt; -/* # line 491 "myingres.sc" */ +/* # line 492 "myingres.sc" */ stmt = bstrdup(query); rowcount = -1; @@ -480,38 +481,40 @@ int INGexec(INGconn *conn, const char *query) * Switch to the correct default session for this thread. */ sess_id = conn->session_id; -/* # line 500 "myingres.sc" */ /* set_sql */ +/* # line 501 "myingres.sc" */ /* set_sql */ { IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id); } -/* # line 501 "myingres.sc" */ /* execute */ +/* # line 502 "myingres.sc" */ /* execute */ { IIsqInit(&sqlca); IIsqExImmed(stmt); IIsyncup((char *)0,0); } -/* # line 503 "myingres.sc" */ /* host code */ +/* # line 504 "myingres.sc" */ /* host code */ free(stmt); - if ((rowcount = INGcheck()) < 0) { + if ((check = INGcheck()) < 0) { + rowcount = check; goto bail_out; } -/* # line 509 "myingres.sc" */ /* inquire_ingres */ +/* # line 511 "myingres.sc" */ /* inquire_ingres */ { IILQisInqSqlio((short *)0,1,30,sizeof(rowcount),&rowcount,8); } -/* # line 510 "myingres.sc" */ /* host code */ - if ((rowcount = INGcheck()) < 0) { +/* # line 512 "myingres.sc" */ /* host code */ + if ((check = INGcheck()) < 0) { + rowcount = check; goto bail_out; } bail_out: /* * Switch to no default session for this thread. */ -/* # line 518 "myingres.sc" */ /* set_sql */ +/* # line 521 "myingres.sc" */ /* set_sql */ { IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97)); } -/* # line 519 "myingres.sc" */ /* host code */ +/* # line 522 "myingres.sc" */ /* host code */ return rowcount; } INGresult *INGquery(INGconn *conn, const char *query) @@ -523,20 +526,20 @@ INGresult *INGquery(INGconn *conn, const char *query) INGresult *res = NULL; int rows = -1; int cols = INGgetCols(conn, query); -/* # line 531 "myingres.sc" */ +/* # line 534 "myingres.sc" */ int sess_id; -/* # line 533 "myingres.sc" */ +/* # line 536 "myingres.sc" */ /* * Switch to the correct default session for this thread. */ sess_id = conn->session_id; -/* # line 539 "myingres.sc" */ /* set_sql */ +/* # line 542 "myingres.sc" */ /* set_sql */ { IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id); } -/* # line 541 "myingres.sc" */ /* host code */ +/* # line 544 "myingres.sc" */ /* host code */ desc = INGgetDescriptor(cols, query); if (!desc) { goto bail_out; @@ -556,11 +559,11 @@ bail_out: /* * Switch to no default session for this thread. */ -/* # line 564 "myingres.sc" */ /* set_sql */ +/* # line 567 "myingres.sc" */ /* set_sql */ { IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97)); } -/* # line 565 "myingres.sc" */ /* host code */ +/* # line 568 "myingres.sc" */ /* host code */ return res; } void INGclear(INGresult *res) @@ -579,13 +582,13 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id) } dbconn = (INGconn *)malloc(sizeof(INGconn)); memset(dbconn, 0, sizeof(INGconn)); -/* # line 589 "myingres.sc" */ +/* # line 592 "myingres.sc" */ char ingdbname[24]; char ingdbuser[32]; char ingdbpasswd[32]; int sess_id; -/* # line 594 "myingres.sc" */ +/* # line 597 "myingres.sc" */ sess_id = session_id; bstrncpy(ingdbname, dbname, sizeof(ingdbname)); @@ -596,7 +599,7 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id) } else { memset(ingdbpasswd, 0, sizeof(ingdbpasswd)); } -/* # line 606 "myingres.sc" */ /* connect */ +/* # line 609 "myingres.sc" */ /* connect */ { IIsqInit(&sqlca); IILQsidSessID(sess_id); @@ -605,9 +608,9 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id) (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0); } -/* # line 611 "myingres.sc" */ /* host code */ +/* # line 614 "myingres.sc" */ /* host code */ } else { -/* # line 612 "myingres.sc" */ /* connect */ +/* # line 615 "myingres.sc" */ /* connect */ { IIsqInit(&sqlca); IILQsidSessID(sess_id); @@ -615,7 +618,7 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id) (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0); } -/* # line 615 "myingres.sc" */ /* host code */ +/* # line 618 "myingres.sc" */ /* host code */ } if (INGcheck() < 0) { return NULL; @@ -629,28 +632,28 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id) /* * Switch to no default session for this thread undo default settings from SQL CONNECT. */ -/* # line 627 "myingres.sc" */ /* set_sql */ +/* # line 633 "myingres.sc" */ /* set_sql */ { IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97)); } -/* # line 629 "myingres.sc" */ /* host code */ +/* # line 635 "myingres.sc" */ /* host code */ return dbconn; } void INGdisconnectDB(INGconn *dbconn) { -/* # line 634 "myingres.sc" */ +/* # line 640 "myingres.sc" */ int sess_id; -/* # line 636 "myingres.sc" */ +/* # line 642 "myingres.sc" */ sess_id = dbconn->session_id; -/* # line 639 "myingres.sc" */ /* disconnect */ +/* # line 645 "myingres.sc" */ /* disconnect */ { IIsqInit(&sqlca); IILQsidSessID(sess_id); IIsqDisconnect(); } -/* # line 641 "myingres.sc" */ /* host code */ +/* # line 647 "myingres.sc" */ /* host code */ if (dbconn != NULL) { free(dbconn->msg); free(dbconn); @@ -658,16 +661,16 @@ void INGdisconnectDB(INGconn *dbconn) } char *INGerrorMessage(const INGconn *conn) { -/* # line 649 "myingres.sc" */ +/* # line 655 "myingres.sc" */ char errbuf[256]; -/* # line 651 "myingres.sc" */ +/* # line 657 "myingres.sc" */ -/* # line 653 "myingres.sc" */ /* inquire_ingres */ +/* # line 659 "myingres.sc" */ /* inquire_ingres */ { IILQisInqSqlio((short *)0,1,32,255,errbuf,63); } -/* # line 654 "myingres.sc" */ /* host code */ +/* # line 660 "myingres.sc" */ /* host code */ memcpy(conn->msg, &errbuf, 256); return conn->msg; } @@ -679,5 +682,5 @@ char *INGcmdTuples(INGresult *res) int INGputCopyEnd(INGconn *conn, const char *errormsg); int INGputCopyData(INGconn *conn, const char *buffer, int nbytes); */ -/* # line 668 "myingres.sc" */ +/* # line 674 "myingres.sc" */ #endif diff --git a/bacula/src/cats/myingres.sc b/bacula/src/cats/myingres.sc index d21dfa40f3..3071572122 100644 --- a/bacula/src/cats/myingres.sc +++ b/bacula/src/cats/myingres.sc @@ -484,6 +484,7 @@ short INGftype(const INGresult *res, int column_number) int INGexec(INGconn *conn, const char *query) { + int check; EXEC SQL BEGIN DECLARE SECTION; int sess_id; int rowcount; @@ -502,12 +503,14 @@ int INGexec(INGconn *conn, const char *query) free(stmt); - if ((rowcount = INGcheck()) < 0) { + if ((check = INGcheck()) < 0) { + rowcount = check; goto bail_out; } EXEC SQL INQUIRE_INGRES(:rowcount = ROWCOUNT); - if ((rowcount = INGcheck()) < 0) { + if ((check = INGcheck()) < 0) { + rowcount = check; goto bail_out; }