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


1.6
date     90.09.25.17.16.10;  author kemnitz;  state Exp;
branches ;
next     1.5;

1.5
date     89.09.05.16.55.38;  author mao;  state C_Demo_1;
branches ;
next     1.4;

1.4
date     89.08.09.18.13.28;  author cimarron;  state Exp;
branches ;
next     1.3;

1.3
date     89.03.22.02.47.31;  author muir;  state Stab;
branches ;
next     1.2;

1.2
date     89.02.02.16.22.39;  author dillon;  state Exp;
branches ;
next     1.1;

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


desc
@@


1.6
log
@update
@
text
@/*
 * InsertIndexTuple.c
 *
 * Note:
 * Inserts an indextuple into the index relation.
 *
 * Note: the last 3 parameters are not used in the routine.
 *       Should be removed.
 */

#include "tmp/postgres.h"

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

#include "access/attnum.h"
#include "access/ftup.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/itup.h"
#include "access/newam.h"
#include "access/relscan.h"
#include "access/skey.h"

#include "rules/rlock.h"
#include "storage/form.h"
#include "utils/rel.h"
#include "utils/log.h"

void
InsertIndexTuple(heapRelation, indexRelation, numberOfAttributes, 
		 attributeNumber, heapTuple, 
		 indexStrategy, parameterCount, parameter)
	Relation	heapRelation;
	Relation	indexRelation;
	AttributeNumber	numberOfAttributes;
	AttributeNumber	attributeNumber[];
        HeapTuple          heapTuple;
	IndexStrategy	indexStrategy;
	uint16		parameterCount;
	Datum		parameter[];
{
	HeapScanDesc	scan;
	Buffer		buffer;
	AttributeNumber	attributeIndex;
	IndexTuple	indexTuple;
	TupleDescriptor	heapDescriptor;
	TupleDescriptor	indexDescriptor;
	Datum		*datum;
	Boolean		*null;

	char		*dom[2];
	extern		HasCached;
	extern	char	CachedClass[];
	extern		fillCached();
	GeneralInsertIndexResult	insertResult;

	/* more & better checking is needed */
	Assert(ObjectIdIsValid(indexRelation->rd_rel->relam));	/* XXX */

	datum = LintCast(Datum *, palloc(numberOfAttributes * sizeof *datum));
	null = LintCast(Boolean *, palloc(numberOfAttributes * sizeof *null));

	heapDescriptor = RelationGetTupleDescriptor(heapRelation);
	indexDescriptor = RelationGetTupleDescriptor(indexRelation);

	Assert(HeapTupleIsValid(heapTuple));
	for (attributeIndex = 1; attributeIndex <= numberOfAttributes;
	     attributeIndex += 1) {
	  
	  AttributeOffset	attributeOffset;
	  Boolean		attributeIsNull;
	  
	  attributeOffset = AttributeNumberGetAttributeOffset(
							      attributeIndex);
	  datum[attributeOffset] =
	    HeapTupleGetAttributeValue(heapTuple, buffer,
				       attributeNumber[attributeOffset],
				       heapDescriptor, &attributeIsNull);
	  null[attributeOffset] =	(attributeIsNull) ? 'n' : ' ';
	  /* XXX constants are better */
		}
	indexTuple = FormIndexTuple(numberOfAttributes, indexDescriptor,
				    datum, null);
/*	elog(DEBUG, "defaultbuild: indextuple is %d", indexTuple); */

	indexTuple->t_tid = heapTuple->t_ctid;

	insertResult = RelationInsertIndexTuple(indexRelation,
						indexTuple, 
						(Pointer)NULL, (double *)NULL);
/*	elog(DEBUG,"defaultbuild: insertResult is %d", insertResult); */
	
	pfree(indexTuple);
	
	
	/*	HeapScanEnd(scan); */
	
	pfree(null);
	pfree(datum);
}


@


1.5
log
@Working version of C-only demo
@
text
@a0 2


d11 1
a11 1
#include "c.h"
d13 1
a13 12
#include "attnum.h"
#include "form.h"
#include "ftup.h"
#include "datum.h"
#include "genam.h"
#include "heapam.h"
#include "itup.h"
#include "rel.h"
#include "relscan.h"
#include "rlock.h"
#include "skey.h"
#include "log.h"
d15 8
a22 1
#include "newam.h"
d24 4
a27 1
RcsId("$Header: /usr6/postgres/mao/postgres/src/access/genam/RCS/InsertIndexTuple.c,v 1.4 89/08/09 18:13:28 cimarron Exp $"); 
@


1.4
log
@"retrieve(x=1)"
@
text
@d30 1
a30 1
RcsId("$Header: /usr6/postgres/cimarron/postgres3/src/access/genam/RCS/InsertIndexTuple.c,v 1.3 89/03/22 02:47:31 muir Stab $"); 
@


1.3
log
@copyright delete
@
text
@d30 1
a30 1
RcsId("$Header: InsertIndexTuple.c,v 1.2 89/02/02 16:22:39 muir Locked $"); 
d45 1
a45 1
	HeapScan	scan;
@


1.2
log
@Txfer from old tree
@
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


d30 1
a30 1
RcsId("$Header: InsertIndexTuple.c,v 1.1 89/01/17 05:51:51 dillon Locked $"); 
@


1.1
log
@Initial revision
@
text
@d55 1
a55 1
RcsId("$Header: InsertIndexTuple.c,v 1.1 88/11/11 16:35:29 postgres Exp $"); 
@
