1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +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/executor/execAmi.c,v 1.25 1998/09/01 04:28:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.26 1998/12/14 05:18:49 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -518,10 +518,6 @@ ExecCreatR(TupleDesc tupType,
* from the range table.. -cim 10/12/89)
* ----------------
*/
/*
sprintf(tempname, "temp_%d.%d", getpid(), tmpcnt++);
EU1_printf("ExecCreatR: attempting to create %s\n", tempname);
*/
/*
* heap_create creates a name if the argument to heap_create is

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.24 1998/11/27 19:52:02 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.25 1998/12/14 05:18:50 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -341,7 +341,8 @@ ExecHashTableCreate(Hash *node)
if (nbatch == 0)
nbuckets = totalbuckets;
#ifdef HJDEBUG
printf("nbatch = %d, totalbuckets = %d, nbuckets = %d\n", nbatch, totalbuckets, nbuckets);
printf("nbatch = %d, totalbuckets = %d, nbuckets = %d\n",
nbatch, totalbuckets, nbuckets);
#endif
/* ----------------
@ -617,32 +618,14 @@ ExecHashOverflowInsert(HashJoinTable hashtable,
+ heapTuple->t_len + HEAPTUPLESIZE);
if (newend > hashtable->bottom)
{
#if 0
elog(DEBUG, "hash table out of memory. expanding.");
/* ------------------
* XXX this is a temporary hack
* eventually, recursive hash partitioning will be
* implemented
* ------------------
*/
hashtable->readbuf = hashtable->bottom = 2 * hashtable->bottom;
hashtable =
(HashJoinTable) repalloc(hashtable, hashtable->bottom + BLCKSZ);
if (hashtable == NULL)
{
perror("repalloc");
elog(ERROR, "can't expand hashtable.");
}
#else
/* ------------------
* XXX the temporary hack above doesn't work because things
* above us don't know that we've moved the hash table!
* - Chris Dunlop, <chris@onthe.net.au>
* ------------------
*/
elog(ERROR, "hash table out of memory. Use -B parameter to increase buffers.");
#endif
elog(ERROR,
"hash table out of memory. Use -B parameter to increase buffers.");
}
/* ----------------
@ -897,7 +880,7 @@ static int hjtmpcnt = 0;
static void
mk_hj_temp(char *tempname)
{
sprintf(tempname, "HJ%d.%d", (int) MyProcPid, hjtmpcnt);
snprintf(tempname, strlen(tempname), "HJ%d.%d", (int) MyProcPid, hjtmpcnt);
hjtmpcnt = (hjtmpcnt + 1) % 1000;
}

View File

@ -15,7 +15,7 @@
* ExecEndTee
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.25 1998/11/27 19:52:03 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.26 1998/12/14 05:18:51 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -47,12 +47,12 @@
bool
ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
{
TeeState *teeState;
Plan *outerPlan;
int len;
TeeState *teeState;
Plan *outerPlan;
int len;
Relation bufferRel;
TupleDesc tupType;
EState *estate;
EState *estate;
/*
* it is possible that the Tee has already been initialized since it
@ -144,8 +144,6 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
tupType = ExecGetResultType(&(teeState->cstate));
len = ExecTargetListLength(((Plan *) node)->targetlist);
/* bufferRel = ExecCreatR(len, tupType, _TEMP_RELATION_ID_); */
/*
* create a catalogued relation even though this is a temporary
* relation
@ -176,7 +174,6 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
sprintf(teeState->tee_bufferRelname,
"ttemp_%d", /* 'ttemp' for 'tee' temporary */
newoid());
/* bufferRel = ExecCreatR(len, tupType, _TEMP_RELATION_ID); */
bufferRel = heap_open(
heap_create_with_catalog(teeState->tee_bufferRelname,
tupType, RELKIND_RELATION));
@ -429,52 +426,6 @@ ExecTee(Tee *node, Plan *parent)
return result;
}
#ifdef NOT_USED
/* ----------------------------------------------------------------
* ExecTeeReScan(node)
*
* Rescans the relation.
* ----------------------------------------------------------------
*/
void
ExecTeeReScan(Tee *node, ExprContext *exprCtxt, Plan *parent)
{
EState *estate;
TeeState *teeState;
ScanDirection dir;
estate = ((Plan *) node)->state;
teeState = node->teestate;
dir = estate->es_direction;
/* XXX doesn't handle backwards direction yet */
if (parent == node->leftParent)
{
if (teeState->tee_leftScanDesc)
{
heap_rescan(teeState->tee_leftScanDesc,
ScanDirectionIsBackward(dir),
NULL);
teeState->tee_leftPlace = 0;
}
}
else
{
if (teeState->tee_rightScanDesc)
{
heap_rescan(teeState->tee_leftScanDesc,
ScanDirectionIsBackward(dir),
NULL);
teeState->tee_rightPlace = 0;
}
}
}
#endif
/* ---------------------------------------------------------------------
* ExecEndTee
*

View File

@ -3,6 +3,8 @@
* spi.c--
* Server Programming Interface
*
* $Id: spi.c,v 1.29 1998/12/14 05:18:51 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#include "executor/spi.h"
@ -43,10 +45,6 @@ typedef struct
static int _SPI_execute(char *src, int tcount, _SPI_plan *plan);
static int _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount);
#if 0
static void _SPI_fetch(FetchStmt *stmt);
#endif
static int _SPI_execute_plan(_SPI_plan *plan,
Datum *Values, char *Nulls, int tcount);
@ -74,8 +72,8 @@ extern void ShowUsage(void);
int
SPI_connect()
{
char pname[64];
PortalVariableMemory pvmem;
char pname[64];
PortalVariableMemory pvmem;
/*
* It's possible on startup and after commit/abort. In future we'll
@ -128,7 +126,7 @@ SPI_connect()
_SPI_current->tuptable = NULL;
/* Create Portal for this procedure ... */
sprintf(pname, "<SPI %d>", _SPI_connected);
snprintf(pname, 64, "<SPI %d>", _SPI_connected);
_SPI_current->portal = CreatePortal(pname);
if (!PortalIsValid(_SPI_current->portal))
elog(FATAL, "SPI_connect: initialization failed");
@ -876,46 +874,6 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount)
}
#if 0
static void
_SPI_fetch(FetchStmt *stmt)
{
char *name = stmt->portalname;
int feature = (stmt->direction == FORWARD) ? EXEC_FOR : EXEC_BACK;
int count = stmt->howMany;
Portal portal;
QueryDesc *queryDesc;
EState *state;
MemoryContext context;
if (name == NULL)
elog(FATAL, "SPI_fetch from blank portal unsupported");
portal = GetPortalByName(name);
if (!PortalIsValid(portal))
elog(FATAL, "SPI_fetch: portal \"%s\" not found", name);
context = MemoryContextSwitchTo((MemoryContext) PortalGetHeapMemory(portal));
queryDesc = PortalGetQueryDesc(portal);
state = PortalGetState(portal);
ExecutorRun(queryDesc, state, feature, count);
MemoryContextSwitchTo(context); /* switch to the normal Executor
* context */
_SPI_current->processed = state->es_processed;
if (_SPI_checktuples())
elog(FATAL, "SPI_fetch: # of processed tuples check failed");
SPI_processed = _SPI_current->processed;
SPI_tuptable = _SPI_current->tuptable;
}
#endif
static MemoryContext
_SPI_execmem()
{