PostgreSQL connection follow-ups and the message_count mapping (#959)

- Accept a URI whose host has an empty port (postgresql://db:/d?
  sslrootcert=/a@b): libpq parses it as no port, but _port_is_numeric()
  treated it as non-numeric and the early refusal rejected the string.
- Close the connection when setting autocommit or registering the
  NUL-safe dumpers fails after psycopg.connect() succeeded, including
  on KeyboardInterrupt; an error from close() is dropped.
- With a connection string, report a create_tables() failure with a
  fixed message (plus a well-formed SQLSTATE), since the server's text
  can quote a session setting from the string's options; with the
  separate settings keep the server's text, URL credentials masked.
  Both raise from None. The CLI now closes a PostgreSQL client whose
  create_tables() raised, as it is not yet in the clients to roll back.
- Declare the Elasticsearch and OpenSearch aggregate documents'
  message_count and original_timespan_seconds as Long() instead of the
  bare Integer class, matching the long type dynamic mapping has always
  given them (the document classes' mappings are never installed).
  Correct the MAX_MESSAGE_COUNT comment, the _smtp_tls_count docstring
  and the GHSA-fxr7 changelog entry, which described an integer
  Elasticsearch/OpenSearch mapping of the counts that is not installed.

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Sean WhalenandClaude Fable 5.2 authored and GitHub committed 2026-11-10 19:15:01 -05:00
1 parent 02fcfd6e82
commit 771c6df0bd
12 files changed
+375 -33

No files matched your search

+8 -6
View File
@@ -807,10 +807,12 @@ The full set of configuration options is:
not put the password in the connection string: a malformed
connection string can make the driver echo it back in an error
message. With a connection string, parsedmarc withholds the
driver's message for a connection failure (keeping only the
server's SQLSTATE code, when there is one) and does not name the
server in its startup warning, because either could repeat part of
a password; the separate settings give full diagnostics. An `@` or
driver's message for a connection failure and the server's message
for a table creation failure (keeping only the server's SQLSTATE
code, when there is one) and does not name the server in its
startup warning, because any of them could repeat part of a
password or a setting from the string; the separate settings give
full diagnostics. An `@` or
`/` in a URI's user name or password must be percent-encoded (`@`
as `%40`, `/` as `%2F`): libpq ends the user name and password at
the first `@` or `/`, so the rest of the password would be parsed
@@ -818,8 +820,8 @@ The full set of configuration options is:
convenience, a URI that libpq would parse that way is refused with a
fixed error before anything is logged: one with an unencoded `@` in
its host list or database name, or in a query value written before
the first `/`, or with an `@` after a host whose port is not a
number. An `@` in such a place is written `%40` (an abstract socket
the first `/`, or with an `@` after a host whose port is neither
empty nor a number. An `@` in such a place is written `%40` (an abstract socket
host as `%40sock`, a database name `d@x` as `d%40x`); an `@` in a
query value after a `/`, such as a certificate path, is accepted as
written. A keyword/value connection string is not checked: its