postgres

package
v0.1.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package postgres implements the target storage interface backed by PostgreSQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for connecting to PostgreSQL.

func NewClient

func NewClient(connString string, l *log.Logger) (*Client, error)

NewClient creates a new PostgreSQL client.

func (*Client) Begin

func (c *Client) Begin(ctx context.Context) (storage.Tx, error)

Begin implements the storage.TargetStorage interface for Client.

func (*Client) Close

func (c *Client) Close()

Close implements the storage.TargetStorage interface for Client.

func (*Client) DisableTriggersAndFKConstraints

func (c *Client) DisableTriggersAndFKConstraints(ctx context.Context) error

DisableTriggersAndFKConstraints disables all triggers and foreign key constraints in nexus tables. This is useful when inserting blockchain data out of order, so that later blocks can refer to (yet unindexed) earlier blocks without violating constraints.

func (*Client) EnableTriggersAndFKConstraints

func (c *Client) EnableTriggersAndFKConstraints(ctx context.Context) error

EnableTriggersAndFKConstraints enables all triggers and foreign key constraints in the given schema. WARNING: This might enable triggers not explicitly disabled by DisableTriggersAndFKConstraints. WARNING: This does not enforce/check contraints on rows that were inserted while triggers were disabled.

func (*Client) Name

func (c *Client) Name() string

Name implements the storage.TargetStorage interface for Client.

func (*Client) Query

func (c *Client) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

Query submits a new read query to PostgreSQL.

func (*Client) QueryRow

func (c *Client) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

QueryRow submits a new read query for a single row to PostgreSQL.

func (*Client) SendBatch

func (c *Client) SendBatch(ctx context.Context, batch *storage.QueryBatch) error

SendBatch submits a new batch of queries as an atomic transaction to PostgreSQL.

For now, updated row counts are discarded as this is not intended to be used by any nexus. We only care about atomic success or failure of the batch of queries corresponding to a new block.

func (*Client) SendBatchWithOptions

func (c *Client) SendBatchWithOptions(ctx context.Context, batch *storage.QueryBatch, opts pgx.TxOptions) error

func (*Client) Wipe

func (c *Client) Wipe(ctx context.Context) error

Wipe removes all contents of the database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL