mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
pgindent run over code.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.2 1999/03/16 04:25:46 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.3 1999/05/25 16:08:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -121,18 +121,18 @@ static QueryTreeList *tg_parseTeeNode(TgRecipe * r,
|
||||
void
|
||||
beginRecipe(RecipeStmt *stmt)
|
||||
{
|
||||
TgRecipe *r;
|
||||
int i,
|
||||
numTees;
|
||||
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;
|
||||
|
||||
TeeInfo *teeInfo;
|
||||
TeeInfo *teeInfo;
|
||||
|
||||
/*
|
||||
* retrieveRecipe() reads the recipe from the database and returns a
|
||||
@@ -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 */
|
||||
relid;
|
||||
int i,
|
||||
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;
|
||||
TgNode *child;
|
||||
Relation rel;
|
||||
unsigned int len;
|
||||
TupleDesc tupdesc;
|
||||
TgNode *child;
|
||||
Relation rel;
|
||||
unsigned int len;
|
||||
TupleDesc tupdesc;
|
||||
|
||||
qList = NULL;
|
||||
|
||||
|
@@ -5,17 +5,17 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* The version stuff has not been tested under postgres95 and probably
|
||||
* The version stuff has not been tested under postgres95 and probably
|
||||
* doesn't work! - jolly 8/19/95
|
||||
*
|
||||
*
|
||||
* $Id: version.c,v 1.18 1999/02/13 23:15:12 momjian Exp $
|
||||
* $Id: version.c,v 1.19 1999/05/25 16:08:32 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* At the point the version is defined, 2 physical relations are created
|
||||
* <vname>_added and <vname>_deleted.
|
||||
*
|
||||
* In addition, 4 rules are defined which govern the semantics of
|
||||
* In addition, 4 rules are defined which govern the semantics of
|
||||
* versions w.r.t retrieves, appends, replaces and deletes.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.46 1999/04/25 19:27:43 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.47 1999/05/25 16:08:15 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -31,17 +31,17 @@
|
||||
* relname to a list of outstanding NOTIFY requests. Actual processing
|
||||
* happens if and only if we reach transaction commit. At that time (in
|
||||
* routine AtCommit_Notify) we scan pg_listener for matching relnames.
|
||||
* If the listenerPID in a matching tuple is ours, we just send a notify
|
||||
* If the listenerPID in a matching tuple is ours, we just send a notify
|
||||
* message to our own front end. If it is not ours, and "notification"
|
||||
* is not already nonzero, we set notification to our own PID and send a
|
||||
* SIGUSR2 signal to the receiving process (indicated by listenerPID).
|
||||
* BTW: if the signal operation fails, we presume that the listener backend
|
||||
* crashed without removing this tuple, and remove the tuple for it.
|
||||
* crashed without removing this tuple, and remove the tuple for it.
|
||||
*
|
||||
* 4. Upon receipt of a SIGUSR2 signal, the signal handler can call inbound-
|
||||
* notify processing immediately if this backend is idle (ie, it is
|
||||
* waiting for a frontend command and is not within a transaction block).
|
||||
* Otherwise the handler may only set a flag, which will cause the
|
||||
* Otherwise the handler may only set a flag, which will cause the
|
||||
* processing to occur just before we next go idle.
|
||||
*
|
||||
* 5. Inbound-notify processing consists of scanning pg_listener for tuples
|
||||
@@ -53,7 +53,7 @@
|
||||
*
|
||||
* Note that the system's use of pg_listener is confined to very short
|
||||
* intervals at the end of a transaction that contains NOTIFY statements,
|
||||
* or during the transaction caused by an inbound SIGUSR2. So the fact that
|
||||
* or during the transaction caused by an inbound SIGUSR2. So the fact that
|
||||
* pg_listener is a global resource shouldn't cause too much performance
|
||||
* problem. But application authors ought to be discouraged from doing
|
||||
* LISTEN or UNLISTEN near the start of a long transaction --- that would
|
||||
@@ -109,8 +109,8 @@ extern CommandDest whereToSendOutput;
|
||||
|
||||
/*
|
||||
* State for outbound notifies consists of a list of all relnames NOTIFYed
|
||||
* in the current transaction. We do not actually perform a NOTIFY until
|
||||
* and unless the transaction commits. pendingNotifies is NULL if no
|
||||
* in the current transaction. We do not actually perform a NOTIFY until
|
||||
* and unless the transaction commits. pendingNotifies is NULL if no
|
||||
* NOTIFYs have been done in the current transaction.
|
||||
*/
|
||||
static Dllist *pendingNotifies = NULL;
|
||||
@@ -125,8 +125,8 @@ static Dllist *pendingNotifies = NULL;
|
||||
* does not grok "volatile", you'd be best advised to compile this file
|
||||
* with all optimization turned off.
|
||||
*/
|
||||
static volatile int notifyInterruptEnabled = 0;
|
||||
static volatile int notifyInterruptOccurred = 0;
|
||||
static volatile int notifyInterruptEnabled = 0;
|
||||
static volatile int notifyInterruptOccurred = 0;
|
||||
|
||||
/* True if we've registered an on_shmem_exit cleanup (or at least tried to). */
|
||||
static int unlistenExitRegistered = 0;
|
||||
@@ -142,7 +142,7 @@ static void ClearPendingNotifies(void);
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* Async_Notify
|
||||
* Async_Notify
|
||||
*
|
||||
* This is executed by the SQL notify command.
|
||||
*
|
||||
@@ -164,28 +164,29 @@ Async_Notify(char *relname)
|
||||
|
||||
/*
|
||||
* We allocate list memory from the global malloc pool to ensure that
|
||||
* it will live until we want to use it. This is probably not necessary
|
||||
* any longer, since we will use it before the end of the transaction.
|
||||
* DLList only knows how to use malloc() anyway, but we could probably
|
||||
* palloc() the strings...
|
||||
* it will live until we want to use it. This is probably not
|
||||
* necessary any longer, since we will use it before the end of the
|
||||
* transaction. DLList only knows how to use malloc() anyway, but we
|
||||
* could probably palloc() the strings...
|
||||
*/
|
||||
if (!pendingNotifies)
|
||||
pendingNotifies = DLNewList();
|
||||
notifyName = strdup(relname);
|
||||
DLAddHead(pendingNotifies, DLNewElem(notifyName));
|
||||
|
||||
/*
|
||||
* NOTE: we could check to see if pendingNotifies already has an entry
|
||||
* for relname, and thus avoid making duplicate entries. However, most
|
||||
* apps probably don't notify the same name multiple times per transaction,
|
||||
* so we'd likely just be wasting cycles to make such a check.
|
||||
* AsyncExistsPendingNotify() doesn't really care whether the list
|
||||
* contains duplicates...
|
||||
* for relname, and thus avoid making duplicate entries. However,
|
||||
* most apps probably don't notify the same name multiple times per
|
||||
* transaction, so we'd likely just be wasting cycles to make such a
|
||||
* check. AsyncExistsPendingNotify() doesn't really care whether the
|
||||
* list contains duplicates...
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* Async_Listen
|
||||
* Async_Listen
|
||||
*
|
||||
* This is executed by the SQL listen command.
|
||||
*
|
||||
@@ -274,7 +275,7 @@ Async_Listen(char *relname, int pid)
|
||||
/*
|
||||
* now that we are listening, make sure we will unlisten before dying.
|
||||
*/
|
||||
if (! unlistenExitRegistered)
|
||||
if (!unlistenExitRegistered)
|
||||
{
|
||||
if (on_shmem_exit(Async_UnlistenOnExit, (caddr_t) NULL) < 0)
|
||||
elog(NOTICE, "Async_Listen: out of shmem_exit slots");
|
||||
@@ -284,7 +285,7 @@ Async_Listen(char *relname, int pid)
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* Async_Unlisten
|
||||
* Async_Unlisten
|
||||
*
|
||||
* This is executed by the SQL unlisten command.
|
||||
*
|
||||
@@ -326,14 +327,16 @@ Async_Unlisten(char *relname, int pid)
|
||||
UnlockRelation(lRel, AccessExclusiveLock);
|
||||
heap_close(lRel);
|
||||
}
|
||||
/* We do not complain about unlistening something not being listened;
|
||||
|
||||
/*
|
||||
* We do not complain about unlistening something not being listened;
|
||||
* should we?
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* Async_UnlistenAll
|
||||
* Async_UnlistenAll
|
||||
*
|
||||
* Unlisten all relations for this backend.
|
||||
*
|
||||
@@ -379,7 +382,7 @@ Async_UnlistenAll()
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* Async_UnlistenOnExit
|
||||
* Async_UnlistenOnExit
|
||||
*
|
||||
* Clean up the pg_listener table at backend exit.
|
||||
*
|
||||
@@ -398,11 +401,12 @@ Async_UnlistenAll()
|
||||
static void
|
||||
Async_UnlistenOnExit()
|
||||
{
|
||||
|
||||
/*
|
||||
* We need to start/commit a transaction for the unlisten,
|
||||
* but if there is already an active transaction we had better
|
||||
* abort that one first. Otherwise we'd end up committing changes
|
||||
* that probably ought to be discarded.
|
||||
* We need to start/commit a transaction for the unlisten, but if
|
||||
* there is already an active transaction we had better abort that one
|
||||
* first. Otherwise we'd end up committing changes that probably
|
||||
* ought to be discarded.
|
||||
*/
|
||||
AbortOutOfAnyTransaction();
|
||||
/* Now we can do the unlisten */
|
||||
@@ -413,7 +417,7 @@ Async_UnlistenOnExit()
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* AtCommit_Notify
|
||||
* AtCommit_Notify
|
||||
*
|
||||
* This is called at transaction commit.
|
||||
*
|
||||
@@ -450,12 +454,14 @@ AtCommit_Notify()
|
||||
int32 listenerPID;
|
||||
|
||||
if (!pendingNotifies)
|
||||
return; /* no NOTIFY statements in this transaction */
|
||||
return; /* no NOTIFY statements in this
|
||||
* transaction */
|
||||
|
||||
/* NOTIFY is disabled if not normal processing mode.
|
||||
* This test used to be in xact.c, but it seems cleaner to do it here.
|
||||
/*
|
||||
* NOTIFY is disabled if not normal processing mode. This test used to
|
||||
* be in xact.c, but it seems cleaner to do it here.
|
||||
*/
|
||||
if (! IsNormalProcessingMode())
|
||||
if (!IsNormalProcessingMode())
|
||||
{
|
||||
ClearPendingNotifies();
|
||||
return;
|
||||
@@ -487,10 +493,13 @@ AtCommit_Notify()
|
||||
|
||||
if (listenerPID == MyProcPid)
|
||||
{
|
||||
/* Self-notify: no need to bother with table update.
|
||||
|
||||
/*
|
||||
* Self-notify: no need to bother with table update.
|
||||
* Indeed, we *must not* clear the notification field in
|
||||
* this path, or we could lose an outside notify, which'd be
|
||||
* bad for applications that ignore self-notify messages.
|
||||
* this path, or we could lose an outside notify, which'd
|
||||
* be bad for applications that ignore self-notify
|
||||
* messages.
|
||||
*/
|
||||
TPRINTF(TRACE_NOTIFY, "AtCommit_Notify: notifying self");
|
||||
NotifyMyFrontEnd(relname, listenerPID);
|
||||
@@ -499,23 +508,27 @@ AtCommit_Notify()
|
||||
{
|
||||
TPRINTF(TRACE_NOTIFY, "AtCommit_Notify: notifying pid %d",
|
||||
listenerPID);
|
||||
|
||||
/*
|
||||
* If someone has already notified this listener,
|
||||
* we don't bother modifying the table, but we do still send
|
||||
* a SIGUSR2 signal, just in case that backend missed the
|
||||
* earlier signal for some reason. It's OK to send the signal
|
||||
* first, because the other guy can't read pg_listener until
|
||||
* we unlock it.
|
||||
* If someone has already notified this listener, we don't
|
||||
* bother modifying the table, but we do still send a
|
||||
* SIGUSR2 signal, just in case that backend missed the
|
||||
* earlier signal for some reason. It's OK to send the
|
||||
* signal first, because the other guy can't read
|
||||
* pg_listener until we unlock it.
|
||||
*/
|
||||
#ifdef HAVE_KILL
|
||||
if (kill(listenerPID, SIGUSR2) < 0)
|
||||
{
|
||||
/* Get rid of pg_listener entry if it refers to a PID
|
||||
|
||||
/*
|
||||
* Get rid of pg_listener entry if it refers to a PID
|
||||
* that no longer exists. Presumably, that backend
|
||||
* crashed without deleting its pg_listener entries.
|
||||
* This code used to only delete the entry if errno==ESRCH,
|
||||
* but as far as I can see we should just do it for any
|
||||
* failure (certainly at least for EPERM too...)
|
||||
* This code used to only delete the entry if
|
||||
* errno==ESRCH, but as far as I can see we should
|
||||
* just do it for any failure (certainly at least for
|
||||
* EPERM too...)
|
||||
*/
|
||||
heap_delete(lRel, &lTuple->t_self, NULL);
|
||||
}
|
||||
@@ -536,6 +549,7 @@ AtCommit_Notify()
|
||||
}
|
||||
|
||||
heap_endscan(sRel);
|
||||
|
||||
/*
|
||||
* We do not do RelationUnsetLockForWrite(lRel) here, because the
|
||||
* transaction is about to be committed anyway.
|
||||
@@ -549,7 +563,7 @@ AtCommit_Notify()
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* AtAbort_Notify
|
||||
* AtAbort_Notify
|
||||
*
|
||||
* This is called at transaction abort.
|
||||
*
|
||||
@@ -569,7 +583,7 @@ AtAbort_Notify()
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
* Async_NotifyHandler
|
||||
* Async_NotifyHandler
|
||||
*
|
||||
* This is the signal handler for SIGUSR2.
|
||||
*
|
||||
@@ -588,25 +602,30 @@ AtAbort_Notify()
|
||||
void
|
||||
Async_NotifyHandler(SIGNAL_ARGS)
|
||||
{
|
||||
|
||||
/*
|
||||
* Note: this is a SIGNAL HANDLER. You must be very wary what you do here.
|
||||
* Some helpful soul had this routine sprinkled with TPRINTFs, which would
|
||||
* likely lead to corruption of stdio buffers if they were ever turned on.
|
||||
* Note: this is a SIGNAL HANDLER. You must be very wary what you do
|
||||
* here. Some helpful soul had this routine sprinkled with TPRINTFs,
|
||||
* which would likely lead to corruption of stdio buffers if they were
|
||||
* ever turned on.
|
||||
*/
|
||||
|
||||
if (notifyInterruptEnabled)
|
||||
{
|
||||
/* I'm not sure whether some flavors of Unix might allow another
|
||||
* SIGUSR2 occurrence to recursively interrupt this routine.
|
||||
* To cope with the possibility, we do the same sort of dance that
|
||||
* EnableNotifyInterrupt must do --- see that routine for comments.
|
||||
|
||||
/*
|
||||
* I'm not sure whether some flavors of Unix might allow another
|
||||
* SIGUSR2 occurrence to recursively interrupt this routine. To
|
||||
* cope with the possibility, we do the same sort of dance that
|
||||
* EnableNotifyInterrupt must do --- see that routine for
|
||||
* comments.
|
||||
*/
|
||||
notifyInterruptEnabled = 0; /* disable any recursive signal */
|
||||
notifyInterruptOccurred = 1; /* do at least one iteration */
|
||||
for (;;)
|
||||
{
|
||||
notifyInterruptEnabled = 1;
|
||||
if (! notifyInterruptOccurred)
|
||||
if (!notifyInterruptOccurred)
|
||||
break;
|
||||
notifyInterruptEnabled = 0;
|
||||
if (notifyInterruptOccurred)
|
||||
@@ -621,14 +640,18 @@ Async_NotifyHandler(SIGNAL_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In this path it is NOT SAFE to do much of anything, except this: */
|
||||
|
||||
/*
|
||||
* In this path it is NOT SAFE to do much of anything, except
|
||||
* this:
|
||||
*/
|
||||
notifyInterruptOccurred = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* EnableNotifyInterrupt
|
||||
* EnableNotifyInterrupt
|
||||
*
|
||||
* This is called by the PostgresMain main loop just before waiting
|
||||
* for a frontend command. If we are truly idle (ie, *not* inside
|
||||
@@ -652,26 +675,27 @@ EnableNotifyInterrupt(void)
|
||||
* notifyInterruptOccurred and then set notifyInterruptEnabled, we
|
||||
* could fail to respond promptly to a signal that happens in between
|
||||
* those two steps. (A very small time window, perhaps, but Murphy's
|
||||
* Law says you can hit it...) Instead, we first set the enable flag,
|
||||
* then test the occurred flag. If we see an unserviced interrupt
|
||||
* has occurred, we re-clear the enable flag before going off to do
|
||||
* the service work. (That prevents re-entrant invocation of
|
||||
* ProcessIncomingNotify() if another interrupt occurs.)
|
||||
* If an interrupt comes in between the setting and clearing of
|
||||
* notifyInterruptEnabled, then it will have done the service
|
||||
* work and left notifyInterruptOccurred zero, so we have to check
|
||||
* again after clearing enable. The whole thing has to be in a loop
|
||||
* in case another interrupt occurs while we're servicing the first.
|
||||
* Once we get out of the loop, enable is set and we know there is no
|
||||
* Law says you can hit it...) Instead, we first set the enable flag,
|
||||
* then test the occurred flag. If we see an unserviced interrupt has
|
||||
* occurred, we re-clear the enable flag before going off to do the
|
||||
* service work. (That prevents re-entrant invocation of
|
||||
* ProcessIncomingNotify() if another interrupt occurs.) If an
|
||||
* interrupt comes in between the setting and clearing of
|
||||
* notifyInterruptEnabled, then it will have done the service work and
|
||||
* left notifyInterruptOccurred zero, so we have to check again after
|
||||
* clearing enable. The whole thing has to be in a loop in case
|
||||
* another interrupt occurs while we're servicing the first. Once we
|
||||
* get out of the loop, enable is set and we know there is no
|
||||
* unserviced interrupt.
|
||||
*
|
||||
* NB: an overenthusiastic optimizing compiler could easily break this
|
||||
* code. Hopefully, they all understand what "volatile" means these days.
|
||||
* code. Hopefully, they all understand what "volatile" means these
|
||||
* days.
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
notifyInterruptEnabled = 1;
|
||||
if (! notifyInterruptOccurred)
|
||||
if (!notifyInterruptOccurred)
|
||||
break;
|
||||
notifyInterruptEnabled = 0;
|
||||
if (notifyInterruptOccurred)
|
||||
@@ -686,7 +710,7 @@ EnableNotifyInterrupt(void)
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* DisableNotifyInterrupt
|
||||
* DisableNotifyInterrupt
|
||||
*
|
||||
* This is called by the PostgresMain main loop just after receiving
|
||||
* a frontend command. Signal handler execution of inbound notifies
|
||||
@@ -702,7 +726,7 @@ DisableNotifyInterrupt(void)
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* ProcessIncomingNotify
|
||||
* ProcessIncomingNotify
|
||||
*
|
||||
* Deal with arriving NOTIFYs from other backends.
|
||||
* This is called either directly from the SIGUSR2 signal handler,
|
||||
@@ -777,6 +801,7 @@ ProcessIncomingNotify(void)
|
||||
}
|
||||
}
|
||||
heap_endscan(sRel);
|
||||
|
||||
/*
|
||||
* We do not do RelationUnsetLockForWrite(lRel) here, because the
|
||||
* transaction is about to be committed anyway.
|
||||
@@ -785,7 +810,10 @@ ProcessIncomingNotify(void)
|
||||
|
||||
CommitTransactionCommand();
|
||||
|
||||
/* Must flush the notify messages to ensure frontend gets them promptly. */
|
||||
/*
|
||||
* Must flush the notify messages to ensure frontend gets them
|
||||
* promptly.
|
||||
*/
|
||||
pq_flush();
|
||||
|
||||
PS_SET_STATUS("idle");
|
||||
@@ -800,20 +828,22 @@ NotifyMyFrontEnd(char *relname, int32 listenerPID)
|
||||
if (whereToSendOutput == Remote)
|
||||
{
|
||||
StringInfoData buf;
|
||||
|
||||
pq_beginmessage(&buf);
|
||||
pq_sendbyte(&buf, 'A');
|
||||
pq_sendint(&buf, listenerPID, sizeof(int32));
|
||||
pq_sendstring(&buf, relname);
|
||||
pq_endmessage(&buf);
|
||||
/* NOTE: we do not do pq_flush() here. For a self-notify, it will
|
||||
|
||||
/*
|
||||
* NOTE: we do not do pq_flush() here. For a self-notify, it will
|
||||
* happen at the end of the transaction, and for incoming notifies
|
||||
* ProcessIncomingNotify will do it after finding all the notifies.
|
||||
* ProcessIncomingNotify will do it after finding all the
|
||||
* notifies.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(NOTICE, "NOTIFY for %s", relname);
|
||||
}
|
||||
}
|
||||
|
||||
/* Does pendingNotifies include the given relname?
|
||||
@@ -847,10 +877,12 @@ ClearPendingNotifies()
|
||||
|
||||
if (pendingNotifies)
|
||||
{
|
||||
/* Since the referenced strings are malloc'd, we have to scan the
|
||||
|
||||
/*
|
||||
* Since the referenced strings are malloc'd, we have to scan the
|
||||
* list and delete them individually. If we used palloc for the
|
||||
* strings then we could just do DLFreeList to get rid of both
|
||||
* the list nodes and the list base...
|
||||
* strings then we could just do DLFreeList to get rid of both the
|
||||
* list nodes and the list base...
|
||||
*/
|
||||
while ((p = DLRemHead(pendingNotifies)) != NULL)
|
||||
{
|
||||
|
@@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.38 1999/02/13 23:15:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.39 1999/05/25 16:08:16 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -236,17 +236,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);
|
||||
@@ -259,14 +259,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
*/
|
||||
Old_pg_index_Tuple = SearchSysCacheTuple(INDEXRELID,
|
||||
ObjectIdGetDatum(RelationGetRelid(OldIndex)),
|
||||
0, 0, 0);
|
||||
0, 0, 0);
|
||||
|
||||
Assert(Old_pg_index_Tuple);
|
||||
Old_pg_index_Form = (Form_pg_index) GETSTRUCT(Old_pg_index_Tuple);
|
||||
|
||||
Old_pg_index_relation_Tuple = SearchSysCacheTuple(RELOID,
|
||||
ObjectIdGetDatum(RelationGetRelid(OldIndex)),
|
||||
0, 0, 0);
|
||||
0, 0, 0);
|
||||
|
||||
Assert(Old_pg_index_relation_Tuple);
|
||||
Old_pg_index_relation_Form = (Form_pg_class) GETSTRUCT(Old_pg_index_relation_Tuple);
|
||||
@@ -296,7 +296,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
|
||||
pg_proc_Tuple = SearchSysCacheTuple(PROOID,
|
||||
ObjectIdGetDatum(Old_pg_index_Form->indproc),
|
||||
0, 0, 0);
|
||||
0, 0, 0);
|
||||
|
||||
Assert(pg_proc_Tuple);
|
||||
pg_proc_Form = (Form_pg_proc) GETSTRUCT(pg_proc_Tuple);
|
||||
@@ -319,7 +319,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
(uint16) 0, (Datum) NULL, NULL,
|
||||
Old_pg_index_Form->indislossy,
|
||||
Old_pg_index_Form->indisunique,
|
||||
Old_pg_index_Form->indisprimary);
|
||||
Old_pg_index_Form->indisprimary);
|
||||
|
||||
heap_close(OldIndex);
|
||||
heap_close(NewHeap);
|
||||
@@ -329,14 +329,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
static void
|
||||
rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
|
||||
{
|
||||
Relation LocalNewHeap,
|
||||
LocalOldHeap,
|
||||
LocalOldIndex;
|
||||
IndexScanDesc ScanDesc;
|
||||
RetrieveIndexResult ScanResult;
|
||||
HeapTupleData LocalHeapTuple;
|
||||
Buffer LocalBuffer;
|
||||
Oid OIDNewHeapInsert;
|
||||
Relation LocalNewHeap,
|
||||
LocalOldHeap,
|
||||
LocalOldIndex;
|
||||
IndexScanDesc ScanDesc;
|
||||
RetrieveIndexResult ScanResult;
|
||||
HeapTupleData LocalHeapTuple;
|
||||
Buffer LocalBuffer;
|
||||
Oid OIDNewHeapInsert;
|
||||
|
||||
/*
|
||||
* Open the relations I need. Scan through the OldHeap on the OldIndex
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.44 1999/05/10 00:44:56 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.45 1999/05/25 16:08:17 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The PortalExecutorHeapMemory crap needs to be eliminated
|
||||
@@ -117,18 +117,18 @@ PerformPortalFetch(char *name,
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* Create a const node from the given count value
|
||||
* Create a const node from the given count value
|
||||
* ----------------
|
||||
*/
|
||||
memset(&limcount, 0, sizeof(limcount));
|
||||
limcount.type = T_Const;
|
||||
limcount.consttype = INT4OID;
|
||||
limcount.constlen = sizeof(int4);
|
||||
limcount.constvalue = (Datum)count;
|
||||
limcount.constisnull = FALSE;
|
||||
limcount.type = T_Const;
|
||||
limcount.consttype = INT4OID;
|
||||
limcount.constlen = sizeof(int4);
|
||||
limcount.constvalue = (Datum) count;
|
||||
limcount.constisnull = FALSE;
|
||||
limcount.constbyval = TRUE;
|
||||
limcount.constisset = FALSE;
|
||||
limcount.constiscast = FALSE;
|
||||
limcount.constiscast = FALSE;
|
||||
|
||||
|
||||
/* ----------------
|
||||
@@ -193,8 +193,8 @@ PerformPortalFetch(char *name,
|
||||
*/
|
||||
PortalExecutorHeapMemory = (MemoryContext) PortalGetHeapMemory(portal);
|
||||
|
||||
ExecutorRun(queryDesc, PortalGetState(portal), feature,
|
||||
(Node *)NULL, (Node *)&limcount);
|
||||
ExecutorRun(queryDesc, PortalGetState(portal), feature,
|
||||
(Node *) NULL, (Node *) &limcount);
|
||||
|
||||
if (dest == None) /* MOVE */
|
||||
pfree(queryDesc);
|
||||
@@ -211,7 +211,7 @@ PerformPortalFetch(char *name,
|
||||
* ----------------
|
||||
*/
|
||||
MemoryContextSwitchTo(
|
||||
(MemoryContext) PortalGetHeapMemory(GetPortalByName(NULL)));
|
||||
(MemoryContext) PortalGetHeapMemory(GetPortalByName(NULL)));
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
@@ -503,7 +503,7 @@ PerformAddAttribute(char *relationName,
|
||||
heap_replace(rel, &reltup->t_self, reltup, NULL);
|
||||
|
||||
{
|
||||
HeapTuple temptup;
|
||||
HeapTuple temptup;
|
||||
|
||||
if ((temptup = get_temp_rel_by_name(relationName)) != NULL)
|
||||
((Form_pg_class) GETSTRUCT(temptup))->relnatts = maxatts;
|
||||
@@ -519,7 +519,7 @@ PerformAddAttribute(char *relationName,
|
||||
}
|
||||
|
||||
void
|
||||
LockTableCommand(LockStmt *lockstmt)
|
||||
LockTableCommand(LockStmt * lockstmt)
|
||||
{
|
||||
Relation rel;
|
||||
int aclresult;
|
||||
|
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.76 1999/05/10 00:44:58 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.77 1999/05/25 16:08:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -70,111 +70,138 @@ static int CountTuples(Relation relation);
|
||||
|
||||
static int lineno;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Internal communications functions
|
||||
*/
|
||||
inline void CopySendData(void *databuf, int datasize, FILE *fp);
|
||||
inline void CopySendString(char *str, FILE *fp);
|
||||
inline void CopySendChar(char c, FILE *fp);
|
||||
inline void CopyGetData(void *databuf, int datasize, FILE *fp);
|
||||
inline int CopyGetChar(FILE *fp);
|
||||
inline int CopyGetEof(FILE *fp);
|
||||
inline int CopyPeekChar(FILE *fp);
|
||||
inline int CopyGetChar(FILE *fp);
|
||||
inline int CopyGetEof(FILE *fp);
|
||||
inline int CopyPeekChar(FILE *fp);
|
||||
inline void CopyDonePeek(FILE *fp, int c, int pickup);
|
||||
|
||||
/*
|
||||
* CopySendData sends output data either to the file
|
||||
* specified by fp or, if fp is NULL, using the standard
|
||||
* backend->frontend functions
|
||||
* specified by fp or, if fp is NULL, using the standard
|
||||
* backend->frontend functions
|
||||
*
|
||||
* CopySendString does the same for null-terminated strings
|
||||
* CopySendChar does the same for single characters
|
||||
*
|
||||
* NB: no data conversion is applied by these functions
|
||||
*/
|
||||
inline void CopySendData(void *databuf, int datasize, FILE *fp) {
|
||||
if (!fp)
|
||||
pq_putbytes((char*) databuf, datasize);
|
||||
else
|
||||
fwrite(databuf, datasize, 1, fp);
|
||||
}
|
||||
|
||||
inline void CopySendString(char *str, FILE *fp) {
|
||||
CopySendData(str,strlen(str),fp);
|
||||
inline void
|
||||
CopySendData(void *databuf, int datasize, FILE *fp)
|
||||
{
|
||||
if (!fp)
|
||||
pq_putbytes((char *) databuf, datasize);
|
||||
else
|
||||
fwrite(databuf, datasize, 1, fp);
|
||||
}
|
||||
|
||||
inline void CopySendChar(char c, FILE *fp) {
|
||||
CopySendData(&c,1,fp);
|
||||
inline void
|
||||
CopySendString(char *str, FILE *fp)
|
||||
{
|
||||
CopySendData(str, strlen(str), fp);
|
||||
}
|
||||
|
||||
inline void
|
||||
CopySendChar(char c, FILE *fp)
|
||||
{
|
||||
CopySendData(&c, 1, fp);
|
||||
}
|
||||
|
||||
/*
|
||||
* CopyGetData reads output data either from the file
|
||||
* specified by fp or, if fp is NULL, using the standard
|
||||
* backend->frontend functions
|
||||
* specified by fp or, if fp is NULL, using the standard
|
||||
* backend->frontend functions
|
||||
*
|
||||
* CopyGetChar does the same for single characters
|
||||
* CopyGetEof checks if it's EOF on the input
|
||||
*
|
||||
* NB: no data conversion is applied by these functions
|
||||
*/
|
||||
inline void CopyGetData(void *databuf, int datasize, FILE *fp) {
|
||||
if (!fp)
|
||||
pq_getbytes((char*) databuf, datasize);
|
||||
else
|
||||
fread(databuf, datasize, 1, fp);
|
||||
inline void
|
||||
CopyGetData(void *databuf, int datasize, FILE *fp)
|
||||
{
|
||||
if (!fp)
|
||||
pq_getbytes((char *) databuf, datasize);
|
||||
else
|
||||
fread(databuf, datasize, 1, fp);
|
||||
}
|
||||
|
||||
inline int CopyGetChar(FILE *fp) {
|
||||
if (!fp)
|
||||
{
|
||||
unsigned char ch;
|
||||
if (pq_getbytes((char*) &ch, 1))
|
||||
return EOF;
|
||||
return ch;
|
||||
}
|
||||
else
|
||||
return getc(fp);
|
||||
inline int
|
||||
CopyGetChar(FILE *fp)
|
||||
{
|
||||
if (!fp)
|
||||
{
|
||||
unsigned char ch;
|
||||
|
||||
if (pq_getbytes((char *) &ch, 1))
|
||||
return EOF;
|
||||
return ch;
|
||||
}
|
||||
else
|
||||
return getc(fp);
|
||||
}
|
||||
|
||||
inline int CopyGetEof(FILE *fp) {
|
||||
if (!fp)
|
||||
return 0; /* Never return EOF when talking to frontend ? */
|
||||
else
|
||||
return feof(fp);
|
||||
inline int
|
||||
CopyGetEof(FILE *fp)
|
||||
{
|
||||
if (!fp)
|
||||
return 0; /* Never return EOF when talking to
|
||||
* frontend ? */
|
||||
else
|
||||
return feof(fp);
|
||||
}
|
||||
|
||||
/*
|
||||
* CopyPeekChar reads a byte in "peekable" mode.
|
||||
* after each call to CopyPeekChar, a call to CopyDonePeek _must_
|
||||
* follow.
|
||||
* CopyDonePeek will either take the peeked char off the steam
|
||||
* CopyDonePeek will either take the peeked char off the steam
|
||||
* (if pickup is != 0) or leave it on the stream (if pickup == 0)
|
||||
*/
|
||||
inline int CopyPeekChar(FILE *fp) {
|
||||
if (!fp)
|
||||
return pq_peekbyte();
|
||||
else
|
||||
return getc(fp);
|
||||
inline int
|
||||
CopyPeekChar(FILE *fp)
|
||||
{
|
||||
if (!fp)
|
||||
return pq_peekbyte();
|
||||
else
|
||||
return getc(fp);
|
||||
}
|
||||
|
||||
inline void CopyDonePeek(FILE *fp, int c, int pickup) {
|
||||
if (!fp) {
|
||||
if (pickup) {
|
||||
/* We want to pick it up - just receive again into dummy buffer */
|
||||
char c;
|
||||
pq_getbytes(&c, 1);
|
||||
}
|
||||
/* If we didn't want to pick it up, just leave it where it sits */
|
||||
}
|
||||
else {
|
||||
if (!pickup) {
|
||||
/* We don't want to pick it up - so put it back in there */
|
||||
ungetc(c,fp);
|
||||
}
|
||||
/* If we wanted to pick it up, it's already there */
|
||||
}
|
||||
inline void
|
||||
CopyDonePeek(FILE *fp, int c, int pickup)
|
||||
{
|
||||
if (!fp)
|
||||
{
|
||||
if (pickup)
|
||||
{
|
||||
|
||||
/*
|
||||
* We want to pick it up - just receive again into dummy
|
||||
* buffer
|
||||
*/
|
||||
char c;
|
||||
|
||||
pq_getbytes(&c, 1);
|
||||
}
|
||||
/* If we didn't want to pick it up, just leave it where it sits */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!pickup)
|
||||
{
|
||||
/* We don't want to pick it up - so put it back in there */
|
||||
ungetc(c, fp);
|
||||
}
|
||||
/* If we wanted to pick it up, it's already there */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -317,7 +344,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
|
||||
else if (!from)
|
||||
{
|
||||
if (!binary)
|
||||
CopySendData("\\.\n",3,fp);
|
||||
CopySendData("\\.\n", 3, fp);
|
||||
if (IsUnderPostmaster)
|
||||
pq_endcopyout(false);
|
||||
}
|
||||
@@ -395,8 +422,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
|
||||
if (oids && !binary)
|
||||
{
|
||||
CopySendString(oidout(tuple->t_data->t_oid),fp);
|
||||
CopySendChar(delim[0],fp);
|
||||
CopySendString(oidout(tuple->t_data->t_oid), fp);
|
||||
CopySendChar(delim[0], fp);
|
||||
}
|
||||
|
||||
for (i = 0; i < attr_count; i++)
|
||||
@@ -466,8 +493,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
}
|
||||
}
|
||||
}
|
||||
CopySendData((char *) tuple->t_data + tuple->t_data->t_hoff,
|
||||
length, fp);
|
||||
CopySendData((char *) tuple->t_data + tuple->t_data->t_hoff,
|
||||
length, fp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +548,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
Node **indexPred = NULL;
|
||||
TupleDesc rtupdesc;
|
||||
ExprContext *econtext = NULL;
|
||||
EState *estate = makeNode(EState); /* for ExecConstraints() */
|
||||
EState *estate = makeNode(EState); /* for ExecConstraints() */
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
TupleTable tupleTable;
|
||||
@@ -566,11 +593,11 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
itupdescArr[i] = RelationGetDescr(index_rels[i]);
|
||||
pgIndexTup = SearchSysCacheTuple(INDEXRELID,
|
||||
ObjectIdGetDatum(RelationGetRelid(index_rels[i])),
|
||||
0, 0, 0);
|
||||
0, 0, 0);
|
||||
Assert(pgIndexTup);
|
||||
pgIndexP[i] = (Form_pg_index) GETSTRUCT(pgIndexTup);
|
||||
for (attnumP = &(pgIndexP[i]->indkey[0]), natts = 0;
|
||||
natts < INDEX_MAX_KEYS && *attnumP != InvalidAttrNumber;
|
||||
natts < INDEX_MAX_KEYS && *attnumP != InvalidAttrNumber;
|
||||
attnumP++, natts++);
|
||||
if (pgIndexP[i]->indproc != InvalidOid)
|
||||
{
|
||||
@@ -777,7 +804,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
}
|
||||
else if (nulls[i] != 'n')
|
||||
{
|
||||
ptr = (char *)att_align(ptr, attr[i]->attlen, attr[i]->attalign);
|
||||
ptr = (char *) att_align(ptr, attr[i]->attlen, attr[i]->attalign);
|
||||
values[i] = (Datum) ptr;
|
||||
ptr = att_addlength(ptr, attr[i]->attlen, ptr);
|
||||
}
|
||||
@@ -888,7 +915,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
pfree(index_nulls);
|
||||
pfree(idatum);
|
||||
pfree(byval);
|
||||
|
||||
|
||||
if (!binary)
|
||||
{
|
||||
pfree(in_functions);
|
||||
@@ -903,7 +930,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
{
|
||||
if (index_rels[i] == NULL)
|
||||
continue;
|
||||
if ((index_rels[i])->rd_rel->relam != BTREE_AM_OID &&
|
||||
if ((index_rels[i])->rd_rel->relam != BTREE_AM_OID &&
|
||||
(index_rels[i])->rd_rel->relam != HASH_AM_OID)
|
||||
UnlockRelation(index_rels[i], AccessExclusiveLock);
|
||||
index_close(index_rels[i]);
|
||||
@@ -1022,12 +1049,12 @@ GetIndexRelations(Oid main_relation_oid,
|
||||
{
|
||||
|
||||
index_relation_oid = (Oid) DatumGetInt32(heap_getattr(tuple, 2,
|
||||
tupDesc, &isnull));
|
||||
tupDesc, &isnull));
|
||||
if (index_relation_oid == main_relation_oid)
|
||||
{
|
||||
scan->index_rel_oid = (Oid) DatumGetInt32(heap_getattr(tuple,
|
||||
Anum_pg_index_indexrelid,
|
||||
tupDesc, &isnull));
|
||||
Anum_pg_index_indexrelid,
|
||||
tupDesc, &isnull));
|
||||
(*n_indices)++;
|
||||
scan->next = (RelationList *) palloc(sizeof(RelationList));
|
||||
scan = scan->next;
|
||||
@@ -1047,7 +1074,7 @@ GetIndexRelations(Oid main_relation_oid,
|
||||
{
|
||||
(*index_rels)[i] = index_open(scan->index_rel_oid);
|
||||
/* comments in execUtils.c */
|
||||
if ((*index_rels)[i] != NULL &&
|
||||
if ((*index_rels)[i] != NULL &&
|
||||
((*index_rels)[i])->rd_rel->relam != BTREE_AM_OID &&
|
||||
((*index_rels)[i])->rd_rel->relam != HASH_AM_OID)
|
||||
LockRelation((*index_rels)[i], AccessExclusiveLock);
|
||||
@@ -1176,26 +1203,29 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
|
||||
if (ISOCTAL(c))
|
||||
{
|
||||
val = (val << 3) + VALUE(c);
|
||||
CopyDonePeek(fp, c, 1); /* Pick up the character! */
|
||||
CopyDonePeek(fp, c, 1); /* Pick up the
|
||||
* character! */
|
||||
c = CopyPeekChar(fp);
|
||||
if (ISOCTAL(c)) {
|
||||
CopyDonePeek(fp,c,1); /* pick up! */
|
||||
if (ISOCTAL(c))
|
||||
{
|
||||
CopyDonePeek(fp, c, 1); /* pick up! */
|
||||
val = (val << 3) + VALUE(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CopyGetEof(fp)) {
|
||||
CopyDonePeek(fp,c,1); /* pick up */
|
||||
if (CopyGetEof(fp))
|
||||
{
|
||||
CopyDonePeek(fp, c, 1); /* pick up */
|
||||
return NULL;
|
||||
}
|
||||
CopyDonePeek(fp,c,0); /* Return to stream! */
|
||||
CopyDonePeek(fp, c, 0); /* Return to stream! */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CopyGetEof(fp))
|
||||
return NULL;
|
||||
CopyDonePeek(fp,c,0); /* Return to stream! */
|
||||
CopyDonePeek(fp, c, 0); /* Return to stream! */
|
||||
}
|
||||
c = val & 0377;
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.40 1999/02/13 23:15:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.41 1999/05/25 16:08:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ static List *MergeAttributes(List *schema, List *supers, List **supconstr);
|
||||
static void StoreCatalogInheritance(Oid relationId, List *supers);
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* DefineRelation
|
||||
* DefineRelation
|
||||
* Creates a new relation.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
@@ -90,10 +90,10 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
|
||||
if (constraints != NIL)
|
||||
{
|
||||
List *entry;
|
||||
int nconstr = length(constraints),
|
||||
ncheck = 0,
|
||||
i;
|
||||
List *entry;
|
||||
int nconstr = length(constraints),
|
||||
ncheck = 0,
|
||||
i;
|
||||
ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck));
|
||||
|
||||
foreach(entry, constraints)
|
||||
@@ -107,9 +107,9 @@ 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;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
}
|
||||
|
||||
/*
|
||||
* RemoveRelation
|
||||
* RemoveRelation
|
||||
* Deletes a new relation.
|
||||
*
|
||||
* Exceptions:
|
||||
@@ -164,7 +164,7 @@ RemoveRelation(char *name)
|
||||
|
||||
|
||||
/*
|
||||
* MergeAttributes
|
||||
* MergeAttributes
|
||||
* Returns new schema given initial schema and supers.
|
||||
*
|
||||
*
|
||||
@@ -276,8 +276,8 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
|
||||
*/
|
||||
attributeName = (attribute->attname).data;
|
||||
tuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(attribute->atttypid),
|
||||
0, 0, 0);
|
||||
ObjectIdGetDatum(attribute->atttypid),
|
||||
0, 0, 0);
|
||||
Assert(HeapTupleIsValid(tuple));
|
||||
attributeType = (((Form_pg_type) GETSTRUCT(tuple))->typname).data;
|
||||
|
||||
@@ -365,7 +365,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
|
||||
}
|
||||
|
||||
/*
|
||||
* StoreCatalogInheritance
|
||||
* StoreCatalogInheritance
|
||||
* Updates the system catalogs with proper inheritance information.
|
||||
*/
|
||||
static void
|
||||
@@ -411,9 +411,9 @@ StoreCatalogInheritance(Oid relationId, List *supers)
|
||||
*/
|
||||
idList = lappendi(idList, tuple->t_data->t_oid);
|
||||
|
||||
datum[0] = ObjectIdGetDatum(relationId); /* inhrel */
|
||||
datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid); /* inhparent */
|
||||
datum[2] = Int16GetDatum(seqNumber); /* inhseqno */
|
||||
datum[0] = ObjectIdGetDatum(relationId); /* inhrel */
|
||||
datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid); /* inhparent */
|
||||
datum[2] = Int16GetDatum(seqNumber); /* inhseqno */
|
||||
|
||||
nullarr[0] = ' ';
|
||||
nullarr[1] = ' ';
|
||||
@@ -467,8 +467,8 @@ StoreCatalogInheritance(Oid relationId, List *supers)
|
||||
break;
|
||||
|
||||
lnext(current) = lconsi(((Form_pg_inherits)
|
||||
GETSTRUCT(tuple))->inhparent,
|
||||
NIL);
|
||||
GETSTRUCT(tuple))->inhparent,
|
||||
NIL);
|
||||
|
||||
current = lnext(current);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.34 1999/05/10 00:44:59 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.35 1999/05/25 16:08:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,8 +47,8 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
|
||||
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
|
||||
@@ -80,13 +80,13 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
|
||||
elog(ERROR, "Unable to create database directory '%s'", lp);
|
||||
|
||||
snprintf(buf, 512, "%s %s%cbase%ctemplate1%c* %s",
|
||||
COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp);
|
||||
COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp);
|
||||
system(buf);
|
||||
|
||||
snprintf(buf, 512,
|
||||
"insert into pg_database (datname, datdba, encoding, datpath)"
|
||||
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding,
|
||||
loc);
|
||||
snprintf(buf, 512,
|
||||
"insert into pg_database (datname, datdba, encoding, datpath)"
|
||||
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding,
|
||||
loc);
|
||||
|
||||
pg_exec_query_dest(buf, dest, false);
|
||||
}
|
||||
@@ -96,9 +96,9 @@ destroydb(char *dbname, CommandDest dest)
|
||||
{
|
||||
int4 user_id;
|
||||
Oid db_id;
|
||||
char *path,
|
||||
dbpath[MAXPGPATH + 1],
|
||||
buf[512];
|
||||
char *path,
|
||||
dbpath[MAXPGPATH + 1],
|
||||
buf[512];
|
||||
|
||||
/*
|
||||
* If this call returns, the database exists and we're allowed to
|
||||
@@ -122,9 +122,9 @@ destroydb(char *dbname, CommandDest dest)
|
||||
* remove the pg_database tuple FIRST, this may fail due to
|
||||
* permissions problems
|
||||
*/
|
||||
snprintf(buf, 512,
|
||||
"delete from pg_database where pg_database.oid = \'%u\'::oid", db_id);
|
||||
pg_exec_query_dest(buf ,dest, false);
|
||||
snprintf(buf, 512,
|
||||
"delete from pg_database where pg_database.oid = \'%u\'::oid", db_id);
|
||||
pg_exec_query_dest(buf, dest, false);
|
||||
|
||||
/* drop pages for this database that are in the shared buffer cache */
|
||||
DropBuffers(db_id);
|
||||
@@ -294,13 +294,13 @@ static void
|
||||
stop_vacuum(char *dbpath, char *dbname)
|
||||
{
|
||||
char filename[256];
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
int pid;
|
||||
|
||||
if (strchr(dbpath, SEP_CHAR) != 0)
|
||||
{
|
||||
snprintf(filename, 256, "%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
|
||||
snprintf(filename, 256, "%s%c%s.vacuum", dbpath, SEP_CHAR, dbname);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.28 1999/04/09 22:35:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.29 1999/05/25 16:08:22 momjian Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The "DefineFoo" routines take the parse tree and pick out the
|
||||
@@ -203,7 +203,7 @@ interpret_AS_clause(const char *languageName, const char *as,
|
||||
|
||||
|
||||
/*
|
||||
* CreateFunction
|
||||
* CreateFunction
|
||||
* Execute a CREATE FUNCTION utility statement.
|
||||
*
|
||||
*/
|
||||
@@ -574,7 +574,7 @@ DefineAggregate(char *aggName, List *parameters)
|
||||
}
|
||||
|
||||
/*
|
||||
* DefineType
|
||||
* DefineType
|
||||
* Registers a new type.
|
||||
*
|
||||
*/
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (c) 1994-5, Regents of the University of California
|
||||
*
|
||||
* $Id: explain.c,v 1.36 1999/05/09 23:31:45 tgl Exp $
|
||||
* $Id: explain.c,v 1.37 1999/05/25 16:08:23 momjian Exp $
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
@@ -34,7 +34,7 @@ typedef struct ExplainState
|
||||
} ExplainState;
|
||||
|
||||
static char *Explain_PlanToString(Plan *plan, ExplainState *es);
|
||||
static void printLongNotice(const char * header, const char * message);
|
||||
static void printLongNotice(const char *header, const char *message);
|
||||
static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest);
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest);
|
||||
void
|
||||
ExplainQuery(Query *query, bool verbose, CommandDest dest)
|
||||
{
|
||||
List *rewritten;
|
||||
List *l;
|
||||
List *rewritten;
|
||||
List *l;
|
||||
|
||||
/* rewriter and planner may not work in aborted state? */
|
||||
if (IsAbortedTransactionBlockState())
|
||||
@@ -145,10 +145,10 @@ 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;
|
||||
int i;
|
||||
char *pname;
|
||||
int i;
|
||||
|
||||
if (plan == NULL)
|
||||
{
|
||||
@@ -208,15 +208,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
case T_IndexScan:
|
||||
appendStringInfo(str, " using ");
|
||||
i = 0;
|
||||
foreach (l, ((IndexScan *) plan)->indxid)
|
||||
foreach(l, ((IndexScan *) plan)->indxid)
|
||||
{
|
||||
relation = RelationIdCacheGetRelation((int) lfirst(l));
|
||||
if (++i > 1)
|
||||
{
|
||||
appendStringInfo(str, ", ");
|
||||
}
|
||||
appendStringInfo(str,
|
||||
stringStringInfo((RelationGetRelationName(relation))->data));
|
||||
appendStringInfo(str,
|
||||
stringStringInfo((RelationGetRelationName(relation))->data));
|
||||
}
|
||||
case T_SeqScan:
|
||||
if (((Scan *) plan)->scanrelid > 0)
|
||||
@@ -227,7 +225,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
if (strcmp(rte->refname, rte->relname) != 0)
|
||||
{
|
||||
appendStringInfo(str, "%s ",
|
||||
stringStringInfo(rte->relname));
|
||||
stringStringInfo(rte->relname));
|
||||
}
|
||||
appendStringInfo(str, stringStringInfo(rte->refname));
|
||||
}
|
||||
@@ -238,7 +236,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
if (es->printCost)
|
||||
{
|
||||
appendStringInfo(str, " (cost=%.2f rows=%d width=%d)",
|
||||
plan->cost, plan->plan_size, plan->plan_width);
|
||||
plan->cost, plan->plan_size, plan->plan_width);
|
||||
}
|
||||
appendStringInfo(str, "\n");
|
||||
|
||||
@@ -248,18 +246,14 @@ 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);
|
||||
}
|
||||
@@ -270,9 +264,7 @@ 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);
|
||||
}
|
||||
@@ -281,9 +273,7 @@ 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);
|
||||
}
|
||||
@@ -295,17 +285,13 @@ 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);
|
||||
}
|
||||
@@ -336,9 +322,7 @@ 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);
|
||||
@@ -353,7 +337,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
static char *
|
||||
Explain_PlanToString(Plan *plan, ExplainState *es)
|
||||
{
|
||||
StringInfoData str;
|
||||
StringInfoData str;
|
||||
|
||||
/* see stringinfo.h for an explanation of this maneuver */
|
||||
initStringInfo(&str);
|
||||
@@ -367,9 +351,9 @@ Explain_PlanToString(Plan *plan, ExplainState *es)
|
||||
* This is a crock ... there shouldn't be an upper limit to what you can elog().
|
||||
*/
|
||||
static void
|
||||
printLongNotice(const char * header, const char * message)
|
||||
printLongNotice(const char *header, const char *message)
|
||||
{
|
||||
int len = strlen(message);
|
||||
int len = strlen(message);
|
||||
|
||||
elog(NOTICE, "%.20s%.*s", header, ELOG_MAXLEN - 64, message);
|
||||
len -= ELOG_MAXLEN - 64;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.3 1999/05/10 00:44:59 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.4 1999/05/25 16:08:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -53,7 +53,7 @@ static void NormIndexAttrs(List *attList, AttrNumber *attNumP,
|
||||
static char *GetDefaultOpClass(Oid atttypid);
|
||||
|
||||
/*
|
||||
* DefineIndex
|
||||
* DefineIndex
|
||||
* Creates a new index.
|
||||
*
|
||||
* 'attributeList' is a list of IndexElem specifying either a functional
|
||||
@@ -164,7 +164,7 @@ DefineIndex(char *heapRelationName,
|
||||
if (nargs > INDEX_MAX_KEYS)
|
||||
{
|
||||
elog(ERROR,
|
||||
"Too many args to function, limit of %d", INDEX_MAX_KEYS);
|
||||
"Too many args to function, limit of %d", INDEX_MAX_KEYS);
|
||||
}
|
||||
|
||||
FIsetnArgs(&fInfo, nargs);
|
||||
@@ -207,7 +207,7 @@ DefineIndex(char *heapRelationName,
|
||||
|
||||
|
||||
/*
|
||||
* ExtendIndex
|
||||
* ExtendIndex
|
||||
* Extends a partial index.
|
||||
*
|
||||
* Exceptions:
|
||||
@@ -304,7 +304,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
|
||||
predInfo->oldPred = oldPred;
|
||||
|
||||
attributeNumberA = (AttrNumber *) palloc(numberOfAttributes *
|
||||
sizeof attributeNumberA[0]);
|
||||
sizeof attributeNumberA[0]);
|
||||
classObjectId = (Oid *) palloc(numberOfAttributes * sizeof classObjectId[0]);
|
||||
|
||||
|
||||
@@ -501,7 +501,7 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
|
||||
/* we just set the type name because that is all we need */
|
||||
attribute->typename = makeNode(TypeName);
|
||||
attribute->typename->name = nameout(&((Form_pg_type) GETSTRUCT(tuple))->typname);
|
||||
|
||||
|
||||
/* we all need the typmod for the char and varchar types. */
|
||||
attribute->typename->typmod = attform->atttypmod;
|
||||
}
|
||||
@@ -547,7 +547,7 @@ GetDefaultOpClass(Oid atttypid)
|
||||
}
|
||||
|
||||
/*
|
||||
* RemoveIndex
|
||||
* RemoveIndex
|
||||
* Deletes an index.
|
||||
*
|
||||
* Exceptions:
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.32 1999/02/13 23:15:08 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.33 1999/05/25 16:08:25 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -36,7 +36,7 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
* RemoveOperator
|
||||
* RemoveOperator
|
||||
* Deletes an operator.
|
||||
*
|
||||
* Exceptions:
|
||||
@@ -288,7 +288,7 @@ RemoveType(char *typeName) /* type name to be removed */
|
||||
}
|
||||
|
||||
/*
|
||||
* RemoveFunction
|
||||
* RemoveFunction
|
||||
* Deletes a function.
|
||||
*
|
||||
* Exceptions:
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.24 1999/05/17 18:24:48 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.25 1999/05/25 16:08:26 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ renameatt(char *relname,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((relid = RelnameFindRelid(relname)) == InvalidOid)
|
||||
elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname);
|
||||
|
||||
@@ -201,7 +201,7 @@ renameatt(char *relname,
|
||||
void
|
||||
renamerel(char *oldrelname, char *newrelname)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Relation relrelation; /* for RELATION relation */
|
||||
HeapTuple oldreltup;
|
||||
char oldpath[MAXPGPATH],
|
||||
@@ -237,7 +237,7 @@ renamerel(char *oldrelname, char *newrelname)
|
||||
{
|
||||
sprintf(toldpath, "%s.%d", oldpath, i);
|
||||
sprintf(tnewpath, "%s.%d", newpath, i);
|
||||
if(rename(toldpath, tnewpath) < 0)
|
||||
if (rename(toldpath, tnewpath) < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ static void init_params(CreateSeqStmt *seq, Form_pg_sequence new);
|
||||
static int get_param(DefElem *def);
|
||||
|
||||
/*
|
||||
* DefineSequence
|
||||
* DefineSequence
|
||||
* Creates a new sequence relation
|
||||
*/
|
||||
void
|
||||
@@ -218,8 +218,8 @@ nextval(struct varlena * seqin)
|
||||
return elm->last;
|
||||
}
|
||||
|
||||
seq = read_info("nextval", elm, &buf); /* lock page' buffer and read
|
||||
* tuple */
|
||||
seq = read_info("nextval", elm, &buf); /* lock page' buffer and
|
||||
* read tuple */
|
||||
|
||||
next = result = seq->last_value;
|
||||
incby = seq->increment_by;
|
||||
@@ -327,8 +327,8 @@ setval(struct varlena * seqin, int4 next)
|
||||
|
||||
/* open and AccessShareLock sequence */
|
||||
elm = init_sequence("setval", seqname);
|
||||
seq = read_info("setval", elm, &buf); /* lock page' buffer and read
|
||||
* tuple */
|
||||
seq = read_info("setval", elm, &buf); /* lock page' buffer and
|
||||
* read tuple */
|
||||
|
||||
if (seq->cache_value != 1)
|
||||
{
|
||||
@@ -361,11 +361,11 @@ setval(struct varlena * seqin, int4 next)
|
||||
static Form_pg_sequence
|
||||
read_info(char *caller, SeqTable elm, Buffer *buf)
|
||||
{
|
||||
PageHeader page;
|
||||
ItemId lp;
|
||||
HeapTupleData tuple;
|
||||
PageHeader page;
|
||||
ItemId lp;
|
||||
HeapTupleData tuple;
|
||||
sequence_magic *sm;
|
||||
Form_pg_sequence seq;
|
||||
Form_pg_sequence seq;
|
||||
|
||||
if (RelationGetNumberOfBlocks(elm->rel) != 1)
|
||||
elog(ERROR, "%s.%s: invalid number of blocks in sequence",
|
||||
@@ -464,7 +464,7 @@ init_sequence(char *caller, char *name)
|
||||
|
||||
|
||||
/*
|
||||
* CloseSequences
|
||||
* CloseSequences
|
||||
* is calling by xact mgr at commit/abort.
|
||||
*/
|
||||
void
|
||||
|
@@ -362,9 +362,9 @@ RelationBuildTriggers(Relation relation)
|
||||
Form_pg_trigger pg_trigger;
|
||||
Relation irel;
|
||||
ScanKeyData skey;
|
||||
HeapTupleData tuple;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
HeapTupleData tuple;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
Buffer buffer;
|
||||
struct varlena *val;
|
||||
bool isnull;
|
||||
@@ -659,14 +659,14 @@ ExecARInsertTriggers(Relation rel, HeapTuple trigtuple)
|
||||
bool
|
||||
ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid)
|
||||
{
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
TriggerData *SaveTriggerData;
|
||||
int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE];
|
||||
Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
|
||||
HeapTuple trigtuple;
|
||||
HeapTuple newtuple = NULL;
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
TriggerData *SaveTriggerData;
|
||||
int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE];
|
||||
Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
|
||||
HeapTuple trigtuple;
|
||||
HeapTuple newtuple = NULL;
|
||||
TupleTableSlot *newSlot;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot);
|
||||
if (trigtuple == NULL)
|
||||
@@ -697,7 +697,7 @@ ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid)
|
||||
void
|
||||
ExecARDeleteTriggers(EState *estate, ItemPointer tupleid)
|
||||
{
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
TriggerData *SaveTriggerData;
|
||||
int ntrigs = rel->trigdesc->n_after_row[TRIGGER_EVENT_DELETE];
|
||||
Trigger **trigger = rel->trigdesc->tg_after_row[TRIGGER_EVENT_DELETE];
|
||||
@@ -727,23 +727,23 @@ ExecARDeleteTriggers(EState *estate, ItemPointer tupleid)
|
||||
HeapTuple
|
||||
ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
|
||||
{
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
TriggerData *SaveTriggerData;
|
||||
int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE];
|
||||
Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_UPDATE];
|
||||
HeapTuple trigtuple;
|
||||
HeapTuple oldtuple;
|
||||
HeapTuple intuple = newtuple;
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
TriggerData *SaveTriggerData;
|
||||
int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE];
|
||||
Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_UPDATE];
|
||||
HeapTuple trigtuple;
|
||||
HeapTuple oldtuple;
|
||||
HeapTuple intuple = newtuple;
|
||||
TupleTableSlot *newSlot;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot);
|
||||
if (trigtuple == NULL)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* In READ COMMITTED isolevel it's possible that newtuple
|
||||
* was changed due to concurrent update.
|
||||
* In READ COMMITTED isolevel it's possible that newtuple was changed
|
||||
* due to concurrent update.
|
||||
*/
|
||||
if (newSlot != NULL)
|
||||
intuple = newtuple = ExecRemoveJunk(estate->es_junkFilter, newSlot);
|
||||
@@ -772,7 +772,7 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
|
||||
void
|
||||
ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
|
||||
{
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
Relation rel = estate->es_result_relation_info->ri_RelationDesc;
|
||||
TriggerData *SaveTriggerData;
|
||||
int ntrigs = rel->trigdesc->n_after_row[TRIGGER_EVENT_UPDATE];
|
||||
Trigger **trigger = rel->trigdesc->tg_after_row[TRIGGER_EVENT_UPDATE];
|
||||
@@ -799,22 +799,22 @@ ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
|
||||
return;
|
||||
}
|
||||
|
||||
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid);
|
||||
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid);
|
||||
|
||||
static HeapTuple
|
||||
GetTupleForTrigger(EState *estate, ItemPointer tid, TupleTableSlot **newSlot)
|
||||
{
|
||||
Relation relation = estate->es_result_relation_info->ri_RelationDesc;
|
||||
HeapTupleData tuple;
|
||||
HeapTuple result;
|
||||
Buffer buffer;
|
||||
Relation relation = estate->es_result_relation_info->ri_RelationDesc;
|
||||
HeapTupleData tuple;
|
||||
HeapTuple result;
|
||||
Buffer buffer;
|
||||
|
||||
if (newSlot != NULL)
|
||||
{
|
||||
int test;
|
||||
int test;
|
||||
|
||||
/*
|
||||
* mark tuple for update
|
||||
* mark tuple for update
|
||||
*/
|
||||
*newSlot = NULL;
|
||||
tuple.t_self = *tid;
|
||||
@@ -824,7 +824,7 @@ ltrmark:;
|
||||
{
|
||||
case HeapTupleSelfUpdated:
|
||||
ReleaseBuffer(buffer);
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
|
||||
case HeapTupleMayBeUpdated:
|
||||
break;
|
||||
@@ -835,9 +835,9 @@ ltrmark:;
|
||||
elog(ERROR, "Can't serialize access due to concurrent update");
|
||||
else if (!(ItemPointerEquals(&(tuple.t_self), tid)))
|
||||
{
|
||||
TupleTableSlot *epqslot = EvalPlanQual(estate,
|
||||
estate->es_result_relation_info->ri_RangeTableIndex,
|
||||
&(tuple.t_self));
|
||||
TupleTableSlot *epqslot = EvalPlanQual(estate,
|
||||
estate->es_result_relation_info->ri_RangeTableIndex,
|
||||
&(tuple.t_self));
|
||||
|
||||
if (!(TupIsNull(epqslot)))
|
||||
{
|
||||
@@ -846,23 +846,23 @@ ltrmark:;
|
||||
goto ltrmark;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if tuple was deleted or PlanQual failed
|
||||
* for updated tuple - we have not process
|
||||
* this tuple!
|
||||
|
||||
/*
|
||||
* if tuple was deleted or PlanQual failed for updated
|
||||
* tuple - we have not process this tuple!
|
||||
*/
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
|
||||
default:
|
||||
ReleaseBuffer(buffer);
|
||||
elog(ERROR, "Unknown status %u from heap_mark4update", test);
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PageHeader dp;
|
||||
ItemId lp;
|
||||
PageHeader dp;
|
||||
ItemId lp;
|
||||
|
||||
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
|
||||
|
||||
|
@@ -5,11 +5,11 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: user.c,v 1.27 1999/04/02 06:16:36 tgl Exp $
|
||||
* $Id: user.c,v 1.28 1999/05/25 16:08:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
static void CheckPgUserAclNotNull(void);
|
||||
|
||||
#define SQL_LENGTH 512
|
||||
#define SQL_LENGTH 512
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* UpdatePgPwdFile
|
||||
@@ -49,9 +49,9 @@ void
|
||||
UpdatePgPwdFile(char *sql, CommandDest dest)
|
||||
{
|
||||
|
||||
char *filename,
|
||||
*tempname;
|
||||
int bufsize;
|
||||
char *filename,
|
||||
*tempname;
|
||||
int bufsize;
|
||||
|
||||
/*
|
||||
* Create a temporary filename to be renamed later. This prevents the
|
||||
@@ -68,9 +68,9 @@ UpdatePgPwdFile(char *sql, CommandDest dest)
|
||||
* SEPCHAR character as the delimiter between fields. Then rename the
|
||||
* file to its final name.
|
||||
*/
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
"copy %s to '%s' using delimiters %s",
|
||||
ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
"copy %s to '%s' using delimiters %s",
|
||||
ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
|
||||
pg_exec_query_dest(sql, dest, false);
|
||||
rename(tempname, filename);
|
||||
pfree((void *) tempname);
|
||||
@@ -94,19 +94,19 @@ UpdatePgPwdFile(char *sql, CommandDest dest)
|
||||
void
|
||||
DefineUser(CreateUserStmt *stmt, CommandDest dest)
|
||||
{
|
||||
char *pg_shadow,
|
||||
sql[SQL_LENGTH];
|
||||
Relation pg_shadow_rel;
|
||||
TupleDesc pg_shadow_dsc;
|
||||
HeapScanDesc scan;
|
||||
HeapTuple tuple;
|
||||
Datum datum;
|
||||
bool exists = false,
|
||||
n,
|
||||
inblock,
|
||||
havepassword,
|
||||
havevaluntil;
|
||||
int max_id = -1;
|
||||
char *pg_shadow,
|
||||
sql[SQL_LENGTH];
|
||||
Relation pg_shadow_rel;
|
||||
TupleDesc pg_shadow_dsc;
|
||||
HeapScanDesc scan;
|
||||
HeapTuple tuple;
|
||||
Datum datum;
|
||||
bool exists = false,
|
||||
n,
|
||||
inblock,
|
||||
havepassword,
|
||||
havevaluntil;
|
||||
int max_id = -1;
|
||||
|
||||
havepassword = stmt->password && stmt->password[0];
|
||||
havevaluntil = stmt->validUntil && stmt->validUntil[0];
|
||||
@@ -161,21 +161,21 @@ DefineUser(CreateUserStmt *stmt, CommandDest dest)
|
||||
UnlockRelation(pg_shadow_rel, AccessExclusiveLock);
|
||||
heap_close(pg_shadow_rel);
|
||||
UserAbortTransactionBlock();
|
||||
elog(ERROR,
|
||||
"defineUser: user \"%s\" has already been created", stmt->user);
|
||||
elog(ERROR,
|
||||
"defineUser: user \"%s\" has already been created", stmt->user);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build the insert statement to be executed.
|
||||
*
|
||||
* XXX Ugly as this code is, it still fails to cope with ' or \
|
||||
* in any of the provided strings.
|
||||
* XXX Ugly as this code is, it still fails to cope with ' or \ in any of
|
||||
* the provided strings.
|
||||
*/
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
"insert into %s (usename,usesysid,usecreatedb,usetrace,"
|
||||
"usesuper,usecatupd,passwd,valuntil) "
|
||||
"values('%s',%d,'%c','t','%c','t',%s%s%s,%s%s%s)",
|
||||
"values('%s',%d,'%c','t','%c','t',%s%s%s,%s%s%s)",
|
||||
ShadowRelationName,
|
||||
stmt->user,
|
||||
max_id + 1,
|
||||
@@ -216,12 +216,12 @@ extern void
|
||||
AlterUser(AlterUserStmt *stmt, CommandDest dest)
|
||||
{
|
||||
|
||||
char *pg_shadow,
|
||||
sql[SQL_LENGTH];
|
||||
char *pg_shadow,
|
||||
sql[SQL_LENGTH];
|
||||
Relation pg_shadow_rel;
|
||||
TupleDesc pg_shadow_dsc;
|
||||
HeapTuple tuple;
|
||||
bool inblock;
|
||||
bool inblock;
|
||||
|
||||
if (stmt->password)
|
||||
CheckPgUserAclNotNull();
|
||||
@@ -272,34 +272,32 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest)
|
||||
snprintf(sql, SQL_LENGTH, "update %s set", ShadowRelationName);
|
||||
|
||||
if (stmt->password)
|
||||
{
|
||||
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password);
|
||||
}
|
||||
|
||||
if (stmt->createdb)
|
||||
{
|
||||
snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'",
|
||||
pstrdup(sql), stmt->password ? "," : "",
|
||||
*stmt->createdb ? "t" : "f");
|
||||
pstrdup(sql), stmt->password ? "," : "",
|
||||
*stmt->createdb ? "t" : "f");
|
||||
}
|
||||
|
||||
if (stmt->createuser)
|
||||
{
|
||||
snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
|
||||
pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "",
|
||||
*stmt->createuser ? "t" : "f");
|
||||
pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "",
|
||||
*stmt->createuser ? "t" : "f");
|
||||
}
|
||||
|
||||
if (stmt->validUntil)
|
||||
{
|
||||
snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
|
||||
pstrdup(sql),
|
||||
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
|
||||
stmt->validUntil);
|
||||
pstrdup(sql),
|
||||
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
|
||||
stmt->validUntil);
|
||||
}
|
||||
|
||||
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'",
|
||||
pstrdup(sql), stmt->user);
|
||||
pstrdup(sql), stmt->user);
|
||||
|
||||
pg_exec_query_dest(sql, dest, false);
|
||||
|
||||
@@ -393,8 +391,8 @@ RemoveUser(char *user, CommandDest dest)
|
||||
datum = heap_getattr(tuple, Anum_pg_database_datname, pg_dsc, &n);
|
||||
if (memcmp((void *) datum, "template1", 9))
|
||||
{
|
||||
dbase =
|
||||
(char **) repalloc((void *) dbase, sizeof(char *) * (ndbase + 1));
|
||||
dbase =
|
||||
(char **) repalloc((void *) dbase, sizeof(char *) * (ndbase + 1));
|
||||
dbase[ndbase] = (char *) palloc(NAMEDATALEN + 1);
|
||||
memcpy((void *) dbase[ndbase], (void *) datum, NAMEDATALEN);
|
||||
dbase[ndbase++][NAMEDATALEN] = '\0';
|
||||
@@ -435,8 +433,8 @@ RemoveUser(char *user, CommandDest dest)
|
||||
/*
|
||||
* Remove the user from the pg_shadow table
|
||||
*/
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
"delete from %s where usename = '%s'", ShadowRelationName, user);
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
"delete from %s where usename = '%s'", ShadowRelationName, user);
|
||||
pg_exec_query_dest(sql, dest, false);
|
||||
|
||||
UpdatePgPwdFile(sql, dest);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.103 1999/05/23 09:10:24 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.104 1999/05/25 16:08:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ static Portal vc_portal;
|
||||
|
||||
static int MESSAGE_LEVEL; /* message level */
|
||||
|
||||
static TransactionId XmaxRecent;
|
||||
static TransactionId XmaxRecent;
|
||||
|
||||
#define swapLong(a,b) {long tmp; tmp=a; a=b; b=tmp;}
|
||||
#define swapInt(a,b) {int tmp; tmp=a; a=b; b=tmp;}
|
||||
@@ -101,8 +101,8 @@ static void vc_free(VRelList vrl);
|
||||
static void vc_getindices(Oid relid, int *nindices, Relation **Irel);
|
||||
static void vc_clsindices(int nindices, Relation *Irel);
|
||||
static void vc_mkindesc(Relation onerel, int nindices, Relation *Irel, IndDesc **Idesc);
|
||||
static void *vc_find_eq(void *bot, int nelem, int size, void *elm,
|
||||
int (*compar) (const void *, const void *));
|
||||
static void *vc_find_eq(void *bot, int nelem, int size, void *elm,
|
||||
int (*compar) (const void *, const void *));
|
||||
static int vc_cmp_blk(const void *left, const void *right);
|
||||
static int vc_cmp_offno(const void *left, const void *right);
|
||||
static int vc_cmp_vtlinks(const void *left, const void *right);
|
||||
@@ -222,14 +222,15 @@ vc_shutdown()
|
||||
{
|
||||
/* on entry, we are not in a transaction */
|
||||
|
||||
/* Flush the init file that relcache.c uses to save startup time.
|
||||
* The next backend startup will rebuild the init file with up-to-date
|
||||
* information from pg_class. This lets the optimizer see the stats that
|
||||
* we've collected for certain critical system indexes. See relcache.c
|
||||
* for more details.
|
||||
/*
|
||||
* Flush the init file that relcache.c uses to save startup time. The
|
||||
* next backend startup will rebuild the init file with up-to-date
|
||||
* information from pg_class. This lets the optimizer see the stats
|
||||
* that we've collected for certain critical system indexes. See
|
||||
* relcache.c for more details.
|
||||
*
|
||||
* Ignore any failure to unlink the file, since it might not be there
|
||||
* if no backend has been started since the last vacuum...
|
||||
* Ignore any failure to unlink the file, since it might not be there if
|
||||
* no backend has been started since the last vacuum...
|
||||
*/
|
||||
unlink(RELCACHE_INIT_FILENAME);
|
||||
|
||||
@@ -578,7 +579,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
|
||||
|
||||
/* update statistics in pg_class */
|
||||
vc_updstats(vacrelstats->relid, vacrelstats->num_pages,
|
||||
vacrelstats->num_tuples, vacrelstats->hasindex, vacrelstats);
|
||||
vacrelstats->num_tuples, vacrelstats->hasindex, vacrelstats);
|
||||
|
||||
/* next command frees attribute stats */
|
||||
CommitTransactionCommand();
|
||||
@@ -601,7 +602,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
blkno;
|
||||
ItemId itemid;
|
||||
Buffer buf;
|
||||
HeapTupleData tuple;
|
||||
HeapTupleData tuple;
|
||||
Page page,
|
||||
tempPage = NULL;
|
||||
OffsetNumber offnum,
|
||||
@@ -712,7 +713,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
else if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (TransactionIdDidCommit((TransactionId)
|
||||
tuple.t_data->t_cmin))
|
||||
tuple.t_data->t_cmin))
|
||||
{
|
||||
tuple.t_data->t_infomask |= HEAP_XMIN_INVALID;
|
||||
tupgone = true;
|
||||
@@ -759,7 +760,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
else
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
|
||||
relname, blkno, offnum, tuple.t_data->t_xmin);
|
||||
relname, blkno, offnum, tuple.t_data->t_xmin);
|
||||
do_shrinking = false;
|
||||
}
|
||||
}
|
||||
@@ -799,6 +800,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
}
|
||||
else if (!TransactionIdIsInProgress(tuple.t_data->t_xmax))
|
||||
{
|
||||
|
||||
/*
|
||||
* Not Aborted, Not Committed, Not in Progress - so it
|
||||
* from crashed process. - vadim 06/02/97
|
||||
@@ -812,11 +814,12 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
relname, blkno, offnum, tuple.t_data->t_xmax);
|
||||
do_shrinking = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* If tuple is recently deleted then
|
||||
* we must not remove it from relation.
|
||||
* If tuple is recently deleted then we must not remove it
|
||||
* from relation.
|
||||
*/
|
||||
if (tupgone && tuple.t_data->t_xmax >= XmaxRecent &&
|
||||
if (tupgone && tuple.t_data->t_xmax >= XmaxRecent &&
|
||||
tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)
|
||||
{
|
||||
tupgone = false;
|
||||
@@ -826,20 +829,21 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
tuple.t_data->t_infomask |= HEAP_XMAX_COMMITTED;
|
||||
pgchanged = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we do shrinking and this tuple is updated one
|
||||
* then remember it to construct updated tuple
|
||||
* dependencies.
|
||||
*/
|
||||
if (do_shrinking && !(ItemPointerEquals(&(tuple.t_self),
|
||||
&(tuple.t_data->t_ctid))))
|
||||
if (do_shrinking && !(ItemPointerEquals(&(tuple.t_self),
|
||||
&(tuple.t_data->t_ctid))))
|
||||
{
|
||||
if (free_vtlinks == 0)
|
||||
{
|
||||
free_vtlinks = 1000;
|
||||
vtlinks = (VTupleLink) repalloc(vtlinks,
|
||||
(free_vtlinks + num_vtlinks) *
|
||||
sizeof(VTupleLinkData));
|
||||
vtlinks = (VTupleLink) repalloc(vtlinks,
|
||||
(free_vtlinks + num_vtlinks) *
|
||||
sizeof(VTupleLinkData));
|
||||
}
|
||||
vtlinks[num_vtlinks].new_tid = tuple.t_data->t_ctid;
|
||||
vtlinks[num_vtlinks].this_tid = tuple.t_self;
|
||||
@@ -962,8 +966,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
|
||||
if (usable_free_size > 0 && num_vtlinks > 0)
|
||||
{
|
||||
qsort((char *) vtlinks, num_vtlinks, sizeof (VTupleLinkData),
|
||||
vc_cmp_vtlinks);
|
||||
qsort((char *) vtlinks, num_vtlinks, sizeof(VTupleLinkData),
|
||||
vc_cmp_vtlinks);
|
||||
vacrelstats->vtlinks = vtlinks;
|
||||
vacrelstats->num_vtlinks = num_vtlinks;
|
||||
}
|
||||
@@ -980,10 +984,10 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
Tup %u: Vac %u, Keep/VTL %u/%u, Crash %u, UnUsed %u, MinLen %u, MaxLen %u; \
|
||||
Re-using: Free/Avail. Space %u/%u; EndEmpty/Avail. Pages %u/%u. \
|
||||
Elapsed %u/%u sec.",
|
||||
nblocks, changed_pages, vacuum_pages->vpl_num_pages, empty_pages,
|
||||
new_pages, num_tuples, tups_vacuumed,
|
||||
nkeep, vacrelstats->num_vtlinks, ncrash,
|
||||
nunused, min_tlen, max_tlen, free_size, usable_free_size,
|
||||
nblocks, changed_pages, vacuum_pages->vpl_num_pages, empty_pages,
|
||||
new_pages, num_tuples, tups_vacuumed,
|
||||
nkeep, vacrelstats->num_vtlinks, ncrash,
|
||||
nunused, min_tlen, max_tlen, free_size, usable_free_size,
|
||||
empty_end_pages, fraged_pages->vpl_num_pages,
|
||||
ru1.ru_stime.tv_sec - ru0.ru_stime.tv_sec,
|
||||
ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec);
|
||||
@@ -1019,8 +1023,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
max_offset;
|
||||
ItemId itemid,
|
||||
newitemid;
|
||||
HeapTupleData tuple,
|
||||
newtup;
|
||||
HeapTupleData tuple,
|
||||
newtup;
|
||||
TupleDesc tupdesc = NULL;
|
||||
Datum *idatum = NULL;
|
||||
char *inulls = NULL;
|
||||
@@ -1128,7 +1132,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
else
|
||||
Assert(!isempty);
|
||||
|
||||
chain_tuple_moved = false; /* no one chain-tuple was moved off this page, yet */
|
||||
chain_tuple_moved = false; /* no one chain-tuple was moved
|
||||
* off this page, yet */
|
||||
vpc->vpd_blkno = blkno;
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
for (offnum = FirstOffsetNumber;
|
||||
@@ -1146,28 +1151,30 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
|
||||
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if ((TransactionId)tuple.t_data->t_cmin != myXID)
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
|
||||
elog(ERROR, "HEAP_MOVED_IN was not expected");
|
||||
/*
|
||||
* If this (chain) tuple is moved by me already then
|
||||
* I have to check is it in vpc or not - i.e. is it
|
||||
* moved while cleaning this page or some previous one.
|
||||
|
||||
/*
|
||||
* If this (chain) tuple is moved by me already then I
|
||||
* have to check is it in vpc or not - i.e. is it moved
|
||||
* while cleaning this page or some previous one.
|
||||
*/
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (keep_tuples == 0)
|
||||
continue;
|
||||
if (chain_tuple_moved) /* some chains was moved while */
|
||||
{ /* cleaning this page */
|
||||
if (chain_tuple_moved) /* some chains was moved
|
||||
* while */
|
||||
{ /* cleaning this page */
|
||||
Assert(vpc->vpd_offsets_free > 0);
|
||||
for (i = 0; i < vpc->vpd_offsets_free; i++)
|
||||
{
|
||||
if (vpc->vpd_offsets[i] == offnum)
|
||||
break;
|
||||
}
|
||||
if (i >= vpc->vpd_offsets_free) /* not found */
|
||||
if (i >= vpc->vpd_offsets_free) /* not found */
|
||||
{
|
||||
vpc->vpd_offsets[vpc->vpd_offsets_free++] = offnum;
|
||||
keep_tuples--;
|
||||
@@ -1184,29 +1191,29 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
}
|
||||
|
||||
/*
|
||||
* If this tuple is in the chain of tuples created in
|
||||
* updates by "recent" transactions then we have to
|
||||
* move all chain of tuples to another places.
|
||||
* If this tuple is in the chain of tuples created in updates
|
||||
* by "recent" transactions then we have to move all chain of
|
||||
* tuples to another places.
|
||||
*/
|
||||
if ((tuple.t_data->t_infomask & HEAP_UPDATED &&
|
||||
if ((tuple.t_data->t_infomask & HEAP_UPDATED &&
|
||||
tuple.t_data->t_xmin >= XmaxRecent) ||
|
||||
(!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) &&
|
||||
(!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) &&
|
||||
!(ItemPointerEquals(&(tuple.t_self), &(tuple.t_data->t_ctid)))))
|
||||
{
|
||||
Buffer Cbuf = buf;
|
||||
Page Cpage;
|
||||
ItemId Citemid;
|
||||
ItemPointerData Ctid;
|
||||
HeapTupleData tp = tuple;
|
||||
Size tlen = tuple_len;
|
||||
VTupleMove vtmove = (VTupleMove)
|
||||
palloc(100 * sizeof(VTupleMoveData));
|
||||
int num_vtmove = 0;
|
||||
int free_vtmove = 100;
|
||||
VPageDescr to_vpd = fraged_pages->vpl_pagedesc[0];
|
||||
int to_item = 0;
|
||||
bool freeCbuf = false;
|
||||
int ti;
|
||||
Buffer Cbuf = buf;
|
||||
Page Cpage;
|
||||
ItemId Citemid;
|
||||
ItemPointerData Ctid;
|
||||
HeapTupleData tp = tuple;
|
||||
Size tlen = tuple_len;
|
||||
VTupleMove vtmove = (VTupleMove)
|
||||
palloc(100 * sizeof(VTupleMoveData));
|
||||
int num_vtmove = 0;
|
||||
int free_vtmove = 100;
|
||||
VPageDescr to_vpd = fraged_pages->vpl_pagedesc[0];
|
||||
int to_item = 0;
|
||||
bool freeCbuf = false;
|
||||
int ti;
|
||||
|
||||
if (vacrelstats->vtlinks == NULL)
|
||||
elog(ERROR, "No one parent tuple was found");
|
||||
@@ -1215,22 +1222,23 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
WriteBuffer(cur_buffer);
|
||||
cur_buffer = InvalidBuffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this tuple is in the begin/middle of the chain
|
||||
* then we have to move to the end of chain.
|
||||
* If this tuple is in the begin/middle of the chain then
|
||||
* we have to move to the end of chain.
|
||||
*/
|
||||
while (!(tp.t_data->t_infomask & HEAP_XMAX_INVALID) &&
|
||||
!(ItemPointerEquals(&(tp.t_self), &(tp.t_data->t_ctid))))
|
||||
while (!(tp.t_data->t_infomask & HEAP_XMAX_INVALID) &&
|
||||
!(ItemPointerEquals(&(tp.t_self), &(tp.t_data->t_ctid))))
|
||||
{
|
||||
Ctid = tp.t_data->t_ctid;
|
||||
if (freeCbuf)
|
||||
ReleaseBuffer(Cbuf);
|
||||
freeCbuf = true;
|
||||
Cbuf = ReadBuffer(onerel,
|
||||
ItemPointerGetBlockNumber(&Ctid));
|
||||
Cbuf = ReadBuffer(onerel,
|
||||
ItemPointerGetBlockNumber(&Ctid));
|
||||
Cpage = BufferGetPage(Cbuf);
|
||||
Citemid = PageGetItemId(Cpage,
|
||||
ItemPointerGetOffsetNumber(&Ctid));
|
||||
Citemid = PageGetItemId(Cpage,
|
||||
ItemPointerGetOffsetNumber(&Ctid));
|
||||
if (!ItemIdIsUsed(Citemid))
|
||||
elog(ERROR, "Child itemid marked as unused");
|
||||
tp.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
|
||||
@@ -1238,16 +1246,16 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
tlen = tp.t_len = ItemIdGetLength(Citemid);
|
||||
}
|
||||
/* first, can chain be moved ? */
|
||||
for ( ; ; )
|
||||
for (;;)
|
||||
{
|
||||
if (!vc_enough_space(to_vpd, tlen))
|
||||
{
|
||||
if (to_vpd != last_fraged_page &&
|
||||
!vc_enough_space(to_vpd, vacrelstats->min_tlen))
|
||||
!vc_enough_space(to_vpd, vacrelstats->min_tlen))
|
||||
{
|
||||
Assert(num_fraged_pages > to_item + 1);
|
||||
memmove(fraged_pages->vpl_pagedesc + to_item,
|
||||
fraged_pages->vpl_pagedesc + to_item + 1,
|
||||
fraged_pages->vpl_pagedesc + to_item + 1,
|
||||
sizeof(VPageDescr *) * (num_fraged_pages - to_item - 1));
|
||||
num_fraged_pages--;
|
||||
Assert(last_fraged_page == fraged_pages->vpl_pagedesc[num_fraged_pages - 1]);
|
||||
@@ -1257,7 +1265,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
if (vc_enough_space(fraged_pages->vpl_pagedesc[i], tlen))
|
||||
break;
|
||||
}
|
||||
if (i == num_fraged_pages) /* can't move item anywhere */
|
||||
if (i == num_fraged_pages) /* can't move item
|
||||
* anywhere */
|
||||
{
|
||||
for (i = 0; i < num_vtmove; i++)
|
||||
{
|
||||
@@ -1277,9 +1286,9 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
if (free_vtmove == 0)
|
||||
{
|
||||
free_vtmove = 1000;
|
||||
vtmove = (VTupleMove) repalloc(vtmove,
|
||||
(free_vtmove + num_vtmove) *
|
||||
sizeof(VTupleMoveData));
|
||||
vtmove = (VTupleMove) repalloc(vtmove,
|
||||
(free_vtmove + num_vtmove) *
|
||||
sizeof(VTupleMoveData));
|
||||
}
|
||||
vtmove[num_vtmove].tid = tp.t_self;
|
||||
vtmove[num_vtmove].vpd = to_vpd;
|
||||
@@ -1289,56 +1298,59 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
vtmove[num_vtmove].cleanVpd = false;
|
||||
free_vtmove--;
|
||||
num_vtmove++;
|
||||
|
||||
/*
|
||||
* All done ?
|
||||
*/
|
||||
if (!(tp.t_data->t_infomask & HEAP_UPDATED) ||
|
||||
tp.t_data->t_xmin < XmaxRecent)
|
||||
if (!(tp.t_data->t_infomask & HEAP_UPDATED) ||
|
||||
tp.t_data->t_xmin < XmaxRecent)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Well, try to find tuple with old row version
|
||||
*/
|
||||
for ( ; ; )
|
||||
for (;;)
|
||||
{
|
||||
Buffer Pbuf;
|
||||
Page Ppage;
|
||||
ItemId Pitemid;
|
||||
HeapTupleData Ptp;
|
||||
VTupleLinkData vtld,
|
||||
*vtlp;
|
||||
Buffer Pbuf;
|
||||
Page Ppage;
|
||||
ItemId Pitemid;
|
||||
HeapTupleData Ptp;
|
||||
VTupleLinkData vtld,
|
||||
*vtlp;
|
||||
|
||||
vtld.new_tid = tp.t_self;
|
||||
vtlp = (VTupleLink)
|
||||
vc_find_eq((void *) (vacrelstats->vtlinks),
|
||||
vacrelstats->num_vtlinks,
|
||||
sizeof(VTupleLinkData),
|
||||
(void *) &vtld,
|
||||
vc_cmp_vtlinks);
|
||||
vtlp = (VTupleLink)
|
||||
vc_find_eq((void *) (vacrelstats->vtlinks),
|
||||
vacrelstats->num_vtlinks,
|
||||
sizeof(VTupleLinkData),
|
||||
(void *) &vtld,
|
||||
vc_cmp_vtlinks);
|
||||
if (vtlp == NULL)
|
||||
elog(ERROR, "Parent tuple was not found");
|
||||
tp.t_self = vtlp->this_tid;
|
||||
Pbuf = ReadBuffer(onerel,
|
||||
Pbuf = ReadBuffer(onerel,
|
||||
ItemPointerGetBlockNumber(&(tp.t_self)));
|
||||
Ppage = BufferGetPage(Pbuf);
|
||||
Pitemid = PageGetItemId(Ppage,
|
||||
ItemPointerGetOffsetNumber(&(tp.t_self)));
|
||||
Pitemid = PageGetItemId(Ppage,
|
||||
ItemPointerGetOffsetNumber(&(tp.t_self)));
|
||||
if (!ItemIdIsUsed(Pitemid))
|
||||
elog(ERROR, "Parent itemid marked as unused");
|
||||
Ptp.t_data = (HeapTupleHeader) PageGetItem(Ppage, Pitemid);
|
||||
Assert(Ptp.t_data->t_xmax == tp.t_data->t_xmin);
|
||||
|
||||
/*
|
||||
* If this tuple is updated version of row and
|
||||
* it was created by the same transaction then
|
||||
* no one is interested in this tuple -
|
||||
* mark it as removed.
|
||||
* If this tuple is updated version of row and it
|
||||
* was created by the same transaction then no one
|
||||
* is interested in this tuple - mark it as
|
||||
* removed.
|
||||
*/
|
||||
if (Ptp.t_data->t_infomask & HEAP_UPDATED &&
|
||||
if (Ptp.t_data->t_infomask & HEAP_UPDATED &&
|
||||
Ptp.t_data->t_xmin == Ptp.t_data->t_xmax)
|
||||
{
|
||||
TransactionIdStore(myXID,
|
||||
(TransactionId*) &(Ptp.t_data->t_cmin));
|
||||
Ptp.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN);
|
||||
TransactionIdStore(myXID,
|
||||
(TransactionId *) &(Ptp.t_data->t_cmin));
|
||||
Ptp.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
|
||||
Ptp.t_data->t_infomask |= HEAP_MOVED_OFF;
|
||||
WriteBuffer(Pbuf);
|
||||
continue;
|
||||
@@ -1354,7 +1366,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
}
|
||||
if (freeCbuf)
|
||||
ReleaseBuffer(Cbuf);
|
||||
if (num_vtmove == 0) /* chain can't be moved */
|
||||
if (num_vtmove == 0) /* chain can't be moved */
|
||||
{
|
||||
pfree(vtmove);
|
||||
break;
|
||||
@@ -1364,19 +1376,20 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
{
|
||||
/* Get tuple from chain */
|
||||
tuple.t_self = vtmove[ti].tid;
|
||||
Cbuf = ReadBuffer(onerel,
|
||||
ItemPointerGetBlockNumber(&(tuple.t_self)));
|
||||
Cbuf = ReadBuffer(onerel,
|
||||
ItemPointerGetBlockNumber(&(tuple.t_self)));
|
||||
Cpage = BufferGetPage(Cbuf);
|
||||
Citemid = PageGetItemId(Cpage,
|
||||
Citemid = PageGetItemId(Cpage,
|
||||
ItemPointerGetOffsetNumber(&(tuple.t_self)));
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
|
||||
tuple_len = tuple.t_len = ItemIdGetLength(Citemid);
|
||||
/* Get page to move in */
|
||||
cur_buffer = ReadBuffer(onerel, vtmove[ti].vpd->vpd_blkno);
|
||||
|
||||
/*
|
||||
* We should LockBuffer(cur_buffer) but don't, at the
|
||||
* moment. If you'll do LockBuffer then UNLOCK it
|
||||
* before index_insert: unique btree-s call heap_fetch
|
||||
* We should LockBuffer(cur_buffer) but don't, at the
|
||||
* moment. If you'll do LockBuffer then UNLOCK it
|
||||
* before index_insert: unique btree-s call heap_fetch
|
||||
* to get t_infomask of inserted heap tuple !!!
|
||||
*/
|
||||
ToPage = BufferGetPage(cur_buffer);
|
||||
@@ -1385,22 +1398,23 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
vc_vacpage(ToPage, vtmove[ti].vpd);
|
||||
heap_copytuple_with_tuple(&tuple, &newtup);
|
||||
RelationInvalidateHeapTuple(onerel, &tuple);
|
||||
TransactionIdStore(myXID, (TransactionId*) &(newtup.t_data->t_cmin));
|
||||
newtup.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_OFF);
|
||||
TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin));
|
||||
newtup.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
|
||||
newtup.t_data->t_infomask |= HEAP_MOVED_IN;
|
||||
newoff = PageAddItem(ToPage, (Item) newtup.t_data, tuple_len,
|
||||
InvalidOffsetNumber, LP_USED);
|
||||
InvalidOffsetNumber, LP_USED);
|
||||
if (newoff == InvalidOffsetNumber)
|
||||
{
|
||||
elog(ERROR, "\
|
||||
moving chain: failed to add item with len = %u to page %u",
|
||||
tuple_len, vtmove[ti].vpd->vpd_blkno);
|
||||
tuple_len, vtmove[ti].vpd->vpd_blkno);
|
||||
}
|
||||
newitemid = PageGetItemId(ToPage, newoff);
|
||||
pfree(newtup.t_data);
|
||||
newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
|
||||
ItemPointerSet(&(newtup.t_self), vtmove[ti].vpd->vpd_blkno, newoff);
|
||||
|
||||
/*
|
||||
* Set t_ctid pointing to itself for last tuple in
|
||||
* chain and to next tuple in chain otherwise.
|
||||
@@ -1411,19 +1425,20 @@ moving chain: failed to add item with len = %u to page %u",
|
||||
newtup.t_data->t_ctid = Ctid;
|
||||
Ctid = newtup.t_self;
|
||||
|
||||
TransactionIdStore(myXID, (TransactionId*) &(tuple.t_data->t_cmin));
|
||||
tuple.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN);
|
||||
TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin));
|
||||
tuple.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
|
||||
tuple.t_data->t_infomask |= HEAP_MOVED_OFF;
|
||||
|
||||
num_moved++;
|
||||
|
||||
/*
|
||||
* Remember that we moved tuple from the current page
|
||||
* (corresponding index tuple will be cleaned).
|
||||
*/
|
||||
if (Cbuf == buf)
|
||||
vpc->vpd_offsets[vpc->vpd_offsets_free++] =
|
||||
ItemPointerGetOffsetNumber(&(tuple.t_self));
|
||||
vpc->vpd_offsets[vpc->vpd_offsets_free++] =
|
||||
ItemPointerGetOffsetNumber(&(tuple.t_self));
|
||||
else
|
||||
keep_tuples++;
|
||||
|
||||
@@ -1432,12 +1447,12 @@ moving chain: failed to add item with len = %u to page %u",
|
||||
for (i = 0, idcur = Idesc; i < nindices; i++, idcur++)
|
||||
{
|
||||
FormIndexDatum(idcur->natts,
|
||||
(AttrNumber *) &(idcur->tform->indkey[0]),
|
||||
&newtup,
|
||||
tupdesc,
|
||||
idatum,
|
||||
inulls,
|
||||
idcur->finfoP);
|
||||
(AttrNumber *) &(idcur->tform->indkey[0]),
|
||||
&newtup,
|
||||
tupdesc,
|
||||
idatum,
|
||||
inulls,
|
||||
idcur->finfoP);
|
||||
iresult = index_insert(Irel[i],
|
||||
idatum,
|
||||
inulls,
|
||||
@@ -1507,13 +1522,13 @@ moving chain: failed to add item with len = %u to page %u",
|
||||
|
||||
RelationInvalidateHeapTuple(onerel, &tuple);
|
||||
|
||||
/*
|
||||
* Mark new tuple as moved_in by vacuum and
|
||||
* store vacuum XID in t_cmin !!!
|
||||
/*
|
||||
* Mark new tuple as moved_in by vacuum and store vacuum XID
|
||||
* in t_cmin !!!
|
||||
*/
|
||||
TransactionIdStore(myXID, (TransactionId*) &(newtup.t_data->t_cmin));
|
||||
newtup.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_OFF);
|
||||
TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin));
|
||||
newtup.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
|
||||
newtup.t_data->t_infomask |= HEAP_MOVED_IN;
|
||||
|
||||
/* add tuple to the page */
|
||||
@@ -1532,13 +1547,13 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff);
|
||||
newtup.t_self = newtup.t_data->t_ctid;
|
||||
|
||||
/*
|
||||
* Mark old tuple as moved_off by vacuum and
|
||||
* store vacuum XID in t_cmin !!!
|
||||
/*
|
||||
* Mark old tuple as moved_off by vacuum and store vacuum XID
|
||||
* in t_cmin !!!
|
||||
*/
|
||||
TransactionIdStore(myXID, (TransactionId*) &(tuple.t_data->t_cmin));
|
||||
tuple.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN);
|
||||
TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin));
|
||||
tuple.t_data->t_infomask &=
|
||||
~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
|
||||
tuple.t_data->t_infomask |= HEAP_MOVED_OFF;
|
||||
|
||||
cur_page->vpd_offsets_used++;
|
||||
@@ -1572,11 +1587,11 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
|
||||
if (offnum < maxoff && keep_tuples > 0)
|
||||
{
|
||||
OffsetNumber off;
|
||||
OffsetNumber off;
|
||||
|
||||
for (off = OffsetNumberNext(offnum);
|
||||
off <= maxoff;
|
||||
off = OffsetNumberNext(off))
|
||||
off <= maxoff;
|
||||
off = OffsetNumberNext(off))
|
||||
{
|
||||
itemid = PageGetItemId(page, off);
|
||||
if (!ItemIdIsUsed(itemid))
|
||||
@@ -1584,21 +1599,22 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)
|
||||
continue;
|
||||
if ((TransactionId)tuple.t_data->t_cmin != myXID)
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin (4)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
|
||||
elog(ERROR, "HEAP_MOVED_IN was not expected (2)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
if (chain_tuple_moved) /* some chains was moved while */
|
||||
{ /* cleaning this page */
|
||||
if (chain_tuple_moved) /* some chains was moved
|
||||
* while */
|
||||
{ /* cleaning this page */
|
||||
Assert(vpc->vpd_offsets_free > 0);
|
||||
for (i = 0; i < vpc->vpd_offsets_free; i++)
|
||||
{
|
||||
if (vpc->vpd_offsets[i] == off)
|
||||
break;
|
||||
}
|
||||
if (i >= vpc->vpd_offsets_free) /* not found */
|
||||
if (i >= vpc->vpd_offsets_free) /* not found */
|
||||
{
|
||||
vpc->vpd_offsets[vpc->vpd_offsets_free++] = off;
|
||||
Assert(keep_tuples > 0);
|
||||
@@ -1619,8 +1635,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
{
|
||||
if (chain_tuple_moved) /* else - they are ordered */
|
||||
{
|
||||
qsort((char *) (vpc->vpd_offsets), vpc->vpd_offsets_free,
|
||||
sizeof(OffsetNumber), vc_cmp_offno);
|
||||
qsort((char *) (vpc->vpd_offsets), vpc->vpd_offsets_free,
|
||||
sizeof(OffsetNumber), vc_cmp_offno);
|
||||
}
|
||||
vc_reappage(&Nvpl, vpc);
|
||||
WriteBuffer(buf);
|
||||
@@ -1645,6 +1661,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
|
||||
if (num_moved > 0)
|
||||
{
|
||||
|
||||
/*
|
||||
* We have to commit our tuple' movings before we'll truncate
|
||||
* relation, but we shouldn't lose our locks. And so - quick hack:
|
||||
@@ -1657,8 +1674,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean uncleaned reapped pages from vacuum_pages list list and set xmin
|
||||
* committed for inserted tuples
|
||||
* Clean uncleaned reapped pages from vacuum_pages list list and set
|
||||
* xmin committed for inserted tuples
|
||||
*/
|
||||
checked_moved = 0;
|
||||
for (i = 0, vpp = vacuum_pages->vpl_pagedesc; i < vacuumed_pages; i++, vpp++)
|
||||
@@ -1671,7 +1688,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
if (!PageIsEmpty(page))
|
||||
vc_vacpage(page, *vpp);
|
||||
}
|
||||
else /* this page was used */
|
||||
else
|
||||
/* this page was used */
|
||||
{
|
||||
num_tuples = 0;
|
||||
max_offset = PageGetMaxOffsetNumber(page);
|
||||
@@ -1685,7 +1703,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if ((TransactionId)tuple.t_data->t_cmin != myXID)
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin (2)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
|
||||
{
|
||||
@@ -1734,8 +1752,8 @@ Elapsed %u/%u sec.",
|
||||
}
|
||||
Assert(keep_tuples >= 0);
|
||||
for (i = 0; i < nindices; i++)
|
||||
vc_vaconeind(&Nvpl, Irel[i],
|
||||
vacrelstats->num_tuples, keep_tuples);
|
||||
vc_vaconeind(&Nvpl, Irel[i],
|
||||
vacrelstats->num_tuples, keep_tuples);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1757,7 +1775,7 @@ Elapsed %u/%u sec.",
|
||||
|
||||
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if ((TransactionId)tuple.t_data->t_cmin != myXID)
|
||||
if ((TransactionId) tuple.t_data->t_cmin != myXID)
|
||||
elog(ERROR, "Invalid XID in t_cmin (3)");
|
||||
if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
|
||||
{
|
||||
@@ -1998,7 +2016,7 @@ vc_vaconeind(VPageList vpl, Relation indrel, int num_tuples, int keep_tuples)
|
||||
getrusage(RUSAGE_SELF, &ru1);
|
||||
|
||||
elog(MESSAGE_LEVEL, "Index %s: Pages %u; Tuples %u: Deleted %u. Elapsed %u/%u sec.",
|
||||
indrel->rd_rel->relname.data, num_pages,
|
||||
indrel->rd_rel->relname.data, num_pages,
|
||||
num_index_tuples - keep_tuples, tups_vacuumed,
|
||||
ru1.ru_stime.tv_sec - ru0.ru_stime.tv_sec,
|
||||
ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec);
|
||||
@@ -2208,25 +2226,25 @@ vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_l
|
||||
static void
|
||||
vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
|
||||
{
|
||||
Relation rd,
|
||||
ad,
|
||||
sd;
|
||||
HeapScanDesc scan;
|
||||
HeapTupleData rtup;
|
||||
HeapTuple ctup,
|
||||
atup,
|
||||
stup;
|
||||
Form_pg_class pgcform;
|
||||
ScanKeyData askey;
|
||||
Form_pg_attribute attp;
|
||||
Buffer buffer;
|
||||
Relation rd,
|
||||
ad,
|
||||
sd;
|
||||
HeapScanDesc scan;
|
||||
HeapTupleData rtup;
|
||||
HeapTuple ctup,
|
||||
atup,
|
||||
stup;
|
||||
Form_pg_class pgcform;
|
||||
ScanKeyData askey;
|
||||
Form_pg_attribute attp;
|
||||
Buffer buffer;
|
||||
|
||||
/*
|
||||
* update number of tuples and number of pages in pg_class
|
||||
*/
|
||||
ctup = SearchSysCacheTupleCopy(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(ctup))
|
||||
elog(ERROR, "pg_class entry for relid %u vanished during vacuuming",
|
||||
relid);
|
||||
@@ -2237,7 +2255,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
rtup.t_self = ctup->t_self;
|
||||
heap_fetch(rd, SnapshotNow, &rtup, &buffer);
|
||||
pfree(ctup);
|
||||
|
||||
|
||||
/* overwrite the existing statistics in the tuple */
|
||||
vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self)));
|
||||
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
|
||||
@@ -2317,8 +2335,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
attp->attdisbursion = selratio;
|
||||
|
||||
/*
|
||||
* Invalidate the cache for the tuple
|
||||
* and write the buffer
|
||||
* Invalidate the cache for the tuple and write the buffer
|
||||
*/
|
||||
RelationInvalidateHeapTuple(ad, atup);
|
||||
WriteNoReleaseBuffer(abuffer);
|
||||
@@ -2375,8 +2392,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
}
|
||||
|
||||
/*
|
||||
* Invalidate the cached pg_class tuple and
|
||||
* write the buffer
|
||||
* Invalidate the cached pg_class tuple and write the buffer
|
||||
*/
|
||||
RelationInvalidateHeapTuple(rd, &rtup);
|
||||
|
||||
@@ -2504,8 +2520,8 @@ vc_free(VRelList vrl)
|
||||
}
|
||||
|
||||
static void *
|
||||
vc_find_eq(void *bot, int nelem, int size, void *elm,
|
||||
int (*compar) (const void *, const void *))
|
||||
vc_find_eq(void *bot, int nelem, int size, void *elm,
|
||||
int (*compar) (const void *, const void *))
|
||||
{
|
||||
int res;
|
||||
int last = nelem - 1;
|
||||
@@ -2527,16 +2543,16 @@ vc_find_eq(void *bot, int nelem, int size, void *elm,
|
||||
}
|
||||
if (last_move == true)
|
||||
{
|
||||
res = compar(elm, (void *)((char *)bot + last * size));
|
||||
res = compar(elm, (void *) ((char *) bot + last * size));
|
||||
if (res > 0)
|
||||
return NULL;
|
||||
if (res == 0)
|
||||
return (void *)((char *)bot + last * size);
|
||||
return (void *) ((char *) bot + last * size);
|
||||
last_move = false;
|
||||
}
|
||||
res = compar(elm, (void *)((char *)bot + celm * size));
|
||||
res = compar(elm, (void *) ((char *) bot + celm * size));
|
||||
if (res == 0)
|
||||
return (void *)((char *)bot + celm * size);
|
||||
return (void *) ((char *) bot + celm * size);
|
||||
if (res < 0)
|
||||
{
|
||||
if (celm == 0)
|
||||
@@ -2551,7 +2567,7 @@ vc_find_eq(void *bot, int nelem, int size, void *elm,
|
||||
return NULL;
|
||||
|
||||
last = last - celm - 1;
|
||||
bot = (void *)((char *)bot + (celm + 1) * size);
|
||||
bot = (void *) ((char *) bot + (celm + 1) * size);
|
||||
celm = (last + 1) / 2;
|
||||
first_move = true;
|
||||
}
|
||||
@@ -2591,25 +2607,25 @@ static int
|
||||
vc_cmp_vtlinks(const void *left, const void *right)
|
||||
{
|
||||
|
||||
if (((VTupleLink)left)->new_tid.ip_blkid.bi_hi <
|
||||
((VTupleLink)right)->new_tid.ip_blkid.bi_hi)
|
||||
if (((VTupleLink) left)->new_tid.ip_blkid.bi_hi <
|
||||
((VTupleLink) right)->new_tid.ip_blkid.bi_hi)
|
||||
return -1;
|
||||
if (((VTupleLink)left)->new_tid.ip_blkid.bi_hi >
|
||||
((VTupleLink)right)->new_tid.ip_blkid.bi_hi)
|
||||
if (((VTupleLink) left)->new_tid.ip_blkid.bi_hi >
|
||||
((VTupleLink) right)->new_tid.ip_blkid.bi_hi)
|
||||
return 1;
|
||||
/* bi_hi-es are equal */
|
||||
if (((VTupleLink)left)->new_tid.ip_blkid.bi_lo <
|
||||
((VTupleLink)right)->new_tid.ip_blkid.bi_lo)
|
||||
if (((VTupleLink) left)->new_tid.ip_blkid.bi_lo <
|
||||
((VTupleLink) right)->new_tid.ip_blkid.bi_lo)
|
||||
return -1;
|
||||
if (((VTupleLink)left)->new_tid.ip_blkid.bi_lo >
|
||||
((VTupleLink)right)->new_tid.ip_blkid.bi_lo)
|
||||
if (((VTupleLink) left)->new_tid.ip_blkid.bi_lo >
|
||||
((VTupleLink) right)->new_tid.ip_blkid.bi_lo)
|
||||
return 1;
|
||||
/* bi_lo-es are equal */
|
||||
if (((VTupleLink)left)->new_tid.ip_posid <
|
||||
((VTupleLink)right)->new_tid.ip_posid)
|
||||
if (((VTupleLink) left)->new_tid.ip_posid <
|
||||
((VTupleLink) right)->new_tid.ip_posid)
|
||||
return -1;
|
||||
if (((VTupleLink)left)->new_tid.ip_posid >
|
||||
((VTupleLink)right)->new_tid.ip_posid)
|
||||
if (((VTupleLink) left)->new_tid.ip_posid >
|
||||
((VTupleLink) right)->new_tid.ip_posid)
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* Routines for handling of 'SET var TO',
|
||||
* 'SHOW var' and 'RESET var' statements.
|
||||
*
|
||||
* $Id: variable.c,v 1.19 1999/02/18 06:00:44 momjian Exp $
|
||||
* $Id: variable.c,v 1.20 1999/05/25 16:08:28 momjian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -45,10 +45,12 @@ static bool parse_ksqo(const char *);
|
||||
static bool show_XactIsoLevel(void);
|
||||
static bool reset_XactIsoLevel(void);
|
||||
static bool parse_XactIsoLevel(const char *);
|
||||
|
||||
#ifdef QUERY_LIMIT
|
||||
static bool show_query_limit(void);
|
||||
static bool reset_query_limit(void);
|
||||
static bool parse_query_limit(const char *);
|
||||
|
||||
#endif
|
||||
|
||||
extern Cost _cpu_page_wight_;
|
||||
@@ -545,41 +547,41 @@ reset_timezone()
|
||||
static bool
|
||||
parse_query_limit(const char *value)
|
||||
{
|
||||
int32 limit;
|
||||
int32 limit;
|
||||
|
||||
if (value == NULL) {
|
||||
reset_query_limit();
|
||||
return(TRUE);
|
||||
}
|
||||
/* why is pg_atoi's arg not declared "const char *" ? */
|
||||
limit = pg_atoi((char *) value, sizeof(int32), '\0');
|
||||
if (limit <= -1) {
|
||||
elog(ERROR, "Bad value for # of query limit (%s)", value);
|
||||
}
|
||||
ExecutorLimit(limit);
|
||||
return(TRUE);
|
||||
if (value == NULL)
|
||||
{
|
||||
reset_query_limit();
|
||||
return (TRUE);
|
||||
}
|
||||
/* why is pg_atoi's arg not declared "const char *" ? */
|
||||
limit = pg_atoi((char *) value, sizeof(int32), '\0');
|
||||
if (limit <= -1)
|
||||
elog(ERROR, "Bad value for # of query limit (%s)", value);
|
||||
ExecutorLimit(limit);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static bool
|
||||
show_query_limit(void)
|
||||
{
|
||||
int limit;
|
||||
int limit;
|
||||
|
||||
limit = ExecutorGetLimit();
|
||||
if (limit == ALL_TUPLES) {
|
||||
elog(NOTICE, "No query limit is set");
|
||||
} else {
|
||||
elog(NOTICE, "query limit is %d",limit);
|
||||
}
|
||||
return(TRUE);
|
||||
limit = ExecutorGetLimit();
|
||||
if (limit == ALL_TUPLES)
|
||||
elog(NOTICE, "No query limit is set");
|
||||
else
|
||||
elog(NOTICE, "query limit is %d", limit);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static bool
|
||||
reset_query_limit(void)
|
||||
{
|
||||
ExecutorLimit(ALL_TUPLES);
|
||||
return(TRUE);
|
||||
ExecutorLimit(ALL_TUPLES);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -685,10 +687,10 @@ ResetPGVariable(const char *name)
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
KSQO code will one day be unnecessary when the optimizer makes use of
|
||||
KSQO code will one day be unnecessary when the optimizer makes use of
|
||||
indexes when multiple ORs are specified in the where clause.
|
||||
See optimizer/prep/prepkeyset.c for more on this.
|
||||
daveh@insightdist.com 6/16/98
|
||||
daveh@insightdist.com 6/16/98
|
||||
-----------------------------------------------------------------------*/
|
||||
static bool
|
||||
parse_ksqo(const char *value)
|
||||
@@ -732,7 +734,7 @@ reset_ksqo()
|
||||
static bool
|
||||
parse_XactIsoLevel(const char *value)
|
||||
{
|
||||
|
||||
|
||||
if (value == NULL)
|
||||
{
|
||||
reset_XactIsoLevel();
|
||||
@@ -770,7 +772,7 @@ show_XactIsoLevel()
|
||||
static bool
|
||||
reset_XactIsoLevel()
|
||||
{
|
||||
|
||||
|
||||
if (SerializableSnapshot != NULL)
|
||||
{
|
||||
elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query");
|
||||
|
@@ -5,11 +5,11 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: view.c,v 1.32 1999/02/13 23:15:12 momjian Exp $
|
||||
* $Id: view.c,v 1.33 1999/05/25 16:08:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <postgres.h>
|
||||
@@ -230,9 +230,9 @@ UpdateRangeTableOfViewParse(char *viewName, Query *viewParse)
|
||||
* table... CURRENT first, then NEW....
|
||||
*/
|
||||
rt_entry1 = addRangeTableEntry(NULL, (char *) viewName, "*CURRENT*",
|
||||
FALSE, FALSE);
|
||||
FALSE, FALSE);
|
||||
rt_entry2 = addRangeTableEntry(NULL, (char *) viewName, "*NEW*",
|
||||
FALSE, FALSE);
|
||||
FALSE, FALSE);
|
||||
new_rt = lcons(rt_entry2, old_rt);
|
||||
new_rt = lcons(rt_entry1, new_rt);
|
||||
|
||||
|
Reference in New Issue
Block a user