@@ -1722,40 +1722,53 @@ int SPI_execute_plan(SPIPlanPtr <parameter>plan</parameter>, Datum * <parameter>
1722
1722
1723
1723
<!-- *********************************************** -->
1724
1724
1725
- <refentry id="spi-spi-execute-plan-with-paramlist ">
1726
- <indexterm><primary>SPI_execute_plan_with_paramlist </primary></indexterm>
1725
+ <refentry id="spi-spi-execute-plan-extended ">
1726
+ <indexterm><primary>SPI_execute_plan_extended </primary></indexterm>
1727
1727
1728
1728
<refmeta>
1729
- <refentrytitle>SPI_execute_plan_with_paramlist </refentrytitle>
1729
+ <refentrytitle>SPI_execute_plan_extended </refentrytitle>
1730
1730
<manvolnum>3</manvolnum>
1731
1731
</refmeta>
1732
1732
1733
1733
<refnamediv>
1734
- <refname>SPI_execute_plan_with_paramlist </refname>
1734
+ <refname>SPI_execute_plan_extended </refname>
1735
1735
<refpurpose>execute a statement prepared by <function>SPI_prepare</function></refpurpose>
1736
1736
</refnamediv>
1737
1737
1738
1738
<refsynopsisdiv>
1739
1739
<synopsis>
1740
- int SPI_execute_plan_with_paramlist(SPIPlanPtr <parameter>plan</parameter>,
1741
- ParamListInfo <parameter>params</parameter>,
1742
- bool <parameter>read_only</parameter>,
1743
- long <parameter>count</parameter>)
1740
+ int SPI_execute_plan_extended(SPIPlanPtr <parameter>plan</parameter>,
1741
+ const SPIExecuteOptions * <parameter>options</parameter>)
1744
1742
</synopsis>
1745
1743
</refsynopsisdiv>
1746
1744
1747
1745
<refsect1>
1748
1746
<title>Description</title>
1749
1747
1750
1748
<para>
1751
- <function>SPI_execute_plan_with_paramlist </function> executes a statement
1752
- prepared by <function>SPI_prepare</function>.
1753
- This function is equivalent to <function>SPI_execute_plan</function>
1749
+ <function>SPI_execute_plan_extended </function> executes a statement
1750
+ prepared by <function>SPI_prepare</function> or one of its siblings .
1751
+ This function is equivalent to <function>SPI_execute_plan</function>,
1754
1752
except that information about the parameter values to be passed to the
1755
- query is presented differently. The <literal>ParamListInfo</literal>
1756
- representation can be convenient for passing down values that are
1757
- already available in that format. It also supports use of dynamic
1758
- parameter sets via hook functions specified in <literal>ParamListInfo</literal>.
1753
+ query is presented differently, and additional execution-controlling
1754
+ options can be passed.
1755
+ </para>
1756
+
1757
+ <para>
1758
+ Query parameter values are represented by
1759
+ a <literal>ParamListInfo</literal> struct, which is convenient for passing
1760
+ down values that are already available in that format. Dynamic parameter
1761
+ sets can also be used, via hook functions specified
1762
+ in <literal>ParamListInfo</literal>.
1763
+ </para>
1764
+
1765
+ <para>
1766
+ Also, instead of always accumulating the result tuples into a
1767
+ <varname>SPI_tuptable</varname> structure, tuples can be passed to a
1768
+ caller-supplied <literal>DestReceiver</literal> object as they are
1769
+ generated by the executor. This is particularly helpful for queries
1770
+ that might generate many tuples, since the data can be processed
1771
+ on-the-fly instead of being accumulated in memory.
1759
1772
</para>
1760
1773
</refsect1>
1761
1774
@@ -1772,11 +1785,30 @@ int SPI_execute_plan_with_paramlist(SPIPlanPtr <parameter>plan</parameter>,
1772
1785
</listitem>
1773
1786
</varlistentry>
1774
1787
1788
+ <varlistentry>
1789
+ <term><literal>const SPIExecuteOptions * <parameter>options</parameter></literal></term>
1790
+ <listitem>
1791
+ <para>
1792
+ struct containing optional arguments
1793
+ </para>
1794
+ </listitem>
1795
+ </varlistentry>
1796
+ </variablelist>
1797
+
1798
+ <para>
1799
+ Callers should always zero out the entire <parameter>options</parameter>
1800
+ struct, then fill whichever fields they want to set. This ensures forward
1801
+ compatibility of code, since any fields that are added to the struct in
1802
+ future will be defined to behave backwards-compatibly if they are zero.
1803
+ The currently available <parameter>options</parameter> fields are:
1804
+ </para>
1805
+
1806
+ <variablelist>
1775
1807
<varlistentry>
1776
1808
<term><literal>ParamListInfo <parameter>params</parameter></literal></term>
1777
1809
<listitem>
1778
1810
<para>
1779
- data structure containing parameter types and values; NULL if none
1811
+ data structure containing query parameter types and values; NULL if none
1780
1812
</para>
1781
1813
</listitem>
1782
1814
</varlistentry>
@@ -1789,14 +1821,47 @@ int SPI_execute_plan_with_paramlist(SPIPlanPtr <parameter>plan</parameter>,
1789
1821
</varlistentry>
1790
1822
1791
1823
<varlistentry>
1792
- <term><literal>long <parameter>count</parameter></literal></term>
1824
+ <term><literal>bool <parameter>no_snapshots</parameter></literal></term>
1825
+ <listitem>
1826
+ <para>
1827
+ <literal>true</literal> prevents SPI from managing snapshots for
1828
+ execution of the query; use with extreme caution
1829
+ </para>
1830
+ </listitem>
1831
+ </varlistentry>
1832
+
1833
+ <varlistentry>
1834
+ <term><literal>uint64 <parameter>tcount</parameter></literal></term>
1793
1835
<listitem>
1794
1836
<para>
1795
1837
maximum number of rows to return,
1796
1838
or <literal>0</literal> for no limit
1797
1839
</para>
1798
1840
</listitem>
1799
1841
</varlistentry>
1842
+
1843
+ <varlistentry>
1844
+ <term><literal>DestReceiver * <parameter>dest</parameter></literal></term>
1845
+ <listitem>
1846
+ <para>
1847
+ <literal>DestReceiver</literal> object that will receive any tuples
1848
+ emitted by the query; if NULL, result tuples are accumulated into
1849
+ a <varname>SPI_tuptable</varname> structure, as
1850
+ in <function>SPI_execute_plan</function>
1851
+ </para>
1852
+ </listitem>
1853
+ </varlistentry>
1854
+
1855
+ <varlistentry>
1856
+ <term><literal>ResourceOwner <parameter>owner</parameter></literal></term>
1857
+ <listitem>
1858
+ <para>
1859
+ The resource owner that will hold a reference count on the plan while
1860
+ it is executed. If NULL, CurrentResourceOwner is used. Ignored for
1861
+ non-saved plans, as SPI does not acquire reference counts on those.
1862
+ </para>
1863
+ </listitem>
1864
+ </varlistentry>
1800
1865
</variablelist>
1801
1866
</refsect1>
1802
1867
@@ -1808,51 +1873,60 @@ int SPI_execute_plan_with_paramlist(SPIPlanPtr <parameter>plan</parameter>,
1808
1873
</para>
1809
1874
1810
1875
<para>
1876
+ When <parameter>dest</parameter> is NULL,
1811
1877
<varname>SPI_processed</varname> and
1812
1878
<varname>SPI_tuptable</varname> are set as in
1813
- <function>SPI_execute_plan</function> if successful.
1879
+ <function>SPI_execute_plan</function>.
1880
+ When <parameter>dest</parameter> is not NULL,
1881
+ <varname>SPI_processed</varname> is set to zero and
1882
+ <varname>SPI_tuptable</varname> is set to NULL. If a tuple count
1883
+ is required, the caller's <literal>DestReceiver</literal> object must
1884
+ calculate it.
1814
1885
</para>
1815
1886
</refsect1>
1816
1887
</refentry>
1817
1888
1818
1889
<!-- *********************************************** -->
1819
1890
1820
- <refentry id="spi-spi-execute-plan-with-receiver ">
1821
- <indexterm><primary>SPI_execute_plan_with_receiver </primary></indexterm>
1891
+ <refentry id="spi-spi-execute-plan-with-paramlist ">
1892
+ <indexterm><primary>SPI_execute_plan_with_paramlist </primary></indexterm>
1822
1893
1823
1894
<refmeta>
1824
- <refentrytitle>SPI_execute_plan_with_receiver </refentrytitle>
1895
+ <refentrytitle>SPI_execute_plan_with_paramlist </refentrytitle>
1825
1896
<manvolnum>3</manvolnum>
1826
1897
</refmeta>
1827
1898
1828
1899
<refnamediv>
1829
- <refname>SPI_execute_plan_with_receiver </refname>
1900
+ <refname>SPI_execute_plan_with_paramlist </refname>
1830
1901
<refpurpose>execute a statement prepared by <function>SPI_prepare</function></refpurpose>
1831
1902
</refnamediv>
1832
1903
1833
1904
<refsynopsisdiv>
1834
1905
<synopsis>
1835
- int SPI_execute_plan_with_receiver(SPIPlanPtr <parameter>plan</parameter>,
1836
- ParamListInfo <parameter>params</parameter>,
1837
- bool <parameter>read_only</parameter>,
1838
- long <parameter>count</parameter>,
1839
- DestReceiver *<parameter>dest</parameter>)
1906
+ int SPI_execute_plan_with_paramlist(SPIPlanPtr <parameter>plan</parameter>,
1907
+ ParamListInfo <parameter>params</parameter>,
1908
+ bool <parameter>read_only</parameter>,
1909
+ long <parameter>count</parameter>)
1840
1910
</synopsis>
1841
1911
</refsynopsisdiv>
1842
1912
1843
1913
<refsect1>
1844
1914
<title>Description</title>
1845
1915
1846
1916
<para>
1847
- <function>SPI_execute_plan_with_receiver</function> executes a statement
1848
- prepared by <function>SPI_prepare</function>. This function is
1849
- equivalent to <function>SPI_execute_plan_with_paramlist</function>
1850
- except that, instead of always accumulating the result tuples into a
1851
- <varname>SPI_tuptable</varname> structure, tuples can be passed to a
1852
- caller-supplied <literal>DestReceiver</literal> object as they are
1853
- generated by the executor. This is particularly helpful for queries
1854
- that might generate many tuples, since the data can be processed
1855
- on-the-fly instead of being accumulated in memory.
1917
+ <function>SPI_execute_plan_with_paramlist</function> executes a statement
1918
+ prepared by <function>SPI_prepare</function>.
1919
+ This function is equivalent to <function>SPI_execute_plan</function>
1920
+ except that information about the parameter values to be passed to the
1921
+ query is presented differently. The <literal>ParamListInfo</literal>
1922
+ representation can be convenient for passing down values that are
1923
+ already available in that format. It also supports use of dynamic
1924
+ parameter sets via hook functions specified in <literal>ParamListInfo</literal>.
1925
+ </para>
1926
+
1927
+ <para>
1928
+ This function is now deprecated in favor
1929
+ of <function>SPI_execute_plan_extended</function>.
1856
1930
</para>
1857
1931
</refsect1>
1858
1932
@@ -1894,17 +1968,6 @@ int SPI_execute_plan_with_receiver(SPIPlanPtr <parameter>plan</parameter>,
1894
1968
</para>
1895
1969
</listitem>
1896
1970
</varlistentry>
1897
-
1898
- <varlistentry>
1899
- <term><literal>DestReceiver * <parameter>dest</parameter></literal></term>
1900
- <listitem>
1901
- <para>
1902
- <literal>DestReceiver</literal> object that will receive any tuples
1903
- emitted by the query; if NULL, this function is exactly equivalent to
1904
- <function>SPI_execute_plan_with_paramlist</function>
1905
- </para>
1906
- </listitem>
1907
- </varlistentry>
1908
1971
</variablelist>
1909
1972
</refsect1>
1910
1973
@@ -1916,15 +1979,9 @@ int SPI_execute_plan_with_receiver(SPIPlanPtr <parameter>plan</parameter>,
1916
1979
</para>
1917
1980
1918
1981
<para>
1919
- When <parameter>dest</parameter> is NULL,
1920
1982
<varname>SPI_processed</varname> and
1921
1983
<varname>SPI_tuptable</varname> are set as in
1922
- <function>SPI_execute_plan</function>.
1923
- When <parameter>dest</parameter> is not NULL,
1924
- <varname>SPI_processed</varname> is set to zero and
1925
- <varname>SPI_tuptable</varname> is set to NULL. If a tuple count
1926
- is required, the caller's <literal>DestReceiver</literal> object must
1927
- calculate it.
1984
+ <function>SPI_execute_plan</function> if successful.
1928
1985
</para>
1929
1986
</refsect1>
1930
1987
</refentry>
0 commit comments