Remove simple protocol and one round trip query options
It is impossible to guarantee that the a query executed with the simple protocol will behave the same as with the extended protocol. This is because the normal pgx path relies on knowing the OID of query parameters. Without this encoding a value can only be determined by the value instead of the combination of value and PostgreSQL type. For example, how should a []int32 be encoded? It might be encoded into a PostgreSQL int4[] or json. Removal also simplifies the core query path. The primary reason for the simple protocol is for servers like PgBouncer that may not be able to support normal prepared statements. After further research it appears that issuing a "flush" instead "sync" after preparing the unnamed statement would allow PgBouncer to work. The one round trip mode can be better handled with prepared statements. As a last resort, all original server functionality can still be accessed by dropping down to PgConn.
This commit is contained in:
@@ -1054,89 +1054,6 @@ func TestRowsColumnTypes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleQueryLifeCycle(t *testing.T) {
|
||||
// TODO - need to use new method of establishing connection with pgx specific configuration
|
||||
|
||||
// driverConfig := stdlib.DriverConfig{
|
||||
// ConnConfig: pgx.ConnConfig{PreferSimpleProtocol: true},
|
||||
// }
|
||||
|
||||
// stdlib.RegisterDriverConfig(&driverConfig)
|
||||
// defer stdlib.UnregisterDriverConfig(&driverConfig)
|
||||
|
||||
// db, err := sql.Open("pgx", driverConfig.ConnectionString("postgres://pgx_md5:secret@127.0.0.1:5432/pgx_test"))
|
||||
// if err != nil {
|
||||
// t.Fatalf("sql.Open failed: %v", err)
|
||||
// }
|
||||
// defer closeDB(t, db)
|
||||
|
||||
// rows, err := db.Query("SELECT 'foo', n FROM generate_series($1::int, $2::int) n WHERE 3 = $3", 1, 10, 3)
|
||||
// if err != nil {
|
||||
// t.Fatalf("stmt.Query unexpectedly failed: %v", err)
|
||||
// }
|
||||
|
||||
// rowCount := int64(0)
|
||||
|
||||
// for rows.Next() {
|
||||
// rowCount++
|
||||
// var (
|
||||
// s string
|
||||
// n int64
|
||||
// )
|
||||
|
||||
// if err := rows.Scan(&s, &n); err != nil {
|
||||
// t.Fatalf("rows.Scan unexpectedly failed: %v", err)
|
||||
// }
|
||||
|
||||
// if s != "foo" {
|
||||
// t.Errorf(`Expected "foo", received "%v"`, s)
|
||||
// }
|
||||
|
||||
// if n != rowCount {
|
||||
// t.Errorf("Expected %d, received %d", rowCount, n)
|
||||
// }
|
||||
// }
|
||||
|
||||
// if err = rows.Err(); err != nil {
|
||||
// t.Fatalf("rows.Err unexpectedly is: %v", err)
|
||||
// }
|
||||
|
||||
// if rowCount != 10 {
|
||||
// t.Fatalf("Expected to receive 10 rows, instead received %d", rowCount)
|
||||
// }
|
||||
|
||||
// err = rows.Close()
|
||||
// if err != nil {
|
||||
// t.Fatalf("rows.Close unexpectedly failed: %v", err)
|
||||
// }
|
||||
|
||||
// rows, err = db.Query("select 1 where false")
|
||||
// if err != nil {
|
||||
// t.Fatalf("stmt.Query unexpectedly failed: %v", err)
|
||||
// }
|
||||
|
||||
// rowCount = int64(0)
|
||||
|
||||
// for rows.Next() {
|
||||
// rowCount++
|
||||
// }
|
||||
|
||||
// if err = rows.Err(); err != nil {
|
||||
// t.Fatalf("rows.Err unexpectedly is: %v", err)
|
||||
// }
|
||||
|
||||
// if rowCount != 0 {
|
||||
// t.Fatalf("Expected to receive 10 rows, instead received %d", rowCount)
|
||||
// }
|
||||
|
||||
// err = rows.Close()
|
||||
// if err != nil {
|
||||
// t.Fatalf("rows.Close unexpectedly failed: %v", err)
|
||||
// }
|
||||
|
||||
// ensureConnValid(t, db)
|
||||
}
|
||||
|
||||
// https://github.com/jackc/pgx/issues/409
|
||||
func TestScanJSONIntoJSONRawMessage(t *testing.T) {
|
||||
db := openDB(t)
|
||||
|
||||
Reference in New Issue
Block a user