@@ -124,6 +124,8 @@ module sqlite
124124 public :: sqlite3_column_type
125125 public :: sqlite3_data_count
126126 public :: sqlite3_db_status
127+ public :: sqlite3_errmsg
128+ public :: sqlite3_errmsg_
127129 public :: sqlite3_exec
128130 public :: sqlite3_exec_
129131 public :: sqlite3_finalize
@@ -155,6 +157,8 @@ module sqlite
155157 public :: c_f_str_ptr
156158 public :: c_strlen
157159
160+ private :: copy
161+
158162 interface
159163 ! int sqlite3_bind_double(sqlite3_stmt *stmt, int idx, double val)
160164 function sqlite3_bind_double (stmt , idx , val ) bind(c, name= ' sqlite3_bind_double' )
@@ -259,7 +263,14 @@ function sqlite3_db_status(db, op, current, highwater, reset_flag) bind(c, name=
259263 integer (kind= c_int) :: sqlite3_db_status
260264 end function sqlite3_db_status
261265
262- ! int sqlite3_exec(sqlite3* db, const char *sql, int (*callback)(void *, int, char **, char **), void *client_data, char **errmsg)
266+ ! const char *sqlite3_errmsg(sqlite3 *db)
267+ function sqlite3_errmsg_ (db ) bind(c, name= ' sqlite3_errmsg' )
268+ import :: c_ptr
269+ type (c_ptr), intent (in ), value :: db
270+ type (c_ptr) :: sqlite3_errmsg_
271+ end function sqlite3_errmsg_
272+
273+ ! int sqlite3_exec(sqlite3 *db, const char *sql, int (*callback)(void *, int, char **, char **), void *client_data, char **errmsg)
263274 function sqlite3_exec_ (db , sql , callback , client_data , errmsg ) bind(c, name= ' sqlite3_exec' )
264275 import :: c_char, c_funptr, c_int, c_ptr
265276 type (c_ptr), intent (in ), value :: db
@@ -277,7 +288,7 @@ function sqlite3_finalize(stmt) bind(c, name='sqlite3_finalize')
277288 integer (kind= c_int) :: sqlite3_finalize
278289 end function sqlite3_finalize
279290
280- ! sqlite3_int64 sqlite3_last_insert_rowid(sqlite3* db)
291+ ! sqlite3_int64 sqlite3_last_insert_rowid(sqlite3 * db)
281292 function sqlite3_last_insert_rowid (db ) bind(c, name= ' sqlite3_last_insert_rowid' )
282293 import :: c_int64_t, c_ptr
283294 type (c_ptr), intent (in ), value :: db
@@ -505,6 +516,18 @@ function sqlite3_column_text(stmt, icol)
505516 call c_f_str_ptr(ptr, sqlite3_column_text)
506517 end function sqlite3_column_text
507518
519+ function sqlite3_errmsg (db )
520+ type (c_ptr), intent (in ) :: db
521+ character (len= :), allocatable :: sqlite3_errmsg
522+ type (c_ptr) :: ptr
523+
524+ ptr = sqlite3_errmsg_(db)
525+
526+ if (c_associated(ptr)) then
527+ call c_f_str_ptr(ptr, sqlite3_errmsg)
528+ end if
529+ end function sqlite3_errmsg
530+
508531 function sqlite3_exec (db , sql , callback , client_data , errmsg )
509532 type (c_ptr), intent (in ) :: db
510533 character (len=* ), intent (in ) :: sql
0 commit comments