Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: szymong/postgres
...
head fork: szymong/postgres
  • 4 commits
  • 16 files changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 20, 2013
@petere petere ecpg: Split off mmfatal() from mmerror()
This allows decorating mmfatal() with noreturn compiler hints, leading
to better diagnostics.
b21de4e
@hlinnaka hlinnaka Further GIN refactoring.
Merge some functions that were always called together. Makes the code
little bit more readable.
04965ad
@hlinnaka hlinnaka Refactor the internal GIN B-tree interface for forming a downlink.
This creates a new gin-btree callback function for creating a downlink for
a page. Previously, ginxlog.c duplicated the logic used during normal
operation.
5010126
@hlinnaka hlinnaka More GIN refactoring.
Split off the portion of ginInsertValue that inserts the tuple to current
level into a separate function, ginPlaceToPage. ginInsertValue's charter
is now to recurse up the tree to insert the downlink, when a page split is
required.

This is in preparation for a patch to change the way incomplete splits are
handled, which will need to do these operations separately. And IMHO makes
the code more readable anyway.
04eee1f
View
331 src/backend/access/gin/ginbtree.c
@@ -52,52 +52,38 @@ ginTraverseLock(Buffer buffer, bool searchMode)
return access;
}
-GinBtreeStack *
-ginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno)
-{
- GinBtreeStack *stack = (GinBtreeStack *) palloc(sizeof(GinBtreeStack));
-
- stack->blkno = blkno;
- stack->buffer = ReadBuffer(btree->index, stack->blkno);
- stack->parent = NULL;
- stack->predictNumber = 1;
-
- ginTraverseLock(stack->buffer, btree->searchMode);
-
- return stack;
-}
-
/*
- * Locates leaf page contained tuple
+ * Descends the tree to the leaf page that contains or would contain the
+ * key we're searching for. The key should already be filled in 'btree',
+ * in tree-type specific manner. If btree->fullScan is true, descends to the
+ * leftmost leaf page.
+ *
+ * If 'searchmode' is false, on return stack->buffer is exclusively locked,
+ * and the stack represents the full path to the root. Otherwise stack->buffer
+ * is share-locked, and stack->parent is NULL.
*/
GinBtreeStack *
-ginFindLeafPage(GinBtree btree, GinBtreeStack *stack)
+ginFindLeafPage(GinBtree btree, BlockNumber rootBlkno, bool searchMode)
{
- bool isfirst = TRUE;
- BlockNumber rootBlkno;
+ GinBtreeStack *stack;
- if (!stack)
- stack = ginPrepareFindLeafPage(btree, GIN_ROOT_BLKNO);
- rootBlkno = stack->blkno;
+ stack = (GinBtreeStack *) palloc(sizeof(GinBtreeStack));
+ stack->blkno = rootBlkno;
+ stack->buffer = ReadBuffer(btree->index, rootBlkno);
+ stack->parent = NULL;
+ stack->predictNumber = 1;
for (;;)
{
Page page;
BlockNumber child;
- int access = GIN_SHARE;
+ int access;
stack->off = InvalidOffsetNumber;
page = BufferGetPage(stack->buffer);
- if (isfirst)
- {
- if (GinPageIsLeaf(page) && !btree->searchMode)
- access = GIN_EXCLUSIVE;
- isfirst = FALSE;
- }
- else
- access = ginTraverseLock(stack->buffer, btree->searchMode);
+ access = ginTraverseLock(stack->buffer, searchMode);
/*
* ok, page is correctly locked, we should check to move right ..,
@@ -127,7 +113,7 @@ ginFindLeafPage(GinBtree btree, GinBtreeStack *stack)
Assert(child != InvalidBlockNumber);
Assert(stack->blkno != child);
- if (btree->searchMode)
+ if (searchMode)
{
/* in search mode we may forget path to leaf */
stack->blkno = child;
@@ -251,7 +237,7 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack,
return;
}
- leftmostBlkno = blkno = btree->getLeftMostPage(btree, page);
+ leftmostBlkno = blkno = btree->getLeftMostChild(btree, page);
LockBuffer(root->buffer, GIN_UNLOCK);
Assert(blkno != InvalidBlockNumber);
@@ -263,7 +249,7 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack,
if (GinPageIsLeaf(page))
elog(ERROR, "Lost path");
- leftmostBlkno = btree->getLeftMostPage(btree, page);
+ leftmostBlkno = btree->getLeftMostChild(btree, page);
while ((offset = btree->findChildPtr(btree, page, stack->blkno, InvalidOffsetNumber)) == InvalidOffsetNumber)
{
@@ -294,80 +280,115 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack,
}
/*
- * Insert value (stored in GinBtree) to tree described by stack
- *
- * During an index build, buildStats is non-null and the counters
- * it contains are incremented as needed.
+ * Returns true if the insertion is done, false if the page was split and
+ * downlink insertion is pending.
*
- * NB: the passed-in stack is freed, as though by freeGinBtreeStack.
+ * stack->buffer is locked on entry, and is kept locked.
*/
-void
-ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats)
+static bool
+ginPlaceToPage(GinBtree btree, BlockNumber rootBlkno, GinBtreeStack *stack,
+ GinStatsData *buildStats)
{
- GinBtreeStack *parent;
- BlockNumber rootBlkno;
- Page page,
- rpage,
- lpage;
+ Page page = BufferGetPage(stack->buffer);
+ XLogRecData *rdata;
+ bool fit;
- /* extract root BlockNumber from stack */
- Assert(stack != NULL);
- parent = stack;
- while (parent->parent)
- parent = parent->parent;
- rootBlkno = parent->blkno;
- Assert(BlockNumberIsValid(rootBlkno));
+ START_CRIT_SECTION();
+ fit = btree->placeToPage(btree, stack->buffer, stack->off, &rdata);
+ if (fit)
+ {
+ MarkBufferDirty(stack->buffer);
- /* this loop crawls up the stack until the insertion is complete */
- for (;;)
+ if (RelationNeedsWAL(btree->index))
+ {
+ XLogRecPtr recptr;
+
+ recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_INSERT, rdata);
+ PageSetLSN(page, recptr);
+ }
+
+ END_CRIT_SECTION();
+
+ return true;
+ }
+ else
{
- XLogRecData *rdata;
+ /* Didn't fit, have to split */
+ Buffer rbuffer;
+ Page newlpage;
BlockNumber savedRightLink;
- bool fit;
+ GinBtreeStack *parent;
+ Page lpage,
+ rpage;
+
+ END_CRIT_SECTION();
+
+ rbuffer = GinNewBuffer(btree->index);
- page = BufferGetPage(stack->buffer);
savedRightLink = GinPageGetOpaque(page)->rightlink;
- START_CRIT_SECTION();
- fit = btree->placeToPage(btree, stack->buffer, stack->off, &rdata);
- if (fit)
+ /*
+ * newlpage is a pointer to memory page, it is not associated with
+ * a buffer. stack->buffer is not touched yet.
+ */
+ newlpage = btree->splitPage(btree, stack->buffer, rbuffer, stack->off, &rdata);
+
+ ((ginxlogSplit *) (rdata->data))->rootBlkno = rootBlkno;
+
+ /* During index build, count the newly-split page */
+ if (buildStats)
{
+ if (btree->isData)
+ buildStats->nDataPages++;
+ else
+ buildStats->nEntryPages++;
+ }
+
+ parent = stack->parent;
+
+ if (parent == NULL)
+ {
+ /*
+ * split root, so we need to allocate new left page and place
+ * pointer on root to left and right page
+ */
+ Buffer lbuffer = GinNewBuffer(btree->index);
+
+ ((ginxlogSplit *) (rdata->data))->isRootSplit = TRUE;
+ ((ginxlogSplit *) (rdata->data))->rrlink = InvalidBlockNumber;
+
+ lpage = BufferGetPage(lbuffer);
+ rpage = BufferGetPage(rbuffer);
+
+ GinPageGetOpaque(rpage)->rightlink = InvalidBlockNumber;
+ GinPageGetOpaque(newlpage)->rightlink = BufferGetBlockNumber(rbuffer);
+ ((ginxlogSplit *) (rdata->data))->lblkno = BufferGetBlockNumber(lbuffer);
+
+ START_CRIT_SECTION();
+
+ GinInitBuffer(stack->buffer, GinPageGetOpaque(newlpage)->flags & ~GIN_LEAF);
+ PageRestoreTempPage(newlpage, lpage);
+ btree->fillRoot(btree, stack->buffer, lbuffer, rbuffer);
+
+ MarkBufferDirty(rbuffer);
+ MarkBufferDirty(lbuffer);
MarkBufferDirty(stack->buffer);
if (RelationNeedsWAL(btree->index))
{
XLogRecPtr recptr;
- recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_INSERT, rdata);
+ recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_SPLIT, rdata);
PageSetLSN(page, recptr);
+ PageSetLSN(lpage, recptr);
+ PageSetLSN(rpage, recptr);
}
- LockBuffer(stack->buffer, GIN_UNLOCK);
- END_CRIT_SECTION();
-
- freeGinBtreeStack(stack);
-
- return;
- }
- else
- {
- /* Didn't fit, have to split */
- Buffer rbuffer;
- Page newlpage;
-
+ UnlockReleaseBuffer(rbuffer);
+ UnlockReleaseBuffer(lbuffer);
END_CRIT_SECTION();
- rbuffer = GinNewBuffer(btree->index);
-
- /*
- * newlpage is a pointer to memory page, it is not associated with
- * a buffer. stack->buffer is not touched yet.
- */
- newlpage = btree->splitPage(btree, stack->buffer, rbuffer, stack->off, &rdata);
-
- ((ginxlogSplit *) (rdata->data))->rootBlkno = rootBlkno;
-
- /* During index build, count the newly-split page */
+ /* During index build, count the newly-added root page */
if (buildStats)
{
if (btree->isData)
@@ -376,97 +397,83 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats)
buildStats->nEntryPages++;
}
- parent = stack->parent;
-
- if (parent == NULL)
- {
- /*
- * split root, so we need to allocate new left page and place
- * pointer on root to left and right page
- */
- Buffer lbuffer = GinNewBuffer(btree->index);
-
- ((ginxlogSplit *) (rdata->data))->isRootSplit = TRUE;
- ((ginxlogSplit *) (rdata->data))->rrlink = InvalidBlockNumber;
-
- page = BufferGetPage(stack->buffer);
- lpage = BufferGetPage(lbuffer);
- rpage = BufferGetPage(rbuffer);
-
- GinPageGetOpaque(rpage)->rightlink = InvalidBlockNumber;
- GinPageGetOpaque(newlpage)->rightlink = BufferGetBlockNumber(rbuffer);
- ((ginxlogSplit *) (rdata->data))->lblkno = BufferGetBlockNumber(lbuffer);
-
- START_CRIT_SECTION();
-
- GinInitBuffer(stack->buffer, GinPageGetOpaque(newlpage)->flags & ~GIN_LEAF);
- PageRestoreTempPage(newlpage, lpage);
- btree->fillRoot(btree, stack->buffer, lbuffer, rbuffer);
-
- MarkBufferDirty(rbuffer);
- MarkBufferDirty(lbuffer);
- MarkBufferDirty(stack->buffer);
+ return true;
+ }
+ else
+ {
+ /* split non-root page */
+ ((ginxlogSplit *) (rdata->data))->isRootSplit = FALSE;
+ ((ginxlogSplit *) (rdata->data))->rrlink = savedRightLink;
- if (RelationNeedsWAL(btree->index))
- {
- XLogRecPtr recptr;
+ lpage = BufferGetPage(stack->buffer);
+ rpage = BufferGetPage(rbuffer);
- recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_SPLIT, rdata);
- PageSetLSN(page, recptr);
- PageSetLSN(lpage, recptr);
- PageSetLSN(rpage, recptr);
- }
+ GinPageGetOpaque(rpage)->rightlink = savedRightLink;
+ GinPageGetOpaque(newlpage)->rightlink = BufferGetBlockNumber(rbuffer);
- UnlockReleaseBuffer(rbuffer);
- UnlockReleaseBuffer(lbuffer);
- LockBuffer(stack->buffer, GIN_UNLOCK);
- END_CRIT_SECTION();
+ START_CRIT_SECTION();
+ PageRestoreTempPage(newlpage, lpage);
- freeGinBtreeStack(stack);
+ MarkBufferDirty(rbuffer);
+ MarkBufferDirty(stack->buffer);
- /* During index build, count the newly-added root page */
- if (buildStats)
- {
- if (btree->isData)
- buildStats->nDataPages++;
- else
- buildStats->nEntryPages++;
- }
+ if (RelationNeedsWAL(btree->index))
+ {
+ XLogRecPtr recptr;
- return;
+ recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_SPLIT, rdata);
+ PageSetLSN(lpage, recptr);
+ PageSetLSN(rpage, recptr);
}
- else
- {
- /* split non-root page */
- ((ginxlogSplit *) (rdata->data))->isRootSplit = FALSE;
- ((ginxlogSplit *) (rdata->data))->rrlink = savedRightLink;
+ UnlockReleaseBuffer(rbuffer);
+ END_CRIT_SECTION();
+
+ return false;
+ }
+ }
+}
- lpage = BufferGetPage(stack->buffer);
- rpage = BufferGetPage(rbuffer);
+/*
+ * Insert value (stored in GinBtree) to tree described by stack
+ *
+ * During an index build, buildStats is non-null and the counters
+ * it contains are incremented as needed.
+ *
+ * NB: the passed-in stack is freed, as though by freeGinBtreeStack.
+ */
+void
+ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats)
+{
+ GinBtreeStack *parent;
+ BlockNumber rootBlkno;
+ Page page;
- GinPageGetOpaque(rpage)->rightlink = savedRightLink;
- GinPageGetOpaque(newlpage)->rightlink = BufferGetBlockNumber(rbuffer);
+ /* extract root BlockNumber from stack */
+ Assert(stack != NULL);
+ parent = stack;
+ while (parent->parent)
+ parent = parent->parent;
+ rootBlkno = parent->blkno;
+ Assert(BlockNumberIsValid(rootBlkno));
- START_CRIT_SECTION();
- PageRestoreTempPage(newlpage, lpage);
+ /* this loop crawls up the stack until the insertion is complete */
+ for (;;)
+ {
+ bool done;
- MarkBufferDirty(rbuffer);
- MarkBufferDirty(stack->buffer);
+ done = ginPlaceToPage(btree, rootBlkno, stack, buildStats);
- if (RelationNeedsWAL(btree->index))
- {
- XLogRecPtr recptr;
+ /* just to be extra sure we don't delete anything by accident... */
+ btree->isDelete = FALSE;
- recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_SPLIT, rdata);
- PageSetLSN(lpage, recptr);
- PageSetLSN(rpage, recptr);
- }
- UnlockReleaseBuffer(rbuffer);
- END_CRIT_SECTION();
- }
+ if (done)
+ {
+ LockBuffer(stack->buffer, GIN_UNLOCK);
+ freeGinBtreeStack(stack);
+ break;
}
- btree->isDelete = FALSE;
+ btree->prepareDownlink(btree, stack->buffer);
/* search parent to lock */
LockBuffer(parent->buffer, GIN_EXCLUSIVE);
View
99 src/backend/access/gin/gindatapage.c
@@ -54,7 +54,7 @@ dataLocateItem(GinBtree btree, GinBtreeStack *stack)
{
stack->off = FirstOffsetNumber;
stack->predictNumber *= GinPageGetOpaque(page)->maxoff;
- return btree->getLeftMostPage(btree, page);
+ return btree->getLeftMostChild(btree, page);
}
low = FirstOffsetNumber;
@@ -580,12 +580,20 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
rdata[1].len = MAXALIGN(maxoff * sizeofitem);
rdata[1].next = NULL;
- /* Prepare a downlink tuple for insertion to the parent */
+ return lpage;
+}
+
+/*
+ * Prepare the state in 'btree' for inserting a downlink for given buffer.
+ */
+static void
+dataPrepareDownlink(GinBtree btree, Buffer lbuf)
+{
+ Page lpage = BufferGetPage(lbuf);
+
PostingItemSetBlockNumber(&(btree->pitem), BufferGetBlockNumber(lbuf));
btree->pitem.key = *GinDataPageGetRightBound(lpage);
- btree->rightblkno = BufferGetBlockNumber(rbuf);
-
- return lpage;
+ btree->rightblkno = GinPageGetOpaque(lpage)->rightlink;
}
/*
@@ -680,17 +688,10 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems,
*/
if (nitems > nrootitems)
{
- GinPostingTreeScan *gdi;
-
- gdi = ginPrepareScanPostingTree(index, blkno, FALSE);
- gdi->btree.isBuild = (buildStats != NULL);
-
- ginInsertItemPointers(gdi,
+ ginInsertItemPointers(index, blkno,
items + nrootitems,
nitems - nrootitems,
buildStats);
-
- pfree(gdi);
}
return blkno;
@@ -704,76 +705,70 @@ ginPrepareDataScan(GinBtree btree, Relation index)
btree->index = index;
btree->findChildPage = dataLocateItem;
+ btree->getLeftMostChild = dataGetLeftMostPage;
btree->isMoveRight = dataIsMoveRight;
btree->findItem = dataLocateLeafItem;
btree->findChildPtr = dataFindChildPtr;
- btree->getLeftMostPage = dataGetLeftMostPage;
btree->placeToPage = dataPlaceToPage;
btree->splitPage = dataSplitPage;
btree->fillRoot = ginDataFillRoot;
+ btree->prepareDownlink = dataPrepareDownlink;
btree->isData = TRUE;
- btree->searchMode = FALSE;
btree->isDelete = FALSE;
btree->fullScan = FALSE;
btree->isBuild = FALSE;
}
-GinPostingTreeScan *
-ginPrepareScanPostingTree(Relation index, BlockNumber rootBlkno, bool searchMode)
-{
- GinPostingTreeScan *gdi = (GinPostingTreeScan *) palloc0(sizeof(GinPostingTreeScan));
-
- ginPrepareDataScan(&gdi->btree, index);
-
- gdi->btree.searchMode = searchMode;
- gdi->btree.fullScan = searchMode;
-
- gdi->stack = ginPrepareFindLeafPage(&gdi->btree, rootBlkno);
-
- return gdi;
-}
-
/*
* Inserts array of item pointers, may execute several tree scan (very rare)
*/
void
-ginInsertItemPointers(GinPostingTreeScan *gdi,
+ginInsertItemPointers(Relation index, BlockNumber rootBlkno,
ItemPointerData *items, uint32 nitem,
GinStatsData *buildStats)
{
- BlockNumber rootBlkno = gdi->stack->blkno;
+ GinBtreeData btree;
+ GinBtreeStack *stack;
- gdi->btree.items = items;
- gdi->btree.nitem = nitem;
- gdi->btree.curitem = 0;
+ ginPrepareDataScan(&btree, index);
+ btree.isBuild = (buildStats != NULL);
+ btree.items = items;
+ btree.nitem = nitem;
+ btree.curitem = 0;
- while (gdi->btree.curitem < gdi->btree.nitem)
+ while (btree.curitem < btree.nitem)
{
- if (!gdi->stack)
- gdi->stack = ginPrepareFindLeafPage(&gdi->btree, rootBlkno);
-
- gdi->stack = ginFindLeafPage(&gdi->btree, gdi->stack);
+ stack = ginFindLeafPage(&btree, rootBlkno, false);
- if (gdi->btree.findItem(&(gdi->btree), gdi->stack))
+ if (btree.findItem(&btree, stack))
{
/*
- * gdi->btree.items[gdi->btree.curitem] already exists in index
+ * btree.items[btree.curitem] already exists in index
*/
- gdi->btree.curitem++;
- LockBuffer(gdi->stack->buffer, GIN_UNLOCK);
- freeGinBtreeStack(gdi->stack);
+ btree.curitem++;
+ LockBuffer(stack->buffer, GIN_UNLOCK);
+ freeGinBtreeStack(stack);
}
else
- ginInsertValue(&(gdi->btree), gdi->stack, buildStats);
-
- gdi->stack = NULL;
+ ginInsertValue(&btree, stack, buildStats);
}
}
-Buffer
-ginScanBeginPostingTree(GinPostingTreeScan *gdi)
+/*
+ * Starts a new scan on a posting tree.
+ */
+GinBtreeStack *
+ginScanBeginPostingTree(Relation index, BlockNumber rootBlkno)
{
- gdi->stack = ginFindLeafPage(&gdi->btree, gdi->stack);
- return gdi->stack->buffer;
+ GinBtreeData btree;
+ GinBtreeStack *stack;
+
+ ginPrepareDataScan(&btree, index);
+
+ btree.fullScan = TRUE;
+
+ stack = ginFindLeafPage(&btree, rootBlkno, TRUE);
+
+ return stack;
}
View
48 src/backend/access/gin/ginentrypage.c
@@ -258,7 +258,7 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack)
{
stack->off = FirstOffsetNumber;
stack->predictNumber *= PageGetMaxOffsetNumber(page);
- return btree->getLeftMostPage(btree, page);
+ return btree->getLeftMostChild(btree, page);
}
low = FirstOffsetNumber;
@@ -570,8 +570,7 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
Size lsize = 0,
size;
char *ptr;
- IndexTuple itup,
- leftrightmost = NULL;
+ IndexTuple itup;
Page page;
Page lpage = PageGetTempPageCopy(BufferGetPage(lbuf));
Page rpage = BufferGetPage(rbuf);
@@ -635,7 +634,6 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
}
else
{
- leftrightmost = itup;
lsize += MAXALIGN(IndexTupleSize(itup)) + sizeof(ItemIdData);
}
@@ -645,11 +643,6 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
ptr += MAXALIGN(IndexTupleSize(itup));
}
- btree->entry = GinFormInteriorTuple(leftrightmost, lpage,
- BufferGetBlockNumber(lbuf));
-
- btree->rightblkno = BufferGetBlockNumber(rbuf);
-
data.node = btree->index->rd_node;
data.rootBlkno = InvalidBlockNumber;
data.lblkno = BufferGetBlockNumber(lbuf);
@@ -674,19 +667,20 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
}
/*
- * return newly allocated rightmost tuple
+ * Prepare the state in 'btree' for inserting a downlink for given buffer.
*/
-IndexTuple
-ginPageGetLinkItup(Buffer buf)
+static void
+entryPrepareDownlink(GinBtree btree, Buffer lbuf)
{
- IndexTuple itup,
- nitup;
- Page page = BufferGetPage(buf);
+ Page lpage = BufferGetPage(lbuf);
+ IndexTuple itup;
- itup = getRightMostTuple(page);
- nitup = GinFormInteriorTuple(itup, page, BufferGetBlockNumber(buf));
+ itup = getRightMostTuple(lpage);
- return nitup;
+ btree->entry = GinFormInteriorTuple(itup,
+ lpage,
+ BufferGetBlockNumber(lbuf));
+ btree->rightblkno = GinPageGetOpaque(lpage)->rightlink;
}
/*
@@ -696,17 +690,21 @@ ginPageGetLinkItup(Buffer buf)
void
ginEntryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
{
- Page page;
+ Page page = BufferGetPage(root);
+ Page lpage = BufferGetPage(lbuf);
+ Page rpage = BufferGetPage(rbuf);
IndexTuple itup;
- page = BufferGetPage(root);
-
- itup = ginPageGetLinkItup(lbuf);
+ itup = GinFormInteriorTuple(getRightMostTuple(lpage),
+ lpage,
+ BufferGetBlockNumber(lbuf));
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
elog(ERROR, "failed to add item to index root page");
pfree(itup);
- itup = ginPageGetLinkItup(rbuf);
+ itup = GinFormInteriorTuple(getRightMostTuple(rpage),
+ rpage,
+ BufferGetBlockNumber(rbuf));
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
elog(ERROR, "failed to add item to index root page");
pfree(itup);
@@ -729,16 +727,16 @@ ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
btree->ginstate = ginstate;
btree->findChildPage = entryLocateEntry;
+ btree->getLeftMostChild = entryGetLeftMostPage;
btree->isMoveRight = entryIsMoveRight;
btree->findItem = entryLocateLeafEntry;
btree->findChildPtr = entryFindChildPtr;
- btree->getLeftMostPage = entryGetLeftMostPage;
btree->placeToPage = entryPlaceToPage;
btree->splitPage = entrySplitPage;
btree->fillRoot = ginEntryFillRoot;
+ btree->prepareDownlink = entryPrepareDownlink;
btree->isData = FALSE;
- btree->searchMode = FALSE;
btree->fullScan = FALSE;
btree->isBuild = FALSE;
View
24 src/backend/access/gin/ginget.c
@@ -124,18 +124,16 @@ static void
scanPostingTree(Relation index, GinScanEntry scanEntry,
BlockNumber rootPostingTree)
{
- GinPostingTreeScan *gdi;
+ GinBtreeStack *stack;
Buffer buffer;
Page page;
/* Descend to the leftmost leaf page */
- gdi = ginPrepareScanPostingTree(index, rootPostingTree, TRUE);
-
- buffer = ginScanBeginPostingTree(gdi);
+ stack = ginScanBeginPostingTree(index, rootPostingTree);
+ buffer = stack->buffer;
IncrBufferRefCount(buffer); /* prevent unpin in freeGinBtreeStack */
- freeGinBtreeStack(gdi->stack);
- pfree(gdi);
+ freeGinBtreeStack(stack);
/*
* Loop iterates through all leaf pages of posting tree
@@ -376,8 +374,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry)
ginPrepareEntryScan(&btreeEntry, entry->attnum,
entry->queryKey, entry->queryCategory,
ginstate);
- btreeEntry.searchMode = TRUE;
- stackEntry = ginFindLeafPage(&btreeEntry, NULL);
+ stackEntry = ginFindLeafPage(&btreeEntry, GIN_ROOT_BLKNO, true);
page = BufferGetPage(stackEntry->buffer);
needUnlock = TRUE;
@@ -427,7 +424,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry)
if (GinIsPostingTree(itup))
{
BlockNumber rootPostingTree = GinGetPostingTree(itup);
- GinPostingTreeScan *gdi;
+ GinBtreeStack *stack;
Page page;
/*
@@ -439,9 +436,9 @@ startScanEntry(GinState *ginstate, GinScanEntry entry)
*/
LockBuffer(stackEntry->buffer, GIN_UNLOCK);
needUnlock = FALSE;
- gdi = ginPrepareScanPostingTree(ginstate->index, rootPostingTree, TRUE);
- entry->buffer = ginScanBeginPostingTree(gdi);
+ stack = ginScanBeginPostingTree(ginstate->index, rootPostingTree);
+ entry->buffer = stack->buffer;
/*
* We keep buffer pinned because we need to prevent deletion of
@@ -451,7 +448,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry)
IncrBufferRefCount(entry->buffer);
page = BufferGetPage(entry->buffer);
- entry->predictNumberResult = gdi->stack->predictNumber * GinPageGetOpaque(page)->maxoff;
+ entry->predictNumberResult = stack->predictNumber * GinPageGetOpaque(page)->maxoff;
/*
* Keep page content in memory to prevent durable page locking
@@ -463,8 +460,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry)
GinPageGetOpaque(page)->maxoff * sizeof(ItemPointerData));
LockBuffer(entry->buffer, GIN_UNLOCK);
- freeGinBtreeStack(gdi->stack);
- pfree(gdi);
+ freeGinBtreeStack(stack);
entry->isFinished = FALSE;
}
else if (GinGetNPosting(itup) > 0)
View
21 src/backend/access/gin/gininsert.c
@@ -81,7 +81,6 @@ addItemPointersToLeafTuple(GinState *ginstate,
{
/* posting list would be too big, convert to posting tree */
BlockNumber postingRoot;
- GinPostingTreeScan *gdi;
/*
* Initialize posting tree with the old tuple's posting list. It's
@@ -94,12 +93,9 @@ addItemPointersToLeafTuple(GinState *ginstate,
buildStats);
/* Now insert the TIDs-to-be-added into the posting tree */
- gdi = ginPrepareScanPostingTree(ginstate->index, postingRoot, FALSE);
- gdi->btree.isBuild = (buildStats != NULL);
-
- ginInsertItemPointers(gdi, items, nitem, buildStats);
-
- pfree(gdi);
+ ginInsertItemPointers(ginstate->index, postingRoot,
+ items, nitem,
+ buildStats);
/* And build a new posting-tree-only result tuple */
res = GinFormTuple(ginstate, attnum, key, category, NULL, 0, true);
@@ -177,7 +173,7 @@ ginEntryInsert(GinState *ginstate,
ginPrepareEntryScan(&btree, attnum, key, category, ginstate);
- stack = ginFindLeafPage(&btree, NULL);
+ stack = ginFindLeafPage(&btree, GIN_ROOT_BLKNO, false);
page = BufferGetPage(stack->buffer);
if (btree.findItem(&btree, stack))
@@ -189,18 +185,15 @@ ginEntryInsert(GinState *ginstate,
{
/* add entries to existing posting tree */
BlockNumber rootPostingTree = GinGetPostingTree(itup);
- GinPostingTreeScan *gdi;
/* release all stack */
LockBuffer(stack->buffer, GIN_UNLOCK);
freeGinBtreeStack(stack);
/* insert into posting tree */
- gdi = ginPrepareScanPostingTree(ginstate->index, rootPostingTree, FALSE);
- gdi->btree.isBuild = (buildStats != NULL);
- ginInsertItemPointers(gdi, items, nitem, buildStats);
- pfree(gdi);
-
+ ginInsertItemPointers(ginstate->index, rootPostingTree,
+ items, nitem,
+ buildStats);
return;
}
View
15 src/backend/access/gin/ginxlog.c
@@ -799,31 +799,20 @@ ginContinueSplit(ginIncompleteSplit *split)
ginPrepareEntryScan(&btree,
InvalidOffsetNumber, (Datum) 0, GIN_CAT_NULL_KEY,
&ginstate);
- btree.entry = ginPageGetLinkItup(buffer);
}
else
{
- Page page = BufferGetPage(buffer);
-
ginPrepareDataScan(&btree, reln);
-
- PostingItemSetBlockNumber(&(btree.pitem), split->leftBlkno);
- if (GinPageIsLeaf(page))
- btree.pitem.key = *GinDataPageGetItemPointer(page,
- GinPageGetOpaque(page)->maxoff);
- else
- btree.pitem.key = GinDataPageGetPostingItem(page,
- GinPageGetOpaque(page)->maxoff)->key;
}
- btree.rightblkno = split->rightBlkno;
-
stack.blkno = split->leftBlkno;
stack.buffer = buffer;
stack.off = InvalidOffsetNumber;
stack.parent = NULL;
ginFindParents(&btree, &stack, split->rootBlkno);
+
+ btree.prepareDownlink(&btree, buffer);
ginInsertValue(&btree, stack.parent, NULL);
FreeFakeRelcacheEntry(reln);
View
21 src/include/access/gin_private.h
@@ -479,18 +479,18 @@ typedef struct GinBtreeData
{
/* search methods */
BlockNumber (*findChildPage) (GinBtree, GinBtreeStack *);
+ BlockNumber (*getLeftMostChild) (GinBtree, Page);
bool (*isMoveRight) (GinBtree, Page);
bool (*findItem) (GinBtree, GinBtreeStack *);
/* insert methods */
OffsetNumber (*findChildPtr) (GinBtree, Page, BlockNumber, OffsetNumber);
- BlockNumber (*getLeftMostPage) (GinBtree, Page);
bool (*placeToPage) (GinBtree, Buffer, OffsetNumber, XLogRecData **);
Page (*splitPage) (GinBtree, Buffer, Buffer, OffsetNumber, XLogRecData **);
+ void (*prepareDownlink) (GinBtree, Buffer);
void (*fillRoot) (GinBtree, Buffer, Buffer, Buffer);
bool isData;
- bool searchMode;
Relation index;
GinState *ginstate; /* not valid in a data scan */
@@ -514,8 +514,7 @@ typedef struct GinBtreeData
PostingItem pitem;
} GinBtreeData;
-extern GinBtreeStack *ginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno);
-extern GinBtreeStack *ginFindLeafPage(GinBtree btree, GinBtreeStack *stack);
+extern GinBtreeStack *ginFindLeafPage(GinBtree btree, BlockNumber rootBlkno, bool searchMode);
extern Buffer ginStepRight(Buffer buffer, Relation index, int lockmode);
extern void freeGinBtreeStack(GinBtreeStack *stack);
extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
@@ -531,7 +530,6 @@ extern void ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
Datum key, GinNullCategory category,
GinState *ginstate);
extern void ginEntryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
-extern IndexTuple ginPageGetLinkItup(Buffer buf);
/* gindatapage.c */
extern BlockNumber createPostingTree(Relation index,
@@ -540,19 +538,10 @@ extern BlockNumber createPostingTree(Relation index,
extern void GinDataPageAddItemPointer(Page page, ItemPointer data, OffsetNumber offset);
extern void GinDataPageAddPostingItem(Page page, PostingItem *data, OffsetNumber offset);
extern void GinPageDeletePostingItem(Page page, OffsetNumber offset);
-
-typedef struct
-{
- GinBtreeData btree;
- GinBtreeStack *stack;
-} GinPostingTreeScan;
-
-extern GinPostingTreeScan *ginPrepareScanPostingTree(Relation index,
- BlockNumber rootBlkno, bool searchMode);
-extern void ginInsertItemPointers(GinPostingTreeScan *gdi,
+extern void ginInsertItemPointers(Relation index, BlockNumber rootBlkno,
ItemPointerData *items, uint32 nitem,
GinStatsData *buildStats);
-extern Buffer ginScanBeginPostingTree(GinPostingTreeScan *gdi);
+extern GinBtreeStack *ginScanBeginPostingTree(Relation index, BlockNumber rootBlkno);
extern void ginDataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
extern void ginPrepareDataScan(GinBtree btree, Relation index);
View
4 src/interfaces/ecpg/preproc/descriptor.c
@@ -274,7 +274,7 @@ output_set_descr(char *desc_name, char *index)
case ECPGd_di_precision:
case ECPGd_precision:
case ECPGd_scale:
- mmerror(PARSE_ERROR, ET_FATAL, "descriptor item \"%s\" is not implemented",
+ mmfatal(PARSE_ERROR, "descriptor item \"%s\" is not implemented",
descriptor_item_name(results->value));
break;
@@ -284,7 +284,7 @@ output_set_descr(char *desc_name, char *index)
case ECPGd_octet:
case ECPGd_ret_length:
case ECPGd_ret_octet:
- mmerror(PARSE_ERROR, ET_FATAL, "descriptor item \"%s\" cannot be set",
+ mmfatal(PARSE_ERROR, "descriptor item \"%s\" cannot be set",
descriptor_item_name(results->value));
break;
View
47 src/interfaces/ecpg/preproc/ecpg.header
@@ -64,11 +64,9 @@ struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
/*
* Handle parsing errors and warnings
*/
-void
-mmerror(int error_code, enum errortype type, const char *error, ...)
+static void __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0)))
+vmmerror(int error_code, enum errortype type, const char *error, va_list ap)
{
- va_list ap;
-
/* internationalize the error message string */
error = _(error);
@@ -80,14 +78,11 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
fprintf(stderr, _("WARNING: "));
break;
case ET_ERROR:
- case ET_FATAL:
fprintf(stderr, _("ERROR: "));
break;
}
- va_start(ap, error);
vfprintf(stderr, error, ap);
- va_end(ap);
fprintf(stderr, "\n");
@@ -98,18 +93,38 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
case ET_ERROR:
ret_value = error_code;
break;
- case ET_FATAL:
- if (yyin)
- fclose(yyin);
- if (yyout)
- fclose(yyout);
-
- if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
- fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
- exit(error_code);
}
}
+void
+mmerror(int error_code, enum errortype type, const char *error, ...)
+{
+ va_list ap;
+
+ va_start(ap, error);
+ vmmerror(error_code, type, error, ap);
+ va_end(ap);
+}
+
+void
+mmfatal(int error_code, const char *error, ...)
+{
+ va_list ap;
+
+ va_start(ap, error);
+ vmmerror(error_code, ET_ERROR, error, ap);
+ va_end(ap);
+
+ if (yyin)
+ fclose(yyin);
+ if (yyout)
+ fclose(yyout);
+
+ if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
+ fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
+ exit(error_code);
+}
+
/*
* string concatenation
*/
View
2  src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1687,7 +1687,7 @@ cvariable: CVARIABLE
{
case '[':
if (brace)
- mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for simple data types are not supported");
+ mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
brace_open++;
break;
case ']':
View
6 src/interfaces/ecpg/preproc/extern.h
@@ -73,10 +73,8 @@ extern int base_yylex(void);
extern void base_yyerror(const char *);
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
extern char *mm_strdup(const char *);
-extern void
-mmerror(int, enum errortype, const char *,...)
-/* This extension allows gcc to check the format string */
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
+extern void mmerror(int errorcode, enum errortype type, const char *error, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
+extern void mmfatal(int errorcode, const char *error, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3),noreturn));
extern void output_get_descr_header(char *);
extern void output_get_descr(char *, char *);
extern void output_set_descr_header(char *);
View
4 src/interfaces/ecpg/preproc/nls.mk
@@ -2,5 +2,5 @@
CATALOG_NAME = ecpg
AVAIL_LANGUAGES = cs de es fr it ja ko pl pt_BR ru tr zh_CN zh_TW
GETTEXT_FILES = descriptor.c ecpg.c pgc.c preproc.c type.c variable.c
-GETTEXT_TRIGGERS = mmerror:3
-GETTEXT_FLAGS = mmerror:3:c-format
+GETTEXT_TRIGGERS = mmerror:3 mmfatal:2
+GETTEXT_FLAGS = mmerror:3:c-format mmfatal:2:c-format
View
42 src/interfaces/ecpg/preproc/pgc.l
@@ -400,7 +400,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xc>{op_chars} { ECHO; }
<xc>\*+ { ECHO; }
-<xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated /* comment"); }
+<xc><<EOF>> { mmfatal(PARSE_ERROR, "unterminated /* comment"); }
<SQL>{xbstart} {
token_start = yytext;
@@ -422,7 +422,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xb>{xbinside} { addlit(yytext, yyleng); }
<xh>{quotecontinue} |
<xb>{quotecontinue} { /* ignore */ }
-<xb><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated bit string literal"); }
+<xb><<EOF>> { mmfatal(PARSE_ERROR, "unterminated bit string literal"); }
<SQL>{xhstart} {
token_start = yytext;
@@ -438,7 +438,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
return XCONST;
}
-<xh><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated hexadecimal string literal"); }
+<xh><<EOF>> { mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal"); }
<SQL>{xnstart} {
/* National character.
* Transfer it as-is to the backend.
@@ -516,7 +516,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
}
-<xq,xqc,xe,xn,xus><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated quoted string"); }
+<xq,xqc,xe,xn,xus><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted string"); }
<SQL>{dolqfailed} {
/* throw back all but the initial "$" */
yyless(1);
@@ -592,7 +592,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
<xd,xui>{xddouble} { addlitchar('"'); }
<xd,xui>{xdinside} { addlit(yytext, yyleng); }
-<xd,xdc,xui><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated quoted identifier"); }
+<xd,xdc,xui><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted identifier"); }
<C,SQL>{xdstart} {
state_before = YYSTATE;
BEGIN(xdc);
@@ -938,7 +938,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(C);
}
<undef>{other}|\n {
- mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command");
+ mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL UNDEF command");
yyterminate();
}
<C>{exec_sql}{include}{space}* { BEGIN(incl); }
@@ -984,10 +984,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
<C,xskip>{exec_sql}{elif}{space}* { /* pop stack */
if ( preproc_tos == 0 ) {
- mmerror(PARSE_ERROR, ET_FATAL, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
+ mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
}
else if ( stacked_if_value[preproc_tos].else_branch )
- mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\"");
+ mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
else
preproc_tos--;
@@ -998,9 +998,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (INFORMIX_MODE)
{
if (preproc_tos == 0)
- mmerror(PARSE_ERROR, ET_FATAL, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
+ mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
else if (stacked_if_value[preproc_tos].else_branch)
- mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\"");
+ mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
else
preproc_tos--;
@@ -1016,7 +1016,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<C,xskip>{exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */
if (stacked_if_value[preproc_tos].else_branch)
- mmerror(PARSE_ERROR, ET_FATAL, "more than one EXEC SQL ELSE");
+ mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
else
{
stacked_if_value[preproc_tos].else_branch = TRUE;
@@ -1035,7 +1035,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (INFORMIX_MODE)
{
if (stacked_if_value[preproc_tos].else_branch)
- mmerror(PARSE_ERROR, ET_FATAL, "more than one EXEC SQL ELSE");
+ mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
else
{
stacked_if_value[preproc_tos].else_branch = TRUE;
@@ -1057,7 +1057,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
<C,xskip>{exec_sql}{endif}{space}*";" {
if (preproc_tos == 0)
- mmerror(PARSE_ERROR, ET_FATAL, "unmatched EXEC SQL ENDIF");
+ mmfatal(PARSE_ERROR, "unmatched EXEC SQL ENDIF");
else
preproc_tos--;
@@ -1071,7 +1071,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (INFORMIX_MODE)
{
if (preproc_tos == 0)
- mmerror(PARSE_ERROR, ET_FATAL, "unmatched EXEC SQL ENDIF");
+ mmfatal(PARSE_ERROR, "unmatched EXEC SQL ENDIF");
else
preproc_tos--;
@@ -1091,7 +1091,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xcond>{identifier}{space}*";" {
if (preproc_tos >= MAX_NESTED_IF-1)
- mmerror(PARSE_ERROR, ET_FATAL, "too many nested EXEC SQL IFDEF conditions");
+ mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
else
{
struct _defines *defptr;
@@ -1124,7 +1124,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
<xcond>{other}|\n {
- mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL IFDEF command");
+ mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL IFDEF command");
yyterminate();
}
<def_ident>{identifier} {
@@ -1133,7 +1133,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
startlit();
}
<def_ident>{other}|\n {
- mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL DEFINE command");
+ mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL DEFINE command");
yyterminate();
}
<def>{space}*";" {
@@ -1166,7 +1166,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<incl>{dquote}{xdinside}{dquote}{space}*";"? { parse_include(); }
<incl>[^;\<\>\"]+";" { parse_include(); }
<incl>{other}|\n {
- mmerror(PARSE_ERROR, ET_FATAL, "syntax error in EXEC SQL INCLUDE command");
+ mmfatal(PARSE_ERROR, "syntax error in EXEC SQL INCLUDE command");
yyterminate();
}
@@ -1176,7 +1176,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if ( preproc_tos > 0 )
{
preproc_tos = 0;
- mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\"");
+ mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
}
yyterminate();
}
@@ -1215,7 +1215,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
}
-<INITIAL>{other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); }
+<INITIAL>{other}|\n { mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); }
%%
void
lex_init(void)
@@ -1362,7 +1362,7 @@ parse_include(void)
}
}
if (!yyin)
- mmerror(NO_INCLUDE_FILE, ET_FATAL, "could not open include file \"%s\" on line %d", yytext, yylineno);
+ mmfatal(NO_INCLUDE_FILE, "could not open include file \"%s\" on line %d", yytext, yylineno);
input_filename = mm_strdup(inc_file);
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE ));
View
14 src/interfaces/ecpg/preproc/type.c
@@ -15,7 +15,7 @@ mm_alloc(size_t size)
void *ptr = malloc(size);
if (ptr == NULL)
- mmerror(OUT_OF_MEMORY, ET_FATAL, "out of memory");
+ mmfatal(OUT_OF_MEMORY, "out of memory");
return ptr;
}
@@ -27,7 +27,7 @@ mm_strdup(const char *string)
char *new = strdup(string);
if (new == NULL)
- mmerror(OUT_OF_MEMORY, ET_FATAL, "out of memory");
+ mmfatal(OUT_OF_MEMORY, "out of memory");
return new;
}
@@ -282,7 +282,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
{
case ECPGt_array:
if (indicator_set && ind_type->type != ECPGt_array)
- mmerror(INDICATOR_NOT_ARRAY, ET_FATAL, "indicator for array/pointer has to be array/pointer");
+ mmfatal(INDICATOR_NOT_ARRAY, "indicator for array/pointer has to be array/pointer");
switch (type->u.element->type)
{
case ECPGt_array:
@@ -319,7 +319,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break;
case ECPGt_struct:
if (indicator_set && ind_type->type != ECPGt_struct)
- mmerror(INDICATOR_NOT_STRUCT, ET_FATAL, "indicator for struct has to be a struct");
+ mmfatal(INDICATOR_NOT_STRUCT, "indicator for struct has to be a struct");
ECPGdump_a_struct(o, name, ind_name, mm_strdup("1"), type, ind_type, prefix, ind_prefix);
break;
@@ -328,7 +328,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break;
case ECPGt_char_variable:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
- mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple");
+ mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, mm_strdup("1"), (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("1"), struct_sizeof, prefix, 0);
if (ind_type != NULL)
@@ -336,7 +336,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break;
case ECPGt_descriptor:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
- mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple");
+ mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, NULL, mm_strdup("-1"), NULL, prefix, 0);
if (ind_type != NULL)
@@ -344,7 +344,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break;
default:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
- mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple");
+ mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), struct_sizeof, prefix, type->counter);
if (ind_type != NULL)
View
2  src/interfaces/ecpg/preproc/type.h
@@ -186,7 +186,7 @@ struct assignment
enum errortype
{
- ET_WARNING, ET_ERROR, ET_FATAL
+ ET_WARNING, ET_ERROR
};
struct fetch_desc
View
36 src/interfaces/ecpg/preproc/variable.c
@@ -86,7 +86,7 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in
case '\0': /* found the end, but this time it has to be
* an array element */
if (members->type->type != ECPGt_array)
- mmerror(PARSE_ERROR, ET_FATAL, "incorrectly formed variable \"%s\"", name);
+ mmfatal(PARSE_ERROR, "incorrectly formed variable \"%s\"", name);
switch (members->type->u.element->type)
{
@@ -113,7 +113,7 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in
return (find_struct_member(name, end, members->type->u.members, brace_level));
break;
default:
- mmerror(PARSE_ERROR, ET_FATAL, "incorrectly formed variable \"%s\"", name);
+ mmfatal(PARSE_ERROR, "incorrectly formed variable \"%s\"", name);
break;
}
}
@@ -136,10 +136,10 @@ find_struct(char *name, char *next, char *end)
if (c == '-')
{
if (p->type->type != ECPGt_array)
- mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not a pointer", name);
+ mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer", name);
if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union)
- mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not a pointer to a structure or a union", name);
+ mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer to a structure or a union", name);
/* restore the name, we will need it later */
*next = c;
@@ -151,7 +151,7 @@ find_struct(char *name, char *next, char *end)
if (next == end)
{
if (p->type->type != ECPGt_struct && p->type->type != ECPGt_union)
- mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is neither a structure nor a union", name);
+ mmfatal(PARSE_ERROR, "variable \"%s\" is neither a structure nor a union", name);
/* restore the name, we will need it later */
*next = c;
@@ -161,10 +161,10 @@ find_struct(char *name, char *next, char *end)
else
{
if (p->type->type != ECPGt_array)
- mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not an array", name);
+ mmfatal(PARSE_ERROR, "variable \"%s\" is not an array", name);
if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union)
- mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not a pointer to a structure or a union", name);
+ mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer to a structure or a union", name);
/* restore the name, we will need it later */
*next = c;
@@ -230,7 +230,7 @@ find_variable(char *name)
*next = '\0';
p = find_simple(name);
if (p == NULL)
- mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not declared", name);
+ mmfatal(PARSE_ERROR, "variable \"%s\" is not declared", name);
*next = c;
switch (p->type->u.element->type)
@@ -252,7 +252,7 @@ find_variable(char *name)
p = find_simple(name);
if (p == NULL)
- mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not declared", name);
+ mmfatal(PARSE_ERROR, "variable \"%s\" is not declared", name);
return (p);
}
@@ -497,7 +497,7 @@ get_typedef(char *name)
for (this = types; this && strcmp(this->name, name) != 0; this = this->next);
if (!this)
- mmerror(PARSE_ERROR, ET_FATAL, "unrecognized data type name \"%s\"", name);
+ mmfatal(PARSE_ERROR, "unrecognized data type name \"%s\"", name);
return (this);
}
@@ -508,7 +508,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if (atoi(type_index) >= 0)
{
if (atoi(*length) >= 0)
- mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
+ mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
*length = type_index;
}
@@ -516,7 +516,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if (atoi(type_dimension) >= 0)
{
if (atoi(*dimension) >= 0 && atoi(*length) >= 0)
- mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
+ mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
if (atoi(*dimension) >= 0)
*length = *dimension;
@@ -525,18 +525,18 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
}
if (pointer_len > 2)
- mmerror(PARSE_ERROR, ET_FATAL, ngettext("multilevel pointers (more than 2 levels) are not supported; found %d level",
+ mmfatal(PARSE_ERROR, ngettext("multilevel pointers (more than 2 levels) are not supported; found %d level",
"multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len),
pointer_len);
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string)
- mmerror(PARSE_ERROR, ET_FATAL, "pointer to pointer is not supported for this data type");
+ mmfatal(PARSE_ERROR, "pointer to pointer is not supported for this data type");
if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0))
- mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
+ mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
if (atoi(*length) >= 0 && atoi(*dimension) >= 0 && pointer_len)
- mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported");
+ mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
switch (type_enum)
{
@@ -550,7 +550,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
}
if (atoi(*length) >= 0)
- mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for structures are not supported");
+ mmfatal(PARSE_ERROR, "multidimensional arrays for structures are not supported");
break;
case ECPGt_varchar:
@@ -611,7 +611,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
}
if (atoi(*length) >= 0)
- mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for simple data types are not supported");
+ mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
break;
}

No commit comments for this range

Something went wrong with that request. Please try again.