1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* indexing.c
|
2002-08-05 05:29:17 +02:00
|
|
|
* This file contains routines to support indexes defined on system
|
1997-09-07 07:04:48 +02:00
|
|
|
* catalogs.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2019-01-02 18:44:25 +01:00
|
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/backend/catalog/indexing.c
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1998-04-27 06:08:07 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
|
2019-01-15 02:02:12 +01:00
|
|
|
#include "access/genam.h"
|
Don't include heapam.h from others headers.
heapam.h previously was included in a number of widely used
headers (e.g. execnodes.h, indirectly in executor.h, ...). That's
problematic on its own, as heapam.h contains a lot of low-level
details that don't need to be exposed that widely, but becomes more
problematic with the upcoming introduction of pluggable table storage
- it seems inappropriate for heapam.h to be included that widely
afterwards.
heapam.h was largely only included in other headers to get the
HeapScanDesc typedef (which was defined in heapam.h, even though
HeapScanDescData is defined in relscan.h). The better solution here
seems to be to just use the underlying struct (forward declared where
necessary). Similar for BulkInsertState.
Another problem was that LockTupleMode was used in executor.h - parts
of the file tried to cope without heapam.h, but due to the fact that
it indirectly included it, several subsequent violations of that goal
were not not noticed. We could just reuse the approach of declaring
parameters as int, but it seems nicer to move LockTupleMode to
lockoptions.h - that's not a perfect location, but also doesn't seem
bad.
As a number of files relied on implicitly included heapam.h, a
significant number of files grew an explicit include. It's quite
probably that a few external projects will need to do the same.
Author: Andres Freund
Reviewed-By: Alvaro Herrera
Discussion: https://postgr.es/m/20190114000701.y4ttcb74jpskkcfb@alap3.anarazel.de
2019-01-15 00:54:18 +01:00
|
|
|
#include "access/heapam.h"
|
2012-08-30 22:15:44 +02:00
|
|
|
#include "access/htup_details.h"
|
1998-04-27 06:08:07 +02:00
|
|
|
#include "catalog/index.h"
|
|
|
|
#include "catalog/indexing.h"
|
2002-08-05 05:29:17 +02:00
|
|
|
#include "executor/executor.h"
|
2011-02-23 18:18:09 +01:00
|
|
|
#include "utils/rel.h"
|
This patch implements ORACLE's COMMENT SQL command.
>From the ORACLE 7 SQL Language Reference Manual:
-----------------------------------------------------
COMMENT
Purpose:
To add a comment about a table, view, snapshot, or
column into the data dictionary.
Prerequisites:
The table, view, or snapshot must be in your own
schema
or you must have COMMENT ANY TABLE system privilege.
Syntax:
COMMENT ON [ TABLE table ] |
[ COLUMN table.column] IS 'text'
You can effectively drop a comment from the database
by setting it to the empty string ''.
-----------------------------------------------------
Example:
COMMENT ON TABLE workorders IS
'Maintains base records for workorder information';
COMMENT ON COLUMN workorders.hours IS
'Number of hours the engineer worked on the task';
to drop a comment:
COMMENT ON COLUMN workorders.hours IS '';
The current patch will simply perform the insert into
pg_description, as per the TODO. And, of course, when
the table is dropped, any comments relating to it
or any of its attributes are also dropped. I haven't
looked at the ODBC source yet, but I do know from
an ODBC client standpoint that the standard does
support the notion of table and column comments.
Hopefully the ODBC driver is already fetching these
values from pg_description, but if not, it should be
trivial.
Hope this makes the grade,
Mike Mascari
(mascarim@yahoo.com)
1999-10-15 03:49:49 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
2002-08-05 05:29:17 +02:00
|
|
|
* CatalogOpenIndexes - open the indexes on a system catalog.
|
|
|
|
*
|
|
|
|
* When inserting or updating tuples in a system catalog, call this
|
|
|
|
* to prepare to update the indexes for the catalog.
|
|
|
|
*
|
|
|
|
* In the current implementation, we share code for opening/closing the
|
|
|
|
* indexes with execUtils.c. But we do not use ExecInsertIndexTuples,
|
|
|
|
* because we don't want to create an EState. This implies that we
|
2009-12-07 06:22:23 +01:00
|
|
|
* do not support partial or expressional indexes on system catalogs,
|
|
|
|
* nor can we support generalized exclusion constraints.
|
2003-05-28 18:04:02 +02:00
|
|
|
* This could be fixed with localized changes here if we wanted to pay
|
|
|
|
* the extra overhead of building an EState.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-08-05 05:29:17 +02:00
|
|
|
CatalogIndexState
|
|
|
|
CatalogOpenIndexes(Relation heapRel)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-08-05 05:29:17 +02:00
|
|
|
ResultRelInfo *resultRelInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-08-05 05:29:17 +02:00
|
|
|
resultRelInfo = makeNode(ResultRelInfo);
|
2018-10-04 20:03:37 +02:00
|
|
|
resultRelInfo->ri_RangeTableIndex = 0; /* dummy */
|
2002-08-05 05:29:17 +02:00
|
|
|
resultRelInfo->ri_RelationDesc = heapRel;
|
2002-09-04 22:31:48 +02:00
|
|
|
resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */
|
2002-08-05 05:29:17 +02:00
|
|
|
|
Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
The newly added ON CONFLICT clause allows to specify an alternative to
raising a unique or exclusion constraint violation error when inserting.
ON CONFLICT refers to constraints that can either be specified using a
inference clause (by specifying the columns of a unique constraint) or
by naming a unique or exclusion constraint. DO NOTHING avoids the
constraint violation, without touching the pre-existing row. DO UPDATE
SET ... [WHERE ...] updates the pre-existing tuple, and has access to
both the tuple proposed for insertion and the existing tuple; the
optional WHERE clause can be used to prevent an update from being
executed. The UPDATE SET and WHERE clauses have access to the tuple
proposed for insertion using the "magic" EXCLUDED alias, and to the
pre-existing tuple using the table name or its alias.
This feature is often referred to as upsert.
This is implemented using a new infrastructure called "speculative
insertion". It is an optimistic variant of regular insertion that first
does a pre-check for existing tuples and then attempts an insert. If a
violating tuple was inserted concurrently, the speculatively inserted
tuple is deleted and a new attempt is made. If the pre-check finds a
matching tuple the alternative DO NOTHING or DO UPDATE action is taken.
If the insertion succeeds without detecting a conflict, the tuple is
deemed inserted.
To handle the possible ambiguity between the excluded alias and a table
named excluded, and for convenience with long relation names, INSERT
INTO now can alias its target table.
Bumps catversion as stored rules change.
Author: Peter Geoghegan, with significant contributions from Heikki
Linnakangas and Andres Freund. Testing infrastructure by Jeff Janes.
Reviewed-By: Heikki Linnakangas, Andres Freund, Robert Haas, Simon Riggs,
Dean Rasheed, Stephen Frost and many others.
2015-05-08 05:31:36 +02:00
|
|
|
ExecOpenIndices(resultRelInfo, false);
|
2002-08-05 05:29:17 +02:00
|
|
|
|
|
|
|
return resultRelInfo;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-08-05 05:29:17 +02:00
|
|
|
* CatalogCloseIndexes - clean up resources allocated by CatalogOpenIndexes
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
void
|
2002-08-05 05:29:17 +02:00
|
|
|
CatalogCloseIndexes(CatalogIndexState indstate)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-08-05 05:29:17 +02:00
|
|
|
ExecCloseIndices(indstate);
|
|
|
|
pfree(indstate);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-08-05 05:29:17 +02:00
|
|
|
* CatalogIndexInsert - insert index entries for one catalog tuple
|
2000-07-15 00:18:02 +02:00
|
|
|
*
|
2002-08-05 05:29:17 +02:00
|
|
|
* This should be called for each inserted or updated catalog tuple.
|
2000-07-15 00:18:02 +02:00
|
|
|
*
|
2002-08-05 05:29:17 +02:00
|
|
|
* This is effectively a cut-down version of ExecInsertIndexTuples.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2017-02-01 23:18:36 +01:00
|
|
|
static void
|
2002-08-05 05:29:17 +02:00
|
|
|
CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-08-05 05:29:17 +02:00
|
|
|
int i;
|
|
|
|
int numIndexes;
|
|
|
|
RelationPtr relationDescs;
|
|
|
|
Relation heapRelation;
|
2005-03-16 22:38:10 +01:00
|
|
|
TupleTableSlot *slot;
|
2002-08-05 05:29:17 +02:00
|
|
|
IndexInfo **indexInfoArray;
|
2005-03-21 02:24:04 +01:00
|
|
|
Datum values[INDEX_MAX_KEYS];
|
|
|
|
bool isnull[INDEX_MAX_KEYS];
|
1997-09-07 07:04:48 +02:00
|
|
|
|
Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible to
either trigger an assertion failure:
TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))
That's because reindex_index() called SetReindexProcessing() - which
enables an asserts ensuring no index insertions happen into the index
- before calling RelationSetNewRelfilenode(). That not correct for
indexes on pg_class, because RelationSetNewRelfilenode() updates the
relevant pg_class row, which needs to update the indexes.
The are two reasons this wasn't noticed earlier. Firstly the bug
doesn't trigger when reindexing all of pg_class, as reindex_relation
has code "hiding" all yet-to-be-reindexed indexes. Secondly, the bug
only triggers when the the update to pg_class doesn't turn out to be a
HOT update - otherwise there's no index insertion to trigger the
bug. Most of the time there's enough space, making this bug hard to
trigger.
To fix, move RelationSetNewRelfilenode() to before the
SetReindexProcessing() (and, together with some other code, to outside
of the PG_TRY()).
To make sure the error checking intended by SetReindexProcessing() is
more robust, modify CatalogIndexInsert() to check
ReindexIsProcessingIndex() even when the update is a HOT update.
Also add a few regression tests for REINDEXing of system catalogs.
The last two improvements would have prevented some of the issues
fixed in 5c1560606dc4c from being introduced in the first place.
Reported-By: Michael Paquier
Diagnosed-By: Tom Lane and Andres Freund
Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20190418011430.GA19133@paquier.xyz
Backpatch: 9.4-, the bug is present in all branches
2019-04-30 04:42:04 +02:00
|
|
|
/*
|
|
|
|
* HOT update does not require index inserts. But with asserts enabled we
|
|
|
|
* want to check that it'd be legal to currently insert into the
|
|
|
|
* table/index.
|
|
|
|
*/
|
|
|
|
#ifndef USE_ASSERT_CHECKING
|
2007-09-20 19:56:33 +02:00
|
|
|
if (HeapTupleIsHeapOnly(heapTuple))
|
|
|
|
return;
|
Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible to
either trigger an assertion failure:
TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))
That's because reindex_index() called SetReindexProcessing() - which
enables an asserts ensuring no index insertions happen into the index
- before calling RelationSetNewRelfilenode(). That not correct for
indexes on pg_class, because RelationSetNewRelfilenode() updates the
relevant pg_class row, which needs to update the indexes.
The are two reasons this wasn't noticed earlier. Firstly the bug
doesn't trigger when reindexing all of pg_class, as reindex_relation
has code "hiding" all yet-to-be-reindexed indexes. Secondly, the bug
only triggers when the the update to pg_class doesn't turn out to be a
HOT update - otherwise there's no index insertion to trigger the
bug. Most of the time there's enough space, making this bug hard to
trigger.
To fix, move RelationSetNewRelfilenode() to before the
SetReindexProcessing() (and, together with some other code, to outside
of the PG_TRY()).
To make sure the error checking intended by SetReindexProcessing() is
more robust, modify CatalogIndexInsert() to check
ReindexIsProcessingIndex() even when the update is a HOT update.
Also add a few regression tests for REINDEXing of system catalogs.
The last two improvements would have prevented some of the issues
fixed in 5c1560606dc4c from being introduced in the first place.
Reported-By: Michael Paquier
Diagnosed-By: Tom Lane and Andres Freund
Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20190418011430.GA19133@paquier.xyz
Backpatch: 9.4-, the bug is present in all branches
2019-04-30 04:42:04 +02:00
|
|
|
#endif
|
2007-09-20 19:56:33 +02:00
|
|
|
|
2002-08-05 05:29:17 +02:00
|
|
|
/*
|
2005-03-16 22:38:10 +01:00
|
|
|
* Get information from the state structure. Fall out if nothing to do.
|
2002-08-05 05:29:17 +02:00
|
|
|
*/
|
|
|
|
numIndexes = indstate->ri_NumIndices;
|
2005-03-16 22:38:10 +01:00
|
|
|
if (numIndexes == 0)
|
|
|
|
return;
|
2002-08-05 05:29:17 +02:00
|
|
|
relationDescs = indstate->ri_IndexRelationDescs;
|
|
|
|
indexInfoArray = indstate->ri_IndexRelationInfo;
|
|
|
|
heapRelation = indstate->ri_RelationDesc;
|
2005-03-16 22:38:10 +01:00
|
|
|
|
|
|
|
/* Need a slot to hold the tuple being examined */
|
Introduce notion of different types of slots (without implementing them).
Upcoming work intends to allow pluggable ways to introduce new ways of
storing table data. Accessing those table access methods from the
executor requires TupleTableSlots to be carry tuples in the native
format of such storage methods; otherwise there'll be a significant
conversion overhead.
Different access methods will require different data to store tuples
efficiently (just like virtual, minimal, heap already require fields
in TupleTableSlot). To allow that without requiring additional pointer
indirections, we want to have different structs (embedding
TupleTableSlot) for different types of slots. Thus different types of
slots are needed, which requires adapting creators of slots.
The slot that most efficiently can represent a type of tuple in an
executor node will often depend on the type of slot a child node
uses. Therefore we need to track the type of slot is returned by
nodes, so parent slots can create slots based on that.
Relatedly, JIT compilation of tuple deforming needs to know which type
of slot a certain expression refers to, so it can create an
appropriate deforming function for the type of tuple in the slot.
But not all nodes will only return one type of slot, e.g. an append
node will potentially return different types of slots for each of its
subplans.
Therefore add function that allows to query the type of a node's
result slot, and whether it'll always be the same type (whether it's
fixed). This can be queried using ExecGetResultSlotOps().
The scan, result, inner, outer type of slots are automatically
inferred from ExecInitScanTupleSlot(), ExecInitResultSlot(),
left/right subtrees respectively. If that's not correct for a node,
that can be overwritten using new fields in PlanState.
This commit does not introduce the actually abstracted implementation
of different kind of TupleTableSlots, that will be left for a followup
commit. The different types of slots introduced will, for now, still
use the same backing implementation.
While this already partially invalidates the big comment in
tuptable.h, it seems to make more sense to update it later, when the
different TupleTableSlot implementations actually exist.
Author: Ashutosh Bapat and Andres Freund, with changes by Amit Khandekar
Discussion: https://postgr.es/m/20181105210039.hh4vvi4vwoq5ba2q@alap3.anarazel.de
2018-11-16 07:00:30 +01:00
|
|
|
slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation),
|
|
|
|
&TTSOpsHeapTuple);
|
2018-09-26 01:27:48 +02:00
|
|
|
ExecStoreHeapTuple(heapTuple, slot, false);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-08-05 05:29:17 +02:00
|
|
|
/*
|
|
|
|
* for each index, form and insert the index tuple
|
|
|
|
*/
|
|
|
|
for (i = 0; i < numIndexes; i++)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-07-15 00:18:02 +02:00
|
|
|
IndexInfo *indexInfo;
|
Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible to
either trigger an assertion failure:
TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))
That's because reindex_index() called SetReindexProcessing() - which
enables an asserts ensuring no index insertions happen into the index
- before calling RelationSetNewRelfilenode(). That not correct for
indexes on pg_class, because RelationSetNewRelfilenode() updates the
relevant pg_class row, which needs to update the indexes.
The are two reasons this wasn't noticed earlier. Firstly the bug
doesn't trigger when reindexing all of pg_class, as reindex_relation
has code "hiding" all yet-to-be-reindexed indexes. Secondly, the bug
only triggers when the the update to pg_class doesn't turn out to be a
HOT update - otherwise there's no index insertion to trigger the
bug. Most of the time there's enough space, making this bug hard to
trigger.
To fix, move RelationSetNewRelfilenode() to before the
SetReindexProcessing() (and, together with some other code, to outside
of the PG_TRY()).
To make sure the error checking intended by SetReindexProcessing() is
more robust, modify CatalogIndexInsert() to check
ReindexIsProcessingIndex() even when the update is a HOT update.
Also add a few regression tests for REINDEXing of system catalogs.
The last two improvements would have prevented some of the issues
fixed in 5c1560606dc4c from being introduced in the first place.
Reported-By: Michael Paquier
Diagnosed-By: Tom Lane and Andres Freund
Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20190418011430.GA19133@paquier.xyz
Backpatch: 9.4-, the bug is present in all branches
2019-04-30 04:42:04 +02:00
|
|
|
Relation index;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-08-05 05:29:17 +02:00
|
|
|
indexInfo = indexInfoArray[i];
|
Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible to
either trigger an assertion failure:
TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))
That's because reindex_index() called SetReindexProcessing() - which
enables an asserts ensuring no index insertions happen into the index
- before calling RelationSetNewRelfilenode(). That not correct for
indexes on pg_class, because RelationSetNewRelfilenode() updates the
relevant pg_class row, which needs to update the indexes.
The are two reasons this wasn't noticed earlier. Firstly the bug
doesn't trigger when reindexing all of pg_class, as reindex_relation
has code "hiding" all yet-to-be-reindexed indexes. Secondly, the bug
only triggers when the the update to pg_class doesn't turn out to be a
HOT update - otherwise there's no index insertion to trigger the
bug. Most of the time there's enough space, making this bug hard to
trigger.
To fix, move RelationSetNewRelfilenode() to before the
SetReindexProcessing() (and, together with some other code, to outside
of the PG_TRY()).
To make sure the error checking intended by SetReindexProcessing() is
more robust, modify CatalogIndexInsert() to check
ReindexIsProcessingIndex() even when the update is a HOT update.
Also add a few regression tests for REINDEXing of system catalogs.
The last two improvements would have prevented some of the issues
fixed in 5c1560606dc4c from being introduced in the first place.
Reported-By: Michael Paquier
Diagnosed-By: Tom Lane and Andres Freund
Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20190418011430.GA19133@paquier.xyz
Backpatch: 9.4-, the bug is present in all branches
2019-04-30 04:42:04 +02:00
|
|
|
index = relationDescs[i];
|
1999-05-25 18:15:34 +02:00
|
|
|
|
2007-09-20 19:56:33 +02:00
|
|
|
/* If the index is marked as read-only, ignore it */
|
|
|
|
if (!indexInfo->ii_ReadyForInserts)
|
|
|
|
continue;
|
|
|
|
|
2003-05-28 18:04:02 +02:00
|
|
|
/*
|
|
|
|
* Expressional and partial indexes on system catalogs are not
|
2009-12-07 06:22:23 +01:00
|
|
|
* supported, nor exclusion constraints, nor deferred uniqueness
|
2003-05-28 18:04:02 +02:00
|
|
|
*/
|
|
|
|
Assert(indexInfo->ii_Expressions == NIL);
|
2002-08-05 05:29:17 +02:00
|
|
|
Assert(indexInfo->ii_Predicate == NIL);
|
2009-12-07 06:22:23 +01:00
|
|
|
Assert(indexInfo->ii_ExclusionOps == NULL);
|
Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible to
either trigger an assertion failure:
TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))
That's because reindex_index() called SetReindexProcessing() - which
enables an asserts ensuring no index insertions happen into the index
- before calling RelationSetNewRelfilenode(). That not correct for
indexes on pg_class, because RelationSetNewRelfilenode() updates the
relevant pg_class row, which needs to update the indexes.
The are two reasons this wasn't noticed earlier. Firstly the bug
doesn't trigger when reindexing all of pg_class, as reindex_relation
has code "hiding" all yet-to-be-reindexed indexes. Secondly, the bug
only triggers when the the update to pg_class doesn't turn out to be a
HOT update - otherwise there's no index insertion to trigger the
bug. Most of the time there's enough space, making this bug hard to
trigger.
To fix, move RelationSetNewRelfilenode() to before the
SetReindexProcessing() (and, together with some other code, to outside
of the PG_TRY()).
To make sure the error checking intended by SetReindexProcessing() is
more robust, modify CatalogIndexInsert() to check
ReindexIsProcessingIndex() even when the update is a HOT update.
Also add a few regression tests for REINDEXing of system catalogs.
The last two improvements would have prevented some of the issues
fixed in 5c1560606dc4c from being introduced in the first place.
Reported-By: Michael Paquier
Diagnosed-By: Tom Lane and Andres Freund
Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20190418011430.GA19133@paquier.xyz
Backpatch: 9.4-, the bug is present in all branches
2019-04-30 04:42:04 +02:00
|
|
|
Assert(index->rd_index->indimmediate);
|
2018-04-07 22:00:39 +02:00
|
|
|
Assert(indexInfo->ii_NumIndexKeyAttrs != 0);
|
2002-08-05 05:29:17 +02:00
|
|
|
|
Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible to
either trigger an assertion failure:
TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))
That's because reindex_index() called SetReindexProcessing() - which
enables an asserts ensuring no index insertions happen into the index
- before calling RelationSetNewRelfilenode(). That not correct for
indexes on pg_class, because RelationSetNewRelfilenode() updates the
relevant pg_class row, which needs to update the indexes.
The are two reasons this wasn't noticed earlier. Firstly the bug
doesn't trigger when reindexing all of pg_class, as reindex_relation
has code "hiding" all yet-to-be-reindexed indexes. Secondly, the bug
only triggers when the the update to pg_class doesn't turn out to be a
HOT update - otherwise there's no index insertion to trigger the
bug. Most of the time there's enough space, making this bug hard to
trigger.
To fix, move RelationSetNewRelfilenode() to before the
SetReindexProcessing() (and, together with some other code, to outside
of the PG_TRY()).
To make sure the error checking intended by SetReindexProcessing() is
more robust, modify CatalogIndexInsert() to check
ReindexIsProcessingIndex() even when the update is a HOT update.
Also add a few regression tests for REINDEXing of system catalogs.
The last two improvements would have prevented some of the issues
fixed in 5c1560606dc4c from being introduced in the first place.
Reported-By: Michael Paquier
Diagnosed-By: Tom Lane and Andres Freund
Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20190418011430.GA19133@paquier.xyz
Backpatch: 9.4-, the bug is present in all branches
2019-04-30 04:42:04 +02:00
|
|
|
/* see earlier check above */
|
|
|
|
#ifdef USE_ASSERT_CHECKING
|
|
|
|
if (HeapTupleIsHeapOnly(heapTuple))
|
|
|
|
{
|
|
|
|
Assert(!ReindexIsProcessingIndex(RelationGetRelid(index)));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif /* USE_ASSERT_CHECKING */
|
|
|
|
|
2002-08-05 05:29:17 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* FormIndexDatum fills in its values and isnull parameters with the
|
|
|
|
* appropriate values for the column(s) of the index.
|
2002-08-05 05:29:17 +02:00
|
|
|
*/
|
2000-07-15 00:18:02 +02:00
|
|
|
FormIndexDatum(indexInfo,
|
2005-03-16 22:38:10 +01:00
|
|
|
slot,
|
2003-05-28 18:04:02 +02:00
|
|
|
NULL, /* no expression eval to do */
|
2005-03-21 02:24:04 +01:00
|
|
|
values,
|
|
|
|
isnull);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-08-05 05:29:17 +02:00
|
|
|
/*
|
|
|
|
* The index AM does the rest.
|
|
|
|
*/
|
2005-03-21 02:24:04 +01:00
|
|
|
index_insert(relationDescs[i], /* index relation */
|
2005-10-15 04:49:52 +02:00
|
|
|
values, /* array of index Datums */
|
|
|
|
isnull, /* is-null flags */
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:18:54 +02:00
|
|
|
&(heapTuple->t_self), /* tid of heap tuple */
|
2005-03-21 02:24:04 +01:00
|
|
|
heapRelation,
|
2009-07-29 22:56:21 +02:00
|
|
|
relationDescs[i]->rd_index->indisunique ?
|
Allow index AMs to cache data across aminsert calls within a SQL command.
It's always been possible for index AMs to cache data across successive
amgettuple calls within a single SQL command: the IndexScanDesc.opaque
field is meant for precisely that. However, no comparable facility
exists for amortizing setup work across successive aminsert calls.
This patch adds such a feature and teaches GIN, GIST, and BRIN to use it
to amortize catalog lookups they'd previously been doing on every call.
(The other standard index AMs keep everything they need in the relcache,
so there's little to improve there.)
For GIN, the overall improvement in a statement that inserts many rows
can be as much as 10%, though it seems a bit less for the other two.
In addition, this makes a really significant difference in runtime
for CLOBBER_CACHE_ALWAYS tests, since in those builds the repeated
catalog lookups are vastly more expensive.
The reason this has been hard up to now is that the aminsert function is
not passed any useful place to cache per-statement data. What I chose to
do is to add suitable fields to struct IndexInfo and pass that to aminsert.
That's not widening the index AM API very much because IndexInfo is already
within the ken of ambuild; in fact, by passing the same info to aminsert
as to ambuild, this is really removing an inconsistency in the AM API.
Discussion: https://postgr.es/m/27568.1486508680@sss.pgh.pa.us
2017-02-09 17:52:12 +01:00
|
|
|
UNIQUE_CHECK_YES : UNIQUE_CHECK_NO,
|
|
|
|
indexInfo);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
2005-03-16 22:38:10 +01:00
|
|
|
|
|
|
|
ExecDropSingleTupleTableSlot(slot);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
2002-08-05 05:29:17 +02:00
|
|
|
|
|
|
|
/*
|
2017-01-31 22:42:24 +01:00
|
|
|
* CatalogTupleInsert - do heap and indexing work for a new catalog tuple
|
2002-08-05 05:29:17 +02:00
|
|
|
*
|
2017-02-01 23:18:36 +01:00
|
|
|
* Insert the tuple data in "tup" into the specified catalog relation.
|
|
|
|
* The Oid of the inserted tuple is returned.
|
|
|
|
*
|
2017-01-31 22:42:24 +01:00
|
|
|
* This is a convenience routine for the common case of inserting a single
|
|
|
|
* tuple in a system catalog; it inserts a new heap tuple, keeping indexes
|
2017-02-01 23:18:36 +01:00
|
|
|
* current. Avoid using it for multiple tuples, since opening the indexes
|
|
|
|
* and building the index info structures is moderately expensive.
|
|
|
|
* (Use CatalogTupleInsertWithInfo in such cases.)
|
2017-01-31 22:42:24 +01:00
|
|
|
*/
|
Remove WITH OIDS support, change oid catalog column visibility.
Previously tables declared WITH OIDS, including a significant fraction
of the catalog tables, stored the oid column not as a normal column,
but as part of the tuple header.
This special column was not shown by default, which was somewhat odd,
as it's often (consider e.g. pg_class.oid) one of the more important
parts of a row. Neither pg_dump nor COPY included the contents of the
oid column by default.
The fact that the oid column was not an ordinary column necessitated a
significant amount of special case code to support oid columns. That
already was painful for the existing, but upcoming work aiming to make
table storage pluggable, would have required expanding and duplicating
that "specialness" significantly.
WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
Remove it.
Removing includes:
- CREATE TABLE and ALTER TABLE syntax for declaring the table to be
WITH OIDS has been removed (WITH (oids[ = true]) will error out)
- pg_dump does not support dumping tables declared WITH OIDS and will
issue a warning when dumping one (and ignore the oid column).
- restoring an pg_dump archive with pg_restore will warn when
restoring a table with oid contents (and ignore the oid column)
- COPY will refuse to load binary dump that includes oids.
- pg_upgrade will error out when encountering tables declared WITH
OIDS, they have to be altered to remove the oid column first.
- Functionality to access the oid of the last inserted row (like
plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
for CREATE TABLE) is still supported. While that requires a bit of
support code, it seems unnecessary to break applications / dumps that
do not use oids, and are explicit about not using them.
The biggest user of WITH OID columns was postgres' catalog. This
commit changes all 'magic' oid columns to be columns that are normally
declared and stored. To reduce unnecessary query breakage all the
newly added columns are still named 'oid', even if a table's column
naming scheme would indicate 'reloid' or such. This obviously
requires adapting a lot code, mostly replacing oid access via
HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
The bootstrap process now assigns oids for all oid columns in
genbki.pl that do not have an explicit value (starting at the largest
oid previously used), only oids assigned later by oids will be above
FirstBootstrapObjectId. As the oid column now is a normal column the
special bootstrap syntax for oids has been removed.
Oids are not automatically assigned during insertion anymore, all
backend code explicitly assigns oids with GetNewOidWithIndex(). For
the rare case that insertions into the catalog via SQL are called for
the new pg_nextoid() function can be used (which only works on catalog
tables).
The fact that oid columns on system tables are now normal columns
means that they will be included in the set of columns expanded
by * (i.e. SELECT * FROM pg_class will now include the table's oid,
previously it did not). It'd not technically be hard to hide oid
column by default, but that'd mean confusing behavior would either
have to be carried forward forever, or it'd cause breakage down the
line.
While it's not unlikely that further adjustments are needed, the
scope/invasiveness of the patch makes it worthwhile to get merge this
now. It's painful to maintain externally, too complicated to commit
after the code code freeze, and a dependency of a number of other
patches.
Catversion bump, for obvious reasons.
Author: Andres Freund, with contributions by John Naylor
Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
2018-11-21 00:36:57 +01:00
|
|
|
void
|
2017-01-31 22:42:24 +01:00
|
|
|
CatalogTupleInsert(Relation heapRel, HeapTuple tup)
|
|
|
|
{
|
|
|
|
CatalogIndexState indstate;
|
|
|
|
|
|
|
|
indstate = CatalogOpenIndexes(heapRel);
|
|
|
|
|
Remove WITH OIDS support, change oid catalog column visibility.
Previously tables declared WITH OIDS, including a significant fraction
of the catalog tables, stored the oid column not as a normal column,
but as part of the tuple header.
This special column was not shown by default, which was somewhat odd,
as it's often (consider e.g. pg_class.oid) one of the more important
parts of a row. Neither pg_dump nor COPY included the contents of the
oid column by default.
The fact that the oid column was not an ordinary column necessitated a
significant amount of special case code to support oid columns. That
already was painful for the existing, but upcoming work aiming to make
table storage pluggable, would have required expanding and duplicating
that "specialness" significantly.
WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
Remove it.
Removing includes:
- CREATE TABLE and ALTER TABLE syntax for declaring the table to be
WITH OIDS has been removed (WITH (oids[ = true]) will error out)
- pg_dump does not support dumping tables declared WITH OIDS and will
issue a warning when dumping one (and ignore the oid column).
- restoring an pg_dump archive with pg_restore will warn when
restoring a table with oid contents (and ignore the oid column)
- COPY will refuse to load binary dump that includes oids.
- pg_upgrade will error out when encountering tables declared WITH
OIDS, they have to be altered to remove the oid column first.
- Functionality to access the oid of the last inserted row (like
plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
for CREATE TABLE) is still supported. While that requires a bit of
support code, it seems unnecessary to break applications / dumps that
do not use oids, and are explicit about not using them.
The biggest user of WITH OID columns was postgres' catalog. This
commit changes all 'magic' oid columns to be columns that are normally
declared and stored. To reduce unnecessary query breakage all the
newly added columns are still named 'oid', even if a table's column
naming scheme would indicate 'reloid' or such. This obviously
requires adapting a lot code, mostly replacing oid access via
HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
The bootstrap process now assigns oids for all oid columns in
genbki.pl that do not have an explicit value (starting at the largest
oid previously used), only oids assigned later by oids will be above
FirstBootstrapObjectId. As the oid column now is a normal column the
special bootstrap syntax for oids has been removed.
Oids are not automatically assigned during insertion anymore, all
backend code explicitly assigns oids with GetNewOidWithIndex(). For
the rare case that insertions into the catalog via SQL are called for
the new pg_nextoid() function can be used (which only works on catalog
tables).
The fact that oid columns on system tables are now normal columns
means that they will be included in the set of columns expanded
by * (i.e. SELECT * FROM pg_class will now include the table's oid,
previously it did not). It'd not technically be hard to hide oid
column by default, but that'd mean confusing behavior would either
have to be carried forward forever, or it'd cause breakage down the
line.
While it's not unlikely that further adjustments are needed, the
scope/invasiveness of the patch makes it worthwhile to get merge this
now. It's painful to maintain externally, too complicated to commit
after the code code freeze, and a dependency of a number of other
patches.
Catversion bump, for obvious reasons.
Author: Andres Freund, with contributions by John Naylor
Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
2018-11-21 00:36:57 +01:00
|
|
|
simple_heap_insert(heapRel, tup);
|
2017-01-31 22:42:24 +01:00
|
|
|
|
|
|
|
CatalogIndexInsert(indstate, tup);
|
|
|
|
CatalogCloseIndexes(indstate);
|
|
|
|
}
|
|
|
|
|
2017-02-01 23:18:36 +01:00
|
|
|
/*
|
|
|
|
* CatalogTupleInsertWithInfo - as above, but with caller-supplied index info
|
|
|
|
*
|
|
|
|
* This should be used when it's important to amortize CatalogOpenIndexes/
|
|
|
|
* CatalogCloseIndexes work across multiple insertions. At some point we
|
|
|
|
* might cache the CatalogIndexState data somewhere (perhaps in the relcache)
|
|
|
|
* so that callers needn't trouble over this ... but we don't do so today.
|
|
|
|
*/
|
Remove WITH OIDS support, change oid catalog column visibility.
Previously tables declared WITH OIDS, including a significant fraction
of the catalog tables, stored the oid column not as a normal column,
but as part of the tuple header.
This special column was not shown by default, which was somewhat odd,
as it's often (consider e.g. pg_class.oid) one of the more important
parts of a row. Neither pg_dump nor COPY included the contents of the
oid column by default.
The fact that the oid column was not an ordinary column necessitated a
significant amount of special case code to support oid columns. That
already was painful for the existing, but upcoming work aiming to make
table storage pluggable, would have required expanding and duplicating
that "specialness" significantly.
WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
Remove it.
Removing includes:
- CREATE TABLE and ALTER TABLE syntax for declaring the table to be
WITH OIDS has been removed (WITH (oids[ = true]) will error out)
- pg_dump does not support dumping tables declared WITH OIDS and will
issue a warning when dumping one (and ignore the oid column).
- restoring an pg_dump archive with pg_restore will warn when
restoring a table with oid contents (and ignore the oid column)
- COPY will refuse to load binary dump that includes oids.
- pg_upgrade will error out when encountering tables declared WITH
OIDS, they have to be altered to remove the oid column first.
- Functionality to access the oid of the last inserted row (like
plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
for CREATE TABLE) is still supported. While that requires a bit of
support code, it seems unnecessary to break applications / dumps that
do not use oids, and are explicit about not using them.
The biggest user of WITH OID columns was postgres' catalog. This
commit changes all 'magic' oid columns to be columns that are normally
declared and stored. To reduce unnecessary query breakage all the
newly added columns are still named 'oid', even if a table's column
naming scheme would indicate 'reloid' or such. This obviously
requires adapting a lot code, mostly replacing oid access via
HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
The bootstrap process now assigns oids for all oid columns in
genbki.pl that do not have an explicit value (starting at the largest
oid previously used), only oids assigned later by oids will be above
FirstBootstrapObjectId. As the oid column now is a normal column the
special bootstrap syntax for oids has been removed.
Oids are not automatically assigned during insertion anymore, all
backend code explicitly assigns oids with GetNewOidWithIndex(). For
the rare case that insertions into the catalog via SQL are called for
the new pg_nextoid() function can be used (which only works on catalog
tables).
The fact that oid columns on system tables are now normal columns
means that they will be included in the set of columns expanded
by * (i.e. SELECT * FROM pg_class will now include the table's oid,
previously it did not). It'd not technically be hard to hide oid
column by default, but that'd mean confusing behavior would either
have to be carried forward forever, or it'd cause breakage down the
line.
While it's not unlikely that further adjustments are needed, the
scope/invasiveness of the patch makes it worthwhile to get merge this
now. It's painful to maintain externally, too complicated to commit
after the code code freeze, and a dependency of a number of other
patches.
Catversion bump, for obvious reasons.
Author: Andres Freund, with contributions by John Naylor
Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
2018-11-21 00:36:57 +01:00
|
|
|
void
|
2017-02-01 23:18:36 +01:00
|
|
|
CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup,
|
|
|
|
CatalogIndexState indstate)
|
|
|
|
{
|
Remove WITH OIDS support, change oid catalog column visibility.
Previously tables declared WITH OIDS, including a significant fraction
of the catalog tables, stored the oid column not as a normal column,
but as part of the tuple header.
This special column was not shown by default, which was somewhat odd,
as it's often (consider e.g. pg_class.oid) one of the more important
parts of a row. Neither pg_dump nor COPY included the contents of the
oid column by default.
The fact that the oid column was not an ordinary column necessitated a
significant amount of special case code to support oid columns. That
already was painful for the existing, but upcoming work aiming to make
table storage pluggable, would have required expanding and duplicating
that "specialness" significantly.
WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
Remove it.
Removing includes:
- CREATE TABLE and ALTER TABLE syntax for declaring the table to be
WITH OIDS has been removed (WITH (oids[ = true]) will error out)
- pg_dump does not support dumping tables declared WITH OIDS and will
issue a warning when dumping one (and ignore the oid column).
- restoring an pg_dump archive with pg_restore will warn when
restoring a table with oid contents (and ignore the oid column)
- COPY will refuse to load binary dump that includes oids.
- pg_upgrade will error out when encountering tables declared WITH
OIDS, they have to be altered to remove the oid column first.
- Functionality to access the oid of the last inserted row (like
plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
for CREATE TABLE) is still supported. While that requires a bit of
support code, it seems unnecessary to break applications / dumps that
do not use oids, and are explicit about not using them.
The biggest user of WITH OID columns was postgres' catalog. This
commit changes all 'magic' oid columns to be columns that are normally
declared and stored. To reduce unnecessary query breakage all the
newly added columns are still named 'oid', even if a table's column
naming scheme would indicate 'reloid' or such. This obviously
requires adapting a lot code, mostly replacing oid access via
HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
The bootstrap process now assigns oids for all oid columns in
genbki.pl that do not have an explicit value (starting at the largest
oid previously used), only oids assigned later by oids will be above
FirstBootstrapObjectId. As the oid column now is a normal column the
special bootstrap syntax for oids has been removed.
Oids are not automatically assigned during insertion anymore, all
backend code explicitly assigns oids with GetNewOidWithIndex(). For
the rare case that insertions into the catalog via SQL are called for
the new pg_nextoid() function can be used (which only works on catalog
tables).
The fact that oid columns on system tables are now normal columns
means that they will be included in the set of columns expanded
by * (i.e. SELECT * FROM pg_class will now include the table's oid,
previously it did not). It'd not technically be hard to hide oid
column by default, but that'd mean confusing behavior would either
have to be carried forward forever, or it'd cause breakage down the
line.
While it's not unlikely that further adjustments are needed, the
scope/invasiveness of the patch makes it worthwhile to get merge this
now. It's painful to maintain externally, too complicated to commit
after the code code freeze, and a dependency of a number of other
patches.
Catversion bump, for obvious reasons.
Author: Andres Freund, with contributions by John Naylor
Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
2018-11-21 00:36:57 +01:00
|
|
|
simple_heap_insert(heapRel, tup);
|
2017-02-01 23:18:36 +01:00
|
|
|
|
|
|
|
CatalogIndexInsert(indstate, tup);
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:42:24 +01:00
|
|
|
/*
|
|
|
|
* CatalogTupleUpdate - do heap and indexing work for updating a catalog tuple
|
|
|
|
*
|
2017-02-01 23:18:36 +01:00
|
|
|
* Update the tuple identified by "otid", replacing it with the data in "tup".
|
|
|
|
*
|
2017-01-31 22:42:24 +01:00
|
|
|
* This is a convenience routine for the common case of updating a single
|
2017-02-01 23:18:36 +01:00
|
|
|
* tuple in a system catalog; it updates one heap tuple, keeping indexes
|
|
|
|
* current. Avoid using it for multiple tuples, since opening the indexes
|
|
|
|
* and building the index info structures is moderately expensive.
|
|
|
|
* (Use CatalogTupleUpdateWithInfo in such cases.)
|
2002-08-05 05:29:17 +02:00
|
|
|
*/
|
|
|
|
void
|
2017-01-31 22:42:24 +01:00
|
|
|
CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
|
2002-08-05 05:29:17 +02:00
|
|
|
{
|
2002-09-04 22:31:48 +02:00
|
|
|
CatalogIndexState indstate;
|
2002-08-05 05:29:17 +02:00
|
|
|
|
|
|
|
indstate = CatalogOpenIndexes(heapRel);
|
2017-01-31 22:42:24 +01:00
|
|
|
|
|
|
|
simple_heap_update(heapRel, otid, tup);
|
|
|
|
|
|
|
|
CatalogIndexInsert(indstate, tup);
|
2002-08-05 05:29:17 +02:00
|
|
|
CatalogCloseIndexes(indstate);
|
|
|
|
}
|
2017-02-01 22:13:30 +01:00
|
|
|
|
2017-02-01 23:18:36 +01:00
|
|
|
/*
|
|
|
|
* CatalogTupleUpdateWithInfo - as above, but with caller-supplied index info
|
|
|
|
*
|
|
|
|
* This should be used when it's important to amortize CatalogOpenIndexes/
|
|
|
|
* CatalogCloseIndexes work across multiple updates. At some point we
|
|
|
|
* might cache the CatalogIndexState data somewhere (perhaps in the relcache)
|
|
|
|
* so that callers needn't trouble over this ... but we don't do so today.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
|
|
|
|
CatalogIndexState indstate)
|
|
|
|
{
|
|
|
|
simple_heap_update(heapRel, otid, tup);
|
|
|
|
|
|
|
|
CatalogIndexInsert(indstate, tup);
|
|
|
|
}
|
|
|
|
|
2017-02-01 22:13:30 +01:00
|
|
|
/*
|
|
|
|
* CatalogTupleDelete - do heap and indexing work for deleting a catalog tuple
|
|
|
|
*
|
2017-02-01 23:18:36 +01:00
|
|
|
* Delete the tuple identified by "tid" in the specified catalog.
|
2017-02-01 22:13:30 +01:00
|
|
|
*
|
|
|
|
* With Postgres heaps, there is no index work to do at deletion time;
|
|
|
|
* cleanup will be done later by VACUUM. However, callers of this function
|
|
|
|
* shouldn't have to know that; we'd like a uniform abstraction for all
|
|
|
|
* catalog tuple changes. Hence, provide this currently-trivial wrapper.
|
2017-02-01 23:18:36 +01:00
|
|
|
*
|
|
|
|
* The abstraction is a bit leaky in that we don't provide an optimized
|
|
|
|
* CatalogTupleDeleteWithInfo version, because there is currently nothing to
|
|
|
|
* optimize. If we ever need that, rather than touching a lot of call sites,
|
|
|
|
* it might be better to do something about caching CatalogIndexState.
|
2017-02-01 22:13:30 +01:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
CatalogTupleDelete(Relation heapRel, ItemPointer tid)
|
|
|
|
{
|
|
|
|
simple_heap_delete(heapRel, tid);
|
|
|
|
}
|