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:
parent
df1468e251
commit
9396802f14
@ -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>
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: execAmi.c,v 1.27 1998/12/14 06:50:20 scrappy Exp $
|
||||
* $Id: execAmi.c,v 1.28 1998/12/14 08:11:02 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,7 +24,7 @@
|
||||
* ExecCreatR function to create temporary relations
|
||||
*
|
||||
*/
|
||||
#include <stdio.h> /* for sprintf() */
|
||||
#include <stdio.h>
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* $Id: nodeHash.c,v 1.26 1998/12/14 06:50:21 scrappy Exp $
|
||||
* $Id: nodeHash.c,v 1.27 1998/12/14 08:11:02 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h> /* for sprintf() */
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <sys/file.h>
|
||||
|
@ -1,5 +1,4 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
/*
|
||||
* stringinfo.c--
|
||||
* These are routines that can be used to write informations to a string,
|
||||
* without having to worry about string lengths, space allocation etc.
|
||||
@ -7,25 +6,24 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/lib/stringinfo.c,v 1.12 1998/11/08 19:22:24 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
* $Id: stringinfo.c,v 1.13 1998/12/14 08:11:04 scrappy Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <postgres.h>
|
||||
|
||||
#include <nodes/pg_list.h>
|
||||
#include <lib/stringinfo.h>
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
/*
|
||||
* makeStringInfo
|
||||
*
|
||||
* Create a StringInfoData & return a pointer to it.
|
||||
*
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
StringInfo
|
||||
makeStringInfo()
|
||||
@ -52,7 +50,7 @@ makeStringInfo()
|
||||
return res;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
/*
|
||||
* appendStringInfo
|
||||
*
|
||||
* append to the current 'StringInfo' a new string.
|
||||
@ -60,26 +58,31 @@ makeStringInfo()
|
||||
* some more...
|
||||
*
|
||||
* NOTE: if we reallocate space, we pfree the old one!
|
||||
*---------------------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
void
|
||||
appendStringInfo(StringInfo str, char *buffer)
|
||||
appendStringInfo(StringInfo str, const char *fmt,...)
|
||||
{
|
||||
int buflen,
|
||||
int buflen,
|
||||
newlen,
|
||||
needed;
|
||||
char *s;
|
||||
char *s,
|
||||
buffer[512];
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
buflen = vsnprintf(buffer, 512, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
Assert(str != NULL);
|
||||
if (buffer == NULL)
|
||||
buffer = "<>";
|
||||
if (buflen == 0)
|
||||
strcpy(buffer, "<>");
|
||||
|
||||
/*
|
||||
* do we have enough space to append the new string? (don't forget to
|
||||
* count the null string terminating char!) If no, then reallocate
|
||||
* some more.
|
||||
*/
|
||||
buflen = strlen(buffer);
|
||||
needed = str->len + buflen + 1;
|
||||
if (needed > str->maxlen)
|
||||
{
|
||||
@ -99,8 +102,7 @@ appendStringInfo(StringInfo str, char *buffer)
|
||||
if (s == NULL)
|
||||
{
|
||||
elog(ERROR,
|
||||
"appendStringInfo: Out of memory (%d bytes requested)",
|
||||
newlen);
|
||||
"appendStringInfo: Out of memory (%d bytes requested)", newlen);
|
||||
}
|
||||
/*
|
||||
* transfer the data. strcpy() would work, but is probably a tad
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: portal.c,v 1.18 1998/12/14 06:50:26 scrappy Exp $
|
||||
* $Id: portal.c,v 1.19 1998/12/14 08:11:06 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -53,7 +53,7 @@
|
||||
* see utils/mmgr/portalmem.c for why. -cim 2/22/91
|
||||
*
|
||||
*/
|
||||
#include <stdio.h> /* for sprintf() */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <postgres.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: util.c,v 1.6 1998/12/14 06:50:27 scrappy Exp $
|
||||
* $Id: util.c,v 1.7 1998/12/14 08:11:07 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
* PQuntrace - turn off pqdebug() tracing
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* for sprintf() */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <postgres.h>
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
/*
|
||||
*
|
||||
* outfuncs.c--
|
||||
* routines to convert a node to ascii representation
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: outfuncs.c,v 1.51 1998/12/14 06:50:28 scrappy Exp $
|
||||
* $Id: outfuncs.c,v 1.52 1998/12/14 08:11:09 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||
@ -18,7 +18,6 @@
|
||||
* passed to them. This argument contains the string holding the ASCII
|
||||
* representation plus some other information (string length, etc.)
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "postgres.h"
|
||||
@ -57,14 +56,12 @@ static void _outNode(StringInfo str, void *obj);
|
||||
static void
|
||||
_outIntList(StringInfo str, List *list)
|
||||
{
|
||||
List *l;
|
||||
char buf[500];
|
||||
List *l;
|
||||
|
||||
appendStringInfo(str, "(");
|
||||
foreach(l, list)
|
||||
{
|
||||
sprintf(buf, " %d ", (int) lfirst(l));
|
||||
appendStringInfo(str, buf);
|
||||
appendStringInfo(str, " %d ", (int) lfirst(l));
|
||||
}
|
||||
appendStringInfo(str, ")");
|
||||
}
|
||||
@ -72,11 +69,8 @@ _outIntList(StringInfo str, List *list)
|
||||
static void
|
||||
_outCreateStmt(StringInfo str, CreateStmt *node)
|
||||
{
|
||||
appendStringInfo(str, " CREATE ");
|
||||
appendStringInfo(str, " CREATE :relname %s :columns ", node->relname);
|
||||
|
||||
appendStringInfo(str, " :relname ");
|
||||
appendStringInfo(str, node->relname);
|
||||
appendStringInfo(str, " :columns ");
|
||||
_outNode(str, node->tableElts);
|
||||
appendStringInfo(str, " :inhRelnames ");
|
||||
_outNode(str, node->inhRelnames);
|
||||
@ -87,15 +81,10 @@ _outCreateStmt(StringInfo str, CreateStmt *node)
|
||||
static void
|
||||
_outIndexStmt(StringInfo str, IndexStmt *node)
|
||||
{
|
||||
appendStringInfo(str, " INDEX ");
|
||||
appendStringInfo(str,
|
||||
" INDEX :idxname %s :relname %s :accessMethod %s :indexParams ",
|
||||
node->idxname, node->relname, node->accessMethod);
|
||||
|
||||
appendStringInfo(str, " :idxname ");
|
||||
appendStringInfo(str, node->idxname);
|
||||
appendStringInfo(str, " :relname ");
|
||||
appendStringInfo(str, node->relname);
|
||||
appendStringInfo(str, " :accessMethod ");
|
||||
appendStringInfo(str, node->accessMethod);
|
||||
appendStringInfo(str, " :indexParams ");
|
||||
_outNode(str, node->indexParams);
|
||||
appendStringInfo(str, " :withClause ");
|
||||
_outNode(str, node->withClause);
|
||||
@ -103,28 +92,24 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
|
||||
_outNode(str, node->whereClause);
|
||||
appendStringInfo(str, " :rangetable ");
|
||||
_outNode(str, node->rangetable);
|
||||
appendStringInfo(str, " :lossy ");
|
||||
appendStringInfo(str, (node->lossy ? "true" : "false"));
|
||||
appendStringInfo(str, " :unique ");
|
||||
appendStringInfo(str, (node->unique ? "true" : "false"));
|
||||
|
||||
appendStringInfo(str, " :lossy %s :unique %s ",
|
||||
node->lossy ? "true" : "false",
|
||||
node->unique ? "true" : "false");
|
||||
}
|
||||
|
||||
#ifdef PARSEDEBUG
|
||||
static void
|
||||
_outSelectStmt(StringInfo str, SelectStmt *node)
|
||||
{
|
||||
appendStringInfo(str, "SELECT");
|
||||
|
||||
appendStringInfo(str, " :where ");
|
||||
appendStringInfo(str, "SELECT :where ");
|
||||
_outNode(str, node->whereClause);
|
||||
}
|
||||
|
||||
static void
|
||||
_outFuncCall(StringInfo str, FuncCall *node)
|
||||
{
|
||||
appendStringInfo(str, "FUNCTION ");
|
||||
appendStringInfo(str, node->funcname);
|
||||
appendStringInfo(str, " :args ");
|
||||
appendStringInfo(str, "FUNCTION %s :args ", node->funcname);
|
||||
_outNode(str, node->args);
|
||||
}
|
||||
|
||||
@ -133,24 +118,18 @@ _outFuncCall(StringInfo str, FuncCall *node)
|
||||
static void
|
||||
_outColumnDef(StringInfo str, ColumnDef *node)
|
||||
{
|
||||
appendStringInfo(str, " COLUMNDEF ");
|
||||
|
||||
appendStringInfo(str, " :colname ");
|
||||
appendStringInfo(str, node->colname);
|
||||
appendStringInfo(str, " :typename ");
|
||||
appendStringInfo(str, " COLUMNDEF :colname %s :typename ", node->colname);
|
||||
_outNode(str, node->typename);
|
||||
appendStringInfo(str, " :is_not_null ");
|
||||
appendStringInfo(str, (node->is_not_null ? "true" : "false"));
|
||||
appendStringInfo(str, " :defval ");
|
||||
appendStringInfo(str, node->defval);
|
||||
appendStringInfo(str, " :constraints ");
|
||||
|
||||
appendStringInfo(str, " :is_not_null %s :defval %s :constraints ",
|
||||
node->is_not_null ? "true" : "false", node->defval);
|
||||
_outNode(str, node->constraints);
|
||||
}
|
||||
|
||||
static void
|
||||
_outTypeName(StringInfo str, TypeName *node)
|
||||
{
|
||||
char buf[500];
|
||||
char buf[500];
|
||||
|
||||
appendStringInfo(str, " TYPENAME ");
|
||||
|
||||
@ -161,7 +140,7 @@ _outTypeName(StringInfo str, TypeName *node)
|
||||
appendStringInfo(str, " :setof ");
|
||||
appendStringInfo(str, (node->setof ? "true" : "false"));
|
||||
appendStringInfo(str, " :typmod ");
|
||||
sprintf(buf, " %d ", node->typmod);
|
||||
snprintf(buf, 500, " %d ", node->typmod);
|
||||
appendStringInfo(str, buf);
|
||||
appendStringInfo(str, " :arrayBounds ");
|
||||
_outNode(str, node->arrayBounds);
|
||||
@ -185,12 +164,12 @@ _outIndexElem(StringInfo str, IndexElem *node)
|
||||
static void
|
||||
_outQuery(StringInfo str, Query *node)
|
||||
{
|
||||
char buf[500];
|
||||
char buf[500];
|
||||
|
||||
appendStringInfo(str, " QUERY ");
|
||||
|
||||
appendStringInfo(str, " :command ");
|
||||
sprintf(buf, " %d ", node->commandType);
|
||||
snprintf(buf, 500, " %d ", node->commandType);
|
||||
appendStringInfo(str, buf);
|
||||
|
||||
if (node->utilityStmt)
|
||||
@ -227,7 +206,7 @@ _outQuery(StringInfo str, Query *node)
|
||||
}
|
||||
|
||||
appendStringInfo(str, " :resultRelation ");
|
||||
sprintf(buf, " %d ", node->resultRelation);
|
||||
snprintf(buf, 500, " %d ", node->resultRelation);
|
||||
appendStringInfo(str, buf);
|
||||
appendStringInfo(str, " :into ");
|
||||
appendStringInfo(str, node->into);
|
||||
@ -266,28 +245,28 @@ _outQuery(StringInfo str, Query *node)
|
||||
static void
|
||||
_outSortClause(StringInfo str, SortClause *node)
|
||||
{
|
||||
char buf[500];
|
||||
char buf[500];
|
||||
|
||||
appendStringInfo(str, " SORTCLAUSE ");
|
||||
|
||||
appendStringInfo(str, " :resdom ");
|
||||
_outNode(str, node->resdom);
|
||||
appendStringInfo(str, " :opoid ");
|
||||
sprintf(buf, " %u ", node->opoid);
|
||||
snprintf(buf, 500, " %u ", node->opoid);
|
||||
appendStringInfo(str, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
_outGroupClause(StringInfo str, GroupClause *node)
|
||||
{
|
||||
char buf[500];
|
||||
char buf[500];
|
||||
|
||||
appendStringInfo(str, " GROUPCLAUSE ");
|
||||
|
||||
appendStringInfo(str, " :entry ");
|
||||
_outNode(str, node->entry);
|
||||
appendStringInfo(str, " :grpOpoid ");
|
||||
sprintf(buf, " %u ", node->grpOpoid);
|
||||
snprintf(buf, 500, " %u ", node->grpOpoid);
|
||||
appendStringInfo(str, buf);
|
||||
}
|
||||
|
||||
@ -297,13 +276,13 @@ _outGroupClause(StringInfo str, GroupClause *node)
|
||||
static void
|
||||
_outPlanInfo(StringInfo str, Plan *node)
|
||||
{
|
||||
char buf[500];
|
||||
char buf[500];
|
||||
|
||||
sprintf(buf, " :cost %g ", node->cost);
|
||||
snprintf(buf, 500, " :cost %g ", node->cost);
|
||||
appendStringInfo(str, buf);
|
||||
sprintf(buf, " :size %d ", node->plan_size);
|
||||
snprintf(buf, 500, " :size %d ", node->plan_size);
|
||||
appendStringInfo(str, buf);
|
||||
sprintf(buf, " :width %d ", node->plan_width);
|
||||
snprintf(buf, 500, " :width %d ", node->plan_width);
|
||||
appendStringInfo(str, buf);
|
||||
appendStringInfo(str, " :state ");
|
||||
appendStringInfo(str, node->state ? "not-NULL" : "<>");
|
||||
@ -321,7 +300,7 @@ _outPlanInfo(StringInfo str, Plan *node)
|
||||
_outIntList(str, node->locParam);
|
||||
appendStringInfo(str, " :initplan ");
|
||||
_outNode(str, node->initPlan);
|
||||
sprintf(buf, " :nprm %d ", node->nParamExec);
|
||||
snprintf(buf, 500, " :nprm %d ", node->nParamExec);
|
||||
appendStringInfo(str, buf);
|
||||
}
|
||||
|
||||
@ -363,7 +342,7 @@ _outAppend(StringInfo str, Append *node)
|
||||
appendStringInfo(str, " :unionrtables ");
|
||||
_outNode(str, node->unionrtables);
|
||||
|
||||
sprintf(buf, " :inheritrelid %d ", node->inheritrelid);
|
||||
snprintf(buf, 500, " :inheritrelid %d ", node->inheritrelid);
|
||||
appendStringInfo(str, buf);
|
||||
|
||||
appendStringInfo(str, " :inheritrtable ");
|
||||
@ -406,13 +385,13 @@ _outMergeJoin(StringInfo str, MergeJoin *node)
|
||||
appendStringInfo(str, " :mergeclauses ");
|
||||
_outNode(str, node->mergeclauses);
|
||||
|
||||
sprintf(buf, " :mergejoinop %u ", node->mergejoinop);
|
||||
snprintf(buf, 500, " :mergejoinop %u ", node->mergejoinop);
|
||||
appendStringInfo(str, buf);
|
||||
|
||||
sprintf(buf, " :mergerightorder %u ", node->mergerightorder[0]);
|
||||
snprintf(buf, 500, " :mergerightorder %u ", node->mergerightorder[0]);
|
||||
appendStringInfo(str, buf);
|
||||
|
||||
sprintf(buf, " :mergeleftorder %u ", node->mergeleftorder[0]);
|
||||
snprintf(buf, 500, " :mergeleftorder %u ", node->mergeleftorder[0]);
|
||||
appendStringInfo(str, buf);
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,11 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
/*
|
||||
* nabstime.c--
|
||||
* parse almost any absolute date getdate(3) can (& some it can't)
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: nabstime.c,v 1.48 1998/12/14 08:11:12 scrappy Exp $
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.47 1998/12/13 23:34:17 thomas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
@ -1,13 +1,10 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
/*
|
||||
* psort.c--
|
||||
* Polyphase merge sort.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.44 1998/12/14 05:19:13 scrappy Exp $
|
||||
* $Id: psort.c,v 1.45 1998/12/14 08:11:14 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Sorts the first relation into the second relation.
|
||||
@ -31,7 +28,7 @@
|
||||
*
|
||||
* Arguments? Variables?
|
||||
* MAXMERGE, MAXTAPES
|
||||
*-------------------------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
@ -323,26 +320,34 @@ initialrun(Sort *node)
|
||||
tp->tp_dummy--;
|
||||
PS(node)->TotalDummy--;
|
||||
if (tp->tp_dummy < (tp + 1)->tp_dummy)
|
||||
tp++;
|
||||
else if (tp->tp_dummy != 0)
|
||||
tp = PS(node)->Tape;
|
||||
else
|
||||
{
|
||||
PS(node)->Level++;
|
||||
baseruns = PS(node)->Tape[0].tp_fib;
|
||||
for (tp = PS(node)->Tape;
|
||||
tp - PS(node)->Tape < PS(node)->TapeRange; tp++)
|
||||
tp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tp->tp_dummy != 0)
|
||||
{
|
||||
PS(node)->TotalDummy +=
|
||||
(tp->tp_dummy = baseruns
|
||||
+ (tp + 1)->tp_fib
|
||||
- tp->tp_fib);
|
||||
tp->tp_fib = baseruns
|
||||
+ (tp + 1)->tp_fib;
|
||||
tp = PS(node)->Tape;
|
||||
}
|
||||
tp = PS(node)->Tape;/* D4 */
|
||||
} /* D3 */
|
||||
else
|
||||
{
|
||||
PS(node)->Level++;
|
||||
baseruns = PS(node)->Tape[0].tp_fib;
|
||||
for (tp = PS(node)->Tape;
|
||||
tp - PS(node)->Tape < PS(node)->TapeRange; tp++)
|
||||
{
|
||||
PS(node)->TotalDummy +=
|
||||
(tp->tp_dummy = baseruns
|
||||
+ (tp + 1)->tp_fib
|
||||
- tp->tp_fib);
|
||||
tp->tp_fib = baseruns
|
||||
+ (tp + 1)->tp_fib;
|
||||
}
|
||||
tp = PS(node)->Tape;/* D4 */
|
||||
} /* D3 */
|
||||
}
|
||||
if (extrapasses)
|
||||
{
|
||||
if (--extrapasses)
|
||||
{
|
||||
dumptuples(tp->tp_file, node);
|
||||
@ -353,7 +358,7 @@ initialrun(Sort *node)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if ((bool) createrun(node, tp->tp_file) == false)
|
||||
extrapasses = 1 + (PS(node)->Tuples != NULL);
|
||||
/* D2 */
|
||||
@ -550,7 +555,9 @@ createrun(Sort *node, FILE *file)
|
||||
memtuples[t_last] = tup;
|
||||
}
|
||||
else
|
||||
{
|
||||
puttuple(&PS(node)->Tuples, tup, 0, &PS(node)->treeContext);
|
||||
}
|
||||
}
|
||||
if (lasttuple != NULL)
|
||||
{
|
||||
@ -639,9 +646,10 @@ merge(Sort *node, struct tape * dest)
|
||||
tp->tp_fib += times;
|
||||
/* Tape[].tp_fib (A[]) is set to proper exit values */
|
||||
|
||||
if (PS(node)->TotalDummy < PS(node)->TapeRange) /* no complete dummy
|
||||
* runs */
|
||||
if (PS(node)->TotalDummy < PS(node)->TapeRange) /* no complete dummy runs */
|
||||
{
|
||||
outdummy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
outdummy = PS(node)->TotalDummy; /* a large positive number */
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: stringinfo.h,v 1.7 1998/09/01 04:36:21 momjian Exp $
|
||||
* $Id: stringinfo.h,v 1.8 1998/12/14 08:11:17 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -42,6 +42,6 @@ extern StringInfo makeStringInfo(void);
|
||||
* appendStringInfo
|
||||
* similar to 'strcat' but reallocates more space if necessary...
|
||||
*/
|
||||
extern void appendStringInfo(StringInfo str, char *buffer);
|
||||
extern void appendStringInfo(StringInfo str, const char *fmt,...);
|
||||
|
||||
#endif /* STRINGINFO_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user