@@ -92,6 +92,9 @@ defmodule Exqlite.Connection do
9292 * `:chunk_size` - The chunk size for bulk fetching. Defaults to `50`.
9393 * `:key` - Optional key to set during database initialization. This PRAGMA
9494 is often used to set up database level encryption.
95+ * `:journal_size_limit` - The size limit in bytes of the journal.
96+ * `:soft_heap_limit` - The size limit in bytes for the heap limit.
97+ * `:hard_heap_limit` - The size limit in bytes for the heap.
9598
9699 For more information about the options above, see [sqlite documenation][1]
97100
@@ -351,6 +354,25 @@ defmodule Exqlite.Connection do
351354 end
352355 end
353356
357+ defp set_pragma_if_present ( _db , _pragma , nil ) , do: :ok
358+ defp set_pragma_if_present ( db , pragma , value ) , do: set_pragma ( db , pragma , value )
359+
360+ defp set_journal_size_limit ( db , options ) do
361+ set_pragma_if_present (
362+ db ,
363+ "journal_size_limit" ,
364+ Keyword . get ( options , :journal_size_limit )
365+ )
366+ end
367+
368+ defp set_soft_heap_limit ( db , options ) do
369+ set_pragma_if_present ( db , "soft_heap_limit" , Keyword . get ( options , :soft_heap_limit ) )
370+ end
371+
372+ defp set_hard_heap_limit ( db , options ) do
373+ set_pragma_if_present ( db , "hard_heap_limit" , Keyword . get ( options , :hard_heap_limit ) )
374+ end
375+
354376 defp set_journal_mode ( db , options ) do
355377 maybe_set_pragma ( db , "journal_mode" , Pragma . journal_mode ( options ) )
356378 end
@@ -414,7 +436,10 @@ defmodule Exqlite.Connection do
414436 :ok <- set_secure_delete ( db , options ) ,
415437 :ok <- set_wal_auto_check_point ( db , options ) ,
416438 :ok <- set_case_sensitive_like ( db , options ) ,
417- :ok <- set_busy_timeout ( db , options ) do
439+ :ok <- set_busy_timeout ( db , options ) ,
440+ :ok <- set_journal_size_limit ( db , options ) ,
441+ :ok <- set_soft_heap_limit ( db , options ) ,
442+ :ok <- set_hard_heap_limit ( db , options ) do
418443 state = % __MODULE__ {
419444 db: db ,
420445 path: path ,
0 commit comments