Changeset 2761 for trunk/tools/database


Ignore:
Timestamp:
Feb 12, 2000, 12:54:25 AM (26 years ago)
Author:
bird
Message:

Preformance and corrections.

Location:
trunk/tools/database
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/database/CreateTables.sql

    r2759 r2761  
    1 -- $Id: CreateTables.sql,v 1.2 2000-02-11 18:35:54 bird Exp $
     1-- $Id: CreateTables.sql,v 1.3 2000-02-11 23:54:24 bird Exp $
    22--
    33-- Create all tables.
     
    1212    name VARCHAR(32) NOT NULL,
    1313    description VARCHAR(255),
    14     UNIQUE i1(refcode),
    15     UNIQUE i2(name)
     14    UNIQUE u1(refcode),
     15    UNIQUE u2(name)
    1616);
    1717
     
    2121    name    VARCHAR(32) NOT NULL,
    2222    description VARCHAR(128),
    23     UNIQUE i1(refcode),
    24     UNIQUE i2(name),
    25     UNIQUE i3(color)
     23    UNIQUE u1(refcode),
     24    UNIQUE u2(name),
     25    UNIQUE u3(color)
    2626);
    2727
    2828CREATE TABLE function (
    29     refcode INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
    30     dll     TINYINT NOT NULL,
    31     name    VARCHAR(64) NOT NULL,
    32     intname VARCHAR(64) NOT NULL,
    33     state   TINYINT NOT NULL DEFAULT 0,
    34     ordinal INTEGER NOT NULL,
     29    refcode  INTEGER  NOT NULL AUTO_INCREMENT PRIMARY KEY,
     30    dll      TINYINT  NOT NULL,
     31    aliasfn  INTEGER  NOT NULL DEFAULT -1,
     32    name     VARCHAR(64) NOT NULL,
     33    intname  VARCHAR(64) NOT NULL,
     34    state    TINYINT  NOT NULL DEFAULT 0,
     35    ordinal  INTEGER  NOT NULL,
    3536    apigroup SMALLINT,
    36     return VARCHAR(64),
    37     updated TINYINT NOT NULL DEFAULT 0,
    38     UNIQUE i1(refcode),
    39     UNIQUE i2(name,dll),
    40     UNIQUE i3(intname, refcode)
     37    return   VARCHAR(64),
     38    updated  TINYINT  NOT NULL DEFAULT 0,
     39    UNIQUE i1(refcode, aliasfn),
     40    UNIQUE i1a(aliasfn, name, dll),
     41    UNIQUE i1b(aliasfn, dll, refcode),
     42    UNIQUE i1c(aliasfn, intname, dll, refcode),
     43    UNIQUE i2(name, dll, refcode),
     44    UNIQUE i3(intname, dll, refcode),
     45    UNIQUE u1(refcode),
     46    UNIQUE u2(name, dll)
    4147);
    4248
     
    4652    name    VARCHAR(64) NOT NULL,
    4753    description VARCHAR(128),
    48     UNIQUE i1(refcode),
    49     UNIQUE i2(name)
     54    UNIQUE u1(refcode),
     55    UNIQUE u2(name)
    5056);
    5157
     
    5864    country  VARCHAR(64),
    5965    location VARCHAR(64),
    60     UNIQUE i1(refcode),
    61     UNIQUE i2(name),
    62     UNIQUE i3(initials)
     66    UNIQUE u1(refcode),
     67    UNIQUE u2(name),
     68    UNIQUE u3(initials)
    6369--   ,UNIQUE i4(alias), UNIQUE columns have to be defined NOT NULL in mySql.
    6470--    UNIQUE i5(email)  UNIQUE columns have to be defined NOT NULL in mySql.
     
    6874    author   SMALLINT NOT NULL,
    6975    function INTEGER NOT NULL,
    70     UNIQUE i1(function, author)
     76    UNIQUE u1(function, author)
    7177);
    7278
     
    7682    date  DATE NOT NULL,
    7783    count SMALLINT NOT NULL,
    78     UNIQUE i1(dll, state, date)
     84    UNIQUE u1(dll, state, date)
    7985);
    8086
     
    8490    date  DATE NOT NULL,
    8591    count SMALLINT NOT NULL,
    86     UNIQUE i1(apigroup, state, date)
     92    UNIQUE u1(apigroup, state, date)
    8793);
    8894
     
    9197    date DATE NOT NULL,
    9298    totalcount SMALLINT NOT NULL,
    93     UNIQUE i1(dll, DATE)
     99    UNIQUE u1(dll, DATE)
    94100);
    95101
     
    98104    date DATE NOT NULL,
    99105    totalcount SMALLINT NOT NULL,
    100     UNIQUE i1(apigroup, date)
     106    UNIQUE u1(apigroup, date)
    101107);
    102108
    103109CREATE TABLE parameter (
    104     function SMALLINT NOT NULL,
     110    function INTEGER NOT NULL,
    105111    sequencenbr TINYINT NOT NULL,
     112    name     VARCHAR(64) NOT NULL,
    106113    type     VARCHAR(64) NOT NULL,
    107     name     VARCHAR(64) NOT NULL,
    108114    description VARCHAR(128),
    109     UNIQUE i1(function, name)
     115    INDEX  i1(function, name(10)),
     116    UNIQUE u1(function, name)
    110117);
    111118
  • trunk/tools/database/Makefile

    r2759 r2761  
    1 # $Id: Makefile,v 1.6 2000-02-11 18:35:55 bird Exp $
     1# $Id: Makefile,v 1.7 2000-02-11 23:54:25 bird Exp $
    22
    33#
     
    1313CINCLUDES= -I$(PDWIN32_INCLUDE) -I$(PDWIN32_INCLUDE)\win -Igd -Imysql -I..\common
    1414!ifdef DEBUG
    15 CFLAGS   = $(CFLAGS)   -Ge+ -Tx+ -Tm- $(CINCLUDES)      -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft-
    16 CXXFLAGS = $(CXXFLAGS) -Ge+ -Gx- -Tx+ -Tm- $(CINCLUDES) -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft-
    17 LDFLAGS  = $(LDFLAGS)  -Ge+ -Fe$@ /B"/MAP:full" $(RTLLIB) os2386.lib
     15CFLAGS   = $(CFLAGS)   -Ge+ -Tx+ -Tm- $(CINCLUDES)      -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft- -Gh+
     16CXXFLAGS = $(CXXFLAGS) -Ge+ -Gx- -Tx+ -Tm- $(CINCLUDES) -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft- -Gh+
     17LDFLAGS  = $(LDFLAGS)  -Ge+ -Fe$@ /B"/MAP:full" $(RTLLIB) os2386.lib cppopa3.obj
    1818!else
    1919CFLAGS   = $(CFLAGS)   -Ge+ -Tx+ $(CINCLUDES)      -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft-
  • trunk/tools/database/StateUpd.cpp

    r2759 r2761  
    1 /* $Id: StateUpd.cpp,v 1.8 2000-02-11 18:35:54 bird Exp $
     1/* $Id: StateUpd.cpp,v 1.9 2000-02-11 23:54:24 bird Exp $
    22 *
    33 * StateUpd - Scans source files for API functions and imports data on them.
     
    626626
    627627        /* 4.*/
    628         ulRcTmp = dbUpdateFunction(&FnDesc, &szErrorDesc[0]);
     628        ulRcTmp = dbUpdateFunction(&FnDesc, pOptions->lDllRefcode, &szErrorDesc[0]);
    629629        if (ulRcTmp != 0)
    630630        {
     
    679679
    680680    /* 3. */
    681     if (!dbFindFunction(pFnDesc->pszName, &FnFindBuf))
     681    if (!dbFindFunction(pFnDesc->pszName, &FnFindBuf, pOptions->lDllRefcode))
    682682    {
    683683        fprintf(phSignal, "%s, %s: error occured while reading from database, %s\n",
     
    701701
    702702        for (lFn = 0; lFn < FnFindBuf.cFns; lFn++)
    703         {
    704             if (FnFindBuf.alDllRefCode[lFn] == pOptions->lDllRefcode)
    705                 pFnDesc->alRefCode[pFnDesc->cRefCodes++] = FnFindBuf.alRefCode[lFn];
    706         }
     703            pFnDesc->alRefCode[pFnDesc->cRefCodes++] = FnFindBuf.alRefCode[lFn];
    707704
    708705        if (pFnDesc->cRefCodes == 0)
     
    741738     */
    742739
    743     int     iFn, iP1, iP2, j;
     740    int     iFn, iP1, iP2, j, c;
    744741    char *  pszFn, *pszFnEnd, *pszP1, *pszP2;
    745742    char *  psz, *pszEnd;
     
    812809
    813810    /* 3. */
     811    c = 1;
    814812    iP2 = iP1;
    815813    pszP2 = pszP1 + 1;
    816     while (*pszP2 != ')')
     814    while (c > 0)
     815    {
     816        if (*pszP2 == '(')
     817            c++;
     818        else if (*pszP2 == ')')
     819            if (--c == 0)
     820                break;
    817821        if (*pszP2++ == '\0')
    818822            if ((pszP2 = papszLines[++iP2]) == NULL)
    819823                break;
     824    }
    820825
    821826    iRet = iP2 + 1; //assumes: only one function on a single line!
     
    832837        char *pszC;
    833838        pszC = trim(psz+1);
     839        c = 1;
    834840        while (*pszC != '\0')
    835841        {
    836842            apszArgs[cArgs] = pszC;
    837             while (*pszC != ',' && *pszC != ')' && *pszC != '\0')
     843            while (*pszC != ',' && c > 0 && *pszC != '\0')
     844            {
     845                if (*pszC == '(')
     846                    c++;
     847                else if (*pszC == ')')
     848                    if (--c == 0)
     849                        break;
    838850                pszC++;
     851            }
    839852            *pszC = '\0';
    840853            trim(apszArgs[cArgs++]);
     
    877890        pFnDesc->pszReturnType = *pszEnd == '\0' ? NULL : pszEnd;
    878891        pszEnd = strlen(pszEnd) + pszEnd + 1;
     892        *pszEnd = '\0';
    879893
    880894        /* function name */
    881         *pszEnd = '\0';
    882895        if (pFnDesc->pszReturnType != NULL
    883896            && stristr(pFnDesc->pszReturnType, "cdecl") != NULL)
    884897        {   /* cdecl function is prefixed with an '_' */
    885898            strcpy(pszEnd, "_");
    886             strncat(pszEnd+1, pszFn, pszFnEnd - pszFn+1);
     899            strncat(pszEnd + 1, pszFn, pszFnEnd - pszFn+1);
    887900        }
    888901        else
    889902            strncat(pszEnd, pszFn, pszFnEnd - pszFn+1);
    890 
    891903        pFnDesc->pszName = pszEnd;
     904        pszEnd = strlen(pszEnd) + pszEnd + 1;
     905        *pszEnd = '\0';
     906
    892907
    893908        /* arguments */
     
    895910        for (j = 0; j < cArgs; j++)
    896911        {
    897             pFnDesc->apszParamName[j] = findStartOfWord(apszArgs[j] + strlen(apszArgs[j]) - 1,
    898                                                         apszArgs[j]);
    899             pFnDesc->apszParamName[j][-1] = '\0';
    900             pFnDesc->apszParamType[j] = trim(apszArgs[j]);
     912            if ((psz = strchr(apszArgs[j], ')')) == NULL)
     913            {
     914                pFnDesc->apszParamName[j] = findStartOfWord(apszArgs[j] + strlen(apszArgs[j]) - 1,
     915                                                            apszArgs[j]);
     916                pFnDesc->apszParamName[j][-1] = '\0';
     917                pFnDesc->apszParamType[j] = trim(apszArgs[j]);
     918            }
     919            else
     920            {
     921                char *pszP2 = psz;
     922                psz = findStartOfWord(psz-1, apszArgs[j]);
     923                strncat(pszEnd, psz, pszP2 - psz);
     924
     925                pFnDesc->apszParamName[j] = pszEnd;
     926                memset(psz, ' ', pszP2 - psz);
     927                pFnDesc->apszParamType[j] = trim(apszArgs[j]);
     928
     929                pszEnd = strlen(pszEnd) + pszEnd + 1;
     930                *pszEnd = '\0';
     931            }
    901932        }
    902933    }
     
    12181249
    12191250                while (pszFnName - cchFnName > papszLines[i] && pszFnName[cchFnName] == ' ')
    1220                     cchFnName--;
     1251                    cchFnName--, pszFnName--;
    12211252
    12221253                pszFnName = findStartOfWord(pszFnName, papszLines[i]);
     
    12391270                        if (psz != NULL && *psz != '*')
    12401271                        {
    1241                             char *pszB = pszP1; /*'{'*/
     1272                            char *pszB = pszP1 + 1; /*'{'*/
     1273                            int   c = 1;
    12421274
    12431275                            /* 3. */
    1244                             while (*pszB != ')')
     1276                            while (c > 0)
     1277                            {
     1278                                if (*pszB == '(')
     1279                                    c++;
     1280                                else if (*pszB == ')')
     1281                                    if (--c == 0)
     1282                                        break;
    12451283                                if (*pszB++ == '\0')
    12461284                                    if ((pszB = papszLines[++i]) == NULL)
    12471285                                        break;
     1286                            }
    12481287                            if (pszB != NULL)
    12491288                            {
     
    12931332                if (pszP1 != NULL && *pszP1 == '(')
    12941333                {
    1295                     char *pszB = pszP1; /*'{'*/
     1334                    char *pszB = pszP1 + 1; /*'{'*/
     1335                    int   c = 1;
    12961336
    12971337                    /* 3. */
    1298                     while (*pszB != ')')
     1338                    while (c > 0)
     1339                    {
     1340                        if (*pszB == '(')
     1341                            c++;
     1342                        else if (*pszB == ')')
     1343                            if (--c == 0)
     1344                                break;
    12991345                        if (*pszB++ == '\0')
    13001346                            if ((pszB = papszLines[++i]) == NULL)
    13011347                                break;
     1348                    }
    13021349                    if (pszB != NULL)
    13031350                    {
  • trunk/tools/database/db.cpp

    r2759 r2761  
    1 /* $Id: db.cpp,v 1.5 2000-02-11 18:35:54 bird Exp $ */
    2 /*
     1/* $Id: db.cpp,v 1.6 2000-02-11 23:54:25 bird Exp $ *
     2 *
    33 * DB - contains all database routines.
    44 *
     
    8080static unsigned long CheckAuthorError(char * &pszError, const char *pszFieldName, const char *pszFieldValue, const char *pszQuery);
    8181static unsigned long logDbError(char * &pszError, const char *pszQuery);
    82 #ifdef NOTDLL
     82#ifndef DLL
    8383    extern "C" void      dbHandler(int sig);
    8484#endif
     
    103103{
    104104    BOOL fRet = FALSE;
    105     #ifdef NOTDLL
     105    #ifndef DLL
    106106        static fHandler = FALSE;
    107107        /* signal handler */
     
    188188    if (ulDll >= 0)
    189189    {
    190         sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE dll = %d\n", ulDll);
     190        sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE dll = %ld\n", ulDll);
    191191        rc   = mysql_query(pmysql, &szQuery[0]);
    192192        pres = mysql_store_result(pmysql);
     
    360360}
    361361
    362 
     362#if 0
    363363/**
    364364 * Find occurences of a function, given by internal name.
     
    366366 * @param     pszFunctionName
    367367 * @param     pFnFindBuf
    368  */
    369 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf)
     368 * @param     lDll
     369 */
     370BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll)
    370371{
    371372    MYSQL_RES   *pres;
     
    374375    char         szQuery[256];
    375376
    376     sprintf(&szQuery[0], "SELECT refcode, dll FROM function WHERE intname = '%s'",
    377             pszFunctionName, pszFunctionName);
     377    if (lDll < 0)
     378        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE intname = '%s'",
     379                pszFunctionName);
     380    else
     381        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
     382                "WHERE intname = '%s' AND dll = %ld",
     383                pszFunctionName, lDll);
    378384
    379385    rc = mysql_query(pmysql, &szQuery[0]);
     
    388394                pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    389395                pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     396                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    390397
    391398                /* next */
     
    393400            }
    394401            mysql_free_result(pres);
     402
     403            /* alias check and fix */
     404            if (lDll >= 0 && pFnFindBuf->cFns != 0)
     405            {
     406                int i;
     407
     408                /* Make the selected function to DONT TOUCH */
     409                sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
     410                                     "WHERE (",
     411                        lDll, pszFunctionName);
     412                for (i = 0; i < pFnFindBuf->cFns; i++)
     413                {
     414                    if (i != 0) strcat(&szQuery[0], " OR");
     415                    sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);
     416                }
     417                strcat(&szQuery[0], ") AND aliasfn <> (-2)");
     418
     419                rc = mysql_query(pmysql, &szQuery[0]);
     420                if (rc >= 0)
     421                {
     422                    /* Update all with equal internal... which is not in this Dll */
     423                    sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
     424                                         "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
     425                            pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
     426                    rc = mysql_query(pmysql, &szQuery[0]);
     427                    if (rc >= 0)
     428                    {
     429                        /* Update all with equal external name... which is not in this Dll */
     430                        sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
     431                                             "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
     432                                pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
     433
     434                        rc = mysql_query(pmysql, &szQuery[0]);
     435                        if (rc >= 0)
     436                        {
     437                            /* get the functions aliases to the functions we have allready found. */
     438                            strcpy(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE (");
     439                            for (i = 0; i < pFnFindBuf->cFns; i++)
     440                            {
     441                                if (i != 0) strcat(&szQuery[0], "OR ");
     442                                sprintf(&szQuery[strlen(szQuery)], "aliasfn = %ld ", pFnFindBuf->alRefCode[i]);
     443                            }
     444                            sprintf(&szQuery[strlen(szQuery)], ") AND dll <> %ld", lDll);
     445
     446                            rc = mysql_query(pmysql, &szQuery[0]);
     447                            if (rc >= 0)
     448                            {
     449                                pres = mysql_store_result(pmysql);
     450                                if (pres != NULL)
     451                                {
     452                                    while ((row = mysql_fetch_row(pres)) != NULL)
     453                                    {
     454                                        pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
     455                                        pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     456                                        if (row[2] != NULL)
     457                                            pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     458                                        else
     459                                            pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
     460
     461                                        /* next */
     462                                        pFnFindBuf->cFns++;
     463                                    }
     464                                    mysql_free_result(pres);
     465                                }
     466                            }
     467                        }
     468                    }
     469                }
     470            }
    395471        }
    396472        else
     
    400476    return rc >= 0;
    401477}
     478#else
     479int     mysql_query1(MYSQL *mysql, const char *q)
     480{
     481    return mysql_query(mysql, q);
     482}
     483
     484int     mysql_query2(MYSQL *mysql, const char *q)
     485{
     486    return mysql_query(mysql, q);
     487}
     488
     489int     mysql_query3(MYSQL *mysql, const char *q)
     490{
     491    return mysql_query(mysql, q);
     492}
     493
     494int     mysql_query4(MYSQL *mysql, const char *q)
     495{
     496    return mysql_query(mysql, q);
     497}
     498
     499int     mysql_query5(MYSQL *mysql, const char *q)
     500{
     501    return mysql_query(mysql, q);
     502}
     503
     504MYSQL_RES *  mysql_store_result1(MYSQL *mysql)
     505{
     506    return mysql_store_result(mysql);
     507}
     508
     509MYSQL_RES *  mysql_store_result2(MYSQL *mysql)
     510{
     511    return mysql_store_result(mysql);
     512}
     513
     514
     515/**
     516 * Find occurences of a function, given by internal name.
     517 * @returns   success indicator, TRUE / FALSE.
     518 * @param     pszFunctionName
     519 * @param     pFnFindBuf
     520 * @param     lDll
     521 */
     522BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll)
     523{
     524    MYSQL_RES   *pres;
     525    MYSQL_ROW    row;
     526    int          rc;
     527    char         szQuery[256];
     528
     529    if (lDll < 0)
     530        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE intname = '%s'",
     531                pszFunctionName);
     532    else
     533        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
     534                "WHERE intname = '%s' AND dll = %ld",
     535                pszFunctionName, lDll);
     536
     537    rc = mysql_query1(pmysql, &szQuery[0]);
     538    if (rc >= 0)
     539    {
     540        pres = mysql_store_result1(pmysql);
     541        if (pres != NULL)
     542        {
     543            pFnFindBuf->cFns = 0;
     544            while ((row = mysql_fetch_row(pres)) != NULL)
     545            {
     546                pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
     547                pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     548                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     549
     550                /* next */
     551                pFnFindBuf->cFns++;
     552            }
     553            mysql_free_result(pres);
     554
     555            /* alias check and fix */
     556            if (lDll >= 0 && pFnFindBuf->cFns != 0)
     557            {
     558                int i;
     559
     560                /* Make the selected function to DONT TOUCH */
     561                sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
     562                                     "WHERE (",
     563                        lDll, pszFunctionName);
     564                for (i = 0; i < pFnFindBuf->cFns; i++)
     565                {
     566                    if (i != 0) strcat(&szQuery[0], " OR");
     567                    sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);
     568                }
     569                strcat(&szQuery[0], ") AND aliasfn <> (-2)");
     570
     571                rc = mysql_query2(pmysql, &szQuery[0]);
     572                if (rc >= 0)
     573                {
     574                    /* Update all with equal internal... which is not in this Dll */
     575                    sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
     576                                         "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
     577                            pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
     578                    rc = mysql_query3(pmysql, &szQuery[0]);
     579                    if (rc >= 0)
     580                    {
     581                        /* Update all with equal external name... which is not in this Dll */
     582                        sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
     583                                             "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
     584                                pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
     585
     586                        rc = mysql_query4(pmysql, &szQuery[0]);
     587                        if (rc >= 0)
     588                        {
     589                            int cFns = pFnFindBuf->cFns;
     590                            for (i = 0; i < cFns; i++)
     591                            {
     592                                /* get the functions aliases to the functions we have allready found. */
     593                                sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE aliasfn = %ld AND dll <> %ld",
     594                                        pFnFindBuf->alRefCode[i], lDll);
     595                                rc = mysql_query5(pmysql, &szQuery[0]);
     596                                if (rc >= 0)
     597                                {
     598                                    pres = mysql_store_result2(pmysql);
     599                                    if (pres != NULL)
     600                                    {
     601                                        while ((row = mysql_fetch_row(pres)) != NULL)
     602                                        {
     603                                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
     604                                            pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     605                                            if (row[2] != NULL)
     606                                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     607                                            else
     608                                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
     609
     610                                            /* next */
     611                                            if (pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] != lDll)
     612                                                pFnFindBuf->cFns++;
     613                                        }
     614                                        mysql_free_result(pres);
     615                                    }
     616                                }
     617                            }
     618                        }
     619                    }
     620                }
     621            }
     622        }
     623        else
     624            rc = -1;
     625    }
     626
     627    return rc >= 0;
     628}
     629
     630#endif
    402631
    403632
     
    475704 * Updates function information.
    476705 * @returns   number of errors.
    477  * @param     pFnDesc
    478  * @param     pszError
     706 * @param     pFnDesc   Function description struct.
     707 * @param     lDll      Dll which we are working at.
     708 * @param     pszError  Buffer for error messages
    479709 * @result    on error(s) pszError will hold information about the error(s).
    480710 */
    481 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, char *pszError)
     711unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lDll, char *pszError)
    482712{
    483713    char  szQuery[256];
     
    491721    {
    492722        /* set updated flag */
    493         sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %d",
     723        sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %ld",
    494724                pFnDesc->alRefCode[k]);
    495725        rc = mysql_query(pmysql, &szQuery[0]);
     
    515745        if (pFnDesc->pszReturnType != NULL)
    516746        {
    517             if (f)
    518             {
    519                 strcat(pszQuery, ", ");
    520                 pszQuery += strlen(pszQuery);
    521             }
    522             sprintf(pszQuery, "return = '%s' ", pFnDesc->pszReturnType);
     747            if (f)  strcat(pszQuery, ", ");
     748            sprintf(pszQuery + strlen(pszQuery),  "return = '%s' ", pFnDesc->pszReturnType);
    523749            pszQuery += strlen(pszQuery);
    524750            f = TRUE;
     
    527753        if (f)
    528754        {
    529             sprintf(pszQuery, "WHERE refcode = %ld", pFnDesc->alRefCode[k]);
     755            sprintf(pszQuery + strlen(pszQuery), "WHERE refcode = %ld", pFnDesc->alRefCode[k]);
    530756            rc = mysql_query(pmysql, &szQuery[0]);
    531757            if (rc < 0)
     
    605831        }
    606832    } /* for */
     833
     834    lDll = lDll;
    607835    return ulRc;
    608836}
     
    11951423
    11961424    /* not updated names */
    1197     sprintf(&szQuery[0], "SELECT name, intname FROM function WHERE dll = %d AND updated = 0",
     1425    sprintf(&szQuery[0], "SELECT name, intname FROM function WHERE dll = %ld AND updated = 0",
    11981426            lDll);
    11991427    pres = dbExecuteQuery(szQuery);
     
    12101438
    12111439    /* warn about updated > 1 too */
    1212     sprintf(&szQuery[0], "SELECT updated, name, intname FROM function WHERE dll = %d AND updated > 1",
     1440    sprintf(&szQuery[0], "SELECT updated, name, intname FROM function WHERE dll = %ld AND updated > 1",
    12131441            lDll);
    12141442    pres = dbExecuteQuery(szQuery);
     
    12241452    }
    12251453
    1226     sprintf(&szQuery[0], "UPDATE function SET updated = 0",
    1227             lDll);
     1454    strcpy(&szQuery[0], "UPDATE function SET updated = 0");
    12281455    mysql_query(pmysql, &szQuery[0]);
    12291456
     
    12321459
    12331460
    1234 #ifdef NOTDLL
     1461#ifndef DLL
    12351462/**
    12361463 * Signal handler.
  • trunk/tools/database/db.h

    r2759 r2761  
    1 /* $Id: db.h,v 1.3 2000-02-11 18:35:54 bird Exp $ */
     1/* $Id: db.h,v 1.4 2000-02-11 23:54:25 bird Exp $ */
    22/*
    33 * DB - contains all database routines
     
    1919*   Defined Constants                                                          *
    2020*******************************************************************************/
    21 #define NBR_FUNCTIONS   20
    22 #define NBR_AUTHORS     20
     21#define NBR_FUNCTIONS       20
     22#define NBR_AUTHORS         20
     23#define ALIAS_NULL          -1
     24#define ALIAS_DONTMIND      -2
     25
    2326
    2427/*******************************************************************************
     
    3639        long  cRefCodes;
    3740        long  alRefCode[NBR_FUNCTIONS];
     41        signed long  lImpDll; /* -1 is SQL-NULL, -2 is do not mind, >= 0 ref to dll. */
    3842
    3943        /* parameters */
     
    5862        signed long   alRefCode[NBR_FUNCTIONS];
    5963        signed long   alDllRefCode[NBR_FUNCTIONS];
     64        signed long   alAliasFn[NBR_FUNCTIONS]; /* -1 is SQL-NULL, -2 is do not mind, >= 0 ref to function. */
    6065    } FNFINDBUF, *PFNFINDBUF;
    6166
     
    8691                                                   BOOL fIgnoreOrdinal);
    8792    BOOL            _System dbFindFunction(const char *pszFunctionName,
    88                                            PFNFINDBUF pFnFindBuf);
     93                                           PFNFINDBUF pFnFindBuf,
     94                                           signed long lDll);
    8995    signed long     _System dbFindAuthor(const char *pszAuthor);
    9096    signed long     _System dbGetFunctionState(signed long lRefCode);
    9197    unsigned long   _System dbUpdateFunction(PFNDESC pFnDesc,
     98                                             signed long lDll,
    9299                                             char *pszError);
    93100    unsigned long   _System dbCreateHistory(char *pszError);
Note: See TracChangeset for help on using the changeset viewer.