cturtle/btpostgres
include "cturtle/btpostgres";
Types
PgConfig
Object
| Field | Type | Writable | Description |
|---|---|---|---|
host | string | yes | |
service | string | yes | |
user | string | yes | |
database | string | yes | |
password | string | yes | |
application_name | string | yes | |
scram_nonce | string | yes | |
allow_cleartext_password | bool | yes | |
max_message_bytes | int | yes |
PgDiagnostic
Object
| Field | Type | Writable | Description |
|---|---|---|---|
severity | string | yes | |
sqlstate | string | yes | |
message | string | yes | |
detail | string | yes | |
hint | string | yes | |
position | string | yes | |
internal_position | string | yes | |
internal_query | string | yes | |
where_text | string | yes | |
schema_name | string | yes | |
table_name | string | yes | |
column_name | string | yes | |
data_type_name | string | yes | |
constraint_name | string | yes | |
file | string | yes | |
line | string | yes | |
routine | string | yes |
PgNotification
Object
| Field | Type | Writable | Description |
|---|---|---|---|
process_id | int | yes | |
channel | string | yes | |
payload | string | yes |
PgField
Object
| Field | Type | Writable | Description |
|---|---|---|---|
name | string | yes | |
table_oid | int | yes | |
column_attribute | int | yes | |
type_oid | int | yes | |
type_size | int | yes | |
type_modifier | int | yes | |
format | int | yes |
PgValue
Object
| Field | Type | Writable | Description |
|---|---|---|---|
is_null | bool | yes | |
bytes | buffer | yes |
text
fn text() -> string
PgRow
Object
| Field | Type | Writable | Description |
|---|---|---|---|
values | array<PgValue> | yes |
value
fn value(int column) -> PgValue
PgResult
Object
| Field | Type | Writable | Description |
|---|---|---|---|
fields | array<PgField> | yes | |
rows | array<PgRow> | yes | |
command_tag | string | yes | |
affected_rows | int | yes |
column infallible
infallible fn column(string name) -> int
PgParameter
Object
| Field | Type | Writable | Description |
|---|---|---|---|
is_null | bool | yes | |
bytes | buffer | yes |
PgConnection
Object
| Field | Type | Writable | Description |
|---|---|---|---|
parameters | map<string, string> | yes | |
notices | array<PgDiagnostic> | yes | |
notifications | array<PgNotification> | yes | |
last_error | PgDiagnostic | yes | |
backend_process_id | int | yes | |
backend_secret_key | int | yes | |
transaction_status | string | yes | |
tls | bool | yes | |
tls_protocol | string | yes | |
tls_cipher | string | yes | |
tls_server_name | string | yes |
parameter infallible
infallible fn parameter(string name) -> string
execute
fn execute(string sql) -> PgResult
query_params
fn query_params(string sql, array<PgParameter> values) -> PgResult
close
fn close()
PgScramState
Object
| Field | Type | Writable | Description |
|---|---|---|---|
nonce | string | yes | |
client_first_bare | string | yes | |
server_first | string | yes | |
client_final_without_proof | string | yes | |
expected_server_signature | buffer | yes |
initial infallible
infallible fn initial() -> string
respond
fn respond(string password, string challenge) -> string
respond_with_crypto
fn respond_with_crypto(
string password,
string challenge,
PgScramCryptoProvider crypto) -> string
verify
fn verify(string final_message)
verify_with_crypto
fn verify_with_crypto(string final_message, PgScramCryptoProvider crypto)
clear
fn clear(PgScramCryptoProvider crypto)
PgWireMessage
Object
| Field | Type | Writable | Description |
|---|---|---|---|
type | int | yes | |
payload | buffer | yes |
PgWireString
Object
| Field | Type | Writable | Description |
|---|---|---|---|
value | string | yes | |
next | int | yes |
PgWireStream
Object
| Field | Type | Writable | Description |
|---|---|---|---|
peer | PgTransport | yes | |
input | buffer | yes | |
start | int | yes | |
end | int | yes | |
limit | int | yes |
Interfaces
PgScramCryptoProvider
Interface
sha256
fn sha256(buffer message, buffer digest)
hmac_sha256
fn hmac_sha256(buffer key, buffer message, buffer tag)
pbkdf2_sha256
fn pbkdf2_sha256(
buffer password,
buffer salt,
int iterations,
buffer output)
equal
fn equal(buffer left, buffer right) -> bool
wipe
fn wipe(buffer secret)
xor_bytes
fn xor_bytes(buffer left, buffer right, buffer output)
PgTransport
Interface
receive
fn receive(buffer bytes, int offset, int count) -> int
send
fn send(buffer bytes, int offset, int count) -> int
close infallible
infallible fn close()
Functions
pg_sha256
fn pg_sha256(buffer message) -> buffer
pg_hmac_sha256
fn pg_hmac_sha256(buffer key, buffer message) -> buffer
pg_pbkdf2_sha256
fn pg_pbkdf2_sha256(buffer password, buffer salt, int iterations) -> buffer
pg_base64_encode
fn pg_base64_encode(buffer bytes) -> string
pg_base64_decode
fn pg_base64_decode(string text) -> buffer
pg_config infallible
infallible fn pg_config(
string host,
string service,
string user,
string database) -> PgConfig
pg_text
fn pg_text(string value) -> PgParameter
pg_null infallible
infallible fn pg_null() -> PgParameter
pg_connect
fn pg_connect(PgConfig config) -> PgConnection
pg_validate_config
fn pg_validate_config(PgConfig config)
pg_connect_transport_with_scram_crypto
fn pg_connect_transport_with_scram_crypto(
PgConfig config,
PgTransport peer,
PgScramCryptoProvider scram_crypto) -> PgConnection
pg_command_rows
fn pg_command_rows(string tag) -> int
pg_tls_client_config
fn pg_tls_client_config(
string server_name,
string trust_anchor_pem) -> BtTlsClientConfig
pg_tls_request
fn pg_tls_request(socket peer)
pg_connect_tls
fn pg_connect_tls(
PgConfig config,
BtTlsCryptoProvider provider,
BtTlsClientConfig tls_config) -> PgConnection
pg_scram_start
fn pg_scram_start(string nonce) -> PgScramState
pg_scram_attribute
fn pg_scram_attribute(string message, string wanted) -> string
pg_wire_stream
fn pg_wire_stream(PgTransport peer, int limit) -> PgWireStream
pg_wire_read_i16
fn pg_wire_read_i16(buffer bytes, int offset) -> int
pg_wire_read_i32
fn pg_wire_read_i32(buffer bytes, int offset) -> int
pg_wire_push_i16
fn pg_wire_push_i16(buffer bytes, int value)
pg_wire_push_i32
fn pg_wire_push_i32(buffer bytes, int value)
pg_wire_push_cstring
fn pg_wire_push_cstring(buffer bytes, string value)
pg_wire_read_cstring
fn pg_wire_read_cstring(buffer bytes, int offset) -> PgWireString
pg_wire_send_message
fn pg_wire_send_message(PgTransport peer, int type, buffer payload)
pg_wire_read_message
fn pg_wire_read_message(PgWireStream stream) -> PgWireMessage