SPI_SCRO...SOR_FETCH(3)
β¨ SPI_scroll_cursor_fetch β it's giving "fetch me some rows, bestie" π
okay so real talk, this is a page straight out of the PostgreSQL 18.6 Documentation manual, and it's all about SPI_scroll_cursor_fetch β the C-level glow-up of the SQL FETCH command. grab a lil snack, we're getting into it π
π NAME π
SPI_scroll_cursor_fetch β fetch some rows from a cursor
πΈ SYNOPSIS πΈ
void SPI_scroll_cursor_fetch(Portal portal, FetchDirection direction,
long count)
π¦ DESCRIPTION π¦
so SPI_scroll_cursor_fetch does exactly what it says on the tin: it fetches some rows from a cursor. no cap. it is equivalent to the SQL command FETCH β like, spiritually the same thing, just living down here in C land. π
π ARGUMENTS π
Portal portalβ the portal that's holding the cursor. it's literally the container for the whole vibe.FetchDirection directionβ you gotta pick one, and your options are:FETCH_FORWARD,FETCH_BACKWARD,FETCH_ABSOLUTEorFETCH_RELATIVE. choose wisely bestie.long countβ the number. but like, the number means different things depending on the direction you picked:- for
FETCH_FORWARDorFETCH_BACKWARDit's the number of rows to fetch; - for
FETCH_ABSOLUTEit's the absolute row number to fetch; - for
FETCH_RELATIVEit's the relative row number to fetch.
- for
π₯ RETURN VALUE π₯
if it works, SPI_processed and SPI_tuptable get set exactly like they do in SPI_execute. same energy, same deal. β¨
π NOTES π
- for the full tea on how
directionandcountare actually interpreted, go read the SQLFETCH(7)command. that's where the details live. π
π¨ okay important one: direction values that aren'tFETCH_FORWARDmay fail if the cursor's plan wasn't created with theCURSOR_OPT_SCROLLoption. so likeβ¦ if you're scrolling backward and it's not working, that's probably why. not a vibe, but that's the rule. π
that's the whole page bestie, no skips, every flag and caveat intact π«Ά go forth and fetch responsibly.
PostgreSQL 18.6 Β· dated 2026 Β· SPI_SCRO...SOR_FETCH(3) β mwah, periodt π
π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql18-docs 18.6-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms