cockroachdb / cockroach

CockroachDB - the open source, cloud-native distributed SQL database.
https://www.cockroachlabs.com
Other
29.52k stars 3.7k forks source link

sql: support `money` type #41578

Open rafiss opened 4 years ago

rafiss commented 4 years ago

https://www.postgresql.org/docs/9.1/datatype-money.html

The money type stores a currency amount with a fixed fractional precision; see Table 8-3. The fractional precision is determined by the database's lc_monetary setting. The range shown in the table assumes there are two fractional digits. Input is accepted in a variety of formats, including integer and floating-point literals, as well as typical currency formatting, such as '$1,000.00'. Output is generally in the latter form but depends on the locale.

Jira issue: CRDB-5432

elliotcourant commented 4 years ago

Would it be better to wait and see if PostgreSQL implements a better solution for the money type? Even on their own wiki they don't encourage using it at this time; https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_money

Making an identical type in Cockroach would be adding a type that already is stricken with flaws. But making those improvements to the new type would then potentially make it incompatible with PostgreSQL's behavior.

Making an improved type might be best rather than trying to make it compatible.

rafiss commented 4 years ago

@elliotcourant Thanks for the information! I agree with the sentiment -- before we commit to working on this we will make sure there is a good case for it. There are almost certainly other compatibility issues we will prioritize higher.

The issue was filed just so we can track known compatibility issues using the A-sql-pgcompat label.

github-actions[bot] commented 3 years ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 5 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!