~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/backend/commands/async.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:
7
7
 * Portions Copyright (c) 1994, Regents of the University of California
8
8
 *
9
9
 * IDENTIFICATION
10
 
 *        $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.146 2009/02/13 17:12:04 tgl Exp $
 
10
 *        $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.147 2009/06/11 14:48:55 momjian Exp $
11
11
 *
12
12
 *-------------------------------------------------------------------------
13
13
 */
53
53
 *        transaction.
54
54
 *
55
55
 * Like NOTIFY, LISTEN and UNLISTEN just add the desired action to a list
56
 
 * of pending actions.  If we reach transaction commit, the changes are
 
56
 * of pending actions.  If we reach transaction commit, the changes are
57
57
 * applied to pg_listener just before executing any pending NOTIFYs.  This
58
58
 * method is necessary because to avoid race conditions, we must hold lock
59
59
 * on pg_listener from when we insert a new listener tuple until we commit.
124
124
typedef struct
125
125
{
126
126
        ListenActionKind action;
127
 
        char            condname[1];                            /* actually, as long as needed */
 
127
        char            condname[1];    /* actually, as long as needed */
128
128
} ListenAction;
129
129
 
130
 
static List *pendingActions = NIL;                      /* list of ListenAction */
 
130
static List *pendingActions = NIL;              /* list of ListenAction */
131
131
 
132
 
static List *upperPendingActions = NIL;         /* list of upper-xact lists */
 
132
static List *upperPendingActions = NIL; /* list of upper-xact lists */
133
133
 
134
134
/*
135
135
 * State for outbound notifies consists of a list of all relnames NOTIFYed
147
147
 * condition name, it will get a self-notify at commit.  This is a bit odd
148
148
 * but is consistent with our historical behavior.
149
149
 */
150
 
static List *pendingNotifies = NIL;                             /* list of C strings */
 
150
static List *pendingNotifies = NIL;             /* list of C strings */
151
151
 
152
152
static List *upperPendingNotifies = NIL;                /* list of upper-xact lists */
153
153
 
209
209
                oldcontext = MemoryContextSwitchTo(CurTransactionContext);
210
210
 
211
211
                /*
212
 
                 * Ordering of the list isn't important.  We choose to put new
213
 
                 * entries on the front, as this might make duplicate-elimination
214
 
                 * a tad faster when the same condition is signaled many times in
215
 
                 * a row.
 
212
                 * Ordering of the list isn't important.  We choose to put new entries
 
213
                 * on the front, as this might make duplicate-elimination a tad faster
 
214
                 * when the same condition is signaled many times in a row.
216
215
                 */
217
216
                pendingNotifies = lcons(pstrdup(relname), pendingNotifies);
218
217
 
235
234
        ListenAction *actrec;
236
235
 
237
236
        /*
238
 
         * Unlike Async_Notify, we don't try to collapse out duplicates.
239
 
         * It would be too complicated to ensure we get the right interactions
240
 
         * of conflicting LISTEN/UNLISTEN/UNLISTEN_ALL, and it's unlikely that
241
 
         * there would be any performance benefit anyway in sane applications.
 
237
         * Unlike Async_Notify, we don't try to collapse out duplicates. It would
 
238
         * be too complicated to ensure we get the right interactions of
 
239
         * conflicting LISTEN/UNLISTEN/UNLISTEN_ALL, and it's unlikely that there
 
240
         * would be any performance benefit anyway in sane applications.
242
241
         */
243
242
        oldcontext = MemoryContextSwitchTo(CurTransactionContext);
244
243
 
488
487
        namestrcpy(&condname, relname);
489
488
        values[Anum_pg_listener_relname - 1] = NameGetDatum(&condname);
490
489
        values[Anum_pg_listener_pid - 1] = Int32GetDatum(MyProcPid);
491
 
        values[Anum_pg_listener_notify - 1] = Int32GetDatum(0); /* no notifies pending */
 
490
        values[Anum_pg_listener_notify - 1] = Int32GetDatum(0);         /* no notifies pending */
492
491
 
493
492
        tuple = heap_form_tuple(RelationGetDescr(lRel), values, nulls);
494
493
 
755
754
        int                     my_level = GetCurrentTransactionNestLevel();
756
755
 
757
756
        /*
758
 
         * All we have to do is pop the stack --- the actions/notifies made in this
759
 
         * subxact are no longer interesting, and the space will be freed when
760
 
         * CurTransactionContext is recycled.
 
757
         * All we have to do is pop the stack --- the actions/notifies made in
 
758
         * this subxact are no longer interesting, and the space will be freed
 
759
         * when CurTransactionContext is recycled.
761
760
         *
762
761
         * This routine could be called more than once at a given nesting level if
763
762
         * there is trouble during subxact abort.  Avoid dumping core by using