feat(format): default output to dist/examples house style
Align the formatter defaults and layout with the hand-formatted reference procedures in dist/examples so a clean `pgtidy fmt` produces the house style. config.Default(): - align_param_types: false (no type-column alignment in param lists) - plpgsql_declare_align_type / plpgsql_declare_align_eq: true Formatter: - routine header: leading-comma params at column 0, first param at one indent, RETURNS/LANGUAGE/volatility/SECURITY each indented one level - %type / %rowtype printed tight (isPctTypeBoundary) - DECLARE = / := / DEFAULT column padded only to the widest declaration that carries an assignment - WHERE continuations in body UPDATE/DELETE: AND/OR aligned with WHERE - EXCEPTION aligned to its enclosing BEGIN; column-0 comment continuations kept flush-left Safety gate: - SemanticallyEqual tolerates CRLF vs LF inside string literals (normNL); the formatter re-emits all layout with st.Newline, so a \r\n inside a multi-line string literal is normalisation, not a code change. This was why action_init and event_exec_func previously refused to format. Corpus: - add the four CRLF reference files as idempotence/safety fixtures - regenerate test_a and test_mm_proc goldens FOR...LOOP body indentation keeps the existing +1 convention (LOOP aligned with FOR); the dist/examples use +2, so loop-body regions differ by whitespace only.
This commit is contained in:
Vendored
+94
-94
@@ -1,84 +1,84 @@
|
||||
CREATE OR REPLACE FUNCTION mm_proc(
|
||||
p_doctype text --File Types: html, docx, text, allfieldvalues
|
||||
,p_commtype text --Merge Data Type: e.g. SMS,Email,All (Will be passed through to menu/taglist funct)
|
||||
,p_template bytea --Source/Template file to be merge
|
||||
,p_data_prefix text --Table prefix for data source. e.g. tcli (client) , sta (standard letters)
|
||||
,p_data_rid integer --rid for given table prefix
|
||||
,p_filterdata json = NULL --Advanced filter data.
|
||||
,OUT p_doc bytea --Merged document output
|
||||
,OUT p_docguid text --optional guid to store document guid from tempfile table. (For disk reading)
|
||||
,OUT p_retval integer
|
||||
,OUT p_errmsg text
|
||||
p_doctype text --File Types: html, docx, text, allfieldvalues
|
||||
, p_commtype text --Merge Data Type: e.g. SMS,Email,All (Will be passed through to menu/taglist funct)
|
||||
, p_template bytea --Source/Template file to be merge
|
||||
, p_data_prefix text --Table prefix for data source. e.g. tcli (client) , sta (standard letters)
|
||||
, p_data_rid integer --rid for given table prefix
|
||||
, p_filterdata json = NULL --Advanced filter data.
|
||||
, OUT p_doc bytea --Merged document output
|
||||
, OUT p_docguid text --optional guid to store document guid from tempfile table. (For disk reading)
|
||||
, OUT p_retval integer
|
||||
, OUT p_errmsg text
|
||||
)
|
||||
LANGUAGE plpgsql
|
||||
VOLATILE
|
||||
LANGUAGE plpgsql
|
||||
VOLATILE
|
||||
AS
|
||||
$$
|
||||
DECLARE
|
||||
--Error Handling--
|
||||
m_funcname text = 'mm_proc';
|
||||
m_errmsg text;
|
||||
m_errcontext text;
|
||||
m_errdetail text;
|
||||
m_errhint text;
|
||||
m_errstate text;
|
||||
m_retval integer;
|
||||
m_funcname text = 'mm_proc';
|
||||
m_errmsg text;
|
||||
m_errcontext text;
|
||||
m_errdetail text;
|
||||
m_errhint text;
|
||||
m_errstate text;
|
||||
m_retval integer;
|
||||
--Error Handling--
|
||||
m_blankexec text;
|
||||
m_comma text;
|
||||
m_debug_exestr text;
|
||||
m_exec_orderstr text;
|
||||
m_execfilter text;
|
||||
m_execstr text;
|
||||
m_fields json;
|
||||
m_guid citext;
|
||||
m_json json;
|
||||
m_json_full json;
|
||||
m_json_full_complex jsonb;
|
||||
m_result text;
|
||||
m_tablefilter text;
|
||||
m_temppath citext;
|
||||
m_user citext;
|
||||
m_exttype citext;
|
||||
m_returnvalues boolean = false;
|
||||
m_data_prefix citext;
|
||||
m_data_rid integer;
|
||||
m_rid_comm integer;
|
||||
m_blankexec text;
|
||||
m_comma text;
|
||||
m_debug_exestr text;
|
||||
m_exec_orderstr text;
|
||||
m_execfilter text;
|
||||
m_execstr text;
|
||||
m_fields json;
|
||||
m_guid citext;
|
||||
m_json json;
|
||||
m_json_full json;
|
||||
m_json_full_complex jsonb;
|
||||
m_result text;
|
||||
m_tablefilter text;
|
||||
m_temppath citext;
|
||||
m_user citext;
|
||||
m_exttype citext;
|
||||
m_returnvalues boolean = false;
|
||||
m_data_prefix citext;
|
||||
m_data_rid integer;
|
||||
m_rid_comm integer;
|
||||
m_rid_commattachment integer;
|
||||
m_rid_obl integer;
|
||||
m_doctype citext;
|
||||
m_ltime timestamp;
|
||||
m_hasfilestream boolean;
|
||||
m_rid_obligation integer;
|
||||
g_debug boolean;
|
||||
g_tag_s text;
|
||||
g_tag_e text;
|
||||
g_tag_split text;
|
||||
g_tag_oper text;
|
||||
g_mtype_root integer = 0;
|
||||
g_mtype_field integer = 1;
|
||||
g_mtype_tblfield integer = 2;
|
||||
g_mtype_tblroot integer = 3;
|
||||
g_mtype_aggfield integer = 4;
|
||||
g_mtype_picture integer = 5;
|
||||
g_mtype_special integer = 6;
|
||||
g_mtype_filter integer = 7;
|
||||
g_mtype_condfield integer = 8;
|
||||
g_mtype_docreplace integer = 9;
|
||||
g_mtype_html integer = 10;
|
||||
g_benchmark integer;
|
||||
a_tblroot integer[];
|
||||
a_types citext[];
|
||||
a_inner_selected citext[];
|
||||
r_template record;
|
||||
r_doc record;
|
||||
r_lp record;
|
||||
r_lp_t record;
|
||||
r_lp_c record;
|
||||
r_retval record;
|
||||
r_tmp record;
|
||||
m_rid_obl integer;
|
||||
m_doctype citext;
|
||||
m_ltime timestamp;
|
||||
m_hasfilestream boolean;
|
||||
m_rid_obligation integer;
|
||||
g_debug boolean;
|
||||
g_tag_s text;
|
||||
g_tag_e text;
|
||||
g_tag_split text;
|
||||
g_tag_oper text;
|
||||
g_mtype_root integer = 0;
|
||||
g_mtype_field integer = 1;
|
||||
g_mtype_tblfield integer = 2;
|
||||
g_mtype_tblroot integer = 3;
|
||||
g_mtype_aggfield integer = 4;
|
||||
g_mtype_picture integer = 5;
|
||||
g_mtype_special integer = 6;
|
||||
g_mtype_filter integer = 7;
|
||||
g_mtype_condfield integer = 8;
|
||||
g_mtype_docreplace integer = 9;
|
||||
g_mtype_html integer = 10;
|
||||
g_benchmark integer;
|
||||
a_tblroot integer[];
|
||||
a_types citext[];
|
||||
a_inner_selected citext[];
|
||||
r_template record;
|
||||
r_doc record;
|
||||
r_lp record;
|
||||
r_lp_t record;
|
||||
r_lp_c record;
|
||||
r_retval record;
|
||||
r_tmp record;
|
||||
--r_lp_prev record;
|
||||
m_start timestamp = clock_timestamp();
|
||||
m_start timestamp = clock_timestamp();
|
||||
BEGIN
|
||||
p_retval = 0;
|
||||
p_errmsg = '';
|
||||
@@ -98,17 +98,17 @@ BEGIN
|
||||
m_user = f_getuser();
|
||||
|
||||
-- if p_doctype ilike '%plain%' and f_iscompressed(p_template) in ('none')
|
||||
-- and byteatotext(p_template) not ilike '%'|| G_TAG_S || '%' || G_TAG_E || '%'
|
||||
-- then
|
||||
-- raise warning 'No tags to merge in plain template.';
|
||||
-- p_doc = p_template;
|
||||
-- return;
|
||||
-- end if;
|
||||
-- and byteatotext(p_template) not ilike '%'|| G_TAG_S || '%' || G_TAG_E || '%'
|
||||
-- then
|
||||
-- raise warning 'No tags to merge in plain template.';
|
||||
-- p_doc = p_template;
|
||||
-- return;
|
||||
-- end if;
|
||||
|
||||
-- perform log_event(m_funcname,format('INIT _ type=%s commtype=%s p_data_prefix=%s p_data_rid=%s Template:%s'
|
||||
-- ,p_doctype, p_commtype,p_data_prefix,p_data_rid
|
||||
-- ,case when octet_length(p_template) < 100 then byteatotext(p_template) else octet_length(p_template)::text end
|
||||
-- ),bt_enum('eventlog','local notice'));
|
||||
-- ,p_doctype, p_commtype,p_data_prefix,p_data_rid
|
||||
-- ,case when octet_length(p_template) < 100 then byteatotext(p_template) else octet_length(p_template)::text end
|
||||
-- ),bt_enum('eventlog','local notice'));
|
||||
|
||||
if p_data_prefix::citext = 'com'
|
||||
then
|
||||
@@ -168,7 +168,7 @@ BEGIN
|
||||
into r_doc;
|
||||
|
||||
-- perform log_event(m_funcname,format('init = p_doctype = %s p_data_prefix = %s p_data_rid = %s p_template[size] = %s'
|
||||
-- ,p_doctype,p_data_prefix,p_data_rid,octet_length(p_template)),bt_enum('eventlog','local notice'));
|
||||
-- ,p_doctype,p_data_prefix,p_data_rid,octet_length(p_template)),bt_enum('eventlog','local notice'));
|
||||
|
||||
if p_doctype = 'allfieldvalues'
|
||||
then
|
||||
@@ -291,7 +291,7 @@ BEGIN
|
||||
from src d ;
|
||||
|
||||
--CREATE INDEX "idx_tmp_merge_init_src_type" ON tmp_merge_init_src USING btree (merge_type);
|
||||
--CREATE INDEX "idx_tmp_merge_init_src_tag" ON tmp_merge_init_src USING btree (mergetag);
|
||||
--CREATE INDEX "idx_tmp_merge_init_src_tag" ON tmp_merge_init_src USING btree (mergetag);
|
||||
|
||||
--HTML field types has a special meaning in the frontend. We treat them as normal fields.
|
||||
update tmp_merge_init_src u
|
||||
@@ -513,8 +513,8 @@ BEGIN
|
||||
)
|
||||
then
|
||||
-- perform log_event(m_funcname,format('NO TAGS p_doctype=%s p_commtype=%s p_data_prefix=%s p_data_rid=%s'
|
||||
-- ,p_doctype, p_commtype,p_data_prefix,p_data_rid),bt_enum('eventlog','local notice'));
|
||||
--
|
||||
-- ,p_doctype, p_commtype,p_data_prefix,p_data_rid),bt_enum('eventlog','local notice'));
|
||||
--
|
||||
p_doc = p_template;
|
||||
|
||||
return;
|
||||
@@ -553,7 +553,7 @@ BEGIN
|
||||
where tat.description ilike 'Form 16 (%'
|
||||
), 'TCLI',1000016) r
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
|
||||
drop table if exists debug_merge_init_src;
|
||||
create table debug_merge_init_src as
|
||||
@@ -1130,10 +1130,10 @@ BEGIN
|
||||
)
|
||||
loop
|
||||
-- perform log_event(m_funcname,format(' Tables %s=%s src=%s rn=%s' ,p_data_prefix,p_data_rid
|
||||
-- ,r_lp_t.source,r_lp_t.rn
|
||||
-- ),bt_enum('eventlog','local notice')
|
||||
-- --,(select jsonb_agg(row_to_json(f)::jsonb) from tmp_merge_init_fields f)::text
|
||||
-- );
|
||||
-- ,r_lp_t.source,r_lp_t.rn
|
||||
-- ),bt_enum('eventlog','local notice')
|
||||
-- --,(select jsonb_agg(row_to_json(f)::jsonb) from tmp_merge_init_fields f)::text
|
||||
-- );
|
||||
|
||||
if r_lp_t.table_name = any(a_inner_selected) and nv(r_lp_t.table_name ) <> ''
|
||||
then
|
||||
@@ -1385,10 +1385,10 @@ BEGIN
|
||||
end if;
|
||||
|
||||
-- perform log_event(m_funcname,format('Complex Tables %s=%s m_json_full_complex=%s' ,p_data_prefix,p_data_rid
|
||||
-- ,m_json_full_complex::text
|
||||
-- ),bt_enum('eventlog','local notice')
|
||||
-- --,(select jsonb_agg(row_to_json(f)::jsonb) from tmp_merge_init_fields f)::text
|
||||
-- );
|
||||
-- ,m_json_full_complex::text
|
||||
-- ),bt_enum('eventlog','local notice')
|
||||
-- --,(select jsonb_agg(row_to_json(f)::jsonb) from tmp_merge_init_fields f)::text
|
||||
-- );
|
||||
|
||||
m_execfilter = '';
|
||||
m_execstr = '';
|
||||
|
||||
Reference in New Issue
Block a user