github lib/pq v1.12.0

16 hours ago
  • The next release may change the default sslmode from require to prefer. See #1271 for details.

  • CopyIn() and CopyInToSchema() have been marked as deprecated. These are simple query builders and not needed for COPY [..] FROM STDIN support (which is not deprecated). (#1279)

    // Old
    tx.Prepare(CopyIn("temp", "num", "text", "blob", "nothing"))
    
    // Replacement
    tx.Prepare(`copy temp (num, text, blob, nothing) from stdin`)
    

Features

  • Support protocol 3.2, and the min_protocol_version and max_protocol_version DSN parameters (#1258).

  • Support sslmode=prefer and sslmode=allow (#1270).

  • Support ssl_min_protocol_version and ssl_max_protocol_version (#1277).

  • Support connection service file to load connection details (#1285).

  • Support sslrootcert=system and use ~/.postgresql/root.crt as the default value of sslrootcert (#1280, #1281).

  • Add a new pqerror package with PostgreSQL error codes (#1275).

    For example, to test if an error is a UNIQUE constraint violation:

    if pqErr, ok := errors.AsType[*pq.Error](err); ok && pqErr.Code == pqerror.UniqueViolation {
        log.Fatalf("email %q already exsts", email)
    }
    

    To make this a bit more convenient, it also adds a pq.As() function:

    pqErr := pq.As(err, pqerror.UniqueViolation)
    if pqErr != nil {
        log.Fatalf("email %q already exsts", email)
    }
    

Fixes

  • Fix SSL key permission check to allow modes stricter than 0600/0640#1265 (#1265).

  • Fix Hstore to work with binary parameters (#1278).

  • Clearer error when starting a new query while pq is still processing another query (#1272).

  • Send intermediate CAs with client certificates, so they can be signed by an intermediate CA (#1267).

  • Use time.UTC for UTC aliases such as Etc/UTC (#1282).

Don't miss a new pq release

NewReleases is sending notifications on new releases.