mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
This commit is contained in:
@@ -40,21 +40,21 @@
|
|||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/elog.h"
|
#include "utils/elog.h"
|
||||||
|
|
||||||
static int32
|
static int32
|
||||||
array_iterator(Oid elemtype, Oid proc, int and, ArrayType * array, Datum value)
|
array_iterator(Oid elemtype, Oid proc, int and, ArrayType * array, Datum value)
|
||||||
{
|
{
|
||||||
HeapTuple typ_tuple;
|
HeapTuple typ_tuple;
|
||||||
TypeTupleForm typ_struct;
|
TypeTupleForm typ_struct;
|
||||||
bool typbyval;
|
bool typbyval;
|
||||||
int typlen;
|
int typlen;
|
||||||
func_ptr proc_fn;
|
func_ptr proc_fn;
|
||||||
int pronargs;
|
int pronargs;
|
||||||
int nitems,
|
int nitems,
|
||||||
i,
|
i,
|
||||||
result;
|
result;
|
||||||
int ndim,
|
int ndim,
|
||||||
*dim;
|
*dim;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
if ((array == (ArrayType *) NULL)
|
if ((array == (ArrayType *) NULL)
|
||||||
@@ -101,16 +101,16 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType * array, Datum value)
|
|||||||
{
|
{
|
||||||
switch (typlen)
|
switch (typlen)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
result = (int) (*proc_fn) (*p, value);
|
result = (int) (*proc_fn) (*p, value);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
result = (int) (*proc_fn) (*(int16 *) p, value);
|
result = (int) (*proc_fn) (*(int16 *) p, value);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
result = (int) (*proc_fn) (*(int32 *) p, value);
|
result = (int) (*proc_fn) (*(int32 *) p, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p += typlen;
|
p += typlen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,33 +13,34 @@
|
|||||||
#include "utils/datetime.h"
|
#include "utils/datetime.h"
|
||||||
|
|
||||||
|
|
||||||
TimeADT *
|
TimeADT *
|
||||||
time_difference(TimeADT * time1, TimeADT * time2)
|
time_difference(TimeADT * time1, TimeADT * time2)
|
||||||
{
|
{
|
||||||
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
||||||
|
|
||||||
*result = *time1 - *time2;
|
*result = *time1 - *time2;
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeADT *
|
TimeADT *
|
||||||
currenttime()
|
currenttime()
|
||||||
{
|
{
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
||||||
|
|
||||||
current_time = time(NULL);
|
current_time = time(NULL);
|
||||||
tm = localtime(¤t_time);
|
tm = localtime(¤t_time);
|
||||||
*result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec);
|
*result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
DateADT
|
DateADT
|
||||||
currentdate()
|
currentdate()
|
||||||
{
|
{
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
DateADT result;
|
DateADT result;
|
||||||
|
|
||||||
current_time = time(NULL);
|
current_time = time(NULL);
|
||||||
tm = localtime(¤t_time);
|
tm = localtime(¤t_time);
|
||||||
@@ -48,6 +49,7 @@ currentdate()
|
|||||||
date2j(100, 1, 1);
|
date2j(100, 1, 1);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int4
|
int4
|
||||||
hours(TimeADT * time)
|
hours(TimeADT * time)
|
||||||
{
|
{
|
||||||
@@ -65,47 +67,52 @@ seconds(TimeADT * time)
|
|||||||
{
|
{
|
||||||
return (((int) *time) % 60);
|
return (((int) *time) % 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
int4
|
int4
|
||||||
day(DateADT * date)
|
day(DateADT * date)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
j2date((*date + date2j(2000, 1, 1)),
|
j2date((*date + date2j(2000, 1, 1)),
|
||||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
||||||
|
|
||||||
return (tm.tm_mday);
|
return (tm.tm_mday);
|
||||||
}
|
}
|
||||||
|
|
||||||
int4
|
int4
|
||||||
month(DateADT * date)
|
month(DateADT * date)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
j2date((*date + date2j(2000, 1, 1)),
|
j2date((*date + date2j(2000, 1, 1)),
|
||||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
||||||
|
|
||||||
return (tm.tm_mon);
|
return (tm.tm_mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
int4
|
int4
|
||||||
year(DateADT * date)
|
year(DateADT * date)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
j2date((*date + date2j(2000, 1, 1)),
|
j2date((*date + date2j(2000, 1, 1)),
|
||||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
||||||
|
|
||||||
return (tm.tm_year);
|
return (tm.tm_year);
|
||||||
}
|
}
|
||||||
|
|
||||||
int4
|
int4
|
||||||
asminutes(TimeADT * time)
|
asminutes(TimeADT * time)
|
||||||
{
|
{
|
||||||
int seconds = (int) *time;
|
int seconds = (int) *time;
|
||||||
|
|
||||||
return (seconds / 60);
|
return (seconds / 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
int4
|
int4
|
||||||
asseconds(TimeADT * time)
|
asseconds(TimeADT * time)
|
||||||
{
|
{
|
||||||
int seconds = (int) *time;
|
int seconds = (int) *time;
|
||||||
|
|
||||||
return (seconds);
|
return (seconds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_64BIT_INTS
|
#ifndef HAVE_64BIT_INTS
|
||||||
typedef char [8] int64;
|
typedef char[8] int64;
|
||||||
|
|
||||||
#elif defined(__alpha)
|
#elif defined(__alpha)
|
||||||
typedef long int int64;
|
typedef long int int64;
|
||||||
@@ -44,40 +44,40 @@ typedef long int int64;
|
|||||||
#define INT64_FORMAT "%ld"
|
#define INT64_FORMAT "%ld"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int64 *int8in(char *str);
|
int64 *int8in(char *str);
|
||||||
char *int8out(int64 * val);
|
char *int8out(int64 * val);
|
||||||
|
|
||||||
bool int8eq(int64 * val1, int64 * val2);
|
bool int8eq(int64 * val1, int64 * val2);
|
||||||
bool int8ne(int64 * val1, int64 * val2);
|
bool int8ne(int64 * val1, int64 * val2);
|
||||||
bool int8lt(int64 * val1, int64 * val2);
|
bool int8lt(int64 * val1, int64 * val2);
|
||||||
bool int8gt(int64 * val1, int64 * val2);
|
bool int8gt(int64 * val1, int64 * val2);
|
||||||
bool int8le(int64 * val1, int64 * val2);
|
bool int8le(int64 * val1, int64 * val2);
|
||||||
bool int8ge(int64 * val1, int64 * val2);
|
bool int8ge(int64 * val1, int64 * val2);
|
||||||
|
|
||||||
bool int84eq(int64 * val1, int32 val2);
|
bool int84eq(int64 * val1, int32 val2);
|
||||||
bool int84ne(int64 * val1, int32 val2);
|
bool int84ne(int64 * val1, int32 val2);
|
||||||
bool int84lt(int64 * val1, int32 val2);
|
bool int84lt(int64 * val1, int32 val2);
|
||||||
bool int84gt(int64 * val1, int32 val2);
|
bool int84gt(int64 * val1, int32 val2);
|
||||||
bool int84le(int64 * val1, int32 val2);
|
bool int84le(int64 * val1, int32 val2);
|
||||||
bool int84ge(int64 * val1, int32 val2);
|
bool int84ge(int64 * val1, int32 val2);
|
||||||
|
|
||||||
int64 *int8um(int64 * val);
|
int64 *int8um(int64 * val);
|
||||||
int64 *int8pl(int64 * val1, int64 * val2);
|
int64 *int8pl(int64 * val1, int64 * val2);
|
||||||
int64 *int8mi(int64 * val1, int64 * val2);
|
int64 *int8mi(int64 * val1, int64 * val2);
|
||||||
int64 *int8mul(int64 * val1, int64 * val2);
|
int64 *int8mul(int64 * val1, int64 * val2);
|
||||||
int64 *int8div(int64 * val1, int64 * val2);
|
int64 *int8div(int64 * val1, int64 * val2);
|
||||||
|
|
||||||
int64 *int48(int32 val);
|
int64 *int48(int32 val);
|
||||||
int32 int84(int64 * val);
|
int32 int84(int64 * val);
|
||||||
|
|
||||||
#if FALSE
|
#if FALSE
|
||||||
int64 *int28(int16 val);
|
int64 *int28(int16 val);
|
||||||
int16 int82(int64 * val);
|
int16 int82(int64 * val);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float64 i8tod(int64 * val);
|
float64 i8tod(int64 * val);
|
||||||
int64 *dtoi8(float64 val);
|
int64 *dtoi8(float64 val);
|
||||||
|
|
||||||
#if USE_LOCAL_CODE
|
#if USE_LOCAL_CODE
|
||||||
|
|
||||||
@@ -103,10 +103,10 @@ int64 *dtoi8(float64 val);
|
|||||||
|
|
||||||
/* int8in()
|
/* int8in()
|
||||||
*/
|
*/
|
||||||
int64 *
|
int64 *
|
||||||
int8in(char *str)
|
int8in(char *str)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
#if HAVE_64BIT_INTS
|
#if HAVE_64BIT_INTS
|
||||||
if (!PointerIsValid(str))
|
if (!PointerIsValid(str))
|
||||||
@@ -126,13 +126,13 @@ int8in(char *str)
|
|||||||
|
|
||||||
/* int8out()
|
/* int8out()
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
int8out(int64 * val)
|
int8out(int64 * val)
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
char buf[MAXINT8LEN + 1];
|
char buf[MAXINT8LEN + 1];
|
||||||
|
|
||||||
#if HAVE_64BIT_INTS
|
#if HAVE_64BIT_INTS
|
||||||
if (!PointerIsValid(val))
|
if (!PointerIsValid(val))
|
||||||
@@ -242,10 +242,10 @@ int84ge(int64 * val1, int32 val2)
|
|||||||
* Arithmetic operators on 64-bit integers.
|
* Arithmetic operators on 64-bit integers.
|
||||||
*---------------------------------------------------------*/
|
*---------------------------------------------------------*/
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
int8um(int64 * val)
|
int8um(int64 * val)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
if (!PointerIsValid(val))
|
if (!PointerIsValid(val))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -255,10 +255,10 @@ int8um(int64 * val)
|
|||||||
return (result);
|
return (result);
|
||||||
} /* int8um() */
|
} /* int8um() */
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
int8pl(int64 * val1, int64 * val2)
|
int8pl(int64 * val1, int64 * val2)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -268,10 +268,10 @@ int8pl(int64 * val1, int64 * val2)
|
|||||||
return (result);
|
return (result);
|
||||||
} /* int8pl() */
|
} /* int8pl() */
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
int8mi(int64 * val1, int64 * val2)
|
int8mi(int64 * val1, int64 * val2)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -281,10 +281,10 @@ int8mi(int64 * val1, int64 * val2)
|
|||||||
return (result);
|
return (result);
|
||||||
} /* int8mi() */
|
} /* int8mi() */
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
int8mul(int64 * val1, int64 * val2)
|
int8mul(int64 * val1, int64 * val2)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -294,10 +294,10 @@ int8mul(int64 * val1, int64 * val2)
|
|||||||
return (result);
|
return (result);
|
||||||
} /* int8mul() */
|
} /* int8mul() */
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
int8div(int64 * val1, int64 * val2)
|
int8div(int64 * val1, int64 * val2)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -312,10 +312,10 @@ int8div(int64 * val1, int64 * val2)
|
|||||||
* Conversion operators.
|
* Conversion operators.
|
||||||
*---------------------------------------------------------*/
|
*---------------------------------------------------------*/
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
int48(int32 val)
|
int48(int32 val)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
*result = val;
|
*result = val;
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ int48(int32 val)
|
|||||||
int32
|
int32
|
||||||
int84(int64 * val)
|
int84(int64 * val)
|
||||||
{
|
{
|
||||||
int32 result;
|
int32 result;
|
||||||
|
|
||||||
if (!PointerIsValid(val))
|
if (!PointerIsValid(val))
|
||||||
elog(WARN, "Invalid (null) int64, can't convert int8 to int4", NULL);
|
elog(WARN, "Invalid (null) int64, can't convert int8 to int4", NULL);
|
||||||
@@ -339,10 +339,10 @@ int84(int64 * val)
|
|||||||
} /* int84() */
|
} /* int84() */
|
||||||
|
|
||||||
#if FALSE
|
#if FALSE
|
||||||
int64 *
|
int64 *
|
||||||
int28(int16 val)
|
int28(int16 val)
|
||||||
{
|
{
|
||||||
int64 *result;
|
int64 *result;
|
||||||
|
|
||||||
if (!PointerIsValid(result = PALLOCTYPE(int64)))
|
if (!PointerIsValid(result = PALLOCTYPE(int64)))
|
||||||
elog(WARN, "Memory allocation failed, can't convert int8 to int2", NULL);
|
elog(WARN, "Memory allocation failed, can't convert int8 to int2", NULL);
|
||||||
@@ -355,7 +355,7 @@ int28(int16 val)
|
|||||||
int16
|
int16
|
||||||
int82(int64 * val)
|
int82(int64 * val)
|
||||||
{
|
{
|
||||||
int16 result;
|
int16 result;
|
||||||
|
|
||||||
if (!PointerIsValid(val))
|
if (!PointerIsValid(val))
|
||||||
elog(WARN, "Invalid (null) int8, can't convert to int2", NULL);
|
elog(WARN, "Invalid (null) int8, can't convert to int2", NULL);
|
||||||
@@ -370,17 +370,17 @@ int82(int64 * val)
|
|||||||
float64
|
float64
|
||||||
i8tod(int64 * val)
|
i8tod(int64 * val)
|
||||||
{
|
{
|
||||||
float64 result = PALLOCTYPE(float64data);
|
float64 result = PALLOCTYPE(float64data);
|
||||||
|
|
||||||
*result = *val;
|
*result = *val;
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
} /* i8tod() */
|
} /* i8tod() */
|
||||||
|
|
||||||
int64 *
|
int64 *
|
||||||
dtoi8(float64 val)
|
dtoi8(float64 val)
|
||||||
{
|
{
|
||||||
int64 *result = PALLOCTYPE(int64);
|
int64 *result = PALLOCTYPE(int64);
|
||||||
|
|
||||||
if ((*val < (-pow(2, 64) + 1)) || (*val > (pow(2, 64) - 1)))
|
if ((*val < (-pow(2, 64) + 1)) || (*val > (pow(2, 64) - 1)))
|
||||||
elog(WARN, "Floating point conversion to int64 is out of range", NULL);
|
elog(WARN, "Floating point conversion to int64 is out of range", NULL);
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ void
|
|||||||
halt(va_alist)
|
halt(va_alist)
|
||||||
va_dcl
|
va_dcl
|
||||||
{
|
{
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
char *format,
|
char *format,
|
||||||
*pstr;
|
*pstr;
|
||||||
void (*sig_func) ();
|
void (*sig_func) ();
|
||||||
|
|
||||||
va_start(arg_ptr);
|
va_start(arg_ptr);
|
||||||
format = va_arg(arg_ptr, char *);
|
format = va_arg(arg_ptr, char *);
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void halt();
|
void halt();
|
||||||
|
|||||||
@@ -13,17 +13,17 @@
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char query[4000];
|
char query[4000];
|
||||||
int row = 1;
|
int row = 1;
|
||||||
int aint;
|
int aint;
|
||||||
float afloat;
|
float afloat;
|
||||||
double adouble;
|
double adouble;
|
||||||
char achar[11],
|
char achar[11],
|
||||||
achar16[17],
|
achar16[17],
|
||||||
abpchar[11],
|
abpchar[11],
|
||||||
avarchar[51],
|
avarchar[51],
|
||||||
atext[51];
|
atext[51];
|
||||||
time_t aabstime;
|
time_t aabstime;
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
halt("Usage: %s database\n", argv[0]);
|
halt("Usage: %s database\n", argv[0]);
|
||||||
|
|||||||
@@ -12,31 +12,31 @@
|
|||||||
#include "halt.h"
|
#include "halt.h"
|
||||||
#include "pginterface.h"
|
#include "pginterface.h"
|
||||||
|
|
||||||
static void sig_disconnect();
|
static void sig_disconnect();
|
||||||
static void set_signals();
|
static void set_signals();
|
||||||
|
|
||||||
#define NUL '\0'
|
#define NUL '\0'
|
||||||
|
|
||||||
/* GLOBAL VARIABLES */
|
/* GLOBAL VARIABLES */
|
||||||
static PGconn *conn;
|
static PGconn *conn;
|
||||||
static PGresult *res = NULL;
|
static PGresult *res = NULL;
|
||||||
|
|
||||||
#define ON_ERROR_STOP 0
|
#define ON_ERROR_STOP 0
|
||||||
#define ON_ERROR_CONTINUE 1
|
#define ON_ERROR_CONTINUE 1
|
||||||
|
|
||||||
static int on_error_state = ON_ERROR_STOP;
|
static int on_error_state = ON_ERROR_STOP;
|
||||||
|
|
||||||
/* LOCAL VARIABLES */
|
/* LOCAL VARIABLES */
|
||||||
static sigset_t block_sigs,
|
static sigset_t block_sigs,
|
||||||
unblock_sigs;
|
unblock_sigs;
|
||||||
static int tuple;
|
static int tuple;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** connectdb - returns PGconn structure
|
** connectdb - returns PGconn structure
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
PGconn *
|
PGconn *
|
||||||
connectdb(char *dbName,
|
connectdb(char *dbName,
|
||||||
char *pghost,
|
char *pghost,
|
||||||
char *pgport,
|
char *pgport,
|
||||||
@@ -68,7 +68,7 @@ disconnectdb()
|
|||||||
** doquery - returns PGresult structure
|
** doquery - returns PGresult structure
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
PGresult *
|
PGresult *
|
||||||
doquery(char *query)
|
doquery(char *query)
|
||||||
{
|
{
|
||||||
if (res != NULL)
|
if (res != NULL)
|
||||||
@@ -104,9 +104,9 @@ doquery(char *query)
|
|||||||
int
|
int
|
||||||
fetch(void *param,...)
|
fetch(void *param,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int arg,
|
int arg,
|
||||||
num_fields;
|
num_fields;
|
||||||
|
|
||||||
num_fields = PQnfields(res);
|
num_fields = PQnfields(res);
|
||||||
|
|
||||||
@@ -142,9 +142,9 @@ fetch(void *param,...)
|
|||||||
int
|
int
|
||||||
fetchwithnulls(void *param,...)
|
fetchwithnulls(void *param,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int arg,
|
int arg,
|
||||||
num_fields;
|
num_fields;
|
||||||
|
|
||||||
num_fields = PQnfields(res);
|
num_fields = PQnfields(res);
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PGresult *doquery(char *query);
|
PGresult *doquery(char *query);
|
||||||
PGconn *connectdb();
|
PGconn *connectdb();
|
||||||
void disconnectdb();
|
void disconnectdb();
|
||||||
int fetch(void *param,...);
|
int fetch(void *param,...);
|
||||||
int fetchwithnulls(void *param,...);
|
int fetchwithnulls(void *param,...);
|
||||||
void on_error_continue();
|
void on_error_continue();
|
||||||
void on_error_stop();
|
void on_error_stop();
|
||||||
|
|
||||||
#define END_OF_TUPLES (-1)
|
#define END_OF_TUPLES (-1)
|
||||||
|
|||||||
@@ -15,26 +15,26 @@
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char query[4000];
|
char query[4000];
|
||||||
int row = 1;
|
int row = 1;
|
||||||
int aint;
|
int aint;
|
||||||
float afloat;
|
float afloat;
|
||||||
double adouble;
|
double adouble;
|
||||||
char achar[11],
|
char achar[11],
|
||||||
achar16[17],
|
achar16[17],
|
||||||
abpchar[11],
|
abpchar[11],
|
||||||
avarchar[51],
|
avarchar[51],
|
||||||
atext[51];
|
atext[51];
|
||||||
time_t aabstime;
|
time_t aabstime;
|
||||||
int aint_null,
|
int aint_null,
|
||||||
afloat_null,
|
afloat_null,
|
||||||
adouble_null,
|
adouble_null,
|
||||||
achar_null,
|
achar_null,
|
||||||
achar16_null,
|
achar16_null,
|
||||||
abpchar_null,
|
abpchar_null,
|
||||||
avarchar_null,
|
avarchar_null,
|
||||||
atext_null,
|
atext_null,
|
||||||
aabstime_null;
|
aabstime_null;
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
halt("Usage: %s database\n", argv[0]);
|
halt("Usage: %s database\n", argv[0]);
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char query[4000];
|
char query[4000];
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int count;
|
int count;
|
||||||
char line[4000];
|
char line[4000];
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
halt("Usage: %s database\n", argv[0]);
|
halt("Usage: %s database\n", argv[0]);
|
||||||
|
|||||||
@@ -11,18 +11,18 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
/* prototype for soundex function */
|
/* prototype for soundex function */
|
||||||
char *soundex(char *instr, char *outstr);
|
char *soundex(char *instr, char *outstr);
|
||||||
|
|
||||||
text *
|
text *
|
||||||
text_soundex(text * t)
|
text_soundex(text * t)
|
||||||
{
|
{
|
||||||
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
||||||
char *table = "01230120022455012623010202";
|
char *table = "01230120022455012623010202";
|
||||||
int count = 0;
|
int count = 0;
|
||||||
text *new_t;
|
text *new_t;
|
||||||
|
|
||||||
char outstr[6 + 1]; /* max length of soundex is 6 */
|
char outstr[6 + 1]; /* max length of soundex is 6 */
|
||||||
char *instr;
|
char *instr;
|
||||||
|
|
||||||
/* make a null-terminated string */
|
/* make a null-terminated string */
|
||||||
instr = palloc(VARSIZE(t) + 1);
|
instr = palloc(VARSIZE(t) + 1);
|
||||||
@@ -47,11 +47,11 @@ text_soundex(text * t)
|
|||||||
return (new_t);
|
return (new_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
soundex(char *instr, char *outstr)
|
soundex(char *instr, char *outstr)
|
||||||
{ /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
{ /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
||||||
char *table = "01230120022455012623010202";
|
char *table = "01230120022455012623010202";
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (!isalpha(instr[0]) && instr[0])
|
while (!isalpha(instr[0]) && instr[0])
|
||||||
++instr;
|
++instr;
|
||||||
|
|||||||
@@ -45,15 +45,15 @@
|
|||||||
* representation of data.
|
* representation of data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
string_output(char *data, int size)
|
string_output(char *data, int size)
|
||||||
{
|
{
|
||||||
register unsigned char c,
|
register unsigned char c,
|
||||||
*p,
|
*p,
|
||||||
*r,
|
*r,
|
||||||
*result;
|
*result;
|
||||||
register int l,
|
register int l,
|
||||||
len;
|
len;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
{
|
{
|
||||||
@@ -74,23 +74,23 @@ string_output(char *data, int size)
|
|||||||
{
|
{
|
||||||
switch (*p)
|
switch (*p)
|
||||||
{
|
{
|
||||||
case '\\':
|
case '\\':
|
||||||
case '"':
|
case '"':
|
||||||
case '{':
|
case '{':
|
||||||
case '}':
|
case '}':
|
||||||
case '\b':
|
case '\b':
|
||||||
case '\f':
|
case '\f':
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
case '\t':
|
case '\t':
|
||||||
case '\v':
|
case '\v':
|
||||||
len++;
|
len++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (NOTPRINTABLE(*p))
|
if (NOTPRINTABLE(*p))
|
||||||
{
|
{
|
||||||
len += 3;
|
len += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len++;
|
len++;
|
||||||
@@ -101,53 +101,53 @@ string_output(char *data, int size)
|
|||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\\':
|
case '\\':
|
||||||
case '"':
|
case '"':
|
||||||
case '{':
|
case '{':
|
||||||
case '}':
|
case '}':
|
||||||
*r++ = '\\';
|
*r++ = '\\';
|
||||||
*r++ = c;
|
|
||||||
break;
|
|
||||||
case '\b':
|
|
||||||
*r++ = '\\';
|
|
||||||
*r++ = 'b';
|
|
||||||
break;
|
|
||||||
case '\f':
|
|
||||||
*r++ = '\\';
|
|
||||||
*r++ = 'f';
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
*r++ = '\\';
|
|
||||||
*r++ = 'n';
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
*r++ = '\\';
|
|
||||||
*r++ = 'r';
|
|
||||||
break;
|
|
||||||
case '\t':
|
|
||||||
*r++ = '\\';
|
|
||||||
*r++ = 't';
|
|
||||||
break;
|
|
||||||
case '\v':
|
|
||||||
*r++ = '\\';
|
|
||||||
*r++ = 'v';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (NOTPRINTABLE(c))
|
|
||||||
{
|
|
||||||
*r = '\\';
|
|
||||||
r += 3;
|
|
||||||
*r-- = DIGIT(c & 07);
|
|
||||||
c >>= 3;
|
|
||||||
*r-- = DIGIT(c & 07);
|
|
||||||
c >>= 3;
|
|
||||||
*r = DIGIT(c & 03);
|
|
||||||
r += 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*r++ = c;
|
*r++ = c;
|
||||||
}
|
break;
|
||||||
|
case '\b':
|
||||||
|
*r++ = '\\';
|
||||||
|
*r++ = 'b';
|
||||||
|
break;
|
||||||
|
case '\f':
|
||||||
|
*r++ = '\\';
|
||||||
|
*r++ = 'f';
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
*r++ = '\\';
|
||||||
|
*r++ = 'n';
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
*r++ = '\\';
|
||||||
|
*r++ = 'r';
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
*r++ = '\\';
|
||||||
|
*r++ = 't';
|
||||||
|
break;
|
||||||
|
case '\v':
|
||||||
|
*r++ = '\\';
|
||||||
|
*r++ = 'v';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (NOTPRINTABLE(c))
|
||||||
|
{
|
||||||
|
*r = '\\';
|
||||||
|
r += 3;
|
||||||
|
*r-- = DIGIT(c & 07);
|
||||||
|
c >>= 3;
|
||||||
|
*r-- = DIGIT(c & 07);
|
||||||
|
c >>= 3;
|
||||||
|
*r = DIGIT(c & 03);
|
||||||
|
r += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*r++ = c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*r = '\0';
|
*r = '\0';
|
||||||
@@ -181,13 +181,13 @@ string_output(char *data, int size)
|
|||||||
* a pointer to the new string or the header.
|
* a pointer to the new string or the header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
string_input(char *str, int size, int hdrsize, int *rtn_size)
|
string_input(char *str, int size, int hdrsize, int *rtn_size)
|
||||||
{
|
{
|
||||||
register unsigned char *p,
|
register unsigned char *p,
|
||||||
*r;
|
*r;
|
||||||
unsigned char *result;
|
unsigned char *result;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if ((str == NULL) || (hdrsize < 0))
|
if ((str == NULL) || (hdrsize < 0))
|
||||||
{
|
{
|
||||||
@@ -247,48 +247,48 @@ string_input(char *str, int size, int hdrsize, int *rtn_size)
|
|||||||
{
|
{
|
||||||
switch (c = *p++)
|
switch (c = *p++)
|
||||||
{
|
{
|
||||||
case '\0':
|
case '\0':
|
||||||
p--;
|
p--;
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
case '5':
|
case '5':
|
||||||
case '6':
|
case '6':
|
||||||
case '7':
|
case '7':
|
||||||
c = VALUE(c);
|
c = VALUE(c);
|
||||||
if (isdigit(*p))
|
if (isdigit(*p))
|
||||||
{
|
{
|
||||||
c = (c << 3) + VALUE(*p++);
|
c = (c << 3) + VALUE(*p++);
|
||||||
}
|
}
|
||||||
if (isdigit(*p))
|
if (isdigit(*p))
|
||||||
{
|
{
|
||||||
c = (c << 3) + VALUE(*p++);
|
c = (c << 3) + VALUE(*p++);
|
||||||
}
|
}
|
||||||
*r++ = c;
|
*r++ = c;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
*r++ = '\b';
|
*r++ = '\b';
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
*r++ = '\f';
|
*r++ = '\f';
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
*r++ = '\n';
|
*r++ = '\n';
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
*r++ = '\r';
|
*r++ = '\r';
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
*r++ = '\t';
|
*r++ = '\t';
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
*r++ = '\v';
|
*r++ = '\v';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*r++ = c;
|
*r++ = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -300,10 +300,10 @@ string_input(char *str, int size, int hdrsize, int *rtn_size)
|
|||||||
return ((char *) result);
|
return ((char *) result);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_charout(int32 c)
|
c_charout(int32 c)
|
||||||
{
|
{
|
||||||
char str[2];
|
char str[2];
|
||||||
|
|
||||||
str[0] = (char) c;
|
str[0] = (char) c;
|
||||||
str[1] = '\0';
|
str[1] = '\0';
|
||||||
@@ -311,25 +311,25 @@ c_charout(int32 c)
|
|||||||
return (string_output(str, 1));
|
return (string_output(str, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_char2out(uint16 s)
|
c_char2out(uint16 s)
|
||||||
{
|
{
|
||||||
return (string_output((char *) &s, 2));
|
return (string_output((char *) &s, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_char4out(uint32 s)
|
c_char4out(uint32 s)
|
||||||
{
|
{
|
||||||
return (string_output((char *) &s, 4));
|
return (string_output((char *) &s, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_char8out(char *s)
|
c_char8out(char *s)
|
||||||
{
|
{
|
||||||
return (string_output(s, 8));
|
return (string_output(s, 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_char16out(char *s)
|
c_char16out(char *s)
|
||||||
{
|
{
|
||||||
return (string_output(s, 16));
|
return (string_output(s, 16));
|
||||||
@@ -339,11 +339,11 @@ c_char16out(char *s)
|
|||||||
* This can be used for text, bytea, SET and unknown data types
|
* This can be used for text, bytea, SET and unknown data types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_textout(struct varlena * vlena)
|
c_textout(struct varlena * vlena)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
|
|
||||||
if (vlena)
|
if (vlena)
|
||||||
{
|
{
|
||||||
@@ -357,10 +357,10 @@ c_textout(struct varlena * vlena)
|
|||||||
* This can be used for varchar and bpchar strings
|
* This can be used for varchar and bpchar strings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_varcharout(char *s)
|
c_varcharout(char *s)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
@@ -375,7 +375,7 @@ struct varlena *
|
|||||||
c_textin(char *str)
|
c_textin(char *str)
|
||||||
{
|
{
|
||||||
struct varlena *result;
|
struct varlena *result;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
@@ -388,7 +388,7 @@ c_textin(char *str)
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
c_char16in(char *str)
|
c_char16in(char *str)
|
||||||
{
|
{
|
||||||
return (string_input(str, 16, 0, NULL));
|
return (string_input(str, 16, 0, NULL));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.22 1997/09/07 04:37:30 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.23 1997/09/08 02:19:47 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* The old interface functions have been converted to macros
|
* The old interface functions have been converted to macros
|
||||||
@@ -53,9 +53,9 @@ ComputeDataSize(TupleDesc tupleDesc,
|
|||||||
Datum value[],
|
Datum value[],
|
||||||
char nulls[])
|
char nulls[])
|
||||||
{
|
{
|
||||||
uint32 data_length;
|
uint32 data_length;
|
||||||
int i;
|
int i;
|
||||||
int numberOfAttributes = tupleDesc->natts;
|
int numberOfAttributes = tupleDesc->natts;
|
||||||
AttributeTupleForm *att = tupleDesc->attrs;
|
AttributeTupleForm *att = tupleDesc->attrs;
|
||||||
|
|
||||||
for (data_length = 0, i = 0; i < numberOfAttributes; i++)
|
for (data_length = 0, i = 0; i < numberOfAttributes; i++)
|
||||||
@@ -65,41 +65,41 @@ ComputeDataSize(TupleDesc tupleDesc,
|
|||||||
|
|
||||||
switch (att[i]->attlen)
|
switch (att[i]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the size of the disk representation and so must
|
* This is the size of the disk representation and so must
|
||||||
* include the additional sizeof long.
|
* include the additional sizeof long.
|
||||||
*/
|
*/
|
||||||
if (att[i]->attalign == 'd')
|
if (att[i]->attalign == 'd')
|
||||||
{
|
{
|
||||||
data_length = DOUBLEALIGN(data_length)
|
data_length = DOUBLEALIGN(data_length)
|
||||||
+ VARSIZE(DatumGetPointer(value[i]));
|
+ VARSIZE(DatumGetPointer(value[i]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data_length = INTALIGN(data_length)
|
data_length = INTALIGN(data_length)
|
||||||
+ VARSIZE(DatumGetPointer(value[i]));
|
+ VARSIZE(DatumGetPointer(value[i]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
data_length++;
|
data_length++;
|
||||||
break;
|
break;
|
||||||
case sizeof(short):
|
case sizeof(short):
|
||||||
data_length = SHORTALIGN(data_length + sizeof(short));
|
data_length = SHORTALIGN(data_length + sizeof(short));
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
data_length = INTALIGN(data_length + sizeof(int32));
|
data_length = INTALIGN(data_length + sizeof(int32));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (att[i]->attlen < sizeof(int32))
|
if (att[i]->attlen < sizeof(int32))
|
||||||
elog(WARN, "ComputeDataSize: attribute %d has len %d",
|
elog(WARN, "ComputeDataSize: attribute %d has len %d",
|
||||||
i, att[i]->attlen);
|
i, att[i]->attlen);
|
||||||
if (att[i]->attalign == 'd')
|
if (att[i]->attalign == 'd')
|
||||||
data_length = DOUBLEALIGN(data_length) + att[i]->attlen;
|
data_length = DOUBLEALIGN(data_length) + att[i]->attlen;
|
||||||
else
|
else
|
||||||
data_length = LONGALIGN(data_length) + att[i]->attlen;
|
data_length = LONGALIGN(data_length) + att[i]->attlen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +118,11 @@ DataFill(char *data,
|
|||||||
char *infomask,
|
char *infomask,
|
||||||
bits8 * bit)
|
bits8 * bit)
|
||||||
{
|
{
|
||||||
bits8 *bitP = 0;
|
bits8 *bitP = 0;
|
||||||
int bitmask = 0;
|
int bitmask = 0;
|
||||||
uint32 data_length;
|
uint32 data_length;
|
||||||
int i;
|
int i;
|
||||||
int numberOfAttributes = tupleDesc->natts;
|
int numberOfAttributes = tupleDesc->natts;
|
||||||
AttributeTupleForm *att = tupleDesc->attrs;
|
AttributeTupleForm *att = tupleDesc->attrs;
|
||||||
|
|
||||||
if (bit != NULL)
|
if (bit != NULL)
|
||||||
@@ -159,58 +159,58 @@ DataFill(char *data,
|
|||||||
|
|
||||||
switch (att[i]->attlen)
|
switch (att[i]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
*infomask |= HEAP_HASVARLENA;
|
*infomask |= HEAP_HASVARLENA;
|
||||||
if (att[i]->attalign == 'd')
|
if (att[i]->attalign == 'd')
|
||||||
{
|
{
|
||||||
data = (char *) DOUBLEALIGN(data);
|
data = (char *) DOUBLEALIGN(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
data = (char *) INTALIGN(data);
|
||||||
|
}
|
||||||
|
data_length = VARSIZE(DatumGetPointer(value[i]));
|
||||||
|
memmove(data, DatumGetPointer(value[i]), data_length);
|
||||||
|
data += data_length;
|
||||||
|
break;
|
||||||
|
case sizeof(char):
|
||||||
|
*data = att[i]->attbyval ?
|
||||||
|
DatumGetChar(value[i]) : *((char *) value[i]);
|
||||||
|
data += sizeof(char);
|
||||||
|
break;
|
||||||
|
case sizeof(int16):
|
||||||
|
data = (char *) SHORTALIGN(data);
|
||||||
|
*(short *) data = (att[i]->attbyval ?
|
||||||
|
DatumGetInt16(value[i]) :
|
||||||
|
*((short *) value[i]));
|
||||||
|
data += sizeof(short);
|
||||||
|
break;
|
||||||
|
case sizeof(int32):
|
||||||
data = (char *) INTALIGN(data);
|
data = (char *) INTALIGN(data);
|
||||||
}
|
*(int32 *) data = (att[i]->attbyval ?
|
||||||
data_length = VARSIZE(DatumGetPointer(value[i]));
|
DatumGetInt32(value[i]) :
|
||||||
memmove(data, DatumGetPointer(value[i]), data_length);
|
*((int32 *) value[i]));
|
||||||
data += data_length;
|
data += sizeof(int32);
|
||||||
break;
|
break;
|
||||||
case sizeof(char):
|
default:
|
||||||
*data = att[i]->attbyval ?
|
if (att[i]->attlen < sizeof(int32))
|
||||||
DatumGetChar(value[i]) : *((char *) value[i]);
|
elog(WARN, "DataFill: attribute %d has len %d",
|
||||||
data += sizeof(char);
|
i, att[i]->attlen);
|
||||||
break;
|
if (att[i]->attalign == 'd')
|
||||||
case sizeof(int16):
|
{
|
||||||
data = (char *) SHORTALIGN(data);
|
data = (char *) DOUBLEALIGN(data);
|
||||||
*(short *) data = (att[i]->attbyval ?
|
memmove(data, DatumGetPointer(value[i]),
|
||||||
DatumGetInt16(value[i]) :
|
att[i]->attlen);
|
||||||
*((short *) value[i]));
|
data += att[i]->attlen;
|
||||||
data += sizeof(short);
|
}
|
||||||
break;
|
else
|
||||||
case sizeof(int32):
|
{
|
||||||
data = (char *) INTALIGN(data);
|
data = (char *) LONGALIGN(data);
|
||||||
*(int32 *) data = (att[i]->attbyval ?
|
memmove(data, DatumGetPointer(value[i]),
|
||||||
DatumGetInt32(value[i]) :
|
att[i]->attlen);
|
||||||
*((int32 *) value[i]));
|
data += att[i]->attlen;
|
||||||
data += sizeof(int32);
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
if (att[i]->attlen < sizeof(int32))
|
|
||||||
elog(WARN, "DataFill: attribute %d has len %d",
|
|
||||||
i, att[i]->attlen);
|
|
||||||
if (att[i]->attalign == 'd')
|
|
||||||
{
|
|
||||||
data = (char *) DOUBLEALIGN(data);
|
|
||||||
memmove(data, DatumGetPointer(value[i]),
|
|
||||||
att[i]->attlen);
|
|
||||||
data += att[i]->attlen;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data = (char *) LONGALIGN(data);
|
|
||||||
memmove(data, DatumGetPointer(value[i]),
|
|
||||||
att[i]->attlen);
|
|
||||||
data += att[i]->attlen;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,24 +240,24 @@ heap_attisnull(HeapTuple tup, int attnum)
|
|||||||
else
|
else
|
||||||
switch (attnum)
|
switch (attnum)
|
||||||
{
|
{
|
||||||
case SelfItemPointerAttributeNumber:
|
case SelfItemPointerAttributeNumber:
|
||||||
case ObjectIdAttributeNumber:
|
case ObjectIdAttributeNumber:
|
||||||
case MinTransactionIdAttributeNumber:
|
case MinTransactionIdAttributeNumber:
|
||||||
case MinCommandIdAttributeNumber:
|
case MinCommandIdAttributeNumber:
|
||||||
case MaxTransactionIdAttributeNumber:
|
case MaxTransactionIdAttributeNumber:
|
||||||
case MaxCommandIdAttributeNumber:
|
case MaxCommandIdAttributeNumber:
|
||||||
case ChainItemPointerAttributeNumber:
|
case ChainItemPointerAttributeNumber:
|
||||||
case AnchorItemPointerAttributeNumber:
|
case AnchorItemPointerAttributeNumber:
|
||||||
case MinAbsoluteTimeAttributeNumber:
|
case MinAbsoluteTimeAttributeNumber:
|
||||||
case MaxAbsoluteTimeAttributeNumber:
|
case MaxAbsoluteTimeAttributeNumber:
|
||||||
case VersionTypeAttributeNumber:
|
case VersionTypeAttributeNumber:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
elog(WARN, "heap_attisnull: zero attnum disallowed");
|
elog(WARN, "heap_attisnull: zero attnum disallowed");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(WARN, "heap_attisnull: undefined negative attnum");
|
elog(WARN, "heap_attisnull: undefined negative attnum");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
@@ -277,38 +277,38 @@ heap_attisnull(HeapTuple tup, int attnum)
|
|||||||
int
|
int
|
||||||
heap_sysattrlen(AttrNumber attno)
|
heap_sysattrlen(AttrNumber attno)
|
||||||
{
|
{
|
||||||
HeapTupleData *f = NULL;
|
HeapTupleData *f = NULL;
|
||||||
|
|
||||||
switch (attno)
|
switch (attno)
|
||||||
{
|
{
|
||||||
case SelfItemPointerAttributeNumber:
|
case SelfItemPointerAttributeNumber:
|
||||||
return sizeof f->t_ctid;
|
return sizeof f->t_ctid;
|
||||||
case ObjectIdAttributeNumber:
|
case ObjectIdAttributeNumber:
|
||||||
return sizeof f->t_oid;
|
return sizeof f->t_oid;
|
||||||
case MinTransactionIdAttributeNumber:
|
case MinTransactionIdAttributeNumber:
|
||||||
return sizeof f->t_xmin;
|
return sizeof f->t_xmin;
|
||||||
case MinCommandIdAttributeNumber:
|
case MinCommandIdAttributeNumber:
|
||||||
return sizeof f->t_cmin;
|
return sizeof f->t_cmin;
|
||||||
case MaxTransactionIdAttributeNumber:
|
case MaxTransactionIdAttributeNumber:
|
||||||
return sizeof f->t_xmax;
|
return sizeof f->t_xmax;
|
||||||
case MaxCommandIdAttributeNumber:
|
case MaxCommandIdAttributeNumber:
|
||||||
return sizeof f->t_cmax;
|
return sizeof f->t_cmax;
|
||||||
case ChainItemPointerAttributeNumber:
|
case ChainItemPointerAttributeNumber:
|
||||||
return sizeof f->t_chain;
|
return sizeof f->t_chain;
|
||||||
case MinAbsoluteTimeAttributeNumber:
|
case MinAbsoluteTimeAttributeNumber:
|
||||||
return sizeof f->t_tmin;
|
return sizeof f->t_tmin;
|
||||||
case MaxAbsoluteTimeAttributeNumber:
|
case MaxAbsoluteTimeAttributeNumber:
|
||||||
return sizeof f->t_tmax;
|
return sizeof f->t_tmax;
|
||||||
case VersionTypeAttributeNumber:
|
case VersionTypeAttributeNumber:
|
||||||
return sizeof f->t_vtype;
|
return sizeof f->t_vtype;
|
||||||
|
|
||||||
case AnchorItemPointerAttributeNumber:
|
case AnchorItemPointerAttributeNumber:
|
||||||
elog(WARN, "heap_sysattrlen: field t_anchor does not exist!");
|
elog(WARN, "heap_sysattrlen: field t_anchor does not exist!");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(WARN, "sysattrlen: System attribute number %d unknown.", attno);
|
elog(WARN, "sysattrlen: System attribute number %d unknown.", attno);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,48 +321,48 @@ heap_sysattrlen(AttrNumber attno)
|
|||||||
bool
|
bool
|
||||||
heap_sysattrbyval(AttrNumber attno)
|
heap_sysattrbyval(AttrNumber attno)
|
||||||
{
|
{
|
||||||
bool byval;
|
bool byval;
|
||||||
|
|
||||||
switch (attno)
|
switch (attno)
|
||||||
{
|
{
|
||||||
case SelfItemPointerAttributeNumber:
|
case SelfItemPointerAttributeNumber:
|
||||||
byval = false;
|
byval = false;
|
||||||
break;
|
break;
|
||||||
case ObjectIdAttributeNumber:
|
case ObjectIdAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
case MinTransactionIdAttributeNumber:
|
case MinTransactionIdAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
case MinCommandIdAttributeNumber:
|
case MinCommandIdAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
case MaxTransactionIdAttributeNumber:
|
case MaxTransactionIdAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
case MaxCommandIdAttributeNumber:
|
case MaxCommandIdAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
case ChainItemPointerAttributeNumber:
|
case ChainItemPointerAttributeNumber:
|
||||||
byval = false;
|
byval = false;
|
||||||
break;
|
break;
|
||||||
case AnchorItemPointerAttributeNumber:
|
case AnchorItemPointerAttributeNumber:
|
||||||
byval = false;
|
byval = false;
|
||||||
break;
|
break;
|
||||||
case MinAbsoluteTimeAttributeNumber:
|
case MinAbsoluteTimeAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
case MaxAbsoluteTimeAttributeNumber:
|
case MaxAbsoluteTimeAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
case VersionTypeAttributeNumber:
|
case VersionTypeAttributeNumber:
|
||||||
byval = true;
|
byval = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
byval = true;
|
byval = true;
|
||||||
elog(WARN, "sysattrbyval: System attribute number %d unknown.",
|
elog(WARN, "sysattrbyval: System attribute number %d unknown.",
|
||||||
attno);
|
attno);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return byval;
|
return byval;
|
||||||
@@ -372,57 +372,57 @@ heap_sysattrbyval(AttrNumber attno)
|
|||||||
* heap_getsysattr
|
* heap_getsysattr
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
|
heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
|
||||||
{
|
{
|
||||||
switch (attnum)
|
switch (attnum)
|
||||||
{
|
{
|
||||||
case SelfItemPointerAttributeNumber:
|
case SelfItemPointerAttributeNumber:
|
||||||
return ((char *) &tup->t_ctid);
|
return ((char *) &tup->t_ctid);
|
||||||
case ObjectIdAttributeNumber:
|
case ObjectIdAttributeNumber:
|
||||||
return ((char *) (long) tup->t_oid);
|
return ((char *) (long) tup->t_oid);
|
||||||
case MinTransactionIdAttributeNumber:
|
case MinTransactionIdAttributeNumber:
|
||||||
return ((char *) (long) tup->t_xmin);
|
return ((char *) (long) tup->t_xmin);
|
||||||
case MinCommandIdAttributeNumber:
|
case MinCommandIdAttributeNumber:
|
||||||
return ((char *) (long) tup->t_cmin);
|
return ((char *) (long) tup->t_cmin);
|
||||||
case MaxTransactionIdAttributeNumber:
|
case MaxTransactionIdAttributeNumber:
|
||||||
return ((char *) (long) tup->t_xmax);
|
return ((char *) (long) tup->t_xmax);
|
||||||
case MaxCommandIdAttributeNumber:
|
case MaxCommandIdAttributeNumber:
|
||||||
return ((char *) (long) tup->t_cmax);
|
return ((char *) (long) tup->t_cmax);
|
||||||
case ChainItemPointerAttributeNumber:
|
case ChainItemPointerAttributeNumber:
|
||||||
return ((char *) &tup->t_chain);
|
return ((char *) &tup->t_chain);
|
||||||
case AnchorItemPointerAttributeNumber:
|
case AnchorItemPointerAttributeNumber:
|
||||||
elog(WARN, "heap_getsysattr: t_anchor does not exist!");
|
elog(WARN, "heap_getsysattr: t_anchor does not exist!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For tmin and tmax, we need to do some extra work. These don't
|
* For tmin and tmax, we need to do some extra work. These
|
||||||
* get filled in until the vacuum cleaner runs (or we manage to
|
* don't get filled in until the vacuum cleaner runs (or we
|
||||||
* flush a page after setting the value correctly below). If the
|
* manage to flush a page after setting the value correctly
|
||||||
* vacuum cleaner hasn't run yet, then the times stored in the
|
* below). If the vacuum cleaner hasn't run yet, then the
|
||||||
* tuple are wrong, and we need to look up the commit time of the
|
* times stored in the tuple are wrong, and we need to look up
|
||||||
* transaction. We cache this value in the tuple to avoid doing
|
* the commit time of the transaction. We cache this value in
|
||||||
* the work more than once.
|
* the tuple to avoid doing the work more than once.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case MinAbsoluteTimeAttributeNumber:
|
case MinAbsoluteTimeAttributeNumber:
|
||||||
if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) &&
|
if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) &&
|
||||||
TransactionIdDidCommit(tup->t_xmin))
|
TransactionIdDidCommit(tup->t_xmin))
|
||||||
tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin);
|
tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin);
|
||||||
return ((char *) (long) tup->t_tmin);
|
return ((char *) (long) tup->t_tmin);
|
||||||
case MaxAbsoluteTimeAttributeNumber:
|
case MaxAbsoluteTimeAttributeNumber:
|
||||||
if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax))
|
if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax))
|
||||||
{
|
{
|
||||||
if (TransactionIdDidCommit(tup->t_xmax))
|
if (TransactionIdDidCommit(tup->t_xmax))
|
||||||
tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax);
|
tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax);
|
||||||
else
|
else
|
||||||
tup->t_tmax = CURRENT_ABSTIME;
|
tup->t_tmax = CURRENT_ABSTIME;
|
||||||
}
|
}
|
||||||
return ((char *) (long) tup->t_tmax);
|
return ((char *) (long) tup->t_tmax);
|
||||||
case VersionTypeAttributeNumber:
|
case VersionTypeAttributeNumber:
|
||||||
return ((char *) (long) tup->t_vtype);
|
return ((char *) (long) tup->t_vtype);
|
||||||
default:
|
default:
|
||||||
elog(WARN, "heap_getsysattr: undefined attnum %d", attnum);
|
elog(WARN, "heap_getsysattr: undefined attnum %d", attnum);
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@@ -444,15 +444,15 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
|
|||||||
* the same attribute descriptor will go much quicker. -cim 5/4/91
|
* the same attribute descriptor will go much quicker. -cim 5/4/91
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
fastgetattr(HeapTuple tup,
|
fastgetattr(HeapTuple tup,
|
||||||
int attnum,
|
int attnum,
|
||||||
TupleDesc tupleDesc,
|
TupleDesc tupleDesc,
|
||||||
bool * isnull)
|
bool * isnull)
|
||||||
{
|
{
|
||||||
char *tp; /* ptr to att in tuple */
|
char *tp; /* ptr to att in tuple */
|
||||||
bits8 *bp = NULL; /* ptr to att in tuple */
|
bits8 *bp = NULL; /* ptr to att in tuple */
|
||||||
int slow; /* do we have to walk nulls? */
|
int slow; /* do we have to walk nulls? */
|
||||||
AttributeTupleForm *att = tupleDesc->attrs;
|
AttributeTupleForm *att = tupleDesc->attrs;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -526,7 +526,7 @@ fastgetattr(HeapTuple tup,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
register int i = 0; /* current offset in bp */
|
register int i = 0; /* current offset in bp */
|
||||||
|
|
||||||
for (i = 0; i < attnum && !slow; i++)
|
for (i = 0; i < attnum && !slow; i++)
|
||||||
{
|
{
|
||||||
@@ -554,7 +554,7 @@ fastgetattr(HeapTuple tup,
|
|||||||
}
|
}
|
||||||
else if (!HeapTupleAllFixed(tup))
|
else if (!HeapTupleAllFixed(tup))
|
||||||
{
|
{
|
||||||
register int j = 0;
|
register int j = 0;
|
||||||
|
|
||||||
for (j = 0; j < attnum && !slow; j++)
|
for (j = 0; j < attnum && !slow; j++)
|
||||||
if (att[j]->attlen < 1)
|
if (att[j]->attlen < 1)
|
||||||
@@ -569,8 +569,8 @@ fastgetattr(HeapTuple tup,
|
|||||||
*/
|
*/
|
||||||
if (!slow)
|
if (!slow)
|
||||||
{
|
{
|
||||||
register int j = 1;
|
register int j = 1;
|
||||||
register long off;
|
register long off;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* need to set cache for some atts
|
* need to set cache for some atts
|
||||||
@@ -587,30 +587,30 @@ fastgetattr(HeapTuple tup,
|
|||||||
{
|
{
|
||||||
switch (att[j]->attlen)
|
switch (att[j]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
off = (att[j]->attalign == 'd') ?
|
off = (att[j]->attalign == 'd') ?
|
||||||
DOUBLEALIGN(off) : INTALIGN(off);
|
DOUBLEALIGN(off) : INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
break;
|
break;
|
||||||
case sizeof(short):
|
case sizeof(short):
|
||||||
off = SHORTALIGN(off);
|
off = SHORTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
off = INTALIGN(off);
|
off = INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (att[j]->attlen < sizeof(int32))
|
if (att[j]->attlen < sizeof(int32))
|
||||||
{
|
{
|
||||||
elog(WARN,
|
elog(WARN,
|
||||||
"fastgetattr: attribute %d has len %d",
|
"fastgetattr: attribute %d has len %d",
|
||||||
j, att[j]->attlen);
|
j, att[j]->attlen);
|
||||||
}
|
}
|
||||||
if (att[j]->attalign == 'd')
|
if (att[j]->attalign == 'd')
|
||||||
off = DOUBLEALIGN(off);
|
off = DOUBLEALIGN(off);
|
||||||
else
|
else
|
||||||
off = LONGALIGN(off);
|
off = LONGALIGN(off);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
att[j]->attcacheoff = off;
|
att[j]->attcacheoff = off;
|
||||||
@@ -622,9 +622,9 @@ fastgetattr(HeapTuple tup,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
register bool usecache = true;
|
register bool usecache = true;
|
||||||
register int off = 0;
|
register int off = 0;
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we know that we have to walk the tuple CAREFULLY.
|
* Now we know that we have to walk the tuple CAREFULLY.
|
||||||
@@ -648,28 +648,28 @@ fastgetattr(HeapTuple tup,
|
|||||||
}
|
}
|
||||||
switch (att[i]->attlen)
|
switch (att[i]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
off = (att[i]->attalign == 'd') ?
|
off = (att[i]->attalign == 'd') ?
|
||||||
DOUBLEALIGN(off) : INTALIGN(off);
|
DOUBLEALIGN(off) : INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
break;
|
break;
|
||||||
case sizeof(short):
|
case sizeof(short):
|
||||||
off = SHORTALIGN(off);
|
off = SHORTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
off = INTALIGN(off);
|
off = INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (att[i]->attlen < sizeof(int32))
|
if (att[i]->attlen < sizeof(int32))
|
||||||
elog(WARN,
|
elog(WARN,
|
||||||
"fastgetattr2: attribute %d has len %d",
|
"fastgetattr2: attribute %d has len %d",
|
||||||
i, att[i]->attlen);
|
i, att[i]->attlen);
|
||||||
if (att[i]->attalign == 'd')
|
if (att[i]->attalign == 'd')
|
||||||
off = DOUBLEALIGN(off);
|
off = DOUBLEALIGN(off);
|
||||||
else
|
else
|
||||||
off = LONGALIGN(off);
|
off = LONGALIGN(off);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (usecache && att[i]->attcacheoff > 0)
|
if (usecache && att[i]->attcacheoff > 0)
|
||||||
{
|
{
|
||||||
@@ -687,47 +687,47 @@ fastgetattr(HeapTuple tup,
|
|||||||
|
|
||||||
switch (att[i]->attlen)
|
switch (att[i]->attlen)
|
||||||
{
|
{
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
off++;
|
off++;
|
||||||
break;
|
break;
|
||||||
case sizeof(int16):
|
case sizeof(int16):
|
||||||
off += sizeof(int16);
|
off += sizeof(int16);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
off += sizeof(int32);
|
off += sizeof(int32);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
usecache = false;
|
usecache = false;
|
||||||
off += VARSIZE(tp + off);
|
off += VARSIZE(tp + off);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
off += att[i]->attlen;
|
off += att[i]->attlen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (att[attnum]->attlen)
|
switch (att[attnum]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
off = (att[attnum]->attalign == 'd') ?
|
off = (att[attnum]->attalign == 'd') ?
|
||||||
DOUBLEALIGN(off) : INTALIGN(off);
|
DOUBLEALIGN(off) : INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
break;
|
break;
|
||||||
case sizeof(short):
|
case sizeof(short):
|
||||||
off = SHORTALIGN(off);
|
off = SHORTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
off = INTALIGN(off);
|
off = INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (att[attnum]->attlen < sizeof(int32))
|
if (att[attnum]->attlen < sizeof(int32))
|
||||||
elog(WARN, "fastgetattr3: attribute %d has len %d",
|
elog(WARN, "fastgetattr3: attribute %d has len %d",
|
||||||
attnum, att[attnum]->attlen);
|
attnum, att[attnum]->attlen);
|
||||||
if (att[attnum]->attalign == 'd')
|
if (att[attnum]->attalign == 'd')
|
||||||
off = DOUBLEALIGN(off);
|
off = DOUBLEALIGN(off);
|
||||||
else
|
else
|
||||||
off = LONGALIGN(off);
|
off = LONGALIGN(off);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ((char *) fetchatt(&(att[attnum]), tp + off));
|
return ((char *) fetchatt(&(att[attnum]), tp + off));
|
||||||
}
|
}
|
||||||
@@ -742,7 +742,7 @@ fastgetattr(HeapTuple tup,
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
heap_copytuple(HeapTuple tuple)
|
heap_copytuple(HeapTuple tuple)
|
||||||
{
|
{
|
||||||
HeapTuple newTuple;
|
HeapTuple newTuple;
|
||||||
|
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@@ -772,15 +772,15 @@ heap_deformtuple(HeapTuple tuple,
|
|||||||
Datum values[],
|
Datum values[],
|
||||||
char nulls[])
|
char nulls[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int natts;
|
int natts;
|
||||||
|
|
||||||
Assert(HeapTupleIsValid(tuple));
|
Assert(HeapTupleIsValid(tuple));
|
||||||
|
|
||||||
natts = tuple->t_natts;
|
natts = tuple->t_natts;
|
||||||
for (i = 0; i < natts; i++)
|
for (i = 0; i < natts; i++)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
values[i] = (Datum) heap_getattr(tuple,
|
values[i] = (Datum) heap_getattr(tuple,
|
||||||
InvalidBuffer,
|
InvalidBuffer,
|
||||||
@@ -819,14 +819,14 @@ heap_formtuple(TupleDesc tupleDescriptor,
|
|||||||
Datum value[],
|
Datum value[],
|
||||||
char nulls[])
|
char nulls[])
|
||||||
{
|
{
|
||||||
char *tp; /* tuple pointer */
|
char *tp; /* tuple pointer */
|
||||||
HeapTuple tuple; /* return tuple */
|
HeapTuple tuple; /* return tuple */
|
||||||
int bitmaplen;
|
int bitmaplen;
|
||||||
long len;
|
long len;
|
||||||
int hoff;
|
int hoff;
|
||||||
bool hasnull = false;
|
bool hasnull = false;
|
||||||
int i;
|
int i;
|
||||||
int numberOfAttributes = tupleDescriptor->natts;
|
int numberOfAttributes = tupleDescriptor->natts;
|
||||||
|
|
||||||
len = sizeof *tuple - sizeof tuple->t_bits;
|
len = sizeof *tuple - sizeof tuple->t_bits;
|
||||||
|
|
||||||
@@ -885,14 +885,14 @@ heap_modifytuple(HeapTuple tuple,
|
|||||||
char replNull[],
|
char replNull[],
|
||||||
char repl[])
|
char repl[])
|
||||||
{
|
{
|
||||||
int attoff;
|
int attoff;
|
||||||
int numberOfAttributes;
|
int numberOfAttributes;
|
||||||
Datum *value;
|
Datum *value;
|
||||||
char *nulls;
|
char *nulls;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
HeapTuple newTuple;
|
HeapTuple newTuple;
|
||||||
int madecopy;
|
int madecopy;
|
||||||
uint8 infomask;
|
uint8 infomask;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -936,7 +936,7 @@ heap_modifytuple(HeapTuple tuple,
|
|||||||
|
|
||||||
if (repl[attoff] == ' ')
|
if (repl[attoff] == ' ')
|
||||||
{
|
{
|
||||||
char *attr;
|
char *attr;
|
||||||
|
|
||||||
attr =
|
attr =
|
||||||
heap_getattr(tuple,
|
heap_getattr(tuple,
|
||||||
@@ -1001,10 +1001,10 @@ heap_addheader(uint32 natts, /* max domain index */
|
|||||||
int structlen, /* its length */
|
int structlen, /* its length */
|
||||||
char *structure) /* pointer to the struct */
|
char *structure) /* pointer to the struct */
|
||||||
{
|
{
|
||||||
register char *tp; /* tuple data pointer */
|
register char *tp; /* tuple data pointer */
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
long len;
|
long len;
|
||||||
int hoff;
|
int hoff;
|
||||||
|
|
||||||
AssertArg(natts > 0);
|
AssertArg(natts > 0);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.17 1997/09/07 04:37:36 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.18 1997/09/08 02:19:51 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -36,9 +36,9 @@ heap_keytest(HeapTuple t,
|
|||||||
int nkeys,
|
int nkeys,
|
||||||
ScanKey keys)
|
ScanKey keys)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Datum atp;
|
Datum atp;
|
||||||
int test;
|
int test;
|
||||||
|
|
||||||
for (; nkeys--; keys++)
|
for (; nkeys--; keys++)
|
||||||
{
|
{
|
||||||
@@ -101,11 +101,11 @@ heap_tuple_satisfies(ItemId itemId,
|
|||||||
int nKeys,
|
int nKeys,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
HeapTuple tuple,
|
HeapTuple tuple,
|
||||||
result;
|
result;
|
||||||
bool res;
|
bool res;
|
||||||
TransactionId old_tmin,
|
TransactionId old_tmin,
|
||||||
old_tmax;
|
old_tmax;
|
||||||
|
|
||||||
if (!ItemIdIsUsed(itemId))
|
if (!ItemIdIsUsed(itemId))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.16 1997/09/07 04:37:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.17 1997/09/08 02:19:54 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Size IndexInfoFindDataOffset(unsigned short t_info);
|
static Size IndexInfoFindDataOffset(unsigned short t_info);
|
||||||
static char *
|
static char *
|
||||||
fastgetiattr(IndexTuple tup, int attnum,
|
fastgetiattr(IndexTuple tup, int attnum,
|
||||||
TupleDesc att, bool * isnull);
|
TupleDesc att, bool * isnull);
|
||||||
|
|
||||||
@@ -45,15 +45,15 @@ index_formtuple(TupleDesc tupleDescriptor,
|
|||||||
Datum value[],
|
Datum value[],
|
||||||
char null[])
|
char null[])
|
||||||
{
|
{
|
||||||
register char *tp; /* tuple pointer */
|
register char *tp; /* tuple pointer */
|
||||||
IndexTuple tuple; /* return tuple */
|
IndexTuple tuple; /* return tuple */
|
||||||
Size size,
|
Size size,
|
||||||
hoff;
|
hoff;
|
||||||
int i;
|
int i;
|
||||||
unsigned short infomask = 0;
|
unsigned short infomask = 0;
|
||||||
bool hasnull = false;
|
bool hasnull = false;
|
||||||
char tupmask = 0;
|
char tupmask = 0;
|
||||||
int numberOfAttributes = tupleDescriptor->natts;
|
int numberOfAttributes = tupleDescriptor->natts;
|
||||||
|
|
||||||
if (numberOfAttributes > MaxIndexAttributeNumber)
|
if (numberOfAttributes > MaxIndexAttributeNumber)
|
||||||
elog(WARN, "index_formtuple: numberOfAttributes of %d > %d",
|
elog(WARN, "index_formtuple: numberOfAttributes of %d > %d",
|
||||||
@@ -133,16 +133,16 @@ index_formtuple(TupleDesc tupleDescriptor,
|
|||||||
* the same attribute descriptor will go much quicker. -cim 5/4/91
|
* the same attribute descriptor will go much quicker. -cim 5/4/91
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
fastgetiattr(IndexTuple tup,
|
fastgetiattr(IndexTuple tup,
|
||||||
int attnum,
|
int attnum,
|
||||||
TupleDesc tupleDesc,
|
TupleDesc tupleDesc,
|
||||||
bool * isnull)
|
bool * isnull)
|
||||||
{
|
{
|
||||||
register char *tp; /* ptr to att in tuple */
|
register char *tp; /* ptr to att in tuple */
|
||||||
register char *bp = NULL; /* ptr to att in tuple */
|
register char *bp = NULL; /* ptr to att in tuple */
|
||||||
int slow; /* do we have to walk nulls? */
|
int slow; /* do we have to walk nulls? */
|
||||||
register int data_off; /* tuple data offset */
|
register int data_off; /* tuple data offset */
|
||||||
AttributeTupleForm *att = tupleDesc->attrs;
|
AttributeTupleForm *att = tupleDesc->attrs;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -212,11 +212,11 @@ fastgetiattr(IndexTuple tup,
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
register int i = 0; /* current offset in bp */
|
register int i = 0; /* current offset in bp */
|
||||||
register int mask; /* bit in byte we're looking at */
|
register int mask; /* bit in byte we're looking at */
|
||||||
register char n; /* current byte in bp */
|
register char n; /* current byte in bp */
|
||||||
register int byte,
|
register int byte,
|
||||||
finalbit;
|
finalbit;
|
||||||
|
|
||||||
byte = attnum >> 3;
|
byte = attnum >> 3;
|
||||||
finalbit = attnum & 0x07;
|
finalbit = attnum & 0x07;
|
||||||
@@ -256,7 +256,7 @@ fastgetiattr(IndexTuple tup,
|
|||||||
}
|
}
|
||||||
else if (!IndexTupleAllFixed(tup))
|
else if (!IndexTupleAllFixed(tup))
|
||||||
{
|
{
|
||||||
register int j = 0;
|
register int j = 0;
|
||||||
|
|
||||||
for (j = 0; j < attnum && !slow; j++)
|
for (j = 0; j < attnum && !slow; j++)
|
||||||
if (att[j]->attlen < 1)
|
if (att[j]->attlen < 1)
|
||||||
@@ -272,8 +272,8 @@ fastgetiattr(IndexTuple tup,
|
|||||||
|
|
||||||
if (!slow)
|
if (!slow)
|
||||||
{
|
{
|
||||||
register int j = 1;
|
register int j = 1;
|
||||||
register long off;
|
register long off;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* need to set cache for some atts
|
* need to set cache for some atts
|
||||||
@@ -297,26 +297,26 @@ fastgetiattr(IndexTuple tup,
|
|||||||
|
|
||||||
switch (att[j]->attlen)
|
switch (att[j]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
off = (att[j]->attalign == 'd') ?
|
|
||||||
DOUBLEALIGN(off) : INTALIGN(off);
|
|
||||||
break;
|
|
||||||
case sizeof(char):
|
|
||||||
break;
|
|
||||||
case sizeof(short):
|
|
||||||
off = SHORTALIGN(off);
|
|
||||||
break;
|
|
||||||
case sizeof(int32):
|
|
||||||
off = INTALIGN(off);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (att[j]->attlen > sizeof(int32))
|
|
||||||
off = (att[j]->attalign == 'd') ?
|
off = (att[j]->attalign == 'd') ?
|
||||||
DOUBLEALIGN(off) : LONGALIGN(off);
|
DOUBLEALIGN(off) : INTALIGN(off);
|
||||||
else
|
break;
|
||||||
elog(WARN, "fastgetiattr: attribute %d has len %d",
|
case sizeof(char):
|
||||||
j, att[j]->attlen);
|
break;
|
||||||
break;
|
case sizeof(short):
|
||||||
|
off = SHORTALIGN(off);
|
||||||
|
break;
|
||||||
|
case sizeof(int32):
|
||||||
|
off = INTALIGN(off);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (att[j]->attlen > sizeof(int32))
|
||||||
|
off = (att[j]->attalign == 'd') ?
|
||||||
|
DOUBLEALIGN(off) : LONGALIGN(off);
|
||||||
|
else
|
||||||
|
elog(WARN, "fastgetiattr: attribute %d has len %d",
|
||||||
|
j, att[j]->attlen);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,9 +329,9 @@ fastgetiattr(IndexTuple tup,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
register bool usecache = true;
|
register bool usecache = true;
|
||||||
register int off = 0;
|
register int off = 0;
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we know that we have to walk the tuple CAREFULLY.
|
* Now we know that we have to walk the tuple CAREFULLY.
|
||||||
@@ -361,31 +361,31 @@ fastgetiattr(IndexTuple tup,
|
|||||||
att[i]->attcacheoff = off;
|
att[i]->attcacheoff = off;
|
||||||
switch (att[i]->attlen)
|
switch (att[i]->attlen)
|
||||||
{
|
{
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
off++;
|
off++;
|
||||||
break;
|
break;
|
||||||
case sizeof(short):
|
case sizeof(short):
|
||||||
off = SHORTALIGN(off) +sizeof(short);
|
off = SHORTALIGN(off) +sizeof(short);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
off = INTALIGN(off) + sizeof(int32);
|
off = INTALIGN(off) + sizeof(int32);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
usecache = false;
|
usecache = false;
|
||||||
off = (att[i]->attalign == 'd') ?
|
|
||||||
DOUBLEALIGN(off) : INTALIGN(off);
|
|
||||||
off += VARSIZE(tp + off);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (att[i]->attlen > sizeof(int32))
|
|
||||||
off = (att[i]->attalign == 'd') ?
|
off = (att[i]->attalign == 'd') ?
|
||||||
DOUBLEALIGN(off) + att[i]->attlen :
|
DOUBLEALIGN(off) : INTALIGN(off);
|
||||||
LONGALIGN(off) + att[i]->attlen;
|
off += VARSIZE(tp + off);
|
||||||
else
|
break;
|
||||||
elog(WARN, "fastgetiattr2: attribute %d has len %d",
|
default:
|
||||||
i, att[i]->attlen);
|
if (att[i]->attlen > sizeof(int32))
|
||||||
|
off = (att[i]->attalign == 'd') ?
|
||||||
|
DOUBLEALIGN(off) + att[i]->attlen :
|
||||||
|
LONGALIGN(off) + att[i]->attlen;
|
||||||
|
else
|
||||||
|
elog(WARN, "fastgetiattr2: attribute %d has len %d",
|
||||||
|
i, att[i]->attlen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,27 +395,27 @@ fastgetiattr(IndexTuple tup,
|
|||||||
*/
|
*/
|
||||||
switch (att[attnum]->attlen)
|
switch (att[attnum]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
off = (att[attnum]->attalign == 'd') ?
|
off = (att[attnum]->attalign == 'd') ?
|
||||||
DOUBLEALIGN(off) : INTALIGN(off);
|
DOUBLEALIGN(off) : INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
break;
|
break;
|
||||||
case sizeof(short):
|
case sizeof(short):
|
||||||
off = SHORTALIGN(off);
|
off = SHORTALIGN(off);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
off = INTALIGN(off);
|
off = INTALIGN(off);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (att[attnum]->attlen < sizeof(int32))
|
if (att[attnum]->attlen < sizeof(int32))
|
||||||
elog(WARN, "fastgetattr3: attribute %d has len %d",
|
elog(WARN, "fastgetattr3: attribute %d has len %d",
|
||||||
attnum, att[attnum]->attlen);
|
attnum, att[attnum]->attlen);
|
||||||
if (att[attnum]->attalign == 'd')
|
if (att[attnum]->attalign == 'd')
|
||||||
off = DOUBLEALIGN(off);
|
off = DOUBLEALIGN(off);
|
||||||
else
|
else
|
||||||
off = LONGALIGN(off);
|
off = LONGALIGN(off);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (fetchatt(&att[attnum], tp + off));
|
return (fetchatt(&att[attnum], tp + off));
|
||||||
@@ -461,14 +461,14 @@ FormRetrieveIndexResult(ItemPointer indexItemPointer,
|
|||||||
*
|
*
|
||||||
* Change me if adding an attribute to IndexTuples!!!!!!!!!!!
|
* Change me if adding an attribute to IndexTuples!!!!!!!!!!!
|
||||||
*/
|
*/
|
||||||
static Size
|
static Size
|
||||||
IndexInfoFindDataOffset(unsigned short t_info)
|
IndexInfoFindDataOffset(unsigned short t_info)
|
||||||
{
|
{
|
||||||
if (!(t_info & INDEX_NULL_MASK))
|
if (!(t_info & INDEX_NULL_MASK))
|
||||||
return ((Size) sizeof(IndexTupleData));
|
return ((Size) sizeof(IndexTupleData));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Size size = sizeof(IndexTupleData);
|
Size size = sizeof(IndexTupleData);
|
||||||
|
|
||||||
if (t_info & INDEX_NULL_MASK)
|
if (t_info & INDEX_NULL_MASK)
|
||||||
{
|
{
|
||||||
@@ -485,8 +485,8 @@ IndexInfoFindDataOffset(unsigned short t_info)
|
|||||||
void
|
void
|
||||||
CopyIndexTuple(IndexTuple source, IndexTuple * target)
|
CopyIndexTuple(IndexTuple source, IndexTuple * target)
|
||||||
{
|
{
|
||||||
Size size;
|
Size size;
|
||||||
IndexTuple ret;
|
IndexTuple ret;
|
||||||
|
|
||||||
size = IndexTupleSize(source);
|
size = IndexTupleSize(source);
|
||||||
if (*target == NULL)
|
if (*target == NULL)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.15 1997/09/07 04:37:38 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.16 1997/09/08 02:19:55 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
* index scan key qualification code
|
* index scan key qualification code
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
int NIndexTupleProcessed;
|
int NIndexTupleProcessed;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* index_keytest
|
* index_keytest
|
||||||
@@ -40,9 +40,9 @@ index_keytest(IndexTuple tuple,
|
|||||||
int scanKeySize,
|
int scanKeySize,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
bool isNull;
|
bool isNull;
|
||||||
Datum datum;
|
Datum datum;
|
||||||
int test;
|
int test;
|
||||||
|
|
||||||
IncrIndexProcessed();
|
IncrIndexProcessed();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.16 1997/09/07 04:37:39 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.17 1997/09/08 02:19:56 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
Oid
|
Oid
|
||||||
typtoout(Oid type)
|
typtoout(Oid type)
|
||||||
{
|
{
|
||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
|
|
||||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||||
ObjectIdGetDatum(type),
|
ObjectIdGetDatum(type),
|
||||||
@@ -52,7 +52,7 @@ typtoout(Oid type)
|
|||||||
Oid
|
Oid
|
||||||
gettypelem(Oid type)
|
gettypelem(Oid type)
|
||||||
{
|
{
|
||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
|
|
||||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||||
ObjectIdGetDatum(type),
|
ObjectIdGetDatum(type),
|
||||||
@@ -73,13 +73,13 @@ gettypelem(Oid type)
|
|||||||
void
|
void
|
||||||
printtup(HeapTuple tuple, TupleDesc typeinfo)
|
printtup(HeapTuple tuple, TupleDesc typeinfo)
|
||||||
{
|
{
|
||||||
int i,
|
int i,
|
||||||
j,
|
j,
|
||||||
k;
|
k;
|
||||||
char *outputstr,
|
char *outputstr,
|
||||||
*attr;
|
*attr;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Oid typoutput;
|
Oid typoutput;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* tell the frontend to expect new tuple data
|
* tell the frontend to expect new tuple data
|
||||||
@@ -158,8 +158,8 @@ printatt(unsigned attributeId,
|
|||||||
void
|
void
|
||||||
showatts(char *name, TupleDesc tupleDesc)
|
showatts(char *name, TupleDesc tupleDesc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int natts = tupleDesc->natts;
|
int natts = tupleDesc->natts;
|
||||||
AttributeTupleForm *attinfo = tupleDesc->attrs;
|
AttributeTupleForm *attinfo = tupleDesc->attrs;
|
||||||
|
|
||||||
puts(name);
|
puts(name);
|
||||||
@@ -175,11 +175,11 @@ showatts(char *name, TupleDesc tupleDesc)
|
|||||||
void
|
void
|
||||||
debugtup(HeapTuple tuple, TupleDesc typeinfo)
|
debugtup(HeapTuple tuple, TupleDesc typeinfo)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
char *attr,
|
char *attr,
|
||||||
*value;
|
*value;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Oid typoutput;
|
Oid typoutput;
|
||||||
|
|
||||||
for (i = 0; i < tuple->t_natts; ++i)
|
for (i = 0; i < tuple->t_natts; ++i)
|
||||||
{
|
{
|
||||||
@@ -209,11 +209,11 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo)
|
|||||||
void
|
void
|
||||||
printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
|
printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
|
||||||
{
|
{
|
||||||
int i,
|
int i,
|
||||||
j,
|
j,
|
||||||
k;
|
k;
|
||||||
char *attr;
|
char *attr;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* tell the frontend to expect new tuple data
|
* tell the frontend to expect new tuple data
|
||||||
@@ -254,7 +254,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
|
|||||||
#endif
|
#endif
|
||||||
for (i = 0; i < tuple->t_natts; ++i)
|
for (i = 0; i < tuple->t_natts; ++i)
|
||||||
{
|
{
|
||||||
int32 len = typeinfo->attrs[i]->attlen;
|
int32 len = typeinfo->attrs[i]->attlen;
|
||||||
|
|
||||||
attr = heap_getattr(tuple, InvalidBuffer, i + 1, typeinfo, &isnull);
|
attr = heap_getattr(tuple, InvalidBuffer, i + 1, typeinfo, &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
@@ -269,7 +269,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
|
|||||||
pq_putnchar(VARDATA(attr), len);
|
pq_putnchar(VARDATA(attr), len);
|
||||||
#ifdef IPORTAL_DEBUG
|
#ifdef IPORTAL_DEBUG
|
||||||
{
|
{
|
||||||
char *d = VARDATA(attr);
|
char *d = VARDATA(attr);
|
||||||
|
|
||||||
fprintf(stderr, "length %d data %x%x%x%x\n",
|
fprintf(stderr, "length %d data %x%x%x%x\n",
|
||||||
len, *d, *(d + 1), *(d + 2), *(d + 3));
|
len, *d, *(d + 1), *(d + 2), *(d + 3));
|
||||||
@@ -281,25 +281,25 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
|
|||||||
/* fixed size */
|
/* fixed size */
|
||||||
if (typeinfo->attrs[i]->attbyval)
|
if (typeinfo->attrs[i]->attbyval)
|
||||||
{
|
{
|
||||||
int8 i8;
|
int8 i8;
|
||||||
int16 i16;
|
int16 i16;
|
||||||
int32 i32;
|
int32 i32;
|
||||||
|
|
||||||
pq_putint(len, sizeof(int32));
|
pq_putint(len, sizeof(int32));
|
||||||
switch (len)
|
switch (len)
|
||||||
{
|
{
|
||||||
case sizeof(int8):
|
case sizeof(int8):
|
||||||
i8 = DatumGetChar(attr);
|
i8 = DatumGetChar(attr);
|
||||||
pq_putnchar((char *) &i8, len);
|
pq_putnchar((char *) &i8, len);
|
||||||
break;
|
break;
|
||||||
case sizeof(int16):
|
case sizeof(int16):
|
||||||
i16 = DatumGetInt16(attr);
|
i16 = DatumGetInt16(attr);
|
||||||
pq_putnchar((char *) &i16, len);
|
pq_putnchar((char *) &i16, len);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
i32 = DatumGetInt32(attr);
|
i32 = DatumGetInt32(attr);
|
||||||
pq_putnchar((char *) &i32, len);
|
pq_putnchar((char *) &i32, len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef IPORTAL_DEBUG
|
#ifdef IPORTAL_DEBUG
|
||||||
fprintf(stderr, "byval length %d data %d\n", len, attr);
|
fprintf(stderr, "byval length %d data %d\n", len, attr);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.20 1997/09/07 04:37:41 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.21 1997/09/08 02:19:56 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* some of the executor utility code such as "ExecTypeFromTL" should be
|
* some of the executor utility code such as "ExecTypeFromTL" should be
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
CreateTemplateTupleDesc(int natts)
|
CreateTemplateTupleDesc(int natts)
|
||||||
{
|
{
|
||||||
uint32 size;
|
uint32 size;
|
||||||
TupleDesc desc;
|
TupleDesc desc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -77,7 +77,7 @@ CreateTemplateTupleDesc(int natts)
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
CreateTupleDesc(int natts, AttributeTupleForm * attrs)
|
CreateTupleDesc(int natts, AttributeTupleForm * attrs)
|
||||||
{
|
{
|
||||||
TupleDesc desc;
|
TupleDesc desc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -105,9 +105,9 @@ CreateTupleDesc(int natts, AttributeTupleForm * attrs)
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
CreateTupleDescCopy(TupleDesc tupdesc)
|
CreateTupleDescCopy(TupleDesc tupdesc)
|
||||||
{
|
{
|
||||||
TupleDesc desc;
|
TupleDesc desc;
|
||||||
int i,
|
int i,
|
||||||
size;
|
size;
|
||||||
|
|
||||||
desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
|
desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
|
||||||
desc->natts = tupdesc->natts;
|
desc->natts = tupdesc->natts;
|
||||||
@@ -139,10 +139,10 @@ CreateTupleDescCopy(TupleDesc tupdesc)
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
CreateTupleDescCopyConstr(TupleDesc tupdesc)
|
CreateTupleDescCopyConstr(TupleDesc tupdesc)
|
||||||
{
|
{
|
||||||
TupleDesc desc;
|
TupleDesc desc;
|
||||||
TupleConstr *constr = tupdesc->constr;
|
TupleConstr *constr = tupdesc->constr;
|
||||||
int i,
|
int i,
|
||||||
size;
|
size;
|
||||||
|
|
||||||
desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
|
desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
|
||||||
desc->natts = tupdesc->natts;
|
desc->natts = tupdesc->natts;
|
||||||
@@ -158,7 +158,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
|
|||||||
}
|
}
|
||||||
if (constr)
|
if (constr)
|
||||||
{
|
{
|
||||||
TupleConstr *cpy = (TupleConstr *) palloc(sizeof(TupleConstr));
|
TupleConstr *cpy = (TupleConstr *) palloc(sizeof(TupleConstr));
|
||||||
|
|
||||||
cpy->has_not_null = constr->has_not_null;
|
cpy->has_not_null = constr->has_not_null;
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
|
|||||||
void
|
void
|
||||||
FreeTupleDesc(TupleDesc tupdesc)
|
FreeTupleDesc(TupleDesc tupdesc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < tupdesc->natts; i++)
|
for (i = 0; i < tupdesc->natts; i++)
|
||||||
pfree(tupdesc->attrs[i]);
|
pfree(tupdesc->attrs[i]);
|
||||||
@@ -210,7 +210,7 @@ FreeTupleDesc(TupleDesc tupdesc)
|
|||||||
{
|
{
|
||||||
if (tupdesc->constr->num_defval > 0)
|
if (tupdesc->constr->num_defval > 0)
|
||||||
{
|
{
|
||||||
AttrDefault *attrdef = tupdesc->constr->defval;
|
AttrDefault *attrdef = tupdesc->constr->defval;
|
||||||
|
|
||||||
for (i = tupdesc->constr->num_defval - 1; i >= 0; i--)
|
for (i = tupdesc->constr->num_defval - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@@ -223,7 +223,7 @@ FreeTupleDesc(TupleDesc tupdesc)
|
|||||||
}
|
}
|
||||||
if (tupdesc->constr->num_check > 0)
|
if (tupdesc->constr->num_check > 0)
|
||||||
{
|
{
|
||||||
ConstrCheck *check = tupdesc->constr->check;
|
ConstrCheck *check = tupdesc->constr->check;
|
||||||
|
|
||||||
for (i = tupdesc->constr->num_check - 1; i >= 0; i--)
|
for (i = tupdesc->constr->num_check - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@@ -258,8 +258,8 @@ TupleDescInitEntry(TupleDesc desc,
|
|||||||
int attdim,
|
int attdim,
|
||||||
bool attisset)
|
bool attisset)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
TypeTupleForm typeForm;
|
TypeTupleForm typeForm;
|
||||||
AttributeTupleForm att;
|
AttributeTupleForm att;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -378,7 +378,7 @@ TupleDescInitEntry(TupleDesc desc,
|
|||||||
*/
|
*/
|
||||||
if (attisset)
|
if (attisset)
|
||||||
{
|
{
|
||||||
Type t = type("oid");
|
Type t = type("oid");
|
||||||
|
|
||||||
att->attlen = tlen(t);
|
att->attlen = tlen(t);
|
||||||
att->attbyval = tbyval(t);
|
att->attbyval = tbyval(t);
|
||||||
@@ -411,7 +411,7 @@ TupleDescMakeSelfReference(TupleDesc desc,
|
|||||||
char *relname)
|
char *relname)
|
||||||
{
|
{
|
||||||
AttributeTupleForm att;
|
AttributeTupleForm att;
|
||||||
Type t = type("oid");
|
Type t = type("oid");
|
||||||
|
|
||||||
att = desc->attrs[attnum - 1];
|
att = desc->attrs[attnum - 1];
|
||||||
att->atttypid = TypeShellMake(relname);
|
att->atttypid = TypeShellMake(relname);
|
||||||
@@ -439,17 +439,17 @@ TupleDescMakeSelfReference(TupleDesc desc,
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
BuildDescForRelation(List * schema, char *relname)
|
BuildDescForRelation(List * schema, char *relname)
|
||||||
{
|
{
|
||||||
int natts;
|
int natts;
|
||||||
AttrNumber attnum;
|
AttrNumber attnum;
|
||||||
List *p;
|
List *p;
|
||||||
TupleDesc desc;
|
TupleDesc desc;
|
||||||
AttrDefault *attrdef = NULL;
|
AttrDefault *attrdef = NULL;
|
||||||
TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
|
TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
|
||||||
char *attname;
|
char *attname;
|
||||||
char *typename;
|
char *typename;
|
||||||
int attdim;
|
int attdim;
|
||||||
int ndef = 0;
|
int ndef = 0;
|
||||||
bool attisset;
|
bool attisset;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* allocate a new tuple descriptor
|
* allocate a new tuple descriptor
|
||||||
@@ -465,8 +465,8 @@ BuildDescForRelation(List * schema, char *relname)
|
|||||||
|
|
||||||
foreach(p, schema)
|
foreach(p, schema)
|
||||||
{
|
{
|
||||||
ColumnDef *entry;
|
ColumnDef *entry;
|
||||||
List *arry;
|
List *arry;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* for each entry in the list, get the name and type
|
* for each entry in the list, get the name and type
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ gistSplit(Relation r, Buffer buffer,
|
|||||||
static void
|
static void
|
||||||
gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt,
|
gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt,
|
||||||
IndexTuple rt);
|
IndexTuple rt);
|
||||||
static void GISTInitBuffer(Buffer b, uint32 f);
|
static void GISTInitBuffer(Buffer b, uint32 f);
|
||||||
static BlockNumber
|
static BlockNumber
|
||||||
gistChooseSubtree(Relation r, IndexTuple itup, int level,
|
gistChooseSubtree(Relation r, IndexTuple itup, int level,
|
||||||
GISTSTATE * giststate,
|
GISTSTATE * giststate,
|
||||||
@@ -63,13 +63,13 @@ gistChooseSubtree(Relation r, IndexTuple itup, int level,
|
|||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
gistchoose(Relation r, Page p, IndexTuple it,
|
gistchoose(Relation r, Page p, IndexTuple it,
|
||||||
GISTSTATE * giststate);
|
GISTSTATE * giststate);
|
||||||
static int gistnospace(Page p, IndexTuple it);
|
static int gistnospace(Page p, IndexTuple it);
|
||||||
void gistdelete(Relation r, ItemPointer tid);
|
void gistdelete(Relation r, ItemPointer tid);
|
||||||
static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t);
|
static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t);
|
||||||
static void
|
static void
|
||||||
gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr,
|
gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr,
|
||||||
Relation r, Page pg, OffsetNumber o, int b, bool l);
|
Relation r, Page pg, OffsetNumber o, int b, bool l);
|
||||||
static char *int_range_out(INTRANGE * r);
|
static char *int_range_out(INTRANGE * r);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** routine to build an index. Basically calls insert over and over
|
** routine to build an index. Basically calls insert over and over
|
||||||
@@ -85,33 +85,33 @@ gistbuild(Relation heap,
|
|||||||
FuncIndexInfo * finfo,
|
FuncIndexInfo * finfo,
|
||||||
PredInfo * predInfo)
|
PredInfo * predInfo)
|
||||||
{
|
{
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
AttrNumber i;
|
AttrNumber i;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
TupleDesc hd,
|
TupleDesc hd,
|
||||||
id;
|
id;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
Datum *d;
|
Datum *d;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
int nb,
|
int nb,
|
||||||
nh,
|
nh,
|
||||||
ni;
|
ni;
|
||||||
|
|
||||||
#ifndef OMIT_PARTIAL_INDEX
|
#ifndef OMIT_PARTIAL_INDEX
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
TupleTable tupleTable;
|
TupleTable tupleTable;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Oid hrelid,
|
Oid hrelid,
|
||||||
irelid;
|
irelid;
|
||||||
Node *pred,
|
Node *pred,
|
||||||
*oldPred;
|
*oldPred;
|
||||||
GISTSTATE giststate;
|
GISTSTATE giststate;
|
||||||
GISTENTRY tmpcentry;
|
GISTENTRY tmpcentry;
|
||||||
bool *compvec;
|
bool *compvec;
|
||||||
|
|
||||||
/* GiSTs only know how to do stupid locking now */
|
/* GiSTs only know how to do stupid locking now */
|
||||||
RelationSetLockForWrite(index);
|
RelationSetLockForWrite(index);
|
||||||
@@ -220,8 +220,8 @@ gistbuild(Relation heap,
|
|||||||
|
|
||||||
for (i = 1; i <= natts; i++)
|
for (i = 1; i <= natts; i++)
|
||||||
{
|
{
|
||||||
int attoff;
|
int attoff;
|
||||||
bool attnull;
|
bool attnull;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Offsets are from the start of the tuple, and are
|
* Offsets are from the start of the tuple, and are
|
||||||
@@ -331,11 +331,11 @@ InsertIndexResult
|
|||||||
gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
||||||
{
|
{
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
GISTSTATE giststate;
|
GISTSTATE giststate;
|
||||||
GISTENTRY tmpentry;
|
GISTENTRY tmpentry;
|
||||||
int i;
|
int i;
|
||||||
bool *compvec;
|
bool *compvec;
|
||||||
|
|
||||||
initGISTstate(&giststate, r);
|
initGISTstate(&giststate, r);
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation
|
|||||||
** that knowledge (some compression routines may want to fish around
|
** that knowledge (some compression routines may want to fish around
|
||||||
** on the page, for example, or do something special for leaf nodes.)
|
** on the page, for example, or do something special for leaf nodes.)
|
||||||
*/
|
*/
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
gistPageAddItem(GISTSTATE * giststate,
|
gistPageAddItem(GISTSTATE * giststate,
|
||||||
Relation r,
|
Relation r,
|
||||||
Page page,
|
Page page,
|
||||||
@@ -384,8 +384,8 @@ gistPageAddItem(GISTSTATE * giststate,
|
|||||||
GISTENTRY * dentry,
|
GISTENTRY * dentry,
|
||||||
IndexTuple * newtup)
|
IndexTuple * newtup)
|
||||||
{
|
{
|
||||||
GISTENTRY tmpcentry;
|
GISTENTRY tmpcentry;
|
||||||
IndexTuple itup = (IndexTuple) item;
|
IndexTuple itup = (IndexTuple) item;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* recompress the item given that we now know the exact page and
|
* recompress the item given that we now know the exact page and
|
||||||
@@ -408,20 +408,20 @@ gistPageAddItem(GISTSTATE * giststate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
gistdoinsert(Relation r,
|
gistdoinsert(Relation r,
|
||||||
IndexTuple itup, /* itup contains compressed entry */
|
IndexTuple itup, /* itup contains compressed entry */
|
||||||
GISTSTATE * giststate)
|
GISTSTATE * giststate)
|
||||||
{
|
{
|
||||||
GISTENTRY tmpdentry;
|
GISTENTRY tmpdentry;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
OffsetNumber l;
|
OffsetNumber l;
|
||||||
GISTSTACK *stack;
|
GISTSTACK *stack;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
Page page;
|
Page page;
|
||||||
OffsetNumber off;
|
OffsetNumber off;
|
||||||
IndexTuple newtup;
|
IndexTuple newtup;
|
||||||
|
|
||||||
/* 3rd arg is ignored for now */
|
/* 3rd arg is ignored for now */
|
||||||
blk = gistChooseSubtree(r, itup, 0, giststate, &stack, &buffer);
|
blk = gistChooseSubtree(r, itup, 0, giststate, &stack, &buffer);
|
||||||
@@ -464,7 +464,7 @@ gistdoinsert(Relation r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BlockNumber
|
static BlockNumber
|
||||||
gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed
|
gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed
|
||||||
* entry */
|
* entry */
|
||||||
int level,
|
int level,
|
||||||
@@ -472,12 +472,12 @@ gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed
|
|||||||
GISTSTACK ** retstack /* out */ ,
|
GISTSTACK ** retstack /* out */ ,
|
||||||
Buffer * leafbuf /* out */ )
|
Buffer * leafbuf /* out */ )
|
||||||
{
|
{
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
GISTSTACK *stack;
|
GISTSTACK *stack;
|
||||||
Page page;
|
Page page;
|
||||||
GISTPageOpaque opaque;
|
GISTPageOpaque opaque;
|
||||||
IndexTuple which;
|
IndexTuple which;
|
||||||
|
|
||||||
blk = GISTP_ROOT;
|
blk = GISTP_ROOT;
|
||||||
buffer = InvalidBuffer;
|
buffer = InvalidBuffer;
|
||||||
@@ -496,8 +496,8 @@ gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed
|
|||||||
opaque = (GISTPageOpaque) PageGetSpecialPointer(page);
|
opaque = (GISTPageOpaque) PageGetSpecialPointer(page);
|
||||||
if (!(opaque->flags & F_LEAF))
|
if (!(opaque->flags & F_LEAF))
|
||||||
{
|
{
|
||||||
GISTSTACK *n;
|
GISTSTACK *n;
|
||||||
ItemId iid;
|
ItemId iid;
|
||||||
|
|
||||||
n = (GISTSTACK *) palloc(sizeof(GISTSTACK));
|
n = (GISTSTACK *) palloc(sizeof(GISTSTACK));
|
||||||
n->gs_parent = stack;
|
n->gs_parent = stack;
|
||||||
@@ -526,17 +526,17 @@ gistAdjustKeys(Relation r,
|
|||||||
int att_size,
|
int att_size,
|
||||||
GISTSTATE * giststate)
|
GISTSTATE * giststate)
|
||||||
{
|
{
|
||||||
char *oldud;
|
char *oldud;
|
||||||
Page p;
|
Page p;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
bool result;
|
bool result;
|
||||||
bytea *evec;
|
bytea *evec;
|
||||||
GISTENTRY centry,
|
GISTENTRY centry,
|
||||||
*ev0p,
|
*ev0p,
|
||||||
*ev1p;
|
*ev1p;
|
||||||
int size,
|
int size,
|
||||||
datumsize;
|
datumsize;
|
||||||
IndexTuple tid;
|
IndexTuple tid;
|
||||||
|
|
||||||
if (stk == (GISTSTACK *) NULL)
|
if (stk == (GISTSTACK *) NULL)
|
||||||
return;
|
return;
|
||||||
@@ -570,7 +570,7 @@ gistAdjustKeys(Relation r,
|
|||||||
(giststate->equalFn) (ev0p->pred, datum, &result);
|
(giststate->equalFn) (ev0p->pred, datum, &result);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
TupleDesc td = RelationGetTupleDescriptor(r);
|
TupleDesc td = RelationGetTupleDescriptor(r);
|
||||||
|
|
||||||
/* compress datum for storage on page */
|
/* compress datum for storage on page */
|
||||||
gistcentryinit(giststate, ¢ry, datum, ev0p->rel, ev0p->page,
|
gistcentryinit(giststate, ¢ry, datum, ev0p->rel, ev0p->page,
|
||||||
@@ -595,10 +595,10 @@ gistAdjustKeys(Relation r,
|
|||||||
* delete the old entry and insert the new * one. Note that
|
* delete the old entry and insert the new * one. Note that
|
||||||
* this may cause a split here!
|
* this may cause a split here!
|
||||||
*/
|
*/
|
||||||
IndexTuple newtup;
|
IndexTuple newtup;
|
||||||
ItemPointerData oldtid;
|
ItemPointerData oldtid;
|
||||||
char *isnull;
|
char *isnull;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
|
|
||||||
/* delete old tuple */
|
/* delete old tuple */
|
||||||
@@ -641,41 +641,41 @@ gistAdjustKeys(Relation r,
|
|||||||
* gistSplit -- split a page in the tree.
|
* gistSplit -- split a page in the tree.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
gistSplit(Relation r,
|
gistSplit(Relation r,
|
||||||
Buffer buffer,
|
Buffer buffer,
|
||||||
GISTSTACK * stack,
|
GISTSTACK * stack,
|
||||||
IndexTuple itup, /* contains compressed entry */
|
IndexTuple itup, /* contains compressed entry */
|
||||||
GISTSTATE * giststate)
|
GISTSTATE * giststate)
|
||||||
{
|
{
|
||||||
Page p;
|
Page p;
|
||||||
Buffer leftbuf,
|
Buffer leftbuf,
|
||||||
rightbuf;
|
rightbuf;
|
||||||
Page left,
|
Page left,
|
||||||
right;
|
right;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
IndexTuple item;
|
IndexTuple item;
|
||||||
IndexTuple ltup,
|
IndexTuple ltup,
|
||||||
rtup,
|
rtup,
|
||||||
newtup;
|
newtup;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
OffsetNumber leftoff,
|
OffsetNumber leftoff,
|
||||||
rightoff;
|
rightoff;
|
||||||
BlockNumber lbknum,
|
BlockNumber lbknum,
|
||||||
rbknum;
|
rbknum;
|
||||||
BlockNumber bufblock;
|
BlockNumber bufblock;
|
||||||
GISTPageOpaque opaque;
|
GISTPageOpaque opaque;
|
||||||
int blank;
|
int blank;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
char *isnull;
|
char *isnull;
|
||||||
GIST_SPLITVEC v;
|
GIST_SPLITVEC v;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
bytea *entryvec;
|
bytea *entryvec;
|
||||||
bool *decompvec;
|
bool *decompvec;
|
||||||
IndexTuple item_1;
|
IndexTuple item_1;
|
||||||
GISTENTRY tmpdentry,
|
GISTENTRY tmpdentry,
|
||||||
tmpentry;
|
tmpentry;
|
||||||
|
|
||||||
isnull = (char *) palloc(r->rd_rel->relnatts);
|
isnull = (char *) palloc(r->rd_rel->relnatts);
|
||||||
for (blank = 0; blank < r->rd_rel->relnatts; blank++)
|
for (blank = 0; blank < r->rd_rel->relnatts; blank++)
|
||||||
@@ -911,11 +911,11 @@ static void
|
|||||||
gistentryinserttwo(Relation r, GISTSTACK * stk, IndexTuple ltup,
|
gistentryinserttwo(Relation r, GISTSTACK * stk, IndexTuple ltup,
|
||||||
IndexTuple rtup, GISTSTATE * giststate)
|
IndexTuple rtup, GISTSTATE * giststate)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
GISTENTRY tmpentry;
|
GISTENTRY tmpentry;
|
||||||
IndexTuple newtup;
|
IndexTuple newtup;
|
||||||
|
|
||||||
b = ReadBuffer(r, stk->gs_blk);
|
b = ReadBuffer(r, stk->gs_blk);
|
||||||
p = BufferGetPage(b);
|
p = BufferGetPage(b);
|
||||||
@@ -949,16 +949,16 @@ gistentryinserttwo(Relation r, GISTSTACK * stk, IndexTuple ltup,
|
|||||||
/*
|
/*
|
||||||
** Insert an entry onto a page
|
** Insert an entry onto a page
|
||||||
*/
|
*/
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
gistentryinsert(Relation r, GISTSTACK * stk, IndexTuple tup,
|
gistentryinsert(Relation r, GISTSTACK * stk, IndexTuple tup,
|
||||||
GISTSTATE * giststate)
|
GISTSTATE * giststate)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
OffsetNumber off;
|
OffsetNumber off;
|
||||||
GISTENTRY tmpentry;
|
GISTENTRY tmpentry;
|
||||||
IndexTuple newtup;
|
IndexTuple newtup;
|
||||||
|
|
||||||
b = ReadBuffer(r, stk->gs_blk);
|
b = ReadBuffer(r, stk->gs_blk);
|
||||||
p = BufferGetPage(b);
|
p = BufferGetPage(b);
|
||||||
@@ -992,10 +992,10 @@ gistentryinsert(Relation r, GISTSTACK * stk, IndexTuple tup,
|
|||||||
static void
|
static void
|
||||||
gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt)
|
gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
GISTENTRY tmpentry;
|
GISTENTRY tmpentry;
|
||||||
IndexTuple newtup;
|
IndexTuple newtup;
|
||||||
|
|
||||||
b = ReadBuffer(r, GISTP_ROOT);
|
b = ReadBuffer(r, GISTP_ROOT);
|
||||||
GISTInitBuffer(b, 0);
|
GISTInitBuffer(b, 0);
|
||||||
@@ -1022,9 +1022,9 @@ gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt)
|
|||||||
static void
|
static void
|
||||||
GISTInitBuffer(Buffer b, uint32 f)
|
GISTInitBuffer(Buffer b, uint32 f)
|
||||||
{
|
{
|
||||||
GISTPageOpaque opaque;
|
GISTPageOpaque opaque;
|
||||||
Page page;
|
Page page;
|
||||||
Size pageSize;
|
Size pageSize;
|
||||||
|
|
||||||
pageSize = BufferGetPageSize(b);
|
pageSize = BufferGetPageSize(b);
|
||||||
|
|
||||||
@@ -1040,21 +1040,21 @@ GISTInitBuffer(Buffer b, uint32 f)
|
|||||||
/*
|
/*
|
||||||
** find entry with lowest penalty
|
** find entry with lowest penalty
|
||||||
*/
|
*/
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
|
gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
|
||||||
GISTSTATE * giststate)
|
GISTSTATE * giststate)
|
||||||
{
|
{
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
char *id;
|
char *id;
|
||||||
char *datum;
|
char *datum;
|
||||||
float usize;
|
float usize;
|
||||||
OffsetNumber which;
|
OffsetNumber which;
|
||||||
float which_grow;
|
float which_grow;
|
||||||
GISTENTRY entry,
|
GISTENTRY entry,
|
||||||
identry;
|
identry;
|
||||||
int size,
|
int size,
|
||||||
idsize;
|
idsize;
|
||||||
|
|
||||||
idsize = IndexTupleSize(it) - sizeof(IndexTupleData);
|
idsize = IndexTupleSize(it) - sizeof(IndexTupleData);
|
||||||
id = ((char *) it) + sizeof(IndexTupleData);
|
id = ((char *) it) + sizeof(IndexTupleData);
|
||||||
@@ -1097,7 +1097,7 @@ gistnospace(Page p, IndexTuple it)
|
|||||||
void
|
void
|
||||||
gistfreestack(GISTSTACK * s)
|
gistfreestack(GISTSTACK * s)
|
||||||
{
|
{
|
||||||
GISTSTACK *p;
|
GISTSTACK *p;
|
||||||
|
|
||||||
while (s != (GISTSTACK *) NULL)
|
while (s != (GISTSTACK *) NULL)
|
||||||
{
|
{
|
||||||
@@ -1114,10 +1114,10 @@ gistfreestack(GISTSTACK * s)
|
|||||||
void
|
void
|
||||||
gistdelete(Relation r, ItemPointer tid)
|
gistdelete(Relation r, ItemPointer tid)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
/* must write-lock on delete */
|
/* must write-lock on delete */
|
||||||
RelationSetLockForWrite(r);
|
RelationSetLockForWrite(r);
|
||||||
@@ -1142,17 +1142,17 @@ gistdelete(Relation r, ItemPointer tid)
|
|||||||
void
|
void
|
||||||
initGISTstate(GISTSTATE * giststate, Relation index)
|
initGISTstate(GISTSTATE * giststate, Relation index)
|
||||||
{
|
{
|
||||||
RegProcedure consistent_proc,
|
RegProcedure consistent_proc,
|
||||||
union_proc,
|
union_proc,
|
||||||
compress_proc,
|
compress_proc,
|
||||||
decompress_proc;
|
decompress_proc;
|
||||||
RegProcedure penalty_proc,
|
RegProcedure penalty_proc,
|
||||||
picksplit_proc,
|
picksplit_proc,
|
||||||
equal_proc;
|
equal_proc;
|
||||||
func_ptr user_fn;
|
func_ptr user_fn;
|
||||||
int pronargs;
|
int pronargs;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
IndexTupleForm itupform;
|
IndexTupleForm itupform;
|
||||||
|
|
||||||
consistent_proc = index_getprocid(index, 1, GIST_CONSISTENT_PROC);
|
consistent_proc = index_getprocid(index, 1, GIST_CONSISTENT_PROC);
|
||||||
union_proc = index_getprocid(index, 1, GIST_UNION_PROC);
|
union_proc = index_getprocid(index, 1, GIST_UNION_PROC);
|
||||||
@@ -1209,10 +1209,10 @@ initGISTstate(GISTSTATE * giststate, Relation index)
|
|||||||
** the key with another key, which may involve generating a new IndexTuple
|
** the key with another key, which may involve generating a new IndexTuple
|
||||||
** if the sizes don't match
|
** if the sizes don't match
|
||||||
*/
|
*/
|
||||||
static IndexTuple
|
static IndexTuple
|
||||||
gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t)
|
gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t)
|
||||||
{
|
{
|
||||||
char *datum = (((char *) t) + sizeof(IndexTupleData));
|
char *datum = (((char *) t) + sizeof(IndexTupleData));
|
||||||
|
|
||||||
/* if new entry fits in index tuple, copy it in */
|
/* if new entry fits in index tuple, copy it in */
|
||||||
if (entry.bytes < IndexTupleSize(t) - sizeof(IndexTupleData))
|
if (entry.bytes < IndexTupleSize(t) - sizeof(IndexTupleData))
|
||||||
@@ -1228,10 +1228,10 @@ gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* generate a new index tuple for the compressed entry */
|
/* generate a new index tuple for the compressed entry */
|
||||||
TupleDesc tupDesc = r->rd_att;
|
TupleDesc tupDesc = r->rd_att;
|
||||||
IndexTuple newtup;
|
IndexTuple newtup;
|
||||||
char *isnull;
|
char *isnull;
|
||||||
int blank;
|
int blank;
|
||||||
|
|
||||||
isnull = (char *) palloc(r->rd_rel->relnatts);
|
isnull = (char *) palloc(r->rd_rel->relnatts);
|
||||||
for (blank = 0; blank < r->rd_rel->relnatts; blank++)
|
for (blank = 0; blank < r->rd_rel->relnatts; blank++)
|
||||||
@@ -1253,7 +1253,7 @@ void
|
|||||||
gistdentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r,
|
gistdentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r,
|
||||||
Page pg, OffsetNumber o, int b, bool l)
|
Page pg, OffsetNumber o, int b, bool l)
|
||||||
{
|
{
|
||||||
GISTENTRY *dep;
|
GISTENTRY *dep;
|
||||||
|
|
||||||
gistentryinit(*e, pr, r, pg, o, b, l);
|
gistentryinit(*e, pr, r, pg, o, b, l);
|
||||||
if (giststate->haskeytype)
|
if (giststate->haskeytype)
|
||||||
@@ -1274,7 +1274,7 @@ static void
|
|||||||
gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r,
|
gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r,
|
||||||
Page pg, OffsetNumber o, int b, bool l)
|
Page pg, OffsetNumber o, int b, bool l)
|
||||||
{
|
{
|
||||||
GISTENTRY *cep;
|
GISTENTRY *cep;
|
||||||
|
|
||||||
gistentryinit(*e, pr, r, pg, o, b, l);
|
gistentryinit(*e, pr, r, pg, o, b, l);
|
||||||
if (giststate->haskeytype)
|
if (giststate->haskeytype)
|
||||||
@@ -1299,18 +1299,18 @@ gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r,
|
|||||||
void
|
void
|
||||||
_gistdump(Relation r)
|
_gistdump(Relation r)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
BlockNumber nblocks;
|
BlockNumber nblocks;
|
||||||
GISTPageOpaque po;
|
GISTPageOpaque po;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
BlockNumber itblkno;
|
BlockNumber itblkno;
|
||||||
OffsetNumber itoffno;
|
OffsetNumber itoffno;
|
||||||
char *datum;
|
char *datum;
|
||||||
char *itkey;
|
char *itkey;
|
||||||
|
|
||||||
nblocks = RelationGetNumberOfBlocks(r);
|
nblocks = RelationGetNumberOfBlocks(r);
|
||||||
for (blkno = 0; blkno < nblocks; blkno++)
|
for (blkno = 0; blkno < nblocks; blkno++)
|
||||||
@@ -1350,12 +1350,12 @@ _gistdump(Relation r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
static char *
|
static char *
|
||||||
text_range_out(TXTRANGE * r)
|
text_range_out(TXTRANGE * r)
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
char *lower,
|
char *lower,
|
||||||
*upper;
|
*upper;
|
||||||
|
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@@ -1377,10 +1377,10 @@ text_range_out(TXTRANGE * r)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
int_range_out(INTRANGE * r)
|
int_range_out(INTRANGE * r)
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|||||||
@@ -62,19 +62,19 @@ gistgettuple(IndexScanDesc s, ScanDirection dir)
|
|||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
gistfirst(IndexScanDesc s, ScanDirection dir)
|
gistfirst(IndexScanDesc s, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
OffsetNumber n;
|
OffsetNumber n;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
GISTPageOpaque po;
|
GISTPageOpaque po;
|
||||||
GISTScanOpaque so;
|
GISTScanOpaque so;
|
||||||
GISTSTACK *stk;
|
GISTSTACK *stk;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
IndexTuple it;
|
IndexTuple it;
|
||||||
|
|
||||||
b = ReadBuffer(s->relation, GISTP_ROOT);
|
b = ReadBuffer(s->relation, GISTP_ROOT);
|
||||||
p = BufferGetPage(b);
|
p = BufferGetPage(b);
|
||||||
@@ -145,19 +145,19 @@ gistfirst(IndexScanDesc s, ScanDirection dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
gistnext(IndexScanDesc s, ScanDirection dir)
|
gistnext(IndexScanDesc s, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
OffsetNumber n;
|
OffsetNumber n;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
GISTPageOpaque po;
|
GISTPageOpaque po;
|
||||||
GISTScanOpaque so;
|
GISTScanOpaque so;
|
||||||
GISTSTACK *stk;
|
GISTSTACK *stk;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
IndexTuple it;
|
IndexTuple it;
|
||||||
|
|
||||||
blk = ItemPointerGetBlockNumber(&(s->currentItemData));
|
blk = ItemPointerGetBlockNumber(&(s->currentItemData));
|
||||||
n = ItemPointerGetOffsetNumber(&(s->currentItemData));
|
n = ItemPointerGetOffsetNumber(&(s->currentItemData));
|
||||||
@@ -247,7 +247,7 @@ gistnext(IndexScanDesc s, ScanDirection dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Similar to index_keytest, but decompresses the key in the IndexTuple */
|
/* Similar to index_keytest, but decompresses the key in the IndexTuple */
|
||||||
static bool
|
static bool
|
||||||
gistindex_keytest(IndexTuple tuple,
|
gistindex_keytest(IndexTuple tuple,
|
||||||
TupleDesc tupdesc,
|
TupleDesc tupdesc,
|
||||||
int scanKeySize,
|
int scanKeySize,
|
||||||
@@ -257,10 +257,10 @@ gistindex_keytest(IndexTuple tuple,
|
|||||||
Page p,
|
Page p,
|
||||||
OffsetNumber offset)
|
OffsetNumber offset)
|
||||||
{
|
{
|
||||||
bool isNull;
|
bool isNull;
|
||||||
Datum datum;
|
Datum datum;
|
||||||
int test;
|
int test;
|
||||||
GISTENTRY de;
|
GISTENTRY de;
|
||||||
|
|
||||||
IncrIndexProcessed();
|
IncrIndexProcessed();
|
||||||
|
|
||||||
@@ -308,14 +308,14 @@ gistindex_keytest(IndexTuple tuple,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
|
gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
|
||||||
{
|
{
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
char *it;
|
char *it;
|
||||||
GISTPageOpaque po;
|
GISTPageOpaque po;
|
||||||
GISTScanOpaque so;
|
GISTScanOpaque so;
|
||||||
GISTSTATE *giststate;
|
GISTSTATE *giststate;
|
||||||
|
|
||||||
maxoff = PageGetMaxOffsetNumber(p);
|
maxoff = PageGetMaxOffsetNumber(p);
|
||||||
po = (GISTPageOpaque) PageGetSpecialPointer(p);
|
po = (GISTPageOpaque) PageGetSpecialPointer(p);
|
||||||
@@ -355,11 +355,11 @@ gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
|
|||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
gistscancache(IndexScanDesc s, ScanDirection dir)
|
gistscancache(IndexScanDesc s, ScanDirection dir)
|
||||||
{
|
{
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
ItemPointer ip;
|
ItemPointer ip;
|
||||||
|
|
||||||
if (!(ScanDirectionIsNoMovement(dir)
|
if (!(ScanDirectionIsNoMovement(dir)
|
||||||
&& ItemPointerIsValid(&(s->currentItemData))))
|
&& ItemPointerIsValid(&(s->currentItemData))))
|
||||||
@@ -384,14 +384,14 @@ gistscancache(IndexScanDesc s, ScanDirection dir)
|
|||||||
* gistheapptr returns the item pointer to the tuple in the heap relation
|
* gistheapptr returns the item pointer to the tuple in the heap relation
|
||||||
* for which itemp is the index relation item pointer.
|
* for which itemp is the index relation item pointer.
|
||||||
*/
|
*/
|
||||||
static ItemPointer
|
static ItemPointer
|
||||||
gistheapptr(Relation r, ItemPointer itemp)
|
gistheapptr(Relation r, ItemPointer itemp)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
IndexTuple it;
|
IndexTuple it;
|
||||||
ItemPointer ip;
|
ItemPointer ip;
|
||||||
OffsetNumber n;
|
OffsetNumber n;
|
||||||
|
|
||||||
ip = (ItemPointer) palloc(sizeof(ItemPointerData));
|
ip = (ItemPointer) palloc(sizeof(ItemPointerData));
|
||||||
if (ItemPointerIsValid(itemp))
|
if (ItemPointerIsValid(itemp))
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* routines defined and used here */
|
/* routines defined and used here */
|
||||||
static void gistregscan(IndexScanDesc s);
|
static void gistregscan(IndexScanDesc s);
|
||||||
static void gistdropscan(IndexScanDesc s);
|
static void gistdropscan(IndexScanDesc s);
|
||||||
static void
|
static void
|
||||||
gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
||||||
OffsetNumber offnum);
|
OffsetNumber offnum);
|
||||||
@@ -51,9 +51,9 @@ adjustiptr(IndexScanDesc s, ItemPointer iptr,
|
|||||||
|
|
||||||
typedef struct GISTScanListData
|
typedef struct GISTScanListData
|
||||||
{
|
{
|
||||||
IndexScanDesc gsl_scan;
|
IndexScanDesc gsl_scan;
|
||||||
struct GISTScanListData *gsl_next;
|
struct GISTScanListData *gsl_next;
|
||||||
} GISTScanListData;
|
} GISTScanListData;
|
||||||
|
|
||||||
typedef GISTScanListData *GISTScanList;
|
typedef GISTScanListData *GISTScanList;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ gistbeginscan(Relation r,
|
|||||||
uint16 nkeys,
|
uint16 nkeys,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
IndexScanDesc s;
|
IndexScanDesc s;
|
||||||
|
|
||||||
RelationSetLockForRead(r);
|
RelationSetLockForRead(r);
|
||||||
s = RelationGetIndexScan(r, fromEnd, nkeys, key);
|
s = RelationGetIndexScan(r, fromEnd, nkeys, key);
|
||||||
@@ -78,8 +78,8 @@ gistbeginscan(Relation r,
|
|||||||
void
|
void
|
||||||
gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
|
gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
|
||||||
{
|
{
|
||||||
GISTScanOpaque p;
|
GISTScanOpaque p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!IndexScanIsValid(s))
|
if (!IndexScanIsValid(s))
|
||||||
{
|
{
|
||||||
@@ -173,10 +173,10 @@ gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
|
|||||||
void
|
void
|
||||||
gistmarkpos(IndexScanDesc s)
|
gistmarkpos(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
GISTScanOpaque p;
|
GISTScanOpaque p;
|
||||||
GISTSTACK *o,
|
GISTSTACK *o,
|
||||||
*n,
|
*n,
|
||||||
*tmp;
|
*tmp;
|
||||||
|
|
||||||
s->currentMarkData = s->currentItemData;
|
s->currentMarkData = s->currentItemData;
|
||||||
p = (GISTScanOpaque) s->opaque;
|
p = (GISTScanOpaque) s->opaque;
|
||||||
@@ -206,10 +206,10 @@ gistmarkpos(IndexScanDesc s)
|
|||||||
void
|
void
|
||||||
gistrestrpos(IndexScanDesc s)
|
gistrestrpos(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
GISTScanOpaque p;
|
GISTScanOpaque p;
|
||||||
GISTSTACK *o,
|
GISTSTACK *o,
|
||||||
*n,
|
*n,
|
||||||
*tmp;
|
*tmp;
|
||||||
|
|
||||||
s->currentItemData = s->currentMarkData;
|
s->currentItemData = s->currentMarkData;
|
||||||
p = (GISTScanOpaque) s->opaque;
|
p = (GISTScanOpaque) s->opaque;
|
||||||
@@ -239,7 +239,7 @@ gistrestrpos(IndexScanDesc s)
|
|||||||
void
|
void
|
||||||
gistendscan(IndexScanDesc s)
|
gistendscan(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
GISTScanOpaque p;
|
GISTScanOpaque p;
|
||||||
|
|
||||||
p = (GISTScanOpaque) s->opaque;
|
p = (GISTScanOpaque) s->opaque;
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ gistendscan(IndexScanDesc s)
|
|||||||
static void
|
static void
|
||||||
gistregscan(IndexScanDesc s)
|
gistregscan(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
GISTScanList l;
|
GISTScanList l;
|
||||||
|
|
||||||
l = (GISTScanList) palloc(sizeof(GISTScanListData));
|
l = (GISTScanList) palloc(sizeof(GISTScanListData));
|
||||||
l->gsl_scan = s;
|
l->gsl_scan = s;
|
||||||
@@ -268,8 +268,8 @@ gistregscan(IndexScanDesc s)
|
|||||||
static void
|
static void
|
||||||
gistdropscan(IndexScanDesc s)
|
gistdropscan(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
GISTScanList l;
|
GISTScanList l;
|
||||||
GISTScanList prev;
|
GISTScanList prev;
|
||||||
|
|
||||||
prev = (GISTScanList) NULL;
|
prev = (GISTScanList) NULL;
|
||||||
|
|
||||||
@@ -294,8 +294,8 @@ gistdropscan(IndexScanDesc s)
|
|||||||
void
|
void
|
||||||
gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
|
gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
GISTScanList l;
|
GISTScanList l;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
|
|
||||||
relid = r->rd_id;
|
relid = r->rd_id;
|
||||||
for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next)
|
for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next)
|
||||||
@@ -321,7 +321,7 @@ gistadjone(IndexScanDesc s,
|
|||||||
BlockNumber blkno,
|
BlockNumber blkno,
|
||||||
OffsetNumber offnum)
|
OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
GISTScanOpaque so;
|
GISTScanOpaque so;
|
||||||
|
|
||||||
adjustiptr(s, &(s->currentItemData), op, blkno, offnum);
|
adjustiptr(s, &(s->currentItemData), op, blkno, offnum);
|
||||||
adjustiptr(s, &(s->currentMarkData), op, blkno, offnum);
|
adjustiptr(s, &(s->currentMarkData), op, blkno, offnum);
|
||||||
@@ -349,8 +349,8 @@ adjustiptr(IndexScanDesc s,
|
|||||||
BlockNumber blkno,
|
BlockNumber blkno,
|
||||||
OffsetNumber offnum)
|
OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
OffsetNumber curoff;
|
OffsetNumber curoff;
|
||||||
GISTScanOpaque so;
|
GISTScanOpaque so;
|
||||||
|
|
||||||
if (ItemPointerIsValid(iptr))
|
if (ItemPointerIsValid(iptr))
|
||||||
{
|
{
|
||||||
@@ -361,39 +361,43 @@ adjustiptr(IndexScanDesc s,
|
|||||||
|
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case GISTOP_DEL:
|
case GISTOP_DEL:
|
||||||
/* back up one if we need to */
|
/* back up one if we need to */
|
||||||
if (curoff >= offnum)
|
if (curoff >= offnum)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (curoff > FirstOffsetNumber)
|
if (curoff > FirstOffsetNumber)
|
||||||
{
|
{
|
||||||
/* just adjust the item pointer */
|
/* just adjust the item pointer */
|
||||||
ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff));
|
ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* remember that we're before the current tuple */
|
|
||||||
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
|
||||||
if (iptr == &(s->currentItemData))
|
|
||||||
so->s_flags |= GS_CURBEFORE;
|
|
||||||
else
|
else
|
||||||
so->s_flags |= GS_MRKBEFORE;
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* remember that we're before the current
|
||||||
|
* tuple
|
||||||
|
*/
|
||||||
|
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
||||||
|
if (iptr == &(s->currentItemData))
|
||||||
|
so->s_flags |= GS_CURBEFORE;
|
||||||
|
else
|
||||||
|
so->s_flags |= GS_MRKBEFORE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case GISTOP_SPLIT:
|
case GISTOP_SPLIT:
|
||||||
/* back to start of page on split */
|
/* back to start of page on split */
|
||||||
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
||||||
if (iptr == &(s->currentItemData))
|
if (iptr == &(s->currentItemData))
|
||||||
so->s_flags &= ~GS_CURBEFORE;
|
so->s_flags &= ~GS_CURBEFORE;
|
||||||
else
|
else
|
||||||
so->s_flags &= ~GS_MRKBEFORE;
|
so->s_flags &= ~GS_MRKBEFORE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(WARN, "Bad operation in GiST scan adjust: %d", op);
|
elog(WARN, "Bad operation in GiST scan adjust: %d", op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.13 1997/09/07 04:37:49 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.14 1997/09/08 02:20:10 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This file contains only the public interface routines.
|
* This file contains only the public interface routines.
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool BuildingHash = false;
|
bool BuildingHash = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hashbuild() -- build a new hash index.
|
* hashbuild() -- build a new hash index.
|
||||||
@@ -52,30 +52,30 @@ hashbuild(Relation heap,
|
|||||||
FuncIndexInfo * finfo,
|
FuncIndexInfo * finfo,
|
||||||
PredInfo * predInfo)
|
PredInfo * predInfo)
|
||||||
{
|
{
|
||||||
HeapScanDesc hscan;
|
HeapScanDesc hscan;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
TupleDesc htupdesc,
|
TupleDesc htupdesc,
|
||||||
itupdesc;
|
itupdesc;
|
||||||
Datum *attdata;
|
Datum *attdata;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
int nhtups,
|
int nhtups,
|
||||||
nitups;
|
nitups;
|
||||||
int i;
|
int i;
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
|
|
||||||
#ifndef OMIT_PARTIAL_INDEX
|
#ifndef OMIT_PARTIAL_INDEX
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
TupleTable tupleTable;
|
TupleTable tupleTable;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Oid hrelid,
|
Oid hrelid,
|
||||||
irelid;
|
irelid;
|
||||||
Node *pred,
|
Node *pred,
|
||||||
*oldPred;
|
*oldPred;
|
||||||
|
|
||||||
/* note that this is a new btree */
|
/* note that this is a new btree */
|
||||||
BuildingHash = true;
|
BuildingHash = true;
|
||||||
@@ -171,8 +171,8 @@ hashbuild(Relation heap,
|
|||||||
*/
|
*/
|
||||||
for (i = 1; i <= natts; i++)
|
for (i = 1; i <= natts; i++)
|
||||||
{
|
{
|
||||||
int attoff;
|
int attoff;
|
||||||
bool attnull;
|
bool attnull;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Offsets are from the start of the tuple, and are
|
* Offsets are from the start of the tuple, and are
|
||||||
@@ -280,8 +280,8 @@ hashbuild(Relation heap,
|
|||||||
InsertIndexResult
|
InsertIndexResult
|
||||||
hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
||||||
{
|
{
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
|
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relati
|
|||||||
/*
|
/*
|
||||||
* hashgettuple() -- Get the next tuple in the scan.
|
* hashgettuple() -- Get the next tuple in the scan.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
hashgettuple(IndexScanDesc scan, ScanDirection dir)
|
hashgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||||
{
|
{
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
@@ -329,14 +329,14 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
/*
|
/*
|
||||||
* hashbeginscan() -- start a scan on a hash index
|
* hashbeginscan() -- start a scan on a hash index
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
hashbeginscan(Relation rel,
|
hashbeginscan(Relation rel,
|
||||||
bool fromEnd,
|
bool fromEnd,
|
||||||
uint16 keysz,
|
uint16 keysz,
|
||||||
ScanKey scankey)
|
ScanKey scankey)
|
||||||
{
|
{
|
||||||
IndexScanDesc scan;
|
IndexScanDesc scan;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey);
|
scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey);
|
||||||
so = (HashScanOpaque) palloc(sizeof(HashScanOpaqueData));
|
so = (HashScanOpaque) palloc(sizeof(HashScanOpaqueData));
|
||||||
@@ -356,8 +356,8 @@ hashbeginscan(Relation rel,
|
|||||||
void
|
void
|
||||||
hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
so = (HashScanOpaque) scan->opaque;
|
so = (HashScanOpaque) scan->opaque;
|
||||||
|
|
||||||
@@ -391,8 +391,8 @@ void
|
|||||||
hashendscan(IndexScanDesc scan)
|
hashendscan(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
|
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
so = (HashScanOpaque) scan->opaque;
|
so = (HashScanOpaque) scan->opaque;
|
||||||
|
|
||||||
@@ -426,8 +426,8 @@ hashendscan(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
hashmarkpos(IndexScanDesc scan)
|
hashmarkpos(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see if we ever call this code. if we do, then so_mrkbuf a useful
|
* see if we ever call this code. if we do, then so_mrkbuf a useful
|
||||||
@@ -463,8 +463,8 @@ hashmarkpos(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
hashrestrpos(IndexScanDesc scan)
|
hashrestrpos(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see if we ever call this code. if we do, then so_mrkbuf a useful
|
* see if we ever call this code. if we do, then so_mrkbuf a useful
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.4 1997/09/07 04:37:53 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.5 1997/09/08 02:20:13 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* These functions are stored in pg_amproc. For each operator class
|
* These functions are stored in pg_amproc. For each operator class
|
||||||
@@ -36,10 +36,10 @@ hashint4(uint32 key)
|
|||||||
uint32
|
uint32
|
||||||
hashfloat4(float32 keyp)
|
hashfloat4(float32 keyp)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int loop;
|
int loop;
|
||||||
uint32 h;
|
uint32 h;
|
||||||
char *kp = (char *) keyp;
|
char *kp = (char *) keyp;
|
||||||
|
|
||||||
len = sizeof(float32data);
|
len = sizeof(float32data);
|
||||||
|
|
||||||
@@ -55,25 +55,25 @@ hashfloat4(float32 keyp)
|
|||||||
|
|
||||||
switch (len & (8 - 1))
|
switch (len & (8 - 1))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
do
|
do
|
||||||
{ /* All fall throughs */
|
{ /* All fall throughs */
|
||||||
HASH4;
|
HASH4;
|
||||||
case 7:
|
case 7:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 6:
|
case 6:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 5:
|
case 5:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 4:
|
case 4:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 3:
|
case 3:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 2:
|
case 2:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 1:
|
case 1:
|
||||||
HASH4;
|
HASH4;
|
||||||
} while (--loop);
|
} while (--loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (h);
|
return (h);
|
||||||
@@ -83,10 +83,10 @@ hashfloat4(float32 keyp)
|
|||||||
uint32
|
uint32
|
||||||
hashfloat8(float64 keyp)
|
hashfloat8(float64 keyp)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int loop;
|
int loop;
|
||||||
uint32 h;
|
uint32 h;
|
||||||
char *kp = (char *) keyp;
|
char *kp = (char *) keyp;
|
||||||
|
|
||||||
len = sizeof(float64data);
|
len = sizeof(float64data);
|
||||||
|
|
||||||
@@ -102,25 +102,25 @@ hashfloat8(float64 keyp)
|
|||||||
|
|
||||||
switch (len & (8 - 1))
|
switch (len & (8 - 1))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
do
|
do
|
||||||
{ /* All fall throughs */
|
{ /* All fall throughs */
|
||||||
HASH4;
|
HASH4;
|
||||||
case 7:
|
case 7:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 6:
|
case 6:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 5:
|
case 5:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 4:
|
case 4:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 3:
|
case 3:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 2:
|
case 2:
|
||||||
HASH4;
|
HASH4;
|
||||||
case 1:
|
case 1:
|
||||||
HASH4;
|
HASH4;
|
||||||
} while (--loop);
|
} while (--loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (h);
|
return (h);
|
||||||
@@ -137,8 +137,8 @@ hashoid(Oid key)
|
|||||||
uint32
|
uint32
|
||||||
hashchar(char key)
|
hashchar(char key)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
uint32 h;
|
uint32 h;
|
||||||
|
|
||||||
len = sizeof(char);
|
len = sizeof(char);
|
||||||
|
|
||||||
@@ -156,9 +156,9 @@ hashchar(char key)
|
|||||||
uint32
|
uint32
|
||||||
hashchar2(uint16 intkey)
|
hashchar2(uint16 intkey)
|
||||||
{
|
{
|
||||||
uint32 h;
|
uint32 h;
|
||||||
int len;
|
int len;
|
||||||
char *key = (char *) &intkey;
|
char *key = (char *) &intkey;
|
||||||
|
|
||||||
h = 0;
|
h = 0;
|
||||||
len = sizeof(uint16);
|
len = sizeof(uint16);
|
||||||
@@ -173,9 +173,9 @@ hashchar2(uint16 intkey)
|
|||||||
uint32
|
uint32
|
||||||
hashchar4(uint32 intkey)
|
hashchar4(uint32 intkey)
|
||||||
{
|
{
|
||||||
uint32 h;
|
uint32 h;
|
||||||
int len;
|
int len;
|
||||||
char *key = (char *) &intkey;
|
char *key = (char *) &intkey;
|
||||||
|
|
||||||
h = 0;
|
h = 0;
|
||||||
len = sizeof(uint32);
|
len = sizeof(uint32);
|
||||||
@@ -190,8 +190,8 @@ hashchar4(uint32 intkey)
|
|||||||
uint32
|
uint32
|
||||||
hashchar8(char *key)
|
hashchar8(char *key)
|
||||||
{
|
{
|
||||||
uint32 h;
|
uint32 h;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
h = 0;
|
h = 0;
|
||||||
len = sizeof(char8);
|
len = sizeof(char8);
|
||||||
@@ -206,9 +206,9 @@ hashchar8(char *key)
|
|||||||
uint32
|
uint32
|
||||||
hashname(NameData * n)
|
hashname(NameData * n)
|
||||||
{
|
{
|
||||||
uint32 h;
|
uint32 h;
|
||||||
int len;
|
int len;
|
||||||
char *key;
|
char *key;
|
||||||
|
|
||||||
key = n->data;
|
key = n->data;
|
||||||
|
|
||||||
@@ -226,8 +226,8 @@ hashname(NameData * n)
|
|||||||
uint32
|
uint32
|
||||||
hashchar16(char *key)
|
hashchar16(char *key)
|
||||||
{
|
{
|
||||||
uint32 h;
|
uint32 h;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
h = 0;
|
h = 0;
|
||||||
len = sizeof(char16);
|
len = sizeof(char16);
|
||||||
@@ -254,10 +254,10 @@ hashchar16(char *key)
|
|||||||
uint32
|
uint32
|
||||||
hashtext(struct varlena * key)
|
hashtext(struct varlena * key)
|
||||||
{
|
{
|
||||||
int keylen;
|
int keylen;
|
||||||
char *keydata;
|
char *keydata;
|
||||||
uint32 n;
|
uint32 n;
|
||||||
int loop;
|
int loop;
|
||||||
|
|
||||||
keydata = VARDATA(key);
|
keydata = VARDATA(key);
|
||||||
keylen = VARSIZE(key);
|
keylen = VARSIZE(key);
|
||||||
@@ -274,25 +274,25 @@ hashtext(struct varlena * key)
|
|||||||
|
|
||||||
switch (keylen & (8 - 1))
|
switch (keylen & (8 - 1))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
do
|
do
|
||||||
{ /* All fall throughs */
|
{ /* All fall throughs */
|
||||||
HASHC;
|
HASHC;
|
||||||
case 7:
|
case 7:
|
||||||
HASHC;
|
HASHC;
|
||||||
case 6:
|
case 6:
|
||||||
HASHC;
|
HASHC;
|
||||||
case 5:
|
case 5:
|
||||||
HASHC;
|
HASHC;
|
||||||
case 4:
|
case 4:
|
||||||
HASHC;
|
HASHC;
|
||||||
case 3:
|
case 3:
|
||||||
HASHC;
|
HASHC;
|
||||||
case 2:
|
case 2:
|
||||||
HASHC;
|
HASHC;
|
||||||
case 1:
|
case 1:
|
||||||
HASHC;
|
HASHC;
|
||||||
} while (--loop);
|
} while (--loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (n);
|
return (n);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.9 1997/09/07 04:37:56 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.10 1997/09/08 02:20:16 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -32,15 +32,15 @@ static OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey
|
|||||||
InsertIndexResult
|
InsertIndexResult
|
||||||
_hash_doinsert(Relation rel, HashItem hitem)
|
_hash_doinsert(Relation rel, HashItem hitem)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
ScanKey itup_scankey;
|
ScanKey itup_scankey;
|
||||||
int natts;
|
int natts;
|
||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ);
|
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ);
|
||||||
metap = (HashMetaPage) BufferGetPage(metabuf);
|
metap = (HashMetaPage) BufferGetPage(metabuf);
|
||||||
@@ -101,7 +101,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
|
|||||||
* we will have dropped both the pin and the write lock on the buffer.
|
* we will have dropped both the pin and the write lock on the buffer.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
_hash_insertonpg(Relation rel,
|
_hash_insertonpg(Relation rel,
|
||||||
Buffer buf,
|
Buffer buf,
|
||||||
int keysz,
|
int keysz,
|
||||||
@@ -110,15 +110,15 @@ _hash_insertonpg(Relation rel,
|
|||||||
Buffer metabuf)
|
Buffer metabuf)
|
||||||
{
|
{
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
Page page;
|
Page page;
|
||||||
BlockNumber itup_blkno;
|
BlockNumber itup_blkno;
|
||||||
OffsetNumber itup_off;
|
OffsetNumber itup_off;
|
||||||
int itemsz;
|
int itemsz;
|
||||||
HashPageOpaque pageopaque;
|
HashPageOpaque pageopaque;
|
||||||
bool do_expand = false;
|
bool do_expand = false;
|
||||||
Buffer ovflbuf;
|
Buffer ovflbuf;
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
Bucket bucket;
|
Bucket bucket;
|
||||||
|
|
||||||
metap = (HashMetaPage) BufferGetPage(metabuf);
|
metap = (HashMetaPage) BufferGetPage(metabuf);
|
||||||
_hash_checkpage((Page) metap, LH_META_PAGE);
|
_hash_checkpage((Page) metap, LH_META_PAGE);
|
||||||
@@ -218,7 +218,7 @@ _hash_insertonpg(Relation rel,
|
|||||||
* write lock and reference associated with the page's buffer. It is
|
* write lock and reference associated with the page's buffer. It is
|
||||||
* an error to call pgaddtup() without a write lock and reference.
|
* an error to call pgaddtup() without a write lock and reference.
|
||||||
*/
|
*/
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
_hash_pgaddtup(Relation rel,
|
_hash_pgaddtup(Relation rel,
|
||||||
Buffer buf,
|
Buffer buf,
|
||||||
int keysz,
|
int keysz,
|
||||||
@@ -226,8 +226,8 @@ _hash_pgaddtup(Relation rel,
|
|||||||
Size itemsize,
|
Size itemsize,
|
||||||
HashItem hitem)
|
HashItem hitem)
|
||||||
{
|
{
|
||||||
OffsetNumber itup_off;
|
OffsetNumber itup_off;
|
||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
_hash_checkpage(page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
_hash_checkpage(page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.10 1997/09/07 04:37:57 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.11 1997/09/08 02:20:17 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Overflow pages look like ordinary relation pages.
|
* Overflow pages look like ordinary relation pages.
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static OverflowPageAddress _hash_getovfladdr(Relation rel, Buffer * metabufp);
|
static OverflowPageAddress _hash_getovfladdr(Relation rel, Buffer * metabufp);
|
||||||
static uint32 _hash_firstfreebit(uint32 map);
|
static uint32 _hash_firstfreebit(uint32 map);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _hash_addovflpage
|
* _hash_addovflpage
|
||||||
@@ -44,13 +44,13 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf)
|
|||||||
{
|
{
|
||||||
|
|
||||||
OverflowPageAddress oaddr;
|
OverflowPageAddress oaddr;
|
||||||
BlockNumber ovflblkno;
|
BlockNumber ovflblkno;
|
||||||
Buffer ovflbuf;
|
Buffer ovflbuf;
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
HashPageOpaque ovflopaque;
|
HashPageOpaque ovflopaque;
|
||||||
HashPageOpaque pageopaque;
|
HashPageOpaque pageopaque;
|
||||||
Page page;
|
Page page;
|
||||||
Page ovflpage;
|
Page ovflpage;
|
||||||
|
|
||||||
/* this had better be the last page in a bucket chain */
|
/* this had better be the last page in a bucket chain */
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
@@ -99,24 +99,24 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf)
|
|||||||
* is exchanged for a read lock.
|
* is exchanged for a read lock.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static OverflowPageAddress
|
static OverflowPageAddress
|
||||||
_hash_getovfladdr(Relation rel, Buffer * metabufp)
|
_hash_getovfladdr(Relation rel, Buffer * metabufp)
|
||||||
{
|
{
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
Buffer mapbuf = 0;
|
Buffer mapbuf = 0;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
PageOffset offset;
|
PageOffset offset;
|
||||||
OverflowPageAddress oaddr;
|
OverflowPageAddress oaddr;
|
||||||
SplitNumber splitnum;
|
SplitNumber splitnum;
|
||||||
uint32 *freep = NULL;
|
uint32 *freep = NULL;
|
||||||
uint32 max_free;
|
uint32 max_free;
|
||||||
uint32 bit;
|
uint32 bit;
|
||||||
uint32 first_page;
|
uint32 first_page;
|
||||||
uint32 free_bit;
|
uint32 free_bit;
|
||||||
uint32 free_page;
|
uint32 free_page;
|
||||||
uint32 in_use_bits;
|
uint32 in_use_bits;
|
||||||
uint32 i,
|
uint32 i,
|
||||||
j;
|
j;
|
||||||
|
|
||||||
metap = (HashMetaPage) _hash_chgbufaccess(rel, metabufp, HASH_READ, HASH_WRITE);
|
metap = (HashMetaPage) _hash_chgbufaccess(rel, metabufp, HASH_READ, HASH_WRITE);
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ _hash_getovfladdr(Relation rel, Buffer * metabufp)
|
|||||||
first_page = metap->LAST_FREED >> (metap->BSHIFT + BYTE_TO_BIT);
|
first_page = metap->LAST_FREED >> (metap->BSHIFT + BYTE_TO_BIT);
|
||||||
for (i = first_page; i <= free_page; i++)
|
for (i = first_page; i <= free_page; i++)
|
||||||
{
|
{
|
||||||
Page mappage;
|
Page mappage;
|
||||||
|
|
||||||
blkno = metap->hashm_mapp[i];
|
blkno = metap->hashm_mapp[i];
|
||||||
mapbuf = _hash_getbuf(rel, blkno, HASH_WRITE);
|
mapbuf = _hash_getbuf(rel, blkno, HASH_WRITE);
|
||||||
@@ -279,11 +279,11 @@ found:
|
|||||||
* splitnumber.
|
* splitnumber.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static uint32
|
static uint32
|
||||||
_hash_firstfreebit(uint32 map)
|
_hash_firstfreebit(uint32 map)
|
||||||
{
|
{
|
||||||
uint32 i,
|
uint32 i,
|
||||||
mask;
|
mask;
|
||||||
|
|
||||||
mask = 0x1;
|
mask = 0x1;
|
||||||
for (i = 0; i < BITS_PER_MAP; i++)
|
for (i = 0; i < BITS_PER_MAP; i++)
|
||||||
@@ -306,22 +306,22 @@ _hash_firstfreebit(uint32 map)
|
|||||||
Buffer
|
Buffer
|
||||||
_hash_freeovflpage(Relation rel, Buffer ovflbuf)
|
_hash_freeovflpage(Relation rel, Buffer ovflbuf)
|
||||||
{
|
{
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Buffer mapbuf;
|
Buffer mapbuf;
|
||||||
BlockNumber prevblkno;
|
BlockNumber prevblkno;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
BlockNumber nextblkno;
|
BlockNumber nextblkno;
|
||||||
HashPageOpaque ovflopaque;
|
HashPageOpaque ovflopaque;
|
||||||
Page ovflpage;
|
Page ovflpage;
|
||||||
Page mappage;
|
Page mappage;
|
||||||
OverflowPageAddress addr;
|
OverflowPageAddress addr;
|
||||||
SplitNumber splitnum;
|
SplitNumber splitnum;
|
||||||
uint32 *freep;
|
uint32 *freep;
|
||||||
uint32 ovflpgno;
|
uint32 ovflpgno;
|
||||||
int32 bitmappage,
|
int32 bitmappage,
|
||||||
bitmapbit;
|
bitmapbit;
|
||||||
Bucket bucket;
|
Bucket bucket;
|
||||||
|
|
||||||
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE);
|
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE);
|
||||||
metap = (HashMetaPage) BufferGetPage(metabuf);
|
metap = (HashMetaPage) BufferGetPage(metabuf);
|
||||||
@@ -348,9 +348,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf)
|
|||||||
*/
|
*/
|
||||||
if (BlockNumberIsValid(prevblkno))
|
if (BlockNumberIsValid(prevblkno))
|
||||||
{
|
{
|
||||||
Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE);
|
Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE);
|
||||||
Page prevpage = BufferGetPage(prevbuf);
|
Page prevpage = BufferGetPage(prevbuf);
|
||||||
HashPageOpaque prevopaque =
|
HashPageOpaque prevopaque =
|
||||||
(HashPageOpaque) PageGetSpecialPointer(prevpage);
|
(HashPageOpaque) PageGetSpecialPointer(prevpage);
|
||||||
|
|
||||||
_hash_checkpage(prevpage, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
_hash_checkpage(prevpage, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
||||||
@@ -360,9 +360,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf)
|
|||||||
}
|
}
|
||||||
if (BlockNumberIsValid(nextblkno))
|
if (BlockNumberIsValid(nextblkno))
|
||||||
{
|
{
|
||||||
Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE);
|
Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE);
|
||||||
Page nextpage = BufferGetPage(nextbuf);
|
Page nextpage = BufferGetPage(nextbuf);
|
||||||
HashPageOpaque nextopaque =
|
HashPageOpaque nextopaque =
|
||||||
(HashPageOpaque) PageGetSpecialPointer(nextpage);
|
(HashPageOpaque) PageGetSpecialPointer(nextpage);
|
||||||
|
|
||||||
_hash_checkpage(nextpage, LH_OVERFLOW_PAGE);
|
_hash_checkpage(nextpage, LH_OVERFLOW_PAGE);
|
||||||
@@ -436,13 +436,13 @@ _hash_initbitmap(Relation rel,
|
|||||||
int32 nbits,
|
int32 nbits,
|
||||||
int32 ndx)
|
int32 ndx)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
Page pg;
|
Page pg;
|
||||||
HashPageOpaque op;
|
HashPageOpaque op;
|
||||||
uint32 *freep;
|
uint32 *freep;
|
||||||
int clearbytes,
|
int clearbytes,
|
||||||
clearints;
|
clearints;
|
||||||
|
|
||||||
blkno = OADDR_TO_BLKNO(pnum);
|
blkno = OADDR_TO_BLKNO(pnum);
|
||||||
buf = _hash_getbuf(rel, blkno, HASH_WRITE);
|
buf = _hash_getbuf(rel, blkno, HASH_WRITE);
|
||||||
@@ -496,18 +496,18 @@ _hash_squeezebucket(Relation rel,
|
|||||||
HashMetaPage metap,
|
HashMetaPage metap,
|
||||||
Bucket bucket)
|
Bucket bucket)
|
||||||
{
|
{
|
||||||
Buffer wbuf;
|
Buffer wbuf;
|
||||||
Buffer rbuf = 0;
|
Buffer rbuf = 0;
|
||||||
BlockNumber wblkno;
|
BlockNumber wblkno;
|
||||||
BlockNumber rblkno;
|
BlockNumber rblkno;
|
||||||
Page wpage;
|
Page wpage;
|
||||||
Page rpage;
|
Page rpage;
|
||||||
HashPageOpaque wopaque;
|
HashPageOpaque wopaque;
|
||||||
HashPageOpaque ropaque;
|
HashPageOpaque ropaque;
|
||||||
OffsetNumber woffnum;
|
OffsetNumber woffnum;
|
||||||
OffsetNumber roffnum;
|
OffsetNumber roffnum;
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
int itemsz;
|
int itemsz;
|
||||||
|
|
||||||
/* elog(DEBUG, "_hash_squeezebucket: squeezing bucket %d", bucket); */
|
/* elog(DEBUG, "_hash_squeezebucket: squeezing bucket %d", bucket); */
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.10 1997/09/07 04:38:00 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.11 1997/09/08 02:20:18 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Postgres hash pages look like ordinary relation pages. The opaque
|
* Postgres hash pages look like ordinary relation pages. The opaque
|
||||||
@@ -38,9 +38,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access);
|
static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access);
|
||||||
static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
||||||
static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket);
|
static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use high-concurrency locking on hash indices. There are two cases in
|
* We use high-concurrency locking on hash indices. There are two cases in
|
||||||
@@ -68,16 +68,16 @@ static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucke
|
|||||||
void
|
void
|
||||||
_hash_metapinit(Relation rel)
|
_hash_metapinit(Relation rel)
|
||||||
{
|
{
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
HashPageOpaque pageopaque;
|
HashPageOpaque pageopaque;
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page pg;
|
Page pg;
|
||||||
int nbuckets;
|
int nbuckets;
|
||||||
uint32 nelem; /* number elements */
|
uint32 nelem; /* number elements */
|
||||||
uint32 lg2nelem; /* _hash_log2(nelem) */
|
uint32 lg2nelem; /* _hash_log2(nelem) */
|
||||||
uint32 nblocks;
|
uint32 nblocks;
|
||||||
uint16 i;
|
uint16 i;
|
||||||
|
|
||||||
/* can't be sharing this with anyone, now... */
|
/* can't be sharing this with anyone, now... */
|
||||||
if (USELOCKING)
|
if (USELOCKING)
|
||||||
@@ -188,7 +188,7 @@ _hash_metapinit(Relation rel)
|
|||||||
Buffer
|
Buffer
|
||||||
_hash_getbuf(Relation rel, BlockNumber blkno, int access)
|
_hash_getbuf(Relation rel, BlockNumber blkno, int access)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
|
|
||||||
if (blkno == P_NEW)
|
if (blkno == P_NEW)
|
||||||
{
|
{
|
||||||
@@ -196,14 +196,14 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
|
|||||||
}
|
}
|
||||||
switch (access)
|
switch (access)
|
||||||
{
|
{
|
||||||
case HASH_WRITE:
|
case HASH_WRITE:
|
||||||
case HASH_READ:
|
case HASH_READ:
|
||||||
_hash_setpagelock(rel, blkno, access);
|
_hash_setpagelock(rel, blkno, access);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s",
|
elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s",
|
||||||
access, RelationGetRelationName(rel));
|
access, RelationGetRelationName(rel));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buf = ReadBuffer(rel, blkno);
|
buf = ReadBuffer(rel, blkno);
|
||||||
|
|
||||||
@@ -217,19 +217,19 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
|
|||||||
void
|
void
|
||||||
_hash_relbuf(Relation rel, Buffer buf, int access)
|
_hash_relbuf(Relation rel, Buffer buf, int access)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(buf);
|
blkno = BufferGetBlockNumber(buf);
|
||||||
|
|
||||||
switch (access)
|
switch (access)
|
||||||
{
|
{
|
||||||
case HASH_WRITE:
|
case HASH_WRITE:
|
||||||
case HASH_READ:
|
case HASH_READ:
|
||||||
_hash_unsetpagelock(rel, blkno, access);
|
_hash_unsetpagelock(rel, blkno, access);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s",
|
elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s",
|
||||||
access, blkno, RelationGetRelationName(rel));
|
access, blkno, RelationGetRelationName(rel));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseBuffer(buf);
|
ReleaseBuffer(buf);
|
||||||
@@ -245,7 +245,7 @@ _hash_relbuf(Relation rel, Buffer buf, int access)
|
|||||||
void
|
void
|
||||||
_hash_wrtbuf(Relation rel, Buffer buf)
|
_hash_wrtbuf(Relation rel, Buffer buf)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(buf);
|
blkno = BufferGetBlockNumber(buf);
|
||||||
WriteBuffer(buf);
|
WriteBuffer(buf);
|
||||||
@@ -262,7 +262,7 @@ _hash_wrtbuf(Relation rel, Buffer buf)
|
|||||||
void
|
void
|
||||||
_hash_wrtnorelbuf(Relation rel, Buffer buf)
|
_hash_wrtnorelbuf(Relation rel, Buffer buf)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(buf);
|
blkno = BufferGetBlockNumber(buf);
|
||||||
WriteNoReleaseBuffer(buf);
|
WriteNoReleaseBuffer(buf);
|
||||||
@@ -274,22 +274,22 @@ _hash_chgbufaccess(Relation rel,
|
|||||||
int from_access,
|
int from_access,
|
||||||
int to_access)
|
int to_access)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(*bufp);
|
blkno = BufferGetBlockNumber(*bufp);
|
||||||
|
|
||||||
switch (from_access)
|
switch (from_access)
|
||||||
{
|
{
|
||||||
case HASH_WRITE:
|
case HASH_WRITE:
|
||||||
_hash_wrtbuf(rel, *bufp);
|
_hash_wrtbuf(rel, *bufp);
|
||||||
break;
|
break;
|
||||||
case HASH_READ:
|
case HASH_READ:
|
||||||
_hash_relbuf(rel, *bufp, from_access);
|
_hash_relbuf(rel, *bufp, from_access);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s",
|
elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s",
|
||||||
from_access, blkno, RelationGetRelationName(rel));
|
from_access, blkno, RelationGetRelationName(rel));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*bufp = _hash_getbuf(rel, blkno, to_access);
|
*bufp = _hash_getbuf(rel, blkno, to_access);
|
||||||
return (BufferGetPage(*bufp));
|
return (BufferGetPage(*bufp));
|
||||||
@@ -328,16 +328,16 @@ _hash_setpagelock(Relation rel,
|
|||||||
|
|
||||||
switch (access)
|
switch (access)
|
||||||
{
|
{
|
||||||
case HASH_WRITE:
|
case HASH_WRITE:
|
||||||
RelationSetSingleWLockPage(rel, &iptr);
|
RelationSetSingleWLockPage(rel, &iptr);
|
||||||
break;
|
break;
|
||||||
case HASH_READ:
|
case HASH_READ:
|
||||||
RelationSetSingleRLockPage(rel, &iptr);
|
RelationSetSingleRLockPage(rel, &iptr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s",
|
elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s",
|
||||||
access, blkno, RelationGetRelationName(rel));
|
access, blkno, RelationGetRelationName(rel));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,16 +355,16 @@ _hash_unsetpagelock(Relation rel,
|
|||||||
|
|
||||||
switch (access)
|
switch (access)
|
||||||
{
|
{
|
||||||
case HASH_WRITE:
|
case HASH_WRITE:
|
||||||
RelationUnsetSingleWLockPage(rel, &iptr);
|
RelationUnsetSingleWLockPage(rel, &iptr);
|
||||||
break;
|
break;
|
||||||
case HASH_READ:
|
case HASH_READ:
|
||||||
RelationUnsetSingleRLockPage(rel, &iptr);
|
RelationUnsetSingleRLockPage(rel, &iptr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s",
|
elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s",
|
||||||
access, blkno, RelationGetRelationName(rel));
|
access, blkno, RelationGetRelationName(rel));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,13 +372,13 @@ _hash_unsetpagelock(Relation rel,
|
|||||||
void
|
void
|
||||||
_hash_pagedel(Relation rel, ItemPointer tid)
|
_hash_pagedel(Relation rel, ItemPointer tid)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Page page;
|
Page page;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
OffsetNumber offno;
|
OffsetNumber offno;
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
HashPageOpaque opaque;
|
HashPageOpaque opaque;
|
||||||
|
|
||||||
blkno = ItemPointerGetBlockNumber(tid);
|
blkno = ItemPointerGetBlockNumber(tid);
|
||||||
offno = ItemPointerGetOffsetNumber(tid);
|
offno = ItemPointerGetOffsetNumber(tid);
|
||||||
@@ -414,10 +414,10 @@ _hash_pagedel(Relation rel, ItemPointer tid)
|
|||||||
void
|
void
|
||||||
_hash_expandtable(Relation rel, Buffer metabuf)
|
_hash_expandtable(Relation rel, Buffer metabuf)
|
||||||
{
|
{
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
Bucket old_bucket;
|
Bucket old_bucket;
|
||||||
Bucket new_bucket;
|
Bucket new_bucket;
|
||||||
uint32 spare_ndx;
|
uint32 spare_ndx;
|
||||||
|
|
||||||
/* elog(DEBUG, "_hash_expandtable: expanding..."); */
|
/* elog(DEBUG, "_hash_expandtable: expanding..."); */
|
||||||
|
|
||||||
@@ -472,26 +472,26 @@ _hash_splitpage(Relation rel,
|
|||||||
Bucket obucket,
|
Bucket obucket,
|
||||||
Bucket nbucket)
|
Bucket nbucket)
|
||||||
{
|
{
|
||||||
Bucket bucket;
|
Bucket bucket;
|
||||||
Buffer obuf;
|
Buffer obuf;
|
||||||
Buffer nbuf;
|
Buffer nbuf;
|
||||||
Buffer ovflbuf;
|
Buffer ovflbuf;
|
||||||
BlockNumber oblkno;
|
BlockNumber oblkno;
|
||||||
BlockNumber nblkno;
|
BlockNumber nblkno;
|
||||||
bool null;
|
bool null;
|
||||||
Datum datum;
|
Datum datum;
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
HashPageOpaque oopaque;
|
HashPageOpaque oopaque;
|
||||||
HashPageOpaque nopaque;
|
HashPageOpaque nopaque;
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
int itemsz;
|
int itemsz;
|
||||||
OffsetNumber ooffnum;
|
OffsetNumber ooffnum;
|
||||||
OffsetNumber noffnum;
|
OffsetNumber noffnum;
|
||||||
OffsetNumber omaxoffnum;
|
OffsetNumber omaxoffnum;
|
||||||
Page opage;
|
Page opage;
|
||||||
Page npage;
|
Page npage;
|
||||||
TupleDesc itupdesc;
|
TupleDesc itupdesc;
|
||||||
|
|
||||||
/* elog(DEBUG, "_hash_splitpage: splitting %d into %d,%d",
|
/* elog(DEBUG, "_hash_splitpage: splitting %d into %d,%d",
|
||||||
obucket, obucket, nbucket);
|
obucket, obucket, nbucket);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.9 1997/09/07 04:38:01 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.10 1997/09/08 02:20:20 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Because we can be doing an index scan on a relation while we
|
* Because we can be doing an index scan on a relation while we
|
||||||
@@ -31,14 +31,14 @@
|
|||||||
|
|
||||||
#include <access/hash.h>
|
#include <access/hash.h>
|
||||||
|
|
||||||
static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||||
static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||||
|
|
||||||
typedef struct HashScanListData
|
typedef struct HashScanListData
|
||||||
{
|
{
|
||||||
IndexScanDesc hashsl_scan;
|
IndexScanDesc hashsl_scan;
|
||||||
struct HashScanListData *hashsl_next;
|
struct HashScanListData *hashsl_next;
|
||||||
} HashScanListData;
|
} HashScanListData;
|
||||||
|
|
||||||
typedef HashScanListData *HashScanList;
|
typedef HashScanListData *HashScanList;
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ static HashScanList HashScans = (HashScanList) NULL;
|
|||||||
void
|
void
|
||||||
_hash_regscan(IndexScanDesc scan)
|
_hash_regscan(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
HashScanList new_el;
|
HashScanList new_el;
|
||||||
|
|
||||||
new_el = (HashScanList) palloc(sizeof(HashScanListData));
|
new_el = (HashScanList) palloc(sizeof(HashScanListData));
|
||||||
new_el->hashsl_scan = scan;
|
new_el->hashsl_scan = scan;
|
||||||
@@ -64,8 +64,8 @@ _hash_regscan(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
_hash_dropscan(IndexScanDesc scan)
|
_hash_dropscan(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
HashScanList chk,
|
HashScanList chk,
|
||||||
last;
|
last;
|
||||||
|
|
||||||
last = (HashScanList) NULL;
|
last = (HashScanList) NULL;
|
||||||
for (chk = HashScans;
|
for (chk = HashScans;
|
||||||
@@ -89,8 +89,8 @@ _hash_dropscan(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
_hash_adjscans(Relation rel, ItemPointer tid)
|
_hash_adjscans(Relation rel, ItemPointer tid)
|
||||||
{
|
{
|
||||||
HashScanList l;
|
HashScanList l;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
|
|
||||||
relid = rel->rd_id;
|
relid = rel->rd_id;
|
||||||
for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next)
|
for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next)
|
||||||
@@ -104,10 +104,10 @@ _hash_adjscans(Relation rel, ItemPointer tid)
|
|||||||
static void
|
static void
|
||||||
_hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
|
_hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
|
||||||
{
|
{
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
if (!_hash_scantouched(scan, blkno, offno))
|
if (!_hash_scantouched(scan, blkno, offno))
|
||||||
return;
|
return;
|
||||||
@@ -144,12 +144,12 @@ _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
_hash_scantouched(IndexScanDesc scan,
|
_hash_scantouched(IndexScanDesc scan,
|
||||||
BlockNumber blkno,
|
BlockNumber blkno,
|
||||||
OffsetNumber offno)
|
OffsetNumber offno)
|
||||||
{
|
{
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
|
|
||||||
current = &(scan->currentItemData);
|
current = &(scan->currentItemData);
|
||||||
if (ItemPointerIsValid(current)
|
if (ItemPointerIsValid(current)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.11 1997/09/07 04:38:02 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.12 1997/09/08 02:20:20 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -34,9 +34,9 @@ _hash_search(Relation rel,
|
|||||||
Buffer * bufP,
|
Buffer * bufP,
|
||||||
HashMetaPage metap)
|
HashMetaPage metap)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
Datum keyDatum;
|
Datum keyDatum;
|
||||||
Bucket bucket;
|
Bucket bucket;
|
||||||
|
|
||||||
if (scankey == (ScanKey) NULL ||
|
if (scankey == (ScanKey) NULL ||
|
||||||
(keyDatum = scankey[0].sk_argument) == (Datum) NULL)
|
(keyDatum = scankey[0].sk_argument) == (Datum) NULL)
|
||||||
@@ -70,16 +70,16 @@ _hash_search(Relation rel,
|
|||||||
RetrieveIndexResult
|
RetrieveIndexResult
|
||||||
_hash_next(IndexScanDesc scan, ScanDirection dir)
|
_hash_next(IndexScanDesc scan, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Page page;
|
Page page;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
rel = scan->relation;
|
rel = scan->relation;
|
||||||
so = (HashScanOpaque) scan->opaque;
|
so = (HashScanOpaque) scan->opaque;
|
||||||
@@ -129,7 +129,7 @@ static void
|
|||||||
_hash_readnext(Relation rel,
|
_hash_readnext(Relation rel,
|
||||||
Buffer * bufp, Page * pagep, HashPageOpaque * opaquep)
|
Buffer * bufp, Page * pagep, HashPageOpaque * opaquep)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = (*opaquep)->hasho_nextblkno;
|
blkno = (*opaquep)->hasho_nextblkno;
|
||||||
_hash_relbuf(rel, *bufp, HASH_READ);
|
_hash_relbuf(rel, *bufp, HASH_READ);
|
||||||
@@ -148,7 +148,7 @@ static void
|
|||||||
_hash_readprev(Relation rel,
|
_hash_readprev(Relation rel,
|
||||||
Buffer * bufp, Page * pagep, HashPageOpaque * opaquep)
|
Buffer * bufp, Page * pagep, HashPageOpaque * opaquep)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = (*opaquep)->hasho_prevblkno;
|
blkno = (*opaquep)->hasho_prevblkno;
|
||||||
_hash_relbuf(rel, *bufp, HASH_READ);
|
_hash_relbuf(rel, *bufp, HASH_READ);
|
||||||
@@ -180,18 +180,18 @@ _hash_readprev(Relation rel,
|
|||||||
RetrieveIndexResult
|
RetrieveIndexResult
|
||||||
_hash_first(IndexScanDesc scan, ScanDirection dir)
|
_hash_first(IndexScanDesc scan, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Page page;
|
Page page;
|
||||||
HashPageOpaque opaque;
|
HashPageOpaque opaque;
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
|
|
||||||
rel = scan->relation;
|
rel = scan->relation;
|
||||||
so = (HashScanOpaque) scan->opaque;
|
so = (HashScanOpaque) scan->opaque;
|
||||||
@@ -286,20 +286,20 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
|
|||||||
bool
|
bool
|
||||||
_hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf)
|
_hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf)
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
HashScanOpaque so;
|
HashScanOpaque so;
|
||||||
int allbuckets;
|
int allbuckets;
|
||||||
HashMetaPage metap;
|
HashMetaPage metap;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
HashPageOpaque opaque;
|
HashPageOpaque opaque;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
Bucket bucket;
|
Bucket bucket;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
|
|
||||||
rel = scan->relation;
|
rel = scan->relation;
|
||||||
current = &(scan->currentItemData);
|
current = &(scan->currentItemData);
|
||||||
@@ -341,107 +341,107 @@ _hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf)
|
|||||||
|
|
||||||
switch (dir)
|
switch (dir)
|
||||||
{
|
{
|
||||||
case ForwardScanDirection:
|
case ForwardScanDirection:
|
||||||
if (offnum != InvalidOffsetNumber)
|
if (offnum != InvalidOffsetNumber)
|
||||||
{
|
{
|
||||||
offnum = OffsetNumberNext(offnum); /* move forward */
|
offnum = OffsetNumberNext(offnum); /* move forward */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
offnum = FirstOffsetNumber; /* new page */
|
offnum = FirstOffsetNumber; /* new page */
|
||||||
}
|
}
|
||||||
while (offnum > maxoff)
|
while (offnum > maxoff)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* either this page is empty (maxoff ==
|
* either this page is empty (maxoff ==
|
||||||
* InvalidOffsetNumber) or we ran off the end.
|
* InvalidOffsetNumber) or we ran off the end.
|
||||||
*/
|
*/
|
||||||
_hash_readnext(rel, &buf, &page, &opaque);
|
_hash_readnext(rel, &buf, &page, &opaque);
|
||||||
if (BufferIsInvalid(buf))
|
if (BufferIsInvalid(buf))
|
||||||
{ /* end of chain */
|
{ /* end of chain */
|
||||||
if (allbuckets && bucket < metap->hashm_maxbucket)
|
if (allbuckets && bucket < metap->hashm_maxbucket)
|
||||||
{
|
|
||||||
++bucket;
|
|
||||||
blkno = BUCKET_TO_BLKNO(bucket);
|
|
||||||
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
|
||||||
page = BufferGetPage(buf);
|
|
||||||
_hash_checkpage(page, LH_BUCKET_PAGE);
|
|
||||||
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
|
||||||
Assert(opaque->hasho_bucket == bucket);
|
|
||||||
while (PageIsEmpty(page) &&
|
|
||||||
BlockNumberIsValid(opaque->hasho_nextblkno))
|
|
||||||
{
|
{
|
||||||
_hash_readnext(rel, &buf, &page, &opaque);
|
++bucket;
|
||||||
|
blkno = BUCKET_TO_BLKNO(bucket);
|
||||||
|
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
||||||
|
page = BufferGetPage(buf);
|
||||||
|
_hash_checkpage(page, LH_BUCKET_PAGE);
|
||||||
|
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
||||||
|
Assert(opaque->hasho_bucket == bucket);
|
||||||
|
while (PageIsEmpty(page) &&
|
||||||
|
BlockNumberIsValid(opaque->hasho_nextblkno))
|
||||||
|
{
|
||||||
|
_hash_readnext(rel, &buf, &page, &opaque);
|
||||||
|
}
|
||||||
|
maxoff = PageGetMaxOffsetNumber(page);
|
||||||
|
offnum = FirstOffsetNumber;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
maxoff = offnum = InvalidOffsetNumber;
|
||||||
|
break; /* while */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* _hash_readnext never returns an empty page */
|
||||||
maxoff = PageGetMaxOffsetNumber(page);
|
maxoff = PageGetMaxOffsetNumber(page);
|
||||||
offnum = FirstOffsetNumber;
|
offnum = FirstOffsetNumber;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
break;
|
||||||
maxoff = offnum = InvalidOffsetNumber;
|
case BackwardScanDirection:
|
||||||
break; /* while */
|
if (offnum != InvalidOffsetNumber)
|
||||||
}
|
{
|
||||||
|
offnum = OffsetNumberPrev(offnum); /* move back */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* _hash_readnext never returns an empty page */
|
offnum = maxoff; /* new page */
|
||||||
maxoff = PageGetMaxOffsetNumber(page);
|
|
||||||
offnum = FirstOffsetNumber;
|
|
||||||
}
|
}
|
||||||
}
|
while (offnum < FirstOffsetNumber)
|
||||||
break;
|
{
|
||||||
case BackwardScanDirection:
|
|
||||||
if (offnum != InvalidOffsetNumber)
|
|
||||||
{
|
|
||||||
offnum = OffsetNumberPrev(offnum); /* move back */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offnum = maxoff;/* new page */
|
|
||||||
}
|
|
||||||
while (offnum < FirstOffsetNumber)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* either this page is empty (offnum ==
|
* either this page is empty (offnum ==
|
||||||
* InvalidOffsetNumber) or we ran off the end.
|
* InvalidOffsetNumber) or we ran off the end.
|
||||||
*/
|
*/
|
||||||
_hash_readprev(rel, &buf, &page, &opaque);
|
_hash_readprev(rel, &buf, &page, &opaque);
|
||||||
if (BufferIsInvalid(buf))
|
if (BufferIsInvalid(buf))
|
||||||
{ /* end of chain */
|
{ /* end of chain */
|
||||||
if (allbuckets && bucket > 0)
|
if (allbuckets && bucket > 0)
|
||||||
{
|
|
||||||
--bucket;
|
|
||||||
blkno = BUCKET_TO_BLKNO(bucket);
|
|
||||||
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
|
||||||
page = BufferGetPage(buf);
|
|
||||||
_hash_checkpage(page, LH_BUCKET_PAGE);
|
|
||||||
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
|
||||||
Assert(opaque->hasho_bucket == bucket);
|
|
||||||
while (BlockNumberIsValid(opaque->hasho_nextblkno))
|
|
||||||
{
|
{
|
||||||
_hash_readnext(rel, &buf, &page, &opaque);
|
--bucket;
|
||||||
|
blkno = BUCKET_TO_BLKNO(bucket);
|
||||||
|
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
||||||
|
page = BufferGetPage(buf);
|
||||||
|
_hash_checkpage(page, LH_BUCKET_PAGE);
|
||||||
|
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
||||||
|
Assert(opaque->hasho_bucket == bucket);
|
||||||
|
while (BlockNumberIsValid(opaque->hasho_nextblkno))
|
||||||
|
{
|
||||||
|
_hash_readnext(rel, &buf, &page, &opaque);
|
||||||
|
}
|
||||||
|
maxoff = offnum = PageGetMaxOffsetNumber(page);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
maxoff = offnum = InvalidOffsetNumber;
|
||||||
|
break; /* while */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* _hash_readprev never returns an empty page */
|
||||||
maxoff = offnum = PageGetMaxOffsetNumber(page);
|
maxoff = offnum = PageGetMaxOffsetNumber(page);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
maxoff = offnum = InvalidOffsetNumber;
|
|
||||||
break; /* while */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
{
|
default:
|
||||||
/* _hash_readprev never returns an empty page */
|
/* NoMovementScanDirection */
|
||||||
maxoff = offnum = PageGetMaxOffsetNumber(page);
|
/* this should not be reached */
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* NoMovementScanDirection */
|
|
||||||
/* this should not be reached */
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we ran off the end of the world without finding a match */
|
/* we ran off the end of the world without finding a match */
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.10 1997/09/07 04:38:03 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.11 1997/09/08 02:20:21 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -52,12 +52,12 @@ static StrategyEvaluationData HTEvaluationData = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
static StrategyNumber
|
static StrategyNumber
|
||||||
_hash_getstrat(Relation rel,
|
_hash_getstrat(Relation rel,
|
||||||
AttrNumber attno,
|
AttrNumber attno,
|
||||||
RegProcedure proc)
|
RegProcedure proc)
|
||||||
{
|
{
|
||||||
StrategyNumber strat;
|
StrategyNumber strat;
|
||||||
|
|
||||||
strat = RelationGetStrategy(rel, attno, &HTEvaluationData, proc);
|
strat = RelationGetStrategy(rel, attno, &HTEvaluationData, proc);
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ _hash_getstrat(Relation rel,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
static bool
|
static bool
|
||||||
_hash_invokestrat(Relation rel,
|
_hash_invokestrat(Relation rel,
|
||||||
AttrNumber attno,
|
AttrNumber attno,
|
||||||
StrategyNumber strat,
|
StrategyNumber strat,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.10 1997/09/07 04:38:04 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.11 1997/09/08 02:20:25 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -28,13 +28,13 @@
|
|||||||
ScanKey
|
ScanKey
|
||||||
_hash_mkscankey(Relation rel, IndexTuple itup, HashMetaPage metap)
|
_hash_mkscankey(Relation rel, IndexTuple itup, HashMetaPage metap)
|
||||||
{
|
{
|
||||||
ScanKey skey;
|
ScanKey skey;
|
||||||
TupleDesc itupdesc;
|
TupleDesc itupdesc;
|
||||||
int natts;
|
int natts;
|
||||||
AttrNumber i;
|
AttrNumber i;
|
||||||
Datum arg;
|
Datum arg;
|
||||||
RegProcedure proc;
|
RegProcedure proc;
|
||||||
bool null;
|
bool null;
|
||||||
|
|
||||||
natts = rel->rd_rel->relnatts;
|
natts = rel->rd_rel->relnatts;
|
||||||
itupdesc = RelationGetTupleDescriptor(rel);
|
itupdesc = RelationGetTupleDescriptor(rel);
|
||||||
@@ -73,9 +73,9 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
|
|||||||
HashItem
|
HashItem
|
||||||
_hash_formitem(IndexTuple itup)
|
_hash_formitem(IndexTuple itup)
|
||||||
{
|
{
|
||||||
int nbytes_hitem;
|
int nbytes_hitem;
|
||||||
HashItem hitem;
|
HashItem hitem;
|
||||||
Size tuplen;
|
Size tuplen;
|
||||||
|
|
||||||
/* disallow nulls in hash keys */
|
/* disallow nulls in hash keys */
|
||||||
if (itup->t_info & INDEX_NULL_MASK)
|
if (itup->t_info & INDEX_NULL_MASK)
|
||||||
@@ -95,9 +95,9 @@ _hash_formitem(IndexTuple itup)
|
|||||||
Bucket
|
Bucket
|
||||||
_hash_call(Relation rel, HashMetaPage metap, Datum key)
|
_hash_call(Relation rel, HashMetaPage metap, Datum key)
|
||||||
{
|
{
|
||||||
uint32 n;
|
uint32 n;
|
||||||
Bucket bucket;
|
Bucket bucket;
|
||||||
RegProcedure proc;
|
RegProcedure proc;
|
||||||
|
|
||||||
proc = metap->hashm_procid;
|
proc = metap->hashm_procid;
|
||||||
n = (uint32) fmgr(proc, key);
|
n = (uint32) fmgr(proc, key);
|
||||||
@@ -113,8 +113,8 @@ _hash_call(Relation rel, HashMetaPage metap, Datum key)
|
|||||||
uint32
|
uint32
|
||||||
_hash_log2(uint32 num)
|
_hash_log2(uint32 num)
|
||||||
{
|
{
|
||||||
uint32 i,
|
uint32 i,
|
||||||
limit;
|
limit;
|
||||||
|
|
||||||
limit = 1;
|
limit = 1;
|
||||||
for (i = 0; limit < num; limit = limit << 1, i++)
|
for (i = 0; limit < num; limit = limit << 1, i++)
|
||||||
@@ -128,7 +128,7 @@ _hash_log2(uint32 num)
|
|||||||
void
|
void
|
||||||
_hash_checkpage(Page page, int flags)
|
_hash_checkpage(Page page, int flags)
|
||||||
{
|
{
|
||||||
HashPageOpaque opaque;
|
HashPageOpaque opaque;
|
||||||
|
|
||||||
Assert(page);
|
Assert(page);
|
||||||
Assert(((PageHeader) (page))->pd_lower >= (sizeof(PageHeaderData) - sizeof(ItemIdData)));
|
Assert(((PageHeader) (page))->pd_lower >= (sizeof(PageHeaderData) - sizeof(ItemIdData)));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.16 1997/09/07 04:38:09 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.17 1997/09/08 02:20:28 momjian Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool ImmediateInvalidation;
|
static bool ImmediateInvalidation;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* heap support routines
|
* heap support routines
|
||||||
@@ -210,7 +210,7 @@ nextpage(int page, int dir)
|
|||||||
* real work in scanning tuples.
|
* real work in scanning tuples.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static HeapTuple
|
static HeapTuple
|
||||||
heapgettup(Relation relation,
|
heapgettup(Relation relation,
|
||||||
ItemPointer tid,
|
ItemPointer tid,
|
||||||
int dir,
|
int dir,
|
||||||
@@ -219,14 +219,14 @@ heapgettup(Relation relation,
|
|||||||
int nkeys,
|
int nkeys,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
ItemId lpp;
|
ItemId lpp;
|
||||||
Page dp;
|
Page dp;
|
||||||
int page;
|
int page;
|
||||||
int pages;
|
int pages;
|
||||||
int lines;
|
int lines;
|
||||||
HeapTuple rtup;
|
HeapTuple rtup;
|
||||||
OffsetNumber lineoff;
|
OffsetNumber lineoff;
|
||||||
int linesleft;
|
int linesleft;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -432,7 +432,7 @@ heapgettup(Relation relation,
|
|||||||
if ((rtup = heap_tuple_satisfies(lpp, relation, *b, (PageHeader) dp,
|
if ((rtup = heap_tuple_satisfies(lpp, relation, *b, (PageHeader) dp,
|
||||||
timeQual, nkeys, key)) != NULL)
|
timeQual, nkeys, key)) != NULL)
|
||||||
{
|
{
|
||||||
ItemPointer iptr = &(rtup->t_ctid);
|
ItemPointer iptr = &(rtup->t_ctid);
|
||||||
|
|
||||||
if (ItemPointerGetBlockNumber(iptr) != page)
|
if (ItemPointerGetBlockNumber(iptr) != page)
|
||||||
{
|
{
|
||||||
@@ -541,7 +541,7 @@ SetHeapAccessMethodImmediateInvalidation(bool on)
|
|||||||
Relation
|
Relation
|
||||||
heap_open(Oid relationId)
|
heap_open(Oid relationId)
|
||||||
{
|
{
|
||||||
Relation r;
|
Relation r;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -570,7 +570,7 @@ heap_open(Oid relationId)
|
|||||||
Relation
|
Relation
|
||||||
heap_openr(char *relationName)
|
heap_openr(char *relationName)
|
||||||
{
|
{
|
||||||
Relation r;
|
Relation r;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -621,7 +621,7 @@ heap_beginscan(Relation relation,
|
|||||||
unsigned nkeys,
|
unsigned nkeys,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
HeapScanDesc sdesc;
|
HeapScanDesc sdesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -808,7 +808,7 @@ heap_getnext(HeapScanDesc scandesc,
|
|||||||
Buffer * b)
|
Buffer * b)
|
||||||
{
|
{
|
||||||
register HeapScanDesc sdesc = scandesc;
|
register HeapScanDesc sdesc = scandesc;
|
||||||
Buffer localb;
|
Buffer localb;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -880,7 +880,7 @@ heap_getnext(HeapScanDesc scandesc,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* NONTUP */
|
{ /* NONTUP */
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
|
|
||||||
iptr = (sdesc->rs_ctup != NULL) ?
|
iptr = (sdesc->rs_ctup != NULL) ?
|
||||||
&(sdesc->rs_ctup->t_ctid) : (ItemPointer) NULL;
|
&(sdesc->rs_ctup->t_ctid) : (ItemPointer) NULL;
|
||||||
@@ -967,7 +967,7 @@ heap_getnext(HeapScanDesc scandesc,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* NONTUP */
|
{ /* NONTUP */
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
|
|
||||||
iptr = (sdesc->rs_ctup != NULL) ?
|
iptr = (sdesc->rs_ctup != NULL) ?
|
||||||
&sdesc->rs_ctup->t_ctid : (ItemPointer) NULL;
|
&sdesc->rs_ctup->t_ctid : (ItemPointer) NULL;
|
||||||
@@ -1035,11 +1035,11 @@ heap_fetch(Relation relation,
|
|||||||
ItemPointer tid,
|
ItemPointer tid,
|
||||||
Buffer * b)
|
Buffer * b)
|
||||||
{
|
{
|
||||||
ItemId lp;
|
ItemId lp;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
PageHeader dp;
|
PageHeader dp;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -1203,10 +1203,10 @@ heap_insert(Relation relation, HeapTuple tup)
|
|||||||
int
|
int
|
||||||
heap_delete(Relation relation, ItemPointer tid)
|
heap_delete(Relation relation, ItemPointer tid)
|
||||||
{
|
{
|
||||||
ItemId lp;
|
ItemId lp;
|
||||||
HeapTuple tp;
|
HeapTuple tp;
|
||||||
PageHeader dp;
|
PageHeader dp;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -1313,10 +1313,10 @@ heap_delete(Relation relation, ItemPointer tid)
|
|||||||
int
|
int
|
||||||
heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
|
heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
|
||||||
{
|
{
|
||||||
ItemId lp;
|
ItemId lp;
|
||||||
HeapTuple tp;
|
HeapTuple tp;
|
||||||
Page dp;
|
Page dp;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Id: hio.c,v 1.10 1997/09/07 04:38:11 momjian Exp $
|
* $Id: hio.c,v 1.11 1997/09/08 02:20:30 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -35,13 +35,13 @@ RelationPutHeapTuple(Relation relation,
|
|||||||
BlockNumber blockIndex,
|
BlockNumber blockIndex,
|
||||||
HeapTuple tuple)
|
HeapTuple tuple)
|
||||||
{
|
{
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
Page pageHeader;
|
Page pageHeader;
|
||||||
BlockNumber numberOfBlocks;
|
BlockNumber numberOfBlocks;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
ItemId itemId;
|
ItemId itemId;
|
||||||
Item item;
|
Item item;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* increment access statistics
|
* increment access statistics
|
||||||
@@ -108,13 +108,13 @@ RelationPutHeapTuple(Relation relation,
|
|||||||
void
|
void
|
||||||
RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
|
RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
|
||||||
{
|
{
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
Page pageHeader;
|
Page pageHeader;
|
||||||
BlockNumber lastblock;
|
BlockNumber lastblock;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
ItemId itemId;
|
ItemId itemId;
|
||||||
Item item;
|
Item item;
|
||||||
|
|
||||||
Assert(RelationIsValid(relation));
|
Assert(RelationIsValid(relation));
|
||||||
Assert(HeapTupleIsValid(tuple));
|
Assert(HeapTupleIsValid(tuple));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.12 1997/09/07 04:38:13 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.13 1997/09/08 02:20:31 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* initam should be moved someplace else.
|
* initam should be moved someplace else.
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void InitHeapAccessStatistics(void);
|
static void InitHeapAccessStatistics(void);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* InitHeapAccessStatistics
|
* InitHeapAccessStatistics
|
||||||
@@ -39,7 +39,7 @@ HeapAccessStatistics heap_access_stats = (HeapAccessStatistics) NULL;
|
|||||||
static void
|
static void
|
||||||
InitHeapAccessStatistics()
|
InitHeapAccessStatistics()
|
||||||
{
|
{
|
||||||
MemoryContext oldContext;
|
MemoryContext oldContext;
|
||||||
HeapAccessStatistics stats;
|
HeapAccessStatistics stats;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.8 1997/09/07 04:38:17 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.9 1997/09/08 02:20:33 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* many of the old access method routines have been turned into
|
* many of the old access method routines have been turned into
|
||||||
@@ -98,7 +98,7 @@ RelationGetIndexScan(Relation relation,
|
|||||||
uint16 numberOfKeys,
|
uint16 numberOfKeys,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
IndexScanDesc scan;
|
IndexScanDesc scan;
|
||||||
|
|
||||||
if (!RelationIsValid(relation))
|
if (!RelationIsValid(relation))
|
||||||
elog(WARN, "RelationGetIndexScan: relation invalid");
|
elog(WARN, "RelationGetIndexScan: relation invalid");
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.14 1997/09/07 04:38:26 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.15 1997/09/08 02:20:37 momjian Exp $
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
* index_open - open an index relation by relationId
|
* index_open - open an index relation by relationId
|
||||||
@@ -167,7 +167,7 @@ index_insert(Relation relation,
|
|||||||
ItemPointer heap_t_ctid,
|
ItemPointer heap_t_ctid,
|
||||||
Relation heapRel)
|
Relation heapRel)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
InsertIndexResult specificResult;
|
InsertIndexResult specificResult;
|
||||||
|
|
||||||
RELATION_CHECKS;
|
RELATION_CHECKS;
|
||||||
@@ -207,7 +207,7 @@ index_insert(Relation relation,
|
|||||||
void
|
void
|
||||||
index_delete(Relation relation, ItemPointer indexItem)
|
index_delete(Relation relation, ItemPointer indexItem)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
|
|
||||||
RELATION_CHECKS;
|
RELATION_CHECKS;
|
||||||
GET_REL_PROCEDURE(delete, amdelete);
|
GET_REL_PROCEDURE(delete, amdelete);
|
||||||
@@ -225,8 +225,8 @@ index_beginscan(Relation relation,
|
|||||||
uint16 numberOfKeys,
|
uint16 numberOfKeys,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
IndexScanDesc scandesc;
|
IndexScanDesc scandesc;
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
|
|
||||||
RELATION_CHECKS;
|
RELATION_CHECKS;
|
||||||
GET_REL_PROCEDURE(beginscan, ambeginscan);
|
GET_REL_PROCEDURE(beginscan, ambeginscan);
|
||||||
@@ -246,7 +246,7 @@ index_beginscan(Relation relation,
|
|||||||
void
|
void
|
||||||
index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
|
index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
|
|
||||||
SCAN_CHECKS;
|
SCAN_CHECKS;
|
||||||
GET_SCAN_PROCEDURE(rescan, amrescan);
|
GET_SCAN_PROCEDURE(rescan, amrescan);
|
||||||
@@ -261,7 +261,7 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
|
|||||||
void
|
void
|
||||||
index_endscan(IndexScanDesc scan)
|
index_endscan(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
|
|
||||||
SCAN_CHECKS;
|
SCAN_CHECKS;
|
||||||
GET_SCAN_PROCEDURE(endscan, amendscan);
|
GET_SCAN_PROCEDURE(endscan, amendscan);
|
||||||
@@ -279,7 +279,7 @@ index_endscan(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
index_markpos(IndexScanDesc scan)
|
index_markpos(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
|
|
||||||
SCAN_CHECKS;
|
SCAN_CHECKS;
|
||||||
GET_SCAN_PROCEDURE(markpos, ammarkpos);
|
GET_SCAN_PROCEDURE(markpos, ammarkpos);
|
||||||
@@ -297,7 +297,7 @@ index_markpos(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
index_restrpos(IndexScanDesc scan)
|
index_restrpos(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
|
|
||||||
SCAN_CHECKS;
|
SCAN_CHECKS;
|
||||||
GET_SCAN_PROCEDURE(restrpos, amrestrpos);
|
GET_SCAN_PROCEDURE(restrpos, amrestrpos);
|
||||||
@@ -317,7 +317,7 @@ RetrieveIndexResult
|
|||||||
index_getnext(IndexScanDesc scan,
|
index_getnext(IndexScanDesc scan,
|
||||||
ScanDirection direction)
|
ScanDirection direction)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
RetrieveIndexResult result;
|
RetrieveIndexResult result;
|
||||||
|
|
||||||
SCAN_CHECKS;
|
SCAN_CHECKS;
|
||||||
@@ -354,8 +354,8 @@ index_getprocid(Relation irel,
|
|||||||
AttrNumber attnum,
|
AttrNumber attnum,
|
||||||
uint16 procnum)
|
uint16 procnum)
|
||||||
{
|
{
|
||||||
RegProcedure *loc;
|
RegProcedure *loc;
|
||||||
int natts;
|
int natts;
|
||||||
|
|
||||||
natts = irel->rd_rel->relnatts;
|
natts = irel->rd_rel->relnatts;
|
||||||
|
|
||||||
@@ -375,13 +375,13 @@ GetIndexValue(HeapTuple tuple,
|
|||||||
bool * attNull,
|
bool * attNull,
|
||||||
Buffer buffer)
|
Buffer buffer)
|
||||||
{
|
{
|
||||||
Datum returnVal;
|
Datum returnVal;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
||||||
if (PointerIsValid(fInfo) && FIgetProcOid(fInfo) != InvalidOid)
|
if (PointerIsValid(fInfo) && FIgetProcOid(fInfo) != InvalidOid)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Datum *attData = (Datum *) palloc(FIgetnArgs(fInfo) * sizeof(Datum));
|
Datum *attData = (Datum *) palloc(FIgetnArgs(fInfo) * sizeof(Datum));
|
||||||
|
|
||||||
for (i = 0; i < FIgetnArgs(fInfo); i++)
|
for (i = 0; i < FIgetnArgs(fInfo); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.10 1997/09/07 04:38:32 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.11 1997/09/08 02:20:41 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <fmgr.h>
|
#include <fmgr.h>
|
||||||
|
|
||||||
#ifndef NO_ASSERT_CHECKING
|
#ifndef NO_ASSERT_CHECKING
|
||||||
static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation);
|
static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation);
|
||||||
static bool
|
static bool
|
||||||
StrategyExpressionIsValid(StrategyExpression expression,
|
StrategyExpressionIsValid(StrategyExpression expression,
|
||||||
StrategyNumber maxStrategy);
|
StrategyNumber maxStrategy);
|
||||||
@@ -68,7 +68,7 @@ StrategyTermIsValid(StrategyTerm term,
|
|||||||
* Assumes that the index strategy number is valid.
|
* Assumes that the index strategy number is valid.
|
||||||
* Bounds checking should be done outside this routine.
|
* Bounds checking should be done outside this routine.
|
||||||
*/
|
*/
|
||||||
static ScanKey
|
static ScanKey
|
||||||
StrategyMapGetScanKeyEntry(StrategyMap map,
|
StrategyMapGetScanKeyEntry(StrategyMap map,
|
||||||
StrategyNumber strategyNumber)
|
StrategyNumber strategyNumber)
|
||||||
{
|
{
|
||||||
@@ -122,7 +122,7 @@ AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber,
|
|||||||
* StrategyOperatorIsValid
|
* StrategyOperatorIsValid
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
StrategyOperatorIsValid(StrategyOperator operator,
|
StrategyOperatorIsValid(StrategyOperator operator,
|
||||||
StrategyNumber maxStrategy)
|
StrategyNumber maxStrategy)
|
||||||
{
|
{
|
||||||
@@ -136,11 +136,11 @@ StrategyOperatorIsValid(StrategyOperator operator,
|
|||||||
* StrategyTermIsValid
|
* StrategyTermIsValid
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
StrategyTermIsValid(StrategyTerm term,
|
StrategyTermIsValid(StrategyTerm term,
|
||||||
StrategyNumber maxStrategy)
|
StrategyNumber maxStrategy)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
|
|
||||||
if (!PointerIsValid(term) || term->degree == 0)
|
if (!PointerIsValid(term) || term->degree == 0)
|
||||||
return false;
|
return false;
|
||||||
@@ -162,11 +162,11 @@ StrategyTermIsValid(StrategyTerm term,
|
|||||||
* StrategyExpressionIsValid
|
* StrategyExpressionIsValid
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
StrategyExpressionIsValid(StrategyExpression expression,
|
StrategyExpressionIsValid(StrategyExpression expression,
|
||||||
StrategyNumber maxStrategy)
|
StrategyNumber maxStrategy)
|
||||||
{
|
{
|
||||||
StrategyTerm *termP;
|
StrategyTerm *termP;
|
||||||
|
|
||||||
if (!PointerIsValid(expression))
|
if (!PointerIsValid(expression))
|
||||||
return true;
|
return true;
|
||||||
@@ -186,10 +186,10 @@ StrategyExpressionIsValid(StrategyExpression expression,
|
|||||||
* StrategyEvaluationIsValid
|
* StrategyEvaluationIsValid
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
StrategyEvaluationIsValid(StrategyEvaluation evaluation)
|
StrategyEvaluationIsValid(StrategyEvaluation evaluation)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
|
|
||||||
if (!PointerIsValid(evaluation) ||
|
if (!PointerIsValid(evaluation) ||
|
||||||
!StrategyNumberIsValid(evaluation->maxStrategy) ||
|
!StrategyNumberIsValid(evaluation->maxStrategy) ||
|
||||||
@@ -219,17 +219,17 @@ StrategyEvaluationIsValid(StrategyEvaluation evaluation)
|
|||||||
* StrategyTermEvaluate
|
* StrategyTermEvaluate
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
StrategyTermEvaluate(StrategyTerm term,
|
StrategyTermEvaluate(StrategyTerm term,
|
||||||
StrategyMap map,
|
StrategyMap map,
|
||||||
Datum left,
|
Datum left,
|
||||||
Datum right)
|
Datum right)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
long tmpres = 0;
|
long tmpres = 0;
|
||||||
bool result = 0;
|
bool result = 0;
|
||||||
StrategyOperator operator;
|
StrategyOperator operator;
|
||||||
ScanKey entry;
|
ScanKey entry;
|
||||||
|
|
||||||
for (index = 0, operator = &term->operatorData[0];
|
for (index = 0, operator = &term->operatorData[0];
|
||||||
index < term->degree; index += 1, operator += 1)
|
index < term->degree; index += 1, operator += 1)
|
||||||
@@ -241,29 +241,29 @@ StrategyTermEvaluate(StrategyTerm term,
|
|||||||
|
|
||||||
switch (operator->flags ^ entry->sk_flags)
|
switch (operator->flags ^ entry->sk_flags)
|
||||||
{
|
{
|
||||||
case 0x0:
|
case 0x0:
|
||||||
tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
||||||
left, right);
|
left, right);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SK_NEGATE:
|
case SK_NEGATE:
|
||||||
tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
||||||
left, right);
|
left, right);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SK_COMMUTE:
|
case SK_COMMUTE:
|
||||||
tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
||||||
right, left);
|
right, left);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SK_NEGATE | SK_COMMUTE:
|
case SK_NEGATE | SK_COMMUTE:
|
||||||
tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure,
|
||||||
right, left);
|
right, left);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(FATAL, "StrategyTermEvaluate: impossible case %d",
|
elog(FATAL, "StrategyTermEvaluate: impossible case %d",
|
||||||
operator->flags ^ entry->sk_flags);
|
operator->flags ^ entry->sk_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (bool) tmpres;
|
result = (bool) tmpres;
|
||||||
@@ -285,11 +285,11 @@ RelationGetStrategy(Relation relation,
|
|||||||
StrategyEvaluation evaluation,
|
StrategyEvaluation evaluation,
|
||||||
RegProcedure procedure)
|
RegProcedure procedure)
|
||||||
{
|
{
|
||||||
StrategyNumber strategy;
|
StrategyNumber strategy;
|
||||||
StrategyMap strategyMap;
|
StrategyMap strategyMap;
|
||||||
ScanKey entry;
|
ScanKey entry;
|
||||||
Index index;
|
Index index;
|
||||||
int numattrs;
|
int numattrs;
|
||||||
|
|
||||||
Assert(RelationIsValid(relation));
|
Assert(RelationIsValid(relation));
|
||||||
numattrs = RelationGetNumberOfAttributes(relation);
|
numattrs = RelationGetNumberOfAttributes(relation);
|
||||||
@@ -325,23 +325,23 @@ RelationGetStrategy(Relation relation,
|
|||||||
|
|
||||||
switch (entry->sk_flags & (SK_NEGATE | SK_COMMUTE))
|
switch (entry->sk_flags & (SK_NEGATE | SK_COMMUTE))
|
||||||
{
|
{
|
||||||
case 0x0:
|
case 0x0:
|
||||||
return strategy;
|
return strategy;
|
||||||
|
|
||||||
case SK_NEGATE:
|
case SK_NEGATE:
|
||||||
strategy = evaluation->negateTransform->strategy[strategy - 1];
|
strategy = evaluation->negateTransform->strategy[strategy - 1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SK_COMMUTE:
|
case SK_COMMUTE:
|
||||||
strategy = evaluation->commuteTransform->strategy[strategy - 1];
|
strategy = evaluation->commuteTransform->strategy[strategy - 1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SK_NEGATE | SK_COMMUTE:
|
case SK_NEGATE | SK_COMMUTE:
|
||||||
strategy = evaluation->negateCommuteTransform->strategy[strategy - 1];
|
strategy = evaluation->negateCommuteTransform->strategy[strategy - 1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(FATAL, "RelationGetStrategy: impossible case %d", entry->sk_flags);
|
elog(FATAL, "RelationGetStrategy: impossible case %d", entry->sk_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -368,11 +368,11 @@ RelationInvokeStrategy(Relation relation,
|
|||||||
Datum left,
|
Datum left,
|
||||||
Datum right)
|
Datum right)
|
||||||
{
|
{
|
||||||
StrategyNumber newStrategy;
|
StrategyNumber newStrategy;
|
||||||
StrategyMap strategyMap;
|
StrategyMap strategyMap;
|
||||||
ScanKey entry;
|
ScanKey entry;
|
||||||
StrategyTermData termData;
|
StrategyTermData termData;
|
||||||
int numattrs;
|
int numattrs;
|
||||||
|
|
||||||
Assert(RelationIsValid(relation));
|
Assert(RelationIsValid(relation));
|
||||||
Assert(relation->rd_rel->relkind == RELKIND_INDEX); /* XXX use accessor */
|
Assert(relation->rd_rel->relkind == RELKIND_INDEX); /* XXX use accessor */
|
||||||
@@ -453,12 +453,12 @@ RelationInvokeStrategy(Relation relation,
|
|||||||
|
|
||||||
if (PointerIsValid(evaluation->expression[strategy - 1]))
|
if (PointerIsValid(evaluation->expression[strategy - 1]))
|
||||||
{
|
{
|
||||||
StrategyTerm *termP;
|
StrategyTerm *termP;
|
||||||
|
|
||||||
termP = &evaluation->expression[strategy - 1]->term[0];
|
termP = &evaluation->expression[strategy - 1]->term[0];
|
||||||
while (PointerIsValid(*termP))
|
while (PointerIsValid(*termP))
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
|
|
||||||
for (index = 0; index < (*termP)->degree; index += 1)
|
for (index = 0; index < (*termP)->degree; index += 1)
|
||||||
{
|
{
|
||||||
@@ -499,9 +499,9 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
|
|||||||
Oid operatorObjectId,
|
Oid operatorObjectId,
|
||||||
ScanKey entry)
|
ScanKey entry)
|
||||||
{
|
{
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
ScanKeyData scanKeyData;
|
ScanKeyData scanKeyData;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&scanKeyData, 0,
|
ScanKeyEntryInitialize(&scanKeyData, 0,
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
@@ -547,15 +547,15 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
|
|||||||
StrategyNumber maxSupportNumber,
|
StrategyNumber maxSupportNumber,
|
||||||
AttrNumber maxAttributeNumber)
|
AttrNumber maxAttributeNumber)
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
Relation operatorRelation;
|
Relation operatorRelation;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
ScanKeyData entry[2];
|
ScanKeyData entry[2];
|
||||||
StrategyMap map;
|
StrategyMap map;
|
||||||
AttrNumber attributeNumber;
|
AttrNumber attributeNumber;
|
||||||
int attributeIndex;
|
int attributeIndex;
|
||||||
Oid operatorClassObjectId[MaxIndexAttributeNumber];
|
Oid operatorClassObjectId[MaxIndexAttributeNumber];
|
||||||
|
|
||||||
maxStrategyNumber = AMStrategies(maxStrategyNumber);
|
maxStrategyNumber = AMStrategies(maxStrategyNumber);
|
||||||
|
|
||||||
@@ -575,7 +575,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
|
|||||||
*/
|
*/
|
||||||
for (attributeIndex = 0; attributeIndex < maxAttributeNumber; attributeIndex++)
|
for (attributeIndex = 0; attributeIndex < maxAttributeNumber; attributeIndex++)
|
||||||
{
|
{
|
||||||
IndexTupleForm iform;
|
IndexTupleForm iform;
|
||||||
|
|
||||||
iform = (IndexTupleForm) GETSTRUCT(tuple);
|
iform = (IndexTupleForm) GETSTRUCT(tuple);
|
||||||
|
|
||||||
@@ -614,9 +614,9 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
|
|||||||
attributeNumber--)
|
attributeNumber--)
|
||||||
{
|
{
|
||||||
|
|
||||||
int16 support;
|
int16 support;
|
||||||
Form_pg_amproc form;
|
Form_pg_amproc form;
|
||||||
RegProcedure *loc;
|
RegProcedure *loc;
|
||||||
|
|
||||||
loc = &indexSupport[((attributeNumber - 1) * maxSupportNumber)];
|
loc = &indexSupport[((attributeNumber - 1) * maxSupportNumber)];
|
||||||
|
|
||||||
@@ -659,7 +659,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
|
|||||||
attributeNumber--)
|
attributeNumber--)
|
||||||
{
|
{
|
||||||
|
|
||||||
StrategyNumber strategy;
|
StrategyNumber strategy;
|
||||||
|
|
||||||
entry[1].sk_argument =
|
entry[1].sk_argument =
|
||||||
ObjectIdGetDatum(operatorClassObjectId[attributeNumber - 1]);
|
ObjectIdGetDatum(operatorClassObjectId[attributeNumber - 1]);
|
||||||
@@ -676,7 +676,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
|
|||||||
while (tuple = heap_getnext(scan, 0, (Buffer *) NULL),
|
while (tuple = heap_getnext(scan, 0, (Buffer *) NULL),
|
||||||
HeapTupleIsValid(tuple))
|
HeapTupleIsValid(tuple))
|
||||||
{
|
{
|
||||||
Form_pg_amop form;
|
Form_pg_amop form;
|
||||||
|
|
||||||
form = (Form_pg_amop) GETSTRUCT(tuple);
|
form = (Form_pg_amop) GETSTRUCT(tuple);
|
||||||
|
|
||||||
@@ -702,9 +702,9 @@ IndexStrategyDisplay(IndexStrategy indexStrategy,
|
|||||||
StrategyNumber numberOfStrategies,
|
StrategyNumber numberOfStrategies,
|
||||||
int numberOfAttributes)
|
int numberOfAttributes)
|
||||||
{
|
{
|
||||||
StrategyMap strategyMap;
|
StrategyMap strategyMap;
|
||||||
AttrNumber attributeNumber;
|
AttrNumber attributeNumber;
|
||||||
StrategyNumber strategyNumber;
|
StrategyNumber strategyNumber;
|
||||||
|
|
||||||
for (attributeNumber = 1; attributeNumber <= numberOfAttributes;
|
for (attributeNumber = 1; attributeNumber <= numberOfAttributes;
|
||||||
attributeNumber += 1)
|
attributeNumber += 1)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.11 1997/09/07 04:38:39 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.12 1997/09/08 02:20:44 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* These functions are stored in pg_amproc. For each operator class
|
* These functions are stored in pg_amproc. For each operator class
|
||||||
@@ -134,13 +134,13 @@ btnamecmp(NameData * a, NameData * b)
|
|||||||
int32
|
int32
|
||||||
bttextcmp(struct varlena * a, struct varlena * b)
|
bttextcmp(struct varlena * a, struct varlena * b)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
unsigned char *ap,
|
unsigned char *ap,
|
||||||
*bp;
|
*bp;
|
||||||
|
|
||||||
#ifdef USE_LOCALE
|
#ifdef USE_LOCALE
|
||||||
int la = VARSIZE(a) - VARHDRSZ;
|
int la = VARSIZE(a) - VARHDRSZ;
|
||||||
int lb = VARSIZE(b) - VARHDRSZ;
|
int lb = VARSIZE(b) - VARHDRSZ;
|
||||||
|
|
||||||
ap = (unsigned char *) palloc(la + 1);
|
ap = (unsigned char *) palloc(la + 1);
|
||||||
bp = (unsigned char *) palloc(lb + 1);
|
bp = (unsigned char *) palloc(lb + 1);
|
||||||
@@ -156,7 +156,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
|
|||||||
pfree(bp);
|
pfree(bp);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
int len = VARSIZE(a);
|
int len = VARSIZE(a);
|
||||||
|
|
||||||
/* len is the length of the shorter of the two strings */
|
/* len is the length of the shorter of the two strings */
|
||||||
if (len > VARSIZE(b))
|
if (len > VARSIZE(b))
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.18 1997/09/07 04:38:45 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.19 1997/09/08 02:20:46 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -28,13 +28,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem);
|
static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem);
|
||||||
static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright);
|
static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright);
|
||||||
static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start, OffsetNumber maxoff, Size llimit);
|
static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start, OffsetNumber maxoff, Size llimit);
|
||||||
static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf);
|
static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf);
|
||||||
static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem);
|
static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem);
|
||||||
static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem);
|
static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem);
|
||||||
static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem);
|
static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem);
|
||||||
static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey);
|
static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _bt_doinsert() -- Handle insertion of a single btitem in the tree.
|
* _bt_doinsert() -- Handle insertion of a single btitem in the tree.
|
||||||
@@ -46,12 +46,12 @@ static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int
|
|||||||
InsertIndexResult
|
InsertIndexResult
|
||||||
_bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel)
|
_bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel)
|
||||||
{
|
{
|
||||||
ScanKey itup_scankey;
|
ScanKey itup_scankey;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
BTStack stack;
|
BTStack stack;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
int natts = rel->rd_rel->relnatts;
|
int natts = rel->rd_rel->relnatts;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
|
|
||||||
itup = &(btitem->bti_itup);
|
itup = &(btitem->bti_itup);
|
||||||
@@ -82,9 +82,9 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
|
|||||||
/* already in the node */
|
/* already in the node */
|
||||||
if (index_is_unique)
|
if (index_is_unique)
|
||||||
{
|
{
|
||||||
OffsetNumber offset,
|
OffsetNumber offset,
|
||||||
maxoff;
|
maxoff;
|
||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
maxoff = PageGetMaxOffsetNumber(page);
|
maxoff = PageGetMaxOffsetNumber(page);
|
||||||
@@ -95,13 +95,13 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
|
|||||||
/* key on the page before trying to compare it */
|
/* key on the page before trying to compare it */
|
||||||
if (!PageIsEmpty(page) && offset <= maxoff)
|
if (!PageIsEmpty(page) && offset <= maxoff)
|
||||||
{
|
{
|
||||||
TupleDesc itupdesc;
|
TupleDesc itupdesc;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
Buffer nbuf;
|
Buffer nbuf;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
itupdesc = RelationGetTupleDescriptor(rel);
|
itupdesc = RelationGetTupleDescriptor(rel);
|
||||||
nbuf = InvalidBuffer;
|
nbuf = InvalidBuffer;
|
||||||
@@ -213,7 +213,7 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
|
|||||||
* 'afteritem' parameter to position ourselves correctly for the
|
* 'afteritem' parameter to position ourselves correctly for the
|
||||||
* insertion on internal pages.
|
* insertion on internal pages.
|
||||||
*/
|
*/
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
_bt_insertonpg(Relation rel,
|
_bt_insertonpg(Relation rel,
|
||||||
Buffer buf,
|
Buffer buf,
|
||||||
BTStack stack,
|
BTStack stack,
|
||||||
@@ -223,14 +223,14 @@ _bt_insertonpg(Relation rel,
|
|||||||
BTItem afteritem)
|
BTItem afteritem)
|
||||||
{
|
{
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque lpageop;
|
BTPageOpaque lpageop;
|
||||||
BlockNumber itup_blkno;
|
BlockNumber itup_blkno;
|
||||||
OffsetNumber itup_off;
|
OffsetNumber itup_off;
|
||||||
OffsetNumber firstright = InvalidOffsetNumber;
|
OffsetNumber firstright = InvalidOffsetNumber;
|
||||||
int itemsz;
|
int itemsz;
|
||||||
bool do_split = false;
|
bool do_split = false;
|
||||||
bool keys_equal = false;
|
bool keys_equal = false;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
lpageop = (BTPageOpaque) PageGetSpecialPointer(page);
|
lpageop = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||||
@@ -251,9 +251,9 @@ _bt_insertonpg(Relation rel,
|
|||||||
*/
|
*/
|
||||||
if (lpageop->btpo_flags & BTP_CHAIN)
|
if (lpageop->btpo_flags & BTP_CHAIN)
|
||||||
{
|
{
|
||||||
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
||||||
ItemId hitemid;
|
ItemId hitemid;
|
||||||
BTItem hitem;
|
BTItem hitem;
|
||||||
|
|
||||||
Assert(!P_RIGHTMOST(lpageop));
|
Assert(!P_RIGHTMOST(lpageop));
|
||||||
hitemid = PageGetItemId(page, P_HIKEY);
|
hitemid = PageGetItemId(page, P_HIKEY);
|
||||||
@@ -280,8 +280,8 @@ _bt_insertonpg(Relation rel,
|
|||||||
else
|
else
|
||||||
/* "eat" page */
|
/* "eat" page */
|
||||||
{
|
{
|
||||||
Buffer pbuf;
|
Buffer pbuf;
|
||||||
Page ppage;
|
Page ppage;
|
||||||
|
|
||||||
itup_blkno = BufferGetBlockNumber(buf);
|
itup_blkno = BufferGetBlockNumber(buf);
|
||||||
itup_off = PageAddItem(page, (Item) btitem, itemsz,
|
itup_off = PageAddItem(page, (Item) btitem, itemsz,
|
||||||
@@ -315,13 +315,13 @@ _bt_insertonpg(Relation rel,
|
|||||||
do_split = true;
|
do_split = true;
|
||||||
else if (PageGetFreeSpace(page) < 3 * itemsz + 2 * sizeof(ItemIdData))
|
else if (PageGetFreeSpace(page) < 3 * itemsz + 2 * sizeof(ItemIdData))
|
||||||
{
|
{
|
||||||
OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
||||||
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
||||||
ItemId itid;
|
ItemId itid;
|
||||||
BTItem previtem,
|
BTItem previtem,
|
||||||
chkitem;
|
chkitem;
|
||||||
Size maxsize;
|
Size maxsize;
|
||||||
Size currsize;
|
Size currsize;
|
||||||
|
|
||||||
itid = PageGetItemId(page, offnum);
|
itid = PageGetItemId(page, offnum);
|
||||||
previtem = (BTItem) PageGetItem(page, itid);
|
previtem = (BTItem) PageGetItem(page, itid);
|
||||||
@@ -351,19 +351,19 @@ _bt_insertonpg(Relation rel,
|
|||||||
|
|
||||||
if (do_split)
|
if (do_split)
|
||||||
{
|
{
|
||||||
Buffer rbuf;
|
Buffer rbuf;
|
||||||
Page rpage;
|
Page rpage;
|
||||||
BTItem ritem;
|
BTItem ritem;
|
||||||
BlockNumber rbknum;
|
BlockNumber rbknum;
|
||||||
BTPageOpaque rpageop;
|
BTPageOpaque rpageop;
|
||||||
Buffer pbuf;
|
Buffer pbuf;
|
||||||
Page ppage;
|
Page ppage;
|
||||||
BTPageOpaque ppageop;
|
BTPageOpaque ppageop;
|
||||||
BlockNumber bknum = BufferGetBlockNumber(buf);
|
BlockNumber bknum = BufferGetBlockNumber(buf);
|
||||||
BTItem lowLeftItem;
|
BTItem lowLeftItem;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
bool shifted = false;
|
bool shifted = false;
|
||||||
bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false;
|
bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have to split leaf page in the chain of duplicates by new
|
* If we have to split leaf page in the chain of duplicates by new
|
||||||
@@ -372,7 +372,7 @@ _bt_insertonpg(Relation rel,
|
|||||||
if ((lpageop->btpo_flags & BTP_CHAIN) &&
|
if ((lpageop->btpo_flags & BTP_CHAIN) &&
|
||||||
(lpageop->btpo_flags & BTP_LEAF) && keys_equal)
|
(lpageop->btpo_flags & BTP_LEAF) && keys_equal)
|
||||||
{
|
{
|
||||||
bool use_left = true;
|
bool use_left = true;
|
||||||
|
|
||||||
rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE);
|
rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE);
|
||||||
rpage = BufferGetPage(rbuf);
|
rpage = BufferGetPage(rbuf);
|
||||||
@@ -429,8 +429,8 @@ _bt_insertonpg(Relation rel,
|
|||||||
*/
|
*/
|
||||||
else if (!(lpageop->btpo_flags & BTP_CHAIN))
|
else if (!(lpageop->btpo_flags & BTP_CHAIN))
|
||||||
{
|
{
|
||||||
OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
||||||
Size llimit;
|
Size llimit;
|
||||||
|
|
||||||
maxoff = PageGetMaxOffsetNumber(page);
|
maxoff = PageGetMaxOffsetNumber(page);
|
||||||
llimit = PageGetPageSize(page) - sizeof(PageHeaderData) -
|
llimit = PageGetPageSize(page) - sizeof(PageHeaderData) -
|
||||||
@@ -547,13 +547,13 @@ _bt_insertonpg(Relation rel,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ScanKey newskey;
|
ScanKey newskey;
|
||||||
InsertIndexResult newres;
|
InsertIndexResult newres;
|
||||||
BTItem new_item;
|
BTItem new_item;
|
||||||
OffsetNumber upditem_offset = P_HIKEY;
|
OffsetNumber upditem_offset = P_HIKEY;
|
||||||
bool do_update = false;
|
bool do_update = false;
|
||||||
bool update_in_place = true;
|
bool update_in_place = true;
|
||||||
bool parent_chained;
|
bool parent_chained;
|
||||||
|
|
||||||
/* form a index tuple that points at the new right page */
|
/* form a index tuple that points at the new right page */
|
||||||
rbknum = BufferGetBlockNumber(rbuf);
|
rbknum = BufferGetBlockNumber(rbuf);
|
||||||
@@ -790,27 +790,27 @@ _bt_insertonpg(Relation rel,
|
|||||||
* Returns the new right sibling of buf, pinned and write-locked. The
|
* Returns the new right sibling of buf, pinned and write-locked. The
|
||||||
* pin and lock on buf are maintained.
|
* pin and lock on buf are maintained.
|
||||||
*/
|
*/
|
||||||
static Buffer
|
static Buffer
|
||||||
_bt_split(Relation rel, Buffer buf, OffsetNumber firstright)
|
_bt_split(Relation rel, Buffer buf, OffsetNumber firstright)
|
||||||
{
|
{
|
||||||
Buffer rbuf;
|
Buffer rbuf;
|
||||||
Page origpage;
|
Page origpage;
|
||||||
Page leftpage,
|
Page leftpage,
|
||||||
rightpage;
|
rightpage;
|
||||||
BTPageOpaque ropaque,
|
BTPageOpaque ropaque,
|
||||||
lopaque,
|
lopaque,
|
||||||
oopaque;
|
oopaque;
|
||||||
Buffer sbuf;
|
Buffer sbuf;
|
||||||
Page spage;
|
Page spage;
|
||||||
BTPageOpaque sopaque;
|
BTPageOpaque sopaque;
|
||||||
Size itemsz;
|
Size itemsz;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
BTItem item;
|
BTItem item;
|
||||||
OffsetNumber leftoff,
|
OffsetNumber leftoff,
|
||||||
rightoff;
|
rightoff;
|
||||||
OffsetNumber start;
|
OffsetNumber start;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
|
|
||||||
rbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
|
rbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
|
||||||
origpage = BufferGetPage(buf);
|
origpage = BufferGetPage(buf);
|
||||||
@@ -871,7 +871,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright)
|
|||||||
maxoff = PageGetMaxOffsetNumber(origpage);
|
maxoff = PageGetMaxOffsetNumber(origpage);
|
||||||
if (firstright == InvalidOffsetNumber)
|
if (firstright == InvalidOffsetNumber)
|
||||||
{
|
{
|
||||||
Size llimit = PageGetFreeSpace(leftpage) / 2;
|
Size llimit = PageGetFreeSpace(leftpage) / 2;
|
||||||
|
|
||||||
firstright = _bt_findsplitloc(rel, origpage, start, maxoff, llimit);
|
firstright = _bt_findsplitloc(rel, origpage, start, maxoff, llimit);
|
||||||
}
|
}
|
||||||
@@ -987,21 +987,21 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright)
|
|||||||
* may be split as
|
* may be split as
|
||||||
* [2 2 2 2] [2 3 4].
|
* [2 2 2 2] [2 3 4].
|
||||||
*/
|
*/
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
_bt_findsplitloc(Relation rel,
|
_bt_findsplitloc(Relation rel,
|
||||||
Page page,
|
Page page,
|
||||||
OffsetNumber start,
|
OffsetNumber start,
|
||||||
OffsetNumber maxoff,
|
OffsetNumber maxoff,
|
||||||
Size llimit)
|
Size llimit)
|
||||||
{
|
{
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
OffsetNumber saferight;
|
OffsetNumber saferight;
|
||||||
ItemId nxtitemid,
|
ItemId nxtitemid,
|
||||||
safeitemid;
|
safeitemid;
|
||||||
BTItem safeitem,
|
BTItem safeitem,
|
||||||
nxtitem;
|
nxtitem;
|
||||||
Size nbytes;
|
Size nbytes;
|
||||||
int natts;
|
int natts;
|
||||||
|
|
||||||
if (start >= maxoff)
|
if (start >= maxoff)
|
||||||
elog(FATAL, "btree: cannot split if start (%d) >= maxoff (%d)",
|
elog(FATAL, "btree: cannot split if start (%d) >= maxoff (%d)",
|
||||||
@@ -1072,18 +1072,18 @@ _bt_findsplitloc(Relation rel,
|
|||||||
static void
|
static void
|
||||||
_bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
|
_bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
|
||||||
{
|
{
|
||||||
Buffer rootbuf;
|
Buffer rootbuf;
|
||||||
Page lpage,
|
Page lpage,
|
||||||
rpage,
|
rpage,
|
||||||
rootpage;
|
rootpage;
|
||||||
BlockNumber lbkno,
|
BlockNumber lbkno,
|
||||||
rbkno;
|
rbkno;
|
||||||
BlockNumber rootbknum;
|
BlockNumber rootbknum;
|
||||||
BTPageOpaque rootopaque;
|
BTPageOpaque rootopaque;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
BTItem item;
|
BTItem item;
|
||||||
Size itemsz;
|
Size itemsz;
|
||||||
BTItem new_item;
|
BTItem new_item;
|
||||||
|
|
||||||
/* get a new root page */
|
/* get a new root page */
|
||||||
rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
|
rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
|
||||||
@@ -1158,7 +1158,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
|
|||||||
* to follow. Otherwise, we do a binary search for the correct place
|
* to follow. Otherwise, we do a binary search for the correct place
|
||||||
* and insert the new item there.
|
* and insert the new item there.
|
||||||
*/
|
*/
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
_bt_pgaddtup(Relation rel,
|
_bt_pgaddtup(Relation rel,
|
||||||
Buffer buf,
|
Buffer buf,
|
||||||
int keysz,
|
int keysz,
|
||||||
@@ -1167,11 +1167,11 @@ _bt_pgaddtup(Relation rel,
|
|||||||
BTItem btitem,
|
BTItem btitem,
|
||||||
BTItem afteritem)
|
BTItem afteritem)
|
||||||
{
|
{
|
||||||
OffsetNumber itup_off;
|
OffsetNumber itup_off;
|
||||||
OffsetNumber first;
|
OffsetNumber first;
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
BTItem chkitem;
|
BTItem chkitem;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||||
@@ -1213,20 +1213,20 @@ _bt_pgaddtup(Relation rel,
|
|||||||
* + the item it is to follow ("afteritem") appears on this
|
* + the item it is to follow ("afteritem") appears on this
|
||||||
* page.
|
* page.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
_bt_goesonpg(Relation rel,
|
_bt_goesonpg(Relation rel,
|
||||||
Buffer buf,
|
Buffer buf,
|
||||||
Size keysz,
|
Size keysz,
|
||||||
ScanKey scankey,
|
ScanKey scankey,
|
||||||
BTItem afteritem)
|
BTItem afteritem)
|
||||||
{
|
{
|
||||||
Page page;
|
Page page;
|
||||||
ItemId hikey;
|
ItemId hikey;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
BTItem chkitem;
|
BTItem chkitem;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
|
|
||||||
@@ -1314,16 +1314,16 @@ _bt_itemcmp(Relation rel,
|
|||||||
BTItem item2,
|
BTItem item2,
|
||||||
StrategyNumber strat)
|
StrategyNumber strat)
|
||||||
{
|
{
|
||||||
TupleDesc tupDes;
|
TupleDesc tupDes;
|
||||||
IndexTuple indexTuple1,
|
IndexTuple indexTuple1,
|
||||||
indexTuple2;
|
indexTuple2;
|
||||||
Datum attrDatum1,
|
Datum attrDatum1,
|
||||||
attrDatum2;
|
attrDatum2;
|
||||||
int i;
|
int i;
|
||||||
bool isFirstNull,
|
bool isFirstNull,
|
||||||
isSecondNull;
|
isSecondNull;
|
||||||
bool compare;
|
bool compare;
|
||||||
bool useEqual = false;
|
bool useEqual = false;
|
||||||
|
|
||||||
if (strat == BTLessEqualStrategyNumber)
|
if (strat == BTLessEqualStrategyNumber)
|
||||||
{
|
{
|
||||||
@@ -1406,14 +1406,14 @@ _bt_updateitem(Relation rel,
|
|||||||
BTItem oldItem,
|
BTItem oldItem,
|
||||||
BTItem newItem)
|
BTItem newItem)
|
||||||
{
|
{
|
||||||
Page page;
|
Page page;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
ItemPointerData itemPtrData;
|
ItemPointerData itemPtrData;
|
||||||
BTItem item;
|
BTItem item;
|
||||||
IndexTuple oldIndexTuple,
|
IndexTuple oldIndexTuple,
|
||||||
newIndexTuple;
|
newIndexTuple;
|
||||||
int first;
|
int first;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
maxoff = PageGetMaxOffsetNumber(page);
|
maxoff = PageGetMaxOffsetNumber(page);
|
||||||
@@ -1460,18 +1460,18 @@ _bt_updateitem(Relation rel,
|
|||||||
*
|
*
|
||||||
* Rule is simple: NOT_NULL not equal NULL, NULL not_equal NULL too.
|
* Rule is simple: NOT_NULL not equal NULL, NULL not_equal NULL too.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
_bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
|
_bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
|
||||||
int keysz, ScanKey scankey)
|
int keysz, ScanKey scankey)
|
||||||
{
|
{
|
||||||
Datum datum;
|
Datum datum;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
ScanKey entry;
|
ScanKey entry;
|
||||||
AttrNumber attno;
|
AttrNumber attno;
|
||||||
long result;
|
long result;
|
||||||
int i;
|
int i;
|
||||||
bool null;
|
bool null;
|
||||||
|
|
||||||
btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offnum));
|
btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offnum));
|
||||||
itup = &(btitem->bti_itup);
|
itup = &(btitem->bti_itup);
|
||||||
@@ -1504,27 +1504,27 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
|
|||||||
*
|
*
|
||||||
* NOTE: tested for shifting leftmost page only, having btitem < hikey.
|
* NOTE: tested for shifting leftmost page only, having btitem < hikey.
|
||||||
*/
|
*/
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
_bt_shift(Relation rel, Buffer buf, BTStack stack, int keysz,
|
_bt_shift(Relation rel, Buffer buf, BTStack stack, int keysz,
|
||||||
ScanKey scankey, BTItem btitem, BTItem hikey)
|
ScanKey scankey, BTItem btitem, BTItem hikey)
|
||||||
{
|
{
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
int itemsz;
|
int itemsz;
|
||||||
Page page;
|
Page page;
|
||||||
BlockNumber bknum;
|
BlockNumber bknum;
|
||||||
BTPageOpaque pageop;
|
BTPageOpaque pageop;
|
||||||
Buffer rbuf;
|
Buffer rbuf;
|
||||||
Page rpage;
|
Page rpage;
|
||||||
BTPageOpaque rpageop;
|
BTPageOpaque rpageop;
|
||||||
Buffer pbuf;
|
Buffer pbuf;
|
||||||
Page ppage;
|
Page ppage;
|
||||||
BTPageOpaque ppageop;
|
BTPageOpaque ppageop;
|
||||||
Buffer nbuf;
|
Buffer nbuf;
|
||||||
Page npage;
|
Page npage;
|
||||||
BTPageOpaque npageop;
|
BTPageOpaque npageop;
|
||||||
BlockNumber nbknum;
|
BlockNumber nbknum;
|
||||||
BTItem nitem;
|
BTItem nitem;
|
||||||
OffsetNumber afteroff;
|
OffsetNumber afteroff;
|
||||||
|
|
||||||
btitem = _bt_formitem(&(btitem->bti_itup));
|
btitem = _bt_formitem(&(btitem->bti_itup));
|
||||||
hikey = _bt_formitem(&(hikey->bti_itup));
|
hikey = _bt_formitem(&(hikey->bti_itup));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.10 1997/09/07 04:38:52 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.11 1997/09/08 02:20:49 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Postgres btree pages look like ordinary relation pages. The opaque
|
* Postgres btree pages look like ordinary relation pages. The opaque
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access);
|
static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access);
|
||||||
static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
||||||
|
|
||||||
#define BTREE_METAPAGE 0
|
#define BTREE_METAPAGE 0
|
||||||
#define BTREE_MAGIC 0x053162
|
#define BTREE_MAGIC 0x053162
|
||||||
@@ -50,18 +50,18 @@ static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
|||||||
|
|
||||||
typedef struct BTMetaPageData
|
typedef struct BTMetaPageData
|
||||||
{
|
{
|
||||||
uint32 btm_magic;
|
uint32 btm_magic;
|
||||||
uint32 btm_version;
|
uint32 btm_version;
|
||||||
BlockNumber btm_root;
|
BlockNumber btm_root;
|
||||||
#ifdef BTREE_VERSION_1
|
#ifdef BTREE_VERSION_1
|
||||||
int32 btm_level;
|
int32 btm_level;
|
||||||
#endif
|
#endif
|
||||||
} BTMetaPageData;
|
} BTMetaPageData;
|
||||||
|
|
||||||
#define BTPageGetMeta(p) \
|
#define BTPageGetMeta(p) \
|
||||||
((BTMetaPageData *) &((PageHeader) p)->pd_linp[0])
|
((BTMetaPageData *) &((PageHeader) p)->pd_linp[0])
|
||||||
|
|
||||||
extern bool BuildingBtree;
|
extern bool BuildingBtree;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use high-concurrency locking on btrees. There are two cases in
|
* We use high-concurrency locking on btrees. There are two cases in
|
||||||
@@ -85,11 +85,11 @@ extern bool BuildingBtree;
|
|||||||
void
|
void
|
||||||
_bt_metapinit(Relation rel)
|
_bt_metapinit(Relation rel)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page pg;
|
Page pg;
|
||||||
int nblocks;
|
int nblocks;
|
||||||
BTMetaPageData metad;
|
BTMetaPageData metad;
|
||||||
BTPageOpaque op;
|
BTPageOpaque op;
|
||||||
|
|
||||||
/* can't be sharing this with anyone, now... */
|
/* can't be sharing this with anyone, now... */
|
||||||
if (USELOCKING)
|
if (USELOCKING)
|
||||||
@@ -131,11 +131,11 @@ _bt_metapinit(Relation rel)
|
|||||||
void
|
void
|
||||||
_bt_checkmeta(Relation rel)
|
_bt_checkmeta(Relation rel)
|
||||||
{
|
{
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Page metap;
|
Page metap;
|
||||||
BTMetaPageData *metad;
|
BTMetaPageData *metad;
|
||||||
BTPageOpaque op;
|
BTPageOpaque op;
|
||||||
int nblocks;
|
int nblocks;
|
||||||
|
|
||||||
/* if the relation is empty, this is init time; don't complain */
|
/* if the relation is empty, this is init time; don't complain */
|
||||||
if ((nblocks = RelationGetNumberOfBlocks(rel)) == 0)
|
if ((nblocks = RelationGetNumberOfBlocks(rel)) == 0)
|
||||||
@@ -187,13 +187,13 @@ _bt_checkmeta(Relation rel)
|
|||||||
Buffer
|
Buffer
|
||||||
_bt_getroot(Relation rel, int access)
|
_bt_getroot(Relation rel, int access)
|
||||||
{
|
{
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Page metapg;
|
Page metapg;
|
||||||
BTPageOpaque metaopaque;
|
BTPageOpaque metaopaque;
|
||||||
Buffer rootbuf;
|
Buffer rootbuf;
|
||||||
Page rootpg;
|
Page rootpg;
|
||||||
BTPageOpaque rootopaque;
|
BTPageOpaque rootopaque;
|
||||||
BlockNumber rootblkno;
|
BlockNumber rootblkno;
|
||||||
BTMetaPageData *metad;
|
BTMetaPageData *metad;
|
||||||
|
|
||||||
metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
|
metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
|
||||||
@@ -319,8 +319,8 @@ _bt_getroot(Relation rel, int access)
|
|||||||
Buffer
|
Buffer
|
||||||
_bt_getbuf(Relation rel, BlockNumber blkno, int access)
|
_bt_getbuf(Relation rel, BlockNumber blkno, int access)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we want a new block, we can't set a lock of the appropriate type
|
* If we want a new block, we can't set a lock of the appropriate type
|
||||||
@@ -359,7 +359,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
|
|||||||
void
|
void
|
||||||
_bt_relbuf(Relation rel, Buffer buf, int access)
|
_bt_relbuf(Relation rel, Buffer buf, int access)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(buf);
|
blkno = BufferGetBlockNumber(buf);
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ _bt_relbuf(Relation rel, Buffer buf, int access)
|
|||||||
void
|
void
|
||||||
_bt_wrtbuf(Relation rel, Buffer buf)
|
_bt_wrtbuf(Relation rel, Buffer buf)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(buf);
|
blkno = BufferGetBlockNumber(buf);
|
||||||
WriteBuffer(buf);
|
WriteBuffer(buf);
|
||||||
@@ -399,7 +399,7 @@ _bt_wrtbuf(Relation rel, Buffer buf)
|
|||||||
void
|
void
|
||||||
_bt_wrtnorelbuf(Relation rel, Buffer buf)
|
_bt_wrtnorelbuf(Relation rel, Buffer buf)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(buf);
|
blkno = BufferGetBlockNumber(buf);
|
||||||
WriteNoReleaseBuffer(buf);
|
WriteNoReleaseBuffer(buf);
|
||||||
@@ -439,9 +439,9 @@ _bt_pageinit(Page page, Size size)
|
|||||||
void
|
void
|
||||||
_bt_metaproot(Relation rel, BlockNumber rootbknum, int level)
|
_bt_metaproot(Relation rel, BlockNumber rootbknum, int level)
|
||||||
{
|
{
|
||||||
Buffer metabuf;
|
Buffer metabuf;
|
||||||
Page metap;
|
Page metap;
|
||||||
BTPageOpaque metaopaque;
|
BTPageOpaque metaopaque;
|
||||||
BTMetaPageData *metad;
|
BTMetaPageData *metad;
|
||||||
|
|
||||||
metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE);
|
metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE);
|
||||||
@@ -473,18 +473,18 @@ _bt_metaproot(Relation rel, BlockNumber rootbknum, int level)
|
|||||||
Buffer
|
Buffer
|
||||||
_bt_getstackbuf(Relation rel, BTStack stack, int access)
|
_bt_getstackbuf(Relation rel, BTStack stack, int access)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
OffsetNumber start,
|
OffsetNumber start,
|
||||||
offnum,
|
offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
Page page;
|
Page page;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
BTItem item;
|
BTItem item;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
BTItem item_save;
|
BTItem item_save;
|
||||||
int item_nbytes;
|
int item_nbytes;
|
||||||
|
|
||||||
blkno = stack->bts_blkno;
|
blkno = stack->bts_blkno;
|
||||||
buf = _bt_getbuf(rel, blkno, access);
|
buf = _bt_getbuf(rel, blkno, access);
|
||||||
@@ -603,10 +603,10 @@ _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access)
|
|||||||
void
|
void
|
||||||
_bt_pagedel(Relation rel, ItemPointer tid)
|
_bt_pagedel(Relation rel, ItemPointer tid)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
OffsetNumber offno;
|
OffsetNumber offno;
|
||||||
|
|
||||||
blkno = ItemPointerGetBlockNumber(tid);
|
blkno = ItemPointerGetBlockNumber(tid);
|
||||||
offno = ItemPointerGetOffsetNumber(tid);
|
offno = ItemPointerGetOffsetNumber(tid);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.20 1997/09/07 04:38:54 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.21 1997/09/08 02:20:50 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This file contains only the public interface routines.
|
* This file contains only the public interface routines.
|
||||||
@@ -35,14 +35,14 @@
|
|||||||
|
|
||||||
#ifdef BTREE_BUILD_STATS
|
#ifdef BTREE_BUILD_STATS
|
||||||
#include <tcop/tcopprot.h>
|
#include <tcop/tcopprot.h>
|
||||||
extern int ShowExecutorStats;
|
extern int ShowExecutorStats;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool BuildingBtree = false; /* see comment in btbuild() */
|
bool BuildingBtree = false; /* see comment in btbuild() */
|
||||||
bool FastBuild = true; /* use sort/build instead of
|
bool FastBuild = true; /* use sort/build instead of insertion
|
||||||
* insertion build */
|
* build */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* btbuild() -- build a new btree index.
|
* btbuild() -- build a new btree index.
|
||||||
@@ -63,33 +63,33 @@ btbuild(Relation heap,
|
|||||||
FuncIndexInfo * finfo,
|
FuncIndexInfo * finfo,
|
||||||
PredInfo * predInfo)
|
PredInfo * predInfo)
|
||||||
{
|
{
|
||||||
HeapScanDesc hscan;
|
HeapScanDesc hscan;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
TupleDesc htupdesc,
|
TupleDesc htupdesc,
|
||||||
itupdesc;
|
itupdesc;
|
||||||
Datum *attdata;
|
Datum *attdata;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
InsertIndexResult res = 0;
|
InsertIndexResult res = 0;
|
||||||
int nhtups,
|
int nhtups,
|
||||||
nitups;
|
nitups;
|
||||||
int i;
|
int i;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
|
|
||||||
#ifndef OMIT_PARTIAL_INDEX
|
#ifndef OMIT_PARTIAL_INDEX
|
||||||
ExprContext *econtext = (ExprContext *) NULL;
|
ExprContext *econtext = (ExprContext *) NULL;
|
||||||
TupleTable tupleTable = (TupleTable) NULL;
|
TupleTable tupleTable = (TupleTable) NULL;
|
||||||
TupleTableSlot *slot = (TupleTableSlot *) NULL;
|
TupleTableSlot *slot = (TupleTableSlot *) NULL;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Oid hrelid,
|
Oid hrelid,
|
||||||
irelid;
|
irelid;
|
||||||
Node *pred,
|
Node *pred,
|
||||||
*oldPred;
|
*oldPred;
|
||||||
void *spool = (void *) NULL;
|
void *spool = (void *) NULL;
|
||||||
bool isunique;
|
bool isunique;
|
||||||
bool usefast;
|
bool usefast;
|
||||||
|
|
||||||
/* note that this is a new btree */
|
/* note that this is a new btree */
|
||||||
BuildingBtree = true;
|
BuildingBtree = true;
|
||||||
@@ -211,8 +211,8 @@ btbuild(Relation heap,
|
|||||||
|
|
||||||
for (i = 1; i <= natts; i++)
|
for (i = 1; i <= natts; i++)
|
||||||
{
|
{
|
||||||
int attoff;
|
int attoff;
|
||||||
bool attnull;
|
bool attnull;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Offsets are from the start of the tuple, and are
|
* Offsets are from the start of the tuple, and are
|
||||||
@@ -358,8 +358,8 @@ btbuild(Relation heap,
|
|||||||
InsertIndexResult
|
InsertIndexResult
|
||||||
btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
||||||
{
|
{
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
|
|
||||||
/* generate an index tuple */
|
/* generate an index tuple */
|
||||||
@@ -389,7 +389,7 @@ btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation
|
|||||||
/*
|
/*
|
||||||
* btgettuple() -- Get the next tuple in the scan.
|
* btgettuple() -- Get the next tuple in the scan.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
btgettuple(IndexScanDesc scan, ScanDirection dir)
|
btgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||||
{
|
{
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
@@ -411,10 +411,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
/*
|
/*
|
||||||
* btbeginscan() -- start a scan on a btree index
|
* btbeginscan() -- start a scan on a btree index
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
|
btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
|
||||||
{
|
{
|
||||||
IndexScanDesc scan;
|
IndexScanDesc scan;
|
||||||
|
|
||||||
/* get the scan */
|
/* get the scan */
|
||||||
scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey);
|
scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey);
|
||||||
@@ -431,8 +431,8 @@ btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
|
|||||||
void
|
void
|
||||||
btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
|
|
||||||
@@ -483,8 +483,8 @@ btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
|||||||
void
|
void
|
||||||
btmovescan(IndexScanDesc scan, Datum v)
|
btmovescan(IndexScanDesc scan, Datum v)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
|
|
||||||
@@ -506,8 +506,8 @@ btmovescan(IndexScanDesc scan, Datum v)
|
|||||||
void
|
void
|
||||||
btendscan(IndexScanDesc scan)
|
btendscan(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
|
|
||||||
@@ -541,8 +541,8 @@ btendscan(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
btmarkpos(IndexScanDesc scan)
|
btmarkpos(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
|
|
||||||
@@ -570,8 +570,8 @@ btmarkpos(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
btrestrpos(IndexScanDesc scan)
|
btrestrpos(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.8 1997/09/07 04:38:57 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.9 1997/09/08 02:20:52 momjian Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
@@ -34,16 +34,16 @@
|
|||||||
|
|
||||||
typedef struct BTScanListData
|
typedef struct BTScanListData
|
||||||
{
|
{
|
||||||
IndexScanDesc btsl_scan;
|
IndexScanDesc btsl_scan;
|
||||||
struct BTScanListData *btsl_next;
|
struct BTScanListData *btsl_next;
|
||||||
} BTScanListData;
|
} BTScanListData;
|
||||||
|
|
||||||
typedef BTScanListData *BTScanList;
|
typedef BTScanListData *BTScanList;
|
||||||
|
|
||||||
static BTScanList BTScans = (BTScanList) NULL;
|
static BTScanList BTScans = (BTScanList) NULL;
|
||||||
|
|
||||||
static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno);
|
static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno);
|
||||||
static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _bt_regscan() -- register a new scan.
|
* _bt_regscan() -- register a new scan.
|
||||||
@@ -51,7 +51,7 @@ static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber
|
|||||||
void
|
void
|
||||||
_bt_regscan(IndexScanDesc scan)
|
_bt_regscan(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
BTScanList new_el;
|
BTScanList new_el;
|
||||||
|
|
||||||
new_el = (BTScanList) palloc(sizeof(BTScanListData));
|
new_el = (BTScanList) palloc(sizeof(BTScanListData));
|
||||||
new_el->btsl_scan = scan;
|
new_el->btsl_scan = scan;
|
||||||
@@ -65,8 +65,8 @@ _bt_regscan(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
_bt_dropscan(IndexScanDesc scan)
|
_bt_dropscan(IndexScanDesc scan)
|
||||||
{
|
{
|
||||||
BTScanList chk,
|
BTScanList chk,
|
||||||
last;
|
last;
|
||||||
|
|
||||||
last = (BTScanList) NULL;
|
last = (BTScanList) NULL;
|
||||||
for (chk = BTScans;
|
for (chk = BTScans;
|
||||||
@@ -94,8 +94,8 @@ _bt_dropscan(IndexScanDesc scan)
|
|||||||
void
|
void
|
||||||
_bt_adjscans(Relation rel, ItemPointer tid, int op)
|
_bt_adjscans(Relation rel, ItemPointer tid, int op)
|
||||||
{
|
{
|
||||||
BTScanList l;
|
BTScanList l;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
|
|
||||||
relid = rel->rd_id;
|
relid = rel->rd_id;
|
||||||
for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next)
|
for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next)
|
||||||
@@ -130,9 +130,9 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op)
|
|||||||
static void
|
static void
|
||||||
_bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
_bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
||||||
{
|
{
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
if (!_bt_scantouched(scan, blkno, offno))
|
if (!_bt_scantouched(scan, blkno, offno))
|
||||||
return;
|
return;
|
||||||
@@ -147,15 +147,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
|||||||
{
|
{
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case BT_INSERT:
|
case BT_INSERT:
|
||||||
_bt_step(scan, &buf, ForwardScanDirection);
|
_bt_step(scan, &buf, ForwardScanDirection);
|
||||||
break;
|
break;
|
||||||
case BT_DELETE:
|
case BT_DELETE:
|
||||||
_bt_step(scan, &buf, BackwardScanDirection);
|
_bt_step(scan, &buf, BackwardScanDirection);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
so->btso_curbuf = buf;
|
so->btso_curbuf = buf;
|
||||||
}
|
}
|
||||||
@@ -172,15 +172,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
|||||||
scan->currentItemData = tmp;
|
scan->currentItemData = tmp;
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case BT_INSERT:
|
case BT_INSERT:
|
||||||
_bt_step(scan, &buf, ForwardScanDirection);
|
_bt_step(scan, &buf, ForwardScanDirection);
|
||||||
break;
|
break;
|
||||||
case BT_DELETE:
|
case BT_DELETE:
|
||||||
_bt_step(scan, &buf, BackwardScanDirection);
|
_bt_step(scan, &buf, BackwardScanDirection);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
so->btso_mrkbuf = buf;
|
so->btso_mrkbuf = buf;
|
||||||
tmp = *current;
|
tmp = *current;
|
||||||
@@ -193,10 +193,10 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
|||||||
* _bt_scantouched() -- check to see if a scan is affected by a given
|
* _bt_scantouched() -- check to see if a scan is affected by a given
|
||||||
* change to the index
|
* change to the index
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
_bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
|
_bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
|
||||||
{
|
{
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
|
|
||||||
current = &(scan->currentItemData);
|
current = &(scan->currentItemData);
|
||||||
if (ItemPointerIsValid(current)
|
if (ItemPointerIsValid(current)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.24 1997/09/07 04:38:58 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.25 1997/09/08 02:20:57 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -28,19 +28,19 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static BTStack
|
static BTStack
|
||||||
_bt_searchr(Relation rel, int keysz, ScanKey scankey,
|
_bt_searchr(Relation rel, int keysz, ScanKey scankey,
|
||||||
Buffer * bufP, BTStack stack_in);
|
Buffer * bufP, BTStack stack_in);
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
_bt_firsteq(Relation rel, TupleDesc itupdesc, Page page,
|
_bt_firsteq(Relation rel, TupleDesc itupdesc, Page page,
|
||||||
Size keysz, ScanKey scankey, OffsetNumber offnum);
|
Size keysz, ScanKey scankey, OffsetNumber offnum);
|
||||||
static int
|
static int
|
||||||
_bt_compare(Relation rel, TupleDesc itupdesc, Page page,
|
_bt_compare(Relation rel, TupleDesc itupdesc, Page page,
|
||||||
int keysz, ScanKey scankey, OffsetNumber offnum);
|
int keysz, ScanKey scankey, OffsetNumber offnum);
|
||||||
static bool
|
static bool
|
||||||
_bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir);
|
_bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir);
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
_bt_endpoint(IndexScanDesc scan, ScanDirection dir);
|
_bt_endpoint(IndexScanDesc scan, ScanDirection dir);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _bt_search() -- Search for a scan key in the index.
|
* _bt_search() -- Search for a scan key in the index.
|
||||||
@@ -58,24 +58,24 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, Buffer * bufP)
|
|||||||
/*
|
/*
|
||||||
* _bt_searchr() -- Search the tree recursively for a particular scankey.
|
* _bt_searchr() -- Search the tree recursively for a particular scankey.
|
||||||
*/
|
*/
|
||||||
static BTStack
|
static BTStack
|
||||||
_bt_searchr(Relation rel,
|
_bt_searchr(Relation rel,
|
||||||
int keysz,
|
int keysz,
|
||||||
ScanKey scankey,
|
ScanKey scankey,
|
||||||
Buffer * bufP,
|
Buffer * bufP,
|
||||||
BTStack stack_in)
|
BTStack stack_in)
|
||||||
{
|
{
|
||||||
BTStack stack;
|
BTStack stack;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
BlockNumber par_blkno;
|
BlockNumber par_blkno;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
BTItem item_save;
|
BTItem item_save;
|
||||||
int item_nbytes;
|
int item_nbytes;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
|
|
||||||
/* if this is a leaf page, we're done */
|
/* if this is a leaf page, we're done */
|
||||||
page = BufferGetPage(*bufP);
|
page = BufferGetPage(*bufP);
|
||||||
@@ -155,11 +155,11 @@ _bt_moveright(Relation rel,
|
|||||||
ScanKey scankey,
|
ScanKey scankey,
|
||||||
int access)
|
int access)
|
||||||
{
|
{
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
ItemId hikey;
|
ItemId hikey;
|
||||||
BlockNumber rblkno;
|
BlockNumber rblkno;
|
||||||
int natts = rel->rd_rel->relnatts;
|
int natts = rel->rd_rel->relnatts;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||||
@@ -183,7 +183,7 @@ _bt_moveright(Relation rel,
|
|||||||
/* move right as long as we need to */
|
/* move right as long as we need to */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
OffsetNumber offmax = PageGetMaxOffsetNumber(page);
|
OffsetNumber offmax = PageGetMaxOffsetNumber(page);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this page consists of all duplicate keys (hikey and
|
* If this page consists of all duplicate keys (hikey and
|
||||||
@@ -197,8 +197,8 @@ _bt_moveright(Relation rel,
|
|||||||
* if number of attrs > keysize. Example: (2,0) - last items
|
* if number of attrs > keysize. Example: (2,0) - last items
|
||||||
* on this page, (2,1) - first item on next page (hikey), our
|
* on this page, (2,1) - first item on next page (hikey), our
|
||||||
* scankey is x = 2. Scankey == (2,1) because of we compare
|
* scankey is x = 2. Scankey == (2,1) because of we compare
|
||||||
* first attrs only, but we shouldn't to move right of here.
|
* first attrs only, but we shouldn't to move right of here. -
|
||||||
* - vadim 04/15/97
|
* vadim 04/15/97
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (_bt_skeycmp(rel, keysz, scankey, page, hikey,
|
if (_bt_skeycmp(rel, keysz, scankey, page, hikey,
|
||||||
@@ -268,17 +268,17 @@ _bt_skeycmp(Relation rel,
|
|||||||
ItemId itemid,
|
ItemId itemid,
|
||||||
StrategyNumber strat)
|
StrategyNumber strat)
|
||||||
{
|
{
|
||||||
BTItem item;
|
BTItem item;
|
||||||
IndexTuple indexTuple;
|
IndexTuple indexTuple;
|
||||||
TupleDesc tupDes;
|
TupleDesc tupDes;
|
||||||
ScanKey entry;
|
ScanKey entry;
|
||||||
int i;
|
int i;
|
||||||
Datum attrDatum;
|
Datum attrDatum;
|
||||||
Datum keyDatum;
|
Datum keyDatum;
|
||||||
bool compare;
|
bool compare;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
bool useEqual = false;
|
bool useEqual = false;
|
||||||
bool keyNull;
|
bool keyNull;
|
||||||
|
|
||||||
if (strat == BTLessEqualStrategyNumber)
|
if (strat == BTLessEqualStrategyNumber)
|
||||||
{
|
{
|
||||||
@@ -382,14 +382,14 @@ _bt_binsrch(Relation rel,
|
|||||||
ScanKey scankey,
|
ScanKey scankey,
|
||||||
int srchtype)
|
int srchtype)
|
||||||
{
|
{
|
||||||
TupleDesc itupdesc;
|
TupleDesc itupdesc;
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
OffsetNumber low,
|
OffsetNumber low,
|
||||||
mid,
|
mid,
|
||||||
high;
|
high;
|
||||||
int natts = rel->rd_rel->relnatts;
|
int natts = rel->rd_rel->relnatts;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
itupdesc = RelationGetTupleDescriptor(rel);
|
itupdesc = RelationGetTupleDescriptor(rel);
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
@@ -515,7 +515,7 @@ _bt_binsrch(Relation rel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
_bt_firsteq(Relation rel,
|
_bt_firsteq(Relation rel,
|
||||||
TupleDesc itupdesc,
|
TupleDesc itupdesc,
|
||||||
Page page,
|
Page page,
|
||||||
@@ -523,8 +523,8 @@ _bt_firsteq(Relation rel,
|
|||||||
ScanKey scankey,
|
ScanKey scankey,
|
||||||
OffsetNumber offnum)
|
OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
OffsetNumber limit;
|
OffsetNumber limit;
|
||||||
|
|
||||||
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||||
|
|
||||||
@@ -572,16 +572,16 @@ _bt_compare(Relation rel,
|
|||||||
ScanKey scankey,
|
ScanKey scankey,
|
||||||
OffsetNumber offnum)
|
OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
Datum datum;
|
Datum datum;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
ScanKey entry;
|
ScanKey entry;
|
||||||
AttrNumber attno;
|
AttrNumber attno;
|
||||||
int result;
|
int result;
|
||||||
int i;
|
int i;
|
||||||
bool null;
|
bool null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a leftmost internal page, and if our comparison is with
|
* If this is a leftmost internal page, and if our comparison is with
|
||||||
@@ -650,7 +650,7 @@ _bt_compare(Relation rel,
|
|||||||
|
|
||||||
for (i = 1; i <= keysz; i++)
|
for (i = 1; i <= keysz; i++)
|
||||||
{
|
{
|
||||||
long tmpres;
|
long tmpres;
|
||||||
|
|
||||||
entry = &scankey[i - 1];
|
entry = &scankey[i - 1];
|
||||||
attno = entry->sk_attno;
|
attno = entry->sk_attno;
|
||||||
@@ -697,16 +697,16 @@ _bt_compare(Relation rel,
|
|||||||
RetrieveIndexResult
|
RetrieveIndexResult
|
||||||
_bt_next(IndexScanDesc scan, ScanDirection dir)
|
_bt_next(IndexScanDesc scan, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
Size keysok;
|
Size keysok;
|
||||||
|
|
||||||
rel = scan->relation;
|
rel = scan->relation;
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
@@ -769,26 +769,26 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
|
|||||||
RetrieveIndexResult
|
RetrieveIndexResult
|
||||||
_bt_first(IndexScanDesc scan, ScanDirection dir)
|
_bt_first(IndexScanDesc scan, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
TupleDesc itupdesc;
|
TupleDesc itupdesc;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque pop;
|
BTPageOpaque pop;
|
||||||
BTStack stack;
|
BTStack stack;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
bool offGmax = false;
|
bool offGmax = false;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
StrategyNumber strat;
|
StrategyNumber strat;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
RegProcedure proc;
|
RegProcedure proc;
|
||||||
int result;
|
int result;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
ScanKeyData skdata;
|
ScanKeyData skdata;
|
||||||
Size keysok;
|
Size keysok;
|
||||||
|
|
||||||
rel = scan->relation;
|
rel = scan->relation;
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
@@ -915,69 +915,69 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
|
|||||||
|
|
||||||
switch (strat)
|
switch (strat)
|
||||||
{
|
{
|
||||||
case BTLessStrategyNumber:
|
case BTLessStrategyNumber:
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
do
|
||||||
break;
|
|
||||||
|
|
||||||
offnum = ItemPointerGetOffsetNumber(current);
|
|
||||||
page = BufferGetPage(buf);
|
|
||||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
|
||||||
} while (result <= 0);
|
|
||||||
|
|
||||||
/* if this is true, the key we just looked at is gone */
|
|
||||||
if (result > 0)
|
|
||||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BTLessEqualStrategyNumber:
|
|
||||||
if (result >= 0)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
|
||||||
break;
|
|
||||||
|
|
||||||
offnum = ItemPointerGetOffsetNumber(current);
|
|
||||||
page = BufferGetPage(buf);
|
|
||||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
|
||||||
} while (result >= 0);
|
|
||||||
|
|
||||||
if (result < 0)
|
|
||||||
_bt_twostep(scan, &buf, BackwardScanDirection);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BTEqualStrategyNumber:
|
|
||||||
if (result != 0)
|
|
||||||
{
|
|
||||||
_bt_relbuf(scan->relation, buf, BT_READ);
|
|
||||||
so->btso_curbuf = InvalidBuffer;
|
|
||||||
ItemPointerSetInvalid(&(scan->currentItemData));
|
|
||||||
return ((RetrieveIndexResult) NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BTGreaterEqualStrategyNumber:
|
|
||||||
if (offGmax)
|
|
||||||
{
|
|
||||||
if (result < 0)
|
|
||||||
{
|
|
||||||
Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY);
|
|
||||||
if (!_bt_step(scan, &buf, ForwardScanDirection))
|
|
||||||
{
|
{
|
||||||
_bt_relbuf(scan->relation, buf, BT_READ);
|
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
||||||
so->btso_curbuf = InvalidBuffer;
|
break;
|
||||||
ItemPointerSetInvalid(&(scan->currentItemData));
|
|
||||||
return ((RetrieveIndexResult) NULL);
|
offnum = ItemPointerGetOffsetNumber(current);
|
||||||
}
|
page = BufferGetPage(buf);
|
||||||
|
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||||
|
} while (result <= 0);
|
||||||
|
|
||||||
|
/* if this is true, the key we just looked at is gone */
|
||||||
|
if (result > 0)
|
||||||
|
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||||
}
|
}
|
||||||
else if (result > 0)
|
break;
|
||||||
{ /* Just remember: _bt_binsrch() returns
|
|
||||||
|
case BTLessEqualStrategyNumber:
|
||||||
|
if (result >= 0)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
||||||
|
break;
|
||||||
|
|
||||||
|
offnum = ItemPointerGetOffsetNumber(current);
|
||||||
|
page = BufferGetPage(buf);
|
||||||
|
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||||
|
} while (result >= 0);
|
||||||
|
|
||||||
|
if (result < 0)
|
||||||
|
_bt_twostep(scan, &buf, BackwardScanDirection);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BTEqualStrategyNumber:
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
_bt_relbuf(scan->relation, buf, BT_READ);
|
||||||
|
so->btso_curbuf = InvalidBuffer;
|
||||||
|
ItemPointerSetInvalid(&(scan->currentItemData));
|
||||||
|
return ((RetrieveIndexResult) NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BTGreaterEqualStrategyNumber:
|
||||||
|
if (offGmax)
|
||||||
|
{
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY);
|
||||||
|
if (!_bt_step(scan, &buf, ForwardScanDirection))
|
||||||
|
{
|
||||||
|
_bt_relbuf(scan->relation, buf, BT_READ);
|
||||||
|
so->btso_curbuf = InvalidBuffer;
|
||||||
|
ItemPointerSetInvalid(&(scan->currentItemData));
|
||||||
|
return ((RetrieveIndexResult) NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (result > 0)
|
||||||
|
{ /* Just remember: _bt_binsrch() returns
|
||||||
* the OffsetNumber of the first matching
|
* the OffsetNumber of the first matching
|
||||||
* key on the page, or the OffsetNumber at
|
* key on the page, or the OffsetNumber at
|
||||||
* which the matching key WOULD APPEAR IF
|
* which the matching key WOULD APPEAR IF
|
||||||
@@ -985,41 +985,41 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
|
|||||||
* page, but offnum from _bt_binsrch()
|
* page, but offnum from _bt_binsrch()
|
||||||
* greater maxoff - have to move right. -
|
* greater maxoff - have to move right. -
|
||||||
* vadim 12/06/96 */
|
* vadim 12/06/96 */
|
||||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (result < 0)
|
||||||
else if (result < 0)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
do
|
||||||
break;
|
{
|
||||||
|
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
||||||
|
break;
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
offnum = ItemPointerGetOffsetNumber(current);
|
offnum = ItemPointerGetOffsetNumber(current);
|
||||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||||
} while (result < 0);
|
} while (result < 0);
|
||||||
|
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BTGreaterStrategyNumber:
|
case BTGreaterStrategyNumber:
|
||||||
/* offGmax helps as above */
|
/* offGmax helps as above */
|
||||||
if (result >= 0 || offGmax)
|
if (result >= 0 || offGmax)
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
do
|
||||||
break;
|
{
|
||||||
|
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
||||||
|
break;
|
||||||
|
|
||||||
offnum = ItemPointerGetOffsetNumber(current);
|
offnum = ItemPointerGetOffsetNumber(current);
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||||
} while (result >= 0);
|
} while (result >= 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* okay, current item pointer for the scan is right */
|
/* okay, current item pointer for the scan is right */
|
||||||
@@ -1062,16 +1062,16 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
|
|||||||
bool
|
bool
|
||||||
_bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
_bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
OffsetNumber start;
|
OffsetNumber start;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
BlockNumber obknum;
|
BlockNumber obknum;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
rel = scan->relation;
|
rel = scan->relation;
|
||||||
current = &(scan->currentItemData);
|
current = &(scan->currentItemData);
|
||||||
@@ -1235,20 +1235,20 @@ _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
|||||||
* proper state and acquires a lock and pin on *bufP. If the twostep
|
* proper state and acquires a lock and pin on *bufP. If the twostep
|
||||||
* succeeded, we return true; otherwise, we return false.
|
* succeeded, we return true; otherwise, we return false.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
_bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
_bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
OffsetNumber start;
|
OffsetNumber start;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
int itemsz;
|
int itemsz;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
BTItem svitem;
|
BTItem svitem;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
blkno = BufferGetBlockNumber(*bufP);
|
blkno = BufferGetBlockNumber(*bufP);
|
||||||
page = BufferGetPage(*bufP);
|
page = BufferGetPage(*bufP);
|
||||||
@@ -1333,23 +1333,23 @@ _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
|||||||
/*
|
/*
|
||||||
* _bt_endpoint() -- Find the first or last key in the index.
|
* _bt_endpoint() -- Find the first or last key in the index.
|
||||||
*/
|
*/
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
_bt_endpoint(IndexScanDesc scan, ScanDirection dir)
|
_bt_endpoint(IndexScanDesc scan, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
ItemPointer current;
|
ItemPointer current;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
OffsetNumber start = 0;
|
OffsetNumber start = 0;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
Size keysok;
|
Size keysok;
|
||||||
|
|
||||||
rel = scan->relation;
|
rel = scan->relation;
|
||||||
current = &(scan->currentItemData);
|
current = &(scan->currentItemData);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Id: nbtsort.c,v 1.20 1997/09/07 04:39:02 momjian Exp $
|
* $Id: nbtsort.c,v 1.21 1997/09/08 02:20:58 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@@ -65,14 +65,14 @@
|
|||||||
|
|
||||||
#ifdef BTREE_BUILD_STATS
|
#ifdef BTREE_BUILD_STATS
|
||||||
#include <tcop/tcopprot.h>
|
#include <tcop/tcopprot.h>
|
||||||
extern int ShowExecutorStats;
|
extern int ShowExecutorStats;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags);
|
static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags);
|
||||||
static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend);
|
static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend);
|
||||||
static void *_bt_pagestate(Relation index, int flags, int level, bool doupper);
|
static void *_bt_pagestate(Relation index, int flags, int level, bool doupper);
|
||||||
static void _bt_uppershutdown(Relation index, BTPageState * state);
|
static void _bt_uppershutdown(Relation index, BTPageState * state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* turn on debugging output.
|
* turn on debugging output.
|
||||||
@@ -88,9 +88,9 @@ static void _bt_uppershutdown(Relation index, BTPageState * state);
|
|||||||
#define TAPEBLCKSZ (MAXBLCKSZ << 2)
|
#define TAPEBLCKSZ (MAXBLCKSZ << 2)
|
||||||
#define TAPETEMP "pg_btsortXXXXXX"
|
#define TAPETEMP "pg_btsortXXXXXX"
|
||||||
|
|
||||||
extern int NDirectFileRead;
|
extern int NDirectFileRead;
|
||||||
extern int NDirectFileWrite;
|
extern int NDirectFileWrite;
|
||||||
extern char *mktemp(char *template);
|
extern char *mktemp(char *template);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this is what we use to shovel BTItems in and out of memory. it's
|
* this is what we use to shovel BTItems in and out of memory. it's
|
||||||
@@ -107,13 +107,13 @@ extern char *mktemp(char *template);
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int bttb_magic; /* magic number */
|
int bttb_magic; /* magic number */
|
||||||
int bttb_fd; /* file descriptor */
|
int bttb_fd; /* file descriptor */
|
||||||
int bttb_top; /* top of free space within bttb_data */
|
int bttb_top; /* top of free space within bttb_data */
|
||||||
short bttb_ntup; /* number of tuples in this block */
|
short bttb_ntup; /* number of tuples in this block */
|
||||||
short bttb_eor; /* End-Of-Run marker */
|
short bttb_eor; /* End-Of-Run marker */
|
||||||
char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)];
|
char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)];
|
||||||
} BTTapeBlock;
|
} BTTapeBlock;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this structure holds the bookkeeping for a simple balanced multiway
|
* this structure holds the bookkeeping for a simple balanced multiway
|
||||||
@@ -124,12 +124,12 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int bts_ntapes;
|
int bts_ntapes;
|
||||||
int bts_tape;
|
int bts_tape;
|
||||||
BTTapeBlock **bts_itape; /* input tape blocks */
|
BTTapeBlock **bts_itape; /* input tape blocks */
|
||||||
BTTapeBlock **bts_otape; /* output tape blocks */
|
BTTapeBlock **bts_otape; /* output tape blocks */
|
||||||
bool isunique;
|
bool isunique;
|
||||||
} BTSpool;
|
} BTSpool;
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* sorting comparison routine - returns {-1,0,1} depending on whether
|
* sorting comparison routine - returns {-1,0,1} depending on whether
|
||||||
@@ -151,13 +151,13 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Datum *btsk_datum;
|
Datum *btsk_datum;
|
||||||
char *btsk_nulls;
|
char *btsk_nulls;
|
||||||
BTItem btsk_item;
|
BTItem btsk_item;
|
||||||
} BTSortKey;
|
} BTSortKey;
|
||||||
|
|
||||||
static Relation _bt_sortrel;
|
static Relation _bt_sortrel;
|
||||||
static int _bt_nattr;
|
static int _bt_nattr;
|
||||||
static BTSpool *_bt_inspool;
|
static BTSpool *_bt_inspool;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -171,12 +171,12 @@ _bt_isortcmpinit(Relation index, BTSpool * spool)
|
|||||||
static int
|
static int
|
||||||
_bt_isortcmp(BTSortKey * k1, BTSortKey * k2)
|
_bt_isortcmp(BTSortKey * k1, BTSortKey * k2)
|
||||||
{
|
{
|
||||||
Datum *k1_datum = k1->btsk_datum;
|
Datum *k1_datum = k1->btsk_datum;
|
||||||
Datum *k2_datum = k2->btsk_datum;
|
Datum *k2_datum = k2->btsk_datum;
|
||||||
char *k1_nulls = k1->btsk_nulls;
|
char *k1_nulls = k1->btsk_nulls;
|
||||||
char *k2_nulls = k2->btsk_nulls;
|
char *k2_nulls = k2->btsk_nulls;
|
||||||
bool equal_isnull = false;
|
bool equal_isnull = false;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (k1->btsk_item == (BTItem) NULL)
|
if (k1->btsk_item == (BTItem) NULL)
|
||||||
{
|
{
|
||||||
@@ -226,12 +226,12 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk)
|
|||||||
|
|
||||||
if (bti != (BTItem) NULL)
|
if (bti != (BTItem) NULL)
|
||||||
{
|
{
|
||||||
IndexTuple it = &(bti->bti_itup);
|
IndexTuple it = &(bti->bti_itup);
|
||||||
TupleDesc itdesc = index->rd_att;
|
TupleDesc itdesc = index->rd_att;
|
||||||
Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum));
|
Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum));
|
||||||
char *np = (char *) palloc(_bt_nattr * sizeof(char));
|
char *np = (char *) palloc(_bt_nattr * sizeof(char));
|
||||||
bool isnull;
|
bool isnull;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < _bt_nattr; i++)
|
for (i = 0; i < _bt_nattr; i++)
|
||||||
{
|
{
|
||||||
@@ -260,17 +260,17 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk)
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int btpqe_tape; /* tape identifier */
|
int btpqe_tape; /* tape identifier */
|
||||||
BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */
|
BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */
|
||||||
} BTPriQueueElem;
|
} BTPriQueueElem;
|
||||||
|
|
||||||
#define MAXELEM MAXTAPES
|
#define MAXELEM MAXTAPES
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int btpq_nelem;
|
int btpq_nelem;
|
||||||
BTPriQueueElem btpq_queue[MAXELEM];
|
BTPriQueueElem btpq_queue[MAXELEM];
|
||||||
Relation btpq_rel;
|
Relation btpq_rel;
|
||||||
} BTPriQueue;
|
} BTPriQueue;
|
||||||
|
|
||||||
/* be sure to call _bt_isortcmpinit first */
|
/* be sure to call _bt_isortcmpinit first */
|
||||||
#define GREATER(a, b) \
|
#define GREATER(a, b) \
|
||||||
@@ -279,8 +279,8 @@ typedef struct
|
|||||||
static void
|
static void
|
||||||
_bt_pqsift(BTPriQueue * q, int parent)
|
_bt_pqsift(BTPriQueue * q, int parent)
|
||||||
{
|
{
|
||||||
int child;
|
int child;
|
||||||
BTPriQueueElem e;
|
BTPriQueueElem e;
|
||||||
|
|
||||||
for (child = parent * 2 + 1;
|
for (child = parent * 2 + 1;
|
||||||
child < q->btpq_nelem;
|
child < q->btpq_nelem;
|
||||||
@@ -328,8 +328,8 @@ _bt_pqnext(BTPriQueue * q, BTPriQueueElem * e)
|
|||||||
static void
|
static void
|
||||||
_bt_pqadd(BTPriQueue * q, BTPriQueueElem * e)
|
_bt_pqadd(BTPriQueue * q, BTPriQueueElem * e)
|
||||||
{
|
{
|
||||||
int child,
|
int child,
|
||||||
parent;
|
parent;
|
||||||
|
|
||||||
if (q->btpq_nelem >= MAXELEM)
|
if (q->btpq_nelem >= MAXELEM)
|
||||||
{
|
{
|
||||||
@@ -422,7 +422,7 @@ _bt_tapeclear(BTTapeBlock * tape)
|
|||||||
static BTTapeBlock *
|
static BTTapeBlock *
|
||||||
_bt_tapecreate(char *fname)
|
_bt_tapecreate(char *fname)
|
||||||
{
|
{
|
||||||
BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock));
|
BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock));
|
||||||
|
|
||||||
if (tape == (BTTapeBlock *) NULL)
|
if (tape == (BTTapeBlock *) NULL)
|
||||||
{
|
{
|
||||||
@@ -474,8 +474,8 @@ _bt_tapewrite(BTTapeBlock * tape, int eor)
|
|||||||
static int
|
static int
|
||||||
_bt_taperead(BTTapeBlock * tape)
|
_bt_taperead(BTTapeBlock * tape)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int nread;
|
int nread;
|
||||||
|
|
||||||
if (tape->bttb_eor)
|
if (tape->bttb_eor)
|
||||||
{
|
{
|
||||||
@@ -510,11 +510,11 @@ _bt_taperead(BTTapeBlock * tape)
|
|||||||
* side effects:
|
* side effects:
|
||||||
* - sets 'pos' to the current position within the block.
|
* - sets 'pos' to the current position within the block.
|
||||||
*/
|
*/
|
||||||
static BTItem
|
static BTItem
|
||||||
_bt_tapenext(BTTapeBlock * tape, char **pos)
|
_bt_tapenext(BTTapeBlock * tape, char **pos)
|
||||||
{
|
{
|
||||||
Size itemsz;
|
Size itemsz;
|
||||||
BTItem bti;
|
BTItem bti;
|
||||||
|
|
||||||
if (*pos >= tape->bttb_data + tape->bttb_top)
|
if (*pos >= tape->bttb_data + tape->bttb_top)
|
||||||
{
|
{
|
||||||
@@ -554,12 +554,12 @@ _bt_tapeadd(BTTapeBlock * tape, BTItem item, int itemsz)
|
|||||||
* create and initialize a spool structure, including the underlying
|
* create and initialize a spool structure, including the underlying
|
||||||
* files.
|
* files.
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
_bt_spoolinit(Relation index, int ntapes, bool isunique)
|
_bt_spoolinit(Relation index, int ntapes, bool isunique)
|
||||||
{
|
{
|
||||||
BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool));
|
BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool));
|
||||||
int i;
|
int i;
|
||||||
char *fname = (char *) palloc(sizeof(TAPETEMP) + 1);
|
char *fname = (char *) palloc(sizeof(TAPETEMP) + 1);
|
||||||
|
|
||||||
if (btspool == (BTSpool *) NULL || fname == (char *) NULL)
|
if (btspool == (BTSpool *) NULL || fname == (char *) NULL)
|
||||||
{
|
{
|
||||||
@@ -600,8 +600,8 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique)
|
|||||||
void
|
void
|
||||||
_bt_spooldestroy(void *spool)
|
_bt_spooldestroy(void *spool)
|
||||||
{
|
{
|
||||||
BTSpool *btspool = (BTSpool *) spool;
|
BTSpool *btspool = (BTSpool *) spool;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < btspool->bts_ntapes; ++i)
|
for (i = 0; i < btspool->bts_ntapes; ++i)
|
||||||
{
|
{
|
||||||
@@ -617,7 +617,7 @@ _bt_spooldestroy(void *spool)
|
|||||||
static void
|
static void
|
||||||
_bt_spoolflush(BTSpool * btspool)
|
_bt_spoolflush(BTSpool * btspool)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < btspool->bts_ntapes; ++i)
|
for (i = 0; i < btspool->bts_ntapes; ++i)
|
||||||
{
|
{
|
||||||
@@ -637,10 +637,10 @@ _bt_spoolflush(BTSpool * btspool)
|
|||||||
static void
|
static void
|
||||||
_bt_spoolswap(BTSpool * btspool)
|
_bt_spoolswap(BTSpool * btspool)
|
||||||
{
|
{
|
||||||
File tmpfd;
|
File tmpfd;
|
||||||
BTTapeBlock *itape;
|
BTTapeBlock *itape;
|
||||||
BTTapeBlock *otape;
|
BTTapeBlock *otape;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < btspool->bts_ntapes; ++i)
|
for (i = 0; i < btspool->bts_ntapes; ++i)
|
||||||
{
|
{
|
||||||
@@ -682,9 +682,9 @@ _bt_spoolswap(BTSpool * btspool)
|
|||||||
void
|
void
|
||||||
_bt_spool(Relation index, BTItem btitem, void *spool)
|
_bt_spool(Relation index, BTItem btitem, void *spool)
|
||||||
{
|
{
|
||||||
BTSpool *btspool = (BTSpool *) spool;
|
BTSpool *btspool = (BTSpool *) spool;
|
||||||
BTTapeBlock *itape;
|
BTTapeBlock *itape;
|
||||||
Size itemsz;
|
Size itemsz;
|
||||||
|
|
||||||
_bt_isortcmpinit(index, btspool);
|
_bt_isortcmpinit(index, btspool);
|
||||||
|
|
||||||
@@ -699,13 +699,13 @@ _bt_spool(Relation index, BTItem btitem, void *spool)
|
|||||||
*/
|
*/
|
||||||
if (btitem == (BTItem) NULL || SPCLEFT(itape) < itemsz)
|
if (btitem == (BTItem) NULL || SPCLEFT(itape) < itemsz)
|
||||||
{
|
{
|
||||||
BTSortKey *parray = (BTSortKey *) NULL;
|
BTSortKey *parray = (BTSortKey *) NULL;
|
||||||
BTTapeBlock *otape;
|
BTTapeBlock *otape;
|
||||||
BTItem bti;
|
BTItem bti;
|
||||||
char *pos;
|
char *pos;
|
||||||
int btisz;
|
int btisz;
|
||||||
int it_ntup = itape->bttb_ntup;
|
int it_ntup = itape->bttb_ntup;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* build an array of pointers to the BTItemDatas on the input
|
* build an array of pointers to the BTItemDatas on the input
|
||||||
@@ -745,9 +745,9 @@ _bt_spool(Relation index, BTItem btitem, void *spool)
|
|||||||
_bt_tapeadd(otape, bti, btisz);
|
_bt_tapeadd(otape, bti, btisz);
|
||||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_SPOOL)
|
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_SPOOL)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att,
|
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att,
|
||||||
&isnull);
|
&isnull);
|
||||||
|
|
||||||
printf("_bt_spool: inserted <%x> into output tape %d\n",
|
printf("_bt_spool: inserted <%x> into output tape %d\n",
|
||||||
d, btspool->bts_tape);
|
d, btspool->bts_tape);
|
||||||
@@ -802,7 +802,7 @@ _bt_spool(Relation index, BTItem btitem, void *spool)
|
|||||||
static void
|
static void
|
||||||
_bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags)
|
_bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags)
|
||||||
{
|
{
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
|
|
||||||
*buf = _bt_getbuf(index, P_NEW, BT_WRITE);
|
*buf = _bt_getbuf(index, P_NEW, BT_WRITE);
|
||||||
#if 0
|
#if 0
|
||||||
@@ -824,10 +824,10 @@ _bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags)
|
|||||||
static void
|
static void
|
||||||
_bt_slideleft(Relation index, Buffer buf, Page page)
|
_bt_slideleft(Relation index, Buffer buf, Page page)
|
||||||
{
|
{
|
||||||
OffsetNumber off;
|
OffsetNumber off;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
ItemId previi;
|
ItemId previi;
|
||||||
ItemId thisii;
|
ItemId thisii;
|
||||||
|
|
||||||
if (!PageIsEmpty(page))
|
if (!PageIsEmpty(page))
|
||||||
{
|
{
|
||||||
@@ -847,10 +847,10 @@ _bt_slideleft(Relation index, Buffer buf, Page page)
|
|||||||
* allocate and initialize a new BTPageState. the returned structure
|
* allocate and initialize a new BTPageState. the returned structure
|
||||||
* is suitable for immediate use by _bt_buildadd.
|
* is suitable for immediate use by _bt_buildadd.
|
||||||
*/
|
*/
|
||||||
static void *
|
static void *
|
||||||
_bt_pagestate(Relation index, int flags, int level, bool doupper)
|
_bt_pagestate(Relation index, int flags, int level, bool doupper)
|
||||||
{
|
{
|
||||||
BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState));
|
BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState));
|
||||||
|
|
||||||
memset((char *) state, 0, sizeof(BTPageState));
|
memset((char *) state, 0, sizeof(BTPageState));
|
||||||
_bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags);
|
_bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags);
|
||||||
@@ -870,12 +870,12 @@ _bt_pagestate(Relation index, int flags, int level, bool doupper)
|
|||||||
* the page to which the item used to point, e.g., a heap page if
|
* the page to which the item used to point, e.g., a heap page if
|
||||||
* 'opage' is a leaf page).
|
* 'opage' is a leaf page).
|
||||||
*/
|
*/
|
||||||
static BTItem
|
static BTItem
|
||||||
_bt_minitem(Page opage, BlockNumber oblkno, int atend)
|
_bt_minitem(Page opage, BlockNumber oblkno, int atend)
|
||||||
{
|
{
|
||||||
OffsetNumber off;
|
OffsetNumber off;
|
||||||
BTItem obti;
|
BTItem obti;
|
||||||
BTItem nbti;
|
BTItem nbti;
|
||||||
|
|
||||||
off = atend ? P_HIKEY : P_FIRSTKEY;
|
off = atend ? P_HIKEY : P_FIRSTKEY;
|
||||||
obti = (BTItem) PageGetItem(opage, PageGetItemId(opage, off));
|
obti = (BTItem) PageGetItem(opage, PageGetItemId(opage, off));
|
||||||
@@ -924,18 +924,18 @@ _bt_minitem(Page opage, BlockNumber oblkno, int atend)
|
|||||||
*
|
*
|
||||||
* if all keys are unique, 'first' will always be the same as 'last'.
|
* if all keys are unique, 'first' will always be the same as 'last'.
|
||||||
*/
|
*/
|
||||||
static BTItem
|
static BTItem
|
||||||
_bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
_bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||||
{
|
{
|
||||||
BTPageState *state = (BTPageState *) pstate;
|
BTPageState *state = (BTPageState *) pstate;
|
||||||
Buffer nbuf;
|
Buffer nbuf;
|
||||||
Page npage;
|
Page npage;
|
||||||
BTItem last_bti;
|
BTItem last_bti;
|
||||||
OffsetNumber first_off;
|
OffsetNumber first_off;
|
||||||
OffsetNumber last_off;
|
OffsetNumber last_off;
|
||||||
OffsetNumber off;
|
OffsetNumber off;
|
||||||
Size pgspc;
|
Size pgspc;
|
||||||
Size btisz;
|
Size btisz;
|
||||||
|
|
||||||
nbuf = state->btps_buf;
|
nbuf = state->btps_buf;
|
||||||
npage = state->btps_page;
|
npage = state->btps_page;
|
||||||
@@ -948,12 +948,12 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
|||||||
btisz = DOUBLEALIGN(btisz);
|
btisz = DOUBLEALIGN(btisz);
|
||||||
if (pgspc < btisz)
|
if (pgspc < btisz)
|
||||||
{
|
{
|
||||||
Buffer obuf = nbuf;
|
Buffer obuf = nbuf;
|
||||||
Page opage = npage;
|
Page opage = npage;
|
||||||
OffsetNumber o,
|
OffsetNumber o,
|
||||||
n;
|
n;
|
||||||
ItemId ii;
|
ItemId ii;
|
||||||
ItemId hii;
|
ItemId hii;
|
||||||
|
|
||||||
_bt_blnewpage(index, &nbuf, &npage, flags);
|
_bt_blnewpage(index, &nbuf, &npage, flags);
|
||||||
|
|
||||||
@@ -989,11 +989,11 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
|||||||
#if 0
|
#if 0
|
||||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
BTItem tmpbti =
|
BTItem tmpbti =
|
||||||
(BTItem) PageGetItem(npage, PageGetItemId(npage, n));
|
(BTItem) PageGetItem(npage, PageGetItemId(npage, n));
|
||||||
Datum d = index_getattr(&(tmpbti->bti_itup), 1,
|
Datum d = index_getattr(&(tmpbti->bti_itup), 1,
|
||||||
index->rd_att, &isnull);
|
index->rd_att, &isnull);
|
||||||
|
|
||||||
printf("_bt_buildadd: moved <%x> to offset %d at level %d\n",
|
printf("_bt_buildadd: moved <%x> to offset %d at level %d\n",
|
||||||
d, n, state->btps_level);
|
d, n, state->btps_level);
|
||||||
@@ -1026,8 +1026,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
|||||||
* set the page (side link) pointers.
|
* set the page (side link) pointers.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage);
|
BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage);
|
||||||
BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage);
|
BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage);
|
||||||
|
|
||||||
oopaque->btpo_next = BufferGetBlockNumber(nbuf);
|
oopaque->btpo_next = BufferGetBlockNumber(nbuf);
|
||||||
nopaque->btpo_prev = BufferGetBlockNumber(obuf);
|
nopaque->btpo_prev = BufferGetBlockNumber(obuf);
|
||||||
@@ -1047,7 +1047,7 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
|||||||
*/
|
*/
|
||||||
if (state->btps_doupper)
|
if (state->btps_doupper)
|
||||||
{
|
{
|
||||||
BTItem nbti;
|
BTItem nbti;
|
||||||
|
|
||||||
if (state->btps_next == (BTPageState *) NULL)
|
if (state->btps_next == (BTPageState *) NULL)
|
||||||
{
|
{
|
||||||
@@ -1077,8 +1077,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
|||||||
#if 0
|
#if 0
|
||||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull);
|
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull);
|
||||||
|
|
||||||
printf("_bt_buildadd: inserted <%x> at offset %d at level %d\n",
|
printf("_bt_buildadd: inserted <%x> at offset %d at level %d\n",
|
||||||
d, off, state->btps_level);
|
d, off, state->btps_level);
|
||||||
@@ -1109,10 +1109,10 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
|||||||
static void
|
static void
|
||||||
_bt_uppershutdown(Relation index, BTPageState * state)
|
_bt_uppershutdown(Relation index, BTPageState * state)
|
||||||
{
|
{
|
||||||
BTPageState *s;
|
BTPageState *s;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
BTPageOpaque opaque;
|
BTPageOpaque opaque;
|
||||||
BTItem bti;
|
BTItem bti;
|
||||||
|
|
||||||
for (s = state; s != (BTPageState *) NULL; s = s->btps_next)
|
for (s = state; s != (BTPageState *) NULL; s = s->btps_next)
|
||||||
{
|
{
|
||||||
@@ -1160,21 +1160,21 @@ _bt_uppershutdown(Relation index, BTPageState * state)
|
|||||||
static void
|
static void
|
||||||
_bt_merge(Relation index, BTSpool * btspool)
|
_bt_merge(Relation index, BTSpool * btspool)
|
||||||
{
|
{
|
||||||
BTPageState *state;
|
BTPageState *state;
|
||||||
BTPriQueue q;
|
BTPriQueue q;
|
||||||
BTPriQueueElem e;
|
BTPriQueueElem e;
|
||||||
BTSortKey btsk;
|
BTSortKey btsk;
|
||||||
BTItem bti;
|
BTItem bti;
|
||||||
BTTapeBlock *itape;
|
BTTapeBlock *itape;
|
||||||
BTTapeBlock *otape;
|
BTTapeBlock *otape;
|
||||||
char *tapepos[MAXTAPES];
|
char *tapepos[MAXTAPES];
|
||||||
int tapedone[MAXTAPES];
|
int tapedone[MAXTAPES];
|
||||||
int t;
|
int t;
|
||||||
int goodtapes;
|
int goodtapes;
|
||||||
int npass;
|
int npass;
|
||||||
int nruns;
|
int nruns;
|
||||||
Size btisz;
|
Size btisz;
|
||||||
bool doleaf = false;
|
bool doleaf = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize state needed for the merge into the btree leaf pages.
|
* initialize state needed for the merge into the btree leaf pages.
|
||||||
@@ -1279,8 +1279,8 @@ _bt_merge(Relation index, BTSpool * btspool)
|
|||||||
_bt_buildadd(index, state, bti, BTP_LEAF);
|
_bt_buildadd(index, state, bti, BTP_LEAF);
|
||||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Datum d = index_getattr(&(bti->bti_itup), 1,
|
Datum d = index_getattr(&(bti->bti_itup), 1,
|
||||||
index->rd_att, &isnull);
|
index->rd_att, &isnull);
|
||||||
|
|
||||||
printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into block %d\n",
|
printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into block %d\n",
|
||||||
@@ -1308,8 +1308,8 @@ _bt_merge(Relation index, BTSpool * btspool)
|
|||||||
_bt_tapeadd(otape, bti, btisz);
|
_bt_tapeadd(otape, bti, btisz);
|
||||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Datum d = index_getattr(&(bti->bti_itup), 1,
|
Datum d = index_getattr(&(bti->bti_itup), 1,
|
||||||
index->rd_att, &isnull);
|
index->rd_att, &isnull);
|
||||||
|
|
||||||
printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into output tape %d\n",
|
printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into output tape %d\n",
|
||||||
@@ -1328,7 +1328,7 @@ _bt_merge(Relation index, BTSpool * btspool)
|
|||||||
itape = btspool->bts_itape[t];
|
itape = btspool->bts_itape[t];
|
||||||
if (!tapedone[t])
|
if (!tapedone[t])
|
||||||
{
|
{
|
||||||
BTItem newbti = _bt_tapenext(itape, &tapepos[t]);
|
BTItem newbti = _bt_tapenext(itape, &tapepos[t]);
|
||||||
|
|
||||||
if (newbti == (BTItem) NULL)
|
if (newbti == (BTItem) NULL)
|
||||||
{
|
{
|
||||||
@@ -1347,7 +1347,7 @@ _bt_merge(Relation index, BTSpool * btspool)
|
|||||||
}
|
}
|
||||||
if (newbti != (BTItem) NULL)
|
if (newbti != (BTItem) NULL)
|
||||||
{
|
{
|
||||||
BTPriQueueElem nexte;
|
BTPriQueueElem nexte;
|
||||||
|
|
||||||
nexte.btpqe_tape = t;
|
nexte.btpqe_tape = t;
|
||||||
_bt_setsortkey(index, newbti, &(nexte.btpqe_item));
|
_bt_setsortkey(index, newbti, &(nexte.btpqe_item));
|
||||||
@@ -1397,12 +1397,12 @@ _bt_merge(Relation index, BTSpool * btspool)
|
|||||||
void
|
void
|
||||||
_bt_upperbuild(Relation index)
|
_bt_upperbuild(Relation index)
|
||||||
{
|
{
|
||||||
Buffer rbuf;
|
Buffer rbuf;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
Page rpage;
|
Page rpage;
|
||||||
BTPageOpaque ropaque;
|
BTPageOpaque ropaque;
|
||||||
BTPageState *state;
|
BTPageState *state;
|
||||||
BTItem nbti;
|
BTItem nbti;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find the first leaf block. while we're at it, clear the BTP_ROOT
|
* find the first leaf block. while we're at it, clear the BTP_ROOT
|
||||||
@@ -1438,9 +1438,9 @@ _bt_upperbuild(Relation index)
|
|||||||
nbti = _bt_minitem(rpage, blk, P_RIGHTMOST(ropaque));
|
nbti = _bt_minitem(rpage, blk, P_RIGHTMOST(ropaque));
|
||||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att,
|
Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att,
|
||||||
&isnull);
|
&isnull);
|
||||||
|
|
||||||
printf("_bt_upperbuild: inserting <%x> at %d\n",
|
printf("_bt_upperbuild: inserting <%x> at %d\n",
|
||||||
d, state->btps_level);
|
d, state->btps_level);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.5 1997/09/07 04:39:04 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.6 1997/09/08 02:20:59 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +47,7 @@ static StrategyNumber BTNegateCommute[5] = {
|
|||||||
BTGreaterEqualStrategyNumber
|
BTGreaterEqualStrategyNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16 BTLessTermData[] = { /* XXX type clash */
|
static uint16 BTLessTermData[] = { /* XXX type clash */
|
||||||
2,
|
2,
|
||||||
BTLessStrategyNumber,
|
BTLessStrategyNumber,
|
||||||
SK_NEGATE,
|
SK_NEGATE,
|
||||||
@@ -55,7 +55,7 @@ static uint16 BTLessTermData[] = { /* XXX type clash */
|
|||||||
SK_NEGATE | SK_COMMUTE
|
SK_NEGATE | SK_COMMUTE
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16 BTLessEqualTermData[] = { /* XXX type clash */
|
static uint16 BTLessEqualTermData[] = { /* XXX type clash */
|
||||||
2,
|
2,
|
||||||
BTLessEqualStrategyNumber,
|
BTLessEqualStrategyNumber,
|
||||||
0x0,
|
0x0,
|
||||||
@@ -63,7 +63,7 @@ static uint16 BTLessEqualTermData[] = { /* XXX type clash */
|
|||||||
SK_COMMUTE
|
SK_COMMUTE
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */
|
static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */
|
||||||
2,
|
2,
|
||||||
BTGreaterEqualStrategyNumber,
|
BTGreaterEqualStrategyNumber,
|
||||||
0x0,
|
0x0,
|
||||||
@@ -71,7 +71,7 @@ static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */
|
|||||||
SK_COMMUTE
|
SK_COMMUTE
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16 BTGreaterTermData[] = { /* XXX type clash */
|
static uint16 BTGreaterTermData[] = { /* XXX type clash */
|
||||||
2,
|
2,
|
||||||
BTGreaterStrategyNumber,
|
BTGreaterStrategyNumber,
|
||||||
SK_NEGATE,
|
SK_NEGATE,
|
||||||
@@ -109,7 +109,7 @@ _bt_getstrat(Relation rel,
|
|||||||
AttrNumber attno,
|
AttrNumber attno,
|
||||||
RegProcedure proc)
|
RegProcedure proc)
|
||||||
{
|
{
|
||||||
StrategyNumber strat;
|
StrategyNumber strat;
|
||||||
|
|
||||||
strat = RelationGetStrategy(rel, attno, &BTEvaluationData, proc);
|
strat = RelationGetStrategy(rel, attno, &BTEvaluationData, proc);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.12 1997/09/07 04:39:05 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.13 1997/09/08 02:21:01 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <catalog/pg_proc.h>
|
#include <catalog/pg_proc.h>
|
||||||
#include <executor/execdebug.h>
|
#include <executor/execdebug.h>
|
||||||
|
|
||||||
extern int NIndexTupleProcessed;
|
extern int NIndexTupleProcessed;
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_MEMMOVE
|
#ifndef HAVE_MEMMOVE
|
||||||
@@ -35,14 +35,14 @@ extern int NIndexTupleProcessed;
|
|||||||
ScanKey
|
ScanKey
|
||||||
_bt_mkscankey(Relation rel, IndexTuple itup)
|
_bt_mkscankey(Relation rel, IndexTuple itup)
|
||||||
{
|
{
|
||||||
ScanKey skey;
|
ScanKey skey;
|
||||||
TupleDesc itupdesc;
|
TupleDesc itupdesc;
|
||||||
int natts;
|
int natts;
|
||||||
int i;
|
int i;
|
||||||
Datum arg;
|
Datum arg;
|
||||||
RegProcedure proc;
|
RegProcedure proc;
|
||||||
bool null;
|
bool null;
|
||||||
bits16 flag;
|
bits16 flag;
|
||||||
|
|
||||||
natts = rel->rd_rel->relnatts;
|
natts = rel->rd_rel->relnatts;
|
||||||
itupdesc = RelationGetTupleDescriptor(rel);
|
itupdesc = RelationGetTupleDescriptor(rel);
|
||||||
@@ -78,7 +78,7 @@ _bt_freeskey(ScanKey skey)
|
|||||||
void
|
void
|
||||||
_bt_freestack(BTStack stack)
|
_bt_freestack(BTStack stack)
|
||||||
{
|
{
|
||||||
BTStack ostack;
|
BTStack ostack;
|
||||||
|
|
||||||
while (stack != (BTStack) NULL)
|
while (stack != (BTStack) NULL)
|
||||||
{
|
{
|
||||||
@@ -99,18 +99,18 @@ _bt_freestack(BTStack stack)
|
|||||||
void
|
void
|
||||||
_bt_orderkeys(Relation relation, BTScanOpaque so)
|
_bt_orderkeys(Relation relation, BTScanOpaque so)
|
||||||
{
|
{
|
||||||
ScanKey xform;
|
ScanKey xform;
|
||||||
ScanKeyData *cur;
|
ScanKeyData *cur;
|
||||||
StrategyMap map;
|
StrategyMap map;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
long test;
|
long test;
|
||||||
int i,
|
int i,
|
||||||
j;
|
j;
|
||||||
int init[BTMaxStrategyNumber + 1];
|
int init[BTMaxStrategyNumber + 1];
|
||||||
ScanKey key;
|
ScanKey key;
|
||||||
uint16 numberOfKeys = so->numberOfKeys;
|
uint16 numberOfKeys = so->numberOfKeys;
|
||||||
uint16 new_numberOfKeys = 0;
|
uint16 new_numberOfKeys = 0;
|
||||||
AttrNumber attno = 1;
|
AttrNumber attno = 1;
|
||||||
|
|
||||||
if (numberOfKeys < 1)
|
if (numberOfKeys < 1)
|
||||||
return;
|
return;
|
||||||
@@ -169,8 +169,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
|||||||
*/
|
*/
|
||||||
if (init[BTEqualStrategyNumber - 1])
|
if (init[BTEqualStrategyNumber - 1])
|
||||||
{
|
{
|
||||||
ScanKeyData *eq,
|
ScanKeyData *eq,
|
||||||
*chk;
|
*chk;
|
||||||
|
|
||||||
eq = &xform[BTEqualStrategyNumber - 1];
|
eq = &xform[BTEqualStrategyNumber - 1];
|
||||||
for (j = BTMaxStrategyNumber; --j >= 0;)
|
for (j = BTMaxStrategyNumber; --j >= 0;)
|
||||||
@@ -192,8 +192,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
|||||||
if (init[BTLessStrategyNumber - 1]
|
if (init[BTLessStrategyNumber - 1]
|
||||||
&& init[BTLessEqualStrategyNumber - 1])
|
&& init[BTLessEqualStrategyNumber - 1])
|
||||||
{
|
{
|
||||||
ScanKeyData *lt,
|
ScanKeyData *lt,
|
||||||
*le;
|
*le;
|
||||||
|
|
||||||
lt = &xform[BTLessStrategyNumber - 1];
|
lt = &xform[BTLessStrategyNumber - 1];
|
||||||
le = &xform[BTLessEqualStrategyNumber - 1];
|
le = &xform[BTLessEqualStrategyNumber - 1];
|
||||||
@@ -216,8 +216,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
|||||||
if (init[BTGreaterStrategyNumber - 1]
|
if (init[BTGreaterStrategyNumber - 1]
|
||||||
&& init[BTGreaterEqualStrategyNumber - 1])
|
&& init[BTGreaterEqualStrategyNumber - 1])
|
||||||
{
|
{
|
||||||
ScanKeyData *gt,
|
ScanKeyData *gt,
|
||||||
*ge;
|
*ge;
|
||||||
|
|
||||||
gt = &xform[BTGreaterStrategyNumber - 1];
|
gt = &xform[BTGreaterStrategyNumber - 1];
|
||||||
ge = &xform[BTGreaterEqualStrategyNumber - 1];
|
ge = &xform[BTGreaterEqualStrategyNumber - 1];
|
||||||
@@ -288,10 +288,10 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
|||||||
BTItem
|
BTItem
|
||||||
_bt_formitem(IndexTuple itup)
|
_bt_formitem(IndexTuple itup)
|
||||||
{
|
{
|
||||||
int nbytes_btitem;
|
int nbytes_btitem;
|
||||||
BTItem btitem;
|
BTItem btitem;
|
||||||
Size tuplen;
|
Size tuplen;
|
||||||
extern Oid newoid();
|
extern Oid newoid();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see comments in btbuild
|
* see comments in btbuild
|
||||||
@@ -318,7 +318,7 @@ _bt_formitem(IndexTuple itup)
|
|||||||
bool
|
bool
|
||||||
_bt_checkqual(IndexScanDesc scan, IndexTuple itup)
|
_bt_checkqual(IndexScanDesc scan, IndexTuple itup)
|
||||||
{
|
{
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
if (so->numberOfKeys > 0)
|
if (so->numberOfKeys > 0)
|
||||||
@@ -334,7 +334,7 @@ _bt_checkqual(IndexScanDesc scan, IndexTuple itup)
|
|||||||
bool
|
bool
|
||||||
_bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz)
|
_bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz)
|
||||||
{
|
{
|
||||||
BTScanOpaque so;
|
BTScanOpaque so;
|
||||||
|
|
||||||
so = (BTScanOpaque) scan->opaque;
|
so = (BTScanOpaque) scan->opaque;
|
||||||
if (keysz > 0 && so->numberOfKeys >= keysz)
|
if (keysz > 0 && so->numberOfKeys >= keysz)
|
||||||
@@ -349,13 +349,13 @@ _bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz)
|
|||||||
bool
|
bool
|
||||||
_bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size * keysok)
|
_bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size * keysok)
|
||||||
{
|
{
|
||||||
BTScanOpaque so = (BTScanOpaque) scan->opaque;
|
BTScanOpaque so = (BTScanOpaque) scan->opaque;
|
||||||
Size keysz = so->numberOfKeys;
|
Size keysz = so->numberOfKeys;
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
ScanKey key;
|
ScanKey key;
|
||||||
Datum datum;
|
Datum datum;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
int test;
|
int test;
|
||||||
|
|
||||||
*keysok = 0;
|
*keysok = 0;
|
||||||
if (keysz == 0)
|
if (keysz == 0)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.8 1997/09/07 04:39:11 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.9 1997/09/08 02:21:03 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -57,19 +57,19 @@ rtgettuple(IndexScanDesc s, ScanDirection dir)
|
|||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
rtfirst(IndexScanDesc s, ScanDirection dir)
|
rtfirst(IndexScanDesc s, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
OffsetNumber n;
|
OffsetNumber n;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
RTreePageOpaque po;
|
RTreePageOpaque po;
|
||||||
RTreeScanOpaque so;
|
RTreeScanOpaque so;
|
||||||
RTSTACK *stk;
|
RTSTACK *stk;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
IndexTuple it;
|
IndexTuple it;
|
||||||
|
|
||||||
b = ReadBuffer(s->relation, P_ROOT);
|
b = ReadBuffer(s->relation, P_ROOT);
|
||||||
p = BufferGetPage(b);
|
p = BufferGetPage(b);
|
||||||
@@ -140,19 +140,19 @@ rtfirst(IndexScanDesc s, ScanDirection dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
rtnext(IndexScanDesc s, ScanDirection dir)
|
rtnext(IndexScanDesc s, ScanDirection dir)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
OffsetNumber n;
|
OffsetNumber n;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
RTreePageOpaque po;
|
RTreePageOpaque po;
|
||||||
RTreeScanOpaque so;
|
RTreeScanOpaque so;
|
||||||
RTSTACK *stk;
|
RTSTACK *stk;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
IndexTuple it;
|
IndexTuple it;
|
||||||
|
|
||||||
blk = ItemPointerGetBlockNumber(&(s->currentItemData));
|
blk = ItemPointerGetBlockNumber(&(s->currentItemData));
|
||||||
n = ItemPointerGetOffsetNumber(&(s->currentItemData));
|
n = ItemPointerGetOffsetNumber(&(s->currentItemData));
|
||||||
@@ -241,11 +241,11 @@ rtnext(IndexScanDesc s, ScanDirection dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
findnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
|
findnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
|
||||||
{
|
{
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
IndexTuple it;
|
IndexTuple it;
|
||||||
RTreePageOpaque po;
|
RTreePageOpaque po;
|
||||||
RTreeScanOpaque so;
|
RTreeScanOpaque so;
|
||||||
|
|
||||||
@@ -295,11 +295,11 @@ findnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
|
|||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RetrieveIndexResult
|
static RetrieveIndexResult
|
||||||
rtscancache(IndexScanDesc s, ScanDirection dir)
|
rtscancache(IndexScanDesc s, ScanDirection dir)
|
||||||
{
|
{
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
ItemPointer ip;
|
ItemPointer ip;
|
||||||
|
|
||||||
if (!(ScanDirectionIsNoMovement(dir)
|
if (!(ScanDirectionIsNoMovement(dir)
|
||||||
&& ItemPointerIsValid(&(s->currentItemData))))
|
&& ItemPointerIsValid(&(s->currentItemData))))
|
||||||
@@ -324,14 +324,14 @@ rtscancache(IndexScanDesc s, ScanDirection dir)
|
|||||||
* rtheapptr returns the item pointer to the tuple in the heap relation
|
* rtheapptr returns the item pointer to the tuple in the heap relation
|
||||||
* for which itemp is the index relation item pointer.
|
* for which itemp is the index relation item pointer.
|
||||||
*/
|
*/
|
||||||
static ItemPointer
|
static ItemPointer
|
||||||
rtheapptr(Relation r, ItemPointer itemp)
|
rtheapptr(Relation r, ItemPointer itemp)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
IndexTuple it;
|
IndexTuple it;
|
||||||
ItemPointer ip;
|
ItemPointer ip;
|
||||||
OffsetNumber n;
|
OffsetNumber n;
|
||||||
|
|
||||||
ip = (ItemPointer) palloc(sizeof(ItemPointerData));
|
ip = (ItemPointer) palloc(sizeof(ItemPointerData));
|
||||||
if (ItemPointerIsValid(itemp))
|
if (ItemPointerIsValid(itemp))
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.8 1997/09/07 04:39:16 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.9 1997/09/08 02:21:05 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
BOX
|
BOX
|
||||||
* rt_box_union(BOX * a, BOX * b)
|
* rt_box_union(BOX * a, BOX * b)
|
||||||
{
|
{
|
||||||
BOX *n;
|
BOX *n;
|
||||||
|
|
||||||
if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL)
|
if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL)
|
||||||
elog(WARN, "Cannot allocate box for union");
|
elog(WARN, "Cannot allocate box for union");
|
||||||
@@ -38,10 +38,10 @@ BOX
|
|||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOX *
|
BOX *
|
||||||
rt_box_inter(BOX * a, BOX * b)
|
rt_box_inter(BOX * a, BOX * b)
|
||||||
{
|
{
|
||||||
BOX *n;
|
BOX *n;
|
||||||
|
|
||||||
if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL)
|
if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL)
|
||||||
elog(WARN, "Cannot allocate box for union");
|
elog(WARN, "Cannot allocate box for union");
|
||||||
@@ -85,10 +85,10 @@ rt_bigbox_size(BOX * a, float *size)
|
|||||||
rt_box_size(a, size);
|
rt_box_size(a, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
POLYGON *
|
POLYGON *
|
||||||
rt_poly_union(POLYGON * a, POLYGON * b)
|
rt_poly_union(POLYGON * a, POLYGON * b)
|
||||||
{
|
{
|
||||||
POLYGON *p;
|
POLYGON *p;
|
||||||
|
|
||||||
p = (POLYGON *) PALLOCTYPE(POLYGON);
|
p = (POLYGON *) PALLOCTYPE(POLYGON);
|
||||||
|
|
||||||
@@ -108,8 +108,8 @@ rt_poly_union(POLYGON * a, POLYGON * b)
|
|||||||
void
|
void
|
||||||
rt_poly_size(POLYGON * a, float *size)
|
rt_poly_size(POLYGON * a, float *size)
|
||||||
{
|
{
|
||||||
double xdim,
|
double xdim,
|
||||||
ydim;
|
ydim;
|
||||||
|
|
||||||
size = (float *) palloc(sizeof(float));
|
size = (float *) palloc(sizeof(float));
|
||||||
if (a == (POLYGON *) NULL ||
|
if (a == (POLYGON *) NULL ||
|
||||||
@@ -127,10 +127,10 @@ rt_poly_size(POLYGON * a, float *size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
POLYGON *
|
POLYGON *
|
||||||
rt_poly_inter(POLYGON * a, POLYGON * b)
|
rt_poly_inter(POLYGON * a, POLYGON * b)
|
||||||
{
|
{
|
||||||
POLYGON *p;
|
POLYGON *p;
|
||||||
|
|
||||||
p = (POLYGON *) PALLOCTYPE(POLYGON);
|
p = (POLYGON *) PALLOCTYPE(POLYGON);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.14 1997/09/07 04:39:22 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.15 1997/09/08 02:21:06 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -34,20 +34,20 @@
|
|||||||
|
|
||||||
typedef struct SPLITVEC
|
typedef struct SPLITVEC
|
||||||
{
|
{
|
||||||
OffsetNumber *spl_left;
|
OffsetNumber *spl_left;
|
||||||
int spl_nleft;
|
int spl_nleft;
|
||||||
char *spl_ldatum;
|
char *spl_ldatum;
|
||||||
OffsetNumber *spl_right;
|
OffsetNumber *spl_right;
|
||||||
int spl_nright;
|
int spl_nright;
|
||||||
char *spl_rdatum;
|
char *spl_rdatum;
|
||||||
} SPLITVEC;
|
} SPLITVEC;
|
||||||
|
|
||||||
typedef struct RTSTATE
|
typedef struct RTSTATE
|
||||||
{
|
{
|
||||||
func_ptr unionFn; /* union function */
|
func_ptr unionFn; /* union function */
|
||||||
func_ptr sizeFn; /* size function */
|
func_ptr sizeFn; /* size function */
|
||||||
func_ptr interFn; /* intersection function */
|
func_ptr interFn; /* intersection function */
|
||||||
} RTSTATE;
|
} RTSTATE;
|
||||||
|
|
||||||
/* non-export function prototypes */
|
/* non-export function prototypes */
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
@@ -62,16 +62,16 @@ dosplit(Relation r, Buffer buffer, RTSTACK * stack,
|
|||||||
static void
|
static void
|
||||||
rtintinsert(Relation r, RTSTACK * stk, IndexTuple ltup,
|
rtintinsert(Relation r, RTSTACK * stk, IndexTuple ltup,
|
||||||
IndexTuple rtup, RTSTATE * rtstate);
|
IndexTuple rtup, RTSTATE * rtstate);
|
||||||
static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt);
|
static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt);
|
||||||
static void
|
static void
|
||||||
picksplit(Relation r, Page page, SPLITVEC * v, IndexTuple itup,
|
picksplit(Relation r, Page page, SPLITVEC * v, IndexTuple itup,
|
||||||
RTSTATE * rtstate);
|
RTSTATE * rtstate);
|
||||||
static void RTInitBuffer(Buffer b, uint32 f);
|
static void RTInitBuffer(Buffer b, uint32 f);
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
choose(Relation r, Page p, IndexTuple it,
|
choose(Relation r, Page p, IndexTuple it,
|
||||||
RTSTATE * rtstate);
|
RTSTATE * rtstate);
|
||||||
static int nospace(Page p, IndexTuple it);
|
static int nospace(Page p, IndexTuple it);
|
||||||
static void initRtstate(RTSTATE * rtstate, Relation index);
|
static void initRtstate(RTSTATE * rtstate, Relation index);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -85,31 +85,31 @@ rtbuild(Relation heap,
|
|||||||
FuncIndexInfo * finfo,
|
FuncIndexInfo * finfo,
|
||||||
PredInfo * predInfo)
|
PredInfo * predInfo)
|
||||||
{
|
{
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
AttrNumber i;
|
AttrNumber i;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
TupleDesc hd,
|
TupleDesc hd,
|
||||||
id;
|
id;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
Datum *d;
|
Datum *d;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
int nb,
|
int nb,
|
||||||
nh,
|
nh,
|
||||||
ni;
|
ni;
|
||||||
|
|
||||||
#ifndef OMIT_PARTIAL_INDEX
|
#ifndef OMIT_PARTIAL_INDEX
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
TupleTable tupleTable;
|
TupleTable tupleTable;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Oid hrelid,
|
Oid hrelid,
|
||||||
irelid;
|
irelid;
|
||||||
Node *pred,
|
Node *pred,
|
||||||
*oldPred;
|
*oldPred;
|
||||||
RTSTATE rtState;
|
RTSTATE rtState;
|
||||||
|
|
||||||
initRtstate(&rtState, index);
|
initRtstate(&rtState, index);
|
||||||
|
|
||||||
@@ -215,8 +215,8 @@ rtbuild(Relation heap,
|
|||||||
|
|
||||||
for (i = 1; i <= natts; i++)
|
for (i = 1; i <= natts; i++)
|
||||||
{
|
{
|
||||||
int attoff;
|
int attoff;
|
||||||
bool attnull;
|
bool attnull;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Offsets are from the start of the tuple, and are
|
* Offsets are from the start of the tuple, and are
|
||||||
@@ -308,8 +308,8 @@ InsertIndexResult
|
|||||||
rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
||||||
{
|
{
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
RTSTATE rtState;
|
RTSTATE rtState;
|
||||||
|
|
||||||
/* generate an index tuple */
|
/* generate an index tuple */
|
||||||
itup = index_formtuple(RelationGetTupleDescriptor(r), datum, nulls);
|
itup = index_formtuple(RelationGetTupleDescriptor(r), datum, nulls);
|
||||||
@@ -323,18 +323,18 @@ rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation h
|
|||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
rtdoinsert(Relation r, IndexTuple itup, RTSTATE * rtstate)
|
rtdoinsert(Relation r, IndexTuple itup, RTSTATE * rtstate)
|
||||||
{
|
{
|
||||||
Page page;
|
Page page;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
IndexTuple which;
|
IndexTuple which;
|
||||||
OffsetNumber l;
|
OffsetNumber l;
|
||||||
RTSTACK *stack;
|
RTSTACK *stack;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
RTreePageOpaque opaque;
|
RTreePageOpaque opaque;
|
||||||
char *datum;
|
char *datum;
|
||||||
|
|
||||||
blk = P_ROOT;
|
blk = P_ROOT;
|
||||||
buffer = InvalidBuffer;
|
buffer = InvalidBuffer;
|
||||||
@@ -353,8 +353,8 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE * rtstate)
|
|||||||
opaque = (RTreePageOpaque) PageGetSpecialPointer(page);
|
opaque = (RTreePageOpaque) PageGetSpecialPointer(page);
|
||||||
if (!(opaque->flags & F_LEAF))
|
if (!(opaque->flags & F_LEAF))
|
||||||
{
|
{
|
||||||
RTSTACK *n;
|
RTSTACK *n;
|
||||||
ItemId iid;
|
ItemId iid;
|
||||||
|
|
||||||
n = (RTSTACK *) palloc(sizeof(RTSTACK));
|
n = (RTSTACK *) palloc(sizeof(RTSTACK));
|
||||||
n->rts_parent = stack;
|
n->rts_parent = stack;
|
||||||
@@ -414,12 +414,12 @@ rttighten(Relation r,
|
|||||||
int att_size,
|
int att_size,
|
||||||
RTSTATE * rtstate)
|
RTSTATE * rtstate)
|
||||||
{
|
{
|
||||||
char *oldud;
|
char *oldud;
|
||||||
char *tdatum;
|
char *tdatum;
|
||||||
Page p;
|
Page p;
|
||||||
float old_size,
|
float old_size,
|
||||||
newd_size;
|
newd_size;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
|
|
||||||
if (stk == (RTSTACK *) NULL)
|
if (stk == (RTSTACK *) NULL)
|
||||||
return;
|
return;
|
||||||
@@ -437,7 +437,7 @@ rttighten(Relation r,
|
|||||||
|
|
||||||
if (newd_size != old_size)
|
if (newd_size != old_size)
|
||||||
{
|
{
|
||||||
TupleDesc td = RelationGetTupleDescriptor(r);
|
TupleDesc td = RelationGetTupleDescriptor(r);
|
||||||
|
|
||||||
if (td->attrs[0]->attlen < 0)
|
if (td->attrs[0]->attlen < 0)
|
||||||
{
|
{
|
||||||
@@ -480,35 +480,35 @@ rttighten(Relation r,
|
|||||||
* his paper. The reason we chose it is that you can implement this
|
* his paper. The reason we chose it is that you can implement this
|
||||||
* with less information about the data types on which you're operating.
|
* with less information about the data types on which you're operating.
|
||||||
*/
|
*/
|
||||||
static InsertIndexResult
|
static InsertIndexResult
|
||||||
dosplit(Relation r,
|
dosplit(Relation r,
|
||||||
Buffer buffer,
|
Buffer buffer,
|
||||||
RTSTACK * stack,
|
RTSTACK * stack,
|
||||||
IndexTuple itup,
|
IndexTuple itup,
|
||||||
RTSTATE * rtstate)
|
RTSTATE * rtstate)
|
||||||
{
|
{
|
||||||
Page p;
|
Page p;
|
||||||
Buffer leftbuf,
|
Buffer leftbuf,
|
||||||
rightbuf;
|
rightbuf;
|
||||||
Page left,
|
Page left,
|
||||||
right;
|
right;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
IndexTuple item;
|
IndexTuple item;
|
||||||
IndexTuple ltup,
|
IndexTuple ltup,
|
||||||
rtup;
|
rtup;
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
OffsetNumber leftoff,
|
OffsetNumber leftoff,
|
||||||
rightoff;
|
rightoff;
|
||||||
BlockNumber lbknum,
|
BlockNumber lbknum,
|
||||||
rbknum;
|
rbknum;
|
||||||
BlockNumber bufblock;
|
BlockNumber bufblock;
|
||||||
RTreePageOpaque opaque;
|
RTreePageOpaque opaque;
|
||||||
int blank;
|
int blank;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
char *isnull;
|
char *isnull;
|
||||||
SPLITVEC v;
|
SPLITVEC v;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
isnull = (char *) palloc(r->rd_rel->relnatts);
|
isnull = (char *) palloc(r->rd_rel->relnatts);
|
||||||
for (blank = 0; blank < r->rd_rel->relnatts; blank++)
|
for (blank = 0; blank < r->rd_rel->relnatts; blank++)
|
||||||
@@ -638,12 +638,12 @@ rtintinsert(Relation r,
|
|||||||
IndexTuple rtup,
|
IndexTuple rtup,
|
||||||
RTSTATE * rtstate)
|
RTSTATE * rtstate)
|
||||||
{
|
{
|
||||||
IndexTuple old;
|
IndexTuple old;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
char *ldatum,
|
char *ldatum,
|
||||||
*rdatum,
|
*rdatum,
|
||||||
*newdatum;
|
*newdatum;
|
||||||
InsertIndexResult res;
|
InsertIndexResult res;
|
||||||
|
|
||||||
if (stk == (RTSTACK *) NULL)
|
if (stk == (RTSTACK *) NULL)
|
||||||
@@ -698,8 +698,8 @@ rtintinsert(Relation r,
|
|||||||
static void
|
static void
|
||||||
rtnewroot(Relation r, IndexTuple lt, IndexTuple rt)
|
rtnewroot(Relation r, IndexTuple lt, IndexTuple rt)
|
||||||
{
|
{
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Page p;
|
Page p;
|
||||||
|
|
||||||
b = ReadBuffer(r, P_ROOT);
|
b = ReadBuffer(r, P_ROOT);
|
||||||
RTInitBuffer(b, 0);
|
RTInitBuffer(b, 0);
|
||||||
@@ -718,33 +718,33 @@ picksplit(Relation r,
|
|||||||
IndexTuple itup,
|
IndexTuple itup,
|
||||||
RTSTATE * rtstate)
|
RTSTATE * rtstate)
|
||||||
{
|
{
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber i,
|
OffsetNumber i,
|
||||||
j;
|
j;
|
||||||
IndexTuple item_1,
|
IndexTuple item_1,
|
||||||
item_2;
|
item_2;
|
||||||
char *datum_alpha,
|
char *datum_alpha,
|
||||||
*datum_beta;
|
*datum_beta;
|
||||||
char *datum_l,
|
char *datum_l,
|
||||||
*datum_r;
|
*datum_r;
|
||||||
char *union_d,
|
char *union_d,
|
||||||
*union_dl,
|
*union_dl,
|
||||||
*union_dr;
|
*union_dr;
|
||||||
char *inter_d;
|
char *inter_d;
|
||||||
bool firsttime;
|
bool firsttime;
|
||||||
float size_alpha,
|
float size_alpha,
|
||||||
size_beta,
|
size_beta,
|
||||||
size_union,
|
size_union,
|
||||||
size_inter;
|
size_inter;
|
||||||
float size_waste,
|
float size_waste,
|
||||||
waste;
|
waste;
|
||||||
float size_l,
|
float size_l,
|
||||||
size_r;
|
size_r;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
OffsetNumber seed_1 = 0,
|
OffsetNumber seed_1 = 0,
|
||||||
seed_2 = 0;
|
seed_2 = 0;
|
||||||
OffsetNumber *left,
|
OffsetNumber *left,
|
||||||
*right;
|
*right;
|
||||||
|
|
||||||
maxoff = PageGetMaxOffsetNumber(page);
|
maxoff = PageGetMaxOffsetNumber(page);
|
||||||
|
|
||||||
@@ -886,8 +886,8 @@ static void
|
|||||||
RTInitBuffer(Buffer b, uint32 f)
|
RTInitBuffer(Buffer b, uint32 f)
|
||||||
{
|
{
|
||||||
RTreePageOpaque opaque;
|
RTreePageOpaque opaque;
|
||||||
Page page;
|
Page page;
|
||||||
Size pageSize;
|
Size pageSize;
|
||||||
|
|
||||||
pageSize = BufferGetPageSize(b);
|
pageSize = BufferGetPageSize(b);
|
||||||
|
|
||||||
@@ -899,18 +899,18 @@ RTInitBuffer(Buffer b, uint32 f)
|
|||||||
opaque->flags = f;
|
opaque->flags = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OffsetNumber
|
static OffsetNumber
|
||||||
choose(Relation r, Page p, IndexTuple it, RTSTATE * rtstate)
|
choose(Relation r, Page p, IndexTuple it, RTSTATE * rtstate)
|
||||||
{
|
{
|
||||||
OffsetNumber maxoff;
|
OffsetNumber maxoff;
|
||||||
OffsetNumber i;
|
OffsetNumber i;
|
||||||
char *ud,
|
char *ud,
|
||||||
*id;
|
*id;
|
||||||
char *datum;
|
char *datum;
|
||||||
float usize,
|
float usize,
|
||||||
dsize;
|
dsize;
|
||||||
OffsetNumber which;
|
OffsetNumber which;
|
||||||
float which_grow;
|
float which_grow;
|
||||||
|
|
||||||
id = ((char *) it) + sizeof(IndexTupleData);
|
id = ((char *) it) + sizeof(IndexTupleData);
|
||||||
maxoff = PageGetMaxOffsetNumber(p);
|
maxoff = PageGetMaxOffsetNumber(p);
|
||||||
@@ -946,7 +946,7 @@ nospace(Page p, IndexTuple it)
|
|||||||
void
|
void
|
||||||
freestack(RTSTACK * s)
|
freestack(RTSTACK * s)
|
||||||
{
|
{
|
||||||
RTSTACK *p;
|
RTSTACK *p;
|
||||||
|
|
||||||
while (s != (RTSTACK *) NULL)
|
while (s != (RTSTACK *) NULL)
|
||||||
{
|
{
|
||||||
@@ -956,13 +956,13 @@ freestack(RTSTACK * s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
rtdelete(Relation r, ItemPointer tid)
|
rtdelete(Relation r, ItemPointer tid)
|
||||||
{
|
{
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
OffsetNumber offnum;
|
OffsetNumber offnum;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
/* must write-lock on delete */
|
/* must write-lock on delete */
|
||||||
RelationSetLockForWrite(r);
|
RelationSetLockForWrite(r);
|
||||||
@@ -988,11 +988,11 @@ rtdelete(Relation r, ItemPointer tid)
|
|||||||
static void
|
static void
|
||||||
initRtstate(RTSTATE * rtstate, Relation index)
|
initRtstate(RTSTATE * rtstate, Relation index)
|
||||||
{
|
{
|
||||||
RegProcedure union_proc,
|
RegProcedure union_proc,
|
||||||
size_proc,
|
size_proc,
|
||||||
inter_proc;
|
inter_proc;
|
||||||
func_ptr user_fn;
|
func_ptr user_fn;
|
||||||
int pronargs;
|
int pronargs;
|
||||||
|
|
||||||
union_proc = index_getprocid(index, 1, RT_UNION_PROC);
|
union_proc = index_getprocid(index, 1, RT_UNION_PROC);
|
||||||
size_proc = index_getprocid(index, 1, RT_SIZE_PROC);
|
size_proc = index_getprocid(index, 1, RT_SIZE_PROC);
|
||||||
@@ -1011,18 +1011,18 @@ initRtstate(RTSTATE * rtstate, Relation index)
|
|||||||
void
|
void
|
||||||
_rtdump(Relation r)
|
_rtdump(Relation r)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
BlockNumber nblocks;
|
BlockNumber nblocks;
|
||||||
RTreePageOpaque po;
|
RTreePageOpaque po;
|
||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
BlockNumber itblkno;
|
BlockNumber itblkno;
|
||||||
OffsetNumber itoffno;
|
OffsetNumber itoffno;
|
||||||
char *datum;
|
char *datum;
|
||||||
char *itkey;
|
char *itkey;
|
||||||
|
|
||||||
nblocks = RelationGetNumberOfBlocks(r);
|
nblocks = RelationGetNumberOfBlocks(r);
|
||||||
for (blkno = 0; blkno < nblocks; blkno++)
|
for (blkno = 0; blkno < nblocks; blkno++)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.11 1997/09/07 04:39:24 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.12 1997/09/08 02:21:08 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* routines defined and used here */
|
/* routines defined and used here */
|
||||||
static void rtregscan(IndexScanDesc s);
|
static void rtregscan(IndexScanDesc s);
|
||||||
static void rtdropscan(IndexScanDesc s);
|
static void rtdropscan(IndexScanDesc s);
|
||||||
static void
|
static void
|
||||||
rtadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
rtadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
||||||
OffsetNumber offnum);
|
OffsetNumber offnum);
|
||||||
@@ -52,9 +52,9 @@ adjustiptr(IndexScanDesc s, ItemPointer iptr,
|
|||||||
|
|
||||||
typedef struct RTScanListData
|
typedef struct RTScanListData
|
||||||
{
|
{
|
||||||
IndexScanDesc rtsl_scan;
|
IndexScanDesc rtsl_scan;
|
||||||
struct RTScanListData *rtsl_next;
|
struct RTScanListData *rtsl_next;
|
||||||
} RTScanListData;
|
} RTScanListData;
|
||||||
|
|
||||||
typedef RTScanListData *RTScanList;
|
typedef RTScanListData *RTScanList;
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ rtbeginscan(Relation r,
|
|||||||
uint16 nkeys,
|
uint16 nkeys,
|
||||||
ScanKey key)
|
ScanKey key)
|
||||||
{
|
{
|
||||||
IndexScanDesc s;
|
IndexScanDesc s;
|
||||||
|
|
||||||
RelationSetLockForRead(r);
|
RelationSetLockForRead(r);
|
||||||
s = RelationGetIndexScan(r, fromEnd, nkeys, key);
|
s = RelationGetIndexScan(r, fromEnd, nkeys, key);
|
||||||
@@ -80,8 +80,8 @@ void
|
|||||||
rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
|
rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
|
||||||
{
|
{
|
||||||
RTreeScanOpaque p;
|
RTreeScanOpaque p;
|
||||||
RegProcedure internal_proc;
|
RegProcedure internal_proc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!IndexScanIsValid(s))
|
if (!IndexScanIsValid(s))
|
||||||
{
|
{
|
||||||
@@ -177,9 +177,9 @@ void
|
|||||||
rtmarkpos(IndexScanDesc s)
|
rtmarkpos(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
RTreeScanOpaque p;
|
RTreeScanOpaque p;
|
||||||
RTSTACK *o,
|
RTSTACK *o,
|
||||||
*n,
|
*n,
|
||||||
*tmp;
|
*tmp;
|
||||||
|
|
||||||
s->currentMarkData = s->currentItemData;
|
s->currentMarkData = s->currentItemData;
|
||||||
p = (RTreeScanOpaque) s->opaque;
|
p = (RTreeScanOpaque) s->opaque;
|
||||||
@@ -210,9 +210,9 @@ void
|
|||||||
rtrestrpos(IndexScanDesc s)
|
rtrestrpos(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
RTreeScanOpaque p;
|
RTreeScanOpaque p;
|
||||||
RTSTACK *o,
|
RTSTACK *o,
|
||||||
*n,
|
*n,
|
||||||
*tmp;
|
*tmp;
|
||||||
|
|
||||||
s->currentItemData = s->currentMarkData;
|
s->currentItemData = s->currentMarkData;
|
||||||
p = (RTreeScanOpaque) s->opaque;
|
p = (RTreeScanOpaque) s->opaque;
|
||||||
@@ -260,7 +260,7 @@ rtendscan(IndexScanDesc s)
|
|||||||
static void
|
static void
|
||||||
rtregscan(IndexScanDesc s)
|
rtregscan(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
RTScanList l;
|
RTScanList l;
|
||||||
|
|
||||||
l = (RTScanList) palloc(sizeof(RTScanListData));
|
l = (RTScanList) palloc(sizeof(RTScanListData));
|
||||||
l->rtsl_scan = s;
|
l->rtsl_scan = s;
|
||||||
@@ -271,8 +271,8 @@ rtregscan(IndexScanDesc s)
|
|||||||
static void
|
static void
|
||||||
rtdropscan(IndexScanDesc s)
|
rtdropscan(IndexScanDesc s)
|
||||||
{
|
{
|
||||||
RTScanList l;
|
RTScanList l;
|
||||||
RTScanList prev;
|
RTScanList prev;
|
||||||
|
|
||||||
prev = (RTScanList) NULL;
|
prev = (RTScanList) NULL;
|
||||||
|
|
||||||
@@ -297,8 +297,8 @@ rtdropscan(IndexScanDesc s)
|
|||||||
void
|
void
|
||||||
rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
|
rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
RTScanList l;
|
RTScanList l;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
|
|
||||||
relid = r->rd_id;
|
relid = r->rd_id;
|
||||||
for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next)
|
for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next)
|
||||||
@@ -352,7 +352,7 @@ adjustiptr(IndexScanDesc s,
|
|||||||
BlockNumber blkno,
|
BlockNumber blkno,
|
||||||
OffsetNumber offnum)
|
OffsetNumber offnum)
|
||||||
{
|
{
|
||||||
OffsetNumber curoff;
|
OffsetNumber curoff;
|
||||||
RTreeScanOpaque so;
|
RTreeScanOpaque so;
|
||||||
|
|
||||||
if (ItemPointerIsValid(iptr))
|
if (ItemPointerIsValid(iptr))
|
||||||
@@ -364,39 +364,43 @@ adjustiptr(IndexScanDesc s,
|
|||||||
|
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case RTOP_DEL:
|
case RTOP_DEL:
|
||||||
/* back up one if we need to */
|
/* back up one if we need to */
|
||||||
if (curoff >= offnum)
|
if (curoff >= offnum)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (curoff > FirstOffsetNumber)
|
if (curoff > FirstOffsetNumber)
|
||||||
{
|
{
|
||||||
/* just adjust the item pointer */
|
/* just adjust the item pointer */
|
||||||
ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff));
|
ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* remember that we're before the current tuple */
|
|
||||||
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
|
||||||
if (iptr == &(s->currentItemData))
|
|
||||||
so->s_flags |= RTS_CURBEFORE;
|
|
||||||
else
|
else
|
||||||
so->s_flags |= RTS_MRKBEFORE;
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* remember that we're before the current
|
||||||
|
* tuple
|
||||||
|
*/
|
||||||
|
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
||||||
|
if (iptr == &(s->currentItemData))
|
||||||
|
so->s_flags |= RTS_CURBEFORE;
|
||||||
|
else
|
||||||
|
so->s_flags |= RTS_MRKBEFORE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case RTOP_SPLIT:
|
case RTOP_SPLIT:
|
||||||
/* back to start of page on split */
|
/* back to start of page on split */
|
||||||
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
ItemPointerSet(iptr, blkno, FirstOffsetNumber);
|
||||||
if (iptr == &(s->currentItemData))
|
if (iptr == &(s->currentItemData))
|
||||||
so->s_flags &= ~RTS_CURBEFORE;
|
so->s_flags &= ~RTS_CURBEFORE;
|
||||||
else
|
else
|
||||||
so->s_flags &= ~RTS_MRKBEFORE;
|
so->s_flags &= ~RTS_MRKBEFORE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(WARN, "Bad operation in rtree scan adjust: %d", op);
|
elog(WARN, "Bad operation in rtree scan adjust: %d", op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.7 1997/09/07 04:39:26 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.8 1997/09/08 02:21:11 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -118,7 +118,7 @@ static StrategyNumber RTNegateCommute[RTNStrategies] = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* if you only have "contained-by", how do you determine equality? */
|
/* if you only have "contained-by", how do you determine equality? */
|
||||||
static uint16 RTContainedByTermData[] = {
|
static uint16 RTContainedByTermData[] = {
|
||||||
2, /* make two comparisons */
|
2, /* make two comparisons */
|
||||||
RTContainedByStrategyNumber,/* use "a contained-by b" */
|
RTContainedByStrategyNumber,/* use "a contained-by b" */
|
||||||
0x0, /* without any magic */
|
0x0, /* without any magic */
|
||||||
@@ -127,7 +127,7 @@ static uint16 RTContainedByTermData[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* if you only have "contains", how do you determine equality? */
|
/* if you only have "contains", how do you determine equality? */
|
||||||
static uint16 RTContainsTermData[] = {
|
static uint16 RTContainsTermData[] = {
|
||||||
2, /* make two comparisons */
|
2, /* make two comparisons */
|
||||||
RTContainsStrategyNumber, /* use "a contains b" */
|
RTContainsStrategyNumber, /* use "a contains b" */
|
||||||
0x0, /* without any magic */
|
0x0, /* without any magic */
|
||||||
@@ -204,7 +204,7 @@ static StrategyNumber RTOperMap[RTNStrategies] = {
|
|||||||
RTOverlapStrategyNumber
|
RTOverlapStrategyNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
static StrategyNumber
|
static StrategyNumber
|
||||||
RelationGetRTStrategy(Relation r,
|
RelationGetRTStrategy(Relation r,
|
||||||
AttrNumber attnum,
|
AttrNumber attnum,
|
||||||
RegProcedure proc)
|
RegProcedure proc)
|
||||||
@@ -231,8 +231,8 @@ RTMapOperator(Relation r,
|
|||||||
AttrNumber attnum,
|
AttrNumber attnum,
|
||||||
RegProcedure proc)
|
RegProcedure proc)
|
||||||
{
|
{
|
||||||
StrategyNumber procstrat;
|
StrategyNumber procstrat;
|
||||||
StrategyMap strategyMap;
|
StrategyMap strategyMap;
|
||||||
|
|
||||||
procstrat = RelationGetRTStrategy(r, attnum, proc);
|
procstrat = RelationGetRTStrategy(r, attnum, proc);
|
||||||
strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(r),
|
strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(r),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.10 1997/09/07 04:39:29 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.11 1997/09/08 02:21:14 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This file contains the high level access-method interface to the
|
* This file contains the high level access-method interface to the
|
||||||
@@ -26,9 +26,9 @@
|
|||||||
#include <storage/spin.h>
|
#include <storage/spin.h>
|
||||||
#include <commands/vacuum.h>
|
#include <commands/vacuum.h>
|
||||||
|
|
||||||
static int RecoveryCheckingEnabled(void);
|
static int RecoveryCheckingEnabled(void);
|
||||||
static void TransRecover(Relation logRelation);
|
static void TransRecover(Relation logRelation);
|
||||||
static bool TransactionLogTest(TransactionId transactionId, XidStatus status);
|
static bool TransactionLogTest(TransactionId transactionId, XidStatus status);
|
||||||
static void
|
static void
|
||||||
TransactionLogUpdate(TransactionId transactionId,
|
TransactionLogUpdate(TransactionId transactionId,
|
||||||
XidStatus status);
|
XidStatus status);
|
||||||
@@ -40,18 +40,18 @@ TransactionLogUpdate(TransactionId transactionId,
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Relation LogRelation = (Relation) NULL;
|
Relation LogRelation = (Relation) NULL;
|
||||||
Relation TimeRelation = (Relation) NULL;
|
Relation TimeRelation = (Relation) NULL;
|
||||||
Relation VariableRelation = (Relation) NULL;
|
Relation VariableRelation = (Relation) NULL;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* global variables holding cached transaction id's and statuses.
|
* global variables holding cached transaction id's and statuses.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
TransactionId cachedGetCommitTimeXid;
|
TransactionId cachedGetCommitTimeXid;
|
||||||
AbsoluteTime cachedGetCommitTime;
|
AbsoluteTime cachedGetCommitTime;
|
||||||
TransactionId cachedTestXid;
|
TransactionId cachedTestXid;
|
||||||
XidStatus cachedTestXidStatus;
|
XidStatus cachedTestXidStatus;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* transaction system constants
|
* transaction system constants
|
||||||
@@ -65,11 +65,11 @@ XidStatus cachedTestXidStatus;
|
|||||||
* FirstTransactionId. -cim 3/23/90
|
* FirstTransactionId. -cim 3/23/90
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
TransactionId NullTransactionId = (TransactionId) 0;
|
TransactionId NullTransactionId = (TransactionId) 0;
|
||||||
|
|
||||||
TransactionId AmiTransactionId = (TransactionId) 512;
|
TransactionId AmiTransactionId = (TransactionId) 512;
|
||||||
|
|
||||||
TransactionId FirstTransactionId = (TransactionId) 514;
|
TransactionId FirstTransactionId = (TransactionId) 514;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* transaction recovery state variables
|
* transaction recovery state variables
|
||||||
@@ -83,19 +83,19 @@ TransactionId FirstTransactionId = (TransactionId) 514;
|
|||||||
* goes from zero to one. -cim 3/21/90
|
* goes from zero to one. -cim 3/21/90
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
int RecoveryCheckingEnableState = 0;
|
int RecoveryCheckingEnableState = 0;
|
||||||
|
|
||||||
/* ------------------
|
/* ------------------
|
||||||
* spinlock for oid generation
|
* spinlock for oid generation
|
||||||
* -----------------
|
* -----------------
|
||||||
*/
|
*/
|
||||||
extern int OidGenLockId;
|
extern int OidGenLockId;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* globals that must be reset at abort
|
* globals that must be reset at abort
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
extern bool BuildingBtree;
|
extern bool BuildingBtree;
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -134,14 +134,14 @@ SetRecoveryCheckingEnabled(bool state)
|
|||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool /* true/false: does transaction id have
|
static bool /* true/false: does transaction id have
|
||||||
* specified status? */
|
* specified status? */
|
||||||
TransactionLogTest(TransactionId transactionId, /* transaction id to test */
|
TransactionLogTest(TransactionId transactionId, /* transaction id to test */
|
||||||
XidStatus status) /* transaction status */
|
XidStatus status) /* transaction status */
|
||||||
{
|
{
|
||||||
BlockNumber blockNumber;
|
BlockNumber blockNumber;
|
||||||
XidStatus xidstatus; /* recorded status of xid */
|
XidStatus xidstatus; /* recorded status of xid */
|
||||||
bool fail = false; /* success/failure */
|
bool fail = false; /* success/failure */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* during initialization consider all transactions
|
* during initialization consider all transactions
|
||||||
@@ -202,9 +202,9 @@ static void
|
|||||||
TransactionLogUpdate(TransactionId transactionId, /* trans id to update */
|
TransactionLogUpdate(TransactionId transactionId, /* trans id to update */
|
||||||
XidStatus status) /* new trans status */
|
XidStatus status) /* new trans status */
|
||||||
{
|
{
|
||||||
BlockNumber blockNumber;
|
BlockNumber blockNumber;
|
||||||
bool fail = false; /* success/failure */
|
bool fail = false; /* success/failure */
|
||||||
AbsoluteTime currentTime;/* time of this transaction */
|
AbsoluteTime currentTime; /* time of this transaction */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* during initialization we don't record any updates.
|
* during initialization we don't record any updates.
|
||||||
@@ -276,9 +276,9 @@ AbsoluteTime /* commit time of transaction id */
|
|||||||
TransactionIdGetCommitTime(TransactionId transactionId) /* transaction id to
|
TransactionIdGetCommitTime(TransactionId transactionId) /* transaction id to
|
||||||
* test */
|
* test */
|
||||||
{
|
{
|
||||||
BlockNumber blockNumber;
|
BlockNumber blockNumber;
|
||||||
AbsoluteTime commitTime; /* commit time */
|
AbsoluteTime commitTime; /* commit time */
|
||||||
bool fail = false; /* success/failure */
|
bool fail = false; /* success/failure */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* return invalid if we aren't running yet...
|
* return invalid if we aren't running yet...
|
||||||
@@ -471,9 +471,9 @@ TransRecover(Relation logRelation)
|
|||||||
void
|
void
|
||||||
InitializeTransactionLog(void)
|
InitializeTransactionLog(void)
|
||||||
{
|
{
|
||||||
Relation logRelation;
|
Relation logRelation;
|
||||||
Relation timeRelation;
|
Relation timeRelation;
|
||||||
MemoryContext oldContext;
|
MemoryContext oldContext;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* don't do anything during bootstrapping
|
* don't do anything during bootstrapping
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.10 1997/09/07 04:39:32 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.11 1997/09/08 02:21:18 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This file contains support functions for the high
|
* This file contains support functions for the high
|
||||||
@@ -63,7 +63,7 @@ TransComputeBlockNumber(Relation relation, /* relation to test */
|
|||||||
* test */
|
* test */
|
||||||
BlockNumber * blockNumberOutP)
|
BlockNumber * blockNumberOutP)
|
||||||
{
|
{
|
||||||
long itemsPerBlock = 0;
|
long itemsPerBlock = 0;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* we calculate the block number of our transaction
|
* we calculate the block number of our transaction
|
||||||
@@ -108,17 +108,17 @@ TransComputeBlockNumber(Relation relation, /* relation to test */
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
static XidStatus
|
static XidStatus
|
||||||
TransBlockGetLastTransactionIdStatus(Block tblock,
|
TransBlockGetLastTransactionIdStatus(Block tblock,
|
||||||
TransactionId baseXid,
|
TransactionId baseXid,
|
||||||
TransactionId * returnXidP)
|
TransactionId * returnXidP)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
Index maxIndex;
|
Index maxIndex;
|
||||||
bits8 bit1;
|
bits8 bit1;
|
||||||
bits8 bit2;
|
bits8 bit2;
|
||||||
BitIndex offset;
|
BitIndex offset;
|
||||||
XidStatus xstatus;
|
XidStatus xstatus;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity check
|
* sanity check
|
||||||
@@ -188,14 +188,14 @@ TransBlockGetLastTransactionIdStatus(Block tblock,
|
|||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static XidStatus
|
static XidStatus
|
||||||
TransBlockGetXidStatus(Block tblock,
|
TransBlockGetXidStatus(Block tblock,
|
||||||
TransactionId transactionId)
|
TransactionId transactionId)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
bits8 bit1;
|
bits8 bit1;
|
||||||
bits8 bit2;
|
bits8 bit2;
|
||||||
BitIndex offset;
|
BitIndex offset;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity check
|
* sanity check
|
||||||
@@ -245,8 +245,8 @@ TransBlockSetXidStatus(Block tblock,
|
|||||||
TransactionId transactionId,
|
TransactionId transactionId,
|
||||||
XidStatus xstatus)
|
XidStatus xstatus)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
BitIndex offset;
|
BitIndex offset;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity check
|
* sanity check
|
||||||
@@ -275,23 +275,23 @@ TransBlockSetXidStatus(Block tblock,
|
|||||||
*/
|
*/
|
||||||
switch (xstatus)
|
switch (xstatus)
|
||||||
{
|
{
|
||||||
case XID_COMMIT: /* set 10 */
|
case XID_COMMIT: /* set 10 */
|
||||||
BitArraySetBit((BitArray) tblock, offset);
|
BitArraySetBit((BitArray) tblock, offset);
|
||||||
BitArrayClearBit((BitArray) tblock, offset + 1);
|
BitArrayClearBit((BitArray) tblock, offset + 1);
|
||||||
break;
|
break;
|
||||||
case XID_ABORT: /* set 01 */
|
case XID_ABORT: /* set 01 */
|
||||||
BitArrayClearBit((BitArray) tblock, offset);
|
BitArrayClearBit((BitArray) tblock, offset);
|
||||||
BitArraySetBit((BitArray) tblock, offset + 1);
|
BitArraySetBit((BitArray) tblock, offset + 1);
|
||||||
break;
|
break;
|
||||||
case XID_INPROGRESS: /* set 00 */
|
case XID_INPROGRESS: /* set 00 */
|
||||||
BitArrayClearBit((BitArray) tblock, offset);
|
BitArrayClearBit((BitArray) tblock, offset);
|
||||||
BitArrayClearBit((BitArray) tblock, offset + 1);
|
BitArrayClearBit((BitArray) tblock, offset + 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(NOTICE,
|
elog(NOTICE,
|
||||||
"TransBlockSetXidStatus: invalid status: %d (ignored)",
|
"TransBlockSetXidStatus: invalid status: %d (ignored)",
|
||||||
xstatus);
|
xstatus);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,12 +302,12 @@ TransBlockSetXidStatus(Block tblock,
|
|||||||
* specified transaction id in the trans block.
|
* specified transaction id in the trans block.
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static AbsoluteTime
|
static AbsoluteTime
|
||||||
TransBlockGetCommitTime(Block tblock,
|
TransBlockGetCommitTime(Block tblock,
|
||||||
TransactionId transactionId)
|
TransactionId transactionId)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
AbsoluteTime *timeArray;
|
AbsoluteTime *timeArray;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity check
|
* sanity check
|
||||||
@@ -348,8 +348,8 @@ TransBlockSetCommitTime(Block tblock,
|
|||||||
TransactionId transactionId,
|
TransactionId transactionId,
|
||||||
AbsoluteTime commitTime)
|
AbsoluteTime commitTime)
|
||||||
{
|
{
|
||||||
Index index;
|
Index index;
|
||||||
AbsoluteTime *timeArray;
|
AbsoluteTime *timeArray;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity check
|
* sanity check
|
||||||
@@ -394,10 +394,10 @@ TransBlockNumberGetXidStatus(Relation relation,
|
|||||||
TransactionId xid,
|
TransactionId xid,
|
||||||
bool * failP)
|
bool * failP)
|
||||||
{
|
{
|
||||||
Buffer buffer; /* buffer associated with block */
|
Buffer buffer; /* buffer associated with block */
|
||||||
Block block; /* block containing xstatus */
|
Block block; /* block containing xstatus */
|
||||||
XidStatus xstatus; /* recorded status of xid */
|
XidStatus xstatus; /* recorded status of xid */
|
||||||
bool localfail; /* bool used if failP = NULL */
|
bool localfail; /* bool used if failP = NULL */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* SOMEDAY place a read lock on the log relation
|
* SOMEDAY place a read lock on the log relation
|
||||||
@@ -451,9 +451,9 @@ TransBlockNumberSetXidStatus(Relation relation,
|
|||||||
XidStatus xstatus,
|
XidStatus xstatus,
|
||||||
bool * failP)
|
bool * failP)
|
||||||
{
|
{
|
||||||
Buffer buffer; /* buffer associated with block */
|
Buffer buffer; /* buffer associated with block */
|
||||||
Block block; /* block containing xstatus */
|
Block block; /* block containing xstatus */
|
||||||
bool localfail; /* bool used if failP = NULL */
|
bool localfail; /* bool used if failP = NULL */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* SOMEDAY gain exclusive access to the log relation
|
* SOMEDAY gain exclusive access to the log relation
|
||||||
@@ -504,10 +504,10 @@ TransBlockNumberGetCommitTime(Relation relation,
|
|||||||
TransactionId xid,
|
TransactionId xid,
|
||||||
bool * failP)
|
bool * failP)
|
||||||
{
|
{
|
||||||
Buffer buffer; /* buffer associated with block */
|
Buffer buffer; /* buffer associated with block */
|
||||||
Block block; /* block containing commit time */
|
Block block; /* block containing commit time */
|
||||||
bool localfail; /* bool used if failP = NULL */
|
bool localfail; /* bool used if failP = NULL */
|
||||||
AbsoluteTime xtime; /* commit time */
|
AbsoluteTime xtime; /* commit time */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* SOMEDAY place a read lock on the time relation
|
* SOMEDAY place a read lock on the time relation
|
||||||
@@ -565,9 +565,9 @@ TransBlockNumberSetCommitTime(Relation relation,
|
|||||||
AbsoluteTime xtime,
|
AbsoluteTime xtime,
|
||||||
bool * failP)
|
bool * failP)
|
||||||
{
|
{
|
||||||
Buffer buffer; /* buffer associated with block */
|
Buffer buffer; /* buffer associated with block */
|
||||||
Block block; /* block containing commit time */
|
Block block; /* block containing commit time */
|
||||||
bool localfail; /* bool used if failP = NULL */
|
bool localfail; /* bool used if failP = NULL */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* SOMEDAY gain exclusive access to the time relation
|
* SOMEDAY gain exclusive access to the time relation
|
||||||
@@ -620,11 +620,11 @@ TransGetLastRecordedTransaction(Relation relation,
|
|||||||
* id */
|
* id */
|
||||||
bool * failP)
|
bool * failP)
|
||||||
{
|
{
|
||||||
BlockNumber blockNumber;/* block number */
|
BlockNumber blockNumber; /* block number */
|
||||||
Buffer buffer; /* buffer associated with block */
|
Buffer buffer; /* buffer associated with block */
|
||||||
Block block; /* block containing xid status */
|
Block block; /* block containing xid status */
|
||||||
BlockNumber n; /* number of blocks in the relation */
|
BlockNumber n; /* number of blocks in the relation */
|
||||||
TransactionId baseXid;
|
TransactionId baseXid;
|
||||||
|
|
||||||
(*failP) = false;
|
(*failP) = false;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.10 1997/09/07 04:39:35 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.11 1997/09/08 02:21:21 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -20,18 +20,18 @@
|
|||||||
#include <access/heapam.h>
|
#include <access/heapam.h>
|
||||||
#include <catalog/catname.h>
|
#include <catalog/catname.h>
|
||||||
|
|
||||||
static void GetNewObjectIdBlock(Oid * oid_return, int oid_block_size);
|
static void GetNewObjectIdBlock(Oid * oid_return, int oid_block_size);
|
||||||
static void VariableRelationGetNextOid(Oid * oid_return);
|
static void VariableRelationGetNextOid(Oid * oid_return);
|
||||||
static void VariableRelationGetNextXid(TransactionId * xidP);
|
static void VariableRelationGetNextXid(TransactionId * xidP);
|
||||||
static void VariableRelationPutLastXid(TransactionId xid);
|
static void VariableRelationPutLastXid(TransactionId xid);
|
||||||
static void VariableRelationPutNextOid(Oid * oidP);
|
static void VariableRelationPutNextOid(Oid * oidP);
|
||||||
static void VariableRelationGetLastXid(TransactionId * xidP);
|
static void VariableRelationGetLastXid(TransactionId * xidP);
|
||||||
|
|
||||||
/* ---------------------
|
/* ---------------------
|
||||||
* spin lock for oid generation
|
* spin lock for oid generation
|
||||||
* ---------------------
|
* ---------------------
|
||||||
*/
|
*/
|
||||||
int OidGenLockId;
|
int OidGenLockId;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* variable relation query/update routines
|
* variable relation query/update routines
|
||||||
@@ -45,7 +45,7 @@ int OidGenLockId;
|
|||||||
static void
|
static void
|
||||||
VariableRelationGetNextXid(TransactionId * xidP)
|
VariableRelationGetNextXid(TransactionId * xidP)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
VariableRelationContents var;
|
VariableRelationContents var;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -87,7 +87,7 @@ VariableRelationGetNextXid(TransactionId * xidP)
|
|||||||
static void
|
static void
|
||||||
VariableRelationGetLastXid(TransactionId * xidP)
|
VariableRelationGetLastXid(TransactionId * xidP)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
VariableRelationContents var;
|
VariableRelationContents var;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -130,9 +130,9 @@ VariableRelationGetLastXid(TransactionId * xidP)
|
|||||||
void
|
void
|
||||||
VariableRelationPutNextXid(TransactionId xid)
|
VariableRelationPutNextXid(TransactionId xid)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
VariableRelationContents var;
|
VariableRelationContents var;
|
||||||
int flushmode;
|
int flushmode;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* We assume that a spinlock has been acquire to guarantee
|
* We assume that a spinlock has been acquire to guarantee
|
||||||
@@ -176,7 +176,7 @@ VariableRelationPutNextXid(TransactionId xid)
|
|||||||
static void
|
static void
|
||||||
VariableRelationPutLastXid(TransactionId xid)
|
VariableRelationPutLastXid(TransactionId xid)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
VariableRelationContents var;
|
VariableRelationContents var;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -219,7 +219,7 @@ VariableRelationPutLastXid(TransactionId xid)
|
|||||||
static void
|
static void
|
||||||
VariableRelationGetNextOid(Oid * oid_return)
|
VariableRelationGetNextOid(Oid * oid_return)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
VariableRelationContents var;
|
VariableRelationContents var;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -289,7 +289,7 @@ VariableRelationGetNextOid(Oid * oid_return)
|
|||||||
static void
|
static void
|
||||||
VariableRelationPutNextOid(Oid * oidP)
|
VariableRelationPutNextOid(Oid * oidP)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
VariableRelationContents var;
|
VariableRelationContents var;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -383,13 +383,13 @@ VariableRelationPutNextOid(Oid * oidP)
|
|||||||
|
|
||||||
#define VAR_XID_PREFETCH 32
|
#define VAR_XID_PREFETCH 32
|
||||||
|
|
||||||
static int prefetched_xid_count = 0;
|
static int prefetched_xid_count = 0;
|
||||||
static TransactionId next_prefetched_xid;
|
static TransactionId next_prefetched_xid;
|
||||||
|
|
||||||
void
|
void
|
||||||
GetNewTransactionId(TransactionId * xid)
|
GetNewTransactionId(TransactionId * xid)
|
||||||
{
|
{
|
||||||
TransactionId nextid;
|
TransactionId nextid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* during bootstrap initialization, we return the special
|
* during bootstrap initialization, we return the special
|
||||||
@@ -457,7 +457,7 @@ GetNewTransactionId(TransactionId * xid)
|
|||||||
void
|
void
|
||||||
UpdateLastCommittedXid(TransactionId xid)
|
UpdateLastCommittedXid(TransactionId xid)
|
||||||
{
|
{
|
||||||
TransactionId lastid;
|
TransactionId lastid;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -501,7 +501,7 @@ GetNewObjectIdBlock(Oid * oid_return, /* place to return the new object
|
|||||||
* id */
|
* id */
|
||||||
int oid_block_size) /* number of oids desired */
|
int oid_block_size) /* number of oids desired */
|
||||||
{
|
{
|
||||||
Oid nextoid;
|
Oid nextoid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* SOMEDAY obtain exclusive access to the variable relation page
|
* SOMEDAY obtain exclusive access to the variable relation page
|
||||||
@@ -554,8 +554,8 @@ GetNewObjectIdBlock(Oid * oid_return, /* place to return the new object
|
|||||||
|
|
||||||
#define VAR_OID_PREFETCH 32
|
#define VAR_OID_PREFETCH 32
|
||||||
|
|
||||||
static int prefetched_oid_count = 0;
|
static int prefetched_oid_count = 0;
|
||||||
static Oid next_prefetched_oid;
|
static Oid next_prefetched_oid;
|
||||||
|
|
||||||
void
|
void
|
||||||
GetNewObjectId(Oid * oid_return)/* place to return the new object id */
|
GetNewObjectId(Oid * oid_return)/* place to return the new object id */
|
||||||
@@ -568,7 +568,7 @@ GetNewObjectId(Oid * oid_return)/* place to return the new object id */
|
|||||||
|
|
||||||
if (prefetched_oid_count == 0)
|
if (prefetched_oid_count == 0)
|
||||||
{
|
{
|
||||||
int oid_block_size = VAR_OID_PREFETCH;
|
int oid_block_size = VAR_OID_PREFETCH;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* during bootstrap time, we want to allocate oids
|
* during bootstrap time, we want to allocate oids
|
||||||
@@ -609,7 +609,7 @@ GetNewObjectId(Oid * oid_return)/* place to return the new object id */
|
|||||||
void
|
void
|
||||||
CheckMaxObjectId(Oid assigned_oid)
|
CheckMaxObjectId(Oid assigned_oid)
|
||||||
{
|
{
|
||||||
Oid pass_oid;
|
Oid pass_oid;
|
||||||
|
|
||||||
|
|
||||||
if (prefetched_oid_count == 0) /* make sure next/max is set, or
|
if (prefetched_oid_count == 0) /* make sure next/max is set, or
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.14 1997/09/07 04:39:38 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.15 1997/09/08 02:21:22 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Transaction aborts can now occur two ways:
|
* Transaction aborts can now occur two ways:
|
||||||
@@ -151,20 +151,20 @@
|
|||||||
#include <commands/async.h>
|
#include <commands/async.h>
|
||||||
#include <commands/sequence.h>
|
#include <commands/sequence.h>
|
||||||
|
|
||||||
static void AbortTransaction(void);
|
static void AbortTransaction(void);
|
||||||
static void AtAbort_Cache(void);
|
static void AtAbort_Cache(void);
|
||||||
static void AtAbort_Locks(void);
|
static void AtAbort_Locks(void);
|
||||||
static void AtAbort_Memory(void);
|
static void AtAbort_Memory(void);
|
||||||
static void AtCommit_Cache(void);
|
static void AtCommit_Cache(void);
|
||||||
static void AtCommit_Locks(void);
|
static void AtCommit_Locks(void);
|
||||||
static void AtCommit_Memory(void);
|
static void AtCommit_Memory(void);
|
||||||
static void AtStart_Cache(void);
|
static void AtStart_Cache(void);
|
||||||
static void AtStart_Locks(void);
|
static void AtStart_Locks(void);
|
||||||
static void AtStart_Memory(void);
|
static void AtStart_Memory(void);
|
||||||
static void CommitTransaction(void);
|
static void CommitTransaction(void);
|
||||||
static void RecordTransactionAbort(void);
|
static void RecordTransactionAbort(void);
|
||||||
static void RecordTransactionCommit(void);
|
static void RecordTransactionCommit(void);
|
||||||
static void StartTransaction(void);
|
static void StartTransaction(void);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* global variables holding the current transaction state.
|
* global variables holding the current transaction state.
|
||||||
@@ -202,17 +202,17 @@ TransactionState CurrentTransactionState =
|
|||||||
* V1 transaction system. -cim 3/18/90
|
* V1 transaction system. -cim 3/18/90
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
TransactionId DisabledTransactionId = (TransactionId) - 1;
|
TransactionId DisabledTransactionId = (TransactionId) - 1;
|
||||||
|
|
||||||
CommandId DisabledCommandId = (CommandId) - 1;
|
CommandId DisabledCommandId = (CommandId) - 1;
|
||||||
|
|
||||||
AbsoluteTime DisabledStartTime = (AbsoluteTime) BIG_ABSTIME; /* 1073741823; */
|
AbsoluteTime DisabledStartTime = (AbsoluteTime) BIG_ABSTIME; /* 1073741823; */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* overflow flag
|
* overflow flag
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
bool CommandIdCounterOverflowFlag;
|
bool CommandIdCounterOverflowFlag;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* catalog creation transaction bootstrapping flag.
|
* catalog creation transaction bootstrapping flag.
|
||||||
@@ -220,7 +220,7 @@ bool CommandIdCounterOverflowFlag;
|
|||||||
* state stuff. -cim 3/19/90
|
* state stuff. -cim 3/19/90
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
bool AMI_OVERRIDE = false;
|
bool AMI_OVERRIDE = false;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* transaction state accessors
|
* transaction state accessors
|
||||||
@@ -239,7 +239,7 @@ bool AMI_OVERRIDE = false;
|
|||||||
* only do writes as necessary.
|
* only do writes as necessary.
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static int TransactionFlushState = 1;
|
static int TransactionFlushState = 1;
|
||||||
|
|
||||||
int
|
int
|
||||||
TransactionFlushEnabled(void)
|
TransactionFlushEnabled(void)
|
||||||
@@ -270,18 +270,18 @@ IsTransactionState(void)
|
|||||||
|
|
||||||
switch (s->state)
|
switch (s->state)
|
||||||
{
|
{
|
||||||
case TRANS_DEFAULT:
|
case TRANS_DEFAULT:
|
||||||
return false;
|
return false;
|
||||||
case TRANS_START:
|
case TRANS_START:
|
||||||
return true;
|
return true;
|
||||||
case TRANS_INPROGRESS:
|
case TRANS_INPROGRESS:
|
||||||
return true;
|
return true;
|
||||||
case TRANS_COMMIT:
|
case TRANS_COMMIT:
|
||||||
return true;
|
return true;
|
||||||
case TRANS_ABORT:
|
case TRANS_ABORT:
|
||||||
return true;
|
return true;
|
||||||
case TRANS_DISABLED:
|
case TRANS_DISABLED:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -317,7 +317,7 @@ IsAbortedTransactionBlockState()
|
|||||||
* themselves.
|
* themselves.
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
int SavedTransactionState;
|
int SavedTransactionState;
|
||||||
|
|
||||||
void
|
void
|
||||||
OverrideTransactionSystem(bool flag)
|
OverrideTransactionSystem(bool flag)
|
||||||
@@ -564,8 +564,8 @@ AtStart_Locks()
|
|||||||
static void
|
static void
|
||||||
AtStart_Memory()
|
AtStart_Memory()
|
||||||
{
|
{
|
||||||
Portal portal;
|
Portal portal;
|
||||||
MemoryContext portalContext;
|
MemoryContext portalContext;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the blank portal and its memory context
|
* get the blank portal and its memory context
|
||||||
@@ -601,8 +601,8 @@ AtStart_Memory()
|
|||||||
static void
|
static void
|
||||||
RecordTransactionCommit()
|
RecordTransactionCommit()
|
||||||
{
|
{
|
||||||
TransactionId xid;
|
TransactionId xid;
|
||||||
int leak;
|
int leak;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the current transaction id
|
* get the current transaction id
|
||||||
@@ -701,7 +701,7 @@ AtCommit_Memory()
|
|||||||
static void
|
static void
|
||||||
RecordTransactionAbort()
|
RecordTransactionAbort()
|
||||||
{
|
{
|
||||||
TransactionId xid;
|
TransactionId xid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the current transaction id
|
* get the current transaction id
|
||||||
@@ -994,73 +994,73 @@ StartTransactionCommand()
|
|||||||
|
|
||||||
switch (s->blockState)
|
switch (s->blockState)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if we aren't in a transaction block, we
|
* if we aren't in a transaction block, we
|
||||||
* just do our usual start transaction.
|
* just do our usual start transaction.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_DEFAULT:
|
case TBLOCK_DEFAULT:
|
||||||
StartTransaction();
|
StartTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* We should never experience this -- if we do it
|
* We should never experience this -- if we do it
|
||||||
* means the BEGIN state was not changed in the previous
|
* means the BEGIN state was not changed in the previous
|
||||||
* CommitTransactionCommand(). If we get it, we print
|
* CommitTransactionCommand(). If we get it, we print
|
||||||
* a warning and change to the in-progress state.
|
* a warning and change to the in-progress state.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_BEGIN:
|
case TBLOCK_BEGIN:
|
||||||
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_BEGIN");
|
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_BEGIN");
|
||||||
s->blockState = TBLOCK_INPROGRESS;
|
s->blockState = TBLOCK_INPROGRESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* This is the case when are somewhere in a transaction
|
* This is the case when are somewhere in a transaction
|
||||||
* block and about to start a new command. For now we
|
* block and about to start a new command. For now we
|
||||||
* do nothing but someday we may do command-local resource
|
* do nothing but someday we may do command-local resource
|
||||||
* initialization.
|
* initialization.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_INPROGRESS:
|
case TBLOCK_INPROGRESS:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* As with BEGIN, we should never experience this --
|
* As with BEGIN, we should never experience this --
|
||||||
* if we do it means the END state was not changed in the
|
* if we do it means the END state was not changed in the
|
||||||
* previous CommitTransactionCommand(). If we get it, we
|
* previous CommitTransactionCommand(). If we get it, we
|
||||||
* print a warning, commit the transaction, start a new
|
* print a warning, commit the transaction, start a new
|
||||||
* transaction and change to the default state.
|
* transaction and change to the default state.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_END:
|
case TBLOCK_END:
|
||||||
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_END");
|
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_END");
|
||||||
s->blockState = TBLOCK_DEFAULT;
|
s->blockState = TBLOCK_DEFAULT;
|
||||||
CommitTransaction();
|
CommitTransaction();
|
||||||
StartTransaction();
|
StartTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Here we are in the middle of a transaction block but
|
* Here we are in the middle of a transaction block but
|
||||||
* one of the commands caused an abort so we do nothing
|
* one of the commands caused an abort so we do nothing
|
||||||
* but remain in the abort state. Eventually we will get
|
* but remain in the abort state. Eventually we will get
|
||||||
* to the "END TRANSACTION" which will set things straight.
|
* to the "END TRANSACTION" which will set things straight.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_ABORT:
|
case TBLOCK_ABORT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* This means we somehow aborted and the last call to
|
* This means we somehow aborted and the last call to
|
||||||
* CommitTransactionCommand() didn't clear the state so
|
* CommitTransactionCommand() didn't clear the state so
|
||||||
* we remain in the ENDABORT state and mabey next time
|
* we remain in the ENDABORT state and mabey next time
|
||||||
* we get to CommitTransactionCommand() the state will
|
* we get to CommitTransactionCommand() the state will
|
||||||
* get reset to default.
|
* get reset to default.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_ENDABORT:
|
case TBLOCK_ENDABORT:
|
||||||
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_ENDABORT");
|
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_ENDABORT");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,75 +1075,75 @@ CommitTransactionCommand()
|
|||||||
|
|
||||||
switch (s->blockState)
|
switch (s->blockState)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if we aren't in a transaction block, we
|
* if we aren't in a transaction block, we
|
||||||
* just do our usual transaction commit
|
* just do our usual transaction commit
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_DEFAULT:
|
case TBLOCK_DEFAULT:
|
||||||
CommitTransaction();
|
CommitTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* This is the case right after we get a "BEGIN TRANSACTION"
|
* This is the case right after we get a "BEGIN TRANSACTION"
|
||||||
* command, but the user hasn't done anything else yet, so
|
* command, but the user hasn't done anything else yet, so
|
||||||
* we change to the "transaction block in progress" state
|
* we change to the "transaction block in progress" state
|
||||||
* and return.
|
* and return.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_BEGIN:
|
case TBLOCK_BEGIN:
|
||||||
s->blockState = TBLOCK_INPROGRESS;
|
s->blockState = TBLOCK_INPROGRESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* This is the case when we have finished executing a command
|
* This is the case when we have finished executing a command
|
||||||
* someplace within a transaction block. We increment the
|
* someplace within a transaction block. We increment the
|
||||||
* command counter and return. Someday we may free resources
|
* command counter and return. Someday we may free resources
|
||||||
* local to the command.
|
* local to the command.
|
||||||
*
|
*
|
||||||
* That someday is today, at least for memory allocated by
|
* That someday is today, at least for memory allocated by
|
||||||
* command in the BlankPortal' HeapMemory context.
|
* command in the BlankPortal' HeapMemory context.
|
||||||
* - vadim 03/25/97
|
* - vadim 03/25/97
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_INPROGRESS:
|
case TBLOCK_INPROGRESS:
|
||||||
CommandCounterIncrement();
|
CommandCounterIncrement();
|
||||||
#ifdef TBL_FREE_CMD_MEMORY
|
#ifdef TBL_FREE_CMD_MEMORY
|
||||||
EndPortalAllocMode();
|
EndPortalAllocMode();
|
||||||
StartPortalAllocMode(DefaultAllocMode, 0);
|
StartPortalAllocMode(DefaultAllocMode, 0);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* This is the case when we just got the "END TRANSACTION"
|
* This is the case when we just got the "END TRANSACTION"
|
||||||
* statement, so we go back to the default state and
|
* statement, so we go back to the default state and
|
||||||
* commit the transaction.
|
* commit the transaction.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_END:
|
case TBLOCK_END:
|
||||||
s->blockState = TBLOCK_DEFAULT;
|
s->blockState = TBLOCK_DEFAULT;
|
||||||
CommitTransaction();
|
CommitTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Here we are in the middle of a transaction block but
|
* Here we are in the middle of a transaction block but
|
||||||
* one of the commands caused an abort so we do nothing
|
* one of the commands caused an abort so we do nothing
|
||||||
* but remain in the abort state. Eventually we will get
|
* but remain in the abort state. Eventually we will get
|
||||||
* to the "END TRANSACTION" which will set things straight.
|
* to the "END TRANSACTION" which will set things straight.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_ABORT:
|
case TBLOCK_ABORT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Here we were in an aborted transaction block which
|
* Here we were in an aborted transaction block which
|
||||||
* just processed the "END TRANSACTION" command from the
|
* just processed the "END TRANSACTION" command from the
|
||||||
* user, so now we return the to default state.
|
* user, so now we return the to default state.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_ENDABORT:
|
case TBLOCK_ENDABORT:
|
||||||
s->blockState = TBLOCK_DEFAULT;
|
s->blockState = TBLOCK_DEFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,71 +1158,71 @@ AbortCurrentTransaction()
|
|||||||
|
|
||||||
switch (s->blockState)
|
switch (s->blockState)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if we aren't in a transaction block, we
|
* if we aren't in a transaction block, we
|
||||||
* just do our usual abort transaction.
|
* just do our usual abort transaction.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_DEFAULT:
|
case TBLOCK_DEFAULT:
|
||||||
AbortTransaction();
|
AbortTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* If we are in the TBLOCK_BEGIN it means something
|
* If we are in the TBLOCK_BEGIN it means something
|
||||||
* screwed up right after reading "BEGIN TRANSACTION"
|
* screwed up right after reading "BEGIN TRANSACTION"
|
||||||
* so we enter the abort state. Eventually an "END
|
* so we enter the abort state. Eventually an "END
|
||||||
* TRANSACTION" will fix things.
|
* TRANSACTION" will fix things.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_BEGIN:
|
case TBLOCK_BEGIN:
|
||||||
s->blockState = TBLOCK_ABORT;
|
s->blockState = TBLOCK_ABORT;
|
||||||
AbortTransaction();
|
AbortTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* This is the case when are somewhere in a transaction
|
* This is the case when are somewhere in a transaction
|
||||||
* block which aborted so we abort the transaction and
|
* block which aborted so we abort the transaction and
|
||||||
* set the ABORT state. Eventually an "END TRANSACTION"
|
* set the ABORT state. Eventually an "END TRANSACTION"
|
||||||
* will fix things and restore us to a normal state.
|
* will fix things and restore us to a normal state.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_INPROGRESS:
|
case TBLOCK_INPROGRESS:
|
||||||
s->blockState = TBLOCK_ABORT;
|
s->blockState = TBLOCK_ABORT;
|
||||||
AbortTransaction();
|
AbortTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Here, the system was fouled up just after the
|
* Here, the system was fouled up just after the
|
||||||
* user wanted to end the transaction block so we
|
* user wanted to end the transaction block so we
|
||||||
* abort the transaction and put us back into the
|
* abort the transaction and put us back into the
|
||||||
* default state.
|
* default state.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_END:
|
case TBLOCK_END:
|
||||||
s->blockState = TBLOCK_DEFAULT;
|
s->blockState = TBLOCK_DEFAULT;
|
||||||
AbortTransaction();
|
AbortTransaction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Here, we are already in an aborted transaction
|
* Here, we are already in an aborted transaction
|
||||||
* state and are waiting for an "END TRANSACTION" to
|
* state and are waiting for an "END TRANSACTION" to
|
||||||
* come along and lo and behold, we abort again!
|
* come along and lo and behold, we abort again!
|
||||||
* So we just remain in the abort state.
|
* So we just remain in the abort state.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_ABORT:
|
case TBLOCK_ABORT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Here we were in an aborted transaction block which
|
* Here we were in an aborted transaction block which
|
||||||
* just processed the "END TRANSACTION" command but somehow
|
* just processed the "END TRANSACTION" command but somehow
|
||||||
* aborted again.. since we must have done the abort
|
* aborted again.. since we must have done the abort
|
||||||
* processing, we return to the default state.
|
* processing, we return to the default state.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case TBLOCK_ENDABORT:
|
case TBLOCK_ENDABORT:
|
||||||
s->blockState = TBLOCK_DEFAULT;
|
s->blockState = TBLOCK_DEFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.8 1997/09/07 04:39:40 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.9 1997/09/08 02:21:24 momjian Exp $
|
||||||
*
|
*
|
||||||
* OLD COMMENTS
|
* OLD COMMENTS
|
||||||
* XXX WARNING
|
* XXX WARNING
|
||||||
@@ -50,11 +50,11 @@ xidin(char *representation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX char16 name for catalogs */
|
/* XXX char16 name for catalogs */
|
||||||
char *
|
char *
|
||||||
xidout(TransactionId transactionId)
|
xidout(TransactionId transactionId)
|
||||||
{
|
{
|
||||||
/* return(TransactionIdFormString(transactionId)); */
|
/* return(TransactionIdFormString(transactionId)); */
|
||||||
char *representation;
|
char *representation;
|
||||||
|
|
||||||
/* maximum 32 bit unsigned integer representation takes 10 chars */
|
/* maximum 32 bit unsigned integer representation takes 10 chars */
|
||||||
representation = palloc(11);
|
representation = palloc(11);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.22 1997/09/07 04:39:49 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.23 1997/09/08 02:21:29 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -103,14 +103,14 @@
|
|||||||
#define ALLOC(t, c) (t *)calloc((unsigned)(c), sizeof(t))
|
#define ALLOC(t, c) (t *)calloc((unsigned)(c), sizeof(t))
|
||||||
#define FIRST_TYPE_OID 16 /* OID of the first type */
|
#define FIRST_TYPE_OID 16 /* OID of the first type */
|
||||||
|
|
||||||
extern int Int_yyparse(void);
|
extern int Int_yyparse(void);
|
||||||
static hashnode *AddStr(char *str, int strlength, int mderef);
|
static hashnode *AddStr(char *str, int strlength, int mderef);
|
||||||
static AttributeTupleForm AllocateAttribute(void);
|
static AttributeTupleForm AllocateAttribute(void);
|
||||||
static bool BootstrapAlreadySeen(Oid id);
|
static bool BootstrapAlreadySeen(Oid id);
|
||||||
static int CompHash(char *str, int len);
|
static int CompHash(char *str, int len);
|
||||||
static hashnode *FindStr(char *str, int length, hashnode * mderef);
|
static hashnode *FindStr(char *str, int length, hashnode * mderef);
|
||||||
static int gettype(char *type);
|
static int gettype(char *type);
|
||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* global variables
|
* global variables
|
||||||
@@ -134,11 +134,10 @@ static void cleanup(void);
|
|||||||
#define NUMSQR 529
|
#define NUMSQR 529
|
||||||
#define NUMCUBE 12167
|
#define NUMCUBE 12167
|
||||||
|
|
||||||
char *strtable[STRTABLESIZE];
|
char *strtable[STRTABLESIZE];
|
||||||
hashnode *hashtable[HASHTABLESIZE];
|
hashnode *hashtable[HASHTABLESIZE];
|
||||||
|
|
||||||
static int strtable_end = -1; /* Tells us last occupied string
|
static int strtable_end = -1; /* Tells us last occupied string space */
|
||||||
* space */
|
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Basic information associated with each type. This is used before
|
* Basic information associated with each type. This is used before
|
||||||
@@ -150,12 +149,12 @@ static int strtable_end = -1; /* Tells us last occupied string
|
|||||||
*/
|
*/
|
||||||
struct typinfo
|
struct typinfo
|
||||||
{
|
{
|
||||||
char name[NAMEDATALEN];
|
char name[NAMEDATALEN];
|
||||||
Oid oid;
|
Oid oid;
|
||||||
Oid elem;
|
Oid elem;
|
||||||
int16 len;
|
int16 len;
|
||||||
Oid inproc;
|
Oid inproc;
|
||||||
Oid outproc;
|
Oid outproc;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct typinfo Procid[] = {
|
static struct typinfo Procid[] = {
|
||||||
@@ -180,29 +179,29 @@ static struct typinfo Procid[] = {
|
|||||||
{"_aclitem", 1034, 1033, -1, F_ARRAY_IN, F_ARRAY_OUT}
|
{"_aclitem", 1034, 1033, -1, F_ARRAY_IN, F_ARRAY_OUT}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int n_types = sizeof(Procid) / sizeof(struct typinfo);
|
static int n_types = sizeof(Procid) / sizeof(struct typinfo);
|
||||||
|
|
||||||
struct typmap
|
struct typmap
|
||||||
{ /* a hack */
|
{ /* a hack */
|
||||||
Oid am_oid;
|
Oid am_oid;
|
||||||
TypeTupleFormData am_typ;
|
TypeTupleFormData am_typ;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct typmap **Typ = (struct typmap **) NULL;
|
static struct typmap **Typ = (struct typmap **) NULL;
|
||||||
static struct typmap *Ap = (struct typmap *) NULL;
|
static struct typmap *Ap = (struct typmap *) NULL;
|
||||||
|
|
||||||
static int Warnings = 0;
|
static int Warnings = 0;
|
||||||
static char Blanks[MAXATTR];
|
static char Blanks[MAXATTR];
|
||||||
|
|
||||||
static char *relname; /* current relation name */
|
static char *relname; /* current relation name */
|
||||||
|
|
||||||
AttributeTupleForm attrtypes[MAXATTR]; /* points to attribute info */
|
AttributeTupleForm attrtypes[MAXATTR]; /* points to attribute info */
|
||||||
static char *values[MAXATTR];/* cooresponding attribute values */
|
static char *values[MAXATTR]; /* cooresponding attribute values */
|
||||||
int numattr; /* number of attributes for cur. rel */
|
int numattr; /* number of attributes for cur. rel */
|
||||||
extern int fsyncOff; /* do not fsync the database */
|
extern int fsyncOff; /* do not fsync the database */
|
||||||
|
|
||||||
#ifndef HAVE_SIGSETJMP
|
#ifndef HAVE_SIGSETJMP
|
||||||
static jmp_buf Warn_restart;
|
static jmp_buf Warn_restart;
|
||||||
|
|
||||||
#define sigsetjmp(x,y) setjmp(x)
|
#define sigsetjmp(x,y) setjmp(x)
|
||||||
#define siglongjmp longjmp
|
#define siglongjmp longjmp
|
||||||
@@ -211,12 +210,12 @@ static sigjmp_buf Warn_restart;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int DebugMode;
|
int DebugMode;
|
||||||
static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem
|
static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem
|
||||||
* context */
|
* context */
|
||||||
|
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At bootstrap time, we first declare all the indices to be built, and
|
* At bootstrap time, we first declare all the indices to be built, and
|
||||||
@@ -226,20 +225,20 @@ extern char *optarg;
|
|||||||
|
|
||||||
typedef struct _IndexList
|
typedef struct _IndexList
|
||||||
{
|
{
|
||||||
char *il_heap;
|
char *il_heap;
|
||||||
char *il_ind;
|
char *il_ind;
|
||||||
int il_natts;
|
int il_natts;
|
||||||
AttrNumber *il_attnos;
|
AttrNumber *il_attnos;
|
||||||
uint16 il_nparams;
|
uint16 il_nparams;
|
||||||
Datum *il_params;
|
Datum *il_params;
|
||||||
FuncIndexInfo *il_finfo;
|
FuncIndexInfo *il_finfo;
|
||||||
PredInfo *il_predInfo;
|
PredInfo *il_predInfo;
|
||||||
struct _IndexList *il_next;
|
struct _IndexList *il_next;
|
||||||
} IndexList;
|
} IndexList;
|
||||||
|
|
||||||
static IndexList *ILHead = (IndexList *) NULL;
|
static IndexList *ILHead = (IndexList *) NULL;
|
||||||
|
|
||||||
typedef void (*sig_func) ();
|
typedef void (*sig_func) ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -293,15 +292,15 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int portFd = -1;
|
int portFd = -1;
|
||||||
char *dbName;
|
char *dbName;
|
||||||
int flag;
|
int flag;
|
||||||
int override = 1; /* use BootstrapProcessing or
|
int override = 1; /* use BootstrapProcessing or
|
||||||
* InitProcessing mode */
|
* InitProcessing mode */
|
||||||
|
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* initialize signal handlers
|
* initialize signal handlers
|
||||||
@@ -335,30 +334,30 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
switch (flag)
|
switch (flag)
|
||||||
{
|
{
|
||||||
case 'D':
|
case 'D':
|
||||||
DataDir = optarg;
|
DataDir = optarg;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
DebugMode = 1; /* print out debugging info while parsing */
|
DebugMode = 1; /* print out debugging info while parsing */
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
Noversion = 1;
|
Noversion = 1;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
fsyncOff = 1;
|
fsyncOff = 1;
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
override = true;
|
override = true;
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
Quiet = 1;
|
Quiet = 1;
|
||||||
break;
|
break;
|
||||||
case 'P': /* specify port */
|
case 'P': /* specify port */
|
||||||
portFd = atoi(optarg);
|
portFd = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
@@ -475,11 +474,11 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
void
|
void
|
||||||
boot_openrel(char *relname)
|
boot_openrel(char *relname)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct typmap **app;
|
struct typmap **app;
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
HeapScanDesc sdesc;
|
HeapScanDesc sdesc;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
if (strlen(relname) > 15)
|
if (strlen(relname) > 15)
|
||||||
relname[15] = '\000';
|
relname[15] = '\000';
|
||||||
@@ -603,8 +602,8 @@ closerel(char *name)
|
|||||||
void
|
void
|
||||||
DefineAttr(char *name, char *type, int attnum)
|
DefineAttr(char *name, char *type, int attnum)
|
||||||
{
|
{
|
||||||
int attlen;
|
int attlen;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
if (reldesc != NULL)
|
if (reldesc != NULL)
|
||||||
{
|
{
|
||||||
@@ -646,10 +645,10 @@ DefineAttr(char *name, char *type, int attnum)
|
|||||||
void
|
void
|
||||||
InsertOneTuple(Oid objectid)
|
InsertOneTuple(Oid objectid)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (DebugMode)
|
if (DebugMode)
|
||||||
{
|
{
|
||||||
@@ -687,8 +686,8 @@ InsertOneTuple(Oid objectid)
|
|||||||
void
|
void
|
||||||
InsertOneValue(Oid objectid, char *value, int i)
|
InsertOneValue(Oid objectid, char *value, int i)
|
||||||
{
|
{
|
||||||
int typeindex;
|
int typeindex;
|
||||||
char *prt;
|
char *prt;
|
||||||
struct typmap **app;
|
struct typmap **app;
|
||||||
|
|
||||||
if (DebugMode)
|
if (DebugMode)
|
||||||
@@ -701,7 +700,7 @@ InsertOneValue(Oid objectid, char *value, int i)
|
|||||||
|
|
||||||
if (Typ != (struct typmap **) NULL)
|
if (Typ != (struct typmap **) NULL)
|
||||||
{
|
{
|
||||||
struct typmap *ap;
|
struct typmap *ap;
|
||||||
|
|
||||||
if (DebugMode)
|
if (DebugMode)
|
||||||
puts("Typ != NULL");
|
puts("Typ != NULL");
|
||||||
@@ -767,13 +766,13 @@ InsertOneNull(int i)
|
|||||||
|
|
||||||
#define MORE_THAN_THE_NUMBER_OF_CATALOGS 256
|
#define MORE_THAN_THE_NUMBER_OF_CATALOGS 256
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
BootstrapAlreadySeen(Oid id)
|
BootstrapAlreadySeen(Oid id)
|
||||||
{
|
{
|
||||||
static Oid seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS];
|
static Oid seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS];
|
||||||
static int nseen = 0;
|
static int nseen = 0;
|
||||||
bool seenthis;
|
bool seenthis;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
seenthis = false;
|
seenthis = false;
|
||||||
|
|
||||||
@@ -800,7 +799,7 @@ BootstrapAlreadySeen(Oid id)
|
|||||||
static void
|
static void
|
||||||
cleanup()
|
cleanup()
|
||||||
{
|
{
|
||||||
static int beenhere = 0;
|
static int beenhere = 0;
|
||||||
|
|
||||||
if (!beenhere)
|
if (!beenhere)
|
||||||
beenhere = 1;
|
beenhere = 1;
|
||||||
@@ -824,10 +823,10 @@ cleanup()
|
|||||||
static int
|
static int
|
||||||
gettype(char *type)
|
gettype(char *type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
HeapScanDesc sdesc;
|
HeapScanDesc sdesc;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
struct typmap **app;
|
struct typmap **app;
|
||||||
|
|
||||||
if (Typ != (struct typmap **) NULL)
|
if (Typ != (struct typmap **) NULL)
|
||||||
@@ -885,7 +884,7 @@ gettype(char *type)
|
|||||||
* AllocateAttribute
|
* AllocateAttribute
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static AttributeTupleForm /* XXX */
|
static AttributeTupleForm /* XXX */
|
||||||
AllocateAttribute()
|
AllocateAttribute()
|
||||||
{
|
{
|
||||||
AttributeTupleForm attribute =
|
AttributeTupleForm attribute =
|
||||||
@@ -914,13 +913,13 @@ AllocateAttribute()
|
|||||||
* be freed by the CALLER.
|
* be freed by the CALLER.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
MapArrayTypeName(char *s)
|
MapArrayTypeName(char *s)
|
||||||
{
|
{
|
||||||
int i,
|
int i,
|
||||||
j;
|
j;
|
||||||
static char newStr[NAMEDATALEN]; /* array type names <
|
static char newStr[NAMEDATALEN]; /* array type names < NAMEDATALEN
|
||||||
* NAMEDATALEN long */
|
* long */
|
||||||
|
|
||||||
if (s == NULL || s[0] == '\0')
|
if (s == NULL || s[0] == '\0')
|
||||||
return s;
|
return s;
|
||||||
@@ -944,8 +943,8 @@ MapArrayTypeName(char *s)
|
|||||||
int
|
int
|
||||||
EnterString(char *str)
|
EnterString(char *str)
|
||||||
{
|
{
|
||||||
hashnode *node;
|
hashnode *node;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
@@ -967,7 +966,7 @@ EnterString(char *str)
|
|||||||
* associated with the idnum
|
* associated with the idnum
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
LexIDStr(int ident_num)
|
LexIDStr(int ident_num)
|
||||||
{
|
{
|
||||||
return (strtable[ident_num]);
|
return (strtable[ident_num]);
|
||||||
@@ -986,7 +985,7 @@ LexIDStr(int ident_num)
|
|||||||
static int
|
static int
|
||||||
CompHash(char *str, int len)
|
CompHash(char *str, int len)
|
||||||
{
|
{
|
||||||
register int result;
|
register int result;
|
||||||
|
|
||||||
result = (NUM * str[0] + NUMSQR * str[len - 1] + NUMCUBE * str[(len - 1) / 2]);
|
result = (NUM * str[0] + NUMSQR * str[len - 1] + NUMCUBE * str[(len - 1) / 2]);
|
||||||
|
|
||||||
@@ -1005,7 +1004,7 @@ CompHash(char *str, int len)
|
|||||||
static hashnode *
|
static hashnode *
|
||||||
FindStr(char *str, int length, hashnode * mderef)
|
FindStr(char *str, int length, hashnode * mderef)
|
||||||
{
|
{
|
||||||
hashnode *node;
|
hashnode *node;
|
||||||
|
|
||||||
node = hashtable[CompHash(str, length)];
|
node = hashtable[CompHash(str, length)];
|
||||||
while (node != NULL)
|
while (node != NULL)
|
||||||
@@ -1040,11 +1039,11 @@ FindStr(char *str, int length, hashnode * mderef)
|
|||||||
static hashnode *
|
static hashnode *
|
||||||
AddStr(char *str, int strlength, int mderef)
|
AddStr(char *str, int strlength, int mderef)
|
||||||
{
|
{
|
||||||
hashnode *temp,
|
hashnode *temp,
|
||||||
*trail,
|
*trail,
|
||||||
*newnode;
|
*newnode;
|
||||||
int hashresult;
|
int hashresult;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (++strtable_end == STRTABLESIZE)
|
if (++strtable_end == STRTABLESIZE)
|
||||||
{
|
{
|
||||||
@@ -1118,10 +1117,10 @@ index_register(char *heap,
|
|||||||
FuncIndexInfo * finfo,
|
FuncIndexInfo * finfo,
|
||||||
PredInfo * predInfo)
|
PredInfo * predInfo)
|
||||||
{
|
{
|
||||||
Datum *v;
|
Datum *v;
|
||||||
IndexList *newind;
|
IndexList *newind;
|
||||||
int len;
|
int len;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX mao 10/31/92 -- don't gc index reldescs, associated info at
|
* XXX mao 10/31/92 -- don't gc index reldescs, associated info at
|
||||||
@@ -1193,8 +1192,8 @@ index_register(char *heap,
|
|||||||
void
|
void
|
||||||
build_indices()
|
build_indices()
|
||||||
{
|
{
|
||||||
Relation heap;
|
Relation heap;
|
||||||
Relation ind;
|
Relation ind;
|
||||||
|
|
||||||
for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next)
|
for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.8 1997/09/07 04:40:00 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.9 1997/09/08 02:21:33 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
* relpath - path to the relation
|
* relpath - path to the relation
|
||||||
* Perhaps this should be in-line code in relopen().
|
* Perhaps this should be in-line code in relopen().
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
relpath(char relname[])
|
relpath(char relname[])
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
if (IsSharedSystemRelationName(relname))
|
if (IsSharedSystemRelationName(relname))
|
||||||
{
|
{
|
||||||
@@ -91,7 +91,7 @@ IsSystemRelationName(char *relname)
|
|||||||
bool
|
bool
|
||||||
IsSharedSystemRelationName(char *relname)
|
IsSharedSystemRelationName(char *relname)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Quick out: if it's not a system relation, it can't be a shared
|
* Quick out: if it's not a system relation, it can't be a shared
|
||||||
@@ -128,7 +128,7 @@ IsSharedSystemRelationName(char *relname)
|
|||||||
Oid
|
Oid
|
||||||
newoid()
|
newoid()
|
||||||
{
|
{
|
||||||
Oid lastoid;
|
Oid lastoid;
|
||||||
|
|
||||||
GetNewObjectId(&lastoid);
|
GetNewObjectId(&lastoid);
|
||||||
if (!OidIsValid(lastoid))
|
if (!OidIsValid(lastoid))
|
||||||
@@ -156,9 +156,9 @@ fillatt(TupleDesc tupleDesc)
|
|||||||
{
|
{
|
||||||
AttributeTupleForm *attributeP;
|
AttributeTupleForm *attributeP;
|
||||||
register TypeTupleForm typp;
|
register TypeTupleForm typp;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
int i;
|
int i;
|
||||||
int natts = tupleDesc->natts;
|
int natts = tupleDesc->natts;
|
||||||
AttributeTupleForm *att = tupleDesc->attrs;
|
AttributeTupleForm *att = tupleDesc->attrs;
|
||||||
|
|
||||||
if (natts < 0 || natts > MaxHeapAttributeNumber)
|
if (natts < 0 || natts > MaxHeapAttributeNumber)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.25 1997/09/07 04:40:10 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.26 1997/09/08 02:21:37 momjian Exp $
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
* heap_creatr() - Create an uncataloged heap relation
|
* heap_creatr() - Create an uncataloged heap relation
|
||||||
@@ -61,17 +61,17 @@
|
|||||||
static void
|
static void
|
||||||
AddPgRelationTuple(Relation pg_class_desc,
|
AddPgRelationTuple(Relation pg_class_desc,
|
||||||
Relation new_rel_desc, Oid new_rel_oid, int arch, unsigned natts);
|
Relation new_rel_desc, Oid new_rel_oid, int arch, unsigned natts);
|
||||||
static void AddToTempRelList(Relation r);
|
static void AddToTempRelList(Relation r);
|
||||||
static void DeletePgAttributeTuples(Relation rdesc);
|
static void DeletePgAttributeTuples(Relation rdesc);
|
||||||
static void DeletePgRelationTuple(Relation rdesc);
|
static void DeletePgRelationTuple(Relation rdesc);
|
||||||
static void DeletePgTypeTuple(Relation rdesc);
|
static void DeletePgTypeTuple(Relation rdesc);
|
||||||
static int RelationAlreadyExists(Relation pg_class_desc, char relname[]);
|
static int RelationAlreadyExists(Relation pg_class_desc, char relname[]);
|
||||||
static void RelationRemoveIndexes(Relation relation);
|
static void RelationRemoveIndexes(Relation relation);
|
||||||
static void RelationRemoveInheritance(Relation relation);
|
static void RelationRemoveInheritance(Relation relation);
|
||||||
static void RemoveFromTempRelList(Relation r);
|
static void RemoveFromTempRelList(Relation r);
|
||||||
static void addNewRelationType(char *typeName, Oid new_rel_oid);
|
static void addNewRelationType(char *typeName, Oid new_rel_oid);
|
||||||
static void StoreConstraints(Relation rel);
|
static void StoreConstraints(Relation rel);
|
||||||
static void RemoveConstraints(Relation rel);
|
static void RemoveConstraints(Relation rel);
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
@@ -160,11 +160,11 @@ static AttributeTupleForm HeapAtt[] =
|
|||||||
*/
|
*/
|
||||||
typedef struct tempRelList
|
typedef struct tempRelList
|
||||||
{
|
{
|
||||||
Relation *rels; /* array of relation descriptors */
|
Relation *rels; /* array of relation descriptors */
|
||||||
int num; /* number of temporary relations */
|
int num; /* number of temporary relations */
|
||||||
int size; /* size of space allocated for the rels
|
int size; /* size of space allocated for the rels
|
||||||
* array */
|
* array */
|
||||||
} TempRelList;
|
} TempRelList;
|
||||||
|
|
||||||
#define TEMP_REL_LIST_SIZE 32
|
#define TEMP_REL_LIST_SIZE 32
|
||||||
|
|
||||||
@@ -194,19 +194,19 @@ heap_creatr(char *name,
|
|||||||
TupleDesc tupDesc)
|
TupleDesc tupDesc)
|
||||||
{
|
{
|
||||||
register unsigned i;
|
register unsigned i;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
int len;
|
int len;
|
||||||
bool nailme = false;
|
bool nailme = false;
|
||||||
char *relname = name;
|
char *relname = name;
|
||||||
char tempname[40];
|
char tempname[40];
|
||||||
int isTemp = 0;
|
int isTemp = 0;
|
||||||
int natts = tupDesc->natts;
|
int natts = tupDesc->natts;
|
||||||
|
|
||||||
/* AttributeTupleForm *att = tupDesc->attrs; */
|
/* AttributeTupleForm *att = tupDesc->attrs; */
|
||||||
|
|
||||||
extern GlobalMemory CacheCxt;
|
extern GlobalMemory CacheCxt;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -425,9 +425,9 @@ heap_creatr(char *name,
|
|||||||
static void
|
static void
|
||||||
CheckAttributeNames(TupleDesc tupdesc)
|
CheckAttributeNames(TupleDesc tupdesc)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned j;
|
unsigned j;
|
||||||
int natts = tupdesc->natts;
|
int natts = tupdesc->natts;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* first check for collision with system attribute names
|
* first check for collision with system attribute names
|
||||||
@@ -487,9 +487,9 @@ CheckAttributeNames(TupleDesc tupdesc)
|
|||||||
static int
|
static int
|
||||||
RelationAlreadyExists(Relation pg_class_desc, char relname[])
|
RelationAlreadyExists(Relation pg_class_desc, char relname[])
|
||||||
{
|
{
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapScanDesc pg_class_scan;
|
HeapScanDesc pg_class_scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is not bootstrap (initdb) time, use the catalog index on
|
* If this is not bootstrap (initdb) time, use the catalog index on
|
||||||
@@ -558,12 +558,12 @@ AddNewAttributeTuples(Oid new_rel_oid,
|
|||||||
TupleDesc tupdesc)
|
TupleDesc tupdesc)
|
||||||
{
|
{
|
||||||
AttributeTupleForm *dpp;
|
AttributeTupleForm *dpp;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
bool hasindex;
|
bool hasindex;
|
||||||
Relation idescs[Num_pg_attr_indices];
|
Relation idescs[Num_pg_attr_indices];
|
||||||
int natts = tupdesc->natts;
|
int natts = tupdesc->natts;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open pg_attribute
|
* open pg_attribute
|
||||||
@@ -659,12 +659,12 @@ AddPgRelationTuple(Relation pg_class_desc,
|
|||||||
int arch,
|
int arch,
|
||||||
unsigned natts)
|
unsigned natts)
|
||||||
{
|
{
|
||||||
Form_pg_class new_rel_reltup;
|
Form_pg_class new_rel_reltup;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Relation idescs[Num_pg_class_indices];
|
Relation idescs[Num_pg_class_indices];
|
||||||
bool isBootstrap;
|
bool isBootstrap;
|
||||||
extern bool ItsSequenceCreation; /* It's hack, I know... -
|
extern bool ItsSequenceCreation; /* It's hack, I know... - vadim
|
||||||
* vadim 03/28/97 */
|
* 03/28/97 */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* first we munge some of the information in our
|
* first we munge some of the information in our
|
||||||
@@ -737,7 +737,7 @@ AddPgRelationTuple(Relation pg_class_desc,
|
|||||||
static void
|
static void
|
||||||
addNewRelationType(char *typeName, Oid new_rel_oid)
|
addNewRelationType(char *typeName, Oid new_rel_oid)
|
||||||
{
|
{
|
||||||
Oid new_type_oid;
|
Oid new_type_oid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The sizes are set to oid size because it makes implementing sets
|
* The sizes are set to oid size because it makes implementing sets
|
||||||
@@ -778,12 +778,12 @@ heap_create(char relname[],
|
|||||||
unsigned smgr,
|
unsigned smgr,
|
||||||
TupleDesc tupdesc)
|
TupleDesc tupdesc)
|
||||||
{
|
{
|
||||||
Relation pg_class_desc;
|
Relation pg_class_desc;
|
||||||
Relation new_rel_desc;
|
Relation new_rel_desc;
|
||||||
Oid new_rel_oid;
|
Oid new_rel_oid;
|
||||||
|
|
||||||
/* NameData typeNameData; */
|
/* NameData typeNameData; */
|
||||||
int natts = tupdesc->natts;
|
int natts = tupdesc->natts;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -906,10 +906,10 @@ heap_create(char relname[],
|
|||||||
static void
|
static void
|
||||||
RelationRemoveInheritance(Relation relation)
|
RelationRemoveInheritance(Relation relation)
|
||||||
{
|
{
|
||||||
Relation catalogRelation;
|
Relation catalogRelation;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
ScanKeyData entry;
|
ScanKeyData entry;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open pg_inherits
|
* open pg_inherits
|
||||||
@@ -1010,10 +1010,10 @@ RelationRemoveInheritance(Relation relation)
|
|||||||
static void
|
static void
|
||||||
RelationRemoveIndexes(Relation relation)
|
RelationRemoveIndexes(Relation relation)
|
||||||
{
|
{
|
||||||
Relation indexRelation;
|
Relation indexRelation;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
ScanKeyData entry;
|
ScanKeyData entry;
|
||||||
|
|
||||||
indexRelation = heap_openr(IndexRelationName);
|
indexRelation = heap_openr(IndexRelationName);
|
||||||
|
|
||||||
@@ -1050,10 +1050,10 @@ RelationRemoveIndexes(Relation relation)
|
|||||||
static void
|
static void
|
||||||
DeletePgRelationTuple(Relation rdesc)
|
DeletePgRelationTuple(Relation rdesc)
|
||||||
{
|
{
|
||||||
Relation pg_class_desc;
|
Relation pg_class_desc;
|
||||||
HeapScanDesc pg_class_scan;
|
HeapScanDesc pg_class_scan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open pg_class
|
* open pg_class
|
||||||
@@ -1108,10 +1108,10 @@ DeletePgRelationTuple(Relation rdesc)
|
|||||||
static void
|
static void
|
||||||
DeletePgAttributeTuples(Relation rdesc)
|
DeletePgAttributeTuples(Relation rdesc)
|
||||||
{
|
{
|
||||||
Relation pg_attribute_desc;
|
Relation pg_attribute_desc;
|
||||||
HeapScanDesc pg_attribute_scan;
|
HeapScanDesc pg_attribute_scan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open pg_attribute
|
* open pg_attribute
|
||||||
@@ -1178,15 +1178,15 @@ DeletePgAttributeTuples(Relation rdesc)
|
|||||||
static void
|
static void
|
||||||
DeletePgTypeTuple(Relation rdesc)
|
DeletePgTypeTuple(Relation rdesc)
|
||||||
{
|
{
|
||||||
Relation pg_type_desc;
|
Relation pg_type_desc;
|
||||||
HeapScanDesc pg_type_scan;
|
HeapScanDesc pg_type_scan;
|
||||||
Relation pg_attribute_desc;
|
Relation pg_attribute_desc;
|
||||||
HeapScanDesc pg_attribute_scan;
|
HeapScanDesc pg_attribute_scan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
ScanKeyData attkey;
|
ScanKeyData attkey;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
HeapTuple atttup;
|
HeapTuple atttup;
|
||||||
Oid typoid;
|
Oid typoid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open pg_type
|
* open pg_type
|
||||||
@@ -1254,7 +1254,7 @@ DeletePgTypeTuple(Relation rdesc)
|
|||||||
|
|
||||||
if (PointerIsValid(atttup))
|
if (PointerIsValid(atttup))
|
||||||
{
|
{
|
||||||
Oid relid = ((AttributeTupleForm) GETSTRUCT(atttup))->attrelid;
|
Oid relid = ((AttributeTupleForm) GETSTRUCT(atttup))->attrelid;
|
||||||
|
|
||||||
heap_endscan(pg_type_scan);
|
heap_endscan(pg_type_scan);
|
||||||
heap_close(pg_type_desc);
|
heap_close(pg_type_desc);
|
||||||
@@ -1287,8 +1287,8 @@ DeletePgTypeTuple(Relation rdesc)
|
|||||||
void
|
void
|
||||||
heap_destroy(char *relname)
|
heap_destroy(char *relname)
|
||||||
{
|
{
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
Oid rid;
|
Oid rid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* first open the relation. if the relation does exist,
|
* first open the relation. if the relation does exist,
|
||||||
@@ -1458,7 +1458,7 @@ InitTempRelList(void)
|
|||||||
static void
|
static void
|
||||||
RemoveFromTempRelList(Relation r)
|
RemoveFromTempRelList(Relation r)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!tempRels)
|
if (!tempRels)
|
||||||
return;
|
return;
|
||||||
@@ -1500,8 +1500,8 @@ AddToTempRelList(Relation r)
|
|||||||
void
|
void
|
||||||
DestroyTempRels(void)
|
DestroyTempRels(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
|
|
||||||
if (!tempRels)
|
if (!tempRels)
|
||||||
return;
|
return;
|
||||||
@@ -1518,30 +1518,30 @@ DestroyTempRels(void)
|
|||||||
tempRels = NULL;
|
tempRels = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern List *flatten_tlist(List * tlist);
|
extern List *flatten_tlist(List * tlist);
|
||||||
extern List *
|
extern List *
|
||||||
pg_plan(char *query_string, Oid * typev, int nargs,
|
pg_plan(char *query_string, Oid * typev, int nargs,
|
||||||
QueryTreeList ** queryListP, CommandDest dest);
|
QueryTreeList ** queryListP, CommandDest dest);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
StoreAttrDefault(Relation rel, AttrDefault * attrdef)
|
StoreAttrDefault(Relation rel, AttrDefault * attrdef)
|
||||||
{
|
{
|
||||||
char str[MAX_PARSE_BUFFER];
|
char str[MAX_PARSE_BUFFER];
|
||||||
char cast[2 * NAMEDATALEN] = {0};
|
char cast[2 * NAMEDATALEN] = {0};
|
||||||
AttributeTupleForm atp = rel->rd_att->attrs[attrdef->adnum - 1];
|
AttributeTupleForm atp = rel->rd_att->attrs[attrdef->adnum - 1];
|
||||||
QueryTreeList *queryTree_list;
|
QueryTreeList *queryTree_list;
|
||||||
Query *query;
|
Query *query;
|
||||||
List *planTree_list;
|
List *planTree_list;
|
||||||
TargetEntry *te;
|
TargetEntry *te;
|
||||||
Resdom *resdom;
|
Resdom *resdom;
|
||||||
Node *expr;
|
Node *expr;
|
||||||
char *adbin;
|
char *adbin;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
Relation adrel;
|
Relation adrel;
|
||||||
Relation idescs[Num_pg_attrdef_indices];
|
Relation idescs[Num_pg_attrdef_indices];
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Datum values[4];
|
Datum values[4];
|
||||||
char nulls[4] = {' ', ' ', ' ', ' '};
|
char nulls[4] = {' ', ' ', ' ', ' '};
|
||||||
extern GlobalMemory CacheCxt;
|
extern GlobalMemory CacheCxt;
|
||||||
|
|
||||||
start:;
|
start:;
|
||||||
@@ -1600,19 +1600,19 @@ start:;
|
|||||||
static void
|
static void
|
||||||
StoreRelCheck(Relation rel, ConstrCheck * check)
|
StoreRelCheck(Relation rel, ConstrCheck * check)
|
||||||
{
|
{
|
||||||
char str[MAX_PARSE_BUFFER];
|
char str[MAX_PARSE_BUFFER];
|
||||||
QueryTreeList *queryTree_list;
|
QueryTreeList *queryTree_list;
|
||||||
Query *query;
|
Query *query;
|
||||||
List *planTree_list;
|
List *planTree_list;
|
||||||
Plan *plan;
|
Plan *plan;
|
||||||
List *qual;
|
List *qual;
|
||||||
char *ccbin;
|
char *ccbin;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
Relation rcrel;
|
Relation rcrel;
|
||||||
Relation idescs[Num_pg_relcheck_indices];
|
Relation idescs[Num_pg_relcheck_indices];
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Datum values[4];
|
Datum values[4];
|
||||||
char nulls[4] = {' ', ' ', ' ', ' '};
|
char nulls[4] = {' ', ' ', ' ', ' '};
|
||||||
extern GlobalMemory CacheCxt;
|
extern GlobalMemory CacheCxt;
|
||||||
|
|
||||||
sprintf(str, "select 1 from %.*s where %s",
|
sprintf(str, "select 1 from %.*s where %s",
|
||||||
@@ -1659,8 +1659,8 @@ StoreRelCheck(Relation rel, ConstrCheck * check)
|
|||||||
static void
|
static void
|
||||||
StoreConstraints(Relation rel)
|
StoreConstraints(Relation rel)
|
||||||
{
|
{
|
||||||
TupleConstr *constr = rel->rd_att->constr;
|
TupleConstr *constr = rel->rd_att->constr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!constr)
|
if (!constr)
|
||||||
return;
|
return;
|
||||||
@@ -1683,10 +1683,10 @@ StoreConstraints(Relation rel)
|
|||||||
static void
|
static void
|
||||||
RemoveAttrDefault(Relation rel)
|
RemoveAttrDefault(Relation rel)
|
||||||
{
|
{
|
||||||
Relation adrel;
|
Relation adrel;
|
||||||
HeapScanDesc adscan;
|
HeapScanDesc adscan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
adrel = heap_openr(AttrDefaultRelationName);
|
adrel = heap_openr(AttrDefaultRelationName);
|
||||||
|
|
||||||
@@ -1710,10 +1710,10 @@ RemoveAttrDefault(Relation rel)
|
|||||||
static void
|
static void
|
||||||
RemoveRelCheck(Relation rel)
|
RemoveRelCheck(Relation rel)
|
||||||
{
|
{
|
||||||
Relation rcrel;
|
Relation rcrel;
|
||||||
HeapScanDesc rcscan;
|
HeapScanDesc rcscan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
rcrel = heap_openr(RelCheckRelationName);
|
rcrel = heap_openr(RelCheckRelationName);
|
||||||
|
|
||||||
@@ -1737,7 +1737,7 @@ RemoveRelCheck(Relation rel)
|
|||||||
static void
|
static void
|
||||||
RemoveConstraints(Relation rel)
|
RemoveConstraints(Relation rel)
|
||||||
{
|
{
|
||||||
TupleConstr *constr = rel->rd_att->constr;
|
TupleConstr *constr = rel->rd_att->constr;
|
||||||
|
|
||||||
if (!constr)
|
if (!constr)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.20 1997/09/07 04:40:19 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.21 1997/09/08 02:21:40 momjian Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@@ -66,21 +66,21 @@
|
|||||||
static Oid
|
static Oid
|
||||||
RelationNameGetObjectId(char *relationName, Relation pg_class,
|
RelationNameGetObjectId(char *relationName, Relation pg_class,
|
||||||
bool setHasIndexAttribute);
|
bool setHasIndexAttribute);
|
||||||
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName);
|
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName);
|
||||||
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo * funcInfo);
|
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo * funcInfo);
|
||||||
static TupleDesc
|
static TupleDesc
|
||||||
ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
|
ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
|
||||||
List * attributeList,
|
List * attributeList,
|
||||||
int numatts, AttrNumber attNums[]);
|
int numatts, AttrNumber attNums[]);
|
||||||
|
|
||||||
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
|
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
|
||||||
static Oid UpdateRelationRelation(Relation indexRelation);
|
static Oid UpdateRelationRelation(Relation indexRelation);
|
||||||
static void
|
static void
|
||||||
InitializeAttributeOids(Relation indexRelation,
|
InitializeAttributeOids(Relation indexRelation,
|
||||||
int numatts,
|
int numatts,
|
||||||
Oid indexoid);
|
Oid indexoid);
|
||||||
static void
|
static void
|
||||||
AppendAttributeTuples(Relation indexRelation, int numatts);
|
AppendAttributeTuples(Relation indexRelation, int numatts);
|
||||||
static void
|
static void
|
||||||
UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
||||||
FuncIndexInfo * funcInfo, int natts,
|
FuncIndexInfo * funcInfo, int natts,
|
||||||
@@ -144,16 +144,16 @@ static FormData_pg_attribute sysatts[] = {
|
|||||||
* Assumes relation descriptor is valid.
|
* Assumes relation descriptor is valid.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
RelationNameGetObjectId(char *relationName,
|
RelationNameGetObjectId(char *relationName,
|
||||||
Relation pg_class,
|
Relation pg_class,
|
||||||
bool setHasIndexAttribute)
|
bool setHasIndexAttribute)
|
||||||
{
|
{
|
||||||
HeapScanDesc pg_class_scan;
|
HeapScanDesc pg_class_scan;
|
||||||
HeapTuple pg_class_tuple;
|
HeapTuple pg_class_tuple;
|
||||||
Oid relationObjectId;
|
Oid relationObjectId;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this isn't bootstrap time, we can use the system catalogs to
|
* If this isn't bootstrap time, we can use the system catalogs to
|
||||||
@@ -217,12 +217,12 @@ RelationNameGetObjectId(char *relationName,
|
|||||||
* GetHeapRelationOid
|
* GetHeapRelationOid
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
GetHeapRelationOid(char *heapRelationName, char *indexRelationName)
|
GetHeapRelationOid(char *heapRelationName, char *indexRelationName)
|
||||||
{
|
{
|
||||||
Relation pg_class;
|
Relation pg_class;
|
||||||
Oid indoid;
|
Oid indoid;
|
||||||
Oid heapoid;
|
Oid heapoid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* XXX ADD INDEXING HERE
|
* XXX ADD INDEXING HERE
|
||||||
@@ -268,15 +268,15 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName)
|
|||||||
return heapoid;
|
return heapoid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TupleDesc
|
static TupleDesc
|
||||||
BuildFuncTupleDesc(FuncIndexInfo * funcInfo)
|
BuildFuncTupleDesc(FuncIndexInfo * funcInfo)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
TupleDesc funcTupDesc;
|
TupleDesc funcTupDesc;
|
||||||
Oid retType;
|
Oid retType;
|
||||||
char *funcname;
|
char *funcname;
|
||||||
int4 nargs;
|
int4 nargs;
|
||||||
Oid *argtypes;
|
Oid *argtypes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and zero a tuple descriptor.
|
* Allocate and zero a tuple descriptor.
|
||||||
@@ -331,23 +331,23 @@ BuildFuncTupleDesc(FuncIndexInfo * funcInfo)
|
|||||||
* ConstructTupleDescriptor
|
* ConstructTupleDescriptor
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static TupleDesc
|
static TupleDesc
|
||||||
ConstructTupleDescriptor(Oid heapoid,
|
ConstructTupleDescriptor(Oid heapoid,
|
||||||
Relation heapRelation,
|
Relation heapRelation,
|
||||||
List * attributeList,
|
List * attributeList,
|
||||||
int numatts,
|
int numatts,
|
||||||
AttrNumber attNums[])
|
AttrNumber attNums[])
|
||||||
{
|
{
|
||||||
TupleDesc heapTupDesc;
|
TupleDesc heapTupDesc;
|
||||||
TupleDesc indexTupDesc;
|
TupleDesc indexTupDesc;
|
||||||
IndexElem *IndexKey;
|
IndexElem *IndexKey;
|
||||||
TypeName *IndexKeyType;
|
TypeName *IndexKeyType;
|
||||||
AttrNumber atnum; /* attributeNumber[attributeOffset] */
|
AttrNumber atnum; /* attributeNumber[attributeOffset] */
|
||||||
AttrNumber atind;
|
AttrNumber atind;
|
||||||
int natts; /* RelationTupleForm->relnatts */
|
int natts; /* RelationTupleForm->relnatts */
|
||||||
char *from; /* used to simplify memcpy below */
|
char *from; /* used to simplify memcpy below */
|
||||||
char *to; /* used to simplify memcpy below */
|
char *to; /* used to simplify memcpy below */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* allocate the new tuple descriptor
|
* allocate the new tuple descriptor
|
||||||
@@ -447,7 +447,7 @@ ConstructTupleDescriptor(Oid heapoid,
|
|||||||
*/
|
*/
|
||||||
if (IndexKeyType != NULL)
|
if (IndexKeyType != NULL)
|
||||||
{
|
{
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
tup = SearchSysCacheTuple(TYPNAME,
|
tup = SearchSysCacheTuple(TYPNAME,
|
||||||
PointerGetDatum(IndexKeyType->name),
|
PointerGetDatum(IndexKeyType->name),
|
||||||
@@ -491,11 +491,11 @@ ConstructTupleDescriptor(Oid heapoid,
|
|||||||
Form_pg_am
|
Form_pg_am
|
||||||
AccessMethodObjectIdGetAccessMethodTupleForm(Oid accessMethodObjectId)
|
AccessMethodObjectIdGetAccessMethodTupleForm(Oid accessMethodObjectId)
|
||||||
{
|
{
|
||||||
Relation pg_am_desc;
|
Relation pg_am_desc;
|
||||||
HeapScanDesc pg_am_scan;
|
HeapScanDesc pg_am_scan;
|
||||||
HeapTuple pg_am_tuple;
|
HeapTuple pg_am_tuple;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
Form_pg_am form;
|
Form_pg_am form;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* form a scan key for the pg_am relation
|
* form a scan key for the pg_am relation
|
||||||
@@ -546,7 +546,7 @@ static void
|
|||||||
ConstructIndexReldesc(Relation indexRelation, Oid amoid)
|
ConstructIndexReldesc(Relation indexRelation, Oid amoid)
|
||||||
{
|
{
|
||||||
extern GlobalMemory CacheCxt;
|
extern GlobalMemory CacheCxt;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* here we make certain to allocate the access method
|
* here we make certain to allocate the access method
|
||||||
@@ -583,13 +583,13 @@ ConstructIndexReldesc(Relation indexRelation, Oid amoid)
|
|||||||
* UpdateRelationRelation
|
* UpdateRelationRelation
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
UpdateRelationRelation(Relation indexRelation)
|
UpdateRelationRelation(Relation indexRelation)
|
||||||
{
|
{
|
||||||
Relation pg_class;
|
Relation pg_class;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Oid tupleOid;
|
Oid tupleOid;
|
||||||
Relation idescs[Num_pg_class_indices];
|
Relation idescs[Num_pg_class_indices];
|
||||||
|
|
||||||
pg_class = heap_openr(RelationRelationName);
|
pg_class = heap_openr(RelationRelationName);
|
||||||
|
|
||||||
@@ -637,8 +637,8 @@ InitializeAttributeOids(Relation indexRelation,
|
|||||||
int numatts,
|
int numatts,
|
||||||
Oid indexoid)
|
Oid indexoid)
|
||||||
{
|
{
|
||||||
TupleDesc tupleDescriptor;
|
TupleDesc tupleDescriptor;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
tupleDescriptor = RelationGetTupleDescriptor(indexRelation);
|
tupleDescriptor = RelationGetTupleDescriptor(indexRelation);
|
||||||
|
|
||||||
@@ -655,18 +655,18 @@ InitializeAttributeOids(Relation indexRelation,
|
|||||||
static void
|
static void
|
||||||
AppendAttributeTuples(Relation indexRelation, int numatts)
|
AppendAttributeTuples(Relation indexRelation, int numatts)
|
||||||
{
|
{
|
||||||
Relation pg_attribute;
|
Relation pg_attribute;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
bool hasind;
|
bool hasind;
|
||||||
Relation idescs[Num_pg_attr_indices];
|
Relation idescs[Num_pg_attr_indices];
|
||||||
|
|
||||||
Datum value[Natts_pg_attribute];
|
Datum value[Natts_pg_attribute];
|
||||||
char nullv[Natts_pg_attribute];
|
char nullv[Natts_pg_attribute];
|
||||||
char replace[Natts_pg_attribute];
|
char replace[Natts_pg_attribute];
|
||||||
|
|
||||||
TupleDesc indexTupDesc;
|
TupleDesc indexTupDesc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open the attribute relation
|
* open the attribute relation
|
||||||
@@ -786,15 +786,15 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
bool islossy,
|
bool islossy,
|
||||||
bool unique)
|
bool unique)
|
||||||
{
|
{
|
||||||
IndexTupleForm indexForm;
|
IndexTupleForm indexForm;
|
||||||
IndexElem *IndexKey;
|
IndexElem *IndexKey;
|
||||||
char *predString;
|
char *predString;
|
||||||
text *predText;
|
text *predText;
|
||||||
int predLen,
|
int predLen,
|
||||||
itupLen;
|
itupLen;
|
||||||
Relation pg_index;
|
Relation pg_index;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* allocate an IndexTupleForm big enough to hold the
|
* allocate an IndexTupleForm big enough to hold the
|
||||||
@@ -903,19 +903,19 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
void
|
void
|
||||||
UpdateIndexPredicate(Oid indexoid, Node * oldPred, Node * predicate)
|
UpdateIndexPredicate(Oid indexoid, Node * oldPred, Node * predicate)
|
||||||
{
|
{
|
||||||
Node *newPred;
|
Node *newPred;
|
||||||
char *predString;
|
char *predString;
|
||||||
text *predText;
|
text *predText;
|
||||||
Relation pg_index;
|
Relation pg_index;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
HeapTuple newtup;
|
HeapTuple newtup;
|
||||||
ScanKeyData entry;
|
ScanKeyData entry;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
int i;
|
int i;
|
||||||
Datum values[Natts_pg_index];
|
Datum values[Natts_pg_index];
|
||||||
char nulls[Natts_pg_index];
|
char nulls[Natts_pg_index];
|
||||||
char replace[Natts_pg_index];
|
char replace[Natts_pg_index];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct newPred as a CNF expression equivalent to the OR of the
|
* Construct newPred as a CNF expression equivalent to the OR of the
|
||||||
@@ -988,12 +988,12 @@ InitIndexStrategy(int numatts,
|
|||||||
Relation indexRelation,
|
Relation indexRelation,
|
||||||
Oid accessMethodObjectId)
|
Oid accessMethodObjectId)
|
||||||
{
|
{
|
||||||
IndexStrategy strategy;
|
IndexStrategy strategy;
|
||||||
RegProcedure *support;
|
RegProcedure *support;
|
||||||
uint16 amstrategies;
|
uint16 amstrategies;
|
||||||
uint16 amsupport;
|
uint16 amsupport;
|
||||||
Oid attrelid;
|
Oid attrelid;
|
||||||
Size strsize;
|
Size strsize;
|
||||||
extern GlobalMemory CacheCxt;
|
extern GlobalMemory CacheCxt;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -1077,12 +1077,12 @@ index_create(char *heapRelationName,
|
|||||||
bool islossy,
|
bool islossy,
|
||||||
bool unique)
|
bool unique)
|
||||||
{
|
{
|
||||||
Relation heapRelation;
|
Relation heapRelation;
|
||||||
Relation indexRelation;
|
Relation indexRelation;
|
||||||
TupleDesc indexTupDesc;
|
TupleDesc indexTupDesc;
|
||||||
Oid heapoid;
|
Oid heapoid;
|
||||||
Oid indexoid;
|
Oid indexoid;
|
||||||
PredInfo *predInfo;
|
PredInfo *predInfo;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* check parameters
|
* check parameters
|
||||||
@@ -1150,7 +1150,7 @@ index_create(char *heapRelationName,
|
|||||||
|
|
||||||
if (PointerIsValid(funcInfo))
|
if (PointerIsValid(funcInfo))
|
||||||
{
|
{
|
||||||
HeapTuple proc_tup;
|
HeapTuple proc_tup;
|
||||||
|
|
||||||
proc_tup = SearchSysCacheTuple(PRONAME,
|
proc_tup = SearchSysCacheTuple(PRONAME,
|
||||||
PointerGetDatum(FIgetname(funcInfo)),
|
PointerGetDatum(FIgetname(funcInfo)),
|
||||||
@@ -1231,11 +1231,11 @@ index_create(char *heapRelationName,
|
|||||||
void
|
void
|
||||||
index_destroy(Oid indexId)
|
index_destroy(Oid indexId)
|
||||||
{
|
{
|
||||||
Relation indexRelation;
|
Relation indexRelation;
|
||||||
Relation catalogRelation;
|
Relation catalogRelation;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
ScanKeyData entry;
|
ScanKeyData entry;
|
||||||
|
|
||||||
Assert(OidIsValid(indexId));
|
Assert(OidIsValid(indexId));
|
||||||
|
|
||||||
@@ -1325,9 +1325,9 @@ FormIndexDatum(int numberOfAttributes,
|
|||||||
char *nullv,
|
char *nullv,
|
||||||
FuncIndexInfoPtr fInfo)
|
FuncIndexInfoPtr fInfo)
|
||||||
{
|
{
|
||||||
AttrNumber i;
|
AttrNumber i;
|
||||||
int offset;
|
int offset;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* for each attribute we need from the heap tuple,
|
* for each attribute we need from the heap tuple,
|
||||||
@@ -1361,23 +1361,23 @@ FormIndexDatum(int numberOfAttributes,
|
|||||||
void
|
void
|
||||||
UpdateStats(Oid relid, long reltuples, bool hasindex)
|
UpdateStats(Oid relid, long reltuples, bool hasindex)
|
||||||
{
|
{
|
||||||
Relation whichRel;
|
Relation whichRel;
|
||||||
Relation pg_class;
|
Relation pg_class;
|
||||||
HeapScanDesc pg_class_scan;
|
HeapScanDesc pg_class_scan;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
HeapTuple newtup;
|
HeapTuple newtup;
|
||||||
long relpages;
|
long relpages;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
int i;
|
int i;
|
||||||
Form_pg_class rd_rel;
|
Form_pg_class rd_rel;
|
||||||
Relation idescs[Num_pg_class_indices];
|
Relation idescs[Num_pg_class_indices];
|
||||||
|
|
||||||
static ScanKeyData key[1] = {
|
static ScanKeyData key[1] = {
|
||||||
{0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure}
|
{0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure}
|
||||||
};
|
};
|
||||||
Datum values[Natts_pg_class];
|
Datum values[Natts_pg_class];
|
||||||
char nulls[Natts_pg_class];
|
char nulls[Natts_pg_class];
|
||||||
char replace[Natts_pg_class];
|
char replace[Natts_pg_class];
|
||||||
|
|
||||||
fmgr_info(ObjectIdEqualRegProcedure, (func_ptr *) & key[0].sk_func,
|
fmgr_info(ObjectIdEqualRegProcedure, (func_ptr *) & key[0].sk_func,
|
||||||
&key[0].sk_nargs);
|
&key[0].sk_nargs);
|
||||||
@@ -1534,26 +1534,26 @@ DefaultBuild(Relation heapRelation,
|
|||||||
FuncIndexInfoPtr funcInfo,
|
FuncIndexInfoPtr funcInfo,
|
||||||
PredInfo * predInfo)
|
PredInfo * predInfo)
|
||||||
{
|
{
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|
||||||
IndexTuple indexTuple;
|
IndexTuple indexTuple;
|
||||||
TupleDesc heapDescriptor;
|
TupleDesc heapDescriptor;
|
||||||
TupleDesc indexDescriptor;
|
TupleDesc indexDescriptor;
|
||||||
Datum *datum;
|
Datum *datum;
|
||||||
char *nullv;
|
char *nullv;
|
||||||
long reltuples,
|
long reltuples,
|
||||||
indtuples;
|
indtuples;
|
||||||
|
|
||||||
#ifndef OMIT_PARTIAL_INDEX
|
#ifndef OMIT_PARTIAL_INDEX
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
TupleTable tupleTable;
|
TupleTable tupleTable;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Node *predicate;
|
Node *predicate;
|
||||||
Node *oldPred;
|
Node *oldPred;
|
||||||
|
|
||||||
InsertIndexResult insertResult;
|
InsertIndexResult insertResult;
|
||||||
|
|
||||||
@@ -1736,7 +1736,7 @@ index_build(Relation heapRelation,
|
|||||||
FuncIndexInfo * funcInfo,
|
FuncIndexInfo * funcInfo,
|
||||||
PredInfo * predInfo)
|
PredInfo * predInfo)
|
||||||
{
|
{
|
||||||
RegProcedure procedure;
|
RegProcedure procedure;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -1781,8 +1781,8 @@ index_build(Relation heapRelation,
|
|||||||
bool
|
bool
|
||||||
IndexIsUnique(Oid indexId)
|
IndexIsUnique(Oid indexId)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
IndexTupleForm index;
|
IndexTupleForm index;
|
||||||
|
|
||||||
tuple = SearchSysCacheTuple(INDEXRELID,
|
tuple = SearchSysCacheTuple(INDEXRELID,
|
||||||
ObjectIdGetDatum(indexId),
|
ObjectIdGetDatum(indexId),
|
||||||
@@ -1813,12 +1813,12 @@ IndexIsUnique(Oid indexId)
|
|||||||
bool
|
bool
|
||||||
IndexIsUniqueNoCache(Oid indexId)
|
IndexIsUniqueNoCache(Oid indexId)
|
||||||
{
|
{
|
||||||
Relation pg_index;
|
Relation pg_index;
|
||||||
ScanKeyData skey[1];
|
ScanKeyData skey[1];
|
||||||
HeapScanDesc scandesc;
|
HeapScanDesc scandesc;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
IndexTupleForm index;
|
IndexTupleForm index;
|
||||||
bool isunique;
|
bool isunique;
|
||||||
|
|
||||||
pg_index = heap_openr(IndexRelationName);
|
pg_index = heap_openr(IndexRelationName);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.12 1997/09/07 04:40:21 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.13 1997/09/08 02:21:44 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -44,21 +44,21 @@
|
|||||||
* pg_trigger
|
* pg_trigger
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex,
|
char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex,
|
||||||
AttributeNumIndex,
|
AttributeNumIndex,
|
||||||
AttributeRelidIndex};
|
AttributeRelidIndex};
|
||||||
char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex,
|
char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex,
|
||||||
ProcedureOidIndex,
|
ProcedureOidIndex,
|
||||||
ProcedureSrcIndex};
|
ProcedureSrcIndex};
|
||||||
char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex,
|
char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex,
|
||||||
TypeOidIndex};
|
TypeOidIndex};
|
||||||
char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex,
|
char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex,
|
||||||
ClassOidIndex};
|
ClassOidIndex};
|
||||||
char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
|
char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
|
||||||
|
|
||||||
char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
|
char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
|
||||||
|
|
||||||
char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
|
char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
|
||||||
|
|
||||||
|
|
||||||
static HeapTuple
|
static HeapTuple
|
||||||
@@ -76,7 +76,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
|
|||||||
void
|
void
|
||||||
CatalogOpenIndices(int nIndices, char *names[], Relation idescs[])
|
CatalogOpenIndices(int nIndices, char *names[], Relation idescs[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nIndices; i++)
|
for (i = 0; i < nIndices; i++)
|
||||||
{
|
{
|
||||||
@@ -90,7 +90,7 @@ CatalogOpenIndices(int nIndices, char *names[], Relation idescs[])
|
|||||||
void
|
void
|
||||||
CatalogCloseIndices(int nIndices, Relation * idescs)
|
CatalogCloseIndices(int nIndices, Relation * idescs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nIndices; i++)
|
for (i = 0; i < nIndices; i++)
|
||||||
index_close(idescs[i]);
|
index_close(idescs[i]);
|
||||||
@@ -108,22 +108,22 @@ CatalogIndexInsert(Relation * idescs,
|
|||||||
Relation heapRelation,
|
Relation heapRelation,
|
||||||
HeapTuple heapTuple)
|
HeapTuple heapTuple)
|
||||||
{
|
{
|
||||||
HeapTuple pgIndexTup;
|
HeapTuple pgIndexTup;
|
||||||
TupleDesc heapDescriptor;
|
TupleDesc heapDescriptor;
|
||||||
IndexTupleForm pgIndexP;
|
IndexTupleForm pgIndexP;
|
||||||
Datum datum;
|
Datum datum;
|
||||||
int natts;
|
int natts;
|
||||||
AttrNumber *attnumP;
|
AttrNumber *attnumP;
|
||||||
FuncIndexInfo finfo,
|
FuncIndexInfo finfo,
|
||||||
*finfoP;
|
*finfoP;
|
||||||
char nulls[INDEX_MAX_KEYS];
|
char nulls[INDEX_MAX_KEYS];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
heapDescriptor = RelationGetTupleDescriptor(heapRelation);
|
heapDescriptor = RelationGetTupleDescriptor(heapRelation);
|
||||||
|
|
||||||
for (i = 0; i < nIndices; i++)
|
for (i = 0; i < nIndices; i++)
|
||||||
{
|
{
|
||||||
TupleDesc indexDescriptor;
|
TupleDesc indexDescriptor;
|
||||||
InsertIndexResult indexRes;
|
InsertIndexResult indexRes;
|
||||||
|
|
||||||
indexDescriptor = RelationGetTupleDescriptor(idescs[i]);
|
indexDescriptor = RelationGetTupleDescriptor(idescs[i]);
|
||||||
@@ -176,10 +176,10 @@ CatalogIndexInsert(Relation * idescs,
|
|||||||
bool
|
bool
|
||||||
CatalogHasIndex(char *catName, Oid catId)
|
CatalogHasIndex(char *catName, Oid catId)
|
||||||
{
|
{
|
||||||
Relation pg_class;
|
Relation pg_class;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
Form_pg_class pgRelP;
|
Form_pg_class pgRelP;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Assert(IsSystemRelationName(catName));
|
Assert(IsSystemRelationName(catName));
|
||||||
|
|
||||||
@@ -221,15 +221,15 @@ CatalogHasIndex(char *catName, Oid catId)
|
|||||||
* iterate until we find a tuple that's valid and satisfies the scan
|
* iterate until we find a tuple that's valid and satisfies the scan
|
||||||
* key.
|
* key.
|
||||||
*/
|
*/
|
||||||
static HeapTuple
|
static HeapTuple
|
||||||
CatalogIndexFetchTuple(Relation heapRelation,
|
CatalogIndexFetchTuple(Relation heapRelation,
|
||||||
Relation idesc,
|
Relation idesc,
|
||||||
ScanKey skey)
|
ScanKey skey)
|
||||||
{
|
{
|
||||||
IndexScanDesc sd;
|
IndexScanDesc sd;
|
||||||
RetrieveIndexResult indexRes;
|
RetrieveIndexResult indexRes;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|
||||||
sd = index_beginscan(idesc, false, 1, skey);
|
sd = index_beginscan(idesc, false, 1, skey);
|
||||||
tuple = (HeapTuple) NULL;
|
tuple = (HeapTuple) NULL;
|
||||||
@@ -239,7 +239,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
|
|||||||
indexRes = index_getnext(sd, ForwardScanDirection);
|
indexRes = index_getnext(sd, ForwardScanDirection);
|
||||||
if (indexRes)
|
if (indexRes)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
|
|
||||||
iptr = &indexRes->heap_iptr;
|
iptr = &indexRes->heap_iptr;
|
||||||
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
||||||
@@ -271,10 +271,10 @@ AttributeNameIndexScan(Relation heapRelation,
|
|||||||
Oid relid,
|
Oid relid,
|
||||||
char *attname)
|
char *attname)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
OidName keyarg;
|
OidName keyarg;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
keyarg = mkoidname(relid, attname);
|
keyarg = mkoidname(relid, attname);
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
@@ -297,10 +297,10 @@ AttributeNumIndexScan(Relation heapRelation,
|
|||||||
Oid relid,
|
Oid relid,
|
||||||
AttrNumber attnum)
|
AttrNumber attnum)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
OidInt2 keyarg;
|
OidInt2 keyarg;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
keyarg = mkoidint2(relid, (uint16) attnum);
|
keyarg = mkoidint2(relid, (uint16) attnum);
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
@@ -321,9 +321,9 @@ AttributeNumIndexScan(Relation heapRelation,
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
ProcedureOidIndexScan(Relation heapRelation, Oid procId)
|
ProcedureOidIndexScan(Relation heapRelation, Oid procId)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
(bits16) 0x0,
|
(bits16) 0x0,
|
||||||
@@ -347,22 +347,21 @@ ProcedureNameIndexScan(Relation heapRelation,
|
|||||||
int nargs,
|
int nargs,
|
||||||
Oid * argTypes)
|
Oid * argTypes)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
HeapTuple tuple; /* tuple being tested */
|
HeapTuple tuple; /* tuple being tested */
|
||||||
HeapTuple return_tuple; /* The tuple pointer we eventually
|
HeapTuple return_tuple; /* The tuple pointer we eventually return */
|
||||||
* return */
|
IndexScanDesc sd;
|
||||||
IndexScanDesc sd;
|
|
||||||
RetrieveIndexResult indexRes;
|
RetrieveIndexResult indexRes;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
Form_pg_proc pgProcP;
|
Form_pg_proc pgProcP;
|
||||||
bool ScanComplete;
|
bool ScanComplete;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The index scan is complete, i.e. we've scanned everything there is
|
* The index scan is complete, i.e. we've scanned everything there is
|
||||||
* to scan.
|
* to scan.
|
||||||
*/
|
*/
|
||||||
bool FoundMatch;
|
bool FoundMatch;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In scanning pg_proc, we have found a row that meets our search
|
* In scanning pg_proc, we have found a row that meets our search
|
||||||
@@ -392,7 +391,7 @@ ProcedureNameIndexScan(Relation heapRelation,
|
|||||||
indexRes = index_getnext(sd, ForwardScanDirection);
|
indexRes = index_getnext(sd, ForwardScanDirection);
|
||||||
if (indexRes)
|
if (indexRes)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
|
|
||||||
iptr = &indexRes->heap_iptr;
|
iptr = &indexRes->heap_iptr;
|
||||||
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
||||||
@@ -438,12 +437,12 @@ ProcedureNameIndexScan(Relation heapRelation,
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
ProcedureSrcIndexScan(Relation heapRelation, text * procSrc)
|
ProcedureSrcIndexScan(Relation heapRelation, text * procSrc)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
IndexScanDesc sd;
|
IndexScanDesc sd;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
RetrieveIndexResult indexRes;
|
RetrieveIndexResult indexRes;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
(bits16) 0x0,
|
(bits16) 0x0,
|
||||||
@@ -457,7 +456,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text * procSrc)
|
|||||||
indexRes = index_getnext(sd, ForwardScanDirection);
|
indexRes = index_getnext(sd, ForwardScanDirection);
|
||||||
if (indexRes)
|
if (indexRes)
|
||||||
{
|
{
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
|
|
||||||
iptr = &indexRes->heap_iptr;
|
iptr = &indexRes->heap_iptr;
|
||||||
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
||||||
@@ -480,9 +479,9 @@ ProcedureSrcIndexScan(Relation heapRelation, text * procSrc)
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
TypeOidIndexScan(Relation heapRelation, Oid typeId)
|
TypeOidIndexScan(Relation heapRelation, Oid typeId)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
(bits16) 0x0,
|
(bits16) 0x0,
|
||||||
@@ -501,9 +500,9 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
TypeNameIndexScan(Relation heapRelation, char *typeName)
|
TypeNameIndexScan(Relation heapRelation, char *typeName)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
(bits16) 0x0,
|
(bits16) 0x0,
|
||||||
@@ -522,9 +521,9 @@ TypeNameIndexScan(Relation heapRelation, char *typeName)
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
ClassNameIndexScan(Relation heapRelation, char *relName)
|
ClassNameIndexScan(Relation heapRelation, char *relName)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
(bits16) 0x0,
|
(bits16) 0x0,
|
||||||
@@ -543,9 +542,9 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
ClassOidIndexScan(Relation heapRelation, Oid relId)
|
ClassOidIndexScan(Relation heapRelation, Oid relId)
|
||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&skey,
|
ScanKeyEntryInitialize(&skey,
|
||||||
(bits16) 0x0,
|
(bits16) 0x0,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.6 1997/09/07 04:40:24 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.7 1997/09/08 02:21:46 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -64,21 +64,21 @@ AggregateCreate(char *aggName,
|
|||||||
char *agginitval1,
|
char *agginitval1,
|
||||||
char *agginitval2)
|
char *agginitval2)
|
||||||
{
|
{
|
||||||
register i;
|
register i;
|
||||||
Relation aggdesc;
|
Relation aggdesc;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
char nulls[Natts_pg_aggregate];
|
char nulls[Natts_pg_aggregate];
|
||||||
Datum values[Natts_pg_aggregate];
|
Datum values[Natts_pg_aggregate];
|
||||||
Form_pg_proc proc;
|
Form_pg_proc proc;
|
||||||
Oid xfn1 = InvalidOid;
|
Oid xfn1 = InvalidOid;
|
||||||
Oid xfn2 = InvalidOid;
|
Oid xfn2 = InvalidOid;
|
||||||
Oid ffn = InvalidOid;
|
Oid ffn = InvalidOid;
|
||||||
Oid xbase = InvalidOid;
|
Oid xbase = InvalidOid;
|
||||||
Oid xret1 = InvalidOid;
|
Oid xret1 = InvalidOid;
|
||||||
Oid xret2 = InvalidOid;
|
Oid xret2 = InvalidOid;
|
||||||
Oid fret = InvalidOid;
|
Oid fret = InvalidOid;
|
||||||
Oid fnArgs[8];
|
Oid fnArgs[8];
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
memset(fnArgs, 0, 8 * sizeof(Oid));
|
memset(fnArgs, 0, 8 * sizeof(Oid));
|
||||||
|
|
||||||
@@ -267,16 +267,16 @@ AggregateCreate(char *aggName,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull)
|
AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull)
|
||||||
{
|
{
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Relation aggRel;
|
Relation aggRel;
|
||||||
int initValAttno;
|
int initValAttno;
|
||||||
Oid transtype;
|
Oid transtype;
|
||||||
text *textInitVal;
|
text *textInitVal;
|
||||||
char *strInitVal,
|
char *strInitVal,
|
||||||
*initVal;
|
*initVal;
|
||||||
|
|
||||||
Assert(PointerIsValid(aggName));
|
Assert(PointerIsValid(aggName));
|
||||||
Assert(PointerIsValid(isNull));
|
Assert(PointerIsValid(isNull));
|
||||||
@@ -295,7 +295,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull)
|
|||||||
initValAttno = Anum_pg_aggregate_agginitval1;
|
initValAttno = Anum_pg_aggregate_agginitval1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* can only be 1 or 2 */
|
/* can only be 1 or 2 */
|
||||||
{
|
{
|
||||||
transtype = ((Form_pg_aggregate) GETSTRUCT(tup))->aggtranstype2;
|
transtype = ((Form_pg_aggregate) GETSTRUCT(tup))->aggtranstype2;
|
||||||
initValAttno = Anum_pg_aggregate_agginitval2;
|
initValAttno = Anum_pg_aggregate_agginitval2;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.12 1997/09/07 04:40:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.13 1997/09/08 02:21:48 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* these routines moved here from commands/define.c and somewhat cleaned up.
|
* these routines moved here from commands/define.c and somewhat cleaned up.
|
||||||
@@ -66,7 +66,7 @@ OperatorDef(char *operatorName,
|
|||||||
bool canHash,
|
bool canHash,
|
||||||
char *leftSortName,
|
char *leftSortName,
|
||||||
char *rightSortName);
|
char *rightSortName);
|
||||||
static void OperatorUpd(Oid baseId, Oid commId, Oid negId);
|
static void OperatorUpd(Oid baseId, Oid commId, Oid negId);
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* OperatorGetWithOpenRelation
|
* OperatorGetWithOpenRelation
|
||||||
@@ -79,15 +79,15 @@ static void OperatorUpd(Oid baseId, Oid commId, Oid negId);
|
|||||||
* leftObjectId -- left oid of operator to fetch
|
* leftObjectId -- left oid of operator to fetch
|
||||||
* rightObjectId -- right oid of operator to fetch
|
* rightObjectId -- right oid of operator to fetch
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
OperatorGetWithOpenRelation(Relation pg_operator_desc,
|
OperatorGetWithOpenRelation(Relation pg_operator_desc,
|
||||||
const char *operatorName,
|
const char *operatorName,
|
||||||
Oid leftObjectId,
|
Oid leftObjectId,
|
||||||
Oid rightObjectId)
|
Oid rightObjectId)
|
||||||
{
|
{
|
||||||
HeapScanDesc pg_operator_scan;
|
HeapScanDesc pg_operator_scan;
|
||||||
Oid operatorObjectId;
|
Oid operatorObjectId;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
static ScanKeyData opKey[3] = {
|
static ScanKeyData opKey[3] = {
|
||||||
{0, Anum_pg_operator_oprname, NameEqualRegProcedure},
|
{0, Anum_pg_operator_oprname, NameEqualRegProcedure},
|
||||||
@@ -145,18 +145,18 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
|
|||||||
* and left and right type names.
|
* and left and right type names.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
OperatorGet(char *operatorName,
|
OperatorGet(char *operatorName,
|
||||||
char *leftTypeName,
|
char *leftTypeName,
|
||||||
char *rightTypeName)
|
char *rightTypeName)
|
||||||
{
|
{
|
||||||
Relation pg_operator_desc;
|
Relation pg_operator_desc;
|
||||||
|
|
||||||
Oid operatorObjectId;
|
Oid operatorObjectId;
|
||||||
Oid leftObjectId = InvalidOid;
|
Oid leftObjectId = InvalidOid;
|
||||||
Oid rightObjectId = InvalidOid;
|
Oid rightObjectId = InvalidOid;
|
||||||
bool leftDefined = false;
|
bool leftDefined = false;
|
||||||
bool rightDefined = false;
|
bool rightDefined = false;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* look up the operator types.
|
* look up the operator types.
|
||||||
@@ -216,18 +216,18 @@ OperatorGet(char *operatorName,
|
|||||||
*
|
*
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
|
OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
|
||||||
char *operatorName,
|
char *operatorName,
|
||||||
Oid leftObjectId,
|
Oid leftObjectId,
|
||||||
Oid rightObjectId)
|
Oid rightObjectId)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Datum values[Natts_pg_operator];
|
Datum values[Natts_pg_operator];
|
||||||
char nulls[Natts_pg_operator];
|
char nulls[Natts_pg_operator];
|
||||||
Oid operatorObjectId;
|
Oid operatorObjectId;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* initialize our nulls[] and values[] arrays
|
* initialize our nulls[] and values[] arrays
|
||||||
@@ -300,18 +300,18 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
|
|||||||
* to the caller.
|
* to the caller.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
OperatorShellMake(char *operatorName,
|
OperatorShellMake(char *operatorName,
|
||||||
char *leftTypeName,
|
char *leftTypeName,
|
||||||
char *rightTypeName)
|
char *rightTypeName)
|
||||||
{
|
{
|
||||||
Relation pg_operator_desc;
|
Relation pg_operator_desc;
|
||||||
Oid operatorObjectId;
|
Oid operatorObjectId;
|
||||||
|
|
||||||
Oid leftObjectId = InvalidOid;
|
Oid leftObjectId = InvalidOid;
|
||||||
Oid rightObjectId = InvalidOid;
|
Oid rightObjectId = InvalidOid;
|
||||||
bool leftDefined = false;
|
bool leftDefined = false;
|
||||||
bool rightDefined = false;
|
bool rightDefined = false;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the left and right type oid's for this operator
|
* get the left and right type oid's for this operator
|
||||||
@@ -450,29 +450,29 @@ OperatorDef(char *operatorName,
|
|||||||
char *leftSortName,
|
char *leftSortName,
|
||||||
char *rightSortName)
|
char *rightSortName)
|
||||||
{
|
{
|
||||||
register i,
|
register i,
|
||||||
j;
|
j;
|
||||||
Relation pg_operator_desc;
|
Relation pg_operator_desc;
|
||||||
|
|
||||||
HeapScanDesc pg_operator_scan;
|
HeapScanDesc pg_operator_scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
char nulls[Natts_pg_operator];
|
char nulls[Natts_pg_operator];
|
||||||
char replaces[Natts_pg_operator];
|
char replaces[Natts_pg_operator];
|
||||||
Datum values[Natts_pg_operator];
|
Datum values[Natts_pg_operator];
|
||||||
Oid other_oid = 0;
|
Oid other_oid = 0;
|
||||||
Oid operatorObjectId;
|
Oid operatorObjectId;
|
||||||
Oid leftTypeId = InvalidOid;
|
Oid leftTypeId = InvalidOid;
|
||||||
Oid rightTypeId = InvalidOid;
|
Oid rightTypeId = InvalidOid;
|
||||||
Oid commutatorId = InvalidOid;
|
Oid commutatorId = InvalidOid;
|
||||||
Oid negatorId = InvalidOid;
|
Oid negatorId = InvalidOid;
|
||||||
bool leftDefined = false;
|
bool leftDefined = false;
|
||||||
bool rightDefined = false;
|
bool rightDefined = false;
|
||||||
char *name[4];
|
char *name[4];
|
||||||
Oid typeId[8];
|
Oid typeId[8];
|
||||||
int nargs;
|
int nargs;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
static ScanKeyData opKey[3] = {
|
static ScanKeyData opKey[3] = {
|
||||||
{0, Anum_pg_operator_oprname, NameEqualRegProcedure},
|
{0, Anum_pg_operator_oprname, NameEqualRegProcedure},
|
||||||
@@ -765,15 +765,15 @@ OperatorDef(char *operatorName,
|
|||||||
static void
|
static void
|
||||||
OperatorUpd(Oid baseId, Oid commId, Oid negId)
|
OperatorUpd(Oid baseId, Oid commId, Oid negId)
|
||||||
{
|
{
|
||||||
register i;
|
register i;
|
||||||
Relation pg_operator_desc;
|
Relation pg_operator_desc;
|
||||||
HeapScanDesc pg_operator_scan;
|
HeapScanDesc pg_operator_scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
char nulls[Natts_pg_operator];
|
char nulls[Natts_pg_operator];
|
||||||
char replaces[Natts_pg_operator];
|
char replaces[Natts_pg_operator];
|
||||||
Datum values[Natts_pg_operator];
|
Datum values[Natts_pg_operator];
|
||||||
|
|
||||||
static ScanKeyData opKey[1] = {
|
static ScanKeyData opKey[1] = {
|
||||||
{0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure},
|
{0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure},
|
||||||
@@ -985,11 +985,11 @@ OperatorCreate(char *operatorName,
|
|||||||
char *leftSortName,
|
char *leftSortName,
|
||||||
char *rightSortName)
|
char *rightSortName)
|
||||||
{
|
{
|
||||||
Oid commObjectId,
|
Oid commObjectId,
|
||||||
negObjectId;
|
negObjectId;
|
||||||
Oid leftSortObjectId,
|
Oid leftSortObjectId,
|
||||||
rightSortObjectId;
|
rightSortObjectId;
|
||||||
int definedOK;
|
int definedOK;
|
||||||
|
|
||||||
if (!leftTypeName && !rightTypeName)
|
if (!leftTypeName && !rightTypeName)
|
||||||
elog(WARN, "OperatorCreate : at least one of leftarg or rightarg must be defined");
|
elog(WARN, "OperatorCreate : at least one of leftarg or rightarg must be defined");
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.6 1997/09/07 04:40:30 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.7 1997/09/08 02:21:50 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -55,23 +55,23 @@ ProcedureCreate(char *procedureName,
|
|||||||
List * argList,
|
List * argList,
|
||||||
CommandDest dest)
|
CommandDest dest)
|
||||||
{
|
{
|
||||||
register i;
|
register i;
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
bool defined;
|
bool defined;
|
||||||
uint16 parameterCount;
|
uint16 parameterCount;
|
||||||
char nulls[Natts_pg_proc];
|
char nulls[Natts_pg_proc];
|
||||||
Datum values[Natts_pg_proc];
|
Datum values[Natts_pg_proc];
|
||||||
Oid languageObjectId;
|
Oid languageObjectId;
|
||||||
Oid typeObjectId;
|
Oid typeObjectId;
|
||||||
List *x;
|
List *x;
|
||||||
QueryTreeList *querytree_list;
|
QueryTreeList *querytree_list;
|
||||||
List *plan_list;
|
List *plan_list;
|
||||||
Oid typev[8];
|
Oid typev[8];
|
||||||
Oid relid;
|
Oid relid;
|
||||||
Oid toid;
|
Oid toid;
|
||||||
text *prosrctext;
|
text *prosrctext;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -84,7 +84,7 @@ ProcedureCreate(char *procedureName,
|
|||||||
memset(typev, 0, 8 * sizeof(Oid));
|
memset(typev, 0, 8 * sizeof(Oid));
|
||||||
foreach(x, argList)
|
foreach(x, argList)
|
||||||
{
|
{
|
||||||
Value *t = lfirst(x);
|
Value *t = lfirst(x);
|
||||||
|
|
||||||
if (parameterCount == 8)
|
if (parameterCount == 8)
|
||||||
elog(WARN, "Procedures cannot take more than 8 arguments");
|
elog(WARN, "Procedures cannot take more than 8 arguments");
|
||||||
@@ -270,7 +270,7 @@ ProcedureCreate(char *procedureName,
|
|||||||
|
|
||||||
if (RelationGetRelationTupleForm(rdesc)->relhasindex)
|
if (RelationGetRelationTupleForm(rdesc)->relhasindex)
|
||||||
{
|
{
|
||||||
Relation idescs[Num_pg_proc_indices];
|
Relation idescs[Num_pg_proc_indices];
|
||||||
|
|
||||||
CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs);
|
CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs);
|
||||||
CatalogIndexInsert(idescs, Num_pg_proc_indices, rdesc, tup);
|
CatalogIndexInsert(idescs, Num_pg_proc_indices, rdesc, tup);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.8 1997/09/07 04:40:31 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.9 1997/09/08 02:21:51 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -44,13 +44,13 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc,
|
|||||||
* typeName -- name of type to be fetched
|
* typeName -- name of type to be fetched
|
||||||
* defined -- has the type been defined?
|
* defined -- has the type been defined?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
TypeGetWithOpenRelation(Relation pg_type_desc,
|
TypeGetWithOpenRelation(Relation pg_type_desc,
|
||||||
char *typeName,
|
char *typeName,
|
||||||
bool * defined)
|
bool * defined)
|
||||||
{
|
{
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
static ScanKeyData typeKey[1] = {
|
static ScanKeyData typeKey[1] = {
|
||||||
{0, Anum_pg_type_typname, NameEqualRegProcedure}
|
{0, Anum_pg_type_typname, NameEqualRegProcedure}
|
||||||
@@ -118,8 +118,8 @@ Oid
|
|||||||
TypeGet(char *typeName, /* name of type to be fetched */
|
TypeGet(char *typeName, /* name of type to be fetched */
|
||||||
bool * defined) /* has the type been defined? */
|
bool * defined) /* has the type been defined? */
|
||||||
{
|
{
|
||||||
Relation pg_type_desc;
|
Relation pg_type_desc;
|
||||||
Oid typeoid;
|
Oid typeoid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open the pg_type relation
|
* open the pg_type relation
|
||||||
@@ -150,15 +150,15 @@ TypeGet(char *typeName, /* name of type to be fetched */
|
|||||||
*
|
*
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
|
TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Datum values[Natts_pg_type];
|
Datum values[Natts_pg_type];
|
||||||
char nulls[Natts_pg_type];
|
char nulls[Natts_pg_type];
|
||||||
Oid typoid;
|
Oid typoid;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* initialize our nulls[] and values[] arrays
|
* initialize our nulls[] and values[] arrays
|
||||||
@@ -214,7 +214,7 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
|
|||||||
|
|
||||||
if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex)
|
if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex)
|
||||||
{
|
{
|
||||||
Relation idescs[Num_pg_type_indices];
|
Relation idescs[Num_pg_type_indices];
|
||||||
|
|
||||||
CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
|
CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
|
||||||
CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup);
|
CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup);
|
||||||
@@ -246,8 +246,8 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
|
|||||||
Oid
|
Oid
|
||||||
TypeShellMake(char *typeName)
|
TypeShellMake(char *typeName)
|
||||||
{
|
{
|
||||||
Relation pg_type_desc;
|
Relation pg_type_desc;
|
||||||
Oid typoid;
|
Oid typoid;
|
||||||
|
|
||||||
Assert(PointerIsValid(typeName));
|
Assert(PointerIsValid(typeName));
|
||||||
|
|
||||||
@@ -295,27 +295,27 @@ TypeCreate(char *typeName,
|
|||||||
bool passedByValue,
|
bool passedByValue,
|
||||||
char alignment)
|
char alignment)
|
||||||
{
|
{
|
||||||
register i,
|
register i,
|
||||||
j;
|
j;
|
||||||
Relation pg_type_desc;
|
Relation pg_type_desc;
|
||||||
HeapScanDesc pg_type_scan;
|
HeapScanDesc pg_type_scan;
|
||||||
|
|
||||||
Oid typeObjectId;
|
Oid typeObjectId;
|
||||||
Oid elementObjectId = InvalidOid;
|
Oid elementObjectId = InvalidOid;
|
||||||
|
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
char nulls[Natts_pg_type];
|
char nulls[Natts_pg_type];
|
||||||
char replaces[Natts_pg_type];
|
char replaces[Natts_pg_type];
|
||||||
Datum values[Natts_pg_type];
|
Datum values[Natts_pg_type];
|
||||||
|
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
char *procname;
|
char *procname;
|
||||||
char *procs[4];
|
char *procs[4];
|
||||||
bool defined;
|
bool defined;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
Oid argList[8];
|
Oid argList[8];
|
||||||
|
|
||||||
|
|
||||||
static ScanKeyData typeKey[1] = {
|
static ScanKeyData typeKey[1] = {
|
||||||
@@ -522,7 +522,7 @@ TypeCreate(char *typeName,
|
|||||||
|
|
||||||
if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex)
|
if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex)
|
||||||
{
|
{
|
||||||
Relation idescs[Num_pg_type_indices];
|
Relation idescs[Num_pg_type_indices];
|
||||||
|
|
||||||
CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
|
CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
|
||||||
CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup);
|
CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup);
|
||||||
@@ -545,11 +545,11 @@ TypeCreate(char *typeName,
|
|||||||
void
|
void
|
||||||
TypeRename(char *oldTypeName, char *newTypeName)
|
TypeRename(char *oldTypeName, char *newTypeName)
|
||||||
{
|
{
|
||||||
Relation pg_type_desc;
|
Relation pg_type_desc;
|
||||||
Relation idescs[Num_pg_type_indices];
|
Relation idescs[Num_pg_type_indices];
|
||||||
Oid type_oid;
|
Oid type_oid;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
bool defined;
|
bool defined;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
|
|
||||||
/* check that that the new type is not already defined */
|
/* check that that the new type is not already defined */
|
||||||
@@ -603,10 +603,10 @@ TypeRename(char *oldTypeName, char *newTypeName)
|
|||||||
* the CALLER is responsible for pfreeing the
|
* the CALLER is responsible for pfreeing the
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
makeArrayTypeName(char *typeName)
|
makeArrayTypeName(char *typeName)
|
||||||
{
|
{
|
||||||
char *arr;
|
char *arr;
|
||||||
|
|
||||||
if (!typeName)
|
if (!typeName)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.6 1997/09/07 04:41:04 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.7 1997/09/08 02:22:18 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* At the point the version is defined, 2 physical relations are created
|
* At the point the version is defined, 2 physical relations are created
|
||||||
@@ -34,10 +34,10 @@
|
|||||||
|
|
||||||
#define MAX_QUERY_LEN 1024
|
#define MAX_QUERY_LEN 1024
|
||||||
|
|
||||||
char rule_buf[MAX_QUERY_LEN];
|
char rule_buf[MAX_QUERY_LEN];
|
||||||
|
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
static char attr_list[MAX_QUERY_LEN];
|
static char attr_list[MAX_QUERY_LEN];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -105,9 +105,9 @@ eval_as_new_xact(char *query)
|
|||||||
void
|
void
|
||||||
DefineVersion(char *name, char *fromRelname, char *date)
|
DefineVersion(char *name, char *fromRelname, char *date)
|
||||||
{
|
{
|
||||||
char *bname;
|
char *bname;
|
||||||
static char saved_basename[512];
|
static char saved_basename[512];
|
||||||
static char saved_snapshot[512];
|
static char saved_snapshot[512];
|
||||||
|
|
||||||
if (date == NULL)
|
if (date == NULL)
|
||||||
{
|
{
|
||||||
@@ -148,7 +148,7 @@ DefineVersion(char *name, char *fromRelname, char *date)
|
|||||||
void
|
void
|
||||||
VersionCreate(char *vname, char *bname)
|
VersionCreate(char *vname, char *bname)
|
||||||
{
|
{
|
||||||
static char query_buf[MAX_QUERY_LEN];
|
static char query_buf[MAX_QUERY_LEN];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creating the dummy version relation for triggering rules.
|
* Creating the dummy version relation for triggering rules.
|
||||||
@@ -184,12 +184,12 @@ VersionCreate(char *vname, char *bname)
|
|||||||
static void
|
static void
|
||||||
setAttrList(char *bname)
|
setAttrList(char *bname)
|
||||||
{
|
{
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int maxattrs = 0;
|
int maxattrs = 0;
|
||||||
char *attrname;
|
char *attrname;
|
||||||
char temp_buf[512];
|
char temp_buf[512];
|
||||||
int notfirst = 0;
|
int notfirst = 0;
|
||||||
|
|
||||||
rdesc = heap_openr(bname);
|
rdesc = heap_openr(bname);
|
||||||
if (rdesc == NULL)
|
if (rdesc == NULL)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.18 1997/09/07 04:40:35 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.19 1997/09/08 02:21:54 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -86,16 +86,16 @@
|
|||||||
|
|
||||||
#include <storage/lmgr.h>
|
#include <storage/lmgr.h>
|
||||||
|
|
||||||
static int notifyFrontEndPending = 0;
|
static int notifyFrontEndPending = 0;
|
||||||
static int notifyIssued = 0;
|
static int notifyIssued = 0;
|
||||||
static Dllist *pendingNotifies = NULL;
|
static Dllist *pendingNotifies = NULL;
|
||||||
|
|
||||||
|
|
||||||
static int AsyncExistsPendingNotify(char *);
|
static int AsyncExistsPendingNotify(char *);
|
||||||
static void ClearPendingNotify(void);
|
static void ClearPendingNotify(void);
|
||||||
static void Async_NotifyFrontEnd(void);
|
static void Async_NotifyFrontEnd(void);
|
||||||
static void Async_Unlisten(char *relname, int pid);
|
static void Async_Unlisten(char *relname, int pid);
|
||||||
static void Async_UnlistenOnExit(int code, char *relname);
|
static void Async_UnlistenOnExit(int code, char *relname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
@@ -169,20 +169,20 @@ void
|
|||||||
Async_Notify(char *relname)
|
Async_Notify(char *relname)
|
||||||
{
|
{
|
||||||
|
|
||||||
HeapTuple lTuple,
|
HeapTuple lTuple,
|
||||||
rTuple;
|
rTuple;
|
||||||
Relation lRel;
|
Relation lRel;
|
||||||
HeapScanDesc sRel;
|
HeapScanDesc sRel;
|
||||||
TupleDesc tdesc;
|
TupleDesc tdesc;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Datum d,
|
Datum d,
|
||||||
value[3];
|
value[3];
|
||||||
bool isnull;
|
bool isnull;
|
||||||
char repl[3],
|
char repl[3],
|
||||||
nulls[3];
|
nulls[3];
|
||||||
|
|
||||||
char *notifyName;
|
char *notifyName;
|
||||||
|
|
||||||
#ifdef ASYNC_DEBUG
|
#ifdef ASYNC_DEBUG
|
||||||
elog(DEBUG, "Async_Notify: %s", relname);
|
elog(DEBUG, "Async_Notify: %s", relname);
|
||||||
@@ -256,15 +256,15 @@ Async_Notify(char *relname)
|
|||||||
void
|
void
|
||||||
Async_NotifyAtCommit()
|
Async_NotifyAtCommit()
|
||||||
{
|
{
|
||||||
HeapTuple lTuple;
|
HeapTuple lTuple;
|
||||||
Relation lRel;
|
Relation lRel;
|
||||||
HeapScanDesc sRel;
|
HeapScanDesc sRel;
|
||||||
TupleDesc tdesc;
|
TupleDesc tdesc;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
Datum d;
|
Datum d;
|
||||||
int ourpid;
|
int ourpid;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
extern TransactionState CurrentTransactionState;
|
extern TransactionState CurrentTransactionState;
|
||||||
|
|
||||||
if (!pendingNotifies)
|
if (!pendingNotifies)
|
||||||
@@ -406,21 +406,21 @@ Async_NotifyAtAbort()
|
|||||||
void
|
void
|
||||||
Async_Listen(char *relname, int pid)
|
Async_Listen(char *relname, int pid)
|
||||||
{
|
{
|
||||||
Datum values[Natts_pg_listener];
|
Datum values[Natts_pg_listener];
|
||||||
char nulls[Natts_pg_listener];
|
char nulls[Natts_pg_listener];
|
||||||
TupleDesc tdesc;
|
TupleDesc tdesc;
|
||||||
HeapScanDesc s;
|
HeapScanDesc s;
|
||||||
HeapTuple htup,
|
HeapTuple htup,
|
||||||
tup;
|
tup;
|
||||||
Relation lDesc;
|
Relation lDesc;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
Datum d;
|
Datum d;
|
||||||
int i;
|
int i;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
int alreadyListener = 0;
|
int alreadyListener = 0;
|
||||||
int ourPid = getpid();
|
int ourPid = getpid();
|
||||||
char *relnamei;
|
char *relnamei;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
#ifdef ASYNC_DEBUG
|
#ifdef ASYNC_DEBUG
|
||||||
elog(DEBUG, "Async_Listen: %s", relname);
|
elog(DEBUG, "Async_Listen: %s", relname);
|
||||||
@@ -513,8 +513,8 @@ Async_Listen(char *relname, int pid)
|
|||||||
static void
|
static void
|
||||||
Async_Unlisten(char *relname, int pid)
|
Async_Unlisten(char *relname, int pid)
|
||||||
{
|
{
|
||||||
Relation lDesc;
|
Relation lDesc;
|
||||||
HeapTuple lTuple;
|
HeapTuple lTuple;
|
||||||
|
|
||||||
lTuple = SearchSysCacheTuple(LISTENREL, PointerGetDatum(relname),
|
lTuple = SearchSysCacheTuple(LISTENREL, PointerGetDatum(relname),
|
||||||
Int32GetDatum(pid),
|
Int32GetDatum(pid),
|
||||||
@@ -560,25 +560,25 @@ Async_UnlistenOnExit(int code, /* from exitpg */
|
|||||||
*
|
*
|
||||||
* --------------------------------------------------------------
|
* --------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
GlobalMemory notifyContext = NULL;
|
GlobalMemory notifyContext = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Async_NotifyFrontEnd()
|
Async_NotifyFrontEnd()
|
||||||
{
|
{
|
||||||
extern CommandDest whereToSendOutput;
|
extern CommandDest whereToSendOutput;
|
||||||
HeapTuple lTuple,
|
HeapTuple lTuple,
|
||||||
rTuple;
|
rTuple;
|
||||||
Relation lRel;
|
Relation lRel;
|
||||||
HeapScanDesc sRel;
|
HeapScanDesc sRel;
|
||||||
TupleDesc tdesc;
|
TupleDesc tdesc;
|
||||||
ScanKeyData key[2];
|
ScanKeyData key[2];
|
||||||
Datum d,
|
Datum d,
|
||||||
value[3];
|
value[3];
|
||||||
char repl[3],
|
char repl[3],
|
||||||
nulls[3];
|
nulls[3];
|
||||||
Buffer b;
|
Buffer b;
|
||||||
int ourpid;
|
int ourpid;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
notifyFrontEndPending = 0;
|
notifyFrontEndPending = 0;
|
||||||
|
|
||||||
@@ -635,7 +635,7 @@ Async_NotifyFrontEnd()
|
|||||||
static int
|
static int
|
||||||
AsyncExistsPendingNotify(char *relname)
|
AsyncExistsPendingNotify(char *relname)
|
||||||
{
|
{
|
||||||
Dlelem *p;
|
Dlelem *p;
|
||||||
|
|
||||||
for (p = DLGetHead(pendingNotifies);
|
for (p = DLGetHead(pendingNotifies);
|
||||||
p != NULL;
|
p != NULL;
|
||||||
@@ -652,7 +652,7 @@ AsyncExistsPendingNotify(char *relname)
|
|||||||
static void
|
static void
|
||||||
ClearPendingNotify()
|
ClearPendingNotify()
|
||||||
{
|
{
|
||||||
Dlelem *p;
|
Dlelem *p;
|
||||||
|
|
||||||
while ((p = DLRemHead(pendingNotifies)) != NULL)
|
while ((p = DLRemHead(pendingNotifies)) != NULL)
|
||||||
free(DLE_VAL(p));
|
free(DLE_VAL(p));
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.14 1997/09/07 04:40:36 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.15 1997/09/08 02:21:55 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
#endif /* !NO_SECURITY */
|
#endif /* !NO_SECURITY */
|
||||||
|
|
||||||
static Relation copy_heap(Oid OIDOldHeap);
|
static Relation copy_heap(Oid OIDOldHeap);
|
||||||
static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap);
|
static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap);
|
||||||
static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex);
|
static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cluster
|
* cluster
|
||||||
@@ -82,18 +82,18 @@ static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex);
|
|||||||
void
|
void
|
||||||
cluster(char oldrelname[], char oldindexname[])
|
cluster(char oldrelname[], char oldindexname[])
|
||||||
{
|
{
|
||||||
Oid OIDOldHeap,
|
Oid OIDOldHeap,
|
||||||
OIDOldIndex,
|
OIDOldIndex,
|
||||||
OIDNewHeap;
|
OIDNewHeap;
|
||||||
|
|
||||||
Relation OldHeap,
|
Relation OldHeap,
|
||||||
OldIndex;
|
OldIndex;
|
||||||
Relation NewHeap;
|
Relation NewHeap;
|
||||||
|
|
||||||
char NewIndexName[NAMEDATALEN];
|
char NewIndexName[NAMEDATALEN];
|
||||||
char NewHeapName[NAMEDATALEN];
|
char NewHeapName[NAMEDATALEN];
|
||||||
char saveoldrelname[NAMEDATALEN];
|
char saveoldrelname[NAMEDATALEN];
|
||||||
char saveoldindexname[NAMEDATALEN];
|
char saveoldindexname[NAMEDATALEN];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -189,15 +189,15 @@ cluster(char oldrelname[], char oldindexname[])
|
|||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Relation
|
static Relation
|
||||||
copy_heap(Oid OIDOldHeap)
|
copy_heap(Oid OIDOldHeap)
|
||||||
{
|
{
|
||||||
char NewName[NAMEDATALEN];
|
char NewName[NAMEDATALEN];
|
||||||
TupleDesc OldHeapDesc,
|
TupleDesc OldHeapDesc,
|
||||||
tupdesc;
|
tupdesc;
|
||||||
Oid OIDNewHeap;
|
Oid OIDNewHeap;
|
||||||
Relation NewHeap,
|
Relation NewHeap,
|
||||||
OldHeap;
|
OldHeap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new heap relation with a temporary name, which has the
|
* Create a new heap relation with a temporary name, which has the
|
||||||
@@ -235,18 +235,18 @@ copy_heap(Oid OIDOldHeap)
|
|||||||
static void
|
static void
|
||||||
copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||||
{
|
{
|
||||||
Relation OldIndex,
|
Relation OldIndex,
|
||||||
NewHeap;
|
NewHeap;
|
||||||
HeapTuple Old_pg_index_Tuple,
|
HeapTuple Old_pg_index_Tuple,
|
||||||
Old_pg_index_relation_Tuple,
|
Old_pg_index_relation_Tuple,
|
||||||
pg_proc_Tuple;
|
pg_proc_Tuple;
|
||||||
IndexTupleForm Old_pg_index_Form;
|
IndexTupleForm Old_pg_index_Form;
|
||||||
Form_pg_class Old_pg_index_relation_Form;
|
Form_pg_class Old_pg_index_relation_Form;
|
||||||
Form_pg_proc pg_proc_Form;
|
Form_pg_proc pg_proc_Form;
|
||||||
char *NewIndexName;
|
char *NewIndexName;
|
||||||
AttrNumber *attnumP;
|
AttrNumber *attnumP;
|
||||||
int natts;
|
int natts;
|
||||||
FuncIndexInfo *finfo;
|
FuncIndexInfo *finfo;
|
||||||
|
|
||||||
NewHeap = heap_open(OIDNewHeap);
|
NewHeap = heap_open(OIDNewHeap);
|
||||||
OldIndex = index_open(OIDOldIndex);
|
OldIndex = index_open(OIDOldIndex);
|
||||||
@@ -330,15 +330,15 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
|||||||
static void
|
static void
|
||||||
rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
|
rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
|
||||||
{
|
{
|
||||||
Relation LocalNewHeap,
|
Relation LocalNewHeap,
|
||||||
LocalOldHeap,
|
LocalOldHeap,
|
||||||
LocalOldIndex;
|
LocalOldIndex;
|
||||||
IndexScanDesc ScanDesc;
|
IndexScanDesc ScanDesc;
|
||||||
RetrieveIndexResult ScanResult;
|
RetrieveIndexResult ScanResult;
|
||||||
ItemPointer HeapTid;
|
ItemPointer HeapTid;
|
||||||
HeapTuple LocalHeapTuple;
|
HeapTuple LocalHeapTuple;
|
||||||
Buffer LocalBuffer;
|
Buffer LocalBuffer;
|
||||||
Oid OIDNewHeapInsert;
|
Oid OIDNewHeapInsert;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the relations I need. Scan through the OldHeap on the OldIndex
|
* Open the relations I need. Scan through the OldHeap on the OldIndex
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.14 1997/09/07 04:40:38 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.15 1997/09/08 02:22:01 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* The PortalExecutorHeapMemory crap needs to be eliminated
|
* The PortalExecutorHeapMemory crap needs to be eliminated
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
* This is where the XXXSuperDuperHacky code was. -cim 3/15/90
|
* This is where the XXXSuperDuperHacky code was. -cim 3/15/90
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
MemoryContext PortalExecutorHeapMemory = NULL;
|
MemoryContext PortalExecutorHeapMemory = NULL;
|
||||||
|
|
||||||
/* --------------------------------
|
/* --------------------------------
|
||||||
* PortalCleanup
|
* PortalCleanup
|
||||||
@@ -55,7 +55,7 @@ MemoryContext PortalExecutorHeapMemory = NULL;
|
|||||||
void
|
void
|
||||||
PortalCleanup(Portal portal)
|
PortalCleanup(Portal portal)
|
||||||
{
|
{
|
||||||
MemoryContext context;
|
MemoryContext context;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -97,10 +97,10 @@ PerformPortalFetch(char *name,
|
|||||||
char *tag,
|
char *tag,
|
||||||
CommandDest dest)
|
CommandDest dest)
|
||||||
{
|
{
|
||||||
Portal portal;
|
Portal portal;
|
||||||
int feature;
|
int feature;
|
||||||
QueryDesc *queryDesc;
|
QueryDesc *queryDesc;
|
||||||
MemoryContext context;
|
MemoryContext context;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -151,7 +151,7 @@ PerformPortalFetch(char *name,
|
|||||||
BeginCommand(name,
|
BeginCommand(name,
|
||||||
queryDesc->operation,
|
queryDesc->operation,
|
||||||
portal->attinfo, /* QueryDescGetTypeInfo(queryDesc),
|
portal->attinfo, /* QueryDescGetTypeInfo(queryDesc),
|
||||||
* */
|
* */
|
||||||
false, /* portal fetches don't end up in
|
false, /* portal fetches don't end up in
|
||||||
* relations */
|
* relations */
|
||||||
false, /* this is a portal fetch, not a "retrieve
|
false, /* this is a portal fetch, not a "retrieve
|
||||||
@@ -190,7 +190,7 @@ PerformPortalFetch(char *name,
|
|||||||
void
|
void
|
||||||
PerformPortalClose(char *name, CommandDest dest)
|
PerformPortalClose(char *name, CommandDest dest)
|
||||||
{
|
{
|
||||||
Portal portal;
|
Portal portal;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -257,22 +257,22 @@ PerformAddAttribute(char *relationName,
|
|||||||
bool inherits,
|
bool inherits,
|
||||||
ColumnDef * colDef)
|
ColumnDef * colDef)
|
||||||
{
|
{
|
||||||
Relation relrdesc,
|
Relation relrdesc,
|
||||||
attrdesc;
|
attrdesc;
|
||||||
HeapScanDesc attsdesc;
|
HeapScanDesc attsdesc;
|
||||||
HeapTuple reltup;
|
HeapTuple reltup;
|
||||||
HeapTuple attributeTuple;
|
HeapTuple attributeTuple;
|
||||||
AttributeTupleForm attribute;
|
AttributeTupleForm attribute;
|
||||||
FormData_pg_attribute attributeD;
|
FormData_pg_attribute attributeD;
|
||||||
int i;
|
int i;
|
||||||
int minattnum,
|
int minattnum,
|
||||||
maxatts;
|
maxatts;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
ScanKeyData key[2];
|
ScanKeyData key[2];
|
||||||
ItemPointerData oldTID;
|
ItemPointerData oldTID;
|
||||||
Relation idescs[Num_pg_attr_indices];
|
Relation idescs[Num_pg_attr_indices];
|
||||||
Relation ridescs[Num_pg_class_indices];
|
Relation ridescs[Num_pg_class_indices];
|
||||||
bool hasindex;
|
bool hasindex;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* permissions checking. this would normally be done in utility.c,
|
* permissions checking. this would normally be done in utility.c,
|
||||||
@@ -310,10 +310,10 @@ PerformAddAttribute(char *relationName,
|
|||||||
{
|
{
|
||||||
if (inherits)
|
if (inherits)
|
||||||
{
|
{
|
||||||
Oid myrelid,
|
Oid myrelid,
|
||||||
childrelid;
|
childrelid;
|
||||||
List *child,
|
List *child,
|
||||||
*children;
|
*children;
|
||||||
|
|
||||||
relrdesc = heap_openr(relationName);
|
relrdesc = heap_openr(relationName);
|
||||||
if (!RelationIsValid(relrdesc))
|
if (!RelationIsValid(relrdesc))
|
||||||
@@ -418,10 +418,10 @@ PerformAddAttribute(char *relationName,
|
|||||||
i = 1 + minattnum;
|
i = 1 + minattnum;
|
||||||
|
|
||||||
{
|
{
|
||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
TypeTupleForm form;
|
TypeTupleForm form;
|
||||||
char *p;
|
char *p;
|
||||||
int attnelems;
|
int attnelems;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX use syscache here as an optimization
|
* XXX use syscache here as an optimization
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.30 1997/09/07 04:40:40 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.31 1997/09/08 02:22:03 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -42,33 +42,33 @@
|
|||||||
|
|
||||||
|
|
||||||
/* non-export function prototypes */
|
/* non-export function prototypes */
|
||||||
static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim);
|
static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim);
|
||||||
static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim);
|
static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim);
|
||||||
static Oid GetOutputFunction(Oid type);
|
static Oid GetOutputFunction(Oid type);
|
||||||
static Oid GetTypeElement(Oid type);
|
static Oid GetTypeElement(Oid type);
|
||||||
static Oid GetInputFunction(Oid type);
|
static Oid GetInputFunction(Oid type);
|
||||||
static Oid IsTypeByVal(Oid type);
|
static Oid IsTypeByVal(Oid type);
|
||||||
static void
|
static void
|
||||||
GetIndexRelations(Oid main_relation_oid,
|
GetIndexRelations(Oid main_relation_oid,
|
||||||
int *n_indices,
|
int *n_indices,
|
||||||
Relation ** index_rels);
|
Relation ** index_rels);
|
||||||
|
|
||||||
#ifdef COPY_PATCH
|
#ifdef COPY_PATCH
|
||||||
static void CopyReadNewline(FILE * fp, int *newline);
|
static void CopyReadNewline(FILE * fp, int *newline);
|
||||||
static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline);
|
static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim);
|
static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
static void CopyAttributeOut(FILE * fp, char *string, char *delim);
|
static void CopyAttributeOut(FILE * fp, char *string, char *delim);
|
||||||
static int CountTuples(Relation relation);
|
static int CountTuples(Relation relation);
|
||||||
|
|
||||||
extern FILE *Pfout,
|
extern FILE *Pfout,
|
||||||
*Pfin;
|
*Pfin;
|
||||||
|
|
||||||
#ifdef COPY_DEBUG
|
#ifdef COPY_DEBUG
|
||||||
static int lineno;
|
static int lineno;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -107,11 +107,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
|
|||||||
the class.
|
the class.
|
||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
extern char *UserName; /* defined in global.c */
|
extern char *UserName; /* defined in global.c */
|
||||||
const AclMode required_access = from ? ACL_WR : ACL_RD;
|
const AclMode required_access = from ? ACL_WR : ACL_RD;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
rel = heap_openr(relname);
|
rel = heap_openr(relname);
|
||||||
if (rel == NULL)
|
if (rel == NULL)
|
||||||
@@ -169,7 +169,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mode_t oumask; /* Pre-existing umask value */
|
mode_t oumask; /* Pre-existing umask value */
|
||||||
|
|
||||||
oumask = umask((mode_t) 0);
|
oumask = umask((mode_t) 0);
|
||||||
fp = AllocateFile(filename, "w");
|
fp = AllocateFile(filename, "w");
|
||||||
@@ -199,19 +199,19 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
|
|||||||
static void
|
static void
|
||||||
CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
HeapScanDesc scandesc;
|
HeapScanDesc scandesc;
|
||||||
|
|
||||||
int32 attr_count,
|
int32 attr_count,
|
||||||
i;
|
i;
|
||||||
AttributeTupleForm *attr;
|
AttributeTupleForm *attr;
|
||||||
func_ptr *out_functions;
|
func_ptr *out_functions;
|
||||||
int dummy;
|
int dummy;
|
||||||
Oid out_func_oid;
|
Oid out_func_oid;
|
||||||
Oid *elements;
|
Oid *elements;
|
||||||
Datum value;
|
Datum value;
|
||||||
bool isnull; /* The attribute we are copying is null */
|
bool isnull; /* The attribute we are copying is null */
|
||||||
char *nulls;
|
char *nulls;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* <nulls> is a (dynamically allocated) array with one character per
|
* <nulls> is a (dynamically allocated) array with one character per
|
||||||
@@ -220,9 +220,9 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
*
|
*
|
||||||
* <nulls> is meaningful only if we are doing a binary copy.
|
* <nulls> is meaningful only if we are doing a binary copy.
|
||||||
*/
|
*/
|
||||||
char *string;
|
char *string;
|
||||||
int32 ntuples;
|
int32 ntuples;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
scandesc = heap_beginscan(rel, 0, NULL, 0, NULL);
|
scandesc = heap_beginscan(rel, 0, NULL, 0, NULL);
|
||||||
|
|
||||||
@@ -311,8 +311,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
|
|
||||||
if (binary)
|
if (binary)
|
||||||
{
|
{
|
||||||
int32 null_ct = 0,
|
int32 null_ct = 0,
|
||||||
length;
|
length;
|
||||||
|
|
||||||
for (i = 0; i < attr_count; i++)
|
for (i = 0; i < attr_count; i++)
|
||||||
{
|
{
|
||||||
@@ -358,54 +358,54 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
static void
|
static void
|
||||||
CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
AttrNumber attr_count;
|
AttrNumber attr_count;
|
||||||
AttributeTupleForm *attr;
|
AttributeTupleForm *attr;
|
||||||
func_ptr *in_functions;
|
func_ptr *in_functions;
|
||||||
int i,
|
int i,
|
||||||
dummy;
|
dummy;
|
||||||
Oid in_func_oid;
|
Oid in_func_oid;
|
||||||
Datum *values;
|
Datum *values;
|
||||||
char *nulls,
|
char *nulls,
|
||||||
*index_nulls;
|
*index_nulls;
|
||||||
bool *byval;
|
bool *byval;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
bool has_index;
|
bool has_index;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
char *string = NULL,
|
char *string = NULL,
|
||||||
*ptr;
|
*ptr;
|
||||||
Relation *index_rels;
|
Relation *index_rels;
|
||||||
int32 len,
|
int32 len,
|
||||||
null_ct,
|
null_ct,
|
||||||
null_id;
|
null_id;
|
||||||
int32 ntuples,
|
int32 ntuples,
|
||||||
tuples_read = 0;
|
tuples_read = 0;
|
||||||
bool reading_to_eof = true;
|
bool reading_to_eof = true;
|
||||||
Oid *elements;
|
Oid *elements;
|
||||||
FuncIndexInfo *finfo,
|
FuncIndexInfo *finfo,
|
||||||
**finfoP = NULL;
|
**finfoP = NULL;
|
||||||
TupleDesc *itupdescArr;
|
TupleDesc *itupdescArr;
|
||||||
HeapTuple pgIndexTup;
|
HeapTuple pgIndexTup;
|
||||||
IndexTupleForm *pgIndexP = NULL;
|
IndexTupleForm *pgIndexP = NULL;
|
||||||
int *indexNatts = NULL;
|
int *indexNatts = NULL;
|
||||||
char *predString;
|
char *predString;
|
||||||
Node **indexPred = NULL;
|
Node **indexPred = NULL;
|
||||||
TupleDesc rtupdesc;
|
TupleDesc rtupdesc;
|
||||||
ExprContext *econtext = NULL;
|
ExprContext *econtext = NULL;
|
||||||
|
|
||||||
#ifndef OMIT_PARTIAL_INDEX
|
#ifndef OMIT_PARTIAL_INDEX
|
||||||
TupleTable tupleTable;
|
TupleTable tupleTable;
|
||||||
TupleTableSlot *slot = NULL;
|
TupleTableSlot *slot = NULL;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
int natts;
|
int natts;
|
||||||
AttrNumber *attnumP;
|
AttrNumber *attnumP;
|
||||||
Datum *idatum;
|
Datum *idatum;
|
||||||
int n_indices;
|
int n_indices;
|
||||||
InsertIndexResult indexRes;
|
InsertIndexResult indexRes;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
Oid loaded_oid;
|
Oid loaded_oid;
|
||||||
bool skip_tuple = false;
|
bool skip_tuple = false;
|
||||||
|
|
||||||
tupDesc = RelationGetTupleDescriptor(rel);
|
tupDesc = RelationGetTupleDescriptor(rel);
|
||||||
attr = tupDesc->attrs;
|
attr = tupDesc->attrs;
|
||||||
@@ -541,7 +541,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
if (!binary)
|
if (!binary)
|
||||||
{
|
{
|
||||||
#ifdef COPY_PATCH
|
#ifdef COPY_PATCH
|
||||||
int newline = 0;
|
int newline = 0;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef COPY_DEBUG
|
#ifdef COPY_DEBUG
|
||||||
@@ -647,58 +647,58 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
|
|
||||||
switch (attr[i]->attlen)
|
switch (attr[i]->attlen)
|
||||||
{
|
{
|
||||||
case sizeof(char):
|
case sizeof(char):
|
||||||
values[i] = (Datum) * (unsigned char *) ptr;
|
values[i] = (Datum) * (unsigned char *) ptr;
|
||||||
ptr += sizeof(char);
|
ptr += sizeof(char);
|
||||||
break;
|
break;
|
||||||
case sizeof(short):
|
case sizeof(short):
|
||||||
ptr = (char *) SHORTALIGN(ptr);
|
ptr = (char *) SHORTALIGN(ptr);
|
||||||
values[i] = (Datum) * (unsigned short *) ptr;
|
values[i] = (Datum) * (unsigned short *) ptr;
|
||||||
ptr += sizeof(short);
|
ptr += sizeof(short);
|
||||||
break;
|
break;
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
ptr = (char *) INTALIGN(ptr);
|
ptr = (char *) INTALIGN(ptr);
|
||||||
values[i] = (Datum) * (uint32 *) ptr;
|
values[i] = (Datum) * (uint32 *) ptr;
|
||||||
ptr += sizeof(int32);
|
ptr += sizeof(int32);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "COPY BINARY: impossible size!");
|
elog(WARN, "COPY BINARY: impossible size!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nulls[i] != 'n')
|
else if (nulls[i] != 'n')
|
||||||
{
|
{
|
||||||
switch (attr[i]->attlen)
|
switch (attr[i]->attlen)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
if (attr[i]->attalign == 'd')
|
if (attr[i]->attalign == 'd')
|
||||||
ptr = (char *) DOUBLEALIGN(ptr);
|
ptr = (char *) DOUBLEALIGN(ptr);
|
||||||
else
|
else
|
||||||
|
ptr = (char *) INTALIGN(ptr);
|
||||||
|
values[i] = (Datum) ptr;
|
||||||
|
ptr += *(uint32 *) ptr;
|
||||||
|
break;
|
||||||
|
case sizeof(char):
|
||||||
|
values[i] = (Datum) ptr;
|
||||||
|
ptr += attr[i]->attlen;
|
||||||
|
break;
|
||||||
|
case sizeof(short):
|
||||||
|
ptr = (char *) SHORTALIGN(ptr);
|
||||||
|
values[i] = (Datum) ptr;
|
||||||
|
ptr += attr[i]->attlen;
|
||||||
|
break;
|
||||||
|
case sizeof(int32):
|
||||||
ptr = (char *) INTALIGN(ptr);
|
ptr = (char *) INTALIGN(ptr);
|
||||||
values[i] = (Datum) ptr;
|
values[i] = (Datum) ptr;
|
||||||
ptr += *(uint32 *) ptr;
|
ptr += attr[i]->attlen;
|
||||||
break;
|
break;
|
||||||
case sizeof(char):
|
default:
|
||||||
values[i] = (Datum) ptr;
|
if (attr[i]->attalign == 'd')
|
||||||
ptr += attr[i]->attlen;
|
ptr = (char *) DOUBLEALIGN(ptr);
|
||||||
break;
|
else
|
||||||
case sizeof(short):
|
ptr = (char *) LONGALIGN(ptr);
|
||||||
ptr = (char *) SHORTALIGN(ptr);
|
values[i] = (Datum) ptr;
|
||||||
values[i] = (Datum) ptr;
|
ptr += attr[i]->attlen;
|
||||||
ptr += attr[i]->attlen;
|
|
||||||
break;
|
|
||||||
case sizeof(int32):
|
|
||||||
ptr = (char *) INTALIGN(ptr);
|
|
||||||
values[i] = (Datum) ptr;
|
|
||||||
ptr += attr[i]->attlen;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (attr[i]->attalign == 'd')
|
|
||||||
ptr = (char *) DOUBLEALIGN(ptr);
|
|
||||||
else
|
|
||||||
ptr = (char *) LONGALIGN(ptr);
|
|
||||||
values[i] = (Datum) ptr;
|
|
||||||
ptr += attr[i]->attlen;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -721,7 +721,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
if (rel->trigdesc &&
|
if (rel->trigdesc &&
|
||||||
rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
|
rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
|
||||||
{
|
{
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
|
|
||||||
newtuple = ExecBRInsertTriggers(rel, tuple);
|
newtuple = ExecBRInsertTriggers(rel, tuple);
|
||||||
|
|
||||||
@@ -743,7 +743,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
|
|
||||||
if (rel->rd_att->constr)
|
if (rel->rd_att->constr)
|
||||||
{
|
{
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
|
|
||||||
newtuple = ExecConstraints("CopyFrom", rel, tuple);
|
newtuple = ExecConstraints("CopyFrom", rel, tuple);
|
||||||
|
|
||||||
@@ -826,10 +826,10 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Oid
|
static Oid
|
||||||
GetOutputFunction(Oid type)
|
GetOutputFunction(Oid type)
|
||||||
{
|
{
|
||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
|
|
||||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||||
ObjectIdGetDatum(type),
|
ObjectIdGetDatum(type),
|
||||||
@@ -842,10 +842,10 @@ GetOutputFunction(Oid type)
|
|||||||
return (InvalidOid);
|
return (InvalidOid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Oid
|
static Oid
|
||||||
GetTypeElement(Oid type)
|
GetTypeElement(Oid type)
|
||||||
{
|
{
|
||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
|
|
||||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||||
ObjectIdGetDatum(type),
|
ObjectIdGetDatum(type),
|
||||||
@@ -859,10 +859,10 @@ GetTypeElement(Oid type)
|
|||||||
return (InvalidOid);
|
return (InvalidOid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Oid
|
static Oid
|
||||||
GetInputFunction(Oid type)
|
GetInputFunction(Oid type)
|
||||||
{
|
{
|
||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
|
|
||||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||||
ObjectIdGetDatum(type),
|
ObjectIdGetDatum(type),
|
||||||
@@ -875,10 +875,10 @@ GetInputFunction(Oid type)
|
|||||||
return (InvalidOid);
|
return (InvalidOid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Oid
|
static Oid
|
||||||
IsTypeByVal(Oid type)
|
IsTypeByVal(Oid type)
|
||||||
{
|
{
|
||||||
HeapTuple typeTuple;
|
HeapTuple typeTuple;
|
||||||
|
|
||||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||||
ObjectIdGetDatum(type),
|
ObjectIdGetDatum(type),
|
||||||
@@ -902,24 +902,24 @@ IsTypeByVal(Oid type)
|
|||||||
|
|
||||||
typedef struct rel_list
|
typedef struct rel_list
|
||||||
{
|
{
|
||||||
Oid index_rel_oid;
|
Oid index_rel_oid;
|
||||||
struct rel_list *next;
|
struct rel_list *next;
|
||||||
} RelationList;
|
} RelationList;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
GetIndexRelations(Oid main_relation_oid,
|
GetIndexRelations(Oid main_relation_oid,
|
||||||
int *n_indices,
|
int *n_indices,
|
||||||
Relation ** index_rels)
|
Relation ** index_rels)
|
||||||
{
|
{
|
||||||
RelationList *head,
|
RelationList *head,
|
||||||
*scan;
|
*scan;
|
||||||
Relation pg_index_rel;
|
Relation pg_index_rel;
|
||||||
HeapScanDesc scandesc;
|
HeapScanDesc scandesc;
|
||||||
Oid index_relation_oid;
|
Oid index_relation_oid;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
int i;
|
int i;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
pg_index_rel = heap_openr(IndexRelationName);
|
pg_index_rel = heap_openr(IndexRelationName);
|
||||||
scandesc = heap_beginscan(pg_index_rel, 0, NULL, 0, NULL);
|
scandesc = heap_beginscan(pg_index_rel, 0, NULL, 0, NULL);
|
||||||
@@ -978,10 +978,10 @@ GetIndexRelations(Oid main_relation_oid,
|
|||||||
/*
|
/*
|
||||||
returns 1 is c is in s
|
returns 1 is c is in s
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
inString(char c, char *s)
|
inString(char c, char *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
@@ -1026,17 +1026,17 @@ CopyReadNewline(FILE * fp, int *newline)
|
|||||||
* can be used as standard input.
|
* can be used as standard input.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
#ifdef COPY_PATCH
|
#ifdef COPY_PATCH
|
||||||
CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline)
|
CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline)
|
||||||
#else
|
#else
|
||||||
CopyReadAttribute(FILE * fp, bool * isnull, char *delim)
|
CopyReadAttribute(FILE * fp, bool * isnull, char *delim)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static char attribute[EXT_ATTLEN];
|
static char attribute[EXT_ATTLEN];
|
||||||
char c;
|
char c;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
#ifdef COPY_PATCH
|
#ifdef COPY_PATCH
|
||||||
/* if last delimiter was a newline return a NULL attribute */
|
/* if last delimiter was a newline return a NULL attribute */
|
||||||
@@ -1064,26 +1064,33 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
case '5':
|
case '5':
|
||||||
case '6':
|
case '6':
|
||||||
case '7':
|
case '7':
|
||||||
{
|
|
||||||
int val;
|
|
||||||
|
|
||||||
val = VALUE(c);
|
|
||||||
c = getc(fp);
|
|
||||||
if (ISOCTAL(c))
|
|
||||||
{
|
{
|
||||||
val = (val << 3) + VALUE(c);
|
int val;
|
||||||
|
|
||||||
|
val = VALUE(c);
|
||||||
c = getc(fp);
|
c = getc(fp);
|
||||||
if (ISOCTAL(c))
|
if (ISOCTAL(c))
|
||||||
{
|
{
|
||||||
val = (val << 3) + VALUE(c);
|
val = (val << 3) + VALUE(c);
|
||||||
|
c = getc(fp);
|
||||||
|
if (ISOCTAL(c))
|
||||||
|
{
|
||||||
|
val = (val << 3) + VALUE(c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (feof(fp))
|
||||||
|
return (NULL);
|
||||||
|
ungetc(c, fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1091,44 +1098,37 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
ungetc(c, fp);
|
ungetc(c, fp);
|
||||||
}
|
}
|
||||||
|
c = val & 0377;
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
{
|
case 'b':
|
||||||
if (feof(fp))
|
c = '\b';
|
||||||
return (NULL);
|
break;
|
||||||
ungetc(c, fp);
|
case 'f':
|
||||||
}
|
c = '\f';
|
||||||
c = val & 0377;
|
break;
|
||||||
}
|
case 'n':
|
||||||
break;
|
c = '\n';
|
||||||
case 'b':
|
break;
|
||||||
c = '\b';
|
case 'r':
|
||||||
break;
|
c = '\r';
|
||||||
case 'f':
|
break;
|
||||||
c = '\f';
|
case 't':
|
||||||
break;
|
c = '\t';
|
||||||
case 'n':
|
break;
|
||||||
c = '\n';
|
case 'v':
|
||||||
break;
|
c = '\v';
|
||||||
case 'r':
|
break;
|
||||||
c = '\r';
|
case 'N':
|
||||||
break;
|
attribute[0] = '\0'; /* just to be safe */
|
||||||
case 't':
|
*isnull = (bool) true;
|
||||||
c = '\t';
|
break;
|
||||||
break;
|
case '.':
|
||||||
case 'v':
|
c = getc(fp);
|
||||||
c = '\v';
|
if (c != '\n')
|
||||||
break;
|
elog(WARN, "CopyReadAttribute - end of record marker corrupted");
|
||||||
case 'N':
|
return (NULL);
|
||||||
attribute[0] = '\0'; /* just to be safe */
|
break;
|
||||||
*isnull = (bool) true;
|
|
||||||
break;
|
|
||||||
case '.':
|
|
||||||
c = getc(fp);
|
|
||||||
if (c != '\n')
|
|
||||||
elog(WARN, "CopyReadAttribute - end of record marker corrupted");
|
|
||||||
return (NULL);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (inString(c, delim) || c == '\n')
|
else if (inString(c, delim) || c == '\n')
|
||||||
@@ -1153,9 +1153,9 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim)
|
|||||||
static void
|
static void
|
||||||
CopyAttributeOut(FILE * fp, char *string, char *delim)
|
CopyAttributeOut(FILE * fp, char *string, char *delim)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
int is_array = false;
|
int is_array = false;
|
||||||
int len = strlen(string);
|
int len = strlen(string);
|
||||||
|
|
||||||
/* XXX - This is a kludge, we should check the data type */
|
/* XXX - This is a kludge, we should check the data type */
|
||||||
if (len && (string[0] == '{') && (string[len - 1] == '}'))
|
if (len && (string[0] == '{') && (string[len - 1] == '}'))
|
||||||
@@ -1194,10 +1194,10 @@ CopyAttributeOut(FILE * fp, char *string, char *delim)
|
|||||||
static int
|
static int
|
||||||
CountTuples(Relation relation)
|
CountTuples(Relation relation)
|
||||||
{
|
{
|
||||||
HeapScanDesc scandesc;
|
HeapScanDesc scandesc;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
scandesc = heap_beginscan(relation, 0, NULL, 0, NULL);
|
scandesc = heap_beginscan(relation, 0, NULL, 0, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.15 1997/09/07 04:40:42 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.16 1997/09/08 02:22:06 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
static int
|
static int
|
||||||
checkAttrExists(char *attributeName,
|
checkAttrExists(char *attributeName,
|
||||||
char *attributeType, List * schema);
|
char *attributeType, List * schema);
|
||||||
static List *MergeAttributes(List * schema, List * supers, List ** supconstr);
|
static List *MergeAttributes(List * schema, List * supers, List ** supconstr);
|
||||||
static void StoreCatalogInheritance(Oid relationId, List * supers);
|
static void StoreCatalogInheritance(Oid relationId, List * supers);
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* DefineRelation --
|
* DefineRelation --
|
||||||
@@ -47,20 +47,20 @@ static void StoreCatalogInheritance(Oid relationId, List * supers);
|
|||||||
void
|
void
|
||||||
DefineRelation(CreateStmt * stmt)
|
DefineRelation(CreateStmt * stmt)
|
||||||
{
|
{
|
||||||
char *relname = palloc(NAMEDATALEN);
|
char *relname = palloc(NAMEDATALEN);
|
||||||
List *schema = stmt->tableElts;
|
List *schema = stmt->tableElts;
|
||||||
int numberOfAttributes;
|
int numberOfAttributes;
|
||||||
Oid relationId;
|
Oid relationId;
|
||||||
char archChar;
|
char archChar;
|
||||||
List *inheritList = NULL;
|
List *inheritList = NULL;
|
||||||
char *archiveName = NULL;
|
char *archiveName = NULL;
|
||||||
TupleDesc descriptor;
|
TupleDesc descriptor;
|
||||||
List *constraints;
|
List *constraints;
|
||||||
int heaploc,
|
int heaploc,
|
||||||
archloc;
|
archloc;
|
||||||
|
|
||||||
char *typename = NULL; /* the typename of this relation.
|
char *typename = NULL;/* the typename of this relation. not
|
||||||
* not useod for now */
|
* useod for now */
|
||||||
|
|
||||||
if (strlen(stmt->relname) >= NAMEDATALEN)
|
if (strlen(stmt->relname) >= NAMEDATALEN)
|
||||||
elog(WARN, "the relation name %s is >= %d characters long", stmt->relname,
|
elog(WARN, "the relation name %s is >= %d characters long", stmt->relname,
|
||||||
@@ -84,19 +84,19 @@ DefineRelation(CreateStmt * stmt)
|
|||||||
|
|
||||||
switch (stmt->archiveType)
|
switch (stmt->archiveType)
|
||||||
{
|
{
|
||||||
case ARCH_NONE:
|
case ARCH_NONE:
|
||||||
archChar = 'n';
|
archChar = 'n';
|
||||||
break;
|
break;
|
||||||
case ARCH_LIGHT:
|
case ARCH_LIGHT:
|
||||||
archChar = 'l';
|
archChar = 'l';
|
||||||
break;
|
break;
|
||||||
case ARCH_HEAVY:
|
case ARCH_HEAVY:
|
||||||
archChar = 'h';
|
archChar = 'h';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "Botched archive mode %d, ignoring",
|
elog(WARN, "Botched archive mode %d, ignoring",
|
||||||
stmt->archiveType);
|
stmt->archiveType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->location == -1)
|
if (stmt->location == -1)
|
||||||
@@ -145,15 +145,15 @@ DefineRelation(CreateStmt * stmt)
|
|||||||
|
|
||||||
if (constraints != NIL)
|
if (constraints != NIL)
|
||||||
{
|
{
|
||||||
List *entry;
|
List *entry;
|
||||||
int nconstr = length(constraints);
|
int nconstr = length(constraints);
|
||||||
ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck));
|
ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck));
|
||||||
int ncheck = 0;
|
int ncheck = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
foreach(entry, constraints)
|
foreach(entry, constraints)
|
||||||
{
|
{
|
||||||
ConstraintDef *cdef = (ConstraintDef *) lfirst(entry);
|
ConstraintDef *cdef = (ConstraintDef *) lfirst(entry);
|
||||||
|
|
||||||
if (cdef->type == CONSTR_CHECK)
|
if (cdef->type == CONSTR_CHECK)
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@ DefineRelation(CreateStmt * stmt)
|
|||||||
*/
|
*/
|
||||||
if (archChar != 'n')
|
if (archChar != 'n')
|
||||||
{
|
{
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need to create an archive relation for this heap relation. We
|
* Need to create an archive relation for this heap relation. We
|
||||||
@@ -279,12 +279,12 @@ RemoveRelation(char *name)
|
|||||||
* \ /
|
* \ /
|
||||||
* stud_emp {7:percent}
|
* stud_emp {7:percent}
|
||||||
*/
|
*/
|
||||||
static List *
|
static List *
|
||||||
MergeAttributes(List * schema, List * supers, List ** supconstr)
|
MergeAttributes(List * schema, List * supers, List ** supconstr)
|
||||||
{
|
{
|
||||||
List *entry;
|
List *entry;
|
||||||
List *inhSchema = NIL;
|
List *inhSchema = NIL;
|
||||||
List *constraints = NIL;
|
List *constraints = NIL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validates that there are no duplications. Validity checking of
|
* Validates that there are no duplications. Validity checking of
|
||||||
@@ -292,8 +292,8 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
*/
|
*/
|
||||||
foreach(entry, schema)
|
foreach(entry, schema)
|
||||||
{
|
{
|
||||||
List *rest;
|
List *rest;
|
||||||
ColumnDef *coldef = lfirst(entry);
|
ColumnDef *coldef = lfirst(entry);
|
||||||
|
|
||||||
foreach(rest, lnext(entry))
|
foreach(rest, lnext(entry))
|
||||||
{
|
{
|
||||||
@@ -301,7 +301,7 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
/*
|
/*
|
||||||
* check for duplicated relation names
|
* check for duplicated relation names
|
||||||
*/
|
*/
|
||||||
ColumnDef *restdef = lfirst(rest);
|
ColumnDef *restdef = lfirst(rest);
|
||||||
|
|
||||||
if (!strcmp(coldef->colname, restdef->colname))
|
if (!strcmp(coldef->colname, restdef->colname))
|
||||||
{
|
{
|
||||||
@@ -312,7 +312,7 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
}
|
}
|
||||||
foreach(entry, supers)
|
foreach(entry, supers)
|
||||||
{
|
{
|
||||||
List *rest;
|
List *rest;
|
||||||
|
|
||||||
foreach(rest, lnext(entry))
|
foreach(rest, lnext(entry))
|
||||||
{
|
{
|
||||||
@@ -329,12 +329,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
*/
|
*/
|
||||||
foreach(entry, supers)
|
foreach(entry, supers)
|
||||||
{
|
{
|
||||||
char *name = strVal(lfirst(entry));
|
char *name = strVal(lfirst(entry));
|
||||||
Relation relation;
|
Relation relation;
|
||||||
List *partialResult = NIL;
|
List *partialResult = NIL;
|
||||||
AttrNumber attrno;
|
AttrNumber attrno;
|
||||||
TupleDesc tupleDesc;
|
TupleDesc tupleDesc;
|
||||||
TupleConstr *constr;
|
TupleConstr *constr;
|
||||||
|
|
||||||
relation = heap_openr(name);
|
relation = heap_openr(name);
|
||||||
if (relation == NULL)
|
if (relation == NULL)
|
||||||
@@ -354,11 +354,11 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
for (attrno = relation->rd_rel->relnatts - 1; attrno >= 0; attrno--)
|
for (attrno = relation->rd_rel->relnatts - 1; attrno >= 0; attrno--)
|
||||||
{
|
{
|
||||||
AttributeTupleForm attribute = tupleDesc->attrs[attrno];
|
AttributeTupleForm attribute = tupleDesc->attrs[attrno];
|
||||||
char *attributeName;
|
char *attributeName;
|
||||||
char *attributeType;
|
char *attributeType;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
ColumnDef *def;
|
ColumnDef *def;
|
||||||
TypeName *typename;
|
TypeName *typename;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* form name, type and constraints
|
* form name, type and constraints
|
||||||
@@ -398,8 +398,8 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
def->defval = NULL;
|
def->defval = NULL;
|
||||||
if (attribute->atthasdef)
|
if (attribute->atthasdef)
|
||||||
{
|
{
|
||||||
AttrDefault *attrdef = constr->defval;
|
AttrDefault *attrdef = constr->defval;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Assert(constr != NULL && constr->num_defval > 0);
|
Assert(constr != NULL && constr->num_defval > 0);
|
||||||
|
|
||||||
@@ -417,12 +417,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
|
|
||||||
if (constr && constr->num_check > 0)
|
if (constr && constr->num_check > 0)
|
||||||
{
|
{
|
||||||
ConstrCheck *check = constr->check;
|
ConstrCheck *check = constr->check;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < constr->num_check; i++)
|
for (i = 0; i < constr->num_check; i++)
|
||||||
{
|
{
|
||||||
ConstraintDef *cdef = (ConstraintDef *) palloc(sizeof(ConstraintDef));
|
ConstraintDef *cdef = (ConstraintDef *) palloc(sizeof(ConstraintDef));
|
||||||
|
|
||||||
cdef->type = CONSTR_CHECK;
|
cdef->type = CONSTR_CHECK;
|
||||||
if (check[i].ccname[0] == '$')
|
if (check[i].ccname[0] == '$')
|
||||||
@@ -461,12 +461,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr)
|
|||||||
static void
|
static void
|
||||||
StoreCatalogInheritance(Oid relationId, List * supers)
|
StoreCatalogInheritance(Oid relationId, List * supers)
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
TupleDesc desc;
|
TupleDesc desc;
|
||||||
int16 seqNumber;
|
int16 seqNumber;
|
||||||
List *entry;
|
List *entry;
|
||||||
List *idList;
|
List *idList;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -488,8 +488,8 @@ StoreCatalogInheritance(Oid relationId, List * supers)
|
|||||||
idList = NIL;
|
idList = NIL;
|
||||||
foreach(entry, supers)
|
foreach(entry, supers)
|
||||||
{
|
{
|
||||||
Datum datum[Natts_pg_inherits];
|
Datum datum[Natts_pg_inherits];
|
||||||
char nullarr[Natts_pg_inherits];
|
char nullarr[Natts_pg_inherits];
|
||||||
|
|
||||||
tuple = SearchSysCacheTuple(RELNAME,
|
tuple = SearchSysCacheTuple(RELNAME,
|
||||||
PointerGetDatum(strVal(lfirst(entry))),
|
PointerGetDatum(strVal(lfirst(entry))),
|
||||||
@@ -536,11 +536,11 @@ StoreCatalogInheritance(Oid relationId, List * supers)
|
|||||||
*/
|
*/
|
||||||
foreach(entry, idList)
|
foreach(entry, idList)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Oid id;
|
Oid id;
|
||||||
int16 number;
|
int16 number;
|
||||||
List *next;
|
List *next;
|
||||||
List *current;
|
List *current;
|
||||||
|
|
||||||
id = (Oid) lfirsti(entry);
|
id = (Oid) lfirsti(entry);
|
||||||
current = entry;
|
current = entry;
|
||||||
@@ -572,9 +572,9 @@ StoreCatalogInheritance(Oid relationId, List * supers)
|
|||||||
*/
|
*/
|
||||||
foreach(entry, idList)
|
foreach(entry, idList)
|
||||||
{
|
{
|
||||||
Oid name;
|
Oid name;
|
||||||
List *rest;
|
List *rest;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
name = lfirsti(entry);
|
name = lfirsti(entry);
|
||||||
@@ -613,8 +613,8 @@ again:
|
|||||||
|
|
||||||
foreach(entry, idList)
|
foreach(entry, idList)
|
||||||
{
|
{
|
||||||
Datum datum[Natts_pg_ipl];
|
Datum datum[Natts_pg_ipl];
|
||||||
char nullarr[Natts_pg_ipl];
|
char nullarr[Natts_pg_ipl];
|
||||||
|
|
||||||
datum[0] = ObjectIdGetDatum(relationId); /* iplrel */
|
datum[0] = ObjectIdGetDatum(relationId); /* iplrel */
|
||||||
datum[1] = ObjectIdGetDatum(lfirsti(entry));
|
datum[1] = ObjectIdGetDatum(lfirsti(entry));
|
||||||
@@ -642,11 +642,11 @@ again:
|
|||||||
static int
|
static int
|
||||||
checkAttrExists(char *attributeName, char *attributeType, List * schema)
|
checkAttrExists(char *attributeName, char *attributeType, List * schema)
|
||||||
{
|
{
|
||||||
List *s;
|
List *s;
|
||||||
|
|
||||||
foreach(s, schema)
|
foreach(s, schema)
|
||||||
{
|
{
|
||||||
ColumnDef *def = lfirst(s);
|
ColumnDef *def = lfirst(s);
|
||||||
|
|
||||||
if (!strcmp(attributeName, def->colname))
|
if (!strcmp(attributeName, def->colname))
|
||||||
{
|
{
|
||||||
@@ -672,10 +672,10 @@ checkAttrExists(char *attributeName, char *attributeType, List * schema)
|
|||||||
* the CALLER is responsible for freeing the memory allocated
|
* the CALLER is responsible for freeing the memory allocated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
MakeArchiveName(Oid relationId)
|
MakeArchiveName(Oid relationId)
|
||||||
{
|
{
|
||||||
char *arch;
|
char *arch;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Archive relations are named a,XXXXX where XXXXX == the OID of the
|
* Archive relations are named a,XXXXX where XXXXX == the OID of the
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.13 1997/09/07 04:40:43 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.14 1997/09/08 02:22:08 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -39,19 +39,19 @@
|
|||||||
#define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args!=NULL)
|
#define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args!=NULL)
|
||||||
|
|
||||||
/* non-export function prototypes */
|
/* non-export function prototypes */
|
||||||
static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid);
|
static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid);
|
||||||
static void
|
static void
|
||||||
CheckPredExpr(Node * predicate, List * rangeTable,
|
CheckPredExpr(Node * predicate, List * rangeTable,
|
||||||
Oid baseRelOid);
|
Oid baseRelOid);
|
||||||
static void
|
static void
|
||||||
CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid);
|
CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid);
|
||||||
static void
|
static void
|
||||||
FuncIndexArgs(IndexElem * funcIndex, AttrNumber * attNumP,
|
FuncIndexArgs(IndexElem * funcIndex, AttrNumber * attNumP,
|
||||||
Oid * argTypes, Oid * opOidP, Oid relId);
|
Oid * argTypes, Oid * opOidP, Oid relId);
|
||||||
static void
|
static void
|
||||||
NormIndexAttrs(List * attList, AttrNumber * attNumP,
|
NormIndexAttrs(List * attList, AttrNumber * attNumP,
|
||||||
Oid * opOidP, Oid relId);
|
Oid * opOidP, Oid relId);
|
||||||
static char *GetDefaultOpClass(Oid atttypid);
|
static char *GetDefaultOpClass(Oid atttypid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DefineIndex --
|
* DefineIndex --
|
||||||
@@ -76,18 +76,18 @@ DefineIndex(char *heapRelationName,
|
|||||||
Expr * predicate,
|
Expr * predicate,
|
||||||
List * rangetable)
|
List * rangetable)
|
||||||
{
|
{
|
||||||
Oid *classObjectId;
|
Oid *classObjectId;
|
||||||
Oid accessMethodId;
|
Oid accessMethodId;
|
||||||
Oid relationId;
|
Oid relationId;
|
||||||
int numberOfAttributes;
|
int numberOfAttributes;
|
||||||
AttrNumber *attributeNumberA;
|
AttrNumber *attributeNumberA;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
uint16 parameterCount = 0;
|
uint16 parameterCount = 0;
|
||||||
Datum *parameterA = NULL;
|
Datum *parameterA = NULL;
|
||||||
FuncIndexInfo fInfo;
|
FuncIndexInfo fInfo;
|
||||||
List *cnfPred = NULL;
|
List *cnfPred = NULL;
|
||||||
bool lossy = FALSE;
|
bool lossy = FALSE;
|
||||||
List *pl;
|
List *pl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle attributes
|
* Handle attributes
|
||||||
@@ -138,7 +138,7 @@ DefineIndex(char *heapRelationName,
|
|||||||
*/
|
*/
|
||||||
foreach(pl, parameterList)
|
foreach(pl, parameterList)
|
||||||
{
|
{
|
||||||
ParamString *param = (ParamString *) lfirst(pl);
|
ParamString *param = (ParamString *) lfirst(pl);
|
||||||
|
|
||||||
if (!strcasecmp(param->name, "islossy"))
|
if (!strcasecmp(param->name, "islossy"))
|
||||||
lossy = TRUE;
|
lossy = TRUE;
|
||||||
@@ -162,8 +162,8 @@ DefineIndex(char *heapRelationName,
|
|||||||
|
|
||||||
if (IsFuncIndex(attributeList))
|
if (IsFuncIndex(attributeList))
|
||||||
{
|
{
|
||||||
IndexElem *funcIndex = lfirst(attributeList);
|
IndexElem *funcIndex = lfirst(attributeList);
|
||||||
int nargs;
|
int nargs;
|
||||||
|
|
||||||
nargs = length(funcIndex->args);
|
nargs = length(funcIndex->args);
|
||||||
if (nargs > INDEX_MAX_KEYS)
|
if (nargs > INDEX_MAX_KEYS)
|
||||||
@@ -225,23 +225,23 @@ DefineIndex(char *heapRelationName,
|
|||||||
void
|
void
|
||||||
ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable)
|
ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable)
|
||||||
{
|
{
|
||||||
Oid *classObjectId;
|
Oid *classObjectId;
|
||||||
Oid accessMethodId;
|
Oid accessMethodId;
|
||||||
Oid indexId,
|
Oid indexId,
|
||||||
relationId;
|
relationId;
|
||||||
Oid indproc;
|
Oid indproc;
|
||||||
int numberOfAttributes;
|
int numberOfAttributes;
|
||||||
AttrNumber *attributeNumberA;
|
AttrNumber *attributeNumberA;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
FuncIndexInfo fInfo;
|
FuncIndexInfo fInfo;
|
||||||
FuncIndexInfo *funcInfo = NULL;
|
FuncIndexInfo *funcInfo = NULL;
|
||||||
IndexTupleForm index;
|
IndexTupleForm index;
|
||||||
Node *oldPred = NULL;
|
Node *oldPred = NULL;
|
||||||
List *cnfPred = NULL;
|
List *cnfPred = NULL;
|
||||||
PredInfo *predInfo;
|
PredInfo *predInfo;
|
||||||
Relation heapRelation;
|
Relation heapRelation;
|
||||||
Relation indexRelation;
|
Relation indexRelation;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* compute index relation id and access method id
|
* compute index relation id and access method id
|
||||||
@@ -283,7 +283,7 @@ ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable)
|
|||||||
|
|
||||||
if (VARSIZE(&index->indpred) != 0)
|
if (VARSIZE(&index->indpred) != 0)
|
||||||
{
|
{
|
||||||
char *predString;
|
char *predString;
|
||||||
|
|
||||||
predString = fmgr(F_TEXTOUT, &index->indpred);
|
predString = fmgr(F_TEXTOUT, &index->indpred);
|
||||||
oldPred = stringToNode(predString);
|
oldPred = stringToNode(predString);
|
||||||
@@ -366,7 +366,7 @@ ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable)
|
|||||||
static void
|
static void
|
||||||
CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid)
|
CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid)
|
||||||
{
|
{
|
||||||
List *item;
|
List *item;
|
||||||
|
|
||||||
foreach(item, predList)
|
foreach(item, predList)
|
||||||
{
|
{
|
||||||
@@ -377,8 +377,8 @@ CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid)
|
|||||||
static void
|
static void
|
||||||
CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid)
|
CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid)
|
||||||
{
|
{
|
||||||
List *clauses = NIL,
|
List *clauses = NIL,
|
||||||
*clause;
|
*clause;
|
||||||
|
|
||||||
if (is_opclause(predicate))
|
if (is_opclause(predicate))
|
||||||
{
|
{
|
||||||
@@ -401,8 +401,8 @@ CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid)
|
|||||||
static void
|
static void
|
||||||
CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid)
|
CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid)
|
||||||
{
|
{
|
||||||
Var *pred_var;
|
Var *pred_var;
|
||||||
Const *pred_const;
|
Const *pred_const;
|
||||||
|
|
||||||
pred_var = (Var *) get_leftop(predicate);
|
pred_var = (Var *) get_leftop(predicate);
|
||||||
pred_const = (Const *) get_rightop(predicate);
|
pred_const = (Const *) get_rightop(predicate);
|
||||||
@@ -427,8 +427,8 @@ FuncIndexArgs(IndexElem * funcIndex,
|
|||||||
Oid * opOidP,
|
Oid * opOidP,
|
||||||
Oid relId)
|
Oid relId)
|
||||||
{
|
{
|
||||||
List *rest;
|
List *rest;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
AttributeTupleForm att;
|
AttributeTupleForm att;
|
||||||
|
|
||||||
tuple = SearchSysCacheTuple(CLANAME,
|
tuple = SearchSysCacheTuple(CLANAME,
|
||||||
@@ -449,7 +449,7 @@ FuncIndexArgs(IndexElem * funcIndex,
|
|||||||
*/
|
*/
|
||||||
for (rest = funcIndex->args; rest != NIL; rest = lnext(rest))
|
for (rest = funcIndex->args; rest != NIL; rest = lnext(rest))
|
||||||
{
|
{
|
||||||
char *arg;
|
char *arg;
|
||||||
|
|
||||||
arg = strVal(lfirst(rest));
|
arg = strVal(lfirst(rest));
|
||||||
|
|
||||||
@@ -475,8 +475,8 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */
|
|||||||
Oid * opOidP,
|
Oid * opOidP,
|
||||||
Oid relId)
|
Oid relId)
|
||||||
{
|
{
|
||||||
List *rest;
|
List *rest;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* process attributeList
|
* process attributeList
|
||||||
@@ -484,7 +484,7 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */
|
|||||||
|
|
||||||
for (rest = attList; rest != NIL; rest = lnext(rest))
|
for (rest = attList; rest != NIL; rest = lnext(rest))
|
||||||
{
|
{
|
||||||
IndexElem *attribute;
|
IndexElem *attribute;
|
||||||
AttributeTupleForm attform;
|
AttributeTupleForm attform;
|
||||||
|
|
||||||
attribute = lfirst(rest);
|
attribute = lfirst(rest);
|
||||||
@@ -531,10 +531,10 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
GetDefaultOpClass(Oid atttypid)
|
GetDefaultOpClass(Oid atttypid)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
tuple = SearchSysCacheTuple(CLADEFTYPE,
|
tuple = SearchSysCacheTuple(CLADEFTYPE,
|
||||||
ObjectIdGetDatum(atttypid),
|
ObjectIdGetDatum(atttypid),
|
||||||
@@ -559,7 +559,7 @@ GetDefaultOpClass(Oid atttypid)
|
|||||||
void
|
void
|
||||||
RemoveIndex(char *name)
|
RemoveIndex(char *name)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
tuple = SearchSysCacheTuple(RELNAME,
|
tuple = SearchSysCacheTuple(RELNAME,
|
||||||
PointerGetDatum(name),
|
PointerGetDatum(name),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.14 1997/09/07 04:40:46 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.15 1997/09/08 02:22:09 momjian Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* The "DefineFoo" routines take the parse tree and pick out the
|
* The "DefineFoo" routines take the parse tree and pick out the
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
#include <tcop/dest.h>
|
#include <tcop/dest.h>
|
||||||
#include <catalog/pg_user.h>
|
#include <catalog/pg_user.h>
|
||||||
|
|
||||||
static char *defGetString(DefElem * def);
|
static char *defGetString(DefElem * def);
|
||||||
static int defGetTypeLength(DefElem * def);
|
static int defGetTypeLength(DefElem * def);
|
||||||
|
|
||||||
#define DEFAULT_TYPDELIM ','
|
#define DEFAULT_TYPDELIM ','
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ case_translate_language_name(const char *input, char *output)
|
|||||||
Translate the input language name to lower case, except if it's C,
|
Translate the input language name to lower case, except if it's C,
|
||||||
translate to upper case.
|
translate to upper case.
|
||||||
--------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------*/
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < NAMEDATALEN && input[i] != '\0'; ++i)
|
for (i = 0; i < NAMEDATALEN && input[i] != '\0'; ++i)
|
||||||
output[i] = tolower(input[i]);
|
output[i] = tolower(input[i]);
|
||||||
@@ -90,7 +90,7 @@ compute_return_type(const Node * returnType,
|
|||||||
if (nodeTag(returnType) == T_TypeName)
|
if (nodeTag(returnType) == T_TypeName)
|
||||||
{
|
{
|
||||||
/* a set of values */
|
/* a set of values */
|
||||||
TypeName *setType = (TypeName *) returnType;
|
TypeName *setType = (TypeName *) returnType;
|
||||||
|
|
||||||
*prorettype_p = setType->name;
|
*prorettype_p = setType->name;
|
||||||
*returnsSet_p = true;
|
*returnsSet_p = true;
|
||||||
@@ -116,7 +116,7 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p,
|
|||||||
|
|
||||||
These are the full parameters of a C or internal function.
|
These are the full parameters of a C or internal function.
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
List *pl;
|
List *pl;
|
||||||
|
|
||||||
/* the defaults */
|
/* the defaults */
|
||||||
*byte_pct_p = BYTE_PCT;
|
*byte_pct_p = BYTE_PCT;
|
||||||
@@ -126,7 +126,7 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p,
|
|||||||
|
|
||||||
foreach(pl, (List *) parameters)
|
foreach(pl, (List *) parameters)
|
||||||
{
|
{
|
||||||
ParamString *param = (ParamString *) lfirst(pl);
|
ParamString *param = (ParamString *) lfirst(pl);
|
||||||
|
|
||||||
if (strcasecmp(param->name, "iscachable") == 0)
|
if (strcasecmp(param->name, "iscachable") == 0)
|
||||||
{
|
{
|
||||||
@@ -153,8 +153,8 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p,
|
|||||||
{
|
{
|
||||||
if (sscanf(param->val, "%d", perbyte_cpu_p) == 0)
|
if (sscanf(param->val, "%d", perbyte_cpu_p) == 0)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
for (count = 0, ptr = param->val; *ptr != '\0'; ptr++)
|
for (count = 0, ptr = param->val; *ptr != '\0'; ptr++)
|
||||||
if (*ptr == '!')
|
if (*ptr == '!')
|
||||||
@@ -166,8 +166,8 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p,
|
|||||||
{
|
{
|
||||||
if (sscanf(param->val, "%d", percall_cpu_p) == 0)
|
if (sscanf(param->val, "%d", percall_cpu_p) == 0)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
for (count = 0, ptr = param->val; *ptr != '\0'; ptr++)
|
for (count = 0, ptr = param->val; *ptr != '\0'; ptr++)
|
||||||
if (*ptr == '!')
|
if (*ptr == '!')
|
||||||
@@ -212,16 +212,16 @@ interpret_AS_clause(const char languageName[], const char as[],
|
|||||||
void
|
void
|
||||||
CreateFunction(ProcedureStmt * stmt, CommandDest dest)
|
CreateFunction(ProcedureStmt * stmt, CommandDest dest)
|
||||||
{
|
{
|
||||||
char *probin_str;
|
char *probin_str;
|
||||||
|
|
||||||
/* pathname of executable file that executes this function, if any */
|
/* pathname of executable file that executes this function, if any */
|
||||||
char *prosrc_str;
|
char *prosrc_str;
|
||||||
|
|
||||||
/* SQL that executes this function, if any */
|
/* SQL that executes this function, if any */
|
||||||
char *prorettype;
|
char *prorettype;
|
||||||
|
|
||||||
/* Type of return value (or member of set of values) from function */
|
/* Type of return value (or member of set of values) from function */
|
||||||
char languageName[NAMEDATALEN];
|
char languageName[NAMEDATALEN];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* name of language of function, with case adjusted: "C", "internal",
|
* name of language of function, with case adjusted: "C", "internal",
|
||||||
@@ -232,12 +232,12 @@ CreateFunction(ProcedureStmt * stmt, CommandDest dest)
|
|||||||
* The following are attributes of the function, as expressed in the
|
* The following are attributes of the function, as expressed in the
|
||||||
* CREATE FUNCTION statement, where applicable.
|
* CREATE FUNCTION statement, where applicable.
|
||||||
*/
|
*/
|
||||||
int32 byte_pct,
|
int32 byte_pct,
|
||||||
perbyte_cpu,
|
perbyte_cpu,
|
||||||
percall_cpu,
|
percall_cpu,
|
||||||
outin_ratio;
|
outin_ratio;
|
||||||
bool canCache;
|
bool canCache;
|
||||||
bool returnsSet;
|
bool returnsSet;
|
||||||
|
|
||||||
/* The function returns a set of values, as opposed to a singleton. */
|
/* The function returns a set of values, as opposed to a singleton. */
|
||||||
|
|
||||||
@@ -317,30 +317,29 @@ void
|
|||||||
DefineOperator(char *oprName,
|
DefineOperator(char *oprName,
|
||||||
List * parameters)
|
List * parameters)
|
||||||
{
|
{
|
||||||
uint16 precedence = 0; /* operator precedence */
|
uint16 precedence = 0; /* operator precedence */
|
||||||
bool canHash = false; /* operator hashes */
|
bool canHash = false;/* operator hashes */
|
||||||
bool isLeftAssociative = true; /* operator is left
|
bool isLeftAssociative = true; /* operator is left
|
||||||
* associative */
|
* associative */
|
||||||
char *functionName = NULL; /* function for operator */
|
char *functionName = NULL; /* function for operator */
|
||||||
char *typeName1 = NULL; /* first type name */
|
char *typeName1 = NULL; /* first type name */
|
||||||
char *typeName2 = NULL; /* second type name */
|
char *typeName2 = NULL; /* second type name */
|
||||||
char *commutatorName = NULL; /* optional commutator
|
char *commutatorName = NULL; /* optional commutator operator
|
||||||
* operator name */
|
|
||||||
char *negatorName = NULL; /* optional negator operator name */
|
|
||||||
char *restrictionName = NULL; /* optional restrict. sel.
|
|
||||||
* procedure */
|
|
||||||
char *joinName = NULL; /* optional join sel. procedure
|
|
||||||
* name */
|
* name */
|
||||||
char *sortName1 = NULL; /* optional first sort operator */
|
char *negatorName = NULL; /* optional negator operator name */
|
||||||
char *sortName2 = NULL; /* optional second sort operator */
|
char *restrictionName = NULL; /* optional restrict. sel.
|
||||||
List *pl;
|
* procedure */
|
||||||
|
char *joinName = NULL;/* optional join sel. procedure name */
|
||||||
|
char *sortName1 = NULL; /* optional first sort operator */
|
||||||
|
char *sortName2 = NULL; /* optional second sort operator */
|
||||||
|
List *pl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop over the definition list and extract the information we need.
|
* loop over the definition list and extract the information we need.
|
||||||
*/
|
*/
|
||||||
foreach(pl, parameters)
|
foreach(pl, parameters)
|
||||||
{
|
{
|
||||||
DefElem *defel = (DefElem *) lfirst(pl);
|
DefElem *defel = (DefElem *) lfirst(pl);
|
||||||
|
|
||||||
if (!strcasecmp(defel->defname, "leftarg"))
|
if (!strcasecmp(defel->defname, "leftarg"))
|
||||||
{
|
{
|
||||||
@@ -465,19 +464,19 @@ void
|
|||||||
DefineAggregate(char *aggName, List * parameters)
|
DefineAggregate(char *aggName, List * parameters)
|
||||||
|
|
||||||
{
|
{
|
||||||
char *stepfunc1Name = NULL;
|
char *stepfunc1Name = NULL;
|
||||||
char *stepfunc2Name = NULL;
|
char *stepfunc2Name = NULL;
|
||||||
char *finalfuncName = NULL;
|
char *finalfuncName = NULL;
|
||||||
char *baseType = NULL;
|
char *baseType = NULL;
|
||||||
char *stepfunc1Type = NULL;
|
char *stepfunc1Type = NULL;
|
||||||
char *stepfunc2Type = NULL;
|
char *stepfunc2Type = NULL;
|
||||||
char *init1 = NULL;
|
char *init1 = NULL;
|
||||||
char *init2 = NULL;
|
char *init2 = NULL;
|
||||||
List *pl;
|
List *pl;
|
||||||
|
|
||||||
foreach(pl, parameters)
|
foreach(pl, parameters)
|
||||||
{
|
{
|
||||||
DefElem *defel = (DefElem *) lfirst(pl);
|
DefElem *defel = (DefElem *) lfirst(pl);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sfunc1
|
* sfunc1
|
||||||
@@ -573,19 +572,19 @@ DefineAggregate(char *aggName, List * parameters)
|
|||||||
void
|
void
|
||||||
DefineType(char *typeName, List * parameters)
|
DefineType(char *typeName, List * parameters)
|
||||||
{
|
{
|
||||||
int16 internalLength = 0; /* int2 */
|
int16 internalLength = 0; /* int2 */
|
||||||
int16 externalLength = 0; /* int2 */
|
int16 externalLength = 0; /* int2 */
|
||||||
char *elemName = NULL;
|
char *elemName = NULL;
|
||||||
char *inputName = NULL;
|
char *inputName = NULL;
|
||||||
char *outputName = NULL;
|
char *outputName = NULL;
|
||||||
char *sendName = NULL;
|
char *sendName = NULL;
|
||||||
char *receiveName = NULL;
|
char *receiveName = NULL;
|
||||||
char *defaultValue = NULL; /* Datum */
|
char *defaultValue = NULL; /* Datum */
|
||||||
bool byValue = false;
|
bool byValue = false;
|
||||||
char delimiter = DEFAULT_TYPDELIM;
|
char delimiter = DEFAULT_TYPDELIM;
|
||||||
char *shadow_type;
|
char *shadow_type;
|
||||||
List *pl;
|
List *pl;
|
||||||
char alignment = 'i'; /* default alignment */
|
char alignment = 'i';/* default alignment */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Type names can only be 15 characters long, so that the shadow type
|
* Type names can only be 15 characters long, so that the shadow type
|
||||||
@@ -599,7 +598,7 @@ DefineType(char *typeName, List * parameters)
|
|||||||
|
|
||||||
foreach(pl, parameters)
|
foreach(pl, parameters)
|
||||||
{
|
{
|
||||||
DefElem *defel = (DefElem *) lfirst(pl);
|
DefElem *defel = (DefElem *) lfirst(pl);
|
||||||
|
|
||||||
if (!strcasecmp(defel->defname, "internallength"))
|
if (!strcasecmp(defel->defname, "internallength"))
|
||||||
{
|
{
|
||||||
@@ -623,7 +622,7 @@ DefineType(char *typeName, List * parameters)
|
|||||||
}
|
}
|
||||||
else if (!strcasecmp(defel->defname, "delimiter"))
|
else if (!strcasecmp(defel->defname, "delimiter"))
|
||||||
{
|
{
|
||||||
char *p = defGetString(defel);
|
char *p = defGetString(defel);
|
||||||
|
|
||||||
delimiter = p[0];
|
delimiter = p[0];
|
||||||
}
|
}
|
||||||
@@ -645,7 +644,7 @@ DefineType(char *typeName, List * parameters)
|
|||||||
}
|
}
|
||||||
else if (!strcasecmp(defel->defname, "alignment"))
|
else if (!strcasecmp(defel->defname, "alignment"))
|
||||||
{
|
{
|
||||||
char *a = defGetString(defel);
|
char *a = defGetString(defel);
|
||||||
|
|
||||||
if (!strcasecmp(a, "double"))
|
if (!strcasecmp(a, "double"))
|
||||||
{
|
{
|
||||||
@@ -720,7 +719,7 @@ DefineType(char *typeName, List * parameters)
|
|||||||
pfree(shadow_type);
|
pfree(shadow_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
defGetString(DefElem * def)
|
defGetString(DefElem * def)
|
||||||
{
|
{
|
||||||
if (nodeTag(def->arg) != T_String)
|
if (nodeTag(def->arg) != T_String)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.11 1997/09/07 04:40:49 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.12 1997/09/08 02:22:10 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -28,13 +28,13 @@
|
|||||||
typedef struct ExplainState
|
typedef struct ExplainState
|
||||||
{
|
{
|
||||||
/* options */
|
/* options */
|
||||||
bool printCost; /* print cost */
|
bool printCost; /* print cost */
|
||||||
bool printNodes; /* do nodeToString() instead */
|
bool printNodes; /* do nodeToString() instead */
|
||||||
/* other states */
|
/* other states */
|
||||||
List *rtable; /* range table */
|
List *rtable; /* range table */
|
||||||
} ExplainState;
|
} ExplainState;
|
||||||
|
|
||||||
static char *Explain_PlanToString(Plan * plan, ExplainState * es);
|
static char *Explain_PlanToString(Plan * plan, ExplainState * es);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ExplainQuery -
|
* ExplainQuery -
|
||||||
@@ -44,15 +44,15 @@ static char *Explain_PlanToString(Plan * plan, ExplainState * es);
|
|||||||
void
|
void
|
||||||
ExplainQuery(Query * query, bool verbose, CommandDest dest)
|
ExplainQuery(Query * query, bool verbose, CommandDest dest)
|
||||||
{
|
{
|
||||||
char *s = NULL,
|
char *s = NULL,
|
||||||
*s2;
|
*s2;
|
||||||
Plan *plan;
|
Plan *plan;
|
||||||
ExplainState *es;
|
ExplainState *es;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (IsAbortedTransactionBlockState())
|
if (IsAbortedTransactionBlockState())
|
||||||
{
|
{
|
||||||
char *tag = "*ABORT STATE*";
|
char *tag = "*ABORT STATE*";
|
||||||
|
|
||||||
EndCommand(tag, dest);
|
EndCommand(tag, dest);
|
||||||
|
|
||||||
@@ -118,9 +118,9 @@ ExplainQuery(Query * query, bool verbose, CommandDest dest)
|
|||||||
static void
|
static void
|
||||||
explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es)
|
explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es)
|
||||||
{
|
{
|
||||||
char *pname;
|
char *pname;
|
||||||
char buf[1000];
|
char buf[1000];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (plan == NULL)
|
if (plan == NULL)
|
||||||
{
|
{
|
||||||
@@ -130,51 +130,51 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es)
|
|||||||
|
|
||||||
switch (nodeTag(plan))
|
switch (nodeTag(plan))
|
||||||
{
|
{
|
||||||
case T_Result:
|
case T_Result:
|
||||||
pname = "Result";
|
pname = "Result";
|
||||||
break;
|
break;
|
||||||
case T_Append:
|
case T_Append:
|
||||||
pname = "Append";
|
pname = "Append";
|
||||||
break;
|
break;
|
||||||
case T_NestLoop:
|
case T_NestLoop:
|
||||||
pname = "Nested Loop";
|
pname = "Nested Loop";
|
||||||
break;
|
break;
|
||||||
case T_MergeJoin:
|
case T_MergeJoin:
|
||||||
pname = "Merge Join";
|
pname = "Merge Join";
|
||||||
break;
|
break;
|
||||||
case T_HashJoin:
|
case T_HashJoin:
|
||||||
pname = "Hash Join";
|
pname = "Hash Join";
|
||||||
break;
|
break;
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
pname = "Seq Scan";
|
pname = "Seq Scan";
|
||||||
break;
|
break;
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
pname = "Index Scan";
|
pname = "Index Scan";
|
||||||
break;
|
break;
|
||||||
case T_Temp:
|
case T_Temp:
|
||||||
pname = "Temp Scan";
|
pname = "Temp Scan";
|
||||||
break;
|
break;
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
pname = "Sort";
|
pname = "Sort";
|
||||||
break;
|
break;
|
||||||
case T_Group:
|
case T_Group:
|
||||||
pname = "Group";
|
pname = "Group";
|
||||||
break;
|
break;
|
||||||
case T_Agg:
|
case T_Agg:
|
||||||
pname = "Aggregate";
|
pname = "Aggregate";
|
||||||
break;
|
break;
|
||||||
case T_Unique:
|
case T_Unique:
|
||||||
pname = "Unique";
|
pname = "Unique";
|
||||||
break;
|
break;
|
||||||
case T_Hash:
|
case T_Hash:
|
||||||
pname = "Hash";
|
pname = "Hash";
|
||||||
break;
|
break;
|
||||||
case T_Tee:
|
case T_Tee:
|
||||||
pname = "Tee";
|
pname = "Tee";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pname = "";
|
pname = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < indent; i++)
|
for (i = 0; i < indent; i++)
|
||||||
@@ -183,18 +183,18 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es)
|
|||||||
appendStringInfo(str, pname);
|
appendStringInfo(str, pname);
|
||||||
switch (nodeTag(plan))
|
switch (nodeTag(plan))
|
||||||
{
|
{
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
if (((Scan *) plan)->scanrelid > 0)
|
if (((Scan *) plan)->scanrelid > 0)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = nth(((Scan *) plan)->scanrelid - 1, es->rtable);
|
RangeTblEntry *rte = nth(((Scan *) plan)->scanrelid - 1, es->rtable);
|
||||||
|
|
||||||
sprintf(buf, " on %s", rte->refname);
|
sprintf(buf, " on %s", rte->refname);
|
||||||
appendStringInfo(str, buf);
|
appendStringInfo(str, buf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (es->printCost)
|
if (es->printCost)
|
||||||
{
|
{
|
||||||
@@ -224,11 +224,11 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
Explain_PlanToString(Plan * plan, ExplainState * es)
|
Explain_PlanToString(Plan * plan, ExplainState * es)
|
||||||
{
|
{
|
||||||
StringInfo str;
|
StringInfo str;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (plan == NULL)
|
if (plan == NULL)
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/purge.c,v 1.7 1997/09/07 04:40:51 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/purge.c,v 1.8 1997/09/08 02:22:11 momjian Exp $
|
||||||
*
|
*
|
||||||
* Note:
|
* Note:
|
||||||
* XXX There are many instances of int32 instead of ...Time. These
|
* XXX There are many instances of int32 instead of ...Time. These
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
#include <commands/purge.h>
|
#include <commands/purge.h>
|
||||||
#include <utils/builtins.h> /* for isreltime() */
|
#include <utils/builtins.h> /* for isreltime() */
|
||||||
|
|
||||||
static char cmdname[] = "RelationPurge";
|
static char cmdname[] = "RelationPurge";
|
||||||
|
|
||||||
#define RELATIVE 01
|
#define RELATIVE 01
|
||||||
#define ABSOLUTE 02
|
#define ABSOLUTE 02
|
||||||
@@ -38,23 +38,23 @@ RelationPurge(char *relationName,
|
|||||||
char *absoluteTimeString,
|
char *absoluteTimeString,
|
||||||
char *relativeTimeString)
|
char *relativeTimeString)
|
||||||
{
|
{
|
||||||
register i;
|
register i;
|
||||||
AbsoluteTime absoluteTime = INVALID_ABSTIME;
|
AbsoluteTime absoluteTime = INVALID_ABSTIME;
|
||||||
RelativeTime relativeTime = INVALID_RELTIME;
|
RelativeTime relativeTime = INVALID_RELTIME;
|
||||||
bits8 dateTag;
|
bits8 dateTag;
|
||||||
Relation relation;
|
Relation relation;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
static ScanKeyData key[1] = {
|
static ScanKeyData key[1] = {
|
||||||
{0, Anum_pg_class_relname, F_NAMEEQ}
|
{0, Anum_pg_class_relname, F_NAMEEQ}
|
||||||
};
|
};
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
HeapTuple newTuple,
|
HeapTuple newTuple,
|
||||||
oldTuple;
|
oldTuple;
|
||||||
AbsoluteTime currentTime;
|
AbsoluteTime currentTime;
|
||||||
char *values[Natts_pg_class];
|
char *values[Natts_pg_class];
|
||||||
char nulls[Natts_pg_class];
|
char nulls[Natts_pg_class];
|
||||||
char replace[Natts_pg_class];
|
char replace[Natts_pg_class];
|
||||||
Relation idescs[Num_pg_class_indices];
|
Relation idescs[Num_pg_class_indices];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX for some reason getmyrelids (in inval.c) barfs when you
|
* XXX for some reason getmyrelids (in inval.c) barfs when you
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.7 1997/09/07 04:40:53 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.8 1997/09/08 02:22:12 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -50,26 +50,26 @@ beginRecipe(RecipeStmt * stmt)
|
|||||||
/* structure to keep track of the tee node plans */
|
/* structure to keep track of the tee node plans */
|
||||||
typedef struct _teePlanInfo
|
typedef struct _teePlanInfo
|
||||||
{
|
{
|
||||||
char *tpi_relName;
|
char *tpi_relName;
|
||||||
Query *tpi_parsetree;
|
Query *tpi_parsetree;
|
||||||
Plan *tpi_plan;
|
Plan *tpi_plan;
|
||||||
} TeePlanInfo;
|
} TeePlanInfo;
|
||||||
|
|
||||||
typedef struct _teeInfo
|
typedef struct _teeInfo
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
TeePlanInfo *val;
|
TeePlanInfo *val;
|
||||||
} TeeInfo;
|
} TeeInfo;
|
||||||
|
|
||||||
QueryTreeList *appendQlist(QueryTreeList * q1, QueryTreeList * q2);
|
QueryTreeList *appendQlist(QueryTreeList * q1, QueryTreeList * q2);
|
||||||
void OffsetVarAttno(Node * node, int varno, int offset);
|
void OffsetVarAttno(Node * node, int varno, int offset);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
appendTeeQuery(TeeInfo * teeInfo,
|
appendTeeQuery(TeeInfo * teeInfo,
|
||||||
QueryTreeList * q,
|
QueryTreeList * q,
|
||||||
char *teeNodeName);
|
char *teeNodeName);
|
||||||
|
|
||||||
static Plan *
|
static Plan *
|
||||||
replaceTeeScans(Plan * plan,
|
replaceTeeScans(Plan * plan,
|
||||||
Query * parsetree,
|
Query * parsetree,
|
||||||
TeeInfo * teeInfo);
|
TeeInfo * teeInfo);
|
||||||
@@ -83,12 +83,12 @@ static void
|
|||||||
tg_rewriteQuery(TgRecipe * r, TgNode * n,
|
tg_rewriteQuery(TgRecipe * r, TgNode * n,
|
||||||
QueryTreeList * q,
|
QueryTreeList * q,
|
||||||
QueryTreeList * inputQlist);
|
QueryTreeList * inputQlist);
|
||||||
static Node *
|
static Node *
|
||||||
tg_replaceNumberedParam(Node * expression,
|
tg_replaceNumberedParam(Node * expression,
|
||||||
int pnum,
|
int pnum,
|
||||||
int rt_ind,
|
int rt_ind,
|
||||||
char *teeRelName);
|
char *teeRelName);
|
||||||
static Node *
|
static Node *
|
||||||
tg_rewriteParamsInExpr(Node * expression,
|
tg_rewriteParamsInExpr(Node * expression,
|
||||||
QueryTreeList * inputQlist);
|
QueryTreeList * inputQlist);
|
||||||
static QueryTreeList *
|
static QueryTreeList *
|
||||||
@@ -129,18 +129,18 @@ tg_parseTeeNode(TgRecipe * r,
|
|||||||
void
|
void
|
||||||
beginRecipe(RecipeStmt * stmt)
|
beginRecipe(RecipeStmt * stmt)
|
||||||
{
|
{
|
||||||
TgRecipe *r;
|
TgRecipe *r;
|
||||||
int i;
|
int i;
|
||||||
QueryTreeList *qList;
|
QueryTreeList *qList;
|
||||||
char portalName[1024];
|
char portalName[1024];
|
||||||
|
|
||||||
Plan *plan;
|
Plan *plan;
|
||||||
TupleDesc attinfo;
|
TupleDesc attinfo;
|
||||||
QueryDesc *queryDesc;
|
QueryDesc *queryDesc;
|
||||||
Query *parsetree;
|
Query *parsetree;
|
||||||
|
|
||||||
int numTees;
|
int numTees;
|
||||||
TeeInfo *teeInfo;
|
TeeInfo *teeInfo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* retrieveRecipe() reads the recipe from the database and returns a
|
* retrieveRecipe() reads the recipe from the database and returns a
|
||||||
@@ -177,7 +177,7 @@ beginRecipe(RecipeStmt * stmt)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < r->eyes->num; i++)
|
for (i = 0; i < r->eyes->num; i++)
|
||||||
{
|
{
|
||||||
TgNodePtr e;
|
TgNodePtr e;
|
||||||
|
|
||||||
e = r->eyes->val[i];
|
e = r->eyes->val[i];
|
||||||
if (e->inNodes->num > 1)
|
if (e->inNodes->num > 1)
|
||||||
@@ -231,9 +231,9 @@ beginRecipe(RecipeStmt * stmt)
|
|||||||
* ---------------------------------------------------------- */
|
* ---------------------------------------------------------- */
|
||||||
if (teeInfo)
|
if (teeInfo)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
Plan *tplan;
|
Plan *tplan;
|
||||||
Tee *newplan;
|
Tee *newplan;
|
||||||
|
|
||||||
for (t = 0; t < teeInfo->num; t++)
|
for (t = 0; t < teeInfo->num; t++)
|
||||||
{
|
{
|
||||||
@@ -320,12 +320,12 @@ tg_rewriteQuery(TgRecipe * r,
|
|||||||
QueryTreeList * q,
|
QueryTreeList * q,
|
||||||
QueryTreeList * inputQlist)
|
QueryTreeList * inputQlist)
|
||||||
{
|
{
|
||||||
Query *orig;
|
Query *orig;
|
||||||
Query *inputQ;
|
Query *inputQ;
|
||||||
int i;
|
int i;
|
||||||
List *rtable;
|
List *rtable;
|
||||||
List *input_rtable;
|
List *input_rtable;
|
||||||
int rt_length;
|
int rt_length;
|
||||||
|
|
||||||
/* orig is the original parse tree of the node */
|
/* orig is the original parse tree of the node */
|
||||||
orig = q->qtrees[0];
|
orig = q->qtrees[0];
|
||||||
@@ -380,8 +380,8 @@ tg_rewriteQuery(TgRecipe * r,
|
|||||||
*/
|
*/
|
||||||
if (orig->targetList != NIL)
|
if (orig->targetList != NIL)
|
||||||
{
|
{
|
||||||
List *tl;
|
List *tl;
|
||||||
TargetEntry *tle;
|
TargetEntry *tle;
|
||||||
|
|
||||||
foreach(tl, orig->targetList)
|
foreach(tl, orig->targetList)
|
||||||
{
|
{
|
||||||
@@ -425,134 +425,134 @@ tg_rewriteQuery(TgRecipe * r,
|
|||||||
it returns a (possibly modified) Node*.
|
it returns a (possibly modified) Node*.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Node *
|
static Node *
|
||||||
tg_replaceNumberedParam(Node * expression,
|
tg_replaceNumberedParam(Node * expression,
|
||||||
int pnum, /* the number of the parameter */
|
int pnum, /* the number of the parameter */
|
||||||
int rt_ind, /* the range table index */
|
int rt_ind, /* the range table index */
|
||||||
char *teeRelName) /* the relname of the tee
|
char *teeRelName) /* the relname of the tee
|
||||||
* table */
|
* table */
|
||||||
{
|
{
|
||||||
TargetEntry *param_tle;
|
TargetEntry *param_tle;
|
||||||
Param *p;
|
Param *p;
|
||||||
Var *newVar,
|
Var *newVar,
|
||||||
*oldVar;
|
*oldVar;
|
||||||
|
|
||||||
if (expression == NULL)
|
if (expression == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (nodeTag(expression))
|
switch (nodeTag(expression))
|
||||||
{
|
{
|
||||||
case T_Param:
|
case T_Param:
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* the node is a parameter, substitute the entry from the
|
|
||||||
* target list of the child that corresponds to the parameter
|
|
||||||
* number
|
|
||||||
*/
|
|
||||||
p = (Param *) expression;
|
|
||||||
|
|
||||||
/* we only deal with the case of numbered parameters */
|
|
||||||
if (p->paramkind == PARAM_NUM && p->paramid == pnum)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (p->param_tlist)
|
/*
|
||||||
|
* the node is a parameter, substitute the entry from the
|
||||||
|
* target list of the child that corresponds to the
|
||||||
|
* parameter number
|
||||||
|
*/
|
||||||
|
p = (Param *) expression;
|
||||||
|
|
||||||
|
/* we only deal with the case of numbered parameters */
|
||||||
|
if (p->paramkind == PARAM_NUM && p->paramid == pnum)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
if (p->param_tlist)
|
||||||
* we have a parameter with an attribute like $N.foo
|
{
|
||||||
* so replace it with a new var node
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* param tlist can only have one entry in them! */
|
/*
|
||||||
param_tle = (TargetEntry *) (lfirst(p->param_tlist));
|
* we have a parameter with an attribute like
|
||||||
oldVar = (Var *) param_tle->expr;
|
* $N.foo so replace it with a new var node
|
||||||
oldVar->varno = rt_ind;
|
*/
|
||||||
oldVar->varnoold = rt_ind;
|
|
||||||
return (Node *) oldVar;
|
/* param tlist can only have one entry in them! */
|
||||||
|
param_tle = (TargetEntry *) (lfirst(p->param_tlist));
|
||||||
|
oldVar = (Var *) param_tle->expr;
|
||||||
|
oldVar->varno = rt_ind;
|
||||||
|
oldVar->varnoold = rt_ind;
|
||||||
|
return (Node *) oldVar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* we have $N without the .foo */
|
||||||
|
bool defined;
|
||||||
|
bool isRel;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO here, we need to check to see whether the
|
||||||
|
* type of the tee is a complex type (relation) or
|
||||||
|
* a simple type
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if it is a simple type, then we need to get the
|
||||||
|
* "result" attribute from the tee relation
|
||||||
|
*/
|
||||||
|
|
||||||
|
isRel = (typeid_get_relid(p->paramtype) != 0);
|
||||||
|
if (isRel)
|
||||||
|
{
|
||||||
|
newVar = makeVar(rt_ind,
|
||||||
|
0, /* the whole tuple */
|
||||||
|
TypeGet(teeRelName, &defined),
|
||||||
|
rt_ind,
|
||||||
|
0);
|
||||||
|
return (Node *) newVar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
newVar = makeVar(rt_ind,
|
||||||
|
1, /* just the first field,
|
||||||
|
* which is 'result' */
|
||||||
|
TypeGet(teeRelName, &defined),
|
||||||
|
rt_ind,
|
||||||
|
0);
|
||||||
|
return (Node *) newVar;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* we have $N without the .foo */
|
elog(NOTICE, "tg_replaceNumberedParam: unexpected paramkind value of %d", p->paramkind);
|
||||||
bool defined;
|
|
||||||
bool isRel;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO here, we need to check to see whether the type
|
|
||||||
* of the tee is a complex type (relation) or a simple
|
|
||||||
* type
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if it is a simple type, then we need to get the
|
|
||||||
* "result" attribute from the tee relation
|
|
||||||
*/
|
|
||||||
|
|
||||||
isRel = (typeid_get_relid(p->paramtype) != 0);
|
|
||||||
if (isRel)
|
|
||||||
{
|
|
||||||
newVar = makeVar(rt_ind,
|
|
||||||
0, /* the whole tuple */
|
|
||||||
TypeGet(teeRelName, &defined),
|
|
||||||
rt_ind,
|
|
||||||
0);
|
|
||||||
return (Node *) newVar;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
newVar = makeVar(rt_ind,
|
|
||||||
1, /* just the first field,
|
|
||||||
* which is 'result' */
|
|
||||||
TypeGet(teeRelName, &defined),
|
|
||||||
rt_ind,
|
|
||||||
0);
|
|
||||||
return (Node *) newVar;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
|
case T_Expr:
|
||||||
{
|
{
|
||||||
elog(NOTICE, "tg_replaceNumberedParam: unexpected paramkind value of %d", p->paramkind);
|
|
||||||
|
/*
|
||||||
|
* the node is an expression, we need to recursively call
|
||||||
|
* ourselves until we find parameter nodes
|
||||||
|
*/
|
||||||
|
List *l;
|
||||||
|
Expr *expr = (Expr *) expression;
|
||||||
|
List *newArgs;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* we have to make a new args lists because Params can be
|
||||||
|
* replaced by Var nodes in tg_replaceNumberedParam()
|
||||||
|
*/
|
||||||
|
newArgs = NIL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* we only care about argument to expressions, it doesn't
|
||||||
|
* matter when the opType is
|
||||||
|
*/
|
||||||
|
/* recursively rewrite the arguments of this expression */
|
||||||
|
foreach(l, expr->args)
|
||||||
|
{
|
||||||
|
newArgs = lappend(newArgs,
|
||||||
|
tg_replaceNumberedParam(lfirst(l),
|
||||||
|
pnum,
|
||||||
|
rt_ind,
|
||||||
|
teeRelName));
|
||||||
|
}
|
||||||
|
/* change the arguments of the expression */
|
||||||
|
expr->args = newArgs;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
default:
|
||||||
case T_Expr:
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* the node is an expression, we need to recursively call
|
|
||||||
* ourselves until we find parameter nodes
|
|
||||||
*/
|
|
||||||
List *l;
|
|
||||||
Expr *expr = (Expr *) expression;
|
|
||||||
List *newArgs;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* we have to make a new args lists because Params can be
|
|
||||||
* replaced by Var nodes in tg_replaceNumberedParam()
|
|
||||||
*/
|
|
||||||
newArgs = NIL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* we only care about argument to expressions, it doesn't
|
|
||||||
* matter when the opType is
|
|
||||||
*/
|
|
||||||
/* recursively rewrite the arguments of this expression */
|
|
||||||
foreach(l, expr->args)
|
|
||||||
{
|
{
|
||||||
newArgs = lappend(newArgs,
|
/* ignore other expr types */
|
||||||
tg_replaceNumberedParam(lfirst(l),
|
|
||||||
pnum,
|
|
||||||
rt_ind,
|
|
||||||
teeRelName));
|
|
||||||
}
|
}
|
||||||
/* change the arguments of the expression */
|
|
||||||
expr->args = newArgs;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
/* ignore other expr types */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return expression;
|
return expression;
|
||||||
@@ -572,118 +572,118 @@ tg_replaceNumberedParam(Node * expression,
|
|||||||
it returns a (possibly modified) Node*.
|
it returns a (possibly modified) Node*.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Node *
|
static Node *
|
||||||
tg_rewriteParamsInExpr(Node * expression, QueryTreeList * inputQlist)
|
tg_rewriteParamsInExpr(Node * expression, QueryTreeList * inputQlist)
|
||||||
{
|
{
|
||||||
List *tl;
|
List *tl;
|
||||||
TargetEntry *param_tle,
|
TargetEntry *param_tle,
|
||||||
*tle;
|
*tle;
|
||||||
Param *p;
|
Param *p;
|
||||||
int childno;
|
int childno;
|
||||||
char *resname;
|
char *resname;
|
||||||
|
|
||||||
if (expression == NULL)
|
if (expression == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (nodeTag(expression))
|
switch (nodeTag(expression))
|
||||||
{
|
{
|
||||||
case T_Param:
|
case T_Param:
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* the node is a parameter, substitute the entry from the
|
|
||||||
* target list of the child that corresponds to the parameter
|
|
||||||
* number
|
|
||||||
*/
|
|
||||||
p = (Param *) expression;
|
|
||||||
|
|
||||||
/* we only deal with the case of numbered parameters */
|
|
||||||
if (p->paramkind == PARAM_NUM)
|
|
||||||
{
|
{
|
||||||
/* paramid's start from 1 */
|
|
||||||
childno = p->paramid - 1;
|
|
||||||
|
|
||||||
if (p->param_tlist)
|
/*
|
||||||
|
* the node is a parameter, substitute the entry from the
|
||||||
|
* target list of the child that corresponds to the
|
||||||
|
* parameter number
|
||||||
|
*/
|
||||||
|
p = (Param *) expression;
|
||||||
|
|
||||||
|
/* we only deal with the case of numbered parameters */
|
||||||
|
if (p->paramkind == PARAM_NUM)
|
||||||
{
|
{
|
||||||
|
/* paramid's start from 1 */
|
||||||
|
childno = p->paramid - 1;
|
||||||
|
|
||||||
/*
|
if (p->param_tlist)
|
||||||
* we have a parameter with an attribute like $N.foo
|
|
||||||
* so match the resname "foo" against the target list
|
|
||||||
* of the (N-1)th inputQlist
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* param tlist can only have one entry in them! */
|
|
||||||
param_tle = (TargetEntry *) (lfirst(p->param_tlist));
|
|
||||||
resname = param_tle->resdom->resname;
|
|
||||||
|
|
||||||
if (inputQlist->qtrees[childno])
|
|
||||||
{
|
{
|
||||||
foreach(tl, inputQlist->qtrees[childno]->targetList)
|
|
||||||
|
/*
|
||||||
|
* we have a parameter with an attribute like
|
||||||
|
* $N.foo so match the resname "foo" against the
|
||||||
|
* target list of the (N-1)th inputQlist
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* param tlist can only have one entry in them! */
|
||||||
|
param_tle = (TargetEntry *) (lfirst(p->param_tlist));
|
||||||
|
resname = param_tle->resdom->resname;
|
||||||
|
|
||||||
|
if (inputQlist->qtrees[childno])
|
||||||
{
|
{
|
||||||
tle = lfirst(tl);
|
foreach(tl, inputQlist->qtrees[childno]->targetList)
|
||||||
if (strcmp(resname, tle->resdom->resname) == 0)
|
|
||||||
{
|
{
|
||||||
return tle->expr;
|
tle = lfirst(tl);
|
||||||
|
if (strcmp(resname, tle->resdom->resname) == 0)
|
||||||
|
{
|
||||||
|
return tle->expr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
elog(WARN, "tg_rewriteParamsInExpr:can't substitute for parameter %d when that input is unconnected", p->paramid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
elog(WARN, "tg_rewriteParamsInExpr:can't substitute for parameter %d when that input is unconnected", p->paramid);
|
/* we have $N without the .foo */
|
||||||
|
/* use the first resdom in the targetlist of the */
|
||||||
|
/* appropriate child query */
|
||||||
|
tl = inputQlist->qtrees[childno]->targetList;
|
||||||
|
tle = lfirst(tl);
|
||||||
|
return tle->expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* we have $N without the .foo */
|
elog(NOTICE, "tg_rewriteParamsInExpr: unexpected paramkind value of %d", p->paramkind);
|
||||||
/* use the first resdom in the targetlist of the */
|
|
||||||
/* appropriate child query */
|
|
||||||
tl = inputQlist->qtrees[childno]->targetList;
|
|
||||||
tle = lfirst(tl);
|
|
||||||
return tle->expr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
|
case T_Expr:
|
||||||
{
|
{
|
||||||
elog(NOTICE, "tg_rewriteParamsInExpr: unexpected paramkind value of %d", p->paramkind);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case T_Expr:
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the node is an expression, we need to recursively call
|
* the node is an expression, we need to recursively call
|
||||||
* ourselves until we find parameter nodes
|
* ourselves until we find parameter nodes
|
||||||
*/
|
*/
|
||||||
List *l;
|
List *l;
|
||||||
Expr *expr = (Expr *) expression;
|
Expr *expr = (Expr *) expression;
|
||||||
List *newArgs;
|
List *newArgs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we have to make a new args lists because Params can be
|
* we have to make a new args lists because Params can be
|
||||||
* replaced by Var nodes in tg_rewriteParamsInExpr()
|
* replaced by Var nodes in tg_rewriteParamsInExpr()
|
||||||
*/
|
*/
|
||||||
newArgs = NIL;
|
newArgs = NIL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we only care about argument to expressions, it doesn't
|
* we only care about argument to expressions, it doesn't
|
||||||
* matter when the opType is
|
* matter when the opType is
|
||||||
*/
|
*/
|
||||||
/* recursively rewrite the arguments of this expression */
|
/* recursively rewrite the arguments of this expression */
|
||||||
foreach(l, expr->args)
|
foreach(l, expr->args)
|
||||||
{
|
{
|
||||||
newArgs = lappend(newArgs,
|
newArgs = lappend(newArgs,
|
||||||
tg_rewriteParamsInExpr(lfirst(l), inputQlist));
|
tg_rewriteParamsInExpr(lfirst(l), inputQlist));
|
||||||
|
}
|
||||||
|
/* change the arguments of the expression */
|
||||||
|
expr->args = newArgs;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
/* ignore other expr types */
|
||||||
}
|
}
|
||||||
/* change the arguments of the expression */
|
|
||||||
expr->args = newArgs;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
/* ignore other expr types */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return expression;
|
return expression;
|
||||||
@@ -703,12 +703,12 @@ static int
|
|||||||
getParamTypes(TgElement * elem, Oid typev[])
|
getParamTypes(TgElement * elem, Oid typev[])
|
||||||
{
|
{
|
||||||
/* this code is similar to ProcedureDefine() */
|
/* this code is similar to ProcedureDefine() */
|
||||||
int16 parameterCount;
|
int16 parameterCount;
|
||||||
bool defined;
|
bool defined;
|
||||||
Oid toid;
|
Oid toid;
|
||||||
char *t;
|
char *t;
|
||||||
int i,
|
int i,
|
||||||
j;
|
j;
|
||||||
|
|
||||||
parameterCount = 0;
|
parameterCount = 0;
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
@@ -763,10 +763,10 @@ tg_parseTeeNode(TgRecipe * r,
|
|||||||
TeeInfo * teeInfo)
|
TeeInfo * teeInfo)
|
||||||
|
|
||||||
{
|
{
|
||||||
QueryTreeList *q;
|
QueryTreeList *q;
|
||||||
char *tt;
|
char *tt;
|
||||||
int rt_ind;
|
int rt_ind;
|
||||||
Query *orig;
|
Query *orig;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the input Node is a tee node, so we need to do the following: we
|
* the input Node is a tee node, so we need to do the following: we
|
||||||
@@ -831,21 +831,21 @@ tg_parseTeeNode(TgRecipe * r,
|
|||||||
static QueryTreeList *
|
static QueryTreeList *
|
||||||
tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
||||||
{
|
{
|
||||||
TgElement *elem;
|
TgElement *elem;
|
||||||
char *funcName;
|
char *funcName;
|
||||||
Oid typev[8]; /* eight arguments maximum */
|
Oid typev[8]; /* eight arguments maximum */
|
||||||
int i;
|
int i;
|
||||||
int parameterCount;
|
int parameterCount;
|
||||||
|
|
||||||
QueryTreeList *qList; /* the parse tree of the nodeElement */
|
QueryTreeList *qList; /* the parse tree of the nodeElement */
|
||||||
QueryTreeList *inputQlist; /* the list of parse trees for the inputs
|
QueryTreeList *inputQlist; /* the list of parse trees for the inputs
|
||||||
* to this node */
|
* to this node */
|
||||||
QueryTreeList *q;
|
QueryTreeList *q;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
TgNode *child;
|
TgNode *child;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
|
|
||||||
qList = NULL;
|
qList = NULL;
|
||||||
|
|
||||||
@@ -856,79 +856,79 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
|||||||
elem = n->nodeElem;
|
elem = n->nodeElem;
|
||||||
switch (elem->srcLang)
|
switch (elem->srcLang)
|
||||||
{
|
{
|
||||||
case TG_SQL:
|
case TG_SQL:
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for SQL ingredients, the SQL query is contained in the
|
* for SQL ingredients, the SQL query is contained in
|
||||||
* 'src' field
|
* the 'src' field
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef DEBUG_RECIPE
|
#ifdef DEBUG_RECIPE
|
||||||
elog(NOTICE, "calling parser with %s", elem->src);
|
elog(NOTICE, "calling parser with %s", elem->src);
|
||||||
#endif /* DEBUG_RECIPE */
|
#endif /* DEBUG_RECIPE */
|
||||||
|
|
||||||
parameterCount = getParamTypes(elem, typev);
|
parameterCount = getParamTypes(elem, typev);
|
||||||
|
|
||||||
qList = parser(elem->src, typev, parameterCount);
|
qList = parser(elem->src, typev, parameterCount);
|
||||||
|
|
||||||
if (qList->len > 1)
|
if (qList->len > 1)
|
||||||
{
|
|
||||||
elog(NOTICE,
|
|
||||||
"tg_parseSubQuery: parser produced > 1 query tree");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TG_C:
|
|
||||||
{
|
|
||||||
/* C ingredients are registered functions in postgres */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* we create a new query string by using the function name
|
|
||||||
* (found in the 'src' field) and adding parameters to it
|
|
||||||
* so if the function was FOOBAR and took in two
|
|
||||||
* arguments, we would create a string select
|
|
||||||
* FOOBAR($1,$2)
|
|
||||||
*/
|
|
||||||
char newquery[1000];
|
|
||||||
|
|
||||||
funcName = elem->src;
|
|
||||||
parameterCount = getParamTypes(elem, typev);
|
|
||||||
|
|
||||||
if (parameterCount > 0)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
sprintf(newquery, "select %s($1", funcName);
|
|
||||||
for (i = 1; i < parameterCount; i++)
|
|
||||||
{
|
{
|
||||||
sprintf(newquery, "%s,$%d", newquery, i);
|
elog(NOTICE,
|
||||||
|
"tg_parseSubQuery: parser produced > 1 query tree");
|
||||||
}
|
}
|
||||||
sprintf(newquery, "%s)", newquery);
|
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
sprintf(newquery, "select %s()", funcName);
|
case TG_C:
|
||||||
|
{
|
||||||
|
/* C ingredients are registered functions in postgres */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* we create a new query string by using the function
|
||||||
|
* name (found in the 'src' field) and adding
|
||||||
|
* parameters to it so if the function was FOOBAR and
|
||||||
|
* took in two arguments, we would create a string
|
||||||
|
* select FOOBAR($1,$2)
|
||||||
|
*/
|
||||||
|
char newquery[1000];
|
||||||
|
|
||||||
|
funcName = elem->src;
|
||||||
|
parameterCount = getParamTypes(elem, typev);
|
||||||
|
|
||||||
|
if (parameterCount > 0)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
sprintf(newquery, "select %s($1", funcName);
|
||||||
|
for (i = 1; i < parameterCount; i++)
|
||||||
|
{
|
||||||
|
sprintf(newquery, "%s,$%d", newquery, i);
|
||||||
|
}
|
||||||
|
sprintf(newquery, "%s)", newquery);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sprintf(newquery, "select %s()", funcName);
|
||||||
|
|
||||||
#ifdef DEBUG_RECIPE
|
#ifdef DEBUG_RECIPE
|
||||||
elog(NOTICE, "calling parser with %s", newquery);
|
elog(NOTICE, "calling parser with %s", newquery);
|
||||||
#endif /* DEBUG_RECIPE */
|
#endif /* DEBUG_RECIPE */
|
||||||
|
|
||||||
qList = parser(newquery, typev, parameterCount);
|
qList = parser(newquery, typev, parameterCount);
|
||||||
if (qList->len > 1)
|
if (qList->len > 1)
|
||||||
{
|
{
|
||||||
elog(NOTICE,
|
elog(NOTICE,
|
||||||
"tg_parseSubQuery: parser produced > 1 query tree");
|
"tg_parseSubQuery: parser produced > 1 query tree");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case TG_RECIPE_GRAPH:
|
||||||
case TG_RECIPE_GRAPH:
|
elog(NOTICE, "tg_parseSubQuery: can't parse recipe graph ingredients yet!");
|
||||||
elog(NOTICE, "tg_parseSubQuery: can't parse recipe graph ingredients yet!");
|
break;
|
||||||
break;
|
case TG_COMPILED:
|
||||||
case TG_COMPILED:
|
elog(NOTICE, "tg_parseSubQuery: can't parse compiled ingredients yet!");
|
||||||
elog(NOTICE, "tg_parseSubQuery: can't parse compiled ingredients yet!");
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
elog(NOTICE, "tg_parseSubQuery: unknown srcLang: %d", elem->srcLang);
|
||||||
elog(NOTICE, "tg_parseSubQuery: unknown srcLang: %d", elem->srcLang);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse each of the subrecipes that are input to this node */
|
/* parse each of the subrecipes that are input to this node */
|
||||||
@@ -1110,41 +1110,41 @@ OffsetVarAttno(Node * node, int varno, int offset)
|
|||||||
return;
|
return;
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
case T_TargetEntry:
|
case T_TargetEntry:
|
||||||
{
|
|
||||||
TargetEntry *tle = (TargetEntry *) node;
|
|
||||||
|
|
||||||
OffsetVarAttno(tle->expr, varno, offset);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case T_Expr:
|
|
||||||
{
|
|
||||||
Expr *expr = (Expr *) node;
|
|
||||||
|
|
||||||
OffsetVarAttno((Node *) expr->args, varno, offset);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case T_Var:
|
|
||||||
{
|
|
||||||
Var *var = (Var *) node;
|
|
||||||
|
|
||||||
if (var->varno == varno)
|
|
||||||
var->varattno += offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case T_List:
|
|
||||||
{
|
|
||||||
List *l;
|
|
||||||
|
|
||||||
foreach(l, (List *) node)
|
|
||||||
{
|
{
|
||||||
OffsetVarAttno(lfirst(l), varno, offset);
|
TargetEntry *tle = (TargetEntry *) node;
|
||||||
|
|
||||||
|
OffsetVarAttno(tle->expr, varno, offset);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case T_Expr:
|
||||||
default:
|
{
|
||||||
/* ignore the others */
|
Expr *expr = (Expr *) node;
|
||||||
break;
|
|
||||||
|
OffsetVarAttno((Node *) expr->args, varno, offset);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case T_Var:
|
||||||
|
{
|
||||||
|
Var *var = (Var *) node;
|
||||||
|
|
||||||
|
if (var->varno == varno)
|
||||||
|
var->varattno += offset;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case T_List:
|
||||||
|
{
|
||||||
|
List *l;
|
||||||
|
|
||||||
|
foreach(l, (List *) node)
|
||||||
|
{
|
||||||
|
OffsetVarAttno(lfirst(l), varno, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* ignore the others */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1156,13 +1156,13 @@ OffsetVarAttno(Node * node, int varno, int offset)
|
|||||||
* returns a new querytree list
|
* returns a new querytree list
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QueryTreeList *
|
QueryTreeList *
|
||||||
appendQlist(QueryTreeList * q1, QueryTreeList * q2)
|
appendQlist(QueryTreeList * q1, QueryTreeList * q2)
|
||||||
{
|
{
|
||||||
QueryTreeList *newq;
|
QueryTreeList *newq;
|
||||||
int i,
|
int i,
|
||||||
j;
|
j;
|
||||||
int newlen;
|
int newlen;
|
||||||
|
|
||||||
if (q1 == NULL)
|
if (q1 == NULL)
|
||||||
return q2;
|
return q2;
|
||||||
@@ -1191,7 +1191,7 @@ appendQlist(QueryTreeList * q1, QueryTreeList * q2)
|
|||||||
static void
|
static void
|
||||||
appendTeeQuery(TeeInfo * teeInfo, QueryTreeList * q, char *teeNodeName)
|
appendTeeQuery(TeeInfo * teeInfo, QueryTreeList * q, char *teeNodeName)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Assert(teeInfo);
|
Assert(teeInfo);
|
||||||
|
|
||||||
@@ -1223,9 +1223,9 @@ static void
|
|||||||
replaceSeqScan(Plan * plan, Plan * parent,
|
replaceSeqScan(Plan * plan, Plan * parent,
|
||||||
int rt_ind, Plan * tplan)
|
int rt_ind, Plan * tplan)
|
||||||
{
|
{
|
||||||
Scan *snode;
|
Scan *snode;
|
||||||
Tee *teePlan;
|
Tee *teePlan;
|
||||||
Result *newPlan;
|
Result *newPlan;
|
||||||
|
|
||||||
if (plan == NULL)
|
if (plan == NULL)
|
||||||
{
|
{
|
||||||
@@ -1306,16 +1306,16 @@ replaceSeqScan(Plan * plan, Plan * parent,
|
|||||||
* places the sequential scans of the Tee table with
|
* places the sequential scans of the Tee table with
|
||||||
* a connection to the actual tee plan node
|
* a connection to the actual tee plan node
|
||||||
*/
|
*/
|
||||||
static Plan *
|
static Plan *
|
||||||
replaceTeeScans(Plan * plan, Query * parsetree, TeeInfo * teeInfo)
|
replaceTeeScans(Plan * plan, Query * parsetree, TeeInfo * teeInfo)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
List *rtable;
|
List *rtable;
|
||||||
RangeTblEntry *rte;
|
RangeTblEntry *rte;
|
||||||
char prefix[5];
|
char prefix[5];
|
||||||
int rt_ind;
|
int rt_ind;
|
||||||
Plan *tplan;
|
Plan *tplan;
|
||||||
|
|
||||||
rtable = parsetree->rtable;
|
rtable = parsetree->rtable;
|
||||||
if (rtable == NULL)
|
if (rtable == NULL)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.11 1997/09/07 04:40:54 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.12 1997/09/08 02:22:13 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -48,16 +48,16 @@ RemoveOperator(char *operatorName, /* operator name */
|
|||||||
char *typeName1, /* first type name */
|
char *typeName1, /* first type name */
|
||||||
char *typeName2) /* optional second type name */
|
char *typeName2) /* optional second type name */
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Oid typeId1 = InvalidOid;
|
Oid typeId1 = InvalidOid;
|
||||||
Oid typeId2 = InvalidOid;
|
Oid typeId2 = InvalidOid;
|
||||||
bool defined;
|
bool defined;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
ScanKeyData operatorKey[3];
|
ScanKeyData operatorKey[3];
|
||||||
char *userName;
|
char *userName;
|
||||||
|
|
||||||
if (typeName1)
|
if (typeName1)
|
||||||
{
|
{
|
||||||
@@ -148,14 +148,14 @@ RemoveOperator(char *operatorName, /* operator name */
|
|||||||
static void
|
static void
|
||||||
SingleOpOperatorRemove(Oid typeOid)
|
SingleOpOperatorRemove(Oid typeOid)
|
||||||
{
|
{
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
ScanKeyData key[3];
|
ScanKeyData key[3];
|
||||||
HeapScanDesc sdesc;
|
HeapScanDesc sdesc;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
static attnums[3] = {7, 8, 9}; /* left, right, return */
|
static attnums[3] = {7, 8, 9}; /* left, right, return */
|
||||||
register i;
|
register i;
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&key[0],
|
ScanKeyEntryInitialize(&key[0],
|
||||||
0, 0, ObjectIdEqualRegProcedure, (Datum) typeOid);
|
0, 0, ObjectIdEqualRegProcedure, (Datum) typeOid);
|
||||||
@@ -186,17 +186,17 @@ AttributeAndRelationRemove(Oid typeOid)
|
|||||||
{
|
{
|
||||||
struct oidlist
|
struct oidlist
|
||||||
{
|
{
|
||||||
Oid reloid;
|
Oid reloid;
|
||||||
struct oidlist *next;
|
struct oidlist *next;
|
||||||
};
|
};
|
||||||
struct oidlist *oidptr,
|
struct oidlist *oidptr,
|
||||||
*optr;
|
*optr;
|
||||||
Relation rdesc;
|
Relation rdesc;
|
||||||
ScanKeyData key[1];
|
ScanKeyData key[1];
|
||||||
HeapScanDesc sdesc;
|
HeapScanDesc sdesc;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the oid's of the relations to be removed by scanning the entire
|
* Get the oid's of the relations to be removed by scanning the entire
|
||||||
@@ -237,7 +237,7 @@ AttributeAndRelationRemove(Oid typeOid)
|
|||||||
tup = heap_getnext(sdesc, 0, &buffer);
|
tup = heap_getnext(sdesc, 0, &buffer);
|
||||||
if (PointerIsValid(tup))
|
if (PointerIsValid(tup))
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = (((Form_pg_class) GETSTRUCT(tup))->relname).data;
|
name = (((Form_pg_class) GETSTRUCT(tup))->relname).data;
|
||||||
heap_destroy(name);
|
heap_destroy(name);
|
||||||
@@ -257,16 +257,16 @@ AttributeAndRelationRemove(Oid typeOid)
|
|||||||
void
|
void
|
||||||
RemoveType(char *typeName) /* type name to be removed */
|
RemoveType(char *typeName) /* type name to be removed */
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Oid typeOid;
|
Oid typeOid;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
static ScanKeyData typeKey[1] = {
|
static ScanKeyData typeKey[1] = {
|
||||||
{0, Anum_pg_type_typname, NameEqualRegProcedure}
|
{0, Anum_pg_type_typname, NameEqualRegProcedure}
|
||||||
};
|
};
|
||||||
char *shadow_type;
|
char *shadow_type;
|
||||||
char *userName;
|
char *userName;
|
||||||
|
|
||||||
#ifndef NO_SECURITY
|
#ifndef NO_SECURITY
|
||||||
userName = GetPgUserName();
|
userName = GetPgUserName();
|
||||||
@@ -332,20 +332,20 @@ RemoveFunction(char *functionName, /* function name to be removed */
|
|||||||
int nargs,
|
int nargs,
|
||||||
List * argNameList /* list of TypeNames */ )
|
List * argNameList /* list of TypeNames */ )
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Buffer buffer = InvalidBuffer;
|
Buffer buffer = InvalidBuffer;
|
||||||
bool bufferUsed = FALSE;
|
bool bufferUsed = FALSE;
|
||||||
Oid argList[8];
|
Oid argList[8];
|
||||||
Form_pg_proc the_proc = NULL;
|
Form_pg_proc the_proc = NULL;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
static ScanKeyData key[3] = {
|
static ScanKeyData key[3] = {
|
||||||
{0, Anum_pg_proc_proname, NameEqualRegProcedure}
|
{0, Anum_pg_proc_proname, NameEqualRegProcedure}
|
||||||
};
|
};
|
||||||
char *userName;
|
char *userName;
|
||||||
char *typename;
|
char *typename;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(argList, 0, 8 * sizeof(Oid));
|
memset(argList, 0, 8 * sizeof(Oid));
|
||||||
for (i = 0; i < nargs; i++)
|
for (i = 0; i < nargs; i++)
|
||||||
@@ -431,14 +431,14 @@ RemoveFunction(char *functionName, /* function name to be removed */
|
|||||||
void
|
void
|
||||||
RemoveAggregate(char *aggName, char *aggType)
|
RemoveAggregate(char *aggName, char *aggType)
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
ItemPointerData itemPointerData;
|
ItemPointerData itemPointerData;
|
||||||
char *userName;
|
char *userName;
|
||||||
Oid basetypeID = InvalidOid;
|
Oid basetypeID = InvalidOid;
|
||||||
bool defined;
|
bool defined;
|
||||||
ScanKeyData aggregateKey[3];
|
ScanKeyData aggregateKey[3];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.8 1997/09/07 04:40:55 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.9 1997/09/08 02:22:14 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -66,13 +66,13 @@ renameatt(char *relname,
|
|||||||
char *userName,
|
char *userName,
|
||||||
int recurse)
|
int recurse)
|
||||||
{
|
{
|
||||||
Relation relrdesc,
|
Relation relrdesc,
|
||||||
attrdesc;
|
attrdesc;
|
||||||
HeapTuple reltup,
|
HeapTuple reltup,
|
||||||
oldatttup,
|
oldatttup,
|
||||||
newatttup;
|
newatttup;
|
||||||
ItemPointerData oldTID;
|
ItemPointerData oldTID;
|
||||||
Relation idescs[Num_pg_attr_indices];
|
Relation idescs[Num_pg_attr_indices];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* permissions checking. this would normally be done in utility.c,
|
* permissions checking. this would normally be done in utility.c,
|
||||||
@@ -101,10 +101,10 @@ renameatt(char *relname,
|
|||||||
*/
|
*/
|
||||||
if (recurse)
|
if (recurse)
|
||||||
{
|
{
|
||||||
Oid myrelid,
|
Oid myrelid,
|
||||||
childrelid;
|
childrelid;
|
||||||
List *child,
|
List *child,
|
||||||
*children;
|
*children;
|
||||||
|
|
||||||
relrdesc = heap_openr(relname);
|
relrdesc = heap_openr(relname);
|
||||||
if (!RelationIsValid(relrdesc))
|
if (!RelationIsValid(relrdesc))
|
||||||
@@ -126,7 +126,7 @@ renameatt(char *relname,
|
|||||||
*/
|
*/
|
||||||
foreach(child, children)
|
foreach(child, children)
|
||||||
{
|
{
|
||||||
char *childname;
|
char *childname;
|
||||||
|
|
||||||
childrelid = lfirsti(child);
|
childrelid = lfirsti(child);
|
||||||
if (childrelid == myrelid)
|
if (childrelid == myrelid)
|
||||||
@@ -213,13 +213,13 @@ renameatt(char *relname,
|
|||||||
void
|
void
|
||||||
renamerel(char oldrelname[], char newrelname[])
|
renamerel(char oldrelname[], char newrelname[])
|
||||||
{
|
{
|
||||||
Relation relrdesc; /* for RELATION relation */
|
Relation relrdesc; /* for RELATION relation */
|
||||||
HeapTuple oldreltup,
|
HeapTuple oldreltup,
|
||||||
newreltup;
|
newreltup;
|
||||||
ItemPointerData oldTID;
|
ItemPointerData oldTID;
|
||||||
char oldpath[MAXPGPATH],
|
char oldpath[MAXPGPATH],
|
||||||
newpath[MAXPGPATH];
|
newpath[MAXPGPATH];
|
||||||
Relation idescs[Num_pg_class_indices];
|
Relation idescs[Num_pg_class_indices];
|
||||||
|
|
||||||
if (IsSystemRelationName(oldrelname))
|
if (IsSystemRelationName(oldrelname))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,37 +24,37 @@
|
|||||||
#define SEQ_MAXVALUE ((int4)0x7FFFFFFF)
|
#define SEQ_MAXVALUE ((int4)0x7FFFFFFF)
|
||||||
#define SEQ_MINVALUE -(SEQ_MAXVALUE)
|
#define SEQ_MINVALUE -(SEQ_MAXVALUE)
|
||||||
|
|
||||||
bool ItsSequenceCreation = false;
|
bool ItsSequenceCreation = false;
|
||||||
|
|
||||||
typedef struct FormData_pg_sequence
|
typedef struct FormData_pg_sequence
|
||||||
{
|
{
|
||||||
NameData sequence_name;
|
NameData sequence_name;
|
||||||
int4 last_value;
|
int4 last_value;
|
||||||
int4 increment_by;
|
int4 increment_by;
|
||||||
int4 max_value;
|
int4 max_value;
|
||||||
int4 min_value;
|
int4 min_value;
|
||||||
int4 cache_value;
|
int4 cache_value;
|
||||||
char is_cycled;
|
char is_cycled;
|
||||||
char is_called;
|
char is_called;
|
||||||
} FormData_pg_sequence;
|
} FormData_pg_sequence;
|
||||||
|
|
||||||
typedef FormData_pg_sequence *SequenceTupleForm;
|
typedef FormData_pg_sequence *SequenceTupleForm;
|
||||||
|
|
||||||
typedef struct sequence_magic
|
typedef struct sequence_magic
|
||||||
{
|
{
|
||||||
uint32 magic;
|
uint32 magic;
|
||||||
} sequence_magic;
|
} sequence_magic;
|
||||||
|
|
||||||
typedef struct SeqTableData
|
typedef struct SeqTableData
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
int4 cached;
|
int4 cached;
|
||||||
int4 last;
|
int4 last;
|
||||||
int4 increment;
|
int4 increment;
|
||||||
struct SeqTableData *next;
|
struct SeqTableData *next;
|
||||||
} SeqTableData;
|
} SeqTableData;
|
||||||
|
|
||||||
typedef SeqTableData *SeqTable;
|
typedef SeqTableData *SeqTable;
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ static SeqTable seqtab = NULL;
|
|||||||
|
|
||||||
static SeqTable init_sequence(char *caller, char *name);
|
static SeqTable init_sequence(char *caller, char *name);
|
||||||
static SequenceTupleForm read_info(char *caller, SeqTable elm, Buffer * buf);
|
static SequenceTupleForm read_info(char *caller, SeqTable elm, Buffer * buf);
|
||||||
static void init_params(CreateSeqStmt * seq, SequenceTupleForm new);
|
static void init_params(CreateSeqStmt * seq, SequenceTupleForm new);
|
||||||
static int get_param(DefElem * def);
|
static int get_param(DefElem * def);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DefineSequence --
|
* DefineSequence --
|
||||||
@@ -73,18 +73,18 @@ void
|
|||||||
DefineSequence(CreateSeqStmt * seq)
|
DefineSequence(CreateSeqStmt * seq)
|
||||||
{
|
{
|
||||||
FormData_pg_sequence new;
|
FormData_pg_sequence new;
|
||||||
CreateStmt *stmt = makeNode(CreateStmt);
|
CreateStmt *stmt = makeNode(CreateStmt);
|
||||||
ColumnDef *coldef;
|
ColumnDef *coldef;
|
||||||
TypeName *typnam;
|
TypeName *typnam;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
PageHeader page;
|
PageHeader page;
|
||||||
sequence_magic *sm;
|
sequence_magic *sm;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
Datum value[SEQ_COL_LASTCOL];
|
Datum value[SEQ_COL_LASTCOL];
|
||||||
char null[SEQ_COL_LASTCOL];
|
char null[SEQ_COL_LASTCOL];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Check and set values */
|
/* Check and set values */
|
||||||
init_params(seq, &new);
|
init_params(seq, &new);
|
||||||
@@ -106,46 +106,46 @@ DefineSequence(CreateSeqStmt * seq)
|
|||||||
|
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case SEQ_COL_NAME:
|
case SEQ_COL_NAME:
|
||||||
typnam->name = "name";
|
typnam->name = "name";
|
||||||
coldef->colname = "sequence_name";
|
coldef->colname = "sequence_name";
|
||||||
value[i - 1] = PointerGetDatum(seq->seqname);
|
value[i - 1] = PointerGetDatum(seq->seqname);
|
||||||
break;
|
break;
|
||||||
case SEQ_COL_LASTVAL:
|
case SEQ_COL_LASTVAL:
|
||||||
typnam->name = "int4";
|
typnam->name = "int4";
|
||||||
coldef->colname = "last_value";
|
coldef->colname = "last_value";
|
||||||
value[i - 1] = Int32GetDatum(new.last_value);
|
value[i - 1] = Int32GetDatum(new.last_value);
|
||||||
break;
|
break;
|
||||||
case SEQ_COL_INCBY:
|
case SEQ_COL_INCBY:
|
||||||
typnam->name = "int4";
|
typnam->name = "int4";
|
||||||
coldef->colname = "increment_by";
|
coldef->colname = "increment_by";
|
||||||
value[i - 1] = Int32GetDatum(new.increment_by);
|
value[i - 1] = Int32GetDatum(new.increment_by);
|
||||||
break;
|
break;
|
||||||
case SEQ_COL_MAXVALUE:
|
case SEQ_COL_MAXVALUE:
|
||||||
typnam->name = "int4";
|
typnam->name = "int4";
|
||||||
coldef->colname = "max_value";
|
coldef->colname = "max_value";
|
||||||
value[i - 1] = Int32GetDatum(new.max_value);
|
value[i - 1] = Int32GetDatum(new.max_value);
|
||||||
break;
|
break;
|
||||||
case SEQ_COL_MINVALUE:
|
case SEQ_COL_MINVALUE:
|
||||||
typnam->name = "int4";
|
typnam->name = "int4";
|
||||||
coldef->colname = "min_value";
|
coldef->colname = "min_value";
|
||||||
value[i - 1] = Int32GetDatum(new.min_value);
|
value[i - 1] = Int32GetDatum(new.min_value);
|
||||||
break;
|
break;
|
||||||
case SEQ_COL_CACHE:
|
case SEQ_COL_CACHE:
|
||||||
typnam->name = "int4";
|
typnam->name = "int4";
|
||||||
coldef->colname = "cache_value";
|
coldef->colname = "cache_value";
|
||||||
value[i - 1] = Int32GetDatum(new.cache_value);
|
value[i - 1] = Int32GetDatum(new.cache_value);
|
||||||
break;
|
break;
|
||||||
case SEQ_COL_CYCLE:
|
case SEQ_COL_CYCLE:
|
||||||
typnam->name = "char";
|
typnam->name = "char";
|
||||||
coldef->colname = "is_cycled";
|
coldef->colname = "is_cycled";
|
||||||
value[i - 1] = CharGetDatum(new.is_cycled);
|
value[i - 1] = CharGetDatum(new.is_cycled);
|
||||||
break;
|
break;
|
||||||
case SEQ_COL_CALLED:
|
case SEQ_COL_CALLED:
|
||||||
typnam->name = "char";
|
typnam->name = "char";
|
||||||
coldef->colname = "is_called";
|
coldef->colname = "is_called";
|
||||||
value[i - 1] = CharGetDatum('f');
|
value[i - 1] = CharGetDatum('f');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stmt->tableElts = lappend(stmt->tableElts, coldef);
|
stmt->tableElts = lappend(stmt->tableElts, coldef);
|
||||||
}
|
}
|
||||||
@@ -203,18 +203,18 @@ DefineSequence(CreateSeqStmt * seq)
|
|||||||
int4
|
int4
|
||||||
nextval(struct varlena * seqin)
|
nextval(struct varlena * seqin)
|
||||||
{
|
{
|
||||||
char *seqname = textout(seqin);
|
char *seqname = textout(seqin);
|
||||||
SeqTable elm;
|
SeqTable elm;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
SequenceTupleForm seq;
|
SequenceTupleForm seq;
|
||||||
ItemPointerData iptr;
|
ItemPointerData iptr;
|
||||||
int4 incby,
|
int4 incby,
|
||||||
maxv,
|
maxv,
|
||||||
minv,
|
minv,
|
||||||
cache;
|
cache;
|
||||||
int4 result,
|
int4 result,
|
||||||
next,
|
next,
|
||||||
rescnt = 0;
|
rescnt = 0;
|
||||||
|
|
||||||
/* open and WIntentLock sequence */
|
/* open and WIntentLock sequence */
|
||||||
elm = init_sequence("nextval", seqname);
|
elm = init_sequence("nextval", seqname);
|
||||||
@@ -303,9 +303,9 @@ nextval(struct varlena * seqin)
|
|||||||
int4
|
int4
|
||||||
currval(struct varlena * seqin)
|
currval(struct varlena * seqin)
|
||||||
{
|
{
|
||||||
char *seqname = textout(seqin);
|
char *seqname = textout(seqin);
|
||||||
SeqTable elm;
|
SeqTable elm;
|
||||||
int4 result;
|
int4 result;
|
||||||
|
|
||||||
/* open and WIntentLock sequence */
|
/* open and WIntentLock sequence */
|
||||||
elm = init_sequence("currval", seqname);
|
elm = init_sequence("currval", seqname);
|
||||||
@@ -322,13 +322,13 @@ currval(struct varlena * seqin)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SequenceTupleForm
|
static SequenceTupleForm
|
||||||
read_info(char *caller, SeqTable elm, Buffer * buf)
|
read_info(char *caller, SeqTable elm, Buffer * buf)
|
||||||
{
|
{
|
||||||
ItemPointerData iptr;
|
ItemPointerData iptr;
|
||||||
PageHeader page;
|
PageHeader page;
|
||||||
ItemId lp;
|
ItemId lp;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
sequence_magic *sm;
|
sequence_magic *sm;
|
||||||
SequenceTupleForm seq;
|
SequenceTupleForm seq;
|
||||||
|
|
||||||
@@ -362,12 +362,12 @@ read_info(char *caller, SeqTable elm, Buffer * buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SeqTable
|
static SeqTable
|
||||||
init_sequence(char *caller, char *name)
|
init_sequence(char *caller, char *name)
|
||||||
{
|
{
|
||||||
SeqTable elm,
|
SeqTable elm,
|
||||||
priv = (SeqTable) NULL;
|
priv = (SeqTable) NULL;
|
||||||
SeqTable temp;
|
SeqTable temp;
|
||||||
|
|
||||||
for (elm = seqtab; elm != (SeqTable) NULL;)
|
for (elm = seqtab; elm != (SeqTable) NULL;)
|
||||||
{
|
{
|
||||||
@@ -436,8 +436,8 @@ init_sequence(char *caller, char *name)
|
|||||||
void
|
void
|
||||||
CloseSequences(void)
|
CloseSequences(void)
|
||||||
{
|
{
|
||||||
SeqTable elm;
|
SeqTable elm;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
ItsSequenceCreation = false;
|
ItsSequenceCreation = false;
|
||||||
|
|
||||||
@@ -461,17 +461,17 @@ CloseSequences(void)
|
|||||||
static void
|
static void
|
||||||
init_params(CreateSeqStmt * seq, SequenceTupleForm new)
|
init_params(CreateSeqStmt * seq, SequenceTupleForm new)
|
||||||
{
|
{
|
||||||
DefElem *last_value = NULL;
|
DefElem *last_value = NULL;
|
||||||
DefElem *increment_by = NULL;
|
DefElem *increment_by = NULL;
|
||||||
DefElem *max_value = NULL;
|
DefElem *max_value = NULL;
|
||||||
DefElem *min_value = NULL;
|
DefElem *min_value = NULL;
|
||||||
DefElem *cache_value = NULL;
|
DefElem *cache_value = NULL;
|
||||||
List *option;
|
List *option;
|
||||||
|
|
||||||
new->is_cycled = 'f';
|
new->is_cycled = 'f';
|
||||||
foreach(option, seq->options)
|
foreach(option, seq->options)
|
||||||
{
|
{
|
||||||
DefElem *defel = (DefElem *) lfirst(option);
|
DefElem *defel = (DefElem *) lfirst(option);
|
||||||
|
|
||||||
if (!strcasecmp(defel->defname, "increment"))
|
if (!strcasecmp(defel->defname, "increment"))
|
||||||
increment_by = defel;
|
increment_by = defel;
|
||||||
|
|||||||
@@ -32,36 +32,36 @@
|
|||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TriggerData *CurrentTriggerData = NULL;
|
TriggerData *CurrentTriggerData = NULL;
|
||||||
|
|
||||||
void RelationBuildTriggers(Relation relation);
|
void RelationBuildTriggers(Relation relation);
|
||||||
void FreeTriggerDesc(Relation relation);
|
void FreeTriggerDesc(Relation relation);
|
||||||
|
|
||||||
static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger);
|
static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger);
|
||||||
|
|
||||||
extern void fmgr_info(Oid procedureId, func_ptr * function, int *nargs);
|
extern void fmgr_info(Oid procedureId, func_ptr * function, int *nargs);
|
||||||
extern GlobalMemory CacheCxt;
|
extern GlobalMemory CacheCxt;
|
||||||
|
|
||||||
void
|
void
|
||||||
CreateTrigger(CreateTrigStmt * stmt)
|
CreateTrigger(CreateTrigStmt * stmt)
|
||||||
{
|
{
|
||||||
int16 tgtype;
|
int16 tgtype;
|
||||||
int16 tgattr[8] = {0};
|
int16 tgattr[8] = {0};
|
||||||
Datum values[Natts_pg_trigger];
|
Datum values[Natts_pg_trigger];
|
||||||
char nulls[Natts_pg_trigger];
|
char nulls[Natts_pg_trigger];
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Relation tgrel;
|
Relation tgrel;
|
||||||
HeapScanDesc tgscan;
|
HeapScanDesc tgscan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
Relation relrdesc;
|
Relation relrdesc;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
ItemPointerData oldTID;
|
ItemPointerData oldTID;
|
||||||
Relation idescs[Num_pg_trigger_indices];
|
Relation idescs[Num_pg_trigger_indices];
|
||||||
Relation ridescs[Num_pg_class_indices];
|
Relation ridescs[Num_pg_class_indices];
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
Oid fargtypes[8];
|
Oid fargtypes[8];
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (IsSystemRelationName(stmt->relname))
|
if (IsSystemRelationName(stmt->relname))
|
||||||
elog(WARN, "CreateTrigger: can't create trigger for system relation %s", stmt->relname);
|
elog(WARN, "CreateTrigger: can't create trigger for system relation %s", stmt->relname);
|
||||||
@@ -86,24 +86,24 @@ CreateTrigger(CreateTrigStmt * stmt)
|
|||||||
{
|
{
|
||||||
switch (stmt->actions[i])
|
switch (stmt->actions[i])
|
||||||
{
|
{
|
||||||
case 'i':
|
case 'i':
|
||||||
if (TRIGGER_FOR_INSERT(tgtype))
|
if (TRIGGER_FOR_INSERT(tgtype))
|
||||||
elog(WARN, "CreateTrigger: double INSERT event specified");
|
elog(WARN, "CreateTrigger: double INSERT event specified");
|
||||||
TRIGGER_SETT_INSERT(tgtype);
|
TRIGGER_SETT_INSERT(tgtype);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if (TRIGGER_FOR_DELETE(tgtype))
|
if (TRIGGER_FOR_DELETE(tgtype))
|
||||||
elog(WARN, "CreateTrigger: double DELETE event specified");
|
elog(WARN, "CreateTrigger: double DELETE event specified");
|
||||||
TRIGGER_SETT_DELETE(tgtype);
|
TRIGGER_SETT_DELETE(tgtype);
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
if (TRIGGER_FOR_UPDATE(tgtype))
|
if (TRIGGER_FOR_UPDATE(tgtype))
|
||||||
elog(WARN, "CreateTrigger: double UPDATE event specified");
|
elog(WARN, "CreateTrigger: double UPDATE event specified");
|
||||||
TRIGGER_SETT_UPDATE(tgtype);
|
TRIGGER_SETT_UPDATE(tgtype);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "CreateTrigger: unknown event specified");
|
elog(WARN, "CreateTrigger: unknown event specified");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,14 +145,14 @@ CreateTrigger(CreateTrigStmt * stmt)
|
|||||||
values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
|
values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
|
||||||
if (stmt->args)
|
if (stmt->args)
|
||||||
{
|
{
|
||||||
List *le;
|
List *le;
|
||||||
char *args;
|
char *args;
|
||||||
int16 nargs = length(stmt->args);
|
int16 nargs = length(stmt->args);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
foreach(le, stmt->args)
|
foreach(le, stmt->args)
|
||||||
{
|
{
|
||||||
char *ar = (char *) lfirst(le);
|
char *ar = (char *) lfirst(le);
|
||||||
|
|
||||||
len += strlen(ar) + 4;
|
len += strlen(ar) + 4;
|
||||||
}
|
}
|
||||||
@@ -213,17 +213,17 @@ CreateTrigger(CreateTrigStmt * stmt)
|
|||||||
void
|
void
|
||||||
DropTrigger(DropTrigStmt * stmt)
|
DropTrigger(DropTrigStmt * stmt)
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Relation tgrel;
|
Relation tgrel;
|
||||||
HeapScanDesc tgscan;
|
HeapScanDesc tgscan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
Relation relrdesc;
|
Relation relrdesc;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
ItemPointerData oldTID;
|
ItemPointerData oldTID;
|
||||||
Relation ridescs[Num_pg_class_indices];
|
Relation ridescs[Num_pg_class_indices];
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int tgfound = 0;
|
int tgfound = 0;
|
||||||
|
|
||||||
#ifndef NO_SECURITY
|
#ifndef NO_SECURITY
|
||||||
if (!pg_ownercheck(GetPgUserName(), stmt->relname, RELNAME))
|
if (!pg_ownercheck(GetPgUserName(), stmt->relname, RELNAME))
|
||||||
@@ -295,10 +295,10 @@ DropTrigger(DropTrigStmt * stmt)
|
|||||||
void
|
void
|
||||||
RelationRemoveTriggers(Relation rel)
|
RelationRemoveTriggers(Relation rel)
|
||||||
{
|
{
|
||||||
Relation tgrel;
|
Relation tgrel;
|
||||||
HeapScanDesc tgscan;
|
HeapScanDesc tgscan;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
tgrel = heap_openr(TriggerRelationName);
|
tgrel = heap_openr(TriggerRelationName);
|
||||||
RelationSetLockForWrite(tgrel);
|
RelationSetLockForWrite(tgrel);
|
||||||
@@ -319,22 +319,22 @@ RelationRemoveTriggers(Relation rel)
|
|||||||
void
|
void
|
||||||
RelationBuildTriggers(Relation relation)
|
RelationBuildTriggers(Relation relation)
|
||||||
{
|
{
|
||||||
TriggerDesc *trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc));
|
TriggerDesc *trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc));
|
||||||
int ntrigs = relation->rd_rel->reltriggers;
|
int ntrigs = relation->rd_rel->reltriggers;
|
||||||
Trigger *triggers = NULL;
|
Trigger *triggers = NULL;
|
||||||
Trigger *build;
|
Trigger *build;
|
||||||
Relation tgrel;
|
Relation tgrel;
|
||||||
Form_pg_trigger pg_trigger;
|
Form_pg_trigger pg_trigger;
|
||||||
Relation irel;
|
Relation irel;
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
IndexScanDesc sd;
|
IndexScanDesc sd;
|
||||||
RetrieveIndexResult indexRes;
|
RetrieveIndexResult indexRes;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
struct varlena *val;
|
struct varlena *val;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
memset(trigdesc, 0, sizeof(TriggerDesc));
|
memset(trigdesc, 0, sizeof(TriggerDesc));
|
||||||
|
|
||||||
@@ -386,8 +386,8 @@ RelationBuildTriggers(Relation relation)
|
|||||||
NAMEDATALEN, relation->rd_rel->relname.data);
|
NAMEDATALEN, relation->rd_rel->relname.data);
|
||||||
if (build->tgnargs > 0)
|
if (build->tgnargs > 0)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
val = (struct varlena *) fastgetattr(tuple,
|
val = (struct varlena *) fastgetattr(tuple,
|
||||||
Anum_pg_trigger_tgargs,
|
Anum_pg_trigger_tgargs,
|
||||||
@@ -437,10 +437,10 @@ RelationBuildTriggers(Relation relation)
|
|||||||
void
|
void
|
||||||
FreeTriggerDesc(Relation relation)
|
FreeTriggerDesc(Relation relation)
|
||||||
{
|
{
|
||||||
TriggerDesc *trigdesc = relation->trigdesc;
|
TriggerDesc *trigdesc = relation->trigdesc;
|
||||||
Trigger ***t;
|
Trigger ***t;
|
||||||
Trigger *trigger;
|
Trigger *trigger;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (trigdesc == NULL)
|
if (trigdesc == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -483,9 +483,9 @@ FreeTriggerDesc(Relation relation)
|
|||||||
static void
|
static void
|
||||||
DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger)
|
DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger)
|
||||||
{
|
{
|
||||||
uint16 *n;
|
uint16 *n;
|
||||||
Trigger ***t,
|
Trigger ***t,
|
||||||
***tp;
|
***tp;
|
||||||
|
|
||||||
if (TRIGGER_FOR_ROW(trigger->tgtype)) /* Is ROW/STATEMENT
|
if (TRIGGER_FOR_ROW(trigger->tgtype)) /* Is ROW/STATEMENT
|
||||||
* trigger */
|
* trigger */
|
||||||
@@ -557,11 +557,11 @@ DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger)
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
ExecBRInsertTriggers(Relation rel, HeapTuple tuple)
|
ExecBRInsertTriggers(Relation rel, HeapTuple tuple)
|
||||||
{
|
{
|
||||||
int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT];
|
int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT];
|
||||||
Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_INSERT];
|
Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_INSERT];
|
||||||
HeapTuple newtuple = tuple;
|
HeapTuple newtuple = tuple;
|
||||||
int nargs;
|
int nargs;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
CurrentTriggerData = (TriggerData *) palloc(sizeof(TriggerData));
|
CurrentTriggerData = (TriggerData *) palloc(sizeof(TriggerData));
|
||||||
CurrentTriggerData->tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW;
|
CurrentTriggerData->tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.43 1997/09/07 04:41:02 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.44 1997/09/08 02:22:17 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -56,11 +56,11 @@
|
|||||||
|
|
||||||
#include <port-protos.h>
|
#include <port-protos.h>
|
||||||
|
|
||||||
bool VacuumRunning = false;
|
bool VacuumRunning = false;
|
||||||
|
|
||||||
static Portal vc_portal;
|
static Portal vc_portal;
|
||||||
|
|
||||||
static int MESSAGE_LEVEL; /* message level */
|
static int MESSAGE_LEVEL; /* message level */
|
||||||
|
|
||||||
#define swapLong(a,b) {long tmp; tmp=a; a=b; b=tmp;}
|
#define swapLong(a,b) {long tmp; tmp=a; a=b; b=tmp;}
|
||||||
#define swapInt(a,b) {int tmp; tmp=a; a=b; b=tmp;}
|
#define swapInt(a,b) {int tmp; tmp=a; a=b; b=tmp;}
|
||||||
@@ -72,46 +72,46 @@ static int MESSAGE_LEVEL; /* message level */
|
|||||||
|
|
||||||
|
|
||||||
/* non-export function prototypes */
|
/* non-export function prototypes */
|
||||||
static void vc_init(void);
|
static void vc_init(void);
|
||||||
static void vc_shutdown(void);
|
static void vc_shutdown(void);
|
||||||
static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols);
|
static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols);
|
||||||
static VRelList vc_getrels(NameData * VacRelP);
|
static VRelList vc_getrels(NameData * VacRelP);
|
||||||
static void vc_vacone(Oid relid, bool analyze, List * va_cols);
|
static void vc_vacone(Oid relid, bool analyze, List * va_cols);
|
||||||
static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl);
|
static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl);
|
||||||
static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel);
|
static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel);
|
||||||
static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList vpl);
|
static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList vpl);
|
||||||
static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel);
|
static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel);
|
||||||
static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups);
|
static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups);
|
||||||
static void vc_scanoneind(Relation indrel, int nhtups);
|
static void vc_scanoneind(Relation indrel, int nhtups);
|
||||||
static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup);
|
static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup);
|
||||||
static void vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucket_len);
|
static void vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucket_len);
|
||||||
static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats);
|
static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats);
|
||||||
static void vc_delhilowstats(Oid relid, int attcnt, int *attnums);
|
static void vc_delhilowstats(Oid relid, int attcnt, int *attnums);
|
||||||
static void vc_setpagelock(Relation rel, BlockNumber blkno);
|
static void vc_setpagelock(Relation rel, BlockNumber blkno);
|
||||||
static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl);
|
static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl);
|
||||||
static void vc_reappage(VPageList vpl, VPageDescr vpc);
|
static void vc_reappage(VPageList vpl, VPageDescr vpc);
|
||||||
static void vc_vpinsert(VPageList vpl, VPageDescr vpnew);
|
static void vc_vpinsert(VPageList vpl, VPageDescr vpnew);
|
||||||
static void vc_free(VRelList vrl);
|
static void vc_free(VRelList vrl);
|
||||||
static void vc_getindices(Oid relid, int *nindices, Relation ** Irel);
|
static void vc_getindices(Oid relid, int *nindices, Relation ** Irel);
|
||||||
static void vc_clsindices(int nindices, Relation * Irel);
|
static void vc_clsindices(int nindices, Relation * Irel);
|
||||||
static Relation vc_getarchrel(Relation heaprel);
|
static Relation vc_getarchrel(Relation heaprel);
|
||||||
static void vc_archive(Relation archrel, HeapTuple htup);
|
static void vc_archive(Relation archrel, HeapTuple htup);
|
||||||
static bool vc_isarchrel(char *rname);
|
static bool vc_isarchrel(char *rname);
|
||||||
static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc);
|
static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc);
|
||||||
static char *vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *));
|
static char *vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *));
|
||||||
static int vc_cmp_blk(char *left, char *right);
|
static int vc_cmp_blk(char *left, char *right);
|
||||||
static int vc_cmp_offno(char *left, char *right);
|
static int vc_cmp_offno(char *left, char *right);
|
||||||
static bool vc_enough_space(VPageDescr vpd, Size len);
|
static bool vc_enough_space(VPageDescr vpd, Size len);
|
||||||
|
|
||||||
void
|
void
|
||||||
vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec)
|
vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec)
|
||||||
{
|
{
|
||||||
char *pname;
|
char *pname;
|
||||||
MemoryContext old;
|
MemoryContext old;
|
||||||
PortalVariableMemory pmem;
|
PortalVariableMemory pmem;
|
||||||
NameData VacRel;
|
NameData VacRel;
|
||||||
List *le;
|
List *le;
|
||||||
List *va_cols = NIL;
|
List *va_cols = NIL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a portal for safe memory across transctions. We need to
|
* Create a portal for safe memory across transctions. We need to
|
||||||
@@ -139,8 +139,8 @@ vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec)
|
|||||||
Assert(va_spec == NIL || analyze);
|
Assert(va_spec == NIL || analyze);
|
||||||
foreach(le, va_spec)
|
foreach(le, va_spec)
|
||||||
{
|
{
|
||||||
char *col = (char *) lfirst(le);
|
char *col = (char *) lfirst(le);
|
||||||
char *dest;
|
char *dest;
|
||||||
|
|
||||||
dest = (char *) palloc(strlen(col) + 1);
|
dest = (char *) palloc(strlen(col) + 1);
|
||||||
strcpy(dest, col);
|
strcpy(dest, col);
|
||||||
@@ -183,7 +183,7 @@ vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec)
|
|||||||
static void
|
static void
|
||||||
vc_init()
|
vc_init()
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if ((fd = open("pg_vlock", O_CREAT | O_EXCL, 0600)) < 0)
|
if ((fd = open("pg_vlock", O_CREAT | O_EXCL, 0600)) < 0)
|
||||||
elog(WARN, "can't create lock file -- another vacuum cleaner running?");
|
elog(WARN, "can't create lock file -- another vacuum cleaner running?");
|
||||||
@@ -238,8 +238,8 @@ vc_abort()
|
|||||||
static void
|
static void
|
||||||
vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols)
|
vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols)
|
||||||
{
|
{
|
||||||
VRelList vrl,
|
VRelList vrl,
|
||||||
cur;
|
cur;
|
||||||
|
|
||||||
/* get list of relations */
|
/* get list of relations */
|
||||||
vrl = vc_getrels(VacRelP);
|
vrl = vc_getrels(VacRelP);
|
||||||
@@ -254,25 +254,25 @@ vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols)
|
|||||||
vc_free(vrl);
|
vc_free(vrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VRelList
|
static VRelList
|
||||||
vc_getrels(NameData * VacRelP)
|
vc_getrels(NameData * VacRelP)
|
||||||
{
|
{
|
||||||
Relation pgclass;
|
Relation pgclass;
|
||||||
TupleDesc pgcdesc;
|
TupleDesc pgcdesc;
|
||||||
HeapScanDesc pgcscan;
|
HeapScanDesc pgcscan;
|
||||||
HeapTuple pgctup;
|
HeapTuple pgctup;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
PortalVariableMemory portalmem;
|
PortalVariableMemory portalmem;
|
||||||
MemoryContext old;
|
MemoryContext old;
|
||||||
VRelList vrl,
|
VRelList vrl,
|
||||||
cur;
|
cur;
|
||||||
Datum d;
|
Datum d;
|
||||||
char *rname;
|
char *rname;
|
||||||
char rkind;
|
char rkind;
|
||||||
int16 smgrno;
|
int16 smgrno;
|
||||||
bool n;
|
bool n;
|
||||||
ScanKeyData pgckey;
|
ScanKeyData pgckey;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
|
|
||||||
@@ -404,23 +404,23 @@ vc_getrels(NameData * VacRelP)
|
|||||||
static void
|
static void
|
||||||
vc_vacone(Oid relid, bool analyze, List * va_cols)
|
vc_vacone(Oid relid, bool analyze, List * va_cols)
|
||||||
{
|
{
|
||||||
Relation pgclass;
|
Relation pgclass;
|
||||||
TupleDesc pgcdesc;
|
TupleDesc pgcdesc;
|
||||||
HeapTuple pgctup,
|
HeapTuple pgctup,
|
||||||
pgttup;
|
pgttup;
|
||||||
Buffer pgcbuf;
|
Buffer pgcbuf;
|
||||||
HeapScanDesc pgcscan;
|
HeapScanDesc pgcscan;
|
||||||
Relation onerel;
|
Relation onerel;
|
||||||
ScanKeyData pgckey;
|
ScanKeyData pgckey;
|
||||||
VPageListData Vvpl; /* List of pages to vacuum and/or clean
|
VPageListData Vvpl; /* List of pages to vacuum and/or clean
|
||||||
* indices */
|
* indices */
|
||||||
VPageListData Fvpl; /* List of pages with space enough for
|
VPageListData Fvpl; /* List of pages with space enough for
|
||||||
* re-using */
|
* re-using */
|
||||||
VPageDescr *vpp;
|
VPageDescr *vpp;
|
||||||
Relation *Irel;
|
Relation *Irel;
|
||||||
int32 nindices,
|
int32 nindices,
|
||||||
i;
|
i;
|
||||||
VRelStats *vacrelstats;
|
VRelStats *vacrelstats;
|
||||||
|
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
|
|
||||||
@@ -454,8 +454,8 @@ vc_vacone(Oid relid, bool analyze, List * va_cols)
|
|||||||
vacrelstats->hasindex = false;
|
vacrelstats->hasindex = false;
|
||||||
if (analyze && !IsSystemRelationName((RelationGetRelationName(onerel))->data))
|
if (analyze && !IsSystemRelationName((RelationGetRelationName(onerel))->data))
|
||||||
{
|
{
|
||||||
int attr_cnt,
|
int attr_cnt,
|
||||||
*attnums = NULL;
|
*attnums = NULL;
|
||||||
AttributeTupleForm *attr;
|
AttributeTupleForm *attr;
|
||||||
|
|
||||||
attr_cnt = onerel->rd_att->natts;
|
attr_cnt = onerel->rd_att->natts;
|
||||||
@@ -463,8 +463,8 @@ vc_vacone(Oid relid, bool analyze, List * va_cols)
|
|||||||
|
|
||||||
if (va_cols != NIL)
|
if (va_cols != NIL)
|
||||||
{
|
{
|
||||||
int tcnt = 0;
|
int tcnt = 0;
|
||||||
List *le;
|
List *le;
|
||||||
|
|
||||||
if (length(va_cols) > attr_cnt)
|
if (length(va_cols) > attr_cnt)
|
||||||
elog(WARN, "vacuum: too many attributes specified for relation %s",
|
elog(WARN, "vacuum: too many attributes specified for relation %s",
|
||||||
@@ -472,7 +472,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols)
|
|||||||
attnums = (int *) palloc(attr_cnt * sizeof(int));
|
attnums = (int *) palloc(attr_cnt * sizeof(int));
|
||||||
foreach(le, va_cols)
|
foreach(le, va_cols)
|
||||||
{
|
{
|
||||||
char *col = (char *) lfirst(le);
|
char *col = (char *) lfirst(le);
|
||||||
|
|
||||||
for (i = 0; i < attr_cnt; i++)
|
for (i = 0; i < attr_cnt; i++)
|
||||||
{
|
{
|
||||||
@@ -495,9 +495,9 @@ vc_vacone(Oid relid, bool analyze, List * va_cols)
|
|||||||
|
|
||||||
for (i = 0; i < attr_cnt; i++)
|
for (i = 0; i < attr_cnt; i++)
|
||||||
{
|
{
|
||||||
Operator func_operator;
|
Operator func_operator;
|
||||||
OperatorTupleForm pgopform;
|
OperatorTupleForm pgopform;
|
||||||
VacAttrStats *stats;
|
VacAttrStats *stats;
|
||||||
|
|
||||||
stats = &vacrelstats->vacattrstats[i];
|
stats = &vacrelstats->vacattrstats[i];
|
||||||
stats->attr = palloc(ATTRIBUTE_TUPLE_SIZE);
|
stats->attr = palloc(ATTRIBUTE_TUPLE_SIZE);
|
||||||
@@ -513,7 +513,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols)
|
|||||||
func_operator = oper("=", stats->attr->atttypid, stats->attr->atttypid, true);
|
func_operator = oper("=", stats->attr->atttypid, stats->attr->atttypid, true);
|
||||||
if (func_operator != NULL)
|
if (func_operator != NULL)
|
||||||
{
|
{
|
||||||
int nargs;
|
int nargs;
|
||||||
|
|
||||||
pgopform = (OperatorTupleForm) GETSTRUCT(func_operator);
|
pgopform = (OperatorTupleForm) GETSTRUCT(func_operator);
|
||||||
fmgr_info(pgopform->oprcode, &(stats->f_cmpeq), &nargs);
|
fmgr_info(pgopform->oprcode, &(stats->f_cmpeq), &nargs);
|
||||||
@@ -524,7 +524,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols)
|
|||||||
func_operator = oper("<", stats->attr->atttypid, stats->attr->atttypid, true);
|
func_operator = oper("<", stats->attr->atttypid, stats->attr->atttypid, true);
|
||||||
if (func_operator != NULL)
|
if (func_operator != NULL)
|
||||||
{
|
{
|
||||||
int nargs;
|
int nargs;
|
||||||
|
|
||||||
pgopform = (OperatorTupleForm) GETSTRUCT(func_operator);
|
pgopform = (OperatorTupleForm) GETSTRUCT(func_operator);
|
||||||
fmgr_info(pgopform->oprcode, &(stats->f_cmplt), &nargs);
|
fmgr_info(pgopform->oprcode, &(stats->f_cmplt), &nargs);
|
||||||
@@ -535,7 +535,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols)
|
|||||||
func_operator = oper(">", stats->attr->atttypid, stats->attr->atttypid, true);
|
func_operator = oper(">", stats->attr->atttypid, stats->attr->atttypid, true);
|
||||||
if (func_operator != NULL)
|
if (func_operator != NULL)
|
||||||
{
|
{
|
||||||
int nargs;
|
int nargs;
|
||||||
|
|
||||||
pgopform = (OperatorTupleForm) GETSTRUCT(func_operator);
|
pgopform = (OperatorTupleForm) GETSTRUCT(func_operator);
|
||||||
fmgr_info(pgopform->oprcode, &(stats->f_cmpgt), &nargs);
|
fmgr_info(pgopform->oprcode, &(stats->f_cmpgt), &nargs);
|
||||||
@@ -642,39 +642,39 @@ static void
|
|||||||
vc_scanheap(VRelStats * vacrelstats, Relation onerel,
|
vc_scanheap(VRelStats * vacrelstats, Relation onerel,
|
||||||
VPageList Vvpl, VPageList Fvpl)
|
VPageList Vvpl, VPageList Fvpl)
|
||||||
{
|
{
|
||||||
int nblocks,
|
int nblocks,
|
||||||
blkno;
|
blkno;
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
ItemPointer itemptr;
|
ItemPointer itemptr;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page,
|
Page page,
|
||||||
tempPage = NULL;
|
tempPage = NULL;
|
||||||
OffsetNumber offnum,
|
OffsetNumber offnum,
|
||||||
maxoff;
|
maxoff;
|
||||||
bool pgchanged,
|
bool pgchanged,
|
||||||
tupgone,
|
tupgone,
|
||||||
dobufrel,
|
dobufrel,
|
||||||
notup;
|
notup;
|
||||||
char *relname;
|
char *relname;
|
||||||
VPageDescr vpc,
|
VPageDescr vpc,
|
||||||
vp;
|
vp;
|
||||||
uint32 nvac,
|
uint32 nvac,
|
||||||
ntups,
|
ntups,
|
||||||
nunused,
|
nunused,
|
||||||
ncrash,
|
ncrash,
|
||||||
nempg,
|
nempg,
|
||||||
nnepg,
|
nnepg,
|
||||||
nchpg,
|
nchpg,
|
||||||
nemend;
|
nemend;
|
||||||
Size frsize,
|
Size frsize,
|
||||||
frsusf;
|
frsusf;
|
||||||
Size min_tlen = MAXTUPLEN;
|
Size min_tlen = MAXTUPLEN;
|
||||||
Size max_tlen = 0;
|
Size max_tlen = 0;
|
||||||
int32 i /* , attr_cnt */ ;
|
int32 i /* , attr_cnt */ ;
|
||||||
struct rusage ru0,
|
struct rusage ru0,
|
||||||
ru1;
|
ru1;
|
||||||
bool do_shrinking = true;
|
bool do_shrinking = true;
|
||||||
|
|
||||||
getrusage(RUSAGE_SELF, &ru0);
|
getrusage(RUSAGE_SELF, &ru0);
|
||||||
|
|
||||||
@@ -844,11 +844,11 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.",
|
|||||||
|
|
||||||
if (tupgone)
|
if (tupgone)
|
||||||
{
|
{
|
||||||
ItemId lpp;
|
ItemId lpp;
|
||||||
|
|
||||||
if (tempPage == (Page) NULL)
|
if (tempPage == (Page) NULL)
|
||||||
{
|
{
|
||||||
Size pageSize;
|
Size pageSize;
|
||||||
|
|
||||||
pageSize = PageGetPageSize(page);
|
pageSize = PageGetPageSize(page);
|
||||||
tempPage = (Page) palloc(pageSize);
|
tempPage = (Page) palloc(pageSize);
|
||||||
@@ -927,7 +927,7 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.",
|
|||||||
*/
|
*/
|
||||||
if (do_shrinking && Vvpl->vpl_npages - nemend > 0)
|
if (do_shrinking && Vvpl->vpl_npages - nemend > 0)
|
||||||
{
|
{
|
||||||
int nusf; /* blocks usefull for re-using */
|
int nusf; /* blocks usefull for re-using */
|
||||||
|
|
||||||
nusf = Vvpl->vpl_npages - nemend;
|
nusf = Vvpl->vpl_npages - nemend;
|
||||||
if ((Vvpl->vpl_pgdesc[nusf - 1])->vpd_blkno == nblocks - nemend - 1)
|
if ((Vvpl->vpl_pgdesc[nusf - 1])->vpd_blkno == nblocks - nemend - 1)
|
||||||
@@ -972,50 +972,50 @@ static void
|
|||||||
vc_rpfheap(VRelStats * vacrelstats, Relation onerel,
|
vc_rpfheap(VRelStats * vacrelstats, Relation onerel,
|
||||||
VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel)
|
VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel)
|
||||||
{
|
{
|
||||||
TransactionId myXID;
|
TransactionId myXID;
|
||||||
CommandId myCID;
|
CommandId myCID;
|
||||||
AbsoluteTime myCTM = 0;
|
AbsoluteTime myCTM = 0;
|
||||||
Buffer buf,
|
Buffer buf,
|
||||||
ToBuf;
|
ToBuf;
|
||||||
int nblocks,
|
int nblocks,
|
||||||
blkno;
|
blkno;
|
||||||
Page page,
|
Page page,
|
||||||
ToPage = NULL;
|
ToPage = NULL;
|
||||||
OffsetNumber offnum = 0,
|
OffsetNumber offnum = 0,
|
||||||
maxoff = 0,
|
maxoff = 0,
|
||||||
newoff,
|
newoff,
|
||||||
moff;
|
moff;
|
||||||
ItemId itemid,
|
ItemId itemid,
|
||||||
newitemid;
|
newitemid;
|
||||||
HeapTuple htup,
|
HeapTuple htup,
|
||||||
newtup;
|
newtup;
|
||||||
TupleDesc tupdesc = NULL;
|
TupleDesc tupdesc = NULL;
|
||||||
Datum *idatum = NULL;
|
Datum *idatum = NULL;
|
||||||
char *inulls = NULL;
|
char *inulls = NULL;
|
||||||
InsertIndexResult iresult;
|
InsertIndexResult iresult;
|
||||||
VPageListData Nvpl;
|
VPageListData Nvpl;
|
||||||
VPageDescr ToVpd = NULL,
|
VPageDescr ToVpd = NULL,
|
||||||
Fvplast,
|
Fvplast,
|
||||||
Vvplast,
|
Vvplast,
|
||||||
vpc,
|
vpc,
|
||||||
*vpp;
|
*vpp;
|
||||||
int ToVpI = 0;
|
int ToVpI = 0;
|
||||||
IndDesc *Idesc,
|
IndDesc *Idesc,
|
||||||
*idcur;
|
*idcur;
|
||||||
int Fblklast,
|
int Fblklast,
|
||||||
Vblklast,
|
Vblklast,
|
||||||
i;
|
i;
|
||||||
Size tlen;
|
Size tlen;
|
||||||
int nmoved,
|
int nmoved,
|
||||||
Fnpages,
|
Fnpages,
|
||||||
Vnpages;
|
Vnpages;
|
||||||
int nchkmvd,
|
int nchkmvd,
|
||||||
ntups;
|
ntups;
|
||||||
bool isempty,
|
bool isempty,
|
||||||
dowrite;
|
dowrite;
|
||||||
Relation archrel;
|
Relation archrel;
|
||||||
struct rusage ru0,
|
struct rusage ru0,
|
||||||
ru1;
|
ru1;
|
||||||
|
|
||||||
getrusage(RUSAGE_SELF, &ru0);
|
getrusage(RUSAGE_SELF, &ru0);
|
||||||
|
|
||||||
@@ -1342,9 +1342,9 @@ Elapsed %u/%u sec.",
|
|||||||
/* vacuum indices again if needed */
|
/* vacuum indices again if needed */
|
||||||
if (Irel != (Relation *) NULL)
|
if (Irel != (Relation *) NULL)
|
||||||
{
|
{
|
||||||
VPageDescr *vpleft,
|
VPageDescr *vpleft,
|
||||||
*vpright,
|
*vpright,
|
||||||
vpsave;
|
vpsave;
|
||||||
|
|
||||||
/* re-sort Nvpl.vpl_pgdesc */
|
/* re-sort Nvpl.vpl_pgdesc */
|
||||||
for (vpleft = Nvpl.vpl_pgdesc,
|
for (vpleft = Nvpl.vpl_pgdesc,
|
||||||
@@ -1426,12 +1426,12 @@ Elapsed %u/%u sec.",
|
|||||||
static void
|
static void
|
||||||
vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl)
|
vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
VPageDescr *vpp;
|
VPageDescr *vpp;
|
||||||
Relation archrel;
|
Relation archrel;
|
||||||
int nblocks;
|
int nblocks;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
nblocks = Vvpl->vpl_npages;
|
nblocks = Vvpl->vpl_npages;
|
||||||
/* if the relation has an archive, open it */
|
/* if the relation has an archive, open it */
|
||||||
@@ -1486,9 +1486,9 @@ vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl)
|
|||||||
static void
|
static void
|
||||||
vc_vacpage(Page page, VPageDescr vpd, Relation archrel)
|
vc_vacpage(Page page, VPageDescr vpd, Relation archrel)
|
||||||
{
|
{
|
||||||
ItemId itemid;
|
ItemId itemid;
|
||||||
HeapTuple htup;
|
HeapTuple htup;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Assert(vpd->vpd_nusd == 0);
|
Assert(vpd->vpd_nusd == 0);
|
||||||
for (i = 0; i < vpd->vpd_noff; i++)
|
for (i = 0; i < vpd->vpd_noff; i++)
|
||||||
@@ -1513,11 +1513,11 @@ static void
|
|||||||
vc_scanoneind(Relation indrel, int nhtups)
|
vc_scanoneind(Relation indrel, int nhtups)
|
||||||
{
|
{
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
IndexScanDesc iscan;
|
IndexScanDesc iscan;
|
||||||
int nitups;
|
int nitups;
|
||||||
int nipages;
|
int nipages;
|
||||||
struct rusage ru0,
|
struct rusage ru0,
|
||||||
ru1;
|
ru1;
|
||||||
|
|
||||||
getrusage(RUSAGE_SELF, &ru0);
|
getrusage(RUSAGE_SELF, &ru0);
|
||||||
|
|
||||||
@@ -1567,14 +1567,14 @@ static void
|
|||||||
vc_vaconeind(VPageList vpl, Relation indrel, int nhtups)
|
vc_vaconeind(VPageList vpl, Relation indrel, int nhtups)
|
||||||
{
|
{
|
||||||
RetrieveIndexResult res;
|
RetrieveIndexResult res;
|
||||||
IndexScanDesc iscan;
|
IndexScanDesc iscan;
|
||||||
ItemPointer heapptr;
|
ItemPointer heapptr;
|
||||||
int nvac;
|
int nvac;
|
||||||
int nitups;
|
int nitups;
|
||||||
int nipages;
|
int nipages;
|
||||||
VPageDescr vp;
|
VPageDescr vp;
|
||||||
struct rusage ru0,
|
struct rusage ru0,
|
||||||
ru1;
|
ru1;
|
||||||
|
|
||||||
getrusage(RUSAGE_SELF, &ru0);
|
getrusage(RUSAGE_SELF, &ru0);
|
||||||
|
|
||||||
@@ -1639,14 +1639,14 @@ vc_vaconeind(VPageList vpl, Relation indrel, int nhtups)
|
|||||||
*
|
*
|
||||||
* vpl->VPageDescr_array is sorted in right order.
|
* vpl->VPageDescr_array is sorted in right order.
|
||||||
*/
|
*/
|
||||||
static VPageDescr
|
static VPageDescr
|
||||||
vc_tidreapped(ItemPointer itemptr, VPageList vpl)
|
vc_tidreapped(ItemPointer itemptr, VPageList vpl)
|
||||||
{
|
{
|
||||||
OffsetNumber ioffno;
|
OffsetNumber ioffno;
|
||||||
OffsetNumber *voff;
|
OffsetNumber *voff;
|
||||||
VPageDescr vp,
|
VPageDescr vp,
|
||||||
*vpp;
|
*vpp;
|
||||||
VPageDescrData vpd;
|
VPageDescrData vpd;
|
||||||
|
|
||||||
vpd.vpd_blkno = ItemPointerGetBlockNumber(itemptr);
|
vpd.vpd_blkno = ItemPointerGetBlockNumber(itemptr);
|
||||||
ioffno = ItemPointerGetOffsetNumber(itemptr);
|
ioffno = ItemPointerGetOffsetNumber(itemptr);
|
||||||
@@ -1702,17 +1702,17 @@ vc_tidreapped(ItemPointer itemptr, VPageList vpl)
|
|||||||
static void
|
static void
|
||||||
vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup)
|
vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup)
|
||||||
{
|
{
|
||||||
int i,
|
int i,
|
||||||
attr_cnt = vacrelstats->va_natts;
|
attr_cnt = vacrelstats->va_natts;
|
||||||
VacAttrStats *vacattrstats = vacrelstats->vacattrstats;
|
VacAttrStats *vacattrstats = vacrelstats->vacattrstats;
|
||||||
TupleDesc tupDesc = onerel->rd_att;
|
TupleDesc tupDesc = onerel->rd_att;
|
||||||
Datum value;
|
Datum value;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
for (i = 0; i < attr_cnt; i++)
|
for (i = 0; i < attr_cnt; i++)
|
||||||
{
|
{
|
||||||
VacAttrStats *stats = &vacattrstats[i];
|
VacAttrStats *stats = &vacattrstats[i];
|
||||||
bool value_hit = true;
|
bool value_hit = true;
|
||||||
|
|
||||||
value = (Datum) heap_getattr(htup, InvalidBuffer,
|
value = (Datum) heap_getattr(htup, InvalidBuffer,
|
||||||
stats->attr->attnum, tupDesc, &isnull);
|
stats->attr->attnum, tupDesc, &isnull);
|
||||||
@@ -1806,7 +1806,7 @@ vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucke
|
|||||||
*bucket = value;
|
*bucket = value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int len = (attr->attlen != -1 ? attr->attlen : VARSIZE(value));
|
int len = (attr->attlen != -1 ? attr->attlen : VARSIZE(value));
|
||||||
|
|
||||||
if (len > *bucket_len)
|
if (len > *bucket_len)
|
||||||
{
|
{
|
||||||
@@ -1833,20 +1833,20 @@ vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucke
|
|||||||
static void
|
static void
|
||||||
vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats)
|
vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats)
|
||||||
{
|
{
|
||||||
Relation rd,
|
Relation rd,
|
||||||
ad,
|
ad,
|
||||||
sd;
|
sd;
|
||||||
HeapScanDesc rsdesc,
|
HeapScanDesc rsdesc,
|
||||||
asdesc;
|
asdesc;
|
||||||
TupleDesc sdesc;
|
TupleDesc sdesc;
|
||||||
HeapTuple rtup,
|
HeapTuple rtup,
|
||||||
atup,
|
atup,
|
||||||
stup;
|
stup;
|
||||||
Buffer rbuf,
|
Buffer rbuf,
|
||||||
abuf;
|
abuf;
|
||||||
Form_pg_class pgcform;
|
Form_pg_class pgcform;
|
||||||
ScanKeyData rskey,
|
ScanKeyData rskey,
|
||||||
askey;
|
askey;
|
||||||
AttributeTupleForm attp;
|
AttributeTupleForm attp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1872,8 +1872,8 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels
|
|||||||
|
|
||||||
if (vacrelstats != NULL && vacrelstats->va_natts > 0)
|
if (vacrelstats != NULL && vacrelstats->va_natts > 0)
|
||||||
{
|
{
|
||||||
VacAttrStats *vacattrstats = vacrelstats->vacattrstats;
|
VacAttrStats *vacattrstats = vacrelstats->vacattrstats;
|
||||||
int natts = vacrelstats->va_natts;
|
int natts = vacrelstats->va_natts;
|
||||||
|
|
||||||
ad = heap_openr(AttributeRelationName);
|
ad = heap_openr(AttributeRelationName);
|
||||||
sd = heap_openr(StatisticRelationName);
|
sd = heap_openr(StatisticRelationName);
|
||||||
@@ -1884,12 +1884,12 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels
|
|||||||
|
|
||||||
while (HeapTupleIsValid(atup = heap_getnext(asdesc, 0, &abuf)))
|
while (HeapTupleIsValid(atup = heap_getnext(asdesc, 0, &abuf)))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float32data selratio; /* average ratio of rows selected
|
float32data selratio; /* average ratio of rows selected
|
||||||
* for a random constant */
|
* for a random constant */
|
||||||
VacAttrStats *stats;
|
VacAttrStats *stats;
|
||||||
Datum values[Natts_pg_statistic];
|
Datum values[Natts_pg_statistic];
|
||||||
char nulls[Natts_pg_statistic];
|
char nulls[Natts_pg_statistic];
|
||||||
|
|
||||||
attp = (AttributeTupleForm) GETSTRUCT(atup);
|
attp = (AttributeTupleForm) GETSTRUCT(atup);
|
||||||
if (attp->attnum <= 0) /* skip system attributes for now, */
|
if (attp->attnum <= 0) /* skip system attributes for now, */
|
||||||
@@ -1916,18 +1916,18 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels
|
|||||||
selratio = 0;
|
selratio = 0;
|
||||||
else if (VacAttrStatsLtGtValid(stats) && stats->min_cnt + stats->max_cnt == stats->nonnull_cnt)
|
else if (VacAttrStatsLtGtValid(stats) && stats->min_cnt + stats->max_cnt == stats->nonnull_cnt)
|
||||||
{
|
{
|
||||||
double min_cnt_d = stats->min_cnt,
|
double min_cnt_d = stats->min_cnt,
|
||||||
max_cnt_d = stats->max_cnt,
|
max_cnt_d = stats->max_cnt,
|
||||||
null_cnt_d = stats->null_cnt,
|
null_cnt_d = stats->null_cnt,
|
||||||
nonnullcnt_d = stats->nonnull_cnt; /* prevent overflow */
|
nonnullcnt_d = stats->nonnull_cnt; /* prevent overflow */
|
||||||
|
|
||||||
selratio = (min_cnt_d * min_cnt_d + max_cnt_d * max_cnt_d + null_cnt_d * null_cnt_d) /
|
selratio = (min_cnt_d * min_cnt_d + max_cnt_d * max_cnt_d + null_cnt_d * null_cnt_d) /
|
||||||
(nonnullcnt_d + null_cnt_d) / (nonnullcnt_d + null_cnt_d);
|
(nonnullcnt_d + null_cnt_d) / (nonnullcnt_d + null_cnt_d);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double most = (double) (stats->best_cnt > stats->null_cnt ? stats->best_cnt : stats->null_cnt);
|
double most = (double) (stats->best_cnt > stats->null_cnt ? stats->best_cnt : stats->null_cnt);
|
||||||
double total = ((double) stats->nonnull_cnt) + ((double) stats->null_cnt);
|
double total = ((double) stats->nonnull_cnt) + ((double) stats->null_cnt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we assume count of other values are 20% of best
|
* we assume count of other values are 20% of best
|
||||||
@@ -1948,12 +1948,12 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels
|
|||||||
*/
|
*/
|
||||||
if (VacAttrStatsLtGtValid(stats) && stats->initialized /* &&
|
if (VacAttrStatsLtGtValid(stats) && stats->initialized /* &&
|
||||||
* !IsSystemRelationName(
|
* !IsSystemRelationName(
|
||||||
* pgcform->relname.data)
|
*
|
||||||
*/ )
|
pgcform->relname.data) */ )
|
||||||
{
|
{
|
||||||
func_ptr out_function;
|
func_ptr out_function;
|
||||||
char *out_string;
|
char *out_string;
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
for (i = 0; i < Natts_pg_statistic; ++i)
|
for (i = 0; i < Natts_pg_statistic; ++i)
|
||||||
nulls[i] = ' ';
|
nulls[i] = ' ';
|
||||||
@@ -2016,10 +2016,10 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels
|
|||||||
static void
|
static void
|
||||||
vc_delhilowstats(Oid relid, int attcnt, int *attnums)
|
vc_delhilowstats(Oid relid, int attcnt, int *attnums)
|
||||||
{
|
{
|
||||||
Relation pgstatistic;
|
Relation pgstatistic;
|
||||||
HeapScanDesc pgsscan;
|
HeapScanDesc pgsscan;
|
||||||
HeapTuple pgstup;
|
HeapTuple pgstup;
|
||||||
ScanKeyData pgskey;
|
ScanKeyData pgskey;
|
||||||
|
|
||||||
pgstatistic = heap_openr(StatisticRelationName);
|
pgstatistic = heap_openr(StatisticRelationName);
|
||||||
|
|
||||||
@@ -2038,7 +2038,7 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums)
|
|||||||
if (attcnt > 0)
|
if (attcnt > 0)
|
||||||
{
|
{
|
||||||
Form_pg_statistic pgs = (Form_pg_statistic) GETSTRUCT(pgstup);
|
Form_pg_statistic pgs = (Form_pg_statistic) GETSTRUCT(pgstup);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < attcnt; i++)
|
for (i = 0; i < attcnt; i++)
|
||||||
{
|
{
|
||||||
@@ -2075,7 +2075,7 @@ vc_setpagelock(Relation rel, BlockNumber blkno)
|
|||||||
static void
|
static void
|
||||||
vc_reappage(VPageList vpl, VPageDescr vpc)
|
vc_reappage(VPageList vpl, VPageDescr vpc)
|
||||||
{
|
{
|
||||||
VPageDescr newvpd;
|
VPageDescr newvpd;
|
||||||
|
|
||||||
/* allocate a VPageDescrData entry */
|
/* allocate a VPageDescrData entry */
|
||||||
newvpd = (VPageDescr) palloc(sizeof(VPageDescrData) + vpc->vpd_noff * sizeof(OffsetNumber));
|
newvpd = (VPageDescr) palloc(sizeof(VPageDescrData) + vpc->vpd_noff * sizeof(OffsetNumber));
|
||||||
@@ -2110,8 +2110,8 @@ vc_vpinsert(VPageList vpl, VPageDescr vpnew)
|
|||||||
static void
|
static void
|
||||||
vc_free(VRelList vrl)
|
vc_free(VRelList vrl)
|
||||||
{
|
{
|
||||||
VRelList p_vrl;
|
VRelList p_vrl;
|
||||||
MemoryContext old;
|
MemoryContext old;
|
||||||
PortalVariableMemory pmem;
|
PortalVariableMemory pmem;
|
||||||
|
|
||||||
pmem = PortalGetVariableMemory(vc_portal);
|
pmem = PortalGetVariableMemory(vc_portal);
|
||||||
@@ -2138,11 +2138,11 @@ vc_free(VRelList vrl)
|
|||||||
|
|
||||||
#define ARCHIVE_PREFIX "a,"
|
#define ARCHIVE_PREFIX "a,"
|
||||||
|
|
||||||
static Relation
|
static Relation
|
||||||
vc_getarchrel(Relation heaprel)
|
vc_getarchrel(Relation heaprel)
|
||||||
{
|
{
|
||||||
Relation archrel;
|
Relation archrel;
|
||||||
char *archrelname;
|
char *archrelname;
|
||||||
|
|
||||||
archrelname = palloc(sizeof(ARCHIVE_PREFIX) + NAMEDATALEN); /* bogus */
|
archrelname = palloc(sizeof(ARCHIVE_PREFIX) + NAMEDATALEN); /* bogus */
|
||||||
sprintf(archrelname, "%s%d", ARCHIVE_PREFIX, heaprel->rd_id);
|
sprintf(archrelname, "%s%d", ARCHIVE_PREFIX, heaprel->rd_id);
|
||||||
@@ -2165,7 +2165,7 @@ vc_archive(Relation archrel, HeapTuple htup)
|
|||||||
doinsert(archrel, htup);
|
doinsert(archrel, htup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
vc_isarchrel(char *rname)
|
vc_isarchrel(char *rname)
|
||||||
{
|
{
|
||||||
if (strncmp(ARCHIVE_PREFIX, rname, strlen(ARCHIVE_PREFIX)) == 0)
|
if (strncmp(ARCHIVE_PREFIX, rname, strlen(ARCHIVE_PREFIX)) == 0)
|
||||||
@@ -2174,14 +2174,14 @@ vc_isarchrel(char *rname)
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *))
|
vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *))
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
int last = nelem - 1;
|
int last = nelem - 1;
|
||||||
int celm = nelem / 2;
|
int celm = nelem / 2;
|
||||||
bool last_move,
|
bool last_move,
|
||||||
first_move;
|
first_move;
|
||||||
|
|
||||||
last_move = first_move = true;
|
last_move = first_move = true;
|
||||||
for (;;)
|
for (;;)
|
||||||
@@ -2231,8 +2231,8 @@ vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, cha
|
|||||||
static int
|
static int
|
||||||
vc_cmp_blk(char *left, char *right)
|
vc_cmp_blk(char *left, char *right)
|
||||||
{
|
{
|
||||||
BlockNumber lblk,
|
BlockNumber lblk,
|
||||||
rblk;
|
rblk;
|
||||||
|
|
||||||
lblk = (*((VPageDescr *) left))->vpd_blkno;
|
lblk = (*((VPageDescr *) left))->vpd_blkno;
|
||||||
rblk = (*((VPageDescr *) right))->vpd_blkno;
|
rblk = (*((VPageDescr *) right))->vpd_blkno;
|
||||||
@@ -2261,17 +2261,17 @@ vc_cmp_offno(char *left, char *right)
|
|||||||
static void
|
static void
|
||||||
vc_getindices(Oid relid, int *nindices, Relation ** Irel)
|
vc_getindices(Oid relid, int *nindices, Relation ** Irel)
|
||||||
{
|
{
|
||||||
Relation pgindex;
|
Relation pgindex;
|
||||||
Relation irel;
|
Relation irel;
|
||||||
TupleDesc pgidesc;
|
TupleDesc pgidesc;
|
||||||
HeapTuple pgitup;
|
HeapTuple pgitup;
|
||||||
HeapScanDesc pgiscan;
|
HeapScanDesc pgiscan;
|
||||||
Datum d;
|
Datum d;
|
||||||
int i,
|
int i,
|
||||||
k;
|
k;
|
||||||
bool n;
|
bool n;
|
||||||
ScanKeyData pgikey;
|
ScanKeyData pgikey;
|
||||||
Oid *ioid;
|
Oid *ioid;
|
||||||
|
|
||||||
*nindices = i = 0;
|
*nindices = i = 0;
|
||||||
|
|
||||||
@@ -2354,11 +2354,11 @@ vc_clsindices(int nindices, Relation * Irel)
|
|||||||
static void
|
static void
|
||||||
vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc)
|
vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc)
|
||||||
{
|
{
|
||||||
IndDesc *idcur;
|
IndDesc *idcur;
|
||||||
HeapTuple pgIndexTup;
|
HeapTuple pgIndexTup;
|
||||||
AttrNumber *attnumP;
|
AttrNumber *attnumP;
|
||||||
int natts;
|
int natts;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
*Idesc = (IndDesc *) palloc(nindices * sizeof(IndDesc));
|
*Idesc = (IndDesc *) palloc(nindices * sizeof(IndDesc));
|
||||||
|
|
||||||
@@ -2390,7 +2390,7 @@ vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc)
|
|||||||
} /* vc_mkindesc */
|
} /* vc_mkindesc */
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
vc_enough_space(VPageDescr vpd, Size len)
|
vc_enough_space(VPageDescr vpd, Size len)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.9 1997/09/07 04:41:06 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.10 1997/09/08 02:22:20 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -44,13 +44,13 @@
|
|||||||
static void
|
static void
|
||||||
DefineVirtualRelation(char *relname, List * tlist)
|
DefineVirtualRelation(char *relname, List * tlist)
|
||||||
{
|
{
|
||||||
CreateStmt createStmt;
|
CreateStmt createStmt;
|
||||||
List *attrList,
|
List *attrList,
|
||||||
*t;
|
*t;
|
||||||
TargetEntry *entry;
|
TargetEntry *entry;
|
||||||
Resdom *res;
|
Resdom *res;
|
||||||
char *resname;
|
char *resname;
|
||||||
char *restypename;
|
char *restypename;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a list with one entry per attribute of this relation. Each
|
* create a list with one entry per attribute of this relation. Each
|
||||||
@@ -63,8 +63,8 @@ DefineVirtualRelation(char *relname, List * tlist)
|
|||||||
{
|
{
|
||||||
foreach(t, tlist)
|
foreach(t, tlist)
|
||||||
{
|
{
|
||||||
ColumnDef *def = makeNode(ColumnDef);
|
ColumnDef *def = makeNode(ColumnDef);
|
||||||
TypeName *typename;
|
TypeName *typename;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find the names of the attribute & its type
|
* find the names of the attribute & its type
|
||||||
@@ -123,7 +123,7 @@ DefineVirtualRelation(char *relname, List * tlist)
|
|||||||
* XXX it also means viewName cannot be 16 chars long! - ay 11/94
|
* XXX it also means viewName cannot be 16 chars long! - ay 11/94
|
||||||
*------------------------------------------------------------------
|
*------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
MakeRetrieveViewRuleName(char *viewName)
|
MakeRetrieveViewRuleName(char *viewName)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -135,7 +135,7 @@ MakeRetrieveViewRuleName(char *viewName)
|
|||||||
namestrcpy(rule_name, buf);
|
namestrcpy(rule_name, buf);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
buf = palloc(strlen(viewName) + 5);
|
buf = palloc(strlen(viewName) + 5);
|
||||||
sprintf(buf, "_RET%s", viewName);
|
sprintf(buf, "_RET%s", viewName);
|
||||||
@@ -145,9 +145,9 @@ MakeRetrieveViewRuleName(char *viewName)
|
|||||||
static RuleStmt *
|
static RuleStmt *
|
||||||
FormViewRetrieveRule(char *viewName, Query * viewParse)
|
FormViewRetrieveRule(char *viewName, Query * viewParse)
|
||||||
{
|
{
|
||||||
RuleStmt *rule;
|
RuleStmt *rule;
|
||||||
char *rname;
|
char *rname;
|
||||||
Attr *attr;
|
Attr *attr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a RuleStmt that corresponds to the suitable rewrite rule
|
* Create a RuleStmt that corresponds to the suitable rewrite rule
|
||||||
@@ -172,12 +172,12 @@ FormViewRetrieveRule(char *viewName, Query * viewParse)
|
|||||||
static void
|
static void
|
||||||
DefineViewRules(char *viewName, Query * viewParse)
|
DefineViewRules(char *viewName, Query * viewParse)
|
||||||
{
|
{
|
||||||
RuleStmt *retrieve_rule = NULL;
|
RuleStmt *retrieve_rule = NULL;
|
||||||
|
|
||||||
#ifdef NOTYET
|
#ifdef NOTYET
|
||||||
RuleStmt *replace_rule = NULL;
|
RuleStmt *replace_rule = NULL;
|
||||||
RuleStmt *append_rule = NULL;
|
RuleStmt *append_rule = NULL;
|
||||||
RuleStmt *delete_rule = NULL;
|
RuleStmt *delete_rule = NULL;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -226,10 +226,10 @@ DefineViewRules(char *viewName, Query * viewParse)
|
|||||||
static void
|
static void
|
||||||
UpdateRangeTableOfViewParse(char *viewName, Query * viewParse)
|
UpdateRangeTableOfViewParse(char *viewName, Query * viewParse)
|
||||||
{
|
{
|
||||||
List *old_rt;
|
List *old_rt;
|
||||||
List *new_rt;
|
List *new_rt;
|
||||||
RangeTblEntry *rt_entry1,
|
RangeTblEntry *rt_entry1,
|
||||||
*rt_entry2;
|
*rt_entry2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* first offset all var nodes by 2
|
* first offset all var nodes by 2
|
||||||
@@ -277,7 +277,7 @@ UpdateRangeTableOfViewParse(char *viewName, Query * viewParse)
|
|||||||
void
|
void
|
||||||
DefineView(char *viewName, Query * viewParse)
|
DefineView(char *viewName, Query * viewParse)
|
||||||
{
|
{
|
||||||
List *viewTlist;
|
List *viewTlist;
|
||||||
|
|
||||||
viewTlist = viewParse->targetList;
|
viewTlist = viewParse->targetList;
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ DefineView(char *viewName, Query * viewParse)
|
|||||||
void
|
void
|
||||||
RemoveView(char *viewName)
|
RemoveView(char *viewName)
|
||||||
{
|
{
|
||||||
char *rname;
|
char *rname;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* first remove all the "view" rules... Currently we only have one!
|
* first remove all the "view" rules... Currently we only have one!
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.6 1997/09/07 04:41:09 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.7 1997/09/08 02:22:23 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -74,8 +74,8 @@ ExecOpenScanR(Oid relOid,
|
|||||||
Relation * returnRelation, /* return */
|
Relation * returnRelation, /* return */
|
||||||
Pointer * returnScanDesc) /* return */
|
Pointer * returnScanDesc) /* return */
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
Pointer scanDesc;
|
Pointer scanDesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* note: scanDesc returned by ExecBeginScan can be either
|
* note: scanDesc returned by ExecBeginScan can be either
|
||||||
@@ -104,10 +104,10 @@ ExecOpenScanR(Oid relOid,
|
|||||||
* returns a relation descriptor given an object id.
|
* returns a relation descriptor given an object id.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Relation
|
static Relation
|
||||||
ExecOpenR(Oid relationOid, bool isindex)
|
ExecOpenR(Oid relationOid, bool isindex)
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
|
|
||||||
relation = (Relation) NULL;
|
relation = (Relation) NULL;
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ ExecOpenR(Oid relationOid, bool isindex)
|
|||||||
* -cim 9/14/89
|
* -cim 9/14/89
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Pointer
|
static Pointer
|
||||||
ExecBeginScan(Relation relation,
|
ExecBeginScan(Relation relation,
|
||||||
int nkeys,
|
int nkeys,
|
||||||
ScanKey skeys,
|
ScanKey skeys,
|
||||||
@@ -149,7 +149,7 @@ ExecBeginScan(Relation relation,
|
|||||||
ScanDirection dir,
|
ScanDirection dir,
|
||||||
TimeQual time_range)
|
TimeQual time_range)
|
||||||
{
|
{
|
||||||
Pointer scanDesc;
|
Pointer scanDesc;
|
||||||
|
|
||||||
scanDesc = NULL;
|
scanDesc = NULL;
|
||||||
|
|
||||||
@@ -198,8 +198,8 @@ void
|
|||||||
ExecCloseR(Plan * node)
|
ExecCloseR(Plan * node)
|
||||||
{
|
{
|
||||||
CommonScanState *state;
|
CommonScanState *state;
|
||||||
Relation relation;
|
Relation relation;
|
||||||
HeapScanDesc scanDesc;
|
HeapScanDesc scanDesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* shut down the heap scan and close the heap relation
|
* shut down the heap scan and close the heap relation
|
||||||
@@ -208,29 +208,29 @@ ExecCloseR(Plan * node)
|
|||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
|
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
state = ((SeqScan *) node)->scanstate;
|
state = ((SeqScan *) node)->scanstate;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
state = ((IndexScan *) node)->scan.scanstate;
|
state = ((IndexScan *) node)->scan.scanstate;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Material:
|
case T_Material:
|
||||||
state = &(((Material *) node)->matstate->csstate);
|
state = &(((Material *) node)->matstate->csstate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
state = &(((Sort *) node)->sortstate->csstate);
|
state = &(((Sort *) node)->sortstate->csstate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Agg:
|
case T_Agg:
|
||||||
state = &(((Agg *) node)->aggstate->csstate);
|
state = &(((Agg *) node)->aggstate->csstate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(DEBUG, "ExecCloseR: not a scan, material, or sort node!");
|
elog(DEBUG, "ExecCloseR: not a scan, material, or sort node!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
relation = state->css_currentRelation;
|
relation = state->css_currentRelation;
|
||||||
@@ -249,12 +249,12 @@ ExecCloseR(Plan * node)
|
|||||||
*/
|
*/
|
||||||
if (nodeTag(node) == T_IndexScan)
|
if (nodeTag(node) == T_IndexScan)
|
||||||
{
|
{
|
||||||
IndexScan *iscan = (IndexScan *) node;
|
IndexScan *iscan = (IndexScan *) node;
|
||||||
IndexScanState *indexstate;
|
IndexScanState *indexstate;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
RelationPtr indexRelationDescs;
|
RelationPtr indexRelationDescs;
|
||||||
IndexScanDescPtr indexScanDescs;
|
IndexScanDescPtr indexScanDescs;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
indexstate = iscan->indxstate;
|
indexstate = iscan->indxstate;
|
||||||
numIndices = indexstate->iss_NumIndices;
|
numIndices = indexstate->iss_NumIndices;
|
||||||
@@ -292,32 +292,32 @@ ExecReScan(Plan * node, ExprContext * exprCtxt, Plan * parent)
|
|||||||
{
|
{
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
ExecSeqReScan((SeqScan *) node, exprCtxt, parent);
|
ExecSeqReScan((SeqScan *) node, exprCtxt, parent);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
ExecIndexReScan((IndexScan *) node, exprCtxt, parent);
|
ExecIndexReScan((IndexScan *) node, exprCtxt, parent);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_Material:
|
case T_Material:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the first call to ExecReScan should have no effect because
|
* the first call to ExecReScan should have no effect because
|
||||||
* everything is initialized properly already. the following
|
* everything is initialized properly already. the following
|
||||||
* calls will be handled by ExecSeqReScan() because the nodes
|
* calls will be handled by ExecSeqReScan() because the nodes
|
||||||
* below the Material node have already been materialized into a
|
* below the Material node have already been materialized into
|
||||||
* temp relation.
|
* a temp relation.
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_Tee:
|
case T_Tee:
|
||||||
ExecTeeReScan((Tee *) node, exprCtxt, parent);
|
ExecTeeReScan((Tee *) node, exprCtxt, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(WARN, "ExecReScan: not a seqscan or indexscan node.");
|
elog(WARN, "ExecReScan: not a seqscan or indexscan node.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,21 +355,21 @@ ExecMarkPos(Plan * node)
|
|||||||
{
|
{
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
ExecSeqMarkPos((SeqScan *) node);
|
ExecSeqMarkPos((SeqScan *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
ExecIndexMarkPos((IndexScan *) node);
|
ExecIndexMarkPos((IndexScan *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
ExecSortMarkPos((Sort *) node);
|
ExecSortMarkPos((Sort *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* elog(DEBUG, "ExecMarkPos: unsupported node type"); */
|
/* elog(DEBUG, "ExecMarkPos: unsupported node type"); */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -385,21 +385,21 @@ ExecRestrPos(Plan * node)
|
|||||||
{
|
{
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
ExecSeqRestrPos((SeqScan *) node);
|
ExecSeqRestrPos((SeqScan *) node);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
ExecIndexRestrPos((IndexScan *) node);
|
ExecIndexRestrPos((IndexScan *) node);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
ExecSortRestrPos((Sort *) node);
|
ExecSortRestrPos((Sort *) node);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* elog(DEBUG, "ExecRestrPos: node type not supported"); */
|
/* elog(DEBUG, "ExecRestrPos: node type not supported"); */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ Relation
|
|||||||
ExecCreatR(TupleDesc tupType,
|
ExecCreatR(TupleDesc tupType,
|
||||||
Oid relationOid)
|
Oid relationOid)
|
||||||
{
|
{
|
||||||
Relation relDesc;
|
Relation relDesc;
|
||||||
|
|
||||||
EU3_printf("ExecCreatR: %s type=%d oid=%d\n",
|
EU3_printf("ExecCreatR: %s type=%d oid=%d\n",
|
||||||
"entering: ", tupType, relationOid);
|
"entering: ", tupType, relationOid);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.3 1997/09/07 04:41:12 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.4 1997/09/08 02:22:25 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -45,7 +45,7 @@ ExecEvalIter(Iter * iterNode,
|
|||||||
bool * resultIsNull,
|
bool * resultIsNull,
|
||||||
bool * iterIsDone)
|
bool * iterIsDone)
|
||||||
{
|
{
|
||||||
Node *expression;
|
Node *expression;
|
||||||
|
|
||||||
expression = iterNode->iterexpr;
|
expression = iterNode->iterexpr;
|
||||||
|
|
||||||
@@ -66,13 +66,13 @@ ExecEvalFjoin(TargetEntry * tlist,
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef SETS_FIXED
|
#ifdef SETS_FIXED
|
||||||
bool isDone;
|
bool isDone;
|
||||||
int curNode;
|
int curNode;
|
||||||
List *tlistP;
|
List *tlistP;
|
||||||
|
|
||||||
Fjoin *fjNode = tlist->fjoin;
|
Fjoin *fjNode = tlist->fjoin;
|
||||||
DatumPtr resVect = fjNode->fj_results;
|
DatumPtr resVect = fjNode->fj_results;
|
||||||
BoolPtr alwaysDone = fjNode->fj_alwaysDone;
|
BoolPtr alwaysDone = fjNode->fj_alwaysDone;
|
||||||
|
|
||||||
if (fj_isDone)
|
if (fj_isDone)
|
||||||
*fj_isDone = false;
|
*fj_isDone = false;
|
||||||
@@ -90,7 +90,7 @@ ExecEvalFjoin(TargetEntry * tlist,
|
|||||||
curNode = 1;
|
curNode = 1;
|
||||||
foreach(tlistP, lnext(tlist))
|
foreach(tlistP, lnext(tlist))
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(tlistP);
|
TargetEntry *tle = lfirst(tlistP);
|
||||||
|
|
||||||
resVect[curNode] = ExecEvalIter((Iter *) tle->expr,
|
resVect[curNode] = ExecEvalIter((Iter *) tle->expr,
|
||||||
econtext,
|
econtext,
|
||||||
@@ -181,19 +181,19 @@ ExecEvalFjoin(TargetEntry * tlist,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SETS_FIXED
|
#ifdef SETS_FIXED
|
||||||
static bool
|
static bool
|
||||||
FjoinBumpOuterNodes(TargetEntry * tlist,
|
FjoinBumpOuterNodes(TargetEntry * tlist,
|
||||||
ExprContext * econtext,
|
ExprContext * econtext,
|
||||||
DatumPtr results,
|
DatumPtr results,
|
||||||
char *nulls)
|
char *nulls)
|
||||||
{
|
{
|
||||||
bool funcIsDone = true;
|
bool funcIsDone = true;
|
||||||
Fjoin *fjNode = tlist->fjoin;
|
Fjoin *fjNode = tlist->fjoin;
|
||||||
char *alwaysDone = fjNode->fj_alwaysDone;
|
char *alwaysDone = fjNode->fj_alwaysDone;
|
||||||
List *outerList = lnext(tlist);
|
List *outerList = lnext(tlist);
|
||||||
List *trailers = lnext(tlist);
|
List *trailers = lnext(tlist);
|
||||||
int trailNode = 1;
|
int trailNode = 1;
|
||||||
int curNode = 1;
|
int curNode = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run through list of functions until we get to one that isn't yet
|
* Run through list of functions until we get to one that isn't yet
|
||||||
@@ -201,7 +201,7 @@ FjoinBumpOuterNodes(TargetEntry * tlist,
|
|||||||
*/
|
*/
|
||||||
while ((funcIsDone == true) && (outerList != NIL))
|
while ((funcIsDone == true) && (outerList != NIL))
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(outerList);
|
TargetEntry *tle = lfirst(outerList);
|
||||||
|
|
||||||
if (alwaysDone[curNode] == true)
|
if (alwaysDone[curNode] == true)
|
||||||
nulls[curNode] = 'n';
|
nulls[curNode] = 'n';
|
||||||
@@ -232,7 +232,7 @@ FjoinBumpOuterNodes(TargetEntry * tlist,
|
|||||||
trailNode = 1;
|
trailNode = 1;
|
||||||
while (trailNode != curNode - 1)
|
while (trailNode != curNode - 1)
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(trailers);
|
TargetEntry *tle = lfirst(trailers);
|
||||||
|
|
||||||
if (alwaysDone[trailNode] != true)
|
if (alwaysDone[trailNode] != true)
|
||||||
results[trailNode] = ExecEvalIter((Iter) tle->expr,
|
results[trailNode] = ExecEvalIter((Iter) tle->expr,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.6 1997/09/07 04:41:14 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.7 1997/09/08 02:22:27 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -60,24 +60,24 @@
|
|||||||
* Initialize the Junk filter.
|
* Initialize the Junk filter.
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
JunkFilter *
|
JunkFilter *
|
||||||
ExecInitJunkFilter(List * targetList)
|
ExecInitJunkFilter(List * targetList)
|
||||||
{
|
{
|
||||||
JunkFilter *junkfilter;
|
JunkFilter *junkfilter;
|
||||||
List *cleanTargetList;
|
List *cleanTargetList;
|
||||||
int len,
|
int len,
|
||||||
cleanLength;
|
cleanLength;
|
||||||
TupleDesc tupType,
|
TupleDesc tupType,
|
||||||
cleanTupType;
|
cleanTupType;
|
||||||
List *t;
|
List *t;
|
||||||
TargetEntry *tle;
|
TargetEntry *tle;
|
||||||
Resdom *resdom,
|
Resdom *resdom,
|
||||||
*cleanResdom;
|
*cleanResdom;
|
||||||
int resjunk;
|
int resjunk;
|
||||||
AttrNumber cleanResno;
|
AttrNumber cleanResno;
|
||||||
AttrNumber *cleanMap;
|
AttrNumber *cleanMap;
|
||||||
Size size;
|
Size size;
|
||||||
Node *expr;
|
Node *expr;
|
||||||
|
|
||||||
/* ---------------------
|
/* ---------------------
|
||||||
* First find the "clean" target list, i.e. all the entries
|
* First find the "clean" target list, i.e. all the entries
|
||||||
@@ -91,7 +91,7 @@ ExecInitJunkFilter(List * targetList)
|
|||||||
|
|
||||||
foreach(t, targetList)
|
foreach(t, targetList)
|
||||||
{
|
{
|
||||||
TargetEntry *rtarget = lfirst(t);
|
TargetEntry *rtarget = lfirst(t);
|
||||||
|
|
||||||
if (rtarget->resdom != NULL)
|
if (rtarget->resdom != NULL)
|
||||||
{
|
{
|
||||||
@@ -120,11 +120,11 @@ ExecInitJunkFilter(List * targetList)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef SETS_FIXED
|
#ifdef SETS_FIXED
|
||||||
List *fjListP;
|
List *fjListP;
|
||||||
Fjoin *cleanFjoin;
|
Fjoin *cleanFjoin;
|
||||||
List *cleanFjList;
|
List *cleanFjList;
|
||||||
List *fjList = lfirst(t);
|
List *fjList = lfirst(t);
|
||||||
Fjoin *fjNode = (Fjoin *) tl_node(fjList);
|
Fjoin *fjNode = (Fjoin *) tl_node(fjList);
|
||||||
|
|
||||||
cleanFjoin = (Fjoin) copyObject((Node) fjNode);
|
cleanFjoin = (Fjoin) copyObject((Node) fjNode);
|
||||||
cleanFjList = lcons(cleanFjoin, NIL);
|
cleanFjList = lcons(cleanFjoin, NIL);
|
||||||
@@ -139,7 +139,7 @@ ExecInitJunkFilter(List * targetList)
|
|||||||
|
|
||||||
foreach(fjListP, lnext(fjList))
|
foreach(fjListP, lnext(fjList))
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(fjListP);
|
TargetEntry *tle = lfirst(fjListP);
|
||||||
|
|
||||||
resdom = tle->resdom;
|
resdom = tle->resdom;
|
||||||
expr = tle->expr;
|
expr = tle->expr;
|
||||||
@@ -189,7 +189,7 @@ ExecInitJunkFilter(List * targetList)
|
|||||||
cleanResno = 1;
|
cleanResno = 1;
|
||||||
foreach(t, targetList)
|
foreach(t, targetList)
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(t);
|
TargetEntry *tle = lfirst(t);
|
||||||
|
|
||||||
if (tle->resdom != NULL)
|
if (tle->resdom != NULL)
|
||||||
{
|
{
|
||||||
@@ -205,9 +205,9 @@ ExecInitJunkFilter(List * targetList)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef SETS_FIXED
|
#ifdef SETS_FIXED
|
||||||
List fjListP;
|
List fjListP;
|
||||||
List fjList = lfirst(t);
|
List fjList = lfirst(t);
|
||||||
Fjoin fjNode = (Fjoin) lfirst(fjList);
|
Fjoin fjNode = (Fjoin) lfirst(fjList);
|
||||||
|
|
||||||
/* what the hell is this????? */
|
/* what the hell is this????? */
|
||||||
resdom = (Resdom) lfirst(get_fj_innerNode(fjNode));
|
resdom = (Resdom) lfirst(get_fj_innerNode(fjNode));
|
||||||
@@ -219,7 +219,7 @@ ExecInitJunkFilter(List * targetList)
|
|||||||
#ifdef SETS_FIXED
|
#ifdef SETS_FIXED
|
||||||
foreach(fjListP, lnext(fjList))
|
foreach(fjListP, lnext(fjList))
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(fjListP);
|
TargetEntry *tle = lfirst(fjListP);
|
||||||
|
|
||||||
resdom = tle->resdom;
|
resdom = tle->resdom;
|
||||||
cleanMap[cleanResno - 1] = resdom->resno;
|
cleanMap[cleanResno - 1] = resdom->resno;
|
||||||
@@ -270,14 +270,14 @@ ExecGetJunkAttribute(JunkFilter * junkfilter,
|
|||||||
Datum * value,
|
Datum * value,
|
||||||
bool * isNull)
|
bool * isNull)
|
||||||
{
|
{
|
||||||
List *targetList;
|
List *targetList;
|
||||||
List *t;
|
List *t;
|
||||||
Resdom *resdom;
|
Resdom *resdom;
|
||||||
AttrNumber resno;
|
AttrNumber resno;
|
||||||
char *resname;
|
char *resname;
|
||||||
int resjunk;
|
int resjunk;
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
/* ---------------------
|
/* ---------------------
|
||||||
* first look in the junkfilter's target list for
|
* first look in the junkfilter's target list for
|
||||||
@@ -289,7 +289,7 @@ ExecGetJunkAttribute(JunkFilter * junkfilter,
|
|||||||
|
|
||||||
foreach(t, targetList)
|
foreach(t, targetList)
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(t);
|
TargetEntry *tle = lfirst(t);
|
||||||
|
|
||||||
resdom = tle->resdom;
|
resdom = tle->resdom;
|
||||||
resname = resdom->resname;
|
resname = resdom->resname;
|
||||||
@@ -330,19 +330,19 @@ ExecGetJunkAttribute(JunkFilter * junkfilter,
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot)
|
ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
HeapTuple cleanTuple;
|
HeapTuple cleanTuple;
|
||||||
AttrNumber *cleanMap;
|
AttrNumber *cleanMap;
|
||||||
TupleDesc cleanTupType;
|
TupleDesc cleanTupType;
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
int cleanLength;
|
int cleanLength;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
int i;
|
int i;
|
||||||
Size size;
|
Size size;
|
||||||
Datum *values;
|
Datum *values;
|
||||||
char *nulls;
|
char *nulls;
|
||||||
Datum values_array[64];
|
Datum values_array[64];
|
||||||
char nulls_array[64];
|
char nulls_array[64];
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get info from the slot and the junk filter
|
* get info from the slot and the junk filter
|
||||||
@@ -391,7 +391,7 @@ ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < cleanLength; i++)
|
for (i = 0; i < cleanLength; i++)
|
||||||
{
|
{
|
||||||
Datum d = (Datum)
|
Datum d = (Datum)
|
||||||
heap_getattr(tuple, InvalidBuffer, cleanMap[i], tupType, &isNull);
|
heap_getattr(tuple, InvalidBuffer, cleanMap[i], tupType, &isNull);
|
||||||
|
|
||||||
values[i] = d;
|
values[i] = d;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.23 1997/09/07 04:41:18 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.24 1997/09/08 02:22:28 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -62,14 +62,14 @@ ExecCheckPerms(CmdType operation, int resultRelation, List * rangeTable,
|
|||||||
static TupleDesc
|
static TupleDesc
|
||||||
InitPlan(CmdType operation, Query * parseTree,
|
InitPlan(CmdType operation, Query * parseTree,
|
||||||
Plan * plan, EState * estate);
|
Plan * plan, EState * estate);
|
||||||
static void EndPlan(Plan * plan, EState * estate);
|
static void EndPlan(Plan * plan, EState * estate);
|
||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
ExecutePlan(EState * estate, Plan * plan,
|
ExecutePlan(EState * estate, Plan * plan,
|
||||||
Query * parseTree, CmdType operation,
|
Query * parseTree, CmdType operation,
|
||||||
int numberTuples, ScanDirection direction,
|
int numberTuples, ScanDirection direction,
|
||||||
void (*printfunc) ());
|
void (*printfunc) ());
|
||||||
static void ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (),
|
static void ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (),
|
||||||
EState * estate);
|
EState * estate);
|
||||||
static void
|
static void
|
||||||
ExecAppend(TupleTableSlot * slot, ItemPointer tupleid,
|
ExecAppend(TupleTableSlot * slot, ItemPointer tupleid,
|
||||||
EState * estate);
|
EState * estate);
|
||||||
@@ -83,7 +83,7 @@ ExecReplace(TupleTableSlot * slot, ItemPointer tupleid,
|
|||||||
/* end of local decls */
|
/* end of local decls */
|
||||||
|
|
||||||
#ifdef QUERY_LIMIT
|
#ifdef QUERY_LIMIT
|
||||||
static int queryLimit = ALL_TUPLES;
|
static int queryLimit = ALL_TUPLES;
|
||||||
|
|
||||||
#undef ALL_TUPLES
|
#undef ALL_TUPLES
|
||||||
#define ALL_TUPLES queryLimit
|
#define ALL_TUPLES queryLimit
|
||||||
@@ -112,7 +112,7 @@ ExecutorLimit(int limit)
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
ExecutorStart(QueryDesc * queryDesc, EState * estate)
|
ExecutorStart(QueryDesc * queryDesc, EState * estate)
|
||||||
{
|
{
|
||||||
TupleDesc result;
|
TupleDesc result;
|
||||||
|
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
Assert(queryDesc != NULL);
|
Assert(queryDesc != NULL);
|
||||||
@@ -157,12 +157,12 @@ ExecutorStart(QueryDesc * queryDesc, EState * estate)
|
|||||||
TupleTableSlot *
|
TupleTableSlot *
|
||||||
ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count)
|
ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count)
|
||||||
{
|
{
|
||||||
CmdType operation;
|
CmdType operation;
|
||||||
Query *parseTree;
|
Query *parseTree;
|
||||||
Plan *plan;
|
Plan *plan;
|
||||||
TupleTableSlot *result;
|
TupleTableSlot *result;
|
||||||
CommandDest dest;
|
CommandDest dest;
|
||||||
void (*destination) ();
|
void (*destination) ();
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -200,7 +200,7 @@ ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count)
|
|||||||
if ((nodeTag(plan) == T_IndexScan) &&
|
if ((nodeTag(plan) == T_IndexScan) &&
|
||||||
(((IndexScan *) plan)->indxstate->iss_RuntimeKeyInfo != NULL))
|
(((IndexScan *) plan)->indxstate->iss_RuntimeKeyInfo != NULL))
|
||||||
{
|
{
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
|
|
||||||
econtext = ((IndexScan *) plan)->scan.scanstate->cstate.cs_ExprContext;
|
econtext = ((IndexScan *) plan)->scan.scanstate->cstate.cs_ExprContext;
|
||||||
ExecIndexReScan((IndexScan *) plan, econtext, plan);
|
ExecIndexReScan((IndexScan *) plan, econtext, plan);
|
||||||
@@ -211,57 +211,57 @@ ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count)
|
|||||||
switch (feature)
|
switch (feature)
|
||||||
{
|
{
|
||||||
|
|
||||||
case EXEC_RUN:
|
case EXEC_RUN:
|
||||||
result = ExecutePlan(estate,
|
result = ExecutePlan(estate,
|
||||||
plan,
|
plan,
|
||||||
parseTree,
|
parseTree,
|
||||||
operation,
|
operation,
|
||||||
ALL_TUPLES,
|
ALL_TUPLES,
|
||||||
ForwardScanDirection,
|
ForwardScanDirection,
|
||||||
destination);
|
destination);
|
||||||
break;
|
break;
|
||||||
case EXEC_FOR:
|
case EXEC_FOR:
|
||||||
result = ExecutePlan(estate,
|
result = ExecutePlan(estate,
|
||||||
plan,
|
plan,
|
||||||
parseTree,
|
parseTree,
|
||||||
operation,
|
operation,
|
||||||
count,
|
count,
|
||||||
ForwardScanDirection,
|
ForwardScanDirection,
|
||||||
destination);
|
destination);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* retrieve next n "backward" tuples
|
* retrieve next n "backward" tuples
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case EXEC_BACK:
|
case EXEC_BACK:
|
||||||
result = ExecutePlan(estate,
|
result = ExecutePlan(estate,
|
||||||
plan,
|
plan,
|
||||||
parseTree,
|
parseTree,
|
||||||
operation,
|
operation,
|
||||||
count,
|
count,
|
||||||
BackwardScanDirection,
|
BackwardScanDirection,
|
||||||
destination);
|
destination);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* return one tuple but don't "retrieve" it.
|
* return one tuple but don't "retrieve" it.
|
||||||
* (this is used by the rule manager..) -cim 9/14/89
|
* (this is used by the rule manager..) -cim 9/14/89
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case EXEC_RETONE:
|
case EXEC_RETONE:
|
||||||
result = ExecutePlan(estate,
|
result = ExecutePlan(estate,
|
||||||
plan,
|
plan,
|
||||||
parseTree,
|
parseTree,
|
||||||
operation,
|
operation,
|
||||||
ONE_TUPLE,
|
ONE_TUPLE,
|
||||||
ForwardScanDirection,
|
ForwardScanDirection,
|
||||||
destination);
|
destination);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = NULL;
|
result = NULL;
|
||||||
elog(DEBUG, "ExecutorRun: Unknown feature %d", feature);
|
elog(DEBUG, "ExecutorRun: Unknown feature %d", feature);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -303,17 +303,17 @@ ExecCheckPerms(CmdType operation,
|
|||||||
List * rangeTable,
|
List * rangeTable,
|
||||||
Query * parseTree)
|
Query * parseTree)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
HeapTuple htp;
|
HeapTuple htp;
|
||||||
List *lp;
|
List *lp;
|
||||||
List *qvars,
|
List *qvars,
|
||||||
*tvars;
|
*tvars;
|
||||||
int32 ok = 1,
|
int32 ok = 1,
|
||||||
aclcheck_result = -1;
|
aclcheck_result = -1;
|
||||||
char *opstr;
|
char *opstr;
|
||||||
NameData rname;
|
NameData rname;
|
||||||
char *userName;
|
char *userName;
|
||||||
|
|
||||||
#define CHECK(MODE) pg_aclcheck(rname.data, userName, MODE)
|
#define CHECK(MODE) pg_aclcheck(rname.data, userName, MODE)
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ ExecCheckPerms(CmdType operation,
|
|||||||
|
|
||||||
foreach(lp, rangeTable)
|
foreach(lp, rangeTable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = lfirst(lp);
|
RangeTblEntry *rte = lfirst(lp);
|
||||||
|
|
||||||
relid = rte->relid;
|
relid = rte->relid;
|
||||||
htp = SearchSysCacheTuple(RELOID,
|
htp = SearchSysCacheTuple(RELOID,
|
||||||
@@ -348,20 +348,21 @@ ExecCheckPerms(CmdType operation,
|
|||||||
}
|
}
|
||||||
switch (operation)
|
switch (operation)
|
||||||
{
|
{
|
||||||
case CMD_INSERT:
|
case CMD_INSERT:
|
||||||
ok = ((aclcheck_result = CHECK(ACL_AP)) == ACLCHECK_OK) ||
|
ok = ((aclcheck_result = CHECK(ACL_AP)) == ACLCHECK_OK) ||
|
||||||
((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK);
|
((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK);
|
||||||
opstr = "append";
|
opstr = "append";
|
||||||
break;
|
break;
|
||||||
case CMD_NOTIFY: /* what does this mean?? -- jw, 1/6/94 */
|
case CMD_NOTIFY: /* what does this mean?? -- jw,
|
||||||
case CMD_DELETE:
|
* 1/6/94 */
|
||||||
case CMD_UPDATE:
|
case CMD_DELETE:
|
||||||
ok = ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK);
|
case CMD_UPDATE:
|
||||||
opstr = "write";
|
ok = ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK);
|
||||||
break;
|
opstr = "write";
|
||||||
default:
|
break;
|
||||||
elog(WARN, "ExecCheckPerms: bogus operation %d",
|
default:
|
||||||
operation);
|
elog(WARN, "ExecCheckPerms: bogus operation %d",
|
||||||
|
operation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -388,16 +389,16 @@ ExecCheckPerms(CmdType operation,
|
|||||||
* and start up the rule manager
|
* and start up the rule manager
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static TupleDesc
|
static TupleDesc
|
||||||
InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate)
|
InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate)
|
||||||
{
|
{
|
||||||
List *rangeTable;
|
List *rangeTable;
|
||||||
int resultRelation;
|
int resultRelation;
|
||||||
Relation intoRelationDesc;
|
Relation intoRelationDesc;
|
||||||
|
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
List *targetList;
|
List *targetList;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get information from query descriptor
|
* get information from query descriptor
|
||||||
@@ -434,11 +435,11 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate)
|
|||||||
* initialize the result relation info stuff.
|
* initialize the result relation info stuff.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
RelationInfo *resultRelationInfo;
|
RelationInfo *resultRelationInfo;
|
||||||
Index resultRelationIndex;
|
Index resultRelationIndex;
|
||||||
RangeTblEntry *rtentry;
|
RangeTblEntry *rtentry;
|
||||||
Oid resultRelationOid;
|
Oid resultRelationOid;
|
||||||
Relation resultRelationDesc;
|
Relation resultRelationDesc;
|
||||||
|
|
||||||
resultRelationIndex = resultRelation;
|
resultRelationIndex = resultRelation;
|
||||||
rtentry = rt_fetch(resultRelationIndex, rangeTable);
|
rtentry = rt_fetch(resultRelationIndex, rangeTable);
|
||||||
@@ -492,8 +493,8 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate)
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int nSlots = ExecCountSlotsNode(plan);
|
int nSlots = ExecCountSlotsNode(plan);
|
||||||
TupleTable tupleTable = ExecCreateTupleTable(nSlots + 10); /* why add ten? - jolly */
|
TupleTable tupleTable = ExecCreateTupleTable(nSlots + 10); /* why add ten? - jolly */
|
||||||
|
|
||||||
estate->es_tupleTable = tupleTable;
|
estate->es_tupleTable = tupleTable;
|
||||||
}
|
}
|
||||||
@@ -530,7 +531,7 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate)
|
|||||||
operation == CMD_INSERT)
|
operation == CMD_INSERT)
|
||||||
{
|
{
|
||||||
|
|
||||||
JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
|
JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
|
||||||
|
|
||||||
estate->es_junkFilter = j;
|
estate->es_junkFilter = j;
|
||||||
}
|
}
|
||||||
@@ -545,10 +546,10 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate)
|
|||||||
|
|
||||||
if (operation == CMD_SELECT)
|
if (operation == CMD_SELECT)
|
||||||
{
|
{
|
||||||
char *intoName;
|
char *intoName;
|
||||||
char archiveMode;
|
char archiveMode;
|
||||||
Oid intoRelationId;
|
Oid intoRelationId;
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
|
|
||||||
if (!parseTree->isPortal)
|
if (!parseTree->isPortal)
|
||||||
{
|
{
|
||||||
@@ -626,8 +627,8 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate)
|
|||||||
static void
|
static void
|
||||||
EndPlan(Plan * plan, EState * estate)
|
EndPlan(Plan * plan, EState * estate)
|
||||||
{
|
{
|
||||||
RelationInfo *resultRelationInfo;
|
RelationInfo *resultRelationInfo;
|
||||||
Relation intoRelationDesc;
|
Relation intoRelationDesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get information from state
|
* get information from state
|
||||||
@@ -647,7 +648,7 @@ EndPlan(Plan * plan, EState * estate)
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
TupleTable tupleTable = (TupleTable) estate->es_tupleTable;
|
TupleTable tupleTable = (TupleTable) estate->es_tupleTable;
|
||||||
|
|
||||||
ExecDestroyTupleTable(tupleTable, true); /* was missing last arg */
|
ExecDestroyTupleTable(tupleTable, true); /* was missing last arg */
|
||||||
estate->es_tupleTable = NULL;
|
estate->es_tupleTable = NULL;
|
||||||
@@ -659,7 +660,7 @@ EndPlan(Plan * plan, EState * estate)
|
|||||||
*/
|
*/
|
||||||
if (resultRelationInfo != NULL)
|
if (resultRelationInfo != NULL)
|
||||||
{
|
{
|
||||||
Relation resultRelationDesc;
|
Relation resultRelationDesc;
|
||||||
|
|
||||||
resultRelationDesc = resultRelationInfo->ri_RelationDesc;
|
resultRelationDesc = resultRelationInfo->ri_RelationDesc;
|
||||||
heap_close(resultRelationDesc);
|
heap_close(resultRelationDesc);
|
||||||
@@ -706,12 +707,12 @@ ExecutePlan(EState * estate,
|
|||||||
ScanDirection direction,
|
ScanDirection direction,
|
||||||
void (*printfunc) ())
|
void (*printfunc) ())
|
||||||
{
|
{
|
||||||
JunkFilter *junkfilter;
|
JunkFilter *junkfilter;
|
||||||
|
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
ItemPointer tupleid = NULL;
|
ItemPointer tupleid = NULL;
|
||||||
ItemPointerData tuple_ctid;
|
ItemPointerData tuple_ctid;
|
||||||
int current_tuple_count;
|
int current_tuple_count;
|
||||||
TupleTableSlot *result;
|
TupleTableSlot *result;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -770,11 +771,11 @@ ExecutePlan(EState * estate,
|
|||||||
*/
|
*/
|
||||||
if ((junkfilter = estate->es_junkFilter) != (JunkFilter *) NULL)
|
if ((junkfilter = estate->es_junkFilter) != (JunkFilter *) NULL)
|
||||||
{
|
{
|
||||||
Datum datum;
|
Datum datum;
|
||||||
|
|
||||||
/* NameData attrName; */
|
/* NameData attrName; */
|
||||||
HeapTuple newTuple;
|
HeapTuple newTuple;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
||||||
/* ---------------
|
/* ---------------
|
||||||
* extract the 'ctid' junk attribute.
|
* extract the 'ctid' junk attribute.
|
||||||
@@ -822,50 +823,50 @@ ExecutePlan(EState * estate,
|
|||||||
|
|
||||||
switch (operation)
|
switch (operation)
|
||||||
{
|
{
|
||||||
case CMD_SELECT:
|
case CMD_SELECT:
|
||||||
ExecRetrieve(slot, /* slot containing tuple */
|
ExecRetrieve(slot, /* slot containing tuple */
|
||||||
printfunc, /* print function */
|
printfunc, /* print function */
|
||||||
estate); /* */
|
estate); /* */
|
||||||
result = slot;
|
result = slot;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_INSERT:
|
case CMD_INSERT:
|
||||||
ExecAppend(slot, tupleid, estate);
|
ExecAppend(slot, tupleid, estate);
|
||||||
result = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CMD_DELETE:
|
|
||||||
ExecDelete(slot, tupleid, estate);
|
|
||||||
result = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CMD_UPDATE:
|
|
||||||
ExecReplace(slot, tupleid, estate, parseTree);
|
|
||||||
result = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Total hack. I'm ignoring any accessor functions for
|
|
||||||
* Relation, RelationTupleForm, NameData. Assuming that
|
|
||||||
* NameData.data has offset 0.
|
|
||||||
*/
|
|
||||||
case CMD_NOTIFY:
|
|
||||||
{
|
|
||||||
RelationInfo *rInfo = estate->es_result_relation_info;
|
|
||||||
Relation rDesc = rInfo->ri_RelationDesc;
|
|
||||||
|
|
||||||
Async_Notify(rDesc->rd_rel->relname.data);
|
|
||||||
result = NULL;
|
result = NULL;
|
||||||
current_tuple_count = 0;
|
break;
|
||||||
numberTuples = 1;
|
|
||||||
elog(DEBUG, "ExecNotify %s", &rDesc->rd_rel->relname);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case CMD_DELETE:
|
||||||
elog(DEBUG, "ExecutePlan: unknown operation in queryDesc");
|
ExecDelete(slot, tupleid, estate);
|
||||||
result = NULL;
|
result = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CMD_UPDATE:
|
||||||
|
ExecReplace(slot, tupleid, estate, parseTree);
|
||||||
|
result = NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Total hack. I'm ignoring any accessor functions for
|
||||||
|
* Relation, RelationTupleForm, NameData. Assuming that
|
||||||
|
* NameData.data has offset 0.
|
||||||
|
*/
|
||||||
|
case CMD_NOTIFY:
|
||||||
|
{
|
||||||
|
RelationInfo *rInfo = estate->es_result_relation_info;
|
||||||
|
Relation rDesc = rInfo->ri_RelationDesc;
|
||||||
|
|
||||||
|
Async_Notify(rDesc->rd_rel->relname.data);
|
||||||
|
result = NULL;
|
||||||
|
current_tuple_count = 0;
|
||||||
|
numberTuples = 1;
|
||||||
|
elog(DEBUG, "ExecNotify %s", &rDesc->rd_rel->relname);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
elog(DEBUG, "ExecutePlan: unknown operation in queryDesc");
|
||||||
|
result = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* check our tuple count.. if we've returned the
|
* check our tuple count.. if we've returned the
|
||||||
@@ -901,8 +902,8 @@ ExecRetrieve(TupleTableSlot * slot,
|
|||||||
void (*printfunc) (),
|
void (*printfunc) (),
|
||||||
EState * estate)
|
EState * estate)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
TupleDesc attrtype;
|
TupleDesc attrtype;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the heap tuple out of the tuple table slot
|
* get the heap tuple out of the tuple table slot
|
||||||
@@ -944,11 +945,11 @@ ExecAppend(TupleTableSlot * slot,
|
|||||||
ItemPointer tupleid,
|
ItemPointer tupleid,
|
||||||
EState * estate)
|
EState * estate)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
RelationInfo *resultRelationInfo;
|
RelationInfo *resultRelationInfo;
|
||||||
Relation resultRelationDesc;
|
Relation resultRelationDesc;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
Oid newId;
|
Oid newId;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the heap tuple out of the tuple table slot
|
* get the heap tuple out of the tuple table slot
|
||||||
@@ -973,7 +974,7 @@ ExecAppend(TupleTableSlot * slot,
|
|||||||
if (resultRelationDesc->trigdesc &&
|
if (resultRelationDesc->trigdesc &&
|
||||||
resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
|
resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
|
||||||
{
|
{
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
|
|
||||||
newtuple = ExecBRInsertTriggers(resultRelationDesc, tuple);
|
newtuple = ExecBRInsertTriggers(resultRelationDesc, tuple);
|
||||||
|
|
||||||
@@ -995,7 +996,7 @@ ExecAppend(TupleTableSlot * slot,
|
|||||||
|
|
||||||
if (resultRelationDesc->rd_att->constr)
|
if (resultRelationDesc->rd_att->constr)
|
||||||
{
|
{
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
|
|
||||||
newtuple = ExecConstraints("ExecAppend", resultRelationDesc, tuple);
|
newtuple = ExecConstraints("ExecAppend", resultRelationDesc, tuple);
|
||||||
|
|
||||||
@@ -1049,8 +1050,8 @@ ExecDelete(TupleTableSlot * slot,
|
|||||||
ItemPointer tupleid,
|
ItemPointer tupleid,
|
||||||
EState * estate)
|
EState * estate)
|
||||||
{
|
{
|
||||||
RelationInfo *resultRelationInfo;
|
RelationInfo *resultRelationInfo;
|
||||||
Relation resultRelationDesc;
|
Relation resultRelationDesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the result relation information
|
* get the result relation information
|
||||||
@@ -1063,7 +1064,7 @@ ExecDelete(TupleTableSlot * slot,
|
|||||||
if (resultRelationDesc->trigdesc &&
|
if (resultRelationDesc->trigdesc &&
|
||||||
resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_DELETE] > 0)
|
resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_DELETE] > 0)
|
||||||
{
|
{
|
||||||
bool dodelete;
|
bool dodelete;
|
||||||
|
|
||||||
dodelete = ExecBRDeleteTriggers(resultRelationDesc, tupleid);
|
dodelete = ExecBRDeleteTriggers(resultRelationDesc, tupleid);
|
||||||
|
|
||||||
@@ -1118,10 +1119,10 @@ ExecReplace(TupleTableSlot * slot,
|
|||||||
EState * estate,
|
EState * estate,
|
||||||
Query * parseTree)
|
Query * parseTree)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
RelationInfo *resultRelationInfo;
|
RelationInfo *resultRelationInfo;
|
||||||
Relation resultRelationDesc;
|
Relation resultRelationDesc;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* abort the operation if not running transactions
|
* abort the operation if not running transactions
|
||||||
@@ -1158,7 +1159,7 @@ ExecReplace(TupleTableSlot * slot,
|
|||||||
if (resultRelationDesc->trigdesc &&
|
if (resultRelationDesc->trigdesc &&
|
||||||
resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0)
|
resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0)
|
||||||
{
|
{
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
|
|
||||||
newtuple = ExecBRUpdateTriggers(resultRelationDesc, tupleid, tuple);
|
newtuple = ExecBRUpdateTriggers(resultRelationDesc, tupleid, tuple);
|
||||||
|
|
||||||
@@ -1180,7 +1181,7 @@ ExecReplace(TupleTableSlot * slot,
|
|||||||
|
|
||||||
if (resultRelationDesc->rd_att->constr)
|
if (resultRelationDesc->rd_att->constr)
|
||||||
{
|
{
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
|
|
||||||
newtuple = ExecConstraints("ExecReplace", resultRelationDesc, tuple);
|
newtuple = ExecConstraints("ExecReplace", resultRelationDesc, tuple);
|
||||||
|
|
||||||
@@ -1244,21 +1245,21 @@ ExecReplace(TupleTableSlot * slot,
|
|||||||
ExecARUpdateTriggers(resultRelationDesc, tupleid, tuple);
|
ExecARUpdateTriggers(resultRelationDesc, tupleid, tuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HeapTuple
|
static HeapTuple
|
||||||
ExecAttrDefault(Relation rel, HeapTuple tuple)
|
ExecAttrDefault(Relation rel, HeapTuple tuple)
|
||||||
{
|
{
|
||||||
int ndef = rel->rd_att->constr->num_defval;
|
int ndef = rel->rd_att->constr->num_defval;
|
||||||
AttrDefault *attrdef = rel->rd_att->constr->defval;
|
AttrDefault *attrdef = rel->rd_att->constr->defval;
|
||||||
ExprContext *econtext = makeNode(ExprContext);
|
ExprContext *econtext = makeNode(ExprContext);
|
||||||
HeapTuple newtuple;
|
HeapTuple newtuple;
|
||||||
Node *expr;
|
Node *expr;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
bool isdone;
|
bool isdone;
|
||||||
Datum val;
|
Datum val;
|
||||||
Datum *replValue = NULL;
|
Datum *replValue = NULL;
|
||||||
char *replNull = NULL;
|
char *replNull = NULL;
|
||||||
char *repl = NULL;
|
char *repl = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
econtext->ecxt_scantuple = NULL; /* scan tuple slot */
|
econtext->ecxt_scantuple = NULL; /* scan tuple slot */
|
||||||
econtext->ecxt_innertuple = NULL; /* inner tuple slot */
|
econtext->ecxt_innertuple = NULL; /* inner tuple slot */
|
||||||
@@ -1309,18 +1310,18 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
ExecRelCheck(Relation rel, HeapTuple tuple)
|
ExecRelCheck(Relation rel, HeapTuple tuple)
|
||||||
{
|
{
|
||||||
int ncheck = rel->rd_att->constr->num_check;
|
int ncheck = rel->rd_att->constr->num_check;
|
||||||
ConstrCheck *check = rel->rd_att->constr->check;
|
ConstrCheck *check = rel->rd_att->constr->check;
|
||||||
ExprContext *econtext = makeNode(ExprContext);
|
ExprContext *econtext = makeNode(ExprContext);
|
||||||
TupleTableSlot *slot = makeNode(TupleTableSlot);
|
TupleTableSlot *slot = makeNode(TupleTableSlot);
|
||||||
RangeTblEntry *rte = makeNode(RangeTblEntry);
|
RangeTblEntry *rte = makeNode(RangeTblEntry);
|
||||||
List *rtlist;
|
List *rtlist;
|
||||||
List *qual;
|
List *qual;
|
||||||
bool res;
|
bool res;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
slot->val = tuple;
|
slot->val = tuple;
|
||||||
slot->ttc_shouldFree = false;
|
slot->ttc_shouldFree = false;
|
||||||
@@ -1370,7 +1371,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
|
|||||||
HeapTuple
|
HeapTuple
|
||||||
ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
|
ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
|
||||||
{
|
{
|
||||||
HeapTuple newtuple = tuple;
|
HeapTuple newtuple = tuple;
|
||||||
|
|
||||||
Assert(rel->rd_att->constr);
|
Assert(rel->rd_att->constr);
|
||||||
|
|
||||||
@@ -1379,7 +1380,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
|
|||||||
|
|
||||||
if (rel->rd_att->constr->has_not_null)
|
if (rel->rd_att->constr->has_not_null)
|
||||||
{
|
{
|
||||||
int attrChk;
|
int attrChk;
|
||||||
|
|
||||||
for (attrChk = 1; attrChk <= rel->rd_att->natts; attrChk++)
|
for (attrChk = 1; attrChk <= rel->rd_att->natts; attrChk++)
|
||||||
{
|
{
|
||||||
@@ -1391,7 +1392,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
|
|||||||
|
|
||||||
if (rel->rd_att->constr->num_check > 0)
|
if (rel->rd_att->constr->num_check > 0)
|
||||||
{
|
{
|
||||||
char *failed;
|
char *failed;
|
||||||
|
|
||||||
if ((failed = ExecRelCheck(rel, tuple)) != NULL)
|
if ((failed = ExecRelCheck(rel, tuple)) != NULL)
|
||||||
elog(WARN, "%s: rejected due to CHECK constraint %s", caller, failed);
|
elog(WARN, "%s: rejected due to CHECK constraint %s", caller, failed);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.3 1997/09/07 04:41:19 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.4 1997/09/08 02:22:30 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
bool
|
bool
|
||||||
ExecInitNode(Plan * node, EState * estate, Plan * parent)
|
ExecInitNode(Plan * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* do nothing when we get to the end
|
* do nothing when we get to the end
|
||||||
@@ -117,82 +117,82 @@ ExecInitNode(Plan * node, EState * estate, Plan * parent)
|
|||||||
|
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* control nodes
|
* control nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Result:
|
case T_Result:
|
||||||
result = ExecInitResult((Result *) node, estate, parent);
|
result = ExecInitResult((Result *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Append:
|
case T_Append:
|
||||||
result = ExecInitAppend((Append *) node, estate, parent);
|
result = ExecInitAppend((Append *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* scan nodes
|
* scan nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
result = ExecInitSeqScan((SeqScan *) node, estate, parent);
|
result = ExecInitSeqScan((SeqScan *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
result = ExecInitIndexScan((IndexScan *) node, estate, parent);
|
result = ExecInitIndexScan((IndexScan *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* join nodes
|
* join nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_NestLoop:
|
case T_NestLoop:
|
||||||
result = ExecInitNestLoop((NestLoop *) node, estate, parent);
|
result = ExecInitNestLoop((NestLoop *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_MergeJoin:
|
case T_MergeJoin:
|
||||||
result = ExecInitMergeJoin((MergeJoin *) node, estate, parent);
|
result = ExecInitMergeJoin((MergeJoin *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* materialization nodes
|
* materialization nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Material:
|
case T_Material:
|
||||||
result = ExecInitMaterial((Material *) node, estate, parent);
|
result = ExecInitMaterial((Material *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
result = ExecInitSort((Sort *) node, estate, parent);
|
result = ExecInitSort((Sort *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Unique:
|
case T_Unique:
|
||||||
result = ExecInitUnique((Unique *) node, estate, parent);
|
result = ExecInitUnique((Unique *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Group:
|
case T_Group:
|
||||||
result = ExecInitGroup((Group *) node, estate, parent);
|
result = ExecInitGroup((Group *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Agg:
|
case T_Agg:
|
||||||
result = ExecInitAgg((Agg *) node, estate, parent);
|
result = ExecInitAgg((Agg *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Hash:
|
case T_Hash:
|
||||||
result = ExecInitHash((Hash *) node, estate, parent);
|
result = ExecInitHash((Hash *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_HashJoin:
|
case T_HashJoin:
|
||||||
result = ExecInitHashJoin((HashJoin *) node, estate, parent);
|
result = ExecInitHashJoin((HashJoin *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Tee:
|
case T_Tee:
|
||||||
result = ExecInitTee((Tee *) node, estate, parent);
|
result = ExecInitTee((Tee *) node, estate, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(DEBUG, "ExecInitNode: node not yet supported: %d",
|
elog(DEBUG, "ExecInitNode: node not yet supported: %d",
|
||||||
nodeTag(node));
|
nodeTag(node));
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -220,82 +220,82 @@ ExecProcNode(Plan * node, Plan * parent)
|
|||||||
|
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* control nodes
|
* control nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Result:
|
case T_Result:
|
||||||
result = ExecResult((Result *) node);
|
result = ExecResult((Result *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Append:
|
case T_Append:
|
||||||
result = ExecProcAppend((Append *) node);
|
result = ExecProcAppend((Append *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* scan nodes
|
* scan nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
result = ExecSeqScan((SeqScan *) node);
|
result = ExecSeqScan((SeqScan *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
result = ExecIndexScan((IndexScan *) node);
|
result = ExecIndexScan((IndexScan *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* join nodes
|
* join nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_NestLoop:
|
case T_NestLoop:
|
||||||
result = ExecNestLoop((NestLoop *) node, parent);
|
result = ExecNestLoop((NestLoop *) node, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_MergeJoin:
|
case T_MergeJoin:
|
||||||
result = ExecMergeJoin((MergeJoin *) node);
|
result = ExecMergeJoin((MergeJoin *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* materialization nodes
|
* materialization nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Material:
|
case T_Material:
|
||||||
result = ExecMaterial((Material *) node);
|
result = ExecMaterial((Material *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
result = ExecSort((Sort *) node);
|
result = ExecSort((Sort *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Unique:
|
case T_Unique:
|
||||||
result = ExecUnique((Unique *) node);
|
result = ExecUnique((Unique *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Group:
|
case T_Group:
|
||||||
result = ExecGroup((Group *) node);
|
result = ExecGroup((Group *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Agg:
|
case T_Agg:
|
||||||
result = ExecAgg((Agg *) node);
|
result = ExecAgg((Agg *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Hash:
|
case T_Hash:
|
||||||
result = ExecHash((Hash *) node);
|
result = ExecHash((Hash *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_HashJoin:
|
case T_HashJoin:
|
||||||
result = ExecHashJoin((HashJoin *) node);
|
result = ExecHashJoin((HashJoin *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Tee:
|
case T_Tee:
|
||||||
result = ExecTee((Tee *) node, parent);
|
result = ExecTee((Tee *) node, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(DEBUG, "ExecProcNode: node not yet supported: %d",
|
elog(DEBUG, "ExecProcNode: node not yet supported: %d",
|
||||||
nodeTag(node));
|
nodeTag(node));
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -309,68 +309,68 @@ ExecCountSlotsNode(Plan * node)
|
|||||||
|
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* control nodes
|
* control nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Result:
|
case T_Result:
|
||||||
return ExecCountSlotsResult((Result *) node);
|
return ExecCountSlotsResult((Result *) node);
|
||||||
|
|
||||||
case T_Append:
|
case T_Append:
|
||||||
return ExecCountSlotsAppend((Append *) node);
|
return ExecCountSlotsAppend((Append *) node);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* scan nodes
|
* scan nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
return ExecCountSlotsSeqScan((SeqScan *) node);
|
return ExecCountSlotsSeqScan((SeqScan *) node);
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
return ExecCountSlotsIndexScan((IndexScan *) node);
|
return ExecCountSlotsIndexScan((IndexScan *) node);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* join nodes
|
* join nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_NestLoop:
|
case T_NestLoop:
|
||||||
return ExecCountSlotsNestLoop((NestLoop *) node);
|
return ExecCountSlotsNestLoop((NestLoop *) node);
|
||||||
|
|
||||||
case T_MergeJoin:
|
case T_MergeJoin:
|
||||||
return ExecCountSlotsMergeJoin((MergeJoin *) node);
|
return ExecCountSlotsMergeJoin((MergeJoin *) node);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* materialization nodes
|
* materialization nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Material:
|
case T_Material:
|
||||||
return ExecCountSlotsMaterial((Material *) node);
|
return ExecCountSlotsMaterial((Material *) node);
|
||||||
|
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
return ExecCountSlotsSort((Sort *) node);
|
return ExecCountSlotsSort((Sort *) node);
|
||||||
|
|
||||||
case T_Unique:
|
case T_Unique:
|
||||||
return ExecCountSlotsUnique((Unique *) node);
|
return ExecCountSlotsUnique((Unique *) node);
|
||||||
|
|
||||||
case T_Group:
|
case T_Group:
|
||||||
return ExecCountSlotsGroup((Group *) node);
|
return ExecCountSlotsGroup((Group *) node);
|
||||||
|
|
||||||
case T_Agg:
|
case T_Agg:
|
||||||
return ExecCountSlotsAgg((Agg *) node);
|
return ExecCountSlotsAgg((Agg *) node);
|
||||||
|
|
||||||
case T_Hash:
|
case T_Hash:
|
||||||
return ExecCountSlotsHash((Hash *) node);
|
return ExecCountSlotsHash((Hash *) node);
|
||||||
|
|
||||||
case T_HashJoin:
|
case T_HashJoin:
|
||||||
return ExecCountSlotsHashJoin((HashJoin *) node);
|
return ExecCountSlotsHashJoin((HashJoin *) node);
|
||||||
|
|
||||||
case T_Tee:
|
case T_Tee:
|
||||||
return ExecCountSlotsTee((Tee *) node);
|
return ExecCountSlotsTee((Tee *) node);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(WARN, "ExecCountSlotsNode: node not yet supported: %d",
|
elog(WARN, "ExecCountSlotsNode: node not yet supported: %d",
|
||||||
nodeTag(node));
|
nodeTag(node));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -399,85 +399,85 @@ ExecEndNode(Plan * node, Plan * parent)
|
|||||||
|
|
||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* control nodes
|
* control nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Result:
|
case T_Result:
|
||||||
ExecEndResult((Result *) node);
|
ExecEndResult((Result *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Append:
|
case T_Append:
|
||||||
ExecEndAppend((Append *) node);
|
ExecEndAppend((Append *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* scan nodes
|
* scan nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
ExecEndSeqScan((SeqScan *) node);
|
ExecEndSeqScan((SeqScan *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_IndexScan:
|
||||||
ExecEndIndexScan((IndexScan *) node);
|
ExecEndIndexScan((IndexScan *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* join nodes
|
* join nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_NestLoop:
|
case T_NestLoop:
|
||||||
ExecEndNestLoop((NestLoop *) node);
|
ExecEndNestLoop((NestLoop *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_MergeJoin:
|
case T_MergeJoin:
|
||||||
ExecEndMergeJoin((MergeJoin *) node);
|
ExecEndMergeJoin((MergeJoin *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* materialization nodes
|
* materialization nodes
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Material:
|
case T_Material:
|
||||||
ExecEndMaterial((Material *) node);
|
ExecEndMaterial((Material *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
ExecEndSort((Sort *) node);
|
ExecEndSort((Sort *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Unique:
|
case T_Unique:
|
||||||
ExecEndUnique((Unique *) node);
|
ExecEndUnique((Unique *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Group:
|
case T_Group:
|
||||||
ExecEndGroup((Group *) node);
|
ExecEndGroup((Group *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Agg:
|
case T_Agg:
|
||||||
ExecEndAgg((Agg *) node);
|
ExecEndAgg((Agg *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* XXX add hooks to these
|
* XXX add hooks to these
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
case T_Hash:
|
case T_Hash:
|
||||||
ExecEndHash((Hash *) node);
|
ExecEndHash((Hash *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_HashJoin:
|
case T_HashJoin:
|
||||||
ExecEndHashJoin((HashJoin *) node);
|
ExecEndHashJoin((HashJoin *) node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Tee:
|
case T_Tee:
|
||||||
ExecEndTee((Tee *) node, parent);
|
ExecEndTee((Tee *) node, parent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elog(DEBUG, "ExecEndNode: node not yet supported",
|
elog(DEBUG, "ExecEndNode: node not yet supported",
|
||||||
nodeTag(node));
|
nodeTag(node));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.13 1997/09/07 04:41:20 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.14 1997/09/08 02:22:33 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -65,31 +65,31 @@
|
|||||||
* Currently only used by ExecHashGetBucket and set only by ExecMakeVarConst
|
* Currently only used by ExecHashGetBucket and set only by ExecMakeVarConst
|
||||||
* and by ExecEvalArrayRef.
|
* and by ExecEvalArrayRef.
|
||||||
*/
|
*/
|
||||||
bool execConstByVal;
|
bool execConstByVal;
|
||||||
int execConstLen;
|
int execConstLen;
|
||||||
|
|
||||||
/* static functions decls */
|
/* static functions decls */
|
||||||
static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull);
|
static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull);
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalArrayRef(ArrayRef * arrayRef, ExprContext * econtext,
|
ExecEvalArrayRef(ArrayRef * arrayRef, ExprContext * econtext,
|
||||||
bool * isNull, bool * isDone);
|
bool * isNull, bool * isDone);
|
||||||
static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull);
|
static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull);
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalFunc(Expr * funcClause, ExprContext * econtext,
|
ExecEvalFunc(Expr * funcClause, ExprContext * econtext,
|
||||||
bool * isNull, bool * isDone);
|
bool * isNull, bool * isDone);
|
||||||
static void
|
static void
|
||||||
ExecEvalFuncArgs(FunctionCachePtr fcache, ExprContext * econtext,
|
ExecEvalFuncArgs(FunctionCachePtr fcache, ExprContext * econtext,
|
||||||
List * argList, Datum argV[], bool * argIsDone);
|
List * argList, Datum argV[], bool * argIsDone);
|
||||||
static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull);
|
static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull);
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalOper(Expr * opClause, ExprContext * econtext,
|
ExecEvalOper(Expr * opClause, ExprContext * econtext,
|
||||||
bool * isNull);
|
bool * isNull);
|
||||||
static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull);
|
static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull);
|
||||||
static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull);
|
static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull);
|
||||||
static Datum
|
static Datum
|
||||||
ExecMakeFunctionResult(Node * node, List * arguments,
|
ExecMakeFunctionResult(Node * node, List * arguments,
|
||||||
ExprContext * econtext, bool * isNull, bool * isDone);
|
ExprContext * econtext, bool * isNull, bool * isDone);
|
||||||
static bool ExecQualClause(Node * clause, ExprContext * econtext);
|
static bool ExecQualClause(Node * clause, ExprContext * econtext);
|
||||||
|
|
||||||
/* --------------------------------
|
/* --------------------------------
|
||||||
* ExecEvalArrayRef
|
* ExecEvalArrayRef
|
||||||
@@ -100,24 +100,24 @@ static bool ExecQualClause(Node * clause, ExprContext * econtext);
|
|||||||
*
|
*
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalArrayRef(ArrayRef * arrayRef,
|
ExecEvalArrayRef(ArrayRef * arrayRef,
|
||||||
ExprContext * econtext,
|
ExprContext * econtext,
|
||||||
bool * isNull,
|
bool * isNull,
|
||||||
bool * isDone)
|
bool * isDone)
|
||||||
{
|
{
|
||||||
bool dummy;
|
bool dummy;
|
||||||
int i = 0,
|
int i = 0,
|
||||||
j = 0;
|
j = 0;
|
||||||
ArrayType *array_scanner;
|
ArrayType *array_scanner;
|
||||||
List *upperIndexpr,
|
List *upperIndexpr,
|
||||||
*lowerIndexpr;
|
*lowerIndexpr;
|
||||||
Node *assgnexpr;
|
Node *assgnexpr;
|
||||||
List *elt;
|
List *elt;
|
||||||
IntArray upper,
|
IntArray upper,
|
||||||
lower;
|
lower;
|
||||||
int *lIndex;
|
int *lIndex;
|
||||||
char *dataPtr;
|
char *dataPtr;
|
||||||
|
|
||||||
*isNull = false;
|
*isNull = false;
|
||||||
array_scanner = (ArrayType *) ExecEvalExpr(arrayRef->refexpr,
|
array_scanner = (ArrayType *) ExecEvalExpr(arrayRef->refexpr,
|
||||||
@@ -199,7 +199,7 @@ ExecEvalArrayRef(ArrayRef * arrayRef,
|
|||||||
* aggregate found in the given expression context.
|
* aggregate found in the given expression context.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull)
|
ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -230,17 +230,17 @@ ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull)
|
|||||||
* We have an Assert to make sure this entry condition is met.
|
* We have an Assert to make sure this entry condition is met.
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------- */
|
* ---------------------------------------------------------------- */
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull)
|
ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull)
|
||||||
{
|
{
|
||||||
Datum result;
|
Datum result;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
AttrNumber attnum;
|
AttrNumber attnum;
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
TupleDesc tuple_type;
|
TupleDesc tuple_type;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
bool byval;
|
bool byval;
|
||||||
int16 len;
|
int16 len;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get the slot we want
|
* get the slot we want
|
||||||
@@ -248,18 +248,18 @@ ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull)
|
|||||||
*/
|
*/
|
||||||
switch (variable->varno)
|
switch (variable->varno)
|
||||||
{
|
{
|
||||||
case INNER: /* get the tuple from the inner node */
|
case INNER: /* get the tuple from the inner node */
|
||||||
slot = econtext->ecxt_innertuple;
|
slot = econtext->ecxt_innertuple;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTER: /* get the tuple from the outer node */
|
case OUTER: /* get the tuple from the outer node */
|
||||||
slot = econtext->ecxt_outertuple;
|
slot = econtext->ecxt_outertuple;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* get the tuple from the relation being
|
default: /* get the tuple from the relation being
|
||||||
* scanned */
|
* scanned */
|
||||||
slot = econtext->ecxt_scantuple;
|
slot = econtext->ecxt_scantuple;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -286,8 +286,8 @@ ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull)
|
|||||||
if (attnum == InvalidAttrNumber)
|
if (attnum == InvalidAttrNumber)
|
||||||
{
|
{
|
||||||
TupleTableSlot *tempSlot;
|
TupleTableSlot *tempSlot;
|
||||||
TupleDesc td;
|
TupleDesc td;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
tempSlot = makeNode(TupleTableSlot);
|
tempSlot = makeNode(TupleTableSlot);
|
||||||
tempSlot->ttc_shouldFree = false;
|
tempSlot->ttc_shouldFree = false;
|
||||||
@@ -380,11 +380,11 @@ Datum
|
|||||||
ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull)
|
ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *thisParameterName;
|
char *thisParameterName;
|
||||||
int thisParameterKind;
|
int thisParameterKind;
|
||||||
AttrNumber thisParameterId;
|
AttrNumber thisParameterId;
|
||||||
int matchFound;
|
int matchFound;
|
||||||
ParamListInfo paramList;
|
ParamListInfo paramList;
|
||||||
|
|
||||||
thisParameterName = expression->paramname;
|
thisParameterName = expression->paramname;
|
||||||
thisParameterKind = expression->paramkind;
|
thisParameterKind = expression->paramkind;
|
||||||
@@ -409,44 +409,44 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull)
|
|||||||
{
|
{
|
||||||
switch (thisParameterKind)
|
switch (thisParameterKind)
|
||||||
{
|
{
|
||||||
case PARAM_NAMED:
|
case PARAM_NAMED:
|
||||||
if (thisParameterKind == paramList->kind &&
|
if (thisParameterKind == paramList->kind &&
|
||||||
strcmp(paramList->name, thisParameterName) == 0)
|
strcmp(paramList->name, thisParameterName) == 0)
|
||||||
{
|
{
|
||||||
matchFound = 1;
|
matchFound = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PARAM_NUM:
|
case PARAM_NUM:
|
||||||
if (thisParameterKind == paramList->kind &&
|
if (thisParameterKind == paramList->kind &&
|
||||||
paramList->id == thisParameterId)
|
paramList->id == thisParameterId)
|
||||||
{
|
{
|
||||||
matchFound = 1;
|
matchFound = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PARAM_OLD:
|
case PARAM_OLD:
|
||||||
case PARAM_NEW:
|
case PARAM_NEW:
|
||||||
if (thisParameterKind == paramList->kind &&
|
if (thisParameterKind == paramList->kind &&
|
||||||
paramList->id == thisParameterId)
|
paramList->id == thisParameterId)
|
||||||
{
|
{
|
||||||
matchFound = 1;
|
matchFound = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sanity check
|
||||||
|
*/
|
||||||
|
if (strcmp(paramList->name, thisParameterName) != 0)
|
||||||
|
{
|
||||||
|
elog(WARN,
|
||||||
|
"ExecEvalParam: new/old params with same id & diff names");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sanity check
|
* oops! this is not supposed to happen!
|
||||||
*/
|
*/
|
||||||
if (strcmp(paramList->name, thisParameterName) != 0)
|
elog(WARN, "ExecEvalParam: invalid paramkind %d",
|
||||||
{
|
thisParameterKind);
|
||||||
elog(WARN,
|
|
||||||
"ExecEvalParam: new/old params with same id & diff names");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
|
|
||||||
/*
|
|
||||||
* oops! this is not supposed to happen!
|
|
||||||
*/
|
|
||||||
elog(WARN, "ExecEvalParam: invalid paramkind %d",
|
|
||||||
thisParameterKind);
|
|
||||||
}
|
}
|
||||||
if (!matchFound)
|
if (!matchFound)
|
||||||
{
|
{
|
||||||
@@ -477,10 +477,10 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull)
|
|||||||
|
|
||||||
if (expression->param_tlist != NIL)
|
if (expression->param_tlist != NIL)
|
||||||
{
|
{
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Datum value;
|
Datum value;
|
||||||
List *tlist = expression->param_tlist;
|
List *tlist = expression->param_tlist;
|
||||||
TargetEntry *tle = (TargetEntry *) lfirst(tlist);
|
TargetEntry *tle = (TargetEntry *) lfirst(tlist);
|
||||||
TupleTableSlot *slot = (TupleTableSlot *) paramList->value;
|
TupleTableSlot *slot = (TupleTableSlot *) paramList->value;
|
||||||
|
|
||||||
tup = slot->val;
|
tup = slot->val;
|
||||||
@@ -508,12 +508,12 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull)
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
static char *
|
static char *
|
||||||
GetAttributeByNum(TupleTableSlot * slot,
|
GetAttributeByNum(TupleTableSlot * slot,
|
||||||
AttrNumber attrno,
|
AttrNumber attrno,
|
||||||
bool * isNull)
|
bool * isNull)
|
||||||
{
|
{
|
||||||
Datum retval;
|
Datum retval;
|
||||||
|
|
||||||
if (!AttributeNumberIsValid(attrno))
|
if (!AttributeNumberIsValid(attrno))
|
||||||
elog(WARN, "GetAttributeByNum: Invalid attribute number");
|
elog(WARN, "GetAttributeByNum: Invalid attribute number");
|
||||||
@@ -545,7 +545,7 @@ GetAttributeByNum(TupleTableSlot * slot,
|
|||||||
|
|
||||||
/* XXX char16 name for catalogs */
|
/* XXX char16 name for catalogs */
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
char *
|
char *
|
||||||
att_by_num(TupleTableSlot * slot,
|
att_by_num(TupleTableSlot * slot,
|
||||||
AttrNumber attrno,
|
AttrNumber attrno,
|
||||||
bool * isNull)
|
bool * isNull)
|
||||||
@@ -555,15 +555,15 @@ att_by_num(TupleTableSlot * slot,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *
|
char *
|
||||||
GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull)
|
GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull)
|
||||||
{
|
{
|
||||||
AttrNumber attrno;
|
AttrNumber attrno;
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Datum retval;
|
Datum retval;
|
||||||
int natts;
|
int natts;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (attname == NULL)
|
if (attname == NULL)
|
||||||
elog(WARN, "GetAttributeByName: Invalid attribute name");
|
elog(WARN, "GetAttributeByName: Invalid attribute name");
|
||||||
@@ -608,7 +608,7 @@ GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull)
|
|||||||
|
|
||||||
/* XXX char16 name for catalogs */
|
/* XXX char16 name for catalogs */
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
char *
|
char *
|
||||||
att_by_name(TupleTableSlot * slot, char *attname, bool * isNull)
|
att_by_name(TupleTableSlot * slot, char *attname, bool * isNull)
|
||||||
{
|
{
|
||||||
return (GetAttributeByName(slot, attname, isNull));
|
return (GetAttributeByName(slot, attname, isNull));
|
||||||
@@ -623,10 +623,10 @@ ExecEvalFuncArgs(FunctionCachePtr fcache,
|
|||||||
Datum argV[],
|
Datum argV[],
|
||||||
bool * argIsDone)
|
bool * argIsDone)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool argIsNull,
|
bool argIsNull,
|
||||||
*nullVect;
|
*nullVect;
|
||||||
List *arg;
|
List *arg;
|
||||||
|
|
||||||
nullVect = fcache->nullVect;
|
nullVect = fcache->nullVect;
|
||||||
|
|
||||||
@@ -663,18 +663,18 @@ ExecEvalFuncArgs(FunctionCachePtr fcache,
|
|||||||
* ExecMakeFunctionResult
|
* ExecMakeFunctionResult
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
ExecMakeFunctionResult(Node * node,
|
ExecMakeFunctionResult(Node * node,
|
||||||
List * arguments,
|
List * arguments,
|
||||||
ExprContext * econtext,
|
ExprContext * econtext,
|
||||||
bool * isNull,
|
bool * isNull,
|
||||||
bool * isDone)
|
bool * isDone)
|
||||||
{
|
{
|
||||||
Datum argv[MAXFMGRARGS];
|
Datum argv[MAXFMGRARGS];
|
||||||
FunctionCachePtr fcache;
|
FunctionCachePtr fcache;
|
||||||
Func *funcNode = NULL;
|
Func *funcNode = NULL;
|
||||||
Oper *operNode = NULL;
|
Oper *operNode = NULL;
|
||||||
bool funcisset = false;
|
bool funcisset = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is kind of ugly, Func nodes now have targetlists so that we
|
* This is kind of ugly, Func nodes now have targetlists so that we
|
||||||
@@ -703,7 +703,7 @@ ExecMakeFunctionResult(Node * node,
|
|||||||
*/
|
*/
|
||||||
if (fcache->nargs != 0)
|
if (fcache->nargs != 0)
|
||||||
{
|
{
|
||||||
bool argDone;
|
bool argDone;
|
||||||
|
|
||||||
if (fcache->nargs > MAXFMGRARGS)
|
if (fcache->nargs > MAXFMGRARGS)
|
||||||
elog(WARN, "ExecMakeFunctionResult: too many arguments");
|
elog(WARN, "ExecMakeFunctionResult: too many arguments");
|
||||||
@@ -774,7 +774,7 @@ ExecMakeFunctionResult(Node * node,
|
|||||||
*/
|
*/
|
||||||
if (fcache->language == SQLlanguageId)
|
if (fcache->language == SQLlanguageId)
|
||||||
{
|
{
|
||||||
Datum result;
|
Datum result;
|
||||||
|
|
||||||
Assert(funcNode);
|
Assert(funcNode);
|
||||||
result = postquel_function(funcNode, (char **) argv, isNull, isDone);
|
result = postquel_function(funcNode, (char **) argv, isNull, isDone);
|
||||||
@@ -788,7 +788,7 @@ ExecMakeFunctionResult(Node * node,
|
|||||||
*/
|
*/
|
||||||
if ((*isDone) && (fcache->hasSetArg))
|
if ((*isDone) && (fcache->hasSetArg))
|
||||||
{
|
{
|
||||||
bool argDone;
|
bool argDone;
|
||||||
|
|
||||||
ExecEvalFuncArgs(fcache, econtext, arguments, argv, &argDone);
|
ExecEvalFuncArgs(fcache, econtext, arguments, argv, &argDone);
|
||||||
|
|
||||||
@@ -828,7 +828,7 @@ ExecMakeFunctionResult(Node * node,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (isDone)
|
if (isDone)
|
||||||
*isDone = true;
|
*isDone = true;
|
||||||
@@ -863,13 +863,13 @@ ExecMakeFunctionResult(Node * node,
|
|||||||
* ExecEvalOper
|
* ExecEvalOper
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull)
|
ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull)
|
||||||
{
|
{
|
||||||
Oper *op;
|
Oper *op;
|
||||||
List *argList;
|
List *argList;
|
||||||
FunctionCachePtr fcache;
|
FunctionCachePtr fcache;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* an opclause is a list (op args). (I think)
|
* an opclause is a list (op args). (I think)
|
||||||
@@ -908,14 +908,14 @@ ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull)
|
|||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalFunc(Expr * funcClause,
|
ExecEvalFunc(Expr * funcClause,
|
||||||
ExprContext * econtext,
|
ExprContext * econtext,
|
||||||
bool * isNull,
|
bool * isNull,
|
||||||
bool * isDone)
|
bool * isDone)
|
||||||
{
|
{
|
||||||
Func *func;
|
Func *func;
|
||||||
List *argList;
|
List *argList;
|
||||||
FunctionCachePtr fcache;
|
FunctionCachePtr fcache;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -963,12 +963,12 @@ ExecEvalFunc(Expr * funcClause,
|
|||||||
* need to know this, mind you...
|
* need to know this, mind you...
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull)
|
ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull)
|
||||||
{
|
{
|
||||||
Datum expr_value;
|
Datum expr_value;
|
||||||
Node *clause;
|
Node *clause;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
clause = lfirst(notclause->args);
|
clause = lfirst(notclause->args);
|
||||||
|
|
||||||
@@ -1002,14 +1002,14 @@ ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull)
|
|||||||
* ExecEvalOr
|
* ExecEvalOr
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull)
|
ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull)
|
||||||
{
|
{
|
||||||
List *clauses;
|
List *clauses;
|
||||||
List *clause;
|
List *clause;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
bool IsNull;
|
bool IsNull;
|
||||||
Datum const_value = 0;
|
Datum const_value = 0;
|
||||||
|
|
||||||
IsNull = false;
|
IsNull = false;
|
||||||
clauses = orExpr->args;
|
clauses = orExpr->args;
|
||||||
@@ -1066,14 +1066,14 @@ ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull)
|
|||||||
* ExecEvalAnd
|
* ExecEvalAnd
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull)
|
ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull)
|
||||||
{
|
{
|
||||||
List *clauses;
|
List *clauses;
|
||||||
List *clause;
|
List *clause;
|
||||||
Datum const_value = 0;
|
Datum const_value = 0;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
bool IsNull;
|
bool IsNull;
|
||||||
|
|
||||||
IsNull = false;
|
IsNull = false;
|
||||||
|
|
||||||
@@ -1149,7 +1149,7 @@ ExecEvalExpr(Node * expression,
|
|||||||
bool * isNull,
|
bool * isNull,
|
||||||
bool * isDone)
|
bool * isDone)
|
||||||
{
|
{
|
||||||
Datum retDatum = 0;
|
Datum retDatum = 0;
|
||||||
|
|
||||||
*isNull = false;
|
*isNull = false;
|
||||||
|
|
||||||
@@ -1173,68 +1173,68 @@ ExecEvalExpr(Node * expression,
|
|||||||
|
|
||||||
switch (nodeTag(expression))
|
switch (nodeTag(expression))
|
||||||
{
|
{
|
||||||
case T_Var:
|
case T_Var:
|
||||||
retDatum = (Datum) ExecEvalVar((Var *) expression, econtext, isNull);
|
retDatum = (Datum) ExecEvalVar((Var *) expression, econtext, isNull);
|
||||||
break;
|
|
||||||
case T_Const:
|
|
||||||
{
|
|
||||||
Const *con = (Const *) expression;
|
|
||||||
|
|
||||||
if (con->constisnull)
|
|
||||||
*isNull = true;
|
|
||||||
retDatum = con->constvalue;
|
|
||||||
break;
|
break;
|
||||||
}
|
case T_Const:
|
||||||
case T_Param:
|
{
|
||||||
retDatum = (Datum) ExecEvalParam((Param *) expression, econtext, isNull);
|
Const *con = (Const *) expression;
|
||||||
break;
|
|
||||||
case T_Iter:
|
if (con->constisnull)
|
||||||
retDatum = (Datum) ExecEvalIter((Iter *) expression,
|
*isNull = true;
|
||||||
econtext,
|
retDatum = con->constvalue;
|
||||||
isNull,
|
break;
|
||||||
isDone);
|
}
|
||||||
break;
|
case T_Param:
|
||||||
case T_Aggreg:
|
retDatum = (Datum) ExecEvalParam((Param *) expression, econtext, isNull);
|
||||||
retDatum = (Datum) ExecEvalAggreg((Aggreg *) expression,
|
break;
|
||||||
econtext,
|
case T_Iter:
|
||||||
isNull);
|
retDatum = (Datum) ExecEvalIter((Iter *) expression,
|
||||||
break;
|
|
||||||
case T_ArrayRef:
|
|
||||||
retDatum = (Datum) ExecEvalArrayRef((ArrayRef *) expression,
|
|
||||||
econtext,
|
econtext,
|
||||||
isNull,
|
isNull,
|
||||||
isDone);
|
isDone);
|
||||||
break;
|
break;
|
||||||
case T_Expr:
|
case T_Aggreg:
|
||||||
{
|
retDatum = (Datum) ExecEvalAggreg((Aggreg *) expression,
|
||||||
Expr *expr = (Expr *) expression;
|
econtext,
|
||||||
|
isNull);
|
||||||
switch (expr->opType)
|
break;
|
||||||
|
case T_ArrayRef:
|
||||||
|
retDatum = (Datum) ExecEvalArrayRef((ArrayRef *) expression,
|
||||||
|
econtext,
|
||||||
|
isNull,
|
||||||
|
isDone);
|
||||||
|
break;
|
||||||
|
case T_Expr:
|
||||||
{
|
{
|
||||||
case OP_EXPR:
|
Expr *expr = (Expr *) expression;
|
||||||
retDatum = (Datum) ExecEvalOper(expr, econtext, isNull);
|
|
||||||
break;
|
switch (expr->opType)
|
||||||
case FUNC_EXPR:
|
{
|
||||||
retDatum = (Datum) ExecEvalFunc(expr, econtext, isNull, isDone);
|
case OP_EXPR:
|
||||||
break;
|
retDatum = (Datum) ExecEvalOper(expr, econtext, isNull);
|
||||||
case OR_EXPR:
|
break;
|
||||||
retDatum = (Datum) ExecEvalOr(expr, econtext, isNull);
|
case FUNC_EXPR:
|
||||||
break;
|
retDatum = (Datum) ExecEvalFunc(expr, econtext, isNull, isDone);
|
||||||
case AND_EXPR:
|
break;
|
||||||
retDatum = (Datum) ExecEvalAnd(expr, econtext, isNull);
|
case OR_EXPR:
|
||||||
break;
|
retDatum = (Datum) ExecEvalOr(expr, econtext, isNull);
|
||||||
case NOT_EXPR:
|
break;
|
||||||
retDatum = (Datum) ExecEvalNot(expr, econtext, isNull);
|
case AND_EXPR:
|
||||||
break;
|
retDatum = (Datum) ExecEvalAnd(expr, econtext, isNull);
|
||||||
default:
|
break;
|
||||||
elog(WARN, "ExecEvalExpr: unknown expression type");
|
case NOT_EXPR:
|
||||||
|
retDatum = (Datum) ExecEvalNot(expr, econtext, isNull);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
elog(WARN, "ExecEvalExpr: unknown expression type");
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
elog(WARN, "ExecEvalExpr: unknown expression type");
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
|
||||||
elog(WARN, "ExecEvalExpr: unknown expression type");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retDatum;
|
return retDatum;
|
||||||
@@ -1256,12 +1256,12 @@ ExecEvalExpr(Node * expression,
|
|||||||
* rest of the qualification)
|
* rest of the qualification)
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
ExecQualClause(Node * clause, ExprContext * econtext)
|
ExecQualClause(Node * clause, ExprContext * econtext)
|
||||||
{
|
{
|
||||||
Datum expr_value;
|
Datum expr_value;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
/* when there is a null clause, consider the qualification to be true */
|
/* when there is a null clause, consider the qualification to be true */
|
||||||
if (clause == NULL)
|
if (clause == NULL)
|
||||||
@@ -1304,8 +1304,8 @@ ExecQualClause(Node * clause, ExprContext * econtext)
|
|||||||
bool
|
bool
|
||||||
ExecQual(List * qual, ExprContext * econtext)
|
ExecQual(List * qual, ExprContext * econtext)
|
||||||
{
|
{
|
||||||
List *clause;
|
List *clause;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* debugging stuff
|
* debugging stuff
|
||||||
@@ -1356,9 +1356,9 @@ ExecQual(List * qual, ExprContext * econtext)
|
|||||||
int
|
int
|
||||||
ExecTargetListLength(List * targetlist)
|
ExecTargetListLength(List * targetlist)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
List *tl;
|
List *tl;
|
||||||
TargetEntry *curTle;
|
TargetEntry *curTle;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
foreach(tl, targetlist)
|
foreach(tl, targetlist)
|
||||||
@@ -1380,7 +1380,7 @@ ExecTargetListLength(List * targetlist)
|
|||||||
* expression context and return a tuple.
|
* expression context and return a tuple.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static HeapTuple
|
static HeapTuple
|
||||||
ExecTargetList(List * targetlist,
|
ExecTargetList(List * targetlist,
|
||||||
int nodomains,
|
int nodomains,
|
||||||
TupleDesc targettype,
|
TupleDesc targettype,
|
||||||
@@ -1388,18 +1388,18 @@ ExecTargetList(List * targetlist,
|
|||||||
ExprContext * econtext,
|
ExprContext * econtext,
|
||||||
bool * isDone)
|
bool * isDone)
|
||||||
{
|
{
|
||||||
char nulls_array[64];
|
char nulls_array[64];
|
||||||
bool fjNullArray[64];
|
bool fjNullArray[64];
|
||||||
bool *fjIsNull;
|
bool *fjIsNull;
|
||||||
char *null_head;
|
char *null_head;
|
||||||
List *tl;
|
List *tl;
|
||||||
TargetEntry *tle;
|
TargetEntry *tle;
|
||||||
Node *expr;
|
Node *expr;
|
||||||
Resdom *resdom;
|
Resdom *resdom;
|
||||||
AttrNumber resind;
|
AttrNumber resind;
|
||||||
Datum constvalue;
|
Datum constvalue;
|
||||||
HeapTuple newTuple;
|
HeapTuple newTuple;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* debugging stuff
|
* debugging stuff
|
||||||
@@ -1497,12 +1497,12 @@ ExecTargetList(List * targetlist,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int curNode;
|
int curNode;
|
||||||
Resdom *fjRes;
|
Resdom *fjRes;
|
||||||
List *fjTlist = (List *) tle->expr;
|
List *fjTlist = (List *) tle->expr;
|
||||||
Fjoin *fjNode = tle->fjoin;
|
Fjoin *fjNode = tle->fjoin;
|
||||||
int nNodes = fjNode->fj_nNodes;
|
int nNodes = fjNode->fj_nNodes;
|
||||||
DatumPtr results = fjNode->fj_results;
|
DatumPtr results = fjNode->fj_results;
|
||||||
|
|
||||||
ExecEvalFjoin(tle, econtext, fjIsNull, isDone);
|
ExecEvalFjoin(tle, econtext, fjIsNull, isDone);
|
||||||
if (*isDone)
|
if (*isDone)
|
||||||
@@ -1529,7 +1529,7 @@ ExecTargetList(List * targetlist,
|
|||||||
curNode++, fjTlist = lnext(fjTlist))
|
curNode++, fjTlist = lnext(fjTlist))
|
||||||
{
|
{
|
||||||
#if 0 /* what is this?? */
|
#if 0 /* what is this?? */
|
||||||
Node *outernode = lfirst(fjTlist);
|
Node *outernode = lfirst(fjTlist);
|
||||||
|
|
||||||
fjRes = (Resdom *) outernode->iterexpr;
|
fjRes = (Resdom *) outernode->iterexpr;
|
||||||
#endif
|
#endif
|
||||||
@@ -1582,12 +1582,12 @@ TupleTableSlot *
|
|||||||
ExecProject(ProjectionInfo * projInfo, bool * isDone)
|
ExecProject(ProjectionInfo * projInfo, bool * isDone)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
List *targetlist;
|
List *targetlist;
|
||||||
int len;
|
int len;
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
Datum *tupValue;
|
Datum *tupValue;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
HeapTuple newTuple;
|
HeapTuple newTuple;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.4 1997/09/07 04:41:23 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.5 1997/09/08 02:22:34 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -48,15 +48,15 @@ ExecScan(Scan * node,
|
|||||||
* tuple */
|
* tuple */
|
||||||
{
|
{
|
||||||
CommonScanState *scanstate;
|
CommonScanState *scanstate;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
List *qual;
|
List *qual;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
TupleTableSlot *resultSlot;
|
TupleTableSlot *resultSlot;
|
||||||
HeapTuple newTuple;
|
HeapTuple newTuple;
|
||||||
|
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
ProjectionInfo *projInfo;
|
ProjectionInfo *projInfo;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.7 1997/09/07 04:41:24 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.8 1997/09/08 02:22:35 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -153,7 +153,7 @@ TupleTable /* return: address of table */
|
|||||||
ExecCreateTupleTable(int initialSize) /* initial number of slots
|
ExecCreateTupleTable(int initialSize) /* initial number of slots
|
||||||
* in table */
|
* in table */
|
||||||
{
|
{
|
||||||
TupleTable newtable; /* newly allocated table */
|
TupleTable newtable; /* newly allocated table */
|
||||||
TupleTableSlot *array; /* newly allocated slot array */
|
TupleTableSlot *array; /* newly allocated slot array */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -200,9 +200,9 @@ ExecDestroyTupleTable(TupleTable table, /* tuple table */
|
|||||||
bool shouldFree) /* true if we should free slot
|
bool shouldFree) /* true if we should free slot
|
||||||
* contents */
|
* contents */
|
||||||
{
|
{
|
||||||
int next; /* next avaliable slot */
|
int next; /* next avaliable slot */
|
||||||
TupleTableSlot *array; /* start of table array */
|
TupleTableSlot *array; /* start of table array */
|
||||||
int i; /* counter */
|
int i; /* counter */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -229,8 +229,8 @@ ExecDestroyTupleTable(TupleTable table, /* tuple table */
|
|||||||
if (shouldFree)
|
if (shouldFree)
|
||||||
for (i = 0; i < next; i++)
|
for (i = 0; i < next; i++)
|
||||||
{
|
{
|
||||||
TupleTableSlot slot;
|
TupleTableSlot slot;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
slot = array[i];
|
slot = array[i];
|
||||||
tuple = slot.val;
|
tuple = slot.val;
|
||||||
@@ -280,7 +280,7 @@ TupleTableSlot * /* return: the slot allocated in the tuple
|
|||||||
* table */
|
* table */
|
||||||
ExecAllocTableSlot(TupleTable table)
|
ExecAllocTableSlot(TupleTable table)
|
||||||
{
|
{
|
||||||
int slotnum; /* new slot number */
|
int slotnum; /* new slot number */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -383,7 +383,7 @@ ExecStoreTuple(HeapTuple tuple, /* tuple to store */
|
|||||||
TupleTableSlot * /* return: slot passed */
|
TupleTableSlot * /* return: slot passed */
|
||||||
ExecClearTuple(TupleTableSlot * slot) /* slot in which to store tuple */
|
ExecClearTuple(TupleTableSlot * slot) /* slot in which to store tuple */
|
||||||
{
|
{
|
||||||
HeapTuple oldtuple; /* prior contents of slot */
|
HeapTuple oldtuple; /* prior contents of slot */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* sanity checks
|
* sanity checks
|
||||||
@@ -462,7 +462,7 @@ ExecSetSlotPolicy(TupleTableSlot * slot, /* slot to change */
|
|||||||
bool shouldFree) /* true if we call pfree() when we
|
bool shouldFree) /* true if we call pfree() when we
|
||||||
* gc. */
|
* gc. */
|
||||||
{
|
{
|
||||||
bool old_shouldFree = slot->ttc_shouldFree;
|
bool old_shouldFree = slot->ttc_shouldFree;
|
||||||
|
|
||||||
slot->ttc_shouldFree = shouldFree;
|
slot->ttc_shouldFree = shouldFree;
|
||||||
|
|
||||||
@@ -490,7 +490,7 @@ TupleDesc /* return: old slot tuple descriptor */
|
|||||||
ExecSetSlotDescriptor(TupleTableSlot * slot, /* slot to change */
|
ExecSetSlotDescriptor(TupleTableSlot * slot, /* slot to change */
|
||||||
TupleDesc tupdesc) /* tuple descriptor */
|
TupleDesc tupdesc) /* tuple descriptor */
|
||||||
{
|
{
|
||||||
TupleDesc old_tupdesc = slot->ttc_tupleDescriptor;
|
TupleDesc old_tupdesc = slot->ttc_tupleDescriptor;
|
||||||
|
|
||||||
slot->ttc_tupleDescriptor = tupdesc;
|
slot->ttc_tupleDescriptor = tupdesc;
|
||||||
return old_tupdesc;
|
return old_tupdesc;
|
||||||
@@ -521,7 +521,7 @@ TupleDesc /* return: old slot tuple descriptor */
|
|||||||
ExecSetNewSlotDescriptor(TupleTableSlot * slot, /* slot to change */
|
ExecSetNewSlotDescriptor(TupleTableSlot * slot, /* slot to change */
|
||||||
TupleDesc tupdesc) /* tuple descriptor */
|
TupleDesc tupdesc) /* tuple descriptor */
|
||||||
{
|
{
|
||||||
TupleDesc old_tupdesc = slot->ttc_tupleDescriptor;
|
TupleDesc old_tupdesc = slot->ttc_tupleDescriptor;
|
||||||
|
|
||||||
slot->ttc_tupleDescriptor = tupdesc;
|
slot->ttc_tupleDescriptor = tupdesc;
|
||||||
slot->ttc_descIsNew = true;
|
slot->ttc_descIsNew = true;
|
||||||
@@ -557,7 +557,7 @@ Buffer /* return: old slot buffer */
|
|||||||
ExecSetSlotBuffer(TupleTableSlot * slot, /* slot to change */
|
ExecSetSlotBuffer(TupleTableSlot * slot, /* slot to change */
|
||||||
Buffer b) /* tuple descriptor */
|
Buffer b) /* tuple descriptor */
|
||||||
{
|
{
|
||||||
Buffer oldb = slot->ttc_buffer;
|
Buffer oldb = slot->ttc_buffer;
|
||||||
|
|
||||||
slot->ttc_buffer = b;
|
slot->ttc_buffer = b;
|
||||||
|
|
||||||
@@ -578,7 +578,7 @@ void
|
|||||||
ExecIncrSlotBufferRefcnt(TupleTableSlot * slot) /* slot to bump refcnt */
|
ExecIncrSlotBufferRefcnt(TupleTableSlot * slot) /* slot to bump refcnt */
|
||||||
{
|
{
|
||||||
/* Buffer b = SlotBuffer((TupleTableSlot*) slot); */
|
/* Buffer b = SlotBuffer((TupleTableSlot*) slot); */
|
||||||
Buffer b = slot->ttc_buffer;
|
Buffer b = slot->ttc_buffer;
|
||||||
|
|
||||||
if (BufferIsValid(b))
|
if (BufferIsValid(b))
|
||||||
IncrBufferRefCount(b);
|
IncrBufferRefCount(b);
|
||||||
@@ -599,7 +599,7 @@ ExecIncrSlotBufferRefcnt(TupleTableSlot * slot) /* slot to bump refcnt */
|
|||||||
bool /* return: true if tuple in slot is NULL */
|
bool /* return: true if tuple in slot is NULL */
|
||||||
TupIsNull(TupleTableSlot * slot) /* slot to check */
|
TupIsNull(TupleTableSlot * slot) /* slot to check */
|
||||||
{
|
{
|
||||||
HeapTuple tuple; /* contents of slot (returned) */
|
HeapTuple tuple; /* contents of slot (returned) */
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if the slot itself is null then we return true
|
* if the slot itself is null then we return true
|
||||||
@@ -733,136 +733,136 @@ NodeGetResultTupleSlot(Plan * node)
|
|||||||
switch (nodeTag(node))
|
switch (nodeTag(node))
|
||||||
{
|
{
|
||||||
|
|
||||||
case T_Result:
|
case T_Result:
|
||||||
{
|
{
|
||||||
ResultState *resstate = ((Result *) node)->resstate;
|
ResultState *resstate = ((Result *) node)->resstate;
|
||||||
|
|
||||||
slot = resstate->cstate.cs_ResultTupleSlot;
|
slot = resstate->cstate.cs_ResultTupleSlot;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case T_SeqScan:
|
|
||||||
{
|
|
||||||
CommonScanState *scanstate = ((SeqScan *) node)->scanstate;
|
|
||||||
|
|
||||||
slot = scanstate->cstate.cs_ResultTupleSlot;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_NestLoop:
|
|
||||||
{
|
|
||||||
NestLoopState *nlstate = ((NestLoop *) node)->nlstate;
|
|
||||||
|
|
||||||
slot = nlstate->jstate.cs_ResultTupleSlot;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_Append:
|
|
||||||
{
|
|
||||||
Append *n = (Append *) node;
|
|
||||||
AppendState *unionstate;
|
|
||||||
List *unionplans;
|
|
||||||
int whichplan;
|
|
||||||
Plan *subplan;
|
|
||||||
|
|
||||||
unionstate = n->unionstate;
|
|
||||||
unionplans = n->unionplans;
|
|
||||||
whichplan = unionstate->as_whichplan;
|
|
||||||
|
|
||||||
subplan = (Plan *) nth(whichplan, unionplans);
|
|
||||||
slot = NodeGetResultTupleSlot(subplan);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case T_IndexScan:
|
case T_SeqScan:
|
||||||
{
|
{
|
||||||
CommonScanState *scanstate = ((IndexScan *) node)->scan.scanstate;
|
CommonScanState *scanstate = ((SeqScan *) node)->scanstate;
|
||||||
|
|
||||||
slot = scanstate->cstate.cs_ResultTupleSlot;
|
slot = scanstate->cstate.cs_ResultTupleSlot;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Material:
|
case T_NestLoop:
|
||||||
{
|
{
|
||||||
MaterialState *matstate = ((Material *) node)->matstate;
|
NestLoopState *nlstate = ((NestLoop *) node)->nlstate;
|
||||||
|
|
||||||
slot = matstate->csstate.css_ScanTupleSlot;
|
slot = nlstate->jstate.cs_ResultTupleSlot;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_Sort:
|
case T_Append:
|
||||||
{
|
{
|
||||||
SortState *sortstate = ((Sort *) node)->sortstate;
|
Append *n = (Append *) node;
|
||||||
|
AppendState *unionstate;
|
||||||
|
List *unionplans;
|
||||||
|
int whichplan;
|
||||||
|
Plan *subplan;
|
||||||
|
|
||||||
slot = sortstate->csstate.css_ScanTupleSlot;
|
unionstate = n->unionstate;
|
||||||
}
|
unionplans = n->unionplans;
|
||||||
break;
|
whichplan = unionstate->as_whichplan;
|
||||||
|
|
||||||
case T_Agg:
|
subplan = (Plan *) nth(whichplan, unionplans);
|
||||||
{
|
slot = NodeGetResultTupleSlot(subplan);
|
||||||
AggState *aggstate = ((Agg *) node)->aggstate;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
slot = aggstate->csstate.cstate.cs_ResultTupleSlot;
|
case T_IndexScan:
|
||||||
}
|
{
|
||||||
break;
|
CommonScanState *scanstate = ((IndexScan *) node)->scan.scanstate;
|
||||||
|
|
||||||
case T_Group:
|
slot = scanstate->cstate.cs_ResultTupleSlot;
|
||||||
{
|
}
|
||||||
GroupState *grpstate = ((Group *) node)->grpstate;
|
break;
|
||||||
|
|
||||||
slot = grpstate->csstate.cstate.cs_ResultTupleSlot;
|
case T_Material:
|
||||||
}
|
{
|
||||||
break;
|
MaterialState *matstate = ((Material *) node)->matstate;
|
||||||
|
|
||||||
case T_Hash:
|
slot = matstate->csstate.css_ScanTupleSlot;
|
||||||
{
|
}
|
||||||
HashState *hashstate = ((Hash *) node)->hashstate;
|
break;
|
||||||
|
|
||||||
slot = hashstate->cstate.cs_ResultTupleSlot;
|
case T_Sort:
|
||||||
}
|
{
|
||||||
break;
|
SortState *sortstate = ((Sort *) node)->sortstate;
|
||||||
|
|
||||||
case T_Unique:
|
slot = sortstate->csstate.css_ScanTupleSlot;
|
||||||
{
|
}
|
||||||
UniqueState *uniquestate = ((Unique *) node)->uniquestate;
|
break;
|
||||||
|
|
||||||
slot = uniquestate->cs_ResultTupleSlot;
|
case T_Agg:
|
||||||
}
|
{
|
||||||
break;
|
AggState *aggstate = ((Agg *) node)->aggstate;
|
||||||
|
|
||||||
case T_MergeJoin:
|
slot = aggstate->csstate.cstate.cs_ResultTupleSlot;
|
||||||
{
|
}
|
||||||
MergeJoinState *mergestate = ((MergeJoin *) node)->mergestate;
|
break;
|
||||||
|
|
||||||
slot = mergestate->jstate.cs_ResultTupleSlot;
|
case T_Group:
|
||||||
}
|
{
|
||||||
break;
|
GroupState *grpstate = ((Group *) node)->grpstate;
|
||||||
|
|
||||||
case T_HashJoin:
|
slot = grpstate->csstate.cstate.cs_ResultTupleSlot;
|
||||||
{
|
}
|
||||||
HashJoinState *hashjoinstate = ((HashJoin *) node)->hashjoinstate;
|
break;
|
||||||
|
|
||||||
slot = hashjoinstate->jstate.cs_ResultTupleSlot;
|
case T_Hash:
|
||||||
}
|
{
|
||||||
break;
|
HashState *hashstate = ((Hash *) node)->hashstate;
|
||||||
|
|
||||||
case T_Tee:
|
slot = hashstate->cstate.cs_ResultTupleSlot;
|
||||||
{
|
}
|
||||||
TeeState *teestate = ((Tee *) node)->teestate;
|
break;
|
||||||
|
|
||||||
slot = teestate->cstate.cs_ResultTupleSlot;
|
case T_Unique:
|
||||||
}
|
{
|
||||||
break;
|
UniqueState *uniquestate = ((Unique *) node)->uniquestate;
|
||||||
|
|
||||||
default:
|
slot = uniquestate->cs_ResultTupleSlot;
|
||||||
/* ----------------
|
}
|
||||||
* should never get here
|
break;
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
elog(WARN, "NodeGetResultTupleSlot: node not yet supported: %d ",
|
|
||||||
nodeTag(node));
|
|
||||||
|
|
||||||
return NULL;
|
case T_MergeJoin:
|
||||||
|
{
|
||||||
|
MergeJoinState *mergestate = ((MergeJoin *) node)->mergestate;
|
||||||
|
|
||||||
|
slot = mergestate->jstate.cs_ResultTupleSlot;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_HashJoin:
|
||||||
|
{
|
||||||
|
HashJoinState *hashjoinstate = ((HashJoin *) node)->hashjoinstate;
|
||||||
|
|
||||||
|
slot = hashjoinstate->jstate.cs_ResultTupleSlot;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_Tee:
|
||||||
|
{
|
||||||
|
TeeState *teestate = ((Tee *) node)->teestate;
|
||||||
|
|
||||||
|
slot = teestate->cstate.cs_ResultTupleSlot;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* ----------------
|
||||||
|
* should never get here
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
elog(WARN, "NodeGetResultTupleSlot: node not yet supported: %d ",
|
||||||
|
nodeTag(node));
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
@@ -897,7 +897,7 @@ TupleDesc
|
|||||||
ExecGetTupType(Plan * node)
|
ExecGetTupType(Plan * node)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
|
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -948,11 +948,11 @@ ExecCopyTupType(TupleDesc td, int natts)
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
ExecTypeFromTL(List * targetList)
|
ExecTypeFromTL(List * targetList)
|
||||||
{
|
{
|
||||||
List *tlcdr;
|
List *tlcdr;
|
||||||
TupleDesc typeInfo;
|
TupleDesc typeInfo;
|
||||||
Resdom *resdom;
|
Resdom *resdom;
|
||||||
Oid restype;
|
Oid restype;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* examine targetlist - if empty then return NULL
|
* examine targetlist - if empty then return NULL
|
||||||
@@ -977,7 +977,7 @@ ExecTypeFromTL(List * targetList)
|
|||||||
tlcdr = targetList;
|
tlcdr = targetList;
|
||||||
while (tlcdr != NIL)
|
while (tlcdr != NIL)
|
||||||
{
|
{
|
||||||
TargetEntry *tle = lfirst(tlcdr);
|
TargetEntry *tle = lfirst(tlcdr);
|
||||||
|
|
||||||
if (tle->resdom != NULL)
|
if (tle->resdom != NULL)
|
||||||
{
|
{
|
||||||
@@ -1005,13 +1005,13 @@ ExecTypeFromTL(List * targetList)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Resdom *fjRes;
|
Resdom *fjRes;
|
||||||
List *fjTlistP;
|
List *fjTlistP;
|
||||||
List *fjList = lfirst(tlcdr);
|
List *fjList = lfirst(tlcdr);
|
||||||
|
|
||||||
#ifdef SETS_FIXED
|
#ifdef SETS_FIXED
|
||||||
TargetEntry *tle;
|
TargetEntry *tle;
|
||||||
Fjoin *fjNode = ((TargetEntry *) lfirst(fjList))->fjoin;
|
Fjoin *fjNode = ((TargetEntry *) lfirst(fjList))->fjoin;
|
||||||
|
|
||||||
tle = fjNode->fj_innerNode; /* ??? */
|
tle = fjNode->fj_innerNode; /* ??? */
|
||||||
#endif
|
#endif
|
||||||
@@ -1037,7 +1037,7 @@ ExecTypeFromTL(List * targetList)
|
|||||||
|
|
||||||
foreach(fjTlistP, lnext(fjList))
|
foreach(fjTlistP, lnext(fjList))
|
||||||
{
|
{
|
||||||
TargetEntry *fjTle = lfirst(fjTlistP);
|
TargetEntry *fjTle = lfirst(fjTlistP);
|
||||||
|
|
||||||
fjRes = fjTle->resdom;
|
fjRes = fjTle->resdom;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.15 1997/09/07 04:41:26 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.16 1997/09/08 02:22:36 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -67,13 +67,13 @@ ExecGetIndexKeyInfo(IndexTupleForm indexTuple, int *numAttsOutP,
|
|||||||
* appended, replaced, deleted.
|
* appended, replaced, deleted.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
int NTupleProcessed;
|
int NTupleProcessed;
|
||||||
int NTupleRetrieved;
|
int NTupleRetrieved;
|
||||||
int NTupleReplaced;
|
int NTupleReplaced;
|
||||||
int NTupleAppended;
|
int NTupleAppended;
|
||||||
int NTupleDeleted;
|
int NTupleDeleted;
|
||||||
int NIndexTupleInserted;
|
int NIndexTupleInserted;
|
||||||
extern int NIndexTupleProcessed; /* have to be defined in the
|
extern int NIndexTupleProcessed; /* have to be defined in the
|
||||||
* access method level so that the
|
* access method level so that the
|
||||||
* cinterface.a will link ok. */
|
* cinterface.a will link ok. */
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ DisplayTupleCount(FILE * statfp)
|
|||||||
void
|
void
|
||||||
ExecAssignNodeBaseInfo(EState * estate, CommonState * cstate, Plan * parent)
|
ExecAssignNodeBaseInfo(EState * estate, CommonState * cstate, Plan * parent)
|
||||||
{
|
{
|
||||||
int baseId;
|
int baseId;
|
||||||
|
|
||||||
baseId = estate->es_BaseId;
|
baseId = estate->es_BaseId;
|
||||||
cstate->cs_base_id = baseId;
|
cstate->cs_base_id = baseId;
|
||||||
@@ -178,9 +178,9 @@ ExecAssignNodeBaseInfo(EState * estate, CommonState * cstate, Plan * parent)
|
|||||||
void
|
void
|
||||||
ExecAssignExprContext(EState * estate, CommonState * commonstate)
|
ExecAssignExprContext(EState * estate, CommonState * commonstate)
|
||||||
{
|
{
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
ParamListInfo paraminfo;
|
ParamListInfo paraminfo;
|
||||||
List *rangeTable;
|
List *rangeTable;
|
||||||
|
|
||||||
paraminfo = estate->es_param_list_info;
|
paraminfo = estate->es_param_list_info;
|
||||||
rangeTable = estate->es_range_table;
|
rangeTable = estate->es_range_table;
|
||||||
@@ -223,8 +223,8 @@ ExecAssignResultType(CommonState * commonstate,
|
|||||||
void
|
void
|
||||||
ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate)
|
ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate)
|
||||||
{
|
{
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
outerPlan = outerPlan(node);
|
outerPlan = outerPlan(node);
|
||||||
tupDesc = ExecGetTupType(outerPlan);
|
tupDesc = ExecGetTupType(outerPlan);
|
||||||
@@ -239,13 +239,13 @@ ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate)
|
|||||||
void
|
void
|
||||||
ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate)
|
ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate)
|
||||||
{
|
{
|
||||||
List *targetList;
|
List *targetList;
|
||||||
int i;
|
int i;
|
||||||
int len;
|
int len;
|
||||||
List *tl;
|
List *tl;
|
||||||
TargetEntry *tle;
|
TargetEntry *tle;
|
||||||
List *fjtl;
|
List *fjtl;
|
||||||
TupleDesc origTupDesc;
|
TupleDesc origTupDesc;
|
||||||
|
|
||||||
targetList = node->targetlist;
|
targetList = node->targetlist;
|
||||||
origTupDesc = ExecTypeFromTL(targetList);
|
origTupDesc = ExecTypeFromTL(targetList);
|
||||||
@@ -269,7 +269,7 @@ ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate)
|
|||||||
#ifdef SETS_FIXED
|
#ifdef SETS_FIXED
|
||||||
if (!tl_is_resdom(tle))
|
if (!tl_is_resdom(tle))
|
||||||
{
|
{
|
||||||
Fjoin *fj = (Fjoin *) lfirst(tle);
|
Fjoin *fj = (Fjoin *) lfirst(tle);
|
||||||
|
|
||||||
/* it is a FJoin */
|
/* it is a FJoin */
|
||||||
fjtl = lnext(tle);
|
fjtl = lnext(tle);
|
||||||
@@ -309,7 +309,7 @@ void
|
|||||||
ExecFreeResultType(CommonState * commonstate)
|
ExecFreeResultType(CommonState * commonstate)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
|
|
||||||
slot = commonstate->cs_ResultTupleSlot;
|
slot = commonstate->cs_ResultTupleSlot;
|
||||||
tupType = slot->ttc_tupleDescriptor;
|
tupType = slot->ttc_tupleDescriptor;
|
||||||
@@ -329,8 +329,8 @@ void
|
|||||||
ExecAssignProjectionInfo(Plan * node, CommonState * commonstate)
|
ExecAssignProjectionInfo(Plan * node, CommonState * commonstate)
|
||||||
{
|
{
|
||||||
ProjectionInfo *projInfo;
|
ProjectionInfo *projInfo;
|
||||||
List *targetList;
|
List *targetList;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
targetList = node->targetlist;
|
targetList = node->targetlist;
|
||||||
len = ExecTargetListLength(targetList);
|
len = ExecTargetListLength(targetList);
|
||||||
@@ -407,7 +407,7 @@ void
|
|||||||
ExecFreeScanType(CommonScanState * csstate)
|
ExecFreeScanType(CommonScanState * csstate)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
|
|
||||||
slot = csstate->css_ScanTupleSlot;
|
slot = csstate->css_ScanTupleSlot;
|
||||||
tupType = slot->ttc_tupleDescriptor;
|
tupType = slot->ttc_tupleDescriptor;
|
||||||
@@ -439,8 +439,8 @@ ExecAssignScanType(CommonScanState * csstate,
|
|||||||
void
|
void
|
||||||
ExecAssignScanTypeFromOuterPlan(Plan * node, CommonScanState * csstate)
|
ExecAssignScanTypeFromOuterPlan(Plan * node, CommonScanState * csstate)
|
||||||
{
|
{
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
outerPlan = outerPlan(node);
|
outerPlan = outerPlan(node);
|
||||||
tupDesc = ExecGetTupType(outerPlan);
|
tupDesc = ExecGetTupType(outerPlan);
|
||||||
@@ -571,10 +571,10 @@ ExecFreeTypeInfo(TupleDesc typeInfo)
|
|||||||
TupleDesc
|
TupleDesc
|
||||||
QueryDescGetTypeInfo(QueryDesc * queryDesc)
|
QueryDescGetTypeInfo(QueryDesc * queryDesc)
|
||||||
{
|
{
|
||||||
Plan *plan;
|
Plan *plan;
|
||||||
TupleDesc tupleType;
|
TupleDesc tupleType;
|
||||||
List *targetList;
|
List *targetList;
|
||||||
AttrInfo *attinfo = (AttrInfo *) palloc(sizeof(AttrInfo));
|
AttrInfo *attinfo = (AttrInfo *) palloc(sizeof(AttrInfo));
|
||||||
|
|
||||||
plan = queryDesc->plantree;
|
plan = queryDesc->plantree;
|
||||||
tupleType = (TupleDesc) ExecGetTupType(plan);
|
tupleType = (TupleDesc) ExecGetTupType(plan);
|
||||||
@@ -611,9 +611,9 @@ ExecGetIndexKeyInfo(IndexTupleForm indexTuple,
|
|||||||
AttrNumber ** attsOutP,
|
AttrNumber ** attsOutP,
|
||||||
FuncIndexInfoPtr fInfoP)
|
FuncIndexInfoPtr fInfoP)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int numKeys;
|
int numKeys;
|
||||||
AttrNumber *attKeys;
|
AttrNumber *attKeys;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* check parameters
|
* check parameters
|
||||||
@@ -708,32 +708,32 @@ void
|
|||||||
ExecOpenIndices(Oid resultRelationOid,
|
ExecOpenIndices(Oid resultRelationOid,
|
||||||
RelationInfo * resultRelationInfo)
|
RelationInfo * resultRelationInfo)
|
||||||
{
|
{
|
||||||
Relation indexRd;
|
Relation indexRd;
|
||||||
HeapScanDesc indexSd;
|
HeapScanDesc indexSd;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
IndexTupleForm indexStruct;
|
IndexTupleForm indexStruct;
|
||||||
Oid indexOid;
|
Oid indexOid;
|
||||||
List *oidList;
|
List *oidList;
|
||||||
List *nkeyList;
|
List *nkeyList;
|
||||||
List *keyList;
|
List *keyList;
|
||||||
List *fiList;
|
List *fiList;
|
||||||
char *predString;
|
char *predString;
|
||||||
List *predList;
|
List *predList;
|
||||||
List *indexoid;
|
List *indexoid;
|
||||||
List *numkeys;
|
List *numkeys;
|
||||||
List *indexkeys;
|
List *indexkeys;
|
||||||
List *indexfuncs;
|
List *indexfuncs;
|
||||||
List *indexpreds;
|
List *indexpreds;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
RelationPtr relationDescs;
|
RelationPtr relationDescs;
|
||||||
IndexInfo **indexInfoArray;
|
IndexInfo **indexInfoArray;
|
||||||
FuncIndexInfoPtr fInfoP;
|
FuncIndexInfoPtr fInfoP;
|
||||||
int numKeyAtts;
|
int numKeyAtts;
|
||||||
AttrNumber *indexKeyAtts;
|
AttrNumber *indexKeyAtts;
|
||||||
PredInfo *predicate;
|
PredInfo *predicate;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* open pg_index
|
* open pg_index
|
||||||
@@ -857,7 +857,7 @@ ExecOpenIndices(Oid resultRelationOid,
|
|||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
IndexInfo *ii = makeNode(IndexInfo);
|
IndexInfo *ii = makeNode(IndexInfo);
|
||||||
|
|
||||||
ii->ii_NumKeyAttributes = 0;
|
ii->ii_NumKeyAttributes = 0;
|
||||||
ii->ii_KeyAttributeNumbers = (AttrNumber *) NULL;
|
ii->ii_KeyAttributeNumbers = (AttrNumber *) NULL;
|
||||||
@@ -875,7 +875,7 @@ ExecOpenIndices(Oid resultRelationOid,
|
|||||||
i = 0;
|
i = 0;
|
||||||
foreach(indexoid, oidList)
|
foreach(indexoid, oidList)
|
||||||
{
|
{
|
||||||
Relation indexDesc;
|
Relation indexDesc;
|
||||||
|
|
||||||
indexOid = lfirsti(indexoid);
|
indexOid = lfirsti(indexoid);
|
||||||
indexDesc = index_open(indexOid);
|
indexDesc = index_open(indexOid);
|
||||||
@@ -954,9 +954,9 @@ ExecOpenIndices(Oid resultRelationOid,
|
|||||||
void
|
void
|
||||||
ExecCloseIndices(RelationInfo * resultRelationInfo)
|
ExecCloseIndices(RelationInfo * resultRelationInfo)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
RelationPtr relationDescs;
|
RelationPtr relationDescs;
|
||||||
|
|
||||||
numIndices = resultRelationInfo->ri_NumIndices;
|
numIndices = resultRelationInfo->ri_NumIndices;
|
||||||
relationDescs = resultRelationInfo->ri_IndexRelationDescs;
|
relationDescs = resultRelationInfo->ri_IndexRelationDescs;
|
||||||
@@ -986,14 +986,14 @@ ExecFormIndexTuple(HeapTuple heapTuple,
|
|||||||
Relation indexRelation,
|
Relation indexRelation,
|
||||||
IndexInfo * indexInfo)
|
IndexInfo * indexInfo)
|
||||||
{
|
{
|
||||||
IndexTuple indexTuple;
|
IndexTuple indexTuple;
|
||||||
TupleDesc heapDescriptor;
|
TupleDesc heapDescriptor;
|
||||||
TupleDesc indexDescriptor;
|
TupleDesc indexDescriptor;
|
||||||
Datum *datum;
|
Datum *datum;
|
||||||
char *nulls;
|
char *nulls;
|
||||||
|
|
||||||
int numberOfAttributes;
|
int numberOfAttributes;
|
||||||
AttrNumber *keyAttributeNumbers;
|
AttrNumber *keyAttributeNumbers;
|
||||||
FuncIndexInfoPtr fInfoP;
|
FuncIndexInfoPtr fInfoP;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -1075,24 +1075,24 @@ ExecInsertIndexTuples(TupleTableSlot * slot,
|
|||||||
EState * estate,
|
EState * estate,
|
||||||
bool is_update)
|
bool is_update)
|
||||||
{
|
{
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
RelationInfo *resultRelationInfo;
|
RelationInfo *resultRelationInfo;
|
||||||
int i;
|
int i;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
RelationPtr relationDescs;
|
RelationPtr relationDescs;
|
||||||
Relation heapRelation;
|
Relation heapRelation;
|
||||||
IndexInfo **indexInfoArray;
|
IndexInfo **indexInfoArray;
|
||||||
IndexInfo *indexInfo;
|
IndexInfo *indexInfo;
|
||||||
Node *predicate;
|
Node *predicate;
|
||||||
bool satisfied;
|
bool satisfied;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
InsertIndexResult result;
|
InsertIndexResult result;
|
||||||
int numberOfAttributes;
|
int numberOfAttributes;
|
||||||
AttrNumber *keyAttributeNumbers;
|
AttrNumber *keyAttributeNumbers;
|
||||||
FuncIndexInfoPtr fInfoP;
|
FuncIndexInfoPtr fInfoP;
|
||||||
TupleDesc heapDescriptor;
|
TupleDesc heapDescriptor;
|
||||||
Datum *datum;
|
Datum *datum;
|
||||||
char *nulls;
|
char *nulls;
|
||||||
|
|
||||||
heapTuple = slot->val;
|
heapTuple = slot->val;
|
||||||
|
|
||||||
@@ -1189,10 +1189,10 @@ void
|
|||||||
setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList,
|
setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList,
|
||||||
List * rangeTable)
|
List * rangeTable)
|
||||||
{
|
{
|
||||||
List *tl;
|
List *tl;
|
||||||
TargetEntry *tle;
|
TargetEntry *tle;
|
||||||
Node *expr;
|
Node *expr;
|
||||||
int varno;
|
int varno;
|
||||||
|
|
||||||
tl = targetList;
|
tl = targetList;
|
||||||
|
|
||||||
@@ -1206,9 +1206,9 @@ setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList,
|
|||||||
expr = tle->expr;
|
expr = tle->expr;
|
||||||
if (expr && IsA(expr, Var))
|
if (expr && IsA(expr, Var))
|
||||||
{
|
{
|
||||||
Var *var;
|
Var *var;
|
||||||
RangeTblEntry *rtentry;
|
RangeTblEntry *rtentry;
|
||||||
Relation rd;
|
Relation rd;
|
||||||
|
|
||||||
var = (Var *) expr;
|
var = (Var *) expr;
|
||||||
rtentry = rt_fetch(var->varnoold, rangeTable);
|
rtentry = rt_fetch(var->varnoold, rangeTable);
|
||||||
@@ -1238,7 +1238,7 @@ setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList,
|
|||||||
void
|
void
|
||||||
resetVarAttrLenForCreateTable(TupleDesc tupType)
|
resetVarAttrLenForCreateTable(TupleDesc tupType)
|
||||||
{
|
{
|
||||||
int varno;
|
int varno;
|
||||||
|
|
||||||
for (varno = 0; varno < tupType->natts; varno++)
|
for (varno = 0; varno < tupType->natts; varno++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.8 1997/09/07 04:41:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.9 1997/09/08 02:22:37 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -44,15 +44,15 @@
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE
|
F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE
|
||||||
} ExecStatus;
|
} ExecStatus;
|
||||||
|
|
||||||
typedef struct local_es
|
typedef struct local_es
|
||||||
{
|
{
|
||||||
QueryDesc *qd;
|
QueryDesc *qd;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
struct local_es *next;
|
struct local_es *next;
|
||||||
ExecStatus status;
|
ExecStatus status;
|
||||||
} execution_state;
|
} execution_state;
|
||||||
|
|
||||||
#define LAST_POSTQUEL_COMMAND(es) ((es)->next == (execution_state *)NULL)
|
#define LAST_POSTQUEL_COMMAND(es) ((es)->next == (execution_state *)NULL)
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ static execution_state *
|
|||||||
init_execution_state(FunctionCachePtr fcache,
|
init_execution_state(FunctionCachePtr fcache,
|
||||||
char *args[]);
|
char *args[]);
|
||||||
static TupleTableSlot *postquel_getnext(execution_state * es);
|
static TupleTableSlot *postquel_getnext(execution_state * es);
|
||||||
static void postquel_end(execution_state * es);
|
static void postquel_end(execution_state * es);
|
||||||
static void
|
static void
|
||||||
postquel_sub_params(execution_state * es, int nargs,
|
postquel_sub_params(execution_state * es, int nargs,
|
||||||
char *args[], bool * nullV);
|
char *args[], bool * nullV);
|
||||||
@@ -77,10 +77,10 @@ ProjectAttribute(TupleDesc TD,
|
|||||||
HeapTuple tup,
|
HeapTuple tup,
|
||||||
bool * isnullP)
|
bool * isnullP)
|
||||||
{
|
{
|
||||||
Datum val,
|
Datum val,
|
||||||
valueP;
|
valueP;
|
||||||
Var *attrVar = (Var *) tlist->expr;
|
Var *attrVar = (Var *) tlist->expr;
|
||||||
AttrNumber attrno = attrVar->varattno;
|
AttrNumber attrno = attrVar->varattno;
|
||||||
|
|
||||||
|
|
||||||
val = PointerGetDatum(heap_getattr(tup,
|
val = PointerGetDatum(heap_getattr(tup,
|
||||||
@@ -105,10 +105,10 @@ init_execution_state(FunctionCachePtr fcache,
|
|||||||
execution_state *newes;
|
execution_state *newes;
|
||||||
execution_state *nextes;
|
execution_state *nextes;
|
||||||
execution_state *preves;
|
execution_state *preves;
|
||||||
QueryTreeList *queryTree_list;
|
QueryTreeList *queryTree_list;
|
||||||
int i;
|
int i;
|
||||||
List *planTree_list;
|
List *planTree_list;
|
||||||
int nargs;
|
int nargs;
|
||||||
|
|
||||||
nargs = fcache->nargs;
|
nargs = fcache->nargs;
|
||||||
|
|
||||||
@@ -122,9 +122,9 @@ init_execution_state(FunctionCachePtr fcache,
|
|||||||
|
|
||||||
for (i = 0; i < queryTree_list->len; i++)
|
for (i = 0; i < queryTree_list->len; i++)
|
||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
Query *queryTree = (Query *) (queryTree_list->qtrees[i]);
|
Query *queryTree = (Query *) (queryTree_list->qtrees[i]);
|
||||||
Plan *planTree = lfirst(planTree_list);
|
Plan *planTree = lfirst(planTree_list);
|
||||||
|
|
||||||
if (!nextes)
|
if (!nextes)
|
||||||
nextes = (execution_state *) palloc(sizeof(execution_state));
|
nextes = (execution_state *) palloc(sizeof(execution_state));
|
||||||
@@ -140,8 +140,8 @@ init_execution_state(FunctionCachePtr fcache,
|
|||||||
|
|
||||||
if (nargs > 0)
|
if (nargs > 0)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ParamListInfo paramLI;
|
ParamListInfo paramLI;
|
||||||
|
|
||||||
paramLI =
|
paramLI =
|
||||||
(ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData));
|
(ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData));
|
||||||
@@ -171,7 +171,7 @@ init_execution_state(FunctionCachePtr fcache,
|
|||||||
return newes;
|
return newes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TupleDesc
|
static TupleDesc
|
||||||
postquel_start(execution_state * es)
|
postquel_start(execution_state * es)
|
||||||
{
|
{
|
||||||
#ifdef FUNC_UTIL_PATCH
|
#ifdef FUNC_UTIL_PATCH
|
||||||
@@ -191,7 +191,7 @@ postquel_start(execution_state * es)
|
|||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
postquel_getnext(execution_state * es)
|
postquel_getnext(execution_state * es)
|
||||||
{
|
{
|
||||||
int feature;
|
int feature;
|
||||||
|
|
||||||
#ifdef FUNC_UTIL_PATCH
|
#ifdef FUNC_UTIL_PATCH
|
||||||
if (es->qd->operation == CMD_UTILITY)
|
if (es->qd->operation == CMD_UTILITY)
|
||||||
@@ -236,8 +236,8 @@ postquel_sub_params(execution_state * es,
|
|||||||
char *args[],
|
char *args[],
|
||||||
bool * nullV)
|
bool * nullV)
|
||||||
{
|
{
|
||||||
ParamListInfo paramLI;
|
ParamListInfo paramLI;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
|
|
||||||
estate = es->estate;
|
estate = es->estate;
|
||||||
paramLI = estate->es_param_list_info;
|
paramLI = estate->es_param_list_info;
|
||||||
@@ -259,9 +259,9 @@ copy_function_result(FunctionCachePtr fcache,
|
|||||||
TupleTableSlot * resultSlot)
|
TupleTableSlot * resultSlot)
|
||||||
{
|
{
|
||||||
TupleTableSlot *funcSlot;
|
TupleTableSlot *funcSlot;
|
||||||
TupleDesc resultTd;
|
TupleDesc resultTd;
|
||||||
HeapTuple newTuple;
|
HeapTuple newTuple;
|
||||||
HeapTuple oldTuple;
|
HeapTuple oldTuple;
|
||||||
|
|
||||||
Assert(!TupIsNull(resultSlot));
|
Assert(!TupIsNull(resultSlot));
|
||||||
oldTuple = resultSlot->val;
|
oldTuple = resultSlot->val;
|
||||||
@@ -279,8 +279,8 @@ copy_function_result(FunctionCachePtr fcache,
|
|||||||
*/
|
*/
|
||||||
if (TupIsNull(funcSlot))
|
if (TupIsNull(funcSlot))
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
TupleDesc funcTd = funcSlot->ttc_tupleDescriptor;
|
TupleDesc funcTd = funcSlot->ttc_tupleDescriptor;
|
||||||
|
|
||||||
while (i < oldTuple->t_natts)
|
while (i < oldTuple->t_natts)
|
||||||
{
|
{
|
||||||
@@ -298,7 +298,7 @@ copy_function_result(FunctionCachePtr fcache,
|
|||||||
return ExecStoreTuple(newTuple, funcSlot, InvalidBuffer, true);
|
return ExecStoreTuple(newTuple, funcSlot, InvalidBuffer, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Datum
|
static Datum
|
||||||
postquel_execute(execution_state * es,
|
postquel_execute(execution_state * es,
|
||||||
FunctionCachePtr fcache,
|
FunctionCachePtr fcache,
|
||||||
List * fTlist,
|
List * fTlist,
|
||||||
@@ -306,7 +306,7 @@ postquel_execute(execution_state * es,
|
|||||||
bool * isNull)
|
bool * isNull)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
Datum value;
|
Datum value;
|
||||||
|
|
||||||
#ifdef INDEXSCAN_PATCH
|
#ifdef INDEXSCAN_PATCH
|
||||||
|
|
||||||
@@ -360,8 +360,8 @@ postquel_execute(execution_state * es,
|
|||||||
resSlot = copy_function_result(fcache, slot);
|
resSlot = copy_function_result(fcache, slot);
|
||||||
if (fTlist != NIL)
|
if (fTlist != NIL)
|
||||||
{
|
{
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
TargetEntry *tle = lfirst(fTlist);
|
TargetEntry *tle = lfirst(fTlist);
|
||||||
|
|
||||||
tup = resSlot->val;
|
tup = resSlot->val;
|
||||||
value = ProjectAttribute(resSlot->ttc_tupleDescriptor,
|
value = ProjectAttribute(resSlot->ttc_tupleDescriptor,
|
||||||
@@ -401,9 +401,9 @@ Datum
|
|||||||
postquel_function(Func * funcNode, char **args, bool * isNull, bool * isDone)
|
postquel_function(Func * funcNode, char **args, bool * isNull, bool * isDone)
|
||||||
{
|
{
|
||||||
execution_state *es;
|
execution_state *es;
|
||||||
Datum result = 0;
|
Datum result = 0;
|
||||||
FunctionCachePtr fcache = funcNode->func_fcache;
|
FunctionCachePtr fcache = funcNode->func_fcache;
|
||||||
CommandId savedId;
|
CommandId savedId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before we start do anything we must save CurrentScanCommandId to
|
* Before we start do anything we must save CurrentScanCommandId to
|
||||||
|
|||||||
@@ -36,18 +36,18 @@
|
|||||||
*/
|
*/
|
||||||
typedef struct AggFuncInfo
|
typedef struct AggFuncInfo
|
||||||
{
|
{
|
||||||
Oid xfn1_oid;
|
Oid xfn1_oid;
|
||||||
Oid xfn2_oid;
|
Oid xfn2_oid;
|
||||||
Oid finalfn_oid;
|
Oid finalfn_oid;
|
||||||
func_ptr xfn1;
|
func_ptr xfn1;
|
||||||
func_ptr xfn2;
|
func_ptr xfn2;
|
||||||
func_ptr finalfn;
|
func_ptr finalfn;
|
||||||
int xfn1_nargs;
|
int xfn1_nargs;
|
||||||
int xfn2_nargs;
|
int xfn2_nargs;
|
||||||
int finalfn_nargs;
|
int finalfn_nargs;
|
||||||
} AggFuncInfo;
|
} AggFuncInfo;
|
||||||
|
|
||||||
static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull);
|
static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull);
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------
|
/* ---------------------------------------
|
||||||
@@ -90,26 +90,26 @@ static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull);
|
|||||||
TupleTableSlot *
|
TupleTableSlot *
|
||||||
ExecAgg(Agg * node)
|
ExecAgg(Agg * node)
|
||||||
{
|
{
|
||||||
AggState *aggstate;
|
AggState *aggstate;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
Aggreg **aggregates;
|
Aggreg **aggregates;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
int i,
|
int i,
|
||||||
nagg;
|
nagg;
|
||||||
Datum *value1,
|
Datum *value1,
|
||||||
*value2;
|
*value2;
|
||||||
int *noInitValue;
|
int *noInitValue;
|
||||||
AggFuncInfo *aggFuncInfo;
|
AggFuncInfo *aggFuncInfo;
|
||||||
long nTuplesAgged = 0;
|
long nTuplesAgged = 0;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
ProjectionInfo *projInfo;
|
ProjectionInfo *projInfo;
|
||||||
TupleTableSlot *resultSlot;
|
TupleTableSlot *resultSlot;
|
||||||
HeapTuple oneTuple;
|
HeapTuple oneTuple;
|
||||||
char *nulls;
|
char *nulls;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
bool isNull = FALSE,
|
bool isNull = FALSE,
|
||||||
isNull1 = FALSE,
|
isNull1 = FALSE,
|
||||||
isNull2 = FALSE;
|
isNull2 = FALSE;
|
||||||
|
|
||||||
/* ---------------------
|
/* ---------------------
|
||||||
* get state info from node
|
* get state info from node
|
||||||
@@ -143,19 +143,19 @@ ExecAgg(Agg * node)
|
|||||||
|
|
||||||
for (i = 0; i < nagg; i++)
|
for (i = 0; i < nagg; i++)
|
||||||
{
|
{
|
||||||
Aggreg *agg;
|
Aggreg *agg;
|
||||||
char *aggname;
|
char *aggname;
|
||||||
HeapTuple aggTuple;
|
HeapTuple aggTuple;
|
||||||
Form_pg_aggregate aggp;
|
Form_pg_aggregate aggp;
|
||||||
Oid xfn1_oid,
|
Oid xfn1_oid,
|
||||||
xfn2_oid,
|
xfn2_oid,
|
||||||
finalfn_oid;
|
finalfn_oid;
|
||||||
func_ptr xfn1_ptr,
|
func_ptr xfn1_ptr,
|
||||||
xfn2_ptr,
|
xfn2_ptr,
|
||||||
finalfn_ptr;
|
finalfn_ptr;
|
||||||
int xfn1_nargs,
|
int xfn1_nargs,
|
||||||
xfn2_nargs,
|
xfn2_nargs,
|
||||||
finalfn_nargs;
|
finalfn_nargs;
|
||||||
|
|
||||||
agg = aggregates[i];
|
agg = aggregates[i];
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ ExecAgg(Agg * node)
|
|||||||
*/
|
*/
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
HeapTuple outerTuple = NULL;
|
HeapTuple outerTuple = NULL;
|
||||||
TupleTableSlot *outerslot;
|
TupleTableSlot *outerslot;
|
||||||
|
|
||||||
isNull = isNull1 = isNull2 = 0;
|
isNull = isNull1 = isNull2 = 0;
|
||||||
@@ -258,9 +258,9 @@ ExecAgg(Agg * node)
|
|||||||
*/
|
*/
|
||||||
if (nTuplesAgged == 0)
|
if (nTuplesAgged == 0)
|
||||||
{
|
{
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
Datum *tupValue;
|
Datum *tupValue;
|
||||||
char *null_array;
|
char *null_array;
|
||||||
|
|
||||||
tupType = aggstate->csstate.css_ScanTupleSlot->ttc_tupleDescriptor;
|
tupType = aggstate->csstate.css_ScanTupleSlot->ttc_tupleDescriptor;
|
||||||
tupValue = projInfo->pi_tupValue;
|
tupValue = projInfo->pi_tupValue;
|
||||||
@@ -277,29 +277,29 @@ ExecAgg(Agg * node)
|
|||||||
|
|
||||||
for (i = 0; i < nagg; i++)
|
for (i = 0; i < nagg; i++)
|
||||||
{
|
{
|
||||||
AttrNumber attnum;
|
AttrNumber attnum;
|
||||||
int2 attlen;
|
int2 attlen;
|
||||||
Datum newVal = (Datum) NULL;
|
Datum newVal = (Datum) NULL;
|
||||||
AggFuncInfo *aggfns = &aggFuncInfo[i];
|
AggFuncInfo *aggfns = &aggFuncInfo[i];
|
||||||
Datum args[2];
|
Datum args[2];
|
||||||
Node *tagnode = NULL;
|
Node *tagnode = NULL;
|
||||||
|
|
||||||
switch (nodeTag(aggregates[i]->target))
|
switch (nodeTag(aggregates[i]->target))
|
||||||
{
|
{
|
||||||
case T_Var:
|
case T_Var:
|
||||||
tagnode = NULL;
|
tagnode = NULL;
|
||||||
newVal = aggGetAttr(outerslot,
|
newVal = aggGetAttr(outerslot,
|
||||||
aggregates[i],
|
aggregates[i],
|
||||||
&isNull);
|
&isNull);
|
||||||
break;
|
break;
|
||||||
case T_Expr:
|
case T_Expr:
|
||||||
tagnode = ((Expr *) aggregates[i]->target)->oper;
|
tagnode = ((Expr *) aggregates[i]->target)->oper;
|
||||||
econtext->ecxt_scantuple = outerslot;
|
econtext->ecxt_scantuple = outerslot;
|
||||||
newVal = ExecEvalExpr(aggregates[i]->target, econtext,
|
newVal = ExecEvalExpr(aggregates[i]->target, econtext,
|
||||||
&isNull, NULL);
|
&isNull, NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN, "ExecAgg: Bad Agg->Target for Agg %d", i);
|
elog(WARN, "ExecAgg: Bad Agg->Target for Agg %d", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNull)
|
if (isNull)
|
||||||
@@ -309,7 +309,7 @@ ExecAgg(Agg * node)
|
|||||||
{
|
{
|
||||||
if (noInitValue[i])
|
if (noInitValue[i])
|
||||||
{
|
{
|
||||||
int byVal;
|
int byVal;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* value1 and value2 has not been initialized. This is
|
* value1 and value2 has not been initialized. This is
|
||||||
@@ -371,7 +371,7 @@ ExecAgg(Agg * node)
|
|||||||
|
|
||||||
if (aggfns->xfn2)
|
if (aggfns->xfn2)
|
||||||
{
|
{
|
||||||
Datum xfn2_val = value2[i];
|
Datum xfn2_val = value2[i];
|
||||||
|
|
||||||
value2[i] =
|
value2[i] =
|
||||||
(Datum) fmgr_c(aggfns->xfn2, aggfns->xfn2_oid,
|
(Datum) fmgr_c(aggfns->xfn2, aggfns->xfn2_oid,
|
||||||
@@ -399,8 +399,8 @@ ExecAgg(Agg * node)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < nagg; i++)
|
for (i = 0; i < nagg; i++)
|
||||||
{
|
{
|
||||||
char *args[2];
|
char *args[2];
|
||||||
AggFuncInfo *aggfns = &aggFuncInfo[i];
|
AggFuncInfo *aggfns = &aggFuncInfo[i];
|
||||||
|
|
||||||
if (noInitValue[i])
|
if (noInitValue[i])
|
||||||
{
|
{
|
||||||
@@ -490,9 +490,9 @@ ExecAgg(Agg * node)
|
|||||||
bool
|
bool
|
||||||
ExecInitAgg(Agg * node, EState * estate, Plan * parent)
|
ExecInitAgg(Agg * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
AggState *aggstate;
|
AggState *aggstate;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* assign the node's execution state
|
* assign the node's execution state
|
||||||
@@ -566,8 +566,8 @@ ExecCountSlotsAgg(Agg * node)
|
|||||||
void
|
void
|
||||||
ExecEndAgg(Agg * node)
|
ExecEndAgg(Agg * node)
|
||||||
{
|
{
|
||||||
AggState *aggstate;
|
AggState *aggstate;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
|
|
||||||
aggstate = node->aggstate;
|
aggstate = node->aggstate;
|
||||||
|
|
||||||
@@ -590,16 +590,16 @@ ExecEndAgg(Agg * node)
|
|||||||
* get the attribute (specified in the Var node in agg) to aggregate
|
* get the attribute (specified in the Var node in agg) to aggregate
|
||||||
* over from the tuple
|
* over from the tuple
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
aggGetAttr(TupleTableSlot * slot,
|
aggGetAttr(TupleTableSlot * slot,
|
||||||
Aggreg * agg,
|
Aggreg * agg,
|
||||||
bool * isNull)
|
bool * isNull)
|
||||||
{
|
{
|
||||||
Datum result;
|
Datum result;
|
||||||
AttrNumber attnum;
|
AttrNumber attnum;
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
TupleDesc tuple_type;
|
TupleDesc tuple_type;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* extract tuple information from the slot
|
* extract tuple information from the slot
|
||||||
@@ -619,8 +619,8 @@ aggGetAttr(TupleTableSlot * slot,
|
|||||||
if (attnum == InvalidAttrNumber)
|
if (attnum == InvalidAttrNumber)
|
||||||
{
|
{
|
||||||
TupleTableSlot *tempSlot;
|
TupleTableSlot *tempSlot;
|
||||||
TupleDesc td;
|
TupleDesc td;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
tempSlot = makeNode(TupleTableSlot);
|
tempSlot = makeNode(TupleTableSlot);
|
||||||
tempSlot->ttc_shouldFree = false;
|
tempSlot->ttc_shouldFree = false;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.6 1997/09/07 04:41:30 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.7 1997/09/08 02:22:40 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
#include "utils/mcxt.h"
|
#include "utils/mcxt.h"
|
||||||
#include "parser/parsetree.h" /* for rt_store() macro */
|
#include "parser/parsetree.h" /* for rt_store() macro */
|
||||||
|
|
||||||
static bool exec_append_initialize_next(Append * node);
|
static bool exec_append_initialize_next(Append * node);
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* exec-append-initialize-next
|
* exec-append-initialize-next
|
||||||
@@ -75,20 +75,20 @@ static bool exec_append_initialize_next(Append * node);
|
|||||||
* Returns t iff there is a "next" scan to process.
|
* Returns t iff there is a "next" scan to process.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
exec_append_initialize_next(Append * node)
|
exec_append_initialize_next(Append * node)
|
||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
AppendState *unionstate;
|
AppendState *unionstate;
|
||||||
TupleTableSlot *result_slot;
|
TupleTableSlot *result_slot;
|
||||||
List *rangeTable;
|
List *rangeTable;
|
||||||
|
|
||||||
int whichplan;
|
int whichplan;
|
||||||
int nplans;
|
int nplans;
|
||||||
List *rtentries;
|
List *rtentries;
|
||||||
ResTarget *rtentry;
|
ResTarget *rtentry;
|
||||||
|
|
||||||
Index unionrelid;
|
Index unionrelid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get information from the append node
|
* get information from the append node
|
||||||
@@ -184,16 +184,16 @@ exec_append_initialize_next(Append * node)
|
|||||||
bool
|
bool
|
||||||
ExecInitAppend(Append * node, EState * estate, Plan * parent)
|
ExecInitAppend(Append * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
AppendState *unionstate;
|
AppendState *unionstate;
|
||||||
int nplans;
|
int nplans;
|
||||||
List *resultList = NULL;
|
List *resultList = NULL;
|
||||||
List *rtentries;
|
List *rtentries;
|
||||||
List *unionplans;
|
List *unionplans;
|
||||||
bool *initialized;
|
bool *initialized;
|
||||||
int i;
|
int i;
|
||||||
Plan *initNode;
|
Plan *initNode;
|
||||||
List *junkList;
|
List *junkList;
|
||||||
RelationInfo *es_rri = estate->es_result_relation_info;
|
RelationInfo *es_rri = estate->es_result_relation_info;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* assign execution state to node and get information
|
* assign execution state to node and get information
|
||||||
@@ -251,13 +251,13 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent)
|
|||||||
if ((es_rri != (RelationInfo *) NULL) &&
|
if ((es_rri != (RelationInfo *) NULL) &&
|
||||||
(node->unionrelid == es_rri->ri_RangeTableIndex))
|
(node->unionrelid == es_rri->ri_RangeTableIndex))
|
||||||
{
|
{
|
||||||
RelationInfo *rri;
|
RelationInfo *rri;
|
||||||
List *rtentryP;
|
List *rtentryP;
|
||||||
|
|
||||||
foreach(rtentryP, rtentries)
|
foreach(rtentryP, rtentries)
|
||||||
{
|
{
|
||||||
Oid reloid;
|
Oid reloid;
|
||||||
RangeTblEntry *rtentry = lfirst(rtentryP);
|
RangeTblEntry *rtentry = lfirst(rtentryP);
|
||||||
|
|
||||||
reloid = rtentry->relid;
|
reloid = rtentry->relid;
|
||||||
rri = makeNode(RelationInfo);
|
rri = makeNode(RelationInfo);
|
||||||
@@ -281,8 +281,8 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent)
|
|||||||
|
|
||||||
for (i = 0; i < nplans; i++)
|
for (i = 0; i < nplans; i++)
|
||||||
{
|
{
|
||||||
JunkFilter *j;
|
JunkFilter *j;
|
||||||
List *targetList;
|
List *targetList;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* NOTE: we first modify range table in
|
* NOTE: we first modify range table in
|
||||||
@@ -343,9 +343,9 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent)
|
|||||||
int
|
int
|
||||||
ExecCountSlotsAppend(Append * node)
|
ExecCountSlotsAppend(Append * node)
|
||||||
{
|
{
|
||||||
List *plan;
|
List *plan;
|
||||||
List *unionplans = node->unionplans;
|
List *unionplans = node->unionplans;
|
||||||
int nSlots = 0;
|
int nSlots = 0;
|
||||||
|
|
||||||
foreach(plan, unionplans)
|
foreach(plan, unionplans)
|
||||||
{
|
{
|
||||||
@@ -365,15 +365,15 @@ ExecCountSlotsAppend(Append * node)
|
|||||||
TupleTableSlot *
|
TupleTableSlot *
|
||||||
ExecProcAppend(Append * node)
|
ExecProcAppend(Append * node)
|
||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
AppendState *unionstate;
|
AppendState *unionstate;
|
||||||
|
|
||||||
int whichplan;
|
int whichplan;
|
||||||
List *unionplans;
|
List *unionplans;
|
||||||
Plan *subnode;
|
Plan *subnode;
|
||||||
TupleTableSlot *result;
|
TupleTableSlot *result;
|
||||||
TupleTableSlot *result_slot;
|
TupleTableSlot *result_slot;
|
||||||
ScanDirection direction;
|
ScanDirection direction;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get information from the node
|
* get information from the node
|
||||||
@@ -458,13 +458,13 @@ ExecProcAppend(Append * node)
|
|||||||
void
|
void
|
||||||
ExecEndAppend(Append * node)
|
ExecEndAppend(Append * node)
|
||||||
{
|
{
|
||||||
AppendState *unionstate;
|
AppendState *unionstate;
|
||||||
int nplans;
|
int nplans;
|
||||||
List *unionplans;
|
List *unionplans;
|
||||||
bool *initialized;
|
bool *initialized;
|
||||||
int i;
|
int i;
|
||||||
List *resultRelationInfoList;
|
List *resultRelationInfoList;
|
||||||
RelationInfo *resultRelationInfo;
|
RelationInfo *resultRelationInfo;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get information from the node
|
* get information from the node
|
||||||
@@ -494,7 +494,7 @@ ExecEndAppend(Append * node)
|
|||||||
resultRelationInfoList = unionstate->as_result_relation_info_list;
|
resultRelationInfoList = unionstate->as_result_relation_info_list;
|
||||||
while (resultRelationInfoList != NIL)
|
while (resultRelationInfoList != NIL)
|
||||||
{
|
{
|
||||||
Relation resultRelationDesc;
|
Relation resultRelationDesc;
|
||||||
|
|
||||||
resultRelationInfo = (RelationInfo *) lfirst(resultRelationInfoList);
|
resultRelationInfo = (RelationInfo *) lfirst(resultRelationInfoList);
|
||||||
resultRelationDesc = resultRelationInfo->ri_RelationDesc;
|
resultRelationDesc = resultRelationInfo->ri_RelationDesc;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* columns. (ie. tuples from the same group are consecutive)
|
* columns. (ie. tuples from the same group are consecutive)
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.6 1997/09/07 04:41:31 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.7 1997/09/08 02:22:41 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -66,17 +66,17 @@ ExecGroup(Group * node)
|
|||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
ExecGroupEveryTuple(Group * node)
|
ExecGroupEveryTuple(Group * node)
|
||||||
{
|
{
|
||||||
GroupState *grpstate;
|
GroupState *grpstate;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
|
|
||||||
HeapTuple outerTuple = NULL;
|
HeapTuple outerTuple = NULL;
|
||||||
TupleTableSlot *outerslot,
|
TupleTableSlot *outerslot,
|
||||||
*lastslot;
|
*lastslot;
|
||||||
ProjectionInfo *projInfo;
|
ProjectionInfo *projInfo;
|
||||||
TupleTableSlot *resultSlot;
|
TupleTableSlot *resultSlot;
|
||||||
|
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
/* ---------------------
|
/* ---------------------
|
||||||
* get state info from node
|
* get state info from node
|
||||||
@@ -167,17 +167,17 @@ ExecGroupEveryTuple(Group * node)
|
|||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
ExecGroupOneTuple(Group * node)
|
ExecGroupOneTuple(Group * node)
|
||||||
{
|
{
|
||||||
GroupState *grpstate;
|
GroupState *grpstate;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
|
|
||||||
HeapTuple outerTuple = NULL;
|
HeapTuple outerTuple = NULL;
|
||||||
TupleTableSlot *outerslot,
|
TupleTableSlot *outerslot,
|
||||||
*lastslot;
|
*lastslot;
|
||||||
ProjectionInfo *projInfo;
|
ProjectionInfo *projInfo;
|
||||||
TupleTableSlot *resultSlot;
|
TupleTableSlot *resultSlot;
|
||||||
|
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
/* ---------------------
|
/* ---------------------
|
||||||
* get state info from node
|
* get state info from node
|
||||||
@@ -291,8 +291,8 @@ ExecGroupOneTuple(Group * node)
|
|||||||
bool
|
bool
|
||||||
ExecInitGroup(Group * node, EState * estate, Plan * parent)
|
ExecInitGroup(Group * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
GroupState *grpstate;
|
GroupState *grpstate;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* assign the node's execution state
|
* assign the node's execution state
|
||||||
@@ -358,8 +358,8 @@ ExecCountSlotsGroup(Group * node)
|
|||||||
void
|
void
|
||||||
ExecEndGroup(Group * node)
|
ExecEndGroup(Group * node)
|
||||||
{
|
{
|
||||||
GroupState *grpstate;
|
GroupState *grpstate;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
|
|
||||||
grpstate = node->grpstate;
|
grpstate = node->grpstate;
|
||||||
|
|
||||||
@@ -379,22 +379,22 @@ ExecEndGroup(Group * node)
|
|||||||
/*
|
/*
|
||||||
* code swiped from nodeUnique.c
|
* code swiped from nodeUnique.c
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
sameGroup(TupleTableSlot * oldslot,
|
sameGroup(TupleTableSlot * oldslot,
|
||||||
TupleTableSlot * newslot,
|
TupleTableSlot * newslot,
|
||||||
int numCols,
|
int numCols,
|
||||||
AttrNumber * grpColIdx,
|
AttrNumber * grpColIdx,
|
||||||
TupleDesc tupdesc)
|
TupleDesc tupdesc)
|
||||||
{
|
{
|
||||||
bool isNull1,
|
bool isNull1,
|
||||||
isNull2;
|
isNull2;
|
||||||
char *attr1,
|
char *attr1,
|
||||||
*attr2;
|
*attr2;
|
||||||
char *val1,
|
char *val1,
|
||||||
*val2;
|
*val2;
|
||||||
int i;
|
int i;
|
||||||
AttrNumber att;
|
AttrNumber att;
|
||||||
Oid typoutput;
|
Oid typoutput;
|
||||||
|
|
||||||
for (i = 0; i < numCols; i++)
|
for (i = 0; i < numCols; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.11 1997/09/07 04:41:32 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.12 1997/09/08 02:22:42 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -42,12 +42,12 @@
|
|||||||
#include "utils/palloc.h"
|
#include "utils/palloc.h"
|
||||||
#include "utils/hsearch.h"
|
#include "utils/hsearch.h"
|
||||||
|
|
||||||
extern int NBuffers;
|
extern int NBuffers;
|
||||||
static int HashTBSize;
|
static int HashTBSize;
|
||||||
|
|
||||||
static void mk_hj_temp(char *tempname);
|
static void mk_hj_temp(char *tempname);
|
||||||
static int hashFunc(char *key, int len);
|
static int hashFunc(char *key, int len);
|
||||||
static int ExecHashPartition(Hash * node);
|
static int ExecHashPartition(Hash * node);
|
||||||
static RelativeAddr hashTableAlloc(int size, HashJoinTable hashtable);
|
static RelativeAddr hashTableAlloc(int size, HashJoinTable hashtable);
|
||||||
static void
|
static void
|
||||||
ExecHashOverflowInsert(HashJoinTable hashtable,
|
ExecHashOverflowInsert(HashJoinTable hashtable,
|
||||||
@@ -64,20 +64,20 @@ ExecHashOverflowInsert(HashJoinTable hashtable,
|
|||||||
TupleTableSlot *
|
TupleTableSlot *
|
||||||
ExecHash(Hash * node)
|
ExecHash(Hash * node)
|
||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
HashState *hashstate;
|
HashState *hashstate;
|
||||||
Plan *outerNode;
|
Plan *outerNode;
|
||||||
Var *hashkey;
|
Var *hashkey;
|
||||||
HashJoinTable hashtable;
|
HashJoinTable hashtable;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
|
|
||||||
int nbatch;
|
int nbatch;
|
||||||
File *batches = NULL;
|
File *batches = NULL;
|
||||||
RelativeAddr *batchPos;
|
RelativeAddr *batchPos;
|
||||||
int *batchSizes;
|
int *batchSizes;
|
||||||
int i;
|
int i;
|
||||||
RelativeAddr *innerbatchNames;
|
RelativeAddr *innerbatchNames;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get state info from node
|
* get state info from node
|
||||||
@@ -167,8 +167,8 @@ ExecHash(Hash * node)
|
|||||||
bool
|
bool
|
||||||
ExecInitHash(Hash * node, EState * estate, Plan * parent)
|
ExecInitHash(Hash * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
HashState *hashstate;
|
HashState *hashstate;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
|
|
||||||
SO1_printf("ExecInitHash: %s\n",
|
SO1_printf("ExecInitHash: %s\n",
|
||||||
"initializing hash node");
|
"initializing hash node");
|
||||||
@@ -240,9 +240,9 @@ ExecCountSlotsHash(Hash * node)
|
|||||||
void
|
void
|
||||||
ExecEndHash(Hash * node)
|
ExecEndHash(Hash * node)
|
||||||
{
|
{
|
||||||
HashState *hashstate;
|
HashState *hashstate;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
File *batches;
|
File *batches;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get info from the hash state
|
* get info from the hash state
|
||||||
@@ -268,10 +268,10 @@ ExecEndHash(Hash * node)
|
|||||||
ExecEndNode(outerPlan, (Plan *) node);
|
ExecEndNode(outerPlan, (Plan *) node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RelativeAddr
|
static RelativeAddr
|
||||||
hashTableAlloc(int size, HashJoinTable hashtable)
|
hashTableAlloc(int size, HashJoinTable hashtable)
|
||||||
{
|
{
|
||||||
RelativeAddr p;
|
RelativeAddr p;
|
||||||
|
|
||||||
p = hashtable->top;
|
p = hashtable->top;
|
||||||
hashtable->top += size;
|
hashtable->top += size;
|
||||||
@@ -290,23 +290,23 @@ hashTableAlloc(int size, HashJoinTable hashtable)
|
|||||||
HashJoinTable
|
HashJoinTable
|
||||||
ExecHashTableCreate(Hash * node)
|
ExecHashTableCreate(Hash * node)
|
||||||
{
|
{
|
||||||
Plan *outerNode;
|
Plan *outerNode;
|
||||||
int nbatch;
|
int nbatch;
|
||||||
int ntuples;
|
int ntuples;
|
||||||
int tupsize;
|
int tupsize;
|
||||||
IpcMemoryId shmid;
|
IpcMemoryId shmid;
|
||||||
HashJoinTable hashtable;
|
HashJoinTable hashtable;
|
||||||
HashBucket bucket;
|
HashBucket bucket;
|
||||||
int nbuckets;
|
int nbuckets;
|
||||||
int totalbuckets;
|
int totalbuckets;
|
||||||
int bucketsize;
|
int bucketsize;
|
||||||
int i;
|
int i;
|
||||||
RelativeAddr *outerbatchNames;
|
RelativeAddr *outerbatchNames;
|
||||||
RelativeAddr *outerbatchPos;
|
RelativeAddr *outerbatchPos;
|
||||||
RelativeAddr *innerbatchNames;
|
RelativeAddr *innerbatchNames;
|
||||||
RelativeAddr *innerbatchPos;
|
RelativeAddr *innerbatchPos;
|
||||||
int *innerbatchSizes;
|
int *innerbatchSizes;
|
||||||
RelativeAddr tempname;
|
RelativeAddr tempname;
|
||||||
|
|
||||||
nbatch = -1;
|
nbatch = -1;
|
||||||
HashTBSize = NBuffers / 2;
|
HashTBSize = NBuffers / 2;
|
||||||
@@ -461,15 +461,15 @@ ExecHashTableInsert(HashJoinTable hashtable,
|
|||||||
File * batches)
|
File * batches)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
HashBucket bucket;
|
HashBucket bucket;
|
||||||
int bucketno;
|
int bucketno;
|
||||||
int nbatch;
|
int nbatch;
|
||||||
int batchno;
|
int batchno;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
RelativeAddr *batchPos;
|
RelativeAddr *batchPos;
|
||||||
int *batchSizes;
|
int *batchSizes;
|
||||||
char *pos;
|
char *pos;
|
||||||
|
|
||||||
nbatch = hashtable->nbatch;
|
nbatch = hashtable->nbatch;
|
||||||
batchPos = (RelativeAddr *) ABSADDR(hashtable->innerbatchPos);
|
batchPos = (RelativeAddr *) ABSADDR(hashtable->innerbatchPos);
|
||||||
@@ -551,9 +551,9 @@ ExecHashGetBucket(HashJoinTable hashtable,
|
|||||||
ExprContext * econtext,
|
ExprContext * econtext,
|
||||||
Var * hashkey)
|
Var * hashkey)
|
||||||
{
|
{
|
||||||
int bucketno;
|
int bucketno;
|
||||||
Datum keyval;
|
Datum keyval;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@@ -606,10 +606,10 @@ ExecHashOverflowInsert(HashJoinTable hashtable,
|
|||||||
HashBucket bucket,
|
HashBucket bucket,
|
||||||
HeapTuple heapTuple)
|
HeapTuple heapTuple)
|
||||||
{
|
{
|
||||||
OverflowTuple otuple;
|
OverflowTuple otuple;
|
||||||
RelativeAddr newend;
|
RelativeAddr newend;
|
||||||
OverflowTuple firstotuple;
|
OverflowTuple firstotuple;
|
||||||
OverflowTuple lastotuple;
|
OverflowTuple lastotuple;
|
||||||
|
|
||||||
firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple);
|
firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple);
|
||||||
lastotuple = (OverflowTuple) ABSADDR(bucket->lastotuple);
|
lastotuple = (OverflowTuple) ABSADDR(bucket->lastotuple);
|
||||||
@@ -687,14 +687,14 @@ ExecScanHashBucket(HashJoinState * hjstate,
|
|||||||
List * hjclauses,
|
List * hjclauses,
|
||||||
ExprContext * econtext)
|
ExprContext * econtext)
|
||||||
{
|
{
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
bool qualResult;
|
bool qualResult;
|
||||||
OverflowTuple otuple = NULL;
|
OverflowTuple otuple = NULL;
|
||||||
OverflowTuple curotuple;
|
OverflowTuple curotuple;
|
||||||
TupleTableSlot *inntuple;
|
TupleTableSlot *inntuple;
|
||||||
OverflowTuple firstotuple;
|
OverflowTuple firstotuple;
|
||||||
OverflowTuple lastotuple;
|
OverflowTuple lastotuple;
|
||||||
HashJoinTable hashtable;
|
HashJoinTable hashtable;
|
||||||
|
|
||||||
hashtable = hjstate->hj_HashTable;
|
hashtable = hjstate->hj_HashTable;
|
||||||
firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple);
|
firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple);
|
||||||
@@ -785,7 +785,7 @@ static int
|
|||||||
hashFunc(char *key, int len)
|
hashFunc(char *key, int len)
|
||||||
{
|
{
|
||||||
register unsigned int h;
|
register unsigned int h;
|
||||||
register int l;
|
register int l;
|
||||||
register unsigned char *k;
|
register unsigned char *k;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -828,11 +828,11 @@ hashFunc(char *key, int len)
|
|||||||
static int
|
static int
|
||||||
ExecHashPartition(Hash * node)
|
ExecHashPartition(Hash * node)
|
||||||
{
|
{
|
||||||
Plan *outerNode;
|
Plan *outerNode;
|
||||||
int b;
|
int b;
|
||||||
int pages;
|
int pages;
|
||||||
int ntuples;
|
int ntuples;
|
||||||
int tupsize;
|
int tupsize;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get size information for plan node
|
* get size information for plan node
|
||||||
@@ -866,8 +866,8 @@ ExecHashPartition(Hash * node)
|
|||||||
void
|
void
|
||||||
ExecHashTableReset(HashJoinTable hashtable, int ntuples)
|
ExecHashTableReset(HashJoinTable hashtable, int ntuples)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
HashBucket bucket;
|
HashBucket bucket;
|
||||||
|
|
||||||
hashtable->nbuckets = hashtable->totalbuckets
|
hashtable->nbuckets = hashtable->totalbuckets
|
||||||
= ceil((double) ntuples / NTUP_PER_BUCKET);
|
= ceil((double) ntuples / NTUP_PER_BUCKET);
|
||||||
@@ -886,7 +886,7 @@ ExecHashTableReset(HashJoinTable hashtable, int ntuples)
|
|||||||
hashtable->pcount = hashtable->nprocess;
|
hashtable->pcount = hashtable->nprocess;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hjtmpcnt = 0;
|
static int hjtmpcnt = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mk_hj_temp(char *tempname)
|
mk_hj_temp(char *tempname)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.6 1997/09/07 04:41:33 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.7 1997/09/08 02:22:43 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
#include "utils/palloc.h"
|
#include "utils/palloc.h"
|
||||||
|
|
||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate);
|
ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate);
|
||||||
|
|
||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
ExecHashJoinGetSavedTuple(HashJoinState * hjstate, char *buffer,
|
ExecHashJoinGetSavedTuple(HashJoinState * hjstate, char *buffer,
|
||||||
@@ -43,7 +43,7 @@ static int
|
|||||||
ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable,
|
ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable,
|
||||||
int nbatch);
|
int nbatch);
|
||||||
|
|
||||||
static int ExecHashJoinNewBatch(HashJoinState * hjstate);
|
static int ExecHashJoinNewBatch(HashJoinState * hjstate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -59,39 +59,39 @@ static int ExecHashJoinNewBatch(HashJoinState * hjstate);
|
|||||||
TupleTableSlot * /* return: a tuple or NULL */
|
TupleTableSlot * /* return: a tuple or NULL */
|
||||||
ExecHashJoin(HashJoin * node)
|
ExecHashJoin(HashJoin * node)
|
||||||
{
|
{
|
||||||
HashJoinState *hjstate;
|
HashJoinState *hjstate;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
Plan *outerNode;
|
Plan *outerNode;
|
||||||
Hash *hashNode;
|
Hash *hashNode;
|
||||||
List *hjclauses;
|
List *hjclauses;
|
||||||
Expr *clause;
|
Expr *clause;
|
||||||
List *qual;
|
List *qual;
|
||||||
ScanDirection dir;
|
ScanDirection dir;
|
||||||
TupleTableSlot *inntuple;
|
TupleTableSlot *inntuple;
|
||||||
Var *outerVar;
|
Var *outerVar;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
|
|
||||||
HashJoinTable hashtable;
|
HashJoinTable hashtable;
|
||||||
int bucketno;
|
int bucketno;
|
||||||
HashBucket bucket;
|
HashBucket bucket;
|
||||||
HeapTuple curtuple;
|
HeapTuple curtuple;
|
||||||
|
|
||||||
bool qualResult;
|
bool qualResult;
|
||||||
|
|
||||||
TupleTableSlot *outerTupleSlot;
|
TupleTableSlot *outerTupleSlot;
|
||||||
TupleTableSlot *innerTupleSlot;
|
TupleTableSlot *innerTupleSlot;
|
||||||
int nbatch;
|
int nbatch;
|
||||||
int curbatch;
|
int curbatch;
|
||||||
File *outerbatches;
|
File *outerbatches;
|
||||||
RelativeAddr *outerbatchNames;
|
RelativeAddr *outerbatchNames;
|
||||||
RelativeAddr *outerbatchPos;
|
RelativeAddr *outerbatchPos;
|
||||||
Var *innerhashkey;
|
Var *innerhashkey;
|
||||||
int batch;
|
int batch;
|
||||||
int batchno;
|
int batchno;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int i;
|
int i;
|
||||||
bool hashPhaseDone;
|
bool hashPhaseDone;
|
||||||
char *pos;
|
char *pos;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get information from HashJoin node
|
* get information from HashJoin node
|
||||||
@@ -125,7 +125,7 @@ ExecHashJoin(HashJoin * node)
|
|||||||
if (hjstate->jstate.cs_TupFromTlist)
|
if (hjstate->jstate.cs_TupFromTlist)
|
||||||
{
|
{
|
||||||
TupleTableSlot *result;
|
TupleTableSlot *result;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
result = ExecProject(hjstate->jstate.cs_ProjInfo, &isDone);
|
result = ExecProject(hjstate->jstate.cs_ProjInfo, &isDone);
|
||||||
if (!isDone)
|
if (!isDone)
|
||||||
@@ -322,7 +322,7 @@ ExecHashJoin(HashJoin * node)
|
|||||||
{
|
{
|
||||||
ProjectionInfo *projInfo;
|
ProjectionInfo *projInfo;
|
||||||
TupleTableSlot *result;
|
TupleTableSlot *result;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
hjstate->hj_CurBucket = bucket;
|
hjstate->hj_CurBucket = bucket;
|
||||||
hjstate->hj_CurTuple = curtuple;
|
hjstate->hj_CurTuple = curtuple;
|
||||||
@@ -394,9 +394,9 @@ ExecHashJoin(HashJoin * node)
|
|||||||
bool /* return: initialization status */
|
bool /* return: initialization status */
|
||||||
ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent)
|
ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
HashJoinState *hjstate;
|
HashJoinState *hjstate;
|
||||||
Plan *outerNode;
|
Plan *outerNode;
|
||||||
Hash *hashNode;
|
Hash *hashNode;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* assign the node's execution state
|
* assign the node's execution state
|
||||||
@@ -451,7 +451,7 @@ ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent)
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
HashState *hashstate = hashNode->hashstate;
|
HashState *hashstate = hashNode->hashstate;
|
||||||
TupleTableSlot *slot =
|
TupleTableSlot *slot =
|
||||||
hashstate->cstate.cs_ResultTupleSlot;
|
hashstate->cstate.cs_ResultTupleSlot;
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ ExecCountSlotsHashJoin(HashJoin * node)
|
|||||||
void
|
void
|
||||||
ExecEndHashJoin(HashJoin * node)
|
ExecEndHashJoin(HashJoin * node)
|
||||||
{
|
{
|
||||||
HashJoinState *hjstate;
|
HashJoinState *hjstate;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get info from the HashJoin state
|
* get info from the HashJoin state
|
||||||
@@ -572,13 +572,13 @@ static TupleTableSlot *
|
|||||||
ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate)
|
ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
HashJoinTable hashtable;
|
HashJoinTable hashtable;
|
||||||
int curbatch;
|
int curbatch;
|
||||||
File *outerbatches;
|
File *outerbatches;
|
||||||
char *outerreadPos;
|
char *outerreadPos;
|
||||||
int batchno;
|
int batchno;
|
||||||
char *outerreadBuf;
|
char *outerreadBuf;
|
||||||
int outerreadBlk;
|
int outerreadBlk;
|
||||||
|
|
||||||
hashtable = hjstate->hj_HashTable;
|
hashtable = hjstate->hj_HashTable;
|
||||||
curbatch = hashtable->curbatch;
|
curbatch = hashtable->curbatch;
|
||||||
@@ -626,11 +626,11 @@ ExecHashJoinGetSavedTuple(HashJoinState * hjstate,
|
|||||||
int *block, /* return parameter */
|
int *block, /* return parameter */
|
||||||
char **position) /* return parameter */
|
char **position) /* return parameter */
|
||||||
{
|
{
|
||||||
char *bufstart;
|
char *bufstart;
|
||||||
char *bufend;
|
char *bufend;
|
||||||
int cc;
|
int cc;
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
HashJoinTable hashtable;
|
HashJoinTable hashtable;
|
||||||
|
|
||||||
hashtable = hjstate->hj_HashTable;
|
hashtable = hjstate->hj_HashTable;
|
||||||
bufend = buffer + *(long *) buffer;
|
bufend = buffer + *(long *) buffer;
|
||||||
@@ -666,20 +666,20 @@ ExecHashJoinGetSavedTuple(HashJoinState * hjstate,
|
|||||||
static int
|
static int
|
||||||
ExecHashJoinNewBatch(HashJoinState * hjstate)
|
ExecHashJoinNewBatch(HashJoinState * hjstate)
|
||||||
{
|
{
|
||||||
File *innerBatches;
|
File *innerBatches;
|
||||||
File *outerBatches;
|
File *outerBatches;
|
||||||
int *innerBatchSizes;
|
int *innerBatchSizes;
|
||||||
Var *innerhashkey;
|
Var *innerhashkey;
|
||||||
HashJoinTable hashtable;
|
HashJoinTable hashtable;
|
||||||
int nbatch;
|
int nbatch;
|
||||||
char *readPos;
|
char *readPos;
|
||||||
int readBlk;
|
int readBlk;
|
||||||
char *readBuf;
|
char *readBuf;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
int i;
|
int i;
|
||||||
int cc;
|
int cc;
|
||||||
int newbatch;
|
int newbatch;
|
||||||
|
|
||||||
hashtable = hjstate->hj_HashTable;
|
hashtable = hjstate->hj_HashTable;
|
||||||
outerBatches = hjstate->hj_OuterBatches;
|
outerBatches = hjstate->hj_OuterBatches;
|
||||||
@@ -793,7 +793,7 @@ ExecHashJoinNewBatch(HashJoinState * hjstate)
|
|||||||
static int
|
static int
|
||||||
ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch)
|
ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch)
|
||||||
{
|
{
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
if (bucketno < hashtable->nbuckets || nbatch == 0)
|
if (bucketno < hashtable->nbuckets || nbatch == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -813,16 +813,16 @@ ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch)
|
|||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ExecHashJoinSaveTuple(HeapTuple heapTuple,
|
ExecHashJoinSaveTuple(HeapTuple heapTuple,
|
||||||
char *buffer,
|
char *buffer,
|
||||||
File file,
|
File file,
|
||||||
char *position)
|
char *position)
|
||||||
{
|
{
|
||||||
long *pageend;
|
long *pageend;
|
||||||
char *pagestart;
|
char *pagestart;
|
||||||
char *pagebound;
|
char *pagebound;
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
pageend = (long *) buffer;
|
pageend = (long *) buffer;
|
||||||
pagestart = (char *) (buffer + sizeof(long));
|
pagestart = (char *) (buffer + sizeof(long));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.8 1997/09/07 04:41:35 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.9 1997/09/08 02:22:44 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -82,19 +82,19 @@ static TupleTableSlot *IndexNext(IndexScan * node);
|
|||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
IndexNext(IndexScan * node)
|
IndexNext(IndexScan * node)
|
||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
CommonScanState *scanstate;
|
CommonScanState *scanstate;
|
||||||
IndexScanState *indexstate;
|
IndexScanState *indexstate;
|
||||||
ScanDirection direction;
|
ScanDirection direction;
|
||||||
int indexPtr;
|
int indexPtr;
|
||||||
IndexScanDescPtr scanDescs;
|
IndexScanDescPtr scanDescs;
|
||||||
IndexScanDesc scandesc;
|
IndexScanDesc scandesc;
|
||||||
Relation heapRelation;
|
Relation heapRelation;
|
||||||
RetrieveIndexResult result;
|
RetrieveIndexResult result;
|
||||||
ItemPointer iptr;
|
ItemPointer iptr;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
Buffer buffer = InvalidBuffer;
|
Buffer buffer = InvalidBuffer;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* extract necessary information from index scan node
|
* extract necessary information from index scan node
|
||||||
@@ -219,30 +219,30 @@ ExecIndexScan(IndexScan * node)
|
|||||||
void
|
void
|
||||||
ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent)
|
ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent)
|
||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
IndexScanState *indexstate;
|
IndexScanState *indexstate;
|
||||||
ScanDirection direction;
|
ScanDirection direction;
|
||||||
IndexScanDescPtr scanDescs;
|
IndexScanDescPtr scanDescs;
|
||||||
ScanKey *scanKeys;
|
ScanKey *scanKeys;
|
||||||
IndexScanDesc sdesc;
|
IndexScanDesc sdesc;
|
||||||
ScanKey skey;
|
ScanKey skey;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Pointer *runtimeKeyInfo;
|
Pointer *runtimeKeyInfo;
|
||||||
int indexPtr;
|
int indexPtr;
|
||||||
int *numScanKeys;
|
int *numScanKeys;
|
||||||
List *indxqual;
|
List *indxqual;
|
||||||
List *qual;
|
List *qual;
|
||||||
int n_keys;
|
int n_keys;
|
||||||
ScanKey scan_keys;
|
ScanKey scan_keys;
|
||||||
int *run_keys;
|
int *run_keys;
|
||||||
int j;
|
int j;
|
||||||
Expr *clause;
|
Expr *clause;
|
||||||
Node *scanexpr;
|
Node *scanexpr;
|
||||||
Datum scanvalue;
|
Datum scanvalue;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
indexstate = node->indxstate;
|
indexstate = node->indxstate;
|
||||||
estate = node->scan.plan.state;
|
estate = node->scan.plan.state;
|
||||||
@@ -335,9 +335,9 @@ ExecEndIndexScan(IndexScan * node)
|
|||||||
{
|
{
|
||||||
CommonScanState *scanstate;
|
CommonScanState *scanstate;
|
||||||
IndexScanState *indexstate;
|
IndexScanState *indexstate;
|
||||||
ScanKey *scanKeys;
|
ScanKey *scanKeys;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
scanstate = node->scan.scanstate;
|
scanstate = node->scan.scanstate;
|
||||||
indexstate = node->indxstate;
|
indexstate = node->indxstate;
|
||||||
@@ -399,8 +399,8 @@ ExecIndexMarkPos(IndexScan * node)
|
|||||||
{
|
{
|
||||||
IndexScanState *indexstate;
|
IndexScanState *indexstate;
|
||||||
IndexScanDescPtr indexScanDescs;
|
IndexScanDescPtr indexScanDescs;
|
||||||
IndexScanDesc scanDesc;
|
IndexScanDesc scanDesc;
|
||||||
int indexPtr;
|
int indexPtr;
|
||||||
|
|
||||||
indexstate = node->indxstate;
|
indexstate = node->indxstate;
|
||||||
indexPtr = indexstate->iss_IndexPtr;
|
indexPtr = indexstate->iss_IndexPtr;
|
||||||
@@ -430,8 +430,8 @@ ExecIndexRestrPos(IndexScan * node)
|
|||||||
{
|
{
|
||||||
IndexScanState *indexstate;
|
IndexScanState *indexstate;
|
||||||
IndexScanDescPtr indexScanDescs;
|
IndexScanDescPtr indexScanDescs;
|
||||||
IndexScanDesc scanDesc;
|
IndexScanDesc scanDesc;
|
||||||
int indexPtr;
|
int indexPtr;
|
||||||
|
|
||||||
indexstate = node->indxstate;
|
indexstate = node->indxstate;
|
||||||
indexPtr = indexstate->iss_IndexPtr;
|
indexPtr = indexstate->iss_IndexPtr;
|
||||||
@@ -465,27 +465,27 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent)
|
|||||||
{
|
{
|
||||||
IndexScanState *indexstate;
|
IndexScanState *indexstate;
|
||||||
CommonScanState *scanstate;
|
CommonScanState *scanstate;
|
||||||
List *indxqual;
|
List *indxqual;
|
||||||
List *indxid;
|
List *indxid;
|
||||||
int i;
|
int i;
|
||||||
int numIndices;
|
int numIndices;
|
||||||
int indexPtr;
|
int indexPtr;
|
||||||
ScanKey *scanKeys;
|
ScanKey *scanKeys;
|
||||||
int *numScanKeys;
|
int *numScanKeys;
|
||||||
RelationPtr relationDescs;
|
RelationPtr relationDescs;
|
||||||
IndexScanDescPtr scanDescs;
|
IndexScanDescPtr scanDescs;
|
||||||
Pointer *runtimeKeyInfo;
|
Pointer *runtimeKeyInfo;
|
||||||
bool have_runtime_keys;
|
bool have_runtime_keys;
|
||||||
List *rangeTable;
|
List *rangeTable;
|
||||||
RangeTblEntry *rtentry;
|
RangeTblEntry *rtentry;
|
||||||
Index relid;
|
Index relid;
|
||||||
Oid reloid;
|
Oid reloid;
|
||||||
TimeQual timeQual;
|
TimeQual timeQual;
|
||||||
|
|
||||||
Relation currentRelation;
|
Relation currentRelation;
|
||||||
HeapScanDesc currentScanDesc;
|
HeapScanDesc currentScanDesc;
|
||||||
ScanDirection direction;
|
ScanDirection direction;
|
||||||
int baseid;
|
int baseid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* assign execution state to node
|
* assign execution state to node
|
||||||
@@ -600,11 +600,11 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < numIndices; i++)
|
for (i = 0; i < numIndices; i++)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
List *qual;
|
List *qual;
|
||||||
int n_keys;
|
int n_keys;
|
||||||
ScanKey scan_keys;
|
ScanKey scan_keys;
|
||||||
int *run_keys;
|
int *run_keys;
|
||||||
|
|
||||||
qual = nth(i, indxqual);
|
qual = nth(i, indxqual);
|
||||||
n_keys = length(qual);
|
n_keys = length(qual);
|
||||||
@@ -623,17 +623,16 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent)
|
|||||||
*/
|
*/
|
||||||
for (j = 0; j < n_keys; j++)
|
for (j = 0; j < n_keys; j++)
|
||||||
{
|
{
|
||||||
Expr *clause; /* one part of index qual */
|
Expr *clause; /* one part of index qual */
|
||||||
Oper *op; /* operator used in scan.. */
|
Oper *op; /* operator used in scan.. */
|
||||||
Node *leftop; /* expr on lhs of operator */
|
Node *leftop; /* expr on lhs of operator */
|
||||||
Node *rightop; /* expr on rhs ... */
|
Node *rightop;/* expr on rhs ... */
|
||||||
bits16 flags = 0;
|
bits16 flags = 0;
|
||||||
|
|
||||||
int scanvar; /* which var identifies varattno */
|
int scanvar;/* which var identifies varattno */
|
||||||
AttrNumber varattno = 0; /* att number used in scan */
|
AttrNumber varattno = 0; /* att number used in scan */
|
||||||
Oid opid; /* operator id used in scan */
|
Oid opid; /* operator id used in scan */
|
||||||
Datum scanvalue = 0; /* value used in scan (if
|
Datum scanvalue = 0; /* value used in scan (if const) */
|
||||||
* const) */
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* extract clause information from the qualification
|
* extract clause information from the qualification
|
||||||
@@ -702,7 +701,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent)
|
|||||||
}
|
}
|
||||||
else if (IsA(leftop, Param))
|
else if (IsA(leftop, Param))
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if the leftop is a Param node then it means
|
* if the leftop is a Param node then it means
|
||||||
@@ -785,7 +784,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent)
|
|||||||
}
|
}
|
||||||
else if (IsA(rightop, Param))
|
else if (IsA(rightop, Param))
|
||||||
{
|
{
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if the rightop is a Param node then it means
|
* if the rightop is a Param node then it means
|
||||||
@@ -885,8 +884,8 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent)
|
|||||||
indexstate->iss_RuntimeKeyInfo = NULL;
|
indexstate->iss_RuntimeKeyInfo = NULL;
|
||||||
for (i = 0; i < numIndices; i++)
|
for (i = 0; i < numIndices; i++)
|
||||||
{
|
{
|
||||||
List *qual;
|
List *qual;
|
||||||
int n_keys;
|
int n_keys;
|
||||||
|
|
||||||
qual = nth(i, indxqual);
|
qual = nth(i, indxqual);
|
||||||
n_keys = length(qual);
|
n_keys = length(qual);
|
||||||
@@ -947,7 +946,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < numIndices; i++)
|
for (i = 0; i < numIndices; i++)
|
||||||
{
|
{
|
||||||
Oid indexOid;
|
Oid indexOid;
|
||||||
|
|
||||||
indexOid = (Oid) nthi(i, indxid);
|
indexOid = (Oid) nthi(i, indxid);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.7 1997/09/07 04:41:36 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.8 1997/09/08 02:22:45 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -50,16 +50,16 @@
|
|||||||
TupleTableSlot * /* result tuple from subplan */
|
TupleTableSlot * /* result tuple from subplan */
|
||||||
ExecMaterial(Material * node)
|
ExecMaterial(Material * node)
|
||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
MaterialState *matstate;
|
MaterialState *matstate;
|
||||||
Plan *outerNode;
|
Plan *outerNode;
|
||||||
ScanDirection dir;
|
ScanDirection dir;
|
||||||
Relation tempRelation;
|
Relation tempRelation;
|
||||||
Relation currentRelation;
|
Relation currentRelation;
|
||||||
HeapScanDesc currentScanDesc;
|
HeapScanDesc currentScanDesc;
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get state info from node
|
* get state info from node
|
||||||
@@ -190,10 +190,10 @@ ExecMaterial(Material * node)
|
|||||||
bool /* initialization status */
|
bool /* initialization status */
|
||||||
ExecInitMaterial(Material * node, EState * estate, Plan * parent)
|
ExecInitMaterial(Material * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
MaterialState *matstate;
|
MaterialState *matstate;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
TupleDesc tupType;
|
TupleDesc tupType;
|
||||||
Relation tempDesc;
|
Relation tempDesc;
|
||||||
|
|
||||||
/* int len; */
|
/* int len; */
|
||||||
|
|
||||||
@@ -308,9 +308,9 @@ ExecCountSlotsMaterial(Material * node)
|
|||||||
void
|
void
|
||||||
ExecEndMaterial(Material * node)
|
ExecEndMaterial(Material * node)
|
||||||
{
|
{
|
||||||
MaterialState *matstate;
|
MaterialState *matstate;
|
||||||
Relation tempRelation;
|
Relation tempRelation;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get info from the material state
|
* get info from the material state
|
||||||
@@ -349,8 +349,8 @@ ExecEndMaterial(Material * node)
|
|||||||
List /* nothing of interest */
|
List /* nothing of interest */
|
||||||
ExecMaterialMarkPos(Material node)
|
ExecMaterialMarkPos(Material node)
|
||||||
{
|
{
|
||||||
MaterialState matstate;
|
MaterialState matstate;
|
||||||
HeapScanDesc sdesc;
|
HeapScanDesc sdesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if we haven't materialized yet, just return NIL.
|
* if we haven't materialized yet, just return NIL.
|
||||||
@@ -379,8 +379,8 @@ ExecMaterialMarkPos(Material node)
|
|||||||
void
|
void
|
||||||
ExecMaterialRestrPos(Material node)
|
ExecMaterialRestrPos(Material node)
|
||||||
{
|
{
|
||||||
MaterialState matstate;
|
MaterialState matstate;
|
||||||
HeapScanDesc sdesc;
|
HeapScanDesc sdesc;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* if we haven't materialized yet, just return.
|
* if we haven't materialized yet, just return.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.4 1997/09/07 04:41:41 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.5 1997/09/08 02:22:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -57,17 +57,17 @@
|
|||||||
TupleTableSlot *
|
TupleTableSlot *
|
||||||
ExecNestLoop(NestLoop * node, Plan * parent)
|
ExecNestLoop(NestLoop * node, Plan * parent)
|
||||||
{
|
{
|
||||||
NestLoopState *nlstate;
|
NestLoopState *nlstate;
|
||||||
Plan *innerPlan;
|
Plan *innerPlan;
|
||||||
Plan *outerPlan;
|
Plan *outerPlan;
|
||||||
bool needNewOuterTuple;
|
bool needNewOuterTuple;
|
||||||
|
|
||||||
TupleTableSlot *outerTupleSlot;
|
TupleTableSlot *outerTupleSlot;
|
||||||
TupleTableSlot *innerTupleSlot;
|
TupleTableSlot *innerTupleSlot;
|
||||||
|
|
||||||
List *qual;
|
List *qual;
|
||||||
bool qualResult;
|
bool qualResult;
|
||||||
ExprContext *econtext;
|
ExprContext *econtext;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* get information from the node
|
* get information from the node
|
||||||
@@ -86,7 +86,7 @@ ExecNestLoop(NestLoop * node, Plan * parent)
|
|||||||
*/
|
*/
|
||||||
econtext = nlstate->jstate.cs_ExprContext;
|
econtext = nlstate->jstate.cs_ExprContext;
|
||||||
|
|
||||||
/* ---------------- * get the current outer tuple
|
/* ---------------- * get the current outer tuple
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
outerTupleSlot = nlstate->jstate.cs_OuterTupleSlot;
|
outerTupleSlot = nlstate->jstate.cs_OuterTupleSlot;
|
||||||
@@ -101,7 +101,7 @@ ExecNestLoop(NestLoop * node, Plan * parent)
|
|||||||
if (nlstate->jstate.cs_TupFromTlist)
|
if (nlstate->jstate.cs_TupFromTlist)
|
||||||
{
|
{
|
||||||
TupleTableSlot *result;
|
TupleTableSlot *result;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
result = ExecProject(nlstate->jstate.cs_ProjInfo, &isDone);
|
result = ExecProject(nlstate->jstate.cs_ProjInfo, &isDone);
|
||||||
if (!isDone)
|
if (!isDone)
|
||||||
@@ -238,7 +238,7 @@ ExecNestLoop(NestLoop * node, Plan * parent)
|
|||||||
*/
|
*/
|
||||||
ProjectionInfo *projInfo;
|
ProjectionInfo *projInfo;
|
||||||
TupleTableSlot *result;
|
TupleTableSlot *result;
|
||||||
bool isDone;
|
bool isDone;
|
||||||
|
|
||||||
ENL1_printf("qualification succeeded, projecting tuple");
|
ENL1_printf("qualification succeeded, projecting tuple");
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ ExecNestLoop(NestLoop * node, Plan * parent)
|
|||||||
bool
|
bool
|
||||||
ExecInitNestLoop(NestLoop * node, EState * estate, Plan * parent)
|
ExecInitNestLoop(NestLoop * node, EState * estate, Plan * parent)
|
||||||
{
|
{
|
||||||
NestLoopState *nlstate;
|
NestLoopState *nlstate;
|
||||||
|
|
||||||
NL1_printf("ExecInitNestLoop: %s\n",
|
NL1_printf("ExecInitNestLoop: %s\n",
|
||||||
"initializing node");
|
"initializing node");
|
||||||
@@ -347,7 +347,7 @@ ExecCountSlotsNestLoop(NestLoop * node)
|
|||||||
void
|
void
|
||||||
ExecEndNestLoop(NestLoop * node)
|
ExecEndNestLoop(NestLoop * node)
|
||||||
{
|
{
|
||||||
NestLoopState *nlstate;
|
NestLoopState *nlstate;
|
||||||
|
|
||||||
NL1_printf("ExecEndNestLoop: %s\n",
|
NL1_printf("ExecEndNestLoop: %s\n",
|
||||||
"ending node processing");
|
"ending node processing");
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user