Commit a32450a5 authored by Bruce Momjian's avatar Bruce Momjian

pgindent run before 6.3 release, with Thomas' requested changes.

parent 757bf69a
...@@ -35,28 +35,34 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -35,28 +35,34 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
int typlen; int typlen;
func_ptr proc_fn; func_ptr proc_fn;
int pronargs; int pronargs;
int nitems, i, result; int nitems,
int ndim, *dim; i,
result;
int ndim,
*dim;
char *p; char *p;
/* Sanity checks */ /* Sanity checks */
if ((array == (ArrayType *) NULL) if ((array == (ArrayType *) NULL)
|| (ARR_IS_LO(array) == true)) { || (ARR_IS_LO(array) == true))
{
/* elog(NOTICE, "array_iterator: array is null"); */ /* elog(NOTICE, "array_iterator: array is null"); */
return (0); return (0);
} }
ndim = ARR_NDIM(array); ndim = ARR_NDIM(array);
dim = ARR_DIMS(array); dim = ARR_DIMS(array);
nitems = getNitems(ndim, dim); nitems = getNitems(ndim, dim);
if (nitems == 0) { if (nitems == 0)
{
/* elog(NOTICE, "array_iterator: nitems = 0"); */ /* elog(NOTICE, "array_iterator: nitems = 0"); */
return (0); return (0);
} }
/* Lookup element type information */ /* Lookup element type information */
typ_tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(elemtype),0,0,0); typ_tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(elemtype), 0, 0, 0);
if (!HeapTupleIsValid(typ_tuple)) { if (!HeapTupleIsValid(typ_tuple))
elog(ERROR,"array_iterator: cache lookup failed for type %d", elemtype); {
elog(ERROR, "array_iterator: cache lookup failed for type %d", elemtype);
return 0; return 0;
} }
typ_struct = (TypeTupleForm) GETSTRUCT(typ_tuple); typ_struct = (TypeTupleForm) GETSTRUCT(typ_tuple);
...@@ -66,7 +72,8 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -66,7 +72,8 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
/* Lookup the function entry point */ /* Lookup the function entry point */
proc_fn = (func_ptr) NULL; proc_fn = (func_ptr) NULL;
fmgr_info(proc, &proc_fn, &pronargs); fmgr_info(proc, &proc_fn, &pronargs);
if ((proc_fn == NULL) || (pronargs != 2)) { if ((proc_fn == NULL) || (pronargs != 2))
{
elog(ERROR, "array_iterator: fmgr_info lookup failed for oid %d", proc); elog(ERROR, "array_iterator: fmgr_info lookup failed for oid %d", proc);
return (0); return (0);
} }
...@@ -74,43 +81,59 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -74,43 +81,59 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
/* Scan the array and apply the operator to each element */ /* Scan the array and apply the operator to each element */
result = 0; result = 0;
p = ARR_DATA_PTR(array); p = ARR_DATA_PTR(array);
for (i = 0; i < nitems; i++) { for (i = 0; i < nitems; i++)
if (typbyval) { {
switch(typlen) { if (typbyval)
{
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;
} else { }
result = (int) (*proc_fn)(p, value); else
if (typlen > 0) { {
result = (int) (*proc_fn) (p, value);
if (typlen > 0)
{
p += typlen; p += typlen;
} else { }
p += INTALIGN(* (int32 *) p); else
{
p += INTALIGN(*(int32 *) p);
} }
} }
if (result) { if (result)
if (!and) { {
if (!and)
{
return (1); return (1);
} }
} else { }
if (and) { else
{
if (and)
{
return (0); return (0);
} }
} }
} }
if (and && result) { if (and && result)
{
return (1); return (1);
} else { }
else
{
return (0); return (0);
} }
} }
...@@ -120,39 +143,39 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -120,39 +143,39 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
*/ */
int32 int32
array_texteq(ArrayType *array, char* value) array_texteq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 25, /* text */ return array_iterator((Oid) 25, /* text */
(Oid) 67, /* texteq */ (Oid) 67, /* texteq */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
array_all_texteq(ArrayType *array, char* value) array_all_texteq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 25, /* text */ return array_iterator((Oid) 25, /* text */
(Oid) 67, /* texteq */ (Oid) 67, /* texteq */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
array_textregexeq(ArrayType *array, char* value) array_textregexeq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 25, /* text */ return array_iterator((Oid) 25, /* text */
(Oid) 1254, /* textregexeq */ (Oid) 1254, /* textregexeq */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
array_all_textregexeq(ArrayType *array, char* value) array_all_textregexeq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 25, /* text */ return array_iterator((Oid) 25, /* text */
(Oid) 1254, /* textregexeq */ (Oid) 1254, /* textregexeq */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
/* /*
...@@ -161,39 +184,39 @@ array_all_textregexeq(ArrayType *array, char* value) ...@@ -161,39 +184,39 @@ array_all_textregexeq(ArrayType *array, char* value)
*/ */
int32 int32
array_char16eq(ArrayType *array, char* value) array_char16eq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* char16 */
(Oid) 1275, /* char16eq */ (Oid) 1275, /* char16eq */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
array_all_char16eq(ArrayType *array, char* value) array_all_char16eq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* char16 */
(Oid) 1275, /* char16eq */ (Oid) 1275, /* char16eq */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
array_char16regexeq(ArrayType *array, char* value) array_char16regexeq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* char16 */
(Oid) 1288, /* char16regexeq */ (Oid) 1288, /* char16regexeq */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
array_all_char16regexeq(ArrayType *array, char* value) array_all_char16regexeq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* char16 */
(Oid) 1288, /* char16regexeq */ (Oid) 1288, /* char16regexeq */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
/* /*
...@@ -206,7 +229,7 @@ array_int4eq(ArrayType *array, int4 value) ...@@ -206,7 +229,7 @@ array_int4eq(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 65, /* int4eq */ (Oid) 65, /* int4eq */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -215,7 +238,7 @@ array_all_int4eq(ArrayType *array, int4 value) ...@@ -215,7 +238,7 @@ array_all_int4eq(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 65, /* int4eq */ (Oid) 65, /* int4eq */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -224,7 +247,7 @@ array_int4ne(ArrayType *array, int4 value) ...@@ -224,7 +247,7 @@ array_int4ne(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 144, /* int4ne */ (Oid) 144, /* int4ne */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -233,7 +256,7 @@ array_all_int4ne(ArrayType *array, int4 value) ...@@ -233,7 +256,7 @@ array_all_int4ne(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 144, /* int4ne */ (Oid) 144, /* int4ne */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -242,7 +265,7 @@ array_int4gt(ArrayType *array, int4 value) ...@@ -242,7 +265,7 @@ array_int4gt(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 147, /* int4gt */ (Oid) 147, /* int4gt */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -251,7 +274,7 @@ array_all_int4gt(ArrayType *array, int4 value) ...@@ -251,7 +274,7 @@ array_all_int4gt(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 147, /* int4gt */ (Oid) 147, /* int4gt */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -260,7 +283,7 @@ array_int4ge(ArrayType *array, int4 value) ...@@ -260,7 +283,7 @@ array_int4ge(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 150, /* int4ge */ (Oid) 150, /* int4ge */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -269,7 +292,7 @@ array_all_int4ge(ArrayType *array, int4 value) ...@@ -269,7 +292,7 @@ array_all_int4ge(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 150, /* int4ge */ (Oid) 150, /* int4ge */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -278,7 +301,7 @@ array_int4lt(ArrayType *array, int4 value) ...@@ -278,7 +301,7 @@ array_int4lt(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 66, /* int4lt */ (Oid) 66, /* int4lt */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -287,7 +310,7 @@ array_all_int4lt(ArrayType *array, int4 value) ...@@ -287,7 +310,7 @@ array_all_int4lt(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 66, /* int4lt */ (Oid) 66, /* int4lt */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -296,7 +319,7 @@ array_int4le(ArrayType *array, int4 value) ...@@ -296,7 +319,7 @@ array_int4le(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 149, /* int4le */ (Oid) 149, /* int4le */
0, /* logical or */ 0, /* logical or */
array, (Datum)value); array, (Datum) value);
} }
int32 int32
...@@ -305,7 +328,7 @@ array_all_int4le(ArrayType *array, int4 value) ...@@ -305,7 +328,7 @@ array_all_int4le(ArrayType *array, int4 value)
return array_iterator((Oid) 23, /* int4 */ return array_iterator((Oid) 23, /* int4 */
(Oid) 149, /* int4le */ (Oid) 149, /* int4le */
1, /* logical and */ 1, /* logical and */
array, (Datum)value); array, (Datum) value);
} }
/* end of file */ /* end of file */
#ifndef ARRAY_ITERATOR_H #ifndef ARRAY_ITERATOR_H
#define ARRAY_ITERATOR_H #define ARRAY_ITERATOR_H
static int32 array_iterator(Oid elemtype, Oid proc, int and, static int32
array_iterator(Oid elemtype, Oid proc, int and,
ArrayType *array, Datum value); ArrayType *array, Datum value);
int32 array_texteq(ArrayType *array, char* value); int32 array_texteq(ArrayType *array, char *value);
int32 array_all_texteq(ArrayType *array, char* value); int32 array_all_texteq(ArrayType *array, char *value);
int32 array_textregexeq(ArrayType *array, char* value); int32 array_textregexeq(ArrayType *array, char *value);
int32 array_all_textregexeq(ArrayType *array, char* value); int32 array_all_textregexeq(ArrayType *array, char *value);
int32 array_char16eq(ArrayType *array, char* value); int32 array_char16eq(ArrayType *array, char *value);
int32 array_all_char16eq(ArrayType *array, char* value); int32 array_all_char16eq(ArrayType *array, char *value);
int32 array_char16regexeq(ArrayType *array, char* value); int32 array_char16regexeq(ArrayType *array, char *value);
int32 array_all_char16regexeq(ArrayType *array, char* value); int32 array_all_char16regexeq(ArrayType *array, char *value);
int32 array_int4eq(ArrayType *array, int4 value); int32 array_int4eq(ArrayType *array, int4 value);
int32 array_all_int4eq(ArrayType *array, int4 value); int32 array_all_int4eq(ArrayType *array, int4 value);
int32 array_int4ne(ArrayType *array, int4 value); int32 array_int4ne(ArrayType *array, int4 value);
......
...@@ -38,39 +38,41 @@ hhmm_in(char *str) ...@@ -38,39 +38,41 @@ hhmm_in(char *str)
TimeADT *time; TimeADT *time;
double fsec; double fsec;
struct tm tt, *tm = &tt; struct tm tt,
*tm = &tt;
int nf; int nf;
char lowstr[MAXDATELEN+1]; char lowstr[MAXDATELEN + 1];
char *field[MAXDATEFIELDS]; char *field[MAXDATEFIELDS];
int dtype; int dtype;
int ftype[MAXDATEFIELDS]; int ftype[MAXDATEFIELDS];
if (!PointerIsValid(str)) if (!PointerIsValid(str))
elog(ERROR,"Bad (null) time external representation",NULL); elog(ERROR, "Bad (null) time external representation", NULL);
if ((ParseDateTime( str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0) if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|| (DecodeTimeOnly( field, ftype, nf, &dtype, tm, &fsec) != 0)) || (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec) != 0))
elog(ERROR,"Bad time external representation '%s'",str); elog(ERROR, "Bad time external representation '%s'", str);
if (tm->tm_hour<0 || tm->tm_hour>24 || if (tm->tm_hour < 0 || tm->tm_hour > 24 ||
(tm->tm_hour==24 && (tm->tm_min!=0 || tm->tm_sec!=0 || fsec!= 0))) { (tm->tm_hour == 24 && (tm->tm_min != 0 || tm->tm_sec != 0 || fsec != 0)))
{
elog(ERROR, elog(ERROR,
"time_in: hour must be limited to values 0 through 24:00 " "time_in: hour must be limited to values 0 through 24:00 "
"in \"%s\"", "in \"%s\"",
str); str);
} }
if ((tm->tm_min < 0) || (tm->tm_min > 59)) if ((tm->tm_min < 0) || (tm->tm_min > 59))
elog(ERROR,"Minute must be limited to values 0 through 59 in '%s'",str); elog(ERROR, "Minute must be limited to values 0 through 59 in '%s'", str);
if ((tm->tm_sec < 0) || ((tm->tm_sec + fsec) >= 60)) if ((tm->tm_sec < 0) || ((tm->tm_sec + fsec) >= 60))
elog(ERROR,"Second must be limited to values 0 through < 60 in '%s'", elog(ERROR, "Second must be limited to values 0 through < 60 in '%s'",
str); str);
time = palloc(sizeof(TimeADT)); time = palloc(sizeof(TimeADT));
*time = ((((tm->tm_hour*60)+tm->tm_min)*60)); *time = ((((tm->tm_hour * 60) + tm->tm_min) * 60));
return(time); return (time);
} }
/* /*
...@@ -83,27 +85,31 @@ char * ...@@ -83,27 +85,31 @@ char *
hhmm_out(TimeADT *time) hhmm_out(TimeADT *time)
{ {
char *result; char *result;
struct tm tt, *tm = &tt; struct tm tt,
char buf[MAXDATELEN+1]; *tm = &tt;
char buf[MAXDATELEN + 1];
if (!PointerIsValid(time)) if (!PointerIsValid(time))
return NULL; return NULL;
tm->tm_hour = (*time / (60*60)); tm->tm_hour = (*time / (60 * 60));
tm->tm_min = (((int) (*time / 60)) % 60); tm->tm_min = (((int) (*time / 60)) % 60);
tm->tm_sec = (((int) *time) % 60); tm->tm_sec = (((int) *time) % 60);
if (tm->tm_sec == 0) { if (tm->tm_sec == 0)
{
sprintf(buf, "%02d:%02d", tm->tm_hour, tm->tm_min); sprintf(buf, "%02d:%02d", tm->tm_hour, tm->tm_min);
} else { }
else
{
sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
} }
result = palloc(strlen(buf)+1); result = palloc(strlen(buf) + 1);
strcpy( result, buf); strcpy(result, buf);
return(result); return (result);
} }
TimeADT * TimeADT *
...@@ -113,7 +119,7 @@ hhmm(TimeADT *time) ...@@ -113,7 +119,7 @@ hhmm(TimeADT *time)
*result = (((int) *time) / 60 * 60); *result = (((int) *time) / 60 * 60);
return(result); return (result);
} }
TimeADT * TimeADT *
...@@ -122,7 +128,7 @@ time_difference(TimeADT *time1, TimeADT *time2) ...@@ -122,7 +128,7 @@ time_difference(TimeADT *time1, TimeADT *time2)
TimeADT *time = palloc(sizeof(TimeADT)); TimeADT *time = palloc(sizeof(TimeADT));
*time = (*time1 - *time2); *time = (*time1 - *time2);
return(time); return (time);
} }
int4 int4
...@@ -158,7 +164,9 @@ as_seconds(TimeADT *time) ...@@ -158,7 +164,9 @@ as_seconds(TimeADT *time)
int4 int4
date_day(DateADT val) date_day(DateADT val)
{ {
int year, month, day; int year,
month,
day;
j2date(val + JDATE_2000, &year, &month, &day); j2date(val + JDATE_2000, &year, &month, &day);
...@@ -168,7 +176,9 @@ date_day(DateADT val) ...@@ -168,7 +176,9 @@ date_day(DateADT val)
int4 int4
date_month(DateADT val) date_month(DateADT val)
{ {
int year, month, day; int year,
month,
day;
j2date(val + JDATE_2000, &year, &month, &day); j2date(val + JDATE_2000, &year, &month, &day);
...@@ -178,7 +188,9 @@ date_month(DateADT val) ...@@ -178,7 +188,9 @@ date_month(DateADT val)
int4 int4
date_year(DateADT val) date_year(DateADT val)
{ {
int year, month, day; int year,
month,
day;
j2date(val + JDATE_2000, &year, &month, &day); j2date(val + JDATE_2000, &year, &month, &day);
...@@ -194,7 +206,7 @@ currenttime() ...@@ -194,7 +206,7 @@ currenttime()
current_time = time(NULL); current_time = time(NULL);
tm = localtime(&current_time); tm = localtime(&current_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);
} }
...@@ -203,10 +215,11 @@ DateADT ...@@ -203,10 +215,11 @@ DateADT
currentdate() currentdate()
{ {
DateADT date; DateADT date;
struct tm tt, *tm = &tt; struct tm tt,
*tm = &tt;
GetCurrentTime(tm); GetCurrentTime(tm);
date = (date2j( tm->tm_year, tm->tm_mon, tm->tm_mday) - JDATE_2000); date = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - JDATE_2000);
return (date); return (date);
} }
......
/* /*
* PostgreSQL type definitions for IP addresses. * PostgreSQL type definitions for IP addresses.
* *
* $Id: ip.c,v 1.2 1998/02/14 17:58:03 scrappy Exp $ * $Id: ip.c,v 1.3 1998/02/26 04:27:37 momjian Exp $
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
* This is the internal storage format for IP addresses: * This is the internal storage format for IP addresses:
*/ */
typedef struct ipaddr { typedef struct ipaddr
{
uint32 address; uint32 address;
int16 width; int16 width;
} ipaddr; } ipaddr;
...@@ -23,29 +24,32 @@ typedef struct ipaddr { ...@@ -23,29 +24,32 @@ typedef struct ipaddr {
*/ */
ipaddr *ipaddr_in(char *str); ipaddr *ipaddr_in(char *str);
char *ipaddr_out(ipaddr *addr); char *ipaddr_out(ipaddr * addr);
bool ipaddr_lt(ipaddr *a1, ipaddr *a2); bool ipaddr_lt(ipaddr * a1, ipaddr * a2);
bool ipaddr_le(ipaddr *a1, ipaddr *a2); bool ipaddr_le(ipaddr * a1, ipaddr * a2);
bool ipaddr_eq(ipaddr *a1, ipaddr *a2); bool ipaddr_eq(ipaddr * a1, ipaddr * a2);
bool ipaddr_ge(ipaddr *a1, ipaddr *a2); bool ipaddr_ge(ipaddr * a1, ipaddr * a2);
bool ipaddr_gt(ipaddr *a1, ipaddr *a2); bool ipaddr_gt(ipaddr * a1, ipaddr * a2);
bool ipaddr_ne(ipaddr *a1, ipaddr *a2); bool ipaddr_ne(ipaddr * a1, ipaddr * a2);
int4 ipaddr_cmp(ipaddr *a1, ipaddr *a2); int4 ipaddr_cmp(ipaddr * a1, ipaddr * a2);
bool ipaddr_in_net(ipaddr *a1, ipaddr *a2); bool ipaddr_in_net(ipaddr * a1, ipaddr * a2);
ipaddr *ipaddr_mask(ipaddr *a); ipaddr *ipaddr_mask(ipaddr * a);
ipaddr *ipaddr_bcast(ipaddr *a); ipaddr *ipaddr_bcast(ipaddr * a);
/* /*
* Build a mask of a given width: * Build a mask of a given width:
*/ */
unsigned long build_mask(unsigned char bits) { unsigned long
build_mask(unsigned char bits)
{
unsigned long mask = 0; unsigned long mask = 0;
int i; int i;
for (i = 0; i < bits; i++) for (i = 0; i < bits; i++)
mask = (mask >> 1) | 0x80000000; mask = (mask >> 1) | 0x80000000;
return mask; return mask;
...@@ -56,18 +60,26 @@ unsigned long build_mask(unsigned char bits) { ...@@ -56,18 +60,26 @@ unsigned long build_mask(unsigned char bits) {
* is used to determine whether the mask size was specified. * is used to determine whether the mask size was specified.
*/ */
ipaddr *ipaddr_in(char *str) { ipaddr *
int a, b, c, d, w; ipaddr_in(char *str)
{
int a,
b,
c,
d,
w;
ipaddr *result; ipaddr *result;
int count; int count;
if (strlen(str) > 0) { if (strlen(str) > 0)
{
count = sscanf(str, "%d.%d.%d.%d/%d", &a, &b, &c, &d, &w); count = sscanf(str, "%d.%d.%d.%d/%d", &a, &b, &c, &d, &w);
if (count < 4) { if (count < 4)
{
elog(ERROR, "ipaddr_in: error in parsing \"%s\"", str); elog(ERROR, "ipaddr_in: error in parsing \"%s\"", str);
return(NULL); return (NULL);
} }
if (count == 4) if (count == 4)
...@@ -75,21 +87,24 @@ ipaddr *ipaddr_in(char *str) { ...@@ -75,21 +87,24 @@ ipaddr *ipaddr_in(char *str) {
if ((a < 0) || (a > 255) || (b < 0) || (b > 255) || if ((a < 0) || (a > 255) || (b < 0) || (b > 255) ||
(c < 0) || (c > 255) || (d < 0) || (d > 255) || (c < 0) || (c > 255) || (d < 0) || (d > 255) ||
(w < 0) || (w > 32)) { (w < 0) || (w > 32))
{
elog(ERROR, "ipaddr_in: illegal address \"%s\"", str); elog(ERROR, "ipaddr_in: illegal address \"%s\"", str);
return(NULL); return (NULL);
}
} }
} else { else
{
a = b = c = d = w = 0; /* special case for missing address */ a = b = c = d = w = 0; /* special case for missing address */
} }
result = (ipaddr *)palloc(sizeof(ipaddr)); result = (ipaddr *) palloc(sizeof(ipaddr));
result->address = (uint32) ((a<<24)|(b<<16)|(c<<8)|d); result->address = (uint32) ((a << 24) | (b << 16) | (c << 8) | d);
result->address &= build_mask(w); result->address &= build_mask(w);
result->width = w; result->width = w;
return(result); return (result);
} }
/* /*
...@@ -97,15 +112,18 @@ ipaddr *ipaddr_in(char *str) { ...@@ -97,15 +112,18 @@ ipaddr *ipaddr_in(char *str) {
* generated only for subnets, not for plain host addresses. * generated only for subnets, not for plain host addresses.
*/ */
char *ipaddr_out(ipaddr *addr) { char *
ipaddr_out(ipaddr * addr)
{
char *result; char *result;
if (addr == NULL) if (addr == NULL)
return(NULL); return (NULL);
result = (char *)palloc(32); result = (char *) palloc(32);
if (addr->address > 0) { if (addr->address > 0)
{
if (addr->width == 32) if (addr->width == 32)
sprintf(result, "%d.%d.%d.%d", sprintf(result, "%d.%d.%d.%d",
(addr->address >> 24) & 0xff, (addr->address >> 24) & 0xff,
...@@ -119,37 +137,51 @@ char *ipaddr_out(ipaddr *addr) { ...@@ -119,37 +137,51 @@ char *ipaddr_out(ipaddr *addr) {
(addr->address >> 8) & 0xff, (addr->address >> 8) & 0xff,
addr->address & 0xff, addr->address & 0xff,
addr->width); addr->width);
} else { }
else
{
result[0] = 0; /* special case for missing address */ result[0] = 0; /* special case for missing address */
} }
return(result); return (result);
} }
/* /*
* Boolean tests for magnitude. * Boolean tests for magnitude.
*/ */
bool ipaddr_lt(ipaddr *a1, ipaddr *a2) { bool
ipaddr_lt(ipaddr * a1, ipaddr * a2)
{
return (a1->address < a2->address); return (a1->address < a2->address);
}; };
bool ipaddr_le(ipaddr *a1, ipaddr *a2) { bool
ipaddr_le(ipaddr * a1, ipaddr * a2)
{
return (a1->address <= a2->address); return (a1->address <= a2->address);
}; };
bool ipaddr_eq(ipaddr *a1, ipaddr *a2) { bool
ipaddr_eq(ipaddr * a1, ipaddr * a2)
{
return (a1->address == a2->address); return (a1->address == a2->address);
}; };
bool ipaddr_ge(ipaddr *a1, ipaddr *a2) { bool
ipaddr_ge(ipaddr * a1, ipaddr * a2)
{
return (a1->address >= a2->address); return (a1->address >= a2->address);
}; };
bool ipaddr_gt(ipaddr *a1, ipaddr *a2) { bool
ipaddr_gt(ipaddr * a1, ipaddr * a2)
{
return (a1->address > a2->address); return (a1->address > a2->address);
}; };
bool ipaddr_ne(ipaddr *a1, ipaddr *a2) { bool
ipaddr_ne(ipaddr * a1, ipaddr * a2)
{
return (a1->address != a2->address); return (a1->address != a2->address);
}; };
...@@ -157,7 +189,9 @@ bool ipaddr_ne(ipaddr *a1, ipaddr *a2) { ...@@ -157,7 +189,9 @@ bool ipaddr_ne(ipaddr *a1, ipaddr *a2) {
* Comparison function for sorting: * Comparison function for sorting:
*/ */
int4 ipaddr_cmp(ipaddr *a1, ipaddr *a2) { int4
ipaddr_cmp(ipaddr * a1, ipaddr * a2)
{
if (a1->address < a2->address) if (a1->address < a2->address)
return -1; return -1;
else if (a1->address > a2->address) else if (a1->address > a2->address)
...@@ -170,8 +204,11 @@ int4 ipaddr_cmp(ipaddr *a1, ipaddr *a2) { ...@@ -170,8 +204,11 @@ int4 ipaddr_cmp(ipaddr *a1, ipaddr *a2) {
* Test whether an address is within a given subnet: * Test whether an address is within a given subnet:
*/ */
bool ipaddr_in_net(ipaddr *a1, ipaddr *a2) { bool
ipaddr_in_net(ipaddr * a1, ipaddr * a2)
{
uint32 maskbits; uint32 maskbits;
if (a1->width < a2->width) if (a1->width < a2->width)
return FALSE; return FALSE;
if ((a1->width == 32) && (a2->width == 32)) if ((a1->width == 32) && (a2->width == 32))
...@@ -186,10 +223,12 @@ bool ipaddr_in_net(ipaddr *a1, ipaddr *a2) { ...@@ -186,10 +223,12 @@ bool ipaddr_in_net(ipaddr *a1, ipaddr *a2) {
* Pick out just the mask of a network: * Pick out just the mask of a network:
*/ */
ipaddr *ipaddr_mask(ipaddr *a) { ipaddr *
ipaddr_mask(ipaddr * a)
{
ipaddr *result; ipaddr *result;
result = (ipaddr *)palloc(sizeof(ipaddr)); result = (ipaddr *) palloc(sizeof(ipaddr));
result->address = build_mask(a->width); result->address = build_mask(a->width);
result->width = 32; result->width = 32;
...@@ -200,10 +239,12 @@ ipaddr *ipaddr_mask(ipaddr *a) { ...@@ -200,10 +239,12 @@ ipaddr *ipaddr_mask(ipaddr *a) {
* Return the broadcast address of a network: * Return the broadcast address of a network:
*/ */
ipaddr *ipaddr_bcast(ipaddr *a) { ipaddr *
ipaddr_bcast(ipaddr * a)
{
ipaddr *result; ipaddr *result;
result = (ipaddr *)palloc(sizeof(ipaddr)); result = (ipaddr *) palloc(sizeof(ipaddr));
result->address = a->address; result->address = a->address;
result->address |= (build_mask(32 - a->width) >> a->width); result->address |= (build_mask(32 - a->width) >> a->width);
result->width = 32; result->width = 32;
......
/* /*
* PostgreSQL type definitions for MAC addresses. * PostgreSQL type definitions for MAC addresses.
* *
* $Id: mac.c,v 1.2 1998/02/14 17:58:05 scrappy Exp $ * $Id: mac.c,v 1.3 1998/02/26 04:27:44 momjian Exp $
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
* This is the internal storage format for MAC addresses: * This is the internal storage format for MAC addresses:
*/ */
typedef struct macaddr { typedef struct macaddr
{
unsigned char a; unsigned char a;
unsigned char b; unsigned char b;
unsigned char c; unsigned char c;
...@@ -29,19 +30,19 @@ typedef struct macaddr { ...@@ -29,19 +30,19 @@ typedef struct macaddr {
*/ */
macaddr *macaddr_in(char *str); macaddr *macaddr_in(char *str);
char *macaddr_out(macaddr *addr); char *macaddr_out(macaddr * addr);
bool macaddr_lt(macaddr *a1, macaddr *a2); bool macaddr_lt(macaddr * a1, macaddr * a2);
bool macaddr_le(macaddr *a1, macaddr *a2); bool macaddr_le(macaddr * a1, macaddr * a2);
bool macaddr_eq(macaddr *a1, macaddr *a2); bool macaddr_eq(macaddr * a1, macaddr * a2);
bool macaddr_ge(macaddr *a1, macaddr *a2); bool macaddr_ge(macaddr * a1, macaddr * a2);
bool macaddr_gt(macaddr *a1, macaddr *a2); bool macaddr_gt(macaddr * a1, macaddr * a2);
bool macaddr_ne(macaddr *a1, macaddr *a2); bool macaddr_ne(macaddr * a1, macaddr * a2);
int4 macaddr_cmp(macaddr *a1, macaddr *a2); int4 macaddr_cmp(macaddr * a1, macaddr * a2);
text *macaddr_manuf(macaddr *addr); text *macaddr_manuf(macaddr * addr);
/* /*
* Utility macros used for sorting and comparing: * Utility macros used for sorting and comparing:
...@@ -57,12 +58,20 @@ text *macaddr_manuf(macaddr *addr); ...@@ -57,12 +58,20 @@ text *macaddr_manuf(macaddr *addr);
* MAC address reader. Accepts several common notations. * MAC address reader. Accepts several common notations.
*/ */
macaddr *macaddr_in(char *str) { macaddr *
int a, b, c, d, e, f; macaddr_in(char *str)
{
int a,
b,
c,
d,
e,
f;
macaddr *result; macaddr *result;
int count; int count;
if (strlen(str) > 0) { if (strlen(str) > 0)
{
count = sscanf(str, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f); count = sscanf(str, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f);
if (count != 6) if (count != 6)
...@@ -74,22 +83,27 @@ macaddr *macaddr_in(char *str) { ...@@ -74,22 +83,27 @@ macaddr *macaddr_in(char *str) {
if (count != 6) if (count != 6)
count = sscanf(str, "%2x%2x.%2x%2x.%2x%2x", &a, &b, &c, &d, &e, &f); count = sscanf(str, "%2x%2x.%2x%2x.%2x%2x", &a, &b, &c, &d, &e, &f);
if (count != 6) { if (count != 6)
{
elog(ERROR, "macaddr_in: error in parsing \"%s\"", str); elog(ERROR, "macaddr_in: error in parsing \"%s\"", str);
return(NULL); return (NULL);
} }
if ((a < 0) || (a > 255) || (b < 0) || (b > 255) || if ((a < 0) || (a > 255) || (b < 0) || (b > 255) ||
(c < 0) || (c > 255) || (d < 0) || (d > 255) || (c < 0) || (c > 255) || (d < 0) || (d > 255) ||
(e < 0) || (e > 255) || (f < 0) || (f > 255)) { (e < 0) || (e > 255) || (f < 0) || (f > 255))
{
elog(ERROR, "macaddr_in: illegal address \"%s\"", str); elog(ERROR, "macaddr_in: illegal address \"%s\"", str);
return(NULL); return (NULL);
}
} }
} else { else
a = b = c = d = e = f = 0; /* special case for missing address */ {
a = b = c = d = e = f = 0; /* special case for missing
* address */
} }
result = (macaddr *)palloc(sizeof(macaddr)); result = (macaddr *) palloc(sizeof(macaddr));
result->a = a; result->a = a;
result->b = b; result->b = b;
...@@ -98,59 +112,76 @@ macaddr *macaddr_in(char *str) { ...@@ -98,59 +112,76 @@ macaddr *macaddr_in(char *str) {
result->e = e; result->e = e;
result->f = f; result->f = f;
return(result); return (result);
} }
/* /*
* MAC address output function. Fixed format. * MAC address output function. Fixed format.
*/ */
char *macaddr_out(macaddr *addr) { char *
macaddr_out(macaddr * addr)
{
char *result; char *result;
if (addr == NULL) if (addr == NULL)
return(NULL); return (NULL);
result = (char *)palloc(32); result = (char *) palloc(32);
if ((hibits(addr) > 0) || (lobits(addr) > 0)) { if ((hibits(addr) > 0) || (lobits(addr) > 0))
{
sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x", sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
addr->a, addr->b, addr->c, addr->d, addr->e, addr->f); addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
} else { }
else
{
result[0] = 0; /* special case for missing address */ result[0] = 0; /* special case for missing address */
} }
return(result); return (result);
} }
/* /*
* Boolean tests. * Boolean tests.
*/ */
bool macaddr_lt(macaddr *a1, macaddr *a2) { bool
return((hibits(a1) < hibits(a2)) || macaddr_lt(macaddr * a1, macaddr * a2)
{
return ((hibits(a1) < hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) < lobits(a2))); ((hibits(a1) == hibits(a2)) && lobits(a1) < lobits(a2)));
}; };
bool macaddr_le(macaddr *a1, macaddr *a2) { bool
return((hibits(a1) < hibits(a2)) || macaddr_le(macaddr * a1, macaddr * a2)
{
return ((hibits(a1) < hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) <= lobits(a2))); ((hibits(a1) == hibits(a2)) && lobits(a1) <= lobits(a2)));
}; };
bool macaddr_eq(macaddr *a1, macaddr *a2) { bool
macaddr_eq(macaddr * a1, macaddr * a2)
{
return ((hibits(a1) == hibits(a2)) && (lobits(a1) == lobits(a2))); return ((hibits(a1) == hibits(a2)) && (lobits(a1) == lobits(a2)));
}; };
bool macaddr_ge(macaddr *a1, macaddr *a2) { bool
return((hibits(a1) > hibits(a2)) || macaddr_ge(macaddr * a1, macaddr * a2)
{
return ((hibits(a1) > hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) >= lobits(a2))); ((hibits(a1) == hibits(a2)) && lobits(a1) >= lobits(a2)));
}; };
bool macaddr_gt(macaddr *a1, macaddr *a2) { bool
return((hibits(a1) > hibits(a2)) || macaddr_gt(macaddr * a1, macaddr * a2)
{
return ((hibits(a1) > hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) > lobits(a2))); ((hibits(a1) == hibits(a2)) && lobits(a1) > lobits(a2)));
}; };
bool macaddr_ne(macaddr *a1, macaddr *a2) { bool
macaddr_ne(macaddr * a1, macaddr * a2)
{
return ((hibits(a1) != hibits(a2)) || (lobits(a1) != lobits(a2))); return ((hibits(a1) != hibits(a2)) || (lobits(a1) != lobits(a2)));
}; };
...@@ -158,7 +189,9 @@ bool macaddr_ne(macaddr *a1, macaddr *a2) { ...@@ -158,7 +189,9 @@ bool macaddr_ne(macaddr *a1, macaddr *a2) {
* Comparison function for sorting: * Comparison function for sorting:
*/ */
int4 macaddr_cmp(macaddr *a1, macaddr *a2) { int4
macaddr_cmp(macaddr * a1, macaddr * a2)
{
if (hibits(a1) < hibits(a2)) if (hibits(a1) < hibits(a2))
return -1; return -1;
else if (hibits(a1) > hibits(a2)) else if (hibits(a1) > hibits(a2))
...@@ -175,22 +208,28 @@ int4 macaddr_cmp(macaddr *a1, macaddr *a2) { ...@@ -175,22 +208,28 @@ int4 macaddr_cmp(macaddr *a1, macaddr *a2) {
* The special manufacturer fetching function. See "mac.h". * The special manufacturer fetching function. See "mac.h".
*/ */
text *macaddr_manuf(macaddr *addr) { text *
macaddr_manuf(macaddr * addr)
{
manufacturer *manuf; manufacturer *manuf;
int length; int length;
text *result; text *result;
for (manuf = manufacturers; manuf->name != NULL; manuf++) { for (manuf = manufacturers; manuf->name != NULL; manuf++)
{
if ((manuf->a == addr->a) && if ((manuf->a == addr->a) &&
(manuf->b == addr->b) && (manuf->b == addr->b) &&
(manuf->c == addr->c)) (manuf->c == addr->c))
break; break;
} }
if (manuf->name == NULL) { if (manuf->name == NULL)
{
result = palloc(VARHDRSZ + 1); result = palloc(VARHDRSZ + 1);
memset(result, 0, VARHDRSZ + 1); memset(result, 0, VARHDRSZ + 1);
VARSIZE(result) = VARHDRSZ + 1; VARSIZE(result) = VARHDRSZ + 1;
} else { }
else
{
length = strlen(manuf->name) + 1; length = strlen(manuf->name) + 1;
result = palloc(length + VARHDRSZ); result = palloc(length + VARHDRSZ);
memset(result, 0, length + VARHDRSZ); memset(result, 0, length + VARHDRSZ);
......
/* /*
* PostgreSQL type definitions for MAC addresses. * PostgreSQL type definitions for MAC addresses.
* *
* $Id: mac.h,v 1.2 1998/02/14 17:58:07 scrappy Exp $ * $Id: mac.h,v 1.3 1998/02/26 04:27:50 momjian Exp $
*/ */
typedef struct manufacturer { typedef struct manufacturer
{
unsigned char a; unsigned char a;
unsigned char b; unsigned char b;
unsigned char c; unsigned char c;
......
...@@ -12,28 +12,28 @@ ...@@ -12,28 +12,28 @@
#include "set_sequence.h" #include "set_sequence.h"
extern int setval(struct varlena *seqin, int4 val); extern int setval(struct varlena * seqin, int4 val);
int int
set_currval(struct varlena *sequence, int4 nextval) set_currval(struct varlena * sequence, int4 nextval)
{ {
return setval(sequence, nextval); return setval(sequence, nextval);
} }
int int
next_id(struct varlena *sequence) next_id(struct varlena * sequence)
{ {
return nextval(sequence); return nextval(sequence);
} }
int int
last_id(struct varlena *sequence) last_id(struct varlena * sequence)
{ {
return currval(sequence); return currval(sequence);
} }
int int
set_last_id(struct varlena *sequence, int4 nextval) set_last_id(struct varlena * sequence, int4 nextval)
{ {
return setval(sequence, nextval); return setval(sequence, nextval);
} }
......
#ifndef SET_SEQUENCE_H #ifndef SET_SEQUENCE_H
#define SET_SEQUENCE_H #define SET_SEQUENCE_H
int set_currval(struct varlena *sequence, int4 nextval); int set_currval(struct varlena * sequence, int4 nextval);
int next_id(struct varlena *sequence); int next_id(struct varlena * sequence);
int last_id(struct varlena *sequence); int last_id(struct varlena * sequence);
int set_last_id(struct varlena *sequence, int4 nextval); int set_last_id(struct varlena * sequence, int4 nextval);
#endif #endif
...@@ -50,22 +50,22 @@ autoinc() ...@@ -50,22 +50,22 @@ autoinc()
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
chattrs = (int *) palloc (nargs/2 * sizeof (int)); chattrs = (int *) palloc(nargs / 2 * sizeof(int));
newvals = (Datum *) palloc (nargs/2 * sizeof (Datum)); newvals = (Datum *) palloc(nargs / 2 * sizeof(Datum));
for (i = 0; i < nargs; ) for (i = 0; i < nargs;)
{ {
struct varlena *seqname; struct varlena *seqname;
int attnum = SPI_fnumber (tupdesc, args[i]); int attnum = SPI_fnumber(tupdesc, args[i]);
int32 val; int32 val;
if ( attnum < 0 ) if (attnum < 0)
elog(ERROR, "autoinc (%s): there is no attribute %s", relname, args[i]); elog(ERROR, "autoinc (%s): there is no attribute %s", relname, args[i]);
if (SPI_gettypeid (tupdesc, attnum) != INT4OID) if (SPI_gettypeid(tupdesc, attnum) != INT4OID)
elog(ERROR, "autoinc (%s): attribute %s must be of INT4 type", elog(ERROR, "autoinc (%s): attribute %s must be of INT4 type",
relname, args[i]); relname, args[i]);
val = DatumGetInt32 (SPI_getbinval (rettuple, tupdesc, attnum, &isnull)); val = DatumGetInt32(SPI_getbinval(rettuple, tupdesc, attnum, &isnull));
if (!isnull && val != 0) if (!isnull && val != 0)
{ {
...@@ -75,26 +75,26 @@ autoinc() ...@@ -75,26 +75,26 @@ autoinc()
i++; i++;
chattrs[chnattrs] = attnum; chattrs[chnattrs] = attnum;
seqname = textin (args[i]); seqname = textin(args[i]);
newvals[chnattrs] = Int32GetDatum (nextval (seqname)); newvals[chnattrs] = Int32GetDatum(nextval(seqname));
if ( DatumGetInt32 (newvals[chnattrs]) == 0 ) if (DatumGetInt32(newvals[chnattrs]) == 0)
newvals[chnattrs] = Int32GetDatum (nextval (seqname)); newvals[chnattrs] = Int32GetDatum(nextval(seqname));
pfree (seqname); pfree(seqname);
chnattrs++; chnattrs++;
i++; i++;
} }
if (chnattrs > 0) if (chnattrs > 0)
{ {
rettuple = SPI_modifytuple (rel, rettuple, chnattrs, chattrs, newvals, NULL); rettuple = SPI_modifytuple(rel, rettuple, chnattrs, chattrs, newvals, NULL);
if ( rettuple == NULL ) if (rettuple == NULL)
elog (ERROR, "autoinc (%s): %d returned by SPI_modifytuple", elog(ERROR, "autoinc (%s): %d returned by SPI_modifytuple",
relname, SPI_result); relname, SPI_result);
} }
pfree (relname); pfree(relname);
pfree (chattrs); pfree(chattrs);
pfree (newvals); pfree(newvals);
return (rettuple); return (rettuple);
} }
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#include "commands/trigger.h" /* -"- and triggers */ #include "commands/trigger.h" /* -"- and triggers */
#include "miscadmin.h" /* for GetPgUserName() */ #include "miscadmin.h" /* for GetPgUserName() */
HeapTuple insert_username (void); HeapTuple insert_username(void);
HeapTuple HeapTuple
insert_username () insert_username()
{ {
Trigger *trigger; /* to get trigger name */ Trigger *trigger; /* to get trigger name */
int nargs; /* # of arguments */ int nargs; /* # of arguments */
...@@ -54,24 +54,24 @@ insert_username () ...@@ -54,24 +54,24 @@ insert_username ()
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
attnum = SPI_fnumber (tupdesc, args[0]); attnum = SPI_fnumber(tupdesc, args[0]);
if ( attnum < 0 ) if (attnum < 0)
elog(ERROR, "insert_username (%s): there is no attribute %s", relname, args[0]); elog(ERROR, "insert_username (%s): there is no attribute %s", relname, args[0]);
if (SPI_gettypeid (tupdesc, attnum) != TEXTOID) if (SPI_gettypeid(tupdesc, attnum) != TEXTOID)
elog(ERROR, "insert_username (%s): attribute %s must be of TEXT type", elog(ERROR, "insert_username (%s): attribute %s must be of TEXT type",
relname, args[0]); relname, args[0]);
/* create fields containing name */ /* create fields containing name */
newval = PointerGetDatum (textin (GetPgUserName ())); newval = PointerGetDatum(textin(GetPgUserName()));
/* construct new tuple */ /* construct new tuple */
rettuple = SPI_modifytuple (rel, rettuple, 1, &attnum, &newval, NULL); rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newval, NULL);
if ( rettuple == NULL ) if (rettuple == NULL)
elog (ERROR, "insert_username (%s): %d returned by SPI_modifytuple", elog(ERROR, "insert_username (%s): %d returned by SPI_modifytuple",
relname, SPI_result); relname, SPI_result);
pfree (relname); pfree(relname);
return (rettuple); return (rettuple);
} }
...@@ -53,8 +53,10 @@ timetravel() ...@@ -53,8 +53,10 @@ timetravel()
Trigger *trigger; /* to get trigger name */ Trigger *trigger; /* to get trigger name */
char **args; /* arguments */ char **args; /* arguments */
int attnum[2]; /* fnumbers of start/stop columns */ int attnum[2]; /* fnumbers of start/stop columns */
Datum oldon, oldoff; Datum oldon,
Datum newon, newoff; oldoff;
Datum newon,
newoff;
Datum *cvals; /* column values */ Datum *cvals; /* column values */
char *cnulls; /* column nulls */ char *cnulls; /* column nulls */
char *relname; /* triggered relation name */ char *relname; /* triggered relation name */
...@@ -101,11 +103,11 @@ timetravel() ...@@ -101,11 +103,11 @@ timetravel()
/* check if TT is OFF for this relation */ /* check if TT is OFF for this relation */
for (i = 0; i < nTTOff; i++) for (i = 0; i < nTTOff; i++)
if (strcasecmp (TTOff[i], relname) == 0) if (strcasecmp(TTOff[i], relname) == 0)
break; break;
if (i < nTTOff) /* OFF - nothing to do */ if (i < nTTOff) /* OFF - nothing to do */
{ {
pfree (relname); pfree(relname);
return ((newtuple != NULL) ? newtuple : trigtuple); return ((newtuple != NULL) ? newtuple : trigtuple);
} }
...@@ -126,12 +128,12 @@ timetravel() ...@@ -126,12 +128,12 @@ timetravel()
*/ */
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
for (i = 0; i < 2; i++ ) for (i = 0; i < 2; i++)
{ {
attnum[i] = SPI_fnumber (tupdesc, args[i]); attnum[i] = SPI_fnumber(tupdesc, args[i]);
if ( attnum[i] < 0 ) if (attnum[i] < 0)
elog(ERROR, "timetravel (%s): there is no attribute %s", relname, args[i]); elog(ERROR, "timetravel (%s): there is no attribute %s", relname, args[i]);
if (SPI_gettypeid (tupdesc, attnum[i]) != ABSTIMEOID) if (SPI_gettypeid(tupdesc, attnum[i]) != ABSTIMEOID)
elog(ERROR, "timetravel (%s): attributes %s and %s must be of abstime type", elog(ERROR, "timetravel (%s): attributes %s and %s must be of abstime type",
relname, args[0], args[1]); relname, args[0], args[1]);
} }
...@@ -142,20 +144,20 @@ timetravel() ...@@ -142,20 +144,20 @@ timetravel()
int chattrs[2]; int chattrs[2];
Datum newvals[2]; Datum newvals[2];
oldon = SPI_getbinval (trigtuple, tupdesc, attnum[0], &isnull); oldon = SPI_getbinval(trigtuple, tupdesc, attnum[0], &isnull);
if (isnull) if (isnull)
{ {
newvals[chnattrs] = GetCurrentAbsoluteTime (); newvals[chnattrs] = GetCurrentAbsoluteTime();
chattrs[chnattrs] = attnum[0]; chattrs[chnattrs] = attnum[0];
chnattrs++; chnattrs++;
} }
oldoff = SPI_getbinval (trigtuple, tupdesc, attnum[1], &isnull); oldoff = SPI_getbinval(trigtuple, tupdesc, attnum[1], &isnull);
if (isnull) if (isnull)
{ {
if ((chnattrs == 0 && DatumGetInt32 (oldon) >= NOEND_ABSTIME) || if ((chnattrs == 0 && DatumGetInt32(oldon) >= NOEND_ABSTIME) ||
(chnattrs > 0 && DatumGetInt32 (newvals[0]) >= NOEND_ABSTIME)) (chnattrs > 0 && DatumGetInt32(newvals[0]) >= NOEND_ABSTIME))
elog (ERROR, "timetravel (%s): %s ge %s", elog(ERROR, "timetravel (%s): %s ge %s",
relname, args[0], args[1]); relname, args[0], args[1]);
newvals[chnattrs] = NOEND_ABSTIME; newvals[chnattrs] = NOEND_ABSTIME;
chattrs[chnattrs] = attnum[1]; chattrs[chnattrs] = attnum[1];
...@@ -163,71 +165,72 @@ timetravel() ...@@ -163,71 +165,72 @@ timetravel()
} }
else else
{ {
if ((chnattrs == 0 && DatumGetInt32 (oldon) >= if ((chnattrs == 0 && DatumGetInt32(oldon) >=
DatumGetInt32 (oldoff)) || DatumGetInt32(oldoff)) ||
(chnattrs > 0 && DatumGetInt32 (newvals[0]) >= (chnattrs > 0 && DatumGetInt32(newvals[0]) >=
DatumGetInt32 (oldoff))) DatumGetInt32(oldoff)))
elog (ERROR, "timetravel (%s): %s ge %s", elog(ERROR, "timetravel (%s): %s ge %s",
relname, args[0], args[1]); relname, args[0], args[1]);
} }
pfree (relname); pfree(relname);
if ( chnattrs <= 0 ) if (chnattrs <= 0)
return (trigtuple); return (trigtuple);
rettuple = SPI_modifytuple (rel, trigtuple, chnattrs, rettuple = SPI_modifytuple(rel, trigtuple, chnattrs,
chattrs, newvals, NULL); chattrs, newvals, NULL);
return (rettuple); return (rettuple);
} }
oldon = SPI_getbinval (trigtuple, tupdesc, attnum[0], &isnull); oldon = SPI_getbinval(trigtuple, tupdesc, attnum[0], &isnull);
if (isnull) if (isnull)
elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]);
oldoff = SPI_getbinval (trigtuple, tupdesc, attnum[1], &isnull); oldoff = SPI_getbinval(trigtuple, tupdesc, attnum[1], &isnull);
if (isnull) if (isnull)
elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]);
/* /*
* If DELETE/UPDATE of tuple with stop_date neq INFINITY * If DELETE/UPDATE of tuple with stop_date neq INFINITY then say
* then say upper Executor to skip operation for this tuple * upper Executor to skip operation for this tuple
*/ */
if (newtuple != NULL) /* UPDATE */ if (newtuple != NULL) /* UPDATE */
{ {
newon = SPI_getbinval (newtuple, tupdesc, attnum[0], &isnull); newon = SPI_getbinval(newtuple, tupdesc, attnum[0], &isnull);
if (isnull) if (isnull)
elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]);
newoff = SPI_getbinval (newtuple, tupdesc, attnum[1], &isnull); newoff = SPI_getbinval(newtuple, tupdesc, attnum[1], &isnull);
if (isnull) if (isnull)
elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]);
if ( oldon != newon || oldoff != newoff ) if (oldon != newon || oldoff != newoff)
elog (ERROR, "timetravel (%s): you can't change %s and/or %s columns (use set_timetravel)", elog(ERROR, "timetravel (%s): you can't change %s and/or %s columns (use set_timetravel)",
relname, args[0], args[1]); relname, args[0], args[1]);
if ( newoff != NOEND_ABSTIME ) if (newoff != NOEND_ABSTIME)
{ {
pfree (relname); /* allocated in upper executor context */ pfree(relname); /* allocated in upper executor context */
return (NULL); return (NULL);
} }
} }
else if (oldoff != NOEND_ABSTIME) /* DELETE */ else if (oldoff != NOEND_ABSTIME) /* DELETE */
{ {
pfree (relname); pfree(relname);
return (NULL); return (NULL);
} }
newoff = GetCurrentAbsoluteTime (); newoff = GetCurrentAbsoluteTime();
/* Connect to SPI manager */ /* Connect to SPI manager */
if ((ret = SPI_connect()) < 0) if ((ret = SPI_connect()) < 0)
elog(ERROR, "timetravel (%s): SPI_connect returned %d", relname, ret); elog(ERROR, "timetravel (%s): SPI_connect returned %d", relname, ret);
/* Fetch tuple values and nulls */ /* Fetch tuple values and nulls */
cvals = (Datum *) palloc (natts * sizeof (Datum)); cvals = (Datum *) palloc(natts * sizeof(Datum));
cnulls = (char *) palloc (natts * sizeof (char)); cnulls = (char *) palloc(natts * sizeof(char));
for (i = 0; i < natts; i++) for (i = 0; i < natts; i++)
{ {
cvals[i] = SPI_getbinval ((newtuple != NULL) ? newtuple : trigtuple, cvals[i] = SPI_getbinval((newtuple != NULL) ? newtuple : trigtuple,
tupdesc, i + 1, &isnull); tupdesc, i + 1, &isnull);
cnulls[i] = (isnull) ? 'n' : ' '; cnulls[i] = (isnull) ? 'n' : ' ';
} }
...@@ -240,15 +243,16 @@ timetravel() ...@@ -240,15 +243,16 @@ timetravel()
cvals[attnum[1] - 1] = NOEND_ABSTIME; /* stop_date eq INFINITY */ cvals[attnum[1] - 1] = NOEND_ABSTIME; /* stop_date eq INFINITY */
cnulls[attnum[1] - 1] = ' '; cnulls[attnum[1] - 1] = ' ';
} }
else /* DELETE */ else
/* DELETE */
{ {
cvals[attnum[1] - 1] = newoff; /* stop_date eq current date */ cvals[attnum[1] - 1] = newoff; /* stop_date eq current date */
cnulls[attnum[1] - 1] = ' '; cnulls[attnum[1] - 1] = ' ';
} }
/* /*
* Construct ident string as TriggerName $ TriggeredRelationId * Construct ident string as TriggerName $ TriggeredRelationId and try
* and try to find prepared execution plan. * to find prepared execution plan.
*/ */
sprintf(ident, "%s$%u", trigger->tgname, rel->rd_id); sprintf(ident, "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &Plans, &nPlans); plan = find_plan(ident, &Plans, &nPlans);
...@@ -264,8 +268,7 @@ timetravel() ...@@ -264,8 +268,7 @@ timetravel()
ctypes = (Oid *) palloc(natts * sizeof(Oid)); ctypes = (Oid *) palloc(natts * sizeof(Oid));
/* /*
* Construct query: * Construct query: INSERT INTO _relation_ VALUES ($1, ...)
* INSERT INTO _relation_ VALUES ($1, ...)
*/ */
sprintf(sql, "INSERT INTO %s VALUES (", relname); sprintf(sql, "INSERT INTO %s VALUES (", relname);
for (i = 1; i <= natts; i++) for (i = 1; i <= natts; i++)
...@@ -305,20 +308,22 @@ timetravel() ...@@ -305,20 +308,22 @@ timetravel()
{ {
HeapTuple tmptuple; HeapTuple tmptuple;
tmptuple = SPI_copytuple (trigtuple); tmptuple = SPI_copytuple(trigtuple);
rettuple = SPI_modifytuple (rel, tmptuple, 1, &(attnum[1]), &newoff, NULL); rettuple = SPI_modifytuple(rel, tmptuple, 1, &(attnum[1]), &newoff, NULL);
/* /*
* SPI_copytuple allocates tmptuple in upper executor context - * SPI_copytuple allocates tmptuple in upper executor context -
* have to free allocation using SPI_pfree * have to free allocation using SPI_pfree
*/ */
SPI_pfree (tmptuple); SPI_pfree(tmptuple);
} }
else /* DELETE */ else
/* DELETE */
rettuple = trigtuple; rettuple = trigtuple;
SPI_finish(); /* don't forget say Bye to SPI mgr */ SPI_finish(); /* don't forget say Bye to SPI mgr */
pfree (relname); pfree(relname);
return (rettuple); return (rettuple);
} }
...@@ -336,7 +341,7 @@ set_timetravel(Name relname, int32 on) ...@@ -336,7 +341,7 @@ set_timetravel(Name relname, int32 on)
int i; int i;
for (i = 0; i < nTTOff; i++) for (i = 0; i < nTTOff; i++)
if (namestrcmp (relname, TTOff[i]) == 0) if (namestrcmp(relname, TTOff[i]) == 0)
break; break;
if (i < nTTOff) /* OFF currently */ if (i < nTTOff) /* OFF currently */
...@@ -345,14 +350,14 @@ set_timetravel(Name relname, int32 on) ...@@ -345,14 +350,14 @@ set_timetravel(Name relname, int32 on)
return (0); return (0);
/* turn ON */ /* turn ON */
free (TTOff[i]); free(TTOff[i]);
if (nTTOff == 1) if (nTTOff == 1)
free (TTOff); free(TTOff);
else else
{ {
if (i < nTTOff - 1) if (i < nTTOff - 1)
memcpy (&(TTOff[i]), &(TTOff[i + 1]), (nTTOff - i) * sizeof (char*)); memcpy(&(TTOff[i]), &(TTOff[i + 1]), (nTTOff - i) * sizeof(char *));
TTOff = realloc (TTOff, (nTTOff - 1) * sizeof (char*)); TTOff = realloc(TTOff, (nTTOff - 1) * sizeof(char *));
} }
nTTOff--; nTTOff--;
return (0); return (0);
...@@ -364,15 +369,15 @@ set_timetravel(Name relname, int32 on) ...@@ -364,15 +369,15 @@ set_timetravel(Name relname, int32 on)
/* turn OFF */ /* turn OFF */
if (nTTOff == 0) if (nTTOff == 0)
TTOff = malloc (sizeof (char*)); TTOff = malloc(sizeof(char *));
else else
TTOff = realloc (TTOff, (nTTOff + 1) * sizeof (char*)); TTOff = realloc(TTOff, (nTTOff + 1) * sizeof(char *));
s = rname = nameout (relname); s = rname = nameout(relname);
d = TTOff[nTTOff] = malloc (strlen (rname) + 1); d = TTOff[nTTOff] = malloc(strlen(rname) + 1);
while (*s) while (*s)
*d++ = tolower (*s++); *d++ = tolower(*s++);
*d = 0; *d = 0;
pfree (rname); pfree(rname);
nTTOff++; nTTOff++;
return (1); return (1);
...@@ -380,9 +385,9 @@ set_timetravel(Name relname, int32 on) ...@@ -380,9 +385,9 @@ set_timetravel(Name relname, int32 on)
} }
AbsoluteTime AbsoluteTime
currabstime () currabstime()
{ {
return (GetCurrentAbsoluteTime ()); return (GetCurrentAbsoluteTime());
} }
static EPlan * static EPlan *
......
...@@ -50,26 +50,34 @@ ...@@ -50,26 +50,34 @@
char * char *
string_output(char *data, int size) string_output(char *data, int size)
{ {
register unsigned char c, *p, *r, *result; register unsigned char c,
register int l, len; *p,
*r,
if (data == NULL) { *result;
register int l,
len;
if (data == NULL)
{
result = (char *) palloc(2); result = (char *) palloc(2);
result[0] = '-'; result[0] = '-';
result[1] = '\0'; result[1] = '\0';
return (result); return (result);
} }
if (size < 0) { if (size < 0)
{
size = strlen(data); size = strlen(data);
} }
/* adjust string length for escapes */ /* adjust string length for escapes */
len = size; len = size;
for (p=data,l=size; l>0; p++,l--) { for (p = data, l = size; l > 0; p++, l--)
switch (*p) { {
switch (*p)
{
case '\\': case '\\':
case '"' : case '"':
case '{': case '{':
case '}': case '}':
case '\b': case '\b':
...@@ -81,7 +89,8 @@ string_output(char *data, int size) ...@@ -81,7 +89,8 @@ string_output(char *data, int size)
len++; len++;
break; break;
default: default:
if (NOTPRINTABLE(*p)) { if (NOTPRINTABLE(*p))
{
len += 3; len += 3;
} }
} }
...@@ -90,10 +99,12 @@ string_output(char *data, int size) ...@@ -90,10 +99,12 @@ string_output(char *data, int size)
result = (char *) palloc(len); result = (char *) palloc(len);
for (p=data,r=result,l=size; (l > 0) && (c = *p); p++,l--) { for (p = data, r = result, l = size; (l > 0) && (c = *p); p++, l--)
switch (c) { {
switch (c)
{
case '\\': case '\\':
case '"' : case '"':
case '{': case '{':
case '}': case '}':
*r++ = '\\'; *r++ = '\\';
...@@ -124,7 +135,8 @@ string_output(char *data, int size) ...@@ -124,7 +135,8 @@ string_output(char *data, int size)
*r++ = 'v'; *r++ = 'v';
break; break;
default: default:
if (NOTPRINTABLE(c)) { if (NOTPRINTABLE(c))
{
*r = '\\'; *r = '\\';
r += 3; r += 3;
*r-- = DIGIT(c & 07); *r-- = DIGIT(c & 07);
...@@ -133,14 +145,16 @@ string_output(char *data, int size) ...@@ -133,14 +145,16 @@ string_output(char *data, int size)
c >>= 3; c >>= 3;
*r = DIGIT(c & 03); *r = DIGIT(c & 03);
r += 3; r += 3;
} else { }
else
{
*r++ = c; *r++ = c;
} }
} }
} }
*r = '\0'; *r = '\0';
return((char *) result); return ((char *) result);
} }
/* /*
...@@ -172,54 +186,69 @@ string_output(char *data, int size) ...@@ -172,54 +186,69 @@ string_output(char *data, int size)
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, *r; register unsigned char *p,
*r;
unsigned char *result; unsigned char *result;
int len; int len;
if ((str == NULL) || (hdrsize < 0)) { if ((str == NULL) || (hdrsize < 0))
{
return (char *) NULL; return (char *) NULL;
} }
/* Compute result size */ /* Compute result size */
len = strlen(str); len = strlen(str);
for (p=str; *p; ) { for (p = str; *p;)
if (*p++ == '\\') { {
if (ISOCTAL(*p)) { if (*p++ == '\\')
if (ISOCTAL(*(p+1))) { {
if (ISOCTAL(*p))
{
if (ISOCTAL(*(p + 1)))
{
p++; p++;
len--; len--;
} }
if (ISOCTAL(*(p+1))) { if (ISOCTAL(*(p + 1)))
{
p++; p++;
len--; len--;
} }
} }
if (*p) p++; if (*p)
p++;
len--; len--;
} }
} }
/* result has variable length */ /* result has variable length */
if (size == 0) { if (size == 0)
size = len+1; {
} else size = len + 1;
}
else
/* result has variable length with maximum size */ /* result has variable length with maximum size */
if (size < 0) { if (size < 0)
size = MIN(len, - size)+1; {
size = MIN(len, -size) + 1;
} }
result = (char *) palloc(hdrsize+size); result = (char *) palloc(hdrsize + size);
memset(result, 0, hdrsize+size); memset(result, 0, hdrsize + size);
if (rtn_size) { if (rtn_size)
{
*rtn_size = size; *rtn_size = size;
} }
r = result + hdrsize; r = result + hdrsize;
for (p=str; *p; ) { for (p = str; *p;)
{
register unsigned char c; register unsigned char c;
if ((c = *p++) == '\\') {
switch (c = *p++) { if ((c = *p++) == '\\')
{
switch (c = *p++)
{
case '\0': case '\0':
p--; p--;
break; break;
...@@ -232,11 +261,13 @@ string_input(char *str, int size, int hdrsize, int *rtn_size) ...@@ -232,11 +261,13 @@ string_input(char *str, int size, int hdrsize, int *rtn_size)
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;
...@@ -261,12 +292,14 @@ string_input(char *str, int size, int hdrsize, int *rtn_size) ...@@ -261,12 +292,14 @@ string_input(char *str, int size, int hdrsize, int *rtn_size)
default: default:
*r++ = c; *r++ = c;
} }
} else { }
else
{
*r++ = c; *r++ = c;
} }
} }
return((char *) result); return ((char *) result);
} }
char * char *
...@@ -309,12 +342,13 @@ c_char16out(char *s) ...@@ -309,12 +342,13 @@ c_char16out(char *s)
*/ */
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)
{
len = VARSIZE(vlena) - VARHDRSZ; len = VARSIZE(vlena) - VARHDRSZ;
s = VARDATA(vlena); s = VARDATA(vlena);
} }
...@@ -330,8 +364,9 @@ c_varcharout(char *s) ...@@ -330,8 +364,9 @@ c_varcharout(char *s)
{ {
int len = 0; int len = 0;
if (s) { if (s)
len = *(int32*)s - 4; {
len = *(int32 *) s - 4;
s += 4; s += 4;
} }
return (string_output(s, len)); return (string_output(s, len));
...@@ -344,7 +379,8 @@ c_textin(char *str) ...@@ -344,7 +379,8 @@ c_textin(char *str)
struct varlena *result; struct varlena *result;
int len; int len;
if (str == NULL) { if (str == NULL)
{
return ((struct varlena *) NULL); return ((struct varlena *) NULL);
} }
...@@ -359,6 +395,7 @@ c_char16in(char *str) ...@@ -359,6 +395,7 @@ c_char16in(char *str)
{ {
return (string_input(str, 16, 0, NULL)); return (string_input(str, 16, 0, NULL));
} }
#endif #endif
......
...@@ -8,12 +8,13 @@ char *c_char2out(uint16 s); ...@@ -8,12 +8,13 @@ char *c_char2out(uint16 s);
char *c_char4out(uint32 s); char *c_char4out(uint32 s);
char *c_char8out(char *s); char *c_char8out(char *s);
char *c_char16out(char *s); char *c_char16out(char *s);
char *c_textout(struct varlena *vlena); char *c_textout(struct varlena * vlena);
char *c_varcharout(char *s); char *c_varcharout(char *s);
#if 0 #if 0
struct varlena *c_textin(char *str); struct varlena *c_textin(char *str);
char *c_char16in(char *str); char *c_char16in(char *str);
#endif #endif
#endif #endif
...@@ -31,7 +31,7 @@ user_lock(unsigned int id1, unsigned int id2, LOCKT lockt) ...@@ -31,7 +31,7 @@ user_lock(unsigned int id1, unsigned int id2, LOCKT lockt)
{ {
LOCKTAG tag; LOCKTAG tag;
memset(&tag,0,sizeof(LOCKTAG)); memset(&tag, 0, sizeof(LOCKTAG));
tag.relId = 0; tag.relId = 0;
tag.dbId = MyDatabaseId; tag.dbId = MyDatabaseId;
tag.tupleId.ip_blkid.bi_hi = id2 >> 16; tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
...@@ -46,7 +46,7 @@ user_unlock(unsigned int id1, unsigned int id2, LOCKT lockt) ...@@ -46,7 +46,7 @@ user_unlock(unsigned int id1, unsigned int id2, LOCKT lockt)
{ {
LOCKTAG tag; LOCKTAG tag;
memset(&tag, 0,sizeof(LOCKTAG)); memset(&tag, 0, sizeof(LOCKTAG));
tag.relId = 0; tag.relId = 0;
tag.dbId = MyDatabaseId; tag.dbId = MyDatabaseId;
tag.tupleId.ip_blkid.bi_hi = id2 >> 16; tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
...@@ -87,8 +87,9 @@ user_unlock_all() ...@@ -87,8 +87,9 @@ user_unlock_all()
PROC *proc; PROC *proc;
SHMEM_OFFSET location; SHMEM_OFFSET location;
ShmemPIDLookup(getpid(),&location); ShmemPIDLookup(getpid(), &location);
if (location == INVALID_OFFSET) { if (location == INVALID_OFFSET)
{
elog(NOTICE, "UserUnlockAll: unable to get proc ptr"); elog(NOTICE, "UserUnlockAll: unable to get proc ptr");
return -1; return -1;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.36 1998/02/11 19:09:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.37 1998/02/26 04:29:15 momjian Exp $
* *
* NOTES * NOTES
* The old interface functions have been converted to macros * The old interface functions have been converted to macros
...@@ -430,6 +430,7 @@ nocachegetattr(HeapTuple tup, ...@@ -430,6 +430,7 @@ nocachegetattr(HeapTuple tup,
} }
else if (attnum == 0) else if (attnum == 0)
{ {
/* /*
* first attribute is always at position zero * first attribute is always at position zero
*/ */
...@@ -486,14 +487,14 @@ nocachegetattr(HeapTuple tup, ...@@ -486,14 +487,14 @@ nocachegetattr(HeapTuple tup,
{ {
/* check for nulls in any "earlier" bytes */ /* check for nulls in any "earlier" bytes */
if ((~n) != 0) if ((~n) != 0)
slow=1; slow = 1;
} }
else else
{ {
/* check for nulls "before" final bit of last byte */ /* check for nulls "before" final bit of last byte */
mask = (1 << finalbit) - 1; mask = (1 << finalbit) - 1;
if ((~n) & mask) if ((~n) & mask)
slow=1; slow = 1;
} }
} }
} }
...@@ -508,7 +509,7 @@ nocachegetattr(HeapTuple tup, ...@@ -508,7 +509,7 @@ nocachegetattr(HeapTuple tup,
{ {
if (att[attnum]->attcacheoff != -1) if (att[attnum]->attcacheoff != -1)
{ {
return (Datum)fetchatt(&(att[attnum]), return (Datum) fetchatt(&(att[attnum]),
tp + att[attnum]->attcacheoff); tp + att[attnum]->attcacheoff);
} }
else if (attnum == 0) else if (attnum == 0)
...@@ -520,8 +521,8 @@ nocachegetattr(HeapTuple tup, ...@@ -520,8 +521,8 @@ nocachegetattr(HeapTuple tup,
int j = 0; int j = 0;
/* /*
* In for(), we make this <= and not < because we want to * In for(), we make this <= and not < because we want to test
* test if we can go past it in initializing offsets. * if we can go past it in initializing offsets.
*/ */
for (j = 0; j <= attnum && !slow; j++) for (j = 0; j <= attnum && !slow; j++)
if (att[j]->attlen < 1 && !VARLENA_FIXED_SIZE(att[j])) if (att[j]->attlen < 1 && !VARLENA_FIXED_SIZE(att[j]))
...@@ -558,9 +559,10 @@ nocachegetattr(HeapTuple tup, ...@@ -558,9 +559,10 @@ nocachegetattr(HeapTuple tup,
(j < tup->t_natts && (j < tup->t_natts &&
att[j]->attcacheoff == -1 && att[j]->attcacheoff == -1 &&
(HeapTupleNoNulls(tup) || !att_isnull(j, bp)) && (HeapTupleNoNulls(tup) || !att_isnull(j, bp)) &&
(HeapTupleAllFixed(tup)|| (HeapTupleAllFixed(tup) ||
att[j]->attlen > 0 || VARLENA_FIXED_SIZE(att[j]))); j++) att[j]->attlen > 0 || VARLENA_FIXED_SIZE(att[j]))); j++)
{ {
/* /*
* Fix me when going to a machine with more than a four-byte * Fix me when going to a machine with more than a four-byte
* word! * word!
...@@ -1018,4 +1020,3 @@ heap_addheader(uint32 natts, /* max domain index */ ...@@ -1018,4 +1020,3 @@ heap_addheader(uint32 natts, /* max domain index */
return (tup); return (tup);
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.27 1998/02/11 19:09:23 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.28 1998/02/26 04:29:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -210,7 +210,7 @@ nocache_index_getattr(IndexTuple tup, ...@@ -210,7 +210,7 @@ nocache_index_getattr(IndexTuple tup,
if (att_isnull(attnum, bp)) if (att_isnull(attnum, bp))
{ {
*isnull = true; *isnull = true;
return (Datum)NULL; return (Datum) NULL;
} }
#endif #endif
...@@ -235,14 +235,14 @@ nocache_index_getattr(IndexTuple tup, ...@@ -235,14 +235,14 @@ nocache_index_getattr(IndexTuple tup,
{ {
/* check for nulls in any "earlier" bytes */ /* check for nulls in any "earlier" bytes */
if ((~n) != 0) if ((~n) != 0)
slow=1; slow = 1;
} }
else else
{ {
/* check for nulls "before" final bit of last byte */ /* check for nulls "before" final bit of last byte */
mask = (1 << finalbit) - 1; mask = (1 << finalbit) - 1;
if ((~n) & mask) if ((~n) & mask)
slow=1; slow = 1;
} }
} }
} }
...@@ -293,13 +293,14 @@ nocache_index_getattr(IndexTuple tup, ...@@ -293,13 +293,14 @@ nocache_index_getattr(IndexTuple tup,
while (att[j]->attcacheoff != -1) while (att[j]->attcacheoff != -1)
j++; j++;
if (!VARLENA_FIXED_SIZE(att[j-1])) if (!VARLENA_FIXED_SIZE(att[j - 1]))
off = att[j - 1]->attcacheoff + att[j - 1]->attlen; off = att[j - 1]->attcacheoff + att[j - 1]->attlen;
else else
off = att[j - 1]->attcacheoff + att[j - 1]->atttypmod; off = att[j - 1]->attcacheoff + att[j - 1]->atttypmod;
for (; j < attnum + 1; j++) for (; j < attnum + 1; j++)
{ {
/* /*
* Fix me when going to a machine with more than a four-byte * Fix me when going to a machine with more than a four-byte
* word! * word!
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.26 1998/02/11 19:09:25 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.27 1998/02/26 04:29:20 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.35 1998/02/10 16:02:46 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.36 1998/02/26 04:29:22 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
...@@ -487,7 +487,7 @@ BuildDescForRelation(List *schema, char *relname) ...@@ -487,7 +487,7 @@ BuildDescForRelation(List *schema, char *relname)
if (arry != NIL) if (arry != NIL)
{ {
/* array of XXX is _XXX */ /* array of XXX is _XXX */
sprintf(typename, "_%.*s", NAMEDATALEN-2,entry->typename->name); sprintf(typename, "_%.*s", NAMEDATALEN - 2, entry->typename->name);
attdim = length(arry); attdim = length(arry);
} }
else else
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.17 1997/11/20 23:19:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.18 1998/02/26 04:29:28 momjian Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.26 1998/02/11 19:09:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.27 1998/02/26 04:29:31 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -654,6 +654,7 @@ heap_beginscan(Relation relation, ...@@ -654,6 +654,7 @@ heap_beginscan(Relation relation,
sdesc->rs_rd = relation; sdesc->rs_rd = relation;
if (nkeys) if (nkeys)
/* /*
* we do this here instead of in initsdesc() because heap_rescan * we do this here instead of in initsdesc() because heap_rescan
* also calls initsdesc() and we don't want to allocate memory * also calls initsdesc() and we don't want to allocate memory
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.16 1998/01/15 19:42:02 pgsql Exp $ * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.17 1998/02/26 04:29:36 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.24 1997/11/20 23:20:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.25 1998/02/26 04:29:44 momjian Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.30 1998/01/15 19:42:13 pgsql Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.31 1998/02/26 04:29:50 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -197,12 +197,11 @@ _bt_moveright(Relation rel, ...@@ -197,12 +197,11 @@ _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
* *
* Also, if this page is not LEAF one (and # of attrs > keysize) * Also, if this page is not LEAF one (and # of attrs > keysize)
* then we can't move too. * then we can't move too. - vadim 10/22/97
* - vadim 10/22/97
*/ */
if (_bt_skeycmp(rel, keysz, scankey, page, hikey, if (_bt_skeycmp(rel, keysz, scankey, page, hikey,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Id: nbtsort.c,v 1.28 1998/02/21 19:23:14 scrappy Exp $ * $Id: nbtsort.c,v 1.29 1998/02/26 04:29:54 momjian Exp $
* *
* NOTES * NOTES
* *
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.15 1998/01/07 21:02:05 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.16 1998/02/26 04:30:06 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.22 1998/01/15 19:42:19 pgsql Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.23 1998/02/26 04:30:15 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.16 1998/01/07 21:02:17 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.17 1998/02/26 04:30:18 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
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.11 1997/11/02 15:24:47 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.12 1998/02/26 04:30:19 momjian Exp $
* *
* OLD COMMENTS * OLD COMMENTS
* XXX WARNING * XXX WARNING
......
...@@ -7,7 +7,7 @@ ...@@ -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.36 1998/02/11 19:09:34 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.37 1998/02/26 04:30:22 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -208,11 +208,13 @@ extern int fsyncOff; /* do not fsync the database */ ...@@ -208,11 +208,13 @@ extern int fsyncOff; /* do not fsync the database */
#if !defined(HAVE_SIGSETJMP) && !defined(sigsetjmp) #if !defined(HAVE_SIGSETJMP) && !defined(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
#else #else
static sigjmp_buf Warn_restart; static sigjmp_buf Warn_restart;
#endif #endif
int DebugMode; int DebugMode;
...@@ -472,8 +474,8 @@ boot_openrel(char *relname) ...@@ -472,8 +474,8 @@ boot_openrel(char *relname)
HeapScanDesc sdesc; HeapScanDesc sdesc;
HeapTuple tup; HeapTuple tup;
if (strlen(relname) >= NAMEDATALEN-1) if (strlen(relname) >= NAMEDATALEN - 1)
relname[NAMEDATALEN-1] = '\0'; relname[NAMEDATALEN - 1] = '\0';
if (Typ == (struct typmap **) NULL) if (Typ == (struct typmap **) NULL)
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.7 1998/02/25 13:05:57 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.8 1998/02/26 04:30:26 momjian Exp $
* *
* NOTES * NOTES
* See acl.h. * See acl.h.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.14 1998/02/11 19:09:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.15 1998/02/26 04:30:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.46 1998/02/11 19:09:54 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.47 1998/02/26 04:30:35 momjian Exp $
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* heap_create() - Create an uncataloged heap relation * heap_create() - Create an uncataloged heap relation
...@@ -63,7 +63,8 @@ ...@@ -63,7 +63,8 @@
#include <string.h> #include <string.h>
#endif #endif
static void AddPgRelationTuple(Relation pg_class_desc, static void
AddPgRelationTuple(Relation pg_class_desc,
Relation new_rel_desc, Oid new_rel_oid, unsigned natts); Relation new_rel_desc, Oid new_rel_oid, unsigned natts);
static void AddToTempRelList(Relation r); static void AddToTempRelList(Relation r);
static void DeletePgAttributeTuples(Relation rdesc); static void DeletePgAttributeTuples(Relation rdesc);
...@@ -731,9 +732,9 @@ addNewRelationType(char *typeName, Oid new_rel_oid) ...@@ -731,9 +732,9 @@ addNewRelationType(char *typeName, Oid new_rel_oid)
'c', /* type-type (catalog) */ 'c', /* type-type (catalog) */
',', /* default array delimiter */ ',', /* default array delimiter */
"int4in", /* input procedure */ "int4in", /* input procedure */
"int4out",/* output procedure */ "int4out", /* output procedure */
"int4in", /* receive procedure */ "int4in", /* receive procedure */
"int4out",/* send procedure */ "int4out", /* send procedure */
NULL, /* array element type - irrelevent */ NULL, /* array element type - irrelevent */
"-", /* default type value */ "-", /* default type value */
(bool) 1, /* passed by value */ (bool) 1, /* passed by value */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.38 1998/02/07 21:41:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.39 1998/02/26 04:30:38 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -1611,7 +1611,7 @@ DefaultBuild(Relation heapRelation, ...@@ -1611,7 +1611,7 @@ DefaultBuild(Relation heapRelation,
*/ */
scan = heap_beginscan(heapRelation, /* relation */ scan = heap_beginscan(heapRelation, /* relation */
0, /* start at end */ 0, /* start at end */
false, /* seeself */ false,/* seeself */
0, /* number of keys */ 0, /* number of keys */
(ScanKey) NULL); /* scan key */ (ScanKey) NULL); /* scan key */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.12 1998/02/11 19:10:03 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.13 1998/02/26 04:30:40 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.21 1998/02/11 19:10:11 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.22 1998/02/26 04:30:41 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.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.14 1998/02/11 19:10:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.15 1998/02/26 04:30:43 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.19 1998/02/11 19:10:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.20 1998/02/26 04:30:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.28 1998/01/31 04:38:17 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.29 1998/02/26 04:30:47 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
#include <libpq/libpq.h> #include <libpq/libpq.h>
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
# include <port-protos.h> /* for strdup() */ #include <port-protos.h> /* for strdup() */
#endif #endif
#include <storage/lmgr.h> #include <storage/lmgr.h>
...@@ -617,7 +617,7 @@ Async_NotifyFrontEnd() ...@@ -617,7 +617,7 @@ Async_NotifyFrontEnd()
if (whereToSendOutput == Remote) if (whereToSendOutput == Remote)
{ {
pq_putnchar("A", 1); pq_putnchar("A", 1);
pq_putint((int32)MyProcPid, sizeof(int32)); pq_putint((int32) MyProcPid, sizeof(int32));
pq_putstr(DatumGetName(d)->data); pq_putstr(DatumGetName(d)->data);
pq_flush(); pq_flush();
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.22 1998/01/10 05:19:03 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.23 1998/02/26 04:30:49 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -212,8 +212,8 @@ copy_heap(Oid OIDOldHeap) ...@@ -212,8 +212,8 @@ copy_heap(Oid OIDOldHeap)
OldHeapDesc = RelationGetTupleDescriptor(OldHeap); OldHeapDesc = RelationGetTupleDescriptor(OldHeap);
/* /*
* Need to make a copy of the tuple descriptor, heap_create_with_catalog * Need to make a copy of the tuple descriptor,
* modifies it. * heap_create_with_catalog modifies it.
*/ */
tupdesc = CreateTupleDescCopy(OldHeapDesc); tupdesc = CreateTupleDescCopy(OldHeapDesc);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.25 1998/02/07 21:41:52 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.26 1998/02/26 04:30:49 momjian Exp $
* *
* NOTES * NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated * The PortalExecutorHeapMemory crap needs to be eliminated
...@@ -149,11 +149,11 @@ PerformPortalFetch(char *name, ...@@ -149,11 +149,11 @@ PerformPortalFetch(char *name,
*/ */
queryDesc = PortalGetQueryDesc(portal); queryDesc = PortalGetQueryDesc(portal);
if ( dest == None ) /* MOVE */ if (dest == None) /* MOVE */
{ {
QueryDesc *qdesc = (QueryDesc *) palloc (sizeof (QueryDesc)); QueryDesc *qdesc = (QueryDesc *) palloc(sizeof(QueryDesc));
memcpy (qdesc, queryDesc, sizeof (QueryDesc)); memcpy(qdesc, queryDesc, sizeof(QueryDesc));
qdesc->dest = dest; qdesc->dest = dest;
queryDesc = qdesc; queryDesc = qdesc;
} }
...@@ -178,8 +178,8 @@ PerformPortalFetch(char *name, ...@@ -178,8 +178,8 @@ PerformPortalFetch(char *name,
ExecutorRun(queryDesc, PortalGetState(portal), feature, count); ExecutorRun(queryDesc, PortalGetState(portal), feature, count);
if ( dest == None ) /* MOVE */ if (dest == None) /* MOVE */
pfree (queryDesc); pfree(queryDesc);
/* ---------------- /* ----------------
* Note: the "end-of-command" tag is returned by higher-level * Note: the "end-of-command" tag is returned by higher-level
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.43 1998/02/25 13:06:08 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.44 1998/02/26 04:30:52 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -48,7 +48,8 @@ static Oid GetOutputFunction(Oid type); ...@@ -48,7 +48,8 @@ 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 GetIndexRelations(Oid main_relation_oid, static void
GetIndexRelations(Oid main_relation_oid,
int *n_indices, int *n_indices,
Relation **index_rels); Relation **index_rels);
...@@ -592,7 +593,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -592,7 +593,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
if (!PointerIsValid(values[i]) && if (!PointerIsValid(values[i]) &&
!(rel->rd_att->attrs[i]->attbyval)) !(rel->rd_att->attrs[i]->attbyval))
{ {
elog(ERROR, "copy from line %d: Bad file format",lineno); elog(ERROR, "copy from line %d: Bad file format", lineno);
} }
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.25 1998/02/10 04:00:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.26 1998/02/26 04:30:55 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -334,7 +334,8 @@ MergeAttributes(List *schema, List *supers, List **supconstr) ...@@ -334,7 +334,8 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
for (i = 0; i < constr->num_check; i++) for (i = 0; i < constr->num_check; i++)
{ {
Constraint *cdef = (Constraint *) makeNode(Constraint); /* palloc(sizeof(Constraint)); */ Constraint *cdef = (Constraint *) makeNode(Constraint); /* palloc(sizeof(Constrai
* nt)); */
cdef->contype = CONSTR_CHECK; cdef->contype = CONSTR_CHECK;
if (check[i].ccname[0] == '$') if (check[i].ccname[0] == '$')
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.7 1998/02/25 13:06:09 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.8 1998/02/26 04:30:56 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -61,10 +61,10 @@ createdb(char *dbname, char *dbpath) ...@@ -61,10 +61,10 @@ createdb(char *dbname, char *dbpath)
closeAllVfds(); closeAllVfds();
/* Now create directory for this new database */ /* Now create directory for this new database */
if ((dbpath != NULL) && (strcmp(dbpath,dbname) != 0)) if ((dbpath != NULL) && (strcmp(dbpath, dbname) != 0))
{ {
if (*(dbpath+strlen(dbpath)-1) == SEP_CHAR) if (*(dbpath + strlen(dbpath) - 1) == SEP_CHAR)
*(dbpath+strlen(dbpath)-1) = '\0'; *(dbpath + strlen(dbpath) - 1) = '\0';
sprintf(loc, "%s%c%s", dbpath, SEP_CHAR, dbname); sprintf(loc, "%s%c%s", dbpath, SEP_CHAR, dbname);
} }
else else
...@@ -75,12 +75,12 @@ createdb(char *dbname, char *dbpath) ...@@ -75,12 +75,12 @@ createdb(char *dbname, char *dbpath)
lp = ExpandDatabasePath(loc); lp = ExpandDatabasePath(loc);
if (lp == NULL) if (lp == NULL)
elog(ERROR,"Unable to locate path '%s'" elog(ERROR, "Unable to locate path '%s'"
"\n\tThis may be due to a missing environment variable" "\n\tThis may be due to a missing environment variable"
" in the server",loc); " in the server", loc);
if (mkdir(lp,S_IRWXU) != 0) if (mkdir(lp, S_IRWXU) != 0)
elog(ERROR,"Unable to create database directory %s",lp); elog(ERROR, "Unable to create database directory %s", lp);
sprintf(buf, "%s %s%cbase%ctemplate1%c* %s", sprintf(buf, "%s %s%cbase%ctemplate1%c* %s",
COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp); COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp);
...@@ -104,7 +104,7 @@ destroydb(char *dbname) ...@@ -104,7 +104,7 @@ destroydb(char *dbname)
Oid user_id, Oid user_id,
db_id; db_id;
char *path; char *path;
char dbpath[MAXPGPATH+1]; char dbpath[MAXPGPATH + 1];
char buf[512]; char buf[512];
/* /*
...@@ -123,9 +123,9 @@ destroydb(char *dbname) ...@@ -123,9 +123,9 @@ destroydb(char *dbname)
path = ExpandDatabasePath(dbpath); path = ExpandDatabasePath(dbpath);
if (path == NULL) if (path == NULL)
elog(ERROR,"Unable to locate path '%s'" elog(ERROR, "Unable to locate path '%s'"
"\n\tThis may be due to a missing environment variable" "\n\tThis may be due to a missing environment variable"
" in the server",dbpath); " in the server", dbpath);
/* /*
* remove the pg_database tuple FIRST, this may fail due to * remove the pg_database tuple FIRST, this may fail due to
...@@ -206,7 +206,7 @@ check_permissions(char *command, ...@@ -206,7 +206,7 @@ check_permissions(char *command,
bool use_super; bool use_super;
char *userName; char *userName;
text *dbtext; text *dbtext;
char path[MAXPGPATH+1]; char path[MAXPGPATH + 1];
userName = GetPgUserName(); userName = GetPgUserName();
utup = SearchSysCacheTuple(USENAME, PointerGetDatum(userName), utup = SearchSysCacheTuple(USENAME, PointerGetDatum(userName),
...@@ -268,8 +268,8 @@ check_permissions(char *command, ...@@ -268,8 +268,8 @@ check_permissions(char *command,
RelationGetTupleDescriptor(dbrel), RelationGetTupleDescriptor(dbrel),
(char *) NULL); (char *) NULL);
strncpy(path, VARDATA(dbtext), (VARSIZE(dbtext)-VARHDRSZ)); strncpy(path, VARDATA(dbtext), (VARSIZE(dbtext) - VARHDRSZ));
*(path+VARSIZE(dbtext)-VARHDRSZ) = '\0'; *(path + VARSIZE(dbtext) - VARHDRSZ) = '\0';
} }
else else
{ {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.23 1998/02/25 13:06:12 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.24 1998/02/26 04:30:57 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
...@@ -273,7 +273,8 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest) ...@@ -273,7 +273,8 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
PointerGetDatum(languageName), PointerGetDatum(languageName),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(languageTuple)) { if (!HeapTupleIsValid(languageTuple))
{
elog(ERROR, elog(ERROR,
"Unrecognized language specified in a CREATE FUNCTION: " "Unrecognized language specified in a CREATE FUNCTION: "
...@@ -284,16 +285,18 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest) ...@@ -284,16 +285,18 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
/* Check that this language is a PL */ /* Check that this language is a PL */
languageStruct = (Form_pg_language) GETSTRUCT(languageTuple); languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
if (!(languageStruct->lanispl)) { if (!(languageStruct->lanispl))
{
elog(ERROR, elog(ERROR,
"Language '%s' isn't defined as PL", languageName); "Language '%s' isn't defined as PL", languageName);
} }
/* /*
* Functions in untrusted procedural languages are * Functions in untrusted procedural languages are restricted to
* restricted to be defined by postgres superusers only * be defined by postgres superusers only
*/ */
if (languageStruct->lanpltrusted == false && !superuser()) { if (languageStruct->lanpltrusted == false && !superuser())
{
elog(ERROR, "Only users with Postgres superuser privilege " elog(ERROR, "Only users with Postgres superuser privilege "
"are permitted to create a function in the '%s' " "are permitted to create a function in the '%s' "
"language.", "language.",
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.17 1998/02/13 03:21:30 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.18 1998/02/26 04:30:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -214,13 +214,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -214,13 +214,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
appendStringInfo(str, " "); appendStringInfo(str, " ");
appendStringInfo(str, " InitPlan\n"); appendStringInfo(str, " InitPlan\n");
foreach (lst, plan->initPlan) foreach(lst, plan->initPlan)
{ {
es->rtable = ((SubPlan*) lfirst(lst))->rtable; es->rtable = ((SubPlan *) lfirst(lst))->rtable;
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
appendStringInfo(str, " "); appendStringInfo(str, " ");
appendStringInfo(str, " -> "); appendStringInfo(str, " -> ");
explain_outNode(str, ((SubPlan*) lfirst(lst))->plan, indent + 4, es); explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 4, es);
} }
es->rtable = saved_rtable; es->rtable = saved_rtable;
} }
...@@ -252,13 +252,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -252,13 +252,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
appendStringInfo(str, " "); appendStringInfo(str, " ");
appendStringInfo(str, " SubPlan\n"); appendStringInfo(str, " SubPlan\n");
foreach (lst, plan->subPlan) foreach(lst, plan->subPlan)
{ {
es->rtable = ((SubPlan*) lfirst(lst))->rtable; es->rtable = ((SubPlan *) lfirst(lst))->rtable;
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
appendStringInfo(str, " "); appendStringInfo(str, " ");
appendStringInfo(str, " -> "); appendStringInfo(str, " -> ");
explain_outNode(str, ((SubPlan*) lfirst(lst))->plan, indent + 4, es); explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 4, es);
} }
es->rtable = saved_rtable; es->rtable = saved_rtable;
} }
......
...@@ -43,7 +43,7 @@ case_translate_language_name(const char *input, char *output) ...@@ -43,7 +43,7 @@ case_translate_language_name(const char *input, char *output)
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
*/ */
void void
CreateProceduralLanguage(CreatePLangStmt * stmt) CreateProceduralLanguage(CreatePLangStmt *stmt)
{ {
char languageName[NAMEDATALEN]; char languageName[NAMEDATALEN];
HeapTuple langTup; HeapTuple langTup;
...@@ -139,7 +139,7 @@ CreateProceduralLanguage(CreatePLangStmt * stmt) ...@@ -139,7 +139,7 @@ CreateProceduralLanguage(CreatePLangStmt * stmt)
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
*/ */
void void
DropProceduralLanguage(DropPLangStmt * stmt) DropProceduralLanguage(DropPLangStmt *stmt)
{ {
char languageName[NAMEDATALEN]; char languageName[NAMEDATALEN];
HeapTuple langTup; HeapTuple langTup;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.19 1998/02/10 04:00:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.20 1998/02/26 04:30:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -38,7 +38,7 @@ TriggerData *CurrentTriggerData = NULL; ...@@ -38,7 +38,7 @@ 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);
static HeapTuple static HeapTuple
GetTupleForTrigger(Relation relation, ItemPointer tid, GetTupleForTrigger(Relation relation, ItemPointer tid,
bool before); bool before);
...@@ -46,7 +46,7 @@ GetTupleForTrigger(Relation relation, ItemPointer tid, ...@@ -46,7 +46,7 @@ GetTupleForTrigger(Relation relation, ItemPointer tid,
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};
...@@ -249,7 +249,7 @@ CreateTrigger(CreateTrigStmt * stmt) ...@@ -249,7 +249,7 @@ CreateTrigger(CreateTrigStmt * stmt)
} }
void void
DropTrigger(DropTrigStmt * stmt) DropTrigger(DropTrigStmt *stmt)
{ {
Relation rel; Relation rel;
Relation tgrel; Relation tgrel;
...@@ -519,7 +519,7 @@ FreeTriggerDesc(Relation relation) ...@@ -519,7 +519,7 @@ 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,
...@@ -593,7 +593,7 @@ DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger) ...@@ -593,7 +593,7 @@ DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger)
} }
static HeapTuple static HeapTuple
ExecCallTriggerFunc(Trigger * trigger) ExecCallTriggerFunc(Trigger *trigger)
{ {
if (trigger->tgfunc.fn_addr == NULL) if (trigger->tgfunc.fn_addr == NULL)
...@@ -601,7 +601,8 @@ ExecCallTriggerFunc(Trigger * trigger) ...@@ -601,7 +601,8 @@ ExecCallTriggerFunc(Trigger * trigger)
fmgr_info(trigger->tgfoid, &trigger->tgfunc); fmgr_info(trigger->tgfoid, &trigger->tgfunc);
} }
if (trigger->tgfunc.fn_plhandler != NULL) { if (trigger->tgfunc.fn_plhandler != NULL)
{
return (HeapTuple) (*(trigger->tgfunc.fn_plhandler)) return (HeapTuple) (*(trigger->tgfunc.fn_plhandler))
(&trigger->tgfunc); (&trigger->tgfunc);
} }
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.62 1998/02/25 23:40:32 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.63 1998/02/26 04:31:03 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
/* #include <port-protos.h> */ /* Why? */ /* #include <port-protos.h> *//* Why? */
extern int BlowawayRelationBuffers(Relation rdesc, BlockNumber block); extern int BlowawayRelationBuffers(Relation rdesc, BlockNumber block);
...@@ -136,7 +136,7 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec) ...@@ -136,7 +136,7 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
old = MemoryContextSwitchTo((MemoryContext) pmem); old = MemoryContextSwitchTo((MemoryContext) pmem);
if (va_spec != NIL && !analyze) if (va_spec != NIL && !analyze)
elog(ERROR,"Can't vacuum columns, only tables. You can 'vacuum analyze' columns."); elog(ERROR, "Can't vacuum columns, only tables. You can 'vacuum analyze' columns.");
foreach(le, va_spec) foreach(le, va_spec)
{ {
...@@ -725,6 +725,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, ...@@ -725,6 +725,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
} }
else if (!TransactionIdIsInProgress(htup->t_xmin)) else if (!TransactionIdIsInProgress(htup->t_xmin))
{ {
/* /*
* Not Aborted, Not Committed, Not in Progress - * Not Aborted, Not Committed, Not in Progress -
* so it's from crashed process. - vadim 11/26/96 * so it's from crashed process. - vadim 11/26/96
...@@ -742,8 +743,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, ...@@ -742,8 +743,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
} }
/* /*
* here we are concerned about tuples with xmin committed * here we are concerned about tuples with xmin committed and
* and xmax unknown or committed * xmax unknown or committed
*/ */
if (htup->t_infomask & HEAP_XMIN_COMMITTED && if (htup->t_infomask & HEAP_XMIN_COMMITTED &&
!(htup->t_infomask & HEAP_XMAX_INVALID)) !(htup->t_infomask & HEAP_XMAX_INVALID))
...@@ -759,6 +760,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, ...@@ -759,6 +760,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
tupgone = true; tupgone = true;
else if (!TransactionIdIsInProgress(htup->t_xmax)) else if (!TransactionIdIsInProgress(htup->t_xmax))
{ {
/* /*
* Not Aborted, Not Committed, Not in Progress - so it * Not Aborted, Not Committed, Not in Progress - so it
* from crashed process. - vadim 06/02/97 * from crashed process. - vadim 06/02/97
...@@ -1095,7 +1097,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, ...@@ -1095,7 +1097,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
Fvpl->vpl_pgdesc + ToVpI + 1, Fvpl->vpl_pgdesc + ToVpI + 1,
sizeof(VPageDescr *) * (Fnpages - ToVpI - 1)); sizeof(VPageDescr *) * (Fnpages - ToVpI - 1));
Fnpages--; Fnpages--;
Assert (Fvplast == Fvpl->vpl_pgdesc[Fnpages - 1]); Assert(Fvplast == Fvpl->vpl_pgdesc[Fnpages - 1]);
} }
} }
for (i = 0; i < Fnpages; i++) for (i = 0; i < Fnpages; i++)
...@@ -1333,7 +1335,7 @@ Elapsed %u/%u sec.", ...@@ -1333,7 +1335,7 @@ Elapsed %u/%u sec.",
{ {
i = BlowawayRelationBuffers(onerel, blkno); i = BlowawayRelationBuffers(onerel, blkno);
if (i < 0) if (i < 0)
elog (FATAL, "VACUUM (vc_rpfheap): BlowawayRelationBuffers returned %d", i); elog(FATAL, "VACUUM (vc_rpfheap): BlowawayRelationBuffers returned %d", i);
blkno = smgrtruncate(DEFAULT_SMGR, onerel, blkno); blkno = smgrtruncate(DEFAULT_SMGR, onerel, blkno);
Assert(blkno >= 0); Assert(blkno >= 0);
vacrelstats->npages = blkno; /* set new number of blocks */ vacrelstats->npages = blkno; /* set new number of blocks */
...@@ -1367,7 +1369,7 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl) ...@@ -1367,7 +1369,7 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl)
int i; int i;
nblocks = Vvpl->vpl_npages; nblocks = Vvpl->vpl_npages;
nblocks -= Vvpl->vpl_nemend; /* nothing to do with them */ nblocks -= Vvpl->vpl_nemend;/* nothing to do with them */
for (i = 0, vpp = Vvpl->vpl_pgdesc; i < nblocks; i++, vpp++) for (i = 0, vpp = Vvpl->vpl_pgdesc; i < nblocks; i++, vpp++)
{ {
...@@ -1397,7 +1399,7 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl) ...@@ -1397,7 +1399,7 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl)
i = BlowawayRelationBuffers(onerel, nblocks); i = BlowawayRelationBuffers(onerel, nblocks);
if (i < 0) if (i < 0)
elog (FATAL, "VACUUM (vc_vacheap): BlowawayRelationBuffers returned %d", i); elog(FATAL, "VACUUM (vc_vacheap): BlowawayRelationBuffers returned %d", i);
nblocks = smgrtruncate(DEFAULT_SMGR, onerel, nblocks); nblocks = smgrtruncate(DEFAULT_SMGR, onerel, nblocks);
Assert(nblocks >= 0); Assert(nblocks >= 0);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Routines for handling of 'SET var TO', * Routines for handling of 'SET var TO',
* 'SHOW var' and 'RESET var' statements. * 'SHOW var' and 'RESET var' statements.
* *
* $Id: variable.c,v 1.3 1998/02/03 16:06:49 thomas Exp $ * $Id: variable.c,v 1.4 1998/02/26 04:31:05 momjian Exp $
* *
*/ */
...@@ -61,7 +61,7 @@ get_token(char **tok, char **val, const char *str) ...@@ -61,7 +61,7 @@ get_token(char **tok, char **val, const char *str)
} }
*tok = (char *) palloc(len + 1); *tok = (char *) palloc(len + 1);
StrNCpy(*tok, start, len+1); StrNCpy(*tok, start, len + 1);
/* skip white spaces */ /* skip white spaces */
while (isspace(*str)) while (isspace(*str))
...@@ -107,7 +107,7 @@ get_token(char **tok, char **val, const char *str) ...@@ -107,7 +107,7 @@ get_token(char **tok, char **val, const char *str)
} }
*val = (char *) palloc(len + 1); *val = (char *) palloc(len + 1);
StrNCpy(*val, start, len+1); StrNCpy(*val, start, len + 1);
/* skip white spaces */ /* skip white spaces */
while (isspace(*str)) while (isspace(*str))
...@@ -342,18 +342,21 @@ parse_date(const char *value) ...@@ -342,18 +342,21 @@ parse_date(const char *value)
DateStyle = USE_GERMAN_DATES; DateStyle = USE_GERMAN_DATES;
dcnt++; dcnt++;
EuroDates = TRUE; EuroDates = TRUE;
if ((ecnt > 0) && (! EuroDates)) ecnt++; if ((ecnt > 0) && (!EuroDates))
ecnt++;
} }
else if (!strncasecmp(tok, "EURO", 4)) else if (!strncasecmp(tok, "EURO", 4))
{ {
EuroDates = TRUE; EuroDates = TRUE;
if ((dcnt <= 0) || (DateStyle != USE_GERMAN_DATES)) ecnt++; if ((dcnt <= 0) || (DateStyle != USE_GERMAN_DATES))
ecnt++;
} }
else if ((!strcasecmp(tok, "US")) else if ((!strcasecmp(tok, "US"))
|| (!strncasecmp(tok, "NONEURO", 7))) || (!strncasecmp(tok, "NONEURO", 7)))
{ {
EuroDates = FALSE; EuroDates = FALSE;
if ((dcnt <= 0) || (DateStyle == USE_GERMAN_DATES)) ecnt++; if ((dcnt <= 0) || (DateStyle == USE_GERMAN_DATES))
ecnt++;
} }
else if (!strcasecmp(tok, "DEFAULT")) else if (!strcasecmp(tok, "DEFAULT"))
{ {
...@@ -468,7 +471,7 @@ show_timezone() ...@@ -468,7 +471,7 @@ show_timezone()
tz = getenv("TZ"); tz = getenv("TZ");
elog(NOTICE, "Time zone is %s", ((tz != NULL)? tz: "unknown")); elog(NOTICE, "Time zone is %s", ((tz != NULL) ? tz : "unknown"));
return TRUE; return TRUE;
} /* show_timezone() */ } /* show_timezone() */
...@@ -501,7 +504,10 @@ reset_timezone() ...@@ -501,7 +504,10 @@ reset_timezone()
tzset(); tzset();
} }
/* otherwise, time zone was set but no original explicit time zone available */ /*
* otherwise, time zone was set but no original explicit time zone
* available
*/
else else
{ {
strcpy(tzbuf, "="); strcpy(tzbuf, "=");
...@@ -523,13 +529,27 @@ struct VariableParsers ...@@ -523,13 +529,27 @@ struct VariableParsers
} VariableParsers[] = } VariableParsers[] =
{ {
{ "datestyle", parse_date, show_date, reset_date }, {
{ "timezone", parse_timezone, show_timezone, reset_timezone }, "datestyle", parse_date, show_date, reset_date
{ "cost_heap", parse_cost_heap, show_cost_heap, reset_cost_heap }, },
{ "cost_index", parse_cost_index, show_cost_index, reset_cost_index }, {
{ "geqo", parse_geqo, show_geqo, reset_geqo }, "timezone", parse_timezone, show_timezone, reset_timezone
{ "r_plans", parse_r_plans, show_r_plans, reset_r_plans }, },
{ NULL, NULL, NULL, NULL } {
"cost_heap", parse_cost_heap, show_cost_heap, reset_cost_heap
},
{
"cost_index", parse_cost_index, show_cost_index, reset_cost_index
},
{
"geqo", parse_geqo, show_geqo, reset_geqo
},
{
"r_plans", parse_r_plans, show_r_plans, reset_r_plans
},
{
NULL, NULL, NULL, NULL
}
}; };
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.20 1998/02/10 04:00:32 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.21 1998/02/26 04:31:06 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.18 1998/02/23 06:26:53 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.19 1998/02/26 04:31:08 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -296,29 +296,32 @@ void ...@@ -296,29 +296,32 @@ void
ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent) ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
{ {
if ( node->chgParam != NULL ) /* Wow! */ if (node->chgParam != NULL) /* Wow! */
{ {
List *lst; List *lst;
foreach (lst, node->initPlan) foreach(lst, node->initPlan)
{ {
Plan *splan = ((SubPlan*) lfirst (lst))->plan; Plan *splan = ((SubPlan *) lfirst(lst))->plan;
if ( splan->extParam != NULL ) /* don't care about child locParam */
SetChangedParamList (splan, node->chgParam); if (splan->extParam != NULL) /* don't care about child
if ( splan->chgParam != NULL ) * locParam */
ExecReScanSetParamPlan ((SubPlan*) lfirst (lst), node); SetChangedParamList(splan, node->chgParam);
if (splan->chgParam != NULL)
ExecReScanSetParamPlan((SubPlan *) lfirst(lst), node);
} }
foreach (lst, node->subPlan) foreach(lst, node->subPlan)
{ {
Plan *splan = ((SubPlan*) lfirst (lst))->plan; Plan *splan = ((SubPlan *) lfirst(lst))->plan;
if ( splan->extParam != NULL )
SetChangedParamList (splan, node->chgParam); if (splan->extParam != NULL)
SetChangedParamList(splan, node->chgParam);
} }
/* Well. Now set chgParam for left/right trees. */ /* Well. Now set chgParam for left/right trees. */
if ( node->lefttree != NULL ) if (node->lefttree != NULL)
SetChangedParamList (node->lefttree, node->chgParam); SetChangedParamList(node->lefttree, node->chgParam);
if ( node->righttree != NULL ) if (node->righttree != NULL)
SetChangedParamList (node->righttree, node->chgParam); SetChangedParamList(node->righttree, node->chgParam);
} }
switch (nodeTag(node)) switch (nodeTag(node))
...@@ -332,35 +335,35 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent) ...@@ -332,35 +335,35 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
break; break;
case T_Material: case T_Material:
ExecMaterialReScan((Material*) node, exprCtxt, parent); ExecMaterialReScan((Material *) node, exprCtxt, parent);
break; break;
case T_NestLoop: case T_NestLoop:
ExecReScanNestLoop((NestLoop*) node, exprCtxt, parent); ExecReScanNestLoop((NestLoop *) node, exprCtxt, parent);
break; break;
case T_HashJoin: case T_HashJoin:
ExecReScanHashJoin((HashJoin*) node, exprCtxt, parent); ExecReScanHashJoin((HashJoin *) node, exprCtxt, parent);
break; break;
case T_Hash: case T_Hash:
ExecReScanHash((Hash*) node, exprCtxt, parent); ExecReScanHash((Hash *) node, exprCtxt, parent);
break; break;
case T_Agg: case T_Agg:
ExecReScanAgg((Agg*) node, exprCtxt, parent); ExecReScanAgg((Agg *) node, exprCtxt, parent);
break; break;
case T_Result: case T_Result:
ExecReScanResult((Result*) node, exprCtxt, parent); ExecReScanResult((Result *) node, exprCtxt, parent);
break; break;
case T_Unique: case T_Unique:
ExecReScanUnique((Unique*) node, exprCtxt, parent); ExecReScanUnique((Unique *) node, exprCtxt, parent);
break; break;
case T_Sort: case T_Sort:
ExecReScanSort((Sort*) node, exprCtxt, parent); ExecReScanSort((Sort *) node, exprCtxt, parent);
break; break;
/* /*
...@@ -374,9 +377,9 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent) ...@@ -374,9 +377,9 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
return; return;
} }
if ( node->chgParam != NULL ) if (node->chgParam != NULL)
{ {
freeList (node->chgParam); freeList(node->chgParam);
node->chgParam = NULL; node->chgParam = NULL;
} }
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.43 1998/02/21 06:31:37 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.44 1998/02/26 04:31:09 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,22 +57,28 @@ ...@@ -57,22 +57,28 @@
/* decls for local routines only used within this module */ /* decls for local routines only used within this module */
static void ExecCheckPerms(CmdType operation, int resultRelation, List *rangeTable, static void
ExecCheckPerms(CmdType operation, int resultRelation, List *rangeTable,
Query *parseTree); Query *parseTree);
static TupleDesc InitPlan(CmdType operation, Query *parseTree, static TupleDesc
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 * ExecutePlan(EState *estate, Plan *plan, static TupleTableSlot *
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 ExecAppend(TupleTableSlot *slot, ItemPointer tupleid, static void
ExecAppend(TupleTableSlot *slot, ItemPointer tupleid,
EState *estate); EState *estate);
static void ExecDelete(TupleTableSlot *slot, ItemPointer tupleid, static void
ExecDelete(TupleTableSlot *slot, ItemPointer tupleid,
EState *estate); EState *estate);
static void ExecReplace(TupleTableSlot *slot, ItemPointer tupleid, static void
ExecReplace(TupleTableSlot *slot, ItemPointer tupleid,
EState *estate, Query *parseTree); EState *estate, Query *parseTree);
/* end of local decls */ /* end of local decls */
...@@ -90,6 +96,7 @@ ExecutorLimit(int limit) ...@@ -90,6 +96,7 @@ ExecutorLimit(int limit)
{ {
return queryLimit = limit; return queryLimit = limit;
} }
#endif #endif
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
...@@ -113,9 +120,9 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate) ...@@ -113,9 +120,9 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
if (queryDesc->plantree->nParamExec > 0) if (queryDesc->plantree->nParamExec > 0)
{ {
estate->es_param_exec_vals = (ParamExecData*) estate->es_param_exec_vals = (ParamExecData *)
palloc (queryDesc->plantree->nParamExec * sizeof (ParamExecData)); palloc(queryDesc->plantree->nParamExec * sizeof(ParamExecData));
memset (estate->es_param_exec_vals, 0 , queryDesc->plantree->nParamExec * sizeof (ParamExecData)); memset(estate->es_param_exec_vals, 0, queryDesc->plantree->nParamExec * sizeof(ParamExecData));
} }
result = InitPlan(queryDesc->operation, result = InitPlan(queryDesc->operation,
...@@ -301,11 +308,12 @@ ExecCheckPerms(CmdType operation, ...@@ -301,11 +308,12 @@ ExecCheckPerms(CmdType operation,
if (rte->skipAcl) if (rte->skipAcl)
{ {
/* /*
* This happens if the access to this table is due * This happens if the access to this table is due to a view
* to a view query rewriting - the rewrite handler * query rewriting - the rewrite handler checked the
* checked the permissions against the view owner, * permissions against the view owner, so we just skip this
* so we just skip this entry. * entry.
*/ */
continue; continue;
} }
...@@ -1283,6 +1291,7 @@ ExecAttrDefault(Relation rel, HeapTuple tuple) ...@@ -1283,6 +1291,7 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
return (newtuple); return (newtuple);
} }
#endif #endif
static char * static char *
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.8 1998/02/13 03:26:40 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.9 1998/02/26 04:31:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -117,10 +117,10 @@ ExecInitNode(Plan *node, EState *estate, Plan *parent) ...@@ -117,10 +117,10 @@ ExecInitNode(Plan *node, EState *estate, Plan *parent)
if (node == NULL) if (node == NULL)
return FALSE; return FALSE;
foreach (subp, node->initPlan) foreach(subp, node->initPlan)
{ {
result = ExecInitSubPlan ((SubPlan*) lfirst (subp), estate, node); result = ExecInitSubPlan((SubPlan *) lfirst(subp), estate, node);
if ( result == FALSE ) if (result == FALSE)
return (FALSE); return (FALSE);
} }
...@@ -203,12 +203,12 @@ ExecInitNode(Plan *node, EState *estate, Plan *parent) ...@@ -203,12 +203,12 @@ ExecInitNode(Plan *node, EState *estate, Plan *parent)
result = FALSE; result = FALSE;
} }
if ( result != FALSE ) if (result != FALSE)
{ {
foreach (subp, node->subPlan) foreach(subp, node->subPlan)
{ {
result = ExecInitSubPlan ((SubPlan*) lfirst (subp), estate, node); result = ExecInitSubPlan((SubPlan *) lfirst(subp), estate, node);
if ( result == FALSE ) if (result == FALSE)
return (FALSE); return (FALSE);
} }
} }
...@@ -236,8 +236,8 @@ ExecProcNode(Plan *node, Plan *parent) ...@@ -236,8 +236,8 @@ ExecProcNode(Plan *node, Plan *parent)
if (node == NULL) if (node == NULL)
return NULL; return NULL;
if ( node->chgParam != NULL ) /* something changed */ if (node->chgParam != NULL) /* something changed */
ExecReScan (node, NULL, parent); /* let ReScan handle this */ ExecReScan(node, NULL, parent); /* let ReScan handle this */
switch (nodeTag(node)) switch (nodeTag(node))
{ {
...@@ -419,17 +419,17 @@ ExecEndNode(Plan *node, Plan *parent) ...@@ -419,17 +419,17 @@ ExecEndNode(Plan *node, Plan *parent)
if (node == NULL) if (node == NULL)
return; return;
foreach (subp, node->initPlan) foreach(subp, node->initPlan)
{ {
ExecEndSubPlan ((SubPlan*) lfirst (subp)); ExecEndSubPlan((SubPlan *) lfirst(subp));
} }
foreach (subp, node->subPlan) foreach(subp, node->subPlan)
{ {
ExecEndSubPlan ((SubPlan*) lfirst (subp)); ExecEndSubPlan((SubPlan *) lfirst(subp));
} }
if ( node->chgParam != NULL ) if (node->chgParam != NULL)
{ {
freeList (node->chgParam); freeList(node->chgParam);
node->chgParam = NULL; node->chgParam = NULL;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.25 1998/02/13 03:26:42 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.26 1998/02/26 04:31:13 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -71,19 +71,24 @@ int execConstLen; ...@@ -71,19 +71,24 @@ 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 ExecEvalArrayRef(ArrayRef *arrayRef, ExprContext *econtext, static Datum
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 ExecEvalFunc(Expr *funcClause, ExprContext *econtext, static Datum
ExecEvalFunc(Expr *funcClause, ExprContext *econtext,
bool *isNull, bool *isDone); bool *isNull, bool *isDone);
static void ExecEvalFuncArgs(FunctionCachePtr fcache, ExprContext *econtext, static void
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 ExecEvalOper(Expr *opClause, ExprContext *econtext, static Datum
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 ExecMakeFunctionResult(Node *node, List *arguments, static Datum
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);
...@@ -302,8 +307,9 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull) ...@@ -302,8 +307,9 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
} }
result = heap_getattr(heapTuple, /* tuple containing attribute */ result = heap_getattr(heapTuple, /* tuple containing attribute */
attnum, /* attribute number of desired attribute */ attnum, /* attribute number of desired
tuple_type,/* tuple descriptor of tuple */ * attribute */
tuple_type, /* tuple descriptor of tuple */
isNull); /* return: is attribute null? */ isNull); /* return: is attribute null? */
/* ---------------- /* ----------------
...@@ -380,13 +386,13 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull) ...@@ -380,13 +386,13 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull)
int matchFound; int matchFound;
ParamListInfo paramList; ParamListInfo paramList;
if ( thisParameterKind == PARAM_EXEC ) if (thisParameterKind == PARAM_EXEC)
{ {
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[thisParameterId]); ParamExecData *prm = &(econtext->ecxt_param_exec_vals[thisParameterId]);
if ( prm->execPlan != NULL ) if (prm->execPlan != NULL)
ExecSetParamPlan (prm->execPlan); ExecSetParamPlan(prm->execPlan);
Assert (prm->execPlan == NULL); Assert(prm->execPlan == NULL);
*isNull = prm->isnull; *isNull = prm->isnull;
return (prm->value); return (prm->value);
} }
...@@ -1045,17 +1051,19 @@ ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull) ...@@ -1045,17 +1051,19 @@ ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull)
if (*isNull) if (*isNull)
{ {
IsNull = *isNull; IsNull = *isNull;
/* /*
* Many functions don't (or can't!) check is an argument * Many functions don't (or can't!) check is an argument NULL
* NULL or NOT_NULL and may return TRUE (1) with *isNull TRUE * or NOT_NULL and may return TRUE (1) with *isNull TRUE
* (an_int4_column <> 1: int4ne returns TRUE for NULLs). * (an_int4_column <> 1: int4ne returns TRUE for NULLs). Not
* Not having time to fix function manager I want to fix * having time to fix function manager I want to fix OR: if we
* OR: if we had 'x <> 1 OR x isnull' then TRUE, TRUE were * had 'x <> 1 OR x isnull' then TRUE, TRUE were returned by
* returned by 'x <> 1' for NULL ... but ExecQualClause say * 'x <> 1' for NULL ... but ExecQualClause say that
* that qualification *fails* if isnull is TRUE for all values * qualification *fails* if isnull is TRUE for all values
* returned by ExecEvalExpr. So, force this rule here: if isnull * returned by ExecEvalExpr. So, force this rule here: if
* is TRUE then clause failed. Note: nullvalue() & nonnullvalue() * isnull is TRUE then clause failed. Note: nullvalue() &
* always set isnull to FALSE for NULLs. - vadim 09/22/97 * nonnullvalue() always set isnull to FALSE for NULLs. -
* vadim 09/22/97
*/ */
const_value = 0; const_value = 0;
} }
...@@ -1238,7 +1246,7 @@ ExecEvalExpr(Node *expression, ...@@ -1238,7 +1246,7 @@ ExecEvalExpr(Node *expression,
retDatum = (Datum) ExecEvalNot(expr, econtext, isNull); retDatum = (Datum) ExecEvalNot(expr, econtext, isNull);
break; break;
case SUBPLAN_EXPR: case SUBPLAN_EXPR:
retDatum = (Datum) ExecSubPlan((SubPlan*) expr->oper, expr->args, econtext); retDatum = (Datum) ExecSubPlan((SubPlan *) expr->oper, expr->args, econtext);
break; break;
default: default:
elog(ERROR, "ExecEvalExpr: unknown expression type %d", expr->opType); elog(ERROR, "ExecEvalExpr: unknown expression type %d", expr->opType);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.16 1998/02/10 04:00:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.17 1998/02/26 04:31:14 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.29 1998/02/13 03:26:43 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.30 1998/02/26 04:31:15 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1177,23 +1177,23 @@ ExecInsertIndexTuples(TupleTableSlot *slot, ...@@ -1177,23 +1177,23 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
} }
void void
SetChangedParamList (Plan *node, List *newchg) SetChangedParamList(Plan *node, List *newchg)
{ {
List *nl; List *nl;
foreach (nl, newchg) foreach(nl, newchg)
{ {
int paramId = lfirsti(nl); int paramId = lfirsti(nl);
/* if this node doesn't depend on a param ... */ /* if this node doesn't depend on a param ... */
if ( !intMember (paramId, node->extParam) && if (!intMember(paramId, node->extParam) &&
!intMember (paramId, node->locParam) ) !intMember(paramId, node->locParam))
continue; continue;
/* if this param is already in list of changed ones ... */ /* if this param is already in list of changed ones ... */
if ( intMember (paramId, node->chgParam) ) if (intMember(paramId, node->chgParam))
continue; continue;
/* else - add this param to the list */ /* else - add this param to the list */
node->chgParam = lappendi (node->chgParam, paramId); node->chgParam = lappendi(node->chgParam, paramId);
} }
} }
...@@ -121,7 +121,7 @@ ExecAgg(Agg *node) ...@@ -121,7 +121,7 @@ ExecAgg(Agg *node)
econtext = aggstate->csstate.cstate.cs_ExprContext; econtext = aggstate->csstate.cstate.cs_ExprContext;
nagg = length(node->aggs); nagg = length(node->aggs);
aggregates = (Aggreg **)palloc(sizeof(Aggreg *) * nagg); aggregates = (Aggreg **) palloc(sizeof(Aggreg *) * nagg);
/* take List* and make it an array that can be quickly indexed */ /* take List* and make it an array that can be quickly indexed */
alist = node->aggs; alist = node->aggs;
...@@ -545,14 +545,14 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) ...@@ -545,14 +545,14 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
ExecInitNode(outerPlan, estate, (Plan *) node); ExecInitNode(outerPlan, estate, (Plan *) node);
/* /*
* Result runs in its own context, but make it use our aggregates * Result runs in its own context, but make it use our aggregates fix
* fix for 'select sum(2+2)' * for 'select sum(2+2)'
*/ */
if (nodeTag(outerPlan) == T_Result) if (nodeTag(outerPlan) == T_Result)
{ {
((Result *)outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_values = ((Result *) outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_values =
econtext->ecxt_values; econtext->ecxt_values;
((Result *)outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_nulls = ((Result *) outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_nulls =
econtext->ecxt_nulls; econtext->ecxt_nulls;
} }
...@@ -686,11 +686,12 @@ ExecReScanAgg(Agg *node, ExprContext *exprCtxt, Plan *parent) ...@@ -686,11 +686,12 @@ ExecReScanAgg(Agg *node, ExprContext *exprCtxt, Plan *parent)
aggstate->agg_done = FALSE; aggstate->agg_done = FALSE;
MemSet(econtext->ecxt_values, 0, sizeof(Datum) * length(node->aggs)); MemSet(econtext->ecxt_values, 0, sizeof(Datum) * length(node->aggs));
MemSet(econtext->ecxt_nulls, 0, length(node->aggs)); MemSet(econtext->ecxt_nulls, 0, length(node->aggs));
/* /*
* if chgParam of subnode is not null then plan * if chgParam of subnode is not null then plan will be re-scanned by
* will be re-scanned by first ExecProcNode. * first ExecProcNode.
*/ */
if (((Plan*) node)->lefttree->chgParam == NULL) if (((Plan *) node)->lefttree->chgParam == NULL)
ExecReScan (((Plan*) node)->lefttree, exprCtxt, (Plan *) node); ExecReScan(((Plan *) node)->lefttree, exprCtxt, (Plan *) node);
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.10 1997/12/27 06:40:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.11 1998/02/26 04:31:21 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -13,7 +13,7 @@ ...@@ -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.17 1998/02/18 12:40:43 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.18 1998/02/26 04:31:24 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -115,21 +115,22 @@ ExecGroupEveryTuple(Group *node) ...@@ -115,21 +115,22 @@ ExecGroupEveryTuple(Group *node)
/* this should occur on the first call only */ /* this should occur on the first call only */
if (firsttuple == NULL) if (firsttuple == NULL)
{ {
grpstate->grp_firstTuple = heap_copytuple (outerTuple); grpstate->grp_firstTuple = heap_copytuple(outerTuple);
} }
else else
{ {
/* /*
* Compare with first tuple and see if this tuple is of * Compare with first tuple and see if this tuple is of the
* the same group. * same group.
*/ */
if (!sameGroup(firsttuple, outerslot->val, if (!sameGroup(firsttuple, outerslot->val,
node->numCols, node->grpColIdx, node->numCols, node->grpColIdx,
ExecGetScanType(&grpstate->csstate))) ExecGetScanType(&grpstate->csstate)))
{ {
grpstate->grp_useFirstTuple = TRUE; grpstate->grp_useFirstTuple = TRUE;
pfree (firsttuple); pfree(firsttuple);
grpstate->grp_firstTuple = heap_copytuple (outerTuple); grpstate->grp_firstTuple = heap_copytuple(outerTuple);
return NULL; /* signifies the end of the group */ return NULL; /* signifies the end of the group */
} }
...@@ -198,7 +199,7 @@ ExecGroupOneTuple(Group *node) ...@@ -198,7 +199,7 @@ ExecGroupOneTuple(Group *node)
grpstate->grp_done = TRUE; grpstate->grp_done = TRUE;
return NULL; return NULL;
} }
grpstate->grp_firstTuple = firsttuple = heap_copytuple (outerTuple); grpstate->grp_firstTuple = firsttuple = heap_copytuple(outerTuple);
} }
/* /*
...@@ -242,8 +243,8 @@ ExecGroupOneTuple(Group *node) ...@@ -242,8 +243,8 @@ ExecGroupOneTuple(Group *node)
/* save outerTuple if we are not done yet */ /* save outerTuple if we are not done yet */
if (!grpstate->grp_done) if (!grpstate->grp_done)
{ {
pfree (firsttuple); pfree(firsttuple);
grpstate->grp_firstTuple = heap_copytuple (outerTuple); grpstate->grp_firstTuple = heap_copytuple(outerTuple);
} }
return resultSlot; return resultSlot;
...@@ -340,7 +341,7 @@ ExecEndGroup(Group *node) ...@@ -340,7 +341,7 @@ ExecEndGroup(Group *node)
ExecClearTuple(grpstate->csstate.css_ScanTupleSlot); ExecClearTuple(grpstate->csstate.css_ScanTupleSlot);
if (grpstate->grp_firstTuple != NULL) if (grpstate->grp_firstTuple != NULL)
{ {
pfree (grpstate->grp_firstTuple); pfree(grpstate->grp_firstTuple);
grpstate->grp_firstTuple = NULL; grpstate->grp_firstTuple = NULL;
} }
} }
...@@ -402,12 +403,12 @@ sameGroup(HeapTuple oldtuple, ...@@ -402,12 +403,12 @@ sameGroup(HeapTuple oldtuple,
*/ */
if (strcmp(val1, val2) != 0) if (strcmp(val1, val2) != 0)
{ {
pfree (val1); pfree(val1);
pfree (val2); pfree(val2);
return FALSE; return FALSE;
} }
pfree (val1); pfree(val1);
pfree (val2); pfree(val2);
} }
else else
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.19 1998/02/13 03:26:46 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.20 1998/02/26 04:31:25 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -903,10 +903,10 @@ ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent) ...@@ -903,10 +903,10 @@ ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent)
} }
/* /*
* if chgParam of subnode is not null then plan * if chgParam of subnode is not null then plan will be re-scanned by
* will be re-scanned by first ExecProcNode. * first ExecProcNode.
*/ */
if (((Plan*) node)->lefttree->chgParam == NULL) if (((Plan *) node)->lefttree->chgParam == NULL)
ExecReScan (((Plan*) node)->lefttree, exprCtxt, (Plan *) node); ExecReScan(((Plan *) node)->lefttree, exprCtxt, (Plan *) node);
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.10 1998/02/13 03:26:47 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.11 1998/02/26 04:31:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -212,12 +212,14 @@ ExecHashJoin(HashJoin *node) ...@@ -212,12 +212,14 @@ ExecHashJoin(HashJoin *node)
while (curbatch <= nbatch && TupIsNull(outerTupleSlot)) while (curbatch <= nbatch && TupIsNull(outerTupleSlot))
{ {
/* /*
* if the current batch runs out, switch to new batch * if the current batch runs out, switch to new batch
*/ */
curbatch = ExecHashJoinNewBatch(hjstate); curbatch = ExecHashJoinNewBatch(hjstate);
if (curbatch > nbatch) if (curbatch > nbatch)
{ {
/* /*
* when the last batch runs out, clean up * when the last batch runs out, clean up
*/ */
...@@ -350,6 +352,7 @@ ExecHashJoin(HashJoin *node) ...@@ -350,6 +352,7 @@ ExecHashJoin(HashJoin *node)
curbatch = ExecHashJoinNewBatch(hjstate); curbatch = ExecHashJoinNewBatch(hjstate);
if (curbatch > nbatch) if (curbatch > nbatch)
{ {
/* /*
* when the last batch runs out, clean up * when the last batch runs out, clean up
*/ */
...@@ -853,8 +856,8 @@ ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent) ...@@ -853,8 +856,8 @@ ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent)
node->hashdone = false; node->hashdone = false;
/* /*
* Unfortunately, currently we have to destroy hashtable * Unfortunately, currently we have to destroy hashtable in all
* in all cases... * cases...
*/ */
if (hjstate->hj_HashTable) if (hjstate->hj_HashTable)
{ {
...@@ -874,12 +877,12 @@ ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent) ...@@ -874,12 +877,12 @@ ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent)
hjstate->jstate.cs_TupFromTlist = (bool) false; hjstate->jstate.cs_TupFromTlist = (bool) false;
/* /*
* if chgParam of subnodes is not null then plans * if chgParam of subnodes is not null then plans will be re-scanned
* will be re-scanned by first ExecProcNode. * by first ExecProcNode.
*/ */
if (((Plan*) node)->lefttree->chgParam == NULL) if (((Plan *) node)->lefttree->chgParam == NULL)
ExecReScan (((Plan*) node)->lefttree, exprCtxt, (Plan *) node); ExecReScan(((Plan *) node)->lefttree, exprCtxt, (Plan *) node);
if (((Plan*) node)->righttree->chgParam == NULL) if (((Plan *) node)->righttree->chgParam == NULL)
ExecReScan (((Plan*) node)->righttree, exprCtxt, (Plan *) node); ExecReScan(((Plan *) node)->righttree, exprCtxt, (Plan *) node);
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.14 1998/02/13 03:26:49 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.15 1998/02/26 04:31:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -713,11 +713,11 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) ...@@ -713,11 +713,11 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
*/ */
/* Life was so easy before ... subselects */ /* Life was so easy before ... subselects */
if ( ((Param *) leftop)->paramkind == PARAM_EXEC ) if (((Param *) leftop)->paramkind == PARAM_EXEC)
{ {
have_runtime_keys = true; have_runtime_keys = true;
run_keys[j] = LEFT_OP; run_keys[j] = LEFT_OP;
execParam = lappendi (execParam, ((Param*) leftop)->paramid); execParam = lappendi(execParam, ((Param *) leftop)->paramid);
} }
else else
{ {
...@@ -806,11 +806,11 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) ...@@ -806,11 +806,11 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
*/ */
/* Life was so easy before ... subselects */ /* Life was so easy before ... subselects */
if ( ((Param *) rightop)->paramkind == PARAM_EXEC ) if (((Param *) rightop)->paramkind == PARAM_EXEC)
{ {
have_runtime_keys = true; have_runtime_keys = true;
run_keys[j] = RIGHT_OP; run_keys[j] = RIGHT_OP;
execParam = lappendi (execParam, ((Param*) rightop)->paramid); execParam = lappendi(execParam, ((Param *) rightop)->paramid);
} }
else else
{ {
...@@ -991,10 +991,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) ...@@ -991,10 +991,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
indexstate->cstate.cs_TupFromTlist = false; indexstate->cstate.cs_TupFromTlist = false;
/* /*
* if there are some PARAM_EXEC in skankeys then * if there are some PARAM_EXEC in skankeys then force index rescan on
* force index rescan on first scan. * first scan.
*/ */
((Plan*) node)->chgParam = execParam; ((Plan *) node)->chgParam = execParam;
/* ---------------- /* ----------------
* all done. * all done.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.12 1998/02/13 03:26:50 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.13 1998/02/26 04:31:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -356,7 +356,7 @@ ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent) ...@@ -356,7 +356,7 @@ ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent)
return; return;
matstate->csstate.css_currentScanDesc = matstate->csstate.css_currentScanDesc =
ExecReScanR (matstate->csstate.css_currentRelation, ExecReScanR(matstate->csstate.css_currentRelation,
matstate->csstate.css_currentScanDesc, matstate->csstate.css_currentScanDesc,
node->plan.state->es_direction, 0, NULL); node->plan.state->es_direction, 0, NULL);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.12 1997/09/08 21:43:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.13 1998/02/26 04:31:30 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -749,7 +749,8 @@ ExecMergeJoin(MergeJoin *node) ...@@ -749,7 +749,8 @@ ExecMergeJoin(MergeJoin *node)
* *
* new outer tuple > marked tuple * new outer tuple > marked tuple
* *
***************************** ****************************
*
* *
* *
* *
...@@ -831,7 +832,8 @@ ExecMergeJoin(MergeJoin *node) ...@@ -831,7 +832,8 @@ ExecMergeJoin(MergeJoin *node)
* we have to advance the outer scan until we find the outer * we have to advance the outer scan until we find the outer
* 8. * 8.
* *
***************************** ****************************
*
* *
* *
* *
...@@ -935,7 +937,8 @@ ExecMergeJoin(MergeJoin *node) ...@@ -935,7 +937,8 @@ ExecMergeJoin(MergeJoin *node)
* we have to advance the inner scan until we find the inner * we have to advance the inner scan until we find the inner
* 12. * 12.
* *
***************************** ****************************
*
* *
* *
* *
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.8 1998/02/13 03:26:51 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.9 1998/02/26 04:31:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -381,17 +381,17 @@ void ...@@ -381,17 +381,17 @@ void
ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt, Plan *parent) ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt, Plan *parent)
{ {
NestLoopState *nlstate = node->nlstate; NestLoopState *nlstate = node->nlstate;
Plan *outerPlan = outerPlan((Plan*) node); Plan *outerPlan = outerPlan((Plan *) node);
/* /*
* If outerPlan->chgParam is not null then plan will be * If outerPlan->chgParam is not null then plan will be automatically
* automatically re-scanned by first ExecProcNode. * re-scanned by first ExecProcNode. innerPlan is re-scanned for each
* innerPlan is re-scanned for each new outer tuple and MUST NOT * new outer tuple and MUST NOT be re-scanned from here or you'll get
* be re-scanned from here or you'll get troubles from inner * troubles from inner index scans when outer Vars are used as
* index scans when outer Vars are used as run-time keys... * run-time keys...
*/ */
if (outerPlan->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan (outerPlan, exprCtxt, (Plan *) node); ExecReScan(outerPlan, exprCtxt, (Plan *) node);
/* let outerPlan to free its result typle ... */ /* let outerPlan to free its result typle ... */
nlstate->jstate.cs_OuterTupleSlot = NULL; nlstate->jstate.cs_OuterTupleSlot = NULL;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* SeqScan (emp.all) * SeqScan (emp.all)
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.7 1998/02/18 07:19:34 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.8 1998/02/26 04:31:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -288,11 +288,11 @@ ExecReScanResult(Result *node, ExprContext *exprCtxt, Plan *parent) ...@@ -288,11 +288,11 @@ ExecReScanResult(Result *node, ExprContext *exprCtxt, Plan *parent)
resstate->rs_checkqual = (node->resconstantqual == NULL) ? false : true; resstate->rs_checkqual = (node->resconstantqual == NULL) ? false : true;
/* /*
* if chgParam of subnode is not null then plan * if chgParam of subnode is not null then plan will be re-scanned by
* will be re-scanned by first ExecProcNode. * first ExecProcNode.
*/ */
if (((Plan*) node)->lefttree && if (((Plan *) node)->lefttree &&
((Plan*) node)->lefttree->chgParam == NULL) ((Plan *) node)->lefttree->chgParam == NULL)
ExecReScan (((Plan*) node)->lefttree, exprCtxt, (Plan *) node); ExecReScan(((Plan *) node)->lefttree, exprCtxt, (Plan *) node);
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.13 1998/02/23 06:26:56 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.14 1998/02/26 04:31:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -395,21 +395,21 @@ ExecReScanSort(Sort *node, ExprContext *exprCtxt, Plan *parent) ...@@ -395,21 +395,21 @@ ExecReScanSort(Sort *node, ExprContext *exprCtxt, Plan *parent)
SortState *sortstate = node->sortstate; SortState *sortstate = node->sortstate;
/* /*
* If we haven't sorted yet, just return. If outerplan' * If we haven't sorted yet, just return. If outerplan' chgParam is
* chgParam is not NULL then it will be re-scanned by * not NULL then it will be re-scanned by ExecProcNode, else - no
* ExecProcNode, else - no reason to re-scan it at all. * reason to re-scan it at all.
*/ */
if (sortstate->sort_Flag == false) if (sortstate->sort_Flag == false)
return; return;
ExecClearTuple(sortstate->csstate.cstate.cs_ResultTupleSlot); ExecClearTuple(sortstate->csstate.cstate.cs_ResultTupleSlot);
psort_rescan (node); psort_rescan(node);
/* /*
* If subnode is to be rescanned then we aren't sorted * If subnode is to be rescanned then we aren't sorted
*/ */
if (((Plan*) node)->lefttree->chgParam != NULL) if (((Plan *) node)->lefttree->chgParam != NULL)
sortstate->sort_Flag = false; sortstate->sort_Flag = false;
} }
...@@ -34,68 +34,68 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext) ...@@ -34,68 +34,68 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext)
bool result = false; bool result = false;
bool found = false; bool found = false;
if ( node->setParam != NULL ) if (node->setParam != NULL)
elog (ERROR, "ExecSubPlan: can't set parent params from subquery"); elog(ERROR, "ExecSubPlan: can't set parent params from subquery");
/* /*
* Set Params of this plan from parent plan correlation Vars * Set Params of this plan from parent plan correlation Vars
*/ */
if ( node->parParam != NULL ) if (node->parParam != NULL)
{ {
foreach (lst, node->parParam) foreach(lst, node->parParam)
{ {
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[lfirsti(lst)]); ParamExecData *prm = &(econtext->ecxt_param_exec_vals[lfirsti(lst)]);
prm->value = ExecEvalExpr ((Node*) lfirst(pvar), prm->value = ExecEvalExpr((Node *) lfirst(pvar),
econtext, econtext,
&(prm->isnull), NULL); &(prm->isnull), NULL);
pvar = lnext (pvar); pvar = lnext(pvar);
} }
plan->chgParam = nconc (plan->chgParam, listCopy(node->parParam)); plan->chgParam = nconc(plan->chgParam, listCopy(node->parParam));
} }
ExecReScan (plan, (ExprContext*) NULL, plan); ExecReScan(plan, (ExprContext *) NULL, plan);
for (slot = ExecProcNode (plan, plan); for (slot = ExecProcNode(plan, plan);
!TupIsNull(slot); !TupIsNull(slot);
slot = ExecProcNode (plan, plan)) slot = ExecProcNode(plan, plan))
{ {
HeapTuple tup = slot->val; HeapTuple tup = slot->val;
TupleDesc tdesc = slot->ttc_tupleDescriptor; TupleDesc tdesc = slot->ttc_tupleDescriptor;
int i = 1; int i = 1;
if ( sublink->subLinkType == EXPR_SUBLINK && found ) if (sublink->subLinkType == EXPR_SUBLINK && found)
{ {
elog (ERROR, "ExecSubPlan: more than one tuple returned by expression subselect"); elog(ERROR, "ExecSubPlan: more than one tuple returned by expression subselect");
return ((Datum) false); return ((Datum) false);
} }
if ( sublink->subLinkType == EXISTS_SUBLINK ) if (sublink->subLinkType == EXISTS_SUBLINK)
return ((Datum) true); return ((Datum) true);
found = true; found = true;
foreach (lst, sublink->oper) foreach(lst, sublink->oper)
{ {
Expr *expr = (Expr*) lfirst(lst); Expr *expr = (Expr *) lfirst(lst);
Const *con = lsecond(expr->args); Const *con = lsecond(expr->args);
bool isnull; bool isnull;
con->constvalue = heap_getattr (tup, i, tdesc, &(con->constisnull)); con->constvalue = heap_getattr(tup, i, tdesc, &(con->constisnull));
result = (bool) ExecEvalExpr ((Node*) expr, econtext, &isnull, (bool*) NULL); result = (bool) ExecEvalExpr((Node *) expr, econtext, &isnull, (bool *) NULL);
if ( isnull ) if (isnull)
result = false; result = false;
if ( (!result && !(sublink->useor)) || (result && sublink->useor) ) if ((!result && !(sublink->useor)) || (result && sublink->useor))
break; break;
i++; i++;
} }
if ( (!result && sublink->subLinkType == ALL_SUBLINK) || if ((!result && sublink->subLinkType == ALL_SUBLINK) ||
(result && sublink->subLinkType == ANY_SUBLINK) ) (result && sublink->subLinkType == ANY_SUBLINK))
break; break;
} }
if ( !found && sublink->subLinkType == ALL_SUBLINK ) if (!found && sublink->subLinkType == ALL_SUBLINK)
return ((Datum) true); return ((Datum) true);
return ((Datum) result); return ((Datum) result);
...@@ -109,39 +109,40 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext) ...@@ -109,39 +109,40 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext)
bool bool
ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent) ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent)
{ {
EState *sp_estate = CreateExecutorState (); EState *sp_estate = CreateExecutorState();
sp_estate->es_range_table = node->rtable; sp_estate->es_range_table = node->rtable;
sp_estate->es_param_list_info = estate->es_param_list_info; sp_estate->es_param_list_info = estate->es_param_list_info;
sp_estate->es_param_exec_vals = estate->es_param_exec_vals; sp_estate->es_param_exec_vals = estate->es_param_exec_vals;
sp_estate->es_tupleTable = sp_estate->es_tupleTable =
ExecCreateTupleTable (ExecCountSlotsNode(node->plan) + 10); ExecCreateTupleTable(ExecCountSlotsNode(node->plan) + 10);
pfree (sp_estate->es_refcount); pfree(sp_estate->es_refcount);
sp_estate->es_refcount = estate->es_refcount; sp_estate->es_refcount = estate->es_refcount;
if ( !ExecInitNode (node->plan, sp_estate, NULL) ) if (!ExecInitNode(node->plan, sp_estate, NULL))
return (false); return (false);
node->shutdown = true; node->shutdown = true;
/* /*
* If this plan is un-correlated or undirect correlated one and * If this plan is un-correlated or undirect correlated one and want
* want to set params for parent plan then prepare parameters. * to set params for parent plan then prepare parameters.
*/ */
if ( node->setParam != NULL ) if (node->setParam != NULL)
{ {
List *lst; List *lst;
foreach (lst, node->setParam) foreach(lst, node->setParam)
{ {
ParamExecData *prm = &(estate->es_param_exec_vals[lfirsti(lst)]); ParamExecData *prm = &(estate->es_param_exec_vals[lfirsti(lst)]);
prm->execPlan = node; prm->execPlan = node;
} }
/* /*
* Note that in the case of un-correlated subqueries we don't care * Note that in the case of un-correlated subqueries we don't care
* about setting parent->chgParam here: indices take care about it, * about setting parent->chgParam here: indices take care about
* for others - it doesn't matter... * it, for others - it doesn't matter...
*/ */
} }
...@@ -155,7 +156,7 @@ ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent) ...@@ -155,7 +156,7 @@ ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent)
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
void void
ExecSetParamPlan (SubPlan *node) ExecSetParamPlan(SubPlan *node)
{ {
Plan *plan = node->plan; Plan *plan = node->plan;
SubLink *sublink = node->sublink; SubLink *sublink = node->sublink;
...@@ -163,30 +164,30 @@ ExecSetParamPlan (SubPlan *node) ...@@ -163,30 +164,30 @@ ExecSetParamPlan (SubPlan *node)
List *lst; List *lst;
bool found = false; bool found = false;
if ( sublink->subLinkType == ANY_SUBLINK || if (sublink->subLinkType == ANY_SUBLINK ||
sublink->subLinkType == ALL_SUBLINK ) sublink->subLinkType == ALL_SUBLINK)
elog (ERROR, "ExecSetParamPlan: ANY/ALL subselect unsupported"); elog(ERROR, "ExecSetParamPlan: ANY/ALL subselect unsupported");
if ( plan->chgParam != NULL ) if (plan->chgParam != NULL)
ExecReScan (plan, (ExprContext*) NULL, plan); ExecReScan(plan, (ExprContext *) NULL, plan);
for (slot = ExecProcNode (plan, plan); for (slot = ExecProcNode(plan, plan);
!TupIsNull(slot); !TupIsNull(slot);
slot = ExecProcNode (plan, plan)) slot = ExecProcNode(plan, plan))
{ {
HeapTuple tup = slot->val; HeapTuple tup = slot->val;
TupleDesc tdesc = slot->ttc_tupleDescriptor; TupleDesc tdesc = slot->ttc_tupleDescriptor;
int i = 1; int i = 1;
if ( sublink->subLinkType == EXPR_SUBLINK && found ) if (sublink->subLinkType == EXPR_SUBLINK && found)
{ {
elog (ERROR, "ExecSetParamPlan: more than one tuple returned by expression subselect"); elog(ERROR, "ExecSetParamPlan: more than one tuple returned by expression subselect");
return; return;
} }
found = true; found = true;
if ( sublink->subLinkType == EXISTS_SUBLINK ) if (sublink->subLinkType == EXISTS_SUBLINK)
{ {
ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(node->setParam)]); ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(node->setParam)]);
...@@ -203,21 +204,21 @@ ExecSetParamPlan (SubPlan *node) ...@@ -203,21 +204,21 @@ ExecSetParamPlan (SubPlan *node)
* this loop ? Who knows... Someday we'll keep track of saved * this loop ? Who knows... Someday we'll keep track of saved
* tuples... * tuples...
*/ */
tup = heap_copytuple (tup); tup = heap_copytuple(tup);
foreach (lst, node->setParam) foreach(lst, node->setParam)
{ {
ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(lst)]); ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(lst)]);
prm->execPlan = NULL; prm->execPlan = NULL;
prm->value = heap_getattr (tup, i, tdesc, &(prm->isnull)); prm->value = heap_getattr(tup, i, tdesc, &(prm->isnull));
i++; i++;
} }
} }
if ( !found ) if (!found)
{ {
if ( sublink->subLinkType == EXISTS_SUBLINK ) if (sublink->subLinkType == EXISTS_SUBLINK)
{ {
ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(node->setParam)]); ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(node->setParam)]);
...@@ -227,7 +228,7 @@ ExecSetParamPlan (SubPlan *node) ...@@ -227,7 +228,7 @@ ExecSetParamPlan (SubPlan *node)
} }
else else
{ {
foreach (lst, node->setParam) foreach(lst, node->setParam)
{ {
ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(lst)]); ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(lst)]);
...@@ -238,9 +239,9 @@ ExecSetParamPlan (SubPlan *node) ...@@ -238,9 +239,9 @@ ExecSetParamPlan (SubPlan *node)
} }
} }
if ( plan->extParam == NULL ) /* un-correlated ... */ if (plan->extParam == NULL) /* un-correlated ... */
{ {
ExecEndNode (plan, plan); ExecEndNode(plan, plan);
node->shutdown = false; node->shutdown = false;
} }
} }
...@@ -253,40 +254,39 @@ void ...@@ -253,40 +254,39 @@ void
ExecEndSubPlan(SubPlan *node) ExecEndSubPlan(SubPlan *node)
{ {
if ( node->shutdown ) if (node->shutdown)
{ {
ExecEndNode (node->plan, node->plan); ExecEndNode(node->plan, node->plan);
node->shutdown = false; node->shutdown = false;
} }
} }
void void
ExecReScanSetParamPlan (SubPlan *node, Plan *parent) ExecReScanSetParamPlan(SubPlan *node, Plan *parent)
{ {
Plan *plan = node->plan; Plan *plan = node->plan;
List *lst; List *lst;
if ( node->parParam != NULL ) if (node->parParam != NULL)
elog (ERROR, "ExecReScanSetParamPlan: direct correlated subquery unsupported, yet"); elog(ERROR, "ExecReScanSetParamPlan: direct correlated subquery unsupported, yet");
if ( node->setParam == NULL ) if (node->setParam == NULL)
elog (ERROR, "ExecReScanSetParamPlan: setParam list is NULL"); elog(ERROR, "ExecReScanSetParamPlan: setParam list is NULL");
if ( plan->extParam == NULL ) if (plan->extParam == NULL)
elog (ERROR, "ExecReScanSetParamPlan: extParam list of plan is NULL"); elog(ERROR, "ExecReScanSetParamPlan: extParam list of plan is NULL");
/* /*
* Don't actual re-scan: ExecSetParamPlan does re-scan if * Don't actual re-scan: ExecSetParamPlan does re-scan if
* node->plan->chgParam is not NULL... * node->plan->chgParam is not NULL... ExecReScan (plan, NULL, plan);
ExecReScan (plan, NULL, plan);
*/ */
foreach (lst, node->setParam) foreach(lst, node->setParam)
{ {
ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(lst)]); ParamExecData *prm = &(plan->state->es_param_exec_vals[lfirsti(lst)]);
prm->execPlan = node; prm->execPlan = node;
} }
parent->chgParam = nconc (parent->chgParam, listCopy(node->setParam)); parent->chgParam = nconc(parent->chgParam, listCopy(node->setParam));
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* ExecEndTee * ExecEndTee
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.15 1998/01/07 21:02:58 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.16 1998/02/26 04:31:33 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.16 1998/02/23 06:26:58 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.17 1998/02/26 04:31:34 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -209,12 +209,12 @@ ExecUnique(Unique *node) ...@@ -209,12 +209,12 @@ ExecUnique(Unique *node)
*/ */
if (strcmp(val1, val2) == 0) /* they are equal */ if (strcmp(val1, val2) == 0) /* they are equal */
{ {
pfree (val1); pfree(val1);
pfree (val2); pfree(val2);
continue; continue;
} }
pfree (val1); pfree(val1);
pfree (val2); pfree(val2);
break; break;
} }
else else
...@@ -363,11 +363,12 @@ ExecReScanUnique(Unique *node, ExprContext *exprCtxt, Plan *parent) ...@@ -363,11 +363,12 @@ ExecReScanUnique(Unique *node, ExprContext *exprCtxt, Plan *parent)
UniqueState *uniquestate = node->uniquestate; UniqueState *uniquestate = node->uniquestate;
ExecClearTuple(uniquestate->cs_ResultTupleSlot); ExecClearTuple(uniquestate->cs_ResultTupleSlot);
/* /*
* if chgParam of subnode is not null then plan * if chgParam of subnode is not null then plan will be re-scanned by
* will be re-scanned by first ExecProcNode. * first ExecProcNode.
*/ */
if (((Plan*) node)->lefttree->chgParam == NULL) if (((Plan *) node)->lefttree->chgParam == NULL)
ExecReScan (((Plan*) node)->lefttree, exprCtxt, (Plan *) node); ExecReScan(((Plan *) node)->lefttree, exprCtxt, (Plan *) node);
} }
...@@ -40,22 +40,22 @@ typedef struct ...@@ -40,22 +40,22 @@ typedef struct
Oid *argtypes; Oid *argtypes;
} _SPI_plan; } _SPI_plan;
static int _SPI_execute(char *src, int tcount, _SPI_plan * plan); static int _SPI_execute(char *src, int tcount, _SPI_plan *plan);
static int _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount); static int _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount);
#if 0 #if 0
static void _SPI_fetch(FetchStmt * stmt); static void _SPI_fetch(FetchStmt *stmt);
#endif #endif
static int static int
_SPI_execute_plan(_SPI_plan * plan, _SPI_execute_plan(_SPI_plan *plan,
Datum * Values, char *Nulls, int tcount); Datum *Values, char *Nulls, int tcount);
#define _SPI_CPLAN_CURCXT 0 #define _SPI_CPLAN_CURCXT 0
#define _SPI_CPLAN_PROCXT 1 #define _SPI_CPLAN_PROCXT 1
#define _SPI_CPLAN_TOPCXT 2 #define _SPI_CPLAN_TOPCXT 2
static _SPI_plan *_SPI_copy_plan(_SPI_plan * plan, int location); static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location);
static int _SPI_begin_call(bool execmem); static int _SPI_begin_call(bool execmem);
static int _SPI_end_call(bool procmem); static int _SPI_end_call(bool procmem);
...@@ -202,7 +202,7 @@ SPI_exec(char *src, int tcount) ...@@ -202,7 +202,7 @@ SPI_exec(char *src, int tcount)
} }
int int
SPI_execp(void *plan, Datum * Values, char *Nulls, int tcount) SPI_execp(void *plan, Datum *Values, char *Nulls, int tcount)
{ {
int res; int res;
...@@ -226,7 +226,7 @@ SPI_execp(void *plan, Datum * Values, char *Nulls, int tcount) ...@@ -226,7 +226,7 @@ SPI_execp(void *plan, Datum * Values, char *Nulls, int tcount)
} }
void * void *
SPI_prepare(char *src, int nargs, Oid * argtypes) SPI_prepare(char *src, int nargs, Oid *argtypes)
{ {
_SPI_plan *plan; _SPI_plan *plan;
...@@ -310,7 +310,7 @@ SPI_copytuple(HeapTuple tuple) ...@@ -310,7 +310,7 @@ SPI_copytuple(HeapTuple tuple)
HeapTuple HeapTuple
SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
Datum * Values, char *Nulls) Datum *Values, char *Nulls)
{ {
MemoryContext oldcxt = NULL; MemoryContext oldcxt = NULL;
HeapTuple mtuple; HeapTuple mtuple;
...@@ -436,7 +436,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -436,7 +436,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
} }
Datum Datum
SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull) SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
{ {
Datum val; Datum val;
...@@ -499,7 +499,7 @@ SPI_getrelname(Relation rel) ...@@ -499,7 +499,7 @@ SPI_getrelname(Relation rel)
} }
void * void *
SPI_palloc (Size size) SPI_palloc(Size size)
{ {
MemoryContext oldcxt = NULL; MemoryContext oldcxt = NULL;
void *pointer; void *pointer;
...@@ -511,7 +511,7 @@ SPI_palloc (Size size) ...@@ -511,7 +511,7 @@ SPI_palloc (Size size)
oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt);
} }
pointer = palloc (size); pointer = palloc(size);
if (oldcxt) if (oldcxt)
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
...@@ -520,7 +520,7 @@ SPI_palloc (Size size) ...@@ -520,7 +520,7 @@ SPI_palloc (Size size)
} }
void * void *
SPI_repalloc (void *pointer, Size size) SPI_repalloc(void *pointer, Size size)
{ {
MemoryContext oldcxt = NULL; MemoryContext oldcxt = NULL;
...@@ -531,7 +531,7 @@ SPI_repalloc (void *pointer, Size size) ...@@ -531,7 +531,7 @@ SPI_repalloc (void *pointer, Size size)
oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt);
} }
pointer = repalloc (pointer, size); pointer = repalloc(pointer, size);
if (oldcxt) if (oldcxt)
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
...@@ -540,7 +540,7 @@ SPI_repalloc (void *pointer, Size size) ...@@ -540,7 +540,7 @@ SPI_repalloc (void *pointer, Size size)
} }
void void
SPI_pfree (void *pointer) SPI_pfree(void *pointer)
{ {
MemoryContext oldcxt = NULL; MemoryContext oldcxt = NULL;
...@@ -551,7 +551,7 @@ SPI_pfree (void *pointer) ...@@ -551,7 +551,7 @@ SPI_pfree (void *pointer)
oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt);
} }
pfree (pointer); pfree(pointer);
if (oldcxt) if (oldcxt)
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
...@@ -613,7 +613,7 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc) ...@@ -613,7 +613,7 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc)
*/ */
static int static int
_SPI_execute(char *src, int tcount, _SPI_plan * plan) _SPI_execute(char *src, int tcount, _SPI_plan *plan)
{ {
QueryTreeList *queryTree_list; QueryTreeList *queryTree_list;
List *planTree_list; List *planTree_list;
...@@ -710,7 +710,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan * plan) ...@@ -710,7 +710,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan * plan)
} }
static int static int
_SPI_execute_plan(_SPI_plan * plan, Datum * Values, char *Nulls, int tcount) _SPI_execute_plan(_SPI_plan *plan, Datum *Values, char *Nulls, int tcount)
{ {
QueryTreeList *queryTree_list = plan->qtlist; QueryTreeList *queryTree_list = plan->qtlist;
List *planTree_list = plan->ptlist; List *planTree_list = plan->ptlist;
...@@ -781,7 +781,7 @@ _SPI_execute_plan(_SPI_plan * plan, Datum * Values, char *Nulls, int tcount) ...@@ -781,7 +781,7 @@ _SPI_execute_plan(_SPI_plan * plan, Datum * Values, char *Nulls, int tcount)
} }
static int static int
_SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount)
{ {
Query *parseTree = queryDesc->parsetree; Query *parseTree = queryDesc->parsetree;
Plan *plan = queryDesc->plantree; Plan *plan = queryDesc->plantree;
...@@ -878,7 +878,7 @@ _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) ...@@ -878,7 +878,7 @@ _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount)
#if 0 #if 0
static void static void
_SPI_fetch(FetchStmt * stmt) _SPI_fetch(FetchStmt *stmt)
{ {
char *name = stmt->portalname; char *name = stmt->portalname;
int feature = (stmt->direction == FORWARD) ? EXEC_FOR : EXEC_BACK; int feature = (stmt->direction == FORWARD) ? EXEC_FOR : EXEC_BACK;
...@@ -1001,7 +1001,8 @@ _SPI_checktuples() ...@@ -1001,7 +1001,8 @@ _SPI_checktuples()
if (tuptable != NULL) if (tuptable != NULL)
failed = true; failed = true;
} }
else /* some tuples were processed */ else
/* some tuples were processed */
{ {
if (tuptable == NULL) /* spi_printtup was not called */ if (tuptable == NULL) /* spi_printtup was not called */
failed = true; failed = true;
...@@ -1013,7 +1014,7 @@ _SPI_checktuples() ...@@ -1013,7 +1014,7 @@ _SPI_checktuples()
} }
static _SPI_plan * static _SPI_plan *
_SPI_copy_plan(_SPI_plan * plan, int location) _SPI_copy_plan(_SPI_plan *plan, int location)
{ {
_SPI_plan *newplan; _SPI_plan *newplan;
MemoryContext oldcxt = NULL; MemoryContext oldcxt = NULL;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.8 1997/09/08 21:43:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.9 1998/02/26 04:31:37 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.7 1997/09/08 21:43:31 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.8 1998/02/26 04:31:39 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/qsort.c,v 1.5 1998/02/11 19:10:35 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/lib/Attic/qsort.c,v 1.6 1998/02/26 04:31:40 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.26 1998/02/25 13:06:49 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.27 1998/02/26 04:31:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <libpq/crypt.h> #include <libpq/crypt.h>
static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)()); static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler) ());
static void handle_done_auth(Port *port); static void handle_done_auth(Port *port);
static void handle_krb4_auth(Port *port); static void handle_krb4_auth(Port *port);
static void handle_krb5_auth(Port *port); static void handle_krb5_auth(Port *port);
...@@ -327,14 +327,18 @@ pg_krb5_recvauth(Port *port) ...@@ -327,14 +327,18 @@ pg_krb5_recvauth(Port *port)
* Handle a v0 password packet. * Handle a v0 password packet.
*/ */
static void pg_passwordv0_recvauth(char *arg, PacketLen len, char *pkt) static void
pg_passwordv0_recvauth(char *arg, PacketLen len, char *pkt)
{ {
Port *port; Port *port;
PasswordPacketV0 *pp; PasswordPacketV0 *pp;
char *user, *password, *cp, *start; char *user,
*password,
*cp,
*start;
port = (Port *)arg; port = (Port *) arg;
pp = (PasswordPacketV0 *)pkt; pp = (PasswordPacketV0 *) pkt;
/* /*
* The packet is supposed to comprise the user name and the password * The packet is supposed to comprise the user name and the password
...@@ -343,7 +347,7 @@ static void pg_passwordv0_recvauth(char *arg, PacketLen len, char *pkt) ...@@ -343,7 +347,7 @@ static void pg_passwordv0_recvauth(char *arg, PacketLen len, char *pkt)
user = password = NULL; user = password = NULL;
len -= sizeof (pp->unused); len -= sizeof(pp->unused);
cp = start = pp->data; cp = start = pp->data;
...@@ -396,7 +400,8 @@ static void pg_passwordv0_recvauth(char *arg, PacketLen len, char *pkt) ...@@ -396,7 +400,8 @@ static void pg_passwordv0_recvauth(char *arg, PacketLen len, char *pkt)
* Tell the user the authentication failed, but not why. * Tell the user the authentication failed, but not why.
*/ */
void auth_failed(Port *port) void
auth_failed(Port *port)
{ {
PacketSendError(&port->pktInfo, "User authentication failed"); PacketSendError(&port->pktInfo, "User authentication failed");
} }
...@@ -405,8 +410,10 @@ void auth_failed(Port *port) ...@@ -405,8 +410,10 @@ void auth_failed(Port *port)
/* /*
* be_recvauth -- server demux routine for incoming authentication information * be_recvauth -- server demux routine for incoming authentication information
*/ */
void be_recvauth(Port *port) void
be_recvauth(Port *port)
{ {
/* /*
* Get the authentication method to use for this frontend/database * Get the authentication method to use for this frontend/database
* combination. * combination.
...@@ -426,7 +433,7 @@ void be_recvauth(Port *port) ...@@ -426,7 +433,7 @@ void be_recvauth(Port *port)
else else
{ {
AuthRequest areq; AuthRequest areq;
void (*auth_handler)(); void (*auth_handler) ();
/* Keep the compiler quiet. */ /* Keep the compiler quiet. */
...@@ -491,9 +498,11 @@ void be_recvauth(Port *port) ...@@ -491,9 +498,11 @@ void be_recvauth(Port *port)
* Send an authentication request packet to the frontend. * Send an authentication request packet to the frontend.
*/ */
static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)()) static void
sendAuthRequest(Port *port, AuthRequest areq, void (*handler) ())
{ {
char *dp, *sp; char *dp,
*sp;
int i; int i;
uint32 net_areq; uint32 net_areq;
...@@ -502,7 +511,7 @@ static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)()) ...@@ -502,7 +511,7 @@ static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)())
net_areq = htonl(areq); net_areq = htonl(areq);
dp = port->pktInfo.pkt.ar.data; dp = port->pktInfo.pkt.ar.data;
sp = (char *)&net_areq; sp = (char *) &net_areq;
*dp++ = 'R'; *dp++ = 'R';
...@@ -518,7 +527,7 @@ static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)()) ...@@ -518,7 +527,7 @@ static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)())
i += 2; i += 2;
} }
PacketSendSetup(&port -> pktInfo, i, handler, (char *)port); PacketSendSetup(&port->pktInfo, i, handler, (char *) port);
} }
...@@ -526,8 +535,10 @@ static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)()) ...@@ -526,8 +535,10 @@ static void sendAuthRequest(Port *port, AuthRequest areq, void (*handler)())
* Called when we have told the front end that it is authorised. * Called when we have told the front end that it is authorised.
*/ */
static void handle_done_auth(Port *port) static void
handle_done_auth(Port *port)
{ {
/* /*
* Don't generate any more traffic. This will cause the backend to * Don't generate any more traffic. This will cause the backend to
* start. * start.
...@@ -542,7 +553,8 @@ static void handle_done_auth(Port *port) ...@@ -542,7 +553,8 @@ static void handle_done_auth(Port *port)
* authentication. * authentication.
*/ */
static void handle_krb4_auth(Port *port) static void
handle_krb4_auth(Port *port)
{ {
if (pg_krb4_recvauth(port) != STATUS_OK) if (pg_krb4_recvauth(port) != STATUS_OK)
auth_failed(port); auth_failed(port);
...@@ -556,7 +568,8 @@ static void handle_krb4_auth(Port *port) ...@@ -556,7 +568,8 @@ static void handle_krb4_auth(Port *port)
* authentication. * authentication.
*/ */
static void handle_krb5_auth(Port *port) static void
handle_krb5_auth(Port *port)
{ {
if (pg_krb5_recvauth(port) != STATUS_OK) if (pg_krb5_recvauth(port) != STATUS_OK)
auth_failed(port); auth_failed(port);
...@@ -570,11 +583,12 @@ static void handle_krb5_auth(Port *port) ...@@ -570,11 +583,12 @@ static void handle_krb5_auth(Port *port)
* authentication. * authentication.
*/ */
static void handle_password_auth(Port *port) static void
handle_password_auth(Port *port)
{ {
/* Set up the read of the password packet. */ /* Set up the read of the password packet. */
PacketReceiveSetup(&port->pktInfo, readPasswordPacket, (char *)port); PacketReceiveSetup(&port->pktInfo, readPasswordPacket, (char *) port);
} }
...@@ -582,19 +596,20 @@ static void handle_password_auth(Port *port) ...@@ -582,19 +596,20 @@ static void handle_password_auth(Port *port)
* Called when we have received the password packet. * Called when we have received the password packet.
*/ */
static void readPasswordPacket(char *arg, PacketLen len, char *pkt) static void
readPasswordPacket(char *arg, PacketLen len, char *pkt)
{ {
char password[sizeof (PasswordPacket) + 1]; char password[sizeof(PasswordPacket) + 1];
Port *port; Port *port;
port = (Port *)arg; port = (Port *) arg;
/* Silently truncate a password that is too big. */ /* Silently truncate a password that is too big. */
if (len > sizeof (PasswordPacket)) if (len > sizeof(PasswordPacket))
len = sizeof (PasswordPacket); len = sizeof(PasswordPacket);
StrNCpy(password, ((PasswordPacket *)pkt)->passwd, len); StrNCpy(password, ((PasswordPacket *) pkt)->passwd, len);
if (checkPassword(port, port->user, password) != STATUS_OK) if (checkPassword(port, port->user, password) != STATUS_OK)
auth_failed(port); auth_failed(port);
...@@ -609,7 +624,8 @@ static void readPasswordPacket(char *arg, PacketLen len, char *pkt) ...@@ -609,7 +624,8 @@ static void readPasswordPacket(char *arg, PacketLen len, char *pkt)
* not. * not.
*/ */
static int checkPassword(Port *port, char *user, char *password) static int
checkPassword(Port *port, char *user, char *password)
{ {
if (port->auth_method == uaPassword && port->auth_arg[0] != '\0') if (port->auth_method == uaPassword && port->auth_arg[0] != '\0')
return verify_password(port->auth_arg, user, password); return verify_password(port->auth_arg, user, password);
...@@ -622,30 +638,31 @@ static int checkPassword(Port *port, char *user, char *password) ...@@ -622,30 +638,31 @@ static int checkPassword(Port *port, char *user, char *password)
* Server demux routine for incoming authentication information for protocol * Server demux routine for incoming authentication information for protocol
* version 0. * version 0.
*/ */
static int old_be_recvauth(Port *port) static int
old_be_recvauth(Port *port)
{ {
int status; int status;
MsgType msgtype = (MsgType)port->proto; MsgType msgtype = (MsgType) port->proto;
/* Handle the authentication that's offered. */ /* Handle the authentication that's offered. */
switch (msgtype) switch (msgtype)
{ {
case STARTUP_KRB4_MSG: case STARTUP_KRB4_MSG:
status = map_old_to_new(port,uaKrb4,pg_krb4_recvauth(port)); status = map_old_to_new(port, uaKrb4, pg_krb4_recvauth(port));
break; break;
case STARTUP_KRB5_MSG: case STARTUP_KRB5_MSG:
status = map_old_to_new(port,uaKrb5,pg_krb5_recvauth(port)); status = map_old_to_new(port, uaKrb5, pg_krb5_recvauth(port));
break; break;
case STARTUP_MSG: case STARTUP_MSG:
status = map_old_to_new(port,uaTrust,STATUS_OK); status = map_old_to_new(port, uaTrust, STATUS_OK);
break; break;
case STARTUP_PASSWORD_MSG: case STARTUP_PASSWORD_MSG:
PacketReceiveSetup(&port->pktInfo, pg_passwordv0_recvauth, PacketReceiveSetup(&port->pktInfo, pg_passwordv0_recvauth,
(char *)port); (char *) port);
return STATUS_OK; return STATUS_OK;
...@@ -665,7 +682,8 @@ static int old_be_recvauth(Port *port) ...@@ -665,7 +682,8 @@ static int old_be_recvauth(Port *port)
* depending on what authentication we really want to use. * depending on what authentication we really want to use.
*/ */
static int map_old_to_new(Port *port, UserAuth old, int status) static int
map_old_to_new(Port *port, UserAuth old, int status)
{ {
switch (port->auth_method) switch (port->auth_method)
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.13 1998/02/10 16:03:12 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.14 1998/02/26 04:31:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.14 1998/01/26 01:41:06 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.15 1998/02/26 04:31:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.28 1998/02/24 15:18:41 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.29 1998/02/26 04:31:49 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -97,7 +97,7 @@ read_through_eol(FILE *file) ...@@ -97,7 +97,7 @@ read_through_eol(FILE *file)
static void static void
read_hba_entry2(FILE *file, UserAuth * userauth_p, char auth_arg[], read_hba_entry2(FILE *file, UserAuth *userauth_p, char auth_arg[],
bool *error_p) bool *error_p)
{ {
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
...@@ -156,7 +156,7 @@ read_hba_entry2(FILE *file, UserAuth * userauth_p, char auth_arg[], ...@@ -156,7 +156,7 @@ read_hba_entry2(FILE *file, UserAuth * userauth_p, char auth_arg[],
static void static void
process_hba_record(FILE *file, SockAddr *raddr, const char database[], process_hba_record(FILE *file, SockAddr *raddr, const char database[],
bool *matches_p, bool *error_p, bool *matches_p, bool *error_p,
UserAuth * userauth_p, char auth_arg[]) UserAuth *userauth_p, char auth_arg[])
{ {
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Process the non-comment record in the config file that is next on the file. Process the non-comment record in the config file that is next on the file.
...@@ -167,7 +167,8 @@ process_hba_record(FILE *file, SockAddr *raddr, const char database[], ...@@ -167,7 +167,8 @@ process_hba_record(FILE *file, SockAddr *raddr, const char database[],
return *error_p true, after issuing a message to stderr. If no error, return *error_p true, after issuing a message to stderr. If no error,
leave *error_p as it was. leave *error_p as it was.
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
char db[MAX_TOKEN], buf[MAX_TOKEN]; char db[MAX_TOKEN],
buf[MAX_TOKEN];
/* Read the record type field. */ /* Read the record type field. */
...@@ -215,7 +216,8 @@ process_hba_record(FILE *file, SockAddr *raddr, const char database[], ...@@ -215,7 +216,8 @@ process_hba_record(FILE *file, SockAddr *raddr, const char database[],
} }
else if (strcmp(buf, "host") == 0) else if (strcmp(buf, "host") == 0)
{ {
struct in_addr file_ip_addr, mask; struct in_addr file_ip_addr,
mask;
/* Get the database. */ /* Get the database. */
...@@ -296,7 +298,7 @@ syntax: ...@@ -296,7 +298,7 @@ syntax:
static void static void
process_open_config_file(FILE *file, SockAddr *raddr, const char database[], process_open_config_file(FILE *file, SockAddr *raddr, const char database[],
bool *host_ok_p, UserAuth * userauth_p, bool *host_ok_p, UserAuth *userauth_p,
char auth_arg[]) char auth_arg[])
{ {
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
...@@ -352,7 +354,7 @@ process_open_config_file(FILE *file, SockAddr *raddr, const char database[], ...@@ -352,7 +354,7 @@ process_open_config_file(FILE *file, SockAddr *raddr, const char database[],
static void static void
find_hba_entry(SockAddr *raddr, const char database[], bool *host_ok_p, find_hba_entry(SockAddr *raddr, const char database[], bool *host_ok_p,
UserAuth * userauth_p, char auth_arg[]) UserAuth *userauth_p, char auth_arg[])
{ {
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
Read the config file and find an entry that allows connection from Read the config file and find an entry that allows connection from
...@@ -812,7 +814,7 @@ verify_against_usermap(const char pguser[], ...@@ -812,7 +814,7 @@ verify_against_usermap(const char pguser[],
int int
authident(struct sockaddr_in *raddr, struct sockaddr_in *laddr, authident(struct sockaddr_in * raddr, struct sockaddr_in * laddr,
const char postgres_username[], const char postgres_username[],
const char auth_arg[]) const char auth_arg[])
{ {
...@@ -860,24 +862,31 @@ struct CharsetItem ...@@ -860,24 +862,31 @@ struct CharsetItem
char Table[MAX_TOKEN]; char Table[MAX_TOKEN];
}; };
int InRange(char *buf,int host) int
InRange(char *buf, int host)
{ {
int valid,i,FromAddr,ToAddr,tmp; int valid,
i,
FromAddr,
ToAddr,
tmp;
struct in_addr file_ip_addr; struct in_addr file_ip_addr;
char *p; char *p;
unsigned int one=0x80000000,NetMask=0; unsigned int one = 0x80000000,
NetMask = 0;
unsigned char mask; unsigned char mask;
p = strchr(buf,'/');
if(p) p = strchr(buf, '/');
if (p)
{ {
*p++ = '\0'; *p++ = '\0';
valid = inet_aton(buf, &file_ip_addr); valid = inet_aton(buf, &file_ip_addr);
if(valid) if (valid)
{ {
mask = strtoul(p,0,0); mask = strtoul(p, 0, 0);
FromAddr = ntohl(file_ip_addr.s_addr); FromAddr = ntohl(file_ip_addr.s_addr);
ToAddr = ntohl(file_ip_addr.s_addr); ToAddr = ntohl(file_ip_addr.s_addr);
for(i=0;i<mask;i++) for (i = 0; i < mask; i++)
{ {
NetMask |= one; NetMask |= one;
one >>= 1; one >>= 1;
...@@ -885,57 +894,63 @@ int InRange(char *buf,int host) ...@@ -885,57 +894,63 @@ int InRange(char *buf,int host)
FromAddr &= NetMask; FromAddr &= NetMask;
ToAddr = ToAddr | ~NetMask; ToAddr = ToAddr | ~NetMask;
tmp = ntohl(host); tmp = ntohl(host);
return ((unsigned)tmp>=(unsigned)FromAddr && return ((unsigned) tmp >= (unsigned) FromAddr &&
(unsigned)tmp<=(unsigned)ToAddr); (unsigned) tmp <= (unsigned) ToAddr);
} }
} }
else else
{ {
p = strchr(buf,'-'); p = strchr(buf, '-');
if(p) if (p)
{ {
*p++ = '\0'; *p++ = '\0';
valid = inet_aton(buf, &file_ip_addr); valid = inet_aton(buf, &file_ip_addr);
if(valid) if (valid)
{ {
FromAddr = ntohl(file_ip_addr.s_addr); FromAddr = ntohl(file_ip_addr.s_addr);
valid = inet_aton(p, &file_ip_addr); valid = inet_aton(p, &file_ip_addr);
if(valid) if (valid)
{ {
ToAddr = ntohl(file_ip_addr.s_addr); ToAddr = ntohl(file_ip_addr.s_addr);
tmp = ntohl(host); tmp = ntohl(host);
return ((unsigned)tmp>=(unsigned)FromAddr && return ((unsigned) tmp >= (unsigned) FromAddr &&
(unsigned)tmp<=(unsigned)ToAddr); (unsigned) tmp <= (unsigned) ToAddr);
} }
} }
} }
else else
{ {
valid = inet_aton(buf, &file_ip_addr); valid = inet_aton(buf, &file_ip_addr);
if(valid) if (valid)
{ {
FromAddr = file_ip_addr.s_addr; FromAddr = file_ip_addr.s_addr;
return ((unsigned)FromAddr == (unsigned)host); return ((unsigned) FromAddr == (unsigned) host);
} }
} }
} }
return false; return false;
} }
void GetCharSetByHost(char TableName[],int host, const char DataDir[]) void
GetCharSetByHost(char TableName[], int host, const char DataDir[])
{ {
FILE *file; FILE *file;
char buf[MAX_TOKEN],BaseCharset[MAX_TOKEN], char buf[MAX_TOKEN],
OrigCharset[MAX_TOKEN],DestCharset[MAX_TOKEN],HostCharset[MAX_TOKEN]; BaseCharset[MAX_TOKEN],
char c,eof=false; OrigCharset[MAX_TOKEN],
DestCharset[MAX_TOKEN],
HostCharset[MAX_TOKEN];
char c,
eof = false;
char *map_file; char *map_file;
int key=0,i; int key = 0,
struct CharsetItem* ChArray[MAX_CHARSETS]; i;
int ChIndex=0; struct CharsetItem *ChArray[MAX_CHARSETS];
int ChIndex = 0;
*TableName = '\0'; *TableName = '\0';
map_file = (char *) malloc((strlen(DataDir) + map_file = (char *) malloc((strlen(DataDir) +
strlen(CHARSET_FILE)+2)*sizeof(char)); strlen(CHARSET_FILE) + 2) * sizeof(char));
sprintf(map_file, "%s/%s", DataDir, CHARSET_FILE); sprintf(map_file, "%s/%s", DataDir, CHARSET_FILE);
file = fopen(map_file, "r"); file = fopen(map_file, "r");
if (file == NULL) if (file == NULL)
...@@ -962,20 +977,20 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[]) ...@@ -962,20 +977,20 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[])
key = KEY_BASE; key = KEY_BASE;
if (strcasecmp(buf, "RecodeTable") == 0) if (strcasecmp(buf, "RecodeTable") == 0)
key = KEY_TABLE; key = KEY_TABLE;
switch(key) switch (key)
{ {
case KEY_HOST: case KEY_HOST:
/* Read the host */ /* Read the host */
next_token(file, buf, sizeof(buf)); next_token(file, buf, sizeof(buf));
if (buf[0] != '\0') if (buf[0] != '\0')
{ {
if (InRange(buf,host)) if (InRange(buf, host))
{ {
/* Read the charset */ /* Read the charset */
next_token(file, buf, sizeof(buf)); next_token(file, buf, sizeof(buf));
if (buf[0] != '\0') if (buf[0] != '\0')
{ {
strcpy(HostCharset,buf); strcpy(HostCharset, buf);
} }
} }
} }
...@@ -985,7 +1000,7 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[]) ...@@ -985,7 +1000,7 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[])
next_token(file, buf, sizeof(buf)); next_token(file, buf, sizeof(buf));
if (buf[0] != '\0') if (buf[0] != '\0')
{ {
strcpy(BaseCharset,buf); strcpy(BaseCharset, buf);
} }
break; break;
case KEY_TABLE: case KEY_TABLE:
...@@ -993,20 +1008,20 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[]) ...@@ -993,20 +1008,20 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[])
next_token(file, buf, sizeof(buf)); next_token(file, buf, sizeof(buf));
if (buf[0] != '\0') if (buf[0] != '\0')
{ {
strcpy(OrigCharset,buf); strcpy(OrigCharset, buf);
/* Read the destination charset */ /* Read the destination charset */
next_token(file, buf, sizeof(buf)); next_token(file, buf, sizeof(buf));
if (buf[0] != '\0') if (buf[0] != '\0')
{ {
strcpy(DestCharset,buf); strcpy(DestCharset, buf);
/* Read the table filename */ /* Read the table filename */
next_token(file, buf, sizeof(buf)); next_token(file, buf, sizeof(buf));
if (buf[0] != '\0') if (buf[0] != '\0')
{ {
ChArray[ChIndex] = (struct CharsetItem *) malloc(sizeof(struct CharsetItem)); ChArray[ChIndex] = (struct CharsetItem *) malloc(sizeof(struct CharsetItem));
strcpy(ChArray[ChIndex]->Orig,OrigCharset); strcpy(ChArray[ChIndex]->Orig, OrigCharset);
strcpy(ChArray[ChIndex]->Dest,DestCharset); strcpy(ChArray[ChIndex]->Dest, DestCharset);
strcpy(ChArray[ChIndex]->Table,buf); strcpy(ChArray[ChIndex]->Table, buf);
ChIndex++; ChIndex++;
} }
} }
...@@ -1021,16 +1036,17 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[]) ...@@ -1021,16 +1036,17 @@ void GetCharSetByHost(char TableName[],int host, const char DataDir[])
fclose(file); fclose(file);
free(map_file); free(map_file);
for(i=0; i<ChIndex; i++) for (i = 0; i < ChIndex; i++)
{ {
if(!strcasecmp(BaseCharset,ChArray[i]->Orig) && if (!strcasecmp(BaseCharset, ChArray[i]->Orig) &&
!strcasecmp(HostCharset,ChArray[i]->Dest)) !strcasecmp(HostCharset, ChArray[i]->Dest))
{ {
strncpy(TableName,ChArray[i]->Table,79); strncpy(TableName, ChArray[i]->Table, 79);
} }
free((struct CharsetItem *) ChArray[i]); free((struct CharsetItem *) ChArray[i]);
} }
} }
#endif #endif
extern int extern int
......
...@@ -36,9 +36,12 @@ verify_password(char *auth_arg, char *user, char *password) ...@@ -36,9 +36,12 @@ verify_password(char *auth_arg, char *user, char *password)
while (!feof(pw_file)) while (!feof(pw_file))
{ {
char pw_file_line[255], *p, *test_user, *test_pw; char pw_file_line[255],
*p,
*test_user,
*test_pw;
fgets(pw_file_line, sizeof (pw_file_line), pw_file); fgets(pw_file_line, sizeof(pw_file_line), pw_file);
p = pw_file_line; p = pw_file_line;
test_user = strtok(p, ":"); test_user = strtok(p, ":");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.12 1997/12/09 03:10:43 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.13 1998/02/26 04:31:51 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.9 1997/12/09 03:10:45 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.10 1998/02/26 04:31:52 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.13 1998/02/05 04:21:56 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.14 1998/02/26 04:31:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -36,12 +36,14 @@ main(int argc, char *argv[]) ...@@ -36,12 +36,14 @@ main(int argc, char *argv[])
int len; int len;
#if defined(alpha) #if defined(alpha)
# ifdef NOFIXADE #ifdef NOFIXADE
int buffer[] = {SSIN_UACPROC, UAC_SIGBUS}; int buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
# endif /* NOFIXADE */
# ifdef NOPRINTADE #endif /* NOFIXADE */
#ifdef NOPRINTADE
int buffer[] = {SSIN_UACPROC, UAC_NOPRINT}; int buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
# endif /* NOPRINTADE */
#endif /* NOPRINTADE */
#endif #endif
#ifdef USE_LOCALE #ifdef USE_LOCALE
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment