~ubuntu-branches/ubuntu/trusty/postgresql-8.4/trusty

« back to all changes in this revision

Viewing changes to src/backend/executor/spi.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *
9
9
 *
10
10
 * IDENTIFICATION
11
 
 *        $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.207 2009/01/21 11:02:40 heikki Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.208 2009/06/11 14:48:57 momjian Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
45
45
static int      _SPI_curid = -1;
46
46
 
47
47
static Portal SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
48
 
                                                                           Datum *Values, const char *Nulls,
49
 
                                                                           bool read_only, int pflags);
 
48
                                                 Datum *Values, const char *Nulls,
 
49
                                                 bool read_only, int pflags);
50
50
 
51
51
static void _SPI_prepare_plan(const char *src, SPIPlanPtr plan,
52
 
                                                          ParamListInfo boundParams);
 
52
                                  ParamListInfo boundParams);
53
53
 
54
54
static int _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
55
55
                                  Snapshot snapshot, Snapshot crosscheck_snapshot,
308
308
bool
309
309
SPI_push_conditional(void)
310
310
{
311
 
        bool    pushed = (_SPI_curid != _SPI_connected);
 
311
        bool            pushed = (_SPI_curid != _SPI_connected);
312
312
 
313
313
        if (pushed)
314
314
        {
962
962
/*
963
963
 * SPI_cursor_open_with_args()
964
964
 *
965
 
 * Parse and plan a query and open it as a portal.  Like SPI_execute_with_args,
 
965
 * Parse and plan a query and open it as a portal.      Like SPI_execute_with_args,
966
966
 * we can tell the planner to rely on the parameter values as constants,
967
967
 * because the plan will only be used once.
968
968
 */
1212
1212
        }
1213
1213
 
1214
1214
        /*
1215
 
         * Set up the snapshot to use.  (PortalStart will do PushActiveSnapshot, so
1216
 
         * we skip that here.)
 
1215
         * Set up the snapshot to use.  (PortalStart will do PushActiveSnapshot,
 
1216
         * so we skip that here.)
1217
1217
         */
1218
1218
        if (read_only)
1219
1219
                snapshot = GetActiveSnapshot();
1767
1767
                        if (read_only && !CommandIsReadOnly(stmt))
1768
1768
                                ereport(ERROR,
1769
1769
                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1770
 
                                                 /* translator: %s is a SQL statement name */
1771
 
                                                 errmsg("%s is not allowed in a non-volatile function",
1772
 
                                                                CreateCommandTag(stmt))));
 
1770
                                /* translator: %s is a SQL statement name */
 
1771
                                           errmsg("%s is not allowed in a non-volatile function",
 
1772
                                                          CreateCommandTag(stmt))));
1773
1773
 
1774
1774
                        /*
1775
 
                         * If not read-only mode, advance the command counter before
1776
 
                         * each command.
 
1775
                         * If not read-only mode, advance the command counter before each
 
1776
                         * command.
1777
1777
                         */
1778
1778
                        if (!read_only)
1779
1779
                                CommandCounterIncrement();
1784
1784
                        {
1785
1785
                                /*
1786
1786
                                 * Default read_only behavior is to use the entry-time
1787
 
                                 * ActiveSnapshot, if any; if read-write, grab a full new snap.
 
1787
                                 * ActiveSnapshot, if any; if read-write, grab a full new
 
1788
                                 * snap.
1788
1789
                                 */
1789
1790
                                if (read_only)
1790
1791
                                {
1804
1805
                        {
1805
1806
                                /*
1806
1807
                                 * We interpret read_only with a specified snapshot to be
1807
 
                                 * exactly that snapshot, but read-write means use the
1808
 
                                 * snap with advancing of command ID.
 
1808
                                 * exactly that snapshot, but read-write means use the snap
 
1809
                                 * with advancing of command ID.
1809
1810
                                 */
1810
1811
                                if (read_only)
1811
1812
                                        PushActiveSnapshot(snapshot);
1839
1840
                                ProcessUtility(stmt,
1840
1841
                                                           plansource->query_string,
1841
1842
                                                           paramLI,
1842
 
                                                           false,               /* not top level */
 
1843
                                                           false,       /* not top level */
1843
1844
                                                           dest,
1844
1845
                                                           NULL);
1845
1846
                                /* Update "processed" if stmt returned tuples */
1853
1854
                                PopActiveSnapshot();
1854
1855
 
1855
1856
                        /*
1856
 
                         * The last canSetTag query sets the status values returned to
1857
 
                         * the caller.  Be careful to free any tuptables not returned,
1858
 
                         * to avoid intratransaction memory leak.
 
1857
                         * The last canSetTag query sets the status values returned to the
 
1858
                         * caller.      Be careful to free any tuptables not returned, to
 
1859
                         * avoid intratransaction memory leak.
1859
1860
                         */
1860
1861
                        if (canSetTag)
1861
1862
                        {
1884
1885
                cplan = NULL;
1885
1886
 
1886
1887
                /*
1887
 
                 * If not read-only mode, advance the command counter after the
1888
 
                 * last command.  This ensures that its effects are visible, in
1889
 
                 * case it was DDL that would affect the next CachedPlanSource.
 
1888
                 * If not read-only mode, advance the command counter after the last
 
1889
                 * command.  This ensures that its effects are visible, in case it was
 
1890
                 * DDL that would affect the next CachedPlanSource.
1890
1891
                 */
1891
1892
                if (!read_only)
1892
1893
                        CommandCounterIncrement();
1912
1913
        _SPI_current->tuptable = NULL;
1913
1914
 
1914
1915
        /*
1915
 
         * If none of the queries had canSetTag, return SPI_OK_REWRITTEN. Prior
1916
 
         * to 8.4, we used return the last query's result code, but not its
1917
 
         * auxiliary results, but that's confusing.
 
1916
         * If none of the queries had canSetTag, return SPI_OK_REWRITTEN. Prior to
 
1917
         * 8.4, we used return the last query's result code, but not its auxiliary
 
1918
         * results, but that's confusing.
1918
1919
         */
1919
1920
        if (my_res == 0)
1920
1921
                my_res = SPI_OK_REWRITTEN;
1938
1939
 
1939
1940
                /* sizeof(ParamListInfoData) includes the first array element */
1940
1941
                paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
1941
 
                                                                                 (nargs - 1) *sizeof(ParamExternData));
 
1942
                                                                           (nargs - 1) *sizeof(ParamExternData));
1942
1943
                paramLI->numParams = nargs;
1943
1944
 
1944
1945
                for (i = 0; i < nargs; i++)