Class PostgresJdbcStoreDialect

java.lang.Object
io.agentscope.extensions.mysql.store.PostgresJdbcStoreDialect
All Implemented Interfaces:
JdbcStoreDialect

public class PostgresJdbcStoreDialect extends Object implements JdbcStoreDialect
PostgreSQL dialect for JdbcStore.
  • Constructor Details

    • PostgresJdbcStoreDialect

      public PostgresJdbcStoreDialect()
  • Method Details

    • getCreateTableSql

      public String getCreateTableSql()
      Description copied from interface: JdbcStoreDialect
      Returns the SQL to create the store table if it does not yet exist.

      The table must have columns: namespace_path VARCHAR(2048), item_key VARCHAR(255), value_json (TEXT-like), version BIGINT, updated_at BIGINT, plus a primary key on (namespace_path, item_key).

      Specified by:
      getCreateTableSql in interface JdbcStoreDialect
      Returns:
      CREATE TABLE statement; must use %s for the table name
    • getUpsertSql

      public String getUpsertSql()
      Description copied from interface: JdbcStoreDialect
      Returns the SQL to insert-or-update an item, incrementing version on update.

      Bind parameters in order: (namespace_path, item_key, value_json, updated_at) — the dialect is responsible for setting version=1 on insert and version=version+1 on update.

      Specified by:
      getUpsertSql in interface JdbcStoreDialect
      Returns:
      UPSERT statement; must use %s for the table name
    • getInsertSql

      public String getInsertSql()
      Description copied from interface: JdbcStoreDialect
      Returns the SQL to insert a new row with version=1.

      Bind parameters in order: (namespace_path, item_key, value_json, updated_at). Used by putIfVersion(... expectedVersion=0): a primary-key violation indicates the row already exists and the CAS attempt has failed.

      Specified by:
      getInsertSql in interface JdbcStoreDialect
      Returns:
      INSERT statement; must use %s for the table name
    • getCasUpdateSql

      public String getCasUpdateSql()
      Description copied from interface: JdbcStoreDialect
      Returns the SQL to conditionally update an item only when the stored version matches.

      Bind parameters in order: (value_json, updated_at, namespace_path, item_key, expectedVersion). Implementations must set version = version + 1. The caller treats an affected-row count of 1 as success.

      Specified by:
      getCasUpdateSql in interface JdbcStoreDialect
      Returns:
      UPDATE statement; must use %s for the table name