Backend-internal SPI operations

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Hollomon <mhh(at)mindspring(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Backend-internal SPI operations
Date: 2000-08-29 15:35:15
Message-ID: 1908.967563315@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Mark Hollomon <mhh(at)mindspring(dot)com> writes:
> sprintf(rulequery, "select * from pg_views where viewname='%s'", relname);
> [ evaluate query via SPI ]

I really dislike seeing backend utility operations built atop SPI.
Quite aside from the (lack of) speed, there are all sorts of nasty
traps that can come from runtime evaluation of query strings. The
most obvious example in this case is what if relname contains a quote
mark? Or backslash?

The permanent memory leak induced by SPI_saveplan() is another good
reason not to do it this way.

Finally, once one has written a nice neat little is_view() query
function, there's a strong temptation to just use it from anywhere,
without thought for the side-effects it might have like grabbing/
releasing locks, CommandCounterIncrement(), etc. There are many
places in the backend where the side-effects of doing a full query
evaluation would be harmful.

Mark's patch is OK as is, since it's merely relocating some poorly
written code and not trying to fix it, but someone ought to think
about fixing the code.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ross J. Reedstrom 2000-08-29 16:30:20 Re: How hard would a "no global server" version be?
Previous Message Mark Hollomon 2000-08-29 15:21:36 disallow LOCK on a view

Browse pgsql-patches by date

  From Date Subject
Next Message Mark Hollomon 2000-08-29 16:37:19 Re: Backend-internal SPI operations
Previous Message Mark Hollomon 2000-08-29 15:21:36 disallow LOCK on a view