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

« back to all changes in this revision

Viewing changes to src/backend/catalog/toasting.c

Tags: upstream-8.4.0
ImportĀ upstreamĀ versionĀ 8.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 * Portions Copyright (c) 1994, Regents of the University of California
9
9
 *
10
10
 * IDENTIFICATION
11
 
 *        $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.15 2009/05/07 22:58:28 tgl Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.17 2009/06/11 20:46:11 tgl Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
43
43
 *              then create a toast table for it.  (With the force option, make
44
44
 *              a toast table even if it appears unnecessary.)
45
45
 *
 
46
 * The caller can also specify the OID to be used for the toast table.
 
47
 * Usually, toastOid should be InvalidOid to allow a free OID to be assigned.
 
48
 * (This option, as well as the force option, is not used by core Postgres,
 
49
 * but is provided to support pg_migrator.)
 
50
 *
46
51
 * reloptions for the toast table can be passed, too.  Pass (Datum) 0
47
52
 * for default reloptions.
48
53
 *
51
56
 * to end with CommandCounterIncrement if it makes any changes.
52
57
 */
53
58
void
54
 
AlterTableCreateToastTable(Oid relOid, Datum reloptions, bool force)
 
59
AlterTableCreateToastTable(Oid relOid, Oid toastOid,
 
60
                                                   Datum reloptions, bool force)
55
61
{
56
62
        Relation        rel;
57
63
 
63
69
        rel = heap_open(relOid, AccessExclusiveLock);
64
70
 
65
71
        /* create_toast_table does all the work */
66
 
        (void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions, force);
 
72
        (void) create_toast_table(rel, toastOid, InvalidOid, reloptions, force);
67
73
 
68
74
        heap_close(rel, NoLock);
69
75
}
101
107
 * create_toast_table --- internal workhorse
102
108
 *
103
109
 * rel is already opened and exclusive-locked
104
 
 * toastOid and toastIndexOid are normally InvalidOid, but during
105
 
 * bootstrap they can be nonzero to specify hand-assigned OIDs
 
110
 * toastOid and toastIndexOid are normally InvalidOid, but
 
111
 * either or both can be nonzero to specify caller-assigned OIDs
106
112
 */
107
113
static bool
108
114
create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
145
151
        /*
146
152
         * Check to see whether the table actually needs a TOAST table.
147
153
         *
148
 
         * Caller can optionally override this check.  (Note: at present
149
 
         * no callers in core Postgres do so, but this option is needed by
 
154
         * Caller can optionally override this check.  (Note: at present no
 
155
         * callers in core Postgres do so, but this option is needed by
150
156
         * pg_migrator.)
151
157
         */
152
158
        if (!force && !needs_toast_table(rel))