mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
more cleanups...of note, appendStringInfo now performs like sprintf(),
where you state a format and arguments. the old behavior required each appendStringInfo to have to have a sprintf() before it if any formatting was required. Also shortened several instances where there were multiple appendStringInfo() calls in a row, doing nothing more then adding one more word to the String, instead of doing them all in one call.
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
/*
|
||||
* explain.c--
|
||||
* Explain the query execution plan
|
||||
*
|
||||
* Copyright (c) 1994-5, Regents of the University of California
|
||||
*
|
||||
* $Id: explain.c,v 1.29 1998/12/14 08:11:00 scrappy Exp $
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.28 1998/12/14 05:18:43 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -217,7 +213,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
{
|
||||
relation = RelationIdCacheGetRelation((int) lfirst(l));
|
||||
if (++i > 1)
|
||||
{
|
||||
appendStringInfo(str, ", ");
|
||||
}
|
||||
appendStringInfo(str, (RelationGetRelationName(relation))->data);
|
||||
}
|
||||
case T_SeqScan:
|
||||
@@ -239,9 +237,8 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
}
|
||||
if (es->printCost)
|
||||
{
|
||||
snprintf(buf, 1000, " (cost=%.2f size=%d width=%d)",
|
||||
appendStringInfo(str, " (cost=%.2f size=%d width=%d)",
|
||||
plan->cost, plan->plan_size, plan->plan_width);
|
||||
appendStringInfo(str, buf);
|
||||
}
|
||||
appendStringInfo(str, "\n");
|
||||
|
||||
@@ -251,14 +248,18 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
List *saved_rtable = es->rtable;
|
||||
List *lst;
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
for (i = 0; i < indent; i++)
|
||||
{
|
||||
appendStringInfo(str, " ");
|
||||
}
|
||||
appendStringInfo(str, " InitPlan\n");
|
||||
foreach(lst, plan->initPlan)
|
||||
{
|
||||
es->rtable = ((SubPlan *) lfirst(lst))->rtable;
|
||||
for (i = 0; i < indent; i++)
|
||||
{
|
||||
appendStringInfo(str, " ");
|
||||
}
|
||||
appendStringInfo(str, " -> ");
|
||||
explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 2, es);
|
||||
}
|
||||
@@ -269,7 +270,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
if (outerPlan(plan))
|
||||
{
|
||||
for (i = 0; i < indent; i++)
|
||||
{
|
||||
appendStringInfo(str, " ");
|
||||
}
|
||||
appendStringInfo(str, " -> ");
|
||||
explain_outNode(str, outerPlan(plan), indent + 3, es);
|
||||
}
|
||||
@@ -278,7 +281,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
if (innerPlan(plan))
|
||||
{
|
||||
for (i = 0; i < indent; i++)
|
||||
{
|
||||
appendStringInfo(str, " ");
|
||||
}
|
||||
appendStringInfo(str, " -> ");
|
||||
explain_outNode(str, innerPlan(plan), indent + 3, es);
|
||||
}
|
||||
@@ -290,13 +295,17 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
List *lst;
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
{
|
||||
appendStringInfo(str, " ");
|
||||
}
|
||||
appendStringInfo(str, " SubPlan\n");
|
||||
foreach(lst, plan->subPlan)
|
||||
{
|
||||
es->rtable = ((SubPlan *) lfirst(lst))->rtable;
|
||||
for (i = 0; i < indent; i++)
|
||||
{
|
||||
appendStringInfo(str, " ");
|
||||
}
|
||||
appendStringInfo(str, " -> ");
|
||||
explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 4, es);
|
||||
}
|
||||
@@ -327,7 +336,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
es->rtable = nth(whichplan, appendplan->unionrtables);
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
{
|
||||
appendStringInfo(str, " ");
|
||||
}
|
||||
appendStringInfo(str, " -> ");
|
||||
|
||||
explain_outNode(str, subnode, indent + 4, es);
|
||||
|
@@ -5,11 +5,11 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: user.c,v 1.21 1998/12/14 06:50:18 scrappy Exp $
|
||||
* $Id: user.c,v 1.22 1998/12/14 08:11:00 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h> /* for sprintf() */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -68,7 +68,7 @@ UpdatePgPwdFile(char *sql)
|
||||
* SEPCHAR character as the delimiter between fields. Then rename the
|
||||
* file to its final name.
|
||||
*/
|
||||
snprintf(sql, QRY_LENGTH,
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
"copy %s to '%s' using delimiters %s",
|
||||
ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
|
||||
pg_exec_query(sql);
|
||||
@@ -173,7 +173,7 @@ DefineUser(CreateUserStmt *stmt)
|
||||
(stmt->createdb && *stmt->createdb) ? ",'t','t'" : ",'f','t'",
|
||||
(stmt->createuser && *stmt->createuser) ? ",'t','t'" : ",'f','t'",
|
||||
stmt->password ? stmt->password : "''",
|
||||
stmt->validUntil ? stmt->valudUntil : "");
|
||||
stmt->validUntil ? stmt->validUntil : "");
|
||||
|
||||
pg_exec_query(sql);
|
||||
|
||||
@@ -262,20 +262,20 @@ AlterUser(AlterUserStmt *stmt)
|
||||
if (stmt->createdb)
|
||||
{
|
||||
snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'",
|
||||
stmt->password ? "," : "",
|
||||
*stmt->createdb ? "t" : "f");
|
||||
sql, stmt->password ? "," : "", *stmt->createdb ? "t" : "f");
|
||||
}
|
||||
|
||||
if (stmt->createuser)
|
||||
{
|
||||
snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
|
||||
(stmt->password || stmt->createdb) ? "," : "",
|
||||
sql, (stmt->password || stmt->createdb) ? "," : "",
|
||||
*stmt->createuser ? "t" : "f");
|
||||
}
|
||||
|
||||
if (stmt->validUntil)
|
||||
{
|
||||
snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
|
||||
sql,
|
||||
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
|
||||
stmt->validUntil);
|
||||
}
|
||||
|
@@ -5,11 +5,11 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: view.c,v 1.28 1998/12/14 06:50:18 scrappy Exp $
|
||||
* $Id: view.c,v 1.29 1998/12/14 08:11:01 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h> /* for sprintf() */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <postgres.h>
|
||||
|
Reference in New Issue
Block a user