@@ -861,12 +861,12 @@ func makeConnectTimeoutDialFunc(timeout time.Duration) DialFunc {
861
861
// ValidateConnectTargetSessionAttrsReadWrite is a ValidateConnectFunc that implements libpq compatible
862
862
// target_session_attrs=read-write.
863
863
func ValidateConnectTargetSessionAttrsReadWrite (ctx context.Context , pgConn * PgConn ) error {
864
- result := pgConn .ExecParams (ctx , "show transaction_read_only" , nil , nil , nil , nil ). Read ()
865
- if result . Err != nil {
866
- return result . Err
864
+ result , err := pgConn .Exec (ctx , "show transaction_read_only" ). ReadAll ()
865
+ if err != nil {
866
+ return err
867
867
}
868
868
869
- if string (result .Rows [0 ][0 ]) == "on" {
869
+ if string (result [ 0 ] .Rows [0 ][0 ]) == "on" {
870
870
return errors .New ("read only connection" )
871
871
}
872
872
@@ -876,12 +876,12 @@ func ValidateConnectTargetSessionAttrsReadWrite(ctx context.Context, pgConn *PgC
876
876
// ValidateConnectTargetSessionAttrsReadOnly is a ValidateConnectFunc that implements libpq compatible
877
877
// target_session_attrs=read-only.
878
878
func ValidateConnectTargetSessionAttrsReadOnly (ctx context.Context , pgConn * PgConn ) error {
879
- result := pgConn .ExecParams (ctx , "show transaction_read_only" , nil , nil , nil , nil ). Read ()
880
- if result . Err != nil {
881
- return result . Err
879
+ result , err := pgConn .Exec (ctx , "show transaction_read_only" ). ReadAll ()
880
+ if err != nil {
881
+ return err
882
882
}
883
883
884
- if string (result .Rows [0 ][0 ]) != "on" {
884
+ if string (result [ 0 ] .Rows [0 ][0 ]) != "on" {
885
885
return errors .New ("connection is not read only" )
886
886
}
887
887
@@ -891,12 +891,12 @@ func ValidateConnectTargetSessionAttrsReadOnly(ctx context.Context, pgConn *PgCo
891
891
// ValidateConnectTargetSessionAttrsStandby is a ValidateConnectFunc that implements libpq compatible
892
892
// target_session_attrs=standby.
893
893
func ValidateConnectTargetSessionAttrsStandby (ctx context.Context , pgConn * PgConn ) error {
894
- result := pgConn .ExecParams (ctx , "select pg_is_in_recovery()" , nil , nil , nil , nil ). Read ()
895
- if result . Err != nil {
896
- return result . Err
894
+ result , err := pgConn .Exec (ctx , "select pg_is_in_recovery()" ). ReadAll ()
895
+ if err != nil {
896
+ return err
897
897
}
898
898
899
- if string (result .Rows [0 ][0 ]) != "t" {
899
+ if string (result [ 0 ] .Rows [0 ][0 ]) != "t" {
900
900
return errors .New ("server is not in hot standby mode" )
901
901
}
902
902
@@ -906,12 +906,12 @@ func ValidateConnectTargetSessionAttrsStandby(ctx context.Context, pgConn *PgCon
906
906
// ValidateConnectTargetSessionAttrsPrimary is a ValidateConnectFunc that implements libpq compatible
907
907
// target_session_attrs=primary.
908
908
func ValidateConnectTargetSessionAttrsPrimary (ctx context.Context , pgConn * PgConn ) error {
909
- result := pgConn .ExecParams (ctx , "select pg_is_in_recovery()" , nil , nil , nil , nil ). Read ()
910
- if result . Err != nil {
911
- return result . Err
909
+ result , err := pgConn .Exec (ctx , "select pg_is_in_recovery()" ). ReadAll ()
910
+ if err != nil {
911
+ return err
912
912
}
913
913
914
- if string (result .Rows [0 ][0 ]) == "t" {
914
+ if string (result [ 0 ] .Rows [0 ][0 ]) == "t" {
915
915
return errors .New ("server is in standby mode" )
916
916
}
917
917
@@ -921,12 +921,12 @@ func ValidateConnectTargetSessionAttrsPrimary(ctx context.Context, pgConn *PgCon
921
921
// ValidateConnectTargetSessionAttrsPreferStandby is a ValidateConnectFunc that implements libpq compatible
922
922
// target_session_attrs=prefer-standby.
923
923
func ValidateConnectTargetSessionAttrsPreferStandby (ctx context.Context , pgConn * PgConn ) error {
924
- result := pgConn .ExecParams (ctx , "select pg_is_in_recovery()" , nil , nil , nil , nil ). Read ()
925
- if result . Err != nil {
926
- return result . Err
924
+ result , err := pgConn .Exec (ctx , "select pg_is_in_recovery()" ). ReadAll ()
925
+ if err != nil {
926
+ return err
927
927
}
928
928
929
- if string (result .Rows [0 ][0 ]) != "t" {
929
+ if string (result [ 0 ] .Rows [0 ][0 ]) != "t" {
930
930
return & NotPreferredError {err : errors .New ("server is not in hot standby mode" )}
931
931
}
932
932
0 commit comments