/******************************************************************************
- $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.33 2007/06/05 21:31:03 tgl Exp $
+ $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.34 2007/11/15 21:14:29 momjian Exp $
This file contains routines that can be bound to a Postgres backend and
called by the backend in the process of processing queries. The calling
result->x[i + dim] = c->x[dx[i] + c->dim - 1];
}
- PG_FREE_IF_COPY(c,0);
+ PG_FREE_IF_COPY(c, 0);
PG_RETURN_NDBOX(result);
}
appendStringInfoChar(&buf, ')');
}
- PG_FREE_IF_COPY(cube,0);
+ PG_FREE_IF_COPY(cube, 0);
PG_RETURN_CSTRING(buf.data);
}
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
NDBOX *query = PG_GETARG_NDBOX(1);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
- bool res;
+ bool res;
/*
* if entry is not leaf, use g_cube_internal_consistent, else use
* g_cube_leaf_consistent
*/
if (GIST_LEAF(entry))
- res = g_cube_leaf_consistent( DatumGetNDBOX(entry->key),
- query, strategy);
+ res = g_cube_leaf_consistent(DatumGetNDBOX(entry->key),
+ query, strategy);
else
- res = g_cube_internal_consistent( DatumGetNDBOX(entry->key),
- query, strategy);
+ res = g_cube_internal_consistent(DatumGetNDBOX(entry->key),
+ query, strategy);
- PG_FREE_IF_COPY(query,1);
+ PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res);
}
g_cube_decompress(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
- NDBOX *key = DatumGetNDBOX(PG_DETOAST_DATUM(entry->key));
+ NDBOX *key = DatumGetNDBOX(PG_DETOAST_DATUM(entry->key));
if (key != DatumGetNDBOX(entry->key))
{
GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
+
gistentryinit(*retval, PointerGetDatum(key),
- entry->rel, entry->page,
- entry->offset, FALSE);
+ entry->rel, entry->page,
+ entry->offset, FALSE);
PG_RETURN_POINTER(retval);
}
PG_RETURN_POINTER(entry);
double tmp1,
tmp2;
- ud = cube_union_v0( DatumGetNDBOX(origentry->key),
- DatumGetNDBOX(newentry->key));
+ ud = cube_union_v0(DatumGetNDBOX(origentry->key),
+ DatumGetNDBOX(newentry->key));
rt_cube_size(ud, &tmp1);
rt_cube_size(DatumGetNDBOX(origentry->key), &tmp2);
*result = (float) (tmp1 - tmp2);
{
NDBOX *a = PG_GETARG_NDBOX(0),
*b = PG_GETARG_NDBOX(1);
- NDBOX *res;
+ NDBOX *res;
res = cube_union_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_NDBOX(res);
}
a->x[i + a->dim]), result->x[i + a->dim]);
}
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
+
/*
* Is it OK to return a non-null intersection for non-overlapping boxes?
*/
for (i = 0, j = a->dim; i < a->dim; i++, j++)
result = result * Abs((a->x[j] - a->x[i]));
- PG_FREE_IF_COPY(a,0);
+ PG_FREE_IF_COPY(a, 0);
PG_RETURN_FLOAT8(result);
}
res = cube_cmp_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_INT32(res);
}
res = cube_cmp_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res == 0);
}
res = cube_cmp_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res != 0);
}
res = cube_cmp_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res < 0);
}
res = cube_cmp_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res > 0);
}
res = cube_cmp_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res <= 0);
}
res = cube_cmp_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res >= 0);
}
res = cube_contains_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res);
}
res = cube_contains_v0(b, a);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res);
}
res = cube_overlap_v0(a, b);
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_BOOL(res);
}
distance += d * d;
}
- PG_FREE_IF_COPY(a,0);
- PG_FREE_IF_COPY(b,1);
+ PG_FREE_IF_COPY(a, 0);
+ PG_FREE_IF_COPY(b, 1);
PG_RETURN_FLOAT8(sqrt(distance));
}
PG_RETURN_BOOL(FALSE);
}
- PG_FREE_IF_COPY(a,0);
+ PG_FREE_IF_COPY(a, 0);
PG_RETURN_BOOL(TRUE);
}
c = PG_GETARG_NDBOX(0);
dim = c->dim;
- PG_FREE_IF_COPY(c,0);
+ PG_FREE_IF_COPY(c, 0);
PG_RETURN_INT32(c->dim);
}
if (c->dim >= n && n > 0)
result = Min(c->x[n - 1], c->x[c->dim + n - 1]);
- PG_FREE_IF_COPY(c,0);
+ PG_FREE_IF_COPY(c, 0);
PG_RETURN_FLOAT8(result);
}
if (c->dim >= n && n > 0)
result = Max(c->x[n - 1], c->x[c->dim + n - 1]);
- PG_FREE_IF_COPY(c,0);
+ PG_FREE_IF_COPY(c, 0);
PG_RETURN_FLOAT8(result);
}
j,
k;
NDBOX *a;
- double r;
+ double r;
int4 n;
a = PG_GETARG_NDBOX(0);
result->x[j] = r;
}
- PG_FREE_IF_COPY(a,0);
+ PG_FREE_IF_COPY(a, 0);
PG_RETURN_NDBOX(result);
}
result->x[result->dim - 1] = x;
result->x[2 * result->dim - 1] = x;
- PG_FREE_IF_COPY(c,0);
+ PG_FREE_IF_COPY(c, 0);
PG_RETURN_NDBOX(result);
}
result->x[result->dim - 1] = x1;
result->x[2 * result->dim - 1] = x2;
- PG_FREE_IF_COPY(c,0);
+ PG_FREE_IF_COPY(c, 0);
PG_RETURN_NDBOX(result);
}
* Darko Prenosil <Darko.Prenosil@finteh.hr>
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
*
- * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.65 2007/08/27 01:24:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.66 2007/11/15 21:14:29 momjian Exp $
* Copyright (c) 2001-2007, PostgreSQL Global Development Group
* ALL RIGHTS RESERVED;
*
pfree(rconn);
ereport(ERROR,
- (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
- errmsg("password is required"),
- errdetail("Non-superuser cannot connect if the server does not request a password."),
- errhint("Target server's authentication method must be changed.")));
+ (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
+ errmsg("password is required"),
+ errdetail("Non-superuser cannot connect if the server does not request a password."),
+ errhint("Target server's authentication method must be changed.")));
}
}
* Copyright (c) 2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/dict_int/dict_int.c,v 1.1 2007/10/15 21:36:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/dict_int/dict_int.c,v 1.2 2007/11/15 21:14:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PG_MODULE_MAGIC;
-typedef struct {
- int maxlen;
- bool rejectlong;
-} DictInt;
+typedef struct
+{
+ int maxlen;
+ bool rejectlong;
+} DictInt;
PG_FUNCTION_INFO_V1(dintdict_init);
-Datum dintdict_init(PG_FUNCTION_ARGS);
+Datum dintdict_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(dintdict_lexize);
-Datum dintdict_lexize(PG_FUNCTION_ARGS);
+Datum dintdict_lexize(PG_FUNCTION_ARGS);
Datum
dintdict_init(PG_FUNCTION_ARGS)
{
- List *dictoptions = (List *) PG_GETARG_POINTER(0);
- DictInt *d;
- ListCell *l;
+ List *dictoptions = (List *) PG_GETARG_POINTER(0);
+ DictInt *d;
+ ListCell *l;
d = (DictInt *) palloc0(sizeof(DictInt));
d->maxlen = 6;
foreach(l, dictoptions)
{
- DefElem *defel = (DefElem *) lfirst(l);
+ DefElem *defel = (DefElem *) lfirst(l);
if (pg_strcasecmp(defel->defname, "MAXLEN") == 0)
{
defel->defname)));
}
}
-
+
PG_RETURN_POINTER(d);
}
Datum
dintdict_lexize(PG_FUNCTION_ARGS)
{
- DictInt *d = (DictInt*)PG_GETARG_POINTER(0);
- char *in = (char*)PG_GETARG_POINTER(1);
- char *txt = pnstrdup(in, PG_GETARG_INT32(2));
- TSLexeme *res=palloc(sizeof(TSLexeme)*2);
+ DictInt *d = (DictInt *) PG_GETARG_POINTER(0);
+ char *in = (char *) PG_GETARG_POINTER(1);
+ char *txt = pnstrdup(in, PG_GETARG_INT32(2));
+ TSLexeme *res = palloc(sizeof(TSLexeme) * 2);
res[1].lexeme = NULL;
- if (PG_GETARG_INT32(2) > d->maxlen)
+ if (PG_GETARG_INT32(2) > d->maxlen)
{
- if ( d->rejectlong )
+ if (d->rejectlong)
{
/* reject by returning void array */
pfree(txt);
* Copyright (c) 2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.1 2007/10/15 21:36:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.2 2007/11/15 21:14:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct
{
- char *key; /* Word */
- char *value; /* Unparsed list of synonyms, including the word itself */
+ char *key; /* Word */
+ char *value; /* Unparsed list of synonyms, including the
+ * word itself */
} Syn;
typedef struct
{
- int len;
- Syn *syn;
+ int len;
+ Syn *syn;
- bool keeporig;
+ bool keeporig;
} DictSyn;
PG_FUNCTION_INFO_V1(dxsyn_init);
-Datum dxsyn_init(PG_FUNCTION_ARGS);
+Datum dxsyn_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(dxsyn_lexize);
-Datum dxsyn_lexize(PG_FUNCTION_ARGS);
+Datum dxsyn_lexize(PG_FUNCTION_ARGS);
static char *
find_word(char *in, char **end)
{
- char *start;
+ char *start;
*end = NULL;
while (*in && t_isspace(in))
}
static void
-read_dictionary(DictSyn *d, char *filename)
+read_dictionary(DictSyn * d, char *filename)
{
- char *real_filename = get_tsearch_config_filename(filename, "rules");
- FILE *fin;
- char *line;
- int cur = 0;
+ char *real_filename = get_tsearch_config_filename(filename, "rules");
+ FILE *fin;
+ char *line;
+ int cur = 0;
if ((fin = AllocateFile(real_filename, "r")) == NULL)
ereport(ERROR,
while ((line = t_readline(fin)) != NULL)
{
- char *value;
- char *key;
- char *end = NULL;
+ char *value;
+ char *key;
+ char *end = NULL;
if (*line == '\0')
continue;
Datum
dxsyn_init(PG_FUNCTION_ARGS)
{
- List *dictoptions = (List *) PG_GETARG_POINTER(0);
- DictSyn *d;
- ListCell *l;
+ List *dictoptions = (List *) PG_GETARG_POINTER(0);
+ DictSyn *d;
+ ListCell *l;
d = (DictSyn *) palloc0(sizeof(DictSyn));
d->len = 0;
foreach(l, dictoptions)
{
- DefElem *defel = (DefElem *) lfirst(l);
+ DefElem *defel = (DefElem *) lfirst(l);
if (pg_strcasecmp(defel->defname, "KEEPORIG") == 0)
{
Datum
dxsyn_lexize(PG_FUNCTION_ARGS)
{
- DictSyn *d = (DictSyn *) PG_GETARG_POINTER(0);
- char *in = (char *) PG_GETARG_POINTER(1);
- int length = PG_GETARG_INT32(2);
- Syn word;
- Syn *found;
- TSLexeme *res = NULL;
+ DictSyn *d = (DictSyn *) PG_GETARG_POINTER(0);
+ char *in = (char *) PG_GETARG_POINTER(1);
+ int length = PG_GETARG_INT32(2);
+ Syn word;
+ Syn *found;
+ TSLexeme *res = NULL;
if (!length || d->len == 0)
PG_RETURN_POINTER(NULL);
/* Create search pattern */
{
- char *temp = pnstrdup(in, length);
+ char *temp = pnstrdup(in, length);
word.key = lowerstr(temp);
pfree(temp);
}
/* Look for matching syn */
- found = (Syn *)bsearch(&word, d->syn, d->len, sizeof(Syn), compare_syn);
+ found = (Syn *) bsearch(&word, d->syn, d->len, sizeof(Syn), compare_syn);
pfree(word.key);
if (!found)
/* Parse string of synonyms and return array of words */
{
- char *value = pstrdup(found->value);
- int value_length = strlen(value);
- char *pos = value;
- int nsyns = 0;
- bool is_first = true;
+ char *value = pstrdup(found->value);
+ int value_length = strlen(value);
+ char *pos = value;
+ int nsyns = 0;
+ bool is_first = true;
res = palloc(0);
- while(pos < value + value_length)
+ while (pos < value + value_length)
{
- char *end;
- char *syn = find_word(pos, &end);
+ char *end;
+ char *syn = find_word(pos, &end);
if (!syn)
break;
*end = '\0';
- res = repalloc(res, sizeof(TSLexeme)*(nsyns + 2));
+ res = repalloc(res, sizeof(TSLexeme) * (nsyns + 2));
res[nsyns].lexeme = NULL;
/* first word is added to result only if KEEPORIG flag is set */
- if(d->keeporig || !is_first)
+ if (d->keeporig || !is_first)
{
res[nsyns].lexeme = pstrdup(syn);
res[nsyns + 1].lexeme = NULL;
int comparePairs(const void *a, const void *b);
int uniquePairs(Pairs * a, int4 l, int4 *buflen);
-#define HStoreContainsStrategyNumber 7
-#define HStoreExistsStrategyNumber 9
+#define HStoreContainsStrategyNumber 7
+#define HStoreExistsStrategyNumber 9
#endif
#include "hstore.h"
-#include "access/gin.h"
+#include "access/gin.h"
-#define KEYFLAG 'K'
-#define VALFLAG 'V'
-#define NULLFLAG 'N'
+#define KEYFLAG 'K'
+#define VALFLAG 'V'
+#define NULLFLAG 'N'
PG_FUNCTION_INFO_V1(gin_extract_hstore);
-Datum gin_extract_hstore(PG_FUNCTION_ARGS);
+Datum gin_extract_hstore(PG_FUNCTION_ARGS);
-static text*
-makeitem( char *str, int len )
+static text *
+makeitem(char *str, int len)
{
- text *item;
+ text *item;
- item = (text*)palloc( VARHDRSZ + len + 1 );
+ item = (text *) palloc(VARHDRSZ + len + 1);
SET_VARSIZE(item, VARHDRSZ + len + 1);
- if ( str && len > 0 )
- memcpy( VARDATA(item)+1, str, len );
+ if (str && len > 0)
+ memcpy(VARDATA(item) + 1, str, len);
return item;
}
Datum
gin_extract_hstore(PG_FUNCTION_ARGS)
{
- HStore *hs = PG_GETARG_HS(0);
- int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
- Datum *entries = NULL;
+ HStore *hs = PG_GETARG_HS(0);
+ int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
+ Datum *entries = NULL;
- *nentries = 2*hs->size;
+ *nentries = 2 * hs->size;
- if ( hs->size > 0 )
+ if (hs->size > 0)
{
- HEntry *ptr = ARRPTR(hs);
- char *words = STRPTR(hs);
- int i=0;
+ HEntry *ptr = ARRPTR(hs);
+ char *words = STRPTR(hs);
+ int i = 0;
- entries = (Datum*)palloc( sizeof(Datum) * 2 * hs->size );
+ entries = (Datum *) palloc(sizeof(Datum) * 2 * hs->size);
while (ptr - ARRPTR(hs) < hs->size)
{
- text *item;
+ text *item;
- item = makeitem( words + ptr->pos, ptr->keylen );
+ item = makeitem(words + ptr->pos, ptr->keylen);
*VARDATA(item) = KEYFLAG;
entries[i++] = PointerGetDatum(item);
- if ( ptr->valisnull )
+ if (ptr->valisnull)
{
- item = makeitem( NULL, 0 );
+ item = makeitem(NULL, 0);
*VARDATA(item) = NULLFLAG;
}
else
{
- item = makeitem( words + ptr->pos + ptr->keylen, ptr->vallen );
+ item = makeitem(words + ptr->pos + ptr->keylen, ptr->vallen);
*VARDATA(item) = VALFLAG;
}
entries[i++] = PointerGetDatum(item);
}
}
- PG_FREE_IF_COPY(hs,0);
+ PG_FREE_IF_COPY(hs, 0);
PG_RETURN_POINTER(entries);
}
PG_FUNCTION_INFO_V1(gin_extract_hstore_query);
-Datum gin_extract_hstore_query(PG_FUNCTION_ARGS);
+Datum gin_extract_hstore_query(PG_FUNCTION_ARGS);
Datum
gin_extract_hstore_query(PG_FUNCTION_ARGS)
{
StrategyNumber strategy = PG_GETARG_UINT16(2);
- if ( strategy == HStoreContainsStrategyNumber )
+ if (strategy == HStoreContainsStrategyNumber)
{
- PG_RETURN_DATUM( DirectFunctionCall2(
- gin_extract_hstore,
- PG_GETARG_DATUM(0),
- PG_GETARG_DATUM(1)
- ));
+ PG_RETURN_DATUM(DirectFunctionCall2(
+ gin_extract_hstore,
+ PG_GETARG_DATUM(0),
+ PG_GETARG_DATUM(1)
+ ));
}
- else if ( strategy == HStoreExistsStrategyNumber )
+ else if (strategy == HStoreExistsStrategyNumber)
{
- text *item, *q = PG_GETARG_TEXT_P(0);
- int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
- Datum *entries = NULL;
+ text *item,
+ *q = PG_GETARG_TEXT_P(0);
+ int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
+ Datum *entries = NULL;
*nentries = 1;
- entries = (Datum*)palloc( sizeof(Datum) );
+ entries = (Datum *) palloc(sizeof(Datum));
- item = makeitem( VARDATA(q), VARSIZE(q)-VARHDRSZ );
+ item = makeitem(VARDATA(q), VARSIZE(q) - VARHDRSZ);
*VARDATA(item) = KEYFLAG;
entries[0] = PointerGetDatum(item);
}
PG_FUNCTION_INFO_V1(gin_consistent_hstore);
-Datum gin_consistent_hstore(PG_FUNCTION_ARGS);
+Datum gin_consistent_hstore(PG_FUNCTION_ARGS);
Datum
gin_consistent_hstore(PG_FUNCTION_ARGS)
{
StrategyNumber strategy = PG_GETARG_UINT16(1);
- bool res = true;
+ bool res = true;
- if ( strategy == HStoreContainsStrategyNumber )
+ if (strategy == HStoreContainsStrategyNumber)
{
- bool *check = (bool *) PG_GETARG_POINTER(0);
- HStore *query = PG_GETARG_HS(2);
- int i;
+ bool *check = (bool *) PG_GETARG_POINTER(0);
+ HStore *query = PG_GETARG_HS(2);
+ int i;
- for(i=0;res && i<2*query->size;i++)
- if ( check[i] == false )
+ for (i = 0; res && i < 2 * query->size; i++)
+ if (check[i] == false)
res = false;
}
- else if ( strategy == HStoreExistsStrategyNumber )
+ else if (strategy == HStoreExistsStrategyNumber)
res = true;
else
elog(ERROR, "Unsupported strategy number: %d", strategy);
PG_RETURN_BOOL(res);
}
-
int len;
HStore *out;
- if ( PG_ARGISNULL(0) )
+ if (PG_ARGISNULL(0))
PG_RETURN_NULL();
key = PG_GETARG_TEXT_P(0);
- if ( PG_ARGISNULL(1) )
- len = CALCDATASIZE(1, VARSIZE(key) );
+ if (PG_ARGISNULL(1))
+ len = CALCDATASIZE(1, VARSIZE(key));
else
{
val = PG_GETARG_TEXT_P(1);
out->size = 1;
ARRPTR(out)->keylen = VARSIZE(key) - VARHDRSZ;
- if ( PG_ARGISNULL(1) )
+ if (PG_ARGISNULL(1))
{
ARRPTR(out)->vallen = 0;
ARRPTR(out)->valisnull = true;
if (entry)
{
- if ( te->valisnull || entry->valisnull )
+ if (te->valisnull || entry->valisnull)
{
- if ( !(te->valisnull && entry->valisnull) )
+ if (!(te->valisnull && entry->valisnull))
res = false;
}
- else if ( te->vallen != entry->vallen ||
- strncmp(
- vv + entry->pos + entry->keylen,
- tv + te->pos + te->keylen,
- te->vallen)
- )
- res = false;
+ else if (te->vallen != entry->vallen ||
+ strncmp(
+ vv + entry->pos + entry->keylen,
+ tv + te->pos + te->keylen,
+ te->vallen)
+ )
+ res = false;
}
else
res = false;
}
}
- if ( nentries == 0 )
+ if (nentries == 0)
{
- switch( strategy )
+ switch (strategy)
{
case BooleanSearchStrategy:
case RTOverlapStrategyNumber:
- *nentries = -1; /* nobody can be found */
- break;
- default: /* require fullscan: GIN can't find void arrays */
- break;
+ *nentries = -1; /* nobody can be found */
+ break;
+ default: /* require fullscan: GIN can't find void
+ * arrays */
+ break;
}
}
CHECKARRVALID(in);
if (ARRISVOID(in))
{
- if (in != (ArrayType *) DatumGetPointer(entry->key)) {
+ if (in != (ArrayType *) DatumGetPointer(entry->key))
+ {
retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(in),
- entry->rel, entry->page, entry->offset, FALSE);
+ entry->rel, entry->page, entry->offset, FALSE);
PG_RETURN_POINTER(retval);
}
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.6 2007/06/05 21:31:03 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.7 2007/11/15 21:14:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Returns the ean13 value of the string.
*/
static
-ean13
+ ean13
str2ean(const char *num)
{
ean13 ean = 0; /* current ean */
buffer = ReadBuffer(rel, blkno);
/*
- * We copy the page into local storage to avoid holding pin on
- * the buffer longer than we must, and possibly failing to
- * release it at all if the calling query doesn't fetch all rows.
+ * We copy the page into local storage to avoid holding pin on the
+ * buffer longer than we must, and possibly failing to release it at
+ * all if the calling query doesn't fetch all rows.
*/
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
* information as possible, even if it's nonsense. That's because if a
* page is corrupt, we don't know why and how exactly it is corrupt, so we
* let the user to judge it.
- *
+ *
* These functions are restricted to superusers for the fear of introducing
- * security holes if the input checking isn't as water-tight as it should.
- * You'd need to be superuser to obtain a raw page image anyway, so
+ * security holes if the input checking isn't as water-tight as it should.
+ * You'd need to be superuser to obtain a raw page image anyway, so
* there's hardly any use case for using these without superuser-rights
* anyway.
*
* Copyright (c) 2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.2 2007/09/12 22:10:25 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.3 2007/11/15 21:14:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/builtins.h"
#include "miscadmin.h"
-Datum heap_page_items(PG_FUNCTION_ARGS);
+Datum heap_page_items(PG_FUNCTION_ARGS);
#define GET_TEXT(str_) \
- DirectFunctionCall1(textin, CStringGetDatum(str_))
+ DirectFunctionCall1(textin, CStringGetDatum(str_))
/*
* bits_to_text
static char *
bits_to_text(bits8 *bits, int len)
{
- int i;
- char *str;
+ int i;
+ char *str;
str = palloc(len + 1);
-
- for(i = 0; i < len; i++)
+
+ for (i = 0; i < len; i++)
str[i] = (bits[(i / 8)] & (1 << (i % 8))) ? '1' : '0';
str[i] = '\0';
TupleDesc tupd;
Page page;
uint16 offset;
-} heap_page_items_state;
+} heap_page_items_state;
Datum
heap_page_items(PG_FUNCTION_ARGS)
{
- bytea *raw_page = PG_GETARG_BYTEA_P(0);
+ bytea *raw_page = PG_GETARG_BYTEA_P(0);
heap_page_items_state *inter_call_data = NULL;
FuncCallContext *fctx;
- int raw_page_size;
+ int raw_page_size;
if (!superuser())
ereport(ERROR,
TupleDesc tupdesc;
MemoryContext mctx;
- if(raw_page_size < SizeOfPageHeaderData)
- ereport(ERROR,
+ if (raw_page_size < SizeOfPageHeaderData)
+ ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("input page too small (%d bytes)", raw_page_size)));
+ errmsg("input page too small (%d bytes)", raw_page_size)));
fctx = SRF_FIRSTCALL_INIT();
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
ItemId id;
Datum values[13];
bool nulls[13];
- uint16 lp_offset;
+ uint16 lp_offset;
uint16 lp_flags;
uint16 lp_len;
memset(nulls, 0, sizeof(nulls));
/* Extract information from the line pointer */
-
+
id = PageGetItemId(page, inter_call_data->offset);
- lp_offset = ItemIdGetOffset(id);
- lp_flags = ItemIdGetFlags(id);
- lp_len = ItemIdGetLength(id);
+ lp_offset = ItemIdGetOffset(id);
+ lp_flags = ItemIdGetFlags(id);
+ lp_len = ItemIdGetLength(id);
values[0] = UInt16GetDatum(inter_call_data->offset);
values[1] = UInt16GetDatum(lp_offset);
values[2] = UInt16GetDatum(lp_flags);
values[3] = UInt16GetDatum(lp_len);
- /* We do just enough validity checking to make sure we don't
- * reference data outside the page passed to us. The page
- * could be corrupt in many other ways, but at least we won't
- * crash.
+ /*
+ * We do just enough validity checking to make sure we don't reference
+ * data outside the page passed to us. The page could be corrupt in
+ * many other ways, but at least we won't crash.
*/
if (ItemIdHasStorage(id) &&
lp_len >= sizeof(HeapTupleHeader) &&
lp_offset == MAXALIGN(lp_offset) &&
lp_offset + lp_len <= raw_page_size)
{
- HeapTupleHeader tuphdr;
- int bits_len;
+ HeapTupleHeader tuphdr;
+ int bits_len;
/* Extract information from the tuple header */
tuphdr = (HeapTupleHeader) PageGetItem(page, id);
-
+
values[4] = UInt32GetDatum(HeapTupleHeaderGetXmin(tuphdr));
values[5] = UInt32GetDatum(HeapTupleHeaderGetXmax(tuphdr));
values[6] = UInt32GetDatum(HeapTupleHeaderGetRawCommandId(tuphdr)); /* shared with xvac */
values[9] = UInt16GetDatum(tuphdr->t_infomask);
values[10] = UInt8GetDatum(tuphdr->t_hoff);
- /* We already checked that the item as is completely within
- * the raw page passed to us, with the length given in the line
+ /*
+ * We already checked that the item as is completely within the
+ * raw page passed to us, with the length given in the line
* pointer.. Let's check that t_hoff doesn't point over lp_len,
* before using it to access t_bits and oid.
*/
- if (tuphdr->t_hoff >= sizeof(HeapTupleHeader) &&
+ if (tuphdr->t_hoff >= sizeof(HeapTupleHeader) &&
tuphdr->t_hoff <= lp_len)
{
if (tuphdr->t_infomask & HEAP_HASNULL)
{
- bits_len = tuphdr->t_hoff -
- (((char *)tuphdr->t_bits) - ((char *)tuphdr));
+ bits_len = tuphdr->t_hoff -
+ (((char *) tuphdr->t_bits) -((char *) tuphdr));
values[11] = GET_TEXT(
- bits_to_text(tuphdr->t_bits, bits_len * 8));
- }
+ bits_to_text(tuphdr->t_bits, bits_len * 8));
+ }
else
nulls[11] = true;
}
else
{
- /* The line pointer is not used, or it's invalid. Set the rest of
- * the fields to NULL */
- int i;
+ /*
+ * The line pointer is not used, or it's invalid. Set the rest of
+ * the fields to NULL
+ */
+ int i;
- for(i = 4; i <= 12; i++)
+ for (i = 4; i <= 12; i++)
nulls[i] = true;
}
- /* Build and return the result tuple. */
- resultTuple = heap_form_tuple(inter_call_data->tupd, values, nulls);
- result = HeapTupleGetDatum(resultTuple);
+ /* Build and return the result tuple. */
+ resultTuple = heap_form_tuple(inter_call_data->tupd, values, nulls);
+ result = HeapTupleGetDatum(resultTuple);
inter_call_data->offset++;
* Copyright (c) 2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/pageinspect/rawpage.c,v 1.2 2007/09/21 21:25:42 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pageinspect/rawpage.c,v 1.3 2007/11/15 21:14:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PG_MODULE_MAGIC;
-Datum get_raw_page(PG_FUNCTION_ARGS);
-Datum page_header(PG_FUNCTION_ARGS);
+Datum get_raw_page(PG_FUNCTION_ARGS);
+Datum page_header(PG_FUNCTION_ARGS);
/*
* get_raw_page
uint32 blkno = PG_GETARG_UINT32(1);
Relation rel;
- RangeVar *relrv;
- bytea *raw_page;
- char *raw_page_data;
+ RangeVar *relrv;
+ bytea *raw_page;
+ char *raw_page_data;
Buffer buf;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot get raw page from view \"%s\"",
- RelationGetRelationName(rel))));
+ RelationGetRelationName(rel))));
if (rel->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot get raw page from composite type \"%s\"",
- RelationGetRelationName(rel))));
+ RelationGetRelationName(rel))));
if (blkno >= RelationGetNumberOfBlocks(rel))
elog(ERROR, "block number %u is out of range for relation \"%s\"",
raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
/*
- * Check that enough data was supplied, so that we don't try to access
- * fields outside the supplied buffer.
+ * Check that enough data was supplied, so that we don't try to access
+ * fields outside the supplied buffer.
*/
- if(raw_page_size < sizeof(PageHeaderData))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("input page too small (%d bytes)", raw_page_size)));
+ if (raw_page_size < sizeof(PageHeaderData))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input page too small (%d bytes)", raw_page_size)));
page = (PageHeader) VARDATA(raw_page);
values[7] = UInt16GetDatum(PageGetPageLayoutVersion(page));
values[8] = TransactionIdGetDatum(page->pd_prune_xid);
- /* Build and return the tuple. */
+ /* Build and return the tuple. */
memset(nulls, 0, sizeof(nulls));
- tuple = heap_form_tuple(tupdesc, values, nulls);
- result = HeapTupleGetDatum(tuple);
+ tuple = heap_form_tuple(tupdesc, values, nulls);
+ result = HeapTupleGetDatum(tuple);
PG_RETURN_DATUM(result);
}
* pg_buffercache_pages.c
* display some contents of the buffer cache
*
- * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.13 2007/07/16 21:20:36 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.14 2007/11/15 21:14:30 momjian Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
/*
* And release locks. We do this in reverse order for two reasons:
* (1) Anyone else who needs more than one of the locks will be trying
- * to lock them in increasing order; we don't want to release the other
- * process until it can get all the locks it needs.
- * (2) This avoids O(N^2) behavior inside LWLockRelease.
+ * to lock them in increasing order; we don't want to release the
+ * other process until it can get all the locks it needs. (2) This
+ * avoids O(N^2) behavior inside LWLockRelease.
*/
for (i = NUM_BUFFER_PARTITIONS; --i >= 0;)
LWLockRelease(FirstBufMappingLock + i);
/*
* pg_standby.c
- *
+ *
* Production-ready example of how to create a Warm Standby
- * database server using continuous archiving as a
+ * database server using continuous archiving as a
* replication mechanism
*
* We separate the parameters for archive and nextWALfile
- * so that we can check the archive exists, even if the
+ * so that we can check the archive exists, even if the
* WAL file doesn't (yet).
*
* This program will be executed once in full for each file
*
* It is designed to cater to a variety of needs, as well
* providing a customizable section.
- *
- * Original author: Simon Riggs simon@2ndquadrant.com
- * Current maintainer: Simon Riggs
+ *
+ * Original author: Simon Riggs simon@2ndquadrant.com
+ * Current maintainer: Simon Riggs
*/
#include "postgres_fe.h"
#include <signal.h>
#ifdef WIN32
-int getopt(int argc, char * const argv[], const char *optstring);
+int getopt(int argc, char *const argv[], const char *optstring);
#else
#include <sys/time.h>
#include <unistd.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
-
#endif /* ! WIN32 */
extern char *optarg;
extern int optind;
/* Options and defaults */
-int sleeptime = 5; /* amount of time to sleep between file checks */
-int waittime = -1; /* how long we have been waiting, -1 no wait yet */
-int maxwaittime = 0; /* how long are we prepared to wait for? */
-int keepfiles = 0; /* number of WAL files to keep, 0 keep all */
-int maxretries = 3; /* number of retries on restore command */
-bool debug = false; /* are we debugging? */
-bool triggered = false; /* have we been triggered? */
-bool need_cleanup = false; /* do we need to remove files from archive? */
+int sleeptime = 5; /* amount of time to sleep between file checks */
+int waittime = -1; /* how long we have been waiting, -1 no wait
+ * yet */
+int maxwaittime = 0; /* how long are we prepared to wait for? */
+int keepfiles = 0; /* number of WAL files to keep, 0 keep all */
+int maxretries = 3; /* number of retries on restore command */
+bool debug = false; /* are we debugging? */
+bool triggered = false; /* have we been triggered? */
+bool need_cleanup = false; /* do we need to remove files from
+ * archive? */
static volatile sig_atomic_t signaled = false;
-char *archiveLocation; /* where to find the archive? */
-char *triggerPath; /* where to find the trigger file? */
-char *xlogFilePath; /* where we are going to restore to */
-char *nextWALFileName; /* the file we need to get from archive */
-char *restartWALFileName; /* the file from which we can restart restore */
-char *priorWALFileName; /* the file we need to get from archive */
-char WALFilePath[MAXPGPATH];/* the file path including archive */
-char restoreCommand[MAXPGPATH]; /* run this to restore */
-char exclusiveCleanupFileName[MAXPGPATH]; /* the file we need to get from archive */
+char *archiveLocation; /* where to find the archive? */
+char *triggerPath; /* where to find the trigger file? */
+char *xlogFilePath; /* where we are going to restore to */
+char *nextWALFileName; /* the file we need to get from archive */
+char *restartWALFileName; /* the file from which we can restart restore */
+char *priorWALFileName; /* the file we need to get from archive */
+char WALFilePath[MAXPGPATH]; /* the file path including archive */
+char restoreCommand[MAXPGPATH]; /* run this to restore */
+char exclusiveCleanupFileName[MAXPGPATH]; /* the file we need to
+ * get from archive */
#define RESTORE_COMMAND_COPY 0
#define RESTORE_COMMAND_LINK 1
-int restoreCommandType;
+int restoreCommandType;
#define XLOG_DATA 0
#define XLOG_HISTORY 1
#define XLOG_BACKUP_LABEL 2
-int nextWALFileType;
+int nextWALFileType;
#define SET_RESTORE_COMMAND(cmd, arg1, arg2) \
snprintf(restoreCommand, MAXPGPATH, cmd " \"%s\" \"%s\"", arg1, arg2)
* accessible directory. If you want to make other assumptions,
* such as using a vendor-specific archive and access API, these
* routines are the ones you'll need to change. You're
- * enouraged to submit any changes to pgsql-patches@postgresql.org
- * or personally to the current maintainer. Those changes may be
+ * enouraged to submit any changes to pgsql-patches@postgresql.org
+ * or personally to the current maintainer. Those changes may be
* folded in to later versions of this program.
*/
-#define XLOG_DATA_FNAME_LEN 24
+#define XLOG_DATA_FNAME_LEN 24
/* Reworked from access/xlog_internal.h */
#define XLogFileName(fname, tli, log, seg) \
snprintf(fname, XLOG_DATA_FNAME_LEN + 1, "%08X%08X%08X", tli, log, seg)
/*
- * Initialize allows customized commands into the warm standby program.
+ * Initialize allows customized commands into the warm standby program.
*
- * As an example, and probably the common case, we use either
- * cp/ln commands on *nix, or copy/move command on Windows.
+ * As an example, and probably the common case, we use either
+ * cp/ln commands on *nix, or copy/move command on Windows.
*
*/
static void
switch (restoreCommandType)
{
case RESTORE_COMMAND_LINK:
- SET_RESTORE_COMMAND("mklink",WALFilePath, xlogFilePath);
+ SET_RESTORE_COMMAND("mklink", WALFilePath, xlogFilePath);
case RESTORE_COMMAND_COPY:
default:
- SET_RESTORE_COMMAND("copy",WALFilePath, xlogFilePath);
+ SET_RESTORE_COMMAND("copy", WALFilePath, xlogFilePath);
break;
- }
+ }
#else
snprintf(WALFilePath, MAXPGPATH, "%s/%s", archiveLocation, nextWALFileName);
switch (restoreCommandType)
{
case RESTORE_COMMAND_LINK:
#if HAVE_WORKING_LINK
- SET_RESTORE_COMMAND("ln -s -f",WALFilePath, xlogFilePath);
+ SET_RESTORE_COMMAND("ln -s -f", WALFilePath, xlogFilePath);
break;
#endif
case RESTORE_COMMAND_COPY:
default:
- SET_RESTORE_COMMAND("cp",WALFilePath, xlogFilePath);
+ SET_RESTORE_COMMAND("cp", WALFilePath, xlogFilePath);
break;
- }
+ }
#endif
/*
- * This code assumes that archiveLocation is a directory
- * You may wish to add code to check for tape libraries, etc..
- * So, since it is a directory, we use stat to test if its accessible
+ * This code assumes that archiveLocation is a directory You may wish to
+ * add code to check for tape libraries, etc.. So, since it is a
+ * directory, we use stat to test if its accessible
*/
if (stat(archiveLocation, &stat_buf) != 0)
{
- fprintf(stderr, "pg_standby: archiveLocation \"%s\" does not exist\n", archiveLocation);
+ fprintf(stderr, "pg_standby: archiveLocation \"%s\" does not exist\n", archiveLocation);
fflush(stderr);
- exit(2);
+ exit(2);
}
}
/*
* CustomizableNextWALFileReady()
- *
+ *
* Is the requested file ready yet?
*/
-static bool
+static bool
CustomizableNextWALFileReady()
{
if (stat(WALFilePath, &stat_buf) == 0)
{
/*
- * If its a backup file, return immediately
- * If its a regular file return only if its the right size already
+ * If its a backup file, return immediately If its a regular file
+ * return only if its the right size already
*/
if (strlen(nextWALFileName) > 24 &&
strspn(nextWALFileName, "0123456789ABCDEF") == 24 &&
- strcmp(nextWALFileName + strlen(nextWALFileName) - strlen(".backup"),
- ".backup") == 0)
+ strcmp(nextWALFileName + strlen(nextWALFileName) - strlen(".backup"),
+ ".backup") == 0)
{
nextWALFileType = XLOG_BACKUP_LABEL;
- return true;
+ return true;
}
- else
- if (stat_buf.st_size == XLOG_SEG_SIZE)
- {
+ else if (stat_buf.st_size == XLOG_SEG_SIZE)
+ {
#ifdef WIN32
- /*
- * Windows reports that the file has the right number of bytes
- * even though the file is still being copied and cannot be
- * opened by pg_standby yet. So we wait for sleeptime secs
- * before attempting to restore. If that is not enough, we
- * will rely on the retry/holdoff mechanism.
- */
- pg_usleep(sleeptime * 1000000L);
+
+ /*
+ * Windows reports that the file has the right number of bytes
+ * even though the file is still being copied and cannot be opened
+ * by pg_standby yet. So we wait for sleeptime secs before
+ * attempting to restore. If that is not enough, we will rely on
+ * the retry/holdoff mechanism.
+ */
+ pg_usleep(sleeptime * 1000000L);
#endif
- nextWALFileType = XLOG_DATA;
- return true;
- }
+ nextWALFileType = XLOG_DATA;
+ return true;
+ }
/*
* If still too small, wait until it is the correct size
{
if (debug)
{
- fprintf(stderr, "file size greater than expected\n");
+ fprintf(stderr, "file size greater than expected\n");
fflush(stderr);
}
- exit(3);
+ exit(3);
}
}
*/
if (nextWALFileType == XLOG_DATA)
{
- int rc;
- DIR *xldir;
- struct dirent *xlde;
+ int rc;
+ DIR *xldir;
+ struct dirent *xlde;
/*
- * Assume its OK to keep failing. The failure situation may change over
- * time, so we'd rather keep going on the main processing than fail
- * because we couldnt clean up yet.
+ * Assume its OK to keep failing. The failure situation may change
+ * over time, so we'd rather keep going on the main processing than
+ * fail because we couldnt clean up yet.
*/
if ((xldir = opendir(archiveLocation)) != NULL)
{
while ((xlde = readdir(xldir)) != NULL)
{
/*
- * We ignore the timeline part of the XLOG segment identifiers in
- * deciding whether a segment is still needed. This ensures that we
- * won't prematurely remove a segment from a parent timeline. We could
- * probably be a little more proactive about removing segments of
- * non-parent timelines, but that would be a whole lot more
- * complicated.
+ * We ignore the timeline part of the XLOG segment identifiers
+ * in deciding whether a segment is still needed. This
+ * ensures that we won't prematurely remove a segment from a
+ * parent timeline. We could probably be a little more
+ * proactive about removing segments of non-parent timelines,
+ * but that would be a whole lot more complicated.
*
- * We use the alphanumeric sorting property of the filenames to decide
- * which ones are earlier than the exclusiveCleanupFileName file.
- * Note that this means files are not removed in the order they were
- * originally written, in case this worries you.
+ * We use the alphanumeric sorting property of the filenames
+ * to decide which ones are earlier than the
+ * exclusiveCleanupFileName file. Note that this means files
+ * are not removed in the order they were originally written,
+ * in case this worries you.
*/
if (strlen(xlde->d_name) == XLOG_DATA_FNAME_LEN &&
strspn(xlde->d_name, "0123456789ABCDEF") == XLOG_DATA_FNAME_LEN &&
- strcmp(xlde->d_name + 8, exclusiveCleanupFileName + 8) < 0)
+ strcmp(xlde->d_name + 8, exclusiveCleanupFileName + 8) < 0)
{
#ifdef WIN32
snprintf(WALFilePath, MAXPGPATH, "%s\\%s", archiveLocation, xlde->d_name);
#endif
if (debug)
- fprintf(stderr, "\nremoving \"%s\"", WALFilePath);
+ fprintf(stderr, "\nremoving \"%s\"", WALFilePath);
rc = unlink(WALFilePath);
if (rc != 0)
fprintf(stderr, "\n");
}
else
- fprintf(stderr, "pg_standby: archiveLocation \"%s\" open error\n", archiveLocation);
+ fprintf(stderr, "pg_standby: archiveLocation \"%s\" open error\n", archiveLocation);
closedir(xldir);
fflush(stderr);
/*
* SetWALFileNameForCleanup()
- *
+ *
* Set the earliest WAL filename that we want to keep on the archive
- * and decide whether we need_cleanup
+ * and decide whether we need_cleanup
*/
static bool
SetWALFileNameForCleanup(void)
{
- uint32 tli = 1,
- log = 0,
- seg = 0;
- uint32 log_diff = 0,
- seg_diff = 0;
- bool cleanup = false;
+ uint32 tli = 1,
+ log = 0,
+ seg = 0;
+ uint32 log_diff = 0,
+ seg_diff = 0;
+ bool cleanup = false;
if (restartWALFileName)
{
{
log_diff = keepfiles / MaxSegmentsPerLogFile;
seg_diff = keepfiles % MaxSegmentsPerLogFile;
- if (seg_diff > seg)
+ if (seg_diff > seg)
{
log_diff++;
seg = MaxSegmentsPerLogFile - seg_diff;
/*
* CheckForExternalTrigger()
- *
+ *
* Is there a trigger file?
*/
-static bool
+static bool
CheckForExternalTrigger(void)
{
- int rc;
+ int rc;
/*
- * Look for a trigger file, if that option has been selected
+ * Look for a trigger file, if that option has been selected
*
- * We use stat() here because triggerPath is always a file
- * rather than potentially being in an archive
+ * We use stat() here because triggerPath is always a file rather than
+ * potentially being in an archive
*/
if (triggerPath && stat(triggerPath, &stat_buf) == 0)
{
- fprintf(stderr, "trigger file found\n");
+ fprintf(stderr, "trigger file found\n");
fflush(stderr);
/*
- * If trigger file found, we *must* delete it. Here's why:
- * When recovery completes, we will be asked again
- * for the same file from the archive using pg_standby
- * so must remove trigger file so we can reload file again
- * and come up correctly.
+ * If trigger file found, we *must* delete it. Here's why: When
+ * recovery completes, we will be asked again for the same file from
+ * the archive using pg_standby so must remove trigger file so we can
+ * reload file again and come up correctly.
*/
rc = unlink(triggerPath);
if (rc != 0)
/*
* RestoreWALFileForRecovery()
- *
+ *
* Perform the action required to restore the file from archive
*/
static bool
RestoreWALFileForRecovery(void)
{
- int rc = 0;
- int numretries = 0;
+ int rc = 0;
+ int numretries = 0;
if (debug)
{
}
return true;
}
- pg_usleep(numretries++ * sleeptime * 1000000L);
+ pg_usleep(numretries++ * sleeptime * 1000000L);
}
/*
}
/*------------ MAIN ----------------------------------------*/
-int
+int
main(int argc, char **argv)
{
int c;
- (void) signal(SIGINT, sighandler);
- (void) signal(SIGQUIT, sighandler);
+ (void) signal(SIGINT, sighandler);
+ (void) signal(SIGQUIT, sighandler);
while ((c = getopt(argc, argv, "cdk:lr:s:t:w:")) != -1)
{
case 't': /* Trigger file */
triggerPath = optarg;
if (CheckForExternalTrigger())
- exit(1); /* Normal exit, with non-zero */
- break;
+ exit(1); /* Normal exit, with non-zero */
+ break;
case 'w': /* Max wait time */
maxwaittime = atoi(optarg);
if (maxwaittime < 0)
}
}
- /*
+ /*
* Parameter checking - after checking to see if trigger file present
*/
if (argc == 1)
/*
* We will go to the archiveLocation to get nextWALFileName.
- * nextWALFileName may not exist yet, which would not be an error,
- * so we separate the archiveLocation and nextWALFileName so we can check
+ * nextWALFileName may not exist yet, which would not be an error, so we
+ * separate the archiveLocation and nextWALFileName so we can check
* separately whether archiveLocation exists, if not that is an error
*/
if (optind < argc)
}
else
{
- fprintf(stderr, "pg_standby: must specify archiveLocation\n");
+ fprintf(stderr, "pg_standby: must specify archiveLocation\n");
usage();
exit(2);
}
}
else
{
- fprintf(stderr, "pg_standby: use %%f to specify nextWALFileName\n");
+ fprintf(stderr, "pg_standby: use %%f to specify nextWALFileName\n");
usage();
exit(2);
}
}
else
{
- fprintf(stderr, "pg_standby: use %%p to specify xlogFilePath\n");
+ fprintf(stderr, "pg_standby: use %%p to specify xlogFilePath\n");
usage();
exit(2);
}
if (debug)
{
- fprintf(stderr, "\nTrigger file : %s", triggerPath ? triggerPath : "<not set>");
- fprintf(stderr, "\nWaiting for WAL file : %s", nextWALFileName);
- fprintf(stderr, "\nWAL file path : %s", WALFilePath);
- fprintf(stderr, "\nRestoring to... : %s", xlogFilePath);
- fprintf(stderr, "\nSleep interval : %d second%s",
- sleeptime, (sleeptime > 1 ? "s" : " "));
- fprintf(stderr, "\nMax wait interval : %d %s",
- maxwaittime, (maxwaittime > 0 ? "seconds" : "forever"));
+ fprintf(stderr, "\nTrigger file : %s", triggerPath ? triggerPath : "<not set>");
+ fprintf(stderr, "\nWaiting for WAL file : %s", nextWALFileName);
+ fprintf(stderr, "\nWAL file path : %s", WALFilePath);
+ fprintf(stderr, "\nRestoring to... : %s", xlogFilePath);
+ fprintf(stderr, "\nSleep interval : %d second%s",
+ sleeptime, (sleeptime > 1 ? "s" : " "));
+ fprintf(stderr, "\nMax wait interval : %d %s",
+ maxwaittime, (maxwaittime > 0 ? "seconds" : "forever"));
fprintf(stderr, "\nCommand for restore : %s", restoreCommand);
fprintf(stderr, "\nKeep archive history : %s and later", exclusiveCleanupFileName);
fflush(stderr);
}
}
- /*
+ /*
* Main wait loop
*/
while (!CustomizableNextWALFileReady() && !triggered)
{
if (sleeptime <= 60)
- pg_usleep(sleeptime * 1000000L);
+ pg_usleep(sleeptime * 1000000L);
if (signaled)
{
triggered = true;
if (debug)
{
- fprintf(stderr, "\nsignaled to exit\n");
+ fprintf(stderr, "\nsignaled to exit\n");
fflush(stderr);
}
}
if (debug)
{
- fprintf(stderr, "\nWAL file not present yet.");
+ fprintf(stderr, "\nWAL file not present yet.");
if (triggerPath)
- fprintf(stderr, " Checking for trigger file...");
+ fprintf(stderr, " Checking for trigger file...");
fflush(stderr);
}
waittime += sleeptime;
-
+
if (!triggered && (CheckForExternalTrigger() || (waittime >= maxwaittime && maxwaittime > 0)))
{
triggered = true;
if (debug && waittime >= maxwaittime && maxwaittime > 0)
- fprintf(stderr, "\nTimed out after %d seconds\n",waittime);
+ fprintf(stderr, "\nTimed out after %d seconds\n", waittime);
}
}
}
- /*
- * Action on exit
+ /*
+ * Action on exit
*/
if (triggered)
- exit(1); /* Normal exit, with non-zero */
-
- /*
- * Once we have restored this file successfully we
- * can remove some prior WAL files.
- * If this restore fails we musn't remove any
- * file because some of them will be requested again
- * immediately after the failed restore, or when
- * we restart recovery.
+ exit(1); /* Normal exit, with non-zero */
+
+ /*
+ * Once we have restored this file successfully we can remove some prior
+ * WAL files. If this restore fails we musn't remove any file because some
+ * of them will be requested again immediately after the failed restore,
+ * or when we restart recovery.
*/
if (RestoreWALFileForRecovery() && need_cleanup)
CustomizableCleanupPriorWALFiles();
Datum
gin_extract_trgm(PG_FUNCTION_ARGS)
{
- text *val = (text *) PG_GETARG_TEXT_P(0);
- int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
- Datum *entries = NULL;
- TRGM *trg;
+ text *val = (text *) PG_GETARG_TEXT_P(0);
+ int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
+ Datum *entries = NULL;
+ TRGM *trg;
int4 trglen;
-
+
*nentries = 0;
-
+
trg = generate_trgm(VARDATA(val), VARSIZE(val) - VARHDRSZ);
trglen = ARRNELEM(trg);
-
+
if (trglen > 0)
{
- trgm *ptr;
- int4 i = 0,
- item;
-
+ trgm *ptr;
+ int4 i = 0,
+ item;
+
*nentries = (int32) trglen;
entries = (Datum *) palloc(sizeof(Datum) * trglen);
{
item = TRGMINT(ptr);
entries[i++] = Int32GetDatum(item);
-
+
ptr++;
}
}
Datum
gin_trgm_consistent(PG_FUNCTION_ARGS)
{
- bool *check = (bool *) PG_GETARG_POINTER(0);
- text *query = (text *) PG_GETARG_TEXT_P(2);
+ bool *check = (bool *) PG_GETARG_POINTER(0);
+ text *query = (text *) PG_GETARG_TEXT_P(2);
bool res = FALSE;
- TRGM *trg;
+ TRGM *trg;
int4 i,
trglen,
ntrue = 0;
-
+
trg = generate_trgm(VARDATA(query), VARSIZE(query) - VARHDRSZ);
trglen = ARRNELEM(trg);
-
+
for (i = 0; i < trglen; i++)
if (check[i])
- ntrue ++;
+ ntrue++;
#ifdef DIVUNION
res = (trglen == ntrue) ? true : ((((((float4) ntrue) / ((float4) (trglen - ntrue)))) >= trgm_limit) ? true : false);
/*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.73 2007/10/22 10:40:47 mha Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.74 2007/11/15 21:14:31 momjian Exp $
*
* pgbench: a simple benchmark program for PostgreSQL
* written by Tatsuo Ishii
/* max number of clients allowed */
#ifdef FD_SETSIZE
-#define MAXCLIENTS (FD_SETSIZE - 10)
+#define MAXCLIENTS (FD_SETSIZE - 10)
#else
-#define MAXCLIENTS 1024
+#define MAXCLIENTS 1024
#endif
int nclients = 1; /* default number of simulated clients */
/* call PQexec() and exit() on failure */
static void
-executeStatement(PGconn *con, const char* sql)
+executeStatement(PGconn *con, const char *sql)
{
PGresult *res;
/* check to see if the SQL result was good */
static int
-check(CState *state, PGresult *res, int n)
+check(CState * state, PGresult *res, int n)
{
CState *st = &state[n];
default:
fprintf(stderr, "Client %d aborted in state %d: %s",
n, st->state, PQerrorMessage(st->con));
- remains--; /* I've aborted */
+ remains--; /* I've aborted */
PQfinish(st->con);
st->con = NULL;
return (-1);
if (st->sleeping)
{ /* are we sleeping? */
- int usec;
- struct timeval now;
+ int usec;
+ struct timeval now;
gettimeofday(&now, NULL);
usec = (st->until.tv_sec - now.tv_sec) * 1000000 +
- st->until.tv_usec - now.tv_usec;
+ st->until.tv_usec - now.tv_usec;
if (usec <= 0)
st->sleeping = 0; /* Done sleeping, go ahead with next command */
else
"drop table if exists accounts",
"create table accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=%d)",
"drop table if exists history",
- "create table history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22))"};
+ "create table history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22))"};
static char *DDLAFTERs[] = {
"alter table branches add primary key (bid)",
"alter table tellers add primary key (tid)",
- "alter table accounts add primary key (aid)"};
+ "alter table accounts add primary key (aid)"};
char sql[256];
(strstr(DDLs[i], "create table tellers") == DDLs[i]) ||
(strstr(DDLs[i], "create table accounts") == DDLs[i]))
{
- char ddl_stmt[128];
+ char ddl_stmt[128];
+
snprintf(ddl_stmt, 128, DDLs[i], fillfactor);
executeStatement(con, ddl_stmt);
continue;
pg_strcasecmp(my_commands->argv[2], "ms") != 0 &&
pg_strcasecmp(my_commands->argv[2], "s"))
{
- fprintf(stderr, "%s: unknown time unit '%s' - must be us, ms or s\n",
+ fprintf(stderr, "%s: unknown time unit '%s' - must be us, ms or s\n",
my_commands->argv[0], my_commands->argv[2]);
return NULL;
}
int c;
int is_init_mode = 0; /* initialize mode? */
int is_no_vacuum = 0; /* no vacuum at all before testing? */
- int do_vacuum_accounts = 0; /* do vacuum accounts before testing? */
+ int do_vacuum_accounts = 0; /* do vacuum accounts before testing? */
int debug = 0; /* debug flag */
int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT only,
* 2: skip update of branches and tellers */
fprintf(stderr, "Use limit/ulimit to increase the limit before using pgbench.\n");
exit(1);
}
-#endif /* HAVE_GETRLIMIT */
+#endif /* HAVE_GETRLIMIT */
break;
case 'C':
is_connect = 1;
if (state[i].sleeping)
{
- int this_usec;
- int sock = PQsocket(state[i].con);
+ int this_usec;
+ int sock = PQsocket(state[i].con);
if (min_usec < 0)
{
}
this_usec = (state[i].until.tv_sec - now.tv_sec) * 1000000 +
- state[i].until.tv_usec - now.tv_usec;
+ state[i].until.tv_usec - now.tv_usec;
if (this_usec > 0 && (min_usec == 0 || this_usec < min_usec))
min_usec = this_usec;
timeout.tv_usec = min_usec % 1000000;
nsocks = select(maxsock + 1, &input_mask, (fd_set *) NULL,
- (fd_set *) NULL, &timeout);
+ (fd_set *) NULL, &timeout);
}
else
nsocks = select(maxsock + 1, &input_mask, (fd_set *) NULL,
- (fd_set *) NULL, (struct timeval *) NULL);
+ (fd_set *) NULL, (struct timeval *) NULL);
if (nsocks < 0)
{
if (errno == EINTR)
/*
* Butchered version of sshblowf.c from putty-0.59.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/blf.c,v 1.8 2007/03/28 22:48:58 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/blf.c,v 1.9 2007/11/15 21:14:31 momjian Exp $
*/
/*
static void
blowfish_encrypt(uint32 xL, uint32 xR, uint32 *output,
- BlowfishContext *ctx)
+ BlowfishContext * ctx)
{
uint32 *S0 = ctx->S0;
uint32 *S1 = ctx->S1;
static void
blowfish_decrypt(uint32 xL, uint32 xR, uint32 *output,
- BlowfishContext *ctx)
+ BlowfishContext * ctx)
{
uint32 *S0 = ctx->S0;
uint32 *S1 = ctx->S1;
}
void
-blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx)
+blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx)
{
uint32 xL,
xR,
}
void
-blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx)
+blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx)
{
uint32 xL,
xR,
}
void
-blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx)
+blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx)
{
uint32 xL,
xR,
}
void
-blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx)
+blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx)
{
uint32 xL,
xR,
}
void
-blowfish_setkey(BlowfishContext *ctx,
+blowfish_setkey(BlowfishContext * ctx,
const uint8 *key, short keybytes)
{
uint32 *S0 = ctx->S0;
uint32 str[2];
int i;
- Assert(keybytes > 0 && keybytes <= (448/8));
+ Assert(keybytes > 0 && keybytes <= (448 / 8));
for (i = 0; i < 18; i++)
{
}
void
-blowfish_setiv(BlowfishContext *ctx, const uint8 *iv)
+blowfish_setiv(BlowfishContext * ctx, const uint8 *iv)
{
ctx->iv0 = GET_32BIT_MSB_FIRST(iv);
ctx->iv1 = GET_32BIT_MSB_FIRST(iv + 4);
}
-
-/* $PostgreSQL: pgsql/contrib/pgcrypto/blf.h,v 1.6 2007/03/28 22:48:58 neilc Exp $ */
+/* $PostgreSQL: pgsql/contrib/pgcrypto/blf.h,v 1.7 2007/11/15 21:14:31 momjian Exp $ */
/*
* PuTTY is copyright 1997-2007 Simon Tatham.
*
S3[256],
P[18];
uint32 iv0,
- iv1; /* for CBC mode */
-} BlowfishContext;
-
-void blowfish_setkey(BlowfishContext *ctx, const uint8 *key, short keybytes);
-void blowfish_setiv(BlowfishContext *ctx, const uint8 *iv);
-void blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx);
-void blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx);
-void blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx);
-void blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx);
-
+ iv1; /* for CBC mode */
+} BlowfishContext;
+void blowfish_setkey(BlowfishContext * ctx, const uint8 *key, short keybytes);
+void blowfish_setiv(BlowfishContext * ctx, const uint8 *iv);
+void blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx);
+void blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx);
+void blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx);
+void blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx);
/*
- * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.12 2007/04/06 05:36:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.13 2007/11/15 21:14:31 momjian Exp $
*
* This code comes from John the Ripper password cracker, with reentrant
* and crypt(3) interfaces added, but optimizations specific to password
}
static void
-BF_swap(BF_word *x, int count)
+BF_swap(BF_word * x, int count)
{
/* Swap on little-endian hardware, else do nothing */
#ifndef WORDS_BIGENDIAN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
-/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.h,v 1.5 2006/10/04 00:29:46 momjian Exp $ */
+/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.h,v 1.6 2007/11/15 21:14:31 momjian Exp $ */
#ifndef IMATH_H_
#define IMATH_H_
mp_result mp_int_mul_value(mp_int a, int value, mp_int c);
mp_result mp_int_mul_pow2(mp_int a, int p2, mp_int c);
mp_result mp_int_sqr(mp_int a, mp_int c); /* c = a * a */
+
mp_result
-mp_int_div(mp_int a, mp_int b, /* q = a / b */
+mp_int_div(mp_int a, mp_int b, /* q = a / b */
mp_int q, mp_int r); /* r = a % b */
mp_result
-mp_int_div_value(mp_int a, int value, /* q = a / value */
+mp_int_div_value(mp_int a, int value, /* q = a / value */
mp_int q, int *r); /* r = a % value */
mp_result
mp_int_div_pow2(mp_int a, int p2, /* q = a / 2^p2 */
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.26 2007/03/28 22:48:58 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.27 2007/11/15 21:14:31 momjian Exp $
*/
#include "postgres.h"
uint8 iv[INT_MAX_IV];
union
{
- BlowfishContext bf;
+ BlowfishContext bf;
rijndael_ctx rj;
} ctx;
unsigned keylen;
static unsigned
bf_key_size(PX_Cipher * c)
{
- return 448/8;
+ return 448 / 8;
}
static unsigned
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.31 2007/09/29 02:18:15 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.32 2007/11/15 21:14:31 momjian Exp $
*/
#include "postgres.h"
AES_cbc_encrypt(const uint8 *src, uint8 *dst, int len, AES_KEY *ctx, uint8 *iv, int enc)
{
memcpy(dst, src, len);
- if (enc) {
+ if (enc)
+ {
aes_cbc_encrypt(ctx, iv, dst, len);
memcpy(iv, dst + len - 16, 16);
- } else {
+ }
+ else
+ {
aes_cbc_decrypt(ctx, iv, dst, len);
memcpy(iv, src + len - 16, 16);
}
bf_check_supported_key_len(void)
{
static const uint8 key[56] = {
- 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,0x78,0x69,
- 0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,0x00,0x11,0x22,0x33,
- 0x44,0x55,0x66,0x77,0x04,0x68,0x91,0x04,0xc2,0xfd,
- 0x3b,0x2f,0x58,0x40,0x23,0x64,0x1a,0xba,0x61,0x76,
- 0x1f,0x1f,0x1f,0x1f,0x0e,0x0e,0x0e,0x0e,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff
+ 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 0x78, 0x69,
+ 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f, 0x00, 0x11, 0x22, 0x33,
+ 0x44, 0x55, 0x66, 0x77, 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd,
+ 0x3b, 0x2f, 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
+ 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
- static const uint8 data[8] = {0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
- static const uint8 res[8] = {0xc0,0x45,0x04,0x01,0x2e,0x4e,0x1f,0x53};
+ static const uint8 data[8] = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10};
+ static const uint8 res[8] = {0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53};
static uint8 out[8];
- BF_KEY bf_key;
+ BF_KEY bf_key;
/* encrypt with 448bits key and verify output */
BF_set_key(&bf_key, 56, key);
BF_ecb_encrypt(data, out, &bf_key, BF_ENCRYPT);
- if (memcmp(out, res, 8) != 0)
- return 0; /* Output does not match -> strong cipher is not supported */
+ if (memcmp(out, res, 8) != 0)
+ return 0; /* Output does not match -> strong cipher is
+ * not supported */
return 1;
}
bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
{
ossldata *od = c->ptr;
- static int bf_is_strong = -1;
+ static int bf_is_strong = -1;
/*
- * Test if key len is supported. BF_set_key silently cut large keys and it could be
- * be a problem when user transfer crypted data from one server to another.
+ * Test if key len is supported. BF_set_key silently cut large keys and it
+ * could be be a problem when user transfer crypted data from one server
+ * to another.
*/
-
- if( bf_is_strong == -1)
+
+ if (bf_is_strong == -1)
bf_is_strong = bf_check_supported_key_len();
- if( !bf_is_strong && klen>16 )
- return PXE_KEY_TOO_BIG;
+ if (!bf_is_strong && klen > 16)
+ return PXE_KEY_TOO_BIG;
/* Key len is supported. We can use it. */
BF_set_key(&od->u.bf.key, klen, key);
static int
ossl_aes_key_init(ossldata * od, int type)
{
- int err;
+ int err;
+
/*
- * Strong key support could be missing on some openssl installations.
- * We must check return value from set key function.
- */
+ * Strong key support could be missing on some openssl installations. We
+ * must check return value from set key function.
+ */
if (type == AES_ENCRYPT)
- err = AES_set_encrypt_key(od->key, od->klen * 8, &od->u.aes_key);
+ err = AES_set_encrypt_key(od->key, od->klen * 8, &od->u.aes_key);
else
err = AES_set_decrypt_key(od->key, od->klen * 8, &od->u.aes_key);
unsigned bs = gen_ossl_block_size(c);
ossldata *od = c->ptr;
const uint8 *end = data + dlen - bs;
- int err;
+ int err;
if (!od->init)
if ((err = ossl_aes_key_init(od, AES_ENCRYPT)) != 0)
unsigned bs = gen_ossl_block_size(c);
ossldata *od = c->ptr;
const uint8 *end = data + dlen - bs;
- int err;
+ int err;
if (!od->init)
if ((err = ossl_aes_key_init(od, AES_DECRYPT)) != 0)
uint8 *res)
{
ossldata *od = c->ptr;
- int err;
+ int err;
if (!od->init)
if ((err = ossl_aes_key_init(od, AES_ENCRYPT)) != 0)
return err;
-
+
AES_cbc_encrypt(data, res, dlen, &od->u.aes_key, od->iv, AES_ENCRYPT);
return 0;
}
uint8 *res)
{
ossldata *od = c->ptr;
- int err;
+ int err;
if (!od->init)
if ((err = ossl_aes_key_init(od, AES_DECRYPT)) != 0)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.6 2007/01/14 20:55:14 alvherre Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.7 2007/11/15 21:14:31 momjian Exp $
*/
#include "postgres.h"
{
return pullf_create(res, &decompress_filter, ctx, src);
}
-
#else /* !HAVE_ZLIB */
int
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.16 2007/08/23 16:15:51 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.17 2007/11/15 21:14:31 momjian Exp $
*/
#include "postgres.h"
/* with padding, empty ciphertext is not allowed */
if (cx->padding)
return PXE_DECRYPT_FAILED;
-
+
/* without padding, report empty result */
*rlen = 0;
return 0;
*
* $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.9 2007/04/06 05:36:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.10 2007/11/15 21:14:31 momjian Exp $
*/
#include "postgres.h"
(x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \
((tmp & 0x0000ffff0000ffffULL) << 16); \
}
-#endif /* not bigendian */
+#endif /* not bigendian */
/*
* Macro for incrementally adding the unsigned 64-bit integer n to the
else if (P_ISLEAF(opaque))
{
- int max_avail;
- max_avail = BLCKSZ - (BLCKSZ - ((PageHeader)page)->pd_special + SizeOfPageHeaderData);
+ int max_avail;
+
+ max_avail = BLCKSZ - (BLCKSZ - ((PageHeader) page)->pd_special + SizeOfPageHeaderData);
indexStat.max_avail += max_avail;
indexStat.free_space += PageGetFreeSpace(page);
indexStat.leaf_pages++;
/*
- * If the next leaf is on an earlier block, it
- * means a fragmentation.
+ * If the next leaf is on an earlier block, it means a
+ * fragmentation.
*/
if (opaque->btpo_next != P_NONE && opaque->btpo_next < blkno)
indexStat.fragments++;
xpstrdup(values[0], rowid);
/*
- * Check to see if the rowid is the same as that of the last
- * tuple sent -- if so, skip this tuple entirely
+ * Check to see if the rowid is the same as that of the
+ * last tuple sent -- if so, skip this tuple entirely
*/
if (!firstpass && xstreq(lastrowid, rowid))
{
}
/*
- * If rowid hasn't changed on us, continue building the
- * ouput tuple.
+ * If rowid hasn't changed on us, continue building the ouput
+ * tuple.
*/
if (xstreq(rowid, values[0]))
{
* Copyright (c) 2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/test_parser/test_parser.c,v 1.1 2007/10/15 21:36:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/test_parser/test_parser.c,v 1.2 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
/* self-defined type */
-typedef struct {
- char * buffer; /* text to parse */
- int len; /* length of the text in buffer */
- int pos; /* position of the parser */
-} ParserState;
+typedef struct
+{
+ char *buffer; /* text to parse */
+ int len; /* length of the text in buffer */
+ int pos; /* position of the parser */
+} ParserState;
/* copy-paste from wparser.h of tsearch2 */
-typedef struct {
- int lexid;
- char *alias;
- char *descr;
-} LexDescr;
+typedef struct
+{
+ int lexid;
+ char *alias;
+ char *descr;
+} LexDescr;
/*
* prototypes
*/
PG_FUNCTION_INFO_V1(testprs_start);
-Datum testprs_start(PG_FUNCTION_ARGS);
+Datum testprs_start(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(testprs_getlexeme);
-Datum testprs_getlexeme(PG_FUNCTION_ARGS);
+Datum testprs_getlexeme(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(testprs_end);
-Datum testprs_end(PG_FUNCTION_ARGS);
+Datum testprs_end(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(testprs_lextype);
-Datum testprs_lextype(PG_FUNCTION_ARGS);
+Datum testprs_lextype(PG_FUNCTION_ARGS);
/*
* functions
*/
-Datum testprs_start(PG_FUNCTION_ARGS)
+Datum
+testprs_start(PG_FUNCTION_ARGS)
{
ParserState *pst = (ParserState *) palloc0(sizeof(ParserState));
+
pst->buffer = (char *) PG_GETARG_POINTER(0);
pst->len = PG_GETARG_INT32(1);
pst->pos = 0;
PG_RETURN_POINTER(pst);
}
-Datum testprs_getlexeme(PG_FUNCTION_ARGS)
+Datum
+testprs_getlexeme(PG_FUNCTION_ARGS)
{
- ParserState *pst = (ParserState *) PG_GETARG_POINTER(0);
- char **t = (char **) PG_GETARG_POINTER(1);
- int *tlen = (int *) PG_GETARG_POINTER(2);
+ ParserState *pst = (ParserState *) PG_GETARG_POINTER(0);
+ char **t = (char **) PG_GETARG_POINTER(1);
+ int *tlen = (int *) PG_GETARG_POINTER(2);
int type;
*tlen = pst->pos;
- *t = pst->buffer + pst->pos;
+ *t = pst->buffer + pst->pos;
if ((pst->buffer)[pst->pos] == ' ')
{
while ((pst->buffer)[pst->pos] == ' ' &&
pst->pos < pst->len)
(pst->pos)++;
- } else {
+ }
+ else
+ {
/* word type */
type = 3;
/* go to the next white-space character */
/* we are finished if (*tlen == 0) */
if (*tlen == 0)
- type=0;
+ type = 0;
PG_RETURN_INT32(type);
}
-Datum testprs_end(PG_FUNCTION_ARGS)
+Datum
+testprs_end(PG_FUNCTION_ARGS)
{
ParserState *pst = (ParserState *) PG_GETARG_POINTER(0);
+
pfree(pst);
PG_RETURN_VOID();
}
-Datum testprs_lextype(PG_FUNCTION_ARGS)
+Datum
+testprs_lextype(PG_FUNCTION_ARGS)
{
/*
- * Remarks:
- * - we have to return the blanks for headline reason
- * - we use the same lexids like Teodor in the default
- * word parser; in this way we can reuse the headline
- * function of the default word parser.
+ * Remarks: - we have to return the blanks for headline reason - we use
+ * the same lexids like Teodor in the default word parser; in this way we
+ * can reuse the headline function of the default word parser.
*/
- LexDescr *descr = (LexDescr *) palloc(sizeof(LexDescr) * (2+1));
+ LexDescr *descr = (LexDescr *) palloc(sizeof(LexDescr) * (2 + 1));
/* there are only two types in this parser */
descr[0].lexid = 3;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.2 2007/11/13 22:14:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.3 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PG_MODULE_MAGIC;
-static Oid current_dictionary_oid = InvalidOid;
-static Oid current_parser_oid = InvalidOid;
+static Oid current_dictionary_oid = InvalidOid;
+static Oid current_parser_oid = InvalidOid;
/* insert given value at argument position 0 */
#define INSERT_ARGUMENT0(argument, isnull) \
} \
PG_FUNCTION_INFO_V1(name)
-static Oid GetCurrentDict(void);
-static Oid GetCurrentParser(void);
-
-Datum tsa_lexize_byname(PG_FUNCTION_ARGS);
-Datum tsa_lexize_bycurrent(PG_FUNCTION_ARGS);
-Datum tsa_set_curdict(PG_FUNCTION_ARGS);
-Datum tsa_set_curdict_byname(PG_FUNCTION_ARGS);
-Datum tsa_token_type_current(PG_FUNCTION_ARGS);
-Datum tsa_set_curprs(PG_FUNCTION_ARGS);
-Datum tsa_set_curprs_byname(PG_FUNCTION_ARGS);
-Datum tsa_parse_current(PG_FUNCTION_ARGS);
-Datum tsa_set_curcfg(PG_FUNCTION_ARGS);
-Datum tsa_set_curcfg_byname(PG_FUNCTION_ARGS);
-Datum tsa_to_tsvector_name(PG_FUNCTION_ARGS);
-Datum tsa_to_tsquery_name(PG_FUNCTION_ARGS);
-Datum tsa_plainto_tsquery_name(PG_FUNCTION_ARGS);
-Datum tsa_headline_byname(PG_FUNCTION_ARGS);
-Datum tsa_ts_stat(PG_FUNCTION_ARGS);
-Datum tsa_tsearch2(PG_FUNCTION_ARGS);
-Datum tsa_rewrite_accum(PG_FUNCTION_ARGS);
-Datum tsa_rewrite_finish(PG_FUNCTION_ARGS);
+static Oid GetCurrentDict(void);
+static Oid GetCurrentParser(void);
+
+Datum tsa_lexize_byname(PG_FUNCTION_ARGS);
+Datum tsa_lexize_bycurrent(PG_FUNCTION_ARGS);
+Datum tsa_set_curdict(PG_FUNCTION_ARGS);
+Datum tsa_set_curdict_byname(PG_FUNCTION_ARGS);
+Datum tsa_token_type_current(PG_FUNCTION_ARGS);
+Datum tsa_set_curprs(PG_FUNCTION_ARGS);
+Datum tsa_set_curprs_byname(PG_FUNCTION_ARGS);
+Datum tsa_parse_current(PG_FUNCTION_ARGS);
+Datum tsa_set_curcfg(PG_FUNCTION_ARGS);
+Datum tsa_set_curcfg_byname(PG_FUNCTION_ARGS);
+Datum tsa_to_tsvector_name(PG_FUNCTION_ARGS);
+Datum tsa_to_tsquery_name(PG_FUNCTION_ARGS);
+Datum tsa_plainto_tsquery_name(PG_FUNCTION_ARGS);
+Datum tsa_headline_byname(PG_FUNCTION_ARGS);
+Datum tsa_ts_stat(PG_FUNCTION_ARGS);
+Datum tsa_tsearch2(PG_FUNCTION_ARGS);
+Datum tsa_rewrite_accum(PG_FUNCTION_ARGS);
+Datum tsa_rewrite_finish(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(tsa_lexize_byname);
PG_FUNCTION_INFO_V1(tsa_lexize_bycurrent);
Datum
tsa_lexize_byname(PG_FUNCTION_ARGS)
{
- text *dictname = PG_GETARG_TEXT_P(0);
- Datum arg1 = PG_GETARG_DATUM(1);
+ text *dictname = PG_GETARG_TEXT_P(0);
+ Datum arg1 = PG_GETARG_DATUM(1);
return DirectFunctionCall2(ts_lexize,
- ObjectIdGetDatum(TextGetObjectId(regdictionaryin, dictname)),
+ ObjectIdGetDatum(TextGetObjectId(regdictionaryin, dictname)),
arg1);
}
Datum
tsa_lexize_bycurrent(PG_FUNCTION_ARGS)
{
- Datum arg0 = PG_GETARG_DATUM(0);
- Oid id = GetCurrentDict();
+ Datum arg0 = PG_GETARG_DATUM(0);
+ Oid id = GetCurrentDict();
return DirectFunctionCall2(ts_lexize,
ObjectIdGetDatum(id),
Datum
tsa_set_curdict(PG_FUNCTION_ARGS)
{
- Oid dict_oid = PG_GETARG_OID(0);
+ Oid dict_oid = PG_GETARG_OID(0);
if (!SearchSysCacheExists(TSDICTOID,
ObjectIdGetDatum(dict_oid),
Datum
tsa_set_curdict_byname(PG_FUNCTION_ARGS)
{
- text *name = PG_GETARG_TEXT_P(0);
- Oid dict_oid;
+ text *name = PG_GETARG_TEXT_P(0);
+ Oid dict_oid;
dict_oid = TSDictionaryGetDictid(stringToQualifiedNameList(TextPGetCString(name)), false);
Datum
tsa_set_curprs(PG_FUNCTION_ARGS)
{
- Oid parser_oid = PG_GETARG_OID(0);
+ Oid parser_oid = PG_GETARG_OID(0);
if (!SearchSysCacheExists(TSPARSEROID,
ObjectIdGetDatum(parser_oid),
Datum
tsa_set_curprs_byname(PG_FUNCTION_ARGS)
{
- text *name = PG_GETARG_TEXT_P(0);
- Oid parser_oid;
+ text *name = PG_GETARG_TEXT_P(0);
+ Oid parser_oid;
parser_oid = TSParserGetPrsid(stringToQualifiedNameList(TextPGetCString(name)), false);
Datum
tsa_set_curcfg(PG_FUNCTION_ARGS)
{
- Oid arg0 = PG_GETARG_OID(0);
- char *name;
+ Oid arg0 = PG_GETARG_OID(0);
+ char *name;
name = DatumGetCString(DirectFunctionCall1(regconfigout,
ObjectIdGetDatum(arg0)));
-
+
set_config_option("default_text_search_config", name,
PGC_USERSET,
PGC_S_SESSION,
Datum
tsa_set_curcfg_byname(PG_FUNCTION_ARGS)
{
- text *arg0 = PG_GETARG_TEXT_P(0);
- char *name;
+ text *arg0 = PG_GETARG_TEXT_P(0);
+ char *name;
name = TextPGetCString(arg0);
Datum
tsa_to_tsvector_name(PG_FUNCTION_ARGS)
{
- text *cfgname = PG_GETARG_TEXT_P(0);
- Datum arg1 = PG_GETARG_DATUM(1);
- Oid config_oid;
+ text *cfgname = PG_GETARG_TEXT_P(0);
+ Datum arg1 = PG_GETARG_DATUM(1);
+ Oid config_oid;
config_oid = TextGetObjectId(regconfigin, cfgname);
Datum
tsa_to_tsquery_name(PG_FUNCTION_ARGS)
{
- text *cfgname = PG_GETARG_TEXT_P(0);
- Datum arg1 = PG_GETARG_DATUM(1);
- Oid config_oid;
+ text *cfgname = PG_GETARG_TEXT_P(0);
+ Datum arg1 = PG_GETARG_DATUM(1);
+ Oid config_oid;
config_oid = TextGetObjectId(regconfigin, cfgname);
Datum
tsa_plainto_tsquery_name(PG_FUNCTION_ARGS)
{
- text *cfgname = PG_GETARG_TEXT_P(0);
- Datum arg1 = PG_GETARG_DATUM(1);
- Oid config_oid;
+ text *cfgname = PG_GETARG_TEXT_P(0);
+ Datum arg1 = PG_GETARG_DATUM(1);
+ Oid config_oid;
config_oid = TextGetObjectId(regconfigin, cfgname);
Datum
tsa_headline_byname(PG_FUNCTION_ARGS)
{
- Datum arg0 = PG_GETARG_DATUM(0);
- Datum arg1 = PG_GETARG_DATUM(1);
- Datum arg2 = PG_GETARG_DATUM(2);
- Datum result;
- Oid config_oid;
+ Datum arg0 = PG_GETARG_DATUM(0);
+ Datum arg1 = PG_GETARG_DATUM(1);
+ Datum arg2 = PG_GETARG_DATUM(2);
+ Datum result;
+ Oid config_oid;
/* first parameter has to be converted to oid */
config_oid = DatumGetObjectId(DirectFunctionCall1(regconfigin,
- DirectFunctionCall1(textout, arg0)));
+ DirectFunctionCall1(textout, arg0)));
if (PG_NARGS() == 3)
result = DirectFunctionCall3(ts_headline_byid,
- ObjectIdGetDatum(config_oid), arg1, arg2);
+ ObjectIdGetDatum(config_oid), arg1, arg2);
else
{
- Datum arg3 = PG_GETARG_DATUM(3);
+ Datum arg3 = PG_GETARG_DATUM(3);
result = DirectFunctionCall4(ts_headline_byid_opt,
ObjectIdGetDatum(config_oid),
{
TriggerData *trigdata;
Trigger *trigger;
- char **tgargs;
+ char **tgargs;
int i;
/* Check call context */
- if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
+ if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
elog(ERROR, "tsvector_update_trigger: not fired by trigger manager");
trigdata = (TriggerData *) fcinfo->context;
tgargs = (char **) palloc((trigger->tgnargs + 1) * sizeof(char *));
tgargs[0] = trigger->tgargs[0];
for (i = 1; i < trigger->tgnargs; i++)
- tgargs[i+1] = trigger->tgargs[i];
+ tgargs[i + 1] = trigger->tgargs[i];
tgargs[1] = pstrdup(GetConfigOptionByName("default_text_search_config",
NULL));
*
* Copyright (c) 2007 PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.3 2007/10/23 21:38:16 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.4 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PG_MODULE_MAGIC;
-Datum uuid_nil(PG_FUNCTION_ARGS);
-Datum uuid_ns_dns(PG_FUNCTION_ARGS);
-Datum uuid_ns_url(PG_FUNCTION_ARGS);
-Datum uuid_ns_oid(PG_FUNCTION_ARGS);
-Datum uuid_ns_x500(PG_FUNCTION_ARGS);
+Datum uuid_nil(PG_FUNCTION_ARGS);
+Datum uuid_ns_dns(PG_FUNCTION_ARGS);
+Datum uuid_ns_url(PG_FUNCTION_ARGS);
+Datum uuid_ns_oid(PG_FUNCTION_ARGS);
+Datum uuid_ns_x500(PG_FUNCTION_ARGS);
-Datum uuid_generate_v1(PG_FUNCTION_ARGS);
-Datum uuid_generate_v1mc(PG_FUNCTION_ARGS);
-Datum uuid_generate_v3(PG_FUNCTION_ARGS);
-Datum uuid_generate_v4(PG_FUNCTION_ARGS);
-Datum uuid_generate_v5(PG_FUNCTION_ARGS);
+Datum uuid_generate_v1(PG_FUNCTION_ARGS);
+Datum uuid_generate_v1mc(PG_FUNCTION_ARGS);
+Datum uuid_generate_v3(PG_FUNCTION_ARGS);
+Datum uuid_generate_v4(PG_FUNCTION_ARGS);
+Datum uuid_generate_v5(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(uuid_nil);
static char *
-uuid_to_string(const uuid_t *uuid)
+uuid_to_string(const uuid_t * uuid)
{
- char *buf = palloc(UUID_LEN_STR + 1);
- void *ptr = buf;
- size_t len = UUID_LEN_STR + 1;
+ char *buf = palloc(UUID_LEN_STR + 1);
+ void *ptr = buf;
+ size_t len = UUID_LEN_STR + 1;
uuid_export(uuid, UUID_FMT_STR, &ptr, &len);
static void
-string_to_uuid(const char *str, uuid_t *uuid)
+string_to_uuid(const char *str, uuid_t * uuid)
{
uuid_import(uuid, UUID_FMT_STR, str, UUID_LEN_STR + 1);
}
static Datum
special_uuid_value(const char *name)
{
- uuid_t *uuid;
- char *str;
+ uuid_t *uuid;
+ char *str;
uuid_create(&uuid);
uuid_load(uuid, name);
static Datum
-uuid_generate_internal(int mode, const uuid_t *ns, const char *name)
+uuid_generate_internal(int mode, const uuid_t * ns, const char *name)
{
- uuid_t *uuid;
- char *str;
+ uuid_t *uuid;
+ char *str;
uuid_create(&uuid);
uuid_make(uuid, mode, ns, name);
static Datum
-uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
+uuid_generate_v35_internal(int mode, pg_uuid_t * ns, text *name)
{
uuid_t *ns_uuid;
Datum result;
result = uuid_generate_internal(mode,
ns_uuid,
- DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(name))));
+ DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(name))));
uuid_destroy(ns_uuid);
* without explicitly invoking the toaster.
*
* This change will break any code that assumes it needn't detoast values
- * that have been put into a tuple but never sent to disk. Hopefully there
+ * that have been put into a tuple but never sent to disk. Hopefully there
* are few such places.
*
* Varlenas still have alignment 'i' (or 'd') in pg_type/pg_attribute, since
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.118 2007/11/07 12:24:23 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.119 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
for (i = 0; i < numberOfAttributes; i++)
{
- Datum val;
+ Datum val;
if (isnull[i])
continue;
val = values[i];
- if (ATT_IS_PACKABLE(att[i]) &&
+ if (ATT_IS_PACKABLE(att[i]) &&
VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))
{
/*
- * we're anticipating converting to a short varlena header,
- * so adjust length and don't count any alignment
+ * we're anticipating converting to a short varlena header, so
+ * adjust length and don't count any alignment
*/
data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
}
for (i = 0; i < numberOfAttributes; i++)
{
- Datum val;
+ Datum val;
if (nulls[i] != ' ')
continue;
val = values[i];
- if (ATT_IS_PACKABLE(att[i]) &&
+ if (ATT_IS_PACKABLE(att[i]) &&
VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))
{
/*
- * we're anticipating converting to a short varlena header,
- * so adjust length and don't count any alignment
+ * we're anticipating converting to a short varlena header, so
+ * adjust length and don't count any alignment
*/
data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
}
int i;
int numberOfAttributes = tupleDesc->natts;
Form_pg_attribute *att = tupleDesc->attrs;
+
#ifdef USE_ASSERT_CHECKING
char *start = data;
#endif
}
/*
- * XXX we use the att_align macros on the pointer value itself,
- * not on an offset. This is a bit of a hack.
+ * XXX we use the att_align macros on the pointer value itself, not on
+ * an offset. This is a bit of a hack.
*/
if (att[i]->attbyval)
int i;
int numberOfAttributes = tupleDesc->natts;
Form_pg_attribute *att = tupleDesc->attrs;
+
#ifdef USE_ASSERT_CHECKING
char *start = data;
#endif
}
/*
- * XXX we use the att_align macros on the pointer value itself,
- * not on an offset. This is a bit of a hack.
+ * XXX we use the att_align macros on the pointer value itself, not on
+ * an offset. This is a bit of a hack.
*/
if (att[i]->attbyval)
/*
* Otherwise, check for non-fixed-length attrs up to and including
- * target. If there aren't any, it's safe to cheaply initialize
- * the cached offsets for these attrs.
+ * target. If there aren't any, it's safe to cheaply initialize the
+ * cached offsets for these attrs.
*/
if (HeapTupleHasVarWidth(tuple))
{
int i;
/*
- * Now we know that we have to walk the tuple CAREFULLY. But we
- * still might be able to cache some offsets for next time.
+ * Now we know that we have to walk the tuple CAREFULLY. But we still
+ * might be able to cache some offsets for next time.
*
* Note - This loop is a little tricky. For each non-null attribute,
* we have to first account for alignment padding before the attr,
* attcacheoff until we reach either a null or a var-width attribute.
*/
off = 0;
- for (i = 0; ; i++) /* loop exit is at "break" */
+ for (i = 0;; i++) /* loop exit is at "break" */
{
if (HeapTupleHasNulls(tuple) && att_isnull(i, bp))
{
usecache = false;
- continue; /* this cannot be the target att */
+ continue; /* this cannot be the target att */
}
/* If we know the next offset, we can skip the rest */
else if (att[i]->attlen == -1)
{
/*
- * We can only cache the offset for a varlena attribute
- * if the offset is already suitably aligned, so that there
- * would be no pad bytes in any case: then the offset will
- * be valid for either an aligned or unaligned value.
+ * We can only cache the offset for a varlena attribute if the
+ * offset is already suitably aligned, so that there would be
+ * no pad bytes in any case: then the offset will be valid for
+ * either an aligned or unaligned value.
*/
if (usecache &&
off == att_align_nominal(off, att[i]->attalign))
break;
case MinCommandIdAttributeNumber:
case MaxCommandIdAttributeNumber:
+
/*
- * cmin and cmax are now both aliases for the same field,
- * which can in fact also be a combo command id. XXX perhaps we
- * should return the "real" cmin or cmax if possible, that is
- * if we are inside the originating transaction?
+ * cmin and cmax are now both aliases for the same field, which
+ * can in fact also be a combo command id. XXX perhaps we should
+ * return the "real" cmin or cmax if possible, that is if we are
+ * inside the originating transaction?
*/
result = CommandIdGetDatum(HeapTupleHeaderGetRawCommandId(tup->t_data));
break;
{
HeapTuple tuple; /* return tuple */
HeapTupleHeader td; /* tuple data */
- Size len, data_len;
+ Size len,
+ data_len;
int hoff;
bool hasnull = false;
Form_pg_attribute *att = tupleDescriptor->attrs;
{
HeapTuple tuple; /* return tuple */
HeapTupleHeader td; /* tuple data */
- Size len, data_len;
+ Size len,
+ data_len;
int hoff;
bool hasnull = false;
Form_pg_attribute *att = tupleDescriptor->attrs;
else if (thisatt->attlen == -1)
{
/*
- * We can only cache the offset for a varlena attribute
- * if the offset is already suitably aligned, so that there
- * would be no pad bytes in any case: then the offset will
- * be valid for either an aligned or unaligned value.
+ * We can only cache the offset for a varlena attribute if the
+ * offset is already suitably aligned, so that there would be no
+ * pad bytes in any case: then the offset will be valid for either
+ * an aligned or unaligned value.
*/
if (!slow &&
off == att_align_nominal(off, thisatt->attalign))
else if (thisatt->attlen == -1)
{
/*
- * We can only cache the offset for a varlena attribute
- * if the offset is already suitably aligned, so that there
- * would be no pad bytes in any case: then the offset will
- * be valid for either an aligned or unaligned value.
+ * We can only cache the offset for a varlena attribute if the
+ * offset is already suitably aligned, so that there would be no
+ * pad bytes in any case: then the offset will be valid for either
+ * an aligned or unaligned value.
*/
if (!slow &&
off == att_align_nominal(off, thisatt->attalign))
else if (thisatt->attlen == -1)
{
/*
- * We can only cache the offset for a varlena attribute
- * if the offset is already suitably aligned, so that there
- * would be no pad bytes in any case: then the offset will
- * be valid for either an aligned or unaligned value.
+ * We can only cache the offset for a varlena attribute if the
+ * offset is already suitably aligned, so that there would be no
+ * pad bytes in any case: then the offset will be valid for either
+ * an aligned or unaligned value.
*/
if (!slow &&
off == att_align_nominal(off, thisatt->attalign))
bool *isnull)
{
MinimalTuple tuple; /* return tuple */
- Size len, data_len;
+ Size len,
+ data_len;
int hoff;
bool hasnull = false;
Form_pg_attribute *att = tupleDescriptor->attrs;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.83 2007/11/07 12:24:24 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.84 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
untoasted_values[i] =
PointerGetDatum(heap_tuple_fetch_attr((struct varlena *)
- DatumGetPointer(values[i])));
+ DatumGetPointer(values[i])));
untoasted_free[i] = true;
}
/*
* Otherwise, check for non-fixed-length attrs up to and including
- * target. If there aren't any, it's safe to cheaply initialize
- * the cached offsets for these attrs.
+ * target. If there aren't any, it's safe to cheaply initialize the
+ * cached offsets for these attrs.
*/
if (IndexTupleHasVarwidths(tup))
{
int i;
/*
- * Now we know that we have to walk the tuple CAREFULLY. But we
- * still might be able to cache some offsets for next time.
+ * Now we know that we have to walk the tuple CAREFULLY. But we still
+ * might be able to cache some offsets for next time.
*
* Note - This loop is a little tricky. For each non-null attribute,
* we have to first account for alignment padding before the attr,
* attcacheoff until we reach either a null or a var-width attribute.
*/
off = 0;
- for (i = 0; ; i++) /* loop exit is at "break" */
+ for (i = 0;; i++) /* loop exit is at "break" */
{
if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
{
usecache = false;
- continue; /* this cannot be the target att */
+ continue; /* this cannot be the target att */
}
/* If we know the next offset, we can skip the rest */
else if (att[i]->attlen == -1)
{
/*
- * We can only cache the offset for a varlena attribute
- * if the offset is already suitably aligned, so that there
- * would be no pad bytes in any case: then the offset will
- * be valid for either an aligned or unaligned value.
+ * We can only cache the offset for a varlena attribute if the
+ * offset is already suitably aligned, so that there would be
+ * no pad bytes in any case: then the offset will be valid for
+ * either an aligned or unaligned value.
*/
if (usecache &&
off == att_align_nominal(off, att[i]->attalign))
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.5 2007/06/03 22:16:02 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.6 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (values[j] && validate)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("parameter \"%s\" specified more than once",
- keywords[j])));
+ errmsg("parameter \"%s\" specified more than once",
+ keywords[j])));
value_len = text_len - kw_len - 1;
value = (char *) palloc(value_len + 1);
memcpy(value, text_str + kw_len + 1, value_len);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.10 2007/08/21 01:11:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.11 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
elmlen, elmbyval, elmalign,
&entries, NULL, (int *) nentries);
- if ( *nentries == 0 && PG_NARGS() == 3 )
+ if (*nentries == 0 && PG_NARGS() == 3)
{
- switch( PG_GETARG_UINT16(2) ) /* StrategyNumber */
+ switch (PG_GETARG_UINT16(2)) /* StrategyNumber */
{
case GinOverlapStrategy:
- *nentries = -1; /* nobody can be found */
- break;
+ *nentries = -1; /* nobody can be found */
+ break;
case GinContainsStrategy:
case GinContainedStrategy:
case GinEqualStrategy:
- default: /* require fullscan: GIN can't find void arrays */
+ default: /* require fullscan: GIN can't find void
+ * arrays */
break;
}
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginbtree.c,v 1.9 2007/06/05 12:47:49 teodor Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginbtree.c,v 1.10 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
Page newlpage;
/*
- * newlpage is a pointer to memory page, it doesn't associate
- * with buffer, stack->buffer should be untouched
+ * newlpage is a pointer to memory page, it doesn't associate with
+ * buffer, stack->buffer should be untouched
*/
newlpage = btree->splitPage(btree, stack->buffer, rbuffer, stack->off, &rdata);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.7 2007/06/04 15:56:28 teodor Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.8 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
static XLogRecData rdata[3];
int sizeofitem = GinSizeOfItem(page);
static ginxlogInsert data;
- int cnt=0;
+ int cnt = 0;
*prdata = rdata;
Assert(GinPageIsData(page));
data.isData = TRUE;
data.isLeaf = GinPageIsLeaf(page) ? TRUE : FALSE;
- /*
- * Prevent full page write if child's split occurs. That is needed
- * to remove incomplete splits while replaying WAL
- *
- * data.updateBlkno contains new block number (of newly created right page)
- * for recently splited page.
+ /*
+ * Prevent full page write if child's split occurs. That is needed to
+ * remove incomplete splits while replaying WAL
+ *
+ * data.updateBlkno contains new block number (of newly created right
+ * page) for recently splited page.
*/
- if ( data.updateBlkno == InvalidBlockNumber )
+ if (data.updateBlkno == InvalidBlockNumber)
{
rdata[0].buffer = buf;
rdata[0].buffer_std = FALSE;
rdata[cnt].buffer = InvalidBuffer;
rdata[cnt].data = (char *) &data;
rdata[cnt].len = sizeof(ginxlogInsert);
- rdata[cnt].next = &rdata[cnt+1];
+ rdata[cnt].next = &rdata[cnt + 1];
cnt++;
rdata[cnt].buffer = InvalidBuffer;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.10 2007/10/29 13:49:21 teodor Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.11 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
static XLogRecData rdata[3];
OffsetNumber placed;
static ginxlogInsert data;
- int cnt=0;
+ int cnt = 0;
*prdata = rdata;
data.updateBlkno = entryPreparePage(btree, page, off);
data.isData = false;
data.isLeaf = GinPageIsLeaf(page) ? TRUE : FALSE;
- /*
- * Prevent full page write if child's split occurs. That is needed
- * to remove incomplete splits while replaying WAL
+ /*
+ * Prevent full page write if child's split occurs. That is needed to
+ * remove incomplete splits while replaying WAL
*
- * data.updateBlkno contains new block number (of newly created right page)
- * for recently splited page.
+ * data.updateBlkno contains new block number (of newly created right
+ * page) for recently splited page.
*/
- if ( data.updateBlkno == InvalidBlockNumber )
+ if (data.updateBlkno == InvalidBlockNumber)
{
rdata[0].buffer = buf;
rdata[0].buffer_std = TRUE;
rdata[cnt].buffer = InvalidBuffer;
rdata[cnt].data = (char *) &data;
rdata[cnt].len = sizeof(ginxlogInsert);
- rdata[cnt].next = &rdata[cnt+1];
+ rdata[cnt].next = &rdata[cnt + 1];
cnt++;
rdata[cnt].buffer = InvalidBuffer;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.8 2007/06/04 15:56:28 teodor Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.9 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
OffsetNumber maxoff = GinPageGetOpaque(page)->maxoff;
int res;
- if ( GinPageGetOpaque(page)->flags & GIN_DELETED )
+ if (GinPageGetOpaque(page)->flags & GIN_DELETED)
/* page was deleted by concurrent vacuum */
return false;
- if ( *off > maxoff || *off == InvalidOffsetNumber )
+ if (*off > maxoff || *off == InvalidOffsetNumber)
res = -1;
else
res = compareItemPointers(item, (ItemPointer) GinDataPageGetItem(page, *off));
- if ( res == 0 )
+ if (res == 0)
{
/* page isn't changed */
- return true;
- }
- else if ( res > 0 )
+ return true;
+ }
+ else if (res > 0)
{
- /*
- * some items was added before our position, look further to find
- * it or first greater
+ /*
+ * some items was added before our position, look further to find it
+ * or first greater
*/
-
+
(*off)++;
- for (; *off <= maxoff; (*off)++)
+ for (; *off <= maxoff; (*off)++)
{
res = compareItemPointers(item, (ItemPointer) GinDataPageGetItem(page, *off));
return true;
if (res < 0)
- {
+ {
(*off)--;
return true;
}
}
else
{
- /*
- * some items was deleted before our position, look from begining
- * to find it or first greater
+ /*
+ * some items was deleted before our position, look from begining to
+ * find it or first greater
*/
- for(*off = FirstOffsetNumber; *off<= maxoff; (*off)++)
+ for (*off = FirstOffsetNumber; *off <= maxoff; (*off)++)
{
res = compareItemPointers(item, (ItemPointer) GinDataPageGetItem(page, *off));
- if ( res == 0 )
+ if (res == 0)
return true;
if (res < 0)
- {
+ {
(*off)--;
return true;
}
page = BufferGetPage(entry->buffer);
/* try to find curItem in current buffer */
- if ( findItemInPage(page, &entry->curItem, &entry->offset) )
+ if (findItemInPage(page, &entry->curItem, &entry->offset))
return;
/* walk to right */
page = BufferGetPage(entry->buffer);
entry->offset = InvalidOffsetNumber;
- if ( findItemInPage(page, &entry->curItem, &entry->offset) )
+ if (findItemInPage(page, &entry->curItem, &entry->offset))
return;
}
/*
- * curItem and any greated items was deleted by concurrent vacuum,
- * so we finished scan with currrent entry
+ * curItem and any greated items was deleted by concurrent vacuum, so
+ * we finished scan with currrent entry
*/
}
}
if (GinFuzzySearchLimit > 0)
{
/*
- * If all of keys more than threshold we will try to reduce result,
- * we hope (and only hope, for intersection operation of array our
- * supposition isn't true), that total result will not more than
- * minimal predictNumberResult.
+ * If all of keys more than threshold we will try to reduce
+ * result, we hope (and only hope, for intersection operation of
+ * array our supposition isn't true), that total result will not
+ * more than minimal predictNumberResult.
*/
for (i = 0; i < key->nentries; i++)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.10 2007/05/27 03:50:38 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.11 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
UInt16GetDatum(scankey[i].sk_strategy)
)
);
- if ( nEntryValues < 0 )
+ if (nEntryValues < 0)
{
/*
- * extractQueryFn signals that nothing will be found,
- * so we can just set isVoidRes flag...
+ * extractQueryFn signals that nothing will be found, so we can
+ * just set isVoidRes flag...
*/
- so->isVoidRes = true;
+ so->isVoidRes = true;
break;
}
if (entryValues == NULL || nEntryValues == 0)
if (so->nkeys == 0 && !so->isVoidRes)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("GIN index does not support search with void query")));
+ errmsg("GIN index does not support search with void query")));
pgstat_count_index_scan(scan->indexRelation);
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.10 2007/01/31 15:09:45 teodor Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.11 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
&ginstate->compareFn,
a, b
)
- );
+ );
}
typedef struct
{
FmgrInfo *cmpDatumFunc;
bool *needUnique;
-} cmpEntriesData;
+} cmpEntriesData;
static int
-cmpEntries(const Datum *a, const Datum *b, cmpEntriesData *arg)
+cmpEntries(const Datum *a, const Datum *b, cmpEntriesData * arg)
{
int res = DatumGetInt32(FunctionCall2(arg->cmpDatumFunc,
*a, *b));
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.17 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.18 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
IndexBulkDeleteCallback callback;
void *callback_state;
GinState ginstate;
- BufferAccessStrategy strategy;
+ BufferAccessStrategy strategy;
} GinVacuumState;
/*
* We should be sure that we don't concurrent with inserts, insert process
* never release root page until end (but it can unlock it and lock
- * again). New scan can't start but previously started
- * ones work concurrently.
+ * again). New scan can't start but previously started ones work
+ * concurrently.
*/
- if ( isRoot )
+ if (isRoot)
LockBufferForCleanup(buffer);
else
- LockBuffer(buffer, GIN_EXCLUSIVE);
+ LockBuffer(buffer, GIN_EXCLUSIVE);
Assert(GinPageIsData(page));
BlockNumber parentBlkno, OffsetNumber myoff, bool isParentRoot)
{
Buffer dBuffer = ReadBufferWithStrategy(gvs->index, deleteBlkno, gvs->strategy);
- Buffer lBuffer = (leftBlkno == InvalidBlockNumber) ?
- InvalidBuffer : ReadBufferWithStrategy(gvs->index, leftBlkno, gvs->strategy);
+ Buffer lBuffer = (leftBlkno == InvalidBlockNumber) ?
+ InvalidBuffer : ReadBufferWithStrategy(gvs->index, leftBlkno, gvs->strategy);
Buffer pBuffer = ReadBufferWithStrategy(gvs->index, parentBlkno, gvs->strategy);
Page page,
parentPage;
parentPage = BufferGetPage(pBuffer);
#ifdef USE_ASSERT_CHECKING
- do {
- PostingItem *tod=(PostingItem *) GinDataPageGetItem(parentPage, myoff);
- Assert( PostingItemGetBlockNumber(tod) == deleteBlkno );
- } while(0);
+ do
+ {
+ PostingItem *tod = (PostingItem *) GinDataPageGetItem(parentPage, myoff);
+
+ Assert(PostingItemGetBlockNumber(tod) == deleteBlkno);
+ } while (0);
#endif
PageDeletePostingItem(parentPage, myoff);
page = BufferGetPage(dBuffer);
+
/*
- * we shouldn't change rightlink field to save
- * workability of running search scan
+ * we shouldn't change rightlink field to save workability of running
+ * search scan
*/
GinPageGetOpaque(page)->flags = GIN_DELETED;
struct DataPageDeleteStack *child;
struct DataPageDeleteStack *parent;
- BlockNumber blkno; /* current block number */
- BlockNumber leftBlkno; /* rightest non-deleted page on left */
+ BlockNumber blkno; /* current block number */
+ BlockNumber leftBlkno; /* rightest non-deleted page on left */
bool isRoot;
} DataPageDeleteStack;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.10 2007/10/29 19:26:57 teodor Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.11 2007/11/15 21:14:31 momjian Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
Assert(data->isDelete == FALSE);
Assert(GinPageIsData(page));
- if ( ! XLByteLE(lsn, PageGetLSN(page)) )
+ if (!XLByteLE(lsn, PageGetLSN(page)))
{
if (data->isLeaf)
{
if (!data->isLeaf && data->updateBlkno != InvalidBlockNumber)
{
PostingItem *pitem = (PostingItem *) (XLogRecGetData(record) + sizeof(ginxlogInsert));
+
forgetIncompleteSplit(data->node, PostingItemGetBlockNumber(pitem), data->updateBlkno);
}
Assert(!GinPageIsData(page));
- if ( ! XLByteLE(lsn, PageGetLSN(page)) )
+ if (!XLByteLE(lsn, PageGetLSN(page)))
{
if (data->updateBlkno != InvalidBlockNumber)
{
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), data->offset, false, false) == InvalidOffsetNumber)
elog(ERROR, "failed to add item to index page in %u/%u/%u",
- data->node.spcNode, data->node.dbNode, data->node.relNode);
+ data->node.spcNode, data->node.dbNode, data->node.relNode);
}
if (!data->isLeaf && data->updateBlkno != InvalidBlockNumber)
}
}
- if ( ! XLByteLE(lsn, PageGetLSN(page)) )
+ if (!XLByteLE(lsn, PageGetLSN(page)))
{
PageSetLSN(page, lsn);
PageSetTLI(page, ThisTimeLineID);
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.147 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.148 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ptr->block.blkno = BufferGetBlockNumber(ptr->buffer);
/*
- * fill page, we can do it because all these pages are new
- * (ie not linked in tree or masked by temp page
+ * fill page, we can do it because all these pages are new (ie not
+ * linked in tree or masked by temp page
*/
data = (char *) (ptr->list);
for (i = 0; i < ptr->block.num; i++)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.67 2007/09/12 22:10:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.68 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* On non-leaf page we can't conclude that child hasn't NULL
* values because of assumption in GiST: uinon (VAL, NULL) is VAL
- * But if on non-leaf page key IS NULL then all childs
- * has NULL.
+ * But if on non-leaf page key IS NULL then all childs has NULL.
*/
- Assert( key->sk_flags & SK_SEARCHNULL );
+ Assert(key->sk_flags & SK_SEARCHNULL);
- if ( GistPageIsLeaf(p) && !isNull )
+ if (GistPageIsLeaf(p) && !isNull)
return false;
}
else if (isNull)
FALSE, isNull);
/*
- * Call the Consistent function to evaluate the test. The arguments
- * are the index datum (as a GISTENTRY*), the comparison datum, and
- * the comparison operator's strategy number and subtype from pg_amop.
+ * Call the Consistent function to evaluate the test. The
+ * arguments are the index datum (as a GISTENTRY*), the comparison
+ * datum, and the comparison operator's strategy number and
+ * subtype from pg_amop.
*
- * (Presently there's no need to pass the subtype since it'll always
- * be zero, but might as well pass it for possible future use.)
+ * (Presently there's no need to pass the subtype since it'll
+ * always be zero, but might as well pass it for possible future
+ * use.)
*/
test = FunctionCall4(&key->sk_func,
PointerGetDatum(&de),
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.11 2007/09/07 17:04:26 teodor Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.12 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ADDLIST(listT, unionT, posT, i);
}
-#define LIMIT_RATIO 0.1
+#define LIMIT_RATIO 0.1
#define _IS_BADRATIO(x,y) ( (y) == 0 || (float)(x)/(float)(y) < LIMIT_RATIO )
#define IS_BADRATIO(x,y) ( _IS_BADRATIO((x),(y)) || _IS_BADRATIO((y),(x)) )
/* bad disposition, try to split by centers of boxes */
- if ( IS_BADRATIO(posR, posL) && IS_BADRATIO(posT, posB) )
+ if (IS_BADRATIO(posR, posL) && IS_BADRATIO(posT, posB))
{
- double avgCenterX=0.0, avgCenterY=0.0;
- double CenterX, CenterY;
+ double avgCenterX = 0.0,
+ avgCenterY = 0.0;
+ double CenterX,
+ CenterY;
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
{
cur = DatumGetBoxP(entryvec->vector[i].key);
- avgCenterX += ((double)cur->high.x + (double)cur->low.x)/2.0;
- avgCenterY += ((double)cur->high.y + (double)cur->low.y)/2.0;
+ avgCenterX += ((double) cur->high.x + (double) cur->low.x) / 2.0;
+ avgCenterY += ((double) cur->high.y + (double) cur->low.y) / 2.0;
}
avgCenterX /= maxoff;
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
{
cur = DatumGetBoxP(entryvec->vector[i].key);
-
- CenterX = ((double)cur->high.x + (double)cur->low.x)/2.0;
- CenterY = ((double)cur->high.y + (double)cur->low.y)/2.0;
- if (CenterX < avgCenterX)
+ CenterX = ((double) cur->high.x + (double) cur->low.x) / 2.0;
+ CenterY = ((double) cur->high.y + (double) cur->low.y) / 2.0;
+
+ if (CenterX < avgCenterX)
ADDLIST(listL, unionL, posL, i);
else if (CenterX == avgCenterX)
{
else
ADDLIST(listB, unionB, posB, i);
}
- else
+ else
ADDLIST(listT, unionT, posT, i);
}
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.32 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.33 2007/11/15 21:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Relation index;
MemoryContext opCtx;
GistBulkDeleteResult *result;
- BufferAccessStrategy strategy;
+ BufferAccessStrategy strategy;
} GistVacuum;
typedef struct
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.96 2007/09/12 22:10:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.97 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* This file contains only the public interface routines.
vacuum_delay_point();
buf = _hash_getbuf_with_strategy(rel, blkno, HASH_WRITE,
- LH_BUCKET_PAGE | LH_OVERFLOW_PAGE,
+ LH_BUCKET_PAGE | LH_OVERFLOW_PAGE,
info->strategy);
page = BufferGetPage(buf);
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.53 2007/09/21 22:52:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.54 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
* To support cross-type hashing of float8 and float4, we want to return
* the same hash value hashfloat8 would produce for an equal float8 value.
* So, widen the value to float8 and hash that. (We must do this rather
- * than have hashfloat8 try to narrow its value to float4; that could
- * fail on overflow.)
+ * than have hashfloat8 try to narrow its value to float4; that could fail
+ * on overflow.)
*/
key8 = key;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.60 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.61 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* Overflow pages look like ordinary relation pages.
/*
* _hash_getovflpage()
*
- * Find an available overflow page and return it. The returned buffer
+ * Find an available overflow page and return it. The returned buffer
* is pinned and write-locked, and has had _hash_pageinit() applied,
* but it is caller's responsibility to fill the special space.
*
bucket = ovflopaque->hasho_bucket;
/*
- * Zero the page for debugging's sake; then write and release it.
- * (Note: if we failed to zero the page here, we'd have problems
- * with the Assert in _hash_pageinit() when the page is reused.)
+ * Zero the page for debugging's sake; then write and release it. (Note:
+ * if we failed to zero the page here, we'd have problems with the Assert
+ * in _hash_pageinit() when the page is reused.)
*/
MemSet(ovflpage, 0, BufferGetPageSize(ovflbuf));
_hash_wrtbuf(rel, ovflbuf);
Buffer prevbuf = _hash_getbuf_with_strategy(rel,
prevblkno,
HASH_WRITE,
- LH_BUCKET_PAGE | LH_OVERFLOW_PAGE,
+ LH_BUCKET_PAGE | LH_OVERFLOW_PAGE,
bstrategy);
Page prevpage = BufferGetPage(prevbuf);
HashPageOpaque prevopaque = (HashPageOpaque) PageGetSpecialPointer(prevpage);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.70 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.71 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* Postgres hash pages look like ordinary relation pages. The opaque
static bool _hash_alloc_buckets(Relation rel, BlockNumber firstblock,
- uint32 nblocks);
+ uint32 nblocks);
static void _hash_splitbucket(Relation rel, Buffer metabuf,
Bucket obucket, Bucket nbucket,
BlockNumber start_oblkno,
*
* This must be used only to fetch pages that are known to be before
* the index's filesystem EOF, but are to be filled from scratch.
- * _hash_pageinit() is applied automatically. Otherwise it has
+ * _hash_pageinit() is applied automatically. Otherwise it has
* effects similar to _hash_getbuf() with access = HASH_WRITE.
*
* When this routine returns, a write lock is set on the
Buffer
_hash_getnewbuf(Relation rel, BlockNumber blkno)
{
- BlockNumber nblocks = RelationGetNumberOfBlocks(rel);
+ BlockNumber nblocks = RelationGetNumberOfBlocks(rel);
Buffer buf;
if (blkno == P_NEW)
ffactor = 10;
/*
- * We initialize the metapage, the first two bucket pages, and the
- * first bitmap page in sequence, using _hash_getnewbuf to cause
- * smgrextend() calls to occur. This ensures that the smgr level
- * has the right idea of the physical index length.
+ * We initialize the metapage, the first two bucket pages, and the first
+ * bitmap page in sequence, using _hash_getnewbuf to cause smgrextend()
+ * calls to occur. This ensures that the smgr level has the right idea of
+ * the physical index length.
*/
metabuf = _hash_getnewbuf(rel, HASH_METAPAGE);
pg = BufferGetPage(metabuf);
goto fail;
/*
- * Can't split anymore if maxbucket has reached its maximum possible value.
+ * Can't split anymore if maxbucket has reached its maximum possible
+ * value.
*
* Ideally we'd allow bucket numbers up to UINT_MAX-1 (no higher because
* the calculation maxbucket+1 mustn't overflow). Currently we restrict
* to half that because of overflow looping in _hash_log2() and
* insufficient space in hashm_spares[]. It's moot anyway because an
- * index with 2^32 buckets would certainly overflow BlockNumber and
- * hence _hash_alloc_buckets() would fail, but if we supported buckets
- * smaller than a disk block then this would be an independent constraint.
+ * index with 2^32 buckets would certainly overflow BlockNumber and hence
+ * _hash_alloc_buckets() would fail, but if we supported buckets smaller
+ * than a disk block then this would be an independent constraint.
*/
if (metap->hashm_maxbucket >= (uint32) 0x7FFFFFFE)
goto fail;
/*
* Likewise lock the new bucket (should never fail).
*
- * Note: it is safe to compute the new bucket's blkno here, even though
- * we may still need to update the BUCKET_TO_BLKNO mapping. This is
- * because the current value of hashm_spares[hashm_ovflpoint] correctly
- * shows where we are going to put a new splitpoint's worth of buckets.
+ * Note: it is safe to compute the new bucket's blkno here, even though we
+ * may still need to update the BUCKET_TO_BLKNO mapping. This is because
+ * the current value of hashm_spares[hashm_ovflpoint] correctly shows
+ * where we are going to put a new splitpoint's worth of buckets.
*/
start_nblkno = BUCKET_TO_BLKNO(metap, new_bucket);
if (spare_ndx > metap->hashm_ovflpoint)
{
Assert(spare_ndx == metap->hashm_ovflpoint + 1);
+
/*
- * The number of buckets in the new splitpoint is equal to the
- * total number already in existence, i.e. new_bucket. Currently
- * this maps one-to-one to blocks required, but someday we may need
- * a more complicated calculation here.
+ * The number of buckets in the new splitpoint is equal to the total
+ * number already in existence, i.e. new_bucket. Currently this maps
+ * one-to-one to blocks required, but someday we may need a more
+ * complicated calculation here.
*/
if (!_hash_alloc_buckets(rel, start_nblkno, new_bucket))
{
static bool
_hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
{
- BlockNumber lastblock;
+ BlockNumber lastblock;
char zerobuf[BLCKSZ];
lastblock = firstblock + nblocks - 1;
/*
- * Check for overflow in block number calculation; if so, we cannot
- * extend the index anymore.
+ * Check for overflow in block number calculation; if so, we cannot extend
+ * the index anymore.
*/
if (lastblock < firstblock || lastblock == InvalidBlockNumber)
return false;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.244 2007/11/07 12:24:24 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.245 2007/11/15 21:14:32 momjian Exp $
*
*
* INTERFACE ROUTINES
static HeapScanDesc heap_beginscan_internal(Relation relation,
- Snapshot snapshot,
- int nkeys, ScanKey key,
- bool is_bitmapscan);
+ Snapshot snapshot,
+ int nkeys, ScanKey key,
+ bool is_bitmapscan);
static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf,
ItemPointerData from, Buffer newbuf, HeapTuple newtup, bool move);
static bool HeapSatisfiesHOTUpdate(Relation relation, Bitmapset *hot_attrs,
* Determine the number of blocks we have to scan.
*
* It is sufficient to do this once at scan start, since any tuples added
- * while the scan is in progress will be invisible to my snapshot
- * anyway. (That is not true when using a non-MVCC snapshot. However,
- * we couldn't guarantee to return tuples added after scan start anyway,
- * since they might go into pages we already scanned. To guarantee
- * consistent results for a non-MVCC snapshot, the caller must hold some
- * higher-level lock that ensures the interesting tuple(s) won't change.)
+ * while the scan is in progress will be invisible to my snapshot anyway.
+ * (That is not true when using a non-MVCC snapshot. However, we couldn't
+ * guarantee to return tuples added after scan start anyway, since they
+ * might go into pages we already scanned. To guarantee consistent
+ * results for a non-MVCC snapshot, the caller must hold some higher-level
+ * lock that ensures the interesting tuple(s) won't change.)
*/
scan->rs_nblocks = RelationGetNumberOfBlocks(scan->rs_rd);
/*
* If the table is large relative to NBuffers, use a bulk-read access
- * strategy and enable synchronized scanning (see syncscan.c). Although
+ * strategy and enable synchronized scanning (see syncscan.c). Although
* the thresholds for these features could be different, we make them the
* same so that there are only two behaviors to tune rather than four.
*
memcpy(scan->rs_key, key, scan->rs_nkeys * sizeof(ScanKeyData));
/*
- * Currently, we don't have a stats counter for bitmap heap scans
- * (but the underlying bitmap index scans will be counted).
+ * Currently, we don't have a stats counter for bitmap heap scans (but the
+ * underlying bitmap index scans will be counted).
*/
if (!scan->rs_bitmapscan)
pgstat_count_heap_scan(scan->rs_rd);
tuple->t_data = NULL;
return;
}
- page = scan->rs_startblock; /* first page */
+ page = scan->rs_startblock; /* first page */
heapgetpage(scan, page);
lineoff = FirstOffsetNumber; /* first offnum */
scan->rs_inited = true;
tuple->t_data = NULL;
return;
}
+
/*
* Disable reporting to syncscan logic in a backwards scan; it's
* not very likely anyone else is doing the same thing at the same
finished = (page == scan->rs_startblock);
/*
- * Report our new scan position for synchronization purposes.
- * We don't do that when moving backwards, however. That would
- * just mess up any other forward-moving scanners.
+ * Report our new scan position for synchronization purposes. We
+ * don't do that when moving backwards, however. That would just
+ * mess up any other forward-moving scanners.
*
* Note: we do this before checking for end of scan so that the
* final state of the position hint is back at the start of the
tuple->t_data = NULL;
return;
}
- page = scan->rs_startblock; /* first page */
+ page = scan->rs_startblock; /* first page */
heapgetpage(scan, page);
lineindex = 0;
scan->rs_inited = true;
tuple->t_data = NULL;
return;
}
+
/*
* Disable reporting to syncscan logic in a backwards scan; it's
* not very likely anyone else is doing the same thing at the same
finished = (page == scan->rs_startblock);
/*
- * Report our new scan position for synchronization purposes.
- * We don't do that when moving backwards, however. That would
- * just mess up any other forward-moving scanners.
+ * Report our new scan position for synchronization purposes. We
+ * don't do that when moving backwards, however. That would just
+ * mess up any other forward-moving scanners.
*
* Note: we do this before checking for end of scan so that the
* final state of the position hint is back at the start of the
* heap_beginscan - begin relation scan
*
* heap_beginscan_bm is an alternative entry point for setting up a HeapScanDesc
- * for a bitmap heap scan. Although that scan technology is really quite
+ * for a bitmap heap scan. Although that scan technology is really quite
* unlike a standard seqscan, there is just enough commonality to make it
* worth using the same data structure.
* ----------------
heap_hot_search_buffer(ItemPointer tid, Buffer buffer, Snapshot snapshot,
bool *all_dead)
{
- Page dp = (Page) BufferGetPage(buffer);
+ Page dp = (Page) BufferGetPage(buffer);
TransactionId prev_xmax = InvalidTransactionId;
OffsetNumber offnum;
- bool at_chain_start;
+ bool at_chain_start;
if (all_dead)
*all_dead = true;
/* Scan through possible multiple members of HOT-chain */
for (;;)
{
- ItemId lp;
+ ItemId lp;
HeapTupleData heapTuple;
/* check for bogus TID */
break;
/*
- * The xmin should match the previous xmax value, else chain is broken.
+ * The xmin should match the previous xmax value, else chain is
+ * broken.
*/
if (TransactionIdIsValid(prev_xmax) &&
!TransactionIdEquals(prev_xmax,
*all_dead = false;
/*
- * Check to see if HOT chain continues past this tuple; if so
- * fetch the next offnum and loop around.
+ * Check to see if HOT chain continues past this tuple; if so fetch
+ * the next offnum and loop around.
*/
if (HeapTupleIsHotUpdated(&heapTuple))
{
prev_xmax = HeapTupleHeaderGetXmax(heapTuple.t_data);
}
else
- break; /* end of chain */
+ break; /* end of chain */
}
return false;
heap_hot_search(ItemPointer tid, Relation relation, Snapshot snapshot,
bool *all_dead)
{
- bool result;
- Buffer buffer;
+ bool result;
+ Buffer buffer;
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
LockBuffer(buffer, BUFFER_LOCK_SHARE);
*
* This is called after we have waited for the XMAX transaction to terminate.
* If the transaction aborted, we guarantee the XMAX_INVALID hint bit will
- * be set on exit. If the transaction committed, we set the XMAX_COMMITTED
+ * be set on exit. If the transaction committed, we set the XMAX_COMMITTED
* hint bit if possible --- but beware that that may not yet be possible,
* if the transaction committed asynchronously. Hence callers should look
* only at XMAX_INVALID.
/*
* If this transaction commits, the tuple will become DEAD sooner or
* later. Set flag that this page is a candidate for pruning once our xid
- * falls below the OldestXmin horizon. If the transaction finally aborts,
+ * falls below the OldestXmin horizon. If the transaction finally aborts,
* the subsequent page pruning will be a no-op and the hint will be
* cleared.
*/
/*
* Fetch the list of attributes to be checked for HOT update. This is
- * wasted effort if we fail to update or have to put the new tuple on
- * a different page. But we must compute the list before obtaining
- * buffer lock --- in the worst case, if we are doing an update on one
- * of the relevant system catalogs, we could deadlock if we try to
- * fetch the list later. In any case, the relcache caches the data
- * so this is usually pretty cheap.
+ * wasted effort if we fail to update or have to put the new tuple on a
+ * different page. But we must compute the list before obtaining buffer
+ * lock --- in the worst case, if we are doing an update on one of the
+ * relevant system catalogs, we could deadlock if we try to fetch the list
+ * later. In any case, the relcache caches the data so this is usually
+ * pretty cheap.
*
- * Note that we get a copy here, so we need not worry about relcache
- * flush happening midway through.
+ * Note that we get a copy here, so we need not worry about relcache flush
+ * happening midway through.
*/
hot_attrs = RelationGetIndexAttrBitmap(relation);
{
/*
* Since the new tuple is going into the same page, we might be able
- * to do a HOT update. Check if any of the index columns have been
+ * to do a HOT update. Check if any of the index columns have been
* changed. If not, then HOT update is possible.
*/
if (HeapSatisfiesHOTUpdate(relation, hot_attrs, &oldtup, heaptup))
/*
* If this transaction commits, the old tuple will become DEAD sooner or
* later. Set flag that this page is a candidate for pruning once our xid
- * falls below the OldestXmin horizon. If the transaction finally aborts,
+ * falls below the OldestXmin horizon. If the transaction finally aborts,
* the subsequent page pruning will be a no-op and the hint will be
* cleared.
*
- * XXX Should we set hint on newbuf as well? If the transaction
- * aborts, there would be a prunable tuple in the newbuf; but for now
- * we choose not to optimize for aborts. Note that heap_xlog_update
- * must be kept in sync if this decision changes.
+ * XXX Should we set hint on newbuf as well? If the transaction aborts,
+ * there would be a prunable tuple in the newbuf; but for now we choose
+ * not to optimize for aborts. Note that heap_xlog_update must be kept in
+ * sync if this decision changes.
*/
PageSetPrunable(dp, xid);
heap_tuple_attr_equals(TupleDesc tupdesc, int attrnum,
HeapTuple tup1, HeapTuple tup2)
{
- Datum value1, value2;
- bool isnull1, isnull2;
+ Datum value1,
+ value2;
+ bool isnull1,
+ isnull2;
Form_pg_attribute att;
/*
* If it's a whole-tuple reference, say "not equal". It's not really
- * worth supporting this case, since it could only succeed after a
- * no-op update, which is hardly a case worth optimizing for.
+ * worth supporting this case, since it could only succeed after a no-op
+ * update, which is hardly a case worth optimizing for.
*/
if (attrnum == 0)
return false;
/*
- * Likewise, automatically say "not equal" for any system attribute
- * other than OID and tableOID; we cannot expect these to be consistent
- * in a HOT chain, or even to be set correctly yet in the new tuple.
+ * Likewise, automatically say "not equal" for any system attribute other
+ * than OID and tableOID; we cannot expect these to be consistent in a HOT
+ * chain, or even to be set correctly yet in the new tuple.
*/
if (attrnum < 0)
{
}
/*
- * Extract the corresponding values. XXX this is pretty inefficient
- * if there are many indexed columns. Should HeapSatisfiesHOTUpdate
- * do a single heap_deform_tuple call on each tuple, instead? But
- * that doesn't work for system columns ...
+ * Extract the corresponding values. XXX this is pretty inefficient if
+ * there are many indexed columns. Should HeapSatisfiesHOTUpdate do a
+ * single heap_deform_tuple call on each tuple, instead? But that doesn't
+ * work for system columns ...
*/
value1 = heap_getattr(tup1, attrnum, tupdesc, &isnull1);
value2 = heap_getattr(tup2, attrnum, tupdesc, &isnull2);
/*
- * If one value is NULL and other is not, then they are certainly
- * not equal
+ * If one value is NULL and other is not, then they are certainly not
+ * equal
*/
if (isnull1 != isnull2)
return false;
/*
* We do simple binary comparison of the two datums. This may be overly
* strict because there can be multiple binary representations for the
- * same logical value. But we should be OK as long as there are no false
+ * same logical value. But we should be OK as long as there are no false
* positives. Using a type-specific equality operator is messy because
* there could be multiple notions of equality in different operator
* classes; furthermore, we cannot safely invoke user-defined functions
else
{
Assert(attrnum <= tupdesc->natts);
- att = tupdesc->attrs[attrnum - 1];
+ att = tupdesc->attrs[attrnum - 1];
return datumIsEqual(value1, value2, att->attbyval, att->attlen);
}
}
HeapSatisfiesHOTUpdate(Relation relation, Bitmapset *hot_attrs,
HeapTuple oldtup, HeapTuple newtup)
{
- int attrnum;
+ int attrnum;
while ((attrnum = bms_first_member(hot_attrs)) >= 0)
{
}
/*
- * We might already hold the desired lock (or stronger), possibly under
- * a different subtransaction of the current top transaction. If so,
- * there is no need to change state or issue a WAL record. We already
- * handled the case where this is true for xmax being a MultiXactId,
- * so now check for cases where it is a plain TransactionId.
+ * We might already hold the desired lock (or stronger), possibly under a
+ * different subtransaction of the current top transaction. If so, there
+ * is no need to change state or issue a WAL record. We already handled
+ * the case where this is true for xmax being a MultiXactId, so now check
+ * for cases where it is a plain TransactionId.
*
* Note in particular that this covers the case where we already hold
- * exclusive lock on the tuple and the caller only wants shared lock.
- * It would certainly not do to give up the exclusive lock.
+ * exclusive lock on the tuple and the caller only wants shared lock. It
+ * would certainly not do to give up the exclusive lock.
*/
xmax = HeapTupleHeaderGetXmax(tuple->t_data);
old_infomask = tuple->t_data->t_infomask;
{
/*
* If the XMAX is a valid TransactionId, then we need to
- * create a new MultiXactId that includes both the old
- * locker and our own TransactionId.
+ * create a new MultiXactId that includes both the old locker
+ * and our own TransactionId.
*/
xid = MultiXactIdCreate(xmax, xid);
new_infomask |= HEAP_XMAX_IS_MULTI;
/*
* Store transaction information of xact locking the tuple.
*
- * Note: Cmax is meaningless in this context, so don't set it; this
- * avoids possibly generating a useless combo CID.
+ * Note: Cmax is meaningless in this context, so don't set it; this avoids
+ * possibly generating a useless combo CID.
*/
tuple->t_data->t_infomask = new_infomask;
HeapTupleHeaderClearHotUpdated(tuple->t_data);
buf = InvalidBuffer;
}
HeapTupleHeaderSetXmin(tuple, FrozenTransactionId);
+
/*
* Might as well fix the hint bits too; usually XMIN_COMMITTED will
* already be set here, but there's a small chance not.
/*
* When we release shared lock, it's possible for someone else to change
* xmax before we get the lock back, so repeat the check after acquiring
- * exclusive lock. (We don't need this pushup for xmin, because only
- * VACUUM could be interested in changing an existing tuple's xmin,
- * and there's only one VACUUM allowed on a table at a time.)
+ * exclusive lock. (We don't need this pushup for xmin, because only
+ * VACUUM could be interested in changing an existing tuple's xmin, and
+ * there's only one VACUUM allowed on a table at a time.)
*/
recheck_xmax:
if (!(tuple->t_infomask & HEAP_XMAX_IS_MULTI))
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
buf = InvalidBuffer;
- goto recheck_xmax; /* see comment above */
+ goto recheck_xmax; /* see comment above */
}
HeapTupleHeaderSetXmax(tuple, InvalidTransactionId);
+
/*
- * The tuple might be marked either XMAX_INVALID or
- * XMAX_COMMITTED + LOCKED. Normalize to INVALID just to be
- * sure no one gets confused.
+ * The tuple might be marked either XMAX_INVALID or XMAX_COMMITTED
+ * + LOCKED. Normalize to INVALID just to be sure no one gets
+ * confused.
*/
tuple->t_infomask &= ~HEAP_XMAX_COMMITTED;
tuple->t_infomask |= HEAP_XMAX_INVALID;
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
buf = InvalidBuffer;
- goto recheck_xvac; /* see comment above */
+ goto recheck_xvac; /* see comment above */
}
+
/*
* If a MOVED_OFF tuple is not dead, the xvac transaction must
* have failed; whereas a non-dead MOVED_IN tuple must mean the
HeapTupleHeaderSetXvac(tuple, InvalidTransactionId);
else
HeapTupleHeaderSetXvac(tuple, FrozenTransactionId);
+
/*
- * Might as well fix the hint bits too; usually XMIN_COMMITTED will
- * already be set here, but there's a small chance not.
+ * Might as well fix the hint bits too; usually XMIN_COMMITTED
+ * will already be set here, but there's a small chance not.
*/
Assert(!(tuple->t_infomask & HEAP_XMIN_INVALID));
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
/*
* The OffsetNumber arrays are not actually in the buffer, but we pretend
* that they are. When XLogInsert stores the whole buffer, the offset
- * arrays need not be stored too. Note that even if all three arrays
- * are empty, we want to expose the buffer as a candidate for whole-page
+ * arrays need not be stored too. Note that even if all three arrays are
+ * empty, we want to expose the buffer as a candidate for whole-page
* storage, since this record type implies a defragmentation operation
* even if no item pointers changed state.
*/
}
/*
- * Perform XLogInsert for a heap-freeze operation. Caller must already
+ * Perform XLogInsert for a heap-freeze operation. Caller must already
* have modified the buffer and marked it dirty.
*/
XLogRecPtr
rdata[0].next = &(rdata[1]);
/*
- * The tuple-offsets array is not actually in the buffer, but pretend
- * that it is. When XLogInsert stores the whole buffer, the offsets array
- * need not be stored too.
+ * The tuple-offsets array is not actually in the buffer, but pretend that
+ * it is. When XLogInsert stores the whole buffer, the offsets array need
+ * not be stored too.
*/
if (offcnt > 0)
{
* for writing the page to disk after calling this routine.
*
* Note: all current callers build pages in private memory and write them
- * directly to smgr, rather than using bufmgr. Therefore there is no need
+ * directly to smgr, rather than using bufmgr. Therefore there is no need
* to pass a buffer ID to XLogInsert, nor to perform MarkBufferDirty within
* the critical section.
*
Page page;
OffsetNumber *offnum;
OffsetNumber *end;
- int nredirected;
- int ndead;
- int i;
+ int nredirected;
+ int ndead;
+ int i;
if (record->xl_info & XLR_BKP_BLOCK_1)
return;
{
OffsetNumber fromoff = *offnum++;
OffsetNumber tooff = *offnum++;
- ItemId fromlp = PageGetItemId(page, fromoff);
+ ItemId fromlp = PageGetItemId(page, fromoff);
if (clean_move)
{
/* Physically move the "to" item to the "from" slot */
- ItemId tolp = PageGetItemId(page, tooff);
+ ItemId tolp = PageGetItemId(page, tooff);
HeapTupleHeader htup;
*fromlp = *tolp;
for (i = 0; i < ndead; i++)
{
OffsetNumber off = *offnum++;
- ItemId lp = PageGetItemId(page, off);
+ ItemId lp = PageGetItemId(page, off);
ItemIdSetDead(lp);
}
while (offnum < end)
{
OffsetNumber off = *offnum++;
- ItemId lp = PageGetItemId(page, off);
+ ItemId lp = PageGetItemId(page, off);
ItemIdSetUnused(lp);
}
/*
- * Finally, repair any fragmentation, and update the page's hint bit
- * about whether it has free pointers.
+ * Finally, repair any fragmentation, and update the page's hint bit about
+ * whether it has free pointers.
*/
PageRepairFragmentation(page);
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- if (xl_info & XLOG_HEAP_INIT_PAGE) /* can this case happen? */
+ if (xl_info & XLOG_HEAP_INIT_PAGE) /* can this case happen? */
appendStringInfo(buf, "hot_update(init): ");
else
appendStringInfo(buf, "hot_update: ");
/* toast heap, if any */
if (OidIsValid(rel->rd_rel->reltoastrelid))
{
- Relation toastrel;
+ Relation toastrel;
toastrel = heap_open(rel->rd_rel->reltoastrelid, AccessShareLock);
FlushRelationBuffers(toastrel);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.3 2007/10/24 13:05:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.4 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Local functions */
-static int heap_prune_chain(Relation relation, Buffer buffer,
- OffsetNumber rootoffnum,
- TransactionId OldestXmin,
- OffsetNumber *redirected, int *nredirected,
- OffsetNumber *nowdead, int *ndead,
- OffsetNumber *nowunused, int *nunused,
- bool redirect_move);
+static int heap_prune_chain(Relation relation, Buffer buffer,
+ OffsetNumber rootoffnum,
+ TransactionId OldestXmin,
+ OffsetNumber *redirected, int *nredirected,
+ OffsetNumber *nowdead, int *ndead,
+ OffsetNumber *nowunused, int *nunused,
+ bool redirect_move);
static void heap_prune_record_redirect(OffsetNumber *redirected,
- int *nredirected,
- OffsetNumber offnum,
- OffsetNumber rdoffnum);
+ int *nredirected,
+ OffsetNumber offnum,
+ OffsetNumber rdoffnum);
static void heap_prune_record_dead(OffsetNumber *nowdead, int *ndead,
- OffsetNumber offnum);
+ OffsetNumber offnum);
static void heap_prune_record_unused(OffsetNumber *nowunused, int *nunused,
- OffsetNumber offnum);
+ OffsetNumber offnum);
/*
return;
/*
- * We prune when a previous UPDATE failed to find enough space on the
- * page for a new tuple version, or when free space falls below the
- * relation's fill-factor target (but not less than 10%).
+ * We prune when a previous UPDATE failed to find enough space on the page
+ * for a new tuple version, or when free space falls below the relation's
+ * fill-factor target (but not less than 10%).
*
- * Checking free space here is questionable since we aren't holding
- * any lock on the buffer; in the worst case we could get a bogus
- * answer. It's unlikely to be *seriously* wrong, though, since
- * reading either pd_lower or pd_upper is probably atomic. Avoiding
- * taking a lock seems better than sometimes getting a wrong answer
- * in what is after all just a heuristic estimate.
+ * Checking free space here is questionable since we aren't holding any
+ * lock on the buffer; in the worst case we could get a bogus answer.
+ * It's unlikely to be *seriously* wrong, though, since reading either
+ * pd_lower or pd_upper is probably atomic. Avoiding taking a lock seems
+ * better than sometimes getting a wrong answer in what is after all just
+ * a heuristic estimate.
*/
minfree = RelationGetTargetPageFreeSpace(relation,
HEAP_DEFAULT_FILLFACTOR);
/*
* Now that we have buffer lock, get accurate information about the
- * page's free space, and recheck the heuristic about whether to prune.
- * (We needn't recheck PageIsPrunable, since no one else could have
- * pruned while we hold pin.)
+ * page's free space, and recheck the heuristic about whether to
+ * prune. (We needn't recheck PageIsPrunable, since no one else could
+ * have pruned while we hold pin.)
*/
if (PageIsFull(dp) || PageGetHeapFreeSpace((Page) dp) < minfree)
{
*
* If redirect_move is set, we remove redirecting line pointers by
* updating the root line pointer to point directly to the first non-dead
- * tuple in the chain. NOTE: eliminating the redirect changes the first
+ * tuple in the chain. NOTE: eliminating the redirect changes the first
* tuple's effective CTID, and is therefore unsafe except within VACUUM FULL.
* The only reason we support this capability at all is that by using it,
* VACUUM FULL need not cope with LP_REDIRECT items at all; which seems a
heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin,
bool redirect_move, bool report_stats)
{
- int ndeleted = 0;
- Page page = BufferGetPage(buffer);
- OffsetNumber offnum,
- maxoff;
- OffsetNumber redirected[MaxHeapTuplesPerPage * 2];
- OffsetNumber nowdead[MaxHeapTuplesPerPage];
- OffsetNumber nowunused[MaxHeapTuplesPerPage];
- int nredirected = 0;
- int ndead = 0;
- int nunused = 0;
- bool page_was_full = false;
- TransactionId save_prune_xid;
+ int ndeleted = 0;
+ Page page = BufferGetPage(buffer);
+ OffsetNumber offnum,
+ maxoff;
+ OffsetNumber redirected[MaxHeapTuplesPerPage * 2];
+ OffsetNumber nowdead[MaxHeapTuplesPerPage];
+ OffsetNumber nowunused[MaxHeapTuplesPerPage];
+ int nredirected = 0;
+ int ndead = 0;
+ int nunused = 0;
+ bool page_was_full = false;
+ TransactionId save_prune_xid;
START_CRIT_SECTION();
save_prune_xid = ((PageHeader) page)->pd_prune_xid;
PageClearPrunable(page);
- /*
+ /*
* Also clear the "page is full" flag if it is set, since there's no point
* in repeating the prune/defrag process until something else happens to
* the page.
offnum <= maxoff;
offnum = OffsetNumberNext(offnum))
{
- ItemId itemid = PageGetItemId(page, offnum);
+ ItemId itemid = PageGetItemId(page, offnum);
/* Nothing to do if slot is empty or already dead */
if (!ItemIdIsUsed(itemid) || ItemIdIsDead(itemid))
END_CRIT_SECTION();
/*
- * If requested, report the number of tuples reclaimed to pgstats.
- * This is ndeleted minus ndead, because we don't want to count a now-DEAD
- * root item as a deletion for this purpose.
+ * If requested, report the number of tuples reclaimed to pgstats. This is
+ * ndeleted minus ndead, because we don't want to count a now-DEAD root
+ * item as a deletion for this purpose.
*/
if (report_stats && ndeleted > ndead)
pgstat_update_heap_dead_tuples(relation, ndeleted - ndead);
/*
* XXX Should we update the FSM information of this page ?
*
- * There are two schools of thought here. We may not want to update
- * FSM information so that the page is not used for unrelated
- * UPDATEs/INSERTs and any free space in this page will remain
- * available for further UPDATEs in *this* page, thus improving
- * chances for doing HOT updates.
+ * There are two schools of thought here. We may not want to update FSM
+ * information so that the page is not used for unrelated UPDATEs/INSERTs
+ * and any free space in this page will remain available for further
+ * UPDATEs in *this* page, thus improving chances for doing HOT updates.
*
- * But for a large table and where a page does not receive further
- * UPDATEs for a long time, we might waste this space by not
- * updating the FSM information. The relation may get extended and
- * fragmented further.
+ * But for a large table and where a page does not receive further UPDATEs
+ * for a long time, we might waste this space by not updating the FSM
+ * information. The relation may get extended and fragmented further.
*
- * One possibility is to leave "fillfactor" worth of space in this
- * page and update FSM with the remaining space.
+ * One possibility is to leave "fillfactor" worth of space in this page
+ * and update FSM with the remaining space.
*
* In any case, the current FSM implementation doesn't accept
* one-page-at-a-time updates, so this is all academic for now.
OffsetNumber *nowunused, int *nunused,
bool redirect_move)
{
- int ndeleted = 0;
- Page dp = (Page) BufferGetPage(buffer);
- TransactionId priorXmax = InvalidTransactionId;
- ItemId rootlp;
- HeapTupleHeader htup;
- OffsetNumber latestdead = InvalidOffsetNumber,
- maxoff = PageGetMaxOffsetNumber(dp),
- offnum;
- OffsetNumber chainitems[MaxHeapTuplesPerPage];
- int nchain = 0,
- i;
+ int ndeleted = 0;
+ Page dp = (Page) BufferGetPage(buffer);
+ TransactionId priorXmax = InvalidTransactionId;
+ ItemId rootlp;
+ HeapTupleHeader htup;
+ OffsetNumber latestdead = InvalidOffsetNumber,
+ maxoff = PageGetMaxOffsetNumber(dp),
+ offnum;
+ OffsetNumber chainitems[MaxHeapTuplesPerPage];
+ int nchain = 0,
+ i;
rootlp = PageGetItemId(dp, rootoffnum);
if (HeapTupleHeaderIsHeapOnly(htup))
{
/*
- * If the tuple is DEAD and doesn't chain to anything else, mark it
- * unused immediately. (If it does chain, we can only remove it as
- * part of pruning its chain.)
+ * If the tuple is DEAD and doesn't chain to anything else, mark
+ * it unused immediately. (If it does chain, we can only remove
+ * it as part of pruning its chain.)
*
* We need this primarily to handle aborted HOT updates, that is,
- * XMIN_INVALID heap-only tuples. Those might not be linked to
- * by any chain, since the parent tuple might be re-updated before
- * any pruning occurs. So we have to be able to reap them
+ * XMIN_INVALID heap-only tuples. Those might not be linked to by
+ * any chain, since the parent tuple might be re-updated before
+ * any pruning occurs. So we have to be able to reap them
* separately from chain-pruning.
*
* Note that we might first arrive at a dead heap-only tuple
/* while not end of the chain */
for (;;)
{
- ItemId lp;
- bool tupdead,
- recent_dead;
+ ItemId lp;
+ bool tupdead,
+ recent_dead;
/* Some sanity checks */
if (offnum < FirstOffsetNumber || offnum > maxoff)
break;
/*
- * If we are looking at the redirected root line pointer,
- * jump to the first normal tuple in the chain. If we find
- * a redirect somewhere else, stop --- it must not be same chain.
+ * If we are looking at the redirected root line pointer, jump to the
+ * first normal tuple in the chain. If we find a redirect somewhere
+ * else, stop --- it must not be same chain.
*/
if (ItemIdIsRedirected(lp))
{
}
/*
- * Likewise, a dead item pointer can't be part of the chain.
- * (We already eliminated the case of dead root tuple outside
- * this function.)
+ * Likewise, a dead item pointer can't be part of the chain. (We
+ * already eliminated the case of dead root tuple outside this
+ * function.)
*/
if (ItemIdIsDead(lp))
break;
case HEAPTUPLE_RECENTLY_DEAD:
recent_dead = true;
+
/*
* This tuple may soon become DEAD. Update the hint field so
* that the page is reconsidered for pruning in future.
break;
case HEAPTUPLE_DELETE_IN_PROGRESS:
+
/*
* This tuple may soon become DEAD. Update the hint field so
* that the page is reconsidered for pruning in future.
case HEAPTUPLE_LIVE:
case HEAPTUPLE_INSERT_IN_PROGRESS:
+
/*
* If we wanted to optimize for aborts, we might consider
* marking the page prunable when we see INSERT_IN_PROGRESS.
- * But we don't. See related decisions about when to mark
- * the page prunable in heapam.c.
+ * But we don't. See related decisions about when to mark the
+ * page prunable in heapam.c.
*/
break;
* Mark as unused each intermediate item that we are able to remove
* from the chain.
*
- * When the previous item is the last dead tuple seen, we are at
- * the right candidate for redirection.
+ * When the previous item is the last dead tuple seen, we are at the
+ * right candidate for redirection.
*/
for (i = 1; (i < nchain) && (chainitems[i - 1] != latestdead); i++)
{
- ItemId lp = PageGetItemId(dp, chainitems[i]);
+ ItemId lp = PageGetItemId(dp, chainitems[i]);
ItemIdSetUnused(lp);
heap_prune_record_unused(nowunused, nunused, chainitems[i]);
}
/*
- * If the root entry had been a normal tuple, we are deleting it,
- * so count it in the result. But changing a redirect (even to
- * DEAD state) doesn't count.
+ * If the root entry had been a normal tuple, we are deleting it, so
+ * count it in the result. But changing a redirect (even to DEAD
+ * state) doesn't count.
*/
if (ItemIdIsNormal(rootlp))
ndeleted++;
/*
* If the DEAD tuple is at the end of the chain, the entire chain is
- * dead and the root line pointer can be marked dead. Otherwise
- * just redirect the root to the correct chain member.
+ * dead and the root line pointer can be marked dead. Otherwise just
+ * redirect the root to the correct chain member.
*/
if (i >= nchain)
{
{
/*
* We found a redirect item that doesn't point to a valid follow-on
- * item. This can happen if the loop in heap_page_prune caused us
- * to visit the dead successor of a redirect item before visiting
- * the redirect item. We can clean up by setting the redirect item
- * to DEAD state.
+ * item. This can happen if the loop in heap_page_prune caused us to
+ * visit the dead successor of a redirect item before visiting the
+ * redirect item. We can clean up by setting the redirect item to
+ * DEAD state.
*/
ItemIdSetDead(rootlp);
heap_prune_record_dead(nowdead, ndead, rootoffnum);
}
/*
- * If requested, eliminate LP_REDIRECT items by moving tuples. Note that
+ * If requested, eliminate LP_REDIRECT items by moving tuples. Note that
* if the root item is LP_REDIRECT and doesn't point to a valid follow-on
* item, we already killed it above.
*/
if (redirect_move && ItemIdIsRedirected(rootlp))
{
OffsetNumber firstoffnum = ItemIdGetRedirect(rootlp);
- ItemId firstlp = PageGetItemId(dp, firstoffnum);
- HeapTupleData firsttup;
+ ItemId firstlp = PageGetItemId(dp, firstoffnum);
+ HeapTupleData firsttup;
Assert(ItemIdIsNormal(firstlp));
/* Set up firsttup to reference the tuple at its existing CTID */
firsttup.t_tableOid = RelationGetRelid(relation);
/*
- * Mark the tuple for invalidation. Needed because we're changing
- * its CTID.
+ * Mark the tuple for invalidation. Needed because we're changing its
+ * CTID.
*/
CacheInvalidateHeapTuple(relation, &firsttup);
/*
- * Change heap-only status of the tuple because after the line
- * pointer manipulation, it's no longer a heap-only tuple, but is
- * directly pointed to by index entries.
+ * Change heap-only status of the tuple because after the line pointer
+ * manipulation, it's no longer a heap-only tuple, but is directly
+ * pointed to by index entries.
*/
Assert(HeapTupleIsHeapOnly(&firsttup));
HeapTupleClearHeapOnly(&firsttup);
/* Record newly-redirected item pointer */
static void
heap_prune_record_redirect(OffsetNumber *redirected, int *nredirected,
- OffsetNumber offnum, OffsetNumber rdoffnum)
+ OffsetNumber offnum, OffsetNumber rdoffnum)
{
Assert(*nredirected < MaxHeapTuplesPerPage);
redirected[*nredirected * 2] = offnum;
void
heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
{
- OffsetNumber offnum, maxoff;
+ OffsetNumber offnum,
+ maxoff;
MemSet(root_offsets, 0, MaxHeapTuplesPerPage * sizeof(OffsetNumber));
maxoff = PageGetMaxOffsetNumber(page);
for (offnum = FirstOffsetNumber; offnum <= maxoff; offnum++)
{
- ItemId lp = PageGetItemId(page, offnum);
- HeapTupleHeader htup;
- OffsetNumber nextoffnum;
- TransactionId priorXmax;
+ ItemId lp = PageGetItemId(page, offnum);
+ HeapTupleHeader htup;
+ OffsetNumber nextoffnum;
+ TransactionId priorXmax;
/* skip unused and dead items */
if (!ItemIdIsUsed(lp) || ItemIdIsDead(lp))
*
* The caller is responsible for creating the new heap, all catalog
* changes, supplying the tuples to be written to the new heap, and
- * rebuilding indexes. The caller must hold AccessExclusiveLock on the
+ * rebuilding indexes. The caller must hold AccessExclusiveLock on the
* target table, because we assume no one else is writing into it.
*
* To use the facility:
* begin_heap_rewrite
* while (fetch next tuple)
* {
- * if (tuple is dead)
- * rewrite_heap_dead_tuple
- * else
- * {
- * // do any transformations here if required
- * rewrite_heap_tuple
- * }
+ * if (tuple is dead)
+ * rewrite_heap_dead_tuple
+ * else
+ * {
+ * // do any transformations here if required
+ * rewrite_heap_tuple
+ * }
* }
* end_heap_rewrite
*
* to substitute the correct ctid instead.
*
* For each ctid reference from A -> B, we might encounter either A first
- * or B first. (Note that a tuple in the middle of a chain is both A and B
+ * or B first. (Note that a tuple in the middle of a chain is both A and B
* of different pairs.)
*
* If we encounter A first, we'll store the tuple in the unresolved_tups
* and can write A immediately with the correct ctid.
*
* Entries in the hash tables can be removed as soon as the later tuple
- * is encountered. That helps to keep the memory usage down. At the end,
+ * is encountered. That helps to keep the memory usage down. At the end,
* both tables are usually empty; we should have encountered both A and B
* of each pair. However, it's possible for A to be RECENTLY_DEAD and B
* entirely DEAD according to HeapTupleSatisfiesVacuum, because the test
- * for deadness using OldestXmin is not exact. In such a case we might
+ * for deadness using OldestXmin is not exact. In such a case we might
* encounter B first, and skip it, and find A later. Then A would be added
* to unresolved_tups, and stay there until end of the rewrite. Since
* this case is very unusual, we don't worry about the memory usage.
* of CLUSTERing on an unchanging key column, we'll see all the versions
* of a given tuple together anyway, and so the peak memory usage is only
* proportional to the number of RECENTLY_DEAD versions of a single row, not
- * in the whole table. Note that if we do fail halfway through a CLUSTER,
+ * in the whole table. Note that if we do fail halfway through a CLUSTER,
* the old table is still valid, so failure is not catastrophic.
*
* We can't use the normal heap_insert function to insert into the new
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.7 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.8 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef struct RewriteStateData
{
- Relation rs_new_rel; /* destination heap */
- Page rs_buffer; /* page currently being built */
- BlockNumber rs_blockno; /* block where page will go */
- bool rs_buffer_valid; /* T if any tuples in buffer */
- bool rs_use_wal; /* must we WAL-log inserts? */
- TransactionId rs_oldest_xmin; /* oldest xmin used by caller to
+ Relation rs_new_rel; /* destination heap */
+ Page rs_buffer; /* page currently being built */
+ BlockNumber rs_blockno; /* block where page will go */
+ bool rs_buffer_valid; /* T if any tuples in buffer */
+ bool rs_use_wal; /* must we WAL-log inserts? */
+ TransactionId rs_oldest_xmin; /* oldest xmin used by caller to
* determine tuple visibility */
- TransactionId rs_freeze_xid; /* Xid that will be used as freeze
- * cutoff point */
- MemoryContext rs_cxt; /* for hash tables and entries and
- * tuples in them */
- HTAB *rs_unresolved_tups; /* unmatched A tuples */
- HTAB *rs_old_new_tid_map; /* unmatched B tuples */
-} RewriteStateData;
+ TransactionId rs_freeze_xid;/* Xid that will be used as freeze cutoff
+ * point */
+ MemoryContext rs_cxt; /* for hash tables and entries and tuples in
+ * them */
+ HTAB *rs_unresolved_tups; /* unmatched A tuples */
+ HTAB *rs_old_new_tid_map; /* unmatched B tuples */
+} RewriteStateData;
/*
* The lookup keys for the hash tables are tuple TID and xmin (we must check
*/
typedef struct
{
- TransactionId xmin; /* tuple xmin */
+ TransactionId xmin; /* tuple xmin */
ItemPointerData tid; /* tuple location in old heap */
-} TidHashKey;
+} TidHashKey;
/*
* Entry structures for the hash tables
*/
typedef struct
{
- TidHashKey key; /* expected xmin/old location of B tuple */
+ TidHashKey key; /* expected xmin/old location of B tuple */
ItemPointerData old_tid; /* A's location in the old heap */
- HeapTuple tuple; /* A's tuple contents */
-} UnresolvedTupData;
+ HeapTuple tuple; /* A's tuple contents */
+} UnresolvedTupData;
typedef UnresolvedTupData *UnresolvedTup;
typedef struct
{
- TidHashKey key; /* actual xmin/old location of B tuple */
+ TidHashKey key; /* actual xmin/old location of B tuple */
ItemPointerData new_tid; /* where we put it in the new heap */
-} OldToNewMappingData;
+} OldToNewMappingData;
typedef OldToNewMappingData *OldToNewMapping;
HASHCTL hash_ctl;
/*
- * To ease cleanup, make a separate context that will contain
- * the RewriteState struct itself plus all subsidiary data.
+ * To ease cleanup, make a separate context that will contain the
+ * RewriteState struct itself plus all subsidiary data.
*/
rw_cxt = AllocSetContextCreate(CurrentMemoryContext,
"Table rewrite",
state->rs_unresolved_tups =
hash_create("Rewrite / Unresolved ctids",
- 128, /* arbitrary initial size */
+ 128, /* arbitrary initial size */
&hash_ctl,
HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT);
state->rs_old_new_tid_map =
hash_create("Rewrite / Old to new tid map",
- 128, /* arbitrary initial size */
+ 128, /* arbitrary initial size */
&hash_ctl,
HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT);
UnresolvedTup unresolved;
/*
- * Write any remaining tuples in the UnresolvedTups table. If we have
- * any left, they should in fact be dead, but let's err on the safe side.
+ * Write any remaining tuples in the UnresolvedTups table. If we have any
+ * left, they should in fact be dead, but let's err on the safe side.
*
* XXX this really is a waste of code no?
*/
}
/*
- * If the rel isn't temp, must fsync before commit. We use heap_sync
- * to ensure that the toast table gets fsync'd too.
+ * If the rel isn't temp, must fsync before commit. We use heap_sync to
+ * ensure that the toast table gets fsync'd too.
*
* It's obvious that we must do this when not WAL-logging. It's less
- * obvious that we have to do it even if we did WAL-log the pages.
- * The reason is the same as in tablecmds.c's copy_relation_data():
- * we're writing data that's not in shared buffers, and so a CHECKPOINT
- * occurring during the rewriteheap operation won't have fsync'd data
- * we wrote before the checkpoint.
+ * obvious that we have to do it even if we did WAL-log the pages. The
+ * reason is the same as in tablecmds.c's copy_relation_data(): we're
+ * writing data that's not in shared buffers, and so a CHECKPOINT
+ * occurring during the rewriteheap operation won't have fsync'd data we
+ * wrote before the checkpoint.
*/
if (!state->rs_new_rel->rd_istemp)
heap_sync(state->rs_new_rel);
{
MemoryContext old_cxt;
ItemPointerData old_tid;
- TidHashKey hashkey;
- bool found;
- bool free_new;
+ TidHashKey hashkey;
+ bool found;
+ bool free_new;
old_cxt = MemoryContextSwitchTo(state->rs_cxt);
/*
* Copy the original tuple's visibility information into new_tuple.
*
- * XXX we might later need to copy some t_infomask2 bits, too?
- * Right now, we intentionally clear the HOT status bits.
+ * XXX we might later need to copy some t_infomask2 bits, too? Right now,
+ * we intentionally clear the HOT status bits.
*/
memcpy(&new_tuple->t_data->t_choice.t_heap,
&old_tuple->t_data->t_choice.t_heap,
* While we have our hands on the tuple, we may as well freeze any
* very-old xmin or xmax, so that future VACUUM effort can be saved.
*
- * Note we abuse heap_freeze_tuple() a bit here, since it's expecting
- * to be given a pointer to a tuple in a disk buffer. It happens
- * though that we can get the right things to happen by passing
- * InvalidBuffer for the buffer.
+ * Note we abuse heap_freeze_tuple() a bit here, since it's expecting to
+ * be given a pointer to a tuple in a disk buffer. It happens though that
+ * we can get the right things to happen by passing InvalidBuffer for the
+ * buffer.
*/
heap_freeze_tuple(new_tuple->t_data, state->rs_freeze_xid, InvalidBuffer);
/*
- * Invalid ctid means that ctid should point to the tuple itself.
- * We'll override it later if the tuple is part of an update chain.
+ * Invalid ctid means that ctid should point to the tuple itself. We'll
+ * override it later if the tuple is part of an update chain.
*/
ItemPointerSetInvalid(&new_tuple->t_data->t_ctid);
if (mapping != NULL)
{
/*
- * We've already copied the tuple that t_ctid points to, so we
- * can set the ctid of this tuple to point to the new location,
- * and insert it right away.
+ * We've already copied the tuple that t_ctid points to, so we can
+ * set the ctid of this tuple to point to the new location, and
+ * insert it right away.
*/
new_tuple->t_data->t_ctid = mapping->new_tid;
}
/*
- * Now we will write the tuple, and then check to see if it is the
- * B tuple in any new or known pair. When we resolve a known pair,
- * we will be able to write that pair's A tuple, and then we have to
- * check if it resolves some other pair. Hence, we need a loop here.
+ * Now we will write the tuple, and then check to see if it is the B tuple
+ * in any new or known pair. When we resolve a known pair, we will be
+ * able to write that pair's A tuple, and then we have to check if it
+ * resolves some other pair. Hence, we need a loop here.
*/
old_tid = old_tuple->t_self;
free_new = false;
new_tid = new_tuple->t_self;
/*
- * If the tuple is the updated version of a row, and the prior
- * version wouldn't be DEAD yet, then we need to either resolve
- * the prior version (if it's waiting in rs_unresolved_tups),
- * or make an entry in rs_old_new_tid_map (so we can resolve it
- * when we do see it). The previous tuple's xmax would equal this
- * one's xmin, so it's RECENTLY_DEAD if and only if the xmin is
- * not before OldestXmin.
+ * If the tuple is the updated version of a row, and the prior version
+ * wouldn't be DEAD yet, then we need to either resolve the prior
+ * version (if it's waiting in rs_unresolved_tups), or make an entry
+ * in rs_old_new_tid_map (so we can resolve it when we do see it).
+ * The previous tuple's xmax would equal this one's xmin, so it's
+ * RECENTLY_DEAD if and only if the xmin is not before OldestXmin.
*/
if ((new_tuple->t_data->t_infomask & HEAP_UPDATED) &&
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(new_tuple->t_data),
if (unresolved != NULL)
{
/*
- * We have seen and memorized the previous tuple already.
- * Now that we know where we inserted the tuple its t_ctid
- * points to, fix its t_ctid and insert it to the new heap.
+ * We have seen and memorized the previous tuple already. Now
+ * that we know where we inserted the tuple its t_ctid points
+ * to, fix its t_ctid and insert it to the new heap.
*/
if (free_new)
heap_freetuple(new_tuple);
new_tuple->t_data->t_ctid = new_tid;
/*
- * We don't need the hash entry anymore, but don't free
- * its tuple just yet.
+ * We don't need the hash entry anymore, but don't free its
+ * tuple just yet.
*/
hash_search(state->rs_unresolved_tups, &hashkey,
HASH_REMOVE, &found);
else
{
/*
- * Remember the new tid of this tuple. We'll use it to set
- * the ctid when we find the previous tuple in the chain.
+ * Remember the new tid of this tuple. We'll use it to set the
+ * ctid when we find the previous tuple in the chain.
*/
OldToNewMapping mapping;
{
/*
* If we have already seen an earlier tuple in the update chain that
- * points to this tuple, let's forget about that earlier tuple. It's
- * in fact dead as well, our simple xmax < OldestXmin test in
- * HeapTupleSatisfiesVacuum just wasn't enough to detect it. It
- * happens when xmin of a tuple is greater than xmax, which sounds
+ * points to this tuple, let's forget about that earlier tuple. It's in
+ * fact dead as well, our simple xmax < OldestXmin test in
+ * HeapTupleSatisfiesVacuum just wasn't enough to detect it. It happens
+ * when xmin of a tuple is greater than xmax, which sounds
* counter-intuitive but is perfectly valid.
*
- * We don't bother to try to detect the situation the other way
- * round, when we encounter the dead tuple first and then the
- * recently dead one that points to it. If that happens, we'll
- * have some unmatched entries in the UnresolvedTups hash table
- * at the end. That can happen anyway, because a vacuum might
- * have removed the dead tuple in the chain before us.
+ * We don't bother to try to detect the situation the other way round,
+ * when we encounter the dead tuple first and then the recently dead one
+ * that points to it. If that happens, we'll have some unmatched entries
+ * in the UnresolvedTups hash table at the end. That can happen anyway,
+ * because a vacuum might have removed the dead tuple in the chain before
+ * us.
*/
UnresolvedTup unresolved;
- TidHashKey hashkey;
- bool found;
+ TidHashKey hashkey;
+ bool found;
memset(&hashkey, 0, sizeof(hashkey));
hashkey.xmin = HeapTupleHeaderGetXmin(old_tuple->t_data);
}
/*
- * Insert a tuple to the new relation. This has to track heap_insert
+ * Insert a tuple to the new relation. This has to track heap_insert
* and its subsidiary functions!
*
* t_self of the tuple is set to the new TID of the tuple. If t_ctid of the
static void
raw_heap_insert(RewriteState state, HeapTuple tup)
{
- Page page = state->rs_buffer;
- Size pageFreeSpace, saveFreeSpace;
- Size len;
- OffsetNumber newoff;
- HeapTuple heaptup;
+ Page page = state->rs_buffer;
+ Size pageFreeSpace,
+ saveFreeSpace;
+ Size len;
+ OffsetNumber newoff;
+ HeapTuple heaptup;
/*
* If the new tuple is too big for storage or contains already toasted
/*
* Now write the page. We say isTemp = true even if it's not a
* temp table, because there's no need for smgr to schedule an
- * fsync for this write; we'll do it ourselves in end_heap_rewrite.
+ * fsync for this write; we'll do it ourselves in
+ * end_heap_rewrite.
*/
RelationOpenSmgr(state->rs_new_rel);
smgrextend(state->rs_new_rel->rd_smgr, state->rs_blockno,
ItemPointerSet(&(tup->t_self), state->rs_blockno, newoff);
/*
- * Insert the correct position into CTID of the stored tuple, too,
- * if the caller didn't supply a valid CTID.
+ * Insert the correct position into CTID of the stored tuple, too, if the
+ * caller didn't supply a valid CTID.
*/
- if(!ItemPointerIsValid(&tup->t_data->t_ctid))
+ if (!ItemPointerIsValid(&tup->t_data->t_ctid))
{
- ItemId newitemid;
+ ItemId newitemid;
HeapTupleHeader onpage_tup;
newitemid = PageGetItemId(page, newoff);
* heap scan synchronization support
*
* When multiple backends run a sequential scan on the same table, we try
- * to keep them synchronized to reduce the overall I/O needed. The goal is
+ * to keep them synchronized to reduce the overall I/O needed. The goal is
* to read each page into shared buffer cache only once, and let all backends
* that take part in the shared scan process the page before it falls out of
* the cache.
* don't want such queries to slow down others.
*
* There can realistically only be a few large sequential scans on different
- * tables in progress at any time. Therefore we just keep the scan positions
+ * tables in progress at any time. Therefore we just keep the scan positions
* in a small LRU list which we scan every time we need to look up or update a
* scan position. The whole mechanism is only applied for tables exceeding
* a threshold size (but that is not the concern of this module).
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/syncscan.c,v 1.1 2007/06/08 18:23:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/syncscan.c,v 1.2 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* GUC variables */
#ifdef TRACE_SYNCSCAN
-bool trace_syncscan = false;
+bool trace_syncscan = false;
#endif
{
RelFileNode relfilenode; /* identity of a relation */
BlockNumber location; /* last-reported location in the relation */
-} ss_scan_location_t;
+} ss_scan_location_t;
typedef struct ss_lru_item_t
{
- struct ss_lru_item_t *prev;
- struct ss_lru_item_t *next;
- ss_scan_location_t location;
-} ss_lru_item_t;
+ struct ss_lru_item_t *prev;
+ struct ss_lru_item_t *next;
+ ss_scan_location_t location;
+} ss_lru_item_t;
typedef struct ss_scan_locations_t
{
- ss_lru_item_t *head;
- ss_lru_item_t *tail;
- ss_lru_item_t items[1]; /* SYNC_SCAN_NELEM items */
-} ss_scan_locations_t;
+ ss_lru_item_t *head;
+ ss_lru_item_t *tail;
+ ss_lru_item_t items[1]; /* SYNC_SCAN_NELEM items */
+} ss_scan_locations_t;
#define SizeOfScanLocations(N) offsetof(ss_scan_locations_t, items[N])
/* prototypes for internal functions */
static BlockNumber ss_search(RelFileNode relfilenode,
- BlockNumber location, bool set);
+ BlockNumber location, bool set);
/*
void
SyncScanShmemInit(void)
{
- int i;
- bool found;
+ int i;
+ bool found;
scan_locations = (ss_scan_locations_t *)
ShmemInitStruct("Sync Scan Locations List",
static BlockNumber
ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
{
- ss_lru_item_t *item;
+ ss_lru_item_t *item;
item = scan_locations->head;
for (;;)
{
- bool match;
+ bool match;
match = RelFileNodeEquals(item->location.relfilenode, relfilenode);
if (match || item->next == NULL)
{
/*
- * If we reached the end of list and no match was found,
- * take over the last entry
+ * If we reached the end of list and no match was found, take over
+ * the last entry
*/
if (!match)
{
* relation, or 0 if no valid location is found.
*
* We expect the caller has just done RelationGetNumberOfBlocks(), and
- * so that number is passed in rather than computing it again. The result
+ * so that number is passed in rather than computing it again. The result
* is guaranteed less than relnblocks (assuming that's > 0).
*/
BlockNumber
/*
* If the location is not a valid block number for this scan, start at 0.
*
- * This can happen if for instance a VACUUM truncated the table
- * since the location was saved.
+ * This can happen if for instance a VACUUM truncated the table since the
+ * location was saved.
*/
if (startloc >= relnblocks)
startloc = 0;
#endif
/*
- * To reduce lock contention, only report scan progress every N pages.
- * For the same reason, don't block if the lock isn't immediately
- * available. Missing a few updates isn't critical, it just means that a
- * new scan that wants to join the pack will start a little bit behind the
- * head of the scan. Hopefully the pages are still in OS cache and the
- * scan catches up quickly.
+ * To reduce lock contention, only report scan progress every N pages. For
+ * the same reason, don't block if the lock isn't immediately available.
+ * Missing a few updates isn't critical, it just means that a new scan
+ * that wants to join the pack will start a little bit behind the head of
+ * the scan. Hopefully the pages are still in OS cache and the scan
+ * catches up quickly.
*/
if ((location % SYNC_SCAN_REPORT_INTERVAL) == 0)
{
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.78 2007/10/11 18:19:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.79 2007/11/15 21:14:32 momjian Exp $
*
*
* INTERFACE ROUTINES
static void toast_delete_datum(Relation rel, Datum value);
static Datum toast_save_datum(Relation rel, Datum value,
- bool use_wal, bool use_fsm);
-static struct varlena *toast_fetch_datum(struct varlena *attr);
-static struct varlena *toast_fetch_datum_slice(struct varlena *attr,
+ bool use_wal, bool use_fsm);
+static struct varlena *toast_fetch_datum(struct varlena * attr);
+static struct varlena *toast_fetch_datum_slice(struct varlena * attr,
int32 sliceoffset, int32 length);
----------
*/
struct varlena *
-heap_tuple_fetch_attr(struct varlena *attr)
+heap_tuple_fetch_attr(struct varlena * attr)
{
- struct varlena *result;
+ struct varlena *result;
if (VARATT_IS_EXTERNAL(attr))
{
* ----------
*/
struct varlena *
-heap_tuple_untoast_attr(struct varlena *attr)
+heap_tuple_untoast_attr(struct varlena * attr)
{
if (VARATT_IS_EXTERNAL(attr))
{
/*
* This is a short-header varlena --- convert to 4-byte header format
*/
- Size data_size = VARSIZE_SHORT(attr) - VARHDRSZ_SHORT;
- Size new_size = data_size + VARHDRSZ;
+ Size data_size = VARSIZE_SHORT(attr) - VARHDRSZ_SHORT;
+ Size new_size = data_size + VARHDRSZ;
struct varlena *new_attr;
new_attr = (struct varlena *) palloc(new_size);
* ----------
*/
struct varlena *
-heap_tuple_untoast_attr_slice(struct varlena *attr,
+heap_tuple_untoast_attr_slice(struct varlena * attr,
int32 sliceoffset, int32 slicelength)
{
struct varlena *preslice;
struct varlena *result;
- char *attrdata;
+ char *attrdata;
int32 attrsize;
if (VARATT_IS_EXTERNAL(attr))
if (VARATT_IS_COMPRESSED(preslice))
{
PGLZ_Header *tmp = (PGLZ_Header *) preslice;
- Size size = PGLZ_RAW_SIZE(tmp) + VARHDRSZ;
+ Size size = PGLZ_RAW_SIZE(tmp) + VARHDRSZ;
preslice = (struct varlena *) palloc(size);
SET_VARSIZE(preslice, size);
Size
toast_datum_size(Datum value)
{
- struct varlena *attr = (struct varlena *) DatumGetPointer(value);
+ struct varlena *attr = (struct varlena *) DatumGetPointer(value);
Size result;
if (VARATT_IS_EXTERNAL(attr))
for (i = 0; i < numAttrs; i++)
{
- struct varlena *old_value;
- struct varlena *new_value;
+ struct varlena *old_value;
+ struct varlena *new_value;
if (oldtup != NULL)
{
VARATT_IS_EXTERNAL(old_value))
{
if (toast_isnull[i] || !VARATT_IS_EXTERNAL(new_value) ||
- memcmp((char *) old_value, (char *) new_value,
+ memcmp((char *) old_value, (char *) new_value,
VARSIZE_EXTERNAL(old_value)) != 0)
{
/*
* We took care of UPDATE above, so any external value we find
* still in the tuple must be someone else's we cannot reuse.
* Fetch it back (without decompression, unless we are forcing
- * PLAIN storage). If necessary, we'll push it out as a new
+ * PLAIN storage). If necessary, we'll push it out as a new
* external value below.
*/
if (VARATT_IS_EXTERNAL(new_value))
/*
* Second we look for attributes of attstorage 'x' or 'e' that are still
- * inline. But skip this if there's no toast table to push them to.
+ * inline. But skip this if there's no toast table to push them to.
*/
while (heap_compute_data_size(tupleDesc,
toast_values, toast_isnull) > maxDataLen &&
has_nulls = true;
else if (att[i]->attlen == -1)
{
- struct varlena *new_value;
+ struct varlena *new_value;
new_value = (struct varlena *) DatumGetPointer(toast_values[i]);
if (VARATT_IS_EXTERNAL(new_value) ||
Assert(!VARATT_IS_COMPRESSED(value));
/*
- * No point in wasting a palloc cycle if value is too short for compression
+ * No point in wasting a palloc cycle if value is too short for
+ * compression
*/
if (valsize < PGLZ_strategy_default->min_input_size)
return PointerGetDatum(NULL);
/*
* Get the data pointer and length, and compute va_rawsize and va_extsize.
*
- * va_rawsize is the size of the equivalent fully uncompressed datum,
- * so we have to adjust for short headers.
+ * va_rawsize is the size of the equivalent fully uncompressed datum, so
+ * we have to adjust for short headers.
*
* va_extsize is the actual size of the data payload in the toast records.
*/
{
data_p = VARDATA_SHORT(value);
data_todo = VARSIZE_SHORT(value) - VARHDRSZ_SHORT;
- toast_pointer.va_rawsize = data_todo + VARHDRSZ; /* as if not short */
+ toast_pointer.va_rawsize = data_todo + VARHDRSZ; /* as if not short */
toast_pointer.va_extsize = data_todo;
}
else if (VARATT_IS_COMPRESSED(value))
* ----------
*/
static struct varlena *
-toast_fetch_datum(struct varlena *attr)
+toast_fetch_datum(struct varlena * attr)
{
Relation toastrel;
Relation toastidx;
int32 numchunks;
Pointer chunk;
bool isnull;
- char *chunkdata;
+ char *chunkdata;
int32 chunksize;
/* Must copy to access aligned fields */
{
/* should never happen */
elog(ERROR, "found toasted toast chunk");
- chunksize = 0; /* keep compiler quiet */
+ chunksize = 0; /* keep compiler quiet */
chunkdata = NULL;
}
residx, numchunks,
toast_pointer.va_valueid);
}
- else if (residx == numchunks-1)
+ else if (residx == numchunks - 1)
{
if ((residx * TOAST_MAX_CHUNK_SIZE + chunksize) != ressize)
elog(ERROR, "unexpected chunk size %d (expected %d) in final chunk %d for toast value %u",
chunksize,
- (int) (ressize - residx*TOAST_MAX_CHUNK_SIZE),
+ (int) (ressize - residx * TOAST_MAX_CHUNK_SIZE),
residx,
toast_pointer.va_valueid);
}
elog(ERROR, "unexpected chunk number %d for toast value %u (out of range %d..%d)",
residx,
toast_pointer.va_valueid,
- 0, numchunks-1);
+ 0, numchunks - 1);
/*
* Copy the data into proper place in our result
* ----------
*/
static struct varlena *
-toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, int32 length)
+toast_fetch_datum_slice(struct varlena * attr, int32 sliceoffset, int32 length)
{
Relation toastrel;
Relation toastidx;
int totalchunks;
Pointer chunk;
bool isnull;
- char *chunkdata;
+ char *chunkdata;
int32 chunksize;
int32 chcpystrt;
int32 chcpyend;
{
/* should never happen */
elog(ERROR, "found toasted toast chunk");
- chunksize = 0; /* keep compiler quiet */
+ chunksize = 0; /* keep compiler quiet */
chunkdata = NULL;
}
residx, totalchunks,
toast_pointer.va_valueid);
}
- else if (residx == totalchunks-1)
+ else if (residx == totalchunks - 1)
{
if ((residx * TOAST_MAX_CHUNK_SIZE + chunksize) != attrsize)
elog(ERROR, "unexpected chunk size %d (expected %d) in final chunk %d for toast value %u when fetching slice",
elog(ERROR, "unexpected chunk number %d for toast value %u (out of range %d..%d)",
residx,
toast_pointer.va_valueid,
- 0, totalchunks-1);
+ 0, totalchunks - 1);
/*
* Copy the data into proper place in our result
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.99 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.100 2007/11/15 21:14:32 momjian Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relation OID
* returnable tuple in each HOT chain, and so restoring the prior state at the
* granularity of the index AM is sufficient. Since the only current user
* of mark/restore functionality is nodeMergejoin.c, this effectively means
- * that merge-join plans only work for MVCC snapshots. This could be fixed
+ * that merge-join plans only work for MVCC snapshots. This could be fixed
* if necessary, but for now it seems unimportant.
* ----------------
*/
index_getnext(IndexScanDesc scan, ScanDirection direction)
{
HeapTuple heapTuple = &scan->xs_ctup;
- ItemPointer tid = &heapTuple->t_self;
+ ItemPointer tid = &heapTuple->t_self;
FmgrInfo *procedure;
SCAN_CHECKS;
for (;;)
{
OffsetNumber offnum;
- bool at_chain_start;
- Page dp;
+ bool at_chain_start;
+ Page dp;
if (scan->xs_next_hot != InvalidOffsetNumber)
{
/*
- * We are resuming scan of a HOT chain after having returned
- * an earlier member. Must still hold pin on current heap page.
+ * We are resuming scan of a HOT chain after having returned an
+ * earlier member. Must still hold pin on current heap page.
*/
Assert(BufferIsValid(scan->xs_cbuf));
Assert(ItemPointerGetBlockNumber(tid) ==
/* Scan through possible multiple members of HOT-chain */
for (;;)
{
- ItemId lp;
+ ItemId lp;
ItemPointer ctid;
/* check for bogus TID */
}
/*
- * We must initialize all of *heapTuple (ie, scan->xs_ctup)
- * since it is returned to the executor on success.
+ * We must initialize all of *heapTuple (ie, scan->xs_ctup) since
+ * it is returned to the executor on success.
*/
heapTuple->t_data = (HeapTupleHeader) PageGetItem(dp, lp);
heapTuple->t_len = ItemIdGetLength(lp);
/*
* Shouldn't see a HEAP_ONLY tuple at chain start. (This test
* should be unnecessary, since the chain root can't be removed
- * while we have pin on the index entry, but let's make it anyway.)
+ * while we have pin on the index entry, but let's make it
+ * anyway.)
*/
if (at_chain_start && HeapTupleIsHeapOnly(heapTuple))
break;
/*
* The xmin should match the previous xmax value, else chain is
- * broken. (Note: this test is not optional because it protects
- * us against the case where the prior chain member's xmax
- * aborted since we looked at it.)
+ * broken. (Note: this test is not optional because it protects
+ * us against the case where the prior chain member's xmax aborted
+ * since we looked at it.)
*/
if (TransactionIdIsValid(scan->xs_prev_xmax) &&
!TransactionIdEquals(scan->xs_prev_xmax,
- HeapTupleHeaderGetXmin(heapTuple->t_data)))
+ HeapTupleHeaderGetXmin(heapTuple->t_data)))
break;
/* If it's visible per the snapshot, we must return it */
scan->xs_cbuf))
{
/*
- * If the snapshot is MVCC, we know that it could accept
- * at most one member of the HOT chain, so we can skip
- * examining any more members. Otherwise, check for
- * continuation of the HOT-chain, and set state for next time.
+ * If the snapshot is MVCC, we know that it could accept at
+ * most one member of the HOT chain, so we can skip examining
+ * any more members. Otherwise, check for continuation of the
+ * HOT-chain, and set state for next time.
*/
if (IsMVCCSnapshot(scan->xs_snapshot))
scan->xs_next_hot = InvalidOffsetNumber;
}
else
break; /* end of chain */
- } /* loop over a single HOT chain */
+ } /* loop over a single HOT chain */
LockBuffer(scan->xs_cbuf, BUFFER_LOCK_UNLOCK);
* particular indexed attribute are those with both types equal to
* the index opclass' opcintype (note that this is subtly different
* from the indexed attribute's own type: it may be a binary-compatible
- * type instead). Only the default functions are stored in relcache
+ * type instead). Only the default functions are stored in relcache
* entries --- access methods can use the syscache to look up non-default
* functions.
*
* index_getprocinfo
*
* This routine allows index AMs to keep fmgr lookup info for
- * support procs in the relcache. As above, only the "default"
+ * support procs in the relcache. As above, only the "default"
* functions for any particular indexed attribute are cached.
*
* Note: the return value points into cached data that will be lost during
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.160 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.161 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
OffsetNumber newitemoff; /* where the new item is to be inserted */
int leftspace; /* space available for items on left page */
int rightspace; /* space available for items on right page */
- int olddataitemstotal; /* space taken by old items */
+ int olddataitemstotal; /* space taken by old items */
bool have_split; /* found a valid split? */
if (!ItemIdIsDead(curitemid))
{
ItemPointerData htid;
- bool all_dead;
+ bool all_dead;
/*
* _bt_compare returns 0 for (1,NULL) and (1,NULL) - this's
/*
* We check the whole HOT-chain to see if there is any tuple
- * that satisfies SnapshotDirty. This is necessary because
- * we have just a single index entry for the entire chain.
+ * that satisfies SnapshotDirty. This is necessary because we
+ * have just a single index entry for the entire chain.
*/
if (heap_hot_search(&htid, heapRel, &SnapshotDirty, &all_dead))
{
* is itself now committed dead --- if so, don't complain.
* This is a waste of time in normal scenarios but we must
* do it to support CREATE INDEX CONCURRENTLY.
- *
+ *
* We must follow HOT-chains here because during
* concurrent index build, we insert the root TID though
* the actual tuple may be somewhere in the HOT-chain.
- * While following the chain we might not stop at the exact
- * tuple which triggered the insert, but that's OK because
- * if we find a live tuple anywhere in this chain, we have
- * a unique key conflict. The other live tuple is not part
- * of this chain because it had a different index entry.
+ * While following the chain we might not stop at the
+ * exact tuple which triggered the insert, but that's OK
+ * because if we find a live tuple anywhere in this chain,
+ * we have a unique key conflict. The other live tuple is
+ * not part of this chain because it had a different index
+ * entry.
*/
htid = itup->t_tid;
if (heap_hot_search(&htid, heapRel, SnapshotSelf, NULL))
ereport(ERROR,
(errcode(ERRCODE_UNIQUE_VIOLATION),
- errmsg("duplicate key value violates unique constraint \"%s\"",
- RelationGetRelationName(rel))));
+ errmsg("duplicate key value violates unique constraint \"%s\"",
+ RelationGetRelationName(rel))));
}
else if (all_dead)
{
* On entry, *buf and *offsetptr point to the first legal position
* where the new tuple could be inserted. The caller should hold an
* exclusive lock on *buf. *offsetptr can also be set to
- * InvalidOffsetNumber, in which case the function will search the right
+ * InvalidOffsetNumber, in which case the function will search the right
* location within the page if needed. On exit, they point to the chosen
* insert location. If findinsertloc decided to move right, the lock and
* pin on the original page will be released and the new page returned to
ScanKey scankey,
IndexTuple newtup)
{
- Buffer buf = *bufptr;
- Page page = BufferGetPage(buf);
- Size itemsz;
+ Buffer buf = *bufptr;
+ Page page = BufferGetPage(buf);
+ Size itemsz;
BTPageOpaque lpageop;
- bool movedright, vacuumed;
+ bool movedright,
+ vacuumed;
OffsetNumber newitemoff;
OffsetNumber firstlegaloff = *offsetptr;
Buffer rbuf;
/*
- * before considering moving right, see if we can obtain enough
- * space by erasing LP_DEAD items
+ * before considering moving right, see if we can obtain enough space
+ * by erasing LP_DEAD items
*/
if (P_ISLEAF(lpageop) && P_HAS_GARBAGE(lpageop))
{
_bt_vacuum_one_page(rel, buf);
- /* remember that we vacuumed this page, because that makes
- * the hint supplied by the caller invalid */
+ /*
+ * remember that we vacuumed this page, because that makes the
+ * hint supplied by the caller invalid
+ */
vacuumed = true;
if (PageGetFreeSpace(page) >= itemsz)
- break; /* OK, now we have enough space */
+ break; /* OK, now we have enough space */
}
/*
/*
* step right to next non-dead page
*
- * must write-lock that page before releasing write lock on
- * current page; else someone else's _bt_check_unique scan could
- * fail to see our insertion. write locks on intermediate dead
- * pages won't do because we don't know when they will get
- * de-linked from the tree.
+ * must write-lock that page before releasing write lock on current
+ * page; else someone else's _bt_check_unique scan could fail to see
+ * our insertion. write locks on intermediate dead pages won't do
+ * because we don't know when they will get de-linked from the tree.
*/
rbuf = InvalidBuffer;
}
/*
- * Now we are on the right page, so find the insert position. If we
- * moved right at all, we know we should insert at the start of the
- * page. If we didn't move right, we can use the firstlegaloff hint
- * if the caller supplied one, unless we vacuumed the page which
- * might have moved tuples around making the hint invalid. If we
- * didn't move right or can't use the hint, find the position
- * by searching.
+ * Now we are on the right page, so find the insert position. If we moved
+ * right at all, we know we should insert at the start of the page. If we
+ * didn't move right, we can use the firstlegaloff hint if the caller
+ * supplied one, unless we vacuumed the page which might have moved tuples
+ * around making the hint invalid. If we didn't move right or can't use
+ * the hint, find the position by searching.
*/
if (movedright)
newitemoff = P_FIRSTDATAKEY(lpageop);
- else if(firstlegaloff != InvalidOffsetNumber && !vacuumed)
+ else if (firstlegaloff != InvalidOffsetNumber && !vacuumed)
newitemoff = firstlegaloff;
else
newitemoff = _bt_binsrch(rel, buf, keysz, scankey, false);
* the data by reinserting it into a new left page. (XXX the latter
* comment is probably obsolete.)
*
- * We need to do this before writing the WAL record, so that XLogInsert can
- * WAL log an image of the page if necessary.
+ * We need to do this before writing the WAL record, so that XLogInsert
+ * can WAL log an image of the page if necessary.
*/
PageRestoreTempPage(leftpage, origpage);
* Log the new item and its offset, if it was inserted on the left
* page. (If it was put on the right page, we don't need to explicitly
* WAL log it because it's included with all the other items on the
- * right page.) Show the new item as belonging to the left page buffer,
- * so that it is not stored if XLogInsert decides it needs a full-page
- * image of the left page. We store the offset anyway, though, to
- * support archive compression of these records.
+ * right page.) Show the new item as belonging to the left page
+ * buffer, so that it is not stored if XLogInsert decides it needs a
+ * full-page image of the left page. We store the offset anyway,
+ * though, to support archive compression of these records.
*/
if (newitemonleft)
{
lastrdata->data = (char *) newitem;
lastrdata->len = MAXALIGN(newitemsz);
- lastrdata->buffer = buf; /* backup block 1 */
+ lastrdata->buffer = buf; /* backup block 1 */
lastrdata->buffer_std = true;
}
else
{
/*
- * Although we don't need to WAL-log the new item, we still
- * need XLogInsert to consider storing a full-page image of the
- * left page, so make an empty entry referencing that buffer.
- * This also ensures that the left page is always backup block 1.
+ * Although we don't need to WAL-log the new item, we still need
+ * XLogInsert to consider storing a full-page image of the left
+ * page, so make an empty entry referencing that buffer. This also
+ * ensures that the left page is always backup block 1.
*/
lastrdata->next = lastrdata + 1;
lastrdata++;
lastrdata->data = NULL;
lastrdata->len = 0;
- lastrdata->buffer = buf; /* backup block 1 */
+ lastrdata->buffer = buf; /* backup block 1 */
lastrdata->buffer_std = true;
}
/*
* Log the contents of the right page in the format understood by
* _bt_restore_page(). We set lastrdata->buffer to InvalidBuffer,
- * because we're going to recreate the whole page anyway, so it
- * should never be stored by XLogInsert.
+ * because we're going to recreate the whole page anyway, so it should
+ * never be stored by XLogInsert.
*
* Direct access to page is not good but faster - we should implement
* some new func in page API. Note we only store the tuples
lastrdata->data = NULL;
lastrdata->len = 0;
- lastrdata->buffer = sbuf; /* backup block 2 */
+ lastrdata->buffer = sbuf; /* backup block 2 */
lastrdata->buffer_std = true;
}
olddataitemstoleft += itemsz;
}
- /* If the new item goes as the last item, check for splitting so that
- * all the old items go to the left page and the new item goes to the
- * right page.
+ /*
+ * If the new item goes as the last item, check for splitting so that all
+ * the old items go to the left page and the new item goes to the right
+ * page.
*/
if (newitemoff > maxoff && !goodenoughfound)
_bt_checksplitloc(&state, newitemoff, false, olddataitemstotal, 0);
int olddataitemstoleft,
Size firstoldonrightsz)
{
- int leftfree,
- rightfree;
- Size firstrightitemsz;
- bool newitemisfirstonright;
+ int leftfree,
+ rightfree;
+ Size firstrightitemsz;
+ bool newitemisfirstonright;
/* Is the new item going to be the first item on the right page? */
newitemisfirstonright = (firstoldonright == state->newitemoff
&& !newitemonleft);
- if(newitemisfirstonright)
+ if (newitemisfirstonright)
firstrightitemsz = state->newitemsz;
else
firstrightitemsz = firstoldonrightsz;
(state->olddataitemstotal - olddataitemstoleft);
/*
- * The first item on the right page becomes the high key of the
- * left page; therefore it counts against left space as well as right
- * space.
+ * The first item on the right page becomes the high key of the left page;
+ * therefore it counts against left space as well as right space.
*/
leftfree -= firstrightitemsz;
BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page);
/*
- * Scan over all items to see which ones need to be deleted
- * according to LP_DEAD flags.
+ * Scan over all items to see which ones need to be deleted according to
+ * LP_DEAD flags.
*/
minoff = P_FIRSTDATAKEY(opaque);
maxoff = PageGetMaxOffsetNumber(page);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.103 2007/09/12 22:10:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.104 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
/*
* In recovery mode, assume the deletion being replayed is valid. We
- * can't always check it because we won't have a full search stack,
- * and we should complain if there's a problem, anyway.
+ * can't always check it because we won't have a full search stack, and we
+ * should complain if there's a problem, anyway.
*/
if (InRecovery)
return true;
{
/*
* It's only child, so safe if parent would itself be removable.
- * We have to check the parent itself, and then recurse to
- * test the conditions at the parent's parent.
+ * We have to check the parent itself, and then recurse to test
+ * the conditions at the parent's parent.
*/
if (P_RIGHTMOST(opaque) || P_ISROOT(opaque))
{
targetkey = CopyIndexTuple((IndexTuple) PageGetItem(page, itemid));
/*
- * To avoid deadlocks, we'd better drop the target page lock before
- * going further.
+ * To avoid deadlocks, we'd better drop the target page lock before going
+ * further.
*/
_bt_relbuf(rel, buf);
/*
- * We need an approximate pointer to the page's parent page. We use
- * the standard search mechanism to search for the page's high key; this
- * will give us a link to either the current parent or someplace to its
- * left (if there are multiple equal high keys). In recursion cases,
- * the caller already generated a search stack and we can just re-use
- * that work.
+ * We need an approximate pointer to the page's parent page. We use the
+ * standard search mechanism to search for the page's high key; this will
+ * give us a link to either the current parent or someplace to its left
+ * (if there are multiple equal high keys). In recursion cases, the
+ * caller already generated a search stack and we can just re-use that
+ * work.
*/
if (stack == NULL)
{
/*
* During WAL recovery, we can't use _bt_search (for one reason,
* it might invoke user-defined comparison functions that expect
- * facilities not available in recovery mode). Instead, just
- * set up a dummy stack pointing to the left end of the parent
- * tree level, from which _bt_getstackbuf will walk right to the
- * parent page. Painful, but we don't care too much about
- * performance in this scenario.
+ * facilities not available in recovery mode). Instead, just set
+ * up a dummy stack pointing to the left end of the parent tree
+ * level, from which _bt_getstackbuf will walk right to the parent
+ * page. Painful, but we don't care too much about performance in
+ * this scenario.
*/
pbuf = _bt_get_endpoint(rel, targetlevel + 1, false);
stack = (BTStack) palloc(sizeof(BTStackData));
/*
* We cannot delete a page that is the rightmost child of its immediate
- * parent, unless it is the only child --- in which case the parent has
- * to be deleted too, and the same condition applies recursively to it.
- * We have to check this condition all the way up before trying to delete.
- * We don't need to re-test when deleting a non-leaf page, though.
+ * parent, unless it is the only child --- in which case the parent has to
+ * be deleted too, and the same condition applies recursively to it. We
+ * have to check this condition all the way up before trying to delete. We
+ * don't need to re-test when deleting a non-leaf page, though.
*/
if (targetlevel == 0 &&
!_bt_parent_deletion_safe(rel, target, stack))
* might be possible to push the fast root even further down, but the odds
* of doing so are slim, and the locking considerations daunting.)
*
- * We don't support handling this in the case where the parent is
- * becoming half-dead, even though it theoretically could occur.
+ * We don't support handling this in the case where the parent is becoming
+ * half-dead, even though it theoretically could occur.
*
* We can safely acquire a lock on the metapage here --- see comments for
* _bt_newroot().
_bt_relbuf(rel, lbuf);
/*
- * If parent became half dead, recurse to delete it. Otherwise, if
- * right sibling is empty and is now the last child of the parent, recurse
- * to try to delete it. (These cases cannot apply at the same time,
- * though the second case might itself recurse to the first.)
+ * If parent became half dead, recurse to delete it. Otherwise, if right
+ * sibling is empty and is now the last child of the parent, recurse to
+ * try to delete it. (These cases cannot apply at the same time, though
+ * the second case might itself recurse to the first.)
*
* When recursing to parent, we hold the lock on the target page until
* done. This delays any insertions into the keyspace that was just
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.113 2007/05/27 03:50:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.114 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* even if the row comparison is of ">" or "<" type, because the
* condition applied to all but the last row member is effectively
* ">=" or "<=", and so the extra keys don't break the positioning
- * scheme. But, by the same token, if we aren't able to use all
+ * scheme. But, by the same token, if we aren't able to use all
* the row members, then the part of the row comparison that we
- * did use has to be treated as just a ">=" or "<=" condition,
- * and so we'd better adjust strat_total accordingly.
+ * did use has to be treated as just a ">=" or "<=" condition, and
+ * so we'd better adjust strat_total accordingly.
*/
if (i == keysCount - 1)
{
bool used_all_subkeys = false;
Assert(!(subkey->sk_flags & SK_ROW_END));
- for(;;)
+ for (;;)
{
subkey++;
Assert(subkey->sk_flags & SK_ROW_MEMBER);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.86 2007/09/12 22:10:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.87 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* that's the only one returned. (So, we return either a single = key,
* or one or two boundary-condition keys for each attr.) However, if we
* cannot compare two keys for lack of a suitable cross-type operator,
- * we cannot eliminate either. If there are two such keys of the same
+ * we cannot eliminate either. If there are two such keys of the same
* operator strategy, the second one is just pushed into the output array
* without further processing here. We may also emit both >/>= or both
* </<= keys if we can't compare them. The logic about required keys still
{
/*
* We treat all btree operators as strict (even if they're not so
- * marked in pg_proc). This means that it is impossible for an
- * operator condition with a NULL comparison constant to succeed,
- * and we can reject it right away.
+ * marked in pg_proc). This means that it is impossible for an
+ * operator condition with a NULL comparison constant to succeed, and
+ * we can reject it right away.
*
* However, we now also support "x IS NULL" clauses as search
- * conditions, so in that case keep going. The planner has not
- * filled in any particular strategy in this case, so set it to
+ * conditions, so in that case keep going. The planner has not filled
+ * in any particular strategy in this case, so set it to
* BTEqualStrategyNumber --- we can treat IS NULL as an equality
* operator for purposes of search strategy.
*/
/*
* Initialize for processing of keys for attr 1.
*
- * xform[i] points to the currently best scan key of strategy type i+1;
- * it is NULL if we haven't yet found such a key for this attr.
+ * xform[i] points to the currently best scan key of strategy type i+1; it
+ * is NULL if we haven't yet found such a key for this attr.
*/
attno = 1;
memset(xform, 0, sizeof(xform));
memcpy(outkey, cur, sizeof(ScanKeyData));
if (numberOfEqualCols == attno - 1)
_bt_mark_scankey_required(outkey);
+
/*
* We don't support RowCompare using equality; such a qual would
* mess up the numberOfEqualCols tracking.
else
{
/*
- * We can't determine which key is more restrictive. Keep
- * the previous one in xform[j] and push this one directly
- * to the output array.
+ * We can't determine which key is more restrictive. Keep the
+ * previous one in xform[j] and push this one directly to the
+ * output array.
*/
ScanKey outkey = &outkeys[new_numberOfKeys++];
* and amoplefttype/amoprighttype equal to the two argument datatypes.
*
* If the opfamily doesn't supply a complete set of cross-type operators we
- * may not be able to make the comparison. If we can make the comparison
+ * may not be able to make the comparison. If we can make the comparison
* we store the operator result in *result and return TRUE. We return FALSE
* if the comparison could not be made.
*
* indexscan initiated by syscache lookup will use cross-data-type
* operators.)
*
- * If the sk_strategy was flipped by _bt_mark_scankey_with_indoption,
- * we have to un-flip it to get the correct opfamily member.
+ * If the sk_strategy was flipped by _bt_mark_scankey_with_indoption, we
+ * have to un-flip it to get the correct opfamily member.
*/
strat = op->sk_strategy;
if (op->sk_flags & SK_BT_DESC)
static void
_bt_mark_scankey_with_indoption(ScanKey skey, int16 *indoption)
{
- int addflags;
+ int addflags;
addflags = indoption[skey->sk_attno - 1] << SK_BT_INDOPTION_SHIFT;
if ((addflags & SK_BT_DESC) && !(skey->sk_flags & SK_BT_DESC))
/*
* Since NULLs are sorted before non-NULLs, we know we have
* reached the lower limit of the range of values for this
- * index attr. On a backward scan, we can stop if this qual is
- * one of the "must match" subset. On a forward scan,
+ * index attr. On a backward scan, we can stop if this qual
+ * is one of the "must match" subset. On a forward scan,
* however, we should keep going.
*/
if ((key->sk_flags & SK_BT_REQBKWD) &&
/*
* Since NULLs are sorted after non-NULLs, we know we have
* reached the upper limit of the range of values for this
- * index attr. On a forward scan, we can stop if this qual is
- * one of the "must match" subset. On a backward scan,
+ * index attr. On a forward scan, we can stop if this qual is
+ * one of the "must match" subset. On a backward scan,
* however, we should keep going.
*/
if ((key->sk_flags & SK_BT_REQFWD) &&
* Since NULLs are sorted before non-NULLs, we know we have
* reached the lower limit of the range of values for this
* index attr. On a backward scan, we can stop if this qual is
- * one of the "must match" subset. On a forward scan,
+ * one of the "must match" subset. On a forward scan,
* however, we should keep going.
*/
if ((subkey->sk_flags & SK_BT_REQBKWD) &&
* Since NULLs are sorted after non-NULLs, we know we have
* reached the upper limit of the range of values for this
* index attr. On a forward scan, we can stop if this qual is
- * one of the "must match" subset. On a backward scan,
+ * one of the "must match" subset. On a backward scan,
* however, we should keep going.
*/
if ((subkey->sk_flags & SK_BT_REQFWD) &&
LWLockAcquire(BtreeVacuumLock, LW_EXCLUSIVE);
/*
- * Assign the next cycle ID, being careful to avoid zero as well as
- * the reserved high values.
+ * Assign the next cycle ID, being careful to avoid zero as well as the
+ * reserved high values.
*/
result = ++(btvacinfo->cycle_ctr);
if (result == 0 || result > MAX_BT_CYCLE_ID)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.46 2007/09/20 17:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.47 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
BlockNumber rightblk; /* right half of split */
/* these fields are for a delete: */
BlockNumber delblk; /* parent block to be deleted */
-} bt_incomplete_action;
+} bt_incomplete_action;
static List *incomplete_actions;
char *datapos;
int datalen;
OffsetNumber newitemoff = 0;
- Item newitem = NULL;
- Size newitemsz = 0;
+ Item newitem = NULL;
+ Size newitemsz = 0;
reln = XLogOpenRelation(xlrec->node);
* Reconstruct left (original) sibling if needed. Note that this code
* ensures that the items remaining on the left page are in the correct
* item number order, but it does not reproduce the physical order they
- * would have had. Is this worth changing? See also _bt_restore_page().
+ * would have had. Is this worth changing? See also _bt_restore_page().
*/
if (!(record->xl_info & XLR_BKP_BLOCK_1))
{
- Buffer lbuf = XLogReadBuffer(reln, xlrec->leftsib, false);
+ Buffer lbuf = XLogReadBuffer(reln, xlrec->leftsib, false);
if (BufferIsValid(lbuf))
{
- Page lpage = (Page) BufferGetPage(lbuf);
+ Page lpage = (Page) BufferGetPage(lbuf);
BTPageOpaque lopaque = (BTPageOpaque) PageGetSpecialPointer(lpage);
if (!XLByteLE(lsn, PageGetLSN(lpage)))
OffsetNumber off;
OffsetNumber maxoff = PageGetMaxOffsetNumber(lpage);
OffsetNumber deletable[MaxOffsetNumber];
- int ndeletable = 0;
- ItemId hiItemId;
- Item hiItem;
+ int ndeletable = 0;
+ ItemId hiItemId;
+ Item hiItem;
/*
- * Remove the items from the left page that were copied to
- * the right page. Also remove the old high key, if any.
- * (We must remove everything before trying to insert any
- * items, else we risk not having enough space.)
+ * Remove the items from the left page that were copied to the
+ * right page. Also remove the old high key, if any. (We must
+ * remove everything before trying to insert any items, else
+ * we risk not having enough space.)
*/
if (!P_RIGHTMOST(lopaque))
{
deletable[ndeletable++] = P_HIKEY;
+
/*
* newitemoff is given to us relative to the original
* page's item numbering, so adjust it for this deletion.
/* Fix left-link of the page to the right of the new right sibling */
if (xlrec->rnext != P_NONE && !(record->xl_info & XLR_BKP_BLOCK_2))
{
- Buffer buffer = XLogReadBuffer(reln, xlrec->rnext, false);
+ Buffer buffer = XLogReadBuffer(reln, xlrec->rnext, false);
if (BufferIsValid(buffer))
{
- Page page = (Page) BufferGetPage(buffer);
+ Page page = (Page) BufferGetPage(buffer);
if (!XLByteLE(lsn, PageGetLSN(page)))
{
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode);
appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
- xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
+ xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
xlrec->level, xlrec->firstright);
break;
}
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode);
appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
- xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
+ xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
xlrec->level, xlrec->firstright);
break;
}
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode);
appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
- xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
+ xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
xlrec->level, xlrec->firstright);
break;
}
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode);
appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
- xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
+ xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
xlrec->level, xlrec->firstright);
break;
}
* CLOG page is initialized to zeroes. Other writes of CLOG come from
* recording of transaction commit or abort in xact.c, which generates its
* own XLOG records for these events and will re-perform the status update
- * on redo; so we need make no additional XLOG entry here. For synchronous
+ * on redo; so we need make no additional XLOG entry here. For synchronous
* transaction commits, the XLOG is guaranteed flushed through the XLOG commit
* record before we are called to log a commit, so the WAL rule "write xlog
* before data" is satisfied automatically. However, for async commits we
* must track the latest LSN affecting each CLOG page, so that we can flush
- * XLOG that far and satisfy the WAL rule. We don't have to worry about this
+ * XLOG that far and satisfy the WAL rule. We don't have to worry about this
* for aborts (whether sync or async), since the post-crash assumption would
* be that such transactions failed anyway.
*
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.44 2007/09/05 18:10:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.45 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
/* We store the latest async LSN for each group of transactions */
-#define CLOG_XACTS_PER_LSN_GROUP 32 /* keep this a power of 2 */
-#define CLOG_LSNS_PER_PAGE (CLOG_XACTS_PER_PAGE / CLOG_XACTS_PER_LSN_GROUP)
+#define CLOG_XACTS_PER_LSN_GROUP 32 /* keep this a power of 2 */
+#define CLOG_LSNS_PER_PAGE (CLOG_XACTS_PER_PAGE / CLOG_XACTS_PER_LSN_GROUP)
#define GetLSNIndex(slotno, xid) ((slotno) * CLOG_LSNS_PER_PAGE + \
((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) / CLOG_XACTS_PER_LSN_GROUP)
* Record the final state of a transaction in the commit log.
*
* lsn must be the WAL location of the commit record when recording an async
- * commit. For a synchronous commit it can be InvalidXLogRecPtr, since the
+ * commit. For a synchronous commit it can be InvalidXLogRecPtr, since the
* caller guarantees the commit record is already flushed in that case. It
* should be InvalidXLogRecPtr for abort cases, too.
*
* an LSN that is late enough to be able to guarantee that if we flush up to
* that LSN then we will have flushed the transaction's commit record to disk.
* The result is not necessarily the exact LSN of the transaction's commit
- * record! For example, for long-past transactions (those whose clog pages
+ * record! For example, for long-past transactions (those whose clog pages
* already migrated to disk), we'll return InvalidXLogRecPtr. Also, because
* we group transactions on the same clog page to conserve storage, we might
* return the LSN of a later transaction that falls into the same group.
memcpy(&pageno, XLogRecGetData(record), sizeof(int));
/*
- * During XLOG replay, latest_page_number isn't set up yet; insert
- * a suitable value to bypass the sanity test in SimpleLruTruncate.
+ * During XLOG replay, latest_page_number isn't set up yet; insert a
+ * suitable value to bypass the sanity test in SimpleLruTruncate.
*/
ClogCtl->shared->latest_page_number = pageno;
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.25 2007/09/05 18:10:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.26 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
/*
- * Checking for myself is cheap compared to looking in shared memory,
- * so first do the equivalent of MultiXactIdIsCurrent(). This is not
- * needed for correctness, it's just a fast path.
+ * Checking for myself is cheap compared to looking in shared memory, so
+ * first do the equivalent of MultiXactIdIsCurrent(). This is not needed
+ * for correctness, it's just a fast path.
*/
for (i = 0; i < nmembers; i++)
{
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.71 2007/09/08 20:31:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.72 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* This file contains the high level access-method interface to the
TransactionIdLatest(TransactionId mainxid,
int nxids, const TransactionId *xids)
{
- TransactionId result;
+ TransactionId result;
/*
- * In practice it is highly likely that the xids[] array is sorted, and
- * so we could save some cycles by just taking the last child XID, but
- * this probably isn't so performance-critical that it's worth depending
- * on that assumption. But just to show we're not totally stupid, scan
- * the array back-to-front to avoid useless assignments.
+ * In practice it is highly likely that the xids[] array is sorted, and so
+ * we could save some cycles by just taking the last child XID, but this
+ * probably isn't so performance-critical that it's worth depending on
+ * that assumption. But just to show we're not totally stupid, scan the
+ * array back-to-front to avoid useless assignments.
*/
result = mainxid;
while (--nxids >= 0)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.37 2007/10/24 20:55:36 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.38 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* Each global transaction is associated with a global transaction
errhint("Must be superuser or the user that prepared the transaction.")));
/*
- * Note: it probably would be possible to allow committing from another
- * database; but at the moment NOTIFY is known not to work and there
- * may be some other issues as well. Hence disallow until someone
- * gets motivated to make it work.
+ * Note: it probably would be possible to allow committing from
+ * another database; but at the moment NOTIFY is known not to work and
+ * there may be some other issues as well. Hence disallow until
+ * someone gets motivated to make it work.
*/
if (MyDatabaseId != gxact->proc.databaseId)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("prepared transaction belongs to another database"),
+ errmsg("prepared transaction belongs to another database"),
errhint("Connect to the database where the transaction was prepared to finish it.")));
/* OK for me to lock it */
* odds of a PANIC actually occurring should be very tiny given that we
* were able to write the bogus CRC above.
*
- * We have to set inCommit here, too; otherwise a checkpoint
- * starting immediately after the WAL record is inserted could complete
- * without fsync'ing our state file. (This is essentially the same kind
- * of race condition as the COMMIT-to-clog-write case that
- * RecordTransactionCommit uses inCommit for; see notes there.)
+ * We have to set inCommit here, too; otherwise a checkpoint starting
+ * immediately after the WAL record is inserted could complete without
+ * fsync'ing our state file. (This is essentially the same kind of race
+ * condition as the COMMIT-to-clog-write case that RecordTransactionCommit
+ * uses inCommit for; see notes there.)
*
* We save the PREPARE record's location in the gxact for later use by
* CheckPointTwoPhase.
MarkAsPrepared(gxact);
/*
- * Now we can mark ourselves as out of the commit critical section:
- * a checkpoint starting after this will certainly see the gxact as a
+ * Now we can mark ourselves as out of the commit critical section: a
+ * checkpoint starting after this will certainly see the gxact as a
* candidate for fsyncing.
*/
MyProc->inCommit = false;
if (errno != ENOENT || giveWarning)
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not remove two-phase state file \"%s\": %m",
- path)));
+ errmsg("could not remove two-phase state file \"%s\": %m",
+ path)));
}
/*
if (buf == NULL)
{
ereport(WARNING,
- (errmsg("removing corrupt two-phase state file \"%s\"",
- clde->d_name)));
+ (errmsg("removing corrupt two-phase state file \"%s\"",
+ clde->d_name)));
RemoveTwoPhaseFile(xid, true);
continue;
}
if (!TransactionIdEquals(hdr->xid, xid))
{
ereport(WARNING,
- (errmsg("removing corrupt two-phase state file \"%s\"",
- clde->d_name)));
+ (errmsg("removing corrupt two-phase state file \"%s\"",
+ clde->d_name)));
RemoveTwoPhaseFile(xid, true);
pfree(buf);
continue;
if (buf == NULL)
{
ereport(WARNING,
- (errmsg("removing corrupt two-phase state file \"%s\"",
- clde->d_name)));
+ (errmsg("removing corrupt two-phase state file \"%s\"",
+ clde->d_name)));
RemoveTwoPhaseFile(xid, true);
continue;
}
recptr = XLogInsert(RM_XACT_ID, XLOG_XACT_COMMIT_PREPARED, rdata);
/*
- * We don't currently try to sleep before flush here ... nor is there
- * any support for async commit of a prepared xact (the very idea is
- * probably a contradiction)
+ * We don't currently try to sleep before flush here ... nor is there any
+ * support for async commit of a prepared xact (the very idea is probably
+ * a contradiction)
*/
/* Flush XLOG to disk */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.5 2007/05/27 03:50:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.6 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
lock_twophase_postcommit, /* Lock */
inval_twophase_postcommit, /* Inval */
flatfile_twophase_postcommit, /* flat file update */
- notify_twophase_postcommit, /* notify/listen */
+ notify_twophase_postcommit, /* notify/listen */
pgstat_twophase_postcommit /* pgstat */
};
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.79 2007/09/08 20:31:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.80 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
TransactionIdIsValid(ShmemVariableCache->xidVacLimit))
{
/*
- * To avoid swamping the postmaster with signals, we issue the
- * autovac request only once per 64K transaction starts. This
- * still gives plenty of chances before we get into real trouble.
+ * To avoid swamping the postmaster with signals, we issue the autovac
+ * request only once per 64K transaction starts. This still gives
+ * plenty of chances before we get into real trouble.
*/
if (IsUnderPostmaster && (xid % 65536) == 0)
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
/*
* We must store the new XID into the shared ProcArray before releasing
- * XidGenLock. This ensures that every active XID older than
- * latestCompletedXid is present in the ProcArray, which is essential
- * for correct OldestXmin tracking; see src/backend/access/transam/README.
+ * XidGenLock. This ensures that every active XID older than
+ * latestCompletedXid is present in the ProcArray, which is essential for
+ * correct OldestXmin tracking; see src/backend/access/transam/README.
*
* XXX by storing xid into MyProc without acquiring ProcArrayLock, we are
* relying on fetch/store of an xid to be atomic, else other backends
xidWarnLimit -= FirstNormalTransactionId;
/*
- * We'll start trying to force autovacuums when oldest_datfrozenxid
- * gets to be more than autovacuum_freeze_max_age transactions old.
+ * We'll start trying to force autovacuums when oldest_datfrozenxid gets
+ * to be more than autovacuum_freeze_max_age transactions old.
*
- * Note: guc.c ensures that autovacuum_freeze_max_age is in a sane
- * range, so that xidVacLimit will be well before xidWarnLimit.
+ * Note: guc.c ensures that autovacuum_freeze_max_age is in a sane range,
+ * so that xidVacLimit will be well before xidWarnLimit.
*
* Note: autovacuum_freeze_max_age is a PGC_POSTMASTER parameter so that
* we don't have to worry about dealing with on-the-fly changes in its
* value. It doesn't look practical to update shared state from a GUC
* assign hook (too many processes would try to execute the hook,
- * resulting in race conditions as well as crashes of those not
- * connected to shared memory). Perhaps this can be improved someday.
+ * resulting in race conditions as well as crashes of those not connected
+ * to shared memory). Perhaps this can be improved someday.
*/
xidVacLimit = oldest_datfrozenxid + autovacuum_freeze_max_age;
if (xidVacLimit < FirstNormalTransactionId)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.252 2007/11/10 14:36:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.253 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
TransactionState s = CurrentTransactionState;
/*
- * TRANS_DEFAULT and TRANS_ABORT are obviously unsafe states. However,
- * we also reject the startup/shutdown states TRANS_START, TRANS_COMMIT,
+ * TRANS_DEFAULT and TRANS_ABORT are obviously unsafe states. However, we
+ * also reject the startup/shutdown states TRANS_START, TRANS_COMMIT,
* TRANS_PREPARE since it might be too soon or too late within those
* transition states to do anything interesting. Hence, the only "valid"
* state is TRANS_INPROGRESS.
static void
AssignTransactionId(TransactionState s)
{
- bool isSubXact = (s->parent != NULL);
+ bool isSubXact = (s->parent != NULL);
ResourceOwner currentOwner;
/* Assert that caller didn't screw up */
SubTransSetParent(s->transactionId, s->parent->transactionId);
/*
- * Acquire lock on the transaction XID. (We assume this cannot block.)
- * We have to ensure that the lock is assigned to the transaction's
- * own ResourceOwner.
+ * Acquire lock on the transaction XID. (We assume this cannot block.) We
+ * have to ensure that the lock is assigned to the transaction's own
+ * ResourceOwner.
*/
currentOwner = CurrentResourceOwner;
PG_TRY();
/*
* If this is the first time through, create a private context for
* AbortTransaction to work in. By reserving some space now, we can
- * insulate AbortTransaction from out-of-memory scenarios. Like
- * ErrorContext, we set it up with slow growth rate and a nonzero
- * minimum size, so that space will be reserved immediately.
+ * insulate AbortTransaction from out-of-memory scenarios. Like
+ * ErrorContext, we set it up with slow growth rate and a nonzero minimum
+ * size, so that space will be reserved immediately.
*/
if (TransactionAbortContext == NULL)
TransactionAbortContext =
* RecordTransactionCommit
*
* Returns latest XID among xact and its children, or InvalidTransactionId
- * if the xact has no XID. (We compute that here just because it's easier.)
+ * if the xact has no XID. (We compute that here just because it's easier.)
*
* This is exported only to support an ugly hack in VACUUM FULL.
*/
RecordTransactionCommit(void)
{
TransactionId xid = GetTopTransactionIdIfAny();
- bool markXidCommitted = TransactionIdIsValid(xid);
+ bool markXidCommitted = TransactionIdIsValid(xid);
TransactionId latestXid = InvalidTransactionId;
int nrels;
RelFileNode *rels;
nchildren = xactGetCommittedChildren(&children);
/*
- * If we haven't been assigned an XID yet, we neither can, nor do we
- * want to write a COMMIT record.
+ * If we haven't been assigned an XID yet, we neither can, nor do we want
+ * to write a COMMIT record.
*/
if (!markXidCommitted)
{
/*
* We expect that every smgrscheduleunlink is followed by a catalog
- * update, and hence XID assignment, so we shouldn't get here with
- * any pending deletes. Use a real test not just an Assert to check
- * this, since it's a bit fragile.
+ * update, and hence XID assignment, so we shouldn't get here with any
+ * pending deletes. Use a real test not just an Assert to check this,
+ * since it's a bit fragile.
*/
if (nrels != 0)
elog(ERROR, "cannot commit a transaction that deleted files but has no xid");
/* Can't have child XIDs either; AssignTransactionId enforces this */
Assert(nchildren == 0);
-
+
/*
* If we didn't create XLOG entries, we're done here; otherwise we
- * should flush those entries the same as a commit record. (An
+ * should flush those entries the same as a commit record. (An
* example of a possible record that wouldn't cause an XID to be
- * assigned is a sequence advance record due to nextval() --- we
- * want to flush that to disk before reporting commit.)
+ * assigned is a sequence advance record due to nextval() --- we want
+ * to flush that to disk before reporting commit.)
*/
if (XactLastRecEnd.xrecoff == 0)
goto cleanup;
/*
* Begin commit critical section and insert the commit XLOG record.
*/
- XLogRecData rdata[3];
- int lastrdata = 0;
- xl_xact_commit xlrec;
+ XLogRecData rdata[3];
+ int lastrdata = 0;
+ xl_xact_commit xlrec;
/* Tell bufmgr and smgr to prepare for commit */
BufmgrCommit();
/*
- * Mark ourselves as within our "commit critical section". This
+ * Mark ourselves as within our "commit critical section". This
* forces any concurrent checkpoint to wait until we've updated
- * pg_clog. Without this, it is possible for the checkpoint to
- * set REDO after the XLOG record but fail to flush the pg_clog
- * update to disk, leading to loss of the transaction commit if
- * the system crashes a little later.
+ * pg_clog. Without this, it is possible for the checkpoint to set
+ * REDO after the XLOG record but fail to flush the pg_clog update to
+ * disk, leading to loss of the transaction commit if the system
+ * crashes a little later.
*
* Note: we could, but don't bother to, set this flag in
- * RecordTransactionAbort. That's because loss of a transaction
- * abort is noncritical; the presumption would be that it aborted,
- * anyway.
+ * RecordTransactionAbort. That's because loss of a transaction abort
+ * is noncritical; the presumption would be that it aborted, anyway.
*
- * It's safe to change the inCommit flag of our own backend
- * without holding the ProcArrayLock, since we're the only one
- * modifying it. This makes checkpoint's determination of which
- * xacts are inCommit a bit fuzzy, but it doesn't matter.
+ * It's safe to change the inCommit flag of our own backend without
+ * holding the ProcArrayLock, since we're the only one modifying it.
+ * This makes checkpoint's determination of which xacts are inCommit a
+ * bit fuzzy, but it doesn't matter.
*/
START_CRIT_SECTION();
MyProc->inCommit = true;
* Check if we want to commit asynchronously. If the user has set
* synchronous_commit = off, and we're not doing cleanup of any non-temp
* rels nor committing any command that wanted to force sync commit, then
- * we can defer flushing XLOG. (We must not allow asynchronous commit if
+ * we can defer flushing XLOG. (We must not allow asynchronous commit if
* there are any non-temp tables to be deleted, because we might delete
* the files before the COMMIT record is flushed to disk. We do allow
* asynchronous commit if all to-be-deleted tables are temporary though,
/*
* Synchronous commit case.
*
- * Sleep before flush! So we can flush more than one commit
- * records per single fsync. (The idea is some other backend
- * may do the XLogFlush while we're sleeping. This needs work
- * still, because on most Unixen, the minimum select() delay
- * is 10msec or more, which is way too long.)
+ * Sleep before flush! So we can flush more than one commit records
+ * per single fsync. (The idea is some other backend may do the
+ * XLogFlush while we're sleeping. This needs work still, because on
+ * most Unixen, the minimum select() delay is 10msec or more, which is
+ * way too long.)
*
- * We do not sleep if enableFsync is not turned on, nor if
- * there are fewer than CommitSiblings other backends with
- * active transactions.
+ * We do not sleep if enableFsync is not turned on, nor if there are
+ * fewer than CommitSiblings other backends with active transactions.
*/
if (CommitDelay > 0 && enableFsync &&
CountActiveBackends() >= CommitSiblings)
/*
* Asynchronous commit case.
*
- * Report the latest async commit LSN, so that
- * the WAL writer knows to flush this commit.
+ * Report the latest async commit LSN, so that the WAL writer knows to
+ * flush this commit.
*/
XLogSetAsyncCommitLSN(XactLastRecEnd);
/*
- * We must not immediately update the CLOG, since we didn't
- * flush the XLOG. Instead, we store the LSN up to which
- * the XLOG must be flushed before the CLOG may be updated.
+ * We must not immediately update the CLOG, since we didn't flush the
+ * XLOG. Instead, we store the LSN up to which the XLOG must be
+ * flushed before the CLOG may be updated.
*/
if (markXidCommitted)
{
}
/*
- * If we entered a commit critical section, leave it now, and
- * let checkpoints proceed.
+ * If we entered a commit critical section, leave it now, and let
+ * checkpoints proceed.
*/
if (markXidCommitted)
{
* We do not log the subcommit in XLOG; it doesn't matter until the
* top-level transaction commits.
*
- * We must mark the subtransaction subcommitted in the CLOG if
- * it had a valid XID assigned. If it did not, nobody else will
- * ever know about the existence of this subxact. We don't
- * have to deal with deletions scheduled for on-commit here, since
- * they'll be reassigned to our parent (who might still abort).
+ * We must mark the subtransaction subcommitted in the CLOG if it had a
+ * valid XID assigned. If it did not, nobody else will ever know about
+ * the existence of this subxact. We don't have to deal with deletions
+ * scheduled for on-commit here, since they'll be reassigned to our parent
+ * (who might still abort).
*/
if (TransactionIdIsValid(xid))
{
* RecordTransactionAbort
*
* Returns latest XID among xact and its children, or InvalidTransactionId
- * if the xact has no XID. (We compute that here just because it's easier.)
+ * if the xact has no XID. (We compute that here just because it's easier.)
*/
static TransactionId
RecordTransactionAbort(bool isSubXact)
RelFileNode *rels;
int nchildren;
TransactionId *children;
- XLogRecData rdata[3];
- int lastrdata = 0;
- xl_xact_abort xlrec;
+ XLogRecData rdata[3];
+ int lastrdata = 0;
+ xl_xact_abort xlrec;
/*
- * If we haven't been assigned an XID, nobody will care whether we
- * aborted or not. Hence, we're done in that case. It does not matter
- * if we have rels to delete (note that this routine is not responsible
- * for actually deleting 'em). We cannot have any child XIDs, either.
+ * If we haven't been assigned an XID, nobody will care whether we aborted
+ * or not. Hence, we're done in that case. It does not matter if we have
+ * rels to delete (note that this routine is not responsible for actually
+ * deleting 'em). We cannot have any child XIDs, either.
*/
if (!TransactionIdIsValid(xid))
{
* We have a valid XID, so we should write an ABORT record for it.
*
* We do not flush XLOG to disk here, since the default assumption after a
- * crash would be that we aborted, anyway. For the same reason, we don't
+ * crash would be that we aborted, anyway. For the same reason, we don't
* need to worry about interlocking against checkpoint start.
*/
* having flushed the ABORT record to disk, because in event of a crash
* we'd be assumed to have aborted anyway.
*
- * The ordering here isn't critical but it seems best to mark the
- * parent first. This assures an atomic transition of all the
- * subtransactions to aborted state from the point of view of
- * concurrent TransactionIdDidAbort calls.
+ * The ordering here isn't critical but it seems best to mark the parent
+ * first. This assures an atomic transition of all the subtransactions to
+ * aborted state from the point of view of concurrent
+ * TransactionIdDidAbort calls.
*/
TransactionIdAbort(xid);
TransactionIdAbortTree(nchildren, children);
AtAbort_Memory(void)
{
/*
- * Switch into TransactionAbortContext, which should have some free
- * space even if nothing else does. We'll work in this context until
- * we've finished cleaning up.
+ * Switch into TransactionAbortContext, which should have some free space
+ * even if nothing else does. We'll work in this context until we've
+ * finished cleaning up.
*
* It is barely possible to get here when we've not been able to create
* TransactionAbortContext yet; if so use TopMemoryContext.
VirtualXactLockTableInsert(vxid);
/*
- * Advertise it in the proc array. We assume assignment of
+ * Advertise it in the proc array. We assume assignment of
* LocalTransactionID is atomic, and the backendId should be set already.
*/
Assert(MyProc->backendId == vxid.backendId);
/*
* set transaction_timestamp() (a/k/a now()). We want this to be the same
* as the first command's statement_timestamp(), so don't do a fresh
- * GetCurrentTimestamp() call (which'd be expensive anyway). Also,
- * mark xactStopTimestamp as unset.
+ * GetCurrentTimestamp() call (which'd be expensive anyway). Also, mark
+ * xactStopTimestamp as unset.
*/
xactStartTimestamp = stmtStartTimestamp;
xactStopTimestamp = 0;
PG_TRACE1(transaction__commit, MyProc->lxid);
/*
- * Let others know about no transaction in progress by me. Note that
- * this must be done _before_ releasing locks we hold and _after_
+ * Let others know about no transaction in progress by me. Note that this
+ * must be done _before_ releasing locks we hold and _after_
* RecordTransactionCommit.
*/
ProcArrayEndTransaction(MyProc, latestXid);
* inside a function or multi-query querystring. (We will always fail if
* this is false, but it's convenient to centralize the check here instead of
* making callers do it.)
- * stmtType: statement type name, for error messages.
+ * stmtType: statement type name, for error messages.
*/
void
PreventTransactionChain(bool isTopLevel, const char *stmtType)
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.287 2007/11/15 20:36:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.288 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* future XLOG segment as long as there aren't already XLOGfileslop future
* segments; else we'll delete it. This could be made a separate GUC
* variable, but at present I think it's sufficient to hardwire it as
- * 2*CheckPointSegments+1. Under normal conditions, a checkpoint will free
+ * 2*CheckPointSegments+1. Under normal conditions, a checkpoint will free
* no more than 2*CheckPointSegments log segments, and we want to recycle all
* of them; the +1 allows boundary cases to happen without wasting a
* delete/create-segment cycle.
XLogwrtResult LogwrtResult;
uint32 ckptXidEpoch; /* nextXID & epoch of latest checkpoint */
TransactionId ckptXid;
- XLogRecPtr asyncCommitLSN; /* LSN of newest async commit */
+ XLogRecPtr asyncCommitLSN; /* LSN of newest async commit */
/* Protected by WALWriteLock: */
XLogCtlWrite Write;
* full-block records into the non-full-block format.
*
* Note: we could just set the flag whenever !forcePageWrites, but
- * defining it like this leaves the info bit free for some potential
- * other use in records without any backup blocks.
+ * defining it like this leaves the info bit free for some potential other
+ * use in records without any backup blocks.
*/
if ((info & XLR_BKP_BLOCK_MASK) && !Insert->forcePageWrites)
info |= XLR_BKP_REMOVABLE;
XLogCheckpointNeeded(void)
{
/*
- * A straight computation of segment number could overflow 32
- * bits. Rather than assuming we have working 64-bit
- * arithmetic, we compare the highest-order bits separately,
- * and force a checkpoint immediately when they change.
+ * A straight computation of segment number could overflow 32 bits.
+ * Rather than assuming we have working 64-bit arithmetic, we compare the
+ * highest-order bits separately, and force a checkpoint immediately when
+ * they change.
*/
uint32 old_segno,
new_segno;
new_segno = (openLogId % XLogSegSize) * XLogSegsPerFile + openLogSeg;
new_highbits = openLogId / XLogSegSize;
if (new_highbits != old_highbits ||
- new_segno >= old_segno + (uint32) (CheckPointSegments-1))
+ new_segno >= old_segno + (uint32) (CheckPointSegments - 1))
return true;
return false;
}
/*
* Signal bgwriter to start a checkpoint if we've consumed too
* much xlog since the last one. For speed, we first check
- * using the local copy of RedoRecPtr, which might be
- * out of date; if it looks like a checkpoint is needed,
- * forcibly update RedoRecPtr and recheck.
+ * using the local copy of RedoRecPtr, which might be out of
+ * date; if it looks like a checkpoint is needed, forcibly
+ * update RedoRecPtr and recheck.
*/
if (IsUnderPostmaster &&
XLogCheckpointNeeded())
* We normally flush only completed blocks; but if there is nothing to do on
* that basis, we check for unflushed async commits in the current incomplete
* block, and flush through the latest one of those. Thus, if async commits
- * are not being used, we will flush complete blocks only. We can guarantee
+ * are not being used, we will flush complete blocks only. We can guarantee
* that async commits reach disk after at most three cycles; normally only
- * one or two. (We allow XLogWrite to write "flexibly", meaning it can stop
+ * one or two. (We allow XLogWrite to write "flexibly", meaning it can stop
* at the end of the buffer ring; this makes a difference only with very high
* load or long wal_writer_delay, but imposes one extra cycle for the worst
* case for async commits.)
XLogAsyncCommitFlush(void)
{
XLogRecPtr WriteRqstPtr;
+
/* use volatile pointer to prevent code rearrangement */
volatile XLogCtlData *xlogctl = XLogCtl;
LWLockRelease(ControlFileLock);
return false;
}
-#endif /* WIN32 */
+#endif /* WIN32 */
ereport(ERROR,
(errcode_for_file_access(),
int rc;
bool signaled;
struct stat stat_buf;
- uint32 restartLog;
- uint32 restartSeg;
+ uint32 restartLog;
+ uint32 restartSeg;
/*
* When doing archive recovery, we always prefer an archived log file even
sp++;
XLByteToSeg(ControlFile->checkPointCopy.redo,
restartLog, restartSeg);
- XLogFileName(lastRestartPointFname,
- ControlFile->checkPointCopy.ThisTimeLineID,
+ XLogFileName(lastRestartPointFname,
+ ControlFile->checkPointCopy.ThisTimeLineID,
restartLog, restartSeg);
StrNCpy(dp, lastRestartPointFname, endp - dp);
dp += strlen(dp);
* incorrectly. We have to assume the former.
*
* However, if the failure was due to any sort of signal, it's best to
- * punt and abort recovery. (If we "return false" here, upper levels
- * will assume that recovery is complete and start up the database!)
- * It's essential to abort on child SIGINT and SIGQUIT, because per spec
+ * punt and abort recovery. (If we "return false" here, upper levels will
+ * assume that recovery is complete and start up the database!) It's
+ * essential to abort on child SIGINT and SIGQUIT, because per spec
* system() ignores SIGINT and SIGQUIT while waiting; if we see one of
* those it's a good bet we should have gotten it too. Aborting on other
* signals such as SIGTERM seems a good idea as well.
*
- * Per the Single Unix Spec, shells report exit status > 128 when
- * a called command died on a signal. Also, 126 and 127 are used to
- * report problems such as an unfindable command; treat those as fatal
- * errors too.
+ * Per the Single Unix Spec, shells report exit status > 128 when a called
+ * command died on a signal. Also, 126 and 127 are used to report
+ * problems such as an unfindable command; treat those as fatal errors
+ * too.
*/
signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125;
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with TOAST_MAX_CHUNK_SIZE %d,"
- " but the server was compiled with TOAST_MAX_CHUNK_SIZE %d.",
- ControlFile->toast_max_chunk_size, (int) TOAST_MAX_CHUNK_SIZE),
+ " but the server was compiled with TOAST_MAX_CHUNK_SIZE %d.",
+ ControlFile->toast_max_chunk_size, (int) TOAST_MAX_CHUNK_SIZE),
errhint("It looks like you need to recompile or initdb.")));
#ifdef HAVE_INT64_TIMESTAMP
*/
recoveryTargetTime =
DatumGetTimestampTz(DirectFunctionCall3(timestamptz_in,
- CStringGetDatum(tok2),
+ CStringGetDatum(tok2),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1)));
ereport(LOG,
{
bool stopsHere;
uint8 record_info;
- TimestampTz recordXtime;
+ TimestampTz recordXtime;
/* We only consider stopping at COMMIT or ABORT records */
if (record->xl_rmid != RM_XACT_ID)
(errmsg("database system was interrupted while in recovery at log time %s",
str_time(ControlFile->checkPointCopy.time)),
errhint("If this has occurred more than once some data might be corrupted"
- " and you might need to choose an earlier recovery target.")));
+ " and you might need to choose an earlier recovery target.")));
else if (ControlFile->state == DB_IN_PRODUCTION)
ereport(LOG,
- (errmsg("database system was interrupted; last known up at %s",
- str_time(ControlFile->time))));
+ (errmsg("database system was interrupted; last known up at %s",
+ str_time(ControlFile->time))));
/* This is just to allow attaching to startup process with a debugger */
#ifdef XLOG_REPLAY_DELAY
wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);
ereport(DEBUG1,
- (errmsg("redo record is at %X/%X; shutdown %s",
- checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
- wasShutdown ? "TRUE" : "FALSE")));
+ (errmsg("redo record is at %X/%X; shutdown %s",
+ checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
+ wasShutdown ? "TRUE" : "FALSE")));
ereport(DEBUG1,
(errmsg("next transaction ID: %u/%u; next OID: %u",
checkPoint.nextXidEpoch, checkPoint.nextXid,
{
if (wasShutdown)
ereport(PANIC,
- (errmsg("invalid redo record in shutdown checkpoint")));
+ (errmsg("invalid redo record in shutdown checkpoint")));
InRecovery = true;
}
else if (ControlFile->state != DB_SHUTDOWNED)
*/
if (recoveryStopsHere(record, &recoveryApply))
{
- reachedStopPoint = true; /* see below */
+ reachedStopPoint = true; /* see below */
recoveryContinue = false;
if (!recoveryApply)
break;
ReadRecPtr.xlogid, ReadRecPtr.xrecoff)));
if (recoveryLastXTime)
ereport(LOG,
- (errmsg("last completed transaction was at log time %s",
- timestamptz_to_str(recoveryLastXTime))));
+ (errmsg("last completed transaction was at log time %s",
+ timestamptz_to_str(recoveryLastXTime))));
InRedo = false;
}
else
if (reachedStopPoint) /* stopped because of stop request */
ereport(FATAL,
(errmsg("requested recovery stop point is before end time of backup dump")));
- else /* ran off end of WAL */
+ else /* ran off end of WAL */
ereport(FATAL,
(errmsg("WAL ends before end time of backup dump")));
}
/*
* Consider whether we need to assign a new timeline ID.
*
- * If we are doing an archive recovery, we always assign a new ID. This
- * handles a couple of issues. If we stopped short of the end of WAL
+ * If we are doing an archive recovery, we always assign a new ID. This
+ * handles a couple of issues. If we stopped short of the end of WAL
* during recovery, then we are clearly generating a new timeline and must
* assign it a unique new ID. Even if we ran to the end, modifying the
- * current last segment is problematic because it may result in trying
- * to overwrite an already-archived copy of that segment, and we encourage
+ * current last segment is problematic because it may result in trying to
+ * overwrite an already-archived copy of that segment, and we encourage
* DBAs to make their archive_commands reject that. We can dodge the
* problem by making the new active segment have a new timeline ID.
*
{
/* use volatile pointer to prevent code rearrangement */
volatile XLogCtlData *xlogctl = XLogCtl;
- XLogRecPtr recptr;
+ XLogRecPtr recptr;
SpinLockAcquire(&xlogctl->info_lck);
recptr = xlogctl->LogwrtRqst.Write;
static void
LogCheckpointEnd(void)
{
- long write_secs, sync_secs, total_secs;
- int write_usecs, sync_usecs, total_usecs;
+ long write_secs,
+ sync_secs,
+ total_secs;
+ int write_usecs,
+ sync_usecs,
+ total_usecs;
CheckpointStats.ckpt_end_t = GetCurrentTimestamp();
CheckpointStats.ckpt_segs_added,
CheckpointStats.ckpt_segs_removed,
CheckpointStats.ckpt_segs_recycled,
- write_secs, write_usecs/1000,
- sync_secs, sync_usecs/1000,
- total_secs, total_usecs/1000);
+ write_secs, write_usecs / 1000,
+ sync_secs, sync_usecs / 1000,
+ total_secs, total_usecs / 1000);
}
/*
}
/*
- * Let smgr prepare for checkpoint; this has to happen before we
- * determine the REDO pointer. Note that smgr must not do anything
- * that'd have to be undone if we decide no checkpoint is needed.
+ * Let smgr prepare for checkpoint; this has to happen before we determine
+ * the REDO pointer. Note that smgr must not do anything that'd have to
+ * be undone if we decide no checkpoint is needed.
*/
smgrpreckpt();
LWLockRelease(WALInsertLock);
/*
- * If enabled, log checkpoint start. We postpone this until now
- * so as not to log anything if we decided to skip the checkpoint.
+ * If enabled, log checkpoint start. We postpone this until now so as not
+ * to log anything if we decided to skip the checkpoint.
*/
if (log_checkpoints)
LogCheckpointStart(flags);
* checkpoint take a bit longer than to hold locks longer than necessary.
* (In fact, the whole reason we have this issue is that xact.c does
* commit record XLOG insertion and clog update as two separate steps
- * protected by different locks, but again that seems best on grounds
- * of minimizing lock contention.)
+ * protected by different locks, but again that seems best on grounds of
+ * minimizing lock contention.)
*
- * A transaction that has not yet set inCommit when we look cannot be
- * at risk, since he's not inserted his commit record yet; and one that's
+ * A transaction that has not yet set inCommit when we look cannot be at
+ * risk, since he's not inserted his commit record yet; and one that's
* already cleared it is not at risk either, since he's done fixing clog
* and we will correctly flush the update below. So we cannot miss any
* xacts we need to wait for.
nInCommit = GetTransactionsInCommit(&inCommitXids);
if (nInCommit > 0)
{
- do {
- pg_usleep(10000L); /* wait for 10 msec */
+ do
+ {
+ pg_usleep(10000L); /* wait for 10 msec */
} while (HaveTransactionsInCommit(inCommitXids, nInCommit));
}
pfree(inCommitXids);
CheckPointCLOG();
CheckPointSUBTRANS();
CheckPointMultiXact();
- CheckPointBuffers(flags); /* performs all required fsyncs */
+ CheckPointBuffers(flags); /* performs all required fsyncs */
/* We deliberately delay 2PC checkpointing as long as possible */
CheckPointTwoPhase(checkPointRedo);
}
* does.
*
* Note, however, that the above statement only covers state "within" the
- * database. When we use a generated OID as a file or directory name,
- * we are in a sense violating the basic WAL rule, because that filesystem
+ * database. When we use a generated OID as a file or directory name, we
+ * are in a sense violating the basic WAL rule, because that filesystem
* change may reach disk before the NEXTOID WAL record does. The impact
- * of this is that if a database crash occurs immediately afterward,
- * we might after restart re-generate the same OID and find that it
- * conflicts with the leftover file or directory. But since for safety's
- * sake we always loop until finding a nonconflicting filename, this poses
- * no real problem in practice. See pgsql-hackers discussion 27-Sep-2006.
+ * of this is that if a database crash occurs immediately afterward, we
+ * might after restart re-generate the same OID and find that it conflicts
+ * with the leftover file or directory. But since for safety's sake we
+ * always loop until finding a nonconflicting filename, this poses no real
+ * problem in practice. See pgsql-hackers discussion 27-Sep-2006.
*/
}
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("must be superuser to switch transaction log files"))));
+ (errmsg("must be superuser to switch transaction log files"))));
switchpoint = RequestXLogSwitch();
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.236 2007/08/02 23:39:44 adunstan Exp $
+ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.237 2007/11/15 21:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
char *progname = argv[0];
int flag;
- AuxProcType auxType = CheckerProcess;
+ AuxProcType auxType = CheckerProcess;
char *userDoption = NULL;
/*
InitXLOGAccess();
WalWriterMain();
proc_exit(1); /* should never return */
-
+
default:
elog(PANIC, "unrecognized process type: %d", auxType);
proc_exit(1);
}
/*
- * Begin shutdown of an auxiliary process. This is approximately the equivalent
+ * Begin shutdown of an auxiliary process. This is approximately the equivalent
* of ShutdownPostgres() in postinit.c. We can't run transactions in an
* auxiliary process, so most of the work of AbortTransaction() is not needed,
* but we do need to make sure we've released any LWLocks we are holding.
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.141 2007/10/12 18:55:11 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.142 2007/11/15 21:14:32 momjian Exp $
*
* NOTES
* See acl.h.
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("text search configuration with OID %u does not exist",
- cfg_oid)));
+ errmsg("text search configuration with OID %u does not exist",
+ cfg_oid)));
ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.67 2007/08/21 01:11:13 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.68 2007/11/15 21:14:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* See also getObjectClass().
*/
static const Oid object_classes[MAX_OCLASS] = {
- RelationRelationId, /* OCLASS_CLASS */
- ProcedureRelationId, /* OCLASS_PROC */
- TypeRelationId, /* OCLASS_TYPE */
- CastRelationId, /* OCLASS_CAST */
- ConstraintRelationId, /* OCLASS_CONSTRAINT */
- ConversionRelationId, /* OCLASS_CONVERSION */
- AttrDefaultRelationId, /* OCLASS_DEFAULT */
- LanguageRelationId, /* OCLASS_LANGUAGE */
- OperatorRelationId, /* OCLASS_OPERATOR */
- OperatorClassRelationId, /* OCLASS_OPCLASS */
- OperatorFamilyRelationId, /* OCLASS_OPFAMILY */
+ RelationRelationId, /* OCLASS_CLASS */
+ ProcedureRelationId, /* OCLASS_PROC */
+ TypeRelationId, /* OCLASS_TYPE */
+ CastRelationId, /* OCLASS_CAST */
+ ConstraintRelationId, /* OCLASS_CONSTRAINT */
+ ConversionRelationId, /* OCLASS_CONVERSION */
+ AttrDefaultRelationId, /* OCLASS_DEFAULT */
+ LanguageRelationId, /* OCLASS_LANGUAGE */
+ OperatorRelationId, /* OCLASS_OPERATOR */
+ OperatorClassRelationId, /* OCLASS_OPCLASS */
+ OperatorFamilyRelationId, /* OCLASS_OPFAMILY */
AccessMethodOperatorRelationId, /* OCLASS_AMOP */
AccessMethodProcedureRelationId, /* OCLASS_AMPROC */
- RewriteRelationId, /* OCLASS_REWRITE */
- TriggerRelationId, /* OCLASS_TRIGGER */
- NamespaceRelationId, /* OCLASS_SCHEMA */
- TSParserRelationId, /* OCLASS_TSPARSER */
- TSDictionaryRelationId, /* OCLASS_TSDICT */
- TSTemplateRelationId, /* OCLASS_TSTEMPLATE */
- TSConfigRelationId, /* OCLASS_TSCONFIG */
- AuthIdRelationId, /* OCLASS_ROLE */
- DatabaseRelationId, /* OCLASS_DATABASE */
- TableSpaceRelationId /* OCLASS_TBLSPACE */
+ RewriteRelationId, /* OCLASS_REWRITE */
+ TriggerRelationId, /* OCLASS_TRIGGER */
+ NamespaceRelationId, /* OCLASS_SCHEMA */
+ TSParserRelationId, /* OCLASS_TSPARSER */
+ TSDictionaryRelationId, /* OCLASS_TSDICT */
+ TSTemplateRelationId, /* OCLASS_TSTEMPLATE */
+ TSConfigRelationId, /* OCLASS_TSCONFIG */
+ AuthIdRelationId, /* OCLASS_ROLE */
+ DatabaseRelationId, /* OCLASS_DATABASE */
+ TableSpaceRelationId /* OCLASS_TBLSPACE */
};
RemoveTSConfigurationById(object->objectId);
break;
- /* OCLASS_ROLE, OCLASS_DATABASE, OCLASS_TBLSPACE not handled */
+ /* OCLASS_ROLE, OCLASS_DATABASE, OCLASS_TBLSPACE not handled */
default:
elog(ERROR, "unrecognized object class: %u",
elog(ERROR, "cache lookup failed for text search parser %u",
object->objectId);
appendStringInfo(&buffer, _("text search parser %s"),
- NameStr(((Form_pg_ts_parser) GETSTRUCT(tup))->prsname));
+ NameStr(((Form_pg_ts_parser) GETSTRUCT(tup))->prsname));
ReleaseSysCache(tup);
break;
}
elog(ERROR, "cache lookup failed for text search dictionary %u",
object->objectId);
appendStringInfo(&buffer, _("text search dictionary %s"),
- NameStr(((Form_pg_ts_dict) GETSTRUCT(tup))->dictname));
+ NameStr(((Form_pg_ts_dict) GETSTRUCT(tup))->dictname));
ReleaseSysCache(tup);
break;
}
elog(ERROR, "cache lookup failed for text search template %u",
object->objectId);
appendStringInfo(&buffer, _("text search template %s"),
- NameStr(((Form_pg_ts_template) GETSTRUCT(tup))->tmplname));
+ NameStr(((Form_pg_ts_template) GETSTRUCT(tup))->tmplname));
ReleaseSysCache(tup);
break;
}
elog(ERROR, "cache lookup failed for text search configuration %u",
object->objectId);
appendStringInfo(&buffer, _("text search configuration %s"),
- NameStr(((Form_pg_ts_config) GETSTRUCT(tup))->cfgname));
+ NameStr(((Form_pg_ts_config) GETSTRUCT(tup))->cfgname));
ReleaseSysCache(tup);
break;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.325 2007/10/29 19:40:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.326 2007/11/15 21:14:33 momjian Exp $
*
*
* INTERFACE ROUTINES
{
/*
* Warn user, but don't fail, if column to be created has UNKNOWN type
- * (usually as a result of a 'retrieve into' - jolly)
+ * (usually as a result of a 'retrieve into' - jolly)
*/
ereport(WARNING,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
else if (att_typtype == TYPTYPE_PSEUDO)
{
/*
- * Refuse any attempt to create a pseudo-type column, except for
- * a special hack for pg_statistic: allow ANYARRAY during initdb
+ * Refuse any attempt to create a pseudo-type column, except for a
+ * special hack for pg_statistic: allow ANYARRAY during initdb
*/
if (atttypid != ANYARRAYOID || IsUnderPostmaster)
ereport(ERROR,
else if (att_typtype == TYPTYPE_COMPOSITE)
{
/*
- * For a composite type, recurse into its attributes. You might
- * think this isn't necessary, but since we allow system catalogs
- * to break the rule, we have to guard against the case.
+ * For a composite type, recurse into its attributes. You might think
+ * this isn't necessary, but since we allow system catalogs to break
+ * the rule, we have to guard against the case.
*/
- Relation relation;
- TupleDesc tupdesc;
- int i;
+ Relation relation;
+ TupleDesc tupdesc;
+ int i;
relation = relation_open(get_typ_typrelid(atttypid), AccessShareLock);
{
/*
* Initialize to the minimum XID that could put tuples in the table.
- * We know that no xacts older than RecentXmin are still running,
- * so that will do.
+ * We know that no xacts older than RecentXmin are still running, so
+ * that will do.
*/
new_rel_reltup->relfrozenxid = RecentXmin;
}
else
{
/*
- * Other relation types will not contain XIDs, so set relfrozenxid
- * to InvalidTransactionId. (Note: a sequence does contain a tuple,
- * but we force its xmin to be FrozenTransactionId always; see
+ * Other relation types will not contain XIDs, so set relfrozenxid to
+ * InvalidTransactionId. (Note: a sequence does contain a tuple, but
+ * we force its xmin to be FrozenTransactionId always; see
* commands/sequence.c.)
*/
new_rel_reltup->relfrozenxid = InvalidTransactionId;
&nb