Ticket #1335: 0001-Replace-deprecated-APIs.patch

File 0001-Replace-deprecated-APIs.patch, 2.6 KB (added by Vasilij Schneidermann, 4 months ago)
  • sqlite3/3.7.2/sqlite3.scm

    From 19ae1cd2dc28b83e0020819cd64bacbe541e960b Mon Sep 17 00:00:00 2001
    From: Vasilij Schneidermann <mail@vasilij.de>
    Date: Fri, 13 Aug 2021 14:32:10 +0200
    Subject: [PATCH] Replace deprecated APIs
    
    ---
     sqlite3/3.7.2/sqlite3.scm | 42 ++++++++++++++++++++++++---------------
     1 file changed, 26 insertions(+), 16 deletions(-)
    
    diff --git a/sqlite3/3.7.2/sqlite3.scm b/sqlite3/3.7.2/sqlite3.scm
    index 9d9440e..9be2faf 100644
    a b  
    9393    database-memory-highwater
    9494    enable-shared-cache!
    9595    enable-load-extension!
     96    load-extension!
    9697  )
    9798
    9899(import
    EOS 
    10701071;; Enables (disables) the sharing of the database cache and schema data
    10711072;; structures between connections to the same database.
    10721073(define (enable-shared-cache! enable?)
    1073   (cond-expand
    1074    [disable-shared-cache
    1075     #f]
    1076    [else
    1077     (cond
    1078      [((foreign-lambda sqlite3:status "sqlite3_enable_shared_cache" bool) enable?)
    1079       => (abort-sqlite3-error 'enable-shared-cache! #f)]
    1080      [else
    1081       enable?])]))
     1074  (error "Deprecated API"))
    10821075
    1083 ;; Enables (disables) the loading of native extensions using SQL statements.
     1076;; Enables (disables) the loading of native extensions.
    10841077(define (enable-load-extension! db enable?)
    1085   (cond-expand
    1086    [disable-load-extension
    1087     #f]
     1078  (define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION (foreign-value "SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION" int))
     1079  (cond
     1080   [((foreign-lambda sqlite3:status "sqlite3_db_config" sqlite3:database int bool (c-pointer int)) db SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION enable? #f)
     1081    => (abort-sqlite3-error 'enable-load-extension! db)]
    10881082   [else
     1083    enable?]))
     1084
     1085;; Loads a native extension.
     1086(define (load-extension! db path #!optional entry-point)
     1087  (let-location [(err c-pointer)
     1088                 (errlen int)]
    10891089    (cond
    1090      [((foreign-lambda sqlite3:status "sqlite3_enable_load_extension" sqlite3:database bool) db enable?)
    1091       => (abort-sqlite3-error 'enable-load-extension! db)]
     1090     [((foreign-lambda* c-string* ((sqlite3:database db) ((const c-string) path) ((const c-string) proc))
     1091         "char *errptr, *errstr;"
     1092         "if (sqlite3_load_extension(db, path, proc, &errptr) != SQLITE_OK) {"
     1093         " errstr = strdup(errptr);"
     1094         " sqlite3_free(errptr);"
     1095         " C_return(errstr);"
     1096         "}"
     1097         "C_return(NULL);")
     1098       db path entry-point)
     1099      => (lambda (err)
     1100           (abort (make-sqlite3-error-condition 'load-extension! err
     1101                                                'error path entry-point)))]
    10921102     [else
    1093       enable?])]))
     1103      (void)])))
    10941104
    10951105)
    10961106