rdsdataapi

package module
v0.0.0-...-37dd40c Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 9 Imported by: 0

README

rds-data-api

SQL Driver for the AWS RDS Data API

Limitations

  • The driver cannot sanity check the nr of parameters in a query
  • The driver doesn't support ordinal query arguments (named only)
  • No streaming support
  • IncludeResultMetadata is always set to true with 1MB of data limit
  • result.LastInsertID() not supported for aurora postgres, instead use https://www.postgresql.org/docs/10/dml-returning.html this is a limitation from AWS: https://godoc.org/github.com/aws/aws-sdk-go/service/rdsdataservice#ExecuteStatementOutput
  • result.RowAffected returns 0 on non empty table, implementation error?
  • Prepared statements are not supported (maybe expose batchExecute?)
  • Prepared statements are not executed as stmt.Exec() / stmt.Query() are called but are instead batched on the client side
  • Prepared statements do not result anything usefull except for INSERT
  • Prepared statements lastInsertID can only be retrieved after closing the statement

TODO

  • Get basic db.Exec and db.Query working
  • add a cloudformation for setting up a testig mysql database
  • test mysql last inserted id function
  • implement Tx, Commit and Rollback
  • figure out how to perform prepared statements;
  • Validate and add to the limitations described here: https://github.com/jeremydaly/data-api-client
  • remove repetition in tests
  • make sure tests that fail halfway still cleanup
  • use https://godoc.org/database/sql/driver#ResultNoRows correctly
  • Can we pass this test: https://github.com/bradfitz/go-sql-test
  • Can we include the AWS library in such a way that we don't have to publish new versions for every new release
  • The package and module name are a bit verbose, maybe shortend to rdsda?
  • Write Function docs
  • Remove fmt dependency, rather use custom errors
  • Double check if our atomic close check works as expected
  • Write error path test cases
  • implement the driver.ColumnType methods on "Rows"
  • Figure out what happen on AWS if transactions are started but never committed or rolled back - @SEE ttps://godoc.org/github.com/aws/aws-sdk-go/service/rdsdataservice#RDSDataService.BeginTransaction a transaction times out if it made no progress in 3 minutes

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(q string) (_ driver.Conn, err error)

Types

type Conn

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

Conn is a connection to a database. It is not used concurrently by multiple goroutines.

func (*Conn) Begin deprecated

func (c *Conn) Begin() (driver.Tx, error)

Begin starts and returns a new transaction.

Deprecated: Drivers should implement ConnBeginTx instead (or additionally).

func (*Conn) BeginTx

func (c *Conn) BeginTx(ctx context.Context, opts sql.TxOptions) (_ driver.Tx, err error)

BeginTx starts and returns a new transaction. If the context is canceled by the user the sql package will call Tx.Rollback before discarding and closing the connection.

This must check opts.Isolation to determine if there is a set isolation level. If the driver does not support a non-default level and one is set or if there is a non-default isolation level that is not supported, an error must be returned.

This must also check opts.ReadOnly to determine if the read-only value is true to either set the read-only transaction property if supported or return an error if it is not supported.

func (*Conn) Close

func (c *Conn) Close() (err error)

Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.

Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.

func (*Conn) Commit

func (c *Conn) Commit() (err error)

func (*Conn) ExecContext

func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (_ driver.Result, err error)

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (driver.Stmt, error)

Prepare returns a prepared statement, bound to this connection.

func (*Conn) PrepareContext

func (c *Conn) PrepareContext(ctx context.Context, query string) (_ driver.Stmt, err error)

PrepareContext returns a prepared statement, bound to this connection. context is for the preparation of the statement, it must not store the context within the statement itself.

func (*Conn) QueryContext

func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (_ driver.Rows, err error)

func (*Conn) Rollback

func (c *Conn) Rollback() (err error)

type Driver

type Driver struct{}

func (*Driver) Open

func (d *Driver) Open(s string) (_ driver.Conn, err error)

type Result

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

Result is the result of a query execution.

func (*Result) LastInsertId

func (r *Result) LastInsertId() (id int64, err error)

LastInsertId returns the database's auto-generated ID after, for example, an INSERT into a table with primary key.

func (*Result) RowsAffected

func (r *Result) RowsAffected() (n int64, err error)

RowsAffected returns the number of rows affected by the query.

type Rows

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

Rows is an iterator over an executed query's results.

func (*Rows) Close

func (r *Rows) Close() error

Close closes the rows iterator.

func (*Rows) Columns

func (r *Rows) Columns() (cols []string)

Columns returns the names of the columns. The number of columns of the result is inferred from the length of the slice. If a particular column name isn't known, an empty string should be returned for that entry.

func (*Rows) Next

func (r *Rows) Next(dest []driver.Value) (err error)

Next is called to populate the next row of data into the provided slice. The provided slice will be the same size as the Columns() are wide.

Next should return io.EOF when there are no more rows.

The dest should not be written to outside of Next. Care should be taken when closing Rows not to modify a buffer held in dest.

type Stmt

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

func (*Stmt) Close

func (s *Stmt) Close() (err error)

func (*Stmt) Exec

func (s *Stmt) Exec(args []driver.Value) (_ driver.Result, err error)

func (*Stmt) ExecContext

func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (_ driver.Result, err error)

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

func (*Stmt) Query

func (s *Stmt) Query(args []driver.Value) (_ driver.Rows, err error)

func (*Stmt) QueryContext

func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (_ driver.Rows, err error)

type StmtResult

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

func (*StmtResult) LastInsertId

func (r *StmtResult) LastInsertId() (id int64, err error)

func (*StmtResult) RowsAffected

func (r *StmtResult) RowsAffected() (n int64, err error)

Jump to

Keyboard shortcuts

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