class Memo::Dialect::Postgres

Defined in:

memo/dialect/postgres.cr

Constant Summary

MIGRATION_LOCK = 1835363695_i64

Any constant shared by every memo process ("memo" in ASCII)

SCHEMA_SQL = {{ read_file("/home/trans/Projects/memo/src/memo/dialect/../../../db/schema/memo_schema_pg.sql") }}

Instance Method Summary

Instance methods inherited from class Memo::Dialect::Base

database_name(db : DB::Database) : String | Nil database_name, db_file_path(db : DB::Database) : String | Nil db_file_path, drop_legacy_texts(db : DBHandle) : Nil drop_legacy_texts, embedding_rowid_column : String embedding_rowid_column, fts_join_sql : String fts_join_sql, fts_where_sql : String fts_where_sql, insert_or_ignore_sql(table : String, columns : String, placeholders : String) : String insert_or_ignore_sql, insert_returning_id(db : DBHandle, sql : String, *args) : Int64 insert_returning_id, lock_for_migration(db : DB::Connection) : Nil lock_for_migration, prepare(db : DB::Database) : Nil prepare, schema_statements : Array(String) schema_statements, table_exists?(db : DBHandle, table : String) : Bool table_exists?, upsert_sql(table : String, columns : String, placeholders : String, conflict_columns : String, update_columns : Array(String)) : String upsert_sql

Instance Method Detail

def database_name(db : DB::Database) : String | Nil #
Description copied from class Memo::Dialect::Base

The database's name on its server, for naming index files.

SQLite: nil (the file names it) PostgreSQL: current_database()


[View source]
def db_file_path(db : DB::Database) : String | Nil #
Description copied from class Memo::Dialect::Base

Get the database file path from a connection, if applicable.

SQLite: reads pragma_database_list PostgreSQL: returns nil (no local file)


[View source]
def drop_legacy_texts(db : DBHandle) : Nil #
Description copied from class Memo::Dialect::Base

Drop the tables content-addressed storage replaced (memo_texts and its full-text index).


[View source]
def embedding_rowid_column : String #
Description copied from class Memo::Dialect::Base

The column name for embedding row identity used as USearch key.

SQLite: "rowid" (implicit) PostgreSQL: "eid" (explicit column)


[View source]
def fts_join_sql : String #
Description copied from class Memo::Dialect::Base

Build FTS JOIN clause for search queries (joining a chunk's text).


[View source]
def fts_where_sql : String #
Description copied from class Memo::Dialect::Base

Build FTS WHERE clause for match queries.


[View source]
def insert_or_ignore_sql(table : String, columns : String, placeholders : String) : String #
Description copied from class Memo::Dialect::Base

Build INSERT OR IGNORE SQL.


[View source]
def insert_returning_id(db : DBHandle, sql : String, *args) : Int64 #
Description copied from class Memo::Dialect::Base

Execute an INSERT and return the generated ID.


[View source]
def lock_for_migration(db : DB::Connection) : Nil #

Two processes opening the database at once would otherwise both migrate it. The lock is released when the transaction ends.


[View source]
def schema_statements : Array(String) #
Description copied from class Memo::Dialect::Base

Get schema DDL statements.


[View source]
def table_exists?(db : DBHandle, table : String) : Bool #

[View source]
def upsert_sql(table : String, columns : String, placeholders : String, conflict_columns : String, update_columns : Array(String)) : String #
Description copied from class Memo::Dialect::Base

Build upsert SQL (INSERT OR REPLACE equivalent).


[View source]