Commit 07842084 authored by Bruce Momjian's avatar Bruce Momjian

pgindent run over code.

parent 4b04b01a
...@@ -43,8 +43,8 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -43,8 +43,8 @@ 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 */
if ((array == (ArrayType *) NULL) if ((array == (ArrayType *) NULL)
...@@ -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);
}
} }
/* /*
...@@ -344,7 +332,7 @@ int32 ...@@ -344,7 +332,7 @@ int32
array_oideq(ArrayType *array, Oid value) array_oideq(ArrayType *array, Oid value)
{ {
return array_iterator((Oid) 26, /* oid */ return array_iterator((Oid) 26, /* oid */
(Oid) 184, /* oideq */ (Oid) 184, /* oideq */
0, /* logical or */ 0, /* logical or */
array, (Datum) value); array, (Datum) value);
} }
......
#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);
...@@ -24,6 +23,7 @@ int32 array_int4lt(ArrayType *array, int4 value); ...@@ -24,6 +23,7 @@ int32 array_int4lt(ArrayType *array, int4 value);
int32 array_all_int4lt(ArrayType *array, int4 value); int32 array_all_int4lt(ArrayType *array, int4 value);
int32 array_int4le(ArrayType *array, int4 value); 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
...@@ -225,8 +225,8 @@ currentdate() ...@@ -225,8 +225,8 @@ currentdate()
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
* End: * End:
*/ */
...@@ -4,23 +4,24 @@ ...@@ -4,23 +4,24 @@
#include <postgres.h> #include <postgres.h>
#include <utils/geo_decls.h> /* for Pt */ #include <utils/geo_decls.h> /* for Pt */
#include <utils/palloc.h> /* for palloc */ #include <utils/palloc.h> /* for palloc */
/* Earth's radius is in statute miles. */ /* Earth's radius is in statute miles. */
const EARTH_RADIUS = 3958.747716; const EARTH_RADIUS = 3958.747716;
const TWO_PI = 2.0 * M_PI; const TWO_PI = 2.0 * M_PI;
/****************************************************** /******************************************************
* *
* degtorad - convert degrees to radians * degtorad - convert degrees to radians
* *
* arg: double, angle in degrees * arg: double, angle in degrees
* *
* returns: double, same angle in radians * returns: double, same angle in radians
******************************************************/ ******************************************************/
static double static double
degtorad (double degrees) { degtorad(double degrees)
{
return (degrees / 360.0) * TWO_PI; return (degrees / 360.0) * TWO_PI;
} }
...@@ -30,36 +31,40 @@ degtorad (double degrees) { ...@@ -30,36 +31,40 @@ degtorad (double degrees) {
* geo_distance - distance between points * geo_distance - distance between points
* *
* args: * args:
* a pair of points - for each point, * a pair of points - for each point,
* x-coordinate is longitude in degrees west of Greenwich * x-coordinate is longitude in degrees west of Greenwich
* y-coordinate is latitude in degrees above equator * y-coordinate is latitude in degrees above equator
* *
* returns: double * returns: double
* distance between the points in miles on earth's surface * distance between the points in miles on earth's surface
******************************************************/ ******************************************************/
double * double *
geo_distance (Point *pt1, Point *pt2) { geo_distance(Point *pt1, Point *pt2)
{
double long1, lat1, long2, lat2; double long1,
double longdiff; lat1,
double * resultp = palloc (sizeof(double)); long2,
lat2;
double longdiff;
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)
...@@ -55,7 +56,7 @@ main(int argc, char **argv) ...@@ -55,7 +56,7 @@ main(int argc, char **argv)
"); ");
doquery("FETCH ALL IN c_relations"); doquery("FETCH ALL IN c_relations");
relres = get_result(); relres = get_result();
set_result(attres); set_result(attres);
while (fetch(typname, relname, attname) != END_OF_TUPLES) while (fetch(typname, relname, attname) != END_OF_TUPLES)
{ {
...@@ -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");
...@@ -96,7 +97,7 @@ main(int argc, char **argv) ...@@ -96,7 +97,7 @@ main(int argc, char **argv)
doquery("CLOSE c_attributes"); doquery("CLOSE c_attributes");
PQclear(attres); PQclear(attres);
unset_result(attres); unset_result(attres);
doquery("COMMIT WORK"); doquery("COMMIT WORK");
disconnectdb(); disconnectdb();
......
This diff is collapsed.
/* /*
* 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>
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
typedef struct isbn typedef struct isbn
{ {
char num[13]; char num[13];
char pad[3]; char pad[3];
} isbn; } isbn;
/* /*
...@@ -50,13 +50,15 @@ isbn_in(char *str) ...@@ -50,13 +50,15 @@ 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,28 +86,40 @@ isbn_in(char *str) ...@@ -84,28 +86,40 @@ isbn_in(char *str)
int4 int4
isbn_sum(char *str) isbn_sum(char *str)
{ {
int4 sum = 0, dashes = 0, val; int4 sum = 0,
int i; dashes = 0,
val;
for (i = 0; str[i] && i < 13; i++) { int i;
switch(str[i]) {
case '-': for (i = 0; str[i] && i < 13; i++)
if (++dashes > 3) {
switch (str[i])
{
case '-':
if (++dashes > 3)
return 12;
continue;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
val = str[i] - '0';
break;
case 'X':
case 'x':
val = 10;
break;
default:
return 12; return 12;
continue;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
val = str[i] - '0';
break;
case 'X': case 'x':
val = 10;
break;
default:
return 12;
} }
sum += val * (i + 1 - dashes); sum += val * (i + 1 - dashes);
......
/* /*
* 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>
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
typedef struct issn typedef struct issn
{ {
char num[9]; char num[9];
char pad[7]; char pad[7];
} issn; } issn;
/* /*
...@@ -50,13 +50,15 @@ issn_in(char *str) ...@@ -50,13 +50,15 @@ 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,28 +77,40 @@ issn_in(char *str) ...@@ -75,28 +77,40 @@ issn_in(char *str)
int4 int4
issn_sum(char *str) issn_sum(char *str)
{ {
int4 sum = 0, dashes = 0, val; int4 sum = 0,
int i; dashes = 0,
val;
for (i = 0; str[i] && i < 9; i++) { int i;
switch(str[i]) {
case '-': for (i = 0; str[i] && i < 9; i++)
if (++dashes > 1) {
switch (str[i])
{
case '-':
if (++dashes > 1)
return 12;
continue;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
val = str[i] - '0';
break;
case 'X':
case 'x':
val = 10;
break;
default:
return 12; return 12;
continue;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
val = str[i] - '0';
break;
case 'X': case 'x':
val = 10;
break;
default:
return 12;
} }
sum += val * (8 - (i - dashes)); sum += val * (8 - (i - dashes));
......
/* /*
* 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 $
* *
*/ */
...@@ -33,11 +33,11 @@ typedef Oid Blob; ...@@ -33,11 +33,11 @@ typedef Oid Blob;
* Various forward declarations: * Various forward declarations:
*/ */
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 */
/* /*
* This creates a large object, and set's its OID to the value in the * This creates a large object, and set's its OID to the value in the
...@@ -49,45 +49,46 @@ HeapTuple lo_manage(void); /* Trigger handler */ ...@@ -49,45 +49,46 @@ HeapTuple lo_manage(void); /* Trigger handler */
Blob * Blob *
lo_in(char *str) lo_in(char *str)
{ {
Blob *result; Blob *result;
Oid oid; Oid oid;
int count; int count;
if (strlen(str) > 0) if (strlen(str) > 0)
{ {
count = sscanf(str, "%d", &oid); count = sscanf(str, "%d", &oid);
if (count < 1) if (count < 1)
{ {
elog(ERROR, "lo_in: error in parsing \"%s\"", str); elog(ERROR, "lo_in: error in parsing \"%s\"", 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);
} }
} }
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); */
if(oid == InvalidOid) oid = lo_creat(INV_READ | INV_WRITE);
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);
} }
} }
result = (Blob *) palloc(sizeof(Blob)); result = (Blob *) palloc(sizeof(Blob));
*result = oid; *result = oid;
return (result); return (result);
} }
/* /*
...@@ -96,42 +97,43 @@ lo_in(char *str) ...@@ -96,42 +97,43 @@ lo_in(char *str)
char * char *
lo_out(Blob * addr) lo_out(Blob * addr)
{ {
char *result; char *result;
if (addr == NULL) if (addr == NULL)
return (NULL); return (NULL);
result = (char *) palloc(32); result = (char *) palloc(32);
sprintf(result,"%d",*addr); sprintf(result, "%d", *addr);
return (result); return (result);
} }
/* /*
* This function converts Blob to oid. * This function converts Blob to oid.
* *
* eg: select lo_export(raster::oid,'/path/file') from table; * eg: select lo_export(raster::oid,'/path/file') from table;
* *
*/ */
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);
} }
/* /*
* This function is used so we can convert oid's to lo's * This function is used so we can convert oid's to lo's
* *
* ie: insert into table values(lo_import('/path/file')::lo); * ie: insert into table values(lo_import('/path/file')::lo);
* *
*/ */
Blob * Blob *
lo(Oid oid) lo(Oid oid)
{ {
Blob *result = (Blob *) palloc(sizeof(Blob)); Blob *result = (Blob *) palloc(sizeof(Blob));
*result = oid;
return (result); *result = oid;
return (result);
} }
/* /*
...@@ -140,74 +142,77 @@ lo(Oid oid) ...@@ -140,74 +142,77 @@ lo(Oid oid)
HeapTuple HeapTuple
lo_manage(void) lo_manage(void)
{ {
int attnum; /* attribute number to monitor */ int attnum; /* attribute number to monitor */
char **args; /* Args containing attr name */ char **args; /* Args containing attr name */
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)
elog(ERROR, "lo: triggers are not initialized"); elog(ERROR, "lo: triggers are not initialized");
/* /*
* Fetch some values from CurrentTriggerData * Fetch some values from CurrentTriggerData
*/ */
newtuple = CurrentTriggerData->tg_newtuple; newtuple = CurrentTriggerData->tg_newtuple;
trigtuple = CurrentTriggerData->tg_trigtuple; trigtuple = CurrentTriggerData->tg_trigtuple;
tupdesc = CurrentTriggerData->tg_relation->rd_att; tupdesc = CurrentTriggerData->tg_relation->rd_att;
args = CurrentTriggerData->tg_trigger->tgargs; args = CurrentTriggerData->tg_trigger->tgargs;
/* tuple to return to Executor */ /* tuple to return to Executor */
if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
rettuple = newtuple; rettuple = newtuple;
else else
rettuple = trigtuple; rettuple = trigtuple;
/* Are we deleting the row? */ /* Are we deleting the row? */
isdelete = TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event); isdelete = TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event);
/* Were done with it */ /* Were done with it */
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)))
lo_unlink(atoi(orig)); if ((orig != newv && (orig == NULL || newv == NULL)) || (orig != NULL && newv != NULL && strcmp(orig, newv)))
lo_unlink(atoi(orig));
if(newv)
pfree(newv); if (newv)
if(orig) pfree(newv);
pfree(orig); if (orig)
} pfree(orig);
/*
* Handle deleting of rows
*
* Here, we unlink the large object associated with the managed attribute
*
*/
if(isdelete) {
char *orig = SPI_getvalue(trigtuple,tupdesc,attnum);
if(orig != NULL) {
lo_unlink(atoi(orig));
pfree(orig);
} }
}
/*
return (rettuple); * Handle deleting of rows
*
* Here, we unlink the large object associated with the managed attribute
*
*/
if (isdelete)
{
char *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
if (orig != NULL)
{
lo_unlink(atoi(orig));
pfree(orig);
}
}
return (rettuple);
} }
This diff is collapsed.
...@@ -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,14 +69,15 @@ assert_test(int val) ...@@ -68,14 +69,15 @@ assert_test(int val)
{ {
return assertTest(val); return assertTest(val);
} }
#endif #endif
/* end of file */ /* end of file */
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
* End: * End:
*/ */
...@@ -7,16 +7,18 @@ int unlisten(char *relname); ...@@ -7,16 +7,18 @@ 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
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
* End: * End:
*/ */
...@@ -12,7 +12,7 @@ HeapTuple noup(void); ...@@ -12,7 +12,7 @@ HeapTuple noup(void);
* noup () -- revoke permission on column * noup () -- revoke permission on column
* *
* Though it's called without args You have to specify referenced * Though it's called without args You have to specify referenced
* table/column while creating trigger: * table/column while creating trigger:
* EXECUTE PROCEDURE noup ('col'). * EXECUTE PROCEDURE noup ('col').
*/ */
...@@ -98,8 +98,8 @@ noup() ...@@ -98,8 +98,8 @@ 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;
} }
......
#undef PORTNAME #undef PORTNAME
#define PORTNAME OS2 #define PORTNAME OS2
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* c.h-- * c.h--
...@@ -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,7 +65,8 @@ ...@@ -65,7 +65,8 @@
#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
* default. This can be overriden by command options, environment variables, * default. This can be overriden by command options, environment variables,
* and the postconfig hook. (set by build script) * and the postconfig hook. (set by build script)
*/ */
#define DEF_PGPORT "5432" #define DEF_PGPORT "5432"
......
...@@ -206,28 +206,30 @@ on_error_continue() ...@@ -206,28 +206,30 @@ on_error_continue()
** get_result ** get_result
** **
*/ */
PGresult *get_result() PGresult *
get_result()
{ {
char *cmdstatus = PQcmdStatus(res); char *cmdstatus = PQcmdStatus(res);
was_get_unset_result = TRUE; was_get_unset_result = TRUE;
/* 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;
} }
/* /*
** **
** set_result ** set_result
** **
*/ */
void set_result(PGresult *newres) void
set_result(PGresult *newres)
{ {
char *cmdstatus = PQcmdStatus(res); char *cmdstatus = PQcmdStatus(res);
if (newres == NULL) if (newres == NULL)
halt("set_result called with null result pointer\n"); halt("set_result called with null result pointer\n");
...@@ -256,9 +258,10 @@ void set_result(PGresult *newres) ...@@ -256,9 +258,10 @@ 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);
if (oldres == NULL) if (oldres == NULL)
halt("unset_result called with null result pointer\n"); halt("unset_result called with null result pointer\n");
...@@ -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;
} }
...@@ -11,8 +11,8 @@ int fetchwithnulls(void *param,...); ...@@ -11,8 +11,8 @@ int fetchwithnulls(void *param,...);
void on_error_continue(); void on_error_continue();
void on_error_stop(); void on_error_stop();
PGresult *get_result(); PGresult *get_result();
void set_result(PGresult *newres); void set_result(PGresult *newres);
void unset_result(PGresult *oldres); void unset_result(PGresult *oldres);
void reset_fetch(); void reset_fetch();
#define END_OF_TUPLES (-1) #define END_OF_TUPLES (-1)
...@@ -7,7 +7,7 @@ a modification datetime stamp in a record when that record is UPDATEd. ...@@ -7,7 +7,7 @@ a modification datetime stamp in a record when that record is UPDATEd.
Credits Credits
This is 95%+ based on autoinc.c, which I used as a starting point as I do This is 95%+ based on autoinc.c, which I used as a starting point as I do
not really know what I am doing. I also had help from not really know what I am doing. I also had help from
Jan Wieck <jwieck@debis.com> who told me about the datetime_in("now") function. Jan Wieck <jwieck@debis.com> who told me about the datetime_in("now") function.
OH, me, I'm Terry Mackintosh <terry@terrym.com> OH, me, I'm Terry Mackintosh <terry@terrym.com>
*/ */
...@@ -17,17 +17,18 @@ OH, me, I'm Terry Mackintosh <terry@terrym.com> ...@@ -17,17 +17,18 @@ 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 */
int attnum; /* positional number of field to change */ int attnum; /* positional number of field to change */
Datum newdt; /* The current datetime. */ Datum newdt; /* The current datetime. */
char **args; /* arguments */ char **args; /* arguments */
char *relname; /* triggered relation name */ char *relname; /* triggered relation name */
Relation rel; /* triggered relation */ Relation rel; /* triggered relation */
HeapTuple rettuple = NULL; HeapTuple rettuple = NULL;
TupleDesc tupdesc; /* tuple description */ TupleDesc tupdesc; /* tuple description */
if (!CurrentTriggerData) if (!CurrentTriggerData)
elog(ERROR, "moddatetime: triggers are not initialized."); elog(ERROR, "moddatetime: triggers are not initialized.");
...@@ -65,28 +66,31 @@ HeapTuple moddatetime() ...@@ -65,28 +66,31 @@ 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]);
/* 1 is the number of items in the arrays attnum and newdt. /* 1 is the number of items in the arrays attnum and newdt.
attnum is the positional number of the field to be updated. attnum is the positional number of the field to be updated.
newdt is the new datetime stamp. newdt is the new datetime stamp.
NOTE that attnum and newdt are not arrays, but then a 1 ellement array NOTE that attnum and newdt are not arrays, but then a 1 ellement array
......
#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));
}
} }
...@@ -60,8 +60,8 @@ check_primary_key() ...@@ -60,8 +60,8 @@ 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
elog(NOTICE,"Check_foreign_key Enter Function"); #ifdef DEBUG_QUERY
elog(NOTICE, "Check_foreign_key Enter Function");
#endif #endif
/* /*
* Some checks first... * Some checks first...
*/ */
...@@ -275,12 +277,12 @@ check_foreign_key() ...@@ -275,12 +277,12 @@ 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;
args = trigger->tgargs; args = trigger->tgargs;
...@@ -288,7 +290,7 @@ check_foreign_key() ...@@ -288,7 +290,7 @@ check_foreign_key()
if (nargs < 5) /* nrefs, action, key, Relation, key - at if (nargs < 5) /* nrefs, action, key, Relation, key - at
* least */ * least */
elog(ERROR, "check_foreign_key: too short %d (< 5) list of arguments", nargs); elog(ERROR, "check_foreign_key: too short %d (< 5) list of arguments", nargs);
nrefs = pg_atoi(args[0], sizeof(int), 0); nrefs = pg_atoi(args[0], sizeof(int), 0);
if (nrefs < 1) if (nrefs < 1)
elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs); elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs);
...@@ -386,7 +388,7 @@ check_foreign_key() ...@@ -386,7 +388,7 @@ check_foreign_key()
if (plan->nplans <= 0) /* Get typeId of column */ if (plan->nplans <= 0) /* Get typeId of column */
argtypes[i] = SPI_gettypeid(tupdesc, fnumber); argtypes[i] = SPI_gettypeid(tupdesc, fnumber);
} }
args_temp = args; args_temp = args;
nargs -= nkeys; nargs -= nkeys;
args += nkeys; args += nkeys;
...@@ -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 =
...@@ -417,50 +420,59 @@ check_foreign_key() ...@@ -417,50 +420,59 @@ check_foreign_key()
* For 'C'ascade action we construct DELETE query - DELETE * For 'C'ascade action we construct DELETE query - DELETE
* 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'){
if (is_update == 1)
{ else if (action == 'c')
int fn; {
char *nv; if (is_update == 1)
int k ;
sprintf(sql, "update %s set ", relname);
for (k = 1; k <= nkeys; k++)
{ {
int is_char_type =0; int fn;
char *type; char *nv;
int k;
fn = SPI_fnumber(tupdesc, args_temp[k-1]);
nv = SPI_getvalue(newtuple, tupdesc, fn); sprintf(sql, "update %s set ", relname);
type=SPI_gettype(tupdesc,fn); for (k = 1; k <= nkeys; k++)
{
if ( (strcmp(type,"text") && strcmp (type,"varchar") && int is_char_type = 0;
strcmp(type,"char") && strcmp (type,"bpchar") && char *type;
strcmp(type,"date") && strcmp (type,"datetime")) == 0 )
is_char_type=1; fn = SPI_fnumber(tupdesc, args_temp[k - 1]);
#ifdef DEBUG_QUERY nv = SPI_getvalue(newtuple, tupdesc, fn);
elog(NOTICE,"Check_foreign_key Debug value %s type %s %d", type = SPI_gettype(tupdesc, fn);
nv,type,is_char_type);
if ((strcmp(type, "text") && strcmp(type, "varchar") &&
strcmp(type, "char") && strcmp(type, "bpchar") &&
strcmp(type, "date") && strcmp(type, "datetime")) == 0)
is_char_type = 1;
#ifdef DEBUG_QUERY
elog(NOTICE, "Check_foreign_key Debug value %s type %s %d",
nv, type, is_char_type);
#endif #endif
/* is_char_type =1 i set ' ' for define a new value
*/ /*
sprintf(sql + strlen(sql), " %s = %s%s%s %s ", * is_char_type =1 i set ' ' for define a new
args2[k], (is_char_type>0) ? "'" :"" , * value
nv, (is_char_type >0) ? "'" :"",(k < nkeys) ? ", " : ""); */
is_char_type=0; sprintf(sql + strlen(sql), " %s = %s%s%s %s ",
args2[k], (is_char_type > 0) ? "'" : "",
nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : "");
is_char_type = 0;
}
strcat(sql, " where ");
} }
strcat(sql, " where "); else
/* DELETE */
} sprintf(sql, "delete from %s where ", relname);
else /* DELETE */
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 [...]]
...@@ -500,15 +512,15 @@ check_foreign_key() ...@@ -500,15 +512,15 @@ check_foreign_key()
elog(ERROR, "check_foreign_key: SPI_saveplan returned %d", SPI_result); elog(ERROR, "check_foreign_key: SPI_saveplan returned %d", SPI_result);
plan->splan[r] = pplan; plan->splan[r] = pplan;
args2 += nkeys + 1; /* to the next relation */ args2 += nkeys + 1; /* to the next relation */
} }
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
} }
/* /*
* If UPDATE and key is not changed ... * If UPDATE and key is not changed ...
*/ */
......
...@@ -352,14 +352,15 @@ c_charin(char *str) ...@@ -352,14 +352,15 @@ 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 */
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
* End: * End:
*/ */
...@@ -14,14 +14,15 @@ char *c_varcharout(char *s); ...@@ -14,14 +14,15 @@ 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
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
* End: * End:
*/ */
...@@ -29,7 +29,7 @@ user_lock(unsigned int id1, unsigned int id2, LOCKMODE lockmode) ...@@ -29,7 +29,7 @@ user_lock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
LOCKTAG tag; LOCKTAG tag;
memset(&tag, 0, sizeof(LOCKTAG)); memset(&tag, 0, sizeof(LOCKTAG));
tag.dbId = MyDatabaseId; tag.dbId = MyDatabaseId;
tag.relId = 0; tag.relId = 0;
tag.tupleId.ip_blkid.bi_hi = id2 >> 16; tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff; tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
...@@ -44,7 +44,7 @@ user_unlock(unsigned int id1, unsigned int id2, LOCKMODE lockmode) ...@@ -44,7 +44,7 @@ user_unlock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
LOCKTAG tag; LOCKTAG tag;
memset(&tag, 0, sizeof(LOCKTAG)); memset(&tag, 0, sizeof(LOCKTAG));
tag.dbId = MyDatabaseId; tag.dbId = MyDatabaseId;
tag.relId = 0; tag.relId = 0;
tag.tupleId.ip_blkid.bi_hi = id2 >> 16; tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff; tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
...@@ -99,8 +99,8 @@ user_unlock_all() ...@@ -99,8 +99,8 @@ user_unlock_all()
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
* End: * End:
*/ */
...@@ -13,8 +13,8 @@ int user_unlock_all(void); ...@@ -13,8 +13,8 @@ int user_unlock_all(void);
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
* End: * End:
*/ */
...@@ -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,177 +25,187 @@ ...@@ -25,177 +25,187 @@
#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,
char buf[BUFSIZE]; *res2;
int matched=0; /* Number matched per scan */ char buf[BUFSIZE];
int i; int matched = 0; /* Number matched per scan */
int i;
conn = PQsetdb(NULL, NULL, NULL, NULL, database);
conn = PQsetdb(NULL, NULL, NULL, NULL, database);
/* check to see that the backend connection was successfully made */
if (PQstatus(conn) == CONNECTION_BAD) /* check to see that the backend connection was successfully made */
if (PQstatus(conn) == CONNECTION_BAD)
{ {
fprintf(stderr, "Connection to database '%s' failed.\n", database); fprintf(stderr, "Connection to database '%s' failed.\n", database);
fprintf(stderr, "%s", PQerrorMessage(conn)); fprintf(stderr, "%s", PQerrorMessage(conn));
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");
PQfinish(conn);
return -1;
}
PQclear(res);
/*
* Now find any candidate tables who have columns of type oid (the column
* oid is ignored, as it has attnum < 1)
*/
buf[0]='\0';
strcat(buf,"SELECT c.relname, a.attname ");
strcat(buf,"FROM pg_class c, pg_attribute a, pg_type t ");
strcat(buf,"WHERE a.attnum > 0 ");
strcat(buf," AND a.attrelid = c.oid ");
strcat(buf," AND a.atttypid = t.oid ");
strcat(buf," AND t.typname = 'oid' ");
strcat(buf," AND c.relname NOT LIKE 'pg_%'");
if(!(res = PQexec(conn,buf))) {
fprintf(stderr,"Failed to create temp table.\n");
PQfinish(conn);
return -1;
}
for(i=0;i<PQntuples(res);i++)
{ {
char *table,*field; fprintf(stderr, "Failed to create temp table.\n");
table = PQgetvalue(res,i,0);
field = PQgetvalue(res,i,1);
if(verbose) {
fprintf(stdout,"Checking %s in %s: ",field,table);
fflush(stdout);
}
res2 = PQexec(conn, "begin");
PQclear(res2);
buf[0] = '\0';
strcat(buf,"DELETE FROM vacuum_l ");
strcat(buf,"WHERE lo IN (");
strcat(buf,"SELECT ");
strcat(buf,field);
strcat(buf," FROM ");
strcat(buf,table);
strcat(buf,");");
if(!(res2 = PQexec(conn,buf))) {
fprintf(stderr,"Failed to check %s in table %s\n",field,table);
PQclear(res);
PQfinish(conn); PQfinish(conn);
return -1; return -1;
} }
if(PQresultStatus(res2)!=PGRES_COMMAND_OK) { PQclear(res);
fprintf(stderr,
"Failed to check %s in table %s\n%s\n", /*
field,table, * Now find any candidate tables who have columns of type oid (the
PQerrorMessage(conn) * column oid is ignored, as it has attnum < 1)
); */
PQclear(res2); buf[0] = '\0';
PQclear(res); strcat(buf, "SELECT c.relname, a.attname ");
strcat(buf, "FROM pg_class c, pg_attribute a, pg_type t ");
strcat(buf, "WHERE a.attnum > 0 ");
strcat(buf, " AND a.attrelid = c.oid ");
strcat(buf, " AND a.atttypid = t.oid ");
strcat(buf, " AND t.typname = 'oid' ");
strcat(buf, " AND c.relname NOT LIKE 'pg_%'");
if (!(res = PQexec(conn, buf)))
{
fprintf(stderr, "Failed to create temp table.\n");
PQfinish(conn); PQfinish(conn);
return -1; return -1;
} }
PQclear(res2); for (i = 0; i < PQntuples(res); i++)
{
char *table,
*field;
table = PQgetvalue(res, i, 0);
field = PQgetvalue(res, i, 1);
if (verbose)
{
fprintf(stdout, "Checking %s in %s: ", field, table);
fflush(stdout);
}
res2 = PQexec(conn, "begin");
PQclear(res2);
buf[0] = '\0';
strcat(buf, "DELETE FROM vacuum_l ");
strcat(buf, "WHERE lo IN (");
strcat(buf, "SELECT ");
strcat(buf, field);
strcat(buf, " FROM ");
strcat(buf, table);
strcat(buf, ");");
if (!(res2 = PQexec(conn, buf)))
{
fprintf(stderr, "Failed to check %s in table %s\n", field, table);
PQclear(res);
PQfinish(conn);
return -1;
}
if (PQresultStatus(res2) != PGRES_COMMAND_OK)
{
fprintf(stderr,
"Failed to check %s in table %s\n%s\n",
field, table,
PQerrorMessage(conn)
);
PQclear(res2);
PQclear(res);
PQfinish(conn);
return -1;
}
PQclear(res2);
res2 = PQexec(conn, "end");
PQclear(res2);
res2 = PQexec(conn, "end");
PQclear(res2);
} }
PQclear(res); PQclear(res);
/* Start the transaction */ /* Start the transaction */
res = PQexec(conn, "begin"); res = PQexec(conn, "begin");
PQclear(res); PQclear(res);
/* /*
* 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");
PQfinish(conn);
return -1;
}
matched=PQntuples(res);
for(i=0;i<matched;i++)
{ {
Oid lo = (Oid) atoi(PQgetvalue(res,i,0)); fprintf(stderr, "Failed to read temp table.\n");
PQfinish(conn);
if(verbose) { return -1;
fprintf(stdout,"\rRemoving lo %6d \n",lo); }
fflush(stdout); matched = PQntuples(res);
} for (i = 0; i < matched; i++)
{
if(lo_unlink(conn,lo)<0) { Oid lo = (Oid) atoi(PQgetvalue(res, i, 0));
fprintf(stderr,"Failed to remove lo %d\n",lo);
} if (verbose)
{
fprintf(stdout, "\rRemoving lo %6d \n", lo);
fflush(stdout);
}
if (lo_unlink(conn, lo) < 0)
fprintf(stderr, "Failed to remove lo %d\n", lo);
} }
PQclear(res); PQclear(res);
/* /*
* That's all folks! * That's all folks!
*/ */
res = PQexec(conn, "end"); res = PQexec(conn, "end");
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;
} }
int int
main(int argc, char **argv) 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)
{ {
fprintf(stderr, "Usage: %s [-v] database_name [db2 ... dbn]\n", fprintf(stderr, "Usage: %s [-v] database_name [db2 ... dbn]\n",
argv[0]); argv[0]);
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)
else verbose = !verbose;
rc += vacuumlo(argv[arg],verbose); else
} 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]);
} }
} }
...@@ -210,7 +210,7 @@ heap_attisnull(HeapTuple tup, int attnum) ...@@ -210,7 +210,7 @@ heap_attisnull(HeapTuple tup, int attnum)
int int
heap_sysattrlen(AttrNumber attno) heap_sysattrlen(AttrNumber attno)
{ {
HeapTupleHeader f = NULL; HeapTupleHeader f = NULL;
switch (attno) switch (attno)
{ {
...@@ -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
/* ---------------- /* ----------------
...@@ -328,11 +329,11 @@ nocachegetattr(HeapTuple tuple, ...@@ -328,11 +329,11 @@ nocachegetattr(HeapTuple tuple,
TupleDesc tupleDesc, TupleDesc tupleDesc,
bool *isnull) bool *isnull)
{ {
char *tp; /* ptr to att in tuple */ char *tp; /* ptr to att in tuple */
HeapTupleHeader tup = tuple->t_data; HeapTupleHeader tup = tuple->t_data;
bits8 *bp = tup->t_bits; /* ptr to att in tuple */ bits8 *bp = tup->t_bits; /* ptr to att in tuple */
Form_pg_attribute *att = tupleDesc->attrs; Form_pg_attribute *att = tupleDesc->attrs;
int slow = 0; /* do we have to walk nulls? */ int slow = 0; /* do we have to walk nulls? */
#if IN_MACRO #if IN_MACRO
...@@ -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)
{ {
...@@ -570,7 +574,7 @@ heap_copytuple(HeapTuple tuple) ...@@ -570,7 +574,7 @@ heap_copytuple(HeapTuple tuple)
newTuple->t_len = tuple->t_len; newTuple->t_len = tuple->t_len;
newTuple->t_self = tuple->t_self; newTuple->t_self = tuple->t_self;
newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE); newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
memmove((char *) newTuple->t_data, memmove((char *) newTuple->t_data,
(char *) tuple->t_data, (int) tuple->t_len); (char *) tuple->t_data, (int) tuple->t_len);
return newTuple; return newTuple;
} }
...@@ -589,11 +593,11 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest) ...@@ -589,11 +593,11 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
dest->t_data = NULL; dest->t_data = NULL;
return; return;
} }
dest->t_len = src->t_len; dest->t_len = src->t_len;
dest->t_self = src->t_self; dest->t_self = src->t_self;
dest->t_data = (HeapTupleHeader) palloc(src->t_len); dest->t_data = (HeapTupleHeader) palloc(src->t_len);
memmove((char *) dest->t_data, memmove((char *) dest->t_data,
(char *) src->t_data, (int) src->t_len); (char *) src->t_data, (int) src->t_len);
return; return;
} }
...@@ -657,14 +661,14 @@ heap_formtuple(TupleDesc tupleDescriptor, ...@@ -657,14 +661,14 @@ heap_formtuple(TupleDesc tupleDescriptor,
Datum *value, Datum *value,
char *nulls) char *nulls)
{ {
HeapTuple tuple; /* return tuple */ HeapTuple tuple; /* return tuple */
HeapTupleHeader td; /* tuple data */ HeapTupleHeader td; /* tuple data */
int bitmaplen; int bitmaplen;
long len; long len;
int hoff; int hoff;
bool hasnull = false; bool hasnull = false;
int i; int i;
int numberOfAttributes = tupleDescriptor->natts; int numberOfAttributes = tupleDescriptor->natts;
len = offsetof(HeapTupleHeaderData, t_bits); len = offsetof(HeapTupleHeaderData, t_bits);
...@@ -760,9 +764,9 @@ heap_modifytuple(HeapTuple tuple, ...@@ -760,9 +764,9 @@ heap_modifytuple(HeapTuple tuple,
if (repl[attoff] == ' ') if (repl[attoff] == ' ')
{ {
value[attoff] = heap_getattr(tuple, value[attoff] = heap_getattr(tuple,
AttrOffsetGetAttrNumber(attoff), AttrOffsetGetAttrNumber(attoff),
RelationGetDescr(relation), RelationGetDescr(relation),
&isNull); &isNull);
nulls[attoff] = (isNull) ? 'n' : ' '; nulls[attoff] = (isNull) ? 'n' : ' ';
} }
...@@ -790,12 +794,12 @@ heap_modifytuple(HeapTuple tuple, ...@@ -790,12 +794,12 @@ heap_modifytuple(HeapTuple tuple,
infomask = newTuple->t_data->t_infomask; infomask = newTuple->t_data->t_infomask;
memmove((char *) &newTuple->t_data->t_oid, /* XXX */ memmove((char *) &newTuple->t_data->t_oid, /* XXX */
(char *) &tuple->t_data->t_oid, (char *) &tuple->t_data->t_oid,
((char *) &tuple->t_data->t_hoff - ((char *) &tuple->t_data->t_hoff -
(char *) &tuple->t_data->t_oid)); /* XXX */ (char *) &tuple->t_data->t_oid)); /* XXX */
newTuple->t_data->t_infomask = infomask; newTuple->t_data->t_infomask = infomask;
newTuple->t_data->t_natts = numberOfAttributes; newTuple->t_data->t_natts = numberOfAttributes;
newTuple->t_self = tuple->t_self; newTuple->t_self = tuple->t_self;
return newTuple; return newTuple;
} }
...@@ -809,10 +813,10 @@ heap_addheader(uint32 natts, /* max domain index */ ...@@ -809,10 +813,10 @@ heap_addheader(uint32 natts, /* max domain index */
int structlen, /* its length */ int structlen, /* its length */
char *structure) /* pointer to the struct */ char *structure) /* pointer to the struct */
{ {
HeapTuple tuple; HeapTuple tuple;
HeapTupleHeader td; /* tuple data */ HeapTupleHeader td; /* tuple data */
long len; long len;
int hoff; int hoff;
AssertArg(natts > 0); AssertArg(natts > 0);
......
...@@ -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,27 +71,29 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem) ...@@ -70,27 +71,29 @@ 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 */ {
TupleDesc attrinfo; /* The attr info we are set up for */ DestReceiver pub; /* publicly-known function pointers */
int nattrs; TupleDesc attrinfo; /* The attr info we are set up for */
PrinttupAttrInfo *myinfo; /* Cached info about each attr */ int nattrs;
} DR_printtup; PrinttupAttrInfo *myinfo; /* Cached info about each attr */
} DR_printtup;
/* ---------------- /* ----------------
* 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,42 +103,43 @@ printtup_create_DR() ...@@ -100,42 +103,43 @@ 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
* until the first call of printtup, for 3 reasons: * until the first call of printtup, for 3 reasons:
* 1. We don't waste time (compared to the old way) if there are no * 1. We don't waste time (compared to the old way) if there are no
* tuples at all to output. * tuples at all to output.
* 2. Checking in printtup allows us to handle the case that the tuples * 2. Checking in printtup allows us to handle the case that the tuples
* change type midway through (although this probably can't happen in * change type midway through (although this probably can't happen in
* the current executor). * the current executor).
* 3. Right now, ExecutorRun passes a NULL for typeinfo anyway :-( * 3. Right now, ExecutorRun passes a NULL for typeinfo anyway :-(
* ---------------- * ----------------
*/ */
} }
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;
if (myState->myinfo) if (myState->myinfo)
pfree(myState->myinfo); /* get rid of any old data */ pfree(myState->myinfo); /* get rid of any old data */
myState->myinfo = NULL; myState->myinfo = NULL;
myState->attrinfo = typeinfo; myState->attrinfo = typeinfo;
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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <access/skey.h> #include <access/skey.h>
/* /*
* ScanKeyEntryIsLegal * ScanKeyEntryIsLegal
* True iff the scan key entry is legal. * True iff the scan key entry is legal.
*/ */
#define ScanKeyEntryIsLegal(entry) \ #define ScanKeyEntryIsLegal(entry) \
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
) )
/* /*
* ScanKeyEntrySetIllegal * ScanKeyEntrySetIllegal
* Marks a scan key entry as illegal. * Marks a scan key entry as illegal.
*/ */
void void
...@@ -43,7 +43,7 @@ ScanKeyEntrySetIllegal(ScanKey entry) ...@@ -43,7 +43,7 @@ ScanKeyEntrySetIllegal(ScanKey entry)
} }
/* /*
* ScanKeyEntryInitialize * ScanKeyEntryInitialize
* Initializes an scan key entry. * Initializes an scan key entry.
* *
* Note: * Note:
......
...@@ -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
...@@ -487,7 +487,7 @@ BuildDescForRelation(List *schema, char *relname) ...@@ -487,7 +487,7 @@ BuildDescForRelation(List *schema, char *relname)
{ {
/* array of XXX is _XXX */ /* array of XXX is _XXX */
snprintf(typename, NAMEDATALEN, snprintf(typename, NAMEDATALEN,
"_%.*s", NAMEDATALEN - 2, entry->typename->name); "_%.*s", NAMEDATALEN - 2, entry->typename->name);
attdim = length(arry); attdim = length(arry);
} }
else else
......
...@@ -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,9 +485,9 @@ hashrestrpos(IndexScanDesc scan) ...@@ -485,9 +485,9 @@ 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);
scan->currentItemData = scan->currentMarkData; scan->currentItemData = scan->currentMarkData;
} }
......
...@@ -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
...@@ -321,7 +321,7 @@ _hash_setpagelock(Relation rel, ...@@ -321,7 +321,7 @@ _hash_setpagelock(Relation rel,
{ {
switch (access) switch (access)
{ {
case HASH_WRITE: case HASH_WRITE:
LockPage(rel, blkno, ExclusiveLock); LockPage(rel, blkno, ExclusiveLock);
break; break;
case HASH_READ: case HASH_READ:
...@@ -345,7 +345,7 @@ _hash_unsetpagelock(Relation rel, ...@@ -345,7 +345,7 @@ _hash_unsetpagelock(Relation rel,
{ {
switch (access) switch (access)
{ {
case HASH_WRITE: case HASH_WRITE:
UnlockPage(rel, blkno, ExclusiveLock); UnlockPage(rel, blkno, ExclusiveLock);
break; break;
case HASH_READ: case HASH_READ:
......
...@@ -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
...@@ -117,7 +117,7 @@ initscan(HeapScanDesc scan, ...@@ -117,7 +117,7 @@ initscan(HeapScanDesc scan,
* relation is empty * relation is empty
* ---------------- * ----------------
*/ */
scan->rs_ntup.t_data = scan->rs_ctup.t_data = scan->rs_ntup.t_data = scan->rs_ctup.t_data =
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer; scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
} }
...@@ -216,15 +216,15 @@ heapgettup(Relation relation, ...@@ -216,15 +216,15 @@ heapgettup(Relation relation,
int nkeys, int nkeys,
ScanKey key) ScanKey key)
{ {
ItemId lpp; ItemId lpp;
Page dp; Page dp;
int page; int page;
int pages; int pages;
int lines; int lines;
OffsetNumber lineoff; OffsetNumber lineoff;
int linesleft; int linesleft;
ItemPointer tid = (tuple->t_data == NULL) ? ItemPointer tid = (tuple->t_data == NULL) ?
(ItemPointer) NULL : &(tuple->t_self); (ItemPointer) NULL : &(tuple->t_self);
/* ---------------- /* ----------------
* increment access statistics * increment access statistics
...@@ -290,8 +290,8 @@ heapgettup(Relation relation, ...@@ -290,8 +290,8 @@ heapgettup(Relation relation,
return; return;
} }
*buffer = RelationGetBufferWithBuffer(relation, *buffer = RelationGetBufferWithBuffer(relation,
ItemPointerGetBlockNumber(tid), ItemPointerGetBlockNumber(tid),
*buffer); *buffer);
if (!BufferIsValid(*buffer)) if (!BufferIsValid(*buffer))
elog(ERROR, "heapgettup: failed ReadBuffer"); elog(ERROR, "heapgettup: failed ReadBuffer");
...@@ -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
...@@ -966,11 +969,11 @@ heap_fetch(Relation relation, ...@@ -966,11 +969,11 @@ heap_fetch(Relation relation,
HeapTuple tuple, HeapTuple tuple,
Buffer *userbuf) Buffer *userbuf)
{ {
ItemId lp; ItemId lp;
Buffer buffer; Buffer buffer;
PageHeader dp; PageHeader dp;
ItemPointer tid = &(tuple->t_self); ItemPointer tid = &(tuple->t_self);
OffsetNumber offnum; OffsetNumber offnum;
AssertMacro(PointerIsValid(userbuf)); /* see comments above */ AssertMacro(PointerIsValid(userbuf)); /* see comments above */
...@@ -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;
} }
...@@ -1106,11 +1107,11 @@ heap_insert(Relation relation, HeapTuple tup) ...@@ -1106,11 +1107,11 @@ heap_insert(Relation relation, HeapTuple tup)
int int
heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
{ {
ItemId lp; ItemId lp;
HeapTupleData tp; HeapTupleData tp;
PageHeader dp; PageHeader dp;
Buffer buffer; Buffer buffer;
int result; int result;
/* increment access statistics */ /* increment access statistics */
IncrHeapAccessStat(local_delete); IncrHeapAccessStat(local_delete);
...@@ -1130,10 +1131,10 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) ...@@ -1130,10 +1131,10 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
tp.t_len = ItemIdGetLength(lp); tp.t_len = ItemIdGetLength(lp);
tp.t_self = *tid; tp.t_self = *tid;
l1: l1:
result = HeapTupleSatisfiesUpdate(&tp); result = HeapTupleSatisfiesUpdate(&tp);
if (result == HeapTupleInvisible) if (result == HeapTupleInvisible)
{ {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
...@@ -1142,7 +1143,7 @@ l1: ...@@ -1142,7 +1143,7 @@ l1:
} }
else if (result == HeapTupleBeingUpdated) else if (result == HeapTupleBeingUpdated)
{ {
TransactionId xwait = tp.t_data->t_xmax; TransactionId xwait = tp.t_data->t_xmax;
/* sleep untill concurrent transaction ends */ /* sleep untill concurrent transaction ends */
LockBuffer(buffer, BUFFER_LOCK_UNLOCK); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
...@@ -1177,8 +1178,8 @@ l1: ...@@ -1177,8 +1178,8 @@ l1:
/* store transaction information of xact deleting the tuple */ /* store transaction information of xact deleting the tuple */
TransactionIdStore(GetCurrentTransactionId(), &(tp.t_data->t_xmax)); TransactionIdStore(GetCurrentTransactionId(), &(tp.t_data->t_xmax));
tp.t_data->t_cmax = GetCurrentCommandId(); tp.t_data->t_cmax = GetCurrentCommandId();
tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE); HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
LockBuffer(buffer, BUFFER_LOCK_UNLOCK); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
...@@ -1194,14 +1195,14 @@ l1: ...@@ -1194,14 +1195,14 @@ l1:
* heap_replace - replace a tuple * heap_replace - replace a tuple
*/ */
int int
heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup, heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup,
ItemPointer ctid) ItemPointer ctid)
{ {
ItemId lp; ItemId lp;
HeapTupleData oldtup; HeapTupleData oldtup;
PageHeader dp; PageHeader dp;
Buffer buffer; Buffer buffer;
int result; int result;
/* increment access statistics */ /* increment access statistics */
IncrHeapAccessStat(local_replace); IncrHeapAccessStat(local_replace);
...@@ -1223,7 +1224,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup, ...@@ -1223,7 +1224,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup,
l2: l2:
result = HeapTupleSatisfiesUpdate(&oldtup); result = HeapTupleSatisfiesUpdate(&oldtup);
if (result == HeapTupleInvisible) if (result == HeapTupleInvisible)
{ {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
...@@ -1232,7 +1233,7 @@ l2: ...@@ -1232,7 +1233,7 @@ l2:
} }
else if (result == HeapTupleBeingUpdated) else if (result == HeapTupleBeingUpdated)
{ {
TransactionId xwait = oldtup.t_data->t_xmax; TransactionId xwait = oldtup.t_data->t_xmax;
/* sleep untill concurrent transaction ends */ /* sleep untill concurrent transaction ends */
LockBuffer(buffer, BUFFER_LOCK_UNLOCK); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
...@@ -1275,19 +1276,20 @@ l2: ...@@ -1275,19 +1276,20 @@ l2:
/* logically delete old item */ /* logically delete old item */
TransactionIdStore(GetCurrentTransactionId(), &(oldtup.t_data->t_xmax)); TransactionIdStore(GetCurrentTransactionId(), &(oldtup.t_data->t_xmax));
oldtup.t_data->t_cmax = GetCurrentCommandId(); oldtup.t_data->t_cmax = GetCurrentCommandId();
oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE); HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
/* insert new item */ /* insert new item */
if ((unsigned) DOUBLEALIGN(newtup->t_len) <= PageGetFreeSpace((Page) dp)) if ((unsigned) DOUBLEALIGN(newtup->t_len) <= PageGetFreeSpace((Page) dp))
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;
...@@ -1316,10 +1318,10 @@ l2: ...@@ -1316,10 +1318,10 @@ l2:
int int
heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer) heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
{ {
ItemPointer tid = &(tuple->t_self); ItemPointer tid = &(tuple->t_self);
ItemId lp; ItemId lp;
PageHeader dp; PageHeader dp;
int result; int result;
/* increment access statistics */ /* increment access statistics */
IncrHeapAccessStat(local_mark4update); IncrHeapAccessStat(local_mark4update);
...@@ -1336,10 +1338,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer) ...@@ -1336,10 +1338,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid)); lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
tuple->t_len = ItemIdGetLength(lp); tuple->t_len = ItemIdGetLength(lp);
l3: l3:
result = HeapTupleSatisfiesUpdate(tuple); result = HeapTupleSatisfiesUpdate(tuple);
if (result == HeapTupleInvisible) if (result == HeapTupleInvisible)
{ {
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
...@@ -1348,7 +1350,7 @@ l3: ...@@ -1348,7 +1350,7 @@ l3:
} }
else if (result == HeapTupleBeingUpdated) else if (result == HeapTupleBeingUpdated)
{ {
TransactionId xwait = tuple->t_data->t_xmax; TransactionId xwait = tuple->t_data->t_xmax;
/* sleep untill concurrent transaction ends */ /* sleep untill concurrent transaction ends */
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
......
...@@ -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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -39,11 +39,11 @@ RelationPutHeapTuple(Relation relation, ...@@ -39,11 +39,11 @@ RelationPutHeapTuple(Relation relation,
Buffer buffer, Buffer buffer,
HeapTuple tuple) HeapTuple tuple)
{ {
Page pageHeader; Page pageHeader;
OffsetNumber offnum; OffsetNumber offnum;
unsigned int len; unsigned int len;
ItemId itemId; ItemId itemId;
Item item; Item item;
/* ---------------- /* ----------------
* increment access statistics * increment access statistics
...@@ -62,13 +62,13 @@ RelationPutHeapTuple(Relation relation, ...@@ -62,13 +62,13 @@ RelationPutHeapTuple(Relation relation,
itemId = PageGetItemId((Page) pageHeader, offnum); itemId = PageGetItemId((Page) pageHeader, offnum);
item = PageGetItem((Page) pageHeader, itemId); item = PageGetItem((Page) pageHeader, itemId);
ItemPointerSet(&((HeapTupleHeader) item)->t_ctid, ItemPointerSet(&((HeapTupleHeader) item)->t_ctid,
BufferGetBlockNumber(buffer), offnum); BufferGetBlockNumber(buffer), offnum);
/* /*
* 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,7 +57,7 @@ static bool StrategyTermIsValid(StrategyTerm term, ...@@ -57,7 +57,7 @@ static bool StrategyTermIsValid(StrategyTerm term,
*/ */
/* /*
* StrategyMapGetScanKeyEntry * StrategyMapGetScanKeyEntry
* Returns a scan key entry of a index strategy mapping member. * Returns a scan key entry of a index strategy mapping member.
* *
* Note: * Note:
...@@ -75,7 +75,7 @@ StrategyMapGetScanKeyEntry(StrategyMap map, ...@@ -75,7 +75,7 @@ StrategyMapGetScanKeyEntry(StrategyMap map,
} }
/* /*
* IndexStrategyGetStrategyMap * IndexStrategyGetStrategyMap
* Returns an index strategy mapping of an index strategy. * Returns an index strategy mapping of an index strategy.
* *
* Note: * Note:
...@@ -97,7 +97,7 @@ IndexStrategyGetStrategyMap(IndexStrategy indexStrategy, ...@@ -97,7 +97,7 @@ IndexStrategyGetStrategyMap(IndexStrategy indexStrategy,
} }
/* /*
* AttributeNumberGetIndexStrategySize * AttributeNumberGetIndexStrategySize
* Computes the size of an index strategy. * Computes the size of an index strategy.
*/ */
Size Size
...@@ -294,8 +294,8 @@ RelationGetStrategy(Relation relation, ...@@ -294,8 +294,8 @@ RelationGetStrategy(Relation relation,
Assert(RegProcedureIsValid(procedure)); Assert(RegProcedureIsValid(procedure));
strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(relation), strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(relation),
evaluation->maxStrategy, evaluation->maxStrategy,
attributeNumber); attributeNumber);
/* get a strategy number for the procedure ignoring flags for now */ /* get a strategy number for the procedure ignoring flags for now */
for (index = 0; index < evaluation->maxStrategy; index += 1) for (index = 0; index < evaluation->maxStrategy; index += 1)
...@@ -526,7 +526,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation, ...@@ -526,7 +526,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
/* /*
* IndexSupportInitialize * IndexSupportInitialize
* Initializes an index strategy and associated support procedures. * Initializes an index strategy and associated support procedures.
*/ */
void void
......
...@@ -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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -99,13 +99,13 @@ l1: ...@@ -99,13 +99,13 @@ l1:
/* key on the page before trying to compare it */ /* key on the page before trying to compare it */
if (!PageIsEmpty(page) && offset <= maxoff) if (!PageIsEmpty(page) && offset <= maxoff)
{ {
TupleDesc itupdesc; TupleDesc itupdesc;
BTItem cbti; BTItem cbti;
HeapTupleData htup; HeapTupleData htup;
BTPageOpaque opaque; BTPageOpaque opaque;
Buffer nbuf; Buffer nbuf;
BlockNumber blkno; BlockNumber blkno;
bool chtup = true; bool chtup = true;
itupdesc = RelationGetDescr(rel); itupdesc = RelationGetDescr(rel);
nbuf = InvalidBuffer; nbuf = InvalidBuffer;
...@@ -122,15 +122,16 @@ l1: ...@@ -122,15 +122,16 @@ 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)
{ {
htup.t_self = btitem->bti_itup.t_tid; htup.t_self = btitem->bti_itup.t_tid;
heap_fetch(heapRel, SnapshotDirty, &htup, &buffer); heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
if (htup.t_data == NULL) /* YES! */ if (htup.t_data == NULL) /* YES! */
break; break;
/* Live tuple was inserted */ /* Live tuple was inserted */
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
...@@ -139,11 +140,11 @@ l1: ...@@ -139,11 +140,11 @@ l1:
cbti = (BTItem) PageGetItem(page, PageGetItemId(page, offset)); cbti = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
htup.t_self = cbti->bti_itup.t_tid; htup.t_self = cbti->bti_itup.t_tid;
heap_fetch(heapRel, SnapshotDirty, &htup, &buffer); heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
if (htup.t_data != NULL) /* it is a duplicate */ if (htup.t_data != NULL) /* it is a duplicate */
{ {
TransactionId xwait = TransactionId xwait =
(TransactionIdIsValid(SnapshotDirty->xmin)) ? (TransactionIdIsValid(SnapshotDirty->xmin)) ?
SnapshotDirty->xmin : SnapshotDirty->xmax; SnapshotDirty->xmin : SnapshotDirty->xmax;
/* /*
* If this tuple is being updated by other transaction * If this tuple is being updated by other transaction
...@@ -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,10 +572,10 @@ _bt_insertonpg(Relation rel, ...@@ -571,10 +572,10 @@ _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 */
{ {
elog(DEBUG, "btree: concurrent ROOT page split"); elog(DEBUG, "btree: concurrent ROOT page split");
stack = (BTStack) palloc(sizeof(BTStackData)); stack = (BTStack) palloc(sizeof(BTStackData));
...@@ -1144,8 +1145,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) ...@@ -1144,8 +1145,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
lpage = BufferGetPage(lbuf); lpage = BufferGetPage(lbuf);
rpage = BufferGetPage(rbuf); rpage = BufferGetPage(rbuf);
((BTPageOpaque) PageGetSpecialPointer(lpage))->btpo_parent = ((BTPageOpaque) PageGetSpecialPointer(lpage))->btpo_parent =
((BTPageOpaque) PageGetSpecialPointer(rpage))->btpo_parent = ((BTPageOpaque) PageGetSpecialPointer(rpage))->btpo_parent =
rootbknum; rootbknum;
/* /*
......
...@@ -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
...@@ -421,7 +421,7 @@ _bt_pageinit(Page page, Size size) ...@@ -421,7 +421,7 @@ _bt_pageinit(Page page, Size size)
MemSet(page, 0, size); MemSet(page, 0, size);
PageInit(page, size, sizeof(BTPageOpaqueData)); PageInit(page, size, sizeof(BTPageOpaqueData));
((BTPageOpaque) PageGetSpecialPointer(page))->btpo_parent = ((BTPageOpaque) PageGetSpecialPointer(page))->btpo_parent =
InvalidBlockNumber; InvalidBlockNumber;
} }
...@@ -494,17 +494,16 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) ...@@ -494,17 +494,16 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access)
opaque = (BTPageOpaque) PageGetSpecialPointer(page); opaque = (BTPageOpaque) PageGetSpecialPointer(page);
maxoff = PageGetMaxOffsetNumber(page); maxoff = PageGetMaxOffsetNumber(page);
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.
...@@ -367,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation ...@@ -367,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
btitem = _bt_formitem(itup); btitem = _bt_formitem(itup);
res = _bt_doinsert(rel, btitem, res = _bt_doinsert(rel, btitem,
IndexIsUnique(RelationGetRelid(rel)), heapRel); IndexIsUnique(RelationGetRelid(rel)), heapRel);
pfree(btitem); pfree(btitem);
pfree(itup); pfree(itup);
...@@ -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,16 +624,15 @@ _bt_restscan(IndexScanDesc scan) ...@@ -623,16 +624,15 @@ _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))
{ {
ItemPointerSetOffsetNumber(&(scan->currentItemData), ItemPointerSetOffsetNumber(&(scan->currentItemData),
OffsetNumberPrev(P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY)); OffsetNumberPrev(P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY));
return; return;
} }
......
...@@ -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
...@@ -112,12 +112,12 @@ _bt_adjscans(Relation rel, ItemPointer tid) ...@@ -112,12 +112,12 @@ _bt_adjscans(Relation rel, ItemPointer tid)
static void static void
_bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
{ {
ItemPointer current; ItemPointer current;
Buffer buf; Buffer buf;
BTScanOpaque so; BTScanOpaque so;
OffsetNumber start; OffsetNumber start;
Page page; Page page;
BTPageOpaque opaque; BTPageOpaque opaque;
so = (BTScanOpaque) scan->opaque; so = (BTScanOpaque) scan->opaque;
buf = so->btso_curbuf; buf = so->btso_curbuf;
...@@ -140,7 +140,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) ...@@ -140,7 +140,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
{ {
Page pg = BufferGetPage(buf); Page pg = BufferGetPage(buf);
BTItem btitem = (BTItem) PageGetItem(pg, BTItem btitem = (BTItem) PageGetItem(pg,
PageGetItemId(pg, ItemPointerGetOffsetNumber(current))); PageGetItemId(pg, ItemPointerGetOffsetNumber(current)));
so->curHeapIptr = btitem->bti_itup.t_tid; so->curHeapIptr = btitem->bti_itup.t_tid;
} }
...@@ -181,7 +181,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) ...@@ -181,7 +181,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
{ {
Page pg = BufferGetPage(buf); Page pg = BufferGetPage(buf);
BTItem btitem = (BTItem) PageGetItem(pg, BTItem btitem = (BTItem) PageGetItem(pg,
PageGetItemId(pg, ItemPointerGetOffsetNumber(current))); PageGetItemId(pg, ItemPointerGetOffsetNumber(current)));
so->mrkHeapIptr = btitem->bti_itup.t_tid; so->mrkHeapIptr = btitem->bti_itup.t_tid;
} }
......
...@@ -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;
...@@ -733,8 +733,8 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) ...@@ -733,8 +733,8 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
return res; return res;
} }
} while (keysok >= so->numberOfFirstKeys || } while (keysok >= so->numberOfFirstKeys ||
(keysok == -1 && ScanDirectionIsBackward(dir))); (keysok == -1 && ScanDirectionIsBackward(dir)));
ItemPointerSetInvalid(current); ItemPointerSetInvalid(current);
so->btso_curbuf = InvalidBuffer; so->btso_curbuf = InvalidBuffer;
...@@ -776,8 +776,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ...@@ -776,8 +776,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
BTScanOpaque so; BTScanOpaque so;
ScanKeyData skdata; ScanKeyData skdata;
Size keysok; Size keysok;
int i; int i;
int nKeyIndex = -1; int nKeyIndex = -1;
rel = scan->relation; rel = scan->relation;
so = (BTScanOpaque) scan->opaque; so = (BTScanOpaque) scan->opaque;
...@@ -795,27 +795,27 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ...@@ -795,27 +795,27 @@ _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;
break; break;
} }
} }
} }
else else
{ {
strat = _bt_getstrat(rel, 1, so->keyData[0].sk_procedure); strat = _bt_getstrat(rel, 1, so->keyData[0].sk_procedure);
if (strat == BTLessStrategyNumber || if (strat == BTLessStrategyNumber ||
strat == BTLessEqualStrategyNumber) strat == BTLessEqualStrategyNumber)
; ;
else else
nKeyIndex = 0; nKeyIndex = 0;
...@@ -850,7 +850,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ...@@ -850,7 +850,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
} }
proc = index_getprocid(rel, 1, BTORDER_PROC); proc = index_getprocid(rel, 1, BTORDER_PROC);
ScanKeyEntryInitialize(&skdata, so->keyData[nKeyIndex].sk_flags, ScanKeyEntryInitialize(&skdata, so->keyData[nKeyIndex].sk_flags,
1, proc, so->keyData[nKeyIndex].sk_argument); 1, proc, so->keyData[nKeyIndex].sk_argument);
stack = _bt_search(rel, 1, &skdata, &buf); stack = _bt_search(rel, 1, &skdata, &buf);
_bt_freestack(stack); _bt_freestack(stack);
...@@ -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,16 +552,16 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique) ...@@ -552,16 +552,16 @@ _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");
for (i = 0; i < ntapes; ++i) for (i = 0; i < ntapes; ++i)
{ {
btspool->bts_itape[i] = _bt_tapecreate(); btspool->bts_itape[i] = _bt_tapecreate();
btspool->bts_otape[i] = _bt_tapecreate(); btspool->bts_otape[i] = _bt_tapecreate();
} }
_bt_isortcmpinit(index, btspool); _bt_isortcmpinit(index, btspool);
......
...@@ -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 ?!
*/ */
...@@ -374,7 +374,7 @@ TransRecover(Relation logRelation) ...@@ -374,7 +374,7 @@ TransRecover(Relation logRelation)
*/ */
/* /*
* InitializeTransactionLog * InitializeTransactionLog
* Initializes transaction logging. * Initializes transaction logging.
*/ */
void void
...@@ -484,7 +484,7 @@ InitializeTransactionLog(void) ...@@ -484,7 +484,7 @@ InitializeTransactionLog(void)
*/ */
/* /*
* TransactionIdDidCommit * TransactionIdDidCommit
* True iff transaction associated with the identifier did commit. * True iff transaction associated with the identifier did commit.
* *
* Note: * Note:
...@@ -500,7 +500,7 @@ TransactionIdDidCommit(TransactionId transactionId) ...@@ -500,7 +500,7 @@ TransactionIdDidCommit(TransactionId transactionId)
} }
/* /*
* TransactionIdDidAborted * TransactionIdDidAborted
* True iff transaction associated with the identifier did abort. * True iff transaction associated with the identifier did abort.
* *
* Note: * Note:
...@@ -541,7 +541,7 @@ TransactionIdIsInProgress(TransactionId transactionId) ...@@ -541,7 +541,7 @@ TransactionIdIsInProgress(TransactionId transactionId)
*/ */
/* /*
* TransactionIdCommit * TransactionIdCommit
* Commits the transaction associated with the identifier. * Commits the transaction associated with the identifier.
* *
* Note: * Note:
...@@ -557,7 +557,7 @@ TransactionIdCommit(TransactionId transactionId) ...@@ -557,7 +557,7 @@ TransactionIdCommit(TransactionId transactionId)
} }
/* /*
* TransactionIdAbort * TransactionIdAbort
* Aborts the transaction associated with the identifier. * Aborts the transaction associated with the identifier.
* *
* Note: * Note:
......
...@@ -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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -260,7 +260,7 @@ VariableRelationPutNextOid(Oid *oidP) ...@@ -260,7 +260,7 @@ VariableRelationPutNextOid(Oid *oidP)
* In the version 2 transaction system, transaction id's are * In the version 2 transaction system, transaction id's are
* restricted in several ways. * restricted in several ways.
* *
* -- Old comments removed * -- Old comments removed
* *
* Second, since we may someday preform compression of the data * Second, since we may someday preform compression of the data
* in the log and time relations, we cause the numbering of the * in the log and time relations, we cause the numbering of the
......
...@@ -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:
...@@ -194,8 +194,8 @@ TransactionStateData CurrentTransactionStateData = { ...@@ -194,8 +194,8 @@ TransactionStateData CurrentTransactionStateData = {
TransactionState CurrentTransactionState = &CurrentTransactionStateData; TransactionState CurrentTransactionState = &CurrentTransactionStateData;
int DefaultXactIsoLevel = XACT_READ_COMMITTED; int DefaultXactIsoLevel = XACT_READ_COMMITTED;
int XactIsoLevel; int XactIsoLevel;
/* ---------------- /* ----------------
* info returned when the system is disabled * info returned when the system is disabled
...@@ -299,6 +299,7 @@ IsTransactionState(void) ...@@ -299,6 +299,7 @@ IsTransactionState(void)
*/ */
return false; return false;
} }
#endif #endif
/* -------------------------------- /* --------------------------------
...@@ -516,7 +517,7 @@ CommandCounterIncrement() ...@@ -516,7 +517,7 @@ CommandCounterIncrement()
AtStart_Cache(); AtStart_Cache();
TransactionIdFlushCache(); TransactionIdFlushCache();
} }
void void
...@@ -695,9 +696,9 @@ AtCommit_Memory() ...@@ -695,9 +696,9 @@ AtCommit_Memory()
/* ---------------- /* ----------------
* Release memory in the blank portal. * Release memory in the blank portal.
* Since EndPortalAllocMode implicitly works on the current context, * Since EndPortalAllocMode implicitly works on the current context,
* first make real sure that the blank portal is the selected context. * first make real sure that the blank portal is the selected context.
* (This is probably not necessary, but seems like a good idea...) * (This is probably not necessary, but seems like a good idea...)
* ---------------- * ----------------
*/ */
portal = GetPortalByName(NULL); portal = GetPortalByName(NULL);
...@@ -789,9 +790,9 @@ AtAbort_Memory() ...@@ -789,9 +790,9 @@ AtAbort_Memory()
/* ---------------- /* ----------------
* Release memory in the blank portal. * Release memory in the blank portal.
* Since EndPortalAllocMode implicitly works on the current context, * Since EndPortalAllocMode implicitly works on the current context,
* first make real sure that the blank portal is the selected context. * first make real sure that the blank portal is the selected context.
* (This is ESSENTIAL in case we aborted from someplace where it wasn't.) * (This is ESSENTIAL in case we aborted from someplace where it wasn't.)
* ---------------- * ----------------
*/ */
portal = GetPortalByName(NULL); portal = GetPortalByName(NULL);
...@@ -1074,7 +1075,7 @@ StartTransactionCommand() ...@@ -1074,7 +1075,7 @@ StartTransactionCommand()
break; break;
/* ---------------- /* ----------------
* As with BEGIN, we should never experience this * As with BEGIN, we should never experience this
* if we do it means the END state was not changed in the * if we do it means the END state was not changed in the
* previous CommitTransactionCommand(). If we get it, we * previous CommitTransactionCommand(). If we get it, we
* print a warning, commit the transaction, start a new * print a warning, commit the transaction, start a new
...@@ -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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -182,7 +182,7 @@ static char *relname; /* current relation name */ ...@@ -182,7 +182,7 @@ static char *relname; /* current relation name */
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */ Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
static char *values[MAXATTR]; /* cooresponding attribute values */ static char *values[MAXATTR]; /* cooresponding attribute values */
int numattr; /* number of attributes for cur. rel */ int numattr; /* number of attributes for cur. rel */
extern bool disableFsync; /* do not fsync the database */ extern bool disableFsync; /* do not fsync the database */
int DebugMode; int DebugMode;
static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem
...@@ -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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
char * char *
relpath(char *relname) relpath(char *relname)
{ {
char *path; char *path;
int bufsize = 0; int bufsize = 0;
if (IsSharedSystemRelationName(relname)) if (IsSharedSystemRelationName(relname))
{ {
...@@ -43,7 +43,7 @@ relpath(char *relname) ...@@ -43,7 +43,7 @@ relpath(char *relname)
} }
/* /*
* IsSystemRelationName * IsSystemRelationName
* True iff name is the name of a system catalog relation. * True iff name is the name of a system catalog relation.
* *
* We now make a new requirement where system catalog relns must begin * We now make a new requirement where system catalog relns must begin
...@@ -64,7 +64,7 @@ IsSystemRelationName(char *relname) ...@@ -64,7 +64,7 @@ IsSystemRelationName(char *relname)
} }
/* /*
* IsSharedSystemRelationName * IsSharedSystemRelationName
* True iff name is the name of a shared system catalog relation. * True iff name is the name of a shared system catalog relation.
*/ */
bool bool
......
...@@ -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
...@@ -70,8 +70,8 @@ ...@@ -70,8 +70,8 @@
#endif #endif
static void AddNewRelationTuple(Relation pg_class_desc, static void AddNewRelationTuple(Relation pg_class_desc,
Relation new_rel_desc, Oid new_rel_oid, unsigned natts, Relation new_rel_desc, Oid new_rel_oid, unsigned natts,
char relkind, char *temp_relname); char relkind, char *temp_relname);
static void AddToNoNameRelList(Relation r); static void AddToNoNameRelList(Relation r);
static void DeleteAttributeTuples(Relation rel); static void DeleteAttributeTuples(Relation rel);
static void DeleteRelationTuple(Relation rel); static void DeleteRelationTuple(Relation rel);
...@@ -185,7 +185,7 @@ heap_create(char *relname, ...@@ -185,7 +185,7 @@ heap_create(char *relname,
bool nailme = false; bool nailme = false;
int natts = tupDesc->natts; int natts = tupDesc->natts;
static unsigned int uniqueId = 0; static unsigned int uniqueId = 0;
extern GlobalMemory CacheCxt; extern GlobalMemory CacheCxt;
MemoryContext oldcxt; MemoryContext oldcxt;
...@@ -240,23 +240,21 @@ heap_create(char *relname, ...@@ -240,23 +240,21 @@ heap_create(char *relname,
nailme = true; nailme = true;
} }
else else
{
relid = newoid(); relid = newoid();
}
if (isnoname) if (isnoname)
{ {
Assert(!relname); Assert(!relname);
relname = palloc(NAMEDATALEN); relname = palloc(NAMEDATALEN);
snprintf(relname, NAMEDATALEN, "pg_noname.%d.%u", snprintf(relname, NAMEDATALEN, "pg_noname.%d.%u",
(int) MyProcPid, uniqueId++); (int) MyProcPid, uniqueId++);
} }
if (istemp) if (istemp)
{ {
/* replace relname of caller */ /* replace relname of caller */
snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u", snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u",
(int) MyProcPid, uniqueId++); (int) MyProcPid, uniqueId++);
} }
/* ---------------- /* ----------------
...@@ -272,7 +270,7 @@ heap_create(char *relname, ...@@ -272,7 +270,7 @@ heap_create(char *relname,
/* /*
* create a new tuple descriptor from the one passed in * create a new tuple descriptor from the one passed in
*/ */
rel->rd_att = CreateTupleDescCopyConstr(tupDesc); rel->rd_att = CreateTupleDescCopyConstr(tupDesc);
/* ---------------- /* ----------------
...@@ -321,7 +319,7 @@ heap_create(char *relname, ...@@ -321,7 +319,7 @@ heap_create(char *relname,
* ---------------- * ----------------
*/ */
rel->rd_nonameunlinked = TRUE; /* change once table is created */ rel->rd_nonameunlinked = TRUE; /* change once table is created */
rel->rd_fd = (File) smgrcreate(DEFAULT_SMGR, rel); rel->rd_fd = (File) smgrcreate(DEFAULT_SMGR, rel);
rel->rd_nonameunlinked = FALSE; rel->rd_nonameunlinked = FALSE;
...@@ -479,8 +477,8 @@ RelnameFindRelid(char *relname) ...@@ -479,8 +477,8 @@ RelnameFindRelid(char *relname)
if (!IsBootstrapProcessingMode()) if (!IsBootstrapProcessingMode())
{ {
tuple = SearchSysCacheTuple(RELNAME, tuple = SearchSysCacheTuple(RELNAME,
PointerGetDatum(relname), PointerGetDatum(relname),
0, 0, 0); 0, 0, 0);
if (HeapTupleIsValid(tuple)) if (HeapTupleIsValid(tuple))
relid = tuple->t_data->t_oid; relid = tuple->t_data->t_oid;
else else
...@@ -488,10 +486,10 @@ RelnameFindRelid(char *relname) ...@@ -488,10 +486,10 @@ RelnameFindRelid(char *relname)
} }
else else
{ {
Relation pg_class_desc; Relation pg_class_desc;
ScanKeyData key; ScanKeyData key;
HeapScanDesc pg_class_scan; HeapScanDesc pg_class_scan;
pg_class_desc = heap_openr(RelationRelationName); pg_class_desc = heap_openr(RelationRelationName);
/* ---------------- /* ----------------
...@@ -504,7 +502,7 @@ RelnameFindRelid(char *relname) ...@@ -504,7 +502,7 @@ RelnameFindRelid(char *relname)
(AttrNumber) Anum_pg_class_relname, (AttrNumber) Anum_pg_class_relname,
(RegProcedure) F_NAMEEQ, (RegProcedure) F_NAMEEQ,
(Datum) relname); (Datum) relname);
/* ---------------- /* ----------------
* begin the scan * begin the scan
* ---------------- * ----------------
...@@ -514,14 +512,14 @@ RelnameFindRelid(char *relname) ...@@ -514,14 +512,14 @@ RelnameFindRelid(char *relname)
SnapshotNow, SnapshotNow,
1, 1,
&key); &key);
/* ---------------- /* ----------------
* get a tuple. if the tuple is NULL then it means we * get a tuple. if the tuple is NULL then it means we
* didn't find an existing relation. * didn't find an existing relation.
* ---------------- * ----------------
*/ */
tuple = heap_getnext(pg_class_scan, 0); tuple = heap_getnext(pg_class_scan, 0);
if (HeapTupleIsValid(tuple)) if (HeapTupleIsValid(tuple))
relid = tuple->t_data->t_oid; relid = tuple->t_data->t_oid;
else else
...@@ -594,7 +592,7 @@ AddNewAttributeTuples(Oid new_rel_oid, ...@@ -594,7 +592,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
(char *) *dpp); (char *) *dpp);
heap_insert(rel, tup); heap_insert(rel, tup);
if (hasindex) if (hasindex)
CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup); CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
...@@ -643,11 +641,11 @@ AddNewAttributeTuples(Oid new_rel_oid, ...@@ -643,11 +641,11 @@ AddNewAttributeTuples(Oid new_rel_oid,
*/ */
static void static void
AddNewRelationTuple(Relation pg_class_desc, AddNewRelationTuple(Relation pg_class_desc,
Relation new_rel_desc, Relation new_rel_desc,
Oid new_rel_oid, Oid new_rel_oid,
unsigned natts, unsigned natts,
char relkind, char relkind,
char *temp_relname) char *temp_relname)
{ {
Form_pg_class new_rel_reltup; Form_pg_class new_rel_reltup;
HeapTuple tup; HeapTuple tup;
...@@ -678,12 +676,12 @@ AddNewRelationTuple(Relation pg_class_desc, ...@@ -678,12 +676,12 @@ AddNewRelationTuple(Relation pg_class_desc,
* the table has been proven to be small by VACUUM or CREATE INDEX. * the table has been proven to be small by VACUUM or CREATE INDEX.
* (NOTE: if user does CREATE TABLE, then CREATE INDEX, then loads * (NOTE: if user does CREATE TABLE, then CREATE INDEX, then loads
* the table, he still loses until he vacuums, because CREATE INDEX * the table, he still loses until he vacuums, because CREATE INDEX
* will set reltuples to zero. Can't win 'em all. Maintaining the * will set reltuples to zero. Can't win 'em all. Maintaining the
* stats on-the-fly would solve the problem, but the overhead of that * stats on-the-fly would solve the problem, but the overhead of that
* would likely cost more than it'd save.) * would likely cost more than it'd save.)
* ---------------- * ----------------
*/ */
new_rel_reltup->relpages = 10; /* bogus estimates */ new_rel_reltup->relpages = 10; /* bogus estimates */
new_rel_reltup->reltuples = 1000; new_rel_reltup->reltuples = 1000;
new_rel_reltup->relowner = GetUserId(); new_rel_reltup->relowner = GetUserId();
...@@ -716,9 +714,10 @@ AddNewRelationTuple(Relation pg_class_desc, ...@@ -716,9 +714,10 @@ AddNewRelationTuple(Relation pg_class_desc,
if (temp_relname) if (temp_relname)
create_temp_relation(temp_relname, tup); create_temp_relation(temp_relname, tup);
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.
...@@ -730,7 +729,7 @@ AddNewRelationTuple(Relation pg_class_desc, ...@@ -730,7 +729,7 @@ AddNewRelationTuple(Relation pg_class_desc,
/* now restore processing mode */ /* now restore processing mode */
SetProcessingMode(NormalProcessing); SetProcessingMode(NormalProcessing);
} }
pfree(tup); pfree(tup);
} }
...@@ -788,8 +787,8 @@ heap_create_with_catalog(char *relname, ...@@ -788,8 +787,8 @@ heap_create_with_catalog(char *relname,
Relation new_rel_desc; Relation new_rel_desc;
Oid new_rel_oid; Oid new_rel_oid;
int natts = tupdesc->natts; int natts = tupdesc->natts;
char *temp_relname = NULL; char *temp_relname = NULL;
/* ---------------- /* ----------------
* sanity checks * sanity checks
* ---------------- * ----------------
...@@ -804,33 +803,34 @@ heap_create_with_catalog(char *relname, ...@@ -804,33 +803,34 @@ heap_create_with_catalog(char *relname,
/* temp tables can mask non-temp tables */ /* temp tables can mask non-temp tables */
if ((!istemp && RelnameFindRelid(relname)) || if ((!istemp && RelnameFindRelid(relname)) ||
(istemp && get_temp_rel_by_name(relname) != NULL)) (istemp && get_temp_rel_by_name(relname) != NULL))
elog(ERROR, "Relation '%s' already exists", relname); elog(ERROR, "Relation '%s' already exists", relname);
/* invalidate cache so non-temp table is masked by temp */ /* invalidate cache so non-temp table is masked by temp */
if (istemp) if (istemp)
{ {
Oid relid = RelnameFindRelid(relname); Oid relid = RelnameFindRelid(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.
*/ */
RelationForgetRelation(relid); RelationForgetRelation(relid);
ResetSystemCache(); ResetSystemCache();
} }
} }
/* save user relation name because heap_create changes it */ /* save user relation name because heap_create changes it */
if (istemp) if (istemp)
{ {
temp_relname = pstrdup(relname); /* save original value */ temp_relname = pstrdup(relname); /* save original value */
relname = palloc(NAMEDATALEN); relname = palloc(NAMEDATALEN);
strcpy(relname, temp_relname); /* heap_create will change this */ strcpy(relname, temp_relname); /* heap_create will change this */
} }
/* ---------------- /* ----------------
* ok, relation does not already exist so now we * ok, relation does not already exist so now we
* create an uncataloged relation and pull its relation oid * create an uncataloged relation and pull its relation oid
...@@ -838,7 +838,7 @@ heap_create_with_catalog(char *relname, ...@@ -838,7 +838,7 @@ heap_create_with_catalog(char *relname,
* *
* Note: The call to heap_create() does all the "real" work * Note: The call to heap_create() does all the "real" work
* of creating the disk file for the relation. * of creating the disk file for the relation.
* This changes relname for noname and temp tables. * This changes relname for noname and temp tables.
* ---------------- * ----------------
*/ */
new_rel_desc = heap_create(relname, tupdesc, false, istemp); new_rel_desc = heap_create(relname, tupdesc, false, istemp);
...@@ -866,11 +866,11 @@ heap_create_with_catalog(char *relname, ...@@ -866,11 +866,11 @@ heap_create_with_catalog(char *relname,
pg_class_desc = heap_openr(RelationRelationName); pg_class_desc = heap_openr(RelationRelationName);
AddNewRelationTuple(pg_class_desc, AddNewRelationTuple(pg_class_desc,
new_rel_desc, new_rel_desc,
new_rel_oid, new_rel_oid,
natts, natts,
relkind, relkind,
temp_relname); temp_relname);
StoreConstraints(new_rel_desc); StoreConstraints(new_rel_desc);
...@@ -1320,7 +1320,7 @@ heap_destroy_with_catalog(char *relname) ...@@ -1320,7 +1320,7 @@ heap_destroy_with_catalog(char *relname)
if (istemp) if (istemp)
remove_temp_relation(rid); remove_temp_relation(rid);
/* ---------------- /* ----------------
* delete type tuple. here we want to see the effects * delete type tuple. here we want to see the effects
* of the deletions we just did, so we use setheapoverride(). * of the deletions we just did, so we use setheapoverride().
...@@ -1334,7 +1334,7 @@ heap_destroy_with_catalog(char *relname) ...@@ -1334,7 +1334,7 @@ heap_destroy_with_catalog(char *relname)
* delete relation tuple * delete relation tuple
* ---------------- * ----------------
*/ */
/* must delete fake tuple in cache */ /* must delete fake tuple in cache */
DeleteRelationTuple(rel); DeleteRelationTuple(rel);
/* /*
...@@ -1516,10 +1516,12 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef) ...@@ -1516,10 +1516,12 @@ 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,
"select %s%s from \"%.*s\"", attrdef->adsrc, cast, "select %s%s from \"%.*s\"", attrdef->adsrc, cast,
NAMEDATALEN, rel->rd_rel->relname.data); NAMEDATALEN, rel->rd_rel->relname.data);
setheapoverride(true); setheapoverride(true);
...@@ -1539,16 +1541,16 @@ start: ...@@ -1539,16 +1541,16 @@ start:
if (type != atp->atttypid) if (type != atp->atttypid)
{ {
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,12 +1600,13 @@ StoreRelCheck(Relation rel, ConstrCheck *check) ...@@ -1598,12 +1600,13 @@ 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,
"select 1 from \"%.*s\" where %s", "select 1 from \"%.*s\" where %s",
NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc); NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
setheapoverride(true); setheapoverride(true);
planTree_list = pg_parse_and_plan(str, NULL, 0, planTree_list = pg_parse_and_plan(str, NULL, 0,
&queryTree_list, None, FALSE); &queryTree_list, None, FALSE);
......
...@@ -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
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
#define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE)) #define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
/* non-export function prototypes */ /* non-export function prototypes */
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName, static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
bool istemp); bool istemp);
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo); static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation, static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
List *attributeList, List *attributeList,
...@@ -77,7 +77,7 @@ static void ...@@ -77,7 +77,7 @@ static void
static void UpdateIndexRelation(Oid indexoid, Oid heapoid, static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
FuncIndexInfo *funcInfo, int natts, FuncIndexInfo *funcInfo, int natts,
AttrNumber *attNums, Oid *classOids, Node *predicate, AttrNumber *attNums, Oid *classOids, Node *predicate,
List *attributeList, bool islossy, bool unique, bool primary); List *attributeList, bool islossy, bool unique, bool primary);
static void DefaultBuild(Relation heapRelation, Relation indexRelation, static void DefaultBuild(Relation heapRelation, Relation indexRelation,
int numberOfAttributes, AttrNumber *attributeNumber, int numberOfAttributes, AttrNumber *attributeNumber,
IndexStrategy indexStrategy, uint16 parameterCount, IndexStrategy indexStrategy, uint16 parameterCount,
...@@ -126,11 +126,11 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp) ...@@ -126,11 +126,11 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp)
Oid indoid; Oid indoid;
Oid heapoid; Oid heapoid;
indoid = RelnameFindRelid(indexRelationName); indoid = RelnameFindRelid(indexRelationName);
if ((!istemp && OidIsValid(indoid)) || if ((!istemp && OidIsValid(indoid)) ||
(istemp && get_temp_rel_by_name(indexRelationName) != NULL)) (istemp && get_temp_rel_by_name(indexRelationName) != NULL))
elog(ERROR, "Cannot create index: '%s' already exists", elog(ERROR, "Cannot create index: '%s' already exists",
indexRelationName); indexRelationName);
...@@ -139,7 +139,7 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp) ...@@ -139,7 +139,7 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp)
if (!OidIsValid(heapoid)) if (!OidIsValid(heapoid))
elog(ERROR, "Cannot create index on '%s': relation does not exist", elog(ERROR, "Cannot create index on '%s': relation does not exist",
heapRelationName); heapRelationName);
return heapoid; return heapoid;
} }
...@@ -356,7 +356,7 @@ ConstructTupleDescriptor(Oid heapoid, ...@@ -356,7 +356,7 @@ ConstructTupleDescriptor(Oid heapoid,
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* AccessMethodObjectIdGetForm * AccessMethodObjectIdGetForm
* Returns the formated access method tuple given its object identifier. * Returns the formated access method tuple given its object identifier.
* *
* XXX ADD INDEXING * XXX ADD INDEXING
...@@ -482,7 +482,7 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname) ...@@ -482,7 +482,7 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname)
if (temp_relname) if (temp_relname)
create_temp_relation(temp_relname, tuple); create_temp_relation(temp_relname, tuple);
/* /*
* During normal processing, we need to make sure that the system * During normal processing, we need to make sure that the system
* catalog indices are correct. Bootstrap (initdb) time doesn't * catalog indices are correct. Bootstrap (initdb) time doesn't
...@@ -571,7 +571,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) ...@@ -571,7 +571,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
value[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1); value[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
init_tuple = heap_addheader(Natts_pg_attribute, init_tuple = heap_addheader(Natts_pg_attribute,
ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE_TUPLE_SIZE,
(char *) (indexRelation->rd_att->attrs[0])); (char *) (indexRelation->rd_att->attrs[0]));
hasind = false; hasind = false;
...@@ -611,7 +611,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) ...@@ -611,7 +611,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
*/ */
memmove(GETSTRUCT(cur_tuple), memmove(GETSTRUCT(cur_tuple),
(char *) indexTupDesc->attrs[i], (char *) indexTupDesc->attrs[i],
ATTRIBUTE_TUPLE_SIZE); ATTRIBUTE_TUPLE_SIZE);
value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(i + 1); value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(i + 1);
...@@ -657,7 +657,7 @@ UpdateIndexRelation(Oid indexoid, ...@@ -657,7 +657,7 @@ UpdateIndexRelation(Oid indexoid,
List *attributeList, List *attributeList,
bool islossy, bool islossy,
bool unique, bool unique,
bool primary) bool primary)
{ {
Form_pg_index indexForm; Form_pg_index indexForm;
IndexElem *IndexKey; IndexElem *IndexKey;
...@@ -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);
...@@ -939,7 +939,7 @@ index_create(char *heapRelationName, ...@@ -939,7 +939,7 @@ index_create(char *heapRelationName,
Node *predicate, Node *predicate,
bool islossy, bool islossy,
bool unique, bool unique,
bool primary) bool primary)
{ {
Relation heapRelation; Relation heapRelation;
Relation indexRelation; Relation indexRelation;
...@@ -948,15 +948,15 @@ index_create(char *heapRelationName, ...@@ -948,15 +948,15 @@ index_create(char *heapRelationName,
Oid indexoid; Oid indexoid;
PredInfo *predInfo; PredInfo *predInfo;
bool istemp = (get_temp_rel_by_name(heapRelationName) != NULL); bool istemp = (get_temp_rel_by_name(heapRelationName) != NULL);
char *temp_relname = NULL; char *temp_relname = NULL;
/* ---------------- /* ----------------
* check parameters * check parameters
* ---------------- * ----------------
*/ */
if (numatts < 1) if (numatts < 1)
elog(ERROR, "must index at least one attribute"); elog(ERROR, "must index at least one attribute");
/* ---------------- /* ----------------
* get heap relation oid and open the heap relation * get heap relation oid and open the heap relation
* XXX ADD INDEXING * XXX ADD INDEXING
...@@ -987,25 +987,27 @@ index_create(char *heapRelationName, ...@@ -987,25 +987,27 @@ index_create(char *heapRelationName,
/* invalidate cache so possible non-temp index is masked by temp */ /* invalidate cache so possible non-temp index is masked by temp */
if (istemp) if (istemp)
{ {
Oid relid = RelnameFindRelid(indexRelationName); Oid relid = RelnameFindRelid(indexRelationName);
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.
*/ */
RelationForgetRelation(relid); RelationForgetRelation(relid);
ResetSystemCache(); ResetSystemCache();
} }
} }
/* save user relation name because heap_create changes it */ /* save user relation name because heap_create changes it */
if (istemp) if (istemp)
{ {
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 */
} }
/* ---------------- /* ----------------
...@@ -1122,8 +1124,8 @@ index_destroy(Oid indexId) ...@@ -1122,8 +1124,8 @@ index_destroy(Oid indexId)
Relation relationRelation; Relation relationRelation;
Relation attributeRelation; Relation attributeRelation;
HeapTuple tuple; HeapTuple tuple;
int16 attnum; int16 attnum;
Assert(OidIsValid(indexId)); Assert(OidIsValid(indexId));
/* Open now to obtain lock by referencing table? bjm */ /* Open now to obtain lock by referencing table? bjm */
...@@ -1166,7 +1168,7 @@ index_destroy(Oid indexId) ...@@ -1166,7 +1168,7 @@ index_destroy(Oid indexId)
/* does something only if it is a temp index */ /* does something only if it is a temp index */
remove_temp_relation(indexId); remove_temp_relation(indexId);
/* ---------------- /* ----------------
* fix INDEX relation * fix INDEX relation
* ---------------- * ----------------
......
...@@ -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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -46,15 +46,15 @@ ...@@ -46,15 +46,15 @@
*/ */
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};
...@@ -63,9 +63,9 @@ char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex}; ...@@ -63,9 +63,9 @@ char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
static HeapTuple CatalogIndexFetchTuple(Relation heapRelation, static HeapTuple CatalogIndexFetchTuple(Relation heapRelation,
Relation idesc, Relation idesc,
ScanKey skey, ScanKey skey,
int16 num_keys); int16 num_keys);
/* /*
...@@ -126,13 +126,13 @@ CatalogIndexInsert(Relation *idescs, ...@@ -126,13 +126,13 @@ CatalogIndexInsert(Relation *idescs,
index_tup = SearchSysCacheTupleCopy(INDEXRELID, index_tup = SearchSysCacheTupleCopy(INDEXRELID,
ObjectIdGetDatum(idescs[i]->rd_id), ObjectIdGetDatum(idescs[i]->rd_id),
0, 0, 0); 0, 0, 0);
Assert(index_tup); Assert(index_tup);
index_form = (Form_pg_index) GETSTRUCT(index_tup); index_form = (Form_pg_index) GETSTRUCT(index_tup);
if (index_form->indproc != InvalidOid) if (index_form->indproc != InvalidOid)
{ {
int fatts; int fatts;
/* /*
* Compute the number of attributes we are indexing upon. * Compute the number of attributes we are indexing upon.
...@@ -152,7 +152,7 @@ CatalogIndexInsert(Relation *idescs, ...@@ -152,7 +152,7 @@ CatalogIndexInsert(Relation *idescs,
natts = RelationGetDescr(idescs[i])->natts; natts = RelationGetDescr(idescs[i])->natts;
finfoP = (FuncIndexInfo *) NULL; finfoP = (FuncIndexInfo *) NULL;
} }
FormIndexDatum(natts, FormIndexDatum(natts,
(AttrNumber *) index_form->indkey, (AttrNumber *) index_form->indkey,
heapTuple, heapTuple,
...@@ -229,11 +229,11 @@ CatalogIndexFetchTuple(Relation heapRelation, ...@@ -229,11 +229,11 @@ CatalogIndexFetchTuple(Relation heapRelation,
ScanKey skey, ScanKey skey,
int16 num_keys) int16 num_keys)
{ {
IndexScanDesc sd; IndexScanDesc sd;
RetrieveIndexResult indexRes; RetrieveIndexResult indexRes;
HeapTupleData tuple; HeapTupleData tuple;
HeapTuple result = NULL; HeapTuple result = NULL;
Buffer buffer; Buffer buffer;
sd = index_beginscan(idesc, false, num_keys, skey); sd = index_beginscan(idesc, false, num_keys, skey);
tuple.t_data = NULL; tuple.t_data = NULL;
...@@ -462,7 +462,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName) ...@@ -462,7 +462,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
*/ */
if ((tuple = get_temp_rel_by_name(relName)) != NULL) if ((tuple = get_temp_rel_by_name(relName)) != NULL)
return heap_copytuple(tuple); return heap_copytuple(tuple);
ScanKeyEntryInitialize(&skey[0], ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
......
...@@ -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.
...@@ -36,15 +36,15 @@ ...@@ -36,15 +36,15 @@
#endif #endif
static Oid OperatorGetWithOpenRelation(Relation pg_operator_desc, static Oid OperatorGetWithOpenRelation(Relation pg_operator_desc,
const char *operatorName, const char *operatorName,
Oid leftObjectId, Oid leftObjectId,
Oid rightObjectId, Oid rightObjectId,
bool *defined); bool *defined);
static Oid OperatorGet(char *operatorName, static Oid OperatorGet(char *operatorName,
char *leftTypeName, char *leftTypeName,
char *rightTypeName, char *rightTypeName,
bool *defined); bool *defined);
static Oid OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, static Oid OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
char *operatorName, char *operatorName,
...@@ -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);
} }
...@@ -259,7 +260,7 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, ...@@ -259,7 +260,7 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
/* ---------------- /* ----------------
* initialize *values with the operator name and input data types. * initialize *values with the operator name and input data types.
* Note that oprcode is set to InvalidOid, indicating it's a shell. * Note that oprcode is set to InvalidOid, indicating it's a shell.
* ---------------- * ----------------
*/ */
i = 0; i = 0;
...@@ -356,9 +357,9 @@ OperatorShellMake(char *operatorName, ...@@ -356,9 +357,9 @@ OperatorShellMake(char *operatorName,
* ---------------- * ----------------
*/ */
operatorObjectId = OperatorShellMakeWithOpenRelation(pg_operator_desc, operatorObjectId = OperatorShellMakeWithOpenRelation(pg_operator_desc,
operatorName, operatorName,
leftObjectId, leftObjectId,
rightObjectId); rightObjectId);
/* ---------------- /* ----------------
* close the operator relation and return the oid. * close the operator relation and return the oid.
* ---------------- * ----------------
...@@ -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.
*/ */
/* ---------------- /* ----------------
...@@ -580,7 +582,7 @@ OperatorDef(char *operatorName, ...@@ -580,7 +582,7 @@ OperatorDef(char *operatorName,
values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_data->t_oid); values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_data->t_oid);
values[Anum_pg_operator_oprresult - 1] = ObjectIdGetDatum(((Form_pg_proc) values[Anum_pg_operator_oprresult - 1] = ObjectIdGetDatum(((Form_pg_proc)
GETSTRUCT(tup))->prorettype); GETSTRUCT(tup))->prorettype);
/* ---------------- /* ----------------
* find restriction * find restriction
...@@ -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
...@@ -663,16 +666,16 @@ OperatorDef(char *operatorName, ...@@ -663,16 +666,16 @@ OperatorDef(char *operatorName,
{ {
if (name[j]) if (name[j])
{ {
char *otherLeftTypeName = NULL; char *otherLeftTypeName = NULL;
char *otherRightTypeName = NULL; char *otherRightTypeName = NULL;
Oid otherLeftTypeId = InvalidOid; Oid otherLeftTypeId = InvalidOid;
Oid otherRightTypeId = InvalidOid; Oid otherRightTypeId = InvalidOid;
Oid other_oid = InvalidOid; Oid other_oid = InvalidOid;
bool otherDefined = false; bool otherDefined = false;
switch (j) switch (j)
{ {
case 0: /* commutator has reversed arg types */ case 0: /* commutator has reversed arg types */
otherLeftTypeName = rightTypeName; otherLeftTypeName = rightTypeName;
otherRightTypeName = leftTypeName; otherRightTypeName = leftTypeName;
otherLeftTypeId = rightTypeId; otherLeftTypeId = rightTypeId;
...@@ -683,7 +686,7 @@ OperatorDef(char *operatorName, ...@@ -683,7 +686,7 @@ OperatorDef(char *operatorName,
&otherDefined); &otherDefined);
commutatorId = other_oid; commutatorId = other_oid;
break; break;
case 1: /* negator has same arg types */ case 1: /* negator has same arg types */
otherLeftTypeName = leftTypeName; otherLeftTypeName = leftTypeName;
otherRightTypeName = rightTypeName; otherRightTypeName = rightTypeName;
otherLeftTypeId = leftTypeId; otherLeftTypeId = leftTypeId;
...@@ -694,7 +697,7 @@ OperatorDef(char *operatorName, ...@@ -694,7 +697,7 @@ OperatorDef(char *operatorName,
&otherDefined); &otherDefined);
negatorId = other_oid; negatorId = other_oid;
break; break;
case 2: /* left sort op takes left-side data type */ case 2: /* left sort op takes left-side data type */
otherLeftTypeName = leftTypeName; otherLeftTypeName = leftTypeName;
otherRightTypeName = leftTypeName; otherRightTypeName = leftTypeName;
otherLeftTypeId = leftTypeId; otherLeftTypeId = leftTypeId;
...@@ -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)
...@@ -239,7 +239,7 @@ ProcedureCreate(char *procedureName, ...@@ -239,7 +239,7 @@ ProcedureCreate(char *procedureName,
prosrc = procedureName; prosrc = procedureName;
if (fmgr_lookupByName(prosrc) == (func_ptr) NULL) if (fmgr_lookupByName(prosrc) == (func_ptr) NULL)
elog(ERROR, elog(ERROR,
"ProcedureCreate: there is no builtin function named \"%s\"", "ProcedureCreate: there is no builtin function named \"%s\"",
prosrc); prosrc);
} }
......
...@@ -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;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* ExecCreatR function to create temporary relations * ExecCreatR function to create temporary relations
* *
*/ */
#include <stdio.h> #include <stdio.h>
#include "postgres.h" #include "postgres.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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