mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +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:
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.15 1998/09/01 04:28:09 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.16 1998/12/14 05:18:44 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* At the point the version is defined, 2 physical relations are created
|
||||
@@ -37,11 +37,6 @@
|
||||
|
||||
char rule_buf[MAX_QUERY_LEN];
|
||||
|
||||
#ifdef NOT_USED
|
||||
static char attr_list[MAX_QUERY_LEN];
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* problem: the version system assumes that the rules it declares will
|
||||
* be fired in the order of declaration, it also assumes
|
||||
|
@@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.33 1998/11/27 19:51:54 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.34 1998/12/14 05:18:39 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -165,7 +165,7 @@ cluster(char *oldrelname, char *oldindexname)
|
||||
|
||||
/* Create new index over the tuples of the new heap. */
|
||||
copy_index(OIDOldIndex, OIDNewHeap);
|
||||
sprintf(NewIndexName, "temp_%x", OIDOldIndex);
|
||||
snprintf(NewIndexName, NAMEDATALEN, "temp_%x", OIDOldIndex);
|
||||
|
||||
/*
|
||||
* make this really happen. Flush all the buffers. (Believe me, it is
|
||||
@@ -207,7 +207,7 @@ copy_heap(Oid OIDOldHeap)
|
||||
* Create a new heap relation with a temporary name, which has the
|
||||
* same tuple description as the old one.
|
||||
*/
|
||||
sprintf(NewName, "temp_%x", OIDOldHeap);
|
||||
snprintf(NewName, NAMEDATALEN, "temp_%x", OIDOldHeap);
|
||||
|
||||
OldHeap = heap_open(OIDOldHeap);
|
||||
OldHeapDesc = RelationGetDescr(OldHeap);
|
||||
@@ -235,17 +235,17 @@ copy_heap(Oid OIDOldHeap)
|
||||
static void
|
||||
copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
{
|
||||
Relation OldIndex,
|
||||
NewHeap;
|
||||
HeapTuple Old_pg_index_Tuple,
|
||||
Old_pg_index_relation_Tuple,
|
||||
pg_proc_Tuple;
|
||||
Relation OldIndex,
|
||||
NewHeap;
|
||||
HeapTuple Old_pg_index_Tuple,
|
||||
Old_pg_index_relation_Tuple,
|
||||
pg_proc_Tuple;
|
||||
Form_pg_index Old_pg_index_Form;
|
||||
Form_pg_class Old_pg_index_relation_Form;
|
||||
Form_pg_proc pg_proc_Form;
|
||||
char *NewIndexName;
|
||||
AttrNumber *attnumP;
|
||||
int natts;
|
||||
Form_pg_proc pg_proc_Form;
|
||||
char *NewIndexName;
|
||||
AttrNumber *attnumP;
|
||||
int natts;
|
||||
FuncIndexInfo *finfo;
|
||||
|
||||
NewHeap = heap_open(OIDNewHeap);
|
||||
@@ -273,8 +273,9 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
Old_pg_index_relation_Form =
|
||||
(Form_pg_class) GETSTRUCT(Old_pg_index_relation_Tuple);
|
||||
|
||||
/* Set the name. */
|
||||
NewIndexName = palloc(NAMEDATALEN); /* XXX */
|
||||
sprintf(NewIndexName, "temp_%x", OIDOldIndex); /* Set the name. */
|
||||
snprintf(NewIndexName, NAMEDATALEN, "temp_%x", OIDOldIndex);
|
||||
|
||||
/*
|
||||
* Ugly as it is, the only way I have of working out the number of
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.36 1998/11/27 19:51:55 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.37 1998/12/14 05:18:43 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -90,11 +90,11 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
|
||||
if (constraints != NIL)
|
||||
{
|
||||
List *entry;
|
||||
int nconstr = length(constraints);
|
||||
List *entry;
|
||||
int nconstr = length(constraints),
|
||||
ncheck = 0,
|
||||
i;
|
||||
ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck));
|
||||
int ncheck = 0;
|
||||
int i;
|
||||
|
||||
foreach(entry, constraints)
|
||||
{
|
||||
@@ -107,14 +107,16 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
for (i = 0; i < ncheck; i++)
|
||||
{
|
||||
if (strcmp(check[i].ccname, cdef->name) == 0)
|
||||
elog(ERROR, "DefineRelation: name (%s) of CHECK constraint duplicated", cdef->name);
|
||||
elog(ERROR,
|
||||
"DefineRelation: name (%s) of CHECK constraint duplicated",
|
||||
cdef->name);
|
||||
}
|
||||
check[ncheck].ccname = cdef->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
check[ncheck].ccname = (char *) palloc(NAMEDATALEN);
|
||||
sprintf(check[ncheck].ccname, "$%d", ncheck + 1);
|
||||
snprintf(check[ncheck].ccname, NAMEDATALEN, "$%d", ncheck + 1);
|
||||
}
|
||||
check[ncheck].ccbin = NULL;
|
||||
check[ncheck].ccsrc = (char *) cdef->def;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.26 1998/11/27 19:51:56 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.27 1998/12/14 05:18:43 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,8 +47,8 @@ createdb(char *dbname, char *dbpath, int encoding)
|
||||
Oid db_id;
|
||||
int4 user_id;
|
||||
char buf[512];
|
||||
char *lp,
|
||||
loc[512];
|
||||
char *lp,
|
||||
loc[512];
|
||||
|
||||
/*
|
||||
* If this call returns, the database does not exist and we're allowed
|
||||
@@ -64,7 +64,7 @@ createdb(char *dbname, char *dbpath, int encoding)
|
||||
{
|
||||
if (*(dbpath + strlen(dbpath) - 1) == SEP_CHAR)
|
||||
*(dbpath + strlen(dbpath) - 1) = '\0';
|
||||
sprintf(loc, "%s%c%s", dbpath, SEP_CHAR, dbname);
|
||||
snprintf(loc, 512, "%s%c%s", dbpath, SEP_CHAR, dbname);
|
||||
}
|
||||
else
|
||||
strcpy(loc, dbname);
|
||||
@@ -79,20 +79,14 @@ createdb(char *dbname, char *dbpath, int encoding)
|
||||
if (mkdir(lp, S_IRWXU) != 0)
|
||||
elog(ERROR, "Unable to create database directory '%s'", lp);
|
||||
|
||||
sprintf(buf, "%s %s%cbase%ctemplate1%c* %s",
|
||||
snprintf(buf, 512, "%s %s%cbase%ctemplate1%c* %s",
|
||||
COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp);
|
||||
system(buf);
|
||||
|
||||
#if FALSE
|
||||
sprintf(buf, "insert into pg_database (datname, datdba, datpath) \
|
||||
values ('%s'::name, '%d'::oid, '%s'::text);",
|
||||
dbname, user_id, dbname);
|
||||
#endif
|
||||
|
||||
sprintf(buf, "insert into pg_database (datname, datdba, encoding, datpath)"
|
||||
snprintf(buf, 512,
|
||||
"insert into pg_database (datname, datdba, encoding, datpath)"
|
||||
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, loc);
|
||||
|
||||
|
||||
pg_exec_query(buf);
|
||||
}
|
||||
|
||||
@@ -101,9 +95,9 @@ destroydb(char *dbname)
|
||||
{
|
||||
int4 user_id;
|
||||
Oid db_id;
|
||||
char *path;
|
||||
char dbpath[MAXPGPATH + 1];
|
||||
char buf[512];
|
||||
char *path,
|
||||
dbpath[MAXPGPATH + 1],
|
||||
buf[512];
|
||||
|
||||
/*
|
||||
* If this call returns, the database exists and we're allowed to
|
||||
@@ -127,8 +121,8 @@ destroydb(char *dbname)
|
||||
* remove the pg_database tuple FIRST, this may fail due to
|
||||
* permissions problems
|
||||
*/
|
||||
sprintf(buf, "delete from pg_database where pg_database.oid = \'%d\'::oid",
|
||||
db_id);
|
||||
snprintf(buf, 512,
|
||||
"delete from pg_database where pg_database.oid = \'%d\'::oid", db_id);
|
||||
pg_exec_query(buf);
|
||||
|
||||
/*
|
||||
@@ -136,7 +130,7 @@ destroydb(char *dbname)
|
||||
* not be reached
|
||||
*/
|
||||
|
||||
sprintf(buf, "rm -r %s", path);
|
||||
snprintf(buf, 512, "rm -r %s", path);
|
||||
system(buf);
|
||||
|
||||
/* drop pages for this database that are in the shared buffer cache */
|
||||
@@ -300,16 +294,16 @@ static void
|
||||
stop_vacuum(char *dbpath, char *dbname)
|
||||
{
|
||||
char filename[256];
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
int pid;
|
||||
|
||||
if (strchr(dbpath, SEP_CHAR) != 0)
|
||||
{
|
||||
sprintf(filename, "%s%cbase%c%s%c%s.vacuum", DataDir, SEP_CHAR, SEP_CHAR,
|
||||
dbname, SEP_CHAR, dbname);
|
||||
snprintf(filename, 256, "%s%cbase%c%s%c%s.vacuum",
|
||||
DataDir, SEP_CHAR, SEP_CHAR, dbname, SEP_CHAR, dbname);
|
||||
}
|
||||
else
|
||||
sprintf(filename, "%s%c%s.vacuum", dbpath, SEP_CHAR, dbname);
|
||||
snprintf(filename, 256, "%s%c%s.vacuum", dbpath, SEP_CHAR, dbname);
|
||||
|
||||
if ((fp = AllocateFile(filename, "r")) != NULL)
|
||||
{
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.27 1998/11/22 10:48:34 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.28 1998/12/14 05:18:43 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -146,11 +146,11 @@ ExplainOneQuery(Query *query, bool verbose, CommandDest dest)
|
||||
static void
|
||||
explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
{
|
||||
List *l;
|
||||
List *l;
|
||||
Relation relation;
|
||||
char *pname;
|
||||
char buf[1000];
|
||||
int i;
|
||||
char *pname,
|
||||
buf[1000];
|
||||
int i;
|
||||
|
||||
if (plan == NULL)
|
||||
{
|
||||
@@ -207,11 +207,6 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < indent; i++)
|
||||
appendStringInfo(str, " ");
|
||||
#endif
|
||||
|
||||
appendStringInfo(str, pname);
|
||||
switch (nodeTag(plan))
|
||||
{
|
||||
@@ -233,7 +228,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
appendStringInfo(str, " on ");
|
||||
if (strcmp(rte->refname, rte->relname) != 0)
|
||||
{
|
||||
sprintf(buf, "%s ", rte->relname);
|
||||
snprintf(buf, 1000, "%s ", rte->relname);
|
||||
appendStringInfo(str, buf);
|
||||
}
|
||||
appendStringInfo(str, rte->refname);
|
||||
@@ -244,7 +239,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
}
|
||||
if (es->printCost)
|
||||
{
|
||||
sprintf(buf, " (cost=%.2f size=%d width=%d)",
|
||||
snprintf(buf, 1000, " (cost=%.2f size=%d width=%d)",
|
||||
plan->cost, plan->plan_size, plan->plan_width);
|
||||
appendStringInfo(str, buf);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.25 1998/10/21 16:21:21 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.26 1998/12/14 05:18:44 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -121,18 +121,18 @@ static QueryTreeList *tg_parseTeeNode(TgRecipe * r,
|
||||
void
|
||||
beginRecipe(RecipeStmt *stmt)
|
||||
{
|
||||
TgRecipe *r;
|
||||
int i;
|
||||
TgRecipe *r;
|
||||
int i,
|
||||
numTees;
|
||||
QueryTreeList *qList;
|
||||
char portalName[1024];
|
||||
char portalName[1024];
|
||||
|
||||
Plan *plan;
|
||||
TupleDesc attinfo;
|
||||
QueryDesc *queryDesc;
|
||||
Query *parsetree;
|
||||
Plan *plan;
|
||||
TupleDesc attinfo;
|
||||
QueryDesc *queryDesc;
|
||||
Query *parsetree;
|
||||
|
||||
int numTees;
|
||||
TeeInfo *teeInfo;
|
||||
TeeInfo *teeInfo;
|
||||
|
||||
/*
|
||||
* retrieveRecipe() reads the recipe from the database and returns a
|
||||
@@ -269,7 +269,7 @@ beginRecipe(RecipeStmt *stmt)
|
||||
|
||||
/* define a portal for this viewer input */
|
||||
/* for now, eyes can only have one input */
|
||||
sprintf(portalName, "%s%d", e->nodeName, 0);
|
||||
snprintf(portalName, 1024, "%s%d", e->nodeName, 0);
|
||||
|
||||
queryDesc = CreateQueryDesc(parsetree,
|
||||
plan,
|
||||
@@ -808,21 +808,21 @@ tg_parseTeeNode(TgRecipe * r,
|
||||
static QueryTreeList *
|
||||
tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
||||
{
|
||||
TgElement *elem;
|
||||
char *funcName;
|
||||
Oid typev[8]; /* eight arguments maximum */
|
||||
int i;
|
||||
int parameterCount;
|
||||
TgElement *elem;
|
||||
char *funcName;
|
||||
Oid typev[8], /* eight arguments maximum */
|
||||
relid;
|
||||
int i,
|
||||
parameterCount;
|
||||
|
||||
QueryTreeList *qList; /* the parse tree of the nodeElement */
|
||||
QueryTreeList *inputQlist; /* the list of parse trees for the inputs
|
||||
* to this node */
|
||||
QueryTreeList *q;
|
||||
Oid relid;
|
||||
TgNode *child;
|
||||
Relation rel;
|
||||
unsigned int len;
|
||||
TupleDesc tupdesc;
|
||||
TgNode *child;
|
||||
Relation rel;
|
||||
unsigned int len;
|
||||
TupleDesc tupdesc;
|
||||
|
||||
qList = NULL;
|
||||
|
||||
@@ -876,13 +876,13 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
sprintf(newquery, "select %s($1", funcName);
|
||||
snprintf(newquery, 1000, "select %s($1", funcName);
|
||||
for (i = 1; i < parameterCount; i++)
|
||||
sprintf(newquery, "%s,$%d", newquery, i);
|
||||
sprintf(newquery, "%s)", newquery);
|
||||
snprintf(newquery, 1000, "%s,$%d", newquery, i);
|
||||
snprintf(newquery, 1000, "%s)", newquery);
|
||||
}
|
||||
else
|
||||
sprintf(newquery, "select %s()", funcName);
|
||||
snprintf(newquery, 1000, "select %s()", funcName);
|
||||
|
||||
#ifdef DEBUG_RECIPE
|
||||
elog(NOTICE, "calling parser with %s", newquery);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.26 1998/10/21 16:21:22 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.27 1998/12/14 05:18:44 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -122,7 +122,7 @@ MakeRetrieveViewRuleName(char *viewName)
|
||||
char *buf;
|
||||
|
||||
buf = palloc(strlen(viewName) + 5);
|
||||
sprintf(buf, "_RET%s", viewName);
|
||||
snprintf(buf, strlen(viewName) + 5, "_RET%s", viewName);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
Reference in New Issue
Block a user