File tree 4 files changed +73
-8
lines changed
4 files changed +73
-8
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ 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
- REGRESS = extension tables unit prefix units temperature functions derived compare aggregate iec
8
+ REGRESS = extension tables unit prefix units temperature functions derived compare aggregate iec custom
9
9
EXTRA_CLEAN = unitparse.yy.* powers powers.o unit-*.dump # unitparse.tab.*
10
10
11
11
PG_CONFIG = pg_config
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ User-Defined Units
171
171
To create custom prefixes and units, insert new rows into the tables:
172
172
173
173
```
174
- # select '1 foobar'::unit;
174
+ # SELECT '1 foobar'::unit;
175
175
ERROR: unit "foobar" is not known
176
176
# INSERT INTO unit_prefixes VALUES ('foo', 42);
177
177
INSERT 0 1
@@ -180,12 +180,11 @@ INSERT 0 1
180
180
---------
181
181
4.2 MPa
182
182
183
- # INSERT INTO unit_units VALUES ('footballfieldsize', '68m * 105m');
184
- INSERT 0 1
185
- # SELECT '1 hectare'::unit @ 'footballfieldsize' AS one_hectare;
186
- one_hectare
187
- ------------------------------------
188
- 1.40056022408964 footballfieldsize
183
+ # INSERT INTO unit_units VALUES ('legobrick', '9.6 mm');
184
+ # SELECT '1 m'::unit @ 'legobricks' AS one_meter;
185
+ one_meter
186
+ -----------------------------
187
+ 104.166666666667 legobricks
189
188
```
190
189
191
190
Input Syntax
Original file line number Diff line number Diff line change
1
+ SELECT '1 foobar'::unit;
2
+ ERROR: unit "foobar" is not known
3
+ LINE 1: SELECT '1 foobar'::unit;
4
+ ^
5
+ SELECT unit_is_hashed('foobar');
6
+ unit_is_hashed
7
+ ----------------
8
+ f
9
+ (1 row)
10
+
11
+ INSERT INTO unit_prefixes VALUES ('foo', 42);
12
+ SELECT '1 foobar'::unit;
13
+ unit
14
+ ---------
15
+ 4.2 MPa
16
+ (1 row)
17
+
18
+ SELECT unit_is_hashed('foobar');
19
+ unit_is_hashed
20
+ ----------------
21
+ t
22
+ (1 row)
23
+
24
+ SELECT * FROM unit_prefixes WHERE dump;
25
+ prefix | factor | definition | dump
26
+ --------+--------+------------+------
27
+ foo | 42 | | t
28
+ (1 row)
29
+
30
+ INSERT INTO unit_units VALUES ('legobrick', '9.6 mm');
31
+ SELECT unit_is_hashed('legobricks');
32
+ unit_is_hashed
33
+ ----------------
34
+ f
35
+ (1 row)
36
+
37
+ SELECT '1 m'::unit @ 'legobricks' AS one_meter;
38
+ one_meter
39
+ -----------------------------
40
+ 104.166666666667 legobricks
41
+ (1 row)
42
+
43
+ SELECT unit_is_hashed('legobricks');
44
+ unit_is_hashed
45
+ ----------------
46
+ t
47
+ (1 row)
48
+
49
+ SELECT * FROM unit_units WHERE dump;
50
+ name | unit | shift | definition | dump
51
+ -----------+--------+-------+------------+------
52
+ legobrick | 9.6 mm | | | t
53
+ (1 row)
54
+
Original file line number Diff line number Diff line change
1
+ SELECT ' 1 foobar' ::unit;
2
+ SELECT unit_is_hashed(' foobar' );
3
+ INSERT INTO unit_prefixes VALUES (' foo' , 42 );
4
+ SELECT ' 1 foobar' ::unit;
5
+ SELECT unit_is_hashed(' foobar' );
6
+ SELECT * FROM unit_prefixes WHERE dump;
7
+
8
+ INSERT INTO unit_units VALUES (' legobrick' , ' 9.6 mm' );
9
+ SELECT unit_is_hashed(' legobricks' );
10
+ SELECT ' 1 m' ::unit @ ' legobricks' AS one_meter;
11
+ SELECT unit_is_hashed(' legobricks' );
12
+ SELECT * FROM unit_units WHERE dump;
You can’t perform that action at this time.
0 commit comments