What is the story behind _SPI_PLAN_MAGIC?

Started by Marcelo Fernandesabout 1 year ago3 messagesgeneral
Jump to latest
#1Marcelo Fernandes
marcefern7@gmail.com

Hi there,

Reading through the SPI code I see this definition:

#define _SPI_PLAN_MAGIC 569278163

Which is used in he _SPI_plan struct in src/include/executor/spi_priv.h:

typedef struct _SPI_plan
{
int magic;
...
}

What is its purpose?

Thank you.
Marcelo

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marcelo Fernandes (#1)
Re: What is the story behind _SPI_PLAN_MAGIC?

Marcelo Fernandes <marcefern7@gmail.com> writes:

Reading through the SPI code I see this definition:
#define _SPI_PLAN_MAGIC 569278163
What is its purpose?

Just to catch programming errors, ie passing the wrong pointer
value to some SPI function. See the checks for it in spi.c.

regards, tom lane

#3Marcelo Fernandes
marcefern7@gmail.com
In reply to: Tom Lane (#2)
Re: What is the story behind _SPI_PLAN_MAGIC?

On Mon, Feb 3, 2025 at 3:17 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Just to catch programming errors, ie passing the wrong pointer
value to some SPI function. See the checks for it in spi.c.

Aha! Perfect, I thought it was something like that. Thank you!
Marcelo.