mirror of https://github.com/postgres/postgres
parent
e075271c17
commit
e9e1ff226f
@ -1,69 +0,0 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* 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)); |
||||
} |
@ -1,86 +0,0 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* sysfunc.c-- |
||||
* process system functions and return a string result |
||||
* |
||||
* Notes: |
||||
* 1) I return a string result because most of the functions cannot return any |
||||
* normal type anyway (e.g. SYS_DATE, SYS_TIME, etc...), and the few that |
||||
* might (SYS_UID or whatever) can just return it as a string - no problem. |
||||
* This keeps the function flexible enough to be of good use. |
||||
* |
||||
* Written by Chad Robinson, chadr@brttech.com |
||||
* Last modified: 04/27/1996 |
||||
* ------------------------------------------------------------------------- |
||||
*/ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <time.h> |
||||
|
||||
#include <config.h> |
||||
#include <postgres.h> |
||||
#include <miscadmin.h> |
||||
#include <parser/sysfunc.h> |
||||
|
||||
/*
|
||||
* Can't get much more obvious than this. Might need to replace localtime() |
||||
* on older systems... |
||||
*/ |
||||
static char * |
||||
Sysfunc_system_date(void) |
||||
{ |
||||
time_t cur_time_secs; |
||||
struct tm *cur_time_expanded; |
||||
static char buf[12]; /* Just for safety, y'understand... */ |
||||
|
||||
time(&cur_time_secs); |
||||
cur_time_expanded = localtime(&cur_time_secs); |
||||
if (EuroDates == 1) |
||||
sprintf(buf, "%2.2d-%2.2d-%4.4d", cur_time_expanded->tm_mday, |
||||
cur_time_expanded->tm_mon + 1, cur_time_expanded->tm_year + 1900); |
||||
else |
||||
sprintf(buf, "%2.2d-%2.2d-%4.4d", cur_time_expanded->tm_mon + 1, |
||||
cur_time_expanded->tm_mday, cur_time_expanded->tm_year + 1900); |
||||
|
||||
return &buf[0]; |
||||
} |
||||
|
||||
static char * |
||||
Sysfunc_system_time(void) |
||||
{ |
||||
time_t cur_time_secs; |
||||
struct tm *cur_time_expanded; |
||||
static char buf[10]; /* Just for safety, y'understand... */ |
||||
|
||||
time(&cur_time_secs); |
||||
cur_time_expanded = localtime(&cur_time_secs); |
||||
sprintf(buf, "%2.2d:%2.2d:%2.2d", cur_time_expanded->tm_hour, |
||||
cur_time_expanded->tm_min, cur_time_expanded->tm_sec); |
||||
|
||||
return &buf[0]; |
||||
} |
||||
|
||||
char * |
||||
SystemFunctionHandler(char *funct) |
||||
{ |
||||
if (!strcmp(funct, "SYS_DATE")) |
||||
return Sysfunc_system_date(); |
||||
if (!strcmp(funct, "SYS_TIME")) |
||||
return Sysfunc_system_time(); |
||||
return "*unknown function*"; |
||||
} |
||||
|
||||
#ifdef SYSFUNC_TEST |
||||
/*
|
||||
* Chad's rule of coding #4 - never delete a test function, even a stupid |
||||
* one - you always need it 10 minutes after you delete it. |
||||
*/ |
||||
void |
||||
main(void) |
||||
{ |
||||
printf("Current system date: %s\n", SystemFunctionHandler("SYS_DATE")); |
||||
return; |
||||
} |
||||
|
||||
#endif |
@ -1,9 +0,0 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* sysfunc.h-- |
||||
* support for system functions |
||||
* |
||||
* ------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
extern char *SystemFunctionHandler(char *funct); |
Loading…
Reference in new issue