PgwireFormatFloat returns a []byte representing a float according to pgwire encoding. The result is appended to the given buffer.
( buf []byte, fl float64, conv sessiondatapb.DataConversionConfig, floatTyp *types.T, )
| 202 | // PgwireFormatFloat returns a []byte representing a float according to |
| 203 | // pgwire encoding. The result is appended to the given buffer. |
| 204 | func PgwireFormatFloat( |
| 205 | buf []byte, fl float64, conv sessiondatapb.DataConversionConfig, floatTyp *types.T, |
| 206 | ) []byte { |
| 207 | // PostgreSQL supports 'Inf' as a valid literal for the floating point |
| 208 | // special value Infinity, therefore handling the special cases for them. |
| 209 | // (https://github.com/cockroachdb/cockroachdb-parser/issues/62601) |
| 210 | if math.IsInf(fl, 1) { |
| 211 | return append(buf, []byte("Infinity")...) |
| 212 | } else if math.IsInf(fl, -1) { |
| 213 | return append(buf, []byte("-Infinity")...) |
| 214 | } else { |
| 215 | return strconv.AppendFloat( |
| 216 | buf, fl, 'g', |
| 217 | conv.GetFloatPrec(floatTyp), |
| 218 | int(floatTyp.Width()), |
| 219 | ) |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | func pgwireQuoteStringInTuple(in string) bool { |
| 224 | return in == "" || tupleQuoteSet.in(in) |
no test coverage detected
searching dependent graphs…