Documentation
¶
Index ¶
- Constants
- func Free[T any](val *T)
- func FreeDatum(val Datum)
- func FromDatum[T any](d Datum) *T
- func FromDatumGoBytes(d Datum, n uint) []byte
- func FromDatumGoString(d Datum) string
- func LoadExtensions() (map[string]*ExtensionFiles, error)
- func Malloc[T any]() *T
- func PostgresDirectories() (libDir string, extensionDir string, err error)
- func ZeroMemory[T any](val *T)
- type Control
- type Datum
- type ExtensionFiles
- type FilenameVersions
- type Function
- type InternalLoadedLibrary
- type Library
- type NullableDatum
- type PgFunctionInfo
- type PgMagicStruct
- type Version
Constants ¶
const PLATFORM = "LIN"
PLATFORM specifies which platform applies to the current library loader. This will always be a three-letter string.
Variables ¶
This section is empty.
Functions ¶
func Free ¶
func Free[T any](val *T)
Free frees the given pointer from C heap. Generally, this is paired with a pointer returned from Malloc.
func FreeDatum ¶
func FreeDatum(val Datum)
FreeDatum frees the given Datum. Care should be exercised as datums may refer to static memory, and attempting to free static memory will result in a crash.
func FromDatumGoBytes ¶
FromDatumGoBytes converts the given datum to a byte array of length N.
func FromDatumGoString ¶
FromDatumGoString converts the given datum to a string.
func LoadExtensions ¶
func LoadExtensions() (map[string]*ExtensionFiles, error)
LoadExtensions loads information for all extensions that are in the extensions directory of a local Postgres installation.
func Malloc ¶
func Malloc[T any]() *T
Malloc allocates the given type within the C heap. These should always be followed up with a Free at some point afterward.
func PostgresDirectories ¶
PostgresDirectories returns the installation directories of a local Postgres instance.
func ZeroMemory ¶
func ZeroMemory[T any](val *T)
ZeroMemory writes all zeroes to the memory location occupied by the given pointer.
Types ¶
type Control ¶
type Control struct {
Directory string
DefaultVersion Version
Comment string
Encoding string
ModulePathname string
Requires []string
Superuser bool
Trusted bool
Relocatable bool
Schema string
Extra map[string]string // All entries in here could not be matched to an expected field
}
Control contains the contents of the control file. https://www.postgresql.org/docs/15/extend-extensions.html#id-1.8.3.20.11
type Datum ¶
type Datum uintptr
Datum is a C pointer to some data. Depending on the function being called, it may not be a pointer that should be freed, as some functions return pointers to static memory.
func CallFmgrFunction ¶
func CallFmgrFunction(fn uintptr, args ...NullableDatum) (result Datum, isNotNull bool)
CallFmgrFunction calls the given function and forwards the arguments.
func ToDatumGoBytes ¶
ToDatumGoBytes converts the given byte slice to a Datum.
func ToDatumGoString ¶
ToDatumGoString converts the given string to a Datum.
type ExtensionFiles ¶
type ExtensionFiles struct {
Name string
ControlFileName string
SQLFileNames []string
LibraryFileName string
ControlFileDir string
LibraryFileDir string
Control Control
}
ExtensionFiles contains all of the files that are related to or used by an extension.
func (*ExtensionFiles) LoadLibrary ¶
func (extFile *ExtensionFiles) LoadLibrary() (*Library, error)
LoadLibrary loads the extension as a library.
func (*ExtensionFiles) LoadSQLFiles ¶
func (extFile *ExtensionFiles) LoadSQLFiles() ([]string, error)
LoadSQLFiles loads the contents of the SQL files used by the extension. These will be in the order that they need to be executed.
func (*ExtensionFiles) LoadSQLFunctionNames ¶
func (extFile *ExtensionFiles) LoadSQLFunctionNames() ([]string, error)
LoadSQLFunctionNames loads all of the library function names that are used by the extension.
type FilenameVersions ¶
FilenameVersions returns the versions that were encoded in a filename. `From` is the first number, while `To` is the second number. If a filename only specifies a single version, this both `From` and `To` will equal one another.
func DecodeFilenameVersions ¶
func DecodeFilenameVersions(name string, fileName string) FilenameVersions
DecodeFilenameVersions decodes the version information within the file name. The `sqlFileName` should be the full file name (excluding the path), and the SQL file name should contain only the name as
type InternalLoadedLibrary ¶
InternalLoadedLibrary is an interface that is implemented by the specific platform to handle library operations.
type Library ¶
type Library struct {
Magic PgMagicStruct
Funcs map[string]Function
Version Version
// contains filtered or unexported fields
}
Library is a fully-loaded extension library.
type NullableDatum ¶
NullableDatum is used for arguments to Fmgr function calls.
type PgFunctionInfo ¶
type PgFunctionInfo struct {
APIVersion int32
}
PgFunctionInfo is a stand-in for the C struct that reports the function information.
type PgMagicStruct ¶
type PgMagicStruct struct {
Len int32
Version int32
FuncMaxArgs int32
IndexMaxKeys int32
NameDataLen int32
Float4ByVal int32
Float8ByVal int32
}
PgMagicStruct is a stand-in for the C struct that reports the information of the library.
type Version ¶
type Version uint32
Version specifies the major and minor version numbers for an extension.