From b3f2f9419bea9489b49baa65a7542cc5b5c28a01 Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Wed, 29 May 2019 16:54:07 -0400 Subject: [PATCH] sql: Fixed roundtrip typecasting issue with inets Fixes an issue brought up in #37938, but does not resolve the entire issue. Release note (sql change): Fix a roundtrip typecasting issue where an inet casted to a string and back to an inet would fail. --- pkg/sql/logictest/testdata/logic_test/inet | 5 +++++ pkg/sql/sem/tree/eval.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/sql/logictest/testdata/logic_test/inet b/pkg/sql/logictest/testdata/logic_test/inet index 7e9a6b8756ba..3eb548312177 100644 --- a/pkg/sql/logictest/testdata/logic_test/inet +++ b/pkg/sql/logictest/testdata/logic_test/inet @@ -27,6 +27,11 @@ SELECT '0.0.0.0':::INET; ---- 0.0.0.0 +query T +SELECT '::/0'::inet::text::inet; +---- +::/0 + # Basic IPv6 tests query T diff --git a/pkg/sql/sem/tree/eval.go b/pkg/sql/sem/tree/eval.go index 4baa1dfda504..1ee2a581d3ee 100644 --- a/pkg/sql/sem/tree/eval.go +++ b/pkg/sql/sem/tree/eval.go @@ -3259,7 +3259,7 @@ func PerformCast(ctx *EvalContext, d Datum, t *types.T) (Datum, error) { case *DUuid: s = t.UUID.String() case *DIPAddr: - s = t.String() + s = AsStringWithFlags(d, FmtBareStrings) case *DString: s = string(*t) case *DCollatedString: