-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45671 from otan-cockroach/backport19.1-45613
release-19.1: pgwire: fix decimal decoding with trailing zeroes
- Loading branch information
Showing
13 changed files
with
229 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where third-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# Ignore .fetch files in case you like to edit your project deps locally. | ||
/.fetch | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
debug-*.tar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
defmodule Cockroach.MixProject do | ||
use Mix.Project | ||
|
||
def project do | ||
[ | ||
app: :debug, | ||
version: "0.1.0", | ||
start_permanent: Mix.env() == :prod, | ||
deps: deps() | ||
] | ||
end | ||
|
||
def application do | ||
[ | ||
extra_applications: [:logger] | ||
] | ||
end | ||
|
||
defp deps do | ||
[{:postgrex, "~> 0.13", hex: :postgrex_cdb, override: true}] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%{ | ||
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"}, | ||
"db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm", "5f0a16a58312a610d5eb0b07506280c65f5137868ad479045f2a2dc4ced80550"}, | ||
"decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"}, | ||
"postgrex": {:hex, :postgrex_cdb, "0.13.5", "83f818ea1b959d176c694bb60c36f42080c36a7413f0d3b05d58ef2093fe17f5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "1a01ba25472ad33bafbac6f042fde2dbab93e23bdaa49ffa3722926165c1052f"}, | ||
} |
63 changes: 63 additions & 0 deletions
63
pkg/acceptance/testdata/elixir/test_crdb/test/decimal_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
defmodule Cockroach.TestDecimal do | ||
use ExUnit.Case | ||
|
||
test "handles decimal correctly" do | ||
ssl_opts = [certfile: System.get_env("PGSSLCERT"), keyfile: System.get_env("PGSSLKEY")] | ||
{port, _} = Integer.parse(System.get_env("PGPORT") || "26257") | ||
{start_ok, pid} = Postgrex.start_link( | ||
hostname: System.get_env("PGHOST") || "localhost", | ||
username: System.get_env("PGUSER") || "root", | ||
password: "", | ||
database: "testdb", | ||
port: port, | ||
ssl: (System.get_env("PGSSLCERT") != nil && true) || false, | ||
ssl_opts: ssl_opts | ||
) | ||
assert start_ok | ||
for dec <- [ | ||
Decimal.new("0"), | ||
Decimal.new("0.0"), | ||
Decimal.new("0.00"), | ||
Decimal.new("0.000"), | ||
Decimal.new("0.0000"), | ||
Decimal.new("0.00000"), | ||
Decimal.new("0.00001"), | ||
Decimal.new("0.000012"), | ||
Decimal.new("0.0000012"), | ||
Decimal.new("0.00000012"), | ||
Decimal.new("0.00000012"), | ||
Decimal.new(".00000012"), | ||
Decimal.new("1"), | ||
Decimal.new("1.0"), | ||
Decimal.new("1.000"), | ||
Decimal.new("1.0000"), | ||
Decimal.new("1.00000"), | ||
Decimal.new("1.000001"), | ||
Decimal.new("12345"), | ||
Decimal.new("12345.0"), | ||
Decimal.new("12345.000"), | ||
Decimal.new("12345.0000"), | ||
Decimal.new("12345.00000"), | ||
Decimal.new("12345.000001"), | ||
Decimal.new("12340"), | ||
Decimal.new("123400"), | ||
Decimal.new("1234000"), | ||
Decimal.new("12340000"), | ||
Decimal.new("12340.00"), | ||
Decimal.new("123400.00"), | ||
Decimal.new("1234000.00"), | ||
Decimal.new("12340000.00"), | ||
Decimal.new("1.2345e-10"), | ||
Decimal.new("1.23450e-10"), | ||
Decimal.new("1.234500e-10"), | ||
Decimal.new("1.2345000e-10"), | ||
Decimal.new("1.23450000e-10"), | ||
Decimal.new("1.234500000e-10"), | ||
] do | ||
{result_ok, result} = Postgrex.query(pid, "SELECT CAST($1 AS DECIMAL)", [dec]) | ||
assert result_ok | ||
[[ret]] = result.rows | ||
assert ret == dec | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ExUnit.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters