File tree 9 files changed +651
-8
lines changed
9 files changed +651
-8
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ DATA = unit_prefixes.data unit_units.data \
5
5
unit--1.sql unit--1--2.sql \
6
6
unit--2.sql
7
7
DATA_built = unit--2--3.sql unit--3.sql \
8
- unit--3--4.sql unit--4.sql
8
+ unit--3--4.sql unit--4.sql \
9
+ unit--4--5.sql unit--5.sql
9
10
REGRESS = extension tables unit unicode prefix units temperature functions derived compare aggregate iec custom
10
11
EXTRA_CLEAN = unitparse.yy.* powers powers.o unit-*.dump # unitparse.tab.*
11
12
Original file line number Diff line number Diff line change @@ -266,6 +266,7 @@ function cbrt(unit)
266
266
function dimension(unit)
267
267
function max(unit)
268
268
function min(unit)
269
+ function round(unit)
269
270
function sqrt(unit)
270
271
function stddev_pop(unit)
271
272
function stddev_samp(unit)
@@ -318,6 +319,10 @@ Details:
318
319
319
320
Returns the numeric part of a unit value.
320
321
322
+ * ** function round(unit): unit**
323
+
324
+ Rounds a unit value to the nearest integer (in base units).
325
+
321
326
References
322
327
----------
323
328
Original file line number Diff line number Diff line change 1
- postgresql-unit (4 .0-3 ) UNRELEASED; urgency=medium
1
+ postgresql-unit (5 .0-1 ) UNRELEASED; urgency=medium
2
2
3
+ * Add rounding functions.
3
4
* Import definitions.units from GNU units 2.16 with 70 new units.
4
5
(The file header erroneously says 2.19.)
5
6
* debian/watch: Ignore debian/ tags.
6
7
7
- -- Christoph Berg <
[email protected] > Tue,
28 Nov 2017 20:23:01 +0100
8
+ -- Christoph Berg <
[email protected] > Tue,
02 Jan 2018 18:53:55 +0100
8
9
9
10
postgresql-unit (4.0-2) unstable; urgency=medium
10
11
Original file line number Diff line number Diff line change 1
- -- text extractors
1
+ -- text functions
2
2
SELECT value('2'::unit);
3
3
value
4
4
-------
@@ -23,6 +23,18 @@ SELECT dimension(kilogram(2));
23
23
1 kg
24
24
(1 row)
25
25
26
+ SELECT round(ampere(1.5));
27
+ round
28
+ -------
29
+ 2 A
30
+ (1 row)
31
+
32
+ SELECT round(candela(-0.5));
33
+ round
34
+ -------
35
+ -1 cd
36
+ (1 row)
37
+
26
38
-- test unit addition/subtraction
27
39
SELECT '1'::unit + '2' AS sum;
28
40
sum
Original file line number Diff line number Diff line change 1
- -- text extractors
1
+ -- test functions
2
2
SELECT value(' 2' ::unit);
3
3
SELECT value(meter(2 ));
4
4
SELECT dimension(' 2' ::unit);
5
5
SELECT dimension(kilogram(2 ));
6
+ SELECT round(ampere(1 .5 ));
7
+ SELECT round(candela(- 0 .5 ));
6
8
7
9
-- test unit addition/subtraction
8
10
SELECT ' 1' ::unit + ' 2' AS sum;
Original file line number Diff line number Diff line change
1
+ CREATE FUNCTION round(unit)
2
+ RETURNS unit
3
+ AS '$libdir/unit', 'unit_round'
4
+ LANGUAGE C IMMUTABLE STRICT;
You can’t perform that action at this time.
0 commit comments