1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

New NameStr macro to convert Name to Str. No need for var.data anymore.

Fewer calls to nameout.

Better use of RelationGetRelationName.
This commit is contained in:
Bruce Momjian
1999-11-07 23:08:36 +00:00
parent df723a8a8a
commit 86ef36c907
65 changed files with 273 additions and 266 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.50 1999/11/01 02:29:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.51 1999/11/07 23:08:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -209,7 +209,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
cache->cc_skey[i].sk_nargs = cache->cc_skey[i].sk_func.fn_nargs;
CACHE5_elog(DEBUG, "CatalogCacheInit %s %d %d %x",
&relation->rd_rel->relname,
RelationGetRelationName(relation),
i,
tupdesc->attrs[cache->cc_key[i] - 1]->attlen,
cache);
@ -304,7 +304,7 @@ comphash(long l, char *v)
* typelen so this may break them - XXX
*/
namestrcpy(&n, v);
v = n.data;
v = NameStr(n);
}
else if (l < 0)
l = VARSIZE(v);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.27 1999/07/16 05:00:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.28 1999/11/07 23:08:26 momjian Exp $
*
* Note - this code is real crufty...
*
@ -584,7 +584,7 @@ RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple)
* this only works for system relations now
* ----------------
*/
if (!IsSystemRelationName(RelationGetForm(relation)->relname.data))
if (!IsSystemRelationName(NameStr(RelationGetForm(relation)->relname)))
return;
/* ----------------

View File

@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.34 1999/09/09 02:36:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.35 1999/11/07 23:08:26 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@ -62,7 +62,7 @@ get_attname(Oid relid, AttrNumber attnum)
if (HeapTupleIsValid(tp))
{
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
return pstrdup(att_tup->attname.data);
return pstrdup(NameStr(att_tup->attname));
}
else
return NULL;
@ -292,7 +292,7 @@ get_opname(Oid opno)
if (HeapTupleIsValid(tp))
{
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
return pstrdup(optup->oprname.data);
return pstrdup(NameStr(optup->oprname));
}
else
return NULL;
@ -529,7 +529,7 @@ get_rel_name(Oid relid)
if (HeapTupleIsValid(tp))
{
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
return pstrdup(reltup->relname.data);
return pstrdup(NameStr(reltup->relname));
}
else
return NULL;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.75 1999/11/04 08:00:59 inoue Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.76 1999/11/07 23:08:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -133,7 +133,7 @@ typedef struct relnamecacheent
do { \
RelIdCacheEnt *idhentry; RelNameCacheEnt *namehentry; \
char *relname; Oid reloid; bool found; \
relname = (RELATION->rd_rel->relname).data; \
relname = RelationGetRelationName(RELATION); \
namehentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \
relname, \
HASH_ENTER, \
@ -186,7 +186,7 @@ do { \
do { \
RelNameCacheEnt *namehentry; RelIdCacheEnt *idhentry; \
char *relname; Oid reloid; bool found; \
relname = (RELATION->rd_rel->relname).data; \
relname = RelationGetRelationName(RELATION); \
namehentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \
relname, \
HASH_REMOVE, \
@ -534,7 +534,7 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cannot find attribute %d of relation %s", i,
relation->rd_rel->relname.data);
RelationGetRelationName(relation));
attp = (Form_pg_attribute) GETSTRUCT(atttup);
relation->rd_att->attrs[i - 1] =
@ -962,7 +962,7 @@ formrdesc(char *relationName,
relation->rd_rel = (Form_pg_class)
palloc((Size) (sizeof(*relation->rd_rel)));
MemSet(relation->rd_rel, 0, sizeof(FormData_pg_class));
namestrcpy(&relation->rd_rel->relname, relationName);
strcpy(RelationGetRelationName(relation), relationName);
/* ----------------
initialize attribute tuple form
@ -1092,7 +1092,7 @@ RelationNameCacheGetRelation(char *relationName)
* null-padded
*/
namestrcpy(&name, relationName);
RelationNameCacheLookup(name.data, rd);
RelationNameCacheLookup(NameStr(name), rd);
if (RelationIsValid(rd))
{
@ -1373,7 +1373,7 @@ RelationForgetRelation(Oid rid)
}
if (curr == NIL)
elog(FATAL, "Local relation %s not found in list",
(RelationGetRelationName(relation))->data);
RelationGetRelationName(relation));
if (prev == NIL)
newlyCreatedRelns = lnext(newlyCreatedRelns);
else
@ -1745,16 +1745,16 @@ AttrDefaultFetch(Relation relation)
continue;
if (attrdef[i].adbin != NULL)
elog(ERROR, "AttrDefaultFetch: second record found for attr %s in rel %s",
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
RelationGetRelationName(relation));
val = (struct varlena *) fastgetattr(&tuple,
Anum_pg_attrdef_adbin,
adrel->rd_att, &isnull);
if (isnull)
elog(ERROR, "AttrDefaultFetch: adbin IS NULL for attr %s in rel %s",
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
RelationGetRelationName(relation));
attrdef[i].adbin = textout(val);
break;
}
@ -1763,12 +1763,12 @@ AttrDefaultFetch(Relation relation)
if (i >= ndef)
elog(ERROR, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
adform->adnum,
relation->rd_rel->relname.data);
RelationGetRelationName(relation));
}
if (found < ndef)
elog(ERROR, "AttrDefaultFetch: %d record not found for rel %s",
ndef - found, relation->rd_rel->relname.data);
ndef - found, RelationGetRelationName(relation));
index_endscan(sd);
pfree(sd);
@ -1818,21 +1818,21 @@ RelCheckFetch(Relation relation)
continue;
if (found == ncheck)
elog(ERROR, "RelCheckFetch: unexpected record found for rel %s",
relation->rd_rel->relname.data);
RelationGetRelationName(relation));
rcname = (Name) fastgetattr(&tuple,
Anum_pg_relcheck_rcname,
rcrel->rd_att, &isnull);
if (isnull)
elog(ERROR, "RelCheckFetch: rcname IS NULL for rel %s",
relation->rd_rel->relname.data);
check[found].ccname = nameout(rcname);
RelationGetRelationName(relation));
check[found].ccname = pstrdup(NameStr(*rcname));
val = (struct varlena *) fastgetattr(&tuple,
Anum_pg_relcheck_rcbin,
rcrel->rd_att, &isnull);
if (isnull)
elog(ERROR, "RelCheckFetch: rcbin IS NULL for rel %s",
relation->rd_rel->relname.data);
RelationGetRelationName(relation));
check[found].ccbin = textout(val);
found++;
ReleaseBuffer(buffer);
@ -1841,7 +1841,7 @@ RelCheckFetch(Relation relation)
if (found < ncheck)
elog(ERROR, "RelCheckFetch: %d record not found for rel %s",
ncheck - found,
relation->rd_rel->relname.data);
RelationGetRelationName(relation));
index_endscan(sd);
pfree(sd);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.14 1999/09/04 22:03:09 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.15 1999/11/07 23:08:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -62,8 +62,8 @@ create_temp_relation(char *relname, HeapTuple pg_class_tuple)
/* save user-supplied name */
strcpy(temp_rel->user_relname, relname);
StrNCpy(temp_rel->relname, ((Form_pg_class)
GETSTRUCT(pg_class_tuple))->relname.data, NAMEDATALEN);
StrNCpy(temp_rel->relname, NameStr(((Form_pg_class)
GETSTRUCT(pg_class_tuple))->relname), NAMEDATALEN);
temp_rel->relid = pg_class_tuple->t_data->t_oid;
temp_rel->relkind = ((Form_pg_class) GETSTRUCT(pg_class_tuple))->relkind;
temp_rel->xid = GetCurrentTransactionId();