mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Repair breakage of inherited constraint expressions --- needed a
CommandCounterIncrement to make new relation visible before trying to parse/deparse the expressions. Also, eliminate unnecessary setheapoverride calls in AddNewAttributeTuples.
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.114 1999/12/20 10:40:40 wieck Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.115 2000/01/16 19:57:00 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -27,7 +27,6 @@
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
#include "miscadmin.h"
|
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
@ -48,6 +47,7 @@
|
|||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "commands/comment.h"
|
#include "commands/comment.h"
|
||||||
#include "commands/trigger.h"
|
#include "commands/trigger.h"
|
||||||
|
#include "miscadmin.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/planmain.h"
|
#include "optimizer/planmain.h"
|
||||||
#include "optimizer/tlist.h"
|
#include "optimizer/tlist.h"
|
||||||
@ -67,8 +67,9 @@
|
|||||||
|
|
||||||
|
|
||||||
static void AddNewRelationTuple(Relation pg_class_desc,
|
static void AddNewRelationTuple(Relation pg_class_desc,
|
||||||
Relation new_rel_desc, Oid new_rel_oid, unsigned natts,
|
Relation new_rel_desc, Oid new_rel_oid,
|
||||||
char relkind, char *temp_relname);
|
int natts,
|
||||||
|
char relkind, char *temp_relname);
|
||||||
static void AddToNoNameRelList(Relation r);
|
static void AddToNoNameRelList(Relation r);
|
||||||
|
|
||||||
static void DeleteAttributeTuples(Relation rel);
|
static void DeleteAttributeTuples(Relation rel);
|
||||||
@ -199,7 +200,8 @@ heap_create(char *relname,
|
|||||||
*/
|
*/
|
||||||
AssertArg(natts > 0);
|
AssertArg(natts > 0);
|
||||||
|
|
||||||
if (relname && !allowSystemTableMods && IsSystemRelationName(relname) && IsNormalProcessingMode())
|
if (relname && !allowSystemTableMods &&
|
||||||
|
IsSystemRelationName(relname) && IsNormalProcessingMode())
|
||||||
{
|
{
|
||||||
elog(ERROR, "Illegal class name '%s'"
|
elog(ERROR, "Illegal class name '%s'"
|
||||||
"\n\tThe 'pg_' name prefix is reserved for system catalogs",
|
"\n\tThe 'pg_' name prefix is reserved for system catalogs",
|
||||||
@ -361,7 +363,7 @@ heap_storage_create(Relation rel)
|
|||||||
* descriptor contains a valid set of attribute names
|
* descriptor contains a valid set of attribute names
|
||||||
*
|
*
|
||||||
* 2) pg_class is opened and RelationFindRelid()
|
* 2) pg_class is opened and RelationFindRelid()
|
||||||
* preforms a scan to ensure that no relation with the
|
* performs a scan to ensure that no relation with the
|
||||||
* same name already exists.
|
* same name already exists.
|
||||||
*
|
*
|
||||||
* 3) heap_create_with_catalog() is called to create the new relation
|
* 3) heap_create_with_catalog() is called to create the new relation
|
||||||
@ -474,8 +476,7 @@ CheckAttributeNames(TupleDesc tupdesc)
|
|||||||
/* --------------------------------
|
/* --------------------------------
|
||||||
* RelnameFindRelid
|
* RelnameFindRelid
|
||||||
*
|
*
|
||||||
* this preforms a scan of pg_class to ensure that
|
* Find any existing relation of the given name.
|
||||||
* no relation with the same name already exists.
|
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
Oid
|
Oid
|
||||||
@ -580,14 +581,10 @@ AddNewAttributeTuples(Oid new_rel_oid,
|
|||||||
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
|
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* initialize tuple descriptor. Note we use setheapoverride()
|
* initialize tuple descriptor.
|
||||||
* so that we can see the effects of our TypeDefine() done
|
|
||||||
* previously.
|
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
setheapoverride(true);
|
|
||||||
fillatt(tupdesc);
|
fillatt(tupdesc);
|
||||||
setheapoverride(false);
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* first we add the user attributes..
|
* first we add the user attributes..
|
||||||
@ -655,7 +652,7 @@ static void
|
|||||||
AddNewRelationTuple(Relation pg_class_desc,
|
AddNewRelationTuple(Relation pg_class_desc,
|
||||||
Relation new_rel_desc,
|
Relation new_rel_desc,
|
||||||
Oid new_rel_oid,
|
Oid new_rel_oid,
|
||||||
unsigned natts,
|
int natts,
|
||||||
char relkind,
|
char relkind,
|
||||||
char *temp_relname)
|
char *temp_relname)
|
||||||
{
|
{
|
||||||
@ -670,8 +667,6 @@ AddNewRelationTuple(Relation pg_class_desc,
|
|||||||
*/
|
*/
|
||||||
new_rel_reltup = new_rel_desc->rd_rel;
|
new_rel_reltup = new_rel_desc->rd_rel;
|
||||||
|
|
||||||
/* CHECK should get new_rel_oid first via an insert then use XXX */
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Here we insert bogus estimates of the size of the new relation.
|
* Here we insert bogus estimates of the size of the new relation.
|
||||||
* In reality, of course, the new relation has 0 tuples and pages,
|
* In reality, of course, the new relation has 0 tuples and pages,
|
||||||
@ -791,7 +786,7 @@ heap_create_with_catalog(char *relname,
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
Assert(IsNormalProcessingMode() || IsBootstrapProcessingMode());
|
Assert(IsNormalProcessingMode() || IsBootstrapProcessingMode());
|
||||||
if (natts == 0 || natts > MaxHeapAttributeNumber)
|
if (natts <= 0 || natts > MaxHeapAttributeNumber)
|
||||||
elog(ERROR, "Number of attributes is out of range"
|
elog(ERROR, "Number of attributes is out of range"
|
||||||
"\n\tFrom 1 to %d attributes may be specified",
|
"\n\tFrom 1 to %d attributes may be specified",
|
||||||
MaxHeapAttributeNumber);
|
MaxHeapAttributeNumber);
|
||||||
@ -1856,6 +1851,12 @@ StoreConstraints(Relation rel)
|
|||||||
if (!constr)
|
if (!constr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* deparsing of constraint expressions will fail unless the just-created
|
||||||
|
* pg_attribute tuples for this relation are made visible. So, bump
|
||||||
|
* the command counter.
|
||||||
|
*/
|
||||||
|
CommandCounterIncrement();
|
||||||
|
|
||||||
for (i = 0; i < constr->num_defval; i++)
|
for (i = 0; i < constr->num_defval; i++)
|
||||||
StoreAttrDefault(rel, constr->defval[i].adnum,
|
StoreAttrDefault(rel, constr->defval[i].adnum,
|
||||||
constr->defval[i].adbin, false);
|
constr->defval[i].adbin, false);
|
||||||
@ -1882,7 +1883,9 @@ StoreConstraints(Relation rel)
|
|||||||
* expression.
|
* expression.
|
||||||
*
|
*
|
||||||
* NB: caller should have opened rel with AccessExclusiveLock, and should
|
* NB: caller should have opened rel with AccessExclusiveLock, and should
|
||||||
* hold that lock till end of transaction.
|
* hold that lock till end of transaction. Also, we assume the caller has
|
||||||
|
* done a CommandCounterIncrement if necessary to make the relation's catalog
|
||||||
|
* tuples visible.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
AddRelationRawConstraints(Relation rel,
|
AddRelationRawConstraints(Relation rel,
|
||||||
|
Reference in New Issue
Block a user