Compare commits
840
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f68f997eb7 | ||
|
|
4d231c1db0 | ||
|
|
a1fdaacb4c | ||
|
|
09e24e13d3 | ||
|
|
1a2d8e865c | ||
|
|
a2790c90d9 | ||
|
|
083b634ea7 | ||
|
|
36f271751b | ||
|
|
2d78caeef2 | ||
|
|
24df64681d | ||
|
|
b7c9ff8dac | ||
|
|
f4df0a5f7c | ||
|
|
1daa5b1451 | ||
|
|
f075a9416b | ||
|
|
201ab42665 | ||
|
|
c793293fae | ||
|
|
40d1b4eafd | ||
|
|
0a902d7f00 | ||
|
|
9b95682243 | ||
|
|
e77038ce2f | ||
|
|
8f720e8165 | ||
|
|
da9948cba3 | ||
|
|
35ff75ea64 | ||
|
|
18459fb906 | ||
|
|
796ba4a15e | ||
|
|
63e5379016 | ||
|
|
ee837e0e5f | ||
|
|
c6e5711905 | ||
|
|
10a62cc3c5 | ||
|
|
021469c825 | ||
|
|
84bdd8a828 | ||
|
|
67fa730436 | ||
|
|
151c768894 | ||
|
|
3560c07d7f | ||
|
|
18816f2bfb | ||
|
|
e99d88500a | ||
|
|
2664095e21 | ||
|
|
5bb0e67499 | ||
|
|
e3e037563b | ||
|
|
944bc8c3ff | ||
|
|
e97d350e5a | ||
|
|
880f756eae | ||
|
|
0164b07b92 | ||
|
|
4a880805cc | ||
|
|
5370ea23c7 | ||
|
|
f1cd40f7e7 | ||
|
|
7aefba181c | ||
|
|
35f098686c | ||
|
|
8a3f28c45b | ||
|
|
53a0e7abf3 | ||
|
|
3c916bdfc9 | ||
|
|
b2a06c6ed6 | ||
|
|
d5b0d86997 | ||
|
|
fa2bed0df5 | ||
|
|
d920d72b0b | ||
|
|
495f2425bc | ||
|
|
6a34f5d6cb | ||
|
|
e08ca8f6bc | ||
|
|
dd907ac2bc | ||
|
|
0268b67d0c | ||
|
|
a90391aeef | ||
|
|
426800df63 | ||
|
|
3ca6133a9e | ||
|
|
f39e3551a0 | ||
|
|
6b50d004bd | ||
|
|
6081613220 | ||
|
|
ef5b82450a | ||
|
|
ab71acd461 | ||
|
|
34e715f460 | ||
|
|
822c574b5c | ||
|
|
484a05dbd9 | ||
|
|
62cbed7f17 | ||
|
|
02d705465c | ||
|
|
e696fa2d39 | ||
|
|
d5efc681e4 | ||
|
|
cd366d7589 | ||
|
|
80c1433bbd | ||
|
|
8f823a5fae | ||
|
|
3eb36f99bb | ||
|
|
8c3b10a061 | ||
|
|
3b5f33503b | ||
|
|
a171d91204 | ||
|
|
efca8e7c9d | ||
|
|
b35e67f65a | ||
|
|
04e81584d1 | ||
|
|
9e57df371a | ||
|
|
b845717077 | ||
|
|
9955b3b8ff | ||
|
|
89dff1244f | ||
|
|
b495fcfef3 | ||
|
|
a2f0ee01a2 | ||
|
|
0c23cc4f4f | ||
|
|
2a68291da7 | ||
|
|
861bef0382 | ||
|
|
9b9f032d30 | ||
|
|
620b02c259 | ||
|
|
9558df2095 | ||
|
|
b5d3c5fd8e | ||
|
|
42c9d21475 | ||
|
|
1e0a8fae06 | ||
|
|
7a08cdf096 | ||
|
|
509e56468b | ||
|
|
d2be601049 | ||
|
|
7335bacc00 | ||
|
|
f0070e6158 | ||
|
|
4684eac410 | ||
|
|
48748b479e | ||
|
|
346db43968 | ||
|
|
0bca39c6a8 | ||
|
|
a30ba351cf | ||
|
|
33b723fa3d | ||
|
|
80ab38a0c9 | ||
|
|
5ab5e8ddf9 | ||
|
|
ced23bbe93 | ||
|
|
8b0ec7b6f5 | ||
|
|
f1bfc70e6e | ||
|
|
9e6da8908c | ||
|
|
6ef7d2cd6e | ||
|
|
304f9fd0d3 | ||
|
|
63dfa51092 | ||
|
|
f07ff35b58 | ||
|
|
1cbbe29e22 | ||
|
|
1ae8eaafd0 | ||
|
|
2a05b86e55 | ||
|
|
dc0b3191f6 | ||
|
|
6a57a85e72 | ||
|
|
08a50c14bb | ||
|
|
ec2fe14ed3 | ||
|
|
305b010225 | ||
|
|
885c7c50fb | ||
|
|
a38c5b275d | ||
|
|
45542b2f28 | ||
|
|
f0a9779a8d | ||
|
|
de1ab5218a | ||
|
|
84f17f946f | ||
|
|
a31b429c7a | ||
|
|
f1e4ff6f33 | ||
|
|
dd1df8695f | ||
|
|
8507067901 | ||
|
|
00f77cca8a | ||
|
|
dfaf0d5245 | ||
|
|
f63d73b9d7 | ||
|
|
29e636f115 | ||
|
|
2ae1547f3c | ||
|
|
f082c918f0 | ||
|
|
246ec135db | ||
|
|
4f5745988f | ||
|
|
f996cb35db | ||
|
|
bbfa03749a | ||
|
|
ab13f3a803 | ||
|
|
ac991a05ab | ||
|
|
0dfd1a9caa | ||
|
|
370272f6c4 | ||
|
|
e2c0a63803 | ||
|
|
84276b4cd3 | ||
|
|
e9856d92f6 | ||
|
|
b608830bce | ||
|
|
a8140e53c3 | ||
|
|
c28ca4861a | ||
|
|
b269c46724 | ||
|
|
6b6fbef586 | ||
|
|
eb4638a326 | ||
|
|
a919b87664 | ||
|
|
98a4ed81c5 | ||
|
|
0ec1e051be | ||
|
|
850497ef79 | ||
|
|
8d2d0ececd | ||
|
|
90fd8587e2 | ||
|
|
64a0616c97 | ||
|
|
b1bdf2460e | ||
|
|
04bbb32849 | ||
|
|
3e6c273b48 | ||
|
|
522591dd63 | ||
|
|
75d0959aff | ||
|
|
b2cdb378fb | ||
|
|
100319ed0e | ||
|
|
5e161b55d2 | ||
|
|
7f4b87f513 | ||
|
|
378458c0ae | ||
|
|
4ae4080bba | ||
|
|
2bb67ba17a | ||
|
|
1027d554a5 | ||
|
|
4e1f081952 | ||
|
|
87bb8bea68 | ||
|
|
dc47f6f71b | ||
|
|
2f6d067b4e | ||
|
|
089d3e3f27 | ||
|
|
765b2f0901 | ||
|
|
36c42096e4 | ||
|
|
909554b453 | ||
|
|
33f40bc945 | ||
|
|
17c993f6ef | ||
|
|
6640909780 | ||
|
|
0bcdaeabc5 | ||
|
|
0e859d8955 | ||
|
|
cd8173c7e0 | ||
|
|
8f362c923e | ||
|
|
56a2ebb210 | ||
|
|
6c1c06f6be | ||
|
|
61a27a9f9d | ||
|
|
ee6f2ab1c2 | ||
|
|
4aa587d32b | ||
|
|
4598d5ed7d | ||
|
|
a57500c966 | ||
|
|
247e9040dd | ||
|
|
4f983ec32f | ||
|
|
88e6245014 | ||
|
|
bafa60303c | ||
|
|
ffa67fe6ca | ||
|
|
3990d13572 | ||
|
|
5989cb1dff | ||
|
|
5307078171 | ||
|
|
ad9619bb00 | ||
|
|
2a6e63b618 | ||
|
|
c5b6c27045 | ||
|
|
b6d37c6773 | ||
|
|
e82fb49028 | ||
|
|
4d3e9f2b32 | ||
|
|
d5864ccada | ||
|
|
0bdba67342 | ||
|
|
08daa6a6a2 | ||
|
|
f4cb9ba812 | ||
|
|
a33dd4315c | ||
|
|
49bcf31832 | ||
|
|
3d42281d2a | ||
|
|
696c24e432 | ||
|
|
f5ad0290b4 | ||
|
|
01f145ab69 | ||
|
|
b4123625f7 | ||
|
|
4b6b4e92e8 | ||
|
|
5ea1a4ca6b | ||
|
|
ca717ed123 | ||
|
|
8a8970efa8 | ||
|
|
603d691017 | ||
|
|
04a5a25d06 | ||
|
|
30e480e545 | ||
|
|
eca4b42a73 | ||
|
|
7a7ccbbfcf | ||
|
|
56c975fef1 | ||
|
|
8fb9524213 | ||
|
|
393da56964 | ||
|
|
17dc3ad1c7 | ||
|
|
1eff219883 | ||
|
|
a09d18a6ee | ||
|
|
d43c9461b1 | ||
|
|
2a2ae481fb | ||
|
|
652242a8f8 | ||
|
|
9a6f52d63b | ||
|
|
48d82e025a | ||
|
|
9398ec0524 | ||
|
|
073c527a62 | ||
|
|
a8e96366a5 | ||
|
|
6cc3cda6e0 | ||
|
|
0e95c5ff90 | ||
|
|
fba933cc88 | ||
|
|
44da876b4c | ||
|
|
288e3a4077 | ||
|
|
821fc04d49 | ||
|
|
a563abb7ab | ||
|
|
9c8647ebd4 | ||
|
|
61aaa0804f | ||
|
|
bd391f4bf4 | ||
|
|
2f4e3d6e05 | ||
|
|
a025034d64 | ||
|
|
d9f647504a | ||
|
|
ed2e87f4ca | ||
|
|
f6791d6ec8 | ||
|
|
c1c671755c | ||
|
|
1f61419467 | ||
|
|
a32e90ea8a | ||
|
|
a6bff9b8d2 | ||
|
|
075f602a7f | ||
|
|
e69849fb86 | ||
|
|
11ec6075c3 | ||
|
|
c6720bf689 | ||
|
|
3524ee1e24 | ||
|
|
80dcde2db0 | ||
|
|
fa3d7db5f8 | ||
|
|
d060ab3d41 | ||
|
|
3a5360c96c | ||
|
|
fc75f1afc8 | ||
|
|
4be3aa88fd | ||
|
|
8162bff204 | ||
|
|
1b31c089ce | ||
|
|
faf9b7237b | ||
|
|
5d2303e1de | ||
|
|
07f5be9207 | ||
|
|
bcb34d1cea | ||
|
|
c5d9db61e6 | ||
|
|
1ff512839d | ||
|
|
9a1b1e2832 | ||
|
|
1cebbe7af0 | ||
|
|
2862c80025 | ||
|
|
abbaf83e97 | ||
|
|
cd5e6510a6 | ||
|
|
fd097724f1 | ||
|
|
96fbf3080a | ||
|
|
0d490bbb19 | ||
|
|
f86558c30b | ||
|
|
0bd2fbf80a | ||
|
|
887fc15915 | ||
|
|
5c09a2eb29 | ||
|
|
b0c1948c14 | ||
|
|
0c5e9da028 | ||
|
|
f534da906c | ||
|
|
5e34faefe5 | ||
|
|
5e8dbaf239 | ||
|
|
b90d402fa9 | ||
|
|
d060bd8229 | ||
|
|
c104f6f34b | ||
|
|
e9ed3bca18 | ||
|
|
e2762a6e03 | ||
|
|
8cb9e123b1 | ||
|
|
e82346e7f6 | ||
|
|
080de34163 | ||
|
|
0a92ae1445 | ||
|
|
0b635377ef | ||
|
|
f2197d4b2a | ||
|
|
6e78da55b2 | ||
|
|
4123a4c442 | ||
|
|
dbb4f9204a | ||
|
|
67fee1cce8 | ||
|
|
b779742585 | ||
|
|
da78b0bc65 | ||
|
|
d46d51c3bb | ||
|
|
0b2ee85c11 | ||
|
|
825e3b7ee8 | ||
|
|
2af9204542 | ||
|
|
34e622b809 | ||
|
|
531ad28158 | ||
|
|
286a75fa8e | ||
|
|
a6c5c21131 | ||
|
|
f6b7c13dde | ||
|
|
1ffe3658fe | ||
|
|
8e430ce1c1 | ||
|
|
8ebd22bc26 | ||
|
|
0ff950d01e | ||
|
|
fed8894c33 | ||
|
|
cce5f92312 | ||
|
|
40ace9cfaa | ||
|
|
f618e4aec3 | ||
|
|
ae84122c3d | ||
|
|
b8475bac30 | ||
|
|
bf8b76b5fe | ||
|
|
31afc82b56 | ||
|
|
5be43e15c0 | ||
|
|
6da70fd8ea | ||
|
|
d00a48f16e | ||
|
|
91012ea62d | ||
|
|
23e3de9da5 | ||
|
|
6c89ca8d70 | ||
|
|
3c07133912 | ||
|
|
5b46c1527e | ||
|
|
89e9bf1ed6 | ||
|
|
ff6cbd1d5b | ||
|
|
8968f0e6ec | ||
|
|
44744de73d | ||
|
|
754c364d22 | ||
|
|
9856adb7ce | ||
|
|
e416a8a641 | ||
|
|
fc610313bf | ||
|
|
18e2349713 | ||
|
|
e884b1d1f4 | ||
|
|
45b8fc4ecf | ||
|
|
379257b4b4 | ||
|
|
8fe9903e7a | ||
|
|
d0b04a97b8 | ||
|
|
a931086e29 | ||
|
|
8f4249ee24 | ||
|
|
71b87834b3 | ||
|
|
9c90c539f8 | ||
|
|
ed828c3b89 | ||
|
|
675ef72e30 | ||
|
|
c13d29e4c2 | ||
|
|
d5e47e39ab | ||
|
|
c2a207b1cd | ||
|
|
e280444479 | ||
|
|
9b64d91998 | ||
|
|
ab7bc424d3 | ||
|
|
91d93bef79 | ||
|
|
bbbf70f3ac | ||
|
|
4d2abc7667 | ||
|
|
58d70e252f | ||
|
|
e85f43f1d1 | ||
|
|
f3f2b213e7 | ||
|
|
34fc6439d2 | ||
|
|
3f08d37ef7 | ||
|
|
be446c1bf2 | ||
|
|
5251534283 | ||
|
|
2687f0c73a | ||
|
|
6b117e26b1 | ||
|
|
9c428dbf31 | ||
|
|
20a610d1d8 | ||
|
|
4b599ecf78 | ||
|
|
3a240bf6ad | ||
|
|
cb7e9d48f4 | ||
|
|
6cc6ee8162 | ||
|
|
920c5a9fc0 | ||
|
|
c682bec387 | ||
|
|
ce79038f46 | ||
|
|
7727fbb1c7 | ||
|
|
214b84f606 | ||
|
|
971695899b | ||
|
|
1a7d0e5a8f | ||
|
|
e4256c1eb1 | ||
|
|
6b38d89153 | ||
|
|
341c240907 | ||
|
|
8be34f0132 | ||
|
|
a56e9f63a3 | ||
|
|
efad90aa62 | ||
|
|
8ceb1e02a5 | ||
|
|
8e49d837b0 | ||
|
|
eb1e3fc5e5 | ||
|
|
02071f1cde | ||
|
|
f368925f8e | ||
|
|
f7349e6a92 | ||
|
|
39af462136 | ||
|
|
073dc3b68b | ||
|
|
9f9bdd7e64 | ||
|
|
292755215c | ||
|
|
6d82896eaa | ||
|
|
89ee3ff8fb | ||
|
|
5f2a0bb7dd | ||
|
|
38a2c3d063 | ||
|
|
6606d26984 | ||
|
|
5a3fcec664 | ||
|
|
af81ba2cf2 | ||
|
|
70232957f8 | ||
|
|
8ab24dc611 | ||
|
|
140094cdde | ||
|
|
7577936c33 | ||
|
|
193513bfea | ||
|
|
c3c28dfd5e | ||
|
|
e5d2182da3 | ||
|
|
33f23e0902 | ||
|
|
94aeceb894 | ||
|
|
e21d3e2e70 | ||
|
|
adde2d3a46 | ||
|
|
6143c04c82 | ||
|
|
3b121c8793 | ||
|
|
e70aefba1d | ||
|
|
423fe42007 | ||
|
|
5e141e3a10 | ||
|
|
50aa537a7a | ||
|
|
e25e2c26a0 | ||
|
|
8025f657b8 | ||
|
|
2a47000f32 | ||
|
|
53e9ad4d2e | ||
|
|
ea5818f08f | ||
|
|
2f8edbe5ce | ||
|
|
552a7d4886 | ||
|
|
a34da0adb5 | ||
|
|
ab5ef64e83 | ||
|
|
f0cef02dfc | ||
|
|
e78063ae75 | ||
|
|
d66804b93d | ||
|
|
6572891036 | ||
|
|
59940ea994 | ||
|
|
b9da6c9ec5 | ||
|
|
ace7683ffe | ||
|
|
6017b53ea0 | ||
|
|
e15c6127d3 | ||
|
|
4bd8726720 | ||
|
|
5d20d0bdf5 | ||
|
|
db5ead6f98 | ||
|
|
44fae489a3 | ||
|
|
71c93fe13a | ||
|
|
d9c569881a | ||
|
|
244d579f6f | ||
|
|
c90859e58b | ||
|
|
12eecc271d | ||
|
|
f216b6d922 | ||
|
|
573a304bd2 | ||
|
|
f5cbc195cc | ||
|
|
e324afd77f | ||
|
|
0196292093 | ||
|
|
f652a52a8d | ||
|
|
1c38b33501 | ||
|
|
59751d7c9c | ||
|
|
ffa1080277 | ||
|
|
b279fafbc5 | ||
|
|
07ed2a4112 | ||
|
|
da7d43cc08 | ||
|
|
39800122b2 | ||
|
|
12ac2c269d | ||
|
|
74c0bb6f26 | ||
|
|
c9d0f0447f | ||
|
|
596189185f | ||
|
|
35f743164e | ||
|
|
4308b5f351 | ||
|
|
9fb04fdc24 | ||
|
|
a2fd0bf142 | ||
|
|
6534b12606 | ||
|
|
8d9c3a4bf7 | ||
|
|
ad46de1156 | ||
|
|
97f1611d62 | ||
|
|
bc4c9fea33 | ||
|
|
177c19f935 | ||
|
|
ef68ad4dcb | ||
|
|
e110ab4cc3 | ||
|
|
e646000f24 | ||
|
|
05e2cc981e | ||
|
|
cbc19b869c | ||
|
|
199788748b | ||
|
|
e3f23adfdd | ||
|
|
39dabffb85 | ||
|
|
03e1d1ca61 | ||
|
|
90d8d207eb | ||
|
|
c14fb057d3 | ||
|
|
9e247685b8 | ||
|
|
1fdb4d3b3a | ||
|
|
029541f298 | ||
|
|
45d9edbba6 | ||
|
|
39c54f3e0c | ||
|
|
54e40645fa | ||
|
|
a86b8e86f9 | ||
|
|
8674dabeb2 | ||
|
|
080a386b8f | ||
|
|
972aba6cfb | ||
|
|
9b43e8a92e | ||
|
|
4e311aef47 | ||
|
|
b65d003742 | ||
|
|
b171951bc7 | ||
|
|
462773a138 | ||
|
|
fad2f25183 | ||
|
|
2f54ef7e4e | ||
|
|
ab4d77edf2 | ||
|
|
0b12f26f47 | ||
|
|
a116aba660 | ||
|
|
29d5a332b6 | ||
|
|
b2825f46a4 | ||
|
|
a791d02dcc | ||
|
|
e2612645c3 | ||
|
|
c5fed2cc80 | ||
|
|
a1f339376e | ||
|
|
019df2b4e0 | ||
|
|
9e67beab3d | ||
|
|
5c7d1e9ac1 | ||
|
|
6e54507b5a | ||
|
|
14925ea448 | ||
|
|
26e0a5e00f | ||
|
|
a99e0cb513 | ||
|
|
1e4fef5868 | ||
|
|
3973483af2 | ||
|
|
88edad9414 | ||
|
|
88ad551e4a | ||
|
|
94eaf84f91 | ||
|
|
0df0b0d49c | ||
|
|
b260c29b8c | ||
|
|
da8aa5a8c0 | ||
|
|
423534068a | ||
|
|
6f508b550d | ||
|
|
1462f87d97 | ||
|
|
6ae8aa45fd | ||
|
|
02cb4862f9 | ||
|
|
07f00cc0ae | ||
|
|
544e0fa763 | ||
|
|
2bbd6bac91 | ||
|
|
2f8dbbb5dc | ||
|
|
3484cce88b | ||
|
|
56c90cc541 | ||
|
|
3583cc6f47 | ||
|
|
850dc09a4f | ||
|
|
876bae6b56 | ||
|
|
8f30359cc7 | ||
|
|
7be27969fa | ||
|
|
502039796f | ||
|
|
e0b1632fa8 | ||
|
|
51bf6c2a43 | ||
|
|
5f9185ee6b | ||
|
|
08e21e3999 | ||
|
|
212cbda9a0 | ||
|
|
05718ce58c | ||
|
|
fed444ff6c | ||
|
|
d1c8f8ced0 | ||
|
|
96d2bf6218 | ||
|
|
b4dc616590 | ||
|
|
4f907053f5 | ||
|
|
1a2785dff4 | ||
|
|
d442fab9da | ||
|
|
236837ebb6 | ||
|
|
6edad7b810 | ||
|
|
7d8cc4ae87 | ||
|
|
41916eed18 | ||
|
|
9921f0f394 | ||
|
|
72b99a1729 | ||
|
|
6c53846e33 | ||
|
|
5781f78c7f | ||
|
|
8127314965 | ||
|
|
9c1ec1ddde | ||
|
|
d1d8713f05 | ||
|
|
0ed477d264 | ||
|
|
42abfd962c | ||
|
|
61e8273a47 | ||
|
|
6339623ad9 | ||
|
|
ae32f91c7c | ||
|
|
a02a634e76 | ||
|
|
7dc87ad38e | ||
|
|
af0125197d | ||
|
|
b10f48166d | ||
|
|
051453898e | ||
|
|
6047300259 | ||
|
|
b282c7db5b | ||
|
|
84749a2631 | ||
|
|
c0cc5fe6a7 | ||
|
|
7d99ede28d | ||
|
|
cd5dba920e | ||
|
|
6d978deb16 | ||
|
|
d3e01b4d53 | ||
|
|
dd6ad0119c | ||
|
|
3bbb3c6bcc | ||
|
|
fa3f2fbc3a | ||
|
|
dc5dbe8c0a | ||
|
|
e7c0628751 | ||
|
|
7775d2373d | ||
|
|
51d97228dc | ||
|
|
cc34a8b19b | ||
|
|
801c5a3cee | ||
|
|
941af522ae | ||
|
|
bb86f080fc | ||
|
|
15340fedad | ||
|
|
c46174210d | ||
|
|
af07def7fc | ||
|
|
bc9dbdbb72 | ||
|
|
dabd596271 | ||
|
|
8c0af7d51d | ||
|
|
b16f7e6ed5 | ||
|
|
1ea5400e40 | ||
|
|
c7bae90e93 | ||
|
|
604e802807 | ||
|
|
27c17ddc8b | ||
|
|
feff20ac5a | ||
|
|
4c996733ce | ||
|
|
046b8f71f9 | ||
|
|
9b8045f2ed | ||
|
|
63786caaa6 | ||
|
|
9d9262c0e7 | ||
|
|
580f6d9867 | ||
|
|
48942cbb03 | ||
|
|
e4a2e13f69 | ||
|
|
048aebedd9 | ||
|
|
1bcfa30938 | ||
|
|
24098a6d2c | ||
|
|
645818838b | ||
|
|
a2929e88cc | ||
|
|
7e7432b4ec | ||
|
|
82db791706 | ||
|
|
d21aa07673 | ||
|
|
dec7842240 | ||
|
|
0cb359a9bc | ||
|
|
5bdf10936e | ||
|
|
bf424a8f1e | ||
|
|
ccf27eaa5c | ||
|
|
d2980aa30c | ||
|
|
bffd6e8200 | ||
|
|
89792b2d0c | ||
|
|
8446c9c388 | ||
|
|
29693ddc81 | ||
|
|
2213900831 | ||
|
|
f645766235 | ||
|
|
657e4064ef | ||
|
|
b5c0e135f9 | ||
|
|
f4d57007c2 | ||
|
|
b44778c586 | ||
|
|
723a3d02ff | ||
|
|
6180b00525 | ||
|
|
5086ee908d | ||
|
|
f751530dd2 | ||
|
|
d42fb3cf8e | ||
|
|
4f5117611f | ||
|
|
ff71a406ae | ||
|
|
98206a3296 | ||
|
|
a69da0084b | ||
|
|
80fc32e1ea | ||
|
|
b8527514b7 | ||
|
|
da8e5f6e36 | ||
|
|
f540a3d6b3 | ||
|
|
e26bf2a803 | ||
|
|
43dd9f6ada | ||
|
|
2cf4072b21 | ||
|
|
d8a20a61b2 | ||
|
|
423431460d | ||
|
|
90e3229e00 | ||
|
|
68e87ca477 | ||
|
|
b56a6bfa45 | ||
|
|
4c7a3a25ec | ||
|
|
e68cc3e820 | ||
|
|
baf9a48dad | ||
|
|
8ecd69d0bf | ||
|
|
1936374124 | ||
|
|
988a0c31dc | ||
|
|
0cd01ee9c9 | ||
|
|
3ed41b065a | ||
|
|
6c3260b6ee | ||
|
|
5005572f89 | ||
|
|
27fde5a910 | ||
|
|
b8e1120169 | ||
|
|
8e33cf9723 | ||
|
|
7b988e3f78 | ||
|
|
f79ac9297d | ||
|
|
854fbb803c | ||
|
|
d029ad7041 | ||
|
|
24c29c0847 | ||
|
|
31e79cb626 | ||
|
|
98eef7ae02 | ||
|
|
445d4cf97d | ||
|
|
3a86ffba71 | ||
|
|
f0a3249b4e | ||
|
|
ef7c5d9218 | ||
|
|
bd63346c50 | ||
|
|
c878384955 | ||
|
|
475df918c7 | ||
|
|
937440c79a | ||
|
|
cb39640179 | ||
|
|
727e5c09a9 | ||
|
|
c13dba71a4 | ||
|
|
55cd62f6dc | ||
|
|
00424a0314 | ||
|
|
2ed183a05c | ||
|
|
9971a0aeed | ||
|
|
e30b081cbc | ||
|
|
797a2dbd24 | ||
|
|
a297504c63 | ||
|
|
5f499c0d1c | ||
|
|
3eee68c56e | ||
|
|
c982c6e4fb | ||
|
|
f5037aab5e | ||
|
|
0e7a777787 | ||
|
|
0cd0087f3f | ||
|
|
13a876b854 | ||
|
|
82b7a95af6 | ||
|
|
928d1111f3 | ||
|
|
e11bc698c3 | ||
|
|
a6c4ee0bdf | ||
|
|
6d802c72be | ||
|
|
1ffbba2a03 | ||
|
|
acd385dc82 | ||
|
|
7281c4a0e3 | ||
|
|
1503b5bb2b | ||
|
|
9fa6d01f8f | ||
|
|
d3a1485a38 | ||
|
|
c5c182fcf0 | ||
|
|
2f35bc5fe5 | ||
|
|
e3aaff4413 | ||
|
|
49a53e4cd7 | ||
|
|
074234b8da | ||
|
|
e123079e92 | ||
|
|
847a7aef99 | ||
|
|
fb4893f27e | ||
|
|
cb5aa3e1af | ||
|
|
7157c0f85c | ||
|
|
9a26c380cd | ||
|
|
71ed0dcc4f | ||
|
|
8ea1ffc425 | ||
|
|
12ffc44efb | ||
|
|
402c14e6ca | ||
|
|
ad6ed9a9bc | ||
|
|
ac854a94af | ||
|
|
61efb66aba | ||
|
|
ddcc7162fb | ||
|
|
37eeab5b9e | ||
|
|
97961a02df | ||
|
|
d7fad6d8d3 | ||
|
|
188767e15a | ||
|
|
59a8cafc74 | ||
|
|
4ef6083344 | ||
|
|
b50637d36f | ||
|
|
c653914694 | ||
|
|
921ef46eb8 | ||
|
|
4c46effc9b | ||
|
|
8bb1943dca | ||
|
|
b4075818be | ||
|
|
a7d322bcd8 | ||
|
|
4c5183e9bd | ||
|
|
a432b9af7d | ||
|
|
b8a69356d4 | ||
|
|
d1b1a6b1e5 | ||
|
|
63dbfa27b5 | ||
|
|
b7ea87cc11 | ||
|
|
6654b69212 | ||
|
|
d95155af71 | ||
|
|
160409c8c0 | ||
|
|
8b031a3016 | ||
|
|
607c8e82c9 | ||
|
|
8917a1c63f | ||
|
|
524d15c1a9 | ||
|
|
c0b0a58d35 | ||
|
|
7ec0a3ab66 | ||
|
|
e55338de90 | ||
|
|
e247fda694 | ||
|
|
2ec38e93f0 | ||
|
|
2197edb467 | ||
|
|
88c43bab2f | ||
|
|
aac89e0236 | ||
|
|
f0b0a9e7f2 | ||
|
|
c74bb85f26 | ||
|
|
77dfda11d9 | ||
|
|
2c15110255 | ||
|
|
6b86acfaa3 | ||
|
|
4b18e1f601 | ||
|
|
970d828768 | ||
|
|
39878ef542 | ||
|
|
2d6b73cb9d | ||
|
|
b1e765c639 | ||
|
|
63eb4e3198 | ||
|
|
164ef42cba | ||
|
|
f2616590ec | ||
|
|
b717674af7 | ||
|
|
c379593d89 | ||
|
|
41c5271de1 | ||
|
|
e850d5c72e | ||
|
|
7101c8d8e8 | ||
|
|
ef09840525 | ||
|
|
cf7460c27d | ||
|
|
63c03894cc | ||
|
|
942c6ac63d | ||
|
|
208469f534 | ||
|
|
73f97128ed | ||
|
|
945c6cd685 | ||
|
|
7f6c19b292 | ||
|
|
87e37e1a26 | ||
|
|
9a04ad06a0 | ||
|
|
cebd7d2141 | ||
|
|
696bdb40b0 | ||
|
|
9d94f99b41 | ||
|
|
680206a437 | ||
|
|
548d6b08db | ||
|
|
77b5ff0b9e | ||
|
|
05b29967c7 | ||
|
|
6c5ca97468 | ||
|
|
a64557b50e | ||
|
|
d8da0a3782 | ||
|
|
01b96fe276 | ||
|
|
4e14e9b0c0 | ||
|
|
26d025a5d1 | ||
|
|
80e7ed90a8 | ||
|
|
250d384d06 | ||
|
|
7e90529a00 | ||
|
|
25ba9866ae | ||
|
|
6a3e17cb9e |
@@ -0,0 +1,56 @@
|
|||||||
|
name: dataservices-api PR testing
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
dataservices-api:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
pg_version: [10, 12]
|
||||||
|
env:
|
||||||
|
PG_VERSION: ${{ matrix.pg_version }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Setup gcloud authentication
|
||||||
|
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
|
||||||
|
with:
|
||||||
|
service_account_key: ${{ secrets.GCS }}
|
||||||
|
|
||||||
|
- name: Pull base image
|
||||||
|
run: gcloud auth configure-docker && docker pull gcr.io/cartodb-on-gcp-ci-testing/cartodb-postgresql-base:${{ matrix.pg_version }}
|
||||||
|
|
||||||
|
- name: Checkout ci tools repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: CartoDB/ci-tools
|
||||||
|
path: ci-tools
|
||||||
|
token: ${{ secrets.CARTOFANTE_PAT }}
|
||||||
|
|
||||||
|
- name: Copy ci files to root
|
||||||
|
run: cp ci-tools/repos/${{ github.event.repository.name }}/* .
|
||||||
|
|
||||||
|
- name: Start docker-compose services
|
||||||
|
run: docker-compose -f docker-compose.yaml up -d
|
||||||
|
|
||||||
|
- name: Install required python3 libs
|
||||||
|
run: docker-compose -f docker-compose.yaml exec -T postgres-server bash -c "cd /dataservices-api/server/ && sudo pip3 install -U -r ./lib/python/cartodb_services/requirements.txt && sudo pip3 install -U ./lib/python/cartodb_services"
|
||||||
|
if: env.PG_VERSION == 12
|
||||||
|
|
||||||
|
- name: Install required python libs
|
||||||
|
run: docker-compose -f docker-compose.yaml exec -T postgres-server bash -c "cd /dataservices-api/server/ && pip install -U -r ./lib/python/cartodb_services/requirements.txt && pip install -U ./lib/python/cartodb_services"
|
||||||
|
|
||||||
|
- name: Run python library tests
|
||||||
|
run: docker-compose -f docker-compose.yaml exec -T postgres-server bash -c "cd /dataservices-api/server/ && MAPBOX_API_KEY=$MAPBOX_API_KEY TOMTOM_API_KEY=$TOMTOM_API_KEY GEOCODIO_API_KEY=$GEOCODIO_API_KEY nosetests lib/python/cartodb_services/test"
|
||||||
|
env:
|
||||||
|
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
|
||||||
|
TOMTOM_API_KEY: ${{ secrets.TOMTOM_API_KEY }}
|
||||||
|
GEOCODIO_API_KEY: ${{ secrets.GEOCODIO_API_KEY }}
|
||||||
|
timeout-minutes: 5
|
||||||
|
|
||||||
|
- name: Run server tests
|
||||||
|
run: docker-compose -f docker-compose.yaml exec -T postgres-server bash -c "cd /dataservices-api/server/extension/ && sudo make clean all install installcheck || (cat /dataservices-api/server/extension/test_out/regression.diffs && false)"
|
||||||
|
timeout-minutes: 5
|
||||||
|
|
||||||
|
- name: Run client tests
|
||||||
|
run: docker-compose -f docker-compose.yaml exec -T postgres-server bash -c "sudo createuser publicuser --no-createrole --no-createdb --no-superuser -U postgres && cd /dataservices-api/client/ && sudo make clean all install installcheck || (cat /home/ubuntu/dataservices-api/client/test_out/regression.diffs && false)"
|
||||||
|
timeout-minutes: 5
|
||||||
@@ -4,3 +4,6 @@
|
|||||||
cartodb_services.egg-info/
|
cartodb_services.egg-info/
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
venv/
|
||||||
|
|||||||
@@ -5,6 +5,23 @@ The issue tracker is at [github.com/CartoDB/dataservices-api](https://github.com
|
|||||||
|
|
||||||
We love pull requests from everyone, see [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/#contributing).
|
We love pull requests from everyone, see [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/#contributing).
|
||||||
|
|
||||||
|
## PostgreSQL
|
||||||
|
When adding or modifying PostgreSQL functions make sure that the
|
||||||
|
[VOLATILITY](https://www.postgresql.org/docs/current/static/xfunc-volatility.html) and [PARALLEL](https://www.postgresql.org/docs/9.6/static/parallel-safety.html) categories are updated accordingly.
|
||||||
|
|
||||||
|
Please mark public [client functions](client/sql) or [templates](client/renderer/templates)
|
||||||
|
as STABLE even if the internals are VOLATILE to allow the planner to cache
|
||||||
|
results inside a query. For example, in this query we need `cdb_geocode_admin1_polygon`
|
||||||
|
to be STABLE so it gets called only once (instead of once per row):
|
||||||
|
```sql
|
||||||
|
SELECT * japank WHERE NOT (the_geom && cdb_geocode_admin1_polygon('Madrid', 'Spain'));
|
||||||
|
```
|
||||||
|
|
||||||
|
As PARALLEL labels need to be stripped for incompatible PostgreSQL versions,
|
||||||
|
please use _PARALLEL SAFE/RESTRICTED/UNSAFE_ in uppercase so it's handled
|
||||||
|
automatically.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Submitting Contributions
|
## Submitting Contributions
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,308 @@
|
|||||||
|
Mar 17th, 2020
|
||||||
|
==============
|
||||||
|
* Version `0.29.0` of the client extension
|
||||||
|
* Adapted client to PG12 (https://github.com/CartoDB/cartodb-platform/issues/6237)
|
||||||
|
* Version `0.38.0` of the server extension
|
||||||
|
* Adapted server to PG12 (https://github.com/CartoDB/cartodb-platform/issues/6237)
|
||||||
|
* Update dependencies to fix vulnerabilities
|
||||||
|
|
||||||
|
Mar 6th, 2020
|
||||||
|
==============
|
||||||
|
* Version `0.23.1` of the Python library
|
||||||
|
* Added query per second throttle to TomTom bulk API calls
|
||||||
|
|
||||||
|
Feb 12th, 2020
|
||||||
|
==============
|
||||||
|
* Version `0.23.0` of the Python library
|
||||||
|
* Added Mapbox true isolines
|
||||||
|
* Version `0.37.0` of the server extension
|
||||||
|
* Added Mapbox true isolines
|
||||||
|
|
||||||
|
Jan 20th, 2020
|
||||||
|
==============
|
||||||
|
* Version `0.22.0` of the Python library
|
||||||
|
* Added geocodio geocoder
|
||||||
|
* Version `0.36.0` of the server extension
|
||||||
|
* Added geocodio geocoder
|
||||||
|
* Version `0.28.0` of the client extension
|
||||||
|
* Added geocodio geocoder
|
||||||
|
|
||||||
|
Oct 9th, 2019
|
||||||
|
==============
|
||||||
|
* Version `0.27.0` of the client extension
|
||||||
|
* Changes in search_path
|
||||||
|
|
||||||
|
Mar 13rd, 2019
|
||||||
|
==============
|
||||||
|
* Version `0.21.4` of the python library
|
||||||
|
* Fix TomTom bulk geocoder bug (#551)
|
||||||
|
|
||||||
|
Mar 5th, 2019
|
||||||
|
==============
|
||||||
|
* Version `0.21.3` of the python library
|
||||||
|
* Fixed TomTom Qps respondes part 2 (#546)
|
||||||
|
|
||||||
|
Mar 4th, 2019
|
||||||
|
==============
|
||||||
|
* Version `0.21.2` of the python library
|
||||||
|
* Fixed TomTom Qps responses (#546)
|
||||||
|
|
||||||
|
Feb 25th, 2019
|
||||||
|
==============
|
||||||
|
* Version `0.26.2` of the client extension
|
||||||
|
* Fixed bulk geocoding soft limit (#543)
|
||||||
|
|
||||||
|
Dec 31st, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.35.1` of the server extension and `0.26.1` of the client
|
||||||
|
* Now the bulk geocoder returns `Point` geometries instead of MultiPolygons (#538)
|
||||||
|
|
||||||
|
Nov 30th, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.35.0` of the server extension
|
||||||
|
* Now the `mode_type` is working the providers that support it (#536)
|
||||||
|
|
||||||
|
Nov 27th, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.34.2` of the server extension
|
||||||
|
* Fixed bulk geocoding log metrics in order to fix problems in ELK due to the JSON not being standard (#530)
|
||||||
|
|
||||||
|
Nov 22th, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.34.1` of the server extension
|
||||||
|
* Fixed isochrones metrics that increase `success_rows` field for every isochrone generated (#533)
|
||||||
|
|
||||||
|
Oct 31th, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.20.2` of the python library
|
||||||
|
* Added missing provider property to the QPS decorator in other TomTom services
|
||||||
|
* Now we only retry with the properly header coming from TomTom
|
||||||
|
|
||||||
|
Oct 3rd, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.20.1` of the python library
|
||||||
|
* Fix QPS manager to retry with 403 status codes coming from TomTom
|
||||||
|
|
||||||
|
Sep 13th, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.34.0` of the server, and `0.26.0` of the client.
|
||||||
|
* Use dataservices with non-master keys
|
||||||
|
|
||||||
|
Aug 27th, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.33.0` of the server, and `0.20.0` of the Python library.
|
||||||
|
* Remove the obs_snapshot quota and now the snapshot functions uses obs_general quota
|
||||||
|
|
||||||
|
Jul 19th, 2018
|
||||||
|
==============
|
||||||
|
* Version `0.25.0` of the client, `0.32.0` of the server, and `0.19.1` of the Python library.
|
||||||
|
* Support for batch street-level geocoding.
|
||||||
|
|
||||||
|
May 7th, 2018
|
||||||
|
=============
|
||||||
|
* Version `0.24.0` of the client, `0.31.0` of the server, and `0.18.0` of the python library.
|
||||||
|
* Support for TomTom routing, geocoding and isolines.
|
||||||
|
|
||||||
|
March 28th, 2018
|
||||||
|
================
|
||||||
|
* Version `0.30.5` of server side and `0.17.6` of the python library
|
||||||
|
* All the returned polygons are now always MULTIPOLYGON #488
|
||||||
|
|
||||||
|
March 27th, 2018
|
||||||
|
================
|
||||||
|
* Version `0.17.5` of python library
|
||||||
|
* Avoid reaching provider for empty geocodings (but still incrementing empty service use) #476
|
||||||
|
|
||||||
|
March 16th, 2018
|
||||||
|
================
|
||||||
|
* Version `0.30.3` of server side
|
||||||
|
* Fix problem with invalid Mapbox isolines #483
|
||||||
|
* Version `0.30.4` of server side
|
||||||
|
* Added ST_CollectionExtract to ST_MakeValid for Mapbox isolines to avoid non-polygonal geometries #486
|
||||||
|
|
||||||
|
March 14th, 2018
|
||||||
|
================
|
||||||
|
* Version `0.17.4` of the python library
|
||||||
|
* Fix bug with previous version when checking quotas #480
|
||||||
|
* Version `0.17.3` of the python library
|
||||||
|
* Fix bug with Mapbox routing not using the proper quota value #477
|
||||||
|
|
||||||
|
February 22th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.17.2` of the python library
|
||||||
|
* Fix bug with Mapbox isolines not stopping at the seacoast #471
|
||||||
|
|
||||||
|
February 27th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.17.1` of the python library
|
||||||
|
* Fix bug when the mapzen credentials are not in the db config and we keep getting them
|
||||||
|
|
||||||
|
February 22th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.17.0` of the python library
|
||||||
|
* Change default provider to Mapbox
|
||||||
|
* Remove the obligatory nature of the Mapzen configuration due to its deprecation as provider
|
||||||
|
|
||||||
|
February 13th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.16.7` of the python library
|
||||||
|
* Pick the first result when Mapbox geocoder returns multiple results #462
|
||||||
|
* Normalize input for Mapbox geocoder #462
|
||||||
|
|
||||||
|
February 12th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.16.6` of the python library
|
||||||
|
* Using Mapbox permanent geocoder #455
|
||||||
|
|
||||||
|
February 5th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.16.5` of the python library
|
||||||
|
* Fix displaced routing shape #443
|
||||||
|
* Check for empty coordinates object before converting it to polygon
|
||||||
|
* 422 errors that come from Mapbox now returns an empty result because is a bad input from the user data
|
||||||
|
|
||||||
|
February 2th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.16.4` of the python library
|
||||||
|
* Create a QuotaExceededException instead of using a generic one
|
||||||
|
* Version `0.30.2` of server side
|
||||||
|
* Return empty value when the quota is exceeded and don't send the exception to external loggers
|
||||||
|
to avoid noise
|
||||||
|
|
||||||
|
January 31th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.16.3` of the python library
|
||||||
|
* Fix for Mapbox geocoder to handle empty requests and empty responses
|
||||||
|
* Remove raising an exception when non parameters are passed to the HERE geocoder
|
||||||
|
* Fix for HERE geocoder with non empty requests
|
||||||
|
* Added more coverage to the google geocoder credentials parse logic
|
||||||
|
|
||||||
|
January 29th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.30.1` of server side
|
||||||
|
* Fix for Mapbox geocoding function due to the iso3166 library doesn't support UTF-8 names for the countries
|
||||||
|
* Version `0.16.2` of the python library
|
||||||
|
* Fix for Mapbox cycling profile
|
||||||
|
|
||||||
|
January 18th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.16.1` of the python library
|
||||||
|
* Fixed encoding problem with Mapbox geocoding (using the Mapbox Python library)
|
||||||
|
|
||||||
|
January 17th, 2018
|
||||||
|
==================
|
||||||
|
* Version `0.16.0` of the python library
|
||||||
|
* Added Mapbox provider for routing, geocoding and isolines
|
||||||
|
* Version `0.30.0` of the server extension
|
||||||
|
* Added Mapbox provider for routing, geocoding and isolines
|
||||||
|
* Fixed a bug that makes impossible to install server side if the client is already installed due a namespace problem
|
||||||
|
* Version `0.23.0` of the client
|
||||||
|
* Added Mapbox provider for routing, geocoding and isolines
|
||||||
|
|
||||||
|
December 1st, 2017
|
||||||
|
==================
|
||||||
|
* Version `0.29.0` of the server extension
|
||||||
|
* Functions qualified with PARALLEL and volatility
|
||||||
|
* Version `0.22.0` of the client
|
||||||
|
* Functions qualified with PARALLEL and volatility
|
||||||
|
* Fixed an issue with upgrades from older versions. See #417
|
||||||
|
|
||||||
|
November 17th, 2017
|
||||||
|
=================
|
||||||
|
* Version `0.15.6` of the python library
|
||||||
|
* Added support for channels for google geocoder #409
|
||||||
|
* Improved the way we manage the client_id #409
|
||||||
|
|
||||||
|
October 18th, 2017
|
||||||
|
=================
|
||||||
|
* Version `0.21.0` of the client extension
|
||||||
|
* Added new parameter `number_geometries` to the `obs_getavailablegeometries` to improve the score calculation
|
||||||
|
* Version `0.28.0` of the server extension
|
||||||
|
* Added new parameter `number_geometries` to the `obs_getavailablegeometries` to improve the score calculation
|
||||||
|
|
||||||
|
October 6th, 2017
|
||||||
|
=================
|
||||||
|
* Version `0.15.5` of the python library
|
||||||
|
* googlemaps dependency updated to v2.5.1
|
||||||
|
* Google geocoder performance boost: client connections are now reused between queries. See #401
|
||||||
|
* Fixed issue with Google keys validity check. See #382
|
||||||
|
* Fixed inconsistency in service usage failed requests tracking. See f0a3249
|
||||||
|
* Client extension tests are now compatible with PostgreSQL 9.5 and 9.6
|
||||||
|
|
||||||
|
August 30th, 2017
|
||||||
|
=============
|
||||||
|
* Version `0.15.4` of the python library
|
||||||
|
* Fixed invalid geometries for isochrones due to `generalize` option. See #397
|
||||||
|
|
||||||
|
August 24th, 2017
|
||||||
|
=============
|
||||||
|
* Improved the documentation
|
||||||
|
* Version `0.15.3` of the python library
|
||||||
|
* Disabled DO quota check for users that have it configured . See #395
|
||||||
|
|
||||||
|
August 23th, 2017
|
||||||
|
=============
|
||||||
|
* Version `0.27.0` of the server
|
||||||
|
* New public DO function to perform metadata validation, `obs_metadatavalidation`. See #392
|
||||||
|
* Version `0.20.0` of the client
|
||||||
|
* New private function to precheck the DO requests, `_obs_precheck`. See #392
|
||||||
|
* New public DO function to perform metadata validation, `obs_metadatavalidation`. See #392
|
||||||
|
|
||||||
|
July 20th, 2017
|
||||||
|
=============
|
||||||
|
* Version `0.26.0` of the server
|
||||||
|
* New private function to be used by the UI, `_obs_getnumerators`. See #386
|
||||||
|
* Version `0.19.0` of the client
|
||||||
|
* New private function to be used by the UI, `_obs_getnumerators`. See #386
|
||||||
|
|
||||||
|
July 13th, 2017
|
||||||
|
=============
|
||||||
|
* Version `0.25.0` of the server
|
||||||
|
* Add postalcode numeric type function. See #387
|
||||||
|
|
||||||
|
* Version `0.15.2` of the python library
|
||||||
|
* Fixed some test. See #387
|
||||||
|
|
||||||
|
* Version `0.18.0` of the client and version `0.25.0` of the server
|
||||||
|
* Add postalcode numeric type function. See #387
|
||||||
|
|
||||||
|
June 28th, 2017
|
||||||
|
=============
|
||||||
|
* Not version specific, content change only
|
||||||
|
* Removed link to /docs/faqs and enhanced ZCTA note directly in the Postal Coder docs.
|
||||||
|
|
||||||
|
May 26th, 2017
|
||||||
|
=============
|
||||||
|
* Version `0.24.2` of the server
|
||||||
|
* Fixed fallback logic for namedplaces geocoding functions
|
||||||
|
|
||||||
|
* Version `0.15.1` of the python library
|
||||||
|
* Fixed some typos and improve exception messages
|
||||||
|
* Added a check for the google client credentials in order to improve the error message
|
||||||
|
|
||||||
|
May 16th, 2017
|
||||||
|
=============
|
||||||
|
* Version `0.24.1` of the server
|
||||||
|
* Fixed an interface mismatch between DS API and OBS backend, when returning no data. See #366
|
||||||
|
|
||||||
|
May 9th, 2017
|
||||||
|
=============
|
||||||
|
* Version `0.17.0` of the client and version `0.24.0` of the server
|
||||||
|
* Fixed some missing return values documented but not present.
|
||||||
|
* `OBS_GetAvailableGeometries` now returns `geom_type`, `geom_extra` and `geom_tags` in addition to existing values.
|
||||||
|
* `OBS_GetAvailableTimespans` now returns `timespan_type`, `timespan_extra`, `timespan_tags` in addition to existing values.
|
||||||
|
|
||||||
|
March 28th, 2017
|
||||||
|
================
|
||||||
|
|
||||||
|
* Version 0.16.0 of the client, version 0.23.0 of the server and version 0.15.0 of the python library
|
||||||
|
* Added support for rate-limiting the geocoding services. See #365
|
||||||
|
|
||||||
|
March 13th, 2017
|
||||||
|
================
|
||||||
|
* Version `0.14.1` of the python library:
|
||||||
|
* Clean up code that reads from non zero padded date keys #206
|
||||||
|
|
||||||
March 8th, 2017
|
March 8th, 2017
|
||||||
===============
|
===============
|
||||||
* Version 0.22.0 of the server and version 0.14.0 of the python library
|
* Version 0.22.0 of the server and version 0.14.0 of the python library
|
||||||
@@ -136,7 +441,7 @@ July 25, 2016
|
|||||||
===========
|
===========
|
||||||
* Release server 0.13.3
|
* Release server 0.13.3
|
||||||
* Add provider per service
|
* Add provider per service
|
||||||
* Default provider in case the provider is not setted
|
* Default provider in case the provider is not set
|
||||||
* Refactor and improvements in the multiprovider services functions
|
* Refactor and improvements in the multiprovider services functions
|
||||||
|
|
||||||
https://github.com/CartoDB/dataservices-api/releases/tag/0.13.3-server
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.13.3-server
|
||||||
@@ -452,7 +757,7 @@ https://github.com/CartoDB/dataservices-api/releases/tag/0.3.0-server
|
|||||||
Feb 4, 2016:
|
Feb 4, 2016:
|
||||||
===========
|
===========
|
||||||
* Release server 0.2.0
|
* Release server 0.2.0
|
||||||
* Logic for the google geocoder so the users with this geocoder setted up can use street level geocoding too
|
* Logic for the google geocoder so the users with this geocoder set 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
|
* 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
|
https://github.com/CartoDB/dataservices-api/releases/tag/0.2.0-server
|
||||||
|
|||||||
@@ -23,52 +23,91 @@ Steps to deploy a new Data Services API version :
|
|||||||
|
|
||||||
### Local install instructions
|
### Local install instructions
|
||||||
|
|
||||||
- install data services geocoder extension
|
|
||||||
|
|
||||||
```
|
|
||||||
git clone https://github.com/CartoDB/data-services.git
|
|
||||||
cd data-services/geocoder/extension
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
||||||
- install observatory extension
|
|
||||||
|
|
||||||
```
|
|
||||||
git clone https://github.com/CartoDB/observatory-extension.git
|
|
||||||
cd observatory
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
||||||
- install server and client extensions
|
- install server and client extensions
|
||||||
|
|
||||||
```
|
```
|
||||||
# in data-services repo root path:
|
# in your workspace root path
|
||||||
|
git clone https://github.com/CartoDB/dataservices-api.git
|
||||||
|
cd dataservices-api
|
||||||
cd client && sudo make install
|
cd client && sudo make install
|
||||||
|
cd -
|
||||||
cd server/extension && sudo make install
|
cd server/extension && sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
- install python library
|
- install python library
|
||||||
|
|
||||||
```
|
```
|
||||||
# in data-services repo root path:
|
# in dataservices-api repo root path:
|
||||||
cd server/lib/python/cartodb_services && sudo pip install . --upgrade
|
cd server/lib/python/cartodb_services && sudo pip install -r requirements.txt && sudo pip install . --upgrade
|
||||||
```
|
```
|
||||||
|
**CLOUD DEPLOY NOTE**: we were not installing automatically `requirements.txt`, so we fixed it in https://github.com/CartoDB/cartodb-platform/pull/6187 . Please, be aware that in some corner cases scenarios, rolling back to a previous version might require to manually force-install some dependency versions that were upgraded previously in this step.
|
||||||
|
|
||||||
- install extensions in user database
|
- Create a database to hold all the server part and a user for it
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE DATABASE dataservices_db ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
|
||||||
|
CREATE USER geocoder_api;
|
||||||
|
```
|
||||||
|
|
||||||
|
- Install needed extensions in `dataservices_db` database
|
||||||
|
|
||||||
```
|
```
|
||||||
create extension cdb_geocoder;
|
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS plproxy; COMMIT" -e
|
||||||
create extension plproxy;
|
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS cdb_dataservices_server; COMMIT" -e
|
||||||
create extension observatory;
|
|
||||||
create extension cdb_dataservices_server;
|
|
||||||
create extension cdb_dataservices_client;
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- [optional] install internal geocoder
|
||||||
|
- Make the extension available in postgres
|
||||||
|
```
|
||||||
|
git clone https://github.com/CartoDB/data-services.git
|
||||||
|
cd data-services/geocoder/extension
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- Make sure you have `wget` installed because is needed for the next step.
|
||||||
|
|
||||||
|
- Go to `geocoder` folder and execute the `geocoder_dowload_dumps` script to download the internal geocoder data.
|
||||||
|
|
||||||
|
- Once the data is downloaded, execute this command:
|
||||||
|
```bash
|
||||||
|
geocoder_restore_dump postgres dataservices_db {DOWNLOADED_DUMPS_FOLDER}/*.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
- Now we have to make available the extension to be installed by postgres. Follow [this](https://github.com/CartoDB/data-services/tree/master/geocoder/extension) instructions.
|
||||||
|
|
||||||
|
- Now install the extension with:
|
||||||
|
```
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS cdb_geocoder; COMMIT" -e
|
||||||
|
```
|
||||||
|
|
||||||
|
- [optional] install data observatory extension
|
||||||
|
- Make the extension available in postgresql to be installed
|
||||||
|
```
|
||||||
|
git clone https://github.com/CartoDB/observatory-extension.git
|
||||||
|
cd observatory
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
- This extension needs data, dumps are not available so we're going to use the test fixtures to make it work. Execute:
|
||||||
|
```
|
||||||
|
psql -U postgres -d dataservices_db -f src/pg/test/fixtures/load_fixtures.sql
|
||||||
|
```
|
||||||
|
- Give permission to execute and select to the `geocoder_api` user:
|
||||||
|
```
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS observatory VERSION 'dev'; COMMIT" -e
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;GRANT SELECT ON ALL TABLES IN SCHEMA cdb_observatory TO geocoder_api; COMMIT" -e
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_observatory TO geocoder_api; COMMIT" -e
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;GRANT USAGE ON SCHEMA cdb_observatory TO geocoder_api; COMMIT" -e
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;GRANT SELECT ON ALL TABLES IN SCHEMA observatory TO geocoder_api; COMMIT" -e
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA observatory TO geocoder_api; COMMIT" -e
|
||||||
|
psql -U postgres -d dataservices_db -c "BEGIN;GRANT USAGE ON SCHEMA observatory TO geocoder_api; COMMIT" -e
|
||||||
|
```
|
||||||
|
|
||||||
### Server configuration
|
### Server configuration
|
||||||
|
|
||||||
Configuration for the different services must be stored in the server database using `CDB_Conf_SetConf()`.
|
Configuration for the different services must be stored in the server database using `CDB_Conf_SetConf()`.
|
||||||
|
|
||||||
|
**All the configuration inside brackets [] is optional**
|
||||||
|
|
||||||
#### Redis configuration
|
#### Redis configuration
|
||||||
|
|
||||||
If sentinel is used:
|
If sentinel is used:
|
||||||
@@ -124,6 +163,33 @@ SELECT CDB_Conf_SetConf(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Mapbox configuration
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT CDB_Conf_SetConf(
|
||||||
|
'mapbox_conf',
|
||||||
|
'{"routing": {"api_keys": ["your_api_key"], "monthly_quota": 999999}, "geocoder": {"api_keys": ["your_api_key"], "monthly_quota": 999999}, "matrix": {"api_keys": ["your_api_key"], "monthly_quota": 1500000}}'
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### TomTom configuration
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT CDB_Conf_SetConf(
|
||||||
|
'tomtom_conf',
|
||||||
|
'{"routing": {"api_keys": ["your_api_key"], "monthly_quota": 999999}, "geocoder": {"api_keys": ["your_api_key"], "monthly_quota": 999999}, "isolines": {"api_keys": ["your_api_key"], "monthly_quota": 1500000}}'
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Geocod.io configuration
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT CDB_Conf_SetConf(
|
||||||
|
'geocodio_conf',
|
||||||
|
'{"geocoder": {"api_keys": ["your_api_key"], "monthly_quota": 999999}}'
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
#### Data Observatory
|
#### Data Observatory
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
@@ -138,10 +204,12 @@ SELECT CDB_Conf_SetConf(
|
|||||||
```sql
|
```sql
|
||||||
SELECT CDB_Conf_SetConf(
|
SELECT CDB_Conf_SetConf(
|
||||||
'logger_conf',
|
'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"]}'
|
'{"geocoder_log_path": "/tmp/geocodings.log", "min_log_level": "LOG_LEVEL", "rollbar_api_key": "SERVER_SIDE_API_KEY", "log_file_path": "LOG_FILE_PATH"}'
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Where `LOG_LEVEL` can be `debug`, `info`, `warning` or `error`.
|
||||||
|
|
||||||
#### Environment
|
#### Environment
|
||||||
|
|
||||||
The execution environment (development/staging/production) affects rollbar messages and other details.
|
The execution environment (development/staging/production) affects rollbar messages and other details.
|
||||||
@@ -220,14 +288,16 @@ jsonb_set(
|
|||||||
```
|
```
|
||||||
### User database configuration
|
### User database configuration
|
||||||
|
|
||||||
|
#### Option 1 (manually)
|
||||||
|
|
||||||
User (client) databases need also some configuration so that the client extension can access the server:
|
User (client) databases need also some configuration so that the client extension can access the server:
|
||||||
#### Users/Organizations
|
##### Users/Organizations
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}');
|
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}');
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Dataservices server
|
##### Dataservices server
|
||||||
|
|
||||||
The `geocoder_server_config` (the name is not accurate for historical reasons) entry points
|
The `geocoder_server_config` (the name is not accurate for historical reasons) entry points
|
||||||
to the dataservices server DB (you can use a specific database for the server or your same user's):
|
to the dataservices server DB (you can use a specific database for the server or your same user's):
|
||||||
@@ -238,10 +308,17 @@ SELECT CDB_Conf_SetConf(
|
|||||||
'{ "connection_str": "host=localhost port=5432 dbname=<SERVER_DB_NAME> user=postgres"}'
|
'{ "connection_str": "host=localhost port=5432 dbname=<SERVER_DB_NAME> user=postgres"}'
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
#### Search path
|
##### Search path
|
||||||
|
|
||||||
The search path must be configured in order to be able to execute the functions without using the schema:
|
The search path must be configured in order to be able to execute the functions without using the schema:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
ALTER ROLE "<USER_ROLE>" SET search_path="$user", public, cartodb, cdb_dataservices_client;
|
ALTER ROLE "<USER_ROLE>" SET search_path="$user", public, cartodb, cdb_dataservices_client;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Option 2 (from builder)
|
||||||
|
|
||||||
|
See [the **Configuring Dataservices** documentation](http://cartodb.readthedocs.io/en/latest/operations/configure_data_services.html)
|
||||||
|
|
||||||
|
### Rate limits
|
||||||
|
See [docs](https://github.com/CartoDB/dataservices-api/blob/master/doc/rate_limits.md)
|
||||||
|
|||||||
+97
-4
@@ -8,6 +8,19 @@ SED = sed
|
|||||||
ERB = erb
|
ERB = erb
|
||||||
REPLACEMENTS = -i 's/$(EXTVERSION)/$(NEW_VERSION)/g'
|
REPLACEMENTS = -i 's/$(EXTVERSION)/$(NEW_VERSION)/g'
|
||||||
NEW_EXTENSION_ARTIFACT = $(EXTENSION)--$(EXTVERSION).sql
|
NEW_EXTENSION_ARTIFACT = $(EXTENSION)--$(EXTVERSION).sql
|
||||||
|
AWK = awk
|
||||||
|
|
||||||
|
# Parallel support macros
|
||||||
|
PG_CONFIG = pg_config
|
||||||
|
PG_PARALLEL := $(shell $(PG_CONFIG) --version | ($(AWK) '{$$2*=1000; if ($$2 >= 9600) print 1; else print 0;}' 2> /dev/null || echo 0))
|
||||||
|
|
||||||
|
# PG12 compatibility
|
||||||
|
PG_VERSION := $(shell $(PG_CONFIG) --version | $(AWK) '{split($$2,a,"."); print a[1]}')
|
||||||
|
PG_12_GE := $(shell [ $(PG_VERSION) -ge 12 ] && echo true)
|
||||||
|
PLPYTHONU := plpythonu
|
||||||
|
ifeq ($(PG_12_GE), true)
|
||||||
|
PLPYTHONU := plpython3u
|
||||||
|
endif
|
||||||
|
|
||||||
# OLD_VERSIONS = $(wildcard old_versions/*.sql)
|
# OLD_VERSIONS = $(wildcard old_versions/*.sql)
|
||||||
# DATA = $(NEW_EXTENSION_ARTIFACT) \
|
# DATA = $(NEW_EXTENSION_ARTIFACT) \
|
||||||
@@ -20,9 +33,9 @@ DATA = $(NEW_EXTENSION_ARTIFACT) \
|
|||||||
$(OLD_VERSIONS)
|
$(OLD_VERSIONS)
|
||||||
SOURCES_DATA_DIR = sql/
|
SOURCES_DATA_DIR = sql/
|
||||||
|
|
||||||
|
REGRESS = $(notdir $(basename $(sort $(wildcard test/sql/*test.sql))))
|
||||||
REGRESS = $(notdir $(basename $(wildcard test/sql/*test.sql)))
|
REGRESS_EXPEC = $(notdir $(basename $(sort $(wildcard test/expected/*test.out))))
|
||||||
TEST_DIR = test/
|
TEST_DIR = test
|
||||||
REGRESS_OPTS = --inputdir='$(TEST_DIR)' --outputdir='$(TEST_DIR)' --user='postgres'
|
REGRESS_OPTS = --inputdir='$(TEST_DIR)' --outputdir='$(TEST_DIR)' --user='postgres'
|
||||||
|
|
||||||
# DATA is a special variable used by postgres build infrastructure
|
# DATA is a special variable used by postgres build infrastructure
|
||||||
@@ -49,7 +62,15 @@ SOURCES_DATA = $(wildcard $(SOURCES_DATA_DIR)/*.sql) $(GENERATED_SQL_FILES)
|
|||||||
|
|
||||||
$(NEW_EXTENSION_ARTIFACT): $(SOURCES_DATA)
|
$(NEW_EXTENSION_ARTIFACT): $(SOURCES_DATA)
|
||||||
rm -f $@
|
rm -f $@
|
||||||
cat $(SOURCES_DATA_DIR)/*.sql >> $@
|
cat $(SOURCES_DATA_DIR)/*.sql | \
|
||||||
|
$(SED) -e 's/@@plpythonu@@/$(PLPYTHONU)/g' >> $@
|
||||||
|
ifeq ($(PG_PARALLEL), 0)
|
||||||
|
# Remove PARALLEL in aggregates and functions
|
||||||
|
$(eval TMPFILE := $(shell mktemp /tmp/$(basename $0).XXXXXXXX))
|
||||||
|
$(SED) -e 's/PARALLEL \= [A-Z]*,/''/g' \
|
||||||
|
-e 's/PARALLEL [A-Z]*/''/g' $@ > $(TMPFILE)
|
||||||
|
mv $(TMPFILE) $@
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(DATA)
|
all: $(DATA)
|
||||||
@@ -64,9 +85,81 @@ release: $(EXTENSION).control $(SOURCES_DATA)
|
|||||||
git add $(EXTENSION)--$(NEW_VERSION).sql
|
git add $(EXTENSION)--$(NEW_VERSION).sql
|
||||||
$(ERB) version=$(NEW_VERSION) upgrade_downgrade_template.erb > $(EXTENSION)--$(EXTVERSION)--$(NEW_VERSION).sql
|
$(ERB) version=$(NEW_VERSION) upgrade_downgrade_template.erb > $(EXTENSION)--$(EXTVERSION)--$(NEW_VERSION).sql
|
||||||
$(ERB) version=$(EXTVERSION) upgrade_downgrade_template.erb > $(EXTENSION)--$(NEW_VERSION)--$(EXTVERSION).sql
|
$(ERB) version=$(EXTVERSION) upgrade_downgrade_template.erb > $(EXTENSION)--$(NEW_VERSION)--$(EXTVERSION).sql
|
||||||
|
@echo
|
||||||
|
@echo "Please review the file $(EXTENSION)--$(EXTVERSION)--$(NEW_VERSION).sql and add any code needed to upgrade $(EXTVERSION) to $(NEW_VERSION)"
|
||||||
|
@echo "Please review the file $(EXTENSION)--$(NEW_VERSION)--$(EXTVERSION).sql and add any code needed to downgrade $(NEW_VERSION) to $(EXTVERSION)"
|
||||||
|
@echo
|
||||||
|
|
||||||
# Only meant for development time, do not use once a version is released
|
# Only meant for development time, do not use once a version is released
|
||||||
.PHONY: devclean
|
.PHONY: devclean
|
||||||
devclean:
|
devclean:
|
||||||
rm -f $(NEW_EXTENSION_ARTIFACT)
|
rm -f $(NEW_EXTENSION_ARTIFACT)
|
||||||
rm -f $(GENERATED_SQL_FILES)
|
rm -f $(GENERATED_SQL_FILES)
|
||||||
|
|
||||||
|
clean: restore_copies
|
||||||
|
|
||||||
|
# If needed remove PARALLEL tags from the release files
|
||||||
|
release_remove_parallel_deploy:
|
||||||
|
ifeq ($(PG_PARALLEL), 0)
|
||||||
|
for n in $(wildcard old_versions/*.sql *.sql); do \
|
||||||
|
$(eval TMPFILE := $(shell mktemp /tmp/XXXXXXXXXX)) \
|
||||||
|
$(SED) -e 's/PARALLEL \= [A-Z]*,/''/g' -e 's/PARALLEL [A-Z]*/''/g' $$n > $(TMPFILE); \
|
||||||
|
mv $(TMPFILE) $$n; \
|
||||||
|
done
|
||||||
|
endif
|
||||||
|
|
||||||
|
restore_copies:
|
||||||
|
# tests
|
||||||
|
for f in $(basename $(wildcard test/sql/*.copy)); do \
|
||||||
|
cat $${f}.copy > $${f}; \
|
||||||
|
done
|
||||||
|
for f in $(basename $(wildcard test/expected/*.copy)); do \
|
||||||
|
cat $${f}.copy > $${f}; \
|
||||||
|
done
|
||||||
|
rm -f test/sql/*.copy;
|
||||||
|
rm -f test/expected/*.copy;
|
||||||
|
# data
|
||||||
|
for f in $(basename $(wildcard sql/*.copy)); do \
|
||||||
|
cat $${f}.copy > $${f}; \
|
||||||
|
done
|
||||||
|
rm -f sql/*.copy;
|
||||||
|
# old_versions
|
||||||
|
for f in $(basename $(wildcard old_versions/*.copy)); do \
|
||||||
|
cat $${f}.copy > $${f}; \
|
||||||
|
done
|
||||||
|
rm -f old_versions/*.copy;
|
||||||
|
# current scripts
|
||||||
|
for f in $(basename $(wildcard *.copy)); do \
|
||||||
|
cat $${f}.copy > $${f}; \
|
||||||
|
done
|
||||||
|
rm -f *.copy;
|
||||||
|
|
||||||
|
# Replacing variables defined within test files
|
||||||
|
replace_variables: restore_copies
|
||||||
|
# tests
|
||||||
|
for f in $(sort $(wildcard test/sql/*test.sql)); do \
|
||||||
|
sed --in-place=.copy -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $${f}; \
|
||||||
|
done
|
||||||
|
for f in $(sort $(wildcard test/expected/*test.out)); do \
|
||||||
|
sed --in-place=.copy -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $${f}; \
|
||||||
|
done
|
||||||
|
# data
|
||||||
|
for f in $(wildcard sql/*.sql); do \
|
||||||
|
sed --in-place=.copy -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $${f}; \
|
||||||
|
done
|
||||||
|
# old_versions
|
||||||
|
for f in $(wildcard old_versions/*.sql); do \
|
||||||
|
sed --in-place=.copy -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $${f}; \
|
||||||
|
done
|
||||||
|
# current scripts
|
||||||
|
for f in $(wildcard *.sql); do \
|
||||||
|
sed --in-place=.copy -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $${f}; \
|
||||||
|
done
|
||||||
|
sed --in-place=.copy -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $(EXTENSION).control;
|
||||||
|
|
||||||
|
# Install the current release into the PostgreSQL extensions directory
|
||||||
|
deploy: release_remove_parallel_deploy
|
||||||
|
$(INSTALL_DATA) $(EXTENSION).control '$(DESTDIR)$(datadir)/extension/'
|
||||||
|
$(INSTALL_DATA) old_versions/*.sql *.sql '$(DESTDIR)$(datadir)/extension/'
|
||||||
|
|
||||||
|
install: replace_variables deploy
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "dataservices-api-client-extension",
|
||||||
|
"current_version": {
|
||||||
|
"requires": {
|
||||||
|
"postgresql": "^11.0.0",
|
||||||
|
"postgis": "^2.5.0.0",
|
||||||
|
"carto_postgresql_ext": "^0.36.0"
|
||||||
|
},
|
||||||
|
"works_with": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
--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.29.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
-- PG12_DEPRECATED
|
||||||
|
-- Create geomval if it doesn't exist (in postgis 3+ it only exists in postgis_raster)
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'geomval') THEN
|
||||||
|
CREATE TYPE cdb_dataservices_client.geomval AS (
|
||||||
|
geom geometry,
|
||||||
|
val double precision
|
||||||
|
);
|
||||||
|
END IF;
|
||||||
|
END$$;
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
--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.28.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
-- PG12_DEPRECATED
|
||||||
|
-- Create geomval if it doesn't exist (in postgis 3+ it only exists in postgis_raster)
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.geomval RESTRICT;
|
||||||
|
END$$;
|
||||||
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.15.0'
|
default_version = '0.29.0'
|
||||||
requires = 'plproxy, cartodb'
|
requires = 'plproxy, cartodb'
|
||||||
superuser = true
|
superuser = true
|
||||||
schema = cdb_dataservices_client
|
schema = cdb_dataservices_client
|
||||||
|
|||||||
@@ -0,0 +1,277 @@
|
|||||||
|
--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.16.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_service_get_rate_limit (service 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._cdb_service_get_rate_limit(username, orgname, service) 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_service_set_user_rate_limit (username text ,orgname text ,service text ,rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
PERFORM cdb_dataservices_client._cdb_service_set_user_rate_limit(username, orgname, service, rate_limit);
|
||||||
|
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_service_set_org_rate_limit (username text ,orgname text ,service text ,rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
PERFORM cdb_dataservices_client._cdb_service_set_org_rate_limit(username, orgname, service, rate_limit);
|
||||||
|
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_service_set_server_rate_limit (username text ,orgname text ,service text ,rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
PERFORM cdb_dataservices_client._cdb_service_set_server_rate_limit(username, orgname, service, rate_limit);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_get_rate_limit_exception_safe (service text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
DECLARE
|
||||||
|
ret json;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
SELECT cdb_dataservices_client._cdb_service_get_rate_limit(username, orgname, service) INTO ret; RETURN ret;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_set_user_rate_limit_exception_safe (username text ,orgname text ,service text ,rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context TEXT;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
PERFORM cdb_dataservices_client._cdb_service_set_user_rate_limit(username, orgname, service, rate_limit);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_set_org_rate_limit_exception_safe (username text ,orgname text ,service text ,rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context TEXT;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
PERFORM cdb_dataservices_client._cdb_service_set_org_rate_limit(username, orgname, service, rate_limit);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_set_server_rate_limit_exception_safe (username text ,orgname text ,service text ,rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context TEXT;
|
||||||
|
BEGIN
|
||||||
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
|
END IF;
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
PERFORM cdb_dataservices_client._cdb_service_set_server_rate_limit(username, orgname, service, rate_limit);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_get_rate_limit (username text, orgname text, service text)
|
||||||
|
RETURNS json AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_service_get_rate_limit (username, orgname, service);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_set_user_rate_limit (username text, orgname text, service text, rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_service_set_user_rate_limit (username, orgname, service, rate_limit);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_set_org_rate_limit (username text, orgname text, service text, rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_service_set_org_rate_limit (username, orgname, service, rate_limit);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_set_server_rate_limit (username text, orgname text, service text, rate_limit json)
|
||||||
|
RETURNS void AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_service_set_server_rate_limit (username, orgname, service, rate_limit);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client.cdb_service_set_user_rate_limit (username text ,orgname text ,service text ,rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client.cdb_service_set_org_rate_limit (username text ,orgname text ,service text ,rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client.cdb_service_set_server_rate_limit (username text ,orgname text ,service text ,rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_set_user_rate_limit_exception_safe (username text ,orgname text ,service text ,rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_set_org_rate_limit_exception_safe (username text ,orgname text ,service text ,rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_set_server_rate_limit_exception_safe (username text ,orgname text ,service text ,rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_get_rate_limit (username text, orgname text, service text) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_set_user_rate_limit (username text, orgname text, service text, rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_set_org_rate_limit (username text, orgname text, service text, rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
REVOKE EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_set_server_rate_limit (username text, orgname text, service text, rate_limit json) FROM PUBLIC, publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_service_get_rate_limit(service text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_get_rate_limit_exception_safe(service text ) TO publicuser;
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
--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.15.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_service_get_rate_limit (text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_service_set_user_rate_limit (text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_service_set_org_rate_limit (text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_service_set_server_rate_limit (text, text, text, json);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_get_rate_limit_exception_safe (text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_set_user_rate_limit_exception_safe (text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_set_org_rate_limit_exception_safe (text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_set_server_rate_limit_exception_safe (text, text, text, json);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_get_rate_limit (text, text, text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_set_user_rate_limit (text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_set_org_rate_limit (text, text, text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_set_server_rate_limit (text, text, text, json);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
--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.17.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_geometry ADD ATTRIBUTE geom_type text;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_geometry ADD ATTRIBUTE geom_extra jsonb;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_geometry ADD ATTRIBUTE geom_tags jsonb;
|
||||||
|
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_timespan ADD ATTRIBUTE timespan_type text;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_timespan ADD ATTRIBUTE timespan_extra jsonb;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_timespan ADD ATTRIBUTE timespan_tags jsonb;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
|||||||
|
--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.16.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_geometry DROP ATTRIBUTE geom_type;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_geometry DROP ATTRIBUTE geom_extra;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_geometry DROP ATTRIBUTE geom_tags;
|
||||||
|
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_timespan DROP ATTRIBUTE timespan_type;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_timespan DROP ATTRIBUTE timespan_extra;
|
||||||
|
ALTER TYPE cdb_dataservices_client.obs_meta_timespan DROP ATTRIBUTE timespan_tags;
|
||||||
@@ -0,0 +1,325 @@
|
|||||||
|
--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.18.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
|
||||||
|
-- Due to an inconsistency between the v0.17.0 script on one side, and the source sql files
|
||||||
|
-- (namely 16_custon_types) and incremental migration scripts on the other (from/to 0.16.0),
|
||||||
|
-- the order of the fields of the obs_meta_geometry and obs_meta_timespan types
|
||||||
|
-- is different between extensions that have been up upgraded to 0.17.0 from prior versions
|
||||||
|
-- and those that have been installed directly.
|
||||||
|
-- For version 0.18.0 we will keep the "correct" ordering which is the one in the source sql
|
||||||
|
-- file and in the migration scripts (new fields added in 0.17.0 at the end).
|
||||||
|
-- When upgrading from 0.17.0 we must take into account that these types may or may not have
|
||||||
|
-- been defined with the correct ordering, so we need to redefine them.
|
||||||
|
-- ALTERing a type does not allow to reorder fields, so we'll need to DROP the types
|
||||||
|
-- (and all functions depending on them) and recreate the types and functions affected.
|
||||||
|
-- (≧︿≦) (╯°□°)╯ ︵ ┻━┻
|
||||||
|
|
||||||
|
DROP FUNCTION cdb_dataservices_client.obs_getavailablegeometries(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, timespan text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailablegeometries_exception_safe(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, timespan text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailablegeometries(username text, orgname text, bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, timespan text);
|
||||||
|
|
||||||
|
DROP FUNCTION cdb_dataservices_client.obs_getavailabletimespans(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, geom_id text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailabletimespans_exception_safe(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, geom_id text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailabletimespans(username text, orgname text, bounds geometry(Geometry, 4326) , filter_tags text[] , numer_id text , denom_id text , geom_id text);
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.obs_meta_geometry;
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.obs_meta_timespan;
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.obs_meta_geometry AS (geom_id text, geom_name text, geom_description text, geom_weight text, geom_aggregate text, geom_license text, geom_source text, valid_numer boolean, valid_denom boolean, valid_timespan boolean, score numeric, numtiles bigint, notnull_percent numeric, numgeoms numeric, percentfill numeric, estnumgeoms numeric, meanmediansize numeric, geom_type text, geom_extra jsonb, geom_tags jsonb);
|
||||||
|
CREATE TYPE cdb_dataservices_client.obs_meta_timespan AS (timespan_id text, timespan_name text, timespan_description text, timespan_weight text, timespan_aggregate text, timespan_license text, timespan_source text, valid_numer boolean, valid_denom boolean, valid_geom boolean, timespan_type text, timespan_extra jsonb, timespan_tags jsonb);
|
||||||
|
|
||||||
|
|
||||||
|
-- TYPE: cdb_dataservices_client.obs_meta_geometry
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 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_getavailablegeometries (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,timespan text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry 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_getavailablegeometries(username, orgname, bounds, filter_tags, numer_id, denom_id, timespan);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailablegeometries_exception_safe (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,timespan text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._obs_getavailablegeometries(username, orgname, bounds, filter_tags, numer_id, denom_id, timespan);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailablegeometries (username text, orgname text, bounds geometry(Geometry, 4326) DEFAULT NULL, filter_tags text[] DEFAULT NULL, numer_id text DEFAULT NULL, denom_id text DEFAULT NULL, timespan text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getavailablegeometries (username, orgname, bounds, filter_tags, numer_id, denom_id, timespan);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
-- TYPE: cdb_dataservices_client.obs_meta_timespan
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 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_getavailabletimespans (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,geom_id text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_timespan 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_getavailabletimespans(username, orgname, bounds, filter_tags, numer_id, denom_id, geom_id);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailabletimespans_exception_safe (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,geom_id text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_timespan AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._obs_getavailabletimespans(username, orgname, bounds, filter_tags, numer_id, denom_id, geom_id);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailabletimespans (username text, orgname text, bounds geometry(Geometry, 4326) DEFAULT NULL, filter_tags text[] DEFAULT NULL, numer_id text DEFAULT NULL, denom_id text DEFAULT NULL, geom_id text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_timespan AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getavailabletimespans (username, orgname, bounds, filter_tags, numer_id, denom_id, geom_id);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getavailablegeometries(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, timespan text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._obs_getavailablegeometries_exception_safe(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, timespan text ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_getavailabletimespans(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, geom_id text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._obs_getavailabletimespans_exception_safe(bounds geometry(Geometry, 4326), filter_tags text[], numer_id text, denom_id text, geom_id text ) TO publicuser;
|
||||||
|
|
||||||
|
|
||||||
|
-- Real migration changes for path 0.17.0 to 0.18.0
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon (postal_code double precision ,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;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point (postal_code double precision ,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;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon_exception_safe (postal_code double precision ,country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_polygon(username, orgname, postal_code, country_name) INTO ret; RETURN ret;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point_exception_safe (postal_code double precision ,country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocode_postalcode_point(username, orgname, postal_code, country_name) INTO ret; RETURN ret;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon (username text, orgname text, postal_code double precision, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon (username, orgname, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point (username text, orgname text, postal_code double precision, country_name text)
|
||||||
|
RETURNS Geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_point (username, orgname, postal_code, country_name);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon(postal_code double precision, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon_exception_safe(postal_code double precision, country_name text ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point(postal_code double precision, country_name text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point_exception_safe(postal_code double precision, country_name text ) TO publicuser;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
|||||||
|
--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.17.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
DROP FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon (postal_code double precision ,country_name text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_point (postal_code double precision ,country_name text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon_exception_safe (postal_code double precision ,country_name text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point_exception_safe (postal_code double precision ,country_name text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon (username text, orgname text, postal_code double precision, country_name text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_point (username text, orgname text, postal_code double precision, country_name text);
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
--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.19.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getnumerators (bounds geometry(Geometry, 4326) DEFAULT NULL ,section_tags text[] DEFAULT ARRAY[]::TEXT[] ,subsection_tags text[] DEFAULT ARRAY[]::TEXT[] ,other_tags text[] DEFAULT ARRAY[]::TEXT[] ,ids text[] DEFAULT ARRAY[]::TEXT[] ,name text DEFAULT NULL ,denom_id text DEFAULT '' ,geom_id text DEFAULT '' ,timespan text DEFAULT '')
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_numerator 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_getnumerators(username, orgname, bounds, section_tags, subsection_tags, other_tags, ids, name, denom_id, geom_id, timespan);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__obs_getnumerators_exception_safe (bounds geometry(Geometry, 4326) DEFAULT NULL ,section_tags text[] DEFAULT ARRAY[]::TEXT[] ,subsection_tags text[] DEFAULT ARRAY[]::TEXT[] ,other_tags text[] DEFAULT ARRAY[]::TEXT[] ,ids text[] DEFAULT ARRAY[]::TEXT[] ,name text DEFAULT NULL ,denom_id text DEFAULT '' ,geom_id text DEFAULT '' ,timespan text DEFAULT '')
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_numerator AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client.__obs_getnumerators(username, orgname, bounds, section_tags, subsection_tags, other_tags, ids, name, denom_id, geom_id, timespan);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__obs_getnumerators (username text, orgname text, bounds geometry(Geometry, 4326) DEFAULT NULL, section_tags text[] DEFAULT ARRAY[]::TEXT[], subsection_tags text[] DEFAULT ARRAY[]::TEXT[], other_tags text[] DEFAULT ARRAY[]::TEXT[], ids text[] DEFAULT ARRAY[]::TEXT[], name text DEFAULT NULL, denom_id text DEFAULT '', geom_id text DEFAULT '', timespan text DEFAULT '')
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_numerator AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server._obs_getnumerators (username, orgname, bounds, section_tags, subsection_tags, other_tags, ids, name, denom_id, geom_id, timespan);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._obs_getnumerators(bounds geometry(Geometry, 4326), section_tags text[], subsection_tags text[], other_tags text[], ids text[], name text, denom_id text, geom_id text, timespan text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.__obs_getnumerators_exception_safe(bounds geometry(Geometry, 4326), section_tags text[], subsection_tags text[], other_tags text[], ids text[], name text, denom_id text, geom_id text, timespan text ) TO publicuser;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
--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.18.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
DROP IF EXISTS FUNCTION cdb_dataservices_client._obs_getnumerators (geometry(Geometry, 4326), text[], text[] , text[], text[] , text, text, text,text);
|
||||||
|
DROP IF EXISTS FUNCTION cdb_dataservices_client.__obs_getnumerators_exception_safe (geometry(Geometry, 4326), text[], text[] , text[], text[] , text, text, text,text);
|
||||||
|
DROP IF EXISTS FUNCTION cdb_dataservices_client.__obs_getnumerators (text, text, geometry(Geometry, 4326), text[], text[] , text[], text[] , text, text, text,text);
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
--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.20.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_PreCheck(
|
||||||
|
source_query text,
|
||||||
|
parameters json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
errors text[];
|
||||||
|
validator_errors text[];
|
||||||
|
validator_error text;
|
||||||
|
valid boolean;
|
||||||
|
geoms record;
|
||||||
|
BEGIN
|
||||||
|
errors := (ARRAY[])::TEXT[];
|
||||||
|
FOR geoms IN EXECUTE format('SELECT ST_GeometryType(the_geom) as geom_type,
|
||||||
|
bool_and(st_isvalid(the_geom)) as valid,
|
||||||
|
avg(st_npoints(the_geom)) as avg_vertex,
|
||||||
|
ST_SetSRID(ST_Extent(the_geom), 4326) as extent,
|
||||||
|
count(*)::INT as numgeoms
|
||||||
|
FROM (%s) as _source
|
||||||
|
GROUP BY ST_GeometryType(the_geom)', source_query)
|
||||||
|
LOOP
|
||||||
|
IF geoms.geom_type NOT IN ('ST_Polygon', 'ST_MultiPolygon', 'ST_Point') THEN
|
||||||
|
errors := array_append(errors, format($data$'Geometry type %s not supported'$data$, geoms.geom_type));
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF geoms.valid IS FALSE THEN
|
||||||
|
errors := array_append(errors, 'There are invalid geometries in the input data, please review them');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 1000 vertex for a geometry is a limit we have in the obs_getdata function. You can check here
|
||||||
|
-- https://github.com/CartoDB/observatory-extension/blob/1.6.0/src/pg/sql/41_observatory_augmentation.sql#L813
|
||||||
|
IF geoms.avg_vertex > 1000 THEN
|
||||||
|
errors := array_append(errors, 'The average number of geometries vertex is greater than 1000, please try to simplify them');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- OBS specific part
|
||||||
|
EXECUTE 'SELECT valid, errors
|
||||||
|
FROM cdb_dataservices_client.OBS_MetadataValidation($1, $2, $3, $4)'
|
||||||
|
INTO valid, validator_errors
|
||||||
|
USING geoms.extent, geoms.geom_type, parameters, geoms.numgeoms;
|
||||||
|
IF valid is FALSE THEN
|
||||||
|
FOR validator_error IN EXECUTE 'SELECT unnest($1)' USING validator_errors
|
||||||
|
LOOP
|
||||||
|
errors := array_append(errors, validator_error);
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
IF CARDINALITY(errors) > 0 THEN
|
||||||
|
RAISE EXCEPTION '%', errors;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN TRUE;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_metadatavalidation (username text, orgname text, geom_extent Geometry(Geometry, 4326), geom_type text, params json, target_geoms integer DEFAULT NULL)
|
||||||
|
RETURNS TABLE(valid boolean, errors text[]) AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_metadatavalidation (username, orgname, geom_extent, geom_type, params, target_geoms);
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_metadatavalidation (geom_extent Geometry(Geometry, 4326) ,geom_type text ,params json ,target_geoms integer DEFAULT NULL)
|
||||||
|
RETURNS TABLE(valid boolean, errors 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_metadatavalidation(username, orgname, geom_extent, geom_type, params, target_geoms);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_metadatavalidation_exception_safe (geom_extent Geometry(Geometry, 4326) ,geom_type text ,params json ,target_geoms integer DEFAULT NULL)
|
||||||
|
RETURNS TABLE(valid boolean, errors text[]) AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._obs_metadatavalidation(username, orgname, geom_extent, geom_type, params, target_geoms);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._OBS_PreCheck(source_query text, params JSON) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.obs_metadatavalidation(geom_extent Geometry(Geometry, 4326), geom_type text, params json, target_geoms integer) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._obs_metadatavalidation_exception_safe(geom_extent Geometry(Geometry, 4326), geom_type text, params json, target_geoms integer ) TO publicuser;
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
|||||||
|
--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.19.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
DROP FUNCTION IF EXISTS _OBS_PreCheck(text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.obs_metadatavalidation (Geometry(Geometry, 4326), text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_metadatavalidation_exception_safe (Geometry(Geometry, 4326), text, json);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._obs_metadatavalidation (text, text, Geometry(Geometry, 4326), text, json);
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
--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.21.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailablegeometries (username text, orgname text, bounds geometry(Geometry, 4326) DEFAULT NULL, filter_tags text[] DEFAULT NULL, numer_id text DEFAULT NULL, denom_id text DEFAULT NULL, timespan text DEFAULT NULL, number_geometries integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getavailablegeometries (username, orgname, bounds, filter_tags, numer_id, denom_id, timespan, number_geometries);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getavailablegeometries (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,timespan text DEFAULT NULL ,number_geometries integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry 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_getavailablegeometries(username, orgname, bounds, filter_tags, numer_id, denom_id, timespan, number_geometries);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailablegeometries_exception_safe (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,timespan text DEFAULT NULL ,number_geometries integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._obs_getavailablegeometries(username, orgname, bounds, filter_tags, numer_id, denom_id, timespan, number_geometries);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
DROP FUNCTION cdb_dataservices_client.obs_getavailablegeometries (geometry(Geometry, 4326), text[], text, text, text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailablegeometries_exception_safe (geometry(Geometry, 4326), text[], text, text, text);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailablegeometries (text, text, geometry(Geometry, 4326), text[], text, text, text);
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,65 @@
|
|||||||
|
--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.20.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailablegeometries (username text, orgname text, bounds geometry(Geometry, 4326) DEFAULT NULL, filter_tags text[] DEFAULT NULL, numer_id text DEFAULT NULL, denom_id text DEFAULT NULL, timespan text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
SELECT * FROM cdb_dataservices_server.obs_getavailablegeometries (username, orgname, bounds, filter_tags, numer_id, denom_id, timespan);
|
||||||
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_getavailablegeometries (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,timespan text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry 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_getavailablegeometries(username, orgname, bounds, filter_tags, numer_id, denom_id, timespan);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_getavailablegeometries_exception_safe (bounds geometry(Geometry, 4326) DEFAULT NULL ,filter_tags text[] DEFAULT NULL ,numer_id text DEFAULT NULL ,denom_id text DEFAULT NULL ,timespan text DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.obs_meta_geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._obs_getavailablegeometries(username, orgname, bounds, filter_tags, numer_id, denom_id, timespan);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
DROP FUNCTION cdb_dataservices_client.obs_getavailablegeometries (geometry(Geometry, 4326), text[], text, text, text, integer);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailablegeometries_exception_safe (geometry(Geometry, 4326), text[], text, text, text, integer);
|
||||||
|
DROP FUNCTION cdb_dataservices_client._obs_getavailablegeometries (text, text, geometry(Geometry, 4326), text[], text, text, text, integer);
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,200 @@
|
|||||||
|
--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.23.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapbox_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_mapbox_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapbox_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_mapbox_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapbox_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_mapbox_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_geocode_street_point_exception_safe (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;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
SELECT cdb_dataservices_client._cdb_mapbox_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isochrone_exception_safe(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;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_mapbox_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isodistance_exception_safe(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;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_mapbox_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_geocode_street_point (username text, orgname 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_mapbox_geocode_street_point (username, orgname, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isochrone (username text, orgname 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_mapbox_isochrone (username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isodistance (username text, orgname 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_mapbox_isodistance (username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapbox_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_mapbox_geocode_street_point_exception_safe(searchtext text, city text, state_province text, country text ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapbox_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_mapbox_isochrone_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapbox_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_mapbox_isodistance_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] ) TO publicuser;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
|||||||
|
--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.22.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_mapbox_geocode_street_point (searchtext text, city text, state_province text, country text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_mapbox_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_mapbox_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapbox_geocode_street_point_exception_safe (searchtext text, city text, state_province text, country text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapbox_isochrone_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapbox_isodistance_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapbox_geocode_street_point (username text, orgname text, searchtext text, city text, state_province text, country text);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapbox_isochrone (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_mapbox_isodistance (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
--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.24.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_tomtom_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_tomtom_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_tomtom_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_tomtom_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_tomtom_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_tomtom_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_tomtom_geocode_street_point_exception_safe (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;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
SELECT cdb_dataservices_client._cdb_tomtom_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_tomtom_isochrone_exception_safe (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;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_tomtom_isochrone(username, orgname, source, mode, range, options);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_tomtom_isodistance_exception_safe (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;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_tomtom_isodistance(username, orgname, source, mode, range, options);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_geocode_street_point (username text, orgname text, searchtext text, city text, state_province text, country text);
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_tomtom_geocode_street_point (username text, orgname 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_tomtom_geocode_street_point (username, orgname, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_isochrone (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_tomtom_isochrone (username text, orgname 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_tomtom_isochrone (username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_isodistance (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_tomtom_isodistance (username text, orgname 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_tomtom_isodistance (username, orgname, source, mode, range, options);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_tomtom_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_tomtom_geocode_street_point_exception_safe(searchtext text, city text, state_province text, country text ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_tomtom_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_tomtom_isochrone_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_tomtom_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_tomtom_isodistance_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] ) TO publicuser;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
|||||||
|
--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.23.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_tomtom_geocode_street_point (text, text, text, text);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_tomtom_isochrone (geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_tomtom_isodistance (geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_geocode_street_point_exception_safe (text, text, text, text);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_isochrone_exception_safe (geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_isodistance_exception_safe (geometry(Geometry, 4326), text, integer[], text[]);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_geocode_street_point (username text, orgname text, searchtext text, city text, state_province text, country text);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_isochrone (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_tomtom_isodistance (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[]);
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
--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 '<%= version %>'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
-- Taken from https://wiki.postgresql.org/wiki/Count_estimate
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_count_estimate(query text) RETURNS INTEGER AS
|
||||||
|
$func$
|
||||||
|
DECLARE
|
||||||
|
rec record;
|
||||||
|
ROWS INTEGER;
|
||||||
|
BEGIN
|
||||||
|
FOR rec IN EXECUTE 'EXPLAIN ' || query LOOP
|
||||||
|
ROWS := SUBSTRING(rec."QUERY PLAN" FROM ' rows=([[:digit:]]+)');
|
||||||
|
EXIT WHEN ROWS IS NOT NULL;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RETURN ROWS;
|
||||||
|
END
|
||||||
|
$func$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
-- Taken from https://stackoverflow.com/a/48013356/351721
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_jsonb_array_casttext(jsonb) RETURNS text[] AS $f$
|
||||||
|
SELECT array_agg(x) || ARRAY[]::text[] FROM jsonb_array_elements_text($1) t(x);
|
||||||
|
$f$ LANGUAGE sql IMMUTABLE;--
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.geocoding AS (
|
||||||
|
cartodb_id integer,
|
||||||
|
the_geom geometry(Multipolygon,4326),
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.service_quota_info_batch AS (
|
||||||
|
service cdb_dataservices_client.service_type,
|
||||||
|
monthly_quota NUMERIC,
|
||||||
|
used_quota NUMERIC,
|
||||||
|
soft_limit BOOLEAN,
|
||||||
|
provider TEXT,
|
||||||
|
max_batch_size NUMERIC
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 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_bulk_geocode_street_point (searches jsonb)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding 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_bulk_geocode_street_point(username, orgname, searches);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 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_service_quota_info_batch ()
|
||||||
|
RETURNS SETOF service_quota_info_batch 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_service_quota_info_batch(username, orgname);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point (query text,
|
||||||
|
street_column text, city_column text default null, state_column text default null, country_column text default null, batch_size integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
DECLARE
|
||||||
|
query_row_count integer;
|
||||||
|
enough_quota boolean;
|
||||||
|
remaining_quota integer;
|
||||||
|
max_batch_size integer;
|
||||||
|
|
||||||
|
cartodb_id_batch integer;
|
||||||
|
batches_n integer;
|
||||||
|
DEFAULT_BATCH_SIZE CONSTANT numeric := 100;
|
||||||
|
MAX_SAFE_BATCH_SIZE CONSTANT numeric := 5000;
|
||||||
|
|
||||||
|
temp_table_name text;
|
||||||
|
BEGIN
|
||||||
|
SELECT csqi.monthly_quota - csqi.used_quota AS remaining_quota, csqi.max_batch_size
|
||||||
|
INTO remaining_quota, max_batch_size
|
||||||
|
FROM cdb_dataservices_client.cdb_service_quota_info_batch() csqi
|
||||||
|
WHERE service = 'hires_geocoder';
|
||||||
|
RAISE DEBUG 'remaining_quota: %; max_batch_size: %', remaining_quota, max_batch_size;
|
||||||
|
|
||||||
|
IF batch_size IS NULL THEN
|
||||||
|
batch_size := max_batch_size;
|
||||||
|
ELSIF batch_size > max_batch_size THEN
|
||||||
|
RAISE EXCEPTION 'batch_size must be lower than %', max_batch_size + 1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF batch_size > MAX_SAFE_BATCH_SIZE THEN
|
||||||
|
batch_size := MAX_SAFE_BATCH_SIZE;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
EXECUTE format('SELECT count(1), ceil(count(1)::float/%s) FROM (%s) _x', batch_size, query)
|
||||||
|
INTO query_row_count, batches_n;
|
||||||
|
|
||||||
|
RAISE DEBUG 'cdb_bulk_geocode_street_point --> query_row_count: %; query: %; country: %; state: %; city: %; street: %',
|
||||||
|
query_row_count, query, country_column, state_column, city_column, street_column;
|
||||||
|
SELECT cdb_dataservices_client.cdb_enough_quota('hires_geocoder', query_row_count) INTO enough_quota;
|
||||||
|
IF remaining_quota < query_row_count THEN
|
||||||
|
RAISE EXCEPTION 'Remaining quota: %. Estimated cost: %', remaining_quota, query_row_count;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RAISE DEBUG 'batches_n: %', batches_n;
|
||||||
|
|
||||||
|
temp_table_name := 'bulk_geocode_street_' || md5(random()::text);
|
||||||
|
|
||||||
|
EXECUTE format('CREATE TEMPORARY TABLE %s ' ||
|
||||||
|
'(cartodb_id integer, the_geom geometry(Multipolygon,4326), metadata jsonb)',
|
||||||
|
temp_table_name);
|
||||||
|
|
||||||
|
select
|
||||||
|
coalesce(street_column, ''''''), coalesce(city_column, ''''''),
|
||||||
|
coalesce(state_column, ''''''), coalesce(country_column, '''''')
|
||||||
|
into street_column, city_column, state_column, country_column;
|
||||||
|
|
||||||
|
IF batches_n > 0 THEN
|
||||||
|
FOR cartodb_id_batch in 0..(batches_n - 1)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'WITH geocoding_data as (' ||
|
||||||
|
' SELECT ' ||
|
||||||
|
' json_build_object(''id'', cartodb_id, ''address'', %s, ''city'', %s, ''state'', %s, ''country'', %s) as data , ' ||
|
||||||
|
' floor((row_number() over () - 1)::float/$1) as batch' ||
|
||||||
|
' FROM (%s) _x' ||
|
||||||
|
') ' ||
|
||||||
|
'INSERT INTO %s SELECT (cdb_dataservices_client._cdb_bulk_geocode_street_point(jsonb_agg(data))).* ' ||
|
||||||
|
'FROM geocoding_data ' ||
|
||||||
|
'WHERE batch = $2', street_column, city_column, state_column, country_column, query, temp_table_name)
|
||||||
|
USING batch_size, cartodb_id_batch;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY EXECUTE 'SELECT * FROM ' || quote_ident(temp_table_name);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__cdb_bulk_geocode_street_point_exception_safe (searches jsonb)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client.__cdb_bulk_geocode_street_point(username, orgname, searches);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Exception-safe private DataServices API function
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_quota_info_batch_exception_safe ()
|
||||||
|
RETURNS SETOF service_quota_info_batch AS $$
|
||||||
|
DECLARE
|
||||||
|
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_service_quota_info_batch(username, orgname);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__cdb_bulk_geocode_street_point (username text, orgname text, searches jsonb);
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__cdb_bulk_geocode_street_point (username text, orgname text, searches jsonb)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server._cdb_bulk_geocode_street_point (username, orgname, searches);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_quota_info_batch (username text, orgname text);
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_service_quota_info_batch (username text, orgname text)
|
||||||
|
RETURNS SETOF service_quota_info_batch AS $$
|
||||||
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
|
|
||||||
|
SELECT * FROM cdb_dataservices_server.cdb_service_quota_info_batch (username, orgname);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point(searches jsonb) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.__cdb_bulk_geocode_street_point_exception_safe(searches jsonb ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch() TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_service_quota_info_batch_exception_safe( ) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point(query text, street_column text, city_column text, state_column text, country_column text, batch_size integer) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_count_estimate(query text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_jsonb_array_casttext(jsonb) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.__cdb_bulk_geocode_street_point (username text, orgname text, searches jsonb) TO publicuser;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
|||||||
|
--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 '<%= version %>'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_count_estimate(query text);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_jsonb_array_casttext(jsonb);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_bulk_geocode_street_point (jsonb);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_service_quota_info_batch();
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_bulk_geocode_street_point (text, text, text, text, text, integer);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__cdb_bulk_geocode_street_point_exception_safe (jsonb);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_quota_info_batch_exception_safe ();
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.__cdb_bulk_geocode_street_point (text, text, jsonb);
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_service_quota_info_batch (text, text);
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.service_quota_info_batch;
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS cdb_dataservices_client.geocoding;
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
|||||||
|
--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.26.1'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
ALTER TYPE cdb_dataservices_client.geocoding ALTER ATTRIBUTE the_geom TYPE geometry(Point,4326);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point (query text,
|
||||||
|
street_column text, city_column text default null, state_column text default null, country_column text default null, batch_size integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
DECLARE
|
||||||
|
query_row_count integer;
|
||||||
|
enough_quota boolean;
|
||||||
|
remaining_quota integer;
|
||||||
|
max_batch_size integer;
|
||||||
|
|
||||||
|
cartodb_id_batch integer;
|
||||||
|
batches_n integer;
|
||||||
|
DEFAULT_BATCH_SIZE CONSTANT numeric := 100;
|
||||||
|
MAX_SAFE_BATCH_SIZE CONSTANT numeric := 5000;
|
||||||
|
|
||||||
|
temp_table_name text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
apikey_permissions json;
|
||||||
|
BEGIN
|
||||||
|
SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN
|
||||||
|
RAISE EXCEPTION 'Geocoding permission denied' USING ERRCODE = '01007';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 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 csqi.monthly_quota - csqi.used_quota AS remaining_quota, csqi.max_batch_size
|
||||||
|
INTO remaining_quota, max_batch_size
|
||||||
|
FROM cdb_dataservices_client.cdb_service_quota_info_batch() csqi
|
||||||
|
WHERE service = 'hires_geocoder';
|
||||||
|
RAISE DEBUG 'remaining_quota: %; max_batch_size: %', remaining_quota, max_batch_size;
|
||||||
|
|
||||||
|
IF batch_size IS NULL THEN
|
||||||
|
batch_size := max_batch_size;
|
||||||
|
ELSIF batch_size > max_batch_size THEN
|
||||||
|
RAISE EXCEPTION 'batch_size must be lower than %', max_batch_size + 1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF batch_size > MAX_SAFE_BATCH_SIZE THEN
|
||||||
|
batch_size := MAX_SAFE_BATCH_SIZE;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
EXECUTE format('SELECT count(1), ceil(count(1)::float/%s) FROM (%s) _x', batch_size, query)
|
||||||
|
INTO query_row_count, batches_n;
|
||||||
|
|
||||||
|
RAISE DEBUG 'cdb_bulk_geocode_street_point --> query_row_count: %; query: %; country: %; state: %; city: %; street: %',
|
||||||
|
query_row_count, query, country_column, state_column, city_column, street_column;
|
||||||
|
SELECT cdb_dataservices_client.cdb_enough_quota('hires_geocoder', query_row_count) INTO enough_quota;
|
||||||
|
IF remaining_quota < query_row_count THEN
|
||||||
|
RAISE EXCEPTION 'Remaining quota: %. Estimated cost: %', remaining_quota, query_row_count;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RAISE DEBUG 'batches_n: %', batches_n;
|
||||||
|
|
||||||
|
temp_table_name := 'bulk_geocode_street_' || md5(random()::text);
|
||||||
|
|
||||||
|
EXECUTE format('CREATE TEMPORARY TABLE %s ' ||
|
||||||
|
'(cartodb_id integer, the_geom geometry(Point,4326), metadata jsonb)',
|
||||||
|
temp_table_name);
|
||||||
|
|
||||||
|
select
|
||||||
|
coalesce(street_column, ''''''), coalesce(city_column, ''''''),
|
||||||
|
coalesce(state_column, ''''''), coalesce(country_column, '''''')
|
||||||
|
into street_column, city_column, state_column, country_column;
|
||||||
|
|
||||||
|
IF batches_n > 0 THEN
|
||||||
|
FOR cartodb_id_batch in 0..(batches_n - 1)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'WITH geocoding_data as (' ||
|
||||||
|
' SELECT ' ||
|
||||||
|
' json_build_object(''id'', cartodb_id, ''address'', %s, ''city'', %s, ''state'', %s, ''country'', %s) as data , ' ||
|
||||||
|
' floor((row_number() over () - 1)::float/$1) as batch' ||
|
||||||
|
' FROM (%s) _x' ||
|
||||||
|
') ' ||
|
||||||
|
'INSERT INTO %s SELECT (cdb_dataservices_client._cdb_bulk_geocode_street_point(jsonb_agg(data))).* ' ||
|
||||||
|
'FROM geocoding_data ' ||
|
||||||
|
'WHERE batch = $2', street_column, city_column, state_column, country_column, query, temp_table_name)
|
||||||
|
USING batch_size, cartodb_id_batch;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY EXECUTE 'SELECT * FROM ' || quote_ident(temp_table_name);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
|||||||
|
--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.26.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
ALTER TYPE cdb_dataservices_client.geocoding ALTER ATTRIBUTE the_geom TYPE geometry(MultiPolygon,4326);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point (query text,
|
||||||
|
street_column text, city_column text default null, state_column text default null, country_column text default null, batch_size integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
DECLARE
|
||||||
|
query_row_count integer;
|
||||||
|
enough_quota boolean;
|
||||||
|
remaining_quota integer;
|
||||||
|
max_batch_size integer;
|
||||||
|
|
||||||
|
cartodb_id_batch integer;
|
||||||
|
batches_n integer;
|
||||||
|
DEFAULT_BATCH_SIZE CONSTANT numeric := 100;
|
||||||
|
MAX_SAFE_BATCH_SIZE CONSTANT numeric := 5000;
|
||||||
|
|
||||||
|
temp_table_name text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
apikey_permissions json;
|
||||||
|
BEGIN
|
||||||
|
SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN
|
||||||
|
RAISE EXCEPTION 'Geocoding permission denied' USING ERRCODE = '01007';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 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 csqi.monthly_quota - csqi.used_quota AS remaining_quota, csqi.max_batch_size
|
||||||
|
INTO remaining_quota, max_batch_size
|
||||||
|
FROM cdb_dataservices_client.cdb_service_quota_info_batch() csqi
|
||||||
|
WHERE service = 'hires_geocoder';
|
||||||
|
RAISE DEBUG 'remaining_quota: %; max_batch_size: %', remaining_quota, max_batch_size;
|
||||||
|
|
||||||
|
IF batch_size IS NULL THEN
|
||||||
|
batch_size := max_batch_size;
|
||||||
|
ELSIF batch_size > max_batch_size THEN
|
||||||
|
RAISE EXCEPTION 'batch_size must be lower than %', max_batch_size + 1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF batch_size > MAX_SAFE_BATCH_SIZE THEN
|
||||||
|
batch_size := MAX_SAFE_BATCH_SIZE;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
EXECUTE format('SELECT count(1), ceil(count(1)::float/%s) FROM (%s) _x', batch_size, query)
|
||||||
|
INTO query_row_count, batches_n;
|
||||||
|
|
||||||
|
RAISE DEBUG 'cdb_bulk_geocode_street_point --> query_row_count: %; query: %; country: %; state: %; city: %; street: %',
|
||||||
|
query_row_count, query, country_column, state_column, city_column, street_column;
|
||||||
|
SELECT cdb_dataservices_client.cdb_enough_quota('hires_geocoder', query_row_count) INTO enough_quota;
|
||||||
|
IF remaining_quota < query_row_count THEN
|
||||||
|
RAISE EXCEPTION 'Remaining quota: %. Estimated cost: %', remaining_quota, query_row_count;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RAISE DEBUG 'batches_n: %', batches_n;
|
||||||
|
|
||||||
|
temp_table_name := 'bulk_geocode_street_' || md5(random()::text);
|
||||||
|
|
||||||
|
EXECUTE format('CREATE TEMPORARY TABLE %s ' ||
|
||||||
|
'(cartodb_id integer, the_geom geometry(Multipolygon,4326), metadata jsonb)',
|
||||||
|
temp_table_name);
|
||||||
|
|
||||||
|
select
|
||||||
|
coalesce(street_column, ''''''), coalesce(city_column, ''''''),
|
||||||
|
coalesce(state_column, ''''''), coalesce(country_column, '''''')
|
||||||
|
into street_column, city_column, state_column, country_column;
|
||||||
|
|
||||||
|
IF batches_n > 0 THEN
|
||||||
|
FOR cartodb_id_batch in 0..(batches_n - 1)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'WITH geocoding_data as (' ||
|
||||||
|
' SELECT ' ||
|
||||||
|
' json_build_object(''id'', cartodb_id, ''address'', %s, ''city'', %s, ''state'', %s, ''country'', %s) as data , ' ||
|
||||||
|
' floor((row_number() over () - 1)::float/$1) as batch' ||
|
||||||
|
' FROM (%s) _x' ||
|
||||||
|
') ' ||
|
||||||
|
'INSERT INTO %s SELECT (cdb_dataservices_client._cdb_bulk_geocode_street_point(jsonb_agg(data))).* ' ||
|
||||||
|
'FROM geocoding_data ' ||
|
||||||
|
'WHERE batch = $2', street_column, city_column, state_column, country_column, query, temp_table_name)
|
||||||
|
USING batch_size, cartodb_id_batch;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY EXECUTE 'SELECT * FROM ' || quote_ident(temp_table_name);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE;
|
||||||
@@ -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.26.2'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point (query text,
|
||||||
|
street_column text, city_column text default null, state_column text default null, country_column text default null, batch_size integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
DECLARE
|
||||||
|
query_row_count integer;
|
||||||
|
enough_quota boolean;
|
||||||
|
remaining_quota integer;
|
||||||
|
max_batch_size integer;
|
||||||
|
|
||||||
|
cartodb_id_batch integer;
|
||||||
|
batches_n integer;
|
||||||
|
DEFAULT_BATCH_SIZE CONSTANT numeric := 100;
|
||||||
|
MAX_SAFE_BATCH_SIZE CONSTANT numeric := 5000;
|
||||||
|
|
||||||
|
temp_table_name text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
apikey_permissions json;
|
||||||
|
BEGIN
|
||||||
|
SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN
|
||||||
|
RAISE EXCEPTION 'Geocoding permission denied' USING ERRCODE = '01007';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 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 csqi.monthly_quota - csqi.used_quota AS remaining_quota, csqi.max_batch_size
|
||||||
|
INTO remaining_quota, max_batch_size
|
||||||
|
FROM cdb_dataservices_client.cdb_service_quota_info_batch() csqi
|
||||||
|
WHERE service = 'hires_geocoder';
|
||||||
|
RAISE DEBUG 'remaining_quota: %; max_batch_size: %', remaining_quota, max_batch_size;
|
||||||
|
|
||||||
|
IF batch_size IS NULL THEN
|
||||||
|
batch_size := max_batch_size;
|
||||||
|
ELSIF batch_size > max_batch_size THEN
|
||||||
|
RAISE EXCEPTION 'batch_size must be lower than %', max_batch_size + 1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF batch_size > MAX_SAFE_BATCH_SIZE THEN
|
||||||
|
batch_size := MAX_SAFE_BATCH_SIZE;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
EXECUTE format('SELECT count(1), ceil(count(1)::float/%s) FROM (%s) _x', batch_size, query)
|
||||||
|
INTO query_row_count, batches_n;
|
||||||
|
|
||||||
|
RAISE DEBUG 'cdb_bulk_geocode_street_point --> query_row_count: %; query: %; country: %; state: %; city: %; street: %',
|
||||||
|
query_row_count, query, country_column, state_column, city_column, street_column;
|
||||||
|
SELECT cdb_dataservices_client.cdb_enough_quota('hires_geocoder', query_row_count) INTO enough_quota;
|
||||||
|
IF enough_quota IS NULL OR NOT enough_quota THEN
|
||||||
|
RAISE EXCEPTION 'Remaining quota: %. Estimated cost: %', remaining_quota, query_row_count;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RAISE DEBUG 'batches_n: %', batches_n;
|
||||||
|
|
||||||
|
temp_table_name := 'bulk_geocode_street_' || md5(random()::text);
|
||||||
|
|
||||||
|
EXECUTE format('CREATE TEMPORARY TABLE %s ' ||
|
||||||
|
'(cartodb_id integer, the_geom geometry(Point,4326), metadata jsonb)',
|
||||||
|
temp_table_name);
|
||||||
|
|
||||||
|
select
|
||||||
|
coalesce(street_column, ''''''), coalesce(city_column, ''''''),
|
||||||
|
coalesce(state_column, ''''''), coalesce(country_column, '''''')
|
||||||
|
into street_column, city_column, state_column, country_column;
|
||||||
|
|
||||||
|
IF batches_n > 0 THEN
|
||||||
|
FOR cartodb_id_batch in 0..(batches_n - 1)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'WITH geocoding_data as (' ||
|
||||||
|
' SELECT ' ||
|
||||||
|
' json_build_object(''id'', cartodb_id, ''address'', %s, ''city'', %s, ''state'', %s, ''country'', %s) as data , ' ||
|
||||||
|
' floor((row_number() over () - 1)::float/$1) as batch' ||
|
||||||
|
' FROM (%s) _x' ||
|
||||||
|
') ' ||
|
||||||
|
'INSERT INTO %s SELECT (cdb_dataservices_client._cdb_bulk_geocode_street_point(jsonb_agg(data))).* ' ||
|
||||||
|
'FROM geocoding_data ' ||
|
||||||
|
'WHERE batch = $2', street_column, city_column, state_column, country_column, query, temp_table_name)
|
||||||
|
USING batch_size, cartodb_id_batch;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY EXECUTE 'SELECT * FROM ' || quote_ident(temp_table_name);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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.26.1'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point (query text,
|
||||||
|
street_column text, city_column text default null, state_column text default null, country_column text default null, batch_size integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
DECLARE
|
||||||
|
query_row_count integer;
|
||||||
|
enough_quota boolean;
|
||||||
|
remaining_quota integer;
|
||||||
|
max_batch_size integer;
|
||||||
|
|
||||||
|
cartodb_id_batch integer;
|
||||||
|
batches_n integer;
|
||||||
|
DEFAULT_BATCH_SIZE CONSTANT numeric := 100;
|
||||||
|
MAX_SAFE_BATCH_SIZE CONSTANT numeric := 5000;
|
||||||
|
|
||||||
|
temp_table_name text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
apikey_permissions json;
|
||||||
|
BEGIN
|
||||||
|
SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN
|
||||||
|
RAISE EXCEPTION 'Geocoding permission denied' USING ERRCODE = '01007';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 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 csqi.monthly_quota - csqi.used_quota AS remaining_quota, csqi.max_batch_size
|
||||||
|
INTO remaining_quota, max_batch_size
|
||||||
|
FROM cdb_dataservices_client.cdb_service_quota_info_batch() csqi
|
||||||
|
WHERE service = 'hires_geocoder';
|
||||||
|
RAISE DEBUG 'remaining_quota: %; max_batch_size: %', remaining_quota, max_batch_size;
|
||||||
|
|
||||||
|
IF batch_size IS NULL THEN
|
||||||
|
batch_size := max_batch_size;
|
||||||
|
ELSIF batch_size > max_batch_size THEN
|
||||||
|
RAISE EXCEPTION 'batch_size must be lower than %', max_batch_size + 1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF batch_size > MAX_SAFE_BATCH_SIZE THEN
|
||||||
|
batch_size := MAX_SAFE_BATCH_SIZE;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
EXECUTE format('SELECT count(1), ceil(count(1)::float/%s) FROM (%s) _x', batch_size, query)
|
||||||
|
INTO query_row_count, batches_n;
|
||||||
|
|
||||||
|
RAISE DEBUG 'cdb_bulk_geocode_street_point --> query_row_count: %; query: %; country: %; state: %; city: %; street: %',
|
||||||
|
query_row_count, query, country_column, state_column, city_column, street_column;
|
||||||
|
SELECT cdb_dataservices_client.cdb_enough_quota('hires_geocoder', query_row_count) INTO enough_quota;
|
||||||
|
IF remaining_quota < query_row_count THEN
|
||||||
|
RAISE EXCEPTION 'Remaining quota: %. Estimated cost: %', remaining_quota, query_row_count;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RAISE DEBUG 'batches_n: %', batches_n;
|
||||||
|
|
||||||
|
temp_table_name := 'bulk_geocode_street_' || md5(random()::text);
|
||||||
|
|
||||||
|
EXECUTE format('CREATE TEMPORARY TABLE %s ' ||
|
||||||
|
'(cartodb_id integer, the_geom geometry(Point,4326), metadata jsonb)',
|
||||||
|
temp_table_name);
|
||||||
|
|
||||||
|
select
|
||||||
|
coalesce(street_column, ''''''), coalesce(city_column, ''''''),
|
||||||
|
coalesce(state_column, ''''''), coalesce(country_column, '''''')
|
||||||
|
into street_column, city_column, state_column, country_column;
|
||||||
|
|
||||||
|
IF batches_n > 0 THEN
|
||||||
|
FOR cartodb_id_batch in 0..(batches_n - 1)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'WITH geocoding_data as (' ||
|
||||||
|
' SELECT ' ||
|
||||||
|
' json_build_object(''id'', cartodb_id, ''address'', %s, ''city'', %s, ''state'', %s, ''country'', %s) as data , ' ||
|
||||||
|
' floor((row_number() over () - 1)::float/$1) as batch' ||
|
||||||
|
' FROM (%s) _x' ||
|
||||||
|
') ' ||
|
||||||
|
'INSERT INTO %s SELECT (cdb_dataservices_client._cdb_bulk_geocode_street_point(jsonb_agg(data))).* ' ||
|
||||||
|
'FROM geocoding_data ' ||
|
||||||
|
'WHERE batch = $2', street_column, city_column, state_column, country_column, query, temp_table_name)
|
||||||
|
USING batch_size, cartodb_id_batch;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY EXECUTE 'SELECT * FROM ' || quote_ident(temp_table_name);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
--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.27.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
|||||||
|
--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.26.2'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
--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.28.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocodio_geocode_street_point_exception_safe (searchtext text ,city text DEFAULT NULL ,state_province text DEFAULT NULL ,country text DEFAULT NULL)
|
||||||
|
RETURNS public.Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret public.Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
_returned_sqlstate TEXT;
|
||||||
|
_message_text TEXT;
|
||||||
|
_pg_exception_context TEXT;
|
||||||
|
apikey_permissions json;
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN
|
||||||
|
RAISE EXCEPTION 'Geocoding permission denied';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 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;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
SELECT cdb_dataservices_client._cdb_geocodio_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
|
_message_text = MESSAGE_TEXT,
|
||||||
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
|
RETURN ret;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_geocodio_geocode_street_point (username text, orgname text, searchtext text, city text, state_province text, country text);
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocodio_geocode_street_point (username text, orgname 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_geocodio_geocode_street_point (username, orgname, searchtext, city, state_province, country);
|
||||||
|
|
||||||
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_geocodio_geocode_street_point (searchtext text ,city text ,state_province text ,country text);
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocodio_geocode_street_point (searchtext text ,city text DEFAULT NULL ,state_province text DEFAULT NULL ,country text DEFAULT NULL)
|
||||||
|
RETURNS public.Geometry AS $$
|
||||||
|
DECLARE
|
||||||
|
ret public.Geometry;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
apikey_permissions json;
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN
|
||||||
|
RAISE EXCEPTION 'Geocoding permission denied' USING ERRCODE = '01007';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 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_geocodio_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_geocodio_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_geocodio_geocode_street_point_exception_safe(searchtext text, city text, state_province text, country text ) TO publicuser;
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
|||||||
|
--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.27.0'" to load this file. \quit
|
||||||
|
|
||||||
|
-- Make sure we have a sane search path to create/update the extension
|
||||||
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
||||||
|
|
||||||
|
-- HERE goes your code to upgrade/downgrade
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_geocodio_geocode_street_point_exception_safe;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client._cdb_geocodio_geocode_street_point;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS cdb_dataservices_client.cdb_geocodio_geocode_street_point;
|
||||||
File diff suppressed because it is too large
Load Diff
+363
-44
@@ -1,65 +1,126 @@
|
|||||||
---
|
---
|
||||||
- name: cdb_geocode_admin0_polygon
|
- name: cdb_geocode_admin0_polygon
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: country_name, type: text }
|
- { name: country_name, type: text }
|
||||||
|
|
||||||
- name: cdb_geocode_admin1_polygon
|
- name: cdb_geocode_admin1_polygon
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: admin1_name, type: text }
|
- { name: admin1_name, type: text }
|
||||||
|
|
||||||
- name: cdb_geocode_admin1_polygon
|
- name: cdb_geocode_admin1_polygon
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: admin1_name, type: text }
|
- { name: admin1_name, type: text }
|
||||||
- { name: country_name, type: text }
|
- { name: country_name, type: text }
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
- name: cdb_geocode_namedplace_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: city_name, type: text}
|
- { name: city_name, type: text}
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
- name: cdb_geocode_namedplace_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: city_name, type: text}
|
- { name: city_name, type: text}
|
||||||
- { name: country_name, type: text}
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
- name: cdb_geocode_namedplace_point
|
- name: cdb_geocode_namedplace_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: city_name, type: text}
|
- { name: city_name, type: text}
|
||||||
- { name: admin1_name, type: text}
|
- { name: admin1_name, type: text}
|
||||||
- { name: country_name, type: text}
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
- name: cdb_geocode_postalcode_polygon
|
- name: cdb_geocode_postalcode_polygon
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
|
params:
|
||||||
|
- { name: postal_code, type: text}
|
||||||
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_postalcode_polygon
|
||||||
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
|
params:
|
||||||
|
- { name: postal_code, type: double precision}
|
||||||
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
|
- name: cdb_geocode_postalcode_point
|
||||||
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: postal_code, type: text}
|
- { name: postal_code, type: text}
|
||||||
- { name: country_name, type: text}
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
- name: cdb_geocode_postalcode_point
|
- name: cdb_geocode_postalcode_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: postal_code, type: text}
|
- { name: postal_code, type: double precision}
|
||||||
- { name: country_name, type: text}
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
- name: cdb_geocode_ipaddress_point
|
- name: cdb_geocode_ipaddress_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: ip_address, type: text}
|
- { name: ip_address, type: text}
|
||||||
|
|
||||||
- name: cdb_geocode_street_point
|
- name: cdb_geocode_street_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: searchtext, type: text}
|
- { name: searchtext, type: text}
|
||||||
- { name: city, type: text, default: 'NULL'}
|
- { name: city, type: text, default: 'NULL'}
|
||||||
- { name: state_province, type: text, default: 'NULL'}
|
- { name: state_province, type: text, default: 'NULL'}
|
||||||
- { name: country, type: text, default: 'NULL'}
|
- { name: country, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: _cdb_bulk_geocode_street_point
|
||||||
|
return_type: SETOF cdb_dataservices_client.geocoding
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
|
params:
|
||||||
|
- { name: searches, type: jsonb } # Array of JSON objects with id, address, city, state and country fields
|
||||||
|
|
||||||
- name: cdb_here_geocode_street_point
|
- name: cdb_here_geocode_street_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: searchtext, type: text}
|
- { name: searchtext, type: text}
|
||||||
- { name: city, type: text, default: 'NULL'}
|
- { name: city, type: text, default: 'NULL'}
|
||||||
@@ -67,7 +128,43 @@
|
|||||||
- { name: country, type: text, default: 'NULL'}
|
- { name: country, type: text, default: 'NULL'}
|
||||||
|
|
||||||
- name: cdb_google_geocode_street_point
|
- name: cdb_google_geocode_street_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
|
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_mapbox_geocode_street_point
|
||||||
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
|
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_tomtom_geocode_street_point
|
||||||
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
|
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_geocodio_geocode_street_point
|
||||||
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: searchtext, type: text}
|
- { name: searchtext, type: text}
|
||||||
- { name: city, type: text, default: 'NULL'}
|
- { name: city, type: text, default: 'NULL'}
|
||||||
@@ -75,7 +172,10 @@
|
|||||||
- { name: country, type: text, default: 'NULL'}
|
- { name: country, type: text, default: 'NULL'}
|
||||||
|
|
||||||
- name: cdb_mapzen_geocode_street_point
|
- name: cdb_mapzen_geocode_street_point
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: geocoding
|
||||||
|
permission_error: Geocoding permission denied
|
||||||
params:
|
params:
|
||||||
- { name: searchtext, type: text}
|
- { name: searchtext, type: text}
|
||||||
- { name: city, type: text, default: 'NULL'}
|
- { name: city, type: text, default: 'NULL'}
|
||||||
@@ -86,8 +186,11 @@
|
|||||||
return_type: SETOF cdb_dataservices_client.isoline
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
params:
|
params:
|
||||||
- { name: source, type: "geometry(Geometry, 4326)" }
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: mode, type: text }
|
- { name: mode, type: text }
|
||||||
- { name: range, type: "integer[]" }
|
- { name: range, type: "integer[]" }
|
||||||
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
@@ -96,8 +199,37 @@
|
|||||||
return_type: SETOF cdb_dataservices_client.isoline
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
params:
|
params:
|
||||||
- { name: source, type: "geometry(Geometry, 4326)" }
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_mapbox_isochrone
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
|
params:
|
||||||
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_tomtom_isochrone
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
|
params:
|
||||||
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: mode, type: text }
|
- { name: mode, type: text }
|
||||||
- { name: range, type: "integer[]" }
|
- { name: range, type: "integer[]" }
|
||||||
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
@@ -106,8 +238,37 @@
|
|||||||
return_type: SETOF cdb_dataservices_client.isoline
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
params:
|
params:
|
||||||
- { name: source, type: "geometry(Geometry, 4326)" }
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_mapbox_isodistance
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
|
params:
|
||||||
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
|
- { name: mode, type: text }
|
||||||
|
- { name: range, type: "integer[]" }
|
||||||
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
|
|
||||||
|
- name: cdb_tomtom_isodistance
|
||||||
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
|
params:
|
||||||
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: mode, type: text }
|
- { name: mode, type: text }
|
||||||
- { name: range, type: "integer[]" }
|
- { name: range, type: "integer[]" }
|
||||||
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
@@ -116,8 +277,11 @@
|
|||||||
return_type: SETOF cdb_dataservices_client.isoline
|
return_type: SETOF cdb_dataservices_client.isoline
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: isolines
|
||||||
|
permission_error: Isolines permission denied
|
||||||
params:
|
params:
|
||||||
- { name: source, type: "geometry(Geometry, 4326)" }
|
- { name: source, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: mode, type: text }
|
- { name: mode, type: text }
|
||||||
- { name: range, type: "integer[]" }
|
- { name: range, type: "integer[]" }
|
||||||
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
@@ -125,9 +289,12 @@
|
|||||||
- name: cdb_route_point_to_point
|
- name: cdb_route_point_to_point
|
||||||
return_type: cdb_dataservices_client.simple_route
|
return_type: cdb_dataservices_client.simple_route
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: routing
|
||||||
|
permission_error: Routing permission denied
|
||||||
params:
|
params:
|
||||||
- { name: origin, type: "geometry(Point, 4326)" }
|
- { name: origin, type: "public.geometry(Point, 4326)" }
|
||||||
- { name: destination, type: "geometry(Point, 4326)" }
|
- { name: destination, type: "public.geometry(Point, 4326)" }
|
||||||
- { name: mode, type: text }
|
- { name: mode, type: text }
|
||||||
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
- { name: units, type: "text", default: "'kilometers'"}
|
- { name: units, type: "text", default: "'kilometers'"}
|
||||||
@@ -135,56 +302,80 @@
|
|||||||
- name: cdb_route_with_waypoints
|
- name: cdb_route_with_waypoints
|
||||||
return_type: cdb_dataservices_client.simple_route
|
return_type: cdb_dataservices_client.simple_route
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: routing
|
||||||
|
permission_error: Routing permission denied
|
||||||
params:
|
params:
|
||||||
- { name: waypoints, type: "geometry(Point, 4326)[]" }
|
- { name: waypoints, type: "public.geometry(Point, 4326)[]" }
|
||||||
- { name: mode, type: text }
|
- { name: mode, type: text }
|
||||||
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
- { name: options, type: "text[]", default: 'ARRAY[]::text[]' }
|
||||||
- { name: units, type: "text", default: "'kilometers'"}
|
- { name: units, type: "text", default: "'kilometers'"}
|
||||||
|
|
||||||
- name: obs_get_demographic_snapshot
|
- name: obs_get_demographic_snapshot
|
||||||
return_type: json
|
return_type: json
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: time_span, type: "text", default: "'2009 - 2013'::text" }
|
- { name: time_span, type: "text", default: "'2009 - 2013'::text" }
|
||||||
- { name: geometry_level, type: text, default: 'NULL' }
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
- name: obs_get_segment_snapshot
|
- name: obs_get_segment_snapshot
|
||||||
return_type: json
|
return_type: json
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: geometry_level, type: text, default: 'NULL' }
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
- name: obs_getdemographicsnapshot
|
- name: obs_getdemographicsnapshot
|
||||||
return_type: SETOF JSON
|
return_type: SETOF JSON
|
||||||
multi_row: true
|
multi_row: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: time_span, type: "text", default: 'NULL' }
|
- { name: time_span, type: "text", default: 'NULL' }
|
||||||
- { name: geometry_level, type: text, default: 'NULL' }
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
- name: obs_getsegmentsnapshot
|
- name: obs_getsegmentsnapshot
|
||||||
return_type: SETOF JSON
|
return_type: SETOF JSON
|
||||||
multi_row: true
|
multi_row: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: geometry_level, type: text, default: 'NULL' }
|
- { name: geometry_level, type: text, default: 'NULL' }
|
||||||
|
|
||||||
- name: obs_getboundary
|
- name: obs_getboundary
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
- name: obs_getboundaryid
|
- name: obs_getboundaryid
|
||||||
return_type: text
|
return_type: text
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
- name: obs_getboundarybyid
|
- name: obs_getboundarybyid
|
||||||
return_type: Geometry
|
return_type: public.Geometry
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geometry_id, type: text }
|
- { name: geometry_id, type: text }
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
@@ -194,11 +385,14 @@
|
|||||||
return_type: TABLE(the_geom geometry, geom_refs text)
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: the_geom, type: geometry }
|
- { name: the_geom, type: geometry }
|
||||||
- { name: geom_refs, type: text }
|
- { name: geom_refs, type: text }
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
- { name: overlap_type, type: text, default: 'NULL'}
|
- { name: overlap_type, type: text, default: 'NULL'}
|
||||||
@@ -207,11 +401,14 @@
|
|||||||
return_type: TABLE(the_geom geometry, geom_refs text)
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: the_geom, type: geometry }
|
- { name: the_geom, type: geometry }
|
||||||
- { name: geom_refs, type: text }
|
- { name: geom_refs, type: text }
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: radius, type: numeric }
|
- { name: radius, type: numeric }
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
@@ -221,11 +418,14 @@
|
|||||||
return_type: TABLE(the_geom geometry, geom_refs text)
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: the_geom, type: geometry }
|
- { name: the_geom, type: geometry }
|
||||||
- { name: geom_refs, type: text }
|
- { name: geom_refs, type: text }
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
- { name: overlap_type, type: text, default: 'NULL'}
|
- { name: overlap_type, type: text, default: 'NULL'}
|
||||||
@@ -234,11 +434,14 @@
|
|||||||
return_type: TABLE(the_geom geometry, geom_refs text)
|
return_type: TABLE(the_geom geometry, geom_refs text)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: the_geom, type: geometry }
|
- { name: the_geom, type: geometry }
|
||||||
- { name: geom_refs, type: text }
|
- { name: geom_refs, type: text }
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: "geometry(Geometry, 4326)" }
|
- { name: geom, type: "public.geometry(Geometry, 4326)" }
|
||||||
- { name: radius, type: numeric }
|
- { name: radius, type: numeric }
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
@@ -246,8 +449,11 @@
|
|||||||
|
|
||||||
- name: obs_getmeasure
|
- name: obs_getmeasure
|
||||||
return_type: numeric
|
return_type: numeric
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: Geometry }
|
- { name: geom, type: public.Geometry }
|
||||||
- { name: measure_id, type: text }
|
- { name: measure_id, type: text }
|
||||||
- { name: normalize, type: text, default: 'NULL'}
|
- { name: normalize, type: text, default: 'NULL'}
|
||||||
- { name: boundary_id, type: text, default: 'NULL' }
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
@@ -255,6 +461,9 @@
|
|||||||
|
|
||||||
- name: obs_getmeasurebyid
|
- name: obs_getmeasurebyid
|
||||||
return_type: numeric
|
return_type: numeric
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom_ref, type: text }
|
- { name: geom_ref, type: text }
|
||||||
- { name: measure_id, type: text }
|
- { name: measure_id, type: text }
|
||||||
@@ -265,6 +474,9 @@
|
|||||||
return_type: TABLE(id int, data json)
|
return_type: TABLE(id int, data json)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: id, type: integer }
|
- { name: id, type: integer }
|
||||||
- { name: data, type: json }
|
- { name: data, type: json }
|
||||||
@@ -277,6 +489,9 @@
|
|||||||
return_type: TABLE(id text, data json)
|
return_type: TABLE(id text, data json)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: id, type: text }
|
- { name: id, type: text }
|
||||||
- { name: data, type: json }
|
- { name: data, type: json }
|
||||||
@@ -286,25 +501,47 @@
|
|||||||
|
|
||||||
- name: obs_getmeta
|
- name: obs_getmeta
|
||||||
return_type: json
|
return_type: json
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom_ref, type: "Geometry(Geometry, 4326)" }
|
- { name: geom_ref, type: "public.Geometry(Geometry, 4326)" }
|
||||||
- { name: params, type: json }
|
- { name: params, type: json }
|
||||||
- { name: max_timespan_rank, type: integer, default: 'NULL' }
|
- { name: max_timespan_rank, type: integer, default: 'NULL' }
|
||||||
- { name: max_score_rank, type: integer, default: 'NULL' }
|
- { name: max_score_rank, type: integer, default: 'NULL' }
|
||||||
- { name: target_geoms, type: integer, default: 'NULL' }
|
- { name: target_geoms, type: integer, default: 'NULL' }
|
||||||
|
|
||||||
|
- name: obs_metadatavalidation
|
||||||
|
return_type: TABLE(valid boolean, errors text[])
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
|
params:
|
||||||
|
- { name: geom_extent, type: "public.Geometry(Geometry, 4326)" }
|
||||||
|
- { name: geom_type, type: text }
|
||||||
|
- { name: params, type: json }
|
||||||
|
- { name: target_geoms, type: integer, default: 'NULL' }
|
||||||
|
|
||||||
- name: obs_getcategory
|
- name: obs_getcategory
|
||||||
return_type: text
|
return_type: text
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: Geometry }
|
- { name: geom, type: public.Geometry }
|
||||||
- { name: category_id, type: text }
|
- { name: category_id, type: text }
|
||||||
- { name: boundary_id, type: text, default: 'NULL' }
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
- name: obs_getuscensusmeasure
|
- name: obs_getuscensusmeasure
|
||||||
return_type: numeric
|
return_type: numeric
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: Geometry }
|
- { name: geom, type: public.Geometry }
|
||||||
- { name: name, type: text }
|
- { name: name, type: text }
|
||||||
- { name: normalize, type: text, default: 'NULL'}
|
- { name: normalize, type: text, default: 'NULL'}
|
||||||
- { name: boundary_id, type: text, default: 'NULL' }
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
@@ -312,16 +549,22 @@
|
|||||||
|
|
||||||
- name: obs_getuscensuscategory
|
- name: obs_getuscensuscategory
|
||||||
return_type: text
|
return_type: text
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: Geometry }
|
- { name: geom, type: public.Geometry }
|
||||||
- { name: name, type: text }
|
- { name: name, type: text }
|
||||||
- { name: boundary_id, type: text, default: 'NULL' }
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
|
|
||||||
- name: obs_getpopulation
|
- name: obs_getpopulation
|
||||||
return_type: numeric
|
return_type: numeric
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: Geometry }
|
- { name: geom, type: public.Geometry }
|
||||||
- { name: normalize, type: text, default: 'NULL'}
|
- { name: normalize, type: text, default: 'NULL'}
|
||||||
- { name: boundary_id, type: text, default: 'NULL' }
|
- { name: boundary_id, type: text, default: 'NULL' }
|
||||||
- { name: time_span, type: text, default: 'NULL'}
|
- { name: time_span, type: text, default: 'NULL'}
|
||||||
@@ -330,6 +573,9 @@
|
|||||||
return_type: TABLE(id text, description text, name text, aggregate text, source text)
|
return_type: TABLE(id text, description text, name text, aggregate text, source text)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: id, type: text }
|
- { name: id, type: text }
|
||||||
- { name: description, type: text }
|
- { name: description, type: text }
|
||||||
@@ -344,17 +590,23 @@
|
|||||||
return_type: TABLE(boundary_id text, description text, time_span text, tablename text)
|
return_type: TABLE(boundary_id text, description text, time_span text, tablename text)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
table_fields:
|
table_fields:
|
||||||
- { name: boundary_id, type: text }
|
- { name: boundary_id, type: text }
|
||||||
- { name: description, type: text }
|
- { name: description, type: text }
|
||||||
- { name: time_span, type: text }
|
- { name: time_span, type: text }
|
||||||
- { name: tablename, type: text }
|
- { name: tablename, type: text }
|
||||||
params:
|
params:
|
||||||
- { name: geom, type: Geometry }
|
- { name: geom, type: public.Geometry }
|
||||||
- { name: timespan, type: text, default: 'NULL'}
|
- { name: timespan, type: text, default: 'NULL'}
|
||||||
|
|
||||||
- name: obs_dumpversion
|
- name: obs_dumpversion
|
||||||
return_type: text
|
return_type: text
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- {}
|
- {}
|
||||||
|
|
||||||
@@ -362,19 +614,43 @@
|
|||||||
return_type: SETOF cdb_dataservices_client.obs_meta_numerator
|
return_type: SETOF cdb_dataservices_client.obs_meta_numerator
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: bounds, type: "geometry(Geometry, 4326)", default: 'NULL' }
|
- { name: bounds, type: "public.geometry(Geometry, 4326)", default: 'NULL' }
|
||||||
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
||||||
- { name: denom_id, type: text, default: 'NULL' }
|
- { name: denom_id, type: text, default: 'NULL' }
|
||||||
- { name: geom_id, type: text, default: 'NULL' }
|
- { name: geom_id, type: text, default: 'NULL' }
|
||||||
- { name: timespan, type: text, default: 'NULL'}
|
- { name: timespan, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: _obs_getnumerators
|
||||||
|
return_type: SETOF cdb_dataservices_client.obs_meta_numerator
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
|
params:
|
||||||
|
- { name: bounds, type: "public.geometry(Geometry, 4326)", default: 'NULL' }
|
||||||
|
- { name: section_tags, type: "text[]", default: 'ARRAY[]::TEXT[]' }
|
||||||
|
- { name: subsection_tags, type: "text[]", default: 'ARRAY[]::TEXT[]' }
|
||||||
|
- { name: other_tags, type: "text[]", default: 'ARRAY[]::TEXT[]' }
|
||||||
|
- { name: ids, type: "text[]", default: 'ARRAY[]::TEXT[]' }
|
||||||
|
- { name: name, type: text, default: 'NULL' }
|
||||||
|
- { name: denom_id, type: text, default: "''" }
|
||||||
|
- { name: geom_id, type: text, default: "''" }
|
||||||
|
- { name: timespan, type: text, default: "''"}
|
||||||
|
|
||||||
- name: obs_getavailabledenominators
|
- name: obs_getavailabledenominators
|
||||||
return_type: SETOF cdb_dataservices_client.obs_meta_denominator
|
return_type: SETOF cdb_dataservices_client.obs_meta_denominator
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: bounds, type: "geometry(Geometry, 4326)", default: 'NULL' }
|
- { name: bounds, type: "public.geometry(Geometry, 4326)", default: 'NULL' }
|
||||||
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
||||||
- { name: numer_id, type: text, default: 'NULL' }
|
- { name: numer_id, type: text, default: 'NULL' }
|
||||||
- { name: geom_id, type: text, default: 'NULL' }
|
- { name: geom_id, type: text, default: 'NULL' }
|
||||||
@@ -384,19 +660,26 @@
|
|||||||
return_type: SETOF cdb_dataservices_client.obs_meta_geometry
|
return_type: SETOF cdb_dataservices_client.obs_meta_geometry
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: bounds, type: "geometry(Geometry, 4326)", default: 'NULL' }
|
- { name: bounds, type: "public.geometry(Geometry, 4326)", default: 'NULL' }
|
||||||
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
||||||
- { name: numer_id, type: text, default: 'NULL' }
|
- { name: numer_id, type: text, default: 'NULL' }
|
||||||
- { name: denom_id, type: text, default: 'NULL' }
|
- { name: denom_id, type: text, default: 'NULL' }
|
||||||
- { name: timespan, type: text, default: 'NULL'}
|
- { name: timespan, type: text, default: 'NULL'}
|
||||||
|
- { name: number_geometries, type: integer, default: 'NULL'}
|
||||||
|
|
||||||
- name: obs_getavailabletimespans
|
- name: obs_getavailabletimespans
|
||||||
return_type: SETOF cdb_dataservices_client.obs_meta_timespan
|
return_type: SETOF cdb_dataservices_client.obs_meta_timespan
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: bounds, type: "geometry(Geometry, 4326)", default: 'NULL' }
|
- { name: bounds, type: "public.geometry(Geometry, 4326)", default: 'NULL' }
|
||||||
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
- { name: filter_tags, type: "text[]", default: 'NULL' }
|
||||||
- { name: numer_id, type: text, default: 'NULL' }
|
- { name: numer_id, type: text, default: 'NULL' }
|
||||||
- { name: denom_id, type: text, default: 'NULL' }
|
- { name: denom_id, type: text, default: 'NULL' }
|
||||||
@@ -406,6 +689,9 @@
|
|||||||
return_type: TABLE(name text, subsection json)
|
return_type: TABLE(name text, subsection json)
|
||||||
multi_row: true
|
multi_row: true
|
||||||
multi_field: true
|
multi_field: true
|
||||||
|
requires_permission: true
|
||||||
|
permission_name: observatory
|
||||||
|
permission_error: Data Observatory permission denied
|
||||||
params:
|
params:
|
||||||
- { name: aggregate_type, type: text, default: 'NULL' }
|
- { name: aggregate_type, type: text, default: 'NULL' }
|
||||||
|
|
||||||
@@ -416,8 +702,41 @@
|
|||||||
params:
|
params:
|
||||||
- {}
|
- {}
|
||||||
|
|
||||||
|
- name: cdb_service_quota_info_batch
|
||||||
|
return_type: SETOF service_quota_info_batch
|
||||||
|
multi_row: true
|
||||||
|
multi_field: true
|
||||||
|
params:
|
||||||
|
- {}
|
||||||
|
|
||||||
- name: cdb_enough_quota
|
- name: cdb_enough_quota
|
||||||
return_type: BOOLEAN
|
return_type: BOOLEAN
|
||||||
params:
|
params:
|
||||||
- { name: service, type: TEXT }
|
- { name: service, type: TEXT }
|
||||||
- { name: input_size, type: NUMERIC }
|
- { name: input_size, type: NUMERIC }
|
||||||
|
|
||||||
|
- name: cdb_service_get_rate_limit
|
||||||
|
return_type: json
|
||||||
|
params:
|
||||||
|
- { name: service, type: "text" }
|
||||||
|
|
||||||
|
- name: cdb_service_set_user_rate_limit
|
||||||
|
superuser: true
|
||||||
|
return_type: void
|
||||||
|
params:
|
||||||
|
- { name: service, type: "text" }
|
||||||
|
- { name: rate_limit, type: json }
|
||||||
|
|
||||||
|
- name: cdb_service_set_org_rate_limit
|
||||||
|
superuser: true
|
||||||
|
return_type: void
|
||||||
|
params:
|
||||||
|
- { name: service, type: "text" }
|
||||||
|
- { name: rate_limit, type: json }
|
||||||
|
|
||||||
|
- name: cdb_service_set_server_rate_limit
|
||||||
|
superuser: true
|
||||||
|
return_type: void
|
||||||
|
params:
|
||||||
|
- { name: service, type: "text" }
|
||||||
|
- { name: rate_limit, type: json }
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class SqlTemplateRenderer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render
|
def render
|
||||||
ERB.new(@template).result(binding)
|
ERB.new(@template, _save_level=nil, _trim_mode='-').result(binding)
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
@@ -28,6 +28,18 @@ class SqlTemplateRenderer
|
|||||||
@function_signature['return_type']
|
@function_signature['return_type']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def requires_permission
|
||||||
|
@function_signature['requires_permission']
|
||||||
|
end
|
||||||
|
|
||||||
|
def permission_name
|
||||||
|
@function_signature['permission_name']
|
||||||
|
end
|
||||||
|
|
||||||
|
def permission_error
|
||||||
|
@function_signature['permission_error']
|
||||||
|
end
|
||||||
|
|
||||||
def multi_field
|
def multi_field
|
||||||
@function_signature['multi_field']
|
@function_signature['multi_field']
|
||||||
end
|
end
|
||||||
@@ -44,16 +56,29 @@ class SqlTemplateRenderer
|
|||||||
@function_signature['geocoder_config_key']
|
@function_signature['geocoder_config_key']
|
||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def parameters_info(with_user_org)
|
||||||
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']}"}
|
parameters = []
|
||||||
|
if with_user_org
|
||||||
|
parameters << { 'name' => 'username', 'type' => 'text' }
|
||||||
|
parameters << { 'name' => 'orgname', 'type' => 'text' }
|
||||||
|
end
|
||||||
|
parameters + @function_signature['params'].reject(&:empty?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type
|
def user_org_declaration()
|
||||||
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']} #{p['type']}" }
|
"username text;\n orgname text;" unless superuser_function?
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type_and_default
|
def params(with_user_org = superuser_function?)
|
||||||
parameters = @function_signature['params'].reject(&:empty?).map do |p|
|
parameters_info(with_user_org).map { |p| p['name'].to_s }
|
||||||
|
end
|
||||||
|
|
||||||
|
def params_with_type(with_user_org = superuser_function?)
|
||||||
|
parameters_info(with_user_org).map { |p| "#{p['name']} #{p['type']}" }
|
||||||
|
end
|
||||||
|
|
||||||
|
def params_with_type_and_default(with_user_org = superuser_function?)
|
||||||
|
parameters = parameters_info(with_user_org).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
|
||||||
@@ -62,6 +87,49 @@ class SqlTemplateRenderer
|
|||||||
end
|
end
|
||||||
return parameters
|
return parameters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def superuser_function?
|
||||||
|
!!@function_signature['superuser']
|
||||||
|
end
|
||||||
|
|
||||||
|
def void_return_type?
|
||||||
|
return_type.downcase == 'void'
|
||||||
|
end
|
||||||
|
|
||||||
|
def return_declaration
|
||||||
|
"ret #{return_type};" unless void_return_type? || multi_row
|
||||||
|
end
|
||||||
|
|
||||||
|
def return_statement(&block)
|
||||||
|
if block
|
||||||
|
erb_out = block.binding.eval('_erbout')
|
||||||
|
|
||||||
|
if multi_row
|
||||||
|
erb_out << 'RETURN QUERY SELECT * FROM '
|
||||||
|
elsif multi_field
|
||||||
|
erb_out << 'SELECT * FROM '
|
||||||
|
elsif void_return_type?
|
||||||
|
erb_out << 'PERFORM '
|
||||||
|
else
|
||||||
|
erb_out << 'SELECT '
|
||||||
|
end
|
||||||
|
yield
|
||||||
|
if multi_row || void_return_type?
|
||||||
|
erb_out << ';'
|
||||||
|
else
|
||||||
|
erb_out << ' INTO ret;'
|
||||||
|
end
|
||||||
|
if !multi_row && !void_return_type?
|
||||||
|
erb_out << ' RETURN ret;'
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if !multi_row && !void_return_type?
|
||||||
|
' RETURN ret;'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,27 +7,24 @@
|
|||||||
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default.join(' ,') %>)
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default.join(' ,') %>)
|
||||||
RETURNS <%= return_type %> AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
<% if not multi_row %>ret <%= return_type %>;<% end %>
|
<%= return_declaration if not multi_row %>
|
||||||
username text;
|
<%= user_org_declaration %>
|
||||||
orgname text;
|
<% unless superuser_function? -%>apikey_permissions json;<% end %>
|
||||||
BEGIN
|
BEGIN
|
||||||
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
<% unless requires_permission %>IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
RAISE EXCEPTION 'The api_key must be provided';
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
END IF;
|
END IF;<% end %>
|
||||||
SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text);
|
<% unless superuser_function? -%>SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
<% if requires_permission %>IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? '<%= permission_name %>' THEN
|
||||||
|
RAISE EXCEPTION '<%= permission_error %>' USING ERRCODE = '01007';
|
||||||
|
END IF;<% end %>
|
||||||
|
<% else %>SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text, p json);<% end %>
|
||||||
-- JSON value stored "" is taken as literal
|
-- JSON value stored "" is taken as literal
|
||||||
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;
|
||||||
<% if multi_row %>
|
|
||||||
RETURN QUERY
|
<% return_statement do %><%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= params(_with_user_org=true).join(', ') %>)<% end %>
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>);
|
|
||||||
<% elsif multi_field %>
|
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
<% else %>
|
|
||||||
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
<% end %>
|
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
|
|||||||
@@ -5,57 +5,37 @@
|
|||||||
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>_exception_safe (<%= params_with_type_and_default.join(' ,') %>)
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>_exception_safe (<%= params_with_type_and_default.join(' ,') %>)
|
||||||
RETURNS <%= return_type %> AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
<% if not multi_row %>ret <%= return_type %>;<% end %>
|
<%= return_declaration %>
|
||||||
username text;
|
<%= user_org_declaration %>
|
||||||
orgname text;
|
|
||||||
_returned_sqlstate TEXT;
|
_returned_sqlstate TEXT;
|
||||||
_message_text TEXT;
|
_message_text TEXT;
|
||||||
_pg_exception_context TEXT;
|
_pg_exception_context TEXT;
|
||||||
|
<% unless superuser_function? -%>apikey_permissions json;<% end %>
|
||||||
BEGIN
|
BEGIN
|
||||||
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
<% unless requires_permission %>IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
RAISE EXCEPTION 'The api_key must be provided';
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
END IF;
|
END IF;<% end %>
|
||||||
SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text);
|
<% unless superuser_function? -%>SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
<% if requires_permission %>IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? '<%= permission_name %>' THEN
|
||||||
|
RAISE EXCEPTION '<%= permission_error %>';
|
||||||
|
END IF;<% end %>
|
||||||
|
<% else %>SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text, p json);<% end %>
|
||||||
-- JSON value stored "" is taken as literal
|
-- JSON value stored "" is taken as literal
|
||||||
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;
|
||||||
|
|
||||||
<% if multi_row %>
|
|
||||||
BEGIN
|
BEGIN
|
||||||
RETURN QUERY
|
<% return_statement do %><%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= params(_with_user_org=true).join(', ') %>)<% end %>
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>);
|
EXCEPTION
|
||||||
EXCEPTION
|
WHEN OTHERS THEN
|
||||||
WHEN OTHERS THEN
|
|
||||||
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
||||||
_message_text = MESSAGE_TEXT,
|
_message_text = MESSAGE_TEXT,
|
||||||
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
||||||
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
||||||
END;
|
<%= return_statement %>
|
||||||
<% elsif multi_field %>
|
END;
|
||||||
BEGIN
|
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
EXCEPTION
|
|
||||||
WHEN OTHERS THEN
|
|
||||||
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
|
||||||
_message_text = MESSAGE_TEXT,
|
|
||||||
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
|
||||||
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
<% else %>
|
|
||||||
BEGIN
|
|
||||||
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
EXCEPTION
|
|
||||||
WHEN OTHERS THEN
|
|
||||||
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
|
||||||
_message_text = MESSAGE_TEXT,
|
|
||||||
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
|
||||||
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
<% end %>
|
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (<%= ['username text', 'organization_name text'].concat(params_with_type_and_default).join(', ') %>)
|
DROP FUNCTION IF EXISTS <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (<%= params_with_type(true).join(', ') %>);
|
||||||
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (<%= params_with_type_and_default(_with_user_org=true).join(', ') %>)
|
||||||
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 %>
|
<% if multi_field %>
|
||||||
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (<%= ['username', 'organization_name'].concat(params).join(', ') %>);
|
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (<%= params(_with_user_org=true).join(', ') %>);
|
||||||
<% else %>
|
<% else %>
|
||||||
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (<%= ['username', 'organization_name'].concat(params).join(', ') %>);
|
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (<%= params(_with_user_org=true).join(', ') %>);
|
||||||
<% end %>
|
<% end %>
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
|
<% unless superuser_function? %>
|
||||||
GRANT EXECUTE ON FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %>(<%= params_with_type.join(', ') %>) TO publicuser;
|
GRANT EXECUTE ON FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %>(<%= params_with_type.join(', ') %>) TO publicuser;
|
||||||
GRANT EXECUTE ON FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>_exception_safe(<%= params_with_type.join(', ') %>) TO publicuser;
|
GRANT EXECUTE ON FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>_exception_safe(<%= params_with_type.join(', ') %> ) TO publicuser;
|
||||||
|
<% end %>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
-- Taken from https://wiki.postgresql.org/wiki/Count_estimate
|
||||||
|
CREATE FUNCTION cdb_dataservices_client.cdb_count_estimate(query text) RETURNS INTEGER AS
|
||||||
|
$func$
|
||||||
|
DECLARE
|
||||||
|
rec record;
|
||||||
|
ROWS INTEGER;
|
||||||
|
BEGIN
|
||||||
|
FOR rec IN EXECUTE 'EXPLAIN ' || query LOOP
|
||||||
|
ROWS := SUBSTRING(rec."QUERY PLAN" FROM ' rows=([[:digit:]]+)');
|
||||||
|
EXIT WHEN ROWS IS NOT NULL;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RETURN ROWS;
|
||||||
|
END
|
||||||
|
$func$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
-- Taken from https://stackoverflow.com/a/48013356/351721
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_jsonb_array_casttext(jsonb) RETURNS text[] AS $f$
|
||||||
|
SELECT array_agg(x) || ARRAY[]::text[] FROM jsonb_array_elements_text($1) t(x);
|
||||||
|
$f$ LANGUAGE sql IMMUTABLE;
|
||||||
|
|
||||||
|
|
||||||
|
-- PG12_DEPRECATED
|
||||||
|
-- Create geomval if it doesn't exist (in postgis 3+ it only exists in postgis_raster)
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'geomval') THEN
|
||||||
|
CREATE TYPE cdb_dataservices_client.geomval AS (
|
||||||
|
geom geometry,
|
||||||
|
val double precision
|
||||||
|
);
|
||||||
|
END IF;
|
||||||
|
END$$;
|
||||||
@@ -13,4 +13,4 @@ BEGIN
|
|||||||
SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str;
|
SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str;
|
||||||
RETURN db_connection_str;
|
RETURN db_connection_str;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql' STABLE PARALLEL SAFE;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
CREATE TYPE cdb_dataservices_client._entity_config AS (
|
CREATE TYPE cdb_dataservices_client._entity_config AS (
|
||||||
username text,
|
username text,
|
||||||
organization_name text
|
organization_name text,
|
||||||
|
apikey_permissions json
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -13,25 +14,23 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_entity_config()
|
|||||||
RETURNS record AS $$
|
RETURNS record AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
result cdb_dataservices_client._entity_config;
|
result cdb_dataservices_client._entity_config;
|
||||||
|
apikey_config json;
|
||||||
is_organization boolean;
|
is_organization boolean;
|
||||||
username text;
|
organization_name text DEFAULT NULL;
|
||||||
organization_name text;
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
SELECT cartodb.cdb_conf_getconf('api_keys_'||session_user) INTO apikey_config;
|
||||||
|
|
||||||
SELECT cartodb.cdb_conf_getconf('user_config')->'is_organization' INTO is_organization;
|
SELECT cartodb.cdb_conf_getconf('user_config')->'is_organization' INTO is_organization;
|
||||||
IF is_organization IS NULL THEN
|
IF is_organization IS NULL THEN
|
||||||
RAISE EXCEPTION 'User must have user configuration in the config table';
|
RAISE EXCEPTION 'User must have user configuration in the config table';
|
||||||
ELSIF is_organization = TRUE THEN
|
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;
|
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;
|
END IF;
|
||||||
result.username = username;
|
result.username = apikey_config->>'username';
|
||||||
result.organization_name = organization_name;
|
result.organization_name = organization_name;
|
||||||
|
result.apikey_permissions = apikey_config->'permissions';
|
||||||
RETURN result;
|
RETURN result;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL SAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ CREATE TYPE cdb_dataservices_client.isoline AS (
|
|||||||
the_geom geometry(Multipolygon,4326)
|
the_geom geometry(Multipolygon,4326)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.geocoding AS (
|
||||||
|
cartodb_id integer,
|
||||||
|
the_geom geometry(Point,4326),
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
CREATE TYPE cdb_dataservices_client.simple_route AS (
|
CREATE TYPE cdb_dataservices_client.simple_route AS (
|
||||||
shape geometry(LineString,4326),
|
shape geometry(LineString,4326),
|
||||||
length real,
|
length real,
|
||||||
@@ -15,9 +21,9 @@ CREATE TYPE cdb_dataservices_client.obs_meta_numerator AS (numer_id text, numer_
|
|||||||
|
|
||||||
CREATE TYPE cdb_dataservices_client.obs_meta_denominator AS (denom_id text, denom_name text, denom_description text, denom_weight text, denom_license text, denom_source text, denom_type text, denom_aggregate text, denom_extra jsonb, denom_tags jsonb, valid_numer boolean, valid_geom boolean, valid_timespan boolean);
|
CREATE TYPE cdb_dataservices_client.obs_meta_denominator AS (denom_id text, denom_name text, denom_description text, denom_weight text, denom_license text, denom_source text, denom_type text, denom_aggregate text, denom_extra jsonb, denom_tags jsonb, valid_numer boolean, valid_geom boolean, valid_timespan boolean);
|
||||||
|
|
||||||
CREATE TYPE cdb_dataservices_client.obs_meta_geometry AS (geom_id text, geom_name text, geom_description text, geom_weight text, geom_aggregate text, geom_license text, geom_source text, valid_numer boolean, valid_denom boolean, valid_timespan boolean, score numeric, numtiles bigint, notnull_percent numeric, numgeoms numeric, percentfill numeric, estnumgeoms numeric, meanmediansize numeric);
|
CREATE TYPE cdb_dataservices_client.obs_meta_geometry AS (geom_id text, geom_name text, geom_description text, geom_weight text, geom_aggregate text, geom_license text, geom_source text, valid_numer boolean, valid_denom boolean, valid_timespan boolean, score numeric, numtiles bigint, notnull_percent numeric, numgeoms numeric, percentfill numeric, estnumgeoms numeric, meanmediansize numeric, geom_type text, geom_extra jsonb, geom_tags jsonb);
|
||||||
|
|
||||||
CREATE TYPE cdb_dataservices_client.obs_meta_timespan AS (timespan_id text, timespan_name text, timespan_description text, timespan_weight text, timespan_aggregate text, timespan_license text, timespan_source text, valid_numer boolean, valid_denom boolean, valid_geom boolean);
|
CREATE TYPE cdb_dataservices_client.obs_meta_timespan AS (timespan_id text, timespan_name text, timespan_description text, timespan_weight text, timespan_aggregate text, timespan_license text, timespan_source text, valid_numer boolean, valid_denom boolean, valid_geom boolean, timespan_type text, timespan_extra jsonb, timespan_tags jsonb);
|
||||||
|
|
||||||
|
|
||||||
-- For quotas and services configuration
|
-- For quotas and services configuration
|
||||||
@@ -35,3 +41,12 @@ CREATE TYPE cdb_dataservices_client.service_quota_info AS (
|
|||||||
soft_limit BOOLEAN,
|
soft_limit BOOLEAN,
|
||||||
provider TEXT
|
provider TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TYPE cdb_dataservices_client.service_quota_info_batch AS (
|
||||||
|
service cdb_dataservices_client.service_type,
|
||||||
|
monthly_quota NUMERIC,
|
||||||
|
used_quota NUMERIC,
|
||||||
|
soft_limit BOOLEAN,
|
||||||
|
provider TEXT,
|
||||||
|
max_batch_size NUMERIC
|
||||||
|
);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ BEGIN
|
|||||||
|
|
||||||
SELECT session_user INTO user_db_role;
|
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);
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
-- JSON value stored "" is taken as literal
|
-- JSON value stored "" is taken as literal
|
||||||
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';
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
@@ -41,7 +41,9 @@ BEGIN
|
|||||||
|
|
||||||
RETURN result;
|
RETURN result;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(
|
||||||
table_name text,
|
table_name text,
|
||||||
@@ -62,7 +64,7 @@ BEGIN
|
|||||||
|
|
||||||
SELECT session_user INTO user_db_role;
|
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);
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
-- JSON value stored "" is taken as literal
|
-- JSON value stored "" is taken as literal
|
||||||
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';
|
RAISE EXCEPTION 'Username is a mandatory argument';
|
||||||
@@ -89,7 +91,9 @@ BEGIN
|
|||||||
|
|
||||||
RETURN result;
|
RETURN result;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure(
|
||||||
@@ -124,7 +128,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeas
|
|||||||
|
|
||||||
# Create a new table with the required columns
|
# Create a new table with the required columns
|
||||||
plpy.execute('CREATE TABLE "{schema}".{table_name} ( '
|
plpy.execute('CREATE TABLE "{schema}".{table_name} ( '
|
||||||
'cartodb_id int, the_geom geometry, {columns_with_types} '
|
'cartodb_id int, the_geom public.geometry, {columns_with_types} '
|
||||||
');'
|
');'
|
||||||
.format(schema=user_schema, table_name=output_table_name, columns_with_types=columns_with_types)
|
.format(schema=user_schema, table_name=output_table_name, columns_with_types=columns_with_types)
|
||||||
)
|
)
|
||||||
@@ -134,7 +138,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeas
|
|||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE @@plpythonu@@ VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure(
|
||||||
username text,
|
username text,
|
||||||
@@ -200,7 +204,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMea
|
|||||||
'INSERT INTO "{schema}".{analysis_table_name} '
|
'INSERT INTO "{schema}".{analysis_table_name} '
|
||||||
'SELECT ut.cartodb_id, ut.the_geom, {colname_list} '
|
'SELECT ut.cartodb_id, ut.the_geom, {colname_list} '
|
||||||
'FROM "{schema}".{table_name} ut '
|
'FROM "{schema}".{table_name} ut '
|
||||||
'LEFT JOIN _DST_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, '
|
'LEFT JOIN cdb_dataservices_client._DST_FetchJoinFdwTableData({username}::text, {orgname}::text, {server_schema}::text, {server_table_name}::text, '
|
||||||
'{function_name}::text, {params}::json) '
|
'{function_name}::text, {params}::json) '
|
||||||
'AS result ({columns_with_types}, cartodb_id int) '
|
'AS result ({columns_with_types}, cartodb_id int) '
|
||||||
'ON result.cartodb_id = ut.cartodb_id;' .format(
|
'ON result.cartodb_id = ut.cartodb_id;' .format(
|
||||||
@@ -227,7 +231,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMea
|
|||||||
fdw_server=plpy.quote_literal(server_name)))
|
fdw_server=plpy.quote_literal(server_name)))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE @@plpythonu@@ VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_ConnectUserTable(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_ConnectUserTable(
|
||||||
username text,
|
username text,
|
||||||
@@ -239,7 +243,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_ConnectUserTable(
|
|||||||
)RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$
|
)RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$
|
||||||
CONNECT cdb_dataservices_client._server_conn_str();
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
TARGET cdb_dataservices_server._DST_ConnectUserTable;
|
TARGET cdb_dataservices_server._DST_ConnectUserTable;
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_GetReturnMetadata(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_GetReturnMetadata(
|
||||||
username text,
|
username text,
|
||||||
@@ -249,7 +253,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_GetReturnMetadata(
|
|||||||
) RETURNS cdb_dataservices_client.ds_return_metadata AS $$
|
) RETURNS cdb_dataservices_client.ds_return_metadata AS $$
|
||||||
CONNECT cdb_dataservices_client._server_conn_str();
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
TARGET cdb_dataservices_server._DST_GetReturnMetadata;
|
TARGET cdb_dataservices_server._DST_GetReturnMetadata;
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_FetchJoinFdwTableData(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_FetchJoinFdwTableData(
|
||||||
username text,
|
username text,
|
||||||
@@ -261,7 +265,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_FetchJoinFdwTableData(
|
|||||||
) RETURNS SETOF record AS $$
|
) RETURNS SETOF record AS $$
|
||||||
CONNECT cdb_dataservices_client._server_conn_str();
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
TARGET cdb_dataservices_server._DST_FetchJoinFdwTableData;
|
TARGET cdb_dataservices_server._DST_FetchJoinFdwTableData;
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_DisconnectUserTable(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_DisconnectUserTable(
|
||||||
username text,
|
username text,
|
||||||
@@ -272,4 +276,4 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_DisconnectUserTable(
|
|||||||
) RETURNS boolean AS $$
|
) RETURNS boolean AS $$
|
||||||
CONNECT cdb_dataservices_client._server_conn_str();
|
CONNECT cdb_dataservices_client._server_conn_str();
|
||||||
TARGET cdb_dataservices_server._DST_DisconnectUserTable;
|
TARGET cdb_dataservices_server._DST_DisconnectUserTable;
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point (query text,
|
||||||
|
street_column text, city_column text default null, state_column text default null, country_column text default null, batch_size integer DEFAULT NULL)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
DECLARE
|
||||||
|
query_row_count integer;
|
||||||
|
enough_quota boolean;
|
||||||
|
remaining_quota integer;
|
||||||
|
max_batch_size integer;
|
||||||
|
|
||||||
|
cartodb_id_batch integer;
|
||||||
|
batches_n integer;
|
||||||
|
DEFAULT_BATCH_SIZE CONSTANT numeric := 100;
|
||||||
|
MAX_SAFE_BATCH_SIZE CONSTANT numeric := 5000;
|
||||||
|
|
||||||
|
temp_table_name text;
|
||||||
|
username text;
|
||||||
|
orgname text;
|
||||||
|
apikey_permissions json;
|
||||||
|
BEGIN
|
||||||
|
SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json);
|
||||||
|
IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN
|
||||||
|
RAISE EXCEPTION 'Geocoding permission denied' USING ERRCODE = '01007';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 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 csqi.monthly_quota - csqi.used_quota AS remaining_quota, csqi.max_batch_size
|
||||||
|
INTO remaining_quota, max_batch_size
|
||||||
|
FROM cdb_dataservices_client.cdb_service_quota_info_batch() csqi
|
||||||
|
WHERE service = 'hires_geocoder';
|
||||||
|
RAISE DEBUG 'remaining_quota: %; max_batch_size: %', remaining_quota, max_batch_size;
|
||||||
|
|
||||||
|
IF batch_size IS NULL THEN
|
||||||
|
batch_size := max_batch_size;
|
||||||
|
ELSIF batch_size > max_batch_size THEN
|
||||||
|
RAISE EXCEPTION 'batch_size must be lower than %', max_batch_size + 1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF batch_size > MAX_SAFE_BATCH_SIZE THEN
|
||||||
|
batch_size := MAX_SAFE_BATCH_SIZE;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
EXECUTE format('SELECT count(1), ceil(count(1)::float/%s) FROM (%s) _x', batch_size, query)
|
||||||
|
INTO query_row_count, batches_n;
|
||||||
|
|
||||||
|
RAISE DEBUG 'cdb_bulk_geocode_street_point --> query_row_count: %; query: %; country: %; state: %; city: %; street: %',
|
||||||
|
query_row_count, query, country_column, state_column, city_column, street_column;
|
||||||
|
SELECT cdb_dataservices_client.cdb_enough_quota('hires_geocoder', query_row_count) INTO enough_quota;
|
||||||
|
IF enough_quota IS NULL OR NOT enough_quota THEN
|
||||||
|
RAISE EXCEPTION 'Remaining quota: %. Estimated cost: %', remaining_quota, query_row_count;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RAISE DEBUG 'batches_n: %', batches_n;
|
||||||
|
|
||||||
|
temp_table_name := 'bulk_geocode_street_' || md5(random()::text);
|
||||||
|
|
||||||
|
EXECUTE format('CREATE TEMPORARY TABLE %s ' ||
|
||||||
|
'(cartodb_id integer, the_geom public.geometry(Point,4326), metadata jsonb)',
|
||||||
|
temp_table_name);
|
||||||
|
|
||||||
|
select
|
||||||
|
coalesce(street_column, ''''''), coalesce(city_column, ''''''),
|
||||||
|
coalesce(state_column, ''''''), coalesce(country_column, '''''')
|
||||||
|
into street_column, city_column, state_column, country_column;
|
||||||
|
|
||||||
|
IF batches_n > 0 THEN
|
||||||
|
FOR cartodb_id_batch in 0..(batches_n - 1)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'WITH geocoding_data as (' ||
|
||||||
|
' SELECT ' ||
|
||||||
|
' json_build_object(''id'', cartodb_id, ''address'', %s, ''city'', %s, ''state'', %s, ''country'', %s) as data , ' ||
|
||||||
|
' floor((row_number() over () - 1)::float/$1) as batch' ||
|
||||||
|
' FROM (%s) _x' ||
|
||||||
|
') ' ||
|
||||||
|
'INSERT INTO %s SELECT (cdb_dataservices_client._cdb_bulk_geocode_street_point(jsonb_agg(data))).* ' ||
|
||||||
|
'FROM geocoding_data ' ||
|
||||||
|
'WHERE batch = $2', street_column, city_column, state_column, country_column, query, temp_table_name)
|
||||||
|
USING batch_size, cartodb_id_batch;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN QUERY EXECUTE 'SELECT * FROM ' || quote_ident(temp_table_name);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE
|
||||||
|
SET search_path = pg_temp;
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._OBS_PreCheck(
|
||||||
|
source_query text,
|
||||||
|
parameters json
|
||||||
|
) RETURNS boolean AS $$
|
||||||
|
DECLARE
|
||||||
|
errors text[];
|
||||||
|
validator_errors text[];
|
||||||
|
validator_error text;
|
||||||
|
valid boolean;
|
||||||
|
geoms record;
|
||||||
|
BEGIN
|
||||||
|
errors := (ARRAY[])::TEXT[];
|
||||||
|
FOR geoms IN EXECUTE format('SELECT ST_GeometryType(the_geom) as geom_type,
|
||||||
|
bool_and(st_isvalid(the_geom)) as valid,
|
||||||
|
avg(st_npoints(the_geom)) as avg_vertex,
|
||||||
|
ST_SetSRID(ST_Extent(the_geom), 4326) as extent,
|
||||||
|
count(*)::INT as numgeoms
|
||||||
|
FROM (%s) as _source
|
||||||
|
GROUP BY ST_GeometryType(the_geom)', source_query)
|
||||||
|
LOOP
|
||||||
|
IF geoms.geom_type NOT IN ('ST_Polygon', 'ST_MultiPolygon', 'ST_Point') THEN
|
||||||
|
errors := array_append(errors, format($data$'Geometry type %s not supported'$data$, geoms.geom_type));
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF geoms.valid IS FALSE THEN
|
||||||
|
errors := array_append(errors, 'There are invalid geometries in the input data, please try to fix them');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 1000 vertex for a geometry is a limit we have in the obs_getdata function. You can check here
|
||||||
|
-- https://github.com/CartoDB/observatory-extension/blob/1.6.0/src/pg/sql/41_observatory_augmentation.sql#L813
|
||||||
|
IF geoms.avg_vertex > 1000 THEN
|
||||||
|
errors := array_append(errors, 'The average number of vertices per geometry is greater than 1000, please try to simplify them');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- OBS specific part
|
||||||
|
EXECUTE 'SELECT valid, errors
|
||||||
|
FROM cdb_dataservices_client.OBS_MetadataValidation($1, $2, $3, $4)'
|
||||||
|
INTO valid, validator_errors
|
||||||
|
USING geoms.extent, geoms.geom_type, parameters, geoms.numgeoms;
|
||||||
|
IF valid is FALSE THEN
|
||||||
|
FOR validator_error IN EXECUTE 'SELECT unnest($1)' USING validator_errors
|
||||||
|
LOOP
|
||||||
|
errors := array_append(errors, validator_error);
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
IF CARDINALITY(errors) > 0 THEN
|
||||||
|
RAISE EXCEPTION '%', errors;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN TRUE;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' VOLATILE PARALLEL UNSAFE;
|
||||||
@@ -1,2 +1,7 @@
|
|||||||
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_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;
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure(table_name text, output_table_name text, params json) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._OBS_PreCheck(source_query text, params JSON) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_bulk_geocode_street_point(query text, street_column text, city_column text, state_column text, country_column text, batch_size integer) TO publicuser;
|
||||||
|
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_count_estimate(query text) TO publicuser;
|
||||||
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_jsonb_array_casttext(jsonb) TO publicuser;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
-- Only show warning or error messages in the tests output
|
||||||
|
SET client_min_messages TO WARNING;
|
||||||
-- Install dependencies
|
-- Install dependencies
|
||||||
CREATE EXTENSION postgis;
|
CREATE EXTENSION postgis;
|
||||||
CREATE EXTENSION schema_triggers;
|
CREATE EXTENSION @@plpythonu@@;
|
||||||
CREATE EXTENSION plpythonu;
|
|
||||||
CREATE EXTENSION cartodb;
|
CREATE EXTENSION cartodb;
|
||||||
CREATE EXTENSION plproxy;
|
CREATE EXTENSION plproxy;
|
||||||
-- Install the extension
|
-- Install the extension
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server function
|
-- Mock the server function
|
||||||
@@ -8,13 +9,37 @@ BEGIN
|
|||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
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)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin0_polygon(text) line 16 at SQL statement
|
|
||||||
cdb_geocode_admin0_polygon
|
cdb_geocode_admin0_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
@@ -15,11 +16,32 @@ BEGIN
|
|||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
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)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text) line 16 at SQL statement
|
|
||||||
cdb_geocode_admin1_polygon
|
cdb_geocode_admin1_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -27,10 +49,15 @@ PL/pgSQL function cdb_geocode_admin1_polygon(text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_admin1_polygon
|
cdb_geocode_admin1_polygon
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch() RENAME TO cdb_service_quota_info_batch_mocked;
|
||||||
|
CREATE FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch ()
|
||||||
|
RETURNS SETOF cdb_dataservices_client.service_quota_info_batch AS $$
|
||||||
|
SELECT 'hires_geocoder'::cdb_dataservices_client.service_type AS service, 0::NUMERIC AS monthly_quota, 0::NUMERIC AS used_quota, FALSE AS soft_limit, 'google' AS provider, 1::NUMERIC AS max_batch_size;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_enough_quota (service TEXT ,input_size NUMERIC) RENAME TO cdb_enough_quota_mocked;
|
||||||
|
CREATE FUNCTION cdb_dataservices_client.cdb_enough_quota (service TEXT ,input_size NUMERIC)
|
||||||
|
RETURNS BOOLEAN as $$
|
||||||
|
SELECT FALSE;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
ALTER FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point(searches jsonb) RENAME TO _cdb_bulk_geocode_street_point_mocked;
|
||||||
|
CREATE FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point(searches jsonb)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'called with this searches: %', searches;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE SET search_path = pg_temp;
|
||||||
|
-- No permissions granted
|
||||||
|
-- Test bulk size not mandatory (it will get the optimal)
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null);
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Test quota check by mocking quota 0
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Test bulk size not mandatory (it will get the optimal)
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null);
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Test quota check by mocking quota 0
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Test bulk size not mandatory (it will get the optimal)
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null);
|
||||||
|
ERROR: Remaining quota: 0. Estimated cost: 1
|
||||||
|
-- Test quota check by mocking quota 0
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
ERROR: Remaining quota: 0. Estimated cost: 1
|
||||||
|
-- Check that when cdb_enough_quota returns true (ie. when soft_limit is set to true, even if not enough quota)
|
||||||
|
-- it is able to proceed with the bulk geocode
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_enough_quota (service TEXT ,input_size NUMERIC)
|
||||||
|
RETURNS BOOLEAN as $$
|
||||||
|
SELECT TRUE;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
NOTICE: called with this searches: [{"id": 1, "city": "", "state": "", "address": "Valladolid, Spain", "country": ""}]
|
||||||
|
cdb_bulk_geocode_street_point
|
||||||
|
-------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch;
|
||||||
|
DROP FUNCTION cdb_dataservices_client.cdb_enough_quota;
|
||||||
|
DROP FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point;
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_enough_quota_mocked (service TEXT ,input_size NUMERIC) RENAME TO cdb_enough_quota;
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch_mocked() RENAME TO cdb_service_quota_info_batch;
|
||||||
|
ALTER FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point_mocked(searches jsonb) RENAME TO _cdb_bulk_geocode_street_point;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
SET client_min_messages TO warning;
|
SET client_min_messages TO warning;
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server functions to raise exceptions
|
-- Mock the server functions to raise exceptions
|
||||||
@@ -26,13 +27,41 @@ BEGIN
|
|||||||
RETURN ret;
|
RETURN ret;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Use regular user role
|
|
||||||
SET ROLE test_regular_user;
|
|
||||||
-- Exercise the exception safe and the proxied functions
|
-- Exercise the exception safe and the proxied functions
|
||||||
|
-- No permissions granted
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
||||||
|
ERROR: Isolines permission denied
|
||||||
|
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
-- No permissions granted but conf created
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": []}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
||||||
|
ERROR: Isolines permission denied
|
||||||
|
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
||||||
WARNING: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever.
|
WARNING: cdb_dataservices_client._cdb_geocode_street_point(6): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever.
|
||||||
DETAIL: SQL statement "SELECT cdb_dataservices_client._cdb_geocode_street_point(username, orgname, searchtext, city, state_province, country)"
|
|
||||||
PL/pgSQL function _cdb_geocode_street_point_exception_safe(text,text,text,text) line 21 at SQL statement
|
|
||||||
_cdb_geocode_street_point_exception_safe
|
_cdb_geocode_street_point_exception_safe
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
@@ -40,17 +69,22 @@ PL/pgSQL function _cdb_geocode_street_point_exception_safe(text,text,text,text)
|
|||||||
|
|
||||||
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
||||||
WARNING: cdb_dataservices_client._cdb_isodistance(6): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever.
|
WARNING: cdb_dataservices_client._cdb_isodistance(6): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever.
|
||||||
DETAIL: PL/pgSQL function _cdb_isodistance_exception_safe(geometry,text,integer[],text[]) line 21 at RETURN QUERY
|
|
||||||
center | data_range | the_geom
|
center | data_range | the_geom
|
||||||
--------+------------+----------
|
--------+------------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
WARNING: cdb_dataservices_client._cdb_route_point_to_point(7): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever.
|
WARNING: cdb_dataservices_client._cdb_route_point_to_point(7): [contrib_regression] REMOTE ERROR: Not enough quota or any other exception whatsoever.
|
||||||
DETAIL: 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_exception_safe(geometry,geometry,text,text[],text) line 21 at SQL statement
|
|
||||||
shape | length | duration
|
shape | length | duration
|
||||||
-------+--------+----------
|
-------+--------+----------
|
||||||
| |
|
| |
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
@@ -22,11 +23,36 @@ BEGIN
|
|||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
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)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text) line 16 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -34,8 +60,6 @@ PL/pgSQL function cdb_geocode_namedplace_point(text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -43,10 +67,15 @@ PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_namedplace_point
|
cdb_geocode_namedplace_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
@@ -15,11 +16,32 @@ BEGIN
|
|||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
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)"
|
|
||||||
PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_postalcode_polygon
|
cdb_geocode_postalcode_polygon
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
@@ -27,10 +49,15 @@ PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_postalcode_point
|
cdb_geocode_postalcode_point
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
@@ -8,13 +9,37 @@ BEGIN
|
|||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
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)"
|
|
||||||
PL/pgSQL function cdb_geocode_ipaddress_point(text) line 16 at SQL statement
|
|
||||||
cdb_geocode_ipaddress_point
|
cdb_geocode_ipaddress_point
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
@@ -8,11 +9,64 @@ BEGIN
|
|||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -20,8 +74,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -29,8 +81,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -38,8 +88,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -47,8 +95,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -56,8 +102,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -65,8 +109,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -74,8 +116,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -83,8 +123,6 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
cdb_geocode_street_point
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@@ -92,10 +130,15 @@ PL/pgSQL function cdb_geocode_street_point(text,text,text,text) line 16 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)"
|
|
||||||
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)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
@@ -21,11 +22,48 @@ BEGIN
|
|||||||
RETURN ret;
|
RETURN ret;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
-- Exercise the public and the proxied functions
|
-- -- Exercise the public and the proxied function
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY[]::text[], 'miles');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
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');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
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[]);
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
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');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
-- Grant other permissions but routing
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY[]::text[], 'miles');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
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');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
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[]);
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
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');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
-- Grant routing permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
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');
|
||||||
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)
|
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
|
cdb_route_point_to_point
|
||||||
--------------------------
|
--------------------------
|
||||||
(,5.33,100)
|
(,5.33,100)
|
||||||
@@ -33,8 +71,6 @@ PL/pgSQL function cdb_route_point_to_point(geometry,geometry,text,text[],text) l
|
|||||||
|
|
||||||
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['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)
|
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
|
cdb_route_point_to_point
|
||||||
--------------------------
|
--------------------------
|
||||||
(,5.33,100)
|
(,5.33,100)
|
||||||
@@ -42,8 +78,6 @@ PL/pgSQL function cdb_route_point_to_point(geometry,geometry,text,text[],text) l
|
|||||||
|
|
||||||
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_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)
|
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
|
cdb_route_point_to_point
|
||||||
--------------------------
|
--------------------------
|
||||||
(,5.33,100)
|
(,5.33,100)
|
||||||
@@ -51,8 +85,6 @@ PL/pgSQL function cdb_route_point_to_point(geometry,geometry,text,text[],text) l
|
|||||||
|
|
||||||
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');
|
||||||
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)
|
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
|
cdb_route_with_waypoints
|
||||||
--------------------------
|
--------------------------
|
||||||
(,2.22,500)
|
(,2.22,500)
|
||||||
@@ -60,8 +92,6 @@ PL/pgSQL function cdb_route_with_waypoints(geometry[],text,text[],text) line 16
|
|||||||
|
|
||||||
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['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)
|
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
|
cdb_route_with_waypoints
|
||||||
--------------------------
|
--------------------------
|
||||||
(,2.22,500)
|
(,2.22,500)
|
||||||
@@ -69,10 +99,15 @@ PL/pgSQL function cdb_route_with_waypoints(geometry[],text,text[],text) line 16
|
|||||||
|
|
||||||
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');
|
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)
|
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
|
cdb_route_with_waypoints
|
||||||
--------------------------
|
--------------------------
|
||||||
(,2.22,500)
|
(,2.22,500)
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -27,6 +27,12 @@ BEGIN
|
|||||||
RETURN true;
|
RETURN true;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": [""]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- Create a sample user table
|
-- Create a sample user table
|
||||||
CREATE TABLE user_table (cartodb_id int, the_geom geometry);
|
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 (1, '0101000020E6100000F74FC902E07D52C05FE24CC7654B4440');
|
||||||
@@ -63,3 +69,9 @@ SELECT * FROM my_table_dst;
|
|||||||
|
|
||||||
-- Clean tables
|
-- Clean tables
|
||||||
DROP TABLE my_table_dst;
|
DROP TABLE my_table_dst;
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,108 +1,8 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Use regular user role
|
-- Use regular user role
|
||||||
SET ROLE test_regular_user;
|
SET ROLE test_regular_user;
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
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 16 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 16 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 16 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 16 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 16 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 16 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 16 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 16 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 16 at SQL statement
|
|
||||||
cdb_geocode_ipaddress_point
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
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>)
|
|
||||||
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 16 at SQL statement
|
|
||||||
cdb_geocode_street_point
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
(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
|
||||||
@@ -126,3 +26,153 @@ 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');
|
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
|
ERROR: permission denied for function _cdb_route_point_to_point
|
||||||
|
-- -- Exercise the public function
|
||||||
|
-- -- it is public, it shall work
|
||||||
|
-- No permissions granted
|
||||||
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('one street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
-- Grant other permissions but geocoding and routing
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["isolines"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_geocode_street_point('one street, 1');
|
||||||
|
ERROR: Geocoding permission denied
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
ERROR: Routing permission denied
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing"]}');
|
||||||
|
cdb_conf_setconf
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
cdb_geocode_ipaddress_point
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
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>)
|
||||||
|
cdb_geocode_street_point
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
(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)
|
||||||
|
cdb_route_point_to_point
|
||||||
|
--------------------------
|
||||||
|
(,5.33,100)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
cdb_conf_removeconf
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
-- Only show warning or error messages in the tests output
|
||||||
|
SET client_min_messages TO WARNING;
|
||||||
-- Install dependencies
|
-- Install dependencies
|
||||||
CREATE EXTENSION postgis;
|
CREATE EXTENSION postgis;
|
||||||
CREATE EXTENSION schema_triggers;
|
CREATE EXTENSION @@plpythonu@@;
|
||||||
CREATE EXTENSION plpythonu;
|
|
||||||
CREATE EXTENSION cartodb;
|
CREATE EXTENSION cartodb;
|
||||||
CREATE EXTENSION plproxy;
|
CREATE EXTENSION plproxy;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -10,6 +11,18 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
-- No permissions granted
|
||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -18,7 +19,21 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
-- No permissions granted
|
||||||
SELECT cdb_geocode_admin1_polygon('California');
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California');
|
||||||
|
SELECT cdb_geocode_admin1_polygon('California', 'United States');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
|
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch() RENAME TO cdb_service_quota_info_batch_mocked;
|
||||||
|
CREATE FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch ()
|
||||||
|
RETURNS SETOF cdb_dataservices_client.service_quota_info_batch AS $$
|
||||||
|
SELECT 'hires_geocoder'::cdb_dataservices_client.service_type AS service, 0::NUMERIC AS monthly_quota, 0::NUMERIC AS used_quota, FALSE AS soft_limit, 'google' AS provider, 1::NUMERIC AS max_batch_size;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_enough_quota (service TEXT ,input_size NUMERIC) RENAME TO cdb_enough_quota_mocked;
|
||||||
|
CREATE FUNCTION cdb_dataservices_client.cdb_enough_quota (service TEXT ,input_size NUMERIC)
|
||||||
|
RETURNS BOOLEAN as $$
|
||||||
|
SELECT FALSE;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
|
ALTER FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point(searches jsonb) RENAME TO _cdb_bulk_geocode_street_point_mocked;
|
||||||
|
CREATE FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point(searches jsonb)
|
||||||
|
RETURNS SETOF cdb_dataservices_client.geocoding AS $$
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'called with this searches: %', searches;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE SET search_path = pg_temp;
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
|
-- Test bulk size not mandatory (it will get the optimal)
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null);
|
||||||
|
-- Test quota check by mocking quota 0
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
-- Test bulk size not mandatory (it will get the optimal)
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null);
|
||||||
|
-- Test quota check by mocking quota 0
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
-- Test bulk size not mandatory (it will get the optimal)
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null);
|
||||||
|
-- Test quota check by mocking quota 0
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
|
||||||
|
-- Check that when cdb_enough_quota returns true (ie. when soft_limit is set to true, even if not enough quota)
|
||||||
|
-- it is able to proceed with the bulk geocode
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_enough_quota (service TEXT ,input_size NUMERIC)
|
||||||
|
RETURNS BOOLEAN as $$
|
||||||
|
SELECT TRUE;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|
||||||
|
DROP FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch;
|
||||||
|
DROP FUNCTION cdb_dataservices_client.cdb_enough_quota;
|
||||||
|
DROP FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point;
|
||||||
|
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_enough_quota_mocked (service TEXT ,input_size NUMERIC) RENAME TO cdb_enough_quota;
|
||||||
|
ALTER FUNCTION cdb_dataservices_client.cdb_service_quota_info_batch_mocked() RENAME TO cdb_service_quota_info_batch;
|
||||||
|
ALTER FUNCTION cdb_dataservices_client._cdb_bulk_geocode_street_point_mocked(searches jsonb) RENAME TO _cdb_bulk_geocode_street_point;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
SET client_min_messages TO warning;
|
SET client_min_messages TO warning;
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -31,11 +32,30 @@ END;
|
|||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Use regular user role
|
|
||||||
SET ROLE test_regular_user;
|
|
||||||
|
|
||||||
-- Exercise the exception safe and the proxied functions
|
-- Exercise the exception safe and the proxied functions
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
||||||
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
||||||
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
|
||||||
|
-- No permissions granted but conf created
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": []}');
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
||||||
|
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
||||||
|
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing", "isolines"]}');
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
SELECT _cdb_geocode_street_point_exception_safe('One street, 1');
|
||||||
|
SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]);
|
||||||
|
SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.41706163)'::geometry,'POINT(-3.69909883 40.41236875)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]);
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -26,8 +27,24 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
SELECT cdb_geocode_namedplace_point('Elx');
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
||||||
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx');
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Spain');
|
||||||
|
SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -18,6 +19,21 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
SELECT cdb_geocode_postalcode_polygon('03204', 'Spain');
|
||||||
|
SELECT cdb_geocode_postalcode_point('03204', 'Spain');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -11,5 +12,18 @@ END;
|
|||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
SELECT cdb_geocode_ipaddress_point('8.8.8.8');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -11,7 +12,9 @@ END;
|
|||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
SELECT cdb_geocode_street_point('One street, 1');
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
SELECT cdb_geocode_street_point('One street', 'city');
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
@@ -22,3 +25,32 @@ SELECT cdb_geocode_street_point('One street', 'city');
|
|||||||
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}');
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
SELECT cdb_geocode_street_point('One street, 1');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country');
|
||||||
|
SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -27,12 +28,33 @@ END;
|
|||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
|
||||||
-- Exercise the public and the proxied functions
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
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');
|
||||||
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['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_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');
|
||||||
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['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');
|
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');
|
||||||
|
|
||||||
|
-- Grant other permissions but routing
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "isolines"]}');
|
||||||
|
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');
|
||||||
|
|
||||||
|
-- Grant routing permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing"]}');
|
||||||
|
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');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
SET search_path TO public,cartodb,cdb_dataservices_client;
|
||||||
|
|
||||||
@@ -218,7 +219,17 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
-- Exercise the public and the proxied function
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.obs_metadatavalidation(username text, orgname text, geom_extent geometry(Geometry, 4326), geom_type text, params JSON, target_geoms INTEGER DEFAULT NULL)
|
||||||
|
RETURNS TABLE (valid boolean, errors text[]) AS $$
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'cdb_dataservices_server.obs_metadatavalidation invoked with params (%, %, %, %, %, %)', username, orgname, geom_extent, geom_type, params, target_geoms;
|
||||||
|
RETURN QUERY SELECT true AS valid, ARRAY[]::TEXT[] AS errors;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
-- -- Exercise the public and the proxied function
|
||||||
|
|
||||||
|
-- No permissions granted
|
||||||
SELECT obs_get_demographic_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013'::text, '"us.census.tiger".block_group'::text);
|
SELECT obs_get_demographic_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013'::text, '"us.census.tiger".block_group'::text);
|
||||||
SELECT obs_get_segment_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '"us.census.tiger".block_group'::text);
|
SELECT obs_get_segment_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '"us.census.tiger".block_group'::text);
|
||||||
SELECT obs_getdemographicsnapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013', '"us.census.tiger".block_group'::text);
|
SELECT obs_getdemographicsnapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013', '"us.census.tiger".block_group'::text);
|
||||||
@@ -241,4 +252,58 @@ SELECT obs_getavailableboundaries(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4
|
|||||||
SELECT obs_getmeta(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]', 1, 1, 1000);
|
SELECT obs_getmeta(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]', 1, 1, 1000);
|
||||||
SELECT obs_getdata(ARRAY['36047'], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001", "geom_id": "us.census.tiger.county"}]', 1, 1, 1000));
|
SELECT obs_getdata(ARRAY['36047'], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001", "geom_id": "us.census.tiger.county"}]', 1, 1, 1000));
|
||||||
SELECT obs_getdata(ARRAY[(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 1)::geomval], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]'));
|
SELECT obs_getdata(ARRAY[(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 1)::geomval], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]'));
|
||||||
|
SELECT obs_metadatavalidation(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 'ST_Polygon', '[{"numer_id": "us.census.acs.B01003001"}]', 1000);
|
||||||
|
|
||||||
|
-- Grant other permissions but DO
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}');
|
||||||
|
SELECT obs_get_demographic_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013'::text, '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_get_segment_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_getdemographicsnapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013', '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_getsegmentsnapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_getboundary(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getboundaryid(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getboundarybyid('36047'::text, 'us.census.tiger.county'::text);
|
||||||
|
SELECT obs_getboundariesbygeometry(ST_MakeEnvelope(-73.9452409744, 40.6988851644, -73.9280319214, 40.7101254524, 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getboundariesbypointandradius(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 500, 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getpointsbygeometry(ST_MakeEnvelope(-73.9452409744, 40.6988851644, -73.9280319214, 40.7101254524, 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getpointsbypointandradius(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 500::numeric, 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getmeasure(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.acs.B01001001'::text);
|
||||||
|
SELECT obs_getmeasurebyid('36047'::text, 'us.census.acs.B01001001'::text, 'us.census.tiger.county'::text);
|
||||||
|
SELECT obs_getcategory(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.spielman_singleton_segments.X10'::text);
|
||||||
|
SELECT obs_getuscensusmeasure(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'male population'::text);
|
||||||
|
SELECT obs_getuscensuscategory(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'Spielman-Singleton Segments: 10 Clusters'::text);
|
||||||
|
SELECT obs_getpopulation(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326));
|
||||||
|
SELECT obs_search('total_pop'::text);
|
||||||
|
SELECT obs_getavailableboundaries(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326));
|
||||||
|
SELECT obs_getmeta(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]', 1, 1, 1000);
|
||||||
|
SELECT obs_getdata(ARRAY['36047'], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001", "geom_id": "us.census.tiger.county"}]', 1, 1, 1000));
|
||||||
|
SELECT obs_getdata(ARRAY[(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 1)::geomval], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]'));
|
||||||
|
SELECT obs_metadatavalidation(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 'ST_Polygon', '[{"numer_id": "us.census.acs.B01003001"}]', 1000);
|
||||||
|
|
||||||
|
-- Grant DO permissions
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["observatory"]}');
|
||||||
|
SELECT obs_get_demographic_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013'::text, '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_get_segment_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_getdemographicsnapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013', '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_getsegmentsnapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '"us.census.tiger".block_group'::text);
|
||||||
|
SELECT obs_getboundary(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getboundaryid(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getboundarybyid('36047'::text, 'us.census.tiger.county'::text);
|
||||||
|
SELECT obs_getboundariesbygeometry(ST_MakeEnvelope(-73.9452409744, 40.6988851644, -73.9280319214, 40.7101254524, 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getboundariesbypointandradius(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 500, 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getpointsbygeometry(ST_MakeEnvelope(-73.9452409744, 40.6988851644, -73.9280319214, 40.7101254524, 4326), 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getpointsbypointandradius(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 500::numeric, 'us.census.tiger.census_tract'::text);
|
||||||
|
SELECT obs_getmeasure(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.acs.B01001001'::text);
|
||||||
|
SELECT obs_getmeasurebyid('36047'::text, 'us.census.acs.B01001001'::text, 'us.census.tiger.county'::text);
|
||||||
|
SELECT obs_getcategory(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'us.census.spielman_singleton_segments.X10'::text);
|
||||||
|
SELECT obs_getuscensusmeasure(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'male population'::text);
|
||||||
|
SELECT obs_getuscensuscategory(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), 'Spielman-Singleton Segments: 10 Clusters'::text);
|
||||||
|
SELECT obs_getpopulation(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326));
|
||||||
|
SELECT obs_search('total_pop'::text);
|
||||||
|
SELECT obs_getavailableboundaries(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326));
|
||||||
|
SELECT obs_getmeta(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]', 1, 1, 1000);
|
||||||
|
SELECT obs_getdata(ARRAY['36047'], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001", "geom_id": "us.census.tiger.county"}]', 1, 1, 1000));
|
||||||
|
SELECT obs_getdata(ARRAY[(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 1)::geomval], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]'));
|
||||||
|
SELECT obs_metadatavalidation(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 'ST_Polygon', '[{"numer_id": "us.census.acs.B01003001"}]', 1000);
|
||||||
|
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": [""]}');
|
||||||
|
|
||||||
-- Create a sample user table
|
-- Create a sample user table
|
||||||
CREATE TABLE user_table (cartodb_id int, the_geom geometry);
|
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 (1, '0101000020E6100000F74FC902E07D52C05FE24CC7654B4440');
|
||||||
@@ -54,3 +56,5 @@ SELECT * FROM my_table_dst;
|
|||||||
|
|
||||||
-- Clean tables
|
-- Clean tables
|
||||||
DROP TABLE my_table_dst;
|
DROP TABLE my_table_dst;
|
||||||
|
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
@@ -1,23 +1,10 @@
|
|||||||
|
\set VERBOSITY terse
|
||||||
-- Use regular user role
|
-- Use regular user role
|
||||||
SET ROLE test_regular_user;
|
SET ROLE test_regular_user;
|
||||||
|
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO public,cartodb,cdb_dataservices_client;
|
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');
|
|
||||||
SELECT cdb_geocode_street_point('one street, 1');
|
|
||||||
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
|
||||||
|
|
||||||
-- 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');
|
||||||
SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Hell');
|
SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Hell');
|
||||||
@@ -30,3 +17,54 @@ SELECT _cdb_geocode_postalcode_point('evil_user', 'evil_orgname', '66666', 'Hell
|
|||||||
SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', '8.8.8.8');
|
SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', '8.8.8.8');
|
||||||
SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'one street, 1');
|
SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'one street, 1');
|
||||||
SELECT _cdb_route_point_to_point('evil_user', 'evil_orgname', 'POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
SELECT _cdb_route_point_to_point('evil_user', 'evil_orgname', 'POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
|
||||||
|
-- -- Exercise the public function
|
||||||
|
-- -- it is public, it shall work
|
||||||
|
-- No permissions granted
|
||||||
|
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');
|
||||||
|
SELECT cdb_geocode_street_point('one street, 1');
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
|
||||||
|
-- Grant other permissions but geocoding and routing
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["isolines"]}');
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
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');
|
||||||
|
SELECT cdb_geocode_street_point('one street, 1');
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
|
||||||
|
-- Grant geocoding permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing"]}');
|
||||||
|
SET ROLE test_regular_user; -- Use regular user role
|
||||||
|
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');
|
||||||
|
SELECT cdb_geocode_street_point('one street, 1');
|
||||||
|
SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car');
|
||||||
|
|
||||||
|
-- Remove permissions
|
||||||
|
SET ROLE postgres;
|
||||||
|
SELECT CDB_Conf_RemoveConf('api_keys_postgres');
|
||||||
|
|||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
# Data Services API
|
|
||||||
|
|
||||||
The CARTO Data Services API offers a set of location based services that can be used programatically to empower your geospatial applications.
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
* [Overview](overview.md)
|
|
||||||
* [Geocoding Functions](geocoding_functions.md)
|
|
||||||
* [Isoline Functions](isoline_functions.md)
|
|
||||||
* [Routing Functions](routing_functions.md)
|
|
||||||
* [Demographic Functions](demographic_functions.md)
|
|
||||||
* [Segmentation Functions](segmentation_functions.md)
|
|
||||||
* [Quota Information](quota_information.md)
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user