k1LoW / tbls

tbls is a CI-Friendly tool for document a database, written in Go.
MIT License
3.46k stars 167 forks source link

Document user-defined functions and stored procedures #307

Open tjdavis3 opened 3 years ago

tjdavis3 commented 3 years ago

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.

YauhenPylAurea commented 2 years ago

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

tjdavis3 commented 2 years ago
YauhenPylAurea commented 2 years ago

I see that

tjdavis3 commented 2 years ago

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:

felixfbecker commented 4 months ago

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 '...';