globegit-postgresql-plruby 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +121 -0
- data/README.markdown +155 -0
- data/Rakefile +48 -0
- data/docs/plruby.rb +1931 -0
- data/ex_trans.sql +33 -0
- data/extconf.rb +267 -0
- data/plruby.html +1454 -0
- data/plruby.rd +1571 -0
- data/postgresql-plruby.gemspec +56 -0
- data/src/conversions.h +5 -0
- data/src/conversions/basic/conversions.h +25 -0
- data/src/conversions/basic/extconf.rb +8 -0
- data/src/conversions/basic/plruby_basic.c +357 -0
- data/src/conversions/bitstring/bitstring.sql +75 -0
- data/src/conversions/bitstring/conversions.h +15 -0
- data/src/conversions/bitstring/extconf.rb +8 -0
- data/src/conversions/bitstring/plruby_bitstring.c +579 -0
- data/src/conversions/convcommon.h +129 -0
- data/src/conversions/datetime/conversions.h +13 -0
- data/src/conversions/datetime/extconf.rb +8 -0
- data/src/conversions/datetime/plruby_datetime.c +269 -0
- data/src/conversions/geometry/conversions.h +37 -0
- data/src/conversions/geometry/extconf.rb +8 -0
- data/src/conversions/geometry/geometry.sql +196 -0
- data/src/conversions/geometry/plruby_geometry.c +2494 -0
- data/src/conversions/network/conversions.h +21 -0
- data/src/conversions/network/extconf.rb +8 -0
- data/src/conversions/network/network.sql +63 -0
- data/src/conversions/network/plruby_network.c +537 -0
- data/src/package.h +20 -0
- data/src/plpl.c +1708 -0
- data/src/plplan.c +893 -0
- data/src/plruby.c +1676 -0
- data/src/plruby.h +324 -0
- data/src/pltrans.c +388 -0
- data/test/conv_bitstring/b.rb +45 -0
- data/test/conv_bitstring/runtest +26 -0
- data/test/conv_bitstring/test.expected.73 +148 -0
- data/test/conv_bitstring/test.expected.74 +148 -0
- data/test/conv_bitstring/test.expected.80 +148 -0
- data/test/conv_bitstring/test.expected.81 +148 -0
- data/test/conv_bitstring/test.expected.82 +148 -0
- data/test/conv_bitstring/test.expected.83 +148 -0
- data/test/conv_bitstring/test.expected.84 +148 -0
- data/test/conv_bitstring/test.out +148 -0
- data/test/conv_bitstring/test_mklang.sql +8 -0
- data/test/conv_bitstring/test_queries.sql +63 -0
- data/test/conv_bitstring/test_queries.sql.in +63 -0
- data/test/conv_geometry/b.rb +45 -0
- data/test/conv_geometry/runtest +26 -0
- data/test/conv_geometry/test.expected.73 +265 -0
- data/test/conv_geometry/test.expected.74 +265 -0
- data/test/conv_geometry/test.expected.80 +265 -0
- data/test/conv_geometry/test.expected.81 +265 -0
- data/test/conv_geometry/test.expected.82 +265 -0
- data/test/conv_geometry/test.expected.83 +265 -0
- data/test/conv_geometry/test.expected.84 +265 -0
- data/test/conv_geometry/test.out +265 -0
- data/test/conv_geometry/test_mklang.sql +8 -0
- data/test/conv_geometry/test_queries.sql +194 -0
- data/test/conv_geometry/test_queries.sql.in +194 -0
- data/test/conv_network/b.rb +45 -0
- data/test/conv_network/runtest +26 -0
- data/test/conv_network/test.expected.73 +213 -0
- data/test/conv_network/test.expected.74 +237 -0
- data/test/conv_network/test.expected.80 +237 -0
- data/test/conv_network/test.expected.81 +237 -0
- data/test/conv_network/test.expected.82 +237 -0
- data/test/conv_network/test.expected.83 +237 -0
- data/test/conv_network/test.expected.84 +237 -0
- data/test/conv_network/test.out +237 -0
- data/test/conv_network/test_mklang.sql +8 -0
- data/test/conv_network/test_queries.sql +60 -0
- data/test/conv_network/test_queries.sql.in +60 -0
- data/test/plp/b.rb +34 -0
- data/test/plp/runtest +29 -0
- data/test/plp/test.expected.73 +472 -0
- data/test/plp/test.expected.74 +472 -0
- data/test/plp/test.expected.75 +472 -0
- data/test/plp/test.expected.80 +472 -0
- data/test/plp/test.expected.81 +472 -0
- data/test/plp/test.expected.82 +472 -0
- data/test/plp/test.expected.83 +472 -0
- data/test/plp/test.expected.84 +472 -0
- data/test/plp/test.out +472 -0
- data/test/plp/test_mklang.sql +8 -0
- data/test/plp/test_queries.sql +273 -0
- data/test/plp/test_setup.sql +931 -0
- data/test/plp/test_setup.sql.in +931 -0
- data/test/plt/b.rb +34 -0
- data/test/plt/runtest +29 -0
- data/test/plt/test.expected.73 +178 -0
- data/test/plt/test.expected.74 +178 -0
- data/test/plt/test.expected.75 +178 -0
- data/test/plt/test.expected.80 +178 -0
- data/test/plt/test.expected.81 +178 -0
- data/test/plt/test.expected.82 +178 -0
- data/test/plt/test.expected.83 +164 -0
- data/test/plt/test.expected.84 +168 -0
- data/test/plt/test.out +168 -0
- data/test/plt/test_mklang.sql +8 -0
- data/test/plt/test_queries.sql +72 -0
- data/test/plt/test_setup.sql +252 -0
- data/test/plt/test_setup.sql.in +252 -0
- data/test/range/b.rb +45 -0
- data/test/range/runtest +26 -0
- data/test/range/test.expected.73 +396 -0
- data/test/range/test.expected.73.in +396 -0
- data/test/range/test.expected.74 +396 -0
- data/test/range/test.expected.74.in +396 -0
- data/test/range/test.expected.75 +396 -0
- data/test/range/test.expected.75.in +396 -0
- data/test/range/test.expected.80 +396 -0
- data/test/range/test.expected.81 +397 -0
- data/test/range/test.expected.82 +397 -0
- data/test/range/test.expected.83 +397 -0
- data/test/range/test.expected.84 +399 -0
- data/test/range/test.out +399 -0
- data/test/range/test_mklang.sql +8 -0
- data/test/range/test_queries.sql +249 -0
- data/test/range/test_queries.sql.in +249 -0
- metadata +207 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
insert into T_pkey1 values (1, 'key1-1', 'test key');
|
2
|
+
insert into T_pkey1 values (1, 'key1-2', 'test key');
|
3
|
+
insert into T_pkey1 values (1, 'key1-3', 'test key');
|
4
|
+
insert into T_pkey1 values (2, 'key2-1', 'test key');
|
5
|
+
insert into T_pkey1 values (2, 'key2-2', 'test key');
|
6
|
+
insert into T_pkey1 values (2, 'key2-3', 'test key');
|
7
|
+
insert into T_pkey2 values (1, 'key1-1', 'test key');
|
8
|
+
insert into T_pkey2 values (1, 'key1-2', 'test key');
|
9
|
+
insert into T_pkey2 values (1, 'key1-3', 'test key');
|
10
|
+
insert into T_pkey2 values (2, 'key2-1', 'test key');
|
11
|
+
insert into T_pkey2 values (2, 'key2-2', 'test key');
|
12
|
+
insert into T_pkey2 values (2, 'key2-3', 'test key');
|
13
|
+
select * from T_pkey1;
|
14
|
+
key1 | key2 | txt
|
15
|
+
------+--------+----------
|
16
|
+
1 | key1-1 | test key
|
17
|
+
1 | key1-2 | test key
|
18
|
+
1 | key1-3 | test key
|
19
|
+
2 | key2-1 | test key
|
20
|
+
2 | key2-2 | test key
|
21
|
+
2 | key2-3 | test key
|
22
|
+
(6 rows)
|
23
|
+
|
24
|
+
select * from T_pkey2;
|
25
|
+
key1 | key2 | txt
|
26
|
+
------+--------+----------
|
27
|
+
1 | KEY1-1 | test key
|
28
|
+
1 | KEY1-2 | test key
|
29
|
+
1 | KEY1-3 | test key
|
30
|
+
2 | KEY2-1 | test key
|
31
|
+
2 | KEY2-2 | test key
|
32
|
+
2 | KEY2-3 | test key
|
33
|
+
(6 rows)
|
34
|
+
|
35
|
+
insert into T_pkey1 values (1, 'KEY1-3', 'should work');
|
36
|
+
insert into T_pkey2 values (1, 'KEY1-3', 'should fail');
|
37
|
+
ERROR: duplicate key '1', 'KEY1-3' for T_pkey2
|
38
|
+
insert into T_dta1 values ('trec 1', 1, 'key1-1');
|
39
|
+
insert into T_dta1 values ('trec 2', 1, 'key1-2');
|
40
|
+
insert into T_dta1 values ('trec 3', 1, 'key1-3');
|
41
|
+
insert into T_dta1 values ('trec 4', 1, 'key1-4');
|
42
|
+
ERROR: key for t_dta1 not in t_pkey1
|
43
|
+
insert into T_dta2 values ('trec 1', 1, 'KEY1-1');
|
44
|
+
insert into T_dta2 values ('trec 2', 1, 'KEY1-2');
|
45
|
+
insert into T_dta2 values ('trec 3', 1, 'KEY1-3');
|
46
|
+
insert into T_dta2 values ('trec 4', 1, 'KEY1-4');
|
47
|
+
ERROR: key for t_dta2 not in t_pkey2
|
48
|
+
select * from T_dta1;
|
49
|
+
tkey | ref1 | ref2
|
50
|
+
--------+------+--------
|
51
|
+
trec 1 | 1 | key1-1
|
52
|
+
trec 2 | 1 | key1-2
|
53
|
+
trec 3 | 1 | key1-3
|
54
|
+
(3 rows)
|
55
|
+
|
56
|
+
select * from T_dta2;
|
57
|
+
tkey | ref1 | ref2
|
58
|
+
--------+------+--------
|
59
|
+
trec 1 | 1 | KEY1-1
|
60
|
+
trec 2 | 1 | KEY1-2
|
61
|
+
trec 3 | 1 | KEY1-3
|
62
|
+
(3 rows)
|
63
|
+
|
64
|
+
update T_pkey1 set key2 = 'key2-9' where key1 = 2 and key2 = 'key2-1';
|
65
|
+
update T_pkey1 set key2 = 'key1-9' where key1 = 1 and key2 = 'key1-1';
|
66
|
+
ERROR: key '1', 'key1-1' referenced by T_dta1
|
67
|
+
delete from T_pkey1 where key1 = 2 and key2 = 'key2-2';
|
68
|
+
delete from T_pkey1 where key1 = 1 and key2 = 'key1-2';
|
69
|
+
ERROR: key '1', 'key1-2' referenced by T_dta1
|
70
|
+
update T_pkey2 set key2 = 'KEY2-9' where key1 = 2 and key2 = 'KEY2-1';
|
71
|
+
update T_pkey2 set key2 = 'KEY1-9' where key1 = 1 and key2 = 'KEY1-1';
|
72
|
+
NOTICE: updated 1 entries in T_dta2 for new key in T_pkey2
|
73
|
+
delete from T_pkey2 where key1 = 2 and key2 = 'KEY2-2';
|
74
|
+
delete from T_pkey2 where key1 = 1 and key2 = 'KEY1-2';
|
75
|
+
NOTICE: deleted 1 entries from T_dta2
|
76
|
+
select * from T_pkey1;
|
77
|
+
key1 | key2 | txt
|
78
|
+
------+--------+-------------
|
79
|
+
1 | key1-1 | test key
|
80
|
+
1 | key1-2 | test key
|
81
|
+
1 | key1-3 | test key
|
82
|
+
2 | key2-3 | test key
|
83
|
+
1 | KEY1-3 | should work
|
84
|
+
2 | key2-9 | test key
|
85
|
+
(6 rows)
|
86
|
+
|
87
|
+
select * from T_pkey2;
|
88
|
+
key1 | key2 | txt
|
89
|
+
------+--------+----------
|
90
|
+
1 | KEY1-3 | test key
|
91
|
+
2 | KEY2-3 | test key
|
92
|
+
2 | KEY2-9 | test key
|
93
|
+
1 | KEY1-9 | test key
|
94
|
+
(4 rows)
|
95
|
+
|
96
|
+
select * from T_dta1;
|
97
|
+
tkey | ref1 | ref2
|
98
|
+
--------+------+--------
|
99
|
+
trec 1 | 1 | key1-1
|
100
|
+
trec 2 | 1 | key1-2
|
101
|
+
trec 3 | 1 | key1-3
|
102
|
+
(3 rows)
|
103
|
+
|
104
|
+
select * from T_dta2;
|
105
|
+
tkey | ref1 | ref2
|
106
|
+
--------+------+--------
|
107
|
+
trec 3 | 1 | KEY1-3
|
108
|
+
trec 1 | 1 | KEY1-9
|
109
|
+
(2 rows)
|
110
|
+
|
111
|
+
select ruby_avg(key1) from T_pkey1;
|
112
|
+
ruby_avg
|
113
|
+
----------
|
114
|
+
1
|
115
|
+
(1 row)
|
116
|
+
|
117
|
+
select ruby_sum(key1) from T_pkey1;
|
118
|
+
ruby_sum
|
119
|
+
----------
|
120
|
+
8
|
121
|
+
(1 row)
|
122
|
+
|
123
|
+
select ruby_avg(key1) from T_pkey2;
|
124
|
+
ruby_avg
|
125
|
+
----------
|
126
|
+
1
|
127
|
+
(1 row)
|
128
|
+
|
129
|
+
select ruby_sum(key1) from T_pkey2;
|
130
|
+
ruby_sum
|
131
|
+
----------
|
132
|
+
6
|
133
|
+
(1 row)
|
134
|
+
|
135
|
+
select ruby_avg(key1) from T_pkey1 where key1 = 99;
|
136
|
+
ruby_avg
|
137
|
+
----------
|
138
|
+
|
139
|
+
(1 row)
|
140
|
+
|
141
|
+
select ruby_sum(key1) from T_pkey1 where key1 = 99;
|
142
|
+
ruby_sum
|
143
|
+
----------
|
144
|
+
0
|
145
|
+
(1 row)
|
146
|
+
|
147
|
+
select 1 @< 2;
|
148
|
+
?column?
|
149
|
+
----------
|
150
|
+
t
|
151
|
+
(1 row)
|
152
|
+
|
153
|
+
select 100 @< 4;
|
154
|
+
?column?
|
155
|
+
----------
|
156
|
+
f
|
157
|
+
(1 row)
|
158
|
+
|
159
|
+
select * from T_pkey1 order by key1 using @<;
|
160
|
+
ERROR: operator @< is not a valid ordering operator
|
161
|
+
HINT: Ordering operators must be "<" or ">" members of btree operator families.
|
162
|
+
select * from T_pkey2 order by key1 using @<;
|
163
|
+
ERROR: operator @< is not a valid ordering operator
|
164
|
+
HINT: Ordering operators must be "<" or ">" members of btree operator families.
|
@@ -0,0 +1,168 @@
|
|
1
|
+
insert into T_pkey1 values (1, 'key1-1', 'test key');
|
2
|
+
insert into T_pkey1 values (1, 'key1-2', 'test key');
|
3
|
+
insert into T_pkey1 values (1, 'key1-3', 'test key');
|
4
|
+
insert into T_pkey1 values (2, 'key2-1', 'test key');
|
5
|
+
insert into T_pkey1 values (2, 'key2-2', 'test key');
|
6
|
+
insert into T_pkey1 values (2, 'key2-3', 'test key');
|
7
|
+
insert into T_pkey2 values (1, 'key1-1', 'test key');
|
8
|
+
insert into T_pkey2 values (1, 'key1-2', 'test key');
|
9
|
+
insert into T_pkey2 values (1, 'key1-3', 'test key');
|
10
|
+
insert into T_pkey2 values (2, 'key2-1', 'test key');
|
11
|
+
insert into T_pkey2 values (2, 'key2-2', 'test key');
|
12
|
+
insert into T_pkey2 values (2, 'key2-3', 'test key');
|
13
|
+
select * from T_pkey1;
|
14
|
+
key1 | key2 | txt
|
15
|
+
------+--------+----------
|
16
|
+
1 | key1-1 | test key
|
17
|
+
1 | key1-2 | test key
|
18
|
+
1 | key1-3 | test key
|
19
|
+
2 | key2-1 | test key
|
20
|
+
2 | key2-2 | test key
|
21
|
+
2 | key2-3 | test key
|
22
|
+
(6 rows)
|
23
|
+
|
24
|
+
select * from T_pkey2;
|
25
|
+
key1 | key2 | txt
|
26
|
+
------+--------+----------
|
27
|
+
1 | KEY1-1 | test key
|
28
|
+
1 | KEY1-2 | test key
|
29
|
+
1 | KEY1-3 | test key
|
30
|
+
2 | KEY2-1 | test key
|
31
|
+
2 | KEY2-2 | test key
|
32
|
+
2 | KEY2-3 | test key
|
33
|
+
(6 rows)
|
34
|
+
|
35
|
+
insert into T_pkey1 values (1, 'KEY1-3', 'should work');
|
36
|
+
insert into T_pkey2 values (1, 'KEY1-3', 'should fail');
|
37
|
+
ERROR: duplicate key '1', 'KEY1-3' for T_pkey2
|
38
|
+
insert into T_dta1 values ('trec 1', 1, 'key1-1');
|
39
|
+
insert into T_dta1 values ('trec 2', 1, 'key1-2');
|
40
|
+
insert into T_dta1 values ('trec 3', 1, 'key1-3');
|
41
|
+
insert into T_dta1 values ('trec 4', 1, 'key1-4');
|
42
|
+
ERROR: key for t_dta1 not in t_pkey1
|
43
|
+
insert into T_dta2 values ('trec 1', 1, 'KEY1-1');
|
44
|
+
insert into T_dta2 values ('trec 2', 1, 'KEY1-2');
|
45
|
+
insert into T_dta2 values ('trec 3', 1, 'KEY1-3');
|
46
|
+
insert into T_dta2 values ('trec 4', 1, 'KEY1-4');
|
47
|
+
ERROR: key for t_dta2 not in t_pkey2
|
48
|
+
select * from T_dta1;
|
49
|
+
tkey | ref1 | ref2
|
50
|
+
--------+------+--------
|
51
|
+
trec 1 | 1 | key1-1
|
52
|
+
trec 2 | 1 | key1-2
|
53
|
+
trec 3 | 1 | key1-3
|
54
|
+
(3 rows)
|
55
|
+
|
56
|
+
select * from T_dta2;
|
57
|
+
tkey | ref1 | ref2
|
58
|
+
--------+------+--------
|
59
|
+
trec 1 | 1 | KEY1-1
|
60
|
+
trec 2 | 1 | KEY1-2
|
61
|
+
trec 3 | 1 | KEY1-3
|
62
|
+
(3 rows)
|
63
|
+
|
64
|
+
update T_pkey1 set key2 = 'key2-9' where key1 = 2 and key2 = 'key2-1';
|
65
|
+
update T_pkey1 set key2 = 'key1-9' where key1 = 1 and key2 = 'key1-1';
|
66
|
+
ERROR: key '1', 'key1-1' referenced by T_dta1
|
67
|
+
delete from T_pkey1 where key1 = 2 and key2 = 'key2-2';
|
68
|
+
delete from T_pkey1 where key1 = 1 and key2 = 'key1-2';
|
69
|
+
ERROR: key '1', 'key1-2' referenced by T_dta1
|
70
|
+
update T_pkey2 set key2 = 'KEY2-9' where key1 = 2 and key2 = 'KEY2-1';
|
71
|
+
update T_pkey2 set key2 = 'KEY1-9' where key1 = 1 and key2 = 'KEY1-1';
|
72
|
+
NOTICE: updated 1 entries in T_dta2 for new key in T_pkey2
|
73
|
+
delete from T_pkey2 where key1 = 2 and key2 = 'KEY2-2';
|
74
|
+
delete from T_pkey2 where key1 = 1 and key2 = 'KEY1-2';
|
75
|
+
NOTICE: deleted 1 entries from T_dta2
|
76
|
+
select * from T_pkey1;
|
77
|
+
key1 | key2 | txt
|
78
|
+
------+--------+-------------
|
79
|
+
1 | key1-1 | test key
|
80
|
+
1 | key1-2 | test key
|
81
|
+
1 | key1-3 | test key
|
82
|
+
2 | key2-3 | test key
|
83
|
+
1 | KEY1-3 | should work
|
84
|
+
2 | key2-9 | test key
|
85
|
+
(6 rows)
|
86
|
+
|
87
|
+
select * from T_pkey2;
|
88
|
+
key1 | key2 | txt
|
89
|
+
------+--------+----------
|
90
|
+
1 | KEY1-3 | test key
|
91
|
+
2 | KEY2-3 | test key
|
92
|
+
2 | KEY2-9 | test key
|
93
|
+
1 | KEY1-9 | test key
|
94
|
+
(4 rows)
|
95
|
+
|
96
|
+
select * from T_dta1;
|
97
|
+
tkey | ref1 | ref2
|
98
|
+
--------+------+--------
|
99
|
+
trec 1 | 1 | key1-1
|
100
|
+
trec 2 | 1 | key1-2
|
101
|
+
trec 3 | 1 | key1-3
|
102
|
+
(3 rows)
|
103
|
+
|
104
|
+
select * from T_dta2;
|
105
|
+
tkey | ref1 | ref2
|
106
|
+
--------+------+--------
|
107
|
+
trec 3 | 1 | KEY1-3
|
108
|
+
trec 1 | 1 | KEY1-9
|
109
|
+
(2 rows)
|
110
|
+
|
111
|
+
select ruby_avg(key1) from T_pkey1;
|
112
|
+
ruby_avg
|
113
|
+
----------
|
114
|
+
1
|
115
|
+
(1 row)
|
116
|
+
|
117
|
+
select ruby_sum(key1) from T_pkey1;
|
118
|
+
ruby_sum
|
119
|
+
----------
|
120
|
+
8
|
121
|
+
(1 row)
|
122
|
+
|
123
|
+
select ruby_avg(key1) from T_pkey2;
|
124
|
+
ruby_avg
|
125
|
+
----------
|
126
|
+
1
|
127
|
+
(1 row)
|
128
|
+
|
129
|
+
select ruby_sum(key1) from T_pkey2;
|
130
|
+
ruby_sum
|
131
|
+
----------
|
132
|
+
6
|
133
|
+
(1 row)
|
134
|
+
|
135
|
+
select ruby_avg(key1) from T_pkey1 where key1 = 99;
|
136
|
+
ruby_avg
|
137
|
+
----------
|
138
|
+
|
139
|
+
(1 row)
|
140
|
+
|
141
|
+
select ruby_sum(key1) from T_pkey1 where key1 = 99;
|
142
|
+
ruby_sum
|
143
|
+
----------
|
144
|
+
0
|
145
|
+
(1 row)
|
146
|
+
|
147
|
+
select 1 @< 2;
|
148
|
+
?column?
|
149
|
+
----------
|
150
|
+
t
|
151
|
+
(1 row)
|
152
|
+
|
153
|
+
select 100 @< 4;
|
154
|
+
?column?
|
155
|
+
----------
|
156
|
+
f
|
157
|
+
(1 row)
|
158
|
+
|
159
|
+
select * from T_pkey1 order by key1 using @<;
|
160
|
+
ERROR: operator @< is not a valid ordering operator
|
161
|
+
LINE 1: select * from T_pkey1 order by key1 using @<;
|
162
|
+
^
|
163
|
+
HINT: Ordering operators must be "<" or ">" members of btree operator families.
|
164
|
+
select * from T_pkey2 order by key1 using @<;
|
165
|
+
ERROR: operator @< is not a valid ordering operator
|
166
|
+
LINE 1: select * from T_pkey2 order by key1 using @<;
|
167
|
+
^
|
168
|
+
HINT: Ordering operators must be "<" or ">" members of btree operator families.
|
data/test/plt/test.out
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
insert into T_pkey1 values (1, 'key1-1', 'test key');
|
2
|
+
insert into T_pkey1 values (1, 'key1-2', 'test key');
|
3
|
+
insert into T_pkey1 values (1, 'key1-3', 'test key');
|
4
|
+
insert into T_pkey1 values (2, 'key2-1', 'test key');
|
5
|
+
insert into T_pkey1 values (2, 'key2-2', 'test key');
|
6
|
+
insert into T_pkey1 values (2, 'key2-3', 'test key');
|
7
|
+
insert into T_pkey2 values (1, 'key1-1', 'test key');
|
8
|
+
insert into T_pkey2 values (1, 'key1-2', 'test key');
|
9
|
+
insert into T_pkey2 values (1, 'key1-3', 'test key');
|
10
|
+
insert into T_pkey2 values (2, 'key2-1', 'test key');
|
11
|
+
insert into T_pkey2 values (2, 'key2-2', 'test key');
|
12
|
+
insert into T_pkey2 values (2, 'key2-3', 'test key');
|
13
|
+
select * from T_pkey1;
|
14
|
+
key1 | key2 | txt
|
15
|
+
------+--------+----------
|
16
|
+
1 | key1-1 | test key
|
17
|
+
1 | key1-2 | test key
|
18
|
+
1 | key1-3 | test key
|
19
|
+
2 | key2-1 | test key
|
20
|
+
2 | key2-2 | test key
|
21
|
+
2 | key2-3 | test key
|
22
|
+
(6 rows)
|
23
|
+
|
24
|
+
select * from T_pkey2;
|
25
|
+
key1 | key2 | txt
|
26
|
+
------+--------+----------
|
27
|
+
1 | KEY1-1 | test key
|
28
|
+
1 | KEY1-2 | test key
|
29
|
+
1 | KEY1-3 | test key
|
30
|
+
2 | KEY2-1 | test key
|
31
|
+
2 | KEY2-2 | test key
|
32
|
+
2 | KEY2-3 | test key
|
33
|
+
(6 rows)
|
34
|
+
|
35
|
+
insert into T_pkey1 values (1, 'KEY1-3', 'should work');
|
36
|
+
insert into T_pkey2 values (1, 'KEY1-3', 'should fail');
|
37
|
+
ERROR: duplicate key '1', 'KEY1-3' for T_pkey2
|
38
|
+
insert into T_dta1 values ('trec 1', 1, 'key1-1');
|
39
|
+
insert into T_dta1 values ('trec 2', 1, 'key1-2');
|
40
|
+
insert into T_dta1 values ('trec 3', 1, 'key1-3');
|
41
|
+
insert into T_dta1 values ('trec 4', 1, 'key1-4');
|
42
|
+
ERROR: key for t_dta1 not in t_pkey1
|
43
|
+
insert into T_dta2 values ('trec 1', 1, 'KEY1-1');
|
44
|
+
insert into T_dta2 values ('trec 2', 1, 'KEY1-2');
|
45
|
+
insert into T_dta2 values ('trec 3', 1, 'KEY1-3');
|
46
|
+
insert into T_dta2 values ('trec 4', 1, 'KEY1-4');
|
47
|
+
ERROR: key for t_dta2 not in t_pkey2
|
48
|
+
select * from T_dta1;
|
49
|
+
tkey | ref1 | ref2
|
50
|
+
--------+------+--------
|
51
|
+
trec 1 | 1 | key1-1
|
52
|
+
trec 2 | 1 | key1-2
|
53
|
+
trec 3 | 1 | key1-3
|
54
|
+
(3 rows)
|
55
|
+
|
56
|
+
select * from T_dta2;
|
57
|
+
tkey | ref1 | ref2
|
58
|
+
--------+------+--------
|
59
|
+
trec 1 | 1 | KEY1-1
|
60
|
+
trec 2 | 1 | KEY1-2
|
61
|
+
trec 3 | 1 | KEY1-3
|
62
|
+
(3 rows)
|
63
|
+
|
64
|
+
update T_pkey1 set key2 = 'key2-9' where key1 = 2 and key2 = 'key2-1';
|
65
|
+
update T_pkey1 set key2 = 'key1-9' where key1 = 1 and key2 = 'key1-1';
|
66
|
+
ERROR: key '1', 'key1-1' referenced by T_dta1
|
67
|
+
delete from T_pkey1 where key1 = 2 and key2 = 'key2-2';
|
68
|
+
delete from T_pkey1 where key1 = 1 and key2 = 'key1-2';
|
69
|
+
ERROR: key '1', 'key1-2' referenced by T_dta1
|
70
|
+
update T_pkey2 set key2 = 'KEY2-9' where key1 = 2 and key2 = 'KEY2-1';
|
71
|
+
update T_pkey2 set key2 = 'KEY1-9' where key1 = 1 and key2 = 'KEY1-1';
|
72
|
+
NOTICE: updated 1 entries in T_dta2 for new key in T_pkey2
|
73
|
+
delete from T_pkey2 where key1 = 2 and key2 = 'KEY2-2';
|
74
|
+
delete from T_pkey2 where key1 = 1 and key2 = 'KEY1-2';
|
75
|
+
NOTICE: deleted 1 entries from T_dta2
|
76
|
+
select * from T_pkey1;
|
77
|
+
key1 | key2 | txt
|
78
|
+
------+--------+-------------
|
79
|
+
1 | key1-1 | test key
|
80
|
+
1 | key1-2 | test key
|
81
|
+
1 | key1-3 | test key
|
82
|
+
2 | key2-3 | test key
|
83
|
+
1 | KEY1-3 | should work
|
84
|
+
2 | key2-9 | test key
|
85
|
+
(6 rows)
|
86
|
+
|
87
|
+
select * from T_pkey2;
|
88
|
+
key1 | key2 | txt
|
89
|
+
------+--------+----------
|
90
|
+
1 | KEY1-3 | test key
|
91
|
+
2 | KEY2-3 | test key
|
92
|
+
2 | KEY2-9 | test key
|
93
|
+
1 | KEY1-9 | test key
|
94
|
+
(4 rows)
|
95
|
+
|
96
|
+
select * from T_dta1;
|
97
|
+
tkey | ref1 | ref2
|
98
|
+
--------+------+--------
|
99
|
+
trec 1 | 1 | key1-1
|
100
|
+
trec 2 | 1 | key1-2
|
101
|
+
trec 3 | 1 | key1-3
|
102
|
+
(3 rows)
|
103
|
+
|
104
|
+
select * from T_dta2;
|
105
|
+
tkey | ref1 | ref2
|
106
|
+
--------+------+--------
|
107
|
+
trec 3 | 1 | KEY1-3
|
108
|
+
trec 1 | 1 | KEY1-9
|
109
|
+
(2 rows)
|
110
|
+
|
111
|
+
select ruby_avg(key1) from T_pkey1;
|
112
|
+
ruby_avg
|
113
|
+
----------
|
114
|
+
1
|
115
|
+
(1 row)
|
116
|
+
|
117
|
+
select ruby_sum(key1) from T_pkey1;
|
118
|
+
ruby_sum
|
119
|
+
----------
|
120
|
+
8
|
121
|
+
(1 row)
|
122
|
+
|
123
|
+
select ruby_avg(key1) from T_pkey2;
|
124
|
+
ruby_avg
|
125
|
+
----------
|
126
|
+
1
|
127
|
+
(1 row)
|
128
|
+
|
129
|
+
select ruby_sum(key1) from T_pkey2;
|
130
|
+
ruby_sum
|
131
|
+
----------
|
132
|
+
6
|
133
|
+
(1 row)
|
134
|
+
|
135
|
+
select ruby_avg(key1) from T_pkey1 where key1 = 99;
|
136
|
+
ruby_avg
|
137
|
+
----------
|
138
|
+
|
139
|
+
(1 row)
|
140
|
+
|
141
|
+
select ruby_sum(key1) from T_pkey1 where key1 = 99;
|
142
|
+
ruby_sum
|
143
|
+
----------
|
144
|
+
0
|
145
|
+
(1 row)
|
146
|
+
|
147
|
+
select 1 @< 2;
|
148
|
+
?column?
|
149
|
+
----------
|
150
|
+
t
|
151
|
+
(1 row)
|
152
|
+
|
153
|
+
select 100 @< 4;
|
154
|
+
?column?
|
155
|
+
----------
|
156
|
+
f
|
157
|
+
(1 row)
|
158
|
+
|
159
|
+
select * from T_pkey1 order by key1 using @<;
|
160
|
+
ERROR: operator @< is not a valid ordering operator
|
161
|
+
LINE 1: select * from T_pkey1 order by key1 using @<;
|
162
|
+
^
|
163
|
+
HINT: Ordering operators must be "<" or ">" members of btree operator families.
|
164
|
+
select * from T_pkey2 order by key1 using @<;
|
165
|
+
ERROR: operator @< is not a valid ordering operator
|
166
|
+
LINE 1: select * from T_pkey2 order by key1 using @<;
|
167
|
+
^
|
168
|
+
HINT: Ordering operators must be "<" or ">" members of btree operator families.
|