Move exception info vars to the top #314

This commit is contained in:
Rafa de la Torre 2016-12-14 10:33:50 +01:00
parent 58b1713a0d
commit 610cfaab57

View File

@ -8,6 +8,9 @@ DECLARE
<% if not multi_row %>ret <%= return_type %>;<% end %> <% if not multi_row %>ret <%= return_type %>;<% end %>
username text; username text;
orgname text; orgname text;
_returned_sqlstate TEXT;
_message_text TEXT;
_pg_exception_context TEXT;
BEGIN BEGIN
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN 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';
@ -27,10 +30,6 @@ BEGIN
RAISE WARNING 'whatever'; RAISE WARNING 'whatever';
END; END;
<% elsif multi_field %> <% elsif multi_field %>
DECLARE
_returned_sqlstate TEXT;
_message_text TEXT;
_pg_exception_context TEXT;
BEGIN BEGIN
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret; SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
RETURN ret; RETURN ret;