gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
7.0KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>SPI_modifytuple</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="spi-spi-returntuple.html" title="SPI_returntuple" /><link rel="next" href="spi-spi-freetuple.html" title="SPI_freetuple" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">SPI_modifytuple</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="spi-spi-returntuple.html" title="SPI_returntuple">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="spi-memory.html" title="46.3. Memory Management">Up</a></td><th width="60%" align="center">46.3. Memory Management</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="spi-spi-freetuple.html" title="SPI_freetuple">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SPI-SPI-MODIFYTUPLE"><div class="titlepage"></div><a id="id-1.8.12.10.11.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">SPI_modifytuple</span></h2><p>SPI_modifytuple — create a row by replacing selected fields of a given row</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. HeapTuple SPI_modifytuple(Relation <em class="parameter"><code>rel</code></em>, HeapTuple <em class="parameter"><code>row</code></em>, int <em class="parameter"><code>ncols</code></em>,
  4. int * <em class="parameter"><code>colnum</code></em>, Datum * <em class="parameter"><code>values</code></em>, const char * <em class="parameter"><code>nulls</code></em>)
  5. </pre></div><div class="refsect1" id="id-1.8.12.10.11.5"><h2>Description</h2><p>
  6. <code class="function">SPI_modifytuple</code> creates a new row by
  7. substituting new values for selected columns, copying the original
  8. row's columns at other positions. The input row is not modified.
  9. The new row is returned in the upper executor context.
  10. </p><p>
  11. This function can only be used while connected to SPI.
  12. Otherwise, it returns NULL and sets <code class="varname">SPI_result</code> to
  13. <code class="symbol">SPI_ERROR_UNCONNECTED</code>.
  14. </p></div><div class="refsect1" id="id-1.8.12.10.11.6"><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">Relation <em class="parameter"><code>rel</code></em></code></span></dt><dd><p>
  15. Used only as the source of the row descriptor for the row.
  16. (Passing a relation rather than a row descriptor is a
  17. misfeature.)
  18. </p></dd><dt><span class="term"><code class="literal">HeapTuple <em class="parameter"><code>row</code></em></code></span></dt><dd><p>
  19. row to be modified
  20. </p></dd><dt><span class="term"><code class="literal">int <em class="parameter"><code>ncols</code></em></code></span></dt><dd><p>
  21. number of columns to be changed
  22. </p></dd><dt><span class="term"><code class="literal">int * <em class="parameter"><code>colnum</code></em></code></span></dt><dd><p>
  23. an array of length <em class="parameter"><code>ncols</code></em>, containing the numbers
  24. of the columns that are to be changed (column numbers start at 1)
  25. </p></dd><dt><span class="term"><code class="literal">Datum * <em class="parameter"><code>values</code></em></code></span></dt><dd><p>
  26. an array of length <em class="parameter"><code>ncols</code></em>, containing the
  27. new values for the specified columns
  28. </p></dd><dt><span class="term"><code class="literal">const char * <em class="parameter"><code>nulls</code></em></code></span></dt><dd><p>
  29. an array of length <em class="parameter"><code>ncols</code></em>, describing which
  30. new values are null
  31. </p><p>
  32. If <em class="parameter"><code>nulls</code></em> is <code class="symbol">NULL</code> then
  33. <code class="function">SPI_modifytuple</code> assumes that no new values
  34. are null. Otherwise, each entry of the <em class="parameter"><code>nulls</code></em>
  35. array should be <code class="literal">' '</code> if the corresponding new value is
  36. non-null, or <code class="literal">'n'</code> if the corresponding new value is
  37. null. (In the latter case, the actual value in the corresponding
  38. <em class="parameter"><code>values</code></em> entry doesn't matter.) Note that
  39. <em class="parameter"><code>nulls</code></em> is not a text string, just an array: it
  40. does not need a <code class="literal">'\0'</code> terminator.
  41. </p></dd></dl></div></div><div class="refsect1" id="id-1.8.12.10.11.7"><h2>Return Value</h2><p>
  42. new row with modifications, allocated in the upper executor
  43. context, or <code class="symbol">NULL</code> on error
  44. (see <code class="varname">SPI_result</code> for an error indication)
  45. </p><p>
  46. On error, <code class="varname">SPI_result</code> is set as follows:
  47. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="symbol">SPI_ERROR_ARGUMENT</code></span></dt><dd><p>
  48. if <em class="parameter"><code>rel</code></em> is <code class="symbol">NULL</code>, or if
  49. <em class="parameter"><code>row</code></em> is <code class="symbol">NULL</code>, or if <em class="parameter"><code>ncols</code></em>
  50. is less than or equal to 0, or if <em class="parameter"><code>colnum</code></em> is
  51. <code class="symbol">NULL</code>, or if <em class="parameter"><code>values</code></em> is <code class="symbol">NULL</code>.
  52. </p></dd><dt><span class="term"><code class="symbol">SPI_ERROR_NOATTRIBUTE</code></span></dt><dd><p>
  53. if <em class="parameter"><code>colnum</code></em> contains an invalid column number (less
  54. than or equal to 0 or greater than the number of columns in
  55. <em class="parameter"><code>row</code></em>)
  56. </p></dd><dt><span class="term"><code class="symbol">SPI_ERROR_UNCONNECTED</code></span></dt><dd><p>
  57. if SPI is not active
  58. </p></dd></dl></div><p>
  59. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="spi-spi-returntuple.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="spi-memory.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="spi-spi-freetuple.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">SPI_returntuple </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> SPI_freetuple</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1