Class PostgresDialect
java.lang.Object
io.agentscope.extensions.jdbc.dialect.AbstractJdbcDialect
io.agentscope.extensions.jdbc.dialect.vendor.PostgresDialect
- All Implemented Interfaces:
SandboxLockStrategy,SessionStateDialect,SnapshotDialect,StoreDialect
PostgreSQL dialect — the ANSI baseline.
Business SQL inherits ANSI defaults from the table-domain interfaces. Only
create-table DDL and UPSERT syntax (which use PostgreSQL-specific ON CONFLICT
and types like TEXT/BYTEA) are overridden.
- Author:
- shanhongyu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsessionStateCheckTableExists(String tableName) Table-existence probe SQL.DDL statements (one or more) to create the sessions table.sessionStateUpsert(String sessionId, String stateKey, int itemIndex, String stateData) UPSERT a single state value.DDL statements (one or more) to create the snapshots table.snapshotUpsert(String snapshotId, InputStream data) Idempotent UPSERT for uploading a snapshot.DDL statements (one or more) to create the KV store table.storeUpsert(String namespacePath, String key, String json, long timestamp) UPSERT: insert new row with version=1 or update existing row with version+1.booleansupports(DatabaseMetaData metaData) Whether this dialect supports the target database.io.agentscope.harness.agent.sandbox.SandboxLeaseAcquires the named lock, blocking until available or timeout expires.Methods inherited from class io.agentscope.extensions.jdbc.dialect.AbstractJdbcDialect
bindDataSource, closeConnection, closeResultSet, closeStatement, createTableDdls, from, getDataSource, getOrder, lockTableName, sessionStateTableName, snapshotTableName, storeTableNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.extensions.jdbc.dialect.table.SessionStateDialect
sessionStateDeleteByKey, sessionStateDeleteSession, sessionStateExists, sessionStateInsert, sessionStateInsertIfAbsent, sessionStateLikeEscapeChar, sessionStateListSessionIds, sessionStateSelect, sessionStateSelectList, sessionStateSelectMaxIndex, sessionStateSelectVersioned, sessionStateUpdateIfVersionMethods inherited from interface io.agentscope.extensions.jdbc.dialect.table.SnapshotDialect
snapshotExists, snapshotSelectMethods inherited from interface io.agentscope.extensions.jdbc.dialect.table.StoreDialect
storeCasUpdate, storeDelete, storeInsert, storeLikeEscapeChar, storeSearch, storeSelect
-
Constructor Details
-
PostgresDialect
public PostgresDialect()
-
-
Method Details
-
storeCreateTableDdls
Description copied from interface:StoreDialectDDL statements (one or more) to create the KV store table. Must be idempotent. -
storeUpsert
Description copied from interface:StoreDialectUPSERT: insert new row with version=1 or update existing row with version+1. -
sessionStateCreateTableDdls
Description copied from interface:SessionStateDialectDDL statements (one or more) to create the sessions table. Must be idempotent. -
sessionStateUpsert
public BoundSql sessionStateUpsert(String sessionId, String stateKey, int itemIndex, String stateData) Description copied from interface:SessionStateDialectUPSERT a single state value. On conflict, updates state_data. -
sessionStateCheckTableExists
Description copied from interface:SessionStateDialectTable-existence probe SQL. One bind param: the table name. -
snapshotCreateTableDdls
Description copied from interface:SnapshotDialectDDL statements (one or more) to create the snapshots table. Must be idempotent. -
snapshotUpsert
Description copied from interface:SnapshotDialectIdempotent UPSERT for uploading a snapshot.The
dataparam is bound as a binary stream viaPreparedStatement.setBinaryStream(int, InputStream)by the client, so snapshots of arbitrary size are streamed straight to the database without loading the whole archive into heap memory. -
tryEnter
public io.agentscope.harness.agent.sandbox.SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException Description copied from interface:SandboxLockStrategyAcquires the named lock, blocking until available or timeout expires.- Specified by:
tryEnterin interfaceSandboxLockStrategy- Overrides:
tryEnterin classAbstractJdbcDialect- Parameters:
lockName- a unique, validated lock nametimeoutSeconds- maximum wait in seconds- Returns:
- a lease that releases the lock when closed
- Throws:
InterruptedException- if the calling thread is interrupted
-
supports
Description copied from class:AbstractJdbcDialectWhether this dialect supports the target database.- Specified by:
supportsin classAbstractJdbcDialect- Parameters:
metaData- JDBC metadata (connection stays open)- Returns:
- true if this dialect handles the database
- Throws:
SQLException- if metadata reading fails
-