/ Check-in [d3f99a5e]
Login

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

Overview
Comment:Enhance the sqlite3_load_extension() interface to permit extensions to return SQLITE_OK_LOAD_PERMANENTLY which will prevent the extensions from unloading when the database connection closes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | load-permanently
Files: files | file ages | folders
SHA1:d3f99a5e8d0486d0917dfe96987c179a6f63b850
User & Date: drh 2016-05-28 17:23:08
Context
2016-06-03
13:35
Enhance the sqlite3_load_extension() interface to permit extensions to return SQLITE_OK_LOAD_PERMANENTLY which will prevents unloading when the database connection closes. check-in: 5908aa4d user: drh tags: trunk
2016-05-28
17:23
Enhance the sqlite3_load_extension() interface to permit extensions to return SQLITE_OK_LOAD_PERMANENTLY which will prevent the extensions from unloading when the database connection closes. Closed-Leaf check-in: d3f99a5e user: drh tags: load-permanently
15:22
Enhance "PRAGMA compile_options" so that it shows the version of the compiler used to generate the executable, for common compilers. check-in: 6a0f2009 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/vfsstat.c.

811
812
813
814
815
816
817

818
819
  memcpy(&pNew->base, &vstat_vfs, sizeof(vstat_vfs));
  pNew->pVfs = sqlite3_vfs_find(0);
  pNew->base.szOsFile = sizeof(VStatFile) + pNew->pVfs->szOsFile;
  rc = sqlite3_vfs_register(&pNew->base, 1);
  if( rc==SQLITE_OK ){
    rc = sqlite3_auto_extension((void(*)(void))vstatRegister);
  }

  return rc;
}







>


811
812
813
814
815
816
817
818
819
820
  memcpy(&pNew->base, &vstat_vfs, sizeof(vstat_vfs));
  pNew->pVfs = sqlite3_vfs_find(0);
  pNew->base.szOsFile = sizeof(VStatFile) + pNew->pVfs->szOsFile;
  rc = sqlite3_vfs_register(&pNew->base, 1);
  if( rc==SQLITE_OK ){
    rc = sqlite3_auto_extension((void(*)(void))vstatRegister);
  }
  if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY;
  return rc;
}

Changes to src/loadext.c.

442
443
444
445
446
447
448

449
450
451
452
453
454
455
...
544
545
546
547
548
549
550
551


552
553
554
555
556
557
558
  int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
  char *zErrmsg = 0;
  const char *zEntry;
  char *zAltEntry = 0;
  void **aHandle;
  u64 nMsg = 300 + sqlite3Strlen30(zFile);
  int ii;


  /* Shared library endings to try if zFile cannot be loaded as written */
  static const char *azEndings[] = {
#if SQLITE_OS_WIN
     "dll"   
#elif defined(__APPLE__)
     "dylib"
................................................................................
      }
    }
    sqlite3OsDlClose(pVfs, handle);
    sqlite3_free(zAltEntry);
    return SQLITE_ERROR;
  }
  sqlite3_free(zAltEntry);
  if( xInit(db, &zErrmsg, &sqlite3Apis) ){


    if( pzErrMsg ){
      *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
    }
    sqlite3_free(zErrmsg);
    sqlite3OsDlClose(pVfs, handle);
    return SQLITE_ERROR;
  }







>







 







|
>
>







442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
...
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
  int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
  char *zErrmsg = 0;
  const char *zEntry;
  char *zAltEntry = 0;
  void **aHandle;
  u64 nMsg = 300 + sqlite3Strlen30(zFile);
  int ii;
  int rc;

  /* Shared library endings to try if zFile cannot be loaded as written */
  static const char *azEndings[] = {
#if SQLITE_OS_WIN
     "dll"   
#elif defined(__APPLE__)
     "dylib"
................................................................................
      }
    }
    sqlite3OsDlClose(pVfs, handle);
    sqlite3_free(zAltEntry);
    return SQLITE_ERROR;
  }
  sqlite3_free(zAltEntry);
  rc = xInit(db, &zErrmsg, &sqlite3Apis);
  if( rc ){
    if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;
    if( pzErrMsg ){
      *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
    }
    sqlite3_free(zErrmsg);
    sqlite3OsDlClose(pVfs, handle);
    return SQLITE_ERROR;
  }

Changes to src/sqlite.h.in.

502
503
504
505
506
507
508

509
510
511
512
513
514
515
#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))


/*
** CAPI3REF: Flags For File Open Operations
**
** These bit values are intended for use in the
** 3rd parameter to the [sqlite3_open_v2()] interface and
** in the 4th parameter to the [sqlite3_vfs.xOpen] method.







>







502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))

/*
** CAPI3REF: Flags For File Open Operations
**
** These bit values are intended for use in the
** 3rd parameter to the [sqlite3_open_v2()] interface and
** in the 4th parameter to the [sqlite3_vfs.xOpen] method.