/ Check-in [085b0d67]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:The user-defined function routines failed to detect a malloc() failure. (CVS 397)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:085b0d671a1dac964693d69d866224de155dfe4c
User & Date: drh 2002-02-27 01:53:13
Context
2002-02-27
19:00
Revise the API for user-defined functions. (CVS 398) check-in: 633951f0 user: drh tags: trunk
01:53
The user-defined function routines failed to detect a malloc() failure. (CVS 397) check-in: 085b0d67 user: drh tags: trunk
01:47
Bug fixes in the VIEW implementation. (CVS 396) check-in: 668ef638 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1392
1393
1394
1395
1396
1397
1398

1399
1400
1401
1402
1403
1404
1405
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.46 2002/02/27 01:47:12 drh Exp $
*/
#include "sqliteInt.h"


/*
** Construct a new expression node and return a pointer to it.  Memory
** for this node is obtained from sqliteMalloc().  The calling function
................................................................................
  const char *zName, /* Name of the function.  Not null-terminated */
  int nName,         /* Number of characters in the name */
  int nArg,          /* Number of arguments.  -1 means any number */
  int createFlag     /* Create new entry if true and does not otherwise exist */
){
  UserFunc *pFirst, *p, *pMaybe;
  pFirst = p = (UserFunc*)sqliteHashFind(&db->userFunc, zName, nName);

  if( !createFlag && nArg<0 ){
    while( p && p->xFunc==0 && p->xStep==0 ){ p = p->pNext; }
    return p;
  }
  pMaybe = 0;
  while( p && p->nArg!=nArg ){
    if( p->nArg<0 && !createFlag && (p->xFunc || p->xStep) ) pMaybe = p;







|







 







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.47 2002/02/27 01:53:13 drh Exp $
*/
#include "sqliteInt.h"


/*
** Construct a new expression node and return a pointer to it.  Memory
** for this node is obtained from sqliteMalloc().  The calling function
................................................................................
  const char *zName, /* Name of the function.  Not null-terminated */
  int nName,         /* Number of characters in the name */
  int nArg,          /* Number of arguments.  -1 means any number */
  int createFlag     /* Create new entry if true and does not otherwise exist */
){
  UserFunc *pFirst, *p, *pMaybe;
  pFirst = p = (UserFunc*)sqliteHashFind(&db->userFunc, zName, nName);
  if( p==0 ) return 0;
  if( !createFlag && nArg<0 ){
    while( p && p->xFunc==0 && p->xStep==0 ){ p = p->pNext; }
    return p;
  }
  pMaybe = 0;
  while( p && p->nArg!=nArg ){
    if( p->nArg<0 && !createFlag && (p->xFunc || p->xStep) ) pMaybe = p;

Changes to src/main.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
644
645
646
647
648
649
650

651
652
653
654
655
656
657
...
659
660
661
662
663
664
665

666
667
668
669
670
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.63 2002/02/24 01:55:17 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"

/*
** This is the callback routine for the code that initializes the
** database.  See sqliteInit() below for additional information.
................................................................................
  const char *zName,   /* Name of the function to add */
  int nArg,            /* Number of arguments */
  void (*xFunc)(void*,int,const char**)  /* Implementation of the function */
){
  UserFunc *p;
  if( db==0 || zName==0 ) return 1;
  p = sqliteFindUserFunction(db, zName, strlen(zName), nArg, 1);

  p->xFunc = xFunc;
  p->xStep = 0;
  p->xFinalize = 0;
  return 0;
}
int sqlite_create_aggregate(
  sqlite *db,          /* Add the function to this database connection */
................................................................................
  int nArg,            /* Number of arguments */
  void *(*xStep)(void*,int,const char**), /* The step function */
  void (*xFinalize)(void*,void*)          /* The finalizer */
){
  UserFunc *p;
  if( db==0 || zName==0 ) return 1;
  p = sqliteFindUserFunction(db, zName, strlen(zName), nArg, 1);

  p->xFunc = 0;
  p->xStep = xStep;
  p->xFinalize = xFinalize;
  return 0;
}







|







 







>







 







>





10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
...
660
661
662
663
664
665
666
667
668
669
670
671
672
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.64 2002/02/27 01:53:13 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"

/*
** This is the callback routine for the code that initializes the
** database.  See sqliteInit() below for additional information.
................................................................................
  const char *zName,   /* Name of the function to add */
  int nArg,            /* Number of arguments */
  void (*xFunc)(void*,int,const char**)  /* Implementation of the function */
){
  UserFunc *p;
  if( db==0 || zName==0 ) return 1;
  p = sqliteFindUserFunction(db, zName, strlen(zName), nArg, 1);
  if( p==0 ) return 1;
  p->xFunc = xFunc;
  p->xStep = 0;
  p->xFinalize = 0;
  return 0;
}
int sqlite_create_aggregate(
  sqlite *db,          /* Add the function to this database connection */
................................................................................
  int nArg,            /* Number of arguments */
  void *(*xStep)(void*,int,const char**), /* The step function */
  void (*xFinalize)(void*,void*)          /* The finalizer */
){
  UserFunc *p;
  if( db==0 || zName==0 ) return 1;
  p = sqliteFindUserFunction(db, zName, strlen(zName), nArg, 1);
  if( p==0 ) return 1;
  p->xFunc = 0;
  p->xStep = xStep;
  p->xFinalize = xFinalize;
  return 0;
}