Package dev.frostlake
Class DatabaseEngine
java.lang.Object
dev.frostlake.DatabaseEngine
Main Database SQL Engine
Provides a complete SQL engine implementing Snowflake DB features
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidBind the session's JSON_INDENT so displayed variants use its width for this statement.voidWrite a WAL checkpoint: snapshot the full state durably, append a checkpoint marker (the atomic pivot — recovery keys off the LAST marker, so a crash before it leaves an ignored orphan snapshot), then truncate the log to the marker and drop superseded snapshots.voidcheckpointStateTo(Path dir) Write this engine's complete state — every database with its schemas, tables and rows, views, sequences (at their current positions), functions, procedures, streams with pending records, tasks, stages, roles and policies — todir, from whichrestoreStateFrom(Path)can rebuild an equivalent engine.A new, fully independent engine carrying a copy of this engine's complete state — databases, schemas, tables with rows, views, sequences at their current positions, functions, procedures, streams with pending records, tasks, stages, roles and policies.voidcommit()Execute a SQL statement or scriptexecuteQuery(String sql) Execute a query and return a single result setintexecuteUpdate(String sql) Execute an update statement (INSERT, UPDATE, DELETE)This engine's effective configuration (read-only introspection, e.g. by embedders and tests).The query-result cache backing RESULT_SCAN and LAST_QUERY_ID.Resolver for s3:// (and S3-backed @stage) references to local files — seeS3PathResolver.booleanbooleanThe loggability decision, exposed so tests can assert it family by family.voidreleaseSavepoint(String name) voidrestoreStateFrom(Path dir) Rebuild this engine's state from acheckpointStateTo(Path)snapshot.voidrollback()voidrollbackToSavepoint(String name) voidsetAutoCommit(boolean autoCommit) voidsetCurrentRole(String roleName) voidsetCurrentUser(String username) voidsetSavepoint(String name) showColumns(String tableName) voidshutdown()Shutdown the engine and release resourcesvoidvoidvoiduseDatabase(String database) void
-
Constructor Details
-
DatabaseEngine
public DatabaseEngine() -
DatabaseEngine
-
-
Method Details
-
isDurableStatementForTesting
The loggability decision, exposed so tests can assert it family by family. -
checkpoint
public void checkpoint()Write a WAL checkpoint: snapshot the full state durably, append a checkpoint marker (the atomic pivot — recovery keys off the LAST marker, so a crash before it leaves an ignored orphan snapshot), then truncate the log to the marker and drop superseded snapshots. No-op while an explicit transaction is open (its statements aren't committed yet). Safe to call explicitly; also driven bydurability.checkpointInterval. -
execute
Execute a SQL statement or script -
executeQuery
Execute a query and return a single result set -
executeUpdate
Execute an update statement (INSERT, UPDATE, DELETE) -
beginTransaction
public void beginTransaction() -
commit
public void commit() -
rollback
public void rollback() -
setSavepoint
-
rollbackToSavepoint
-
releaseSavepoint
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) -
isAutoCommit
public boolean isAutoCommit() -
useDatabase
-
useSchema
-
getCurrentDatabase
-
getCurrentSchema
-
showDatabases
-
showSchemas
-
showTables
-
showColumns
-
showViews
-
showProcedures
-
showFunctions
-
checkpointStateTo
Write this engine's complete state — every database with its schemas, tables and rows, views, sequences (at their current positions), functions, procedures, streams with pending records, tasks, stages, roles and policies — todir, from whichrestoreStateFrom(Path)can rebuild an equivalent engine. Holds the engine monitor, so it is mutually exclusive with statements running on direct connections. Works regardless ofpersistence.enabled.- Throws:
IOException
-
restoreStateFrom
Rebuild this engine's state from acheckpointStateTo(Path)snapshot. Intended for a freshly constructed engine (the template-clone pattern: migrate once, checkpoint, boot many); restored functions and procedures recompile lazily from their stored source on first use.- Throws:
IOExceptionClassNotFoundException
-
cloneInstance
A new, fully independent engine carrying a copy of this engine's complete state — databases, schemas, tables with rows, views, sequences at their current positions, functions, procedures, streams with pending records, tasks, stages, roles and policies. Writes to either engine are invisible to the other. The copy happens entirely in memory (no filesystem involvement); usecheckpointStateTo(Path)/restoreStateFrom(Path)instead when the clone must cross a process boundary — a serialized checkpoint is the only form of this engine that can.- Throws:
IOExceptionClassNotFoundException
-
getConfig
This engine's effective configuration (read-only introspection, e.g. by embedders and tests). -
bindJsonIndent
public void bindJsonIndent()Bind the session's JSON_INDENT so displayed variants use its width for this statement. The HTTP wire binds it again while it renders a statement's rows, which happens after the statement's own scope has closed; the caller clears it withVariantJsonFormat.clearSessionScope(). -
getQueryResultCache
The query-result cache backing RESULT_SCAN and LAST_QUERY_ID. -
getCatalog
-
getS3PathResolver
Resolver for s3:// (and S3-backed @stage) references to local files — seeS3PathResolver. -
getExecutor
-
getStorageEngine
-
getFunctionRegistry
-
getTransactionManager
-
getSystemViews
-
startTaskScheduler
public void startTaskScheduler() -
stopTaskScheduler
public void stopTaskScheduler() -
getStreamManager
-
getTaskScheduler
-
getSecurityManager
-
getSessionContext
-
setCurrentUser
-
setCurrentRole
-
getCurrentUser
-
getCurrentRole
-
shutdown
public void shutdown()Shutdown the engine and release resources
-