Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
a83bd89d
Commit
a83bd89d
authored
Nov 12, 2001
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indent new rename.c for Tom Lane.
parent
b52950cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
56 deletions
+56
-56
src/backend/commands/rename.c
src/backend/commands/rename.c
+56
-56
No files found.
src/backend/commands/rename.c
View file @
a83bd89d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.6
2 2001/11/12 00:46:36 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.6
3 2001/11/12 01:34:50 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -41,16 +41,16 @@
...
@@ -41,16 +41,16 @@
#include "utils/temprel.h"
#include "utils/temprel.h"
#define RI_TRIGGER_PK
1
/* is a trigger on the PK relation */
#define RI_TRIGGER_PK
1
/* is a trigger on the PK relation */
#define RI_TRIGGER_FK
2
/* is a trigger on the FK relation */
#define RI_TRIGGER_FK
2
/* is a trigger on the FK relation */
#define RI_TRIGGER_NONE 0
/* is not an RI trigger function */
#define RI_TRIGGER_NONE 0
/* is not an RI trigger function */
static
int
ri_trigger_type
(
Oid
tgfoid
);
static
int
ri_trigger_type
(
Oid
tgfoid
);
static
void
update_ri_trigger_args
(
Oid
relid
,
static
void
update_ri_trigger_args
(
Oid
relid
,
const
char
*
oldname
,
const
char
*
oldname
,
const
char
*
newname
,
const
char
*
newname
,
bool
fk_scan
,
bool
fk_scan
,
bool
update_relname
);
bool
update_relname
);
/*
/*
...
@@ -251,7 +251,7 @@ renameatt(char *relname,
...
@@ -251,7 +251,7 @@ renameatt(char *relname,
if
(
targetrelation
->
rd_rel
->
reltriggers
>
0
)
if
(
targetrelation
->
rd_rel
->
reltriggers
>
0
)
{
{
/* update tgargs column reference where att is primary key */
/* update tgargs column reference where att is primary key */
update_ri_trigger_args
(
RelationGetRelid
(
targetrelation
),
update_ri_trigger_args
(
RelationGetRelid
(
targetrelation
),
oldattname
,
newattname
,
oldattname
,
newattname
,
false
,
false
);
false
,
false
);
/* update tgargs column reference where att is foreign key */
/* update tgargs column reference where att is foreign key */
...
@@ -425,19 +425,19 @@ ri_trigger_type(Oid tgfoid)
...
@@ -425,19 +425,19 @@ ri_trigger_type(Oid tgfoid)
*/
*/
static
void
static
void
update_ri_trigger_args
(
Oid
relid
,
update_ri_trigger_args
(
Oid
relid
,
const
char
*
oldname
,
const
char
*
oldname
,
const
char
*
newname
,
const
char
*
newname
,
bool
fk_scan
,
bool
fk_scan
,
bool
update_relname
)
bool
update_relname
)
{
{
Relation
tgrel
;
Relation
tgrel
;
Relation
irel
;
Relation
irel
;
ScanKeyData
skey
[
1
];
ScanKeyData
skey
[
1
];
IndexScanDesc
idxtgscan
;
IndexScanDesc
idxtgscan
;
RetrieveIndexResult
idxres
;
RetrieveIndexResult
idxres
;
Datum
values
[
Natts_pg_trigger
];
Datum
values
[
Natts_pg_trigger
];
char
nulls
[
Natts_pg_trigger
];
char
nulls
[
Natts_pg_trigger
];
char
replaces
[
Natts_pg_trigger
];
char
replaces
[
Natts_pg_trigger
];
tgrel
=
heap_openr
(
TriggerRelationName
,
RowExclusiveLock
);
tgrel
=
heap_openr
(
TriggerRelationName
,
RowExclusiveLock
);
if
(
fk_scan
)
if
(
fk_scan
)
...
@@ -445,29 +445,29 @@ update_ri_trigger_args(Oid relid,
...
@@ -445,29 +445,29 @@ update_ri_trigger_args(Oid relid,
else
else
irel
=
index_openr
(
TriggerRelidIndex
);
irel
=
index_openr
(
TriggerRelidIndex
);
ScanKeyEntryInitialize
(
&
skey
[
0
],
0x0
,
ScanKeyEntryInitialize
(
&
skey
[
0
],
0x0
,
1
,
/* always column 1 of index */
1
,
/* always column 1 of index */
F_OIDEQ
,
F_OIDEQ
,
ObjectIdGetDatum
(
relid
));
ObjectIdGetDatum
(
relid
));
idxtgscan
=
index_beginscan
(
irel
,
false
,
1
,
skey
);
idxtgscan
=
index_beginscan
(
irel
,
false
,
1
,
skey
);
while
((
idxres
=
index_getnext
(
idxtgscan
,
ForwardScanDirection
))
!=
NULL
)
while
((
idxres
=
index_getnext
(
idxtgscan
,
ForwardScanDirection
))
!=
NULL
)
{
{
HeapTupleData
tupledata
;
HeapTupleData
tupledata
;
Buffer
buffer
;
Buffer
buffer
;
HeapTuple
tuple
;
HeapTuple
tuple
;
Form_pg_trigger
pg_trigger
;
Form_pg_trigger
pg_trigger
;
bytea
*
val
;
bytea
*
val
;
bytea
*
newtgargs
;
bytea
*
newtgargs
;
bool
isnull
;
bool
isnull
;
int
tg_type
;
int
tg_type
;
bool
examine_pk
;
bool
examine_pk
;
bool
changed
;
bool
changed
;
int
tgnargs
;
int
tgnargs
;
int
i
;
int
i
;
int
newlen
;
int
newlen
;
const
char
*
arga
[
RI_MAX_ARGUMENTS
];
const
char
*
arga
[
RI_MAX_ARGUMENTS
];
const
char
*
argp
;
const
char
*
argp
;
tupledata
.
t_self
=
idxres
->
heap_iptr
;
tupledata
.
t_self
=
idxres
->
heap_iptr
;
heap_fetch
(
tgrel
,
SnapshotNow
,
&
tupledata
,
&
buffer
,
idxtgscan
);
heap_fetch
(
tgrel
,
SnapshotNow
,
&
tupledata
,
&
buffer
,
idxtgscan
);
...
@@ -487,8 +487,8 @@ update_ri_trigger_args(Oid relid,
...
@@ -487,8 +487,8 @@ update_ri_trigger_args(Oid relid,
/*
/*
* It is an RI trigger, so parse the tgargs bytea.
* It is an RI trigger, so parse the tgargs bytea.
*
*
* NB: we assume the field will never be compressed or moved
* NB: we assume the field will never be compressed or moved
out of
*
out of
line; so does trigger.c ...
* line; so does trigger.c ...
*/
*/
tgnargs
=
pg_trigger
->
tgnargs
;
tgnargs
=
pg_trigger
->
tgnargs
;
val
=
(
bytea
*
)
fastgetattr
(
tuple
,
val
=
(
bytea
*
)
fastgetattr
(
tuple
,
...
@@ -505,15 +505,15 @@ update_ri_trigger_args(Oid relid,
...
@@ -505,15 +505,15 @@ update_ri_trigger_args(Oid relid,
for
(
i
=
0
;
i
<
tgnargs
;
i
++
)
for
(
i
=
0
;
i
<
tgnargs
;
i
++
)
{
{
arga
[
i
]
=
argp
;
arga
[
i
]
=
argp
;
argp
+=
strlen
(
argp
)
+
1
;
argp
+=
strlen
(
argp
)
+
1
;
}
}
/*
/*
* Figure out which item(s) to look at. If the trigger is
* Figure out which item(s) to look at. If the trigger is
* primary-key type and attached to my rel, I should look at
* primary-key type and attached to my rel, I should look at
the
*
the PK fields; if it is foreign-key type and attached to my
*
PK fields; if it is foreign-key type and attached to my rel, I
*
rel, I should look at the FK fields. But the opposite rule
*
should look at the FK fields. But the opposite rule holds when
*
holds when
examining triggers found by tgconstrrel search.
* examining triggers found by tgconstrrel search.
*/
*/
examine_pk
=
(
tg_type
==
RI_TRIGGER_PK
)
==
(
!
fk_scan
);
examine_pk
=
(
tg_type
==
RI_TRIGGER_PK
)
==
(
!
fk_scan
);
...
@@ -590,27 +590,27 @@ update_ri_trigger_args(Oid relid,
...
@@ -590,27 +590,27 @@ update_ri_trigger_args(Oid relid,
simple_heap_update
(
tgrel
,
&
tuple
->
t_self
,
tuple
);
simple_heap_update
(
tgrel
,
&
tuple
->
t_self
,
tuple
);
{
{
Relation
irelations
[
Num_pg_attr_indices
];
Relation
irelations
[
Num_pg_attr_indices
];
CatalogOpenIndices
(
Num_pg_trigger_indices
,
Name_pg_trigger_indices
,
irelations
);
CatalogIndexInsert
(
irelations
,
Num_pg_trigger_indices
,
tgrel
,
tuple
);
CatalogCloseIndices
(
Num_pg_trigger_indices
,
irelations
);
}
CatalogOpenIndices
(
Num_pg_trigger_indices
,
Name_pg_trigger_indices
,
irelations
);
CatalogIndexInsert
(
irelations
,
Num_pg_trigger_indices
,
tgrel
,
tuple
);
CatalogCloseIndices
(
Num_pg_trigger_indices
,
irelations
);
}
/* free up our scratch memory */
/* free up our scratch memory */
pfree
(
newtgargs
);
pfree
(
newtgargs
);
heap_freetuple
(
tuple
);
heap_freetuple
(
tuple
);
}
}
index_endscan
(
idxtgscan
);
index_endscan
(
idxtgscan
);
index_close
(
irel
);
index_close
(
irel
);
heap_close
(
tgrel
,
RowExclusiveLock
);
heap_close
(
tgrel
,
RowExclusiveLock
);
/*
/*
* Increment cmd counter to make updates visible; this is needed
* Increment cmd counter to make updates visible; this is needed
in
*
in case the same tuple has to be updated again by next pass
*
case the same tuple has to be updated again by next pass (can
*
(can
happen in case of a self-referential FK relationship).
* happen in case of a self-referential FK relationship).
*/
*/
CommandCounterIncrement
();
CommandCounterIncrement
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment