Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-07 Thread Tom Lane
Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> Comments? > +1 to backpatching it all, including the initialization in SPI_connect. Done. regards, tom lane

Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-06 Thread Andrew Gierth
> "Tom" == Tom Lane writes: Tom> Also, in further service of providing insulation between SPI Tom> nesting levels, I thought it'd be a good idea for SPI_connect() to Tom> reset the globals to zero/NULL after saving them. This ensures Tom> that a nesting level can't accidentally be affecte

Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-06 Thread Tom Lane
Peter Eisentraut writes: > On 06/09/2018 18:25, Tom Lane wrote: >> Also, in further service of providing insulation between SPI nesting >> levels, I thought it'd be a good idea for SPI_connect() to reset the >> globals to zero/NULL after saving them. This ensures that a nesting >> level can't acc

Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-06 Thread Peter Eisentraut
On 06/09/2018 18:25, Tom Lane wrote: > Here's a proposed patch along that line. I included SPI_result (SPI's > equivalent of errno) in the set of saved-and-restored variables, > so that all the exposed SPI globals behave the same. > > Also, in further service of providing insulation between SPI n

Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-06 Thread Tom Lane
I wrote: > Chapman Flack writes: >> Another alternative might be to have SPI_connect save them and >> SPI_finish put them back, which leaves you just responsible for >> reasoning about your own code. You'd still be expected to save them >> across your own uses of other SPI calls, but no longer exp

Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-05 Thread Tom Lane
Chapman Flack writes: > On 09/05/18 18:07, Tom Lane wrote: >> * Replace SPI_tuptable et al with macros that access fields in the >> current SPI stack level (similar to the way that, eg, errno works >> on most modern platforms). This seems do-able, if a bit grotty. > It would mean they'd have to

Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-05 Thread Chapman Flack
On 09/05/18 18:07, Tom Lane wrote: > * Replace SPI_tuptable et al with macros that access fields in the > current SPI stack level (similar to the way that, eg, errno works > on most modern platforms). This seems do-able, if a bit grotty. It would mean they'd have to *be* in the stack frame, wher

Re: *_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-05 Thread Tom Lane
Chapman Flack writes: > In xml.c, query_to_xml_internal() contains a loop that refers > to SPI_processed every iteration: > for (i = 0; i < SPI_processed; i++) > SPI_sql_row_to_xmlelement(i, result, tablename, nulls, > tableforest, targetns, top_level); > likewise

*_to_xml() should copy SPI_processed/SPI_tuptable

2018-09-05 Thread Chapman Flack
I encountered this in 9.5 and haven't yet written a reproducer for 10 or 11, but the code in question looks the same in master. In xml.c, query_to_xml_internal() contains a loop that refers to SPI_processed every iteration: for (i = 0; i < SPI_processed; i++) SPI_sql_row_to_xmlelement(i, res