Adding OBS_DumpVersion function
This commit is contained in:
parent
9c068fa45e
commit
5bc2d974ac
@ -321,3 +321,9 @@
|
|||||||
params:
|
params:
|
||||||
- { name: geom, type: Geometry }
|
- { name: geom, type: Geometry }
|
||||||
- { name: timespan, type: text, default: 'NULL'}
|
- { name: timespan, type: text, default: 'NULL'}
|
||||||
|
|
||||||
|
- name: obs_dumpversion
|
||||||
|
return_type: text
|
||||||
|
no_params: true
|
||||||
|
params:
|
||||||
|
- {}
|
||||||
|
@ -36,6 +36,10 @@ class SqlTemplateRenderer
|
|||||||
@function_signature['multi_row']
|
@function_signature['multi_row']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def no_params
|
||||||
|
@function_signature['no_params']
|
||||||
|
end
|
||||||
|
|
||||||
def user_config_key
|
def user_config_key
|
||||||
@function_signature['user_config_key']
|
@function_signature['user_config_key']
|
||||||
end
|
end
|
||||||
@ -45,15 +49,15 @@ class SqlTemplateRenderer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
@function_signature['params'].map { |p| p['name'] }.join(', ')
|
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']}"}.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type
|
def params_with_type
|
||||||
@function_signature['params'].map { |p| "#{p['name']} #{p['type']}" }.join(', ')
|
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']} #{p['type']}" }.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type_and_default
|
def params_with_type_and_default
|
||||||
parameters = @function_signature['params'].map do |p|
|
parameters = @function_signature['params'].reject(&:empty?).map do |p|
|
||||||
if not p['default'].nil?
|
if not p['default'].nil?
|
||||||
"#{p['name']} #{p['type']} DEFAULT #{p['default']}"
|
"#{p['name']} #{p['type']} DEFAULT #{p['default']}"
|
||||||
else
|
else
|
||||||
|
@ -25,10 +25,12 @@ BEGIN
|
|||||||
<% elsif multi_field %>
|
<% elsif multi_field %>
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
||||||
RETURN ret;
|
RETURN ret;
|
||||||
|
<% elsif no_params %>
|
||||||
|
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname) INTO ret;
|
||||||
|
RETURN ret;
|
||||||
<% else %>
|
<% else %>
|
||||||
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
||||||
RETURN ret;
|
RETURN ret;
|
||||||
<% end %>
|
<% end %>
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
|
<% if no_params %>
|
||||||
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text)
|
||||||
|
<% else %>
|
||||||
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type_and_default %>)
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type_and_default %>)
|
||||||
|
<% end %>
|
||||||
RETURNS <%= return_type %> AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
CONNECT <%= DATASERVICES_CLIENT_SCHEMA %>._server_conn_str();
|
CONNECT <%= DATASERVICES_CLIENT_SCHEMA %>._server_conn_str();
|
||||||
<% if multi_field %>
|
<% if multi_field %>
|
||||||
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
||||||
|
<% elsif no_params %>
|
||||||
|
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name);
|
||||||
<% else %>
|
<% else %>
|
||||||
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
||||||
<% end %>
|
<% end %>
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy;
|
||||||
|
|
||||||
|
5
server/extension/sql/130_data_observatory_helper.sql
Normal file
5
server/extension/sql/130_data_observatory_helper.sql
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.obs_dumpversion(username text, orgname text)
|
||||||
|
RETURNS text AS $$
|
||||||
|
CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname);
|
||||||
|
SELECT cdb_observatory.obs_dumpversion();
|
||||||
|
$$ LANGUAGE plproxy;
|
Loading…
Reference in New Issue
Block a user