pg_get_viewdefs() indentation considered harmful - Mailing list pgsql-hackers

From Greg Stark
Subject pg_get_viewdefs() indentation considered harmful
Date
Msg-id CAM-w4HNKU9Y38QrLxPMOYp+CSfjfcrAoJ4rs1nsO+uBt79qGXQ@mail.gmail.com
Whole thread Raw
Responses Re: pg_get_viewdefs() indentation considered harmful  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
We're finding it more and more common for people to define partitioned
table views with hundreds or thousands of union branches.
pg_get_viewdefs indents each branch of the union by 8 spaces more than
the previous branch. The net effect is that the size of the output is
O(n^2) bytes just for the indentation spaces. If your union branches
are about 5 lines long then you hit MaxAlloc after about 5,000
branches. And incidentally there's no CHECK_FOR_INTERRUPTS in that
loop.

I would actually suggest pg_dump should be able to pass a flag to
disable indentation but then I noticed that all the code is already
there. It's just that every single variation of pg_get_viewdef sets
the indentation flag explicitly. I wonder if this was the intended
behaviour. Shouldn't pg_get_viewdef(view, false) set indentation off?

-- 
greg



pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: Standalone synchronous master
Next
From: Tom Lane
Date:
Subject: Re: pg_get_viewdefs() indentation considered harmful