Skip to content

Commit

Permalink
better SQLITE_TRACE_CLOSE test; implemented SQLITE3_DB_FILENAME()
Browse files Browse the repository at this point in the history
  • Loading branch information
tuffnatty committed Nov 16, 2023
1 parent f624bf1 commit c499aca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions contrib/hbsqlit3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2488,6 +2488,26 @@ HB_FUNC( SQLITE3_CREATE_FUNCTION )
}


/**
Get database filename for given connection and database name
sqlite3_db_filename( pDb, sDbName )
*/
HB_FUNC( SQLITE3_DB_FILENAME )
{
#if SQLITE_VERSION_NUMBER >= 3007010
HB_SQLITE3 * pHbSqlite3 = ( HB_SQLITE3 * ) hb_sqlite3_param( 1, HB_SQLITE3_DB, HB_TRUE );

if( pHbSqlite3 && pHbSqlite3->db && HB_ISCHAR( 2 ) )
hb_retc( ( const char * ) sqlite3_db_filename( pHbSqlite3->db, hb_parc( 2 ) ) );
else
hb_errRT_BASE_SubstR( EG_ARG, 0, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
#else
hb_errRT_BASE_SubstR( EG_UNSUPPORTED, 0, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
#endif
}


/**
Get expanded SQL for a prepared statement
Expand Down
1 change: 1 addition & 0 deletions contrib/hbsqlit3/hbsqlit3.hbx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ DYNAMIC sqlite3_compileoption_get
DYNAMIC sqlite3_compileoption_used
DYNAMIC sqlite3_complete
DYNAMIC sqlite3_create_function
DYNAMIC sqlite3_db_filename
DYNAMIC sqlite3_db_status
DYNAMIC sqlite3_enable_load_extension
DYNAMIC sqlite3_enable_shared_cache
Expand Down
2 changes: 1 addition & 1 deletion contrib/hbsqlit3/tests/backup.prg
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PROCEDURE init_trace( pDb, cPrefix )
FWrite( hFile, sqlite3_expanded_sql( p ) + hb_eol() )
ENDIF
ELSEIF nMask == SQLITE_TRACE_CLOSE /* p is the database connection */
FWrite( hFile, "Closing the database connection" + hb_eol() )
FWrite( hFile, "Closing the database connection: " + sqlite3_db_filename( p, "main" ) + hb_eol() )
ENDIF
RETURN 0
} )
Expand Down

0 comments on commit c499aca

Please sign in to comment.