Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47a895f

Browse files
committed
Repair breakage of inherited constraint expressions --- needed a
CommandCounterIncrement to make new relation visible before trying toparse/deparse the expressions. Also, eliminate unnecessarysetheapoverride calls in AddNewAttributeTuples.
1 parent7d715ba commit47a895f

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

‎src/backend/catalog/heap.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.114 1999/12/20 10:40:40 wieck Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.115 2000/01/16 19:57:00 tgl Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -27,7 +27,6 @@
2727
*-------------------------------------------------------------------------
2828
*/
2929
#include"postgres.h"
30-
#include"miscadmin.h"
3130

3231
#include"access/heapam.h"
3332
#include"access/genam.h"
@@ -48,6 +47,7 @@
4847
#include"catalog/pg_type.h"
4948
#include"commands/comment.h"
5049
#include"commands/trigger.h"
50+
#include"miscadmin.h"
5151
#include"optimizer/clauses.h"
5252
#include"optimizer/planmain.h"
5353
#include"optimizer/tlist.h"
@@ -67,8 +67,9 @@
6767

6868

6969
staticvoidAddNewRelationTuple(Relationpg_class_desc,
70-
Relationnew_rel_desc,Oidnew_rel_oid,unsignednatts,
71-
charrelkind,char*temp_relname);
70+
Relationnew_rel_desc,Oidnew_rel_oid,
71+
intnatts,
72+
charrelkind,char*temp_relname);
7273
staticvoidAddToNoNameRelList(Relationr);
7374

7475
staticvoidDeleteAttributeTuples(Relationrel);
@@ -199,7 +200,8 @@ heap_create(char *relname,
199200
*/
200201
AssertArg(natts>0);
201202

202-
if (relname&& !allowSystemTableMods&&IsSystemRelationName(relname)&&IsNormalProcessingMode())
203+
if (relname&& !allowSystemTableMods&&
204+
IsSystemRelationName(relname)&&IsNormalProcessingMode())
203205
{
204206
elog(ERROR,"Illegal class name '%s'"
205207
"\n\tThe 'pg_' name prefix is reserved for system catalogs",
@@ -361,7 +363,7 @@ heap_storage_create(Relation rel)
361363
* descriptor contains a valid set of attribute names
362364
*
363365
*2) pg_class is opened and RelationFindRelid()
364-
*preforms a scan to ensure that no relation with the
366+
*performs a scan to ensure that no relation with the
365367
* same name already exists.
366368
*
367369
*3) heap_create_with_catalog() is called to create the new relation
@@ -474,8 +476,7 @@ CheckAttributeNames(TupleDesc tupdesc)
474476
/* --------------------------------
475477
*RelnameFindRelid
476478
*
477-
*this preforms a scan of pg_class to ensure that
478-
*no relation with the same name already exists.
479+
*Find any existing relation of the given name.
479480
* --------------------------------
480481
*/
481482
Oid
@@ -580,14 +581,10 @@ AddNewAttributeTuples(Oid new_rel_oid,
580581
CatalogOpenIndices(Num_pg_attr_indices,Name_pg_attr_indices,idescs);
581582

582583
/* ----------------
583-
*initialize tuple descriptor. Note we use setheapoverride()
584-
*so that we can see the effects of our TypeDefine() done
585-
*previously.
584+
*initialize tuple descriptor.
586585
* ----------------
587586
*/
588-
setheapoverride(true);
589587
fillatt(tupdesc);
590-
setheapoverride(false);
591588

592589
/* ----------------
593590
*first we add the user attributes..
@@ -655,7 +652,7 @@ static void
655652
AddNewRelationTuple(Relationpg_class_desc,
656653
Relationnew_rel_desc,
657654
Oidnew_rel_oid,
658-
unsignednatts,
655+
intnatts,
659656
charrelkind,
660657
char*temp_relname)
661658
{
@@ -670,8 +667,6 @@ AddNewRelationTuple(Relation pg_class_desc,
670667
*/
671668
new_rel_reltup=new_rel_desc->rd_rel;
672669

673-
/* CHECK should get new_rel_oid first via an insert then use XXX */
674-
675670
/* ----------------
676671
* Here we insert bogus estimates of the size of the new relation.
677672
* In reality, of course, the new relation has 0 tuples and pages,
@@ -791,7 +786,7 @@ heap_create_with_catalog(char *relname,
791786
* ----------------
792787
*/
793788
Assert(IsNormalProcessingMode()||IsBootstrapProcessingMode());
794-
if (natts==0||natts>MaxHeapAttributeNumber)
789+
if (natts<=0||natts>MaxHeapAttributeNumber)
795790
elog(ERROR,"Number of attributes is out of range"
796791
"\n\tFrom 1 to %d attributes may be specified",
797792
MaxHeapAttributeNumber);
@@ -1856,6 +1851,12 @@ StoreConstraints(Relation rel)
18561851
if (!constr)
18571852
return;
18581853

1854+
/* deparsing of constraint expressions will fail unless the just-created
1855+
* pg_attribute tuples for this relation are made visible. So, bump
1856+
* the command counter.
1857+
*/
1858+
CommandCounterIncrement();
1859+
18591860
for (i=0;i<constr->num_defval;i++)
18601861
StoreAttrDefault(rel,constr->defval[i].adnum,
18611862
constr->defval[i].adbin, false);
@@ -1882,7 +1883,9 @@ StoreConstraints(Relation rel)
18821883
* expression.
18831884
*
18841885
* NB: caller should have opened rel with AccessExclusiveLock, and should
1885-
* hold that lock till end of transaction.
1886+
* hold that lock till end of transaction. Also, we assume the caller has
1887+
* done a CommandCounterIncrement if necessary to make the relation's catalog
1888+
* tuples visible.
18861889
*/
18871890
void
18881891
AddRelationRawConstraints(Relationrel,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp