💾 Archived View for godocs.io › github.com › nakagami › firebirdsql captured on 2024-12-17 at 17:08:32. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-08-19)
-=-=-=-=-=-=-
import "github.com/nakagami/firebirdsql"
Package firebird provides database/sql driver for Firebird RDBMS.
const ( ISC_TIME_SECONDS_PRECISION = 10000 // Protocol Version PROTOCOL_VERSION13 = 13 PROTOCOL_VERSION16 = 16 CNCT_user = 1 CNCT_passwd = 2 CNCT_host = 4 CNCT_group = 5 CNCT_user_verification = 6 CNCT_specific_data = 7 CNCT_plugin_name = 8 CNCT_login = 9 CNCT_plugin_list = 10 CNCT_client_crypt = 11 )
const ( ISOLATION_LEVEL_READ_COMMITED_LEGACY = iota ISOLATION_LEVEL_READ_COMMITED ISOLATION_LEVEL_REPEATABLE_READ ISOLATION_LEVEL_SERIALIZABLE ISOLATION_LEVEL_READ_COMMITED_RO )
const ( SRP_KEY_SIZE = 128 SRP_SALT_SIZE = 32 DEBUG_PRIVATE_KEY = "60975527035CF2AD1989806F0407210BC81EDC04E2762A56AFD529DDDA2D4393" DEBUG_SRP = false )
const ( SessionStopped = iota SessionRunning SessionPaused )
const ( PLUGIN_LIST = "Srp256,Srp,Legacy_Auth" BUFFER_LEN = 1024 MAX_CHAR_LENGTH = 32767 BLOB_SEGMENT_SIZE = 32000 )
const ( SQL_TYPE_TEXT = 452 SQL_TYPE_VARYING = 448 SQL_TYPE_SHORT = 500 SQL_TYPE_LONG = 496 SQL_TYPE_FLOAT = 482 SQL_TYPE_DOUBLE = 480 SQL_TYPE_D_FLOAT = 530 SQL_TYPE_TIMESTAMP = 510 SQL_TYPE_BLOB = 520 SQL_TYPE_ARRAY = 540 SQL_TYPE_QUAD = 550 SQL_TYPE_TIME = 560 SQL_TYPE_DATE = 570 SQL_TYPE_INT64 = 580 SQL_TYPE_INT128 = 32752 SQL_TYPE_TIMESTAMP_TZ = 32754 SQL_TYPE_TIME_TZ = 32756 SQL_TYPE_DEC_FIXED = 32758 SQL_TYPE_DEC64 = 32760 SQL_TYPE_DEC128 = 32762 SQL_TYPE_BOOLEAN = 32764 SQL_TYPE_NULL = 32766 )
const ( EPB_version1 = 1 )
Event
var ( ErrAlreadySubscribe = errors.New("already subscribe") ErrFbEventClosed = errors.New("fbevent already closed") )
Errors
var ( ErrEventAlreadyRunning = errors.New("events are already running") ErrEventNeed = errors.New("at least one event is needed") ErrWrongLengthEvent = errors.New("length name events are longer than 255") ErrEventBufferLarge = errors.New("whole events buffer is bigger than 65535") )
var ErrDsnUserUnknown = errors.New("User unknown")
var ErrOpSqlResponse = errors.New("Error op_sql_response")
var FirebirdVersionPattern = regexp.MustCompile(`((\w{2})-(\w)(\d+)\.(\d+)\.(\d+)\.(\d+)(?:-\S+)?) (.+)`)
func GetServiceInfoSPBPreamble() []byte
func NewErrOpResonse(opRCode int32) error
Error interface implementation
type BackupManager struct { // contains filtered or unexported fields }
func NewBackupManager(addr string, user string, password string, options ServiceManagerOptions) (*BackupManager, error)
func (bm *BackupManager) Backup(database string, backup string, options BackupOptions, verbose chan string) error
func (bm *BackupManager) Restore(backup string, database string, options RestoreOptions, verbose chan string) error
type BackupOption func(*BackupOptions)
func WithConvertExternalTablesToInternalTables() BackupOption
func WithExpand() BackupOption
func WithGarbageCollect() BackupOption
func WithIgnoreChecksums() BackupOption
func WithIgnoreLimboTransactions() BackupOption
func WithMetadataOnly() BackupOption
func WithTransportable() BackupOption
func WithoutConvertExternalTablesToInternalTables() BackupOption
func WithoutExpand() BackupOption
func WithoutGarbageCollect() BackupOption
func WithoutIgnoreChecksums() BackupOption
func WithoutIgnoreLimboTransactions() BackupOption
func WithoutMetadataOnly() BackupOption
func WithoutTransportable() BackupOption
type BackupOptions struct { IgnoreChecksums bool IgnoreLimboTransactions bool MetadataOnly bool GarbageCollect bool Transportable bool ConvertExternalTablesToInternalTables bool Expand bool }
func GetDefaultBackupOptions() BackupOptions
func NewBackupOptions(opts ...BackupOption) BackupOptions
type ErrOpResponse struct { // contains filtered or unexported fields }
ErrOpResponse operation request error
func (e *ErrOpResponse) Error() string
type Event struct { Name string Count int ID int32 RemoteID int32 }
Event stores event data: the amount since the last time the event was received and id
type EventHandler func(e Event)
EventHandler callback function type
type FbEvent struct { // contains filtered or unexported fields }
FbEvent allows you to subscribe to events, also stores subscribers. It is possible to send events to the database.
func NewFBEvent(dsns string) (*FbEvent, error)
NewFBEvent returns FbEvent for event subscription
func (e *FbEvent) Close() error
Close closes FbEvent and all subscribers
func (e *FbEvent) Count() int
Count returns the number of subscribers
func (e *FbEvent) IsClosed() bool
IsClosed returns a close flag
func (e *FbEvent) PostEvent(name string) error
PostEvent posts an event to the database
func (e *FbEvent) Subscribe(events []string, cb EventHandler) (*Subscription, error)
Subscribe subscribe to events using the callback function
func (e *FbEvent) SubscribeChan(events []string, chEvent chan Event) (*Subscription, error)
SubscribeChan subscribe to events using the channel
func (e *FbEvent) Subscribers() []*Subscription
Subscribers returns slice of all subscribers
type FirebirdVersion struct { Platform string Type string Full string Major int Minor int Patch int BuildNumber int Raw string }
func ParseFirebirdVersion(rawVersionString string) FirebirdVersion
func (v FirebirdVersion) EqualOrGreater(major int, minor int) bool
func (v FirebirdVersion) EqualOrGreaterPatch(major int, minor int, patch int) bool
type MaintenanceManager struct { // contains filtered or unexported fields }
func NewMaintenanceManager(addr string, user string, password string, options ServiceManagerOptions) (*MaintenanceManager, error)
func (mm *MaintenanceManager) ActivateShadow(shadow string) error
func (mm *MaintenanceManager) CommitTransaction(database string, transaction int64) error
func (mm *MaintenanceManager) GetLimboTransactions(database string) ([]int64, error)
func (mm *MaintenanceManager) KillShadow(database string) error
func (mm *MaintenanceManager) Mend(database string) error
func (mm *MaintenanceManager) NoLinger(database string) error
func (mm *MaintenanceManager) Online(database string) error
func (mm *MaintenanceManager) OnlineEx(database string, operationMode OperationMode) error
func (mm *MaintenanceManager) RollbackTransaction(database string, transaction int64) error
func (mm *MaintenanceManager) SetAccessModeReadOnly(database string) error
func (mm *MaintenanceManager) SetAccessModeReadWrite(database string) error
func (mm *MaintenanceManager) SetDialect(database string, dialect int) error
func (mm *MaintenanceManager) SetPageBuffers(database string, pageCount int) error
func (mm *MaintenanceManager) SetPageFillNoReserve(database string) error
func (mm *MaintenanceManager) SetPageFillReserve(database string) error
func (mm *MaintenanceManager) SetSweepInterval(database string, transactions uint) error
func (mm *MaintenanceManager) SetWriteModeAsync(database string) error
func (mm *MaintenanceManager) SetWriteModeSync(database string) error
func (mm *MaintenanceManager) Shutdown(database string, shutdownMode ShutdownMode, timeout uint) error
func (mm *MaintenanceManager) ShutdownEx(database string, operationMode OperationMode, shutdownModeEx ShutdownModeEx, timeout uint) error
func (mm *MaintenanceManager) Sweep(database string) error
func (mm *MaintenanceManager) Validate(database string, options int) error
type NBackupManager struct { // contains filtered or unexported fields }
func NewNBackupManager(addr string, user string, password string, options ServiceManagerOptions) (*NBackupManager, error)
func (bm *NBackupManager) Backup(database string, backup string, options NBackupOptions, verbose chan string) error
func (bm *NBackupManager) Fixup(database string, options NBackupOptions, verbose chan string) error
func (bm *NBackupManager) Restore(backups []string, database string, options NBackupOptions, verbose chan string) error
type NBackupOption func(*NBackupOptions)
func WithDBTriggers() NBackupOption
func WithGuid(guid string) NBackupOption
func WithInPlaceRestore() NBackupOption
func WithLevel(level int) NBackupOption
func WithPlaceRestore() NBackupOption
func WithPreserveSequence() NBackupOption
func WithoutDBTriggers() NBackupOption
func WithoutPreserveSequence() NBackupOption
type NBackupOptions struct { Level int32 Guid string NoDBTriggers bool InPlaceRestore bool PreserveSequence bool }
func GetDefaultNBackupOptions() NBackupOptions
func NewNBackupOptions(opts ...NBackupOption) NBackupOptions
func (o NBackupOptions) GetOptionsMask() int32
type OperationMode byte
const ( OperationModeNormal OperationMode = isc_spb_prp_sm_normal OperationModeMulti OperationMode = isc_spb_prp_sm_multi OperationModeSingle OperationMode = isc_spb_prp_sm_single OperationModeFull OperationMode = isc_spb_prp_sm_full )
type RestoreOption func(*RestoreOptions)
func WithCacheBuffers(cacheBuffers int32) RestoreOption
func WithCommitAfterEachTable() RestoreOption
func WithDeactivateIndexes() RestoreOption
func WithEnforceConstraints() RestoreOption
func WithPageSize(pageSize int32) RestoreOption
func WithReplace() RestoreOption
func WithRestoreShadows() RestoreOption
func WithUseAllPageSpace() RestoreOption
func WithoutCommitAfterEachTable() RestoreOption
func WithoutEnforceConstraints() RestoreOption
func WithoutReplace() RestoreOption
func WithoutRestoreShadows() RestoreOption
func WithoutUseAllPageSpace() RestoreOption
type RestoreOptions struct { Replace bool DeactivateIndexes bool RestoreShadows bool EnforceConstraints bool CommitAfterEachTable bool UseAllPageSpace bool PageSize int32 CacheBuffers int32 }
func GetDefaultRestoreOptions() RestoreOptions
func NewRestoreOptions(opts ...RestoreOption) RestoreOptions
type ServiceManager struct { // contains filtered or unexported fields }
func NewServiceManager(addr string, user string, password string, options ServiceManagerOptions) (*ServiceManager, error)
func (svc *ServiceManager) Close() (err error)
func (svc *ServiceManager) GetArchitecture() (string, error)
func (svc *ServiceManager) GetDbStats(database string, options StatisticsOptions, result chan string) error
func (svc *ServiceManager) GetDbStatsString(database string, options StatisticsOptions) (string, error)
func (svc *ServiceManager) GetFbLog(result chan string) error
func (svc *ServiceManager) GetFbLogString() (string, error)
func (svc *ServiceManager) GetHomeDir() (string, error)
func (svc *ServiceManager) GetLockFileDir() (string, error)
func (svc *ServiceManager) GetMsgFileDir() (string, error)
func (svc *ServiceManager) GetSecurityDatabasePath() (string, error)
func (svc *ServiceManager) GetServerVersion() (FirebirdVersion, error)
func (svc *ServiceManager) GetServerVersionString() (string, error)
func (svc *ServiceManager) GetServiceInfo(spb []byte, srb []byte, bufferLength int32) ([]byte, error)
func (svc *ServiceManager) GetServiceInfoInt(item byte) (int16, error)
func (svc *ServiceManager) GetServiceInfoString(item byte) (string, error)
func (svc *ServiceManager) GetString() (result string, end bool, err error)
func (svc *ServiceManager) GetSvrDbInfo() (*SrvDbInfo, error)
func (svc *ServiceManager) IsRunning() (bool, error)
func (svc *ServiceManager) ServiceAttach(spb []byte, verbose chan string) error
func (svc *ServiceManager) ServiceAttachBuffer(spb []byte, verbose chan []byte) error
func (svc *ServiceManager) ServiceStart(spb []byte) error
func (svc *ServiceManager) Wait() error
func (svc *ServiceManager) WaitBuffer(stream chan []byte) error
func (svc *ServiceManager) WaitString() (string, error)
func (svc *ServiceManager) WaitStrings(result chan string) error
type ServiceManagerOption func(*ServiceManagerOptions)
func WithAuthPlugin(authPlugin string) ServiceManagerOption
func WithWireCrypt() ServiceManagerOption
func WithoutWireCrypt() ServiceManagerOption
type ServiceManagerOptions struct { WireCrypt bool AuthPlugin string }
func GetDefaultServiceManagerOptions() ServiceManagerOptions
func NewServiceManagerOptions(opts ...ServiceManagerOption) ServiceManagerOptions
func (sm ServiceManagerOptions) WithAuthPlugin(authPlugin string) ServiceManagerOptions
func (sm ServiceManagerOptions) WithWireCrypt() ServiceManagerOptions
func (sm ServiceManagerOptions) WithoutWireCrypt() ServiceManagerOptions
type ShutdownMode byte
const ( //ShutdownModeForce Wait for N seconds then shutdown ShutdownModeForce ShutdownMode = isc_spb_prp_shutdown_db //ShutdownModeDenyNewAttachments Disable new attachments for N seconds then shutdown ShutdownModeDenyNewAttachments ShutdownMode = isc_spb_prp_deny_new_attachments //ShutdownModeDenyNewTransactions Disable new transactions for N seconds then shutdown ShutdownModeDenyNewTransactions ShutdownMode = isc_spb_prp_deny_new_transactions )
type ShutdownModeEx byte
const ( //ShutdownModeExForce Wait for N seconds then shutdown ShutdownModeExForce ShutdownModeEx = isc_spb_prp_force_shutdown //ShutdownModeExDenyNewAttachments Disable new attachments for N seconds then shutdown ShutdownModeExDenyNewAttachments ShutdownModeEx = isc_spb_prp_attachments_shutdown //ShutdownModeExDenyNewTransactions Disable new transactions for N seconds then shutdown ShutdownModeExDenyNewTransactions ShutdownModeEx = isc_spb_prp_transactions_shutdown )
type SrvDbInfo struct { AttachmentsCount int DatabaseCount int Databases []string }
type StatisticsOption func(*StatisticsOptions)
func WithOnlyHeaderPages() StatisticsOption
func WithRecordVersions() StatisticsOption
func WithSystemRelationsAndIndexes() StatisticsOption
func WithTables(tables []string) StatisticsOption
func WithUserDataPages() StatisticsOption
func WithUserIndexPages() StatisticsOption
func WithoutIndexPages() StatisticsOption
func WithoutOnlyHeaderPages() StatisticsOption
func WithoutRecordVersions() StatisticsOption
func WithoutSystemRelationsAndIndexes() StatisticsOption
func WithoutUserDataPages() StatisticsOption
type StatisticsOptions struct { UserDataPages bool UserIndexPages bool OnlyHeaderPages bool SystemRelationsAndIndexes bool RecordVersions bool Tables []string }
func GetDefaultStatisticsOptions() StatisticsOptions
func NewStatisticsOptions(opts ...StatisticsOption) StatisticsOptions
type Subscription struct { // contains filtered or unexported fields }
func (s *Subscription) Close() error
func (s *Subscription) IsClose() bool
func (s *Subscription) NotifyClose(receiver chan error)
func (s *Subscription) Unsubscribe() error
type TraceManager struct { // contains filtered or unexported fields }
func NewTraceManager(addr string, user string, password string, options ServiceManagerOptions) (*TraceManager, error)
func (t *TraceManager) List() (string, error)
func (t *TraceManager) Start(config string) (*TraceSession, error)
func (t *TraceManager) StartWithName(name string, config string) (*TraceSession, error)
type TraceSession struct { // contains filtered or unexported fields }
func (ts *TraceSession) Close() (err error)
func (ts *TraceSession) Pause() (err error)
func (ts *TraceSession) Resume() (err error)
func (ts *TraceSession) Stop() (err error)
func (ts *TraceSession) Wait() (err error)
func (ts *TraceSession) WaitStrings(result chan string) (err error)
type User struct { Username *string Password *string FirstName *string MiddleName *string LastName *string UserId int32 GroupId int32 Admin *bool }
func NewUser(opts ...UserOption) User
func (u *User) GetSpb() []byte
type UserManager struct { // contains filtered or unexported fields }
func NewUserManager(addr string, user string, password string, smo ServiceManagerOptions, umo UserManagerOptions) (*UserManager, error)
func (um *UserManager) AddUser(user User) error
func (um *UserManager) Close() error
func (um *UserManager) DeleteUser(user User) error
func (um *UserManager) DropAdminRoleMapping() error
func (um *UserManager) GetUsers() ([]User, error)
func (um *UserManager) ModifyUser(user User) error
func (um *UserManager) SetAdminRoleMapping() error
type UserManagerOption func(*UserManagerOptions)
func WithSecurityDB(securityDB string) UserManagerOption
type UserManagerOptions struct { SecurityDB string }
func GetDefaultUserManagerOptions() UserManagerOptions
func NewUserManagerOptions(opts ...UserManagerOption) UserManagerOptions
type UserOption func(*User)
func WithAdmin() UserOption
func WithFirstName(firstname string) UserOption
func WithGroupId(groupId int32) UserOption
func WithLastName(lastname string) UserOption
func WithMiddleName(middlename string) UserOption
func WithPassword(password string) UserOption
func WithUserId(userId int32) UserOption
func WithUsername(username string) UserOption
func WithoutAdmin() UserOption
type XPBReader struct { // contains filtered or unexported fields }
func NewXPBReader(buf []byte) *XPBReader
func (pb *XPBReader) End() bool
func (pb *XPBReader) Get() byte
func (pb *XPBReader) GetInt16() int16
func (pb *XPBReader) GetInt32() int32
func (pb *XPBReader) GetInt64() int64
func (pb *XPBReader) GetString() string
func (pb *XPBReader) Next() (have bool, value byte)
func (pb *XPBReader) Reset()
func (pb *XPBReader) Skip(count int)
type XPBWriter struct { // contains filtered or unexported fields }
func NewXPBWriter() *XPBWriter
func NewXPBWriterFromBytes(bytes []byte) *XPBWriter
func NewXPBWriterFromTag(tag byte) *XPBWriter
func (pb *XPBWriter) Bytes() []byte
func (pb *XPBWriter) PutByte(tag byte, val byte) *XPBWriter
func (pb *XPBWriter) PutBytes(bytes []byte) *XPBWriter
func (pb *XPBWriter) PutInt16(tag byte, val int16) *XPBWriter
func (pb *XPBWriter) PutInt32(tag byte, val int32) *XPBWriter
func (pb *XPBWriter) PutInt64(tag byte, val int64) *XPBWriter
func (pb *XPBWriter) PutString(tag byte, val string) *XPBWriter
func (pb *XPBWriter) PutTag(tag byte) *XPBWriter
func (pb *XPBWriter) Reset() *XPBWriter