-
Notifications
You must be signed in to change notification settings - Fork 0
Prepare Postgres.jl for the 1.0 release #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
62ff22f
ac85a2f
9b02386
8bc5a42
3e362b9
18cc378
136d060
302aa97
6323566
a9c348a
fa9bad1
2cf22bf
e8451c0
007ceaa
0da51f2
c1ae7ba
eab05bd
826babf
6f65316
4fea291
119ab47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2022 Jacob Quinn and contributors | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| # Postgres.jl | ||
|
|
||
| Postgres.jl is a PostgreSQL client that implements the v3 wire protocol with `DBInterface` and `Tables` integration. | ||
| [](https://github.com/JuliaDatabases/Postgres.jl/actions/workflows/CI.yml) | ||
| [](https://JuliaDatabases.github.io/Postgres.jl/dev/) | ||
| [](https://codecov.io/gh/JuliaDatabases/Postgres.jl) | ||
|
|
||
| Postgres.jl is a PostgreSQL client written in Julia that implements the v3 wire protocol with `DBInterface` and `Tables` integration. | ||
|
|
||
| ## Installation | ||
|
|
||
|
|
@@ -12,10 +16,10 @@ Pkg.add("Postgres") | |
| ## Quick start | ||
|
|
||
| ```julia | ||
| using Postgres, DBInterface, Tables | ||
| using Postgres | ||
| DBInterface.connect(Postgres.Connection, "host=127.0.0.1;port=5432;user=postgres;password=postgres;dbname=postgres") do conn | ||
| rows = Tables.rowtable(DBInterface.execute(conn, "SELECT 1 AS a")) | ||
| @show rows[1].a | ||
| row = only(DBInterface.execute(conn, "SELECT 1 AS a")) | ||
| @show row.a | ||
| end | ||
| ``` | ||
|
|
||
|
|
@@ -32,11 +36,15 @@ Connection options support: | |
| - libpq-style keyword strings such as `host=127.0.0.1 port=5432 user=postgres dbname=postgres`. | ||
| - PostgreSQL URIs such as `postgresql://postgres:postgres@127.0.0.1:5432/postgres`. | ||
| - Environment defaults: `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, `PGDATABASE`, `PGAPPNAME`, `PGCONNECT_TIMEOUT`, and TLS-related `PGSSL*` variables. | ||
| - `sslmode` values: `disable`, `prefer`, `require`, `verify-full` (only `verify-full` enforces certificate verification). | ||
| - TLS files: `sslrootcert`, `sslcert`, `sslkey`, `sslcapath`. | ||
| - `sslmode` values: `disable`, `prefer` (the default), `require`, `verify-full`. Only `verify-full` verifies the server's certificate; `require` encrypts without authenticating the server, and the default `prefer` falls back to an unencrypted connection if the server declines TLS. Use `verify-full` with `sslrootcert` when the connection needs to be authenticated. | ||
| - TLS files: `sslrootcert`, `sslcert`, `sslkey`, and `sslcapath` (`sslcapath` is a fallback CA bundle or directory, used only when `sslrootcert` is unset and ignored otherwise). `sslservername` overrides the TLS server name when connecting to a pre-resolved address; under `verify-full` it is also the name the certificate is verified against, so it must name the server you intend to authenticate. | ||
| - `connect_timeout` (seconds) and `statement_timeout` (milliseconds). | ||
| - `application_name` and `statement_cache_maxsize`. | ||
|
|
||
| See the [1.0 support policy](https://JuliaDatabases.github.io/Postgres.jl/dev/support/) | ||
| for tested Julia and PostgreSQL versions, TLS limits, and transaction-pooler | ||
| requirements. | ||
|
|
||
| You can also use `ConnectionParams`: | ||
|
|
||
| ```julia | ||
|
|
@@ -51,9 +59,9 @@ DBInterface.close!(conn) | |
| ```julia | ||
| using Postgres, DBInterface, Tables | ||
| conn = DBInterface.connect(Postgres.Connection, "host=127.0.0.1;user=postgres;password=postgres;dbname=postgres") | ||
| rows = Tables.rowtable(DBInterface.execute(conn, "SELECT $1::int AS val", (42,))) | ||
| rows = Tables.rowtable(DBInterface.execute(conn, raw"SELECT $1::int AS val", (42,))) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Make the documented first run work after the stated install step
Please make the default quick start runnable after only |
||
| @show rows[1].val | ||
| stmt = DBInterface.prepare(conn, "SELECT $1::int AS val") | ||
| stmt = DBInterface.prepare(conn, raw"SELECT $1::int AS val") | ||
| rows = Tables.rowtable(DBInterface.execute(stmt, (7,))) | ||
| DBInterface.close!(stmt) | ||
| DBInterface.close!(conn) | ||
|
|
@@ -87,7 +95,7 @@ StructUtils.@tags struct ProfileSummary | |
| createdAt::DateTime &(postgres=(name=:created_at,),) | ||
| end | ||
|
|
||
| profile = DBInterface.execute(conn, """ | ||
| profile = DBInterface.execute(conn, raw""" | ||
| SELECT profile_id, first_name, last_name, created_at | ||
| FROM profiles | ||
| WHERE profile_id = $1 | ||
|
|
@@ -103,7 +111,8 @@ profiles = DBInterface.execute(conn, """ | |
|
|
||
| `Postgres.command_tag(result)` and `Postgres.rows_affected(result)` expose PostgreSQL command completion metadata. | ||
|
|
||
| Statement caching is LRU-based. Set `statement_cache_maxsize=0` to disable caching. | ||
| Explicit named prepared statements use an LRU backend cache. Caller handles are | ||
| independent. Set `statement_cache_maxsize=0` to disable this cache. | ||
|
|
||
| ```julia | ||
| using Postgres, DBInterface | ||
|
|
@@ -183,15 +192,22 @@ DBInterface.close!(conn) | |
| ``` | ||
|
|
||
| `Numeric` values are returned as `Postgres.Numeric`, `interval` values as `Dates.Period` or `Dates.CompoundPeriod`, and range types as `Postgres.PostgresRange{T}`. | ||
| Custom enum, composite, and range registration controls result decoding. Those | ||
| custom Julia values are not accepted as direct query parameters in 1.0; bind a | ||
| PostgreSQL text representation with an explicit SQL cast instead. | ||
|
|
||
| ## Query logging and driver styles | ||
|
|
||
| ## Query logging | ||
| Driver behavior — query logging, server notices, asynchronous notifications — is customized by defining a driver "style": subtype `Postgres.AbstractPostgresStyle`, overload the behavior hooks for it, and pass an instance via the `style` connection keyword. | ||
|
|
||
| ```julia | ||
| using Postgres, DBInterface | ||
| conn = DBInterface.connect(Postgres.Connection, "host=127.0.0.1;user=postgres;password=postgres;dbname=postgres") | ||
| Postgres.set_query_logger!(conn) do event, info | ||
| @show event info.success info.duration_ns | ||
| end | ||
|
|
||
| struct LoggingStyle <: Postgres.AbstractPostgresStyle end | ||
| Postgres.query_logging_enabled(::LoggingStyle) = true | ||
| Postgres.query_logger(::LoggingStyle, event::Symbol, info::NamedTuple) = @info "query" event info.success info.duration_ns | ||
|
|
||
| conn = DBInterface.connect(Postgres.Connection, "host=127.0.0.1;user=postgres;password=postgres;dbname=postgres"; style=LoggingStyle()) | ||
| DBInterface.execute(conn, "SELECT 1") | ||
| DBInterface.close!(conn) | ||
| ``` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Describe
sslcapathaccording to the transport behaviorThis new limitation is not true for the supported Reseau releases. Its
ca_fileinput explicitly accepts a CA bundle or hashed CA directory, and its trust-store loader branches onisdir. Passingsslcapaththrough that field therefore does support a directory. Also, this code choosessslrootcertwhen both options are set;sslcapathis not loaded as an additional file.Please test a CA directory and document the real precedence and supported path forms. If the intent is to forbid directories, validate and reject them instead of documenting behavior that the code does not enforce.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retested the documentation change at
007ceaa. The new fallback precedence is accurate: Postgres.jl selectssslrootcertwhen both are set, otherwise it passessslcapathas Reseauca_file.The directory limitation is still false for resolved Reseau 1.3.4. Its public Config docs define
ca_fileas a CA bundle or hashed CA directory._tls_load_trust_certificatesbranches onisdir, scans regular files for PEM certificate blocks, and builds the trust store. I passed a real directory containing this review CA certificate to_tls_load_trust_store; it loaded one root successfully. Please documentsslcapathas a fallback CA path that may be a bundle or directory, and add an end-to-endverify-fulldirectory case.