SPI_CURSOR_FETCH(3)

πŸ“¦ version 15.19, in opensuse-leap 16.0

✨ 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 β€” true means fetch forward, false means 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