ruby-pg
Code
require 'pg'
PG.connect(ENV['DATABASE_URL']) do |conn|
conn.exec_params("SELECT $1::text AS greeting", ['Hello world!']) do |result|
puts(result)
end
end
Elephantshark transcript
listening ...
connected at t0 = 2025-10-08 22:40:42 +0200
client -> script: "\x00\x00\x00\x08\x04\xd2\x16\x2f" = SSLRequest
script -> client: "S" = SSL supported
TLSv1.3/TLS_AES_256_GCM_SHA384 connection established with client
server name via SNI: localhost
client -> script: "\x00\x00\x00\x45" = 69 bytes of startup message "\x00\x03\x00\x00" = protocol version
"user\x00" = key "frodo\x00" = value
"database\x00" = key "postgres\x00" = value
"application_name\x00" = key "select-one.rb\x00" = value
"\x00" = end
connecting to Postgres server: localhost
script -> server: "\x00\x00\x00\x08\x04\xd2\x16\x2f" = SSLRequest
server -> script: "S" = SSL supported
TLSv1.3/TLS_AES_256_GCM_SHA384 connection established with server
forwarding client startup message to server
script -> server: "\x00\x00\x00\x45" = 69 bytes of startup message "\x00\x03\x00\x00" = protocol version
"user\x00" = key "frodo\x00" = value
"database\x00" = key "postgres\x00" = value
"application_name\x00" = key "select-one.rb\x00" = value
"\x00" = end
forwarding all later traffic
server -> client: "R" = Authentication "\x00\x00\x00\x2a" = 42 bytes "\x00\x00\x00\x0a" = AuthenticationSASL
"SCRAM-SHA-256-PLUS\x00" = SASL mechanism
"SCRAM-SHA-256\x00" = SASL mechanism
"\x00" = end
^^ 43 bytes forwarded at +0.03s, 0 bytes left in buffer
client -> server: "p" = SASLInitialResponse "\x00\x00\x00\x50" = 80 bytes
"SCRAM-SHA-256-PLUS\x00" = selected mechanism
"\x00\x00\x00\x35" = 53 bytes follow
"p=tls-server-end-point,,n=,r=4KAg6eMm8GvBc5gOdCdfohhh" = SCRAM client-first-message
^^ 81 bytes forwarded at +0.03s, 0 bytes left in buffer
server -> client: "R" = Authentication "\x00\x00\x00\x5c" = 92 bytes "\x00\x00\x00\x0b" = AuthenticationSASLContinue
"r=4KAg6eMm8GvBc5gOdCdfohhhE1Y7hGUMikoHuQFp0vHpESxr,s=ZPXsknNfrTfGBNripnqk4A==,i=4096" = SCRAM server-first-message
^^ 93 bytes forwarded at +0.04s, 0 bytes left in buffer
client -> server: "p" = SASLResponse "\x00\x00\x00\xb4" = 180 bytes
"c=cD10bHMtc2VydmVyLWVuZC1wb2ludCwsBnYAKt8DVOF0Dbf6e/kV+f4GIYYITTYxvPTfEl/DLPA=,r=4KAg6eMm8GvBc5gOdCdfohhhE1Y7hGUMikoHuQFp0vHpESxr,p=le0m/bgL2FFj2Pf/tsGwxXkJjfxmWMukjesj0f7qn4U=" = SCRAM client-final-message
^^ 181 bytes forwarded at +0.05s, 0 bytes left in buffer
server -> client: "R" = Authentication "\x00\x00\x00\x36" = 54 bytes "\x00\x00\x00\x0c" = AuthenticationSASLFinal
"v=gyq4U2Z6jODWSHPRJ/uPEzcS0utpSlLJ7x+6WE68Y/w=" = SCRAM server-final-message
server -> client: "R" = Authentication "\x00\x00\x00\x08" = 8 bytes "\x00\x00\x00\x00" = AuthenticationOk
server -> client: "S" = ParameterStatus "\x00\x00\x00\x17" = 23 bytes "in_hot_standby\x00" = key "off\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x19" = 25 bytes "integer_datetimes\x00" = key "on\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x15" = 21 bytes "TimeZone\x00" = key "Etc/UTC\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x1b" = 27 bytes "IntervalStyle\x00" = key "postgres\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x20" = 32 bytes "search_path\x00" = key "\"$user\", public\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x14" = 20 bytes "is_superuser\x00" = key "on\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x23" = 35 bytes "application_name\x00" = key "select-one.rb\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x26" = 38 bytes "default_transaction_read_only\x00" = key "off\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x1a" = 26 bytes "scram_iterations\x00" = key "4096\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x17" = 23 bytes "DateStyle\x00" = key "ISO, MDY\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x23" = 35 bytes "standard_conforming_strings\x00" = key "on\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x20" = 32 bytes "session_authorization\x00" = key "frodo\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x19" = 25 bytes "client_encoding\x00" = key "UTF8\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x31" = 49 bytes "server_version\x00" = key "18.0 (Debian 18.0-1.pgdg13+3)\x00" = value
server -> client: "S" = ParameterStatus "\x00\x00\x00\x19" = 25 bytes "server_encoding\x00" = key "UTF8\x00" = value
server -> client: "K" = BackendKeyData "\x00\x00\x00\x0c" = 12 bytes "\x00\x00\x00\x5d" = process ID "\x6c\xbc\xd7\x01" = secret key
server -> client: "Z" = ReadyForQuery "\x00\x00\x00\x05" = 5 bytes "I" = idle
^^ 534 bytes forwarded at +0.05s, 0 bytes left in buffer
client -> server: "P" = Parse "\x00\x00\x00\x27" = 39 bytes "\x00" = destination prepared statement "SELECT $1::text AS greeting\x00" = SQL query "\x00\x01" = 1 parameter data types follow "\x00\x00\x00\x00" = parameter type OID: 0
client -> server: "B" = Bind "\x00\x00\x00\x20" = 32 bytes "\x00" = destination portal "\x00" = source prepared statement
"\x00\x01" = 1 parameter format codes follow "\x00\x00" = format: text
"\x00\x01" = 1 parameter values follow "\x00\x00\x00\x0c" = 12 bytes follow "Hello world!" = parameter value
"\x00\x01" = 1 result format codes follow "\x00\x00" = format: text
client -> server: "D" = Describe "\x00\x00\x00\x06" = 6 bytes "P" = portal "\x00" = name of portal
client -> server: "E" = Execute "\x00\x00\x00\x09" = 9 bytes "\x00" = portal name "\x00\x00\x00\x00" = max rows: 0 = no limit
client -> server: "S" = Sync "\x00\x00\x00\x04" = 4 bytes
^^ 95 bytes forwarded at +0.06s, 0 bytes left in buffer
server -> client: "1" = ParseComplete "\x00\x00\x00\x04" = 4 bytes
server -> client: "2" = BindComplete "\x00\x00\x00\x04" = 4 bytes
server -> client: "T" = RowDescription "\x00\x00\x00\x21" = 33 bytes "\x00\x01" = 1 columns follow
"greeting\x00" = column name "\x00\x00\x00\x00" = table OID: 0 "\x00\x00" = table attrib no: 0
"\x00\x00\x00\x19" = type OID: 25 "\xff\xff" = type length: -1 "\xff\xff\xff\xff" = type modifier: -1 "\x00\x00" = format: text
server -> client: "D" = DataRow "\x00\x00\x00\x16" = 22 bytes "\x00\x01" = 1 columns follow
"\x00\x00\x00\x0c" = 12 bytes "Hello world!" = column value
server -> client: "C" = CommandComplete "\x00\x00\x00\x0d" = 13 bytes "SELECT 1\x00" = command tag
server -> client: "Z" = ReadyForQuery "\x00\x00\x00\x05" = 5 bytes "I" = idle
^^ 87 bytes forwarded at +0.06s, 0 bytes left in buffer
client -> server: "X" = Terminate "\x00\x00\x00\x04" = 4 bytes
^^ 5 bytes forwarded at +0.06s, 0 bytes left in buffer
client hung up
connection end
listening ...
connection end