Documentation
¶
Index ¶
- Constants
- Variables
- func AppendLLCP(dst []byte, codePoint uint16, payload []byte) []byte
- func DecodeEBCDIC37(data []byte) (string, error)
- func DecodeUTF16BE(data []byte) (string, error)
- func EncodeEBCDIC37(text string) ([]byte, error)
- func EncodeEBCDIC37BlankPad(text string, size int) ([]byte, error)
- func EncodeUTF16BE(text string) []byte
- func EncodeUTF16BEBlankPad(text string, size int) []byte
- func EncodeUTF16BEString(text string) []byte
- func ParseLLCP(data []byte) (codePoint uint16, payload []byte, rest []byte, err error)
- func ResolvePort(ctx context.Context, host, service string) (int, error)
- type BindingError
- type Config
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)
- func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *Conn) CheckNamedValue(value *driver.NamedValue) error
- func (c *Conn) ClearWarnings()
- func (c *Conn) ClientInfo(name string) string
- func (c *Conn) Close() error
- func (c *Conn) ExecBatch(ctx context.Context, query string, rows [][]driver.Value) (int64, error)
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *Conn) IsValid() bool
- func (c *Conn) Ping(ctx context.Context) error
- func (c *Conn) Prepare(query string) (driver.Stmt, error)
- func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (c *Conn) ResetSession(ctx context.Context) error
- func (c *Conn) SetClientInfo(ctx context.Context, name, value string) error
- func (c *Conn) Warnings() *SQLWarning
- type Connector
- type Driver
- type Header
- type NamingConvention
- type NullTimestamp
- type ProtocolError
- type SQLError
- type SQLWarning
- type ScrollableRows
- type Stmt
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)
- func (s *Stmt) ExecBatch(ctx context.Context, rows [][]driver.Value) (int64, error)
- func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Stmt) NumInput() int
- func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)
- func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type SystemInfo
- type Timestamp
- type TransportError
- type Tx
- type WireError
Constants ¶
const ( PortMapperPort = 449 DatabasePort = 8471 SecureDatabasePort = 9471 DatabaseServiceName = "as-database" DatabaseServiceSecureName = "as-database-s" SignonPort = 8476 SecureSignonPort = 9476 SignonServiceName = "as-signon" SignonServiceSecureName = "as-signon-s" DatabaseServerID = 0xE004 NativeDatabaseServerID = 0xE005 SignonServerID = 0xE009 HostConnServerID = 0xE00B RequestExchangeRandomSeeds = 0x7001 RequestStartServer = 0x7002 RequestExchangeAttributes = 0x7003 RequestSignonInfo = 0x7004 ReplyExchangeRandomSeeds = 0xF001 ReplyStartServer = 0xF002 ReplyExchangeAttributes = 0xF003 ReplySignonInfo = 0xF004 FunctionPrepare = 0x1800 FunctionDescribe = 0x1801 FunctionDescribeParmMarker = 0x1802 FunctionPrepareDescribe = 0x1803 FunctionOpenDescribe = 0x1804 FunctionExecute = 0x1805 FunctionExecuteImmediate = 0x1806 FunctionCommit = 0x1807 FunctionRollback = 0x1808 FunctionConnect = 0x1809 FunctionClose = 0x180A FunctionFetch = 0x180B FunctionStreamFetch = 0x180C FunctionAddLibraryList = 0x180C FunctionPrepareExecute = 0x180D FunctionOpenDescribeFetch = 0x180E FunctionCreatePackage = 0x180F FunctionClearPackage = 0x1810 FunctionDeletePackage = 0x1811 FunctionExecuteOpenDescribe = 0x1812 FunctionEndStreamFetch = 0x1813 FunctionCreateRPB = 0x1D00 FunctionChangeRPB = 0x1D03 FunctionDeleteRPB = 0x1D02 FunctionChangeDescriptor = 0x1E00 FunctionDeleteDescriptor = 0x1E01 FunctionReturnPackage = 0x1815 FunctionRetrieveLobData = 0x1816 FunctionWriteLobData = 0x1817 FunctionCancel = 0x1818 FunctionFreeLob = 0x1819 FunctionTestConnection = 0x0000 FunctionEndJob = 0x1FFF FunctionSetAttributes = 0x1F80 FunctionRetrieveAttributes = 0x1F81 HeaderSize = 20 TemplateSize = 20 CodePointClientVersion = 0x1101 CodePointClientDSLevel = 0x1102 CodePointClientSeed = 0x1103 CodePointUserID = 0x1104 CodePointPassword = 0x1105 CodePointCurrentSignonDate = 0x1106 CodePointLastSignonDate = 0x1107 CodePointPasswordExpireDate = 0x1108 CodePointServerCCSID = 0x1114 CodePointPasswordLevel = 0x1119 CodePointJobName = 0x111F CodePointReturnErrorMessages = 0x1128 CodePointPasswordWarning = 0x112C CodePointAdditionalAuthFactor = 0x112F CodePointVerificationID = 0x1130 CodePointClientIPAddress = 0x1131 CodePointClientCCSID = 0x1113 CodePointNamingConvention = 0x380C CodePointDefaultSQLLibrary = 0x380F CodePointJobIdentifier = 0x3826 CodePointCommitmentControlLevel = 0x380E CodePointDateFormat = 0x3807 CodePointDateSeparator = 0x3808 CodePointTimeFormat = 0x3809 CodePointTimeSeparator = 0x380A CodePointDecimalSeparator = 0x380B CodePointClientFunctionalLevel = 0x3803 CodePointLanguageFeatureCode = 0x3802 CodePointTranslateIndicator = 0x00F0 CodePointUseExtendedFormats = 0x00F1 CodePointUseSuperExtendedFormats = 0x00F2 CodePointTrueAutoCommitIndicator = 0x3824 CodePointLOBFieldThreshold = 0x3822 CodePointDecimalPrecision = 0x3827 CodePointQueryOptimizeGoal = 0x3833 CodePointDecfloatRoundingMode = 0x3835 CodePointCloseOnEOF = 0x383F CodePointMessageID = 0x3801 CodePointFirstLevelMessageText = 0x3802 CodePointSecondLevelMessageText = 0x3803 CodePointServerAttributes = 0x3804 CodePointDataFormat = 0x3805 CodePointResultData = 0x3806 CodePointSQLCA = 0x3807 CodePointParameterMarkerFormat = 0x3808 CodePointPackageInfo = 0x380B CodePointExtendedDataFormat = 0x380C CodePointExtendedParameterMarker = 0x380D CodePointExtendedResultData = 0x380E CodePointLOBLocatorData = 0x380F CodePointCurrentLOBLength = 0x3810 CodePointExtendedColumnDescriptors = 0x3811 CodePointSuperExtendedDataFormat = 0x3812 CodePointSuperExtendedParameterMarker = 0x3813 CodePointCursorAttributes = 0x3814 CodePointAlternateServer = 0x3846 CodePointVariableResultData = 0x3901 CodePointXIDData = 0x38A1 CodePointStatementText = 0x3807 CodePointPrepareStatementName = 0x3806 CodePointPackageName = 0x3804 CodePointPrepareOption = 0x3808 CodePointOpenAttributes = 0x3809 CodePointDescribeOption = 0x380A CodePointCursorName = 0x380B CodePointBlockingFactor = 0x380C CodePointScrollableCursorFlag = 0x380D CodePointFetchScrollOption = 0x380E CodePointHoldIndicator = 0x380F CodePointReuseIndicator = 0x3810 CodePointParameterMarkerData = 0x3811 CodePointStatementType = 0x3812 CodePointParameterMarkerBlockInd = 0x3814 CodePointReturnSize = 0x3815 CodePointLOBLocatorHandle = 0x3818 CodePointRequestedSize = 0x3819 CodePointStartOffset = 0x381A CodePointCompressionIndicator = 0x381B CodePointParameterMarkerDataExt = 0x381F CodePointColumnIndex = 0x3828 CodePointExtendedColumnDescOption = 0x3829 CodePointResultSetHoldability = 0x3830 CodePointExtendedStatementText = 0x3831 CodePointVariableFieldCompression = 0x3833 CodePointListOfLibraries = 0x3813 )
const ( // CodePointPackageLibrary is the library code point (0x3801) used on // CREATE_PACKAGE, the RPB request and nothing else. CodePointPackageLibrary = 0x3801 )
Variables ¶
var ( ErrInvalidDSN = errors.New("as400 driver: invalid DSN") ErrUnsupported = errors.New("as400 driver: unsupported operation") ErrConnection = errors.New("as400 driver: connection error") ErrConnectionClosed = errors.New("as400 driver: connection is closed") ErrAuthentication = errors.New("as400 driver: authentication failed") // SQLSTATE class sentinels – use with errors.Is to check the error class // of a *SQLError without coupling to a specific error code or message. // // var sqlErr *as400.SQLError // if errors.Is(err, as400.ErrSQLNoData) { /* SQLSTATE 02xxx */ } // if errors.As(err, &sqlErr) { /* access sqlErr.Code, .State, .Message */ } ErrSQLNoData = errors.New("as400: no data (SQLSTATE 02xxx)") ErrSQLDataException = errors.New("as400: data exception (SQLSTATE 22xxx)") ErrSQLConstraintViolation = errors.New("as400: constraint violation (SQLSTATE 23xxx)") ErrSQLInvalidCursor = errors.New("as400: invalid cursor state (SQLSTATE 24xxx/25xxx)") ErrSQLSyntaxError = errors.New("as400: syntax error or access violation (SQLSTATE 42xxx)") )
var ErrUnknownClientInfo = errors.New("as400 driver: unknown client info name")
ErrUnknownClientInfo is returned by SetClientInfo for a name that is not one of the client info keys (JTOpen raises SQLClientInfoException).
Functions ¶
func DecodeEBCDIC37 ¶
func DecodeUTF16BE ¶
func EncodeEBCDIC37 ¶
func EncodeUTF16BE ¶
func EncodeUTF16BEBlankPad ¶
func EncodeUTF16BEString ¶
Types ¶
type BindingError ¶
BindingError describes a value that cannot be bound to a prepared parameter.
func (*BindingError) Error ¶
func (e *BindingError) Error() string
func (*BindingError) Unwrap ¶
func (e *BindingError) Unwrap() error
type Config ¶
type Config struct {
DSN string
Host string
Port int
UseTLS bool
User string
Password string
Schema string
Naming NamingConvention
DateFormat int
DateSeparator int
TimeFormat int
TimeSeparator int
DecimalSeparator int
CommitmentControl int
Libraries []string
RawQuery url.Values
ConnectTimeout time.Duration
StatementCacheSize int
ScrollableCursors bool
HoldCursors bool
// QueryOptimizeGoal: 0 = server default (not sent), 1 = *FIRSTIO, 2 = *ALLIO.
QueryOptimizeGoal int
// DecimalMaxPrecision is 31 or 63.
DecimalMaxPrecision int
// DecimalMaxScale is 0-63.
DecimalMaxScale int
// MinimumDivideScale is 0-9.
MinimumDivideScale int
// LOBThreshold is the inline LOB threshold in bytes, 0-15728640.
LOBThreshold int
// BlockSize is the fetch block size in KB (JTOpen "block size").
BlockSize int
// TrueAutocommit makes autocommit keep the configured commitment control level.
TrueAutocommit bool
// UseBlockUpdate is JTOpen's "use block update". When true, ExecBatch sends
// eligible rows as parameter blocks. Default false.
UseBlockUpdate bool
// ReturnGeneratedKeys wraps INSERT statements run through ExecContext as
// SELECT *SQLGENCOLUMNS FROM NEW TABLE(...) to read the generated key (V6R1+).
ReturnGeneratedKeys bool
// DecfloatRoundingMode: 0 half-even, 1 half-up, 2 down, 3 ceiling, 4 floor, 5 half-down, 6 up.
DecfloatRoundingMode int
// ExtendedDynamic enables JTOpen-style extended dynamic support (SQL packages).
ExtendedDynamic bool
// Package is the user package name; it is normalized to 6 characters plus a 4-character suffix.
Package string
// PackageLibrary is the library that holds the package. Empty means QGPL.
PackageLibrary string
// PackageCriteria is "default" or "select". Empty means "default".
PackageCriteria string
// PackageAddDisabled turns off the "package add" server attribute (default allow).
PackageAddDisabled bool
// PackageError is "none", "warning" or "exception". Empty means "warning".
PackageError string
// PackageCCSID is the statement-text CCSID for packages. Zero means 13488.
PackageCCSID int
// PackageCCSIDSystem is set when packageCCSID=system was requested.
PackageCCSIDSystem bool
// PackageCache enables the client-side package cache: an existing package is
// downloaded with RETURN_PACKAGE and matching packaged statements skip prepare.
PackageCache bool
// PackageClear is JTOpen's "package clear" option. It is parsed for
// compatibility and has no effect: JTOpen stopped sending the clearing
// threshold, and the server clears full packages on its own.
PackageClear bool
// ApplicationName, ClientUser, ClientAccounting, ClientHostname and
// ClientProgramID are JTOpen client info values. Empty means not set.
ApplicationName string
ClientUser string
ClientAccounting string
ClientHostname string
ClientProgramID string
// QueryStorageLimit is the query storage limit in bytes; -1 (default) is *NOMAX and is not sent.
QueryStorageLimit int
// QueryTimeoutMechanism is "cancel" (default) or "qqrytimlmt" (see clientinfo.go).
QueryTimeoutMechanism string
// KeepAlive enables (true) or disables (false) TCP keep-alive probes (JTOpen
// "keep alive"). Nil keeps the platform default.
KeepAlive *bool
// TCPNoDelay sets TCP_NODELAY (JTOpen "tcp no delay"). Nil keeps the Go default.
TCPNoDelay *bool
// ReceiveBufferSize is the socket receive buffer in bytes (JTOpen "receive
// buffer size"). Zero keeps the OS default.
ReceiveBufferSize int
// SendBufferSize is the socket send buffer in bytes (JTOpen "send buffer
// size"). Zero keeps the OS default.
SendBufferSize int
// SocketTimeout bounds each read from the server (JTOpen "socket timeout").
// Zero means no socket timeout.
SocketTimeout time.Duration
// ErrorsFull requests second-level message text with SQL errors (JTOpen
// "errors=full"). False means basic: message ID and first-level text only.
ErrorsFull bool
// TimestampString returns TIMESTAMP result columns as IBM i formatted
// strings with every fractional digit the server sent (DSN option
// timestampPrecision=string). False (nanoseconds) decodes them to time.Time.
TimestampString bool
// BidiStringType is the bidi string type of character data (DSN "bidiStringType"):
// 0, 4 to 11, or -1 when not set. Not set converts each column with the string type of
// its CCSID (JTOpen's SQLChar). The default is 5, as in JTOpen. It only applies to the
// CCSIDs that JTOpen converts with a bidi table, see IsConversionBidiCCSID.
BidiStringType int
// BidiImplicitReordering (DSN "bidiImplicitReordering") selects implicit to implicit
// reordering. The default is true.
BidiImplicitReordering bool
// BidiNumericOrdering (DSN "bidiNumericOrdering") selects the numeric ordering round trip.
// The default is false.
BidiNumericOrdering bool
TLSConfig *tls.Config
}
func (Config) DatabaseServiceName ¶
func (Config) DefaultPort ¶
func (Config) ResolveAddress ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) CheckNamedValue ¶
func (c *Conn) CheckNamedValue(value *driver.NamedValue) error
func (*Conn) ClearWarnings ¶
func (c *Conn) ClearWarnings()
func (*Conn) ClientInfo ¶
ClientInfo returns the current value of a client info key ("ApplicationName", "ClientUser", "ClientAccounting", "ClientHostname" or "ClientProgramID"). It returns "" for an unknown name.
func (*Conn) ExecBatch ¶
ExecBatch executes query once for every row in rows and returns the total number of rows affected. The statement is prepared once. Values are normalized with the same rules as CheckNamedValue. Positional placeholders are bound in order; named placeholders bind in order of appearance.
When the DSN sets useBlockUpdate=true, eligible statements are sent in blocks (see batchBlockable). Any other statement runs row by row.
func (*Conn) ExecContext ¶
func (*Conn) PrepareContext ¶
func (*Conn) QueryContext ¶
func (*Conn) SetClientInfo ¶
SetClientInfo sets a client info key on the server for this connection, as JTOpen's setClientInfo does. It is usable through sql.Conn.Raw. Below V6R1 the value is kept on the client only. An unknown name returns ErrUnknownClientInfo.
func (*Conn) Warnings ¶
func (c *Conn) Warnings() *SQLWarning
type Header ¶
type Header struct {
Length uint32
HeaderID uint16
ServerID uint16
CSInstance uint32
CorrelationID uint32
TemplateLength uint16
ReqRepID uint16
}
func ParseHeader ¶
func (Header) MarshalBinary ¶
type NamingConvention ¶
type NamingConvention string
const ( NamingSQL NamingConvention = "sql" NamingSystem NamingConvention = "system" )
type NullTimestamp ¶
NullTimestamp is a Timestamp that may be NULL, like sql.NullTime.
func (*NullTimestamp) Scan ¶
func (n *NullTimestamp) Scan(value any) error
Scan implements sql.Scanner. A NULL sets Valid to false.
type ProtocolError ¶
ProtocolError describes an error returned by the IBM i host-server protocol outside the SQLCA payload.
func (*ProtocolError) Error ¶
func (e *ProtocolError) Error() string
type SQLError ¶
type SQLError struct {
Code int
State string
Message string
MessageID string
MessageText string
SecondLevelText string
Tokens string
}
SQLError is an error reported by the server in the SQLCA.
Message holds the first-level message text when the server returned one, otherwise a summary built from the SQLSTATE. MessageID (for example SQL0204), MessageText and SecondLevelText carry the server message as JTOpen exposes it; SecondLevelText is only requested when the DSN sets errors=full. Tokens holds the SQLERRMC substitution values from the SQLCA.
type SQLWarning ¶
type SQLWarning struct {
Code int32
State string
Message string
Next *SQLWarning
}
type ScrollableRows ¶
type ScrollableRows interface {
driver.Rows
BeforeFirst() error
AfterLast() error
Current() error
First() error
Last() error
Absolute(row int) error
Relative(rows int) error
Row() int
}
ScrollableRows is an optional IBM i extension. A query must be opened with scrollableCursors=true to provide a scrollable result set. Row returns the current driver-known row position and returns zero when no row is current.
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
func (*Stmt) ExecBatch ¶
ExecBatch executes the prepared statement once for every row in rows. It has the same semantics as Conn.ExecBatch but reuses the statement prepared by the Stmt.
func (*Stmt) ExecContext ¶
func (*Stmt) QueryContext ¶
type SystemInfo ¶
type Timestamp ¶
Timestamp holds an IBM i TIMESTAMP with picosecond precision. time.Time only has nanosecond resolution, so the sub-second part is carried in Picoseconds as JTOpen's SQLTimestamp does.
Time provides the date and the time to the second. Picoseconds is the full sub-second part in picoseconds, 0 through 999999999999. Scan keeps the two consistent: Time.Nanosecond() is Picoseconds/1000, truncated. When Value is called with Picoseconds set to 0 it uses Time's nanosecond part, so a Timestamp built from a plain time.Time keeps its digits.
func (*Timestamp) Scan ¶
Scan implements sql.Scanner. It accepts time.Time, and string or []byte text in the IBM i form "YYYY-MM-DD-HH.MM.SS[.f{1,12}]" or the ISO form "YYYY-MM-DD HH:MM:SS[.f{1,12}]". NULL is an error here; use NullTimestamp.
type TransportError ¶
TransportError describes a network or TLS failure while connecting or communicating.
func (*TransportError) Error ¶
func (e *TransportError) Error() string
func (*TransportError) Unwrap ¶
func (e *TransportError) Unwrap() error
Source Files
¶
- batch.go
- bidi_settings.go
- boolean.go
- call_result_sets.go
- clientinfo.go
- config.go
- datetime_format.go
- dbconn.go
- decfloat_encode.go
- driver.go
- dsn.go
- encoding.go
- encryption.go
- errors.go
- generatedkeys.go
- lob_inline.go
- numeric_param.go
- package.go
- package_cache.go
- package_ccsid.go
- portmapper.go
- protocol.go
- register.go
- reply_error.go
- signon.go
- sql.go
- sqlerror_text.go
- stmt.go
- systeminfo.go
- timestamp.go
- transport.go
- tx.go
- wire.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
bidi
Package bidi is a Go port of the Bidi layout engine of JTOpen (com.ibm.as400.access, files BidiFlag, BidiFlagSet, ArabicOption, ArabicOptionSet, BidiShape, ...).
|
Package bidi is a Go port of the Bidi layout engine of JTOpen (com.ibm.as400.access, files BidiFlag, BidiFlagSet, ArabicOption, ArabicOptionSet, BidiShape, ...). |
|
ccsid
Package ccsid converts between Go strings and IBM i CCSID encoded bytes.
|
Package ccsid converts between Go strings and IBM i CCSID encoded bytes. |