]> granicus.if.org Git - postgresql/commit
Add a stack overflow check to copyObject().
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 7 Dec 2010 03:56:12 +0000 (22:56 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 7 Dec 2010 03:56:12 +0000 (22:56 -0500)
commit0ae63a4fb2db1131e0715810199de0c0a8e7c2d8
tree1492fc203aa7a6f792fffc295d2349eec8614532
parent8a6eb2ee9895b88311d01fd0d54fb380304d3df6
Add a stack overflow check to copyObject().

There are some code paths, such as SPI_execute(), where we invoke
copyObject() on raw parse trees before doing parse analysis on them.  Since
the bison grammar is capable of building heavily nested parsetrees while
itself using only minimal stack depth, this means that copyObject() can be
the front-line function that hits stack overflow before anything else does.
Accordingly, it had better have a check_stack_depth() call.  I did a bit of
performance testing and found that this slows down copyObject() by only a
few percent, so the hit ought to be negligible in the context of complete
processing of a query.

Per off-list report from Toshihide Katayama.  Back-patch to all supported
branches.
src/backend/nodes/copyfuncs.c