Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document user-defined functions and stored procedures #307

Open
tjdavis3 opened this issue May 12, 2021 · 5 comments
Open

Document user-defined functions and stored procedures #307

tjdavis3 opened this issue May 12, 2021 · 5 comments
Labels

Comments

@tjdavis3
Copy link

Add UDF and stored procedure documentation to the database. Some databases (eg. mysql) all a comment to create procedure that can be used. Others may need to look for comments in the DDL. At a minimum just creating a list of them (and/or a separate page that could be edited) would be helpful.

@tjdavis3 tjdavis3 added the enhancement New feature or request label May 12, 2021
@YauhenPylAurea
Copy link
Contributor

It seems this PR covers mysql, mssql and postgreSQL. Is there any other supported dbs with such functionality?

@tjdavis3
Copy link
Author

  • MariaDB is a fork of MySQL, so it should be the same
  • Amazon Redshift is based on PostgreSQL, so it should be the same
  • Snowflake has UDFs and StoredProcedures. Not sure of the query syntax / tables

@YauhenPylAurea
Copy link
Contributor

I see that

@tjdavis3
Copy link
Author

tjdavis3 commented Sep 9, 2022

The stored procedures and functions do appear now, but the presentation only works for very simple procedures. Here's what one of my current databases looks like.

Stored procedures and functions

Name ReturnType Arguments Type
public.pg_stat_statements record showtext boolean, OUT userid oid, OUT dbid oid, OUT queryid bigint, OUT query text, OUT calls bigint, OUT total_time double precision, OUT min_time double precision, OUT max_time double precision, OUT mean_time double precision, OUT stddev_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_dirtied bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_dirtied bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint, OUT blk_read_time double precision, OUT blk_write_time double precision FUNCTION
public.pg_stat_statements_reset void FUNCTION
public.pg_buffercache_pages record FUNCTION
public.base36_encode varchar digits bigint, min_width integer DEFAULT 0 FUNCTION
public.friendly_id varchar digits bigint, prefix character varying DEFAULT 'M5'::character varying FUNCTION

Some enhancements that would be nice:

  • It would be nice to be able to ignore certain functions like can be done with tables. In this case I'd want to ignore pg_*.
  • On the index page just list the function name and comment and link to a separate page like the tables
  • The function page would then be a template like tables. It would be nice to format it much like an API document. eg.

    FUNCTION public.friendly_id(bigint, character) returns varchar

    Description (from the comment in the db)

    Parameters:

    • digits (bigint)
    • prefix (character varying DEFAULT 'M5'::character varying)

    -> Create Statement

FelixZY added a commit to dansdata-se/portal that referenced this issue Jan 21, 2023
This update includes a fix for
k1LoW/tbls#369
("Exclude all tables except specific table").

It seems tbls does not yet support functions and stored procedures,
which would probably be quite useful for us:
k1LoW/tbls#307
@felixfbecker
Copy link

I really wish the functions table would show the comment of the function like for tables, columns, etc. Right now the comments are not shown anywhere which makes the table not that useful for documentation.

COMMENT ON FUNCTION foo_bar IS '...';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants