Ignore:
Timestamp:
Feb 14, 2000, 2:49:14 PM (26 years ago)
Author:
bird
Message:

Optimizations and a couple of fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/database/db.cpp

    r2770 r2773  
    1 /* $Id: db.cpp,v 1.8 2000-02-12 23:54:29 bird Exp $ *
     1/* $Id: db.cpp,v 1.9 2000-02-14 13:49:13 bird Exp $ *
    22 *
    33 * DB - contains all database routines.
     
    364364
    365365
    366 #if 1
     366#if 0
    367367/*
    368368 * Stubs used while optimizing sqls.
     
    378378int     mysql_query5(MYSQL *mysql, const char *q)
    379379{   return mysql_query(mysql, q); }
    380 MYSQL_RES *  mysql_store_result1(MYSQL *mysql)
    381 {   return mysql_store_result(mysql); }
    382 MYSQL_RES *  mysql_store_result5(MYSQL *mysql)
    383 {   return mysql_store_result(mysql); }
     380int     mysql_query6(MYSQL *mysql, const char *q)
     381{   return mysql_query(mysql, q); }
    384382
    385383#else
     
    390388#define mysql_query4            mysql_query
    391389#define mysql_query5            mysql_query
    392 #define mysql_store_result1     mysql_store_result
    393 #define mysql_store_result5     mysql_store_result
     390#define mysql_query6            mysql_query
    394391
    395392#endif
     
    403400 * @param     pFnFindBuf
    404401 * @param     lDll
     402 * @sketch    1) Get functions for this dll(if given).
     403 *            2) Get functions which aliases the functions found in (1).
     404 *            3) Get new aliases by intname
     405 *            4) Get new aliases by name
     406 *            5) Update all functions from (1) to have aliasfn -2 (DONTMIND)
     407 *            6) Update all functions from (3) and (4) to alias the first function from 1.
    405408 */
    406409BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll)
     
    411414    char         szQuery[256];
    412415
     416    /*
     417     * 1) Get functions for this dll(if given).
     418     */
    413419    if (lDll < 0)
    414         sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE intname = '%s'",
     420        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, name FROM function WHERE intname = '%s'",
    415421                pszFunctionName);
    416422    else
    417         sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
     423        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, name FROM function "
    418424                "WHERE intname = '%s' AND dll = %ld",
    419425                pszFunctionName, lDll);
     
    422428    if (rc >= 0)
    423429    {
    424         pres = mysql_store_result1(pmysql);
     430        pres = mysql_store_result(pmysql);
    425431        if (pres != NULL)
    426432        {
     433            char szFnName[NBR_FUNCTIONS][80];
     434
    427435            pFnFindBuf->cFns = 0;
    428436            while ((row = mysql_fetch_row(pres)) != NULL)
     
    431439                pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    432440                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     441                strcpy(szFnName[pFnFindBuf->cFns], row[3]);
    433442
    434443                /* next */
     
    440449            if (lDll >= 0 && pFnFindBuf->cFns != 0)
    441450            {
    442                 #if 0
    443                 int i;
    444                 /* Make the selected function to DONT TOUCH */
    445                 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
    446                                      "WHERE (",
    447                         lDll, pszFunctionName);
    448                 for (i = 0; i < pFnFindBuf->cFns; i++)
     451                int cFnsThisDll, cFnsAliasesAndThisDll, i;
     452
     453                /*
     454                 * 2) Get functions which aliases the functions found in (1).
     455                 */
     456                cFnsThisDll = (int)pFnFindBuf->cFns;
     457                strcpy(&szQuery[0], "SELECT refcode, dll, aliasfn, name FROM function WHERE aliasfn IN (");
     458                for (i = 0; i < cFnsThisDll; i++)
    449459                {
    450                     if (i != 0) strcat(&szQuery[0], " OR");
    451                     sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);
     460                    if (i > 0)  strcat(&szQuery[0], " OR ");
     461                    sprintf(&szQuery[strlen(szQuery)], "(%ld)", pFnFindBuf->alRefCode[i]);
    452462                }
    453                 strcat(&szQuery[0], ") AND aliasfn <> (-2)");
    454 
    455                 rc = mysql_query2(pmysql, &szQuery[0]);
    456                 if (rc >= 0)
    457                 {
    458                     /* Update all with equal internal... which is not in this Dll */
    459                     sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
    460                                          "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
    461                             pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
    462                     rc = mysql_query3(pmysql, &szQuery[0]);
    463                     if (rc >= 0)
    464                     {
    465                         /* Update all with equal external name... which is not in this Dll */
    466                         sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
    467                                              "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
    468                                 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
    469 
    470                         rc = mysql_query4(pmysql, &szQuery[0]);
    471                         if (rc >= 0)
    472                         {
    473                             /* get the functions aliases to the functions we have allready found. */
    474                             sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE dll = %ld AND aliasfn IN (", lDll);
    475                             for (i = 0; i < pFnFindBuf->cFns; i++)
    476                             {
    477                                 if (i != 0) strcat(&szQuery[0], ", ");
    478                                 sprintf(&szQuery[strlen(szQuery)], "%ld", pFnFindBuf->alRefCode[i]);
    479                             }
    480                             strcat(&szQuery[strlen(szQuery)], ")");
    481 
    482                             DosSleep(0);
    483                             rc = mysql_query5(pmysql, &szQuery[0]);
    484                             if (rc >= 0)
    485                             {
    486                                 pres = mysql_store_result5(pmysql);
    487                                 if (pres != NULL)
    488                                 {
    489                                     while ((row = mysql_fetch_row(pres)) != NULL)
    490                                     {
    491                                         pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    492                                         pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    493                                         if (row[2] != NULL)
    494                                             pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    495                                         else
    496                                             pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
    497 
    498                                         /* next */
    499                                         pFnFindBuf->cFns++;
    500                                     }
    501                                     mysql_free_result(pres);
    502                                 }
    503                             }
    504                         }
    505                     }
    506                 }
    507                 #else
    508                 int i;
    509                 int cFnsThisDll = (int)pFnFindBuf->cFns;
    510 
    511                 /* get the functions aliases to the functions we have allready found. */
    512                 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
    513                                      "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
    514                         lDll, pszFunctionName);
     463                strcat(&szQuery[0], ")");
     464
    515465                rc = mysql_query2(pmysql, &szQuery[0]);
    516466                if (rc >= 0)
     
    523473                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    524474                            pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    525                             if (row[2] != NULL)
    526                                 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    527                             else
    528                                 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
     475                            pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     476                            strcpy(szFnName[pFnFindBuf->cFns], row[3]);
    529477
    530478                            /* next */
     
    533481                        mysql_free_result(pres);
    534482
    535 
    536                         /* get the functions aliases to the functions we have allready found. */
     483                        /*
     484                         * 3) Get new aliases by intname
     485                         */
     486                        cFnsAliasesAndThisDll = (int)pFnFindBuf->cFns;
    537487                        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
    538                                              "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
     488                                             "WHERE aliasfn = (-1) AND dll <> %ld AND (intname = '%s'",
    539489                                lDll, pszFunctionName);
     490                        for (i = 0; i < cFnsAliasesAndThisDll; i++)
     491                            sprintf(&szQuery[strlen(&szQuery[0])], " OR intname = '%s'", szFnName[i]);
     492                        strcat(&szQuery[0], ")");
     493
    540494                        rc = mysql_query3(pmysql, &szQuery[0]);
    541495                        if (rc >= 0)
     
    558512                                mysql_free_result(pres);
    559513
    560                                 /* do updates! */
    561                                 /* Make the selected function to DONT TOUCH */
    562                                 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
    563                                                      "WHERE (",
     514
     515                                /*
     516                                 * 4) Get new aliases by name
     517                                 */
     518                                sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
     519                                                     "WHERE aliasfn = (-1) AND dll <> %ld AND (name = '%s'",
    564520                                        lDll, pszFunctionName);
    565                                 for (i = 0; i < cFnsThisDll; i++)
    566                                 {
    567                                     if (i != 0) strcat(&szQuery[0], " OR");
    568                                     sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);
    569                                 }
    570                                 strcat(&szQuery[0], ") AND aliasfn <> (-2)");
     521                                for (i = 0; i < cFnsAliasesAndThisDll; i++)
     522                                    sprintf(&szQuery[strlen(&szQuery[0])], " OR name = '%s'", szFnName[i]);
     523                                strcat(&szQuery[0], ")");
    571524
    572525                                rc = mysql_query4(pmysql, &szQuery[0]);
    573526                                if (rc >= 0)
    574527                                {
    575                                     /* Update all with equal internal... which is not in this Dll */
    576                                     sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
    577                                                          "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
    578                                             pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
    579                                     rc = mysql_query5(pmysql, &szQuery[0]);
    580                                     if (rc >= 0)
     528                                    pres = mysql_store_result(pmysql);
     529                                    if (pres != NULL)
    581530                                    {
    582                                         /* Update all with equal external name... which is not in this Dll */
    583                                         sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
    584                                                              "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
    585                                                 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
    586 
    587                                         rc = mysql_query4(pmysql, &szQuery[0]);
     531                                        while ((row = mysql_fetch_row(pres)) != NULL)
     532                                        {
     533                                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
     534                                            pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     535                                            if (row[2] != NULL)
     536                                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     537                                            else
     538                                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
     539
     540                                            /* next */
     541                                            pFnFindBuf->cFns++;
     542                                        }
     543                                        mysql_free_result(pres);
     544
     545                                        /*
     546                                         * 5) Update all functions from (1) to have aliasfn -2 (DONTMIND)
     547                                         */
     548                                        sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
     549                                                             "WHERE (",
     550                                                lDll, pszFunctionName);
     551                                        for (i = 0; i < cFnsThisDll; i++)
     552                                        {
     553                                            if (i != 0) strcat(&szQuery[0], " OR");
     554                                            sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);
     555                                        }
     556                                        strcat(&szQuery[0], ") AND aliasfn <> (-2)");
     557
     558                                        rc = mysql_query5(pmysql, &szQuery[0]);
     559                                        if (rc >= 0 && cFnsAliasesAndThisDll < pFnFindBuf->cFns)
     560                                        {
     561                                            /*
     562                                             * 6) Update all functions from (3) and (4) to alias the first function from 1.
     563                                             */
     564                                            sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
     565                                                                 "WHERE aliasfn = (-1) AND refcode IN (",
     566                                                    pFnFindBuf->alRefCode[0]);
     567                                            for (i = cFnsAliasesAndThisDll; i < pFnFindBuf->cFns; i++)
     568                                                sprintf(&szQuery[strlen(&szQuery[0])],
     569                                                        i > 0 ? ", %ld" : "%ld", pFnFindBuf->alRefCode[i]);
     570                                            strcat(&szQuery[0], ")");
     571                                            rc = mysql_query6(pmysql, &szQuery[0]);
     572                                        } /* query 5 */
    588573                                    }
    589                                 }
     574                                } /* query 4 */
    590575                            }
    591                         }
     576                        } /* query 3 */
    592577                    }
    593                 }
    594                 #endif
     578                } /* query 2 */
    595579            }
    596         }
     580        } /* query 1 */
    597581        else
    598582            rc = -1;
     
    672656}
    673657
     658#if 1
     659/*
     660 * Stubs used while optimizing sqls.
     661 */
     662int     mysql_queryu1(MYSQL *mysql, const char *q)
     663{   return mysql_query(mysql, q); }
     664int     mysql_queryu2(MYSQL *mysql, const char *q)
     665{   return mysql_query(mysql, q); }
     666int     mysql_queryu3(MYSQL *mysql, const char *q)
     667{   return mysql_query(mysql, q); }
     668int     mysql_queryu4(MYSQL *mysql, const char *q)
     669{   return mysql_query(mysql, q); }
     670int     mysql_queryu5(MYSQL *mysql, const char *q)
     671{   return mysql_query(mysql, q); }
     672int     mysql_queryu6(MYSQL *mysql, const char *q)
     673{   return mysql_query(mysql, q); }
     674int     mysql_queryu7(MYSQL *mysql, const char *q)
     675{   return mysql_query(mysql, q); }
     676int     mysql_queryu8(MYSQL *mysql, const char *q)
     677{   return mysql_query(mysql, q); }
     678#else
     679#define mysql_queryu1 mysql_query
     680#define mysql_queryu2 mysql_query
     681#define mysql_queryu3 mysql_query
     682#define mysql_queryu4 mysql_query
     683#define mysql_queryu5 mysql_query
     684#define mysql_queryu6 mysql_query
     685#define mysql_queryu7 mysql_query
     686#define mysql_queryu8 mysql_query
     687#endif
    674688
    675689/**
     
    683697unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lDll, char *pszError)
    684698{
    685     char  szQuery[256];
    686     char *pszQuery = &szQuery[0];
    687     long  lCurrentState;
    688     int   i,k,rc;
    689     unsigned long ulRc = 0;
     699    MYSQL_RES *     pres;
     700    MYSQL_ROW       row;
     701    char            szQuery[512];
     702    char *          pszQuery = &szQuery[0];
     703    long            lCurrentState;
     704    int             i,k,rc;
     705    unsigned long   ulRc = 0;
    690706
    691707    for (k = 0; k < pFnDesc->cRefCodes; k++)
     
    693709        BOOL    f = FALSE;
    694710
    695         /* set updated flag */
     711        /*
     712         * Set updated flag
     713         */
    696714        sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %ld",
    697715                pFnDesc->alRefCode[k]);
    698         rc = mysql_query(pmysql, &szQuery[0]);
    699 
    700         /* get current status */
     716        rc = mysql_queryu1(pmysql, &szQuery[0]);
     717
     718
     719        /*
     720         * Get current status
     721         */
    701722        lCurrentState = dbGetFunctionState(pFnDesc->alRefCode[k]);
    702723        if (lCurrentState == -1)
     
    706727        }
    707728
    708         /* update function table first */
     729
     730        /*
     731         * Update function table first
     732         */
    709733        strcpy(pszQuery, "UPDATE function SET ");
    710734        pszQuery += strlen(pszQuery);
     
    727751        {
    728752            sprintf(pszQuery + strlen(pszQuery), "WHERE refcode = %ld", pFnDesc->alRefCode[k]);
    729             rc = mysql_query(pmysql, &szQuery[0]);
     753            rc = mysql_queryu2(pmysql, &szQuery[0]);
    730754            if (rc < 0)
    731755            {
     
    737761        }
    738762
    739         /* parameters */
     763
     764        /*
     765         * Parameters
     766         */
    740767        pszQuery = &szQuery[0];
    741         sprintf(pszQuery, "DELETE FROM parameter WHERE function = %ld", pFnDesc->alRefCode[k]);
    742         rc = mysql_query(pmysql, &szQuery[0]);
    743         if (rc < 0)
     768        sprintf(pszQuery, "SELECT count(*) FROM parameter WHERE function = %ld", pFnDesc->alRefCode[k]);
     769        rc = mysql_queryu3(pmysql, pszQuery);
     770        if (rc >= 0)
     771        {
     772            pres = mysql_store_result(pmysql);
     773            if (pres != NULL)
     774                row = mysql_fetch_row(pres);
     775            if (pres != NULL && row != NULL && mysql_num_rows(pres) == 1)
     776            {
     777                if (atol(row[0]) == pFnDesc->cParams)
     778                {   /* update parameters */
     779                    for (i = 0; i < pFnDesc->cParams; i++)
     780                    {
     781                        sprintf(pszQuery, "UPDATE parameter SET type = '%s', name = '%s' "
     782                                "WHERE function = (%ld) AND sequencenbr == (%ld)",
     783                                pFnDesc->apszParamType[i] != NULL ? pFnDesc->apszParamType[i] : "",
     784                                pFnDesc->apszParamName[i] != NULL ? pFnDesc->apszParamName[i] : "",
     785                                pFnDesc->alRefCode[k], i
     786                                );
     787                        rc = mysql_queryu4(pmysql, pszQuery);
     788                        if (rc < 0)
     789                        {
     790                            if (*pszError == ' ')
     791                                strcpy(pszError++, "\n\t");
     792                            sprintf(pszError, "Updateing parameter %i failed with error: %s - (sql=%s) ",
     793                                    i, dbGetLastErrorDesc(), pszQuery);
     794                            pszError += strlen(pszError) - 1;
     795                            ulRc++;
     796                        }
     797                    }
     798                }
     799                else
     800                {
     801                    if (atol(row[0]) != 0)
     802                    {   /* delete old parameters */
     803                        sprintf(pszQuery, "DELETE FROM parameter WHERE function = %ld", pFnDesc->alRefCode[k]);
     804                        rc = mysql_queryu5(pmysql, pszQuery);
     805                        if (rc < 0)
     806                        {
     807                            if (*pszError == ' ')
     808                                strcpy(pszError++, "\n\t");
     809                            sprintf(pszError, "Deleting old parameters failed with error: %s - (sql=%s) ",
     810                                    dbGetLastErrorDesc(), pszQuery);
     811                            pszError += strlen(pszError) - 1;
     812                            ulRc++;
     813                        }
     814                    }
     815
     816                    /* insert parameters */
     817                    for (i = 0; i < pFnDesc->cParams; i++)
     818                    {
     819                        sprintf(pszQuery, "INSERT INTO parameter(function, sequencenbr, type, name) "
     820                                "VALUES (%ld, %d, '%s', '%s')",
     821                                pFnDesc->alRefCode[k], i,
     822                                pFnDesc->apszParamType[i] != NULL ? pFnDesc->apszParamType[i] : "",
     823                                pFnDesc->apszParamName[i] != NULL ? pFnDesc->apszParamName[i] : ""
     824                                );
     825                        rc = mysql_queryu6(pmysql, pszQuery);
     826                        if (rc < 0)
     827                        {
     828                            if (*pszError == ' ')
     829                                strcpy(pszError++, "\n\t");
     830                            sprintf(pszError, "Inserting parameter %i failed with error: %s - (sql=%s) ",
     831                                    i, dbGetLastErrorDesc(), pszQuery);
     832                            pszError += strlen(pszError) - 1;
     833                            ulRc++;
     834                        }
     835                    }
     836                }
     837            }
     838            else
     839            {
     840                if (*pszError == ' ')
     841                    strcpy(pszError++, "\n\t");
     842                sprintf(pszError, "failed to store result or to fetch a row , error: %s - (sql=%s) ",
     843                        dbGetLastErrorDesc(), pszQuery);
     844                pszError += strlen(pszError) - 1;
     845                ulRc++;
     846            }
     847        }
     848        else
    744849        {
    745850            if (*pszError == ' ')
    746851                strcpy(pszError++, "\n\t");
    747             sprintf(pszError, "Deleting old parameters failed with error: %s - (sql=%s) ",
    748                     dbGetLastErrorDesc(), &szQuery[0]);
     852            sprintf(pszError, "Failed querying number of parameters, error: %s - (sql=%s) ",
     853                    dbGetLastErrorDesc(), pszQuery);
    749854            pszError += strlen(pszError) - 1;
    750855            ulRc++;
    751856        }
    752857
    753         for (i = 0; i < pFnDesc->cParams; i++)
    754         {
    755             sprintf(pszQuery, "INSERT INTO parameter(function, sequencenbr, type, name) "
    756                     "VALUES (%ld, %d, '%s', '%s')",
    757                     pFnDesc->alRefCode[k], i,
    758                     pFnDesc->apszParamType[i] != NULL ? pFnDesc->apszParamType[i] : "",
    759                     pFnDesc->apszParamName[i] != NULL ? pFnDesc->apszParamName[i] : ""
    760                     );
    761             rc = mysql_query(pmysql, pszQuery);
     858
     859        /*
     860         * Authors
     861         */
     862        sprintf(pszQuery, "DELETE FROM fnauthor WHERE function = %ld", pFnDesc->alRefCode[k]);
     863        rc = mysql_queryu7(pmysql, pszQuery);
     864        if (rc < 0)
     865        {
     866            if (*pszError == ' ')
     867                strcpy(pszError++, "\n\t");
     868            sprintf(pszError, "Deleting old authors failed with error: %s - (sql=%s) ",
     869                    dbGetLastErrorDesc(), pszQuery);
     870            pszError += strlen(pszError) - 1;
     871            ulRc++;
     872        }
     873
     874        for (i = 0; i < pFnDesc->cAuthors; i++)
     875        {
     876            if (pFnDesc->alAuthorRefCode[i] == -1)
     877                continue;
     878            sprintf(pszQuery, "INSERT INTO fnauthor(author, function) "
     879                    "VALUES (%ld, %ld)",
     880                    pFnDesc->alAuthorRefCode[i], pFnDesc->alRefCode[k]);
     881            rc = mysql_queryu8(pmysql, pszQuery);
    762882            if (rc < 0)
    763883            {
     
    765885                    strcpy(pszError++, "\n\t");
    766886                sprintf(pszError, "Inserting parameter %i failed with error: %s - (sql=%s) ",
    767                         i, dbGetLastErrorDesc(), &szQuery[0]);
    768                 pszError += strlen(pszError) - 1;
    769                 ulRc++;
    770             }
    771         }
    772 
    773         /* authors */
    774         pszQuery = &szQuery[0];
    775         sprintf(pszQuery, "DELETE FROM fnauthor WHERE function = %ld", pFnDesc->alRefCode[k]);
    776         rc = mysql_query(pmysql, &szQuery[0]);
    777         if (rc < 0)
    778         {
    779             if (*pszError == ' ')
    780                 strcpy(pszError++, "\n\t");
    781             sprintf(pszError, "Deleting old authors failed with error: %s - (sql=%s) ",
    782                     dbGetLastErrorDesc(), &szQuery[0]);
    783             pszError += strlen(pszError) - 1;
    784             ulRc++;
    785         }
    786 
    787         for (i = 0; i < pFnDesc->cAuthors; i++)
    788         {
    789             if (pFnDesc->alAuthorRefCode[i] == -1)
    790                 continue;
    791             sprintf(pszQuery, "INSERT INTO fnauthor(author, function) "
    792                     "VALUES (%ld, %ld)",
    793                     pFnDesc->alAuthorRefCode[i], pFnDesc->alRefCode[k]);
    794             rc = mysql_query(pmysql, pszQuery);
    795             if (rc < 0)
    796             {
    797                 if (*pszError == ' ')
    798                     strcpy(pszError++, "\n\t");
    799                 sprintf(pszError, "Inserting parameter %i failed with error: %s - (sql=%s) ",
    800                         i, dbGetLastErrorDesc(), &szQuery[0]);
     887                        i, dbGetLastErrorDesc(), pszQuery);
    801888                pszError += strlen(pszError) - 1;
    802889                ulRc++;
Note: See TracChangeset for help on using the changeset viewer.