Skip to content

Commit eb9f0fb

Browse files
committed
Modify @(unit, text) operator to return text instead of cstring.
Close #17.
1 parent e74cacd commit eb9f0fb

File tree

8 files changed

+693
-5
lines changed

8 files changed

+693
-5
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ DATA = unit_prefixes.data unit_units.data \
77
DATA_built = unit--2--3.sql unit--3.sql \
88
unit--3--4.sql unit--4.sql \
99
unit--4--5.sql unit--5.sql \
10-
unit--5--6.sql unit--6.sql
10+
unit--5--6.sql unit--6.sql \
11+
unit--6--7.sql unit--7.sql
1112
REGRESS = extension tables unit unicode prefix units time temperature functions round derived compare aggregate iec custom
1213
EXTRA_CLEAN = unitparse.yy.* powers powers.o unit-*.dump unitparse.tab.*
1314

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
6.1: Jul 8, 2018
1+
7.0: Jul ?, 2018
22
----------------
33
* Format time using commonyears + days + hh:mm:ss.sss s.
4+
* Modify @(unit, text) operator to return text instead of cstring.
45
* Import definitions.units from GNU units 2.17 with 13 new units.
56
* Bison 3 is now required.
67

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ Details:
387387

388388
Rounds a unit value to the nearest integer (in base units).
389389

390-
* **unit @ text: cstring** -- scale conversion, output with unit
390+
* **unit @ text: text** -- scale conversion, output with unit
391391

392392
Converts a unit value on the left side to the scale of the unit on the right
393393
side. The units must have the same dimension. The unit on the right side can

debian/changelog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
postgresql-unit (6.1-1) UNRELEASED; urgency=medium
1+
postgresql-unit (7.0-1) UNRELEASED; urgency=medium
22

33
* Format time using commonyears + days + hh:mm:ss.sss s.
4+
* Modify @(unit, text) operator to return text instead of cstring.
45
* Import definitions.units from GNU units 2.17 with 13 new units.
56
* Bison 3 is now required.
67

unit--6--7.sql.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- convert @ from (unit, text)->cstring to (unit, text)->text
2+
3+
DROP OPERATOR @ (unit, text);
4+
DROP FUNCTION unit_at(unit, text);
5+
6+
CREATE FUNCTION unit_at(unit, text)
7+
RETURNS text
8+
SET search_path = @extschema@
9+
AS '$libdir/unit', 'unit_at_text2'
10+
LANGUAGE C IMMUTABLE STRICT;
11+
12+
CREATE OPERATOR @ (
13+
leftarg = unit,
14+
rightarg = text,
15+
procedure = unit_at
16+
);
17+
18+
-- load prefixes and units tables
19+
SELECT unit_load();

0 commit comments

Comments
 (0)