Ir para o conteúdo

Usuário:Peter/Lembretes SQL e docs: mudanças entre as edições

add funcoes e seu relatorio
(add funcoes e seu relatorio)
Linha 1: Linha 1:
Tabelas da base corrente dl05. Documentação gerada por recursos do "psql" e [https://tableconvert.com/markdown-to-mediawiki tableconvert.com/markdown-to-mediawiki].
Tabelas da base corrente <code>DL05s_main</code>. Documentação gerada por recursos do "psql" e [https://tableconvert.com/markdown-to-mediawiki tableconvert.com/markdown-to-mediawiki].
 
== Table <code>osmc.coverage</code> ==


== Table <code>osmc.coverage</code> ==
== Table <code>osmc.coverage</code> ==
Linha 46: Linha 48:
Queries que geram reports e sugestão de análise das views próprias.
Queries que geram reports e sugestão de análise das views próprias.
<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
-- R0
-- R0a
select * from optim.admin_views_dependency_summary where ref_tab_name='osmc.coverage';
select * from optim.admin_views_dependency_summary where ref_tab_name='osmc.coverage'
;
-- R0b
select schema_name, name, arguments_simplified , return_type, oid
from doc_UDF_using_a_table('osmc.cover') t order by 1,2,3
;


-- R1  
-- R1  
Linha 86: Linha 93:


=== Reports ===
=== Reports ===
'''R0'''. Views que fazem uso desta tabela:
'''R0a'''. Views que fazem uso desta tabela:
* osmc.jurisdictions_select
* osmc.jurisdictions_select
* osmc.tmpvw10: temporária  
* osmc.tmpvw10: temporária  
* osmc.tmpvwpoeira: indica "sobras" dos polígonos que não foram aceitas como cobertura válida, por serem menores que 100 metros quadrados.
* osmc.tmpvwpoeira: indica "sobras" dos polígonos que não foram aceitas como cobertura válida, por serem menores que 100 metros quadrados.
'''R0b'''. Funções que fazem uso desta tabela. (removidas as variantes "EC" e "UY")
{| class="wikitable"
! schema_name !! name !! arguments_simplified !! return_type
|-
| api || jurisdiction_coverage || {text,integer} || jsonb
|-
| api || jurisdiction_geojson_from_isolabel || {text} || jsonb
|-
| api || osmcode_decode_postal || {text,text} || jsonb
|-
| api || osmcode_decode_postal_absolute || {text,text} || jsonb
|-
| api || osmcode_decode_scientific_absolute || {text,text,integer} || jsonb
|-
| api || osmcode_encode || {text,integer} || jsonb
|-
| osmc || afa_log_to_hbig || {text,text} || int8
|-
| osmc || cellcontainsproperly || {text,text,integer,text,integer} || text
|-
| osmc || check_coverage || {text,ARRAY,text,ARRAY,ARRAY,ARRAY,ARRAY,boolean,ARRAY} || record
|-
| osmc || cover_child_geometries || {text,text,integer,text,text,USER-DEFINED} || record
|-
| osmc || encode_point_brazil || {USER-DEFINED} || text
|-
| osmc || encode_point_colombia || {USER-DEFINED} || text
|-
| osmc || encode_postal_br || {USER-DEFINED,"double precision",integer,text} || jsonb
|-
| osmc || encode_postal_cm || {USER-DEFINED,"double precision",integer,text} || jsonb
|-
| osmc || encode_postal_co || {USER-DEFINED,"double precision",integer,text} || jsonb
|-
| osmc || encode_scientific_br || {USER-DEFINED,"double precision",integer} || jsonb
|-
| osmc || encode_scientific_cm || {USER-DEFINED,"double precision",integer} || jsonb
|-
| osmc || encode_scientific_co || {USER-DEFINED,"double precision",integer} || jsonb
|-
| osmc || encode_short_code || {text,"bit varying",text,USER-DEFINED,text,integer,text} || record
|-
| osmc || generate_cover_csv || {text,text} || text
|-
| osmc || l0_upsert || {text,smallint,integer,integer,integer,integer,integer,ARRAY,ARRAY} || text
|-
| osmc || l0cover_upsert_br || {NULL} || text
|-
| osmc || l0cover_upsert_co || {NULL} || text
|-
| osmc || update_coverage_isolevel3 || {text,smallint,ARRAY,ARRAY} || text
|}


'''R1'''. Sumário do conteúdo corrente (final de 2023). Diferencia coberturas nacionais, expressa contagem de células e contagem de jurisdições.
'''R1'''. Sumário do conteúdo corrente (final de 2023). Diferencia coberturas nacionais, expressa contagem de células e contagem de jurisdições.
Linha 210: Linha 270:
order by u.view_schema, u.view_name
order by u.view_schema, u.view_name
;
;
-- DROP VIEW optim.admin_udf_summary;
CREATE VIEW optim.admin_udf_summary AS
SELECT  n.oid, quote_ident(n.nspname) as schema , quote_ident(p.proname) as function,
        pg_get_function_result(n.oid) as fres
FROM  pg_catalog.pg_proc p
JOIN  pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE  n.nspname not like 'pg%'
;
CREATE or replace FUNCTION doc_UDF_using_a_table(
  p_table text,
  p_schema_name text DEFAULT NULL,
  p_name_like text DEFAULT '',
  p_name_notlike text DEFAULT '',
  p_oid oid DEFAULT NULL
) RETURNS TABLE (
  id text,
  oid oid,
  schema_name text,
  name text,
  language text, --new
  definition_md5 text, -- version control
  arguments_simplified text[],
  arguments text,
  return_type text,
  prokind text,
  comment text
) AS $f$
  SELECT doc_UDF_transparent_id(u.schema_name, u.name::text, s.arguments_simplified::text[]) AS id,
        u.oid, u.schema_name, u.name::text,
        u.language, md5(u.definition),
        s.arguments_simplified::text[] as arguments_simplified,
        u.arguments::text AS arguments,
        u.return_type, u.prokind, u.comment
  FROM doc_UDF_show_simplified_signature($2,$3,$4) s
      INNER JOIN doc_UDF_show($2,$3,$4,$5) u ON s.oid=u.oid::text
  WHERE u.definition ilike '%'|| p_table ||'%'
$f$ LANGUAGE SQL IMMUTABLE;


----
CREATE VIEW optim.admin_views_dependency_summary AS
CREATE VIEW optim.admin_views_dependency_summary AS
select schema_name||'.'||view_name as vw_name, referenced_table_schema||'.'||referenced_table_name as ref_tab_name
select schema_name||'.'||view_name as vw_name,
from optim.admin_views_dependency
referenced_table_schema||'.'||referenced_table_name as ref_tab_name
from optim.admin_views_dependency
;
;
</pre>
</pre>
2 391

edições