Compare commits
620 Commits
0.3.0-serv
...
python-0.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d22942a72 | ||
|
|
e8122c6728 | ||
|
|
d4ac2eb5e6 | ||
|
|
db80d389e0 | ||
|
|
8e02c64aeb | ||
|
|
cc2ab1bc0c | ||
|
|
948463f836 | ||
|
|
e1a7d1751c | ||
|
|
0c49107f96 | ||
|
|
05dc69af34 | ||
|
|
247034c21e | ||
|
|
2b1b1c981f | ||
|
|
aaff5564ec | ||
|
|
72998c324a | ||
|
|
bbd9b6b98e | ||
|
|
27be704bd6 | ||
|
|
03f4a1f4f7 | ||
|
|
91131488c5 | ||
|
|
7d137f3efc | ||
|
|
93a5de5f20 | ||
|
|
fc35aac639 | ||
|
|
98d533b707 | ||
|
|
6d0ad85d48 | ||
|
|
00e6cace76 | ||
|
|
e9ad35ba1d | ||
|
|
dcb3935021 | ||
|
|
cded6c2f08 | ||
|
|
e1b357137a | ||
|
|
3844cfc226 | ||
|
|
2a1276f4f1 | ||
|
|
35da7e48fd | ||
|
|
12aebb7eee | ||
|
|
0d87a95270 | ||
|
|
18e1a5c7c9 | ||
|
|
fcca5da302 | ||
|
|
1aec541906 | ||
|
|
9e98e0794d | ||
|
|
8fbb41742c | ||
|
|
275a6dc27f | ||
|
|
d522083d5c | ||
|
|
073163eb1a | ||
|
|
0c62c4bada | ||
|
|
3361960cfc | ||
|
|
86ab3abc53 | ||
|
|
b1f3405cd0 | ||
|
|
fb812ee15e | ||
|
|
c1dd410201 | ||
|
|
34ddd28e6b | ||
|
|
d85bc65bf8 | ||
|
|
443fe88d5a | ||
|
|
6c61626214 | ||
|
|
74d2fba763 | ||
|
|
e24819f193 | ||
|
|
1e6ee8d5c1 | ||
|
|
3a6cc4c364 | ||
|
|
8ad2434b1d | ||
|
|
0b7b44d8a5 | ||
|
|
02a2619b45 | ||
|
|
4b4a02905c | ||
|
|
1f3a655ae5 | ||
|
|
9d60fde0b8 | ||
|
|
efdc151282 | ||
|
|
fd2cc21942 | ||
|
|
18f05fbd4f | ||
|
|
d2f4586bae | ||
|
|
54eb279ae8 | ||
|
|
85d6c2a54e | ||
|
|
cad2051efe | ||
|
|
96a93e3c56 | ||
|
|
facda9e8be | ||
|
|
64fc18b9e0 | ||
|
|
9381d5644b | ||
|
|
9f55f2ee3b | ||
|
|
1087c1266b | ||
|
|
d5a296a30c | ||
|
|
f8caf4314d | ||
|
|
d7910fbbf1 | ||
|
|
d47049c813 | ||
|
|
cc8f93c535 | ||
|
|
3f9441de7e | ||
|
|
fe41359a1f | ||
|
|
46a934b178 | ||
|
|
184358bdec | ||
|
|
a6d546f2ee | ||
|
|
fc99f7aba9 | ||
|
|
e959873b32 | ||
|
|
a98093540d | ||
|
|
78add220cd | ||
|
|
cf2f86136b | ||
|
|
fb183b07ee | ||
|
|
5ab727bcb6 | ||
|
|
1e9b551160 | ||
|
|
699dc9bf0e | ||
|
|
fc291a7c63 | ||
|
|
d73af32c2c | ||
|
|
7ea88fa051 | ||
|
|
d2ca40cf38 | ||
|
|
18ae2525b6 | ||
|
|
06462fdf7a | ||
|
|
71d5ce951a | ||
|
|
d602c42559 | ||
|
|
d88763f889 | ||
|
|
c86496478a | ||
|
|
1851b2b716 | ||
|
|
3cc4e06420 | ||
|
|
a1f7dccb07 | ||
|
|
0c0f231db3 | ||
|
|
38439065fd | ||
|
|
13b10063e2 | ||
|
|
a2aeac9c3b | ||
|
|
46c96e02b4 | ||
|
|
2117b931bf | ||
|
|
a5696f84b1 | ||
|
|
8b4b04a669 | ||
|
|
a1fc7ba3fd | ||
|
|
19b3e05661 | ||
|
|
1107371f6f | ||
|
|
fd80f3b99f | ||
|
|
d63f2ba4d5 | ||
|
|
0fb3cdd8b1 | ||
|
|
0ef333b274 | ||
|
|
6f68014eab | ||
|
|
91b35e04a6 | ||
|
|
7f2f6e7d99 | ||
|
|
5f8416d166 | ||
|
|
02a8825c49 | ||
|
|
7cca8e95c3 | ||
|
|
f97294cfc1 | ||
|
|
fcee6f440c | ||
|
|
a33999ed04 | ||
|
|
9186eb5d5b | ||
|
|
ed5cf25e9c | ||
|
|
5d5e8d6f9a | ||
|
|
993059eafb | ||
|
|
f9f39dcf9c | ||
|
|
e456ff9170 | ||
|
|
4d47b905e8 | ||
|
|
0e556ee9ac | ||
|
|
70f290cdcf | ||
|
|
2417441ef4 | ||
|
|
83493e4dc6 | ||
|
|
9c982c3a97 | ||
|
|
6349be476d | ||
|
|
073be9dae4 | ||
|
|
4fdca01a73 | ||
|
|
c23a57c03f | ||
|
|
ca7d0ba239 | ||
|
|
d1b17a6603 | ||
|
|
a68ab22c89 | ||
|
|
e3b053d4cd | ||
|
|
ae568ed741 | ||
|
|
341ee05f87 | ||
|
|
efde2ee1b7 | ||
|
|
fc399c12c1 | ||
|
|
f03897257e | ||
|
|
90998d4819 | ||
|
|
5c5bed5557 | ||
|
|
d0f8797ccb | ||
|
|
eb2c713b0e | ||
|
|
79d0b5ba7c | ||
|
|
15eb8633d7 | ||
|
|
ea4ee402a8 | ||
|
|
e8d55ec68a | ||
|
|
69548eaa25 | ||
|
|
ff8eed9750 | ||
|
|
91c715f9f5 | ||
|
|
a5bf57a197 | ||
|
|
5f32f7e2cd | ||
|
|
91b1648f12 | ||
|
|
d5b6d1f5f1 | ||
|
|
28f49bdad2 | ||
|
|
3c63c4ec43 | ||
|
|
8e4c1554bb | ||
|
|
39a7cc955a | ||
|
|
1ee7992504 | ||
|
|
6cd53b519b | ||
|
|
261fff7873 | ||
|
|
66e1183e00 | ||
|
|
3b524ee3bc | ||
|
|
5bc2d974ac | ||
|
|
5da4e245ed | ||
|
|
8d3c99bc7c | ||
|
|
14dffc8841 | ||
|
|
9fffd24133 | ||
|
|
0eba673f59 | ||
|
|
9c068fa45e | ||
|
|
554af3075e | ||
|
|
9f4df6fa7d | ||
|
|
7d24ba4efb | ||
|
|
65d8ab3c74 | ||
|
|
aafacc3af7 | ||
|
|
7b1132b4d2 | ||
|
|
e3a9a0c08d | ||
|
|
62f866fb55 | ||
|
|
99d21f9a84 | ||
|
|
ca1461c020 | ||
|
|
2aace4bf7d | ||
|
|
6fb9f67e64 | ||
|
|
5721e10520 | ||
|
|
4e6aa0721d | ||
|
|
b2f487664a | ||
|
|
64e02e2f77 | ||
|
|
d22bf661e1 | ||
|
|
d8aa646251 | ||
|
|
d48ee48119 | ||
|
|
8f7e94e7d6 | ||
|
|
aff5dd13d7 | ||
|
|
97f4a8228b | ||
|
|
1022097300 | ||
|
|
442a9a8433 | ||
|
|
5c20866277 | ||
|
|
caf4fe8e23 | ||
|
|
f5d51da673 | ||
|
|
9c87762b8b | ||
|
|
9b7a2d491f | ||
|
|
bcc6bc35d3 | ||
|
|
99798f2618 | ||
|
|
230112b7e5 | ||
|
|
523eda2cc7 | ||
|
|
54221fa671 | ||
|
|
6d888a7a62 | ||
|
|
075edf0e0d | ||
|
|
6c4829df01 | ||
|
|
7ddb3da60d | ||
|
|
ff4eb5b348 | ||
|
|
2147d190a1 | ||
|
|
a046d3ce97 | ||
|
|
cdcac2dc1f | ||
|
|
3dacb43a9a | ||
|
|
eb906fae35 | ||
|
|
e9346faf42 | ||
|
|
6810dc0ff0 | ||
|
|
b78bd05754 | ||
|
|
77cdc3d8ff | ||
|
|
2d95601c5a | ||
|
|
9a9f35d9c2 | ||
|
|
9becf1adb4 | ||
|
|
87413255af | ||
|
|
46971fe96f | ||
|
|
96199b0d6d | ||
|
|
a70560e566 | ||
|
|
53fe4ce21d | ||
|
|
40cacd99dc | ||
|
|
893b8db374 | ||
|
|
9f210fbc5a | ||
|
|
45fcfe44e2 | ||
|
|
a4b0725843 | ||
|
|
4075e7349b | ||
|
|
6d35cff9c7 | ||
|
|
3a43cf2094 | ||
|
|
d6a3d26cf7 | ||
|
|
f46b2f68f4 | ||
|
|
a3bdbf6461 | ||
|
|
465e55713e | ||
|
|
92b89b7408 | ||
|
|
50ac8bc972 | ||
|
|
b3c8c86561 | ||
|
|
ffe44ce94e | ||
|
|
88d2af4e0a | ||
|
|
4b79ab988e | ||
|
|
4b72af34ec | ||
|
|
d517c62e6f | ||
|
|
01edf81600 | ||
|
|
c0ad0412bf | ||
|
|
6886a8639f | ||
|
|
1ed02c69bc | ||
|
|
6c627fb207 | ||
|
|
594fb99854 | ||
|
|
4df1c26973 | ||
|
|
d53e394532 | ||
|
|
63ae4a362a | ||
|
|
5ebc2ce2e3 | ||
|
|
e822321306 | ||
|
|
500d860f46 | ||
|
|
b33730aae3 | ||
|
|
9ed059f4cc | ||
|
|
972970a12d | ||
|
|
37bcaeada3 | ||
|
|
25bf9b6372 | ||
|
|
f76a5cdfcc | ||
|
|
e046ca2c4d | ||
|
|
c9f57259be | ||
|
|
a566397f16 | ||
|
|
9ba8f92418 | ||
|
|
41b9db4144 | ||
|
|
25d42a75e4 | ||
|
|
f9e9617d6f | ||
|
|
b0bb60736c | ||
|
|
a2863d7135 | ||
|
|
a114f857fd | ||
|
|
47962c9ccb | ||
|
|
901f5d7b8b | ||
|
|
c7bcbddaa9 | ||
|
|
9ad55a4d53 | ||
|
|
14ba8c6b84 | ||
|
|
f4d8d28d14 | ||
|
|
faab16bb64 | ||
|
|
3e74ac05bb | ||
|
|
2b35c0b375 | ||
|
|
6412d432bf | ||
|
|
a68f6e9705 | ||
|
|
27124e26dd | ||
|
|
175d5e716d | ||
|
|
d57856367a | ||
|
|
770ff0eb95 | ||
|
|
0fc9469430 | ||
|
|
29c719354a | ||
|
|
a613ee3039 | ||
|
|
2d67865079 | ||
|
|
6b7e67304a | ||
|
|
6d398a9499 | ||
|
|
ecbcf98670 | ||
|
|
587ae051f5 | ||
|
|
b33d696817 | ||
|
|
5e027d5001 | ||
|
|
337c47cd81 | ||
|
|
bf121ea3e3 | ||
|
|
21aac960a6 | ||
|
|
ae86785ece | ||
|
|
7815c9cdc7 | ||
|
|
d17b5656fb | ||
|
|
f46305de6f | ||
|
|
0fc1a24aec | ||
|
|
ed667dc301 | ||
|
|
982f178d5a | ||
|
|
3c222bd82d | ||
|
|
bbcba337f5 | ||
|
|
6887adcdb0 | ||
|
|
7b8165fbed | ||
|
|
48779e56ef | ||
|
|
2a98a673d1 | ||
|
|
9a49a20358 | ||
|
|
d63c688851 | ||
|
|
0d5fa7a199 | ||
|
|
5e61ef2076 | ||
|
|
75fc489143 | ||
|
|
3d617a4349 | ||
|
|
6abc5a4cdd | ||
|
|
fedcd606c5 | ||
|
|
4730088a22 | ||
|
|
8df879f7d3 | ||
|
|
8a8a5e11b5 | ||
|
|
eb6fe79a4c | ||
|
|
182e6a0e92 | ||
|
|
77e31db729 | ||
|
|
67383efd44 | ||
|
|
0ac00153be | ||
|
|
6052582a0c | ||
|
|
31d3111b82 | ||
|
|
50c4126747 | ||
|
|
5376af3d2b | ||
|
|
f9c0b73737 | ||
|
|
0d90b602cb | ||
|
|
bb17b3bff7 | ||
|
|
aa3cb46dee | ||
|
|
86dabe1c35 | ||
|
|
22883352e1 | ||
|
|
6540519a91 | ||
|
|
5d6c3d7b11 | ||
|
|
8680c9cbd0 | ||
|
|
f59217779e | ||
|
|
c7c9e6e284 | ||
|
|
64d2afb536 | ||
|
|
632cfd9293 | ||
|
|
4f8fc16434 | ||
|
|
1039d1caa8 | ||
|
|
d745ba2ae7 | ||
|
|
42a33cf74c | ||
|
|
33b48ade5c | ||
|
|
efdc1b759e | ||
|
|
3e09605757 | ||
|
|
d49f97de2b | ||
|
|
bf2930984d | ||
|
|
1345a97055 | ||
|
|
0735bbcb41 | ||
|
|
8c6318e25d | ||
|
|
5de6a2430d | ||
|
|
d29b156d76 | ||
|
|
01a3fa3b59 | ||
|
|
9b88e91ec2 | ||
|
|
fdc58f1eb0 | ||
|
|
5ea0d0e6da | ||
|
|
a6de16449f | ||
|
|
693c7739fb | ||
|
|
bbea5518d3 | ||
|
|
df8810f55d | ||
|
|
e81dadaf2e | ||
|
|
7cb89434bc | ||
|
|
7434b72a20 | ||
|
|
6017944db1 | ||
|
|
2628a73a3f | ||
|
|
b6cf319ed5 | ||
|
|
ee3913dd86 | ||
|
|
97b415080d | ||
|
|
dcfa0ff5d8 | ||
|
|
ae109a8cdc | ||
|
|
e70794a620 | ||
|
|
9b48a4756b | ||
|
|
ee13920a8e | ||
|
|
5efb81d809 | ||
|
|
4407ff630e | ||
|
|
a9c420ba7b | ||
|
|
976697c81e | ||
|
|
3de15de1c9 | ||
|
|
303c7c81fb | ||
|
|
b9757d2026 | ||
|
|
8aaaba3737 | ||
|
|
e73d6b84ff | ||
|
|
178651150c | ||
|
|
b0d614d032 | ||
|
|
b3e6d6731a | ||
|
|
403f0d2164 | ||
|
|
d9ffe539f4 | ||
|
|
06e8752c33 | ||
|
|
c3b695d1e7 | ||
|
|
ea087713c5 | ||
|
|
1daf78e41a | ||
|
|
3c5325c1d7 | ||
|
|
dda13033b0 | ||
|
|
f5dd2a7011 | ||
|
|
b4f4ac1d99 | ||
|
|
6d852bd27a | ||
|
|
1e30b21d35 | ||
|
|
4c5c31cfea | ||
|
|
5ac9bd884f | ||
|
|
5008470ac2 | ||
|
|
15a7ed5a09 | ||
|
|
ad5d25f0a0 | ||
|
|
6b6c30ff17 | ||
|
|
3ed89c09d5 | ||
|
|
2ffee03e7b | ||
|
|
8cd94973ff | ||
|
|
9fce6b558b | ||
|
|
8955b0cd9b | ||
|
|
6d88580fdf | ||
|
|
2ab7c78b35 | ||
|
|
c9ddc37051 | ||
|
|
c8ea635385 | ||
|
|
923774ffe4 | ||
|
|
cb921614c3 | ||
|
|
ccd5daa63e | ||
|
|
6eb8df2955 | ||
|
|
b4c1991c90 | ||
|
|
1fbab0617f | ||
|
|
d18eb95575 | ||
|
|
3c1250ee72 | ||
|
|
7e8d666c8c | ||
|
|
f223ad9ca0 | ||
|
|
2c8cfa3032 | ||
|
|
0b53ede06c | ||
|
|
6bd854a395 | ||
|
|
30cb5869f1 | ||
|
|
187fe8f849 | ||
|
|
ee9e5aba38 | ||
|
|
6105f677af | ||
|
|
9e90ee3e1f | ||
|
|
ea24aa938f | ||
|
|
75d58dc836 | ||
|
|
652bd6abd6 | ||
|
|
dab46269d4 | ||
|
|
d5c896274c | ||
|
|
8eeef94eab | ||
|
|
14d02fd63f | ||
|
|
a0377150f3 | ||
|
|
79e69c6020 | ||
|
|
c04e8fa586 | ||
|
|
9c47bc45e7 | ||
|
|
a8dd211acf | ||
|
|
bfb8df54f4 | ||
|
|
5c23a43efa | ||
|
|
ac49dc1fda | ||
|
|
3af2a8f8f0 | ||
|
|
752d8317a2 | ||
|
|
8c5a4d32de | ||
|
|
0ba513d13d | ||
|
|
f29f0769d7 | ||
|
|
d625b26e57 | ||
|
|
62da0eff21 | ||
|
|
5f74d012a6 | ||
|
|
42b1d6f630 | ||
|
|
7de498cc95 | ||
|
|
1505e0e6ea | ||
|
|
2668a1dfdc | ||
|
|
03ce547b8e | ||
|
|
28b4b12ce4 | ||
|
|
dd2af74b03 | ||
|
|
020f428ceb | ||
|
|
98a7762da6 | ||
|
|
0deb834531 | ||
|
|
67e1ddd6a4 | ||
|
|
1d5545b239 | ||
|
|
89ec3dcfa6 | ||
|
|
0117830ffd | ||
|
|
d622e17608 | ||
|
|
fcee72f42f | ||
|
|
357458f44d | ||
|
|
0ca1b84096 | ||
|
|
f92191a69f | ||
|
|
4061009df0 | ||
|
|
47f2eba4e4 | ||
|
|
30001b68a7 | ||
|
|
b3db80eeaf | ||
|
|
f8fc424e4c | ||
|
|
7802f85c4b | ||
|
|
0f262510b2 | ||
|
|
b9f18dda69 | ||
|
|
7acf70131b | ||
|
|
0e44910165 | ||
|
|
1c33a72fdc | ||
|
|
5d57624fd5 | ||
|
|
f0a49d5fbc | ||
|
|
6fb891ec86 | ||
|
|
1bdf2e80e6 | ||
|
|
3ba70358d5 | ||
|
|
f85c4f1bbf | ||
|
|
60f17fdb09 | ||
|
|
bd2e380225 | ||
|
|
c293b55c3c | ||
|
|
b97e838416 | ||
|
|
ac1627b5c5 | ||
|
|
0b4d1bb17f | ||
|
|
e867394261 | ||
|
|
7237e01601 | ||
|
|
fbd42e3db0 | ||
|
|
3bf81b426b | ||
|
|
f4082b3a00 | ||
|
|
df08b27068 | ||
|
|
4d04882c18 | ||
|
|
ad3e457b4c | ||
|
|
2b084ee2ab | ||
|
|
7ddd2dfc8a | ||
|
|
d99a0c80d3 | ||
|
|
9a36445661 | ||
|
|
df195a9539 | ||
|
|
e6b0e3794b | ||
|
|
d2e73a69fa | ||
|
|
2a807af6df | ||
|
|
6c5b1b4e99 | ||
|
|
472d8c2360 | ||
|
|
ab32065e1d | ||
|
|
04617332a2 | ||
|
|
93463b3032 | ||
|
|
557f67c51f | ||
|
|
d27b2a2b78 | ||
|
|
f42d007b77 | ||
|
|
926655fdf9 | ||
|
|
599f58fce0 | ||
|
|
06a850efb0 | ||
|
|
a69f767417 | ||
|
|
b0f4d5db88 | ||
|
|
0ab255eb93 | ||
|
|
6c9d59d7c0 | ||
|
|
826a3e65c0 | ||
|
|
2090ed56bc | ||
|
|
448f47589a | ||
|
|
c4d682a5a5 | ||
|
|
d0bf339250 | ||
|
|
31711851c4 | ||
|
|
23780b3f3a | ||
|
|
fa16d3fddf | ||
|
|
880cfd8742 | ||
|
|
05179a4ef2 | ||
|
|
e764b9036d | ||
|
|
134d2f400e | ||
|
|
610b9aef64 | ||
|
|
03d50e96f4 | ||
|
|
5b5f9575d8 | ||
|
|
4374f1108d | ||
|
|
9e6028872a | ||
|
|
3260c92ad2 | ||
|
|
0bb046cc21 | ||
|
|
b5cdeedb36 | ||
|
|
c8e2c7b0b3 | ||
|
|
41681a7ef1 | ||
|
|
c95aa171c7 | ||
|
|
dea64f9fe6 | ||
|
|
ecd387cc8f | ||
|
|
6a37e9a550 | ||
|
|
634ae4b96f | ||
|
|
d8bc370ab1 | ||
|
|
0da873fd6f | ||
|
|
d23b74d3c1 | ||
|
|
7b844d7773 | ||
|
|
4b7e9aa19e | ||
|
|
2c2547ea2b | ||
|
|
fdd2ecb5e1 | ||
|
|
5ff5f4d0b3 | ||
|
|
e5a72b81a5 | ||
|
|
983440086d | ||
|
|
32c146336d | ||
|
|
93f003a672 | ||
|
|
a90f8cac1c | ||
|
|
1cf766faaa | ||
|
|
fbc5a1bbf8 | ||
|
|
f44ab1fc4c | ||
|
|
2896cbb287 | ||
|
|
bde183e9c1 | ||
|
|
3889904afe | ||
|
|
3a4130282e | ||
|
|
d9ca7911e4 | ||
|
|
8d18e50cc5 | ||
|
|
0ca20196c0 | ||
|
|
f36a345db2 | ||
|
|
5c1b320555 | ||
|
|
d0f7ac4d49 | ||
|
|
d4a2184ce0 | ||
|
|
42d0812383 | ||
|
|
e996d3796a | ||
|
|
b97ce043c3 | ||
|
|
bd3f6678c1 | ||
|
|
54622d5c81 | ||
|
|
75a915019f | ||
|
|
13cfee2d4c | ||
|
|
3b0f92d5e7 | ||
|
|
9029e38216 | ||
|
|
b8c7015994 | ||
|
|
05cd8f5c5c | ||
|
|
910381e4a6 | ||
|
|
3f6381ba78 | ||
|
|
48e00329f3 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,6 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
*.pyc
|
*.pyc
|
||||||
|
.coverage
|
||||||
|
cartodb_services.egg-info/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
|||||||
429
NEWS.md
Normal file
429
NEWS.md
Normal file
@@ -0,0 +1,429 @@
|
|||||||
|
October 21st, 2016
|
||||||
|
==================
|
||||||
|
* Version 0.9.2 of the python package
|
||||||
|
* mapzen routing quota now is configurable per user
|
||||||
|
|
||||||
|
September 28, 2016
|
||||||
|
==========
|
||||||
|
* Released version 0.8.1 of Python package cartodb\_services
|
||||||
|
* Improvements in QPS retry decorator for requests to external services
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/python-0.8.1
|
||||||
|
|
||||||
|
September 8, 2016
|
||||||
|
===========
|
||||||
|
* Released version 0.11.1 of the client
|
||||||
|
* Minor change in the name of the function parameter sent to server and Observatory backend for compatibility with the last observatory-extension framework updates
|
||||||
|
|
||||||
|
September 1, 2016
|
||||||
|
===========
|
||||||
|
* Released version 0.11.0 of the client
|
||||||
|
* Include DS table functions to create and populate a table with the GetMeasure function in observatory
|
||||||
|
* Released version 0.15.1 of the server
|
||||||
|
* Rename DS table functions
|
||||||
|
|
||||||
|
August 29, 2016
|
||||||
|
===========
|
||||||
|
* Released version 0.15.0 of the server
|
||||||
|
* Geocode namedplace point functions uses Mapzen search service and in case of error
|
||||||
|
it'll use the internal geocoder
|
||||||
|
|
||||||
|
August 19, 2016
|
||||||
|
===========
|
||||||
|
* Released version 0.7.4.2 of the server python library
|
||||||
|
* Now connection errors, that intermittently come from Mapzen geocoding service, are caught and treated
|
||||||
|
* Added more information to the logs from response
|
||||||
|
* Fixed some errors in the QPS manager when the response object is None
|
||||||
|
|
||||||
|
August 11, 2016
|
||||||
|
===========
|
||||||
|
* Released server version 0.14.2
|
||||||
|
* Released client version 0.10.2
|
||||||
|
* Always default arguments for DO functions to NULL, which prevents duplication & overwrite
|
||||||
|
|
||||||
|
August 5, 2016
|
||||||
|
===========
|
||||||
|
* Released server version 0.14.1
|
||||||
|
* Fix problem with calling a logger method that doesn't exists
|
||||||
|
|
||||||
|
August 3, 2016
|
||||||
|
===========
|
||||||
|
* Released server version 0.14
|
||||||
|
* New logger with: plpy, rollbar integration and file
|
||||||
|
* Added min log level to notify as config option
|
||||||
|
* Server config to define dataservices environment for: log, third party servers, etc
|
||||||
|
* Added logger to the SQL functions
|
||||||
|
* Raise exception on events that should not be logged like reach the quota limit
|
||||||
|
|
||||||
|
July 28, 2016
|
||||||
|
===========
|
||||||
|
* Release server 0.13.3.1
|
||||||
|
* Fixed limit to 1 row for isolines with multiple range
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.13.3.1-server
|
||||||
|
|
||||||
|
July 25, 2016
|
||||||
|
===========
|
||||||
|
* Release client 0.10.1
|
||||||
|
* Includes an update of the `__AugmentTable` function of the client which creates an index on `cartodb_id` for the temporary table that stores the augmented results that will be afterwards joined with the original table by using this same key, `cartodb_id`.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.10.1-client
|
||||||
|
|
||||||
|
July 25, 2016
|
||||||
|
===========
|
||||||
|
* Release server 0.13.3
|
||||||
|
* Add provider per service
|
||||||
|
* Default provider in case the provider is not setted
|
||||||
|
* Refactor and improvements in the multiprovider services functions
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.13.3-server
|
||||||
|
|
||||||
|
July 22, 2016
|
||||||
|
===========
|
||||||
|
* Release server 0.13.2
|
||||||
|
* Fixes bug with multirange isolines #233
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.13.2-server
|
||||||
|
|
||||||
|
July 15, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.13.1
|
||||||
|
* Includes a fix for the table augmentation functions in the server, which will now retrieve the client IP address and send it to the observatory functions as a new parameter. The affected functions are:
|
||||||
|
|
||||||
|
* _OBS_ConnectUserTable
|
||||||
|
|
||||||
|
* __OBS_ConnectUserTable
|
||||||
|
|
||||||
|
This change does not require any client change.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.13.1-server
|
||||||
|
|
||||||
|
Jul 12, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.13.0
|
||||||
|
* [Server] Add beta augment functions, isoline fixes, observatory dump version
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.13.0-server
|
||||||
|
|
||||||
|
Jul 12, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.10.0
|
||||||
|
* [Client] Add beta augment functions, isoline fixes, observatory dump version
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.10.0-client
|
||||||
|
|
||||||
|
Jul 7, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.9.0
|
||||||
|
* This release adds two new functions in the Data Services extension client:
|
||||||
|
* cdb_mapzen_isodistance
|
||||||
|
* cdb_mapzen_isochrone
|
||||||
|
it also includes a bugfix for the previous release in which the explicit GRANTs to the new functions for the here, google and mapzen geocoder providers was missing in the upgrade file.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.9.0-client
|
||||||
|
|
||||||
|
Jul 7, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.12.0
|
||||||
|
* This release adds four new functions in the Data Services extension server:
|
||||||
|
* cdb_mapzen_isodistance
|
||||||
|
* cdb_mapzen_isochrone
|
||||||
|
* _cdb_mapzen_isolines, which contains the real isoline logic.
|
||||||
|
* _get_mapzen_isolines_config which retrieves the explicit configuration for the Mapzen matrix service.
|
||||||
|
* In the Python end, this release adds the new Mapzen Matrix logic as well as the additions in the configuration and metrics file for the new service type mapzen_isolines.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.12.0-server
|
||||||
|
|
||||||
|
Jul 5, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.11.0
|
||||||
|
* Added three new public functions for each geocoding provider:
|
||||||
|
* cdb_here_geocode_street_point
|
||||||
|
* cdb_google_geocode_street_point
|
||||||
|
* cdb_mapzen_geocode_street_point
|
||||||
|
* Added new function to retrieve specifically Mapzen configuration:
|
||||||
|
* _get_mapzen_geocoder_config
|
||||||
|
which uses the new class MapzenGeocoderConfig in the Python library.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.11.0-server
|
||||||
|
|
||||||
|
Jul 5, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.8.0
|
||||||
|
* Expose providers in high-precision geocoder functions
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.8.0-client
|
||||||
|
|
||||||
|
Jun 15, 2016:
|
||||||
|
===========
|
||||||
|
* [server python] Write quota info from services with zero padding. Closes issue #204.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.10.0-server3
|
||||||
|
|
||||||
|
Jun 13, 2016:
|
||||||
|
===========
|
||||||
|
* [server python] Read quota info from services with and without zero padding. Closes issue #201.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.10.0-server2
|
||||||
|
|
||||||
|
May 31, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.7.0
|
||||||
|
* Adds new function OBS_GetMeasureById
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.7.0-client
|
||||||
|
|
||||||
|
May 31, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.10.0
|
||||||
|
* Adds new function OBS_GetMeasureById
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.10.0-server
|
||||||
|
|
||||||
|
May 25, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.9.0
|
||||||
|
* Added a new routing function which allows to generate routes from an origin to a destination, which passes through a set of defined locations:
|
||||||
|
|
||||||
|
* cdb_dataservices_server.cdb_route_with_waypoints (username text, organization_name text, waypoints geometry(Point, 4326)[], mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
|
||||||
|
* cdb_dataservices_server._cdb_mapzen_route_with_waypoints(waypoints geometry(username text, orgname text, Point, 4326)[], mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
|
||||||
|
and updates the old cdb_route_point_to_point function to convert the input origin and destination geometries into an array of geometries.
|
||||||
|
|
||||||
|
* Support arrays of geometries as input for the Mapzen routing Python client.
|
||||||
|
|
||||||
|
* __parse_directions will now generate the locations JSON for the service from an array of geometries.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.9.0-server
|
||||||
|
|
||||||
|
May 25, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.6.0
|
||||||
|
* Includes new client function to obtain a route with waypoints:
|
||||||
|
* cdb_dataservices_client.cdb_route_with_waypoints (waypoints geometry(Point, 4326)[], mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.6.0-client
|
||||||
|
|
||||||
|
May 18, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.5.0
|
||||||
|
* Added new functions for the data observatory:
|
||||||
|
* obs_getdemographicsnapshot(geometry);
|
||||||
|
* obs_getsegmentsnapshot(geometry);
|
||||||
|
* obs_getboundary(geometry, text);
|
||||||
|
* obs_getboundaryid(geometry, text);
|
||||||
|
* obs_getboundarybyid(text, text);
|
||||||
|
* obs_getboundariesbygeometry(geometry, text);
|
||||||
|
* obs_getboundariesbypointandradius(geometry, numeric, text);
|
||||||
|
* obs_getpointsbygeometry(geometry, text);
|
||||||
|
* obs_getpointsbypointandradius(geometry, numeric, text);
|
||||||
|
* obs_getmeasure(geometry, text);
|
||||||
|
* obs_getcategory(geometry, text);
|
||||||
|
* obs_getuscensusmeasure(geometry, text);
|
||||||
|
* obs_getuscensuscategory(geometry, text);
|
||||||
|
* obs_getpopulation(geometry);
|
||||||
|
* obs_search(text);
|
||||||
|
* obs_getavailableboundaries(geometry);
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.5.0-client
|
||||||
|
|
||||||
|
May 18, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.8.0: Data Observatory release
|
||||||
|
* Added new functions for the data observatory:
|
||||||
|
* obs_getdemographicsnapshot(geometry);
|
||||||
|
* obs_getsegmentsnapshot(geometry);
|
||||||
|
* obs_getboundary(geometry, text);
|
||||||
|
* obs_getboundaryid(geometry, text);
|
||||||
|
* obs_getboundarybyid(text, text);
|
||||||
|
* obs_getboundariesbygeometry(geometry, text);
|
||||||
|
* obs_getboundariesbypointandradius(geometry, numeric, text);
|
||||||
|
* obs_getpointsbygeometry(geometry, text);
|
||||||
|
* obs_getpointsbypointandradius(geometry, numeric, text);
|
||||||
|
* obs_getmeasure(geometry, text);
|
||||||
|
* obs_getcategory(geometry, text);
|
||||||
|
* obs_getuscensusmeasure(geometry, text);
|
||||||
|
* obs_getuscensuscategory(geometry, text);
|
||||||
|
* obs_getpopulation(geometry);
|
||||||
|
* obs_search(text);
|
||||||
|
* obs_getavailableboundaries(geometry);
|
||||||
|
* Added quota manage for these new functions
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.8.0-server
|
||||||
|
|
||||||
|
May 10, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.7.4
|
||||||
|
* In case we receive a 4xx error from one of the services: isolines, here geocoder, etc we have to return an empty value an increment the empty counter. We have to raise exception in 5xx or unhandled exceptions
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.7.4-server
|
||||||
|
|
||||||
|
May 10, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.7.3
|
||||||
|
* Change how the blue/green system is working in the server side. Now the loopback is only in the observatory extension functions call instead in all the dataservices-api function for observatory
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.7.3-server
|
||||||
|
|
||||||
|
May 4, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.7.2
|
||||||
|
* Added Blue/Green capability to the data observatory functions in order to be able to use staging or production databases
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.7.2-server
|
||||||
|
|
||||||
|
Apr 25, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.7.1
|
||||||
|
* Use redis based config if exists, if not use the db config value
|
||||||
|
* Refactor key to segregate more, now the services is called obs_snapshot
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.7.1-server
|
||||||
|
|
||||||
|
Apr 21, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.4.0
|
||||||
|
* Remove old versioning system for client side
|
||||||
|
* Added obs_get_demography_snapshot function
|
||||||
|
* Added obs_get_segment snapshot function
|
||||||
|
* Integrated quota checking
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.4.0-client
|
||||||
|
|
||||||
|
Apr 21, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.7.0
|
||||||
|
* Added obs_get_demography_snapshot function
|
||||||
|
* Added obs_get_segment snapshot function
|
||||||
|
* Integrated quota checking
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.7.0-server
|
||||||
|
|
||||||
|
Apr 19, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.6.2
|
||||||
|
* Add Mapzen routing and geocoder quota check
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.6.2-server
|
||||||
|
|
||||||
|
Apr 14, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.6.1
|
||||||
|
* Now the implementation knows how to get the iso3 for the passed country in order to pass it to Mapzen
|
||||||
|
* The city an the state/province parameters are used for mapzen too
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.6.1-server
|
||||||
|
|
||||||
|
Apr 1, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.6.0.1
|
||||||
|
* Use specific isoline routing credentials for a provider for isoline functions, which were previously using the general credentials from the provider.
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.6.0.1-server
|
||||||
|
|
||||||
|
Mar 28, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.6.0
|
||||||
|
* Integrated Mapzen geocoder for street level geocoding function
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.6.0-server
|
||||||
|
|
||||||
|
Mar 23, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.5.2
|
||||||
|
* Deleted old versioning system
|
||||||
|
* 4xx responses returns empty routes despite to raise an exception
|
||||||
|
* In some cases we return and empty response: one of the inputs is null, there is no generated shape for the route, etc
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.5.2-server
|
||||||
|
|
||||||
|
Mar 17, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.5.1
|
||||||
|
* Renamed the python library metrics functions
|
||||||
|
* Create old version's folder to store the last versions
|
||||||
|
* Refactor: Move redis and DB config logic to the python library
|
||||||
|
* Generate the metrics log file
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.5.1-server
|
||||||
|
|
||||||
|
Mar 14, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.5.0
|
||||||
|
* Mapzen routing functions to calculate a route point to point
|
||||||
|
* Use of Sentinel transparently
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.5.0-server
|
||||||
|
|
||||||
|
Mar 14, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.3.0
|
||||||
|
* Added cdb_routing_point_to_point function using Mapzen as provider
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.3.0-client
|
||||||
|
|
||||||
|
Feb 26, 2016:
|
||||||
|
===========
|
||||||
|
* Release client 0.2.0
|
||||||
|
* Added routing isolines capabilities to the client and public API
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.2.0-client
|
||||||
|
|
||||||
|
Feb 26, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.4.0
|
||||||
|
* Added routing isolines capabilities
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.4.0-server
|
||||||
|
|
||||||
|
Feb 11, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.3.0
|
||||||
|
* Extension refactor, now is called cdb_dataservices_[client|server] in order to include more services aside the geocoder.
|
||||||
|
* Add logic to save the metrics for the internal geocoder services as we have for the nokia and google geocoders
|
||||||
|
* Trimmed all the inputs to avoid empty results
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.3.0-server
|
||||||
|
|
||||||
|
Feb 4, 2016:
|
||||||
|
===========
|
||||||
|
* Release server 0.2.0
|
||||||
|
* Logic for the google geocoder so the users with this geocoder setted up can use street level geocoding too
|
||||||
|
* Refactor of the python library in order to reflect the change to a services extension more than only geocoder
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.2.0-server
|
||||||
|
|
||||||
|
Jan 25, 2016:
|
||||||
|
===========
|
||||||
|
* Release Geocoder API 0.1.0
|
||||||
|
* Street geocoding available through the cdb_geocoder_street_point_v2 function (only working Heremaps geocoder)
|
||||||
|
* User config comes from Redis database
|
||||||
|
* Increment of usage metrics for the cdb_geocoder_street_v2
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.1.0
|
||||||
|
|
||||||
|
Jan 25, 2016:
|
||||||
|
===========
|
||||||
|
* Release Geocoder API 0.0.1 production ready
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.0.1
|
||||||
|
|
||||||
|
Dec 23, 2015:
|
||||||
|
===========
|
||||||
|
* Release Geocoder API 0.0.2 beta
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.0.2
|
||||||
|
|
||||||
|
Dec 3, 2015:
|
||||||
|
===========
|
||||||
|
* Release Geocoder API 0.0.1 Beta2
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.0.1-beta2
|
||||||
|
|
||||||
|
Nov 27, 2015:
|
||||||
|
===========
|
||||||
|
* Release Geocoder API BETA 1
|
||||||
|
* Added the organization public user to the api key check
|
||||||
|
|
||||||
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.0.1-beta
|
||||||
93
README.md
93
README.md
@@ -1,21 +1,100 @@
|
|||||||
# geocoder-api
|
# CARTO Data Services API
|
||||||
The CartoDB Geocoder SQL API (server and client FTM)
|
The CARTO Data Services SQL API
|
||||||
|
|
||||||
### Deploy instructions
|
### Deploy instructions
|
||||||
Steps to deploy a new Geocoder API version :
|
Steps to deploy a new Data Services API version :
|
||||||
|
|
||||||
- Deploy new version of geocoder API to all servers
|
- Deploy new version of dataservices API to all servers
|
||||||
- Update the server user using: ALTER EXTENSION cdb_geocoder_server UPDATE TO '<CURRENT_VERSION>';
|
- Update the server user using: ALTER EXTENSION cdb_dataservices_server UPDATE TO '\<CURRENT_VERSION\>';
|
||||||
- Update the python dependencies if needed: **cartodb_geocoder** and **heremaps**
|
- Update the python dependencies if needed: **cartodb_geocoder** and **heremaps**
|
||||||
- Add the needed config in the `cdb_conf` table:
|
- Add the needed config in the `cdb_conf` table:
|
||||||
- `redis_metadata_config` and `redis_metrics_conf`
|
- `redis_metadata_config` and `redis_metrics_conf`
|
||||||
- `{"sentinel_host": "localhost", "sentinel_port": 26739, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}`
|
- `{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}`
|
||||||
- `heremaps_conf`
|
- `heremaps_conf`
|
||||||
- `{"app_id": "APP_ID", "app_code": "APP_CODE"}`
|
- `{"app_id": "APP_ID", "app_code": "APP_CODE"}`
|
||||||
- Deploy the client to all the servers with the new version
|
- Deploy the client to all the servers with the new version
|
||||||
- Deploy the editor with the new geocoder api version changed (https://github.com/CartoDB/cartodb/blob/master/app/models/user/db_service.rb#L18)
|
- Deploy the editor with the new dataservices api version changed (https://github.com/CartoDB/cartodb/blob/master/app/models/user/db_service.rb#L18)
|
||||||
- Execute the rails task to update first the CartoDB team organizaton to test in production
|
- Execute the rails task to update first the CartoDB team organizaton to test in production
|
||||||
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['team']`
|
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['team']`
|
||||||
- Check if all works perfectly for our team. If so, execute the rake tasks to update all the users and organizations:
|
- Check if all works perfectly for our team. If so, execute the rake tasks to update all the users and organizations:
|
||||||
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['', true]`
|
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['', true]`
|
||||||
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_non_org_users['', true]`
|
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_non_org_users['', true]`
|
||||||
|
- Freeze the generated SQL file for the version. Eg. cdb_dataservices_server--0.0.1.sql
|
||||||
|
|
||||||
|
### Local install instructions
|
||||||
|
|
||||||
|
- install data services geocoder extension
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone git@github.com:CartoDB/data-services.git
|
||||||
|
cd data-services/geocoder/extension
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- install observatory extension
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone git@github.com:CartoDB/observatory-extension.git
|
||||||
|
cd observatory
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- install server and client extensions
|
||||||
|
|
||||||
|
```
|
||||||
|
cd client && sudo make install
|
||||||
|
cd server/extension && sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- install python library
|
||||||
|
|
||||||
|
```
|
||||||
|
cd server/lib/python/cartodb_services && sudo pip install --upgrade .
|
||||||
|
```
|
||||||
|
|
||||||
|
- install extensions in user database
|
||||||
|
|
||||||
|
```
|
||||||
|
create extension cdb_geocoder;
|
||||||
|
create extension plproxy;
|
||||||
|
create extension observatory;
|
||||||
|
create extension cdb_dataservices_server;
|
||||||
|
create extension cdb_dataservices_client;
|
||||||
|
```
|
||||||
|
|
||||||
|
- add configuration for different services in server database
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
# If sentinel is used:
|
||||||
|
SELECT CDB_Conf_SetConf('redis_metadata_config', '{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}');
|
||||||
|
SELECT CDB_Conf_SetConf('redis_metrics_config', '{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}');
|
||||||
|
|
||||||
|
# If sentinel is not used
|
||||||
|
SELECT CDB_Conf_SetConf('redis_metadata_config', '{"redis_host": "localhost", "redis_port": 6379, "sentinel_master_id": "", "timeout": 0.1, "redis_db": 5}');
|
||||||
|
SELECT CDB_Conf_SetConf('redis_metrics_config', '{"redis_host": "localhost", "redis_port": 6379, "sentinel_master_id": "", "timeout": 0.1, "redis_db": 5}');
|
||||||
|
|
||||||
|
SELECT CDB_Conf_SetConf('heremaps_conf', '{"geocoder": {"app_id": "here_geocoder_app_id", "app_code": "here_geocoder_app_code", "geocoder_cost_per_hit": "1"}, "isolines" : {"app_id": "here_isolines_app_id", "app_code": "here_geocoder_app_code"}}');
|
||||||
|
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}')
|
||||||
|
SELECT CDB_Conf_SetConf('mapzen_conf', '{"routing": {"api_key": "valhalla_app_key", "monthly_quota": 999999}, "geocoder": {"api_key": "search_app_key", "monthly_quota": 999999}, "matrix": {"api_key": "[your_matrix_key]", "monthly_quota": 1500000}}');
|
||||||
|
SELECT CDB_Conf_SetConf('logger_conf', '{"geocoder_log_path": "/tmp/geocodings.log", [ "min_log_level": "[debug|info|warning|error]", "rollbar_api_key": "SERVER_SIDE_API_KEY", "log_file_path": "LOG_FILE_PATH"]}');
|
||||||
|
SELECT CDB_Conf_SetConf('data_observatory_conf', '{"connection": {"whitelist": [], "production": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api", "staging": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api"}}');
|
||||||
|
|
||||||
|
# Environment to decide: rollbar message, which servers for third party use, etc. If not setted uses production by default (current behavior)
|
||||||
|
SELECT CDB_Conf_SetConf('server_conf', '{"environment": "[development|staging|production]"}')
|
||||||
|
```
|
||||||
|
|
||||||
|
- configure the user DB:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- Point to the dataservices server DB (you can use a specific database for the server or your same user's):
|
||||||
|
SELECT CDB_Conf_SetConf('geocoder_server_config', '{ "connection_str": "host=localhost port=5432 dbname=<SERVER_DB_NAME> user=postgres"}');
|
||||||
|
|
||||||
|
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}');
|
||||||
|
```
|
||||||
|
|
||||||
|
- configure the search path in order to be able to execute the functions without using the schema:
|
||||||
|
|
||||||
|
```
|
||||||
|
ALTER ROLE "<USER_ROLE>" SET search_path="$user", public, cartodb, cdb_dataservices_client;
|
||||||
|
```
|
||||||
|
|||||||
2
client/.gitignore
vendored
2
client/.gitignore
vendored
@@ -6,3 +6,5 @@ regression.out
|
|||||||
90_grant_execute.sql
|
90_grant_execute.sql
|
||||||
cdb_geocoder_client--0.0.1.sql
|
cdb_geocoder_client--0.0.1.sql
|
||||||
cdb_geocoder_client--0.1.0.sql
|
cdb_geocoder_client--0.1.0.sql
|
||||||
|
cdb_geocoder_client--0.2.0.sql
|
||||||
|
cdb_geocoder_client--0.3.0.sql
|
||||||
@@ -5,19 +5,20 @@ EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/defau
|
|||||||
|
|
||||||
# The new version to be generated from templates
|
# The new version to be generated from templates
|
||||||
NEW_EXTENSION_ARTIFACT = $(EXTENSION)--$(EXTVERSION).sql
|
NEW_EXTENSION_ARTIFACT = $(EXTENSION)--$(EXTVERSION).sql
|
||||||
|
OLD_VERSIONS = $(wildcard old_versions/*.sql)
|
||||||
|
|
||||||
# DATA is a special variable used by postgres build infrastructure
|
# DATA is a special variable used by postgres build infrastructure
|
||||||
# These are the files to be installed in the server shared dir,
|
# These are the files to be installed in the server shared dir,
|
||||||
# for installation from scratch, upgrades and downgrades.
|
# for installation from scratch, upgrades and downgrades.
|
||||||
# @see http://www.postgresql.org/docs/current/static/extend-pgxs.html
|
# @see http://www.postgresql.org/docs/current/static/extend-pgxs.html
|
||||||
DATA = $(NEW_EXTENSION_ARTIFACT) \
|
DATA = $(NEW_EXTENSION_ARTIFACT) \
|
||||||
cdb_dataservices_client--0.0.1.sql \
|
$(OLD_VERSIONS) \
|
||||||
cdb_dataservices_client--0.1.0--0.0.1.sql \
|
cdb_dataservices_client--0.11.0--0.11.1.sql \
|
||||||
cdb_dataservices_client--0.0.1--0.1.0.sql
|
cdb_dataservices_client--0.11.1--0.11.0.sql
|
||||||
|
|
||||||
|
|
||||||
REGRESS = $(notdir $(basename $(wildcard test/$(EXTVERSION)/sql/*test.sql)))
|
REGRESS = $(notdir $(basename $(wildcard test/sql/*test.sql)))
|
||||||
TEST_DIR = test/$(EXTVERSION)
|
TEST_DIR = test/
|
||||||
REGRESS_OPTS = --inputdir='$(TEST_DIR)' --outputdir='$(TEST_DIR)'
|
REGRESS_OPTS = --inputdir='$(TEST_DIR)' --outputdir='$(TEST_DIR)'
|
||||||
|
|
||||||
# postgres build stuff
|
# postgres build stuff
|
||||||
@@ -25,11 +26,11 @@ PG_CONFIG = pg_config
|
|||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||||
include $(PGXS)
|
include $(PGXS)
|
||||||
|
|
||||||
SOURCES_DATA_DIR = sql/$(EXTVERSION)
|
SOURCES_DATA_DIR = sql/
|
||||||
|
|
||||||
# The interface definition is used along with some templates to automatically generate code
|
# The interface definition is used along with some templates to automatically generate code
|
||||||
RENDERER = renderer/sql-template-renderer
|
RENDERER = renderer/sql-template-renderer
|
||||||
INTERFACE_FILE = renderer/interfaces/interface_$(EXTVERSION).yaml
|
INTERFACE_FILE = renderer/interface.yaml
|
||||||
TEMPLATE_DIR = renderer/templates
|
TEMPLATE_DIR = renderer/templates
|
||||||
TEMPLATE_FILES = $(wildcard $(TEMPLATE_DIR)/*.erb)
|
TEMPLATE_FILES = $(wildcard $(TEMPLATE_DIR)/*.erb)
|
||||||
GENERATED_SQL_FILES = $(patsubst $(TEMPLATE_DIR)/%.erb, $(SOURCES_DATA_DIR)/%.sql, $(TEMPLATE_FILES))
|
GENERATED_SQL_FILES = $(patsubst $(TEMPLATE_DIR)/%.erb, $(SOURCES_DATA_DIR)/%.sql, $(TEMPLATE_FILES))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# CartoDB dataservices API client extension
|
# CARTO Data Services API client extension
|
||||||
Postgres extension for the CartoDB dataservices API, client side.
|
Postgres extension for the CARTO Data Services API, client side.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
This extension is thought to be used on top of CartoDB geocoder extension, for the multiples available geocoders (internal, nokia, etc).
|
This extension is thought to be used on top of CartoDB geocoder extension, for the multiples available geocoders (internal, nokia, etc).
|
||||||
@@ -9,7 +9,7 @@ The following is a non-comprehensive list of dependencies:
|
|||||||
- Postgres 9.3+
|
- Postgres 9.3+
|
||||||
- Postgis extension
|
- Postgis extension
|
||||||
- Schema triggers extension
|
- Schema triggers extension
|
||||||
- CartoDB extension
|
- cartodb-postgresql CARTO extension
|
||||||
|
|
||||||
## Installation into the db cluster
|
## Installation into the db cluster
|
||||||
This requires root privileges
|
This requires root privileges
|
||||||
@@ -28,7 +28,7 @@ One-liner:
|
|||||||
sudo PGUSER=postgres make all install installcheck
|
sudo PGUSER=postgres make all install installcheck
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install onto a cartodb user's database
|
## Install onto a CARTO user's database
|
||||||
|
|
||||||
```
|
```
|
||||||
psql -U postgres cartodb_dev_user_fe3b850a-01c0-48f9-8a26-a82f09e9b53f_db
|
psql -U postgres cartodb_dev_user_fe3b850a-01c0-48f9-8a26-a82f09e9b53f_db
|
||||||
@@ -41,3 +41,14 @@ CREATE EXTENSION cdb_dataservices_client;
|
|||||||
```
|
```
|
||||||
|
|
||||||
The extension creation in the user's db requires **superuser** privileges.
|
The extension creation in the user's db requires **superuser** privileges.
|
||||||
|
|
||||||
|
## User database configuration
|
||||||
|
|
||||||
|
After installing the client extension in a database, you will need to set up your configuration to be able to connect with the server.
|
||||||
|
|
||||||
|
```
|
||||||
|
-- Point to the dataservices server DB (you can use a specific database for the server or your same user's):
|
||||||
|
SELECT CDB_Conf_SetConf('geocoder_server_config', '{ "connection_str": "host=localhost port=5432 dbname=<SERVER_DB_NAME> user=postgres"}');
|
||||||
|
|
||||||
|
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}');
|
||||||
|
```
|
||||||
|
|||||||
140
client/cdb_dataservices_client--0.11.0--0.11.1.sql
Normal file
140
client/cdb_dataservices_client--0.11.0--0.11.1.sql
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.11.1'" to load this file. \quit
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'OBS_GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute('CREATE TABLE "{schema}".{table_name} ( '
|
||||||
|
'cartodb_id int, the_geom geometry, {columns_with_types} '
|
||||||
|
');'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, columns_with_types=columns_with_types)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('ALTER TABLE "{schema}".{table_name} OWNER TO "{user}";'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, user=user_db_role)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
dbname text,
|
||||||
|
table_name text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'OBS_GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute(
|
||||||
|
"SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)))
|
||||||
|
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [
|
||||||
|
colnames_arr[i] +
|
||||||
|
' ' +
|
||||||
|
coltypes_arr[i] for i in range(
|
||||||
|
0,
|
||||||
|
len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
aliased_colname_list = ','.join(
|
||||||
|
['result.' + name for name in colnames_arr])
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute(
|
||||||
|
"SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._DST_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, "
|
||||||
|
"{schema}::text, {dbname}::text, {table_name}::text);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_db_role=plpy.quote_literal(user_db_role),
|
||||||
|
schema=plpy.quote_literal(user_schema),
|
||||||
|
dbname=plpy.quote_literal(dbname),
|
||||||
|
table_name=plpy.quote_literal(table_name)))
|
||||||
|
|
||||||
|
if ds_fdw_metadata[0]["schemaname"]:
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error connecting dataset via FDW')
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute(
|
||||||
|
'INSERT INTO "{schema}".{analysis_table_name} '
|
||||||
|
'SELECT ut.cartodb_id, ut.the_geom, {colname_list} '
|
||||||
|
'FROM "{schema}".{table_name} ut '
|
||||||
|
'LEFT JOIN _DST_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, '
|
||||||
|
'{function_name}::text, {params}::json) '
|
||||||
|
'AS result ({columns_with_types}, cartodb_id int) '
|
||||||
|
'ON result.cartodb_id = ut.cartodb_id;' .format(
|
||||||
|
schema=user_schema,
|
||||||
|
analysis_table_name=output_table_name,
|
||||||
|
colname_list=aliased_colname_list,
|
||||||
|
table_name=table_name,
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params),
|
||||||
|
columns_with_types=columns_with_types))
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute(
|
||||||
|
"SELECT cdb_dataservices_client._DST_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, "
|
||||||
|
"{server_table_name}::text, {fdw_server}::text)" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
fdw_server=plpy.quote_literal(server_name)))
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
140
client/cdb_dataservices_client--0.11.1--0.11.0.sql
Normal file
140
client/cdb_dataservices_client--0.11.1--0.11.0.sql
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.11.0'" to load this file. \quit
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute('CREATE TABLE "{schema}".{table_name} ( '
|
||||||
|
'cartodb_id int, the_geom geometry, {columns_with_types} '
|
||||||
|
');'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, columns_with_types=columns_with_types)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('ALTER TABLE "{schema}".{table_name} OWNER TO "{user}";'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, user=user_db_role)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
dbname text,
|
||||||
|
table_name text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute(
|
||||||
|
"SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)))
|
||||||
|
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [
|
||||||
|
colnames_arr[i] +
|
||||||
|
' ' +
|
||||||
|
coltypes_arr[i] for i in range(
|
||||||
|
0,
|
||||||
|
len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
aliased_colname_list = ','.join(
|
||||||
|
['result.' + name for name in colnames_arr])
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute(
|
||||||
|
"SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._DST_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, "
|
||||||
|
"{schema}::text, {dbname}::text, {table_name}::text);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_db_role=plpy.quote_literal(user_db_role),
|
||||||
|
schema=plpy.quote_literal(user_schema),
|
||||||
|
dbname=plpy.quote_literal(dbname),
|
||||||
|
table_name=plpy.quote_literal(table_name)))
|
||||||
|
|
||||||
|
if ds_fdw_metadata[0]["schemaname"]:
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error connecting dataset via FDW')
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute(
|
||||||
|
'INSERT INTO "{schema}".{analysis_table_name} '
|
||||||
|
'SELECT ut.cartodb_id, ut.the_geom, {colname_list} '
|
||||||
|
'FROM "{schema}".{table_name} ut '
|
||||||
|
'LEFT JOIN _DST_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, '
|
||||||
|
'{function_name}::text, {params}::json) '
|
||||||
|
'AS result ({columns_with_types}, cartodb_id int) '
|
||||||
|
'ON result.cartodb_id = ut.cartodb_id;' .format(
|
||||||
|
schema=user_schema,
|
||||||
|
analysis_table_name=output_table_name,
|
||||||
|
colname_list=aliased_colname_list,
|
||||||
|
table_name=table_name,
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params),
|
||||||
|
columns_with_types=columns_with_types))
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute(
|
||||||
|
"SELECT cdb_dataservices_client._DST_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, "
|
||||||
|
"{server_table_name}::text, {fdw_server}::text)" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
fdw_server=plpy.quote_literal(server_name)))
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
1792
client/cdb_dataservices_client--0.11.1.sql
Normal file
1792
client/cdb_dataservices_client--0.11.1.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
comment = 'CartoDB dataservices client API extension'
|
comment = 'CartoDB dataservices client API extension'
|
||||||
default_version = '0.1.0'
|
default_version = '0.11.1'
|
||||||
requires = 'plproxy, cartodb'
|
requires = 'plproxy, cartodb'
|
||||||
superuser = true
|
superuser = true
|
||||||
schema = cdb_dataservices_client
|
schema = cdb_dataservices_client
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
CREATE TYPE cdb_dataservices_client.isoline AS (
|
||||||
|
center geometry(Geometry,4326),
|
||||||
|
data_range integer,
|
||||||
|
the_geom geometry(Multipolygon,4326)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT array[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isodistance (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT array[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isodistance (username, organization_name, source, mode, range, options);
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT array[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isochrone (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT array[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isochrone (username, organization_name, source, mode, range, options);
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.10.1'" to load this file. \quit
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__OBS_AugmentTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
from time import strftime
|
||||||
|
try:
|
||||||
|
server_table_name = None
|
||||||
|
temporary_table_name = 'ds_tmp_' + str(strftime("%s")) + table_name
|
||||||
|
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._OBS_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params))
|
||||||
|
)
|
||||||
|
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
colnames = ','.join(colnames_arr)
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute("SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._OBS_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, {user_schema}::text, {dbname}::text, {table_name}::text);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), user_db_role=plpy.quote_literal(user_db_role), user_schema=plpy.quote_literal(user_schema), dbname=plpy.quote_literal(dbname), table_name=plpy.quote_literal(table_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
|
||||||
|
# Create temporary table with the augmented results
|
||||||
|
plpy.execute('CREATE UNLOGGED TABLE "{user_schema}".{temp_table_name} AS '
|
||||||
|
'(SELECT {columns}, cartodb_id '
|
||||||
|
'FROM cdb_dataservices_client._OBS_FetchJoinFdwTableData('
|
||||||
|
'{username}::text, {orgname}::text, {schema}::text, {table_name}::text, {function_name}::text, {params}::json) '
|
||||||
|
'AS results({columns_with_types}, cartodb_id int) )'
|
||||||
|
.format(columns=colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema=user_schema, schema=plpy.quote_literal(server_schema), table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params), columns_with_types=columns_with_types,
|
||||||
|
temp_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add index to cartodb_id
|
||||||
|
plpy.execute('CREATE UNIQUE INDEX {temp_table_name}_pkey ON "{user_schema}".{temp_table_name} (cartodb_id)'
|
||||||
|
.format(user_schema=user_schema, temp_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Prepare table to receive augmented results in new columns
|
||||||
|
for idx, column in enumerate(colnames_arr):
|
||||||
|
if colnames_arr[idx] is not 'the_geom':
|
||||||
|
plpy.execute('ALTER TABLE "{user_schema}".{table_name} ADD COLUMN {column_name} {column_type}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, column_name=colnames_arr[idx], column_type=coltypes_arr[idx])
|
||||||
|
)
|
||||||
|
|
||||||
|
# Populate the user table with the augmented results
|
||||||
|
plpy.execute('UPDATE "{user_schema}".{table_name} SET {columns} = '
|
||||||
|
'(SELECT {columns} FROM "{user_schema}".{temporary_table_name} '
|
||||||
|
'WHERE "{user_schema}".{temporary_table_name}.cartodb_id = "{user_schema}".{table_name}.cartodb_id)'
|
||||||
|
.format(columns = colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema = user_schema, table_name=table_name, function_name=function_name, params=params, columns_with_types=columns_with_types,
|
||||||
|
temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
plpy.warning('Error trying to augment table {0}'.format(e))
|
||||||
|
# Wipe user FDW data from the server in case of failure if the table was connected
|
||||||
|
if server_table_name:
|
||||||
|
# Wipe local temporary table
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.9.0'" to load this file. \quit
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_GetTable(text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_AugmentTable(text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__OBS_AugmentTable(text, text, text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__OBS_GetTable(text, text, text, text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_ConnectUserTable(text, text, text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_GetReturnMetadata(text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_FetchJoinFdwTableData(text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_DisconnectUserTable(text, text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.OBS_DumpVersion();
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_DumpVersion(text, text);
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.ds_fdw_metadata;
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.ds_return_metadata;
|
||||||
1780
client/old_versions/cdb_dataservices_client--0.10.0.sql
Normal file
1780
client/old_versions/cdb_dataservices_client--0.10.0.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.10.0'" to load this file. \quit
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__OBS_AugmentTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
from time import strftime
|
||||||
|
try:
|
||||||
|
server_table_name = None
|
||||||
|
temporary_table_name = 'ds_tmp_' + str(strftime("%s")) + table_name
|
||||||
|
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._OBS_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params))
|
||||||
|
)
|
||||||
|
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
colnames = ','.join(colnames_arr)
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute("SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._OBS_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, {user_schema}::text, {dbname}::text, {table_name}::text);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), user_db_role=plpy.quote_literal(user_db_role), user_schema=plpy.quote_literal(user_schema), dbname=plpy.quote_literal(dbname), table_name=plpy.quote_literal(table_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
|
||||||
|
# Create temporary table with the augmented results
|
||||||
|
plpy.execute('CREATE UNLOGGED TABLE "{user_schema}".{temp_table_name} AS '
|
||||||
|
'(SELECT {columns}, cartodb_id '
|
||||||
|
'FROM cdb_dataservices_client._OBS_FetchJoinFdwTableData('
|
||||||
|
'{username}::text, {orgname}::text, {schema}::text, {table_name}::text, {function_name}::text, {params}::json) '
|
||||||
|
'AS results({columns_with_types}, cartodb_id int) )'
|
||||||
|
.format(columns=colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema=user_schema, schema=plpy.quote_literal(server_schema), table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params), columns_with_types=columns_with_types,
|
||||||
|
temp_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
# Prepare table to receive augmented results in new columns
|
||||||
|
for idx, column in enumerate(colnames_arr):
|
||||||
|
if colnames_arr[idx] is not 'the_geom':
|
||||||
|
plpy.execute('ALTER TABLE "{user_schema}".{table_name} ADD COLUMN {column_name} {column_type}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, column_name=colnames_arr[idx], column_type=coltypes_arr[idx])
|
||||||
|
)
|
||||||
|
|
||||||
|
# Populate the user table with the augmented results
|
||||||
|
plpy.execute('UPDATE "{user_schema}".{table_name} SET {columns} = '
|
||||||
|
'(SELECT {columns} FROM "{user_schema}".{temporary_table_name} '
|
||||||
|
'WHERE "{user_schema}".{temporary_table_name}.cartodb_id = "{user_schema}".{table_name}.cartodb_id)'
|
||||||
|
.format(columns = colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema = user_schema, table_name=table_name, function_name=function_name, params=params, columns_with_types=columns_with_types,
|
||||||
|
temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
plpy.warning('Error trying to augment table {0}'.format(e))
|
||||||
|
# Wipe user FDW data from the server in case of failure if the table was connected
|
||||||
|
if server_table_name:
|
||||||
|
# Wipe local temporary table
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
286
client/old_versions/cdb_dataservices_client--0.10.1--0.10.2.sql
Normal file
286
client/old_versions/cdb_dataservices_client--0.10.1--0.10.2.sql
Normal file
@@ -0,0 +1,286 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.10.2'" to load this file. \quit
|
||||||
|
|
||||||
|
-- 20 public functions
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_demographic_snapshot (geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT NULL)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_demographic_snapshot(username, orgname, geom, time_span, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_segment_snapshot (geom geometry(Geometry, 4326), geometry_level text DEFAULT NULL)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_segment_snapshot(username, orgname, geom, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundariesbygeometry (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getboundariesbygeometry(username, orgname, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundariesbypointandradius (geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getboundariesbypointandradius(username, orgname, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpointsbygeometry (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getpointsbygeometry(username, orgname, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpointsbypointandradius (geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getpointsbypointandradius(username, orgname, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getmeasure (geom Geometry, measure_id text, normalize text DEFAULT NULL, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getmeasure(username, orgname, geom, measure_id, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getuscensusmeasure (geom Geometry, name text, normalize text DEFAULT NULL, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getuscensusmeasure(username, orgname, geom, name, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpopulation (geom Geometry, normalize text DEFAULT NULL, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getpopulation(username, orgname, geom, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
-- 30_plproxy_functions
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_demographic_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_demographic_snapshot (username, organization_name, geom, time_span, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_segment_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), geometry_level text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_segment_snapshot (username, organization_name, geom, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundariesbygeometry (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getboundariesbygeometry (username, organization_name, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundariesbypointandradius (username text, organization_name text, geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getboundariesbypointandradius (username, organization_name, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpointsbygeometry (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getpointsbygeometry (username, organization_name, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpointsbypointandradius (username text, organization_name text, geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getpointsbypointandradius (username, organization_name, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getmeasure (username text, organization_name text, geom Geometry, measure_id text, normalize text DEFAULT NULL, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getmeasure (username, organization_name, geom, measure_id, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getuscensusmeasure (username text, organization_name text, geom Geometry, name text, normalize text DEFAULT NULL, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getuscensusmeasure (username, organization_name, geom, name, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpopulation (username text, organization_name text, geom Geometry, normalize text DEFAULT NULL, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getpopulation (username, organization_name, geom, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
1785
client/old_versions/cdb_dataservices_client--0.10.1.sql
Normal file
1785
client/old_versions/cdb_dataservices_client--0.10.1.sql
Normal file
File diff suppressed because it is too large
Load Diff
286
client/old_versions/cdb_dataservices_client--0.10.2--0.10.1.sql
Normal file
286
client/old_versions/cdb_dataservices_client--0.10.2--0.10.1.sql
Normal file
@@ -0,0 +1,286 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.10.1'" to load this file. \quit
|
||||||
|
|
||||||
|
-- 20 public functions
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_demographic_snapshot (geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT '"us.census.tiger".block_group'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_demographic_snapshot(username, orgname, geom, time_span, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_segment_snapshot (geom geometry(Geometry, 4326), geometry_level text DEFAULT '"us.census.tiger".census_tract'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_segment_snapshot(username, orgname, geom, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundariesbygeometry (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getboundariesbygeometry(username, orgname, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundariesbypointandradius (geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getboundariesbypointandradius(username, orgname, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpointsbygeometry (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getpointsbygeometry(username, orgname, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpointsbypointandradius (geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getpointsbypointandradius(username, orgname, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getmeasure (geom Geometry, measure_id text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getmeasure(username, orgname, geom, measure_id, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getuscensusmeasure (geom Geometry, name text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getuscensusmeasure(username, orgname, geom, name, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpopulation (geom Geometry, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getpopulation(username, orgname, geom, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
-- 30_plproxy_functions
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_demographic_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT '"us.census.tiger".block_group'::text)
|
||||||
|
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_demographic_snapshot (username, organization_name, geom, time_span, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_segment_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), geometry_level text DEFAULT '"us.census.tiger".census_tract'::text)
|
||||||
|
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_segment_snapshot (username, organization_name, geom, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundariesbygeometry (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getboundariesbygeometry (username, organization_name, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundariesbypointandradius (username text, organization_name text, geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getboundariesbypointandradius (username, organization_name, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpointsbygeometry (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getpointsbygeometry (username, organization_name, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpointsbypointandradius (username text, organization_name text, geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getpointsbypointandradius (username, organization_name, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getmeasure (username text, organization_name text, geom Geometry, measure_id text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getmeasure (username, organization_name, geom, measure_id, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getuscensusmeasure (username text, organization_name text, geom Geometry, name text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getuscensusmeasure (username, organization_name, geom, name, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpopulation (username text, organization_name text, geom Geometry, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getpopulation (username, organization_name, geom, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
289
client/old_versions/cdb_dataservices_client--0.10.2--0.11.0.sql
Normal file
289
client/old_versions/cdb_dataservices_client--0.10.2--0.11.0.sql
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.11.0'" to load this file. \quit
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_GetTable(text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_AugmentTable(text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__OBS_AugmentTable(text, text, text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__OBS_GetTable(text, text, text, text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_ConnectUserTable(text, text, text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_GetReturnMetadata(text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_FetchJoinFdwTableData(text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_DisconnectUserTable(text, text, text, text, text);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_PrepareTableOBS_GetMeasure(
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
||||||
|
username,
|
||||||
|
orgname,
|
||||||
|
user_db_role,
|
||||||
|
user_schema,
|
||||||
|
output_table_name,
|
||||||
|
params
|
||||||
|
) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(
|
||||||
|
table_name text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
dbname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT current_database() INTO dbname;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
||||||
|
username,
|
||||||
|
orgname,
|
||||||
|
user_db_role,
|
||||||
|
user_schema,
|
||||||
|
dbname,
|
||||||
|
table_name,
|
||||||
|
output_table_name,
|
||||||
|
params
|
||||||
|
) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute('CREATE TABLE "{schema}".{table_name} ( '
|
||||||
|
'cartodb_id int, the_geom geometry, {columns_with_types} '
|
||||||
|
');'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, columns_with_types=columns_with_types)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('ALTER TABLE "{schema}".{table_name} OWNER TO "{user}";'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, user=user_db_role)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
dbname text,
|
||||||
|
table_name text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute(
|
||||||
|
"SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)))
|
||||||
|
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [
|
||||||
|
colnames_arr[i] +
|
||||||
|
' ' +
|
||||||
|
coltypes_arr[i] for i in range(
|
||||||
|
0,
|
||||||
|
len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
aliased_colname_list = ','.join(
|
||||||
|
['result.' + name for name in colnames_arr])
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute(
|
||||||
|
"SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._DST_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, "
|
||||||
|
"{schema}::text, {dbname}::text, {table_name}::text);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_db_role=plpy.quote_literal(user_db_role),
|
||||||
|
schema=plpy.quote_literal(user_schema),
|
||||||
|
dbname=plpy.quote_literal(dbname),
|
||||||
|
table_name=plpy.quote_literal(table_name)))
|
||||||
|
|
||||||
|
if ds_fdw_metadata[0]["schemaname"]:
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error connecting dataset via FDW')
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute(
|
||||||
|
'INSERT INTO "{schema}".{analysis_table_name} '
|
||||||
|
'SELECT ut.cartodb_id, ut.the_geom, {colname_list} '
|
||||||
|
'FROM "{schema}".{table_name} ut '
|
||||||
|
'LEFT JOIN _DST_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, '
|
||||||
|
'{function_name}::text, {params}::json) '
|
||||||
|
'AS result ({columns_with_types}, cartodb_id int) '
|
||||||
|
'ON result.cartodb_id = ut.cartodb_id;' .format(
|
||||||
|
schema=user_schema,
|
||||||
|
analysis_table_name=output_table_name,
|
||||||
|
colname_list=aliased_colname_list,
|
||||||
|
table_name=table_name,
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params),
|
||||||
|
columns_with_types=columns_with_types))
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute(
|
||||||
|
"SELECT cdb_dataservices_client._DST_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, "
|
||||||
|
"{server_table_name}::text, {fdw_server}::text)" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
fdw_server=plpy.quote_literal(server_name)))
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_ConnectUserTable(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
dbname text,
|
||||||
|
table_name text
|
||||||
|
)RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_ConnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_GetReturnMetadata(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
function_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS cdb_dataservices_client.ds_return_metadata AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_GetReturnMetadata;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_FetchJoinFdwTableData(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
table_schema text,
|
||||||
|
table_name text,
|
||||||
|
function_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS SETOF record AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_FetchJoinFdwTableData;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_DisconnectUserTable(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
table_schema text,
|
||||||
|
table_name text,
|
||||||
|
server_name text
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_DisconnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._DST_PrepareTableOBS_GetMeasure(output_table_name text, params json) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(table_name text, output_table_name text, params json) TO publicuser;
|
||||||
|
|
||||||
1785
client/old_versions/cdb_dataservices_client--0.10.2.sql
Normal file
1785
client/old_versions/cdb_dataservices_client--0.10.2.sql
Normal file
File diff suppressed because it is too large
Load Diff
281
client/old_versions/cdb_dataservices_client--0.11.0--0.10.2.sql
Normal file
281
client/old_versions/cdb_dataservices_client--0.11.0--0.10.2.sql
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.10.2'" to load this file. \quit
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._DST_PrepareTableOBS_GetMeasure(text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(text, text, text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._DST_ConnectUserTable(text, text, text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._DST_GetReturnMetadata(text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._DST_FetchJoinFdwTableData(text, text, text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._DST_DisconnectUserTable(text, text, text, text, text);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_GetTable(table_name text, output_table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
dbname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT current_database() INTO dbname;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__OBS_GetTable(username, orgname, user_db_role, user_schema, dbname, table_name, output_table_name, function_name, params) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_AugmentTable(table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
dbname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT current_database() INTO dbname;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__OBS_AugmentTable(username, orgname, user_db_role, user_schema, dbname, table_name, function_name, params) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__OBS_AugmentTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
from time import strftime
|
||||||
|
try:
|
||||||
|
server_table_name = None
|
||||||
|
temporary_table_name = 'ds_tmp_' + str(strftime("%s")) + table_name
|
||||||
|
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._OBS_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params))
|
||||||
|
)
|
||||||
|
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
colnames = ','.join(colnames_arr)
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute("SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._OBS_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, {user_schema}::text, {dbname}::text, {table_name}::text);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), user_db_role=plpy.quote_literal(user_db_role), user_schema=plpy.quote_literal(user_schema), dbname=plpy.quote_literal(dbname), table_name=plpy.quote_literal(table_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
|
||||||
|
# Create temporary table with the augmented results
|
||||||
|
plpy.execute('CREATE UNLOGGED TABLE "{user_schema}".{temp_table_name} AS '
|
||||||
|
'(SELECT {columns}, cartodb_id '
|
||||||
|
'FROM cdb_dataservices_client._OBS_FetchJoinFdwTableData('
|
||||||
|
'{username}::text, {orgname}::text, {schema}::text, {table_name}::text, {function_name}::text, {params}::json) '
|
||||||
|
'AS results({columns_with_types}, cartodb_id int) )'
|
||||||
|
.format(columns=colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema=user_schema, schema=plpy.quote_literal(server_schema), table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params), columns_with_types=columns_with_types,
|
||||||
|
temp_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add index to cartodb_id
|
||||||
|
plpy.execute('CREATE UNIQUE INDEX {temp_table_name}_pkey ON "{user_schema}".{temp_table_name} (cartodb_id)'
|
||||||
|
.format(user_schema=user_schema, temp_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Prepare table to receive augmented results in new columns
|
||||||
|
for idx, column in enumerate(colnames_arr):
|
||||||
|
if colnames_arr[idx] is not 'the_geom':
|
||||||
|
plpy.execute('ALTER TABLE "{user_schema}".{table_name} ADD COLUMN {column_name} {column_type}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, column_name=colnames_arr[idx], column_type=coltypes_arr[idx])
|
||||||
|
)
|
||||||
|
|
||||||
|
# Populate the user table with the augmented results
|
||||||
|
plpy.execute('UPDATE "{user_schema}".{table_name} SET {columns} = '
|
||||||
|
'(SELECT {columns} FROM "{user_schema}".{temporary_table_name} '
|
||||||
|
'WHERE "{user_schema}".{temporary_table_name}.cartodb_id = "{user_schema}".{table_name}.cartodb_id)'
|
||||||
|
.format(columns = colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema = user_schema, table_name=table_name, function_name=function_name, params=params, columns_with_types=columns_with_types,
|
||||||
|
temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
plpy.warning('Error trying to augment table {0}'.format(e))
|
||||||
|
# Wipe user FDW data from the server in case of failure if the table was connected
|
||||||
|
if server_table_name:
|
||||||
|
# Wipe local temporary table
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__OBS_GetTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text, output_table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
try:
|
||||||
|
server_table_name = None
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._OBS_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params))
|
||||||
|
)
|
||||||
|
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
colnames = ','.join(colnames_arr)
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute("SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._OBS_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, {schema}::text, {dbname}::text, {table_name}::text);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), user_db_role=plpy.quote_literal(user_db_role), schema=plpy.quote_literal(user_schema), dbname=plpy.quote_literal(dbname), table_name=plpy.quote_literal(table_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
|
||||||
|
# Get list of user columns to include in the new table
|
||||||
|
user_table_columns = ','.join(
|
||||||
|
plpy.execute('SELECT array_agg(\'user_table.\' || attname) AS columns '
|
||||||
|
'FROM pg_attribute WHERE attrelid = \'"{user_schema}".{table_name}\'::regclass '
|
||||||
|
'AND attnum > 0 AND NOT attisdropped AND attname NOT LIKE \'the_geom_webmercator\' '
|
||||||
|
'AND NOT attname LIKE ANY(string_to_array(\'{colnames}\',\',\'));'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, colnames=colnames)
|
||||||
|
)[0]["columns"]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Populate a new table with the augmented results
|
||||||
|
plpy.execute('CREATE TABLE "{user_schema}".{output_table_name} AS '
|
||||||
|
'(SELECT results.{columns}, {user_table_columns} '
|
||||||
|
'FROM {table_name} AS user_table '
|
||||||
|
'LEFT JOIN cdb_dataservices_client._OBS_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {function_name}::text, {params}::json) as results({columns_with_types}, cartodb_id int) '
|
||||||
|
'ON results.cartodb_id = user_table.cartodb_id)'
|
||||||
|
.format(output_table_name=output_table_name, columns=colnames, user_table_columns=user_table_columns, username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname), user_schema=user_schema, server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
table_name=table_name, function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params), columns_with_types=columns_with_types)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('ALTER TABLE "{schema}".{table_name} OWNER TO "{user}";'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, user=user_db_role)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
plpy.warning('Error trying to get table {0}'.format(e))
|
||||||
|
# Wipe user FDW data from the server in case of failure if the table was connected
|
||||||
|
if server_table_name:
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_ConnectUserTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text)
|
||||||
|
RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_ConnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_GetReturnMetadata(username text, orgname text, function_name text, params json)
|
||||||
|
RETURNS cdb_dataservices_client.ds_return_metadata AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_GetReturnMetadata;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_FetchJoinFdwTableData(username text, orgname text, table_schema text, table_name text, function_name text, params json)
|
||||||
|
RETURNS SETOF record AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_FetchJoinFdwTableData;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_DisconnectUserTable(username text, orgname text, table_schema text, table_name text, server_name text)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_DisconnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._obs_augmenttable(table_name text, function_name text, params json) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._obs_gettable(table_name text, output_table_name text, function_name text, params json) TO publicuser;
|
||||||
1792
client/old_versions/cdb_dataservices_client--0.11.0.sql
Normal file
1792
client/old_versions/cdb_dataservices_client--0.11.0.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
|||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_isochrone (geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_isochrone (text, text, geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_isodistance (geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_isodistance (text, text, geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.isoline;
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
CREATE TYPE cdb_dataservices_client.simple_route AS (
|
||||||
|
shape geometry(LineString,4326),
|
||||||
|
length real,
|
||||||
|
duration integer
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_route_point_to_point (origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_route_point_to_point(username, orgname, origin, destination, mode, options, units) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_route_point_to_point (username text, organization_name text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_route_point_to_point (username, organization_name, origin, destination, mode, options, units);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_route_point_to_point(origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[], units text) TO publicuser;
|
||||||
513
client/old_versions/cdb_dataservices_client--0.2.0.sql
Normal file
513
client/old_versions/cdb_dataservices_client--0.2.0.sql
Normal file
@@ -0,0 +1,513 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "CREATE EXTENSION cdb_dataservices_client" to load this file. \quit
|
||||||
|
--
|
||||||
|
-- Geocoder server connection config
|
||||||
|
--
|
||||||
|
-- The purpose of this function is provide to the PL/Proxy functions
|
||||||
|
-- the connection string needed to connect with the server
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._server_conn_str()
|
||||||
|
RETURNS text AS $$
|
||||||
|
DECLARE
|
||||||
|
db_connection_str text;
|
||||||
|
BEGIN
|
||||||
|
SELECT cartodb.cdb_conf_getconf('geocoder_server_config')->'connection_str' INTO db_connection_str;
|
||||||
|
SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str;
|
||||||
|
RETURN db_connection_str;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
CREATE TYPE cdb_dataservices_client._entity_config AS (
|
||||||
|
username text,
|
||||||
|
organization_name text
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Get entity config function
|
||||||
|
--
|
||||||
|
-- The purpose of this function is to retrieve the username and organization name from
|
||||||
|
-- a) schema where he/her is the owner in case is an organization user
|
||||||
|
-- b) entity_name from the cdb_conf database in case is a non organization user
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_entity_config()
|
||||||
|
RETURNS record AS $$
|
||||||
|
DECLARE
|
||||||
|
result cdb_dataservices_client._entity_config;
|
||||||
|
is_organization boolean;
|
||||||
|
username text;
|
||||||
|
organization_name text;
|
||||||
|
BEGIN
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->'is_organization' INTO is_organization;
|
||||||
|
IF is_organization IS NULL THEN
|
||||||
|
RAISE EXCEPTION 'User must have user configuration in the config table';
|
||||||
|
ELSIF is_organization = TRUE THEN
|
||||||
|
SELECT nspname
|
||||||
|
FROM pg_namespace s
|
||||||
|
LEFT JOIN pg_roles r ON s.nspowner = r.oid
|
||||||
|
WHERE r.rolname = session_user INTO username;
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->>'entity_name' INTO organization_name;
|
||||||
|
ELSE
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->>'entity_name' INTO username;
|
||||||
|
organization_name = NULL;
|
||||||
|
END IF;
|
||||||
|
result.username = username;
|
||||||
|
result.organization_name = organization_name;
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
CREATE TYPE cdb_dataservices_client.isoline AS (
|
||||||
|
center geometry(Geometry,4326),
|
||||||
|
data_range integer,
|
||||||
|
the_geom geometry(Multipolygon,4326)
|
||||||
|
);--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin0_polygon (country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon (admin1_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon (admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon (postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point (postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_ipaddress_point (ip_address text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_street_point (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin0_polygon (username text, organization_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon (username, organization_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin1_polygon (username text, organization_name text, admin1_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon (username, organization_name, admin1_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin1_polygon (username text, organization_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon (username, organization_name, admin1_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name, admin1_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon (username text, organization_name text, postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon (username, organization_name, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point (username text, organization_name text, postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_point (username, organization_name, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_ipaddress_point (username text, organization_name text, ip_address text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point (username, organization_name, ip_address);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_street_point (username text, organization_name text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_street_point (username, organization_name, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isodistance (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isodistance (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isochrone (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isochrone (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
-- Make sure by default there are no permissions for publicuser
|
||||||
|
-- NOTE: this happens at extension creation time, as part of an implicit transaction.
|
||||||
|
REVOKE ALL PRIVILEGES ON SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser CASCADE;
|
||||||
|
|
||||||
|
-- Grant permissions on the schema to publicuser (but just the schema)
|
||||||
|
GRANT USAGE ON SCHEMA cdb_dataservices_client TO publicuser;
|
||||||
|
|
||||||
|
-- Revoke execute permissions on all functions in the schema by default
|
||||||
|
REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin0_polygon(country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon(admin1_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon(admin1_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point(postal_code text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_ipaddress_point(ip_address text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_route_point_to_point (geometry(Point, 4326), geometry(Point, 4326), text, text[], text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_route_point_to_point (text, text, geometry(Point, 4326), geometry(Point, 4326), text, text[], text);
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.simple_route;
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.4.0'" to load this file. \quit
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_demographic_snapshot (geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT '"us.census.tiger".block_group'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_demographic_snapshot(username, orgname, geom, time_span, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_segment_snapshot (geom geometry(Geometry, 4326), geometry_level text DEFAULT '"us.census.tiger".census_tract'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_segment_snapshot(username, orgname, geom, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_demographic_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT '"us.census.tiger".block_group'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_demographic_snapshot (username, organization_name, geom, time_span, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_segment_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), geometry_level text DEFAULT '"us.census.tiger".census_tract'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_segment_snapshot (username, organization_name, geom, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_get_demographic_snapshot(geom geometry(Geometry, 4326), time_span text, geometry_level text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_get_segment_snapshot(geom geometry(Geometry, 4326), geometry_level text) TO publicuser;
|
||||||
556
client/old_versions/cdb_dataservices_client--0.3.0.sql
Normal file
556
client/old_versions/cdb_dataservices_client--0.3.0.sql
Normal file
@@ -0,0 +1,556 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "CREATE EXTENSION cdb_dataservices_client" to load this file. \quit
|
||||||
|
--
|
||||||
|
-- Geocoder server connection config
|
||||||
|
--
|
||||||
|
-- The purpose of this function is provide to the PL/Proxy functions
|
||||||
|
-- the connection string needed to connect with the server
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._server_conn_str()
|
||||||
|
RETURNS text AS $$
|
||||||
|
DECLARE
|
||||||
|
db_connection_str text;
|
||||||
|
BEGIN
|
||||||
|
SELECT cartodb.cdb_conf_getconf('geocoder_server_config')->'connection_str' INTO db_connection_str;
|
||||||
|
SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str;
|
||||||
|
RETURN db_connection_str;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
CREATE TYPE cdb_dataservices_client._entity_config AS (
|
||||||
|
username text,
|
||||||
|
organization_name text
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Get entity config function
|
||||||
|
--
|
||||||
|
-- The purpose of this function is to retrieve the username and organization name from
|
||||||
|
-- a) schema where he/her is the owner in case is an organization user
|
||||||
|
-- b) entity_name from the cdb_conf database in case is a non organization user
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_entity_config()
|
||||||
|
RETURNS record AS $$
|
||||||
|
DECLARE
|
||||||
|
result cdb_dataservices_client._entity_config;
|
||||||
|
is_organization boolean;
|
||||||
|
username text;
|
||||||
|
organization_name text;
|
||||||
|
BEGIN
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->'is_organization' INTO is_organization;
|
||||||
|
IF is_organization IS NULL THEN
|
||||||
|
RAISE EXCEPTION 'User must have user configuration in the config table';
|
||||||
|
ELSIF is_organization = TRUE THEN
|
||||||
|
SELECT nspname
|
||||||
|
FROM pg_namespace s
|
||||||
|
LEFT JOIN pg_roles r ON s.nspowner = r.oid
|
||||||
|
WHERE r.rolname = session_user INTO username;
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->>'entity_name' INTO organization_name;
|
||||||
|
ELSE
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->>'entity_name' INTO username;
|
||||||
|
organization_name = NULL;
|
||||||
|
END IF;
|
||||||
|
result.username = username;
|
||||||
|
result.organization_name = organization_name;
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
CREATE TYPE cdb_dataservices_client.isoline AS (
|
||||||
|
center geometry(Geometry,4326),
|
||||||
|
data_range integer,
|
||||||
|
the_geom geometry(Multipolygon,4326)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.simple_route AS (
|
||||||
|
shape geometry(LineString,4326),
|
||||||
|
length real,
|
||||||
|
duration integer
|
||||||
|
);--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin0_polygon (country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon (admin1_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon (admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon (postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point (postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_ipaddress_point (ip_address text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_street_point (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public geocoder API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_route_point_to_point (origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_route_point_to_point(username, orgname, origin, destination, mode, options, units) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin0_polygon (username text, organization_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon (username, organization_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin1_polygon (username text, organization_name text, admin1_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon (username, organization_name, admin1_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin1_polygon (username text, organization_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon (username, organization_name, admin1_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name, admin1_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon (username text, organization_name text, postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon (username, organization_name, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point (username text, organization_name text, postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_point (username, organization_name, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_ipaddress_point (username text, organization_name text, ip_address text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point (username, organization_name, ip_address);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_street_point (username text, organization_name text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_street_point (username, organization_name, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isodistance (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isodistance (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isochrone (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isochrone (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_route_point_to_point (username text, organization_name text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_route_point_to_point (username, organization_name, origin, destination, mode, options, units);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
-- Make sure by default there are no permissions for publicuser
|
||||||
|
-- NOTE: this happens at extension creation time, as part of an implicit transaction.
|
||||||
|
REVOKE ALL PRIVILEGES ON SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser CASCADE;
|
||||||
|
|
||||||
|
-- Grant permissions on the schema to publicuser (but just the schema)
|
||||||
|
GRANT USAGE ON SCHEMA cdb_dataservices_client TO publicuser;
|
||||||
|
|
||||||
|
-- Revoke execute permissions on all functions in the schema by default
|
||||||
|
REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin0_polygon(country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon(admin1_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon(admin1_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point(postal_code text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_ipaddress_point(ip_address text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_route_point_to_point(origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[], units text) TO publicuser;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.3.0'" to load this file. \quit
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_get_demographic_snapshot (text, text, geometry(Geometry, 4326), text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_get_segment_snapshot (text, text, geometry(Geometry, 4326), text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_get_demographic_snapshot (geometry(Geometry, 4326), text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_get_segment_snapshot (geometry(Geometry, 4326), text);
|
||||||
597
client/old_versions/cdb_dataservices_client--0.4.0--0.5.0.sql
Normal file
597
client/old_versions/cdb_dataservices_client--0.4.0--0.5.0.sql
Normal file
@@ -0,0 +1,597 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.5.0'" to load this file. \quit
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getdemographicsnapshot (geom geometry(Geometry, 4326), time_span text DEFAULT NULL, geometry_level text DEFAULT NULL)
|
||||||
|
RETURNS SETOF JSON AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getdemographicsnapshot(username, orgname, geom, time_span, geometry_level);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getsegmentsnapshot (geom geometry(Geometry, 4326), geometry_level text DEFAULT NULL)
|
||||||
|
RETURNS SETOF JSON AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getsegmentsnapshot(username, orgname, geom, geometry_level);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundary (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getboundary(username, orgname, geom, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundaryid (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS text AS $$
|
||||||
|
DECLARE
|
||||||
|
ret text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getboundaryid(username, orgname, geom, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundarybyid (geometry_id text, boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getboundarybyid(username, orgname, geometry_id, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundariesbygeometry (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getboundariesbygeometry(username, orgname, geom, boundary_id, time_span, overlap_type) AS query;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getboundariesbypointandradius (geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getboundariesbypointandradius(username, orgname, geom, radius, boundary_id, time_span, overlap_type) AS query;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpointsbygeometry (geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getpointsbygeometry(username, orgname, geom, boundary_id, time_span, overlap_type) AS query;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpointsbypointandradius (geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getpointsbypointandradius(username, orgname, geom, radius, boundary_id, time_span, overlap_type) AS query;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getmeasure (geom Geometry, measure_id text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getmeasure(username, orgname, geom, measure_id, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getcategory (geom Geometry, category_id text, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS text AS $$
|
||||||
|
DECLARE
|
||||||
|
ret text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getcategory(username, orgname, geom, category_id, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getuscensusmeasure (geom Geometry, name text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getuscensusmeasure(username, orgname, geom, name, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getuscensuscategory (geom Geometry, name text, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS text AS $$
|
||||||
|
DECLARE
|
||||||
|
ret text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getuscensuscategory(username, orgname, geom, name, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getpopulation (geom Geometry, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getpopulation(username, orgname, geom, normalize, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_search (search_term text, relevant_boundary text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(id text, description text, name text, aggregate text, source text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_search(username, orgname, search_term, relevant_boundary) AS query;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getavailableboundaries (geom Geometry, timespan text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(boundary_id text, description text, time_span text, tablename text) AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_getavailableboundaries(username, orgname, geom, timespan) AS query;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getdemographicsnapshot (username text, organization_name text, geom geometry(Geometry, 4326), time_span text DEFAULT NULL, geometry_level text DEFAULT NULL)
|
||||||
|
RETURNS SETOF JSON AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getdemographicsnapshot (username, organization_name, geom, time_span, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getsegmentsnapshot (username text, organization_name text, geom geometry(Geometry, 4326), geometry_level text DEFAULT NULL)
|
||||||
|
RETURNS SETOF JSON AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getsegmentsnapshot (username, organization_name, geom, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundary (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getboundary (username, organization_name, geom, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundaryid (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS text AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getboundaryid (username, organization_name, geom, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundarybyid (username text, organization_name text, geometry_id text, boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getboundarybyid (username, organization_name, geometry_id, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundariesbygeometry (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getboundariesbygeometry (username, organization_name, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getboundariesbypointandradius (username text, organization_name text, geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getboundariesbypointandradius (username, organization_name, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpointsbygeometry (username text, organization_name text, geom geometry(Geometry, 4326), boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getpointsbygeometry (username, organization_name, geom, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpointsbypointandradius (username text, organization_name text, geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text DEFAULT NULL, overlap_type text DEFAULT 'intersects')
|
||||||
|
RETURNS TABLE(the_geom geometry, geom_refs text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getpointsbypointandradius (username, organization_name, geom, radius, boundary_id, time_span, overlap_type);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getmeasure (username text, organization_name text, geom Geometry, measure_id text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getmeasure (username, organization_name, geom, measure_id, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getcategory (username text, organization_name text, geom Geometry, category_id text, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS text AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getcategory (username, organization_name, geom, category_id, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getuscensusmeasure (username text, organization_name text, geom Geometry, name text, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getuscensusmeasure (username, organization_name, geom, name, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getuscensuscategory (username text, organization_name text, geom Geometry, name text, boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS text AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getuscensuscategory (username, organization_name, geom, name, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getpopulation (username text, organization_name text, geom Geometry, normalize text DEFAULT 'area', boundary_id text DEFAULT NULL, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getpopulation (username, organization_name, geom, normalize, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_search (username text, organization_name text, search_term text, relevant_boundary text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(id text, description text, name text, aggregate text, source text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_search (username, organization_name, search_term, relevant_boundary);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailableboundaries (username text, organization_name text, geom Geometry, time_span text DEFAULT NULL)
|
||||||
|
RETURNS TABLE(boundary_id text, description text, time_span text, tablename text) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getavailableboundaries (username, organization_name, geom, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getdemographicsnapshot(geom geometry(Geometry, 4326), time_span text, geometry_level text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getsegmentsnapshot(geom geometry(Geometry, 4326), geometry_level text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getboundary(geom geometry(Geometry, 4326), boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getboundaryid(geom geometry(Geometry, 4326), boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getboundarybyid(geometry_id text, boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getboundariesbygeometry(geom geometry(Geometry, 4326), boundary_id text, time_span text, overlap_type text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getboundariesbypointandradius(geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text, overlap_type text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getpointsbygeometry(geom geometry(Geometry, 4326), boundary_id text, time_span text, overlap_type text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getpointsbypointandradius(geom geometry(Geometry, 4326), radius numeric, boundary_id text, time_span text, overlap_type text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getmeasure(geom Geometry, measure_id text, normalize text, boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getcategory(geom Geometry, category_id text, boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getuscensusmeasure(geom Geometry, name text, normalize text, boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getuscensuscategory(geom Geometry, name text, boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getpopulation(geom Geometry, normalize text, boundary_id text, time_span text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_search(search_term text, relevant_boundary text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getavailableboundaries(geom Geometry, time_span text) TO publicuser;
|
||||||
627
client/old_versions/cdb_dataservices_client--0.4.0.sql
Normal file
627
client/old_versions/cdb_dataservices_client--0.4.0.sql
Normal file
@@ -0,0 +1,627 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "CREATE EXTENSION cdb_dataservices_client" to load this file. \quit
|
||||||
|
--
|
||||||
|
-- Geocoder server connection config
|
||||||
|
--
|
||||||
|
-- The purpose of this function is provide to the PL/Proxy functions
|
||||||
|
-- the connection string needed to connect with the server
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._server_conn_str()
|
||||||
|
RETURNS text AS $$
|
||||||
|
DECLARE
|
||||||
|
db_connection_str text;
|
||||||
|
BEGIN
|
||||||
|
SELECT cartodb.cdb_conf_getconf('geocoder_server_config')->'connection_str' INTO db_connection_str;
|
||||||
|
SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str;
|
||||||
|
RETURN db_connection_str;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';CREATE TYPE cdb_dataservices_client._entity_config AS (
|
||||||
|
username text,
|
||||||
|
organization_name text
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Get entity config function
|
||||||
|
--
|
||||||
|
-- The purpose of this function is to retrieve the username and organization name from
|
||||||
|
-- a) schema where he/her is the owner in case is an organization user
|
||||||
|
-- b) entity_name from the cdb_conf database in case is a non organization user
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_entity_config()
|
||||||
|
RETURNS record AS $$
|
||||||
|
DECLARE
|
||||||
|
result cdb_dataservices_client._entity_config;
|
||||||
|
is_organization boolean;
|
||||||
|
username text;
|
||||||
|
organization_name text;
|
||||||
|
BEGIN
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->'is_organization' INTO is_organization;
|
||||||
|
IF is_organization IS NULL THEN
|
||||||
|
RAISE EXCEPTION 'User must have user configuration in the config table';
|
||||||
|
ELSIF is_organization = TRUE THEN
|
||||||
|
SELECT nspname
|
||||||
|
FROM pg_namespace s
|
||||||
|
LEFT JOIN pg_roles r ON s.nspowner = r.oid
|
||||||
|
WHERE r.rolname = session_user INTO username;
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->>'entity_name' INTO organization_name;
|
||||||
|
ELSE
|
||||||
|
SELECT cartodb.cdb_conf_getconf('user_config')->>'entity_name' INTO username;
|
||||||
|
organization_name = NULL;
|
||||||
|
END IF;
|
||||||
|
result.username = username;
|
||||||
|
result.organization_name = organization_name;
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;CREATE TYPE cdb_dataservices_client.isoline AS (
|
||||||
|
center geometry(Geometry,4326),
|
||||||
|
data_range integer,
|
||||||
|
the_geom geometry(Multipolygon,4326)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.simple_route AS (
|
||||||
|
shape geometry(LineString,4326),
|
||||||
|
length real,
|
||||||
|
duration integer
|
||||||
|
);--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin0_polygon (country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon (admin1_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon (admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point (city_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon (postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point (postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_ipaddress_point (ip_address text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_street_point (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_route_point_to_point (origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_route_point_to_point(username, orgname, origin, destination, mode, options, units) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_demographic_snapshot (geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT '"us.census.tiger".block_group'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_demographic_snapshot(username, orgname, geom, time_span, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_segment_snapshot (geom geometry(Geometry, 4326), geometry_level text DEFAULT '"us.census.tiger".census_tract'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_get_segment_snapshot(username, orgname, geom, geometry_level) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin0_polygon (username text, organization_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon (username, organization_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin1_polygon (username text, organization_name text, admin1_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon (username, organization_name, admin1_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin1_polygon (username text, organization_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon (username, organization_name, admin1_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point (username text, organization_name text, city_name text, admin1_name text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_namedplace_point (username, organization_name, city_name, admin1_name, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon (username text, organization_name text, postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon (username, organization_name, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point (username text, organization_name text, postal_code text, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_point (username, organization_name, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_ipaddress_point (username text, organization_name text, ip_address text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point (username, organization_name, ip_address);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_street_point (username text, organization_name text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_street_point (username, organization_name, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isodistance (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isodistance (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isochrone (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_isochrone (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_route_point_to_point (username text, organization_name text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_route_point_to_point (username, organization_name, origin, destination, mode, options, units);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_demographic_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), time_span text DEFAULT '2009 - 2013'::text, geometry_level text DEFAULT '"us.census.tiger".block_group'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_demographic_snapshot (username, organization_name, geom, time_span, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_get_segment_snapshot (username text, organization_name text, geom geometry(Geometry, 4326), geometry_level text DEFAULT '"us.census.tiger".census_tract'::text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_get_segment_snapshot (username, organization_name, geom, geometry_level);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
-- Make sure by default there are no permissions for publicuser
|
||||||
|
-- NOTE: this happens at extension creation time, as part of an implicit transaction.
|
||||||
|
REVOKE ALL PRIVILEGES ON SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser CASCADE;
|
||||||
|
|
||||||
|
-- Grant permissions on the schema to publicuser (but just the schema)
|
||||||
|
GRANT USAGE ON SCHEMA cdb_dataservices_client TO publicuser;
|
||||||
|
|
||||||
|
-- Revoke execute permissions on all functions in the schema by default
|
||||||
|
REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser;GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin0_polygon(country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon(admin1_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon(admin1_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point(postal_code text, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_ipaddress_point(ip_address text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_route_point_to_point(origin geometry(Point, 4326), destination geometry(Point, 4326), mode text, options text[], units text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_get_demographic_snapshot(geom geometry(Geometry, 4326), time_span text, geometry_level text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_get_segment_snapshot(geom geometry(Geometry, 4326), geometry_level text) TO publicuser;
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.4.0'" to load this file. \quit
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_get_demographic_snapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_get_segment_snapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getdemographicsnapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getsegmentsnapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getboundary(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getboundaryid(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getboundarybyid(text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getboundariesbygeometry(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getboundariesbypointandradius(geometry, numeric, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getpointsbygeometry(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getpointsbypointandradius(geometry, numeric, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getmeasure(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getcategory(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getuscensusmeasure(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getuscensuscategory(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getpopulation(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_search(text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getavailableboundaries(geometry);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_get_demographic_snapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_get_segment_snapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getdemographicsnapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getsegmentsnapshot(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getboundary(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getboundaryid(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getboundarybyid(text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getboundariesbygeometry(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getboundariesbypointandradius(geometry, numeric, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getpointsbygeometry(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getpointsbypointandradius(geometry, numeric, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getmeasure(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getcategory(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getuscensusmeasure(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getuscensuscategory(geometry, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getpopulation(geometry);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_search(text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getavailableboundaries(geometry);
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.6.0'" to load this file. \quit
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_route_with_waypoints (waypoints geometry(Point, 4326)[], mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_route_with_waypoints(username, orgname, waypoints, mode, options, units) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_route_with_waypoints (username text, organization_name text, waypoints geometry(Point, 4326)[], mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_route_with_waypoints (username, organization_name, waypoints, mode, options, units);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_route_with_waypoints(waypoints geometry(Point, 4326)[], mode text, options text[], units text) TO publicuser;
|
||||||
1219
client/old_versions/cdb_dataservices_client--0.5.0.sql
Normal file
1219
client/old_versions/cdb_dataservices_client--0.5.0.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.5.0'" to load this file. \quit
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_route_with_waypoints (text, text, geometry(Point, 4326)[], text, text[], text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_route_with_waypoints (geometry(Point, 4326)[], text, text[], text);
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.7.0'" to load this file. \quit
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getmeasurebyid (geom_ref text, measure_id text, boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
DECLARE
|
||||||
|
ret numeric;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._obs_getmeasurebyid(username, orgname, geom_ref, measure_id, boundary_id, time_span) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getmeasurebyid (username text, organization_name text, geom_ref text, measure_id text, boundary_id text, time_span text DEFAULT NULL)
|
||||||
|
RETURNS numeric AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.obs_getmeasurebyid (username, organization_name, geom_ref, measure_id, boundary_id, time_span);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getmeasurebyid(geom_ref text, measure_id text, boundary_id text, time_span text) TO publicuser;
|
||||||
1256
client/old_versions/cdb_dataservices_client--0.6.0.sql
Normal file
1256
client/old_versions/cdb_dataservices_client--0.6.0.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.6.0'" to load this file. \quit
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_getmeasurebyid (text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_getmeasurebyid (text, text, text, text);
|
||||||
113
client/old_versions/cdb_dataservices_client--0.7.0--0.8.0.sql
Normal file
113
client/old_versions/cdb_dataservices_client--0.7.0--0.8.0.sql
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.8.0'" to load this file. \quit
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_here_geocode_street_point (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_here_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_google_geocode_street_point (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_google_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapzen_geocode_street_point (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client._cdb_mapzen_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_here_geocode_street_point (username text, organization_name text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_here_geocode_street_point (username, organization_name, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_google_geocode_street_point (username text, organization_name text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_google_geocode_street_point (username, organization_name, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapzen_geocode_street_point (username text, organization_name text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_mapzen_geocode_street_point (username, organization_name, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
1293
client/old_versions/cdb_dataservices_client--0.7.0.sql
Normal file
1293
client/old_versions/cdb_dataservices_client--0.7.0.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.7.0'" to load this file. \quit
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_here_geocode_street_point (text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_google_geocode_street_point (text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_mapzen_geocode_street_point (text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_here_geocode_street_point (text, text, text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_google_geocode_street_point (text, text, text, text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapzen_geocode_street_point (text, text, text, text, text, text);
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.9.0'" to load this file. \quit
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapzen_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_mapzen_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Public dataservices API function
|
||||||
|
--
|
||||||
|
-- These are the only ones with permissions to publicuser role
|
||||||
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapzen_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT * FROM cdb_dataservices_client._cdb_mapzen_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapzen_isochrone (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_mapzen_isochrone (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapzen_isodistance (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
||||||
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_mapzen_isodistance (username, organization_name, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapzen_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapzen_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
|
||||||
|
-- Grants missing in previous version
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_here_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_google_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapzen_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
1404
client/old_versions/cdb_dataservices_client--0.8.0.sql
Normal file
1404
client/old_versions/cdb_dataservices_client--0.8.0.sql
Normal file
File diff suppressed because it is too large
Load Diff
303
client/old_versions/cdb_dataservices_client--0.9.0--0.10.0.sql
Normal file
303
client/old_versions/cdb_dataservices_client--0.9.0--0.10.0.sql
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.10.0'" to load this file. \quit
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.ds_fdw_metadata as (schemaname text, tabname text, servername text);
|
||||||
|
CREATE TYPE cdb_dataservices_client.ds_return_metadata as (colnames text[], coltypes text[]);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_GetTable(table_name text, output_table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
dbname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT current_database() INTO dbname;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__OBS_GetTable(username, orgname, user_db_role, user_schema, dbname, table_name, output_table_name, function_name, params) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_AugmentTable(table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
dbname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT current_database() INTO dbname;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__OBS_AugmentTable(username, orgname, user_db_role, user_schema, dbname, table_name, function_name, params) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__OBS_AugmentTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
from time import strftime
|
||||||
|
try:
|
||||||
|
server_table_name = None
|
||||||
|
temporary_table_name = 'ds_tmp_' + str(strftime("%s")) + table_name
|
||||||
|
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._OBS_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params))
|
||||||
|
)
|
||||||
|
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
colnames = ','.join(colnames_arr)
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute("SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._OBS_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, {user_schema}::text, {dbname}::text, {table_name}::text);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), user_db_role=plpy.quote_literal(user_db_role), user_schema=plpy.quote_literal(user_schema), dbname=plpy.quote_literal(dbname), table_name=plpy.quote_literal(table_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
|
||||||
|
# Create temporary table with the augmented results
|
||||||
|
plpy.execute('CREATE UNLOGGED TABLE "{user_schema}".{temp_table_name} AS '
|
||||||
|
'(SELECT {columns}, cartodb_id '
|
||||||
|
'FROM cdb_dataservices_client._OBS_FetchJoinFdwTableData('
|
||||||
|
'{username}::text, {orgname}::text, {schema}::text, {table_name}::text, {function_name}::text, {params}::json) '
|
||||||
|
'AS results({columns_with_types}, cartodb_id int) )'
|
||||||
|
.format(columns=colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema=user_schema, schema=plpy.quote_literal(server_schema), table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params), columns_with_types=columns_with_types,
|
||||||
|
temp_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
# Prepare table to receive augmented results in new columns
|
||||||
|
for idx, column in enumerate(colnames_arr):
|
||||||
|
if colnames_arr[idx] is not 'the_geom':
|
||||||
|
plpy.execute('ALTER TABLE "{user_schema}".{table_name} ADD COLUMN {column_name} {column_type}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, column_name=colnames_arr[idx], column_type=coltypes_arr[idx])
|
||||||
|
)
|
||||||
|
|
||||||
|
# Populate the user table with the augmented results
|
||||||
|
plpy.execute('UPDATE "{user_schema}".{table_name} SET {columns} = '
|
||||||
|
'(SELECT {columns} FROM "{user_schema}".{temporary_table_name} '
|
||||||
|
'WHERE "{user_schema}".{temporary_table_name}.cartodb_id = "{user_schema}".{table_name}.cartodb_id)'
|
||||||
|
.format(columns = colnames, username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_schema = user_schema, table_name=table_name, function_name=function_name, params=params, columns_with_types=columns_with_types,
|
||||||
|
temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
plpy.warning('Error trying to augment table {0}'.format(e))
|
||||||
|
# Wipe user FDW data from the server in case of failure if the table was connected
|
||||||
|
if server_table_name:
|
||||||
|
# Wipe local temporary table
|
||||||
|
plpy.execute('DROP TABLE IF EXISTS "{user_schema}".{temporary_table_name}'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, temporary_table_name=temporary_table_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__OBS_GetTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text, output_table_name text, function_name text, params json)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
try:
|
||||||
|
server_table_name = None
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._OBS_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params))
|
||||||
|
)
|
||||||
|
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
colnames = ','.join(colnames_arr)
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute("SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._OBS_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, {schema}::text, {dbname}::text, {table_name}::text);"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), user_db_role=plpy.quote_literal(user_db_role), schema=plpy.quote_literal(user_schema), dbname=plpy.quote_literal(dbname), table_name=plpy.quote_literal(table_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
|
||||||
|
# Get list of user columns to include in the new table
|
||||||
|
user_table_columns = ','.join(
|
||||||
|
plpy.execute('SELECT array_agg(\'user_table.\' || attname) AS columns '
|
||||||
|
'FROM pg_attribute WHERE attrelid = \'"{user_schema}".{table_name}\'::regclass '
|
||||||
|
'AND attnum > 0 AND NOT attisdropped AND attname NOT LIKE \'the_geom_webmercator\' '
|
||||||
|
'AND NOT attname LIKE ANY(string_to_array(\'{colnames}\',\',\'));'
|
||||||
|
.format(user_schema=user_schema, table_name=table_name, colnames=colnames)
|
||||||
|
)[0]["columns"]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Populate a new table with the augmented results
|
||||||
|
plpy.execute('CREATE TABLE "{user_schema}".{output_table_name} AS '
|
||||||
|
'(SELECT results.{columns}, {user_table_columns} '
|
||||||
|
'FROM {table_name} AS user_table '
|
||||||
|
'LEFT JOIN cdb_dataservices_client._OBS_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {function_name}::text, {params}::json) as results({columns_with_types}, cartodb_id int) '
|
||||||
|
'ON results.cartodb_id = user_table.cartodb_id)'
|
||||||
|
.format(output_table_name=output_table_name, columns=colnames, user_table_columns=user_table_columns, username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname), user_schema=user_schema, server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
table_name=table_name, function_name=plpy.quote_literal(function_name), params=plpy.quote_literal(params), columns_with_types=columns_with_types)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('ALTER TABLE "{schema}".{table_name} OWNER TO "{user}";'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, user=user_db_role)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
plpy.warning('Error trying to get table {0}'.format(e))
|
||||||
|
# Wipe user FDW data from the server in case of failure if the table was connected
|
||||||
|
if server_table_name:
|
||||||
|
wiped = plpy.execute("SELECT cdb_dataservices_client._OBS_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, {fdw_server}::text)"
|
||||||
|
.format(username=plpy.quote_nullable(username), orgname=plpy.quote_nullable(orgname), server_schema=plpy.quote_literal(server_schema), server_table_name=plpy.quote_literal(server_table_name), fdw_server=plpy.quote_literal(server_name))
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_ConnectUserTable(username text, orgname text, user_db_role text, user_schema text, dbname text, table_name text)
|
||||||
|
RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_ConnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_GetReturnMetadata(username text, orgname text, function_name text, params json)
|
||||||
|
RETURNS cdb_dataservices_client.ds_return_metadata AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_GetReturnMetadata;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_FetchJoinFdwTableData(username text, orgname text, table_schema text, table_name text, function_name text, params json)
|
||||||
|
RETURNS SETOF record AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_FetchJoinFdwTableData;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_DisconnectUserTable(username text, orgname text, table_schema text, table_name text, server_name text)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
CONNECT _server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._OBS_DisconnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_dumpversion ()
|
||||||
|
RETURNS text AS $$
|
||||||
|
DECLARE
|
||||||
|
ret text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_client._obs_dumpversion(username, orgname) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_dumpversion (username text, organization_name text)
|
||||||
|
|
||||||
|
RETURNS text AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_dumpversion (username, organization_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._OBS_AugmentTable(text, text, json) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._OBS_GetTable(text, text, text, json) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.OBS_DumpVersion() TO publicuser;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
||||||
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.8.0'" to load this file. \quit
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_mapzen_isochrone(geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_mapzen_isodistance(geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapzen_isochrone(text, text, geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapzen_isodistance(text, text, geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
1478
client/old_versions/cdb_dataservices_client--0.9.0.sql
Normal file
1478
client/old_versions/cdb_dataservices_client--0.9.0.sql
Normal file
File diff suppressed because it is too large
Load Diff
328
client/renderer/interface.yaml
Normal file
328
client/renderer/interface.yaml
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
---
|
||||||
|
- name: cdb_geocode_admin0_polygon
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: country_name, type: text }
|
||||||
|
|
||||||
|
- name: cdb_geocode_admin1_polygon
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: admin1_name, type: text }
|
||||||
|
|
||||||
|
- name: cdb_geocode_admin1_polygon
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: admin1_name, type: text }
|
||||||
|
- { name: country_name, type: text }
|
||||||
|
|
||||||
|
- name: cdb_geocode_namedplace_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: city_name, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_namedplace_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: city_name, type: text}
|
||||||
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_namedplace_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: city_name, type: text}
|
||||||
|
- { name: admin1_name, type: text}
|
||||||
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_postalcode_polygon
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: postal_code, type: text}
|
||||||
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_postalcode_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: postal_code, type: text}
|
||||||
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_ipaddress_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: ip_address, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_street_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: searchtext, type: text}
|
||||||
|
- { name: city, type: text, default: 'NULL'}
|
||||||
|
- { name: state_province, type: text, default: 'NULL'}
|
||||||
|
- { name: country, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: cdb_here_geocode_street_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: searchtext, type: text}
|
||||||
|
- { name: city, type: text, default: 'NULL'}
|
||||||
|
- { name: state_province, type: text, default: 'NULL'}
|
||||||
|
- { name: country, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: cdb_google_geocode_street_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: searchtext, type: text}
|
||||||
|
- { name: city, type: text, default: 'NULL'}
|
||||||
|
- { name: state_province, type: text, default: 'NULL'}
|
||||||
|
- { name: country, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: cdb_mapzen_geocode_street_point
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: searchtext, type: text}
|
||||||
|
- { name: city, type: text, default: 'NULL'}
|
||||||
|
- { name: state_province, type: text, default: 'NULL'}
|
||||||
|
- { name: country, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: cdb_isodistance
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
params:
|
||||||
|
- { name: source, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_isochrone
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
params:
|
||||||
|
- { name: source, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_mapzen_isochrone
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
params:
|
||||||
|
- { name: source, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_mapzen_isodistance
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
params:
|
||||||
|
- { name: source, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_route_point_to_point
|
||||||
|
return_type: cdb_dataservices_client.simple_route
|
||||||
|
multi_field: true
|
||||||
|
params:
|
||||||
|
- { name: origin, type: "geometry(Point, 4326)" }
|
||||||
|
- { name: destination, type: "geometry(Point, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
- { name: units, type: "text", default: "'kilometers'"}
|
||||||
|
|
||||||
|
- name: cdb_route_with_waypoints
|
||||||
|
return_type: cdb_dataservices_client.simple_route
|
||||||
|
multi_field: true
|
||||||
|
params:
|
||||||
|
- { name: waypoints, type: "geometry(Point, 4326)[]" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
- { name: units, type: "text", default: "'kilometers'"}
|
||||||
|
|
||||||
|
- name: obs_get_demographic_snapshot
|
||||||
|
return_type: json
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: time_span, type: "text", default: "'2009 - 2013'::text" }
|
||||||
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
|
- name: obs_get_segment_snapshot
|
||||||
|
return_type: json
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
|
- name: obs_getdemographicsnapshot
|
||||||
|
return_type: SETOF JSON
|
||||||
|
multi_row: true
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: time_span, type: "text", default: 'NULL' }
|
||||||
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
|
- name: obs_getsegmentsnapshot
|
||||||
|
return_type: SETOF JSON
|
||||||
|
multi_row: true
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
|
- name: obs_getboundary
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getboundaryid
|
||||||
|
return_type: text
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getboundarybyid
|
||||||
|
return_type: Geometry
|
||||||
|
params:
|
||||||
|
- { name: geometry_id, type: text }
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getboundariesbygeometry
|
||||||
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
table_fields:
|
||||||
|
- { name: the_geom, type: geometry }
|
||||||
|
- { name: geom_refs, type: text }
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
- { name: overlap_type, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getboundariesbypointandradius
|
||||||
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
table_fields:
|
||||||
|
- { name: the_geom, type: geometry }
|
||||||
|
- { name: geom_refs, type: text }
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: radius, type: numeric }
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
- { name: overlap_type, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getpointsbygeometry
|
||||||
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
table_fields:
|
||||||
|
- { name: the_geom, type: geometry }
|
||||||
|
- { name: geom_refs, type: text }
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
- { name: overlap_type, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getpointsbypointandradius
|
||||||
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
table_fields:
|
||||||
|
- { name: the_geom, type: geometry }
|
||||||
|
- { name: geom_refs, type: text }
|
||||||
|
params:
|
||||||
|
- { name: geom, type: "geometry(Geometry, 4326)" }
|
||||||
|
- { name: radius, type: numeric }
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
- { name: overlap_type, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getmeasure
|
||||||
|
return_type: numeric
|
||||||
|
params:
|
||||||
|
- { name: geom, type: Geometry }
|
||||||
|
- { name: measure_id, type: text }
|
||||||
|
- { name: normalize, type: text, default: 'NULL'}
|
||||||
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getmeasurebyid
|
||||||
|
return_type: numeric
|
||||||
|
params:
|
||||||
|
- { name: geom_ref, type: text }
|
||||||
|
- { name: measure_id, type: text }
|
||||||
|
- { name: boundary_id, type: text}
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getcategory
|
||||||
|
return_type: text
|
||||||
|
params:
|
||||||
|
- { name: geom, type: Geometry }
|
||||||
|
- { name: category_id, type: text }
|
||||||
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getuscensusmeasure
|
||||||
|
return_type: numeric
|
||||||
|
params:
|
||||||
|
- { name: geom, type: Geometry }
|
||||||
|
- { name: name, type: text }
|
||||||
|
- { name: normalize, type: text, default: 'NULL'}
|
||||||
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getuscensuscategory
|
||||||
|
return_type: text
|
||||||
|
params:
|
||||||
|
- { name: geom, type: Geometry }
|
||||||
|
- { name: name, type: text }
|
||||||
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_getpopulation
|
||||||
|
return_type: numeric
|
||||||
|
params:
|
||||||
|
- { name: geom, type: Geometry }
|
||||||
|
- { name: normalize, type: text, default: 'NULL'}
|
||||||
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_search
|
||||||
|
return_type: TABLE(id text, description text, name text, aggregate text, source text)
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
table_fields:
|
||||||
|
- { name: id, type: text }
|
||||||
|
- { name: description, type: text }
|
||||||
|
- { name: name, type: text }
|
||||||
|
- { name: aggregate, type: text }
|
||||||
|
- { name: source, type: text }
|
||||||
|
params:
|
||||||
|
- { name: search_term, type: text }
|
||||||
|
- { name: relevant_boundary, type: text, default: 'NULL' }
|
||||||
|
|
||||||
|
- name: obs_getavailableboundaries
|
||||||
|
return_type: TABLE(boundary_id text, description text, time_span text, tablename text)
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
table_fields:
|
||||||
|
- { name: boundary_id, type: text }
|
||||||
|
- { name: description, type: text }
|
||||||
|
- { name: time_span, type: text }
|
||||||
|
- { name: tablename, type: text }
|
||||||
|
params:
|
||||||
|
- { name: geom, type: Geometry }
|
||||||
|
- { name: timespan, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_dumpversion
|
||||||
|
return_type: text
|
||||||
|
no_params: true
|
||||||
|
params:
|
||||||
|
- {}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
---
|
|
||||||
- name: cdb_geocode_admin0_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: country_name, type: text }
|
|
||||||
|
|
||||||
- name: cdb_geocode_admin1_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: admin1_name, type: text }
|
|
||||||
|
|
||||||
- name: cdb_geocode_admin1_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: admin1_name, type: text }
|
|
||||||
- { name: country_name, type: text }
|
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: city_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: city_name, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: city_name, type: text}
|
|
||||||
- { name: admin1_name, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
|
|
||||||
- name: cdb_geocode_postalcode_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: postal_code, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_postalcode_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: postal_code, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_ipaddress_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: ip_address, type: text}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
---
|
|
||||||
- name: cdb_geocode_admin0_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: country_name, type: text }
|
|
||||||
|
|
||||||
- name: cdb_geocode_admin1_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: admin1_name, type: text }
|
|
||||||
|
|
||||||
- name: cdb_geocode_admin1_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: admin1_name, type: text }
|
|
||||||
- { name: country_name, type: text }
|
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: city_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: city_name, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: city_name, type: text}
|
|
||||||
- { name: admin1_name, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
|
|
||||||
- name: cdb_geocode_postalcode_polygon
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: postal_code, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_postalcode_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: postal_code, type: text}
|
|
||||||
- { name: country_name, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_ipaddress_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: ip_address, type: text}
|
|
||||||
|
|
||||||
- name: cdb_geocode_street_point
|
|
||||||
return_type: Geometry
|
|
||||||
params:
|
|
||||||
- { name: searchtext, type: text}
|
|
||||||
- { name: city, type: text, default: 'NULL'}
|
|
||||||
- { name: state_province, type: text, default: 'NULL'}
|
|
||||||
- { name: country, type: text, default: 'NULL'}
|
|
||||||
@@ -28,6 +28,18 @@ class SqlTemplateRenderer
|
|||||||
@function_signature['return_type']
|
@function_signature['return_type']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def multi_field
|
||||||
|
@function_signature['multi_field']
|
||||||
|
end
|
||||||
|
|
||||||
|
def multi_row
|
||||||
|
@function_signature['multi_row']
|
||||||
|
end
|
||||||
|
|
||||||
|
def no_params
|
||||||
|
@function_signature['no_params']
|
||||||
|
end
|
||||||
|
|
||||||
def user_config_key
|
def user_config_key
|
||||||
@function_signature['user_config_key']
|
@function_signature['user_config_key']
|
||||||
end
|
end
|
||||||
@@ -37,15 +49,15 @@ class SqlTemplateRenderer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
@function_signature['params'].map { |p| p['name'] }.join(', ')
|
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']}"}.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type
|
def params_with_type
|
||||||
@function_signature['params'].map { |p| "#{p['name']} #{p['type']}" }.join(', ')
|
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']} #{p['type']}" }.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type_and_default
|
def params_with_type_and_default
|
||||||
parameters = @function_signature['params'].map do |p|
|
parameters = @function_signature['params'].reject(&:empty?).map do |p|
|
||||||
if not p['default'].nil?
|
if not p['default'].nil?
|
||||||
"#{p['name']} #{p['type']} DEFAULT #{p['default']}"
|
"#{p['name']} #{p['type']} DEFAULT #{p['default']}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--
|
--
|
||||||
-- Public geocoder API function
|
-- Public dataservices API function
|
||||||
--
|
--
|
||||||
-- These are the only ones with permissions to publicuser role
|
-- These are the only ones with permissions to publicuser role
|
||||||
-- and should also be the only ones with SECURITY DEFINER
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default %>)
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default %>)
|
||||||
RETURNS <%= return_type %> AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret <%= return_type %>;
|
<% if not multi_row %>ret <%= return_type %>;<% end %>
|
||||||
username text;
|
username text;
|
||||||
orgname text;
|
orgname text;
|
||||||
BEGIN
|
BEGIN
|
||||||
@@ -19,8 +19,18 @@ BEGIN
|
|||||||
IF username IS NULL OR username = '' OR username = '""' THEN
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
END IF;
|
END IF;
|
||||||
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
<% if multi_row %>
|
||||||
RETURN ret;
|
RETURN QUERY
|
||||||
|
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>);
|
||||||
|
<% elsif multi_field %>
|
||||||
|
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
<% elsif no_params %>
|
||||||
|
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
<% else %>
|
||||||
|
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
<% end %>
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
|
<% if no_params %>
|
||||||
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text)
|
||||||
|
<% else %>
|
||||||
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type_and_default %>)
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type_and_default %>)
|
||||||
|
<% end %>
|
||||||
RETURNS <%= return_type %> AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
CONNECT <%= DATASERVICES_CLIENT_SCHEMA %>._server_conn_str();
|
CONNECT <%= DATASERVICES_CLIENT_SCHEMA %>._server_conn_str();
|
||||||
|
<% if multi_field %>
|
||||||
|
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
||||||
|
<% elsif no_params %>
|
||||||
|
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name);
|
||||||
|
<% else %>
|
||||||
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
||||||
|
<% end %>
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
--
|
|
||||||
-- Geocoder server connection config
|
|
||||||
--
|
|
||||||
-- The purpose of this function is provide to the PL/Proxy functions
|
|
||||||
-- the connection string needed to connect with the server
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client._server_conn_str()
|
|
||||||
RETURNS text AS $$
|
|
||||||
DECLARE
|
|
||||||
db_connection_str text;
|
|
||||||
BEGIN
|
|
||||||
SELECT cartodb.cdb_conf_getconf('geocoder_server_config')->'connection_str' INTO db_connection_str;
|
|
||||||
SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str;
|
|
||||||
RETURN db_connection_str;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
CREATE TYPE cdb_dataservices_client._entity_config AS (
|
|
||||||
username text,
|
|
||||||
organization_name text
|
|
||||||
);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Get entity config function
|
|
||||||
--
|
|
||||||
-- The purpose of this function is to retrieve the username and organization name from
|
|
||||||
-- a) schema where he/her is the owner in case is an organization user
|
|
||||||
-- b) entity_name from the cdb_conf database in case is a non organization user
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_entity_config()
|
|
||||||
RETURNS record AS $$
|
|
||||||
DECLARE
|
|
||||||
result cdb_dataservices_client._entity_config;
|
|
||||||
is_organization boolean;
|
|
||||||
username text;
|
|
||||||
organization_name text;
|
|
||||||
BEGIN
|
|
||||||
SELECT cartodb.cdb_conf_getconf('user_config')->'is_organization' INTO is_organization;
|
|
||||||
IF is_organization IS NULL THEN
|
|
||||||
RAISE EXCEPTION 'User must have user configuration in the config table';
|
|
||||||
ELSIF is_organization = TRUE THEN
|
|
||||||
SELECT nspname
|
|
||||||
FROM pg_namespace s
|
|
||||||
LEFT JOIN pg_roles r ON s.nspowner = r.oid
|
|
||||||
WHERE r.rolname = session_user INTO username;
|
|
||||||
SELECT cartodb.cdb_conf_getconf('user_config')->'entity_name' INTO organization_name;
|
|
||||||
ELSE
|
|
||||||
SELECT cartodb.cdb_conf_getconf('user_config')->'entity_name' INTO username;
|
|
||||||
organization_name = NULL;
|
|
||||||
END IF;
|
|
||||||
result.username = username;
|
|
||||||
result.organization_name = organization_name;
|
|
||||||
RETURN result;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
|
||||||
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
||||||
\echo Use "CREATE EXTENSION cdb_dataservices_client" to load this file. \quit
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
-- Make sure by default there are no permissions for publicuser
|
|
||||||
-- NOTE: this happens at extension creation time, as part of an implicit transaction.
|
|
||||||
REVOKE ALL PRIVILEGES ON SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser CASCADE;
|
|
||||||
|
|
||||||
-- Grant permissions on the schema to publicuser (but just the schema)
|
|
||||||
GRANT USAGE ON SCHEMA cdb_dataservices_client TO publicuser;
|
|
||||||
|
|
||||||
-- Revoke execute permissions on all functions in the schema by default
|
|
||||||
REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_dataservices_client FROM PUBLIC, publicuser;
|
|
||||||
11
client/sql/16_custom_types.sql
Normal file
11
client/sql/16_custom_types.sql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
CREATE TYPE cdb_dataservices_client.isoline AS (
|
||||||
|
center geometry(Geometry,4326),
|
||||||
|
data_range integer,
|
||||||
|
the_geom geometry(Multipolygon,4326)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.simple_route AS (
|
||||||
|
shape geometry(LineString,4326),
|
||||||
|
length real,
|
||||||
|
duration integer
|
||||||
|
);
|
||||||
275
client/sql/20_table_augmentation.sql
Normal file
275
client/sql/20_table_augmentation.sql
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
CREATE TYPE cdb_dataservices_client.ds_fdw_metadata as (schemaname text, tabname text, servername text);
|
||||||
|
CREATE TYPE cdb_dataservices_client.ds_return_metadata as (colnames text[], coltypes text[]);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_PrepareTableOBS_GetMeasure(
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
||||||
|
username,
|
||||||
|
orgname,
|
||||||
|
user_db_role,
|
||||||
|
user_schema,
|
||||||
|
output_table_name,
|
||||||
|
params
|
||||||
|
) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(
|
||||||
|
table_name text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
user_db_role text;
|
||||||
|
orgname text;
|
||||||
|
dbname text;
|
||||||
|
user_schema text;
|
||||||
|
result boolean;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT session_user INTO user_db_role;
|
||||||
|
|
||||||
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
||||||
|
-- JSON value stored "" is taken as literal
|
||||||
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF orgname IS NULL OR orgname = '' OR orgname = '""' THEN
|
||||||
|
user_schema := 'public';
|
||||||
|
ELSE
|
||||||
|
user_schema := username;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT current_database() INTO dbname;
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
||||||
|
username,
|
||||||
|
orgname,
|
||||||
|
user_db_role,
|
||||||
|
user_schema,
|
||||||
|
dbname,
|
||||||
|
table_name,
|
||||||
|
output_table_name,
|
||||||
|
params
|
||||||
|
) INTO result;
|
||||||
|
|
||||||
|
RETURN result;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'OBS_GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute("SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);"
|
||||||
|
.format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [colnames_arr[i] + ' ' + coltypes_arr[i] for i in range(0,len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute('CREATE TABLE "{schema}".{table_name} ( '
|
||||||
|
'cartodb_id int, the_geom geometry, {columns_with_types} '
|
||||||
|
');'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, columns_with_types=columns_with_types)
|
||||||
|
)
|
||||||
|
|
||||||
|
plpy.execute('ALTER TABLE "{schema}".{table_name} OWNER TO "{user}";'
|
||||||
|
.format(schema=user_schema, table_name=output_table_name, user=user_db_role)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
dbname text,
|
||||||
|
table_name text,
|
||||||
|
output_table_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
function_name = 'OBS_GetMeasure'
|
||||||
|
# Obtain return types for augmentation procedure
|
||||||
|
ds_return_metadata = plpy.execute(
|
||||||
|
"SELECT colnames, coltypes "
|
||||||
|
"FROM cdb_dataservices_client._DST_GetReturnMetadata({username}::text, {orgname}::text, {function_name}::text, {params}::json);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params)))
|
||||||
|
|
||||||
|
if ds_return_metadata[0]["colnames"]:
|
||||||
|
colnames_arr = ds_return_metadata[0]["colnames"]
|
||||||
|
coltypes_arr = ds_return_metadata[0]["coltypes"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error retrieving OBS_GetMeasure metadata')
|
||||||
|
|
||||||
|
# Prepare column and type strings required in the SQL queries
|
||||||
|
columns_with_types_arr = [
|
||||||
|
colnames_arr[i] +
|
||||||
|
' ' +
|
||||||
|
coltypes_arr[i] for i in range(
|
||||||
|
0,
|
||||||
|
len(colnames_arr))]
|
||||||
|
columns_with_types = ','.join(columns_with_types_arr)
|
||||||
|
aliased_colname_list = ','.join(
|
||||||
|
['result.' + name for name in colnames_arr])
|
||||||
|
|
||||||
|
# Instruct the OBS server side to establish a FDW
|
||||||
|
# The metadata is obtained as well in order to:
|
||||||
|
# - (a) be able to write the query to grab the actual data to be executed in the remote server via pl/proxy,
|
||||||
|
# - (b) be able to tell OBS to free resources when done.
|
||||||
|
ds_fdw_metadata = plpy.execute(
|
||||||
|
"SELECT schemaname, tabname, servername "
|
||||||
|
"FROM cdb_dataservices_client._DST_ConnectUserTable({username}::text, {orgname}::text, {user_db_role}::text, "
|
||||||
|
"{schema}::text, {dbname}::text, {table_name}::text);" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
user_db_role=plpy.quote_literal(user_db_role),
|
||||||
|
schema=plpy.quote_literal(user_schema),
|
||||||
|
dbname=plpy.quote_literal(dbname),
|
||||||
|
table_name=plpy.quote_literal(table_name)))
|
||||||
|
|
||||||
|
if ds_fdw_metadata[0]["schemaname"]:
|
||||||
|
server_schema = ds_fdw_metadata[0]["schemaname"]
|
||||||
|
server_table_name = ds_fdw_metadata[0]["tabname"]
|
||||||
|
server_name = ds_fdw_metadata[0]["servername"]
|
||||||
|
else:
|
||||||
|
raise Exception('Error connecting dataset via FDW')
|
||||||
|
|
||||||
|
# Create a new table with the required columns
|
||||||
|
plpy.execute(
|
||||||
|
'INSERT INTO "{schema}".{analysis_table_name} '
|
||||||
|
'SELECT ut.cartodb_id, ut.the_geom, {colname_list} '
|
||||||
|
'FROM "{schema}".{table_name} ut '
|
||||||
|
'LEFT JOIN _DST_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, '
|
||||||
|
'{function_name}::text, {params}::json) '
|
||||||
|
'AS result ({columns_with_types}, cartodb_id int) '
|
||||||
|
'ON result.cartodb_id = ut.cartodb_id;' .format(
|
||||||
|
schema=user_schema,
|
||||||
|
analysis_table_name=output_table_name,
|
||||||
|
colname_list=aliased_colname_list,
|
||||||
|
table_name=table_name,
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
function_name=plpy.quote_literal(function_name),
|
||||||
|
params=plpy.quote_literal(params),
|
||||||
|
columns_with_types=columns_with_types))
|
||||||
|
|
||||||
|
# Wipe user FDW data from the server
|
||||||
|
wiped = plpy.execute(
|
||||||
|
"SELECT cdb_dataservices_client._DST_DisconnectUserTable({username}::text, {orgname}::text, {server_schema}::text, "
|
||||||
|
"{server_table_name}::text, {fdw_server}::text)" .format(
|
||||||
|
username=plpy.quote_nullable(username),
|
||||||
|
orgname=plpy.quote_nullable(orgname),
|
||||||
|
server_schema=plpy.quote_literal(server_schema),
|
||||||
|
server_table_name=plpy.quote_literal(server_table_name),
|
||||||
|
fdw_server=plpy.quote_literal(server_name)))
|
||||||
|
|
||||||
|
return True
|
||||||
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_ConnectUserTable(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
user_db_role text,
|
||||||
|
user_schema text,
|
||||||
|
dbname text,
|
||||||
|
table_name text
|
||||||
|
)RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_ConnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_GetReturnMetadata(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
function_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS cdb_dataservices_client.ds_return_metadata AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_GetReturnMetadata;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_FetchJoinFdwTableData(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
table_schema text,
|
||||||
|
table_name text,
|
||||||
|
function_name text,
|
||||||
|
params json
|
||||||
|
) RETURNS SETOF record AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_FetchJoinFdwTableData;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_DisconnectUserTable(
|
||||||
|
username text,
|
||||||
|
orgname text,
|
||||||
|
table_schema text,
|
||||||
|
table_name text,
|
||||||
|
server_name text
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
TARGET cdb_dataservices_server._DST_DisconnectUserTable;
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
2
client/sql/95_grant_execute_manual.sql
Normal file
2
client/sql/95_grant_execute_manual.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._DST_PrepareTableOBS_GetMeasure(output_table_name text, params json) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(table_name text, output_table_name text, params json) TO publicuser;
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
-- Mock the server function
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (%, %, %)', username, orgname, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params ("test_user", <NULL>, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin0_polygon(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_admin0_polygon
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %)', username, orgname, admin1_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', username, orgname, admin1_name, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params ("test_user", <NULL>, California)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_admin1_polygon
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params ("test_user", <NULL>, California, United States)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_admin1_polygon
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %)', username, orgname, city_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', username, orgname, city_name, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', username, orgname, city_name, admin1_name, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params ("test_user", <NULL>, Elx)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params ("test_user", <NULL>, Elx, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params ("test_user", <NULL>, Elx, Valencia, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %)', username, orgname, postal_code, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %)', username, orgname, postal_code, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params ("test_user", <NULL>, 03204, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_postalcode_polygon
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params ("test_user", <NULL>, 03204, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_postalcode_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, ip_address text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (%, %, %)', username, orgname, ip_address;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_ipaddress_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params ("test_user", <NULL>, 8.8.8.8)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address)"
|
|
||||||
PL/pgSQL function cdb_geocode_ipaddress_point(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_ipaddress_point
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
-- Use regular user role
|
|
||||||
SET ROLE test_regular_user;
|
|
||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
-- Exercise the public function
|
|
||||||
-- it is public, it shall work
|
|
||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params ("test_user", <NULL>, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin0_polygon(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_admin0_polygon
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params ("test_user", <NULL>, California)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_admin1_polygon
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params ("test_user", <NULL>, California, United States)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_admin1_polygon
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params ("test_user", <NULL>, Elx)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params ("test_user", <NULL>, Elx, Valencia)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params ("test_user", <NULL>, Elx, Valencia, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params ("test_user", <NULL>, 03204, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_postalcode_polygon
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params ("test_user", <NULL>, 03204, Spain)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name)"
|
|
||||||
PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 15 at SQL statement
|
|
||||||
cdb_geocode_postalcode_point
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_ipaddress_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params ("test_user", <NULL>, 8.8.8.8)
|
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address)"
|
|
||||||
PL/pgSQL function cdb_geocode_ipaddress_point(text) line 15 at SQL statement
|
|
||||||
cdb_geocode_ipaddress_point
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- Check the regular user has no permissions on private functions
|
|
||||||
SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'Hell');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_admin0_polygon
|
|
||||||
SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Hell');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_admin1_polygon
|
|
||||||
SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Sheol', 'Hell');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_admin1_polygon
|
|
||||||
SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_namedplace_point
|
|
||||||
SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_namedplace_point
|
|
||||||
SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell', 'Ugly world');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_namedplace_point
|
|
||||||
SELECT _cdb_geocode_postalcode_polygon('evil_user', 'evil_orgname', '66666', 'Hell');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_postalcode_polygon
|
|
||||||
SELECT _cdb_geocode_postalcode_point('evil_user', 'evil_orgname', '66666', 'Hell');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_postalcode_point
|
|
||||||
SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', '8.8.8.8');
|
|
||||||
ERROR: permission denied for function _cdb_geocode_ipaddress_point
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
-- Use regular user role
|
|
||||||
SET ROLE test_regular_user;
|
|
||||||
|
|
||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
|
|
||||||
-- Exercise the public function
|
|
||||||
-- it is public, it shall work
|
|
||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California');
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx');
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia');
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
|
||||||
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
|
||||||
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
|
||||||
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
|
||||||
|
|
||||||
-- Check the regular user has no permissions on private functions
|
|
||||||
SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'Hell');
|
|
||||||
SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Hell');
|
|
||||||
SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Sheol', 'Hell');
|
|
||||||
SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol');
|
|
||||||
SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell');
|
|
||||||
SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell', 'Ugly world');
|
|
||||||
SELECT _cdb_geocode_postalcode_polygon('evil_user', 'evil_orgname', '66666', 'Hell');
|
|
||||||
SELECT _cdb_geocode_postalcode_point('evil_user', 'evil_orgname', '66666', 'Hell');
|
|
||||||
SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', '8.8.8.8');
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
-- Install dependencies
|
|
||||||
CREATE EXTENSION postgis;
|
|
||||||
CREATE EXTENSION schema_triggers;
|
|
||||||
CREATE EXTENSION plpythonu;
|
|
||||||
CREATE EXTENSION cartodb;
|
|
||||||
CREATE EXTENSION plproxy;
|
|
||||||
-- Install the extension
|
|
||||||
CREATE EXTENSION cdb_dataservices_client;
|
|
||||||
-- Mock the server connection to point to this very test db
|
|
||||||
SELECT cartodb.cdb_conf_setconf('geocoder_server_config', '{"connection_str": "dbname=contrib_regression host=127.0.0.1 user=postgres"}');
|
|
||||||
cdb_conf_setconf
|
|
||||||
------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- Mock the user configuration
|
|
||||||
SELECT cartodb.cdb_conf_setconf('user_config', '{"is_organization": false, "entity_name": "test_user"}');
|
|
||||||
cdb_conf_setconf
|
|
||||||
------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- Mock the server schema
|
|
||||||
CREATE SCHEMA cdb_dataservices_server;
|
|
||||||
-- Create a test user to check permissions
|
|
||||||
DROP ROLE IF EXISTS test_regular_user;
|
|
||||||
CREATE ROLE test_regular_user;
|
|
||||||
GRANT publicuser TO test_regular_user;
|
|
||||||
ALTER ROLE test_regular_user SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
-- Install dependencies
|
|
||||||
CREATE EXTENSION postgis;
|
|
||||||
CREATE EXTENSION schema_triggers;
|
|
||||||
CREATE EXTENSION plpythonu;
|
|
||||||
CREATE EXTENSION cartodb;
|
|
||||||
CREATE EXTENSION plproxy;
|
|
||||||
|
|
||||||
-- Install the extension
|
|
||||||
CREATE EXTENSION cdb_dataservices_client;
|
|
||||||
|
|
||||||
-- Mock the server connection to point to this very test db
|
|
||||||
SELECT cartodb.cdb_conf_setconf('geocoder_server_config', '{"connection_str": "dbname=contrib_regression host=127.0.0.1 user=postgres"}');
|
|
||||||
-- Mock the user configuration
|
|
||||||
SELECT cartodb.cdb_conf_setconf('user_config', '{"is_organization": false, "entity_name": "test_user"}');
|
|
||||||
|
|
||||||
-- Mock the server schema
|
|
||||||
CREATE SCHEMA cdb_dataservices_server;
|
|
||||||
|
|
||||||
-- Create a test user to check permissions
|
|
||||||
DROP ROLE IF EXISTS test_regular_user;
|
|
||||||
CREATE ROLE test_regular_user;
|
|
||||||
GRANT publicuser TO test_regular_user;
|
|
||||||
ALTER ROLE test_regular_user SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
|
|
||||||
-- Mock the server function
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (%, %, %)', username, orgname, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %)', username, orgname, admin1_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', username, orgname, admin1_name, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California');
|
|
||||||
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %)', username, orgname, city_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', username, orgname, city_name, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', username, orgname, city_name, admin1_name, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx');
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
|
||||||
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %)', username, orgname, postal_code, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %)', username, orgname, postal_code, country_name;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
|
||||||
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
-- Add to the search path the schema
|
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
|
||||||
|
|
||||||
-- Mock the server functions
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, ip_address text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
BEGIN
|
|
||||||
RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (%, %, %)', username, orgname, ip_address;
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql';
|
|
||||||
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
|
||||||
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
|
||||||
@@ -12,7 +12,7 @@ $$ LANGUAGE 'plpgsql';
|
|||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (test_user, <NULL>, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (test_user, <NULL>, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_admin0_polygon(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_admin0_polygon(text) line 16 at SQL statement
|
||||||
cdb_geocode_admin0_polygon
|
cdb_geocode_admin0_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ $$ LANGUAGE 'plpgsql';
|
|||||||
SELECT cdb_geocode_admin1_polygon('California');
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California)
|
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name)"
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_admin1_polygon(text) line 16 at SQL statement
|
||||||
cdb_geocode_admin1_polygon
|
cdb_geocode_admin1_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ PL/pgSQL function cdb_geocode_admin1_polygon(text) line 15 at SQL statement
|
|||||||
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California, United States)
|
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California, United States)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_admin1_polygon
|
cdb_geocode_admin1_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ $$ LANGUAGE 'plpgsql';
|
|||||||
SELECT cdb_geocode_namedplace_point('Elx');
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx)
|
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name)"
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_namedplace_point(text) line 16 at SQL statement
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ PL/pgSQL function cdb_geocode_namedplace_point(text) line 15 at SQL statement
|
|||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 15 at SQL stateme
|
|||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Valencia, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Valencia, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ $$ LANGUAGE 'plpgsql';
|
|||||||
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (test_user, <NULL>, 03204, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (test_user, <NULL>, 03204, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_postalcode_polygon
|
cdb_geocode_postalcode_polygon
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 15 at SQL state
|
|||||||
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (test_user, <NULL>, 03204, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (test_user, <NULL>, 03204, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_postalcode_point
|
cdb_geocode_postalcode_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ $$ LANGUAGE 'plpgsql';
|
|||||||
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_ipaddress_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (test_user, <NULL>, 8.8.8.8)
|
NOTICE: cdb_dataservices_client._cdb_geocode_ipaddress_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (test_user, <NULL>, 8.8.8.8)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address)"
|
||||||
PL/pgSQL function cdb_geocode_ipaddress_point(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_ipaddress_point(text) line 16 at SQL statement
|
||||||
cdb_geocode_ipaddress_point
|
cdb_geocode_ipaddress_point
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ $$ LANGUAGE 'plpgsql';
|
|||||||
SELECT cdb_geocode_street_point('One street, 1');
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, 1, <NULL>, <NULL>, <NULL>)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, 1, <NULL>, <NULL>, <NULL>)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city');
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, <NULL>)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, <NULL>)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, <NULL>)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, <NULL>)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, country)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, country)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, country)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, country)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street, 1');
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, 1, <NULL>, <NULL>, <NULL>)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, 1, <NULL>, <NULL>, <NULL>)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city');
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, <NULL>)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, <NULL>)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, <NULL>)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, <NULL>)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, country)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, state, country)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL s
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, country)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, One street, city, <NULL>, country)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
78
client/test/expected/80_route_point_to_point_test.out
Normal file
78
client/test/expected/80_route_point_to_point_test.out
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
-- Add to the search path the schema
|
||||||
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
-- Mock the server functions
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'cdb_dataservices_server.cdb_route_point_to_point invoked with params (%, %, %, %, %, %, %)', username, orgname, origin, destination, mode, options, units;
|
||||||
|
SELECT NULL, 5.33, 100 INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_with_waypoints(username text, orgname text, waypoints geometry(Point, 4326)[], mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'cdb_dataservices_server.cdb_route_with_waypoints invoked with params (%, %, %, %, %, %)', username, orgname, waypoints, mode, options, units;
|
||||||
|
SELECT NULL, 2.22, 500 INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
-- Exercise the public and the proxied functions
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
NOTICE: cdb_dataservices_client._cdb_route_point_to_point(7): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_route_point_to_point invoked with params (test_user, <NULL>, 0101000000D53E1D8F19F455C0185B087250F24440, 0101000000465F419AB1F255C0D8B628B341EE4440, car, {}, kilometers)
|
||||||
|
CONTEXT: SQL statement "SELECT * FROM cdb_dataservices_client._cdb_route_point_to_point(username, orgname, origin, destination, mode, options, units)"
|
||||||
|
PL/pgSQL function cdb_route_point_to_point(geometry,geometry,text,text[],text) line 16 at SQL statement
|
||||||
|
cdb_route_point_to_point
|
||||||
|
--------------------------
|
||||||
|
(,5.33,100)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
NOTICE: cdb_dataservices_client._cdb_route_point_to_point(7): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_route_point_to_point invoked with params (test_user, <NULL>, 0101000000D53E1D8F19F455C0185B087250F24440, 0101000000465F419AB1F255C0D8B628B341EE4440, car, {mode_type=shortest}, kilometers)
|
||||||
|
CONTEXT: SQL statement "SELECT * FROM cdb_dataservices_client._cdb_route_point_to_point(username, orgname, origin, destination, mode, options, units)"
|
||||||
|
PL/pgSQL function cdb_route_point_to_point(geometry,geometry,text,text[],text) line 16 at SQL statement
|
||||||
|
cdb_route_point_to_point
|
||||||
|
--------------------------
|
||||||
|
(,5.33,100)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY[]::text[], 'miles');
|
||||||
|
NOTICE: cdb_dataservices_client._cdb_route_point_to_point(7): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_route_point_to_point invoked with params (test_user, <NULL>, 0101000000D53E1D8F19F455C0185B087250F24440, 0101000000465F419AB1F255C0D8B628B341EE4440, car, {}, miles)
|
||||||
|
CONTEXT: SQL statement "SELECT * FROM cdb_dataservices_client._cdb_route_point_to_point(username, orgname, origin, destination, mode, options, units)"
|
||||||
|
PL/pgSQL function cdb_route_point_to_point(geometry,geometry,text,text[],text) line 16 at SQL statement
|
||||||
|
cdb_route_point_to_point
|
||||||
|
--------------------------
|
||||||
|
(,5.33,100)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car');
|
||||||
|
NOTICE: cdb_dataservices_client._cdb_route_with_waypoints(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_route_with_waypoints invoked with params (test_user, <NULL>, {0101000000D53E1D8F19F455C0185B087250F24440:0101000000650113B875F355C05665DF15C1EF4440:0101000000465F419AB1F255C0D8B628B341EE4440}, car, {}, kilometers)
|
||||||
|
CONTEXT: SQL statement "SELECT * FROM cdb_dataservices_client._cdb_route_with_waypoints(username, orgname, waypoints, mode, options, units)"
|
||||||
|
PL/pgSQL function cdb_route_with_waypoints(geometry[],text,text[],text) line 16 at SQL statement
|
||||||
|
cdb_route_with_waypoints
|
||||||
|
--------------------------
|
||||||
|
(,2.22,500)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
NOTICE: cdb_dataservices_client._cdb_route_with_waypoints(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_route_with_waypoints invoked with params (test_user, <NULL>, {0101000000D53E1D8F19F455C0185B087250F24440:0101000000650113B875F355C05665DF15C1EF4440:0101000000465F419AB1F255C0D8B628B341EE4440}, car, {mode_type=shortest}, kilometers)
|
||||||
|
CONTEXT: SQL statement "SELECT * FROM cdb_dataservices_client._cdb_route_with_waypoints(username, orgname, waypoints, mode, options, units)"
|
||||||
|
PL/pgSQL function cdb_route_with_waypoints(geometry[],text,text[],text) line 16 at SQL statement
|
||||||
|
cdb_route_with_waypoints
|
||||||
|
--------------------------
|
||||||
|
(,2.22,500)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY[]::text[], 'miles');
|
||||||
|
NOTICE: cdb_dataservices_client._cdb_route_with_waypoints(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_route_with_waypoints invoked with params (test_user, <NULL>, {0101000000D53E1D8F19F455C0185B087250F24440:0101000000650113B875F355C05665DF15C1EF4440:0101000000465F419AB1F255C0D8B628B341EE4440}, car, {}, miles)
|
||||||
|
CONTEXT: SQL statement "SELECT * FROM cdb_dataservices_client._cdb_route_with_waypoints(username, orgname, waypoints, mode, options, units)"
|
||||||
|
PL/pgSQL function cdb_route_with_waypoints(geometry[],text,text[],text) line 16 at SQL statement
|
||||||
|
cdb_route_with_waypoints
|
||||||
|
--------------------------
|
||||||
|
(,2.22,500)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
339
client/test/expected/90_data_observatory_test.out
Normal file
339
client/test/expected/90_data_observatory_test.out
Normal file
File diff suppressed because one or more lines are too long
65
client/test/expected/95_data_observatory_tables_test.out
Normal file
65
client/test/expected/95_data_observatory_tables_test.out
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
-- Add to the search path the schema
|
||||||
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
CREATE TABLE my_table(cartodb_id int);
|
||||||
|
INSERT INTO my_table (cartodb_id) VALUES (1);
|
||||||
|
-- Mock the server functions
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._DST_ConnectUserTable(username text, orgname text, user_db_role text, input_schema text, dbname text, table_name text)
|
||||||
|
RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN ('dummy_schema'::text, 'dummy_table'::text, 'dummy_server'::text);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._DST_GetReturnMetadata(username text, orgname text, function_name text, params json)
|
||||||
|
RETURNS cdb_dataservices_client.ds_return_metadata AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN (Array['total_pop'], Array['double precision']);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._DST_FetchJoinFdwTableData(username text, orgname text, table_schema text, table_name text, function_name text, params json)
|
||||||
|
RETURNS RECORD AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN (23.4::double precision, 1::int);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._DST_DisconnectUserTable(username text, orgname text, table_schema text, table_name text, servername text)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN true;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
-- Create a sample user table
|
||||||
|
CREATE TABLE user_table (cartodb_id int, the_geom geometry);
|
||||||
|
INSERT INTO user_table(cartodb_id, the_geom) VALUES (1, '0101000020E6100000F74FC902E07D52C05FE24CC7654B4440');
|
||||||
|
INSERT INTO user_table(cartodb_id, the_geom) VALUES (2, '0101000020E6100000F74FC902E07D52C05FE24CC7654B4440');
|
||||||
|
INSERT INTO user_table(cartodb_id, the_geom) VALUES (3, '0101000020E6100000F74FC902E07D52C05FE24CC7654B4440');
|
||||||
|
-- Prepare a table with the total_pop column
|
||||||
|
SELECT cdb_dataservices_client._DST_PrepareTableOBS_GetMeasure('my_table_dst', '{"dummy":"dummy"}'::json);
|
||||||
|
_dst_preparetableobs_getmeasure
|
||||||
|
---------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- The table should now exist and be empty
|
||||||
|
SELECT * FROM my_table_dst;
|
||||||
|
cartodb_id | the_geom | total_pop
|
||||||
|
------------+----------+-----------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
-- Populate the table with measurement data
|
||||||
|
SELECT cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure('user_table', 'my_table_dst', '{"dummy":"dummy"}'::json);
|
||||||
|
_dst_populatetableobs_getmeasure
|
||||||
|
----------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- The table should now show the results
|
||||||
|
SELECT * FROM my_table_dst;
|
||||||
|
cartodb_id | the_geom | total_pop
|
||||||
|
------------+----------------------------------------------------+-----------
|
||||||
|
1 | 0101000020E6100000F74FC902E07D52C05FE24CC7654B4440 | 23.4
|
||||||
|
2 | 0101000020E6100000F74FC902E07D52C05FE24CC7654B4440 |
|
||||||
|
3 | 0101000020E6100000F74FC902E07D52C05FE24CC7654B4440 |
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
-- Clean tables
|
||||||
|
DROP TABLE my_table_dst;
|
||||||
@@ -7,7 +7,7 @@ SET search_path TO public,cartodb,cdb_dataservices_client;
|
|||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (test_user, <NULL>, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (test_user, <NULL>, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin0_polygon(username, orgname, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_admin0_polygon(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_admin0_polygon(text) line 16 at SQL statement
|
||||||
cdb_geocode_admin0_polygon
|
cdb_geocode_admin0_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ PL/pgSQL function cdb_geocode_admin0_polygon(text) line 15 at SQL statement
|
|||||||
SELECT cdb_geocode_admin1_polygon('California');
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California)
|
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name)"
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_admin1_polygon(text) line 16 at SQL statement
|
||||||
cdb_geocode_admin1_polygon
|
cdb_geocode_admin1_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ PL/pgSQL function cdb_geocode_admin1_polygon(text) line 15 at SQL statement
|
|||||||
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California, United States)
|
NOTICE: cdb_dataservices_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (test_user, <NULL>, California, United States)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_admin1_polygon(username, orgname, admin1_name, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_admin1_polygon
|
cdb_geocode_admin1_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 15 at SQL statement
|
|||||||
SELECT cdb_geocode_namedplace_point('Elx');
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx)
|
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name)"
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_namedplace_point(text) line 16 at SQL statement
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ PL/pgSQL function cdb_geocode_namedplace_point(text) line 15 at SQL statement
|
|||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia');
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Valencia)
|
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Valencia)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 15 at SQL stateme
|
|||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Valencia, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (test_user, <NULL>, Elx, Valencia, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_namedplace_point(username, orgname, city_name, admin1_name, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 15 at SQL st
|
|||||||
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (test_user, <NULL>, 03204, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (test_user, <NULL>, 03204, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_postalcode_polygon
|
cdb_geocode_postalcode_polygon
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 15 at SQL state
|
|||||||
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (test_user, <NULL>, 03204, Spain)
|
NOTICE: cdb_dataservices_client._cdb_geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (test_user, <NULL>, 03204, Spain)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name)"
|
||||||
PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 16 at SQL statement
|
||||||
cdb_geocode_postalcode_point
|
cdb_geocode_postalcode_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 15 at SQL stateme
|
|||||||
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_ipaddress_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (test_user, <NULL>, 8.8.8.8)
|
NOTICE: cdb_dataservices_client._cdb_geocode_ipaddress_point(3): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (test_user, <NULL>, 8.8.8.8)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_ipaddress_point(username, orgname, ip_address)"
|
||||||
PL/pgSQL function cdb_geocode_ipaddress_point(text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_ipaddress_point(text) line 16 at SQL statement
|
||||||
cdb_geocode_ipaddress_point
|
cdb_geocode_ipaddress_point
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
@@ -88,12 +88,21 @@ PL/pgSQL function cdb_geocode_ipaddress_point(text) line 15 at SQL statement
|
|||||||
SELECT cdb_geocode_street_point('one street, 1');
|
SELECT cdb_geocode_street_point('one street, 1');
|
||||||
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, one street, 1, <NULL>, <NULL>, <NULL>)
|
NOTICE: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (test_user, <NULL>, one street, 1, <NULL>, <NULL>, <NULL>)
|
||||||
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
CONTEXT: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 15 at SQL statement
|
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
NOTICE: cdb_dataservices_client._cdb_route_point_to_point(7): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.cdb_route_point_to_point invoked with params (test_user, <NULL>, 0101000000D53E1D8F19F455C0185B087250F24440, 0101000000465F419AB1F255C0D8B628B341EE4440, car, {}, kilometers)
|
||||||
|
CONTEXT: SQL statement "SELECT * FROM cdb_dataservices_client._cdb_route_point_to_point(username, orgname, origin, destination, mode, options, units)"
|
||||||
|
PL/pgSQL function cdb_route_point_to_point(geometry,geometry,text,text[],text) line 16 at SQL statement
|
||||||
|
cdb_route_point_to_point
|
||||||
|
--------------------------
|
||||||
|
(,5.33,100)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- Check the regular user has no permissions on private functions
|
-- Check the regular user has no permissions on private functions
|
||||||
SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'Hell');
|
SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'Hell');
|
||||||
ERROR: permission denied for function _cdb_geocode_admin0_polygon
|
ERROR: permission denied for function _cdb_geocode_admin0_polygon
|
||||||
@@ -115,3 +124,5 @@ SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', '8.8.8.8');
|
|||||||
ERROR: permission denied for function _cdb_geocode_ipaddress_point
|
ERROR: permission denied for function _cdb_geocode_ipaddress_point
|
||||||
SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'one street, 1');
|
SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'one street, 1');
|
||||||
ERROR: permission denied for function _cdb_geocode_street_point
|
ERROR: permission denied for function _cdb_geocode_street_point
|
||||||
|
SELECT _cdb_route_point_to_point('evil_user', 'evil_orgname', 'POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
ERROR: permission denied for function _cdb_route_point_to_point
|
||||||
38
client/test/sql/80_route_point_to_point_test.sql
Normal file
38
client/test/sql/80_route_point_to_point_test.sql
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
-- Add to the search path the schema
|
||||||
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- Mock the server functions
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'cdb_dataservices_server.cdb_route_point_to_point invoked with params (%, %, %, %, %, %, %)', username, orgname, origin, destination, mode, options, units;
|
||||||
|
SELECT NULL, 5.33, 100 INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_with_waypoints(username text, orgname text, waypoints geometry(Point, 4326)[], mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
||||||
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
||||||
|
DECLARE
|
||||||
|
ret cdb_dataservices_client.simple_route;
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'cdb_dataservices_server.cdb_route_with_waypoints invoked with params (%, %, %, %, %, %)', username, orgname, waypoints, mode, options, units;
|
||||||
|
SELECT NULL, 2.22, 500 INTO ret;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
|
||||||
|
-- Exercise the public and the proxied functions
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY[]::text[], 'miles');
|
||||||
|
|
||||||
|
SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car');
|
||||||
|
SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY[]::text[], 'miles');
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user