head     1.5;
branch   ;
access   ;
symbols  Version_2_1:1.5 C_Demo_1:1.3;
locks    cimarron:1.5; strict;
comment  @ * @;


1.5
date     90.09.25.17.16.16;  author kemnitz;  state Exp;
branches ;
next     1.4;

1.4
date     90.06.09.18.54.15;  author kemnitz;  state Exp;
branches ;
next     1.3;

1.3
date     89.09.05.16.55.59;  author mao;  state C_Demo_1;
branches ;
next     1.2;

1.2
date     89.03.22.02.48.01;  author muir;  state Stab;
branches ;
next     1.1;

1.1
date     89.01.17.05.51.55;  author cimarron;  state Exp;
branches ;
next     ;


desc
@@


1.5
log
@update
@
text
@/*
 * iqual.c --
 *	Index scan key qualification code.
 */

#include "tmp/postgres.h"

RcsId("$Header: src/access/genam/iqual.c,v 1.1 90/09/25 17:12:32 kemnitz Exp $");

/* XXX check the includes--probably missing something */

#include "access/genam.h"
#include "access/iqual.h"
#include "access/itup.h"
#include "access/skey.h"

#include "storage/buf.h"
#include "storage/itemid.h"
#include "storage/page.h"
#include "utils/rel.h"

/*
 * ikeytest --
 */
extern
bool
ikeytest ARGS((
	IndexTuple	tuple,
	Buffer		buffer,
	Relation	relation,
	ScanKeySize	scanKeySize,
	ScanKey		key
));

bool
ItemIdSatisfiesScanKey(itemId, page, relation, scanKeySize, key)
	ItemId		itemId;
	Page		page;
	Relation	relation;
	ScanKeySize	scanKeySize;
	ScanKey		key;
{
	IndexTuple	tuple;

	Assert(ItemIdIsValid(itemId));
	Assert(PageIsValid(page));	/* XXX needs better checking */
	Assert(RelationIsValid(relation));
	Assert(ScanKeyIsValid(scanKeySize, key));

	if (!ItemIdIsUsed(itemId) || ItemIdIsContinuation(itemId)) {
		return (false);
	}
	tuple = (IndexTuple)PageGetItem(page, itemId);
	if (!ikeytest(tuple, relation, scanKeySize, key)) {
		return (false);
	}
	return (true);
}

/*
 *	ikeytest		- test tuple for satisfaction of scan key
 *
 *	This is for index tuples only.
 *
 *	May eventually combine with other tests (like timeranges)?
 *	Should have Buffer buffer; as an argument and pass it
 *	to amgetattr.
 */

bool
ikeytest(tuple, relation, scanKeySize, key)
	IndexTuple	tuple;
	Relation	relation;
	ScanKeySize	scanKeySize;
	ScanKey		key;
{
	Boolean	isNull;
	Datum	datum;

	int	test;

	while (scanKeySize > 0) {
		/*
		 *  XXX -- When we support multi-key indices, the code fragment
		 *	   here is what we'll want to use.
		 * datum = IndexTupleGetAttributeValue(tuple,
		 *	key->data[0].attributeNumber,
		 *	RelationGetTupleDescriptor(relation), &isNull);
		 */

		 datum = IndexTupleGetAttributeValue(tuple,
			1,					/* XXX */
			RelationGetTupleDescriptor(relation), &isNull);


		if (isNull) {
			/* XXX eventually should check if SK_ISNULL */
			return (false);
		}
		if (key->data[0].flags & CommuteArguments) {
			test = (int)fmgr(key->data[0].procedure,
				DatumGetPointer(key->data[0].argument), datum);
			/* XXX .argument.pointer.value will disappear */
		} else {
			test = (int)fmgr(key->data[0].procedure, datum,
				DatumGetPointer(key->data[0].argument));
			/* XXX .argument.pointer.value will disappear */
		}
		if (!test == !(key->data[0].flags & NegateResult)) {
			return (false);
		}

		scanKeySize -= 1;
		key = (ScanKey)&key->data[1];
	}
	return (true);
}
@


1.4
log
@Got rid of datum indirection.
@
text
@a0 2


d6 1
a6 1
#include "c.h"
d8 2
a10 8
#include "buf.h"
#include "datum.h"
#include "genam.h"
#include "itup.h"
#include "itemid.h"
#include "page.h"
#include "rel.h"
#include "skey.h"
d12 4
a15 1
#include "iqual.h"
d17 4
a20 1
RcsId("$Header: RCS/iqual.c,v 1.3 89/09/05 16:55:59 mao C_Demo_1 Locker: kemnitz $");
d83 10
a92 2
		datum = IndexTupleGetAttributeValue(tuple,
			key->data[0].attributeNumber,
d94 1
@


1.3
log
@Working version of C-only demo
@
text
@d22 1
a22 1
RcsId("$Header: /usr6/postgres/mao/postgres/src/access/genam/RCS/iqual.c,v 1.2 89/03/22 02:48:01 muir Stab $");
d95 1
a95 1
				key->data[0].argument.pointer.value, datum);
d99 1
a99 1
				key->data[0].argument.pointer.value);
@


1.2
log
@copyright delete
@
text
@d22 1
a22 1
RcsId("$Header: iqual.c,v 1.1 89/01/17 05:51:55 muir Locked $");
@


1.1
log
@Initial revision
@
text
@a1 23
/*
 * 
 * POSTGRES Data Base Management System
 * 
 * Copyright (c) 1988 Regents of the University of California
 * 
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for educational, research, and non-profit purposes and
 * without fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation, and that
 * the name of the University of California not be used in advertising
 * or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Permission to incorporate this
 * software into commercial products can be obtained from the Campus
 * Software Office, 295 Evans Hall, University of California, Berkeley,
 * Ca., 94720 provided only that the the requestor give the University
 * of California a free licence to any derived software for educational
 * and research purposes.  The University of California makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 * 
 */
a2 2


d22 1
a22 1
RcsId("$Header: iqual.c,v 1.1 88/11/11 16:35:33 postgres Exp $");
@
