aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/prep/archive.c
blob: d053bd61a3d4d38c12eefd309223715123808838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*-------------------------------------------------------------------------
 *
 * archive.c--
 *	  Support for planning scans on archived relations
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *	  $Header: /cvsroot/pgsql/src/backend/optimizer/prep/Attic/archive.c,v 1.4 1997/09/08 21:45:29 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */
#include <stdio.h>				/* for sprintf() */
#include <sys/types.h>			/* for u_int in relcache.h */
#include "postgres.h"

#include "utils/rel.h"
#include "utils/elog.h"
#include "utils/palloc.h"
#include "utils/relcache.h"
#include "catalog/pg_class.h"
#include "nodes/pg_list.h"
#include "nodes/parsenodes.h"
#include "optimizer/prep.h"
#include "commands/creatinh.h"

void
plan_archive(List *rt)
{
	List	   *rtitem;
	RangeTblEntry *rte;
	TimeRange  *trange;
	Relation	r;
	Oid			reloid;

	foreach(rtitem, rt)
	{
		rte = lfirst(rtitem);
		trange = rte->timeRange;
		if (trange)
		{
			reloid = rte->relid;
			r = RelationIdGetRelation(reloid);
			if (r->rd_rel->relarch != 'n')
			{
				rte->archive = true;
			}
		}
	}
}


/*
 *	find_archive_rels -- Given a particular relid, find the archive
 *						 relation's relid.
 */
List	   *
find_archive_rels(Oid relid)
{
	Relation	arel;
	char	   *arelName;

	arelName = MakeArchiveName(relid);
	arel = RelationNameGetRelation(arelName);
	pfree(arelName);

	return lconsi(arel->rd_id, lconsi(relid, NIL));
}