Skip to content

babelfishpg_money

SQL Server Money Data Type

babelfish · SQL Server Money Data Type

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
9330babelfishpg_moneybabelfish1.1.0SIMApache-2.0C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--NoYesNoYesnono
Babelfish kernel: PG17.11/5.7.0, PG18.6/6.2.0; packages follow PG18.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.1.019 18 17 16 15babelfish-
RPMPIGSTY6.2.019 18 17 16 15babelfish-$vantlr4-runtime413
DEBPIGSTY6.2.019 18 17 16 15babelfish-$vlibantlr4-runtime413
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
el8.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
el9.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
el9.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
el10.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
el10.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
d12.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
d12.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
d13.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
d13.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
u22.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
u22.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
u24.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
u24.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
u26.x86_64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A
u26.aarch64N/APIGSTY 6.2.0PIGSTY 5.7.0N/AN/A

Source

pig build pkg babelfish;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install babelfish;		# install by package name
pig install babelfishpg_money;		# install by extension name

pig install babelfishpg_money -v 18;   # install for PG 18
pig install babelfishpg_money -v 17;   # install for PG 17

Create this extension with:

CREATE EXTENSION babelfishpg_money;

Usage

babelfishpg_money: SQL Server Money Data Type

The babelfishpg_money extension provides SQL Server-compatible MONEY and SMALLMONEY data type implementations for PostgreSQL as part of the Babelfish project.

Enabling

CREATE EXTENSION babelfishpg_money;

Data Types

  • MONEY - 8-byte monetary value ranging from -922,337,203,685,477.5808 to 922,337,203,685,477.5807, with fixed 4 decimal places
  • SMALLMONEY - 4-byte monetary value ranging from -214,748.3648 to 214,748.3647, with fixed 4 decimal places

Behavior

The extension implements SQL Server’s monetary arithmetic rules:

  • Fixed-point representation with exactly 4 decimal digits
  • SQL Server-compatible rounding behavior for monetary calculations
  • Proper casting between MONEY and other numeric types
  • Arithmetic operations follow SQL Server semantics (e.g., money / money = money, not float)

Notes

  • Part of the Babelfish for PostgreSQL project
  • Works in conjunction with babelfishpg_common which provides the base type infrastructure
  • The PostgreSQL built-in money type has different precision and behavior; this extension provides the SQL Server-compatible variant

Table reader