1.Dd March 11, 2017 2.Dt SQLITE3_CLOSE 3 3.Os 4.Sh NAME 5.Nm sqlite3_close , 6.Nm sqlite3_close_v2 7.Nd Closing A Database Connection 8.Sh SYNOPSIS 9.Ft int 10.Fo sqlite3_close 11.Fa "sqlite3*" 12.Fc 13.Ft int 14.Fo sqlite3_close_v2 15.Fa "sqlite3*" 16.Fc 17.Sh DESCRIPTION 18The sqlite3_close() and sqlite3_close_v2() routines are destructors 19for the sqlite3 object. 20Calls to sqlite3_close() and sqlite3_close_v2() return SQLITE_OK 21if the sqlite3 object is successfully destroyed and all associated 22resources are deallocated. 23.Pp 24If the database connection is associated with unfinalized prepared 25statements or unfinished sqlite3_backup objects then sqlite3_close() 26will leave the database connection open and return SQLITE_BUSY. 27If sqlite3_close_v2() is called with unfinalized prepared statements 28and/or unfinished sqlite3_backups, then the database connection becomes 29an unusable "zombie" which will automatically be deallocated when the 30last prepared statement is finalized or the last sqlite3_backup is 31finished. 32The sqlite3_close_v2() interface is intended for use with host languages 33that are garbage collected, and where the order in which destructors 34are called is arbitrary. 35.Pp 36Applications should finalize all prepared statements, 37 close all BLOB handles, and finish all sqlite3_backup 38objects associated with the sqlite3 object prior to attempting 39to close the object. 40If sqlite3_close_v2() is called on a database connection 41that still has outstanding prepared statements, 42BLOB handles, and/or sqlite3_backup objects 43then it returns SQLITE_OK and the deallocation of resources 44is deferred until all prepared statements, BLOB handles, 45and sqlite3_backup objects are also destroyed. 46.Pp 47If an sqlite3 object is destroyed while a transaction is open, 48the transaction is automatically rolled back. 49.Pp 50The C parameter to sqlite3_close(C) and sqlite3_close_v2(C) 51must be either a NULL pointer or an sqlite3 object pointer obtained 52from sqlite3_open(), sqlite3_open16(), 53or sqlite3_open_v2(), and not previously closed. 54Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer argument 55is a harmless no-op. 56.Sh SEE ALSO 57.Xr sqlite3_blob 3 , 58.Xr sqlite3 3 , 59.Xr sqlite3_stmt 3 , 60.Xr sqlite3 3 , 61.Xr sqlite3_backup 3 , 62.Xr sqlite3_backup_init 3 , 63.Xr sqlite3_blob_close 3 , 64.Xr sqlite3_finalize 3 , 65.Xr sqlite3_open 3 , 66.Xr SQLITE_OK 3 67