pg_get_viewdefs() indentation considered harmful

From: Greg Stark <stark(at)mit(dot)edu>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_get_viewdefs() indentation considered harmful
Date: 2014-01-24 22:48:26
Message-ID: CAM-w4HNKU9Y38QrLxPMOYp+CSfjfcrAoJ4rs1nsO+uBt79qGXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-01-24 23:54:17 Re: pg_get_viewdefs() indentation considered harmful
Previous Message Florian Pflug 2014-01-24 22:25:19 Re: Standalone synchronous master