|
13 | 13 | * Portions Copyright (c) 1994, Regents of the University of California
|
14 | 14 | *
|
15 | 15 | * IDENTIFICATION
|
16 |
| - * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.77 2005/08/01 04:03:54 tgl Exp $ |
| 16 | + * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.78 2005/10/06 22:43:16 tgl Exp $ |
17 | 17 | *
|
18 | 18 | *-------------------------------------------------------------------------
|
19 | 19 | */
|
@@ -335,12 +335,28 @@ RelationIsVisible(Oid relid)
|
335 | 335 | /*
|
336 | 336 | * If it is in the path, it might still not be visible; it could
|
337 | 337 | * be hidden by another relation of the same name earlier in the
|
338 |
| - * path. So we must do a slow check to see if this rel would be |
339 |
| - * found by RelnameGetRelid. |
| 338 | + * path. So we must do a slow check for conflicting relations. |
340 | 339 | */
|
341 | 340 | char *relname = NameStr(relform->relname);
|
| 341 | + ListCell *l; |
342 | 342 |
|
343 |
| - visible = (RelnameGetRelid(relname) == relid); |
| 343 | + visible = false; |
| 344 | + foreach(l, namespaceSearchPath) |
| 345 | + { |
| 346 | + Oid namespaceId = lfirst_oid(l); |
| 347 | + |
| 348 | + if (namespaceId == relnamespace) |
| 349 | + { |
| 350 | + /* Found it first in path */ |
| 351 | + visible = true; |
| 352 | + break; |
| 353 | + } |
| 354 | + if (OidIsValid(get_relname_relid(relname, namespaceId))) |
| 355 | + { |
| 356 | + /* Found something else first in path */ |
| 357 | + break; |
| 358 | + } |
| 359 | + } |
344 | 360 | }
|
345 | 361 |
|
346 | 362 | ReleaseSysCache(reltup);
|
@@ -417,12 +433,31 @@ TypeIsVisible(Oid typid)
|
417 | 433 | /*
|
418 | 434 | * If it is in the path, it might still not be visible; it could
|
419 | 435 | * be hidden by another type of the same name earlier in the path.
|
420 |
| - * So we must do a slow check to see if this type would be found |
421 |
| - * by TypenameGetTypid. |
| 436 | + * So we must do a slow check for conflicting types. |
422 | 437 | */
|
423 | 438 | char *typname = NameStr(typform->typname);
|
| 439 | + ListCell *l; |
424 | 440 |
|
425 |
| - visible = (TypenameGetTypid(typname) == typid); |
| 441 | + visible = false; |
| 442 | + foreach(l, namespaceSearchPath) |
| 443 | + { |
| 444 | + Oid namespaceId = lfirst_oid(l); |
| 445 | + |
| 446 | + if (namespaceId == typnamespace) |
| 447 | + { |
| 448 | + /* Found it first in path */ |
| 449 | + visible = true; |
| 450 | + break; |
| 451 | + } |
| 452 | + if (SearchSysCacheExists(TYPENAMENSP, |
| 453 | + PointerGetDatum(typname), |
| 454 | + ObjectIdGetDatum(namespaceId), |
| 455 | + 0, 0)) |
| 456 | + { |
| 457 | + /* Found something else first in path */ |
| 458 | + break; |
| 459 | + } |
| 460 | + } |
426 | 461 | }
|
427 | 462 |
|
428 | 463 | ReleaseSysCache(typtup);
|
|
0 commit comments