PostgreSQL 7.3.4 Documentation
Prev |  | Next

# SPI_modifytuple

## Name

SPI_modifytuple -- Creates a tuple by replacing selected fields of a given tuple

## Synopsis

    SPI_modifytuple(rel, tuple, nattrs, attnum, Values, Nulls)

### Inputs

Relation rel

  Used only as source of tuple descriptor for tuple. (Passing a relation rather than a tuple descriptor is a misfeature.)

HeapTuple tuple

  Input tuple to be modified

int nattrs

  Number of attribute numbers in attnum array

int * attnum

  Array of numbers of the attributes that are to be changed

Datum * Values

  New values for the attributes specified

char * Nulls

  Which new values are NULL, if any

### Outputs

HeapTuple

  New tuple with modifications

  non-NULL if tuple is not NULL and the modify was successful
  NULL only if tuple is NULL

SPI_result

  SPI_ERROR_ARGUMENT if rel is NULL or tuple is NULL or natts <= 0 or attnum is NULL or Values is NULL.
  SPI_ERROR_NOATTRIBUTE if there is an invalid attribute number in attnum (attnum <= 0 or > number of attributes in tuple)

## Description

`SPI_modifytuple` creates a new tuple by substituting new values for selected attributes, copying the original tuple's attributes at other positions. The input tuple is not modified.

## Usage

If successful, a pointer to the new tuple is returned. The new tuple is allocated in upper Executor context.

Prev | Home | Next
SPI_copytupleintoslot | Up | SPI_palloc