Skip to content
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

Pull upstream #6

Merged
merged 148 commits into from
Jan 31, 2022
Merged

Pull upstream #6

merged 148 commits into from
Jan 31, 2022

Conversation

jansenclever
Copy link

This PR pulls the latest from lib/pq to see if it fixes the broken pipe issues we're seeing. A similar looking issue in our timeline repo was fixed by using the latest lib/pq as well.

ghouscht and others added 30 commits September 2, 2018 22:59
Tested with Cockroach v2.1.6 and PostgreSQL 11.
pq: support returning multiple result sets from a single query
implement driver.Pinger interface
Make minimal changes to enable using the Connector for real.
This sets the stage to allow setting custom properties on the
Connector (like DialerContext) or other userful properties
that don't fit into a dsn.

Fixes lib#783
pq: pipe the context through to the dialer, make use of the Connector
Add SCRAM-SHA-256 authentication to this library
Previously, float4 values were incorrectly parsed by this library. For
example, a value of `1.2::float4` would be returned to the user as a
float64 of `1.2000000476837158`. Now, float4s are parsed correctly,
using the 64-bit-float string parsing facility, and return 1.2 as
expected. Note that this problem only showed up if you used the returned
float64 value from lib/pq directly - casting to a float32 would make the
problem stay hidden - but since lib/pq returns float64, we should make
an effort for that value to be correct anyway.
encode: use 64-bit parsing for float32s
There already exists a `QuoteIdentifier` function that helps to escape
identifiers that you need to dynamically generate. `QuoteLiteral` does the
same, but for literals, which is helpful for DDL statements that utilize literals,
as you cannot pass parameters into said statements.

This is modeled after the way libpq implements `PQescapeStringInternal` and
can be referenced here:

https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/interfaces/libpq/fe-exec.c;hb=HEAD#l3336
When connecting to a server using SSL fails (i.e. with SSL disabled)
the connection was never freed.

Fixes lib#840
Rollback cannot be called in Commit as the function
that watches the context for cancelation assumes it
is only ever called once. Calling it multiple times
hangs the goroutine.

This is an alternative to lib#829.

Fixes lib#731 and lib#848
Replaces lib#829

Signed-off-by: Jay Mundrawala <jmundrawala@chef.io>
name                 old time/op    new time/op    delta
_writeBuf_string-16    14.8ns ± 0%     1.8ns ± 0%  -87.68%  (p=0.000 n=12+15)

name                 old alloc/op   new alloc/op   delta
_writeBuf_string-16     0.00B          0.00B          ~     (all equal)

name                 old allocs/op  new allocs/op  delta
_writeBuf_string-16      0.00           0.00          ~     (all equal)
Previously, this test would panic the test suite if the server didn't
return any error at all.
unify receiver name for conn struct methods
Refactor rollback in commit
Reduce writeBuf.string run-time by 87.68%
bugfix to infinity timestamp test
Our tested support for Go versions is changing to the two latest instead
of three latest. This matches what the Go team supports. If lib/pq
happens to not work in older versions of Go, you must use an earlier
version of lib/pq.

Remove tested support for Go 1.9 and 1.10, add Go 1.12. Remove tested
support for unsupported Postgres versions (< 9.4).

Megacheck was renamed to staticcheck.

Fix two issues found by golint.
bump supported versions; fix tests
Just two nit-picky typo fixes.
err can't have changed since we last checked.
Just a tiny fix to improve code readability.
Fixed lib#887 -- don't nil-ptr-deref when calling RowsAffected on the result of a 0-item CopyIn
otan and others added 26 commits May 17, 2021 13:44
lib/pq previously did not work with TimeTZ offsets with second offsets.
Rectify this by modifying the parse format string as appropriate.
encode: fix TimeTZ with second offsets
From Go 1.13, the illumos build tag implies the solaris build tag (but it's better use both to clarify)
Avoid type assertion to the same type
Looking through recent issues, this seems to be roughly the current situation. Making it clearer here, to help users evaluating this lightweight library against the heavier-weight pgx. But I confess, I might be guessing totally wrong.

Whether or not this PR content is right, I just want to say thanks to the maintainers of this library. We're using it at Camus Energy to help grid operators decarbonize, a.k.a. fighting climate change. We're really happy this library exists, because it serves our needs better than pgx. Really, thanks 😃
…aces

implement ConnPrepareContext/StmtQueryContext/StmtExecContext interfaces
TestConnPrepareContext checks it receives an context.DeadlineExceeded. However,
the context isn't necessarily always expired. This causes most of the test runs
to fail for me, only occasionally succeeding. This change ensures the context
used in the test is actually context.DeadlineExceeded. The negative duration
causes the context package to return an already canceled context.
…d make rows.Next return it (lib#1064)

* add reproducer for issue 1062

see lib#1062

* Keep track of an error for a connection.

Instead of just whether the connection is ErrBadConn. Often times, the error
will still be ErrBadConn. But for expired/cancelled contexts, it will be the
error for the context. Most functions still return ErrBadConn per the
database/sql/driver contract ("ErrBadConn should only be returned from [...] a
query method"). For rows.Next() we return the context-related error.

The database/sql/driver contract doesn't look very precise. Is Next a "query
method" and should database/sql handle ErrBadConns when Next returns them?

Do we have more functions that should return the canceled-context error
message?

* in test for QueryRowContext, fail for all unexpected errors, not just for the one unexpected error

* in TestContextCancel*, accept context.Canceled as valid error

* explicitly test for driver.ErrBadConn in test that breaks the connection

feedback from otan

* move the mutex-protected data in a struct with the mutex, and fix an unsafe usage.

there may be unsafeness in this file.

feedback from otan
Copy link

@mikelucke mikelucke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jansenclever jansenclever merged commit 81df9a6 into master Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.