SPI: process exit in SPI_exec when table not exist. error code not return.

Started by sasa sualmost 5 years ago3 messages
#1sasa su
i@sasa.su

<div>Hi.</div><div> </div><div>When running a query with a not exist table in SPI_exec. the process exit with -1 in SPI_exec function.</div><div>the error code SPI_ERROR_REL_NOT_FOUND never return.</div><div> </div><div>I made a minimal reproduction code in https://github.com/Sasasu/worker_spi_table_not_exist&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;The core code is:</div><div> </div><div><div>   int spi = SPI_exec("select * from not_exist_table", 0);</div><div>   // can not reach here<br />   Assert(spi == SPI_ERROR_REL_NOT_FOUND);</div></div><div> </div><div><div>I think it is a bug, PG_TRY macro it not mentioned in SPI document.</div><div><div>The code inside SPI should be wrapped with PG_TRY macro.</div></div></div>

#2Ian Lawrence Barwick
barwick@gmail.com
In reply to: sasa su (#1)
Re: SPI: process exit in SPI_exec when table not exist. error code not return.

2021年2月5日(金) 11:38 sasa su <i@sasa.su>:

Hi.

When running a query with a not exist table in SPI_exec. the process exit
with -1 in SPI_exec function.
the error code SPI_ERROR_REL_NOT_FOUND never return.

I made a minimal reproduction code in
https://github.com/Sasasu/worker_spi_table_not_exist

The core code is:

int spi = SPI_exec("select * from not_exist_table", 0);
// can not reach here
Assert(spi == SPI_ERROR_REL_NOT_FOUND);

The list of return codes returned by SPI_exec is here:

https://www.postgresql.org/docs/current/spi-spi-execute.html

and doesn't include "SPI_ERROR_REL_NOT_FOUND". The only
function which does return that is SPI_unregister_relation, see:

https://www.postgresql.org/docs/current/spi-spi-unregister-relation.html

Regards

Ian Barwick

--
EnterpriseDB: https://www.enterprisedb.com

#3sasa su
i@sasa.su
In reply to: Ian Lawrence Barwick (#2)
Re: SPI: process exit in SPI_exec when table not exist. error code not return.

<div>Thanks barwick,</div><div> </div><div><div>Is the process crash also expected,</div><div> </div><div><div>And dose anyone considered enhancing this API?</div></div></div><div> </div><div>05.02.2021, 10:55, "Ian Lawrence Barwick" &lt;barwick@gmail.com&gt;:</div><blockquote><div><div><div>2021年2月5日(金) 11:38 sasa su &lt;<a href="mailto:i@sasa.su" rel="noopener noreferrer">i@sasa.su</a>&gt;:</div><blockquote style="border-left-color:rgb( 204 , 204 , 204 );border-left-style:solid;border-left-width:1px;margin:0px 0px 0px 0.8ex;padding-left:1ex"><div>Hi.</div><div> </div><div>When running a query with a not exist table in SPI_exec. the process exit with -1 in SPI_exec function.</div><div>the error code SPI_ERROR_REL_NOT_FOUND never return.</div><div> </div><div>I made a minimal reproduction code in <a href="https://github.com/Sasasu/worker_spi_table_not_exist&quot; rel="noopener noreferrer" target="_blank">https://github.com/Sasasu/worker_spi_table_not_exist&lt;/a&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;The core code is:</div><div> </div><div><div>   int spi = SPI_exec("select * from not_exist_table", 0);</div><div>   // can not reach here<br />   Assert(spi == SPI_ERROR_REL_NOT_FOUND);</div></div></blockquote><div> </div><div> </div><div>The list of return codes returned by SPI_exec is here:</div><div> </div><div>   <a href="https://www.postgresql.org/docs/current/spi-spi-execute.html&quot; rel="noopener noreferrer">https://www.postgresql.org/docs/current/spi-spi-execute.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;and doesn't include "SPI_ERROR_REL_NOT_FOUND". The only</div><div>function which does return that is SPI_unregister_relation, see:</div><div> </div><div>  <a href="https://www.postgresql.org/docs/current/spi-spi-unregister-relation.html&quot; rel="noopener noreferrer">https://www.postgresql.org/docs/current/spi-spi-unregister-relation.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Regards&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Ian Barwick</div></div><br /><br />--<div><div>EnterpriseDB: <a href="https://www.enterprisedb.com/&quot; rel="noopener noreferrer" target="_blank">https://www.enterprisedb.com&lt;/a&gt;&lt;div&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;