SPI_CURSOR_FETCH(3)
β¨ SPI_CURSOR_FETCH β¨
okay bestie, welcome to SPI_cursor_fetch from the PostgreSQL 15.19 docs π
this is a libpq-adjacent... no wait, it's a server-side SPI situation, and it's lowkey iconic. Buckle up π
πΈ NAME πΈ
SPI_cursor_fetch β grab some rows out of a cursor, fr fr π«Ά
π¦ SYNOPSIS π¦
void SPI_cursor_fetch(Portal portal, bool forward, long count)
that's the whole vibe. one function, three args, zero drama β¨
π DESCRIPTION π
so SPI_cursor_fetch fetches some rows from a cursor. that's it, that's the tweet π¦
the docs are very clear that this is equivalent to a subset of the SQL command FETCH β like, not the whole thing, just a lil slice of it. and if you want more functionality (aka the main character version), the page literally points you at SPI_scroll_cursor_fetch. iykyk π
π ARGUMENTS π
Portal portalβ the portal that's holding your cursor. that's the container, the vessel, the home of the vibe πbool forwardβtruemeans fetch forward,falsemeans fetch backward. yes it's just a boolean, no it's not that deep (except when it is, see NOTES π)long countβ the maximum number of rows to fetch. maximum, bestie, not a promise, not a guarantee, just a ceiling π§
β RETURN VALUE β
if it succeeds, SPI_processed and SPI_tuptable get set β exactly the same way they get set in SPI_execute. so if you already know how that works, you already know how this works. slay π
π NOTES π
fetching backward may fail if the cursor's plan was not created with the CURSOR_OPT_SCROLL option π
like, genuinely β that's a real caveat, not a vibe. if you didn't build the plan with CURSOR_OPT_SCROLL, going backwards can just... not work. no cap. plan accordingly π«‘
mwah π that's the whole page, bestie β go forth and fetch responsibly. this lil number comes to you from PostgreSQL 15.19, dated 2026, and honestly? it ate. periodt. πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15-docs 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms