oracle

package
v1.26.4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 13 Imported by: 0

README

Oracle adapter (CLI v2 preview)

The Oracle adapter is registered only by cmd/tdtpcli_v2. It uses the pure-Go github.com/sijms/go-ora/v2 driver and the shared TDTP adapter contract. The automated integration suite runs against Oracle XE 18c and 21c. Oracle 19c belongs to the intended 18c–21c range, but has not yet had a live run.

Create a v2 config with tdtpcli_v2 init-config oracle --output oracle.yaml. Set database.host, port, database (service name, e.g. XEPDB1), user and password. A raw database.dsn overrides those fields. For example:

database:
  type: oracle
  host: localhost
  port: 1521
  database: XEPDB1
  user: tdtp
  password: password

The signed tdtp.lic must list oracle in its adapters array. The vendor can reissue a license with the original tier, features, limits and expiry, adding Oracle to the existing adapter list:

tdtp-license issue --key vendor.priv --out tdtp.lic --licensee "Customer" \
  --tier professional --adapters sqlite,postgres,mysql,mssql,oracle \
  --features etl,enc --expires 2027-12-31
tdtp-license verify --in tdtp.lic

Use the signing key whose public half is embedded in the target CLI build. Editing the JSON by hand invalidates its signature. Keep the private key and issued license outside Git.

tdtpcli_v2 --config oracle.yaml list
tdtpcli_v2 --config oracle.yaml inspect-table ORDERS
tdtpcli_v2 --config oracle.yaml export ORDERS --where "ID > 10" --limit 5
tdtpcli_v2 --config oracle.yaml import orders.tdtp.xml --strategy replace

type: oracle is accepted for v2 pipeline sources. Its query is Oracle SQL; the pipeline transform is still SQLite SQL. NUMBER fields are selected as decimal text during export and pipeline reads to avoid float64 rounding. Oracle treats empty strings as NULL, so an empty string cannot round-trip as a distinct value. Import supports fail, copy, ignore and replace; the latter two require key fields. Oracle DDL commits implicitly, so a missing target table is created before the transactional row import. A failed batch rolls back its rows, but leaves that newly created empty table.

Packets from other engines (SQLite, PostgreSQL, …) are imported with their field names quoted as written, so columns can be lower case ("name"). The pushdown SQL for --where / --order-by quotes every column with its exact schema spelling, so such tables are filtered inside Oracle; the lookup is case-insensitive. Comparisons on DATE / DATETIME / TIMESTAMP columns use ANSI DATE '…' / TIMESTAMP '…' literals, which do not depend on the session's NLS_DATE_FORMAT. On import, a text key without a length becomes VARCHAR2(255 CHAR) (a LOB cannot be a key), other lengthless text becomes CLOB, and TDTP REAL becomes BINARY_DOUBLE.

TDTP INTEGER is created as NUMBER(19,0), and NUMBER(19,0) is read back as DECIMAL with the subtype bigint: a native NUMBER(19,0) may hold values above int64, which DECIMAL keeps exact, while the subtype lets the PostgreSQL, MSSQL and MySQL importers create BIGINT instead of a numeric column. Values travel as exact int64 (never float64); one above int64 makes a BIGINT target refuse the row. SQLite ignores the hint.

To run the live test suite, start Oracle XE 18c and 21c separately, create a user with CREATE TABLE and CREATE VIEW privileges, and set:

$env:TDTP_ORACLE18_DSN = 'oracle://user:password@127.0.0.1:1522/XEPDB1'
$env:TDTP_ORACLE21_DSN = 'oracle://user:password@127.0.0.1:1523/XEPDB1'
go test ./pkg/adapters/oracle -count=1 -v

Without those environment variables the unit tests still run and the live subtests skip.

Documentation

Overview

Package oracle implements the TDTP adapter for Oracle Database 18c and 21c.

Index

Constants

View Source
const AdapterType = "oracle"

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

func (*Adapter) BeginTx

func (a *Adapter) BeginTx(ctx context.Context) (adapters.Tx, error)

func (*Adapter) Close

func (a *Adapter) Close(context.Context) error

func (*Adapter) Connect

func (a *Adapter) Connect(ctx context.Context, cfg adapters.Config) error

func (*Adapter) CreateTable

func (a *Adapter) CreateTable(ctx context.Context, name string, schema packet.Schema) error

func (*Adapter) DropTable

func (a *Adapter) DropTable(ctx context.Context, name string) error

func (*Adapter) ExecuteRawQuery

func (a *Adapter) ExecuteRawQuery(ctx context.Context, query string) (*packet.DataPacket, error)

ExecuteRawQuery loads a pipeline source query. NUMBER columns are selected as decimal text in the outer query so the driver cannot round them to float64.

func (*Adapter) ExportTable

func (a *Adapter) ExportTable(ctx context.Context, table string) ([]*packet.DataPacket, error)

func (*Adapter) ExportTableIncremental

func (a *Adapter) ExportTableIncremental(ctx context.Context, table string, cfg adapters.IncrementalConfig) ([]*packet.DataPacket, string, error)

func (*Adapter) ExportTableWithQuery

func (a *Adapter) ExportTableWithQuery(ctx context.Context, table string, query *packet.Query, sender, recipient string) ([]*packet.DataPacket, error)

func (*Adapter) GetDatabaseType

func (a *Adapter) GetDatabaseType() string

func (*Adapter) GetDatabaseVersion

func (a *Adapter) GetDatabaseVersion(ctx context.Context) (string, error)

func (*Adapter) GetRowCount

func (a *Adapter) GetRowCount(ctx context.Context, name string) (int64, error)

func (*Adapter) GetTableNames

func (a *Adapter) GetTableNames(ctx context.Context) ([]string, error)

func (*Adapter) GetTableSchema

func (a *Adapter) GetTableSchema(ctx context.Context, name string) (packet.Schema, error)

func (*Adapter) GetViewNames

func (a *Adapter) GetViewNames(ctx context.Context) ([]adapters.ViewInfo, error)

func (*Adapter) ImportPacket

func (a *Adapter) ImportPacket(ctx context.Context, pkt *packet.DataPacket, strategy adapters.ImportStrategy) error

func (*Adapter) ImportPackets

func (a *Adapter) ImportPackets(ctx context.Context, packets []*packet.DataPacket, strategy adapters.ImportStrategy) error

Oracle DDL commits implicitly. Create a missing table before the DML transaction, then keep all rows of all packets in one real *sql.Tx.

func (*Adapter) InspectTable

func (a *Adapter) InspectTable(ctx context.Context, name string) (*adapters.TableReport, error)

func (*Adapter) ParseFailures

func (a *Adapter) ParseFailures() []base.ParseFailure

ParseFailures implements base.ParseFailureReporter: values this adapter's exports could not convert to their declared type, since the previous call.

func (*Adapter) Ping

func (a *Adapter) Ping(ctx context.Context) error

func (*Adapter) ReadAllRows

func (a *Adapter) ReadAllRows(ctx context.Context, name string, schema packet.Schema) ([][]string, error)

func (*Adapter) ReadRowsWithSQL

func (a *Adapter) ReadRowsWithSQL(ctx context.Context, query string, schema packet.Schema) ([][]string, error)

func (*Adapter) RenameTable

func (a *Adapter) RenameTable(ctx context.Context, oldName, newName string) error

func (*Adapter) SetColumnarLayout

func (a *Adapter) SetColumnarLayout(on bool)

func (*Adapter) SetMaxFallbackRows

func (a *Adapter) SetMaxFallbackRows(n int64)

func (*Adapter) SetMaxMessageSize

func (a *Adapter) SetMaxMessageSize(n int)

func (*Adapter) SetSkipSpecialValues

func (a *Adapter) SetSkipSpecialValues(on bool)

func (*Adapter) TableExists

func (a *Adapter) TableExists(ctx context.Context, name string) (bool, error)

Jump to

Keyboard shortcuts

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