|
7 | 7 | * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group |
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California |
9 | 9 | * |
10 | | - * $Id: rel.h,v 1.47 2001/06/1905:11:50 tgl Exp $ |
| 10 | + * $Id: rel.h,v 1.48 2001/06/1912:03:41 momjian Exp $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
@@ -187,43 +187,6 @@ typedef Relation *RelationPtr; |
187 | 187 | */ |
188 | 188 | #defineRelationGetFile(relation) ((relation)->rd_fd) |
189 | 189 |
|
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 | | -#defineRelationGetRelationName(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 | | -#defineRelationGetPhysicalRelationName(relation) \ |
225 | | -(NameStr((relation)->rd_rel->relname)) |
226 | | - |
227 | 190 | /* |
228 | 191 | * RelationGetNumberOfAttributes |
229 | 192 | * |
@@ -254,4 +217,48 @@ extern void RelationSetIndexSupport(Relation relation, |
254 | 217 | IndexStrategystrategy, |
255 | 218 | RegProcedure*support); |
256 | 219 |
|
| 220 | +/* |
| 221 | + * Handle temp relations |
| 222 | + */ |
| 223 | +#definePG_TEMP_REL_PREFIX "pg_temp" |
| 224 | + |
| 225 | +#defineis_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 | +#defineRelationGetPhysicalRelationName(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 | +#defineRelationGetRelationName(relation) \ |
| 254 | +(\ |
| 255 | +!is_temp_relname(relation) \ |
| 256 | +? \ |
| 257 | +RelationGetPhysicalRelationName(relation) \ |
| 258 | +: \ |
| 259 | +get_temp_rel_by_physicalname( \ |
| 260 | +RelationGetPhysicalRelationName(relation)) \ |
| 261 | +) |
| 262 | + |
| 263 | + |
257 | 264 | #endif/* REL_H */ |