Skip to content

Commit d9a069e

Browse files
committed
Move temprel name define from temprel.h to rel.h.
1 parent d47e10b commit d9a069e

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

src/include/utils/rel.h

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: rel.h,v 1.47 2001/06/19 05:11:50 tgl Exp $
10+
* $Id: rel.h,v 1.48 2001/06/19 12:03:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -187,43 +187,6 @@ typedef Relation *RelationPtr;
187187
*/
188188
#define RelationGetFile(relation) ((relation)->rd_fd)
189189

190-
/*
191-
* RelationGetRelationName
192-
*
193-
* Returns the relation's logical name (as seen by the user).
194-
*
195-
* If the rel is a temp rel, the temp name will be returned. Therefore,
196-
* this name is not unique. But it is the name to use in heap_openr(),
197-
* for example.
198-
*/
199-
#define RelationGetRelationName(relation) \
200-
(\
201-
(strncmp(RelationGetPhysicalRelationName(relation), \
202-
"pg_temp", 7) != 0) \
203-
? \
204-
RelationGetPhysicalRelationName(relation) \
205-
: \
206-
get_temp_rel_by_physicalname( \
207-
RelationGetPhysicalRelationName(relation)) \
208-
)
209-
210-
211-
/*
212-
* RelationGetPhysicalRelationName
213-
*
214-
* Returns the rel's physical name, ie, the name appearing in pg_class.
215-
*
216-
* While this name is unique across all rels in the database, it is not
217-
* necessarily useful for accessing the rel, since a temp table of the
218-
* same name might mask the rel. It is useful mainly for determining if
219-
* the rel is a shared system rel or not.
220-
*
221-
* The macro is rather unfortunately named, since the pg_class name no longer
222-
* has anything to do with the file name used for physical storage of the rel.
223-
*/
224-
#define RelationGetPhysicalRelationName(relation) \
225-
(NameStr((relation)->rd_rel->relname))
226-
227190
/*
228191
* RelationGetNumberOfAttributes
229192
*
@@ -254,4 +217,48 @@ extern void RelationSetIndexSupport(Relation relation,
254217
IndexStrategy strategy,
255218
RegProcedure *support);
256219

220+
/*
221+
* Handle temp relations
222+
*/
223+
#define PG_TEMP_REL_PREFIX "pg_temp"
224+
225+
#define is_temp_relname(relname) \
226+
(strncmp(relname, PG_TEMP_REL_PREFIX, strlen(PG_TEMP_REL_PREFIX)) == 0)
227+
228+
/*
229+
* RelationGetPhysicalRelationName
230+
*
231+
* Returns the rel's physical name, ie, the name appearing in pg_class.
232+
*
233+
* While this name is unique across all rels in the database, it is not
234+
* necessarily useful for accessing the rel, since a temp table of the
235+
* same name might mask the rel. It is useful mainly for determining if
236+
* the rel is a shared system rel or not.
237+
*
238+
* The macro is rather unfortunately named, since the pg_class name no longer
239+
* has anything to do with the file name used for physical storage of the rel.
240+
*/
241+
#define RelationGetPhysicalRelationName(relation) \
242+
(NameStr((relation)->rd_rel->relname))
243+
244+
/*
245+
* RelationGetRelationName
246+
*
247+
* Returns the relation's logical name (as seen by the user).
248+
*
249+
* If the rel is a temp rel, the temp name will be returned. Therefore,
250+
* this name is not unique. But it is the name to use in heap_openr(),
251+
* for example.
252+
*/
253+
#define RelationGetRelationName(relation) \
254+
(\
255+
!is_temp_relname(relation) \
256+
? \
257+
RelationGetPhysicalRelationName(relation) \
258+
: \
259+
get_temp_rel_by_physicalname( \
260+
RelationGetPhysicalRelationName(relation)) \
261+
)
262+
263+
257264
#endif /* REL_H */

src/include/utils/temprel.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: temprel.h,v 1.16 2001/06/18 16:13:21 momjian Exp $
10+
* $Id: temprel.h,v 1.17 2001/06/19 12:03:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -16,11 +16,6 @@
1616

1717
#include "access/htup.h"
1818

19-
#define PG_TEMP_REL_PREFIX "pg_temp"
20-
21-
#define is_temp_relname(relname) \
22-
(strncmp(relname, PG_TEMP_REL_PREFIX, strlen(PG_TEMP_REL_PREFIX)) == 0)
23-
2419
extern void create_temp_relation(const char *relname,
2520
HeapTuple pg_class_tuple);
2621
extern void remove_temp_rel_by_relid(Oid relid);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy