Documentation
¶
Index ¶
- Constants
- func DisableOutput(ctx context.Context, e Execer) error
- func EnableOutput(ctx context.Context, e Execer, size int) error
- func NewBatch(array driver.Value) driver.Value
- func ReadOutput(ctx context.Context, e Execer) ([]string, error)
- func RegisterType(db *sql.DB, typeName, arrayTypeName string, typeObj any) error
- func RegisterTypeWithOwner(db *sql.DB, owner, typeName, arrayTypeName string, typeObj any) error
- func WithOptions(ctx context.Context, opts ...Option) context.Context
- func WrapRefCursor(ctx context.Context, q Querier, cursor *RefCursor) (*sql.Rows, error)
- type Auth
- type BFile
- type BatchError
- type Blob
- type Bool
- type Client
- type Clob
- type Config
- type Connector
- type ConnectorOption
- type Dialer
- type Driver
- type Error
- type Execer
- type IntervalYM
- type JSON
- type Kerberos
- type LobFetch
- type LobRead
- type LobReader
- type NTS
- type NVarChar
- type Object
- type Option
- func WithBatchErrors() Option
- func WithDatabase(name string) Option
- func WithLobFetch(f LobFetch) Option
- func WithParameter(name string, value any) Option
- func WithPrefetch(rows int) Option
- func WithReadonly(readonly bool) Option
- func WithRowCounts(counts *[]int64) Option
- func WithTimeout(d time.Duration) Option
- type Out
- type Privilege
- type Querier
- type RefCursor
- type RowError
- type RowID
- type SSLMode
- type ServerError
- type ServiceLevel
- type SparseVector
- type TimestampTZ
- type Vector
Constants ¶
const ( // ErrScheme is a DSN whose scheme is not oracle. ErrScheme Error = "the scheme of the dsn is not oracle" // ErrUnknownKey is a key of a DSN that the driver does not know. ErrUnknownKey Error = "unknown key" // ErrRepeatedKey is a key that a DSN holds twice. ErrRepeatedKey Error = "repeated key" // ErrInvalidValue is a value that the driver cannot use. ErrInvalidValue = tns.ErrInvalidValue // ErrNotSupported is a feature that the driver or the server does not // have. ErrNotSupported = tns.ErrNotSupported // ErrRowsClosed is a read of a LOB of a row after its rows closed. The // connection of the rows can serve another caller by then. ErrRowsClosed = tns.ErrRowsClosed // ErrConnectorClosed is a Connect after Close. ErrConnectorClosed Error = "the connector is closed" // ErrAuthentication is a server that refused the credential. A // *ServerError with ORA-01017 matches it. ErrAuthentication = tns.ErrAuthentication // ErrCompilation is a PL/SQL unit, a view or a type that the server // created but could not compile. The statement returns a *ServerError // with ORA-24344, which matches it, and USER_ERRORS holds the errors of // the compilation (D32). ErrCompilation = tns.ErrCompilation )
The sentinel errors.
const DefaultPieceSize = types.DefaultPieceSize
DefaultPieceSize is the size in bytes of the piece that a LobReader asks the server for, unless NewReaderSize sets another.
const DefaultPort = 1521
DefaultPort is the port of an Oracle listener when the DSN names none.
Variables ¶
This section is empty.
Functions ¶
func DisableOutput ¶
DisableOutput disables DBMS_OUTPUT in the session of e, and drops the lines that it holds.
func EnableOutput ¶
EnableOutput enables DBMS_OUTPUT in the session of e, with a buffer of size bytes, or with no limit when size is 0.
func NewBatch ¶
NewBatch returns an argument that binds each element of array, a slice, as one row of an array bind, for a bulk insert.
func ReadOutput ¶
ReadOutput reads and removes the lines that DBMS_OUTPUT holds in the session of e, which EnableOutput enabled. go-ora read them through dbms.NewOutput.
func RegisterType ¶
RegisterType registers the user defined type typeName, and its collection arrayTypeName when that is not empty, for the Go type of typeObj, with the database of db alone. The owner of the type is the user of the database. It reads the attributes of the type through db, so the type must exist.
func RegisterTypeWithOwner ¶
RegisterTypeWithOwner is RegisterType for a type that owner owns.
func WithOptions ¶
WithOptions returns a context that carries opts, after the options that ctx carries. Each statement that runs with the context applies them.
Types ¶
type Auth ¶
type Auth string
Auth is how a connection proves who it is.
const ( // AuthPassword sends the user and the password. It is the default. AuthPassword Auth = "password" // AuthOS uses the user of the operating system, through NTS on Windows. AuthOS Auth = "os" // AuthKerberos uses Kerberos, through Config.Kerberos. AuthKerberos Auth = "kerberos" // AuthToken sends the token of Config.Token, signed with Config.TokenKey. AuthToken Auth = "token" )
The ways to authenticate.
type BatchError ¶
type BatchError = tns.BatchError
BatchError is the error of a batch of DML that ran with WithBatchErrors: the rows that failed, each with the index of the row from 0 and the error of the server. The other rows ran. errors.As finds the error of each row (D34).
type Client ¶
Client is what the connect packet and the logon say about the client. An empty field takes the value of this process: the path of the program, the name of the host, and the user of the operating system. The logon sends Host as the machine and User as the user of the operating system, which v$session shows, and Terminal as its terminal, which is Host when it is empty, sijms/go-ora#584.
type Config ¶
type Config struct {
User string
Password string
// Host and Port are the address of the listener. Servers are more
// addresses, as host:port, that the driver tries in order.
Host string
Port int
Servers []string
// Service is the service name, Instance the instance name, and SID the
// SID, which some old databases use in place of a service name.
Service string
Instance string
SID string
// Descriptor is a TNS descriptor, such as (DESCRIPTION=...), that names
// the addresses and the service in place of the fields above.
Descriptor string
// Alias is an alias of tnsnames.ora, whose descriptor takes the place of
// Descriptor. The file is in the folder TNSAdmin, or in the folder that
// the environment variable TNS_ADMIN names when TNSAdmin is empty (D20).
Alias string
TNSAdmin string
// SSLMode and the SSL fields say whether and how the connection uses TLS.
SSLMode SSLMode
SSLRootCert string
SSLCert string
SSLKey string
SSLServerName string
// TLS is a TLS configuration for the connection. When it is set, it takes
// the place of the SSL files, and the connector clones it for each dial.
TLS *tls.Config
// Wallet is a folder that holds cwallet.sso or ewallet.p12, and
// WalletPassword the password of ewallet.p12.
Wallet string
WalletPassword string
// Timeout is the deadline of each round trip, and ConnectTimeout the limit
// on the dial, the TLS handshake and the logon. Zero means no timeout and
// 60 seconds.
Timeout time.Duration
ConnectTimeout time.Duration
// Prefetch is the number of rows that one fetch asks for. Zero means 25.
Prefetch int
LobFetch LobFetch
LobRead LobRead
Auth Auth
Privilege Privilege
// Token and TokenKey are the files of a token and of its private key.
Token string
TokenKey string
// Encryption and Checksum are the levels of the native encryption and
// checksums of Oracle Net.
Encryption ServiceLevel
Checksum ServiceLevel
// Language, Territory and Charset are the NLS settings of the client.
Language string
Territory string
Charset string
// Program is the program name that the session reports, and ProxyUser
// the user of a proxy session.
Program string
ProxyUser string
// UnixSocket is a Unix socket to dial in place of TCP.
UnixSocket string
// Client is what the connect packet says about the client.
Client Client
// Dialer opens each network connection. Nil uses a net.Dialer.
Dialer Dialer
// Kerberos returns the ticket when Auth is AuthKerberos.
Kerberos Kerberos
// NTS makes the messages of NTS when Auth is AuthOS and the server asks
// for it. Nil uses the NTLM of the driver.
NTS NTS
// Logger receives the packets and events of each connection. Nil logs
// nothing (D14).
Logger *slog.Logger
}
Config is the configuration of one database. ParseDSN fills it from a DSN, and a caller can change it or build one, and pass it to NewConnector. The zero value of a field is its default.
func ParseDSN ¶
ParseDSN parses a DSN of the form
oracle://user:password@host:port/service/instance?key=value
The scheme must be oracle. The port is 1521 when the DSN names none. The path is the service name, and an instance name after it. A service name that holds a / is written with %2F. A key that ParseDSN does not know, and a key that appears twice, other than server, are errors. An error never holds the DSN, which can hold a password.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector opens connections to one Oracle database. It holds everything that belongs to that database: the configuration, the session parameters, the registered types and the type coders (D9). Pass it to sql.OpenDB.
func NewConnector ¶
func NewConnector(cfg Config, opts ...ConnectorOption) (*Connector, error)
NewConnector returns a Connector for cfg. It reads the files that cfg names, such as a wallet or a certificate, and it does not connect.
func (*Connector) Close ¶
Close makes each later Connect fail. sql.DB.Close calls it. It closes no connection, because database/sql closes those.
type ConnectorOption ¶
ConnectorOption changes a Connector as NewConnector makes it.
func WithSessionParam ¶
func WithSessionParam(key, value string) ConnectorOption
WithSessionParam sets the session parameter key to value, with ALTER SESSION, on each connection after its logon. The value is written as it is, so a string value needs its quotes, as in WithSessionParam("nls_date_format", "'YYYY-MM-DD'").
func WithWallet ¶
func WithWallet(r io.Reader) ConnectorOption
WithWallet reads a wallet, a cwallet.sso file, from r. It takes the place of the folder that Config.Wallet names.
type Dialer ¶
type Dialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
Dialer opens the network connection to a listener. A caller sets it to reach the server through a proxy or a tunnel.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is the oracle driver. The value that init registers holds nothing. Each Connector returns a Driver that points back at it, so that RegisterType reaches the types of one database through its *sql.DB.
type Error ¶
Error is the type of the sentinel errors of the driver. Compare an error with a sentinel with errors.Is.
type Execer ¶
type Execer interface {
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
Execer runs a statement. *sql.Conn and *sql.Tx are each one, and each holds one session, which DBMS_OUTPUT belongs to. A *sql.DB is one too, but each call can take another session from its pool, so it reads no output.
type IntervalYM ¶
type IntervalYM = types.IntervalYM
IntervalYM is an INTERVAL YEAR TO MONTH. An INTERVAL DAY TO SECOND is a time.Duration.
type JSON ¶
JSON is a JSON value of Oracle 21c and later. A JSON column scans as a jsontext.Value, and into any destination that encoding/json/v2 decodes into. NewJSON makes one to bind.
type LobRead ¶
type LobRead string
LobRead says whether the driver reads the value of a LOB locator for the caller.
type LobReader ¶
LobReader reads the value of a Clob, a Blob or a BFile in pieces, through their NewReader. A LOB of a row reads until its rows close, and a read after that fails with ErrRowsClosed (D22).
type NTS ¶
type NTS = config.NTSAuthenticator
NTS makes the NTLM messages of NTS, the Windows authentication of Oracle Net, for Config.NTS.
type NVarChar ¶
NVarChar is a string that binds as NVARCHAR2, in the national character set of the database. A string binds as VARCHAR2. A []NVarChar binds as a PL/SQL array of NVARCHAR2, and sql.Null[NVarChar] as a NULL one.
type Object ¶
Object names the user defined type of a bind, as RegisterType registered it. Most values need none, because the Go type that RegisterType names binds as its type. A collection of a basic type, such as a TABLE OF DATE, needs one, since a []time.Time binds as a PL/SQL array. Value is the value, or a pointer to the destination in an Out.
type Option ¶
Option sets one option of one statement (D109). An option comes from the DSN, then from the context through WithOptions, then from an argument of the statement, and a later one wins:
rows, err := db.QueryContext(ctx, query, oracle.WithPrefetch(1000))
func WithBatchErrors ¶
func WithBatchErrors() Option
WithBatchErrors runs a batch of DML past the rows that fail. The batch returns a *BatchError, which holds the index and the error of each row that failed, and the other rows run. A statement that is not DML fails with ErrNotSupported (D34).
func WithDatabase ¶
WithDatabase names the database of one statement. A connection of Oracle reaches one database, so a name fails the statement with ErrNotSupported.
func WithLobFetch ¶
WithLobFetch sets how a query returns a LOB, as the key lob_fetch does.
func WithParameter ¶
WithParameter sets a setting of the server by its name, for a setting that the driver has no option for. Oracle has none for one statement, so it fails the statement with ErrNotSupported. ALTER SESSION, or WithSessionParam on the connector, sets a setting of the session.
func WithPrefetch ¶
WithPrefetch sets the number of rows that one fetch asks for, as the key prefetch does.
func WithReadonly ¶
WithReadonly asks that the server refuse a write. Oracle has it for a transaction, through sql.TxOptions, and not for one statement, so true fails the statement with ErrNotSupported.
func WithRowCounts ¶
WithRowCounts fills counts with the count of the rows that each row of a batch of DML changed, or with the count of the one row of a statement that is not a batch. A statement that is not DML fails with ErrNotSupported (D34).
func WithTimeout ¶
WithTimeout ends the call of a statement after d, through the break of Oracle Net, which leaves the connection usable. Zero asks for nothing. It bounds the call that runs the statement, and not the fetches of its rows after it.
type Out ¶
Out is an OUT or IN OUT argument of a PL/SQL call. Dest receives the value, Size is the largest size in bytes that the value can have, and In sends the value of Dest too.
type Privilege ¶
type Privilege string
Privilege is an administrative privilege that a session asks for.
const ( PrivilegeSYSDBA Privilege = "sysdba" PrivilegeSYSOPER Privilege = "sysoper" PrivilegeSYSASM Privilege = "sysasm" PrivilegeSYSBACKUP Privilege = "sysbackup" PrivilegeSYSDG Privilege = "sysdg" PrivilegeSYSKM Privilege = "syskm" PrivilegeSYSRAC Privilege = "sysrac" )
The administrative privileges.
type RefCursor ¶
RefCursor is a REF CURSOR that a PL/SQL call returns. WrapRefCursor reads its rows as *sql.Rows.
type SSLMode ¶
type SSLMode string
SSLMode says whether a connection uses TLS, and what it checks. The values are the ones of the sslmode key of pgx and lib/pq (D11).
const ( // SSLDisable speaks TCP with no TLS. SSLDisable SSLMode = "disable" // SSLRequire speaks TLS and checks no certificate. SSLRequire SSLMode = "require" // SSLVerifyCA speaks TLS and checks that a known authority signed the // certificate of the server, and not its name. SSLVerifyCA SSLMode = "verify-ca" // SSLVerifyFull speaks TLS and checks the authority and the name. SSLVerifyFull SSLMode = "verify-full" )
The modes. An Oracle listener speaks TCP or TCPS on one port, never both, so the allow and prefer modes of pgx do not exist here.
type ServerError ¶
type ServerError = tns.OracleError
ServerError is an error that the server returned, with its ORA code in ErrCode. Its method AuthenticationRefused reports whether the server refused the credential, as usql asks an error, and matches errors.Is(err, ErrAuthentication).
type ServiceLevel ¶
type ServiceLevel string
ServiceLevel is how much the client wants an Oracle Net service, such as encryption or checksums. The server compares it with its own level.
const ( ServiceAccepted ServiceLevel = "accepted" ServiceRejected ServiceLevel = "rejected" ServiceRequested ServiceLevel = "requested" ServiceRequired ServiceLevel = "required" )
The service levels of Oracle Net.
type SparseVector ¶
type SparseVector = types.SparseVector
SparseVector is a sparse VECTOR: the number of its dimensions, and the indices and values of the elements that are not zero.
type TimestampTZ ¶
type TimestampTZ = types.TimestampTZ
TimestampTZ is a time that binds as TIMESTAMP WITH TIME ZONE, where a time.Time binds as TIMESTAMP. A nullable one is sql.Null[TimestampTZ].
type Vector ¶
Vector is a VECTOR of Oracle 23ai and later.
func CreateVector ¶
CreateVector returns a VECTOR that holds array: a []float32, a []float64, a []int8, a []byte of the BINARY format, which holds 8 dimensions in each byte, or a SparseVector. A VECTOR column scans into a *Vector, or into a pointer to the type of its elements.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
auth/ntlmssp
Package ntlmssp provides NTLM/Negotiate authentication over HTTP
|
Package ntlmssp provides NTLM/Negotiate authentication over HTTP |
|
auth/ntlmssp/md4
Package md4 implements the MD4 hash algorithm as defined in RFC 1320.
|
Package md4 implements the MD4 hash algorithm as defined in RFC 1320. |
|
tnstest
Package tnstest records the TNS packets that the driver and a server exchange, and plays them back to the driver with no server.
|
Package tnstest records the TNS packets that the driver and a server exchange, and plays them back to the driver with no server. |