1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-13 16:22:44 +03:00

Initial attempt to clean up the code...

Switch sprintf() to snprintf()
Remove any/all #if 0 -or- #ifdef NOT_USED -or- #ifdef FALSE sections of
	code
This commit is contained in:
Marc G. Fournier
1998-12-14 05:19:16 +00:00
parent f722af618a
commit 7c3b7d2744
21 changed files with 5898 additions and 5812 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.18 1998/09/01 04:27:28 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.19 1998/12/14 05:18:36 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -29,40 +29,19 @@
char *
relpath(char *relname)
{
char *path;
char *path;
int bufsize = 0;
if (IsSharedSystemRelationName(relname))
{
path = (char *) palloc(strlen(DataDir) + sizeof(NameData) + 2);
sprintf(path, "%s/%s", DataDir, relname);
bufsize = strlen(DataDir) + sizeof(NameData) + 2;
path = (char *) palloc(bufsize);
snprintf(path, bufsize, "%s/%s", DataDir, relname);
return path;
}
return relname;
}
#ifdef NOT_USED
/*
* issystem - returns non-zero iff relname is a system catalog
*
* We now make a new requirement where system catalog relns must begin
* with pg_ while user relns are forbidden to do so. Make the test
* trivial and instantaneous.
*
* XXX this is way bogus. -- pma
*/
bool
issystem(char *relname)
{
if (relname[0] && relname[1] && relname[2])
return (relname[0] == 'p' &&
relname[1] == 'g' &&
relname[2] == '_');
else
return FALSE;
}
#endif
/*
* IsSystemRelationName --
* True iff name is the name of a system catalog relation.

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.68 1998/12/13 23:50:58 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.69 1998/12/14 05:18:37 scrappy Exp $
*
* INTERFACE ROUTINES
* heap_create() - Create an uncataloged heap relation
@@ -244,7 +244,7 @@ heap_create(char *name,
if (name[0] == '\0')
{
sprintf(tempname, "temp_%d", relid);
snprintf(tempname, NAMEDATALEN, "temp_%d", relid);
Assert(strlen(tempname) < NAMEDATALEN);
relname = tempname;
isTemp = 1;
@@ -1448,8 +1448,9 @@ start:;
/* Surround table name with double quotes to allow mixed-case and
* whitespaces in names. - BGA 1998-11-14
*/
sprintf(str, "select %s%s from \"%.*s\"", attrdef->adsrc, cast,
NAMEDATALEN, rel->rd_rel->relname.data);
snprintf(str, MAX_PARSE_BUFFER,
"select %s%s from \"%.*s\"", attrdef->adsrc, cast,
NAMEDATALEN, rel->rd_rel->relname.data);
setheapoverride(true);
planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);
setheapoverride(false);
@@ -1463,22 +1464,6 @@ start:;
expr = te->expr;
type = exprType(expr);
#if 0
if (IsA(expr, Const))
{
if (((Const *) expr)->consttype != atp->atttypid)
{
if (*cast != 0)
elog(ERROR, "DEFAULT: const type mismatched");
sprintf(cast, ":: %s", typeidTypeName(atp->atttypid));
goto start;
}
}
else if ((exprType(expr) != atp->atttypid)
&& !IS_BINARY_COMPATIBLE(exprType(expr), atp->atttypid))
elog(ERROR, "DEFAULT: type mismatched");
#endif
if (type != atp->atttypid)
{
if (IS_BINARY_COMPATIBLE(type, atp->atttypid))
@@ -1490,7 +1475,7 @@ start:;
if (*cast != 0)
elog(ERROR, "DEFAULT clause const type '%s' mismatched with column type '%s'",
typeidTypeName(type), typeidTypeName(atp->atttypid));
sprintf(cast, ":: %s", typeidTypeName(atp->atttypid));
snprintf(cast, 2*NAMEDATALEN, ":: %s", typeidTypeName(atp->atttypid));
goto start;
}
else
@@ -1544,7 +1529,8 @@ StoreRelCheck(Relation rel, ConstrCheck *check)
/* Check for table's existance. Surround table name with double-quotes
* to allow mixed-case and whitespace names. - thomas 1998-11-12
*/
sprintf(str, "select 1 from \"%.*s\" where %s",
snprintf(str, MAX_PARSE_BUFFER,
"select 1 from \"%.*s\" where %s",
NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
setheapoverride(true);
planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);