Commit 07842084 authored by Bruce Momjian's avatar Bruce Momjian

pgindent run over code.

parent 4b04b01a
...@@ -43,7 +43,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -43,7 +43,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
int ndim, int ndim,
*dim; *dim;
char *p; char *p;
FmgrInfo finf; /*Tobias Gabele Jan 18 1999*/ FmgrInfo finf; /* Tobias Gabele Jan 18 1999 */
/* Sanity checks */ /* Sanity checks */
...@@ -75,9 +75,9 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -75,9 +75,9 @@ 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,&finf); /*Tobias Gabele Jan 18 1999*/ fmgr_info(proc, &finf); /* Tobias Gabele Jan 18 1999 */
proc_fn=finf.fn_addr; /*Tobias Gabele Jan 18 1999*/ proc_fn = finf.fn_addr; /* Tobias Gabele Jan 18 1999 */
pronargs=finf.fn_nargs; /*Tobias Gabele Jan 18 1999*/ pronargs = finf.fn_nargs; /* Tobias Gabele Jan 18 1999 */
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);
...@@ -110,38 +110,26 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -110,38 +110,26 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
{ {
result = (int) (*proc_fn) (p, value); result = (int) (*proc_fn) (p, value);
if (typlen > 0) if (typlen > 0)
{
p += typlen; p += typlen;
}
else else
{
p += INTALIGN(*(int32 *) p); p += INTALIGN(*(int32 *) p);
} }
}
if (result) if (result)
{ {
if (!and) if (!and)
{
return (1); return (1);
} }
}
else else
{ {
if (and) if (and)
{
return (0); return (0);
} }
} }
}
if (and && result) if (and && result)
{
return (1); return (1);
}
else else
{
return (0); return (0);
}
} }
/* /*
......
#ifndef ARRAY_ITERATOR_H #ifndef ARRAY_ITERATOR_H
#define ARRAY_ITERATOR_H #define ARRAY_ITERATOR_H
static int32 static int32 array_iterator(Oid elemtype, Oid proc, int and,
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);
...@@ -26,4 +25,5 @@ int32 array_int4le(ArrayType *array, int4 value); ...@@ -26,4 +25,5 @@ int32 array_int4le(ArrayType *array, int4 value);
int32 array_all_int4le(ArrayType *array, int4 value); int32 array_all_int4le(ArrayType *array, int4 value);
int32 array_oideq(ArrayType *array, Oid value); int32 array_oideq(ArrayType *array, Oid value);
int32 array_all_oidne(ArrayType *array, Oid value); int32 array_all_oidne(ArrayType *array, Oid value);
#endif #endif
...@@ -20,7 +20,8 @@ const TWO_PI = 2.0 * M_PI; ...@@ -20,7 +20,8 @@ const TWO_PI = 2.0 * M_PI;
******************************************************/ ******************************************************/
static double static double
degtorad (double degrees) { degtorad(double degrees)
{
return (degrees / 360.0) * TWO_PI; return (degrees / 360.0) * TWO_PI;
} }
...@@ -39,27 +40,31 @@ degtorad (double degrees) { ...@@ -39,27 +40,31 @@ degtorad (double degrees) {
******************************************************/ ******************************************************/
double * double *
geo_distance (Point *pt1, Point *pt2) { geo_distance(Point *pt1, Point *pt2)
{
double long1, lat1, long2, lat2; double long1,
lat1,
long2,
lat2;
double longdiff; double longdiff;
double * resultp = palloc (sizeof(double)); double *resultp = palloc(sizeof(double));
/* convert degrees to radians */ /* convert degrees to radians */
long1 = degtorad (pt1->x); long1 = degtorad(pt1->x);
lat1 = degtorad (pt1->y); lat1 = degtorad(pt1->y);
long2 = degtorad (pt2->x); long2 = degtorad(pt2->x);
lat2 = degtorad (pt2->y); lat2 = degtorad(pt2->y);
/* compute difference in longitudes - want < 180 degrees */ /* compute difference in longitudes - want < 180 degrees */
longdiff = fabs (long1 - long2); longdiff = fabs(long1 - long2);
if (longdiff > M_PI) if (longdiff > M_PI)
longdiff = TWO_PI - longdiff; longdiff = TWO_PI - longdiff;
* resultp = EARTH_RADIUS * acos *resultp = EARTH_RADIUS * acos
(sin (lat1) * sin (lat2) + cos (lat1) * cos (lat2) * cos (longdiff)); (sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(longdiff));
return resultp; return resultp;
} }
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include <libpq-fe.h> #include <libpq-fe.h>
#include "pginterface.h" #include "pginterface.h"
PGresult *attres, *relres; PGresult *attres,
*relres;
int int
main(int argc, char **argv) main(int argc, char **argv)
...@@ -65,17 +66,17 @@ main(int argc, char **argv) ...@@ -65,17 +66,17 @@ main(int argc, char **argv)
{ {
unset_result(relres); unset_result(relres);
if (strcmp(typname, "oid") == 0) if (strcmp(typname, "oid") == 0)
sprintf(query,"\ sprintf(query, "\
DECLARE c_matches BINARY CURSOR FOR \ DECLARE c_matches BINARY CURSOR FOR \
SELECT count(*) SELECT count(*) \
FROM %s t1, %s t2 \ FROM % s t1, %s t2 \
WHERE t1.%s = t2.oid", relname, relname2, attname); WHERE t1.% s = t2.oid ", relname, relname2, attname);
else else
sprintf(query,"\ sprintf(query, "\
DECLARE c_matches BINARY CURSOR FOR \ DECLARE c_matches BINARY CURSOR FOR \
SELECT count(*) SELECT count(*) \
FROM %s t1, %s t2 \ FROM % s t1, %s t2 \
WHERE RegprocToOid(t1.%s) = t2.oid", relname, relname2, attname); WHERE RegprocToOid(t1.% s) = t2.oid ", relname, relname2, attname);
doquery(query); doquery(query);
doquery("FETCH ALL IN c_matches"); doquery("FETCH ALL IN c_matches");
......
...@@ -62,8 +62,8 @@ select p.* from product p, title_fti f1, title_fti f2 where ...@@ -62,8 +62,8 @@ select p.* from product p, title_fti f1, title_fti f2 where
*/ */
HeapTuple fti(void); HeapTuple fti(void);
char *breakup(char*, char*); char *breakup(char *, char *);
bool is_stopword(char*); bool is_stopword(char *);
bool new_tuple = false; bool new_tuple = false;
...@@ -104,19 +104,19 @@ fti() ...@@ -104,19 +104,19 @@ fti()
char *indexname; /* name of table for substrings */ char *indexname; /* name of table for substrings */
HeapTuple rettuple = NULL; HeapTuple rettuple = NULL;
TupleDesc tupdesc; /* tuple description */ TupleDesc tupdesc; /* tuple description */
bool isinsert=false; bool isinsert = false;
bool isdelete=false; bool isdelete = false;
int ret; int ret;
char query[8192]; char query[8192];
Oid oid; Oid oid;
/* /*
FILE *debug; * FILE *debug;
*/ */
/* /*
debug = fopen("/dev/xconsole", "w"); * debug = fopen("/dev/xconsole", "w"); fprintf(debug, "FTI: entered
fprintf(debug, "FTI: entered function\n"); * function\n"); fflush(debug);
fflush(debug);
*/ */
if (!CurrentTriggerData) if (!CurrentTriggerData)
...@@ -127,23 +127,27 @@ fti() ...@@ -127,23 +127,27 @@ fti()
elog(ERROR, "Full Text Indexing: must be fired AFTER event"); elog(ERROR, "Full Text Indexing: must be fired AFTER event");
if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
isinsert=true; isinsert = true;
if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
{ isdelete=true;isinsert=true;} {
isdelete = true;
isinsert = true;
}
if (TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event))
isdelete=true; isdelete = true;
trigger = CurrentTriggerData->tg_trigger; trigger = CurrentTriggerData->tg_trigger;
rel = CurrentTriggerData->tg_relation; rel = CurrentTriggerData->tg_relation;
relname = SPI_getrelname(rel); relname = SPI_getrelname(rel);
rettuple=CurrentTriggerData->tg_trigtuple; rettuple = CurrentTriggerData->tg_trigtuple;
if (isdelete&&isinsert) /* is an UPDATE */ if (isdelete && isinsert) /* is an UPDATE */
rettuple=CurrentTriggerData->tg_newtuple; rettuple = CurrentTriggerData->tg_newtuple;
CurrentTriggerData = NULL; /* invalidate 'normal' calls to this function */ CurrentTriggerData = NULL; /* invalidate 'normal' calls to this
* function */
if ((ret = SPI_connect()) <0) if ((ret = SPI_connect()) < 0)
elog(ERROR,"Full Text Indexing: SPI_connect failed, returned %d\n",ret); elog(ERROR, "Full Text Indexing: SPI_connect failed, returned %d\n", ret);
nargs = trigger->tgnargs; nargs = trigger->tgnargs;
if (nargs != 2) if (nargs != 2)
...@@ -156,9 +160,10 @@ fti() ...@@ -156,9 +160,10 @@ fti()
/* get oid of current tuple, needed by all, so place here */ /* get oid of current tuple, needed by all, so place here */
oid = rettuple->t_data->t_oid; oid = rettuple->t_data->t_oid;
if (!OidIsValid(oid)) if (!OidIsValid(oid))
elog(ERROR,"Full Text Indexing: oid of current tuple is NULL"); elog(ERROR, "Full Text Indexing: oid of current tuple is NULL");
if (isdelete) { if (isdelete)
{
void *pplan; void *pplan;
Oid *argtypes; Oid *argtypes;
Datum values[1]; Datum values[1];
...@@ -166,8 +171,9 @@ fti() ...@@ -166,8 +171,9 @@ fti()
sprintf(query, "D%s$%s", args[0], args[1]); sprintf(query, "D%s$%s", args[0], args[1]);
plan = find_plan(query, &DeletePlans, &nDeletePlans); plan = find_plan(query, &DeletePlans, &nDeletePlans);
if (plan->nplans <= 0) { if (plan->nplans <= 0)
argtypes = (Oid *)palloc(sizeof(Oid)); {
argtypes = (Oid *) palloc(sizeof(Oid));
argtypes[0] = OIDOID; argtypes[0] = OIDOID;
...@@ -181,7 +187,7 @@ fti() ...@@ -181,7 +187,7 @@ fti()
elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL " elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL "
"in delete"); "in delete");
plan->splan = (void **)malloc(sizeof(void*)); plan->splan = (void **) malloc(sizeof(void *));
*(plan->splan) = pplan; *(plan->splan) = pplan;
plan->nplans = 1; plan->nplans = 1;
} }
...@@ -193,8 +199,10 @@ fti() ...@@ -193,8 +199,10 @@ fti()
elog(ERROR, "Full Text Indexing: error executing plan in delete"); elog(ERROR, "Full Text Indexing: error executing plan in delete");
} }
if (isinsert) { if (isinsert)
char *substring, *column; {
char *substring,
*column;
void *pplan; void *pplan;
Oid *argtypes; Oid *argtypes;
Datum values[2]; Datum values[2];
...@@ -206,11 +214,12 @@ fti() ...@@ -206,11 +214,12 @@ fti()
plan = find_plan(query, &InsertPlans, &nInsertPlans); plan = find_plan(query, &InsertPlans, &nInsertPlans);
/* no plan yet, so allocate mem for argtypes */ /* no plan yet, so allocate mem for argtypes */
if (plan->nplans <= 0) { if (plan->nplans <= 0)
argtypes = (Oid *)palloc(2*sizeof(Oid)); {
argtypes = (Oid *) palloc(2 * sizeof(Oid));
argtypes[0] = VARCHAROID; /*create table t_name argtypes[0] = VARCHAROID; /* create table t_name (string
(string varchar, */ * varchar, */
argtypes[1] = OIDOID; /* id oid); */ argtypes[1] = OIDOID; /* id oid); */
/* prepare plan to gain speed */ /* prepare plan to gain speed */
...@@ -226,14 +235,14 @@ fti() ...@@ -226,14 +235,14 @@ fti()
elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL" elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL"
" in insert"); " in insert");
plan->splan = (void **)malloc(sizeof(void*)); plan->splan = (void **) malloc(sizeof(void *));
*(plan->splan) = pplan; *(plan->splan) = pplan;
plan->nplans = 1; plan->nplans = 1;
} }
/* prepare plan for query */ /* prepare plan for query */
colnum=SPI_fnumber(tupdesc, args[1]); colnum = SPI_fnumber(tupdesc, args[1]);
if (colnum == SPI_ERROR_NOATTRIBUTE) if (colnum == SPI_ERROR_NOATTRIBUTE)
elog(ERROR, "Full Text Indexing: column '%s' of '%s' not found", elog(ERROR, "Full Text Indexing: column '%s' of '%s' not found",
args[1], args[0]); args[1], args[0]);
...@@ -241,26 +250,30 @@ fti() ...@@ -241,26 +250,30 @@ fti()
/* Get the char* representation of the column with name args[1] */ /* Get the char* representation of the column with name args[1] */
column = SPI_getvalue(rettuple, tupdesc, colnum); column = SPI_getvalue(rettuple, tupdesc, colnum);
if (column) { /* make sure we don't try to index NULL's */ if (column)
{ /* make sure we don't try to index NULL's */
char *buff; char *buff;
char *string = column; char *string = column;
while(*string != '\0') { /* placed 'really' inline. */ while (*string != '\0')
*string = tolower(*string); /* some compilers will choke */ { /* placed 'really' inline. */
*string = tolower(*string); /* some compilers will
* choke */
string++; /* on 'inline' keyword */ string++; /* on 'inline' keyword */
} }
data = (struct varlena*)palloc(sizeof(int32)+strlen(column)+1); data = (struct varlena *) palloc(sizeof(int32) + strlen(column) +1);
buff = palloc(strlen(column) + 1); buff = palloc(strlen(column) + 1);
/* saves lots of calls in while-loop and in breakup()*/ /* saves lots of calls in while-loop and in breakup() */
new_tuple=true; new_tuple = true;
while ((substring = breakup(column, buff))) { while ((substring = breakup(column, buff)))
{
int l; int l;
l = strlen(substring); l = strlen(substring);
data->vl_len = l+sizeof(int32); data->vl_len = l + sizeof(int32);
memcpy(VARDATA(data), substring, l); memcpy(VARDATA(data), substring, l);
values[0] = PointerGetDatum(data); values[0] = PointerGetDatum(data);
values[1] = oid; values[1] = oid;
...@@ -279,41 +292,48 @@ fti() ...@@ -279,41 +292,48 @@ fti()
return (rettuple); return (rettuple);
} }
char *breakup(char *string, char *substring) char *
breakup(char *string, char *substring)
{ {
static char *last_start; static char *last_start;
static char *cur_pos; static char *cur_pos;
if (new_tuple) if (new_tuple)
{ {
cur_pos=last_start=&string[strlen(string)-1]; cur_pos = last_start = &string[strlen(string) - 1];
new_tuple=false; /* don't initialize this next time */ new_tuple = false; /* don't initialize this next time */
} }
while (cur_pos > string) /* don't read before start of 'string' */ while (cur_pos > string) /* don't read before start of 'string' */
{ {
/* skip pieces at the end of a string that are not
alfa-numeric (ie. 'string$%^&', last_start first points to /*
'&', and after this to 'g' */ * skip pieces at the end of a string that are not alfa-numeric
if (!isalnum((int)*last_start)) { * (ie. 'string$%^&', last_start first points to '&', and after
while (!isalnum((int)*last_start) && * this to 'g'
*/
if (!isalnum((int) *last_start))
{
while (!isalnum((int) *last_start) &&
last_start > string) last_start > string)
last_start--; last_start--;
cur_pos=last_start; cur_pos = last_start;
} }
cur_pos--; /* substrings are at minimum 2 characters long */ cur_pos--; /* substrings are at minimum 2 characters
* long */
if (isalnum((int)*cur_pos)) if (isalnum((int) *cur_pos))
{ {
/* Houston, we have a substring! :) */ /* Houston, we have a substring! :) */
memcpy(substring, cur_pos, last_start - cur_pos + 1); memcpy(substring, cur_pos, last_start - cur_pos + 1);
substring[last_start-cur_pos+1]='\0'; substring[last_start - cur_pos + 1] = '\0';
if (!is_stopword(substring)) return substring; if (!is_stopword(substring))
return substring;
} }
else else
{ {
last_start=cur_pos-1; last_start = cur_pos - 1;
cur_pos = last_start; cur_pos = last_start;
} }
} }
......
/* /*
* PostgreSQL type definitions for ISBNs. * PostgreSQL type definitions for ISBNs.
* *
* $Id: isbn.c,v 1.1 1998/08/17 03:35:04 scrappy Exp $ * $Id: isbn.c,v 1.2 1999/05/25 16:05:40 momjian Exp $
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -50,11 +50,13 @@ isbn_in(char *str) ...@@ -50,11 +50,13 @@ isbn_in(char *str)
char *cp; char *cp;
int count; int count;
if (strlen(str) != 13) { if (strlen(str) != 13)
{
elog(ERROR, "isbn_in: invalid ISBN \"%s\"", str); elog(ERROR, "isbn_in: invalid ISBN \"%s\"", str);
return (NULL); return (NULL);
} }
if (isbn_sum(str) != 0) { if (isbn_sum(str) != 0)
{
elog(ERROR, "isbn_in: purported ISBN \"%s\" failed checksum", elog(ERROR, "isbn_in: purported ISBN \"%s\" failed checksum",
str); str);
return (NULL); return (NULL);
...@@ -84,23 +86,35 @@ isbn_in(char *str) ...@@ -84,23 +86,35 @@ isbn_in(char *str)
int4 int4
isbn_sum(char *str) isbn_sum(char *str)
{ {
int4 sum = 0, dashes = 0, val; int4 sum = 0,
dashes = 0,
val;
int i; int i;
for (i = 0; str[i] && i < 13; i++) { for (i = 0; str[i] && i < 13; i++)
switch(str[i]) { {
switch (str[i])
{
case '-': case '-':
if (++dashes > 3) if (++dashes > 3)
return 12; return 12;
continue; continue;
case '0': case '1': case '2': case '3': case '0':
case '4': case '5': case '6': case '7': case '1':
case '8': case '9': case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
val = str[i] - '0'; val = str[i] - '0';
break; break;
case 'X': case 'x': case 'X':
case 'x':
val = 10; val = 10;
break; break;
......
/* /*
* PostgreSQL type definitions for ISSNs. * PostgreSQL type definitions for ISSNs.
* *
* $Id: issn.c,v 1.1 1998/08/17 03:35:05 scrappy Exp $ * $Id: issn.c,v 1.2 1999/05/25 16:05:42 momjian Exp $
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -50,11 +50,13 @@ issn_in(char *str) ...@@ -50,11 +50,13 @@ issn_in(char *str)
char *cp; char *cp;
int count; int count;
if (strlen(str) != 9) { if (strlen(str) != 9)
{
elog(ERROR, "issn_in: invalid ISSN \"%s\"", str); elog(ERROR, "issn_in: invalid ISSN \"%s\"", str);
return (NULL); return (NULL);
} }
if (issn_sum(str) != 0) { if (issn_sum(str) != 0)
{
elog(ERROR, "issn_in: purported ISSN \"%s\" failed checksum", elog(ERROR, "issn_in: purported ISSN \"%s\" failed checksum",
str); str);
return (NULL); return (NULL);
...@@ -75,23 +77,35 @@ issn_in(char *str) ...@@ -75,23 +77,35 @@ issn_in(char *str)
int4 int4
issn_sum(char *str) issn_sum(char *str)
{ {
int4 sum = 0, dashes = 0, val; int4 sum = 0,
dashes = 0,
val;
int i; int i;
for (i = 0; str[i] && i < 9; i++) { for (i = 0; str[i] && i < 9; i++)
switch(str[i]) { {
switch (str[i])
{
case '-': case '-':
if (++dashes > 1) if (++dashes > 1)
return 12; return 12;
continue; continue;
case '0': case '1': case '2': case '3': case '0':
case '4': case '5': case '6': case '7': case '1':
case '8': case '9': case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
val = str[i] - '0'; val = str[i] - '0';
break; break;
case 'X': case 'x': case 'X':
case 'x':
val = 10; val = 10;
break; break;
......
/* /*
* PostgreSQL type definitions for managed LargeObjects. * PostgreSQL type definitions for managed LargeObjects.
* *
* $Id: lo.c,v 1.1 1998/06/16 07:07:11 momjian Exp $ * $Id: lo.c,v 1.2 1999/05/25 16:05:45 momjian Exp $
* *
*/ */
...@@ -34,8 +34,8 @@ typedef Oid Blob; ...@@ -34,8 +34,8 @@ typedef Oid Blob;
*/ */
Blob *lo_in(char *str); /* Create from String */ Blob *lo_in(char *str); /* Create from String */
char *lo_out(Blob * addr); /* Output oid as String */ char *lo_out(Blob * addr);/* Output oid as String */
Oid lo_oid(Blob * addr); /* Return oid as an oid */ Oid lo_oid(Blob * addr);/* Return oid as an oid */
Blob *lo(Oid oid); /* Return Blob based on oid */ Blob *lo(Oid oid); /* Return Blob based on oid */
HeapTuple lo_manage(void); /* Trigger handler */ HeapTuple lo_manage(void); /* Trigger handler */
...@@ -64,7 +64,7 @@ lo_in(char *str) ...@@ -64,7 +64,7 @@ lo_in(char *str)
return (NULL); return (NULL);
} }
if(oid < 0) if (oid < 0)
{ {
elog(ERROR, "lo_in: illegal oid \"%s\"", str); elog(ERROR, "lo_in: illegal oid \"%s\"", str);
return (NULL); return (NULL);
...@@ -72,13 +72,14 @@ lo_in(char *str) ...@@ -72,13 +72,14 @@ lo_in(char *str)
} }
else else
{ {
/* /*
* There is no Oid passed, so create a new one * There is no Oid passed, so create a new one
*/ */
oid = lo_creat(INV_READ|INV_WRITE); oid = lo_creat(INV_READ | INV_WRITE);
if(oid == InvalidOid) if (oid == InvalidOid)
{ {
elog(ERROR,"lo_in: InvalidOid returned from lo_creat"); elog(ERROR, "lo_in: InvalidOid returned from lo_creat");
return (NULL); return (NULL);
} }
} }
...@@ -102,7 +103,7 @@ lo_out(Blob * addr) ...@@ -102,7 +103,7 @@ lo_out(Blob * addr)
return (NULL); return (NULL);
result = (char *) palloc(32); result = (char *) palloc(32);
sprintf(result,"%d",*addr); sprintf(result, "%d", *addr);
return (result); return (result);
} }
...@@ -115,9 +116,9 @@ lo_out(Blob * addr) ...@@ -115,9 +116,9 @@ lo_out(Blob * addr)
Oid Oid
lo_oid(Blob * addr) lo_oid(Blob * addr)
{ {
if(addr == NULL) if (addr == NULL)
return InvalidOid; return InvalidOid;
return (Oid)(*addr); return (Oid) (*addr);
} }
/* /*
...@@ -130,6 +131,7 @@ Blob * ...@@ -130,6 +131,7 @@ Blob *
lo(Oid oid) lo(Oid oid)
{ {
Blob *result = (Blob *) palloc(sizeof(Blob)); Blob *result = (Blob *) palloc(sizeof(Blob));
*result = oid; *result = oid;
return (result); return (result);
} }
...@@ -145,7 +147,7 @@ lo_manage(void) ...@@ -145,7 +147,7 @@ lo_manage(void)
TupleDesc tupdesc; /* Tuple Descriptor */ TupleDesc tupdesc; /* Tuple Descriptor */
HeapTuple rettuple; /* Tuple to be returned */ HeapTuple rettuple; /* Tuple to be returned */
bool isdelete; /* are we deleting? */ bool isdelete; /* are we deleting? */
HeapTuple newtuple=NULL; /* The new value for tuple */ HeapTuple newtuple = NULL;/* The new value for tuple */
HeapTuple trigtuple; /* The original value of tuple */ HeapTuple trigtuple; /* The original value of tuple */
if (!CurrentTriggerData) if (!CurrentTriggerData)
...@@ -172,24 +174,25 @@ lo_manage(void) ...@@ -172,24 +174,25 @@ lo_manage(void)
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
/* Get the column were interested in */ /* Get the column were interested in */
attnum = SPI_fnumber(tupdesc,args[0]); attnum = SPI_fnumber(tupdesc, args[0]);
/* /*
* Handle updates * Handle updates
* *
* Here, if the value of the monitored attribute changes, then the * Here, if the value of the monitored attribute changes, then the large
* large object associated with the original value is unlinked. * object associated with the original value is unlinked.
*/ */
if(newtuple!=NULL) { if (newtuple != NULL)
char *orig = SPI_getvalue(trigtuple,tupdesc,attnum); {
char *newv = SPI_getvalue(newtuple,tupdesc,attnum); char *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
char *newv = SPI_getvalue(newtuple, tupdesc, attnum);
if((orig != newv && (orig==NULL || newv==NULL)) || (orig!=NULL && newv!=NULL && strcmp(orig,newv))) if ((orig != newv && (orig == NULL || newv == NULL)) || (orig != NULL && newv != NULL && strcmp(orig, newv)))
lo_unlink(atoi(orig)); lo_unlink(atoi(orig));
if(newv) if (newv)
pfree(newv); pfree(newv);
if(orig) if (orig)
pfree(orig); pfree(orig);
} }
...@@ -199,10 +202,12 @@ lo_manage(void) ...@@ -199,10 +202,12 @@ lo_manage(void)
* Here, we unlink the large object associated with the managed attribute * Here, we unlink the large object associated with the managed attribute
* *
*/ */
if(isdelete) { if (isdelete)
char *orig = SPI_getvalue(trigtuple,tupdesc,attnum); {
char *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
if(orig != NULL) { if (orig != NULL)
{
lo_unlink(atoi(orig)); lo_unlink(atoi(orig));
pfree(orig); pfree(orig);
......
...@@ -17,33 +17,41 @@ char *msqlErrors[] = { ...@@ -17,33 +17,41 @@ char *msqlErrors[] = {
"Out of database handlers." "Out of database handlers."
}; };
char msqlErrMsg[BUFSIZ], *tfrom = "dunno"; char msqlErrMsg[BUFSIZ],
*tfrom = "dunno";
PGresult *queryres = NULL; PGresult *queryres = NULL;
int msqlConnect (char *host) { int
msqlConnect(char *host)
{
int count; int count;
for (count = 0; count < HNDMAX; count++) for (count = 0; count < HNDMAX; count++)
if (PGh[count] == NULL) break; if (PGh[count] == NULL)
break;
if (count == HNDMAX) { if (count == HNDMAX)
{
strncpy(msqlErrMsg, msqlErrors[E_NOHANDLERS], BUFSIZ); strncpy(msqlErrMsg, msqlErrors[E_NOHANDLERS], BUFSIZ);
return -1; return -1;
} }
PGh[count] = malloc(sizeof (PGconn)); PGh[count] = malloc(sizeof(PGconn));
PGh[count]->pghost = host ? strdup(host) : NULL; PGh[count]->pghost = host ? strdup(host) : NULL;
return count; return count;
} }
int msqlSelectDB(int handle, char *dbname) { int
msqlSelectDB(int handle, char *dbname)
{
char *options = calloc(1, BUFSIZ); char *options = calloc(1, BUFSIZ);
char *e = getenv("PG_OPTIONS"); char *e = getenv("PG_OPTIONS");
if (e == NULL) if (e == NULL)
e = ""; e = "";
if (PGh[handle]->pghost) { if (PGh[handle]->pghost)
{
strcat(options, "host="); strcat(options, "host=");
strncat(options, PGh[handle]->pghost, BUFSIZ); strncat(options, PGh[handle]->pghost, BUFSIZ);
strncat(options, " ", BUFSIZ); strncat(options, " ", BUFSIZ);
...@@ -61,7 +69,9 @@ int msqlSelectDB(int handle, char *dbname) { ...@@ -61,7 +69,9 @@ int msqlSelectDB(int handle, char *dbname) {
return (PQstatus(PGh[handle]) == CONNECTION_BAD ? -1 : 0); return (PQstatus(PGh[handle]) == CONNECTION_BAD ? -1 : 0);
} }
int msqlQuery(int handle, char *query) { int
msqlQuery(int handle, char *query)
{
char *tq = strdup(query); char *tq = strdup(query);
char *p = tq; char *p = tq;
PGresult *res; PGresult *res;
...@@ -72,84 +82,122 @@ int msqlQuery(int handle, char *query) { ...@@ -72,84 +82,122 @@ int msqlQuery(int handle, char *query) {
rcode = PQresultStatus(res); rcode = PQresultStatus(res);
if (rcode == PGRES_TUPLES_OK) { if (rcode == PGRES_TUPLES_OK)
{
queryres = res; queryres = res;
return PQntuples(res); return PQntuples(res);
} else if (rcode == PGRES_FATAL_ERROR || rcode == PGRES_NONFATAL_ERROR) { }
else if (rcode == PGRES_FATAL_ERROR || rcode == PGRES_NONFATAL_ERROR)
{
PQclear(res); PQclear(res);
queryres = NULL; queryres = NULL;
return -1; return -1;
} else { }
else
{
PQclear(res); PQclear(res);
queryres = NULL; queryres = NULL;
return 0; return 0;
} }
} }
int msqlCreateDB (int a, char*b) { int
msqlCreateDB(int a, char *b)
{
char tbuf[BUFSIZ]; char tbuf[BUFSIZ];
sprintf(tbuf, "create database %s", b); sprintf(tbuf, "create database %s", b);
return msqlQuery(a, tbuf) >= 0 ? 0 : -1; return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
} }
int msqlDropDB (int a, char* b) { int
msqlDropDB(int a, char *b)
{
char tbuf[BUFSIZ]; char tbuf[BUFSIZ];
sprintf(tbuf, "drop database %s", b); sprintf(tbuf, "drop database %s", b);
return msqlQuery(a, tbuf) >= 0 ? 0 : -1; return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
} }
int msqlShutdown(int a) { int
msqlShutdown(int a)
{
} }
int msqlGetProtoInfo(void) { int
msqlGetProtoInfo(void)
{
} }
int msqlReloadAcls(int a) { int
msqlReloadAcls(int a)
{
} }
char *msqlGetServerInfo(void) { char *
msqlGetServerInfo(void)
{
} }
char *msqlGetHostInfo(void) { char *
msqlGetHostInfo(void)
{
} }
char *msqlUnixTimeToDate(time_t date) { char *
msqlUnixTimeToDate(time_t date)
{
} }
char *msqlUnixTimeToTime(time_t time) { char *
msqlUnixTimeToTime(time_t time)
{
} }
void msqlClose(int a) { void
msqlClose(int a)
{
PQfinish(PGh[a]); PQfinish(PGh[a]);
PGh[a] = NULL; PGh[a] = NULL;
if (queryres) { if (queryres)
{
free(queryres); free(queryres);
queryres = NULL; queryres = NULL;
} }
} }
void msqlDataSeek(m_result *result, int count) { void
msqlDataSeek(m_result * result, int count)
{
int c; int c;
result->cursor = result->queryData; result->cursor = result->queryData;
for (c = 1; c < count; c++) for (c = 1; c < count; c++)
if (result->cursor->next) if (result->cursor->next)
result->cursor = result->cursor->next; result->cursor = result->cursor->next;
} }
void msqlFieldSeek(m_result *result, int count) { void
msqlFieldSeek(m_result * result, int count)
{
int c; int c;
result->fieldCursor = result->fieldData; result->fieldCursor = result->fieldData;
for (c = 1; c < count; c++) for (c = 1; c < count; c++)
if (result->fieldCursor->next) if (result->fieldCursor->next)
result->fieldCursor = result->fieldCursor->next; result->fieldCursor = result->fieldCursor->next;
} }
void msqlFreeResult(m_result *result) { void
if (result) { msqlFreeResult(m_result * result)
{
if (result)
{
/* Clears fields */ /* Clears fields */
free(result->fieldData); free(result->fieldData);
result->cursor = result->queryData; result->cursor = result->queryData;
while (result->cursor) { while (result->cursor)
{
int c; int c;
m_row m = result->cursor->data; m_row m = result->cursor->data;
...@@ -163,113 +211,155 @@ void msqlFreeResult(m_result *result) { ...@@ -163,113 +211,155 @@ void msqlFreeResult(m_result *result) {
} }
} }
m_row msqlFetchRow(m_result *row) { m_row
msqlFetchRow(m_result * row)
{
m_data *r = row->cursor; m_data *r = row->cursor;
if (r) {
if (r)
{
row->cursor = row->cursor->next; row->cursor = row->cursor->next;
return (m_row)r->data; return (m_row) r->data;
} }
return (m_row)NULL; return (m_row) NULL;
} }
m_seq *msqlGetSequenceInfo(int a, char *b) { m_seq *
msqlGetSequenceInfo(int a, char *b)
{
} }
m_field *msqlFetchField (m_result *mr) { m_field *
m_field *m = (m_field*)mr->fieldCursor; msqlFetchField(m_result * mr)
if (m) { {
m_field *m = (m_field *) mr->fieldCursor;
if (m)
{
mr->fieldCursor = mr->fieldCursor->next; mr->fieldCursor = mr->fieldCursor->next;
return m; return m;
} }
return NULL; return NULL;
} }
m_result *msqlListDBs(int a) { m_result *
msqlListDBs(int a)
{
m_result *m; m_result *m;
if (msqlQuery(a, "select datname from pg_database") > 0) {
if (msqlQuery(a, "select datname from pg_database") > 0)
{
m = msqlStoreResult(); m = msqlStoreResult();
return m; return m;
} else return NULL; }
else
return NULL;
} }
m_result *msqlListTables(int a) { m_result *
msqlListTables(int a)
{
m_result *m; m_result *m;
char tbuf[BUFSIZ]; char tbuf[BUFSIZ];
sprintf(tbuf, "select relname from pg_class where relkind='r' and relowner=%d", getuid()); sprintf(tbuf, "select relname from pg_class where relkind='r' and relowner=%d", getuid());
if (msqlQuery(a, tbuf) > 0) { if (msqlQuery(a, tbuf) > 0)
{
m = msqlStoreResult(); m = msqlStoreResult();
return m; return m;
} else return NULL; }
else
return NULL;
} }
m_result *msqlListFields(int a, char *b) { m_result *
msqlListFields(int a, char *b)
{
} }
m_result *msqlListIndex(int a, char *b, char *c) { m_result *
msqlListIndex(int a, char *b, char *c)
{
m_result *m; m_result *m;
char tbuf[BUFSIZ]; char tbuf[BUFSIZ];
sprintf(tbuf, "select relname from pg_class where relkind='i' and relowner=%d", getuid()); sprintf(tbuf, "select relname from pg_class where relkind='i' and relowner=%d", getuid());
if (msqlQuery(a, tbuf) > 0) { if (msqlQuery(a, tbuf) > 0)
{
m = msqlStoreResult(); m = msqlStoreResult();
return m; return m;
} else return NULL; }
else
return NULL;
} }
m_result *msqlStoreResult(void) { m_result *
if (queryres) { msqlStoreResult(void)
{
if (queryres)
{
m_result *mr = malloc(sizeof(m_result)); m_result *mr = malloc(sizeof(m_result));
m_fdata *mf; m_fdata *mf;
m_data *md; m_data *md;
int count; int count;
mr->queryData = mr->cursor = NULL; mr->queryData = mr->cursor = NULL;
mr->numRows = PQntuples(queryres); mr->numRows = PQntuples(queryres);
mr->numFields = PQnfields(queryres); mr->numFields = PQnfields(queryres);
mf = calloc(PQnfields(queryres), sizeof(m_fdata)); mf = calloc(PQnfields(queryres), sizeof(m_fdata));
for (count = 0; count < PQnfields(queryres); count++) { for (count = 0; count < PQnfields(queryres); count++)
(m_fdata*)(mf+count)->field.name = strdup(PQfname(queryres, count)); {
(m_fdata*)(mf+count)->field.table = tfrom; (m_fdata *) (mf + count)->field.name = strdup(PQfname(queryres, count));
(m_fdata*)(mf+count)->field.type = CHAR_TYPE; (m_fdata *) (mf + count)->field.table = tfrom;
(m_fdata*)(mf+count)->field.length = PQfsize(queryres, count); (m_fdata *) (mf + count)->field.type = CHAR_TYPE;
(m_fdata*)(mf+count)->next = (m_fdata*)(mf+count+1); (m_fdata *) (mf + count)->field.length = PQfsize(queryres, count);
(m_fdata *) (mf + count)->next = (m_fdata *) (mf + count + 1);
} }
(m_fdata*)(mf+count-1)->next = NULL; (m_fdata *) (mf + count - 1)->next = NULL;
md = calloc(PQntuples(queryres), sizeof(m_data)); md = calloc(PQntuples(queryres), sizeof(m_data));
for (count = 0; count < PQntuples(queryres); count++) { for (count = 0; count < PQntuples(queryres); count++)
m_row rows = calloc(PQnfields(queryres)*sizeof(m_row)+1, 1); {
m_row rows = calloc(PQnfields(queryres) * sizeof(m_row) + 1, 1);
int c; int c;
for (c = 0; c < PQnfields(queryres); c++) { for (c = 0; c < PQnfields(queryres); c++)
rows[c] = strdup(PQgetvalue(queryres, count, c)); rows[c] = strdup(PQgetvalue(queryres, count, c));
} (m_data *) (md + count)->data = rows;
(m_data*)(md+count)->data = rows;
(m_data*)(md+count)->width = PQnfields(queryres); (m_data *) (md + count)->width = PQnfields(queryres);
(m_data*)(md+count)->next = (m_data*)(md+count+1); (m_data *) (md + count)->next = (m_data *) (md + count + 1);
} }
(m_data*)(md+count-1)->next = NULL; (m_data *) (md + count - 1)->next = NULL;
mr->queryData = mr->cursor = md; mr->queryData = mr->cursor = md;
mr->fieldCursor = mr->fieldData = mf; mr->fieldCursor = mr->fieldData = mf;
return mr; return mr;
} else return NULL; }
else
return NULL;
} }
time_t msqlDateToUnixTime(char *a) { time_t
msqlDateToUnixTime(char *a)
{
} }
time_t msqlTimeToUnixTime(char *b) { time_t
msqlTimeToUnixTime(char *b)
{
} }
char *msql_tmpnam(void) { char *
msql_tmpnam(void)
{
return tmpnam("/tmp/msql.XXXXXX"); return tmpnam("/tmp/msql.XXXXXX");
} }
int msqlLoadConfigFile(char *a) { int
msqlLoadConfigFile(char *a)
{
} }
...@@ -23,6 +23,7 @@ extern int assertTest(int val); ...@@ -23,6 +23,7 @@ extern int assertTest(int val);
#ifdef ASSERT_CHECKING_TEST #ifdef ASSERT_CHECKING_TEST
extern int assertEnable(int val); extern int assertEnable(int val);
#endif #endif
int int
...@@ -68,6 +69,7 @@ assert_test(int val) ...@@ -68,6 +69,7 @@ assert_test(int val)
{ {
return assertTest(val); return assertTest(val);
} }
#endif #endif
/* end of file */ /* end of file */
......
...@@ -7,8 +7,10 @@ int unlisten(char *relname); ...@@ -7,8 +7,10 @@ int unlisten(char *relname);
int max(int x, int y); int max(int x, int y);
int min(int x, int y); int min(int x, int y);
int assert_enable(int val); int assert_enable(int val);
#ifdef ASSERT_CHECKING_TEST #ifdef ASSERT_CHECKING_TEST
int assert_test(int val); int assert_test(int val);
#endif #endif
#endif #endif
......
...@@ -99,7 +99,7 @@ noup() ...@@ -99,7 +99,7 @@ noup()
if (!isnull) if (!isnull)
{ {
elog(WARN, "%s: update not allowed", args[i] ); elog(WARN, "%s: update not allowed", args[i]);
SPI_finish(); SPI_finish();
return NULL; return NULL;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: c.h,v 1.1 1998/10/31 04:10:53 scrappy Exp $ * $Id: c.h,v 1.2 1999/05/25 16:06:01 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#ifndef __cplusplus #ifndef __cplusplus
#ifndef bool #ifndef bool
typedef char bool; typedef char bool;
#endif /* ndef bool */ #endif /* ndef bool */
#endif /* not C++ */ #endif /* not C++ */
typedef bool *BoolPtr; typedef bool *BoolPtr;
......
#ifndef TCPIPV4 #ifndef TCPIPV4
# define TCPIPV4 #define TCPIPV4
#endif #endif /* */
#ifndef MAXSOCKETS #ifndef MAXSOCKETS
#define MAXSOCKETS 2048 #define MAXSOCKETS 2048
#endif #endif /* */
/* /*
* DEF_PGPORT is the TCP port number on which the Postmaster listens by * DEF_PGPORT is the TCP port number on which the Postmaster listens by
......
...@@ -206,7 +206,8 @@ on_error_continue() ...@@ -206,7 +206,8 @@ on_error_continue()
** get_result ** get_result
** **
*/ */
PGresult *get_result() PGresult *
get_result()
{ {
char *cmdstatus = PQcmdStatus(res); char *cmdstatus = PQcmdStatus(res);
...@@ -214,7 +215,7 @@ PGresult *get_result() ...@@ -214,7 +215,7 @@ PGresult *get_result()
/* we have to store the fetch location somewhere */ /* we have to store the fetch location somewhere */
cmdstatus[0] = NUL; cmdstatus[0] = NUL;
memcpy(&cmdstatus[1],&tuple, sizeof(tuple)); memcpy(&cmdstatus[1], &tuple, sizeof(tuple));
return res; return res;
} }
...@@ -224,7 +225,8 @@ PGresult *get_result() ...@@ -224,7 +225,8 @@ PGresult *get_result()
** set_result ** set_result
** **
*/ */
void set_result(PGresult *newres) void
set_result(PGresult *newres)
{ {
char *cmdstatus = PQcmdStatus(res); char *cmdstatus = PQcmdStatus(res);
...@@ -256,7 +258,8 @@ void set_result(PGresult *newres) ...@@ -256,7 +258,8 @@ void set_result(PGresult *newres)
** unset_result ** unset_result
** **
*/ */
void unset_result(PGresult *oldres) void
unset_result(PGresult *oldres)
{ {
char *cmdstatus = PQcmdStatus(oldres); char *cmdstatus = PQcmdStatus(oldres);
...@@ -277,8 +280,8 @@ void unset_result(PGresult *oldres) ...@@ -277,8 +280,8 @@ void unset_result(PGresult *oldres)
** reset_fetch ** reset_fetch
** **
*/ */
void reset_fetch() void
reset_fetch()
{ {
tuple = 0; tuple = 0;
} }
...@@ -17,7 +17,8 @@ OH, me, I'm Terry Mackintosh <terry@terrym.com> ...@@ -17,7 +17,8 @@ OH, me, I'm Terry Mackintosh <terry@terrym.com>
HeapTuple moddatetime(void); HeapTuple moddatetime(void);
HeapTuple moddatetime() HeapTuple
moddatetime()
{ {
Trigger *trigger; /* to get trigger name */ Trigger *trigger; /* to get trigger name */
int nargs; /* # of arguments */ int nargs; /* # of arguments */
...@@ -65,24 +66,27 @@ HeapTuple moddatetime() ...@@ -65,24 +66,27 @@ HeapTuple moddatetime()
/* Get the current datetime. */ /* Get the current datetime. */
newdt = datetime_in("now"); newdt = datetime_in("now");
/* This gets the position in the turple of the field we want. /*
args[0] being the name of the field to update, as passed in * This gets the position in the turple of the field we want. args[0]
from the trigger. * being the name of the field to update, as passed in from the
* trigger.
*/ */
attnum = SPI_fnumber(tupdesc, args[0]); attnum = SPI_fnumber(tupdesc, args[0]);
/* This is were we check to see if the feild we are suppost to update even /*
exits. The above function must return -1 if name not found? * This is were we check to see if the feild we are suppost to update
* even exits. The above function must return -1 if name not found?
*/ */
if (attnum < 0) if (attnum < 0)
elog(ERROR, "moddatetime (%s): there is no attribute %s", relname, elog(ERROR, "moddatetime (%s): there is no attribute %s", relname,
args[0]); args[0]);
/* OK, this is where we make sure the datetime field that we are /*
modifying is really a datetime field. * OK, this is where we make sure the datetime field that we are
Hay, error checking, what a novel idea !-) * modifying is really a datetime field. Hay, error checking, what a
* novel idea !-)
*/ */
if (SPI_gettypeid(tupdesc, attnum) != DATETIMEOID ) if (SPI_gettypeid(tupdesc, attnum) != DATETIMEOID)
elog(ERROR, "moddatetime (%s): attribute %s must be of DATETIME type", elog(ERROR, "moddatetime (%s): attribute %s must be of DATETIME type",
relname, args[0]); relname, args[0]);
......
#include <stdio.h> #include <stdio.h>
char *strtoupper(char *string) char *
strtoupper(char *string)
{ {
int i ; int i;
for (i=0;i<strlen(string);i++)
{ for (i = 0; i < strlen(string); i++)
string[i]=toupper(string[i]); string[i] = toupper(string[i]);
}
return string; return string;
} }
void main ( char argc , char **argv ) void
main(char argc, char **argv)
{ {
char str[250]; char str[250];
int sw = 0 ; int sw = 0;
while ( fgets (str,240,stdin) )
while (fgets(str, 240, stdin))
{ {
if ( sw == 0 ) printf("%s",strtoupper(str)); if (sw == 0)
printf("%s", strtoupper(str));
} }
} }
...@@ -61,7 +61,7 @@ check_primary_key() ...@@ -61,7 +61,7 @@ check_primary_key()
* Some checks first... * Some checks first...
*/ */
#ifdef DEBUG_QUERY #ifdef DEBUG_QUERY
elog(NOTICE,"Check_primary_key Enter Function"); elog(NOTICE, "Check_primary_key Enter Function");
#endif #endif
/* Called by trigger manager ? */ /* Called by trigger manager ? */
if (!CurrentTriggerData) if (!CurrentTriggerData)
...@@ -228,7 +228,7 @@ check_foreign_key() ...@@ -228,7 +228,7 @@ check_foreign_key()
Trigger *trigger; /* to get trigger name */ Trigger *trigger; /* to get trigger name */
int nargs; /* # of args specified in CREATE TRIGGER */ int nargs; /* # of args specified in CREATE TRIGGER */
char **args; /* arguments: as described above */ char **args; /* arguments: as described above */
char **args_temp ; char **args_temp;
int nrefs; /* number of references (== # of plans) */ int nrefs; /* number of references (== # of plans) */
char action; /* 'R'estrict | 'S'etnull | 'C'ascade */ char action; /* 'R'estrict | 'S'etnull | 'C'ascade */
int nkeys; /* # of key columns */ int nkeys; /* # of key columns */
...@@ -244,13 +244,15 @@ check_foreign_key() ...@@ -244,13 +244,15 @@ check_foreign_key()
bool isequal = true; /* are keys in both tuples equal (in bool isequal = true; /* are keys in both tuples equal (in
* UPDATE) */ * UPDATE) */
char ident[2 * NAMEDATALEN]; /* to identify myself */ char ident[2 * NAMEDATALEN]; /* to identify myself */
int is_update=0; int is_update = 0;
int ret; int ret;
int i, int i,
r; r;
#ifdef DEBUG_QUERY #ifdef DEBUG_QUERY
elog(NOTICE,"Check_foreign_key Enter Function"); elog(NOTICE, "Check_foreign_key Enter Function");
#endif #endif
/* /*
* Some checks first... * Some checks first...
*/ */
...@@ -275,11 +277,11 @@ check_foreign_key() ...@@ -275,11 +277,11 @@ check_foreign_key()
* key in tg_newtuple is the same as in tg_trigtuple then nothing to * key in tg_newtuple is the same as in tg_trigtuple then nothing to
* do. * do.
*/ */
is_update=0; is_update = 0;
if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
{ {
newtuple = CurrentTriggerData->tg_newtuple; newtuple = CurrentTriggerData->tg_newtuple;
is_update=1; is_update = 1;
} }
trigger = CurrentTriggerData->tg_trigger; trigger = CurrentTriggerData->tg_trigger;
nargs = trigger->tgnargs; nargs = trigger->tgnargs;
...@@ -397,13 +399,14 @@ check_foreign_key() ...@@ -397,13 +399,14 @@ check_foreign_key()
{ {
void *pplan; void *pplan;
char sql[8192]; char sql[8192];
char **args2 = args ; char **args2 = args;
plan->splan = (void **) malloc(nrefs * sizeof(void *)); plan->splan = (void **) malloc(nrefs * sizeof(void *));
for (r = 0; r < nrefs; r++) for (r = 0; r < nrefs; r++)
{ {
relname = args2[0]; relname = args2[0];
/* /*
* For 'R'estrict action we construct SELECT query - SELECT 1 * For 'R'estrict action we construct SELECT query - SELECT 1
* FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 = * FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 =
...@@ -418,49 +421,58 @@ check_foreign_key() ...@@ -418,49 +421,58 @@ check_foreign_key()
* FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 = * FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 =
* $2 [...]] - to delete all referencing tuples. * $2 [...]] - to delete all referencing tuples.
*/ */
/*Max : Cascade with UPDATE query i create update query that
updates new key values in referenced tables /*
* Max : Cascade with UPDATE query i create update query that
* updates new key values in referenced tables
*/ */
else if (action == 'c'){ else if (action == 'c')
{
if (is_update == 1) if (is_update == 1)
{ {
int fn; int fn;
char *nv; char *nv;
int k ; int k;
sprintf(sql, "update %s set ", relname); sprintf(sql, "update %s set ", relname);
for (k = 1; k <= nkeys; k++) for (k = 1; k <= nkeys; k++)
{ {
int is_char_type =0; int is_char_type = 0;
char *type; char *type;
fn = SPI_fnumber(tupdesc, args_temp[k-1]); fn = SPI_fnumber(tupdesc, args_temp[k - 1]);
nv = SPI_getvalue(newtuple, tupdesc, fn); nv = SPI_getvalue(newtuple, tupdesc, fn);
type=SPI_gettype(tupdesc,fn); type = SPI_gettype(tupdesc, fn);
if ( (strcmp(type,"text") && strcmp (type,"varchar") && if ((strcmp(type, "text") && strcmp(type, "varchar") &&
strcmp(type,"char") && strcmp (type,"bpchar") && strcmp(type, "char") && strcmp(type, "bpchar") &&
strcmp(type,"date") && strcmp (type,"datetime")) == 0 ) strcmp(type, "date") && strcmp(type, "datetime")) == 0)
is_char_type=1; is_char_type = 1;
#ifdef DEBUG_QUERY #ifdef DEBUG_QUERY
elog(NOTICE,"Check_foreign_key Debug value %s type %s %d", elog(NOTICE, "Check_foreign_key Debug value %s type %s %d",
nv,type,is_char_type); nv, type, is_char_type);
#endif #endif
/* is_char_type =1 i set ' ' for define a new value
/*
* is_char_type =1 i set ' ' for define a new
* value
*/ */
sprintf(sql + strlen(sql), " %s = %s%s%s %s ", sprintf(sql + strlen(sql), " %s = %s%s%s %s ",
args2[k], (is_char_type>0) ? "'" :"" , args2[k], (is_char_type > 0) ? "'" : "",
nv, (is_char_type >0) ? "'" :"",(k < nkeys) ? ", " : ""); nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : "");
is_char_type=0; is_char_type = 0;
} }
strcat(sql, " where "); strcat(sql, " where ");
} }
else /* DELETE */ else
/* DELETE */
sprintf(sql, "delete from %s where ", relname); sprintf(sql, "delete from %s where ", relname);
} }
/* /*
* For 'S'etnull action we construct UPDATE query - UPDATE * For 'S'etnull action we construct UPDATE query - UPDATE
* _referencing_relation_ SET Fkey1 null [, Fkey2 null [...]] * _referencing_relation_ SET Fkey1 null [, Fkey2 null [...]]
...@@ -505,7 +517,7 @@ check_foreign_key() ...@@ -505,7 +517,7 @@ check_foreign_key()
} }
plan->nplans = nrefs; plan->nplans = nrefs;
#ifdef DEBUG_QUERY #ifdef DEBUG_QUERY
elog(NOTICE,"Check_foreign_key Debug Query is : %s ", sql); elog(NOTICE, "Check_foreign_key Debug Query is : %s ", sql);
#endif #endif
} }
......
...@@ -352,6 +352,7 @@ c_charin(char *str) ...@@ -352,6 +352,7 @@ c_charin(char *str)
{ {
return (string_input(str, 1, 0, NULL)); return (string_input(str, 1, 0, NULL));
} }
#endif #endif
/* end of file */ /* end of file */
......
...@@ -14,6 +14,7 @@ char *c_varcharout(char *s); ...@@ -14,6 +14,7 @@ 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
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.1 1999/04/10 16:48:05 peter Exp $ * $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.2 1999/05/25 16:06:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,18 +25,20 @@ ...@@ -25,18 +25,20 @@
#define BUFSIZE 1024 #define BUFSIZE 1024
int vacuumlo(char *,int); int vacuumlo(char *, int);
/* /*
* This vacuums a database. It returns 1 on success, -1 on failure. * This vacuums a database. It returns 1 on success, -1 on failure.
*/ */
int vacuumlo(char *database,int verbose) int
vacuumlo(char *database, int verbose)
{ {
PGconn *conn; PGconn *conn;
PGresult *res, *res2; PGresult *res,
*res2;
char buf[BUFSIZE]; char buf[BUFSIZE];
int matched=0; /* Number matched per scan */ int matched = 0; /* Number matched per scan */
int i; int i;
conn = PQsetdb(NULL, NULL, NULL, NULL, database); conn = PQsetdb(NULL, NULL, NULL, NULL, database);
...@@ -49,50 +51,54 @@ int vacuumlo(char *database,int verbose) ...@@ -49,50 +51,54 @@ int vacuumlo(char *database,int verbose)
return -1; return -1;
} }
if(verbose) if (verbose)
fprintf(stdout,"Connected to %s\n",database); fprintf(stdout, "Connected to %s\n", database);
/* /*
* First we create and populate the lo temp table * First we create and populate the lo temp table
*/ */
buf[0]='\0'; buf[0] = '\0';
strcat(buf,"SELECT oid AS lo "); strcat(buf, "SELECT oid AS lo ");
strcat(buf,"INTO TEMP TABLE vacuum_l "); strcat(buf, "INTO TEMP TABLE vacuum_l ");
strcat(buf,"FROM pg_class "); strcat(buf, "FROM pg_class ");
strcat(buf,"WHERE relkind='l'"); strcat(buf, "WHERE relkind='l'");
if(!(res = PQexec(conn,buf))) { if (!(res = PQexec(conn, buf)))
fprintf(stderr,"Failed to create temp table.\n"); {
fprintf(stderr, "Failed to create temp table.\n");
PQfinish(conn); PQfinish(conn);
return -1; return -1;
} }
PQclear(res); PQclear(res);
/* /*
* Now find any candidate tables who have columns of type oid (the column * Now find any candidate tables who have columns of type oid (the
* oid is ignored, as it has attnum < 1) * column oid is ignored, as it has attnum < 1)
*/ */
buf[0]='\0'; buf[0] = '\0';
strcat(buf,"SELECT c.relname, a.attname "); strcat(buf, "SELECT c.relname, a.attname ");
strcat(buf,"FROM pg_class c, pg_attribute a, pg_type t "); strcat(buf, "FROM pg_class c, pg_attribute a, pg_type t ");
strcat(buf,"WHERE a.attnum > 0 "); strcat(buf, "WHERE a.attnum > 0 ");
strcat(buf," AND a.attrelid = c.oid "); strcat(buf, " AND a.attrelid = c.oid ");
strcat(buf," AND a.atttypid = t.oid "); strcat(buf, " AND a.atttypid = t.oid ");
strcat(buf," AND t.typname = 'oid' "); strcat(buf, " AND t.typname = 'oid' ");
strcat(buf," AND c.relname NOT LIKE 'pg_%'"); strcat(buf, " AND c.relname NOT LIKE 'pg_%'");
if(!(res = PQexec(conn,buf))) { if (!(res = PQexec(conn, buf)))
fprintf(stderr,"Failed to create temp table.\n"); {
fprintf(stderr, "Failed to create temp table.\n");
PQfinish(conn); PQfinish(conn);
return -1; return -1;
} }
for(i=0;i<PQntuples(res);i++) for (i = 0; i < PQntuples(res); i++)
{ {
char *table,*field; char *table,
*field;
table = PQgetvalue(res,i,0); table = PQgetvalue(res, i, 0);
field = PQgetvalue(res,i,1); field = PQgetvalue(res, i, 1);
if(verbose) { if (verbose)
fprintf(stdout,"Checking %s in %s: ",field,table); {
fprintf(stdout, "Checking %s in %s: ", field, table);
fflush(stdout); fflush(stdout);
} }
...@@ -100,23 +106,25 @@ int vacuumlo(char *database,int verbose) ...@@ -100,23 +106,25 @@ int vacuumlo(char *database,int verbose)
PQclear(res2); PQclear(res2);
buf[0] = '\0'; buf[0] = '\0';
strcat(buf,"DELETE FROM vacuum_l "); strcat(buf, "DELETE FROM vacuum_l ");
strcat(buf,"WHERE lo IN ("); strcat(buf, "WHERE lo IN (");
strcat(buf,"SELECT "); strcat(buf, "SELECT ");
strcat(buf,field); strcat(buf, field);
strcat(buf," FROM "); strcat(buf, " FROM ");
strcat(buf,table); strcat(buf, table);
strcat(buf,");"); strcat(buf, ");");
if(!(res2 = PQexec(conn,buf))) { if (!(res2 = PQexec(conn, buf)))
fprintf(stderr,"Failed to check %s in table %s\n",field,table); {
fprintf(stderr, "Failed to check %s in table %s\n", field, table);
PQclear(res); PQclear(res);
PQfinish(conn); PQfinish(conn);
return -1; return -1;
} }
if(PQresultStatus(res2)!=PGRES_COMMAND_OK) { if (PQresultStatus(res2) != PGRES_COMMAND_OK)
{
fprintf(stderr, fprintf(stderr,
"Failed to check %s in table %s\n%s\n", "Failed to check %s in table %s\n%s\n",
field,table, field, table,
PQerrorMessage(conn) PQerrorMessage(conn)
); );
PQclear(res2); PQclear(res2);
...@@ -139,27 +147,28 @@ int vacuumlo(char *database,int verbose) ...@@ -139,27 +147,28 @@ int vacuumlo(char *database,int verbose)
/* /*
* Finally, those entries remaining in vacuum_l are orphans. * Finally, those entries remaining in vacuum_l are orphans.
*/ */
buf[0]='\0'; buf[0] = '\0';
strcat(buf,"SELECT lo "); strcat(buf, "SELECT lo ");
strcat(buf,"FROM vacuum_l"); strcat(buf, "FROM vacuum_l");
if(!(res = PQexec(conn,buf))) { if (!(res = PQexec(conn, buf)))
fprintf(stderr,"Failed to read temp table.\n"); {
fprintf(stderr, "Failed to read temp table.\n");
PQfinish(conn); PQfinish(conn);
return -1; return -1;
} }
matched=PQntuples(res); matched = PQntuples(res);
for(i=0;i<matched;i++) for (i = 0; i < matched; i++)
{ {
Oid lo = (Oid) atoi(PQgetvalue(res,i,0)); Oid lo = (Oid) atoi(PQgetvalue(res, i, 0));
if(verbose) { if (verbose)
fprintf(stdout,"\rRemoving lo %6d \n",lo); {
fprintf(stdout, "\rRemoving lo %6d \n", lo);
fflush(stdout); fflush(stdout);
} }
if(lo_unlink(conn,lo)<0) { if (lo_unlink(conn, lo) < 0)
fprintf(stderr,"Failed to remove lo %d\n",lo); fprintf(stderr, "Failed to remove lo %d\n", lo);
}
} }
PQclear(res); PQclear(res);
...@@ -170,8 +179,8 @@ int vacuumlo(char *database,int verbose) ...@@ -170,8 +179,8 @@ int vacuumlo(char *database,int verbose)
PQclear(res); PQclear(res);
PQfinish(conn); PQfinish(conn);
if(verbose) if (verbose)
fprintf(stdout,"\rRemoved %d large objects from %s.\n",matched,database); fprintf(stdout, "\rRemoved %d large objects from %s.\n", matched, database);
return 0; return 0;
} }
...@@ -181,7 +190,7 @@ main(int argc, char **argv) ...@@ -181,7 +190,7 @@ main(int argc, char **argv)
{ {
int verbose = 0; int verbose = 0;
int arg; int arg;
int rc=0; int rc = 0;
if (argc < 2) if (argc < 2)
{ {
...@@ -190,11 +199,12 @@ main(int argc, char **argv) ...@@ -190,11 +199,12 @@ main(int argc, char **argv)
exit(1); exit(1);
} }
for(arg=1;arg<argc;arg++) { for (arg = 1; arg < argc; arg++)
if(strcmp("-v",argv[arg])==0) {
verbose=!verbose; if (strcmp("-v", argv[arg]) == 0)
verbose = !verbose;
else else
rc += vacuumlo(argv[arg],verbose); rc += vacuumlo(argv[arg], verbose);
} }
return rc; return rc;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.50 1999/03/14 20:17:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.51 1999/05/25 16:06:35 momjian Exp $
* *
* NOTES * NOTES
* The old interface functions have been converted to macros * The old interface functions have been converted to macros
...@@ -124,7 +124,7 @@ DataFill(char *data, ...@@ -124,7 +124,7 @@ DataFill(char *data,
*bitP |= bitmask; *bitP |= bitmask;
} }
data = (char *)att_align((long)data, att[i]->attlen, att[i]->attalign); data = (char *) att_align((long) data, att[i]->attlen, att[i]->attalign);
switch (att[i]->attlen) switch (att[i]->attlen)
{ {
case -1: case -1:
...@@ -151,7 +151,7 @@ DataFill(char *data, ...@@ -151,7 +151,7 @@ DataFill(char *data,
att[i]->attlen); att[i]->attlen);
break; break;
} }
data = (char *)att_addlength((long)data, att[i]->attlen, value[i]); data = (char *) att_addlength((long) data, att[i]->attlen, value[i]);
} }
} }
...@@ -301,6 +301,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum) ...@@ -301,6 +301,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
} }
return (Datum) NULL; return (Datum) NULL;
} }
#endif #endif
/* ---------------- /* ----------------
...@@ -376,6 +377,7 @@ nocachegetattr(HeapTuple tuple, ...@@ -376,6 +377,7 @@ nocachegetattr(HeapTuple tuple,
} }
else else
{ {
/* /*
* there's a null somewhere in the tuple * there's a null somewhere in the tuple
*/ */
...@@ -404,12 +406,13 @@ nocachegetattr(HeapTuple tuple, ...@@ -404,12 +406,13 @@ nocachegetattr(HeapTuple tuple,
int finalbit = attnum & 0x07; int finalbit = attnum & 0x07;
/* check for nulls "before" final bit of last byte */ /* check for nulls "before" final bit of last byte */
if ((~ bp[byte]) & ((1 << finalbit) - 1)) if ((~bp[byte]) & ((1 << finalbit) - 1))
slow = 1; slow = 1;
else else
{ {
/* check for nulls in any "earlier" bytes */ /* check for nulls in any "earlier" bytes */
int i; int i;
for (i = 0; i < byte; i++) for (i = 0; i < byte; i++)
{ {
if (bp[i] != 0xFF) if (bp[i] != 0xFF)
...@@ -439,6 +442,7 @@ nocachegetattr(HeapTuple tuple, ...@@ -439,6 +442,7 @@ nocachegetattr(HeapTuple tuple,
else if (!HeapTupleAllFixed(tuple)) else if (!HeapTupleAllFixed(tuple))
{ {
int j; int j;
/* /*
* In for(), we make this <= and not < because we want to test * In for(), we make this <= and not < because we want to test
* if we can go past it in initializing offsets. * if we can go past it in initializing offsets.
...@@ -456,9 +460,9 @@ nocachegetattr(HeapTuple tuple, ...@@ -456,9 +460,9 @@ nocachegetattr(HeapTuple tuple,
/* /*
* If slow is zero, and we got here, we know that we have a tuple with * If slow is zero, and we got here, we know that we have a tuple with
* no nulls or varlenas before the target attribute. * no nulls or varlenas before the target attribute. If possible, we
* If possible, we also want to initialize the remainder of the * also want to initialize the remainder of the attribute cached
* attribute cached offset values. * offset values.
*/ */
if (!slow) if (!slow)
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.45 1999/05/10 00:44:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.46 1999/05/25 16:06:39 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "libpq/pqformat.h" #include "libpq/pqformat.h"
#include "utils/syscache.h" #include "utils/syscache.h"
static void printtup_setup(DestReceiver* self, TupleDesc typeinfo); static void printtup_setup(DestReceiver * self, TupleDesc typeinfo);
static void printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self); static void printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self);
static void printtup_cleanup(DestReceiver* self); static void printtup_cleanup(DestReceiver * self);
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* printtup / debugtup support * printtup / debugtup support
...@@ -43,7 +43,7 @@ static void printtup_cleanup(DestReceiver* self); ...@@ -43,7 +43,7 @@ static void printtup_cleanup(DestReceiver* self);
* ---------------- * ----------------
*/ */
int int
getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem) getTypeOutAndElem(Oid type, Oid *typOutput, Oid *typElem)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
...@@ -54,6 +54,7 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem) ...@@ -54,6 +54,7 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem)
if (HeapTupleIsValid(typeTuple)) if (HeapTupleIsValid(typeTuple))
{ {
Form_pg_type pt = (Form_pg_type) GETSTRUCT(typeTuple); Form_pg_type pt = (Form_pg_type) GETSTRUCT(typeTuple);
*typOutput = (Oid) pt->typoutput; *typOutput = (Oid) pt->typoutput;
*typElem = (Oid) pt->typelem; *typElem = (Oid) pt->typelem;
return OidIsValid(*typOutput); return OidIsValid(*typOutput);
...@@ -70,13 +71,15 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem) ...@@ -70,13 +71,15 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem)
* Private state for a printtup destination object * Private state for a printtup destination object
* ---------------- * ----------------
*/ */
typedef struct { /* Per-attribute information */ typedef struct
{ /* Per-attribute information */
Oid typoutput; /* Oid for the attribute's type output fn */ Oid typoutput; /* Oid for the attribute's type output fn */
Oid typelem; /* typelem value to pass to the output fn */ Oid typelem; /* typelem value to pass to the output fn */
FmgrInfo finfo; /* Precomputed call info for typoutput */ FmgrInfo finfo; /* Precomputed call info for typoutput */
} PrinttupAttrInfo; } PrinttupAttrInfo;
typedef struct { typedef struct
{
DestReceiver pub; /* publicly-known function pointers */ DestReceiver pub; /* publicly-known function pointers */
TupleDesc attrinfo; /* The attr info we are set up for */ TupleDesc attrinfo; /* The attr info we are set up for */
int nattrs; int nattrs;
...@@ -87,10 +90,10 @@ typedef struct { ...@@ -87,10 +90,10 @@ typedef struct {
* Initialize: create a DestReceiver for printtup * Initialize: create a DestReceiver for printtup
* ---------------- * ----------------
*/ */
DestReceiver* DestReceiver *
printtup_create_DR() printtup_create_DR()
{ {
DR_printtup* self = (DR_printtup*) palloc(sizeof(DR_printtup)); DR_printtup *self = (DR_printtup *) palloc(sizeof(DR_printtup));
self->pub.receiveTuple = printtup; self->pub.receiveTuple = printtup;
self->pub.setup = printtup_setup; self->pub.setup = printtup_setup;
...@@ -100,11 +103,11 @@ printtup_create_DR() ...@@ -100,11 +103,11 @@ printtup_create_DR()
self->nattrs = 0; self->nattrs = 0;
self->myinfo = NULL; self->myinfo = NULL;
return (DestReceiver*) self; return (DestReceiver *) self;
} }
static void static void
printtup_setup(DestReceiver* self, TupleDesc typeinfo) printtup_setup(DestReceiver * self, TupleDesc typeinfo)
{ {
/* ---------------- /* ----------------
* We could set up the derived attr info at this time, but we postpone it * We could set up the derived attr info at this time, but we postpone it
...@@ -120,7 +123,7 @@ printtup_setup(DestReceiver* self, TupleDesc typeinfo) ...@@ -120,7 +123,7 @@ printtup_setup(DestReceiver* self, TupleDesc typeinfo)
} }
static void static void
printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs) printtup_prepare_info(DR_printtup * myState, TupleDesc typeinfo, int numAttrs)
{ {
int i; int i;
...@@ -131,11 +134,12 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs) ...@@ -131,11 +134,12 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs)
myState->nattrs = numAttrs; myState->nattrs = numAttrs;
if (numAttrs <= 0) if (numAttrs <= 0)
return; return;
myState->myinfo = (PrinttupAttrInfo*) myState->myinfo = (PrinttupAttrInfo *)
palloc(numAttrs * sizeof(PrinttupAttrInfo)); palloc(numAttrs * sizeof(PrinttupAttrInfo));
for (i = 0; i < numAttrs; i++) for (i = 0; i < numAttrs; i++)
{ {
PrinttupAttrInfo* thisState = myState->myinfo + i; PrinttupAttrInfo *thisState = myState->myinfo + i;
if (getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid, if (getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid,
&thisState->typoutput, &thisState->typelem)) &thisState->typoutput, &thisState->typelem))
fmgr_info(thisState->typoutput, &thisState->finfo); fmgr_info(thisState->typoutput, &thisState->finfo);
...@@ -147,9 +151,9 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs) ...@@ -147,9 +151,9 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs)
* ---------------- * ----------------
*/ */
static void static void
printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self)
{ {
DR_printtup *myState = (DR_printtup*) self; DR_printtup *myState = (DR_printtup *) self;
StringInfoData buf; StringInfoData buf;
int i, int i,
j, j,
...@@ -178,7 +182,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) ...@@ -178,7 +182,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
k = 1 << 7; k = 1 << 7;
for (i = 0; i < tuple->t_data->t_natts; ++i) for (i = 0; i < tuple->t_data->t_natts; ++i)
{ {
if (! heap_attisnull(tuple, i + 1)) if (!heap_attisnull(tuple, i + 1))
j |= k; /* set bit if not null */ j |= k; /* set bit if not null */
k >>= 1; k >>= 1;
if (k == 0) /* end of byte? */ if (k == 0) /* end of byte? */
...@@ -197,7 +201,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) ...@@ -197,7 +201,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
*/ */
for (i = 0; i < tuple->t_data->t_natts; ++i) for (i = 0; i < tuple->t_data->t_natts; ++i)
{ {
PrinttupAttrInfo* thisState = myState->myinfo + i; PrinttupAttrInfo *thisState = myState->myinfo + i;
attr = heap_getattr(tuple, i + 1, typeinfo, &isnull); attr = heap_getattr(tuple, i + 1, typeinfo, &isnull);
if (isnull) if (isnull)
continue; continue;
...@@ -223,9 +228,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) ...@@ -223,9 +228,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
* ---------------- * ----------------
*/ */
static void static void
printtup_cleanup(DestReceiver* self) printtup_cleanup(DestReceiver * self)
{ {
DR_printtup* myState = (DR_printtup*) self; DR_printtup *myState = (DR_printtup *) self;
if (myState->myinfo) if (myState->myinfo)
pfree(myState->myinfo); pfree(myState->myinfo);
pfree(myState); pfree(myState);
...@@ -274,7 +280,7 @@ showatts(char *name, TupleDesc tupleDesc) ...@@ -274,7 +280,7 @@ showatts(char *name, TupleDesc tupleDesc)
* ---------------- * ----------------
*/ */
void void
debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self)
{ {
int i; int i;
Datum attr; Datum attr;
...@@ -310,7 +316,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) ...@@ -310,7 +316,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
* ---------------- * ----------------
*/ */
void void
printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self)
{ {
StringInfoData buf; StringInfoData buf;
int i, int i,
...@@ -334,7 +340,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) ...@@ -334,7 +340,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
k = 1 << 7; k = 1 << 7;
for (i = 0; i < tuple->t_data->t_natts; ++i) for (i = 0; i < tuple->t_data->t_natts; ++i)
{ {
if (! heap_attisnull(tuple, i + 1)) if (!heap_attisnull(tuple, i + 1))
j |= k; /* set bit if not null */ j |= k; /* set bit if not null */
k >>= 1; k >>= 1;
if (k == 0) /* end of byte? */ if (k == 0) /* end of byte? */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.13 1999/02/13 23:14:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.14 1999/05/25 16:06:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.48 1999/02/13 23:14:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.49 1999/05/25 16:06:42 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
......
...@@ -344,7 +344,7 @@ gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation ...@@ -344,7 +344,7 @@ gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
/* /*
* Notes in ExecUtils:ExecOpenIndices() * Notes in ExecUtils:ExecOpenIndices()
* *
RelationSetLockForWrite(r); * RelationSetLockForWrite(r);
*/ */
res = gistdoinsert(r, itup, &giststate); res = gistdoinsert(r, itup, &giststate);
...@@ -1106,10 +1106,10 @@ gistdelete(Relation r, ItemPointer tid) ...@@ -1106,10 +1106,10 @@ gistdelete(Relation r, ItemPointer tid)
Page page; Page page;
/* /*
* Notes in ExecUtils:ExecOpenIndices() * Notes in ExecUtils:ExecOpenIndices() Also note that only vacuum
* Also note that only vacuum deletes index tuples now... * deletes index tuples now...
* *
RelationSetLockForWrite(r); * RelationSetLockForWrite(r);
*/ */
blkno = ItemPointerGetBlockNumber(tid); blkno = ItemPointerGetBlockNumber(tid);
......
...@@ -68,7 +68,7 @@ gistbeginscan(Relation r, ...@@ -68,7 +68,7 @@ gistbeginscan(Relation r,
/* /*
* Let index_beginscan does its work... * Let index_beginscan does its work...
* *
RelationSetLockForRead(r); * RelationSetLockForRead(r);
*/ */
s = RelationGetIndexScan(r, fromEnd, nkeys, key); s = RelationGetIndexScan(r, fromEnd, nkeys, key);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.25 1999/02/13 23:14:17 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.26 1999/05/25 16:06:54 momjian Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
...@@ -485,7 +485,7 @@ hashrestrpos(IndexScanDesc scan) ...@@ -485,7 +485,7 @@ hashrestrpos(IndexScanDesc scan)
/* bump lock on currentMarkData and copy to currentItemData */ /* bump lock on currentMarkData and copy to currentItemData */
if (ItemPointerIsValid(&(scan->currentMarkData))) if (ItemPointerIsValid(&(scan->currentMarkData)))
{ {
so->hashso_curbuf =_hash_getbuf(scan->relation, so->hashso_curbuf = _hash_getbuf(scan->relation,
BufferGetBlockNumber(so->hashso_mrkbuf), BufferGetBlockNumber(so->hashso_mrkbuf),
HASH_READ); HASH_READ);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.16 1999/03/14 16:27:59 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.17 1999/05/25 16:06:56 momjian Exp $
* *
* NOTES * NOTES
* These functions are stored in pg_amproc. For each operator class * These functions are stored in pg_amproc. For each operator class
...@@ -34,9 +34,9 @@ hashint4(uint32 key) ...@@ -34,9 +34,9 @@ hashint4(uint32 key)
} }
uint32 uint32
hashint8(int64 *key) hashint8(int64 * key)
{ {
return ~((uint32)*key); return ~((uint32) *key);
} }
/* Hash function from Chris Torek. */ /* Hash function from Chris Torek. */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.19 1999/02/13 23:14:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.20 1999/05/25 16:06:58 momjian Exp $
* *
* NOTES * NOTES
* Postgres hash pages look like ordinary relation pages. The opaque * Postgres hash pages look like ordinary relation pages. The opaque
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.42 1999/03/28 20:31:56 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.43 1999/05/25 16:07:04 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -439,7 +439,8 @@ heapgettup(Relation relation, ...@@ -439,7 +439,8 @@ heapgettup(Relation relation,
} }
else else
{ {
++lpp; /* move forward in this page's ItemId array */ ++lpp; /* move forward in this page's ItemId
* array */
++lineoff; ++lineoff;
} }
} }
...@@ -816,6 +817,7 @@ heap_getnext(HeapScanDesc scandesc, int backw) ...@@ -816,6 +817,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
} }
else else
{ /* NONTUP */ { /* NONTUP */
/* /*
* Don't release scan->rs_cbuf at this point, because * Don't release scan->rs_cbuf at this point, because
* heapgettup doesn't increase PrivateRefCount if it is * heapgettup doesn't increase PrivateRefCount if it is
...@@ -897,6 +899,7 @@ heap_getnext(HeapScanDesc scandesc, int backw) ...@@ -897,6 +899,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
} }
else else
{ /* NONTUP */ { /* NONTUP */
/* /*
* Don't release scan->rs_cbuf at this point, because * Don't release scan->rs_cbuf at this point, because
* heapgettup doesn't increase PrivateRefCount if it is * heapgettup doesn't increase PrivateRefCount if it is
...@@ -1093,9 +1096,7 @@ heap_insert(Relation relation, HeapTuple tup) ...@@ -1093,9 +1096,7 @@ heap_insert(Relation relation, HeapTuple tup)
RelationPutHeapTupleAtEnd(relation, tup); RelationPutHeapTupleAtEnd(relation, tup);
if (IsSystemRelationName(RelationGetRelationName(relation)->data)) if (IsSystemRelationName(RelationGetRelationName(relation)->data))
{
RelationInvalidateHeapTuple(relation, tup); RelationInvalidateHeapTuple(relation, tup);
}
return tup->t_data->t_oid; return tup->t_data->t_oid;
} }
...@@ -1283,11 +1284,12 @@ l2: ...@@ -1283,11 +1284,12 @@ l2:
RelationPutHeapTuple(relation, buffer, newtup); RelationPutHeapTuple(relation, buffer, newtup);
else else
{ {
/* /*
* New item won't fit on same page as old item, have to look * New item won't fit on same page as old item, have to look for a
* for a new place to put it. Note that we have to unlock * new place to put it. Note that we have to unlock current buffer
* current buffer context - not good but RelationPutHeapTupleAtEnd * context - not good but RelationPutHeapTupleAtEnd uses extend
* uses extend lock. * lock.
*/ */
LockBuffer(buffer, BUFFER_LOCK_UNLOCK); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
RelationPutHeapTupleAtEnd(relation, newtup); RelationPutHeapTupleAtEnd(relation, newtup);
...@@ -1295,8 +1297,8 @@ l2: ...@@ -1295,8 +1297,8 @@ l2:
} }
/* /*
* New item in place, now record address of new tuple in * New item in place, now record address of new tuple in t_ctid of old
* t_ctid of old one. * one.
*/ */
oldtup.t_data->t_ctid = newtup->t_self; oldtup.t_data->t_ctid = newtup->t_self;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Id: hio.c,v 1.19 1999/05/07 01:22:53 vadim Exp $ * $Id: hio.c,v 1.20 1999/05/25 16:07:07 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -68,7 +68,7 @@ RelationPutHeapTuple(Relation relation, ...@@ -68,7 +68,7 @@ RelationPutHeapTuple(Relation relation,
/* /*
* Let the caller do this! * Let the caller do this!
* *
WriteBuffer(buffer); * WriteBuffer(buffer);
*/ */
/* return an accurate tuple */ /* return an accurate tuple */
...@@ -111,8 +111,8 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) ...@@ -111,8 +111,8 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
Item item; Item item;
/* /*
* Lock relation for extention. We can use LockPage here as long as * Lock relation for extention. We can use LockPage here as long as in
* in all other places we use page-level locking for indices only. * all other places we use page-level locking for indices only.
* Alternatevely, we could define pseudo-table as we do for * Alternatevely, we could define pseudo-table as we do for
* transactions with XactLockTable. * transactions with XactLockTable.
*/ */
...@@ -132,6 +132,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) ...@@ -132,6 +132,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
{ {
buffer = ReadBuffer(relation, lastblock); buffer = ReadBuffer(relation, lastblock);
pageHeader = (Page) BufferGetPage(buffer); pageHeader = (Page) BufferGetPage(buffer);
/* /*
* There was IF instead of ASSERT here ?! * There was IF instead of ASSERT here ?!
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.16 1999/02/13 23:14:29 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.17 1999/05/25 16:07:12 momjian Exp $
* *
* NOTES * NOTES
* many of the old access method routines have been turned into * many of the old access method routines have been turned into
...@@ -270,5 +270,5 @@ IndexScanRestorePosition(IndexScanDesc scan) ...@@ -270,5 +270,5 @@ IndexScanRestorePosition(IndexScanDesc scan)
scan->flags = 0x0; /* XXX should have a symbolic name */ scan->flags = 0x0; /* XXX should have a symbolic name */
} }
#endif
#endif
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.31 1999/02/13 23:14:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.32 1999/05/25 16:07:15 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.22 1999/03/14 05:08:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.23 1999/05/25 16:07:21 momjian Exp $
* *
* NOTES * NOTES
* These functions are stored in pg_amproc. For each operator class * These functions are stored in pg_amproc. For each operator class
...@@ -40,7 +40,7 @@ btint4cmp(int32 a, int32 b) ...@@ -40,7 +40,7 @@ btint4cmp(int32 a, int32 b)
} }
int32 int32
btint8cmp(int64 *a, int64 *b) btint8cmp(int64 * a, int64 * b)
{ {
if (*a > *b) if (*a > *b)
return 1; return 1;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.39 1999/05/01 16:09:45 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.40 1999/05/25 16:07:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -122,9 +122,10 @@ l1: ...@@ -122,9 +122,10 @@ l1:
*/ */
while (_bt_isequal(itupdesc, page, offset, natts, itup_scankey)) while (_bt_isequal(itupdesc, page, offset, natts, itup_scankey))
{ /* they're equal */ { /* they're equal */
/* /*
* Have to check is inserted heap tuple deleted one * Have to check is inserted heap tuple deleted one (i.e.
* (i.e. just moved to another place by vacuum)! * just moved to another place by vacuum)!
*/ */
if (chtup) if (chtup)
{ {
...@@ -156,7 +157,7 @@ l1: ...@@ -156,7 +157,7 @@ l1:
_bt_relbuf(rel, nbuf, BT_READ); _bt_relbuf(rel, nbuf, BT_READ);
_bt_relbuf(rel, buf, BT_WRITE); _bt_relbuf(rel, buf, BT_WRITE);
XactLockTableWait(xwait); XactLockTableWait(xwait);
goto l1; /* continue from the begin */ goto l1;/* continue from the begin */
} }
elog(ERROR, "Cannot insert a duplicate key into a unique index"); elog(ERROR, "Cannot insert a duplicate key into a unique index");
} }
...@@ -571,7 +572,7 @@ _bt_insertonpg(Relation rel, ...@@ -571,7 +572,7 @@ _bt_insertonpg(Relation rel,
* reasoning). * reasoning).
*/ */
l_spl:; l_spl: ;
if (stack == (BTStack) NULL) if (stack == (BTStack) NULL)
{ {
if (!is_root) /* if this page was not root page */ if (!is_root) /* if this page was not root page */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.20 1999/04/22 08:19:59 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.21 1999/05/25 16:07:26 momjian Exp $
* *
* NOTES * NOTES
* Postgres btree pages look like ordinary relation pages. The opaque * Postgres btree pages look like ordinary relation pages. The opaque
...@@ -497,14 +497,13 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) ...@@ -497,14 +497,13 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access)
if (stack->bts_offset == InvalidOffsetNumber || if (stack->bts_offset == InvalidOffsetNumber ||
maxoff >= stack->bts_offset) maxoff >= stack->bts_offset)
{ {
/* /*
* _bt_insertonpg set bts_offset to InvalidOffsetNumber * _bt_insertonpg set bts_offset to InvalidOffsetNumber in the
* in the case of concurrent ROOT page split * case of concurrent ROOT page split
*/ */
if (stack->bts_offset == InvalidOffsetNumber) if (stack->bts_offset == InvalidOffsetNumber)
{
i = P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY; i = P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY;
}
else else
{ {
itemid = PageGetItemId(page, stack->bts_offset); itemid = PageGetItemId(page, stack->bts_offset);
...@@ -524,7 +523,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) ...@@ -524,7 +523,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access)
} }
/* if the item has just moved right on this page, we're done */ /* if the item has just moved right on this page, we're done */
for ( ; for (;
i <= maxoff; i <= maxoff;
i = OffsetNumberNext(i)) i = OffsetNumberNext(i))
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.37 1999/03/28 20:31:58 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.38 1999/05/25 16:07:27 momjian Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
...@@ -391,9 +391,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir) ...@@ -391,9 +391,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir)
if (ItemPointerIsValid(&(scan->currentItemData))) if (ItemPointerIsValid(&(scan->currentItemData)))
{ {
/* /*
* Restore scan position using heap TID returned * Restore scan position using heap TID returned by previous call
* by previous call to btgettuple(). * to btgettuple().
*/ */
_bt_restscan(scan); _bt_restscan(scan);
res = _bt_next(scan, dir); res = _bt_next(scan, dir);
...@@ -623,10 +624,9 @@ _bt_restscan(IndexScanDesc scan) ...@@ -623,10 +624,9 @@ _bt_restscan(IndexScanDesc scan)
BlockNumber blkno; BlockNumber blkno;
/* /*
* We use this as flag when first index tuple on page * We use this as flag when first index tuple on page is deleted but
* is deleted but we do not move left (this would * we do not move left (this would slowdown vacuum) - so we set
* slowdown vacuum) - so we set current->ip_posid * current->ip_posid before first index tuple on the current page
* before first index tuple on the current page
* (_bt_step will move it right)... * (_bt_step will move it right)...
*/ */
if (!ItemPointerIsValid(&target)) if (!ItemPointerIsValid(&target))
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.20 1999/03/28 20:31:58 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.21 1999/05/25 16:07:29 momjian Exp $
* *
* *
* NOTES * NOTES
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.43 1999/04/13 17:18:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.44 1999/05/25 16:07:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -706,7 +706,7 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) ...@@ -706,7 +706,7 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
so = (BTScanOpaque) scan->opaque; so = (BTScanOpaque) scan->opaque;
current = &(scan->currentItemData); current = &(scan->currentItemData);
Assert (BufferIsValid(so->btso_curbuf)); Assert(BufferIsValid(so->btso_curbuf));
/* we still have the buffer pinned and locked */ /* we still have the buffer pinned and locked */
buf = so->btso_curbuf; buf = so->btso_curbuf;
...@@ -795,14 +795,14 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ...@@ -795,14 +795,14 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
if (ScanDirectionIsBackward(dir)) if (ScanDirectionIsBackward(dir))
{ {
for (i=0; i<so->numberOfKeys; i++) for (i = 0; i < so->numberOfKeys; i++)
{ {
if (so->keyData[i].sk_attno != 1) if (so->keyData[i].sk_attno != 1)
break; break;
strat = _bt_getstrat(rel, so->keyData[i].sk_attno, strat = _bt_getstrat(rel, so->keyData[i].sk_attno,
so->keyData[i].sk_procedure); so->keyData[i].sk_procedure);
if (strat == BTLessStrategyNumber || if (strat == BTLessStrategyNumber ||
strat == BTLessEqualStrategyNumber|| strat == BTLessEqualStrategyNumber ||
strat == BTEqualStrategyNumber) strat == BTEqualStrategyNumber)
{ {
nKeyIndex = i; nKeyIndex = i;
...@@ -1104,9 +1104,10 @@ _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) ...@@ -1104,9 +1104,10 @@ _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
rel = scan->relation; rel = scan->relation;
current = &(scan->currentItemData); current = &(scan->currentItemData);
/* /*
* Don't use ItemPointerGetOffsetNumber or you risk to get * Don't use ItemPointerGetOffsetNumber or you risk to get assertion
* assertion due to ability of ip_posid to be equal 0. * due to ability of ip_posid to be equal 0.
*/ */
offnum = current->ip_posid; offnum = current->ip_posid;
page = BufferGetPage(*bufP); page = BufferGetPage(*bufP);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Id: nbtsort.c,v 1.38 1999/05/09 00:53:19 tgl Exp $ * $Id: nbtsort.c,v 1.39 1999/05/25 16:07:34 momjian Exp $
* *
* NOTES * NOTES
* *
...@@ -552,8 +552,8 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique) ...@@ -552,8 +552,8 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique)
btspool->bts_tape = 0; btspool->bts_tape = 0;
btspool->isunique = isunique; btspool->isunique = isunique;
btspool->bts_itape =(BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes); btspool->bts_itape = (BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes);
btspool->bts_otape =(BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes); btspool->bts_otape = (BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes);
if (btspool->bts_itape == (BTTapeBlock **) NULL || if (btspool->bts_itape == (BTTapeBlock **) NULL ||
btspool->bts_otape == (BTTapeBlock **) NULL) btspool->bts_otape == (BTTapeBlock **) NULL)
elog(ERROR, "_bt_spoolinit: out of memory"); elog(ERROR, "_bt_spoolinit: out of memory");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.31 1999/02/13 23:14:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.32 1999/05/25 16:07:38 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -307,7 +307,7 @@ rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation he ...@@ -307,7 +307,7 @@ rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation he
/* /*
* Notes in ExecUtils:ExecOpenIndices() * Notes in ExecUtils:ExecOpenIndices()
* *
RelationSetLockForWrite(r); * RelationSetLockForWrite(r);
*/ */
res = rtdoinsert(r, itup, &rtState); res = rtdoinsert(r, itup, &rtState);
...@@ -947,10 +947,10 @@ rtdelete(Relation r, ItemPointer tid) ...@@ -947,10 +947,10 @@ rtdelete(Relation r, ItemPointer tid)
Page page; Page page;
/* /*
* Notes in ExecUtils:ExecOpenIndices() * Notes in ExecUtils:ExecOpenIndices() Also note that only vacuum
* Also note that only vacuum deletes index tuples now... * deletes index tuples now...
* *
RelationSetLockForWrite(r); * RelationSetLockForWrite(r);
*/ */
blkno = ItemPointerGetBlockNumber(tid); blkno = ItemPointerGetBlockNumber(tid);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.22 1999/02/13 23:14:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.23 1999/05/25 16:07:40 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -69,7 +69,7 @@ rtbeginscan(Relation r, ...@@ -69,7 +69,7 @@ rtbeginscan(Relation r,
/* /*
* Let index_beginscan does its work... * Let index_beginscan does its work...
* *
RelationSetLockForRead(r); * RelationSetLockForRead(r);
*/ */
s = RelationGetIndexScan(r, fromEnd, nkeys, key); s = RelationGetIndexScan(r, fromEnd, nkeys, key);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.25 1999/03/30 01:37:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.26 1999/05/25 16:07:45 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
...@@ -221,7 +221,7 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */ ...@@ -221,7 +221,7 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */
/* /*
* update (invalidate) our single item TransactionLogTest cache. * update (invalidate) our single item TransactionLogTest cache.
* *
if (status != XID_COMMIT) * if (status != XID_COMMIT)
* *
* What's the hell ?! Why != XID_COMMIT ?! * What's the hell ?! Why != XID_COMMIT ?!
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.19 1999/02/13 23:14:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.20 1999/05/25 16:07:48 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.35 1999/05/13 00:34:57 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.36 1999/05/25 16:07:50 momjian Exp $
* *
* NOTES * NOTES
* Transaction aborts can now occur two ways: * Transaction aborts can now occur two ways:
...@@ -299,6 +299,7 @@ IsTransactionState(void) ...@@ -299,6 +299,7 @@ IsTransactionState(void)
*/ */
return false; return false;
} }
#endif #endif
/* -------------------------------- /* --------------------------------
...@@ -1509,6 +1510,7 @@ AbortOutOfAnyTransaction() ...@@ -1509,6 +1510,7 @@ AbortOutOfAnyTransaction()
*/ */
if (s->state != TRANS_DEFAULT) if (s->state != TRANS_DEFAULT)
AbortTransaction(); AbortTransaction();
/* /*
* Now reset the high-level state * Now reset the high-level state
*/ */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: xid.c,v 1.21 1999/02/13 23:14:49 momjian Exp $ * $Id: xid.c,v 1.22 1999/05/25 16:07:52 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.59 1999/05/10 00:44:52 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.60 1999/05/25 16:07:56 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -587,7 +587,9 @@ DefineAttr(char *name, char *type, int attnum) ...@@ -587,7 +587,9 @@ DefineAttr(char *name, char *type, int attnum)
printf("<%s %s> ", attrtypes[attnum]->attname.data, type); printf("<%s %s> ", attrtypes[attnum]->attname.data, type);
attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */ attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
attlen = attrtypes[attnum]->attlen = Procid[typeoid].len; attlen = attrtypes[attnum]->attlen = Procid[typeoid].len;
/* Cheat like mad to fill in these items from the length only.
/*
* Cheat like mad to fill in these items from the length only.
* This only has to work for types used in the system catalogs... * This only has to work for types used in the system catalogs...
*/ */
switch (attlen) switch (attlen)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.20 1999/02/13 23:14:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.21 1999/05/25 16:08:01 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.84 1999/05/22 04:12:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.85 1999/05/25 16:08:03 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -240,9 +240,7 @@ heap_create(char *relname, ...@@ -240,9 +240,7 @@ heap_create(char *relname,
nailme = true; nailme = true;
} }
else else
{
relid = newoid(); relid = newoid();
}
if (isnoname) if (isnoname)
{ {
...@@ -719,6 +717,7 @@ AddNewRelationTuple(Relation pg_class_desc, ...@@ -719,6 +717,7 @@ AddNewRelationTuple(Relation pg_class_desc,
if (!isBootstrap) if (!isBootstrap)
{ {
/* /*
* First, open the catalog indices and insert index tuples for the * First, open the catalog indices and insert index tuples for the
* new relation. * new relation.
...@@ -814,6 +813,7 @@ heap_create_with_catalog(char *relname, ...@@ -814,6 +813,7 @@ heap_create_with_catalog(char *relname,
if (relid != InvalidOid) if (relid != InvalidOid)
{ {
/* /*
* This is heavy-handed, but appears necessary bjm 1999/02/01 * This is heavy-handed, but appears necessary bjm 1999/02/01
* SystemCacheRelationFlushed(relid) is not enough either. * SystemCacheRelationFlushed(relid) is not enough either.
...@@ -1516,7 +1516,9 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef) ...@@ -1516,7 +1516,9 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef)
extern GlobalMemory CacheCxt; extern GlobalMemory CacheCxt;
start: start:
/* Surround table name with double quotes to allow mixed-case and
/*
* Surround table name with double quotes to allow mixed-case and
* whitespaces in names. - BGA 1998-11-14 * whitespaces in names. - BGA 1998-11-14
*/ */
snprintf(str, MAX_PARSE_BUFFER, snprintf(str, MAX_PARSE_BUFFER,
...@@ -1541,14 +1543,14 @@ start: ...@@ -1541,14 +1543,14 @@ start:
if (IS_BINARY_COMPATIBLE(type, atp->atttypid)) if (IS_BINARY_COMPATIBLE(type, atp->atttypid))
; /* use without change */ ; /* use without change */
else if (can_coerce_type(1, &(type), &(atp->atttypid))) else if (can_coerce_type(1, &(type), &(atp->atttypid)))
expr = coerce_type(NULL, (Node *)expr, type, atp->atttypid, expr = coerce_type(NULL, (Node *) expr, type, atp->atttypid,
atp->atttypmod); atp->atttypmod);
else if (IsA(expr, Const)) else if (IsA(expr, Const))
{ {
if (*cast != 0) if (*cast != 0)
elog(ERROR, "DEFAULT clause const type '%s' mismatched with column type '%s'", elog(ERROR, "DEFAULT clause const type '%s' mismatched with column type '%s'",
typeidTypeName(type), typeidTypeName(atp->atttypid)); typeidTypeName(type), typeidTypeName(atp->atttypid));
snprintf(cast, 2*NAMEDATALEN, ":: %s", typeidTypeName(atp->atttypid)); snprintf(cast, 2 * NAMEDATALEN, ":: %s", typeidTypeName(atp->atttypid));
goto start; goto start;
} }
else else
...@@ -1598,7 +1600,8 @@ StoreRelCheck(Relation rel, ConstrCheck *check) ...@@ -1598,7 +1600,8 @@ StoreRelCheck(Relation rel, ConstrCheck *check)
char nulls[4] = {' ', ' ', ' ', ' '}; char nulls[4] = {' ', ' ', ' ', ' '};
extern GlobalMemory CacheCxt; extern GlobalMemory CacheCxt;
/* Check for table's existance. Surround table name with double-quotes /*
* Check for table's existance. Surround table name with double-quotes
* to allow mixed-case and whitespace names. - thomas 1998-11-12 * to allow mixed-case and whitespace names. - thomas 1998-11-12
*/ */
snprintf(str, MAX_PARSE_BUFFER, snprintf(str, MAX_PARSE_BUFFER,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.74 1999/05/17 00:27:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.75 1999/05/25 16:08:06 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -686,7 +686,7 @@ UpdateIndexRelation(Oid indexoid, ...@@ -686,7 +686,7 @@ UpdateIndexRelation(Oid indexoid,
predLen = VARSIZE(predText); predLen = VARSIZE(predText);
itupLen = predLen + sizeof(FormData_pg_index); itupLen = predLen + sizeof(FormData_pg_index);
indexForm = (Form_pg_index) palloc(itupLen); indexForm = (Form_pg_index) palloc(itupLen);
memset (indexForm, 0, sizeof(FormData_pg_index)); memset(indexForm, 0, sizeof(FormData_pg_index));
memmove((char *) &indexForm->indpred, (char *) predText, predLen); memmove((char *) &indexForm->indpred, (char *) predText, predLen);
...@@ -991,6 +991,7 @@ index_create(char *heapRelationName, ...@@ -991,6 +991,7 @@ index_create(char *heapRelationName,
if (relid != InvalidOid) if (relid != InvalidOid)
{ {
/* /*
* This is heavy-handed, but appears necessary bjm 1999/02/01 * This is heavy-handed, but appears necessary bjm 1999/02/01
* SystemCacheRelationFlushed(relid) is not enough either. * SystemCacheRelationFlushed(relid) is not enough either.
...@@ -1005,7 +1006,8 @@ index_create(char *heapRelationName, ...@@ -1005,7 +1006,8 @@ index_create(char *heapRelationName,
{ {
temp_relname = pstrdup(indexRelationName); /* save original value */ temp_relname = pstrdup(indexRelationName); /* save original value */
indexRelationName = palloc(NAMEDATALEN); indexRelationName = palloc(NAMEDATALEN);
strcpy(indexRelationName, temp_relname); /* heap_create will change this */ strcpy(indexRelationName, temp_relname); /* heap_create will
* change this */
} }
/* ---------------- /* ----------------
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.37 1999/05/10 00:44:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.38 1999/05/25 16:08:07 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,14 +47,14 @@ ...@@ -47,14 +47,14 @@
char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex, char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex,
AttributeNumIndex, AttributeNumIndex,
AttributeRelidIndex}; AttributeRelidIndex};
char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex, char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex,
ProcedureOidIndex, ProcedureOidIndex,
ProcedureSrcIndex}; ProcedureSrcIndex};
char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex, char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex,
TypeOidIndex}; TypeOidIndex};
char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex, char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex,
ClassOidIndex}; ClassOidIndex};
char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex}; char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex}; char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.36 1999/05/10 00:44:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.37 1999/05/25 16:08:09 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.
...@@ -135,6 +135,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, ...@@ -135,6 +135,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
if (HeapTupleIsValid(tup)) if (HeapTupleIsValid(tup))
{ {
regproc oprcode = ((Form_pg_operator) GETSTRUCT(tup))->oprcode; regproc oprcode = ((Form_pg_operator) GETSTRUCT(tup))->oprcode;
operatorObjectId = tup->t_data->t_oid; operatorObjectId = tup->t_data->t_oid;
*defined = RegProcedureIsValid(oprcode); *defined = RegProcedureIsValid(oprcode);
} }
...@@ -506,8 +507,9 @@ OperatorDef(char *operatorName, ...@@ -506,8 +507,9 @@ OperatorDef(char *operatorName,
elog(ERROR, "OperatorDef: operator \"%s\" already defined", elog(ERROR, "OperatorDef: operator \"%s\" already defined",
operatorName); operatorName);
/* At this point, if operatorObjectId is not InvalidOid then /*
* we are filling in a previously-created shell. * At this point, if operatorObjectId is not InvalidOid then we are
* filling in a previously-created shell.
*/ */
/* ---------------- /* ----------------
...@@ -648,7 +650,8 @@ OperatorDef(char *operatorName, ...@@ -648,7 +650,8 @@ OperatorDef(char *operatorName,
values[i++] = ObjectIdGetDatum(leftTypeId); values[i++] = ObjectIdGetDatum(leftTypeId);
values[i++] = ObjectIdGetDatum(rightTypeId); values[i++] = ObjectIdGetDatum(rightTypeId);
++i; /* Skip "oprresult", it was filled in above */ ++i; /* Skip "oprresult", it was filled in
* above */
/* /*
* Set up the other operators. If they do not currently exist, create * Set up the other operators. If they do not currently exist, create
...@@ -704,7 +707,8 @@ OperatorDef(char *operatorName, ...@@ -704,7 +707,8 @@ OperatorDef(char *operatorName,
otherRightTypeName, otherRightTypeName,
&otherDefined); &otherDefined);
break; break;
case 3: /* right sort op takes right-side data type */ case 3: /* right sort op takes right-side data
* type */
otherLeftTypeName = rightTypeName; otherLeftTypeName = rightTypeName;
otherRightTypeName = rightTypeName; otherRightTypeName = rightTypeName;
otherLeftTypeId = rightTypeId; otherLeftTypeId = rightTypeId;
...@@ -737,8 +741,10 @@ OperatorDef(char *operatorName, ...@@ -737,8 +741,10 @@ OperatorDef(char *operatorName,
} }
else else
{ {
/* self-linkage to this operator; will fix below.
* Note that only self-linkage for commutation makes sense. /*
* self-linkage to this operator; will fix below. Note
* that only self-linkage for commutation makes sense.
*/ */
if (j != 0) if (j != 0)
elog(ERROR, elog(ERROR,
...@@ -804,15 +810,14 @@ OperatorDef(char *operatorName, ...@@ -804,15 +810,14 @@ OperatorDef(char *operatorName,
/* /*
* If a commutator and/or negator link is provided, update the other * If a commutator and/or negator link is provided, update the other
* operator(s) to point at this one, if they don't already have a link. * operator(s) to point at this one, if they don't already have a
* This supports an alternate style of operator definition wherein the * link. This supports an alternate style of operator definition
* user first defines one operator without giving negator or * wherein the user first defines one operator without giving negator
* commutator, then defines the other operator of the pair with the * or commutator, then defines the other operator of the pair with the
* proper commutator or negator attribute. That style doesn't require * proper commutator or negator attribute. That style doesn't require
* creation of a shell, and it's the only style that worked right before * creation of a shell, and it's the only style that worked right
* Postgres version 6.5. * before Postgres version 6.5. This code also takes care of the
* This code also takes care of the situation where the new operator * situation where the new operator is its own commutator.
* is its own commutator.
*/ */
if (selfCommutator) if (selfCommutator)
commutatorId = operatorObjectId; commutatorId = operatorObjectId;
...@@ -869,7 +874,8 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) ...@@ -869,7 +874,8 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
tup = heap_getnext(pg_operator_scan, 0); tup = heap_getnext(pg_operator_scan, 0);
/* if the commutator and negator are the same operator, do one update. /*
* if the commutator and negator are the same operator, do one update.
* XXX this is probably useless code --- I doubt it ever makes sense * XXX this is probably useless code --- I doubt it ever makes sense
* for commutator and negator to be the same thing... * for commutator and negator to be the same thing...
*/ */
...@@ -1008,7 +1014,7 @@ OperatorCreate(char *operatorName, ...@@ -1008,7 +1014,7 @@ OperatorCreate(char *operatorName,
if (!leftTypeName && !rightTypeName) if (!leftTypeName && !rightTypeName)
elog(ERROR, "OperatorCreate: at least one of leftarg or rightarg must be defined"); elog(ERROR, "OperatorCreate: at least one of leftarg or rightarg must be defined");
if (! (leftTypeName && rightTypeName)) if (!(leftTypeName && rightTypeName))
{ {
/* If it's not a binary op, these things mustn't be set: */ /* If it's not a binary op, these things mustn't be set: */
if (commutatorName) if (commutatorName)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.28 1999/05/13 07:28:27 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.29 1999/05/25 16:08:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -226,11 +226,11 @@ ProcedureCreate(char *procedureName, ...@@ -226,11 +226,11 @@ ProcedureCreate(char *procedureName,
* function name (the 'prosrc' value) is a known builtin function. * function name (the 'prosrc' value) is a known builtin function.
* *
* NOTE: in Postgres versions before 6.5, the SQL name of the created * NOTE: in Postgres versions before 6.5, the SQL name of the created
* function could not be different from the internal name, and 'prosrc' * function could not be different from the internal name, and
* wasn't used. So there is code out there that does CREATE FUNCTION * 'prosrc' wasn't used. So there is code out there that does CREATE
* xyz AS '' LANGUAGE 'internal'. To preserve some modicum of * FUNCTION xyz AS '' LANGUAGE 'internal'. To preserve some modicum
* backwards compatibility, accept an empty 'prosrc' value as meaning * of backwards compatibility, accept an empty 'prosrc' value as
* the supplied SQL function name. * meaning the supplied SQL function name.
*/ */
if (strcmp(languageName, "internal") == 0) if (strcmp(languageName, "internal") == 0)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.36 1999/04/20 03:51:14 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.37 1999/05/25 16:08:12 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -400,8 +400,8 @@ TypeCreate(char *typeName, ...@@ -400,8 +400,8 @@ TypeCreate(char *typeName,
procname = procs[j]; procname = procs[j];
/* /*
* First look for a 1-argument func with all argtypes 0. * First look for a 1-argument func with all argtypes 0. This is
* This is valid for all four kinds of procedure. * valid for all four kinds of procedure.
*/ */
MemSet(argList, 0, 8 * sizeof(Oid)); MemSet(argList, 0, 8 * sizeof(Oid));
...@@ -413,20 +413,23 @@ TypeCreate(char *typeName, ...@@ -413,20 +413,23 @@ TypeCreate(char *typeName,
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
{ {
/* /*
* For array types, the input procedures may take 3 args * For array types, the input procedures may take 3 args (data
* (data value, element OID, atttypmod); the pg_proc * value, element OID, atttypmod); the pg_proc argtype
* argtype signature is 0,0,INT4OID. The output procedures * signature is 0,0,INT4OID. The output procedures may take 2
* may take 2 args (data value, element OID). * args (data value, element OID).
*/ */
if (OidIsValid(elementObjectId)) if (OidIsValid(elementObjectId))
{ {
int nargs; int nargs;
if (j % 2) if (j % 2)
{ {
/* output proc */ /* output proc */
nargs = 2; nargs = 2;
} else }
else
{ {
/* input proc */ /* input proc */
nargs = 3; nargs = 3;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.2 1999/03/16 04:25:46 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.3 1999/05/25 16:08:30 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* doesn't work! - jolly 8/19/95 * doesn't work! - jolly 8/19/95
* *
* *
* $Id: version.c,v 1.18 1999/02/13 23:15:12 momjian Exp $ * $Id: version.c,v 1.19 1999/05/25 16:08:32 momjian Exp $
* *
* NOTES * NOTES
* At the point the version is defined, 2 physical relations are created * At the point the version is defined, 2 physical relations are created
......
This diff is collapsed.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.38 1999/02/13 23:15:02 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.39 1999/05/25 16:08:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.44 1999/05/10 00:44:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.45 1999/05/25 16:08:17 momjian Exp $
* *
* NOTES * NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated * The PortalExecutorHeapMemory crap needs to be eliminated
...@@ -124,7 +124,7 @@ PerformPortalFetch(char *name, ...@@ -124,7 +124,7 @@ PerformPortalFetch(char *name,
limcount.type = T_Const; limcount.type = T_Const;
limcount.consttype = INT4OID; limcount.consttype = INT4OID;
limcount.constlen = sizeof(int4); limcount.constlen = sizeof(int4);
limcount.constvalue = (Datum)count; limcount.constvalue = (Datum) count;
limcount.constisnull = FALSE; limcount.constisnull = FALSE;
limcount.constbyval = TRUE; limcount.constbyval = TRUE;
limcount.constisset = FALSE; limcount.constisset = FALSE;
...@@ -194,7 +194,7 @@ PerformPortalFetch(char *name, ...@@ -194,7 +194,7 @@ PerformPortalFetch(char *name,
PortalExecutorHeapMemory = (MemoryContext) PortalGetHeapMemory(portal); PortalExecutorHeapMemory = (MemoryContext) PortalGetHeapMemory(portal);
ExecutorRun(queryDesc, PortalGetState(portal), feature, ExecutorRun(queryDesc, PortalGetState(portal), feature,
(Node *)NULL, (Node *)&limcount); (Node *) NULL, (Node *) &limcount);
if (dest == None) /* MOVE */ if (dest == None) /* MOVE */
pfree(queryDesc); pfree(queryDesc);
...@@ -519,7 +519,7 @@ PerformAddAttribute(char *relationName, ...@@ -519,7 +519,7 @@ PerformAddAttribute(char *relationName,
} }
void void
LockTableCommand(LockStmt *lockstmt) LockTableCommand(LockStmt * lockstmt)
{ {
Relation rel; Relation rel;
int aclresult; int aclresult;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.76 1999/05/10 00:44:58 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.77 1999/05/25 16:08:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -92,19 +92,25 @@ inline void CopyDonePeek(FILE *fp, int c, int pickup); ...@@ -92,19 +92,25 @@ inline void CopyDonePeek(FILE *fp, int c, int pickup);
* *
* NB: no data conversion is applied by these functions * NB: no data conversion is applied by these functions
*/ */
inline void CopySendData(void *databuf, int datasize, FILE *fp) { inline void
CopySendData(void *databuf, int datasize, FILE *fp)
{
if (!fp) if (!fp)
pq_putbytes((char*) databuf, datasize); pq_putbytes((char *) databuf, datasize);
else else
fwrite(databuf, datasize, 1, fp); fwrite(databuf, datasize, 1, fp);
} }
inline void CopySendString(char *str, FILE *fp) { inline void
CopySendData(str,strlen(str),fp); CopySendString(char *str, FILE *fp)
{
CopySendData(str, strlen(str), fp);
} }
inline void CopySendChar(char c, FILE *fp) { inline void
CopySendData(&c,1,fp); CopySendChar(char c, FILE *fp)
{
CopySendData(&c, 1, fp);
} }
/* /*
...@@ -117,18 +123,23 @@ inline void CopySendChar(char c, FILE *fp) { ...@@ -117,18 +123,23 @@ inline void CopySendChar(char c, FILE *fp) {
* *
* NB: no data conversion is applied by these functions * NB: no data conversion is applied by these functions
*/ */
inline void CopyGetData(void *databuf, int datasize, FILE *fp) { inline void
CopyGetData(void *databuf, int datasize, FILE *fp)
{
if (!fp) if (!fp)
pq_getbytes((char*) databuf, datasize); pq_getbytes((char *) databuf, datasize);
else else
fread(databuf, datasize, 1, fp); fread(databuf, datasize, 1, fp);
} }
inline int CopyGetChar(FILE *fp) { inline int
CopyGetChar(FILE *fp)
{
if (!fp) if (!fp)
{ {
unsigned char ch; unsigned char ch;
if (pq_getbytes((char*) &ch, 1))
if (pq_getbytes((char *) &ch, 1))
return EOF; return EOF;
return ch; return ch;
} }
...@@ -136,9 +147,12 @@ inline int CopyGetChar(FILE *fp) { ...@@ -136,9 +147,12 @@ inline int CopyGetChar(FILE *fp) {
return getc(fp); return getc(fp);
} }
inline int CopyGetEof(FILE *fp) { inline int
CopyGetEof(FILE *fp)
{
if (!fp) if (!fp)
return 0; /* Never return EOF when talking to frontend ? */ return 0; /* Never return EOF when talking to
* frontend ? */
else else
return feof(fp); return feof(fp);
} }
...@@ -150,26 +164,39 @@ inline int CopyGetEof(FILE *fp) { ...@@ -150,26 +164,39 @@ inline int CopyGetEof(FILE *fp) {
* CopyDonePeek will either take the peeked char off the steam * CopyDonePeek will either take the peeked char off the steam
* (if pickup is != 0) or leave it on the stream (if pickup == 0) * (if pickup is != 0) or leave it on the stream (if pickup == 0)
*/ */
inline int CopyPeekChar(FILE *fp) { inline int
CopyPeekChar(FILE *fp)
{
if (!fp) if (!fp)
return pq_peekbyte(); return pq_peekbyte();
else else
return getc(fp); return getc(fp);
} }
inline void CopyDonePeek(FILE *fp, int c, int pickup) { inline void
if (!fp) { CopyDonePeek(FILE *fp, int c, int pickup)
if (pickup) { {
/* We want to pick it up - just receive again into dummy buffer */ if (!fp)
{
if (pickup)
{
/*
* We want to pick it up - just receive again into dummy
* buffer
*/
char c; char c;
pq_getbytes(&c, 1); pq_getbytes(&c, 1);
} }
/* If we didn't want to pick it up, just leave it where it sits */ /* If we didn't want to pick it up, just leave it where it sits */
} }
else { else
if (!pickup) { {
if (!pickup)
{
/* We don't want to pick it up - so put it back in there */ /* We don't want to pick it up - so put it back in there */
ungetc(c,fp); ungetc(c, fp);
} }
/* If we wanted to pick it up, it's already there */ /* If we wanted to pick it up, it's already there */
} }
...@@ -317,7 +344,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, ...@@ -317,7 +344,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
else if (!from) else if (!from)
{ {
if (!binary) if (!binary)
CopySendData("\\.\n",3,fp); CopySendData("\\.\n", 3, fp);
if (IsUnderPostmaster) if (IsUnderPostmaster)
pq_endcopyout(false); pq_endcopyout(false);
} }
...@@ -395,8 +422,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -395,8 +422,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
if (oids && !binary) if (oids && !binary)
{ {
CopySendString(oidout(tuple->t_data->t_oid),fp); CopySendString(oidout(tuple->t_data->t_oid), fp);
CopySendChar(delim[0],fp); CopySendChar(delim[0], fp);
} }
for (i = 0; i < attr_count; i++) for (i = 0; i < attr_count; i++)
...@@ -777,7 +804,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -777,7 +804,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
} }
else if (nulls[i] != 'n') else if (nulls[i] != 'n')
{ {
ptr = (char *)att_align(ptr, attr[i]->attlen, attr[i]->attalign); ptr = (char *) att_align(ptr, attr[i]->attlen, attr[i]->attalign);
values[i] = (Datum) ptr; values[i] = (Datum) ptr;
ptr = att_addlength(ptr, attr[i]->attlen, ptr); ptr = att_addlength(ptr, attr[i]->attlen, ptr);
} }
...@@ -1176,26 +1203,29 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim) ...@@ -1176,26 +1203,29 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
if (ISOCTAL(c)) if (ISOCTAL(c))
{ {
val = (val << 3) + VALUE(c); val = (val << 3) + VALUE(c);
CopyDonePeek(fp, c, 1); /* Pick up the character! */ CopyDonePeek(fp, c, 1); /* Pick up the
* character! */
c = CopyPeekChar(fp); c = CopyPeekChar(fp);
if (ISOCTAL(c)) { if (ISOCTAL(c))
CopyDonePeek(fp,c,1); /* pick up! */ {
CopyDonePeek(fp, c, 1); /* pick up! */
val = (val << 3) + VALUE(c); val = (val << 3) + VALUE(c);
} }
else else
{ {
if (CopyGetEof(fp)) { if (CopyGetEof(fp))
CopyDonePeek(fp,c,1); /* pick up */ {
CopyDonePeek(fp, c, 1); /* pick up */
return NULL; return NULL;
} }
CopyDonePeek(fp,c,0); /* Return to stream! */ CopyDonePeek(fp, c, 0); /* Return to stream! */
} }
} }
else else
{ {
if (CopyGetEof(fp)) if (CopyGetEof(fp))
return NULL; return NULL;
CopyDonePeek(fp,c,0); /* Return to stream! */ CopyDonePeek(fp, c, 0); /* Return to stream! */
} }
c = val & 0377; c = val & 0377;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.40 1999/02/13 23:15:05 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.41 1999/05/25 16:08:20 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.34 1999/05/10 00:44:59 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.35 1999/05/25 16:08:21 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -124,7 +124,7 @@ destroydb(char *dbname, CommandDest dest) ...@@ -124,7 +124,7 @@ destroydb(char *dbname, CommandDest dest)
*/ */
snprintf(buf, 512, snprintf(buf, 512,
"delete from pg_database where pg_database.oid = \'%u\'::oid", db_id); "delete from pg_database where pg_database.oid = \'%u\'::oid", db_id);
pg_exec_query_dest(buf ,dest, false); pg_exec_query_dest(buf, dest, false);
/* drop pages for this database that are in the shared buffer cache */ /* drop pages for this database that are in the shared buffer cache */
DropBuffers(db_id); DropBuffers(db_id);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.28 1999/04/09 22:35:41 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.29 1999/05/25 16:08:22 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
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Copyright (c) 1994-5, Regents of the University of California * Copyright (c) 1994-5, Regents of the University of California
* *
* $Id: explain.c,v 1.36 1999/05/09 23:31:45 tgl Exp $ * $Id: explain.c,v 1.37 1999/05/25 16:08:23 momjian Exp $
* *
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -34,7 +34,7 @@ typedef struct ExplainState ...@@ -34,7 +34,7 @@ typedef struct ExplainState
} ExplainState; } ExplainState;
static char *Explain_PlanToString(Plan *plan, ExplainState *es); static char *Explain_PlanToString(Plan *plan, ExplainState *es);
static void printLongNotice(const char * header, const char * message); static void printLongNotice(const char *header, const char *message);
static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest); static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest);
...@@ -208,13 +208,11 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -208,13 +208,11 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
case T_IndexScan: case T_IndexScan:
appendStringInfo(str, " using "); appendStringInfo(str, " using ");
i = 0; i = 0;
foreach (l, ((IndexScan *) plan)->indxid) foreach(l, ((IndexScan *) plan)->indxid)
{ {
relation = RelationIdCacheGetRelation((int) lfirst(l)); relation = RelationIdCacheGetRelation((int) lfirst(l));
if (++i > 1) if (++i > 1)
{
appendStringInfo(str, ", "); appendStringInfo(str, ", ");
}
appendStringInfo(str, appendStringInfo(str,
stringStringInfo((RelationGetRelationName(relation))->data)); stringStringInfo((RelationGetRelationName(relation))->data));
} }
...@@ -249,17 +247,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -249,17 +247,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
List *lst; List *lst;
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 + 2, es); explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 2, es);
} }
...@@ -270,9 +264,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -270,9 +264,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
if (outerPlan(plan)) if (outerPlan(plan))
{ {
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
{
appendStringInfo(str, " "); appendStringInfo(str, " ");
}
appendStringInfo(str, " -> "); appendStringInfo(str, " -> ");
explain_outNode(str, outerPlan(plan), indent + 3, es); explain_outNode(str, outerPlan(plan), indent + 3, es);
} }
...@@ -281,9 +273,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -281,9 +273,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
if (innerPlan(plan)) if (innerPlan(plan))
{ {
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
{
appendStringInfo(str, " "); appendStringInfo(str, " ");
}
appendStringInfo(str, " -> "); appendStringInfo(str, " -> ");
explain_outNode(str, innerPlan(plan), indent + 3, es); explain_outNode(str, innerPlan(plan), indent + 3, es);
} }
...@@ -295,17 +285,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -295,17 +285,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
List *lst; List *lst;
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);
} }
...@@ -336,9 +322,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) ...@@ -336,9 +322,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
es->rtable = nth(whichplan, appendplan->unionrtables); es->rtable = nth(whichplan, appendplan->unionrtables);
for (i = 0; i < indent; i++) for (i = 0; i < indent; i++)
{
appendStringInfo(str, " "); appendStringInfo(str, " ");
}
appendStringInfo(str, " -> "); appendStringInfo(str, " -> ");
explain_outNode(str, subnode, indent + 4, es); explain_outNode(str, subnode, indent + 4, es);
...@@ -367,7 +351,7 @@ Explain_PlanToString(Plan *plan, ExplainState *es) ...@@ -367,7 +351,7 @@ Explain_PlanToString(Plan *plan, ExplainState *es)
* This is a crock ... there shouldn't be an upper limit to what you can elog(). * This is a crock ... there shouldn't be an upper limit to what you can elog().
*/ */
static void static void
printLongNotice(const char * header, const char * message) printLongNotice(const char *header, const char *message)
{ {
int len = strlen(message); int len = strlen(message);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.3 1999/05/10 00:44:59 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.4 1999/05/25 16:08:24 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.32 1999/02/13 23:15:08 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.33 1999/05/25 16:08:25 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.24 1999/05/17 18:24:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.25 1999/05/25 16:08:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -237,7 +237,7 @@ renamerel(char *oldrelname, char *newrelname) ...@@ -237,7 +237,7 @@ renamerel(char *oldrelname, char *newrelname)
{ {
sprintf(toldpath, "%s.%d", oldpath, i); sprintf(toldpath, "%s.%d", oldpath, i);
sprintf(tnewpath, "%s.%d", newpath, i); sprintf(tnewpath, "%s.%d", newpath, i);
if(rename(toldpath, tnewpath) < 0) if (rename(toldpath, tnewpath) < 0)
break; break;
} }
......
...@@ -218,8 +218,8 @@ nextval(struct varlena * seqin) ...@@ -218,8 +218,8 @@ nextval(struct varlena * seqin)
return elm->last; return elm->last;
} }
seq = read_info("nextval", elm, &buf); /* lock page' buffer and read seq = read_info("nextval", elm, &buf); /* lock page' buffer and
* tuple */ * read tuple */
next = result = seq->last_value; next = result = seq->last_value;
incby = seq->increment_by; incby = seq->increment_by;
...@@ -327,8 +327,8 @@ setval(struct varlena * seqin, int4 next) ...@@ -327,8 +327,8 @@ setval(struct varlena * seqin, int4 next)
/* open and AccessShareLock sequence */ /* open and AccessShareLock sequence */
elm = init_sequence("setval", seqname); elm = init_sequence("setval", seqname);
seq = read_info("setval", elm, &buf); /* lock page' buffer and read seq = read_info("setval", elm, &buf); /* lock page' buffer and
* tuple */ * read tuple */
if (seq->cache_value != 1) if (seq->cache_value != 1)
{ {
......
...@@ -742,8 +742,8 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple) ...@@ -742,8 +742,8 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
return NULL; return NULL;
/* /*
* In READ COMMITTED isolevel it's possible that newtuple * In READ COMMITTED isolevel it's possible that newtuple was changed
* was changed due to concurrent update. * due to concurrent update.
*/ */
if (newSlot != NULL) if (newSlot != NULL)
intuple = newtuple = ExecRemoveJunk(estate->es_junkFilter, newSlot); intuple = newtuple = ExecRemoveJunk(estate->es_junkFilter, newSlot);
...@@ -824,7 +824,7 @@ ltrmark:; ...@@ -824,7 +824,7 @@ ltrmark:;
{ {
case HeapTupleSelfUpdated: case HeapTupleSelfUpdated:
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
return(NULL); return (NULL);
case HeapTupleMayBeUpdated: case HeapTupleMayBeUpdated:
break; break;
...@@ -846,17 +846,17 @@ ltrmark:; ...@@ -846,17 +846,17 @@ ltrmark:;
goto ltrmark; goto ltrmark;
} }
} }
/* /*
* if tuple was deleted or PlanQual failed * if tuple was deleted or PlanQual failed for updated
* for updated tuple - we have not process * tuple - we have not process this tuple!
* this tuple!
*/ */
return(NULL); return (NULL);
default: default:
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
elog(ERROR, "Unknown status %u from heap_mark4update", test); elog(ERROR, "Unknown status %u from heap_mark4update", test);
return(NULL); return (NULL);
} }
} }
else else
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: user.c,v 1.27 1999/04/02 06:16:36 tgl Exp $ * $Id: user.c,v 1.28 1999/05/25 16:08:27 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -169,8 +169,8 @@ DefineUser(CreateUserStmt *stmt, CommandDest dest) ...@@ -169,8 +169,8 @@ DefineUser(CreateUserStmt *stmt, CommandDest dest)
/* /*
* Build the insert statement to be executed. * Build the insert statement to be executed.
* *
* XXX Ugly as this code is, it still fails to cope with ' or \ * XXX Ugly as this code is, it still fails to cope with ' or \ in any of
* in any of the provided strings. * the provided strings.
*/ */
snprintf(sql, SQL_LENGTH, snprintf(sql, SQL_LENGTH,
"insert into %s (usename,usesysid,usecreatedb,usetrace," "insert into %s (usename,usesysid,usecreatedb,usetrace,"
...@@ -272,9 +272,7 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest) ...@@ -272,9 +272,7 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest)
snprintf(sql, SQL_LENGTH, "update %s set", ShadowRelationName); snprintf(sql, SQL_LENGTH, "update %s set", ShadowRelationName);
if (stmt->password) if (stmt->password)
{
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password); snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password);
}
if (stmt->createdb) if (stmt->createdb)
{ {
......
This diff is collapsed.
...@@ -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.19 1999/02/18 06:00:44 momjian Exp $ * $Id: variable.c,v 1.20 1999/05/25 16:08:28 momjian Exp $
* *
*/ */
...@@ -45,10 +45,12 @@ static bool parse_ksqo(const char *); ...@@ -45,10 +45,12 @@ static bool parse_ksqo(const char *);
static bool show_XactIsoLevel(void); static bool show_XactIsoLevel(void);
static bool reset_XactIsoLevel(void); static bool reset_XactIsoLevel(void);
static bool parse_XactIsoLevel(const char *); static bool parse_XactIsoLevel(const char *);
#ifdef QUERY_LIMIT #ifdef QUERY_LIMIT
static bool show_query_limit(void); static bool show_query_limit(void);
static bool reset_query_limit(void); static bool reset_query_limit(void);
static bool parse_query_limit(const char *); static bool parse_query_limit(const char *);
#endif #endif
extern Cost _cpu_page_wight_; extern Cost _cpu_page_wight_;
...@@ -547,17 +549,17 @@ parse_query_limit(const char *value) ...@@ -547,17 +549,17 @@ parse_query_limit(const char *value)
{ {
int32 limit; int32 limit;
if (value == NULL) { if (value == NULL)
{
reset_query_limit(); reset_query_limit();
return(TRUE); return (TRUE);
} }
/* why is pg_atoi's arg not declared "const char *" ? */ /* why is pg_atoi's arg not declared "const char *" ? */
limit = pg_atoi((char *) value, sizeof(int32), '\0'); limit = pg_atoi((char *) value, sizeof(int32), '\0');
if (limit <= -1) { if (limit <= -1)
elog(ERROR, "Bad value for # of query limit (%s)", value); elog(ERROR, "Bad value for # of query limit (%s)", value);
}
ExecutorLimit(limit); ExecutorLimit(limit);
return(TRUE); return (TRUE);
} }
static bool static bool
...@@ -566,20 +568,20 @@ show_query_limit(void) ...@@ -566,20 +568,20 @@ show_query_limit(void)
int limit; int limit;
limit = ExecutorGetLimit(); limit = ExecutorGetLimit();
if (limit == ALL_TUPLES) { if (limit == ALL_TUPLES)
elog(NOTICE, "No query limit is set"); elog(NOTICE, "No query limit is set");
} else { else
elog(NOTICE, "query limit is %d",limit); elog(NOTICE, "query limit is %d", limit);
} return (TRUE);
return(TRUE);
} }
static bool static bool
reset_query_limit(void) reset_query_limit(void)
{ {
ExecutorLimit(ALL_TUPLES); ExecutorLimit(ALL_TUPLES);
return(TRUE); return (TRUE);
} }
#endif #endif
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: view.c,v 1.32 1999/02/13 23:15:12 momjian Exp $ * $Id: view.c,v 1.33 1999/05/25 16:08:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* ExecInitTee * ExecInitTee
* ExecEndTee * ExecEndTee
* *
* $Id: nodeTee.c,v 1.1 1999/03/23 16:50:49 momjian Exp $ * $Id: nodeTee.c,v 1.2 1999/05/25 16:08:50 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -339,6 +339,7 @@ ExecTee(Tee *node, Plan *parent) ...@@ -339,6 +339,7 @@ ExecTee(Tee *node, Plan *parent)
slot = ExecProcNode(childNode, (Plan *) node); slot = ExecProcNode(childNode, (Plan *) node);
if (!TupIsNull(slot)) if (!TupIsNull(slot))
{ {
/* /*
* heap_insert changes something... * heap_insert changes something...
*/ */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: execAmi.c,v 1.34 1999/05/10 00:45:05 momjian Exp $ * $Id: execAmi.c,v 1.35 1999/05/25 16:08:34 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
This diff is collapsed.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.24 1999/03/23 16:50:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.25 1999/05/25 16:08:39 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -467,6 +467,7 @@ ExecSetSlotPolicy(TupleTableSlot *slot, /* slot to change */ ...@@ -467,6 +467,7 @@ ExecSetSlotPolicy(TupleTableSlot *slot, /* slot to change */
return old_shouldFree; return old_shouldFree;
} }
#endif #endif
/* -------------------------------- /* --------------------------------
...@@ -650,6 +651,7 @@ ExecInitMarkedTupleSlot(EState *estate, MergeJoinState *mergestate) ...@@ -650,6 +651,7 @@ ExecInitMarkedTupleSlot(EState *estate, MergeJoinState *mergestate)
INIT_SLOT_ALLOC; INIT_SLOT_ALLOC;
mergestate->mj_MarkedTupleSlot = (TupleTableSlot *) slot; mergestate->mj_MarkedTupleSlot = (TupleTableSlot *) slot;
} }
#endif #endif
/* ---------------- /* ----------------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.44 1999/03/20 01:13:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.45 1999/05/25 16:08:39 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -711,7 +711,7 @@ ExecGetIndexKeyInfo(Form_pg_index indexTuple, ...@@ -711,7 +711,7 @@ ExecGetIndexKeyInfo(Form_pg_index indexTuple,
*/ */
CXT1_printf("ExecGetIndexKeyInfo: context is %d\n", CurrentMemoryContext); CXT1_printf("ExecGetIndexKeyInfo: context is %d\n", CurrentMemoryContext);
attKeys = (AttrNumber *)palloc(numKeys * sizeof(AttrNumber)); attKeys = (AttrNumber *) palloc(numKeys * sizeof(AttrNumber));
for (i = 0; i < numKeys; i++) for (i = 0; i < numKeys; i++)
attKeys[i] = indexTuple->indkey[i]; attKeys[i] = indexTuple->indkey[i];
...@@ -917,16 +917,17 @@ ExecOpenIndices(Oid resultRelationOid, ...@@ -917,16 +917,17 @@ ExecOpenIndices(Oid resultRelationOid,
if (indexDesc != NULL) if (indexDesc != NULL)
{ {
relationDescs[i++] = indexDesc; relationDescs[i++] = indexDesc;
/* /*
* Hack for not btree and hash indices: they use relation level * Hack for not btree and hash indices: they use relation
* exclusive locking on updation (i.e. - they are not ready * level exclusive locking on updation (i.e. - they are
* for MVCC) and so we have to exclusively lock indices here * not ready for MVCC) and so we have to exclusively lock
* to prevent deadlocks if we will scan them - index_beginscan * indices here to prevent deadlocks if we will scan them
* places AccessShareLock, indices update methods don't use * - index_beginscan places AccessShareLock, indices
* locks at all. We release this lock in ExecCloseIndices. * update methods don't use locks at all. We release this
* Note, that hashes use page level locking - i.e. are not * lock in ExecCloseIndices. Note, that hashes use page
* deadlock-free, - let's them be on their way -:)) * level locking - i.e. are not deadlock-free, - let's
* vadim 03-12-1998 * them be on their way -:)) vadim 03-12-1998
*/ */
if (indexDesc->rd_rel->relam != BTREE_AM_OID && if (indexDesc->rd_rel->relam != BTREE_AM_OID &&
indexDesc->rd_rel->relam != HASH_AM_OID) indexDesc->rd_rel->relam != HASH_AM_OID)
...@@ -1014,6 +1015,7 @@ ExecCloseIndices(RelationInfo *resultRelationInfo) ...@@ -1014,6 +1015,7 @@ ExecCloseIndices(RelationInfo *resultRelationInfo)
{ {
if (relationDescs[i] == NULL) if (relationDescs[i] == NULL)
continue; continue;
/* /*
* Notes in ExecOpenIndices. * Notes in ExecOpenIndices.
*/ */
...@@ -1023,6 +1025,7 @@ ExecCloseIndices(RelationInfo *resultRelationInfo) ...@@ -1023,6 +1025,7 @@ ExecCloseIndices(RelationInfo *resultRelationInfo)
index_close(relationDescs[i]); index_close(relationDescs[i]);
} }
/* /*
* XXX should free indexInfo array here too. * XXX should free indexInfo array here too.
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.25 1999/05/13 07:28:29 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.26 1999/05/25 16:08:39 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -109,7 +109,7 @@ init_execution_state(FunctionCachePtr fcache, ...@@ -109,7 +109,7 @@ init_execution_state(FunctionCachePtr fcache,
planTree_list = pg_parse_and_plan(fcache->src, fcache->argOidVect, planTree_list = pg_parse_and_plan(fcache->src, fcache->argOidVect,
nargs, &queryTree_list, None, FALSE); nargs, &queryTree_list, None, FALSE);
foreach (qtl_item, queryTree_list) foreach(qtl_item, queryTree_list)
{ {
Query *queryTree = lfirst(qtl_item); Query *queryTree = lfirst(qtl_item);
Plan *planTree = lfirst(planTree_list); Plan *planTree = lfirst(planTree_list);
...@@ -199,7 +199,7 @@ postquel_getnext(execution_state *es) ...@@ -199,7 +199,7 @@ postquel_getnext(execution_state *es)
feature = (LAST_POSTQUEL_COMMAND(es)) ? EXEC_RETONE : EXEC_RUN; feature = (LAST_POSTQUEL_COMMAND(es)) ? EXEC_RETONE : EXEC_RUN;
return ExecutorRun(es->qd, es->estate, feature, (Node *)NULL, (Node *)NULL); return ExecutorRun(es->qd, es->estate, feature, (Node *) NULL, (Node *) NULL);
} }
static void static void
......
...@@ -45,7 +45,7 @@ typedef struct AggFuncInfo ...@@ -45,7 +45,7 @@ typedef struct AggFuncInfo
FmgrInfo finalfn; FmgrInfo finalfn;
} AggFuncInfo; } AggFuncInfo;
static Datum aggGetAttr(TupleTableSlot *tuple, Aggref *aggref, bool *isNull); static Datum aggGetAttr(TupleTableSlot *tuple, Aggref * aggref, bool *isNull);
/* --------------------------------------- /* ---------------------------------------
...@@ -121,7 +121,8 @@ ExecAgg(Agg *node) ...@@ -121,7 +121,8 @@ ExecAgg(Agg *node)
*/ */
/* /*
* We loop retrieving groups until we find one matching node->plan.qual * We loop retrieving groups until we find one matching
* node->plan.qual
*/ */
do do
{ {
...@@ -245,6 +246,7 @@ ExecAgg(Agg *node) ...@@ -245,6 +246,7 @@ ExecAgg(Agg *node)
outerslot = ExecProcNode(outerPlan, (Plan *) node); outerslot = ExecProcNode(outerPlan, (Plan *) node);
if (TupIsNull(outerslot)) if (TupIsNull(outerslot))
{ {
/* /*
* when the outerplan doesn't return a single tuple, * when the outerplan doesn't return a single tuple,
* create a dummy heaptuple anyway because we still need * create a dummy heaptuple anyway because we still need
...@@ -299,17 +301,19 @@ ExecAgg(Agg *node) ...@@ -299,17 +301,19 @@ ExecAgg(Agg *node)
{ {
if (noInitValue[aggno]) if (noInitValue[aggno])
{ {
/* /*
* value1 has not been initialized. * value1 has not been initialized. This is the
* This is the first non-NULL input value. * first non-NULL input value. We use it as the
* We use it as the initial value for value1. * initial value for value1.
* *
* But we can't just use it straight, we have to * But we can't just use it straight, we have to make
* make a copy of it since the tuple from which it * a copy of it since the tuple from which it came
* came will be freed on the next iteration of the * will be freed on the next iteration of the
* scan. This requires finding out how to copy * scan. This requires finding out how to copy
* the Datum. We assume the datum is of the agg's * the Datum. We assume the datum is of the agg's
* basetype, or at least binary compatible with it. * basetype, or at least binary compatible with
* it.
*/ */
Type aggBaseType = typeidType(aggref->basetype); Type aggBaseType = typeidType(aggref->basetype);
int attlen = typeLen(aggBaseType); int attlen = typeLen(aggBaseType);
...@@ -330,6 +334,7 @@ ExecAgg(Agg *node) ...@@ -330,6 +334,7 @@ ExecAgg(Agg *node)
} }
else else
{ {
/* /*
* apply the transition functions. * apply the transition functions.
*/ */
...@@ -441,9 +446,10 @@ ExecAgg(Agg *node) ...@@ -441,9 +446,10 @@ ExecAgg(Agg *node)
* As long as the retrieved group does not match the * As long as the retrieved group does not match the
* qualifications it is ignored and the next group is fetched * qualifications it is ignored and the next group is fetched
*/ */
if(node->plan.qual != NULL) if (node->plan.qual != NULL)
qual_result = ExecQual(fix_opids(node->plan.qual), econtext); qual_result = ExecQual(fix_opids(node->plan.qual), econtext);
else qual_result = false; else
qual_result = false;
if (oneTuple) if (oneTuple)
pfree(oneTuple); pfree(oneTuple);
...@@ -576,7 +582,7 @@ ExecEndAgg(Agg *node) ...@@ -576,7 +582,7 @@ ExecEndAgg(Agg *node)
*/ */
static Datum static Datum
aggGetAttr(TupleTableSlot *slot, aggGetAttr(TupleTableSlot *slot,
Aggref *aggref, Aggref * aggref,
bool *isNull) bool *isNull)
{ {
Datum result; Datum result;
...@@ -623,8 +629,9 @@ aggGetAttr(TupleTableSlot *slot, ...@@ -623,8 +629,9 @@ aggGetAttr(TupleTableSlot *slot,
} }
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? */
/* ---------------- /* ----------------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.18 1999/02/21 03:48:40 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.19 1999/05/25 16:08:40 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.25 1999/02/13 23:15:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.26 1999/05/25 16:08:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.35 1999/05/10 00:45:06 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.36 1999/05/25 16:08:43 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -98,6 +98,7 @@ IndexNext(IndexScan *node) ...@@ -98,6 +98,7 @@ IndexNext(IndexScan *node)
bool bBackward; bool bBackward;
int indexNumber; int indexNumber;
/* ---------------- /* ----------------
* extract necessary information from index scan node * extract necessary information from index scan node
* ---------------- * ----------------
...@@ -114,9 +115,9 @@ IndexNext(IndexScan *node) ...@@ -114,9 +115,9 @@ IndexNext(IndexScan *node)
/* /*
* Check if we are evaluating PlanQual for tuple of this relation. * Check if we are evaluating PlanQual for tuple of this relation.
* Additional checking is not good, but no other way for now. * Additional checking is not good, but no other way for now. We could
* We could introduce new nodes for this case and handle * introduce new nodes for this case and handle IndexScan --> NewNode
* IndexScan --> NewNode switching in Init/ReScan plan... * switching in Init/ReScan plan...
*/ */
if (estate->es_evTuple != NULL && if (estate->es_evTuple != NULL &&
estate->es_evTuple[node->scan.scanrelid - 1] != NULL) estate->es_evTuple[node->scan.scanrelid - 1] != NULL)
...@@ -703,7 +704,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) ...@@ -703,7 +704,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
run_keys = (n_keys <= 0) ? NULL : run_keys = (n_keys <= 0) ? NULL :
(int *) palloc(n_keys * sizeof(int)); (int *) palloc(n_keys * sizeof(int));
CXT1_printf("ExecInitIndexScan: context is %d\n",CurrentMemoryContext); CXT1_printf("ExecInitIndexScan: context is %d\n", CurrentMemoryContext);
/* ---------------- /* ----------------
* for each opclause in the given qual, * for each opclause in the given qual,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.21 1999/02/13 23:15:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.22 1999/05/25 16:08:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.26 1999/05/10 00:45:07 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.27 1999/05/25 16:08:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -103,7 +103,7 @@ static bool MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext) ...@@ -103,7 +103,7 @@ static bool MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
static List * static List *
MJFormSkipQual(List *qualList, char * replaceopname) MJFormSkipQual(List *qualList, char *replaceopname)
{ {
List *qualCopy; List *qualCopy;
List *qualcdr; List *qualcdr;
......
...@@ -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.10 1999/03/20 01:13:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.11 1999/05/25 16:08:46 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -278,7 +278,8 @@ ExecEndResult(Result *node) ...@@ -278,7 +278,8 @@ ExecEndResult(Result *node)
* ---------------- * ----------------
*/ */
ExecClearTuple(resstate->cstate.cs_ResultTupleSlot); ExecClearTuple(resstate->cstate.cs_ResultTupleSlot);
pfree(resstate); node->resstate = NULL; /* XXX - new for us - er1p */ pfree(resstate);
node->resstate = NULL; /* XXX - new for us - er1p */
} }
void void
......
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/lib/Attic/fstack.c,v 1.10 1999/02/13 23:15:34 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/lib/Attic/fstack.c,v 1.11 1999/05/25 16:08:52 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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